Skip to content

Commit

Permalink
Revert "HADOOP-17873. ABFS: Fix transient failures in ITestAbfsStream…
Browse files Browse the repository at this point in the history
…Statistics and ITestAbfsRestOperationException (#3341)"

This reverts commit 0379aeb.
  • Loading branch information
steveloughran committed Nov 5, 2021
1 parent 689dd7b commit 7b632dd
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 51 deletions.
2 changes: 0 additions & 2 deletions hadoop-tools/hadoop-azure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,6 @@
<exclude>**/azurebfs/ITestAzureBlobFileSystemListStatus.java</exclude>
<exclude>**/azurebfs/extensions/ITestAbfsDelegationTokens.java</exclude>
<exclude>**/azurebfs/ITestSmallWriteOptimization.java</exclude>
<exclude>**/azurebfs/ITestAbfsStreamStatistics*.java</exclude>
<exclude>**/azurebfs/services/ITestReadBufferManager.java</exclude>
</excludes>

Expand Down Expand Up @@ -598,7 +597,6 @@
<include>**/azurebfs/extensions/ITestAbfsDelegationTokens.java</include>
<include>**/azurebfs/ITestSmallWriteOptimization.java</include>
<include>**/azurebfs/services/ITestReadBufferManager.java</include>
<include>**/azurebfs/ITestAbfsStreamStatistics*.java</include>
</includes>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.io.IOException;
import java.net.URI;

import org.apache.hadoop.thirdparty.com.google.common.annotations.VisibleForTesting;
import org.apache.hadoop.thirdparty.com.google.common.base.Preconditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -139,9 +138,4 @@ public String getUserAgentSuffix() {
String suffix = ExtensionHelper.getUserAgentSuffix(adaptee, "");
return suffix != null ? suffix : "";
}

@VisibleForTesting
protected CustomTokenProviderAdaptee getCustomTokenProviderAdaptee() {
return adaptee;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1223,9 +1223,4 @@ public ListenableFuture<?> submit(Runnable runnable) {
public <V> void addCallback(ListenableFuture<V> future, FutureCallback<V> callback) {
Futures.addCallback(future, callback, executorService);
}

@VisibleForTesting
protected AccessTokenProvider getTokenProvider() {
return tokenProvider;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.azurebfs.constants.FSOperationType;
import org.apache.hadoop.fs.azurebfs.contracts.exceptions.AzureBlobFileSystemException;
import org.apache.hadoop.fs.azurebfs.oauth2.AccessTokenProvider;
import org.apache.hadoop.fs.azurebfs.security.AbfsDelegationTokenManager;
import org.apache.hadoop.fs.azurebfs.services.AbfsOutputStream;
import org.apache.hadoop.fs.azurebfs.services.AuthType;
import org.apache.hadoop.fs.azurebfs.services.TestAbfsClient;
import org.apache.hadoop.fs.azure.AzureNativeFileSystemStore;
import org.apache.hadoop.fs.azure.NativeAzureFileSystem;
import org.apache.hadoop.fs.azure.metrics.AzureFileSystemInstrumentation;
Expand Down Expand Up @@ -241,9 +239,6 @@ public Hashtable<String, String> call() throws Exception {
}
}

public AccessTokenProvider getAccessTokenProvider(final AzureBlobFileSystem fs) {
return TestAbfsClient.getAccessTokenProvider(fs.getAbfsStore().getClient());
}

public void loadConfiguredFileSystem() throws Exception {
// disable auto-creation of filesystem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,18 @@ public void testWithDifferentCustomTokenFetchRetry(int numOfRetries) throws Exce
final AzureBlobFileSystem fs1 =
(AzureBlobFileSystem) FileSystem.newInstance(fs.getUri(),
config);
RetryTestTokenProvider retryTestTokenProvider
= RetryTestTokenProvider.getCurrentRetryTestProviderInstance(
getAccessTokenProvider(fs1));
retryTestTokenProvider.resetStatusToFirstTokenFetch();
RetryTestTokenProvider.ResetStatusToFirstTokenFetch();

intercept(Exception.class,
()-> {
fs1.getFileStatus(new Path("/"));
});

// Number of retries done should be as configured
Assert.assertEquals(
"Number of token fetch retries done does not match with fs.azure"
+ ".custom.token.fetch.retry.count configured", numOfRetries,
retryTestTokenProvider.getRetryCount());
Assert.assertTrue(
"Number of token fetch retries (" + RetryTestTokenProvider.reTryCount
+ ") done, does not match with fs.azure.custom.token.fetch.retry.count configured (" + numOfRetries
+ ")", RetryTestTokenProvider.reTryCount == numOfRetries);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,30 @@
*/
public class RetryTestTokenProvider implements CustomTokenProviderAdaptee {

private static final Logger LOG = LoggerFactory.getLogger(
RetryTestTokenProvider.class);

// Need to track first token fetch otherwise will get counted as a retry too.
private boolean isThisFirstTokenFetch = true;
private int retryCount = 0;
private static boolean isThisFirstTokenFetch = true;
public static int reTryCount = 0;

private static final Logger LOG = LoggerFactory
.getLogger(RetryTestTokenProvider.class);

@Override
public void initialize(Configuration configuration, String accountName)
throws IOException {

}

/**
* Clear earlier retry details and reset RetryTestTokenProvider instance to
* state of first access token fetch call.
*/
public void resetStatusToFirstTokenFetch() {
public static void ResetStatusToFirstTokenFetch() {
isThisFirstTokenFetch = true;
retryCount = 0;
reTryCount = 0;
}

@Override
public String getAccessToken() throws IOException {
if (isThisFirstTokenFetch) {
isThisFirstTokenFetch = false;
} else {
retryCount++;
reTryCount++;
}

LOG.debug("RetryTestTokenProvider: Throw an exception in fetching tokens");
Expand All @@ -68,13 +64,4 @@ public String getAccessToken() throws IOException {
public Date getExpiryTime() {
return new Date();
}

public static RetryTestTokenProvider getCurrentRetryTestProviderInstance(
AccessTokenProvider customTokenProvider) {
return (RetryTestTokenProvider) ((CustomTokenProviderAdapter) customTokenProvider).getCustomTokenProviderAdaptee();
}

public int getRetryCount() {
return retryCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,4 @@ public static AbfsRestOperation getRestOp(AbfsRestOperationType type,
url,
requestHeaders);
}

public static AccessTokenProvider getAccessTokenProvider(AbfsClient client) {
return client.getTokenProvider();
}
}

0 comments on commit 7b632dd

Please sign in to comment.