Skip to content

Commit 8f27ac1

Browse files
committed
Removing Unwanted Code
1 parent cc96f4d commit 8f27ac1

14 files changed

+40
-83
lines changed

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystemStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@ public String listStatus(final Path path, final String startFrom,
12791279
try (AbfsPerfInfo perfInfo = startTracking("listStatus", "listPath")) {
12801280
ListResponseData listResponseData = listingClient.listPath(relativePath,
12811281
false, abfsConfiguration.getListMaxResults(), continuation,
1282-
tracingContext, this.uri, false);
1282+
tracingContext, this.uri);
12831283
AbfsRestOperation op = listResponseData.getOp();
12841284
perfInfo.registerResult(op.getResult());
12851285
continuation = listResponseData.getContinuationToken();

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsBlobClient.java

Lines changed: 8 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ public AbfsRestOperation deleteFilesystem(TracingContext tracingContext)
350350
*/
351351
@Override
352352
public ListResponseData listPath(final String relativePath, final boolean recursive,
353-
final int listMaxResults, final String continuation, TracingContext tracingContext, URI uri, boolean is404CheckRequired)
353+
final int listMaxResults, final String continuation, TracingContext tracingContext, URI uri)
354354
throws AzureBlobFileSystemException {
355355

356356
final List<AbfsHttpHeader> requestHeaders = createDefaultHeaders();
@@ -398,34 +398,6 @@ public ListResponseData listPath(final String relativePath, final boolean recurs
398398
listResponseData.setOp(retryListOp);
399399
}
400400
}
401-
402-
if (is404CheckRequired && isEmptyListResults(listResponseData)) {
403-
// If the list operation returns no paths, we need to check if the path is a file.
404-
// If it is a file, we need to return the file in the list.
405-
// If it is a non-existing path, we need to throw a FileNotFoundException.
406-
if (relativePath.equals(ROOT_PATH)) {
407-
// Root Always exists as directory. It can be an empty listing.
408-
return listResponseData;
409-
}
410-
AbfsRestOperation pathStatus = this.getPathStatus(relativePath, tracingContext, null, false);
411-
BlobListResultSchema listResultSchema = getListResultSchemaFromPathStatus(relativePath, pathStatus);
412-
LOG.debug("ListBlob attempted on a file path. Returning file status.");
413-
List<VersionedFileStatus> fileStatusList = new ArrayList<>();
414-
for (BlobListResultEntrySchema entry : listResultSchema.paths()) {
415-
fileStatusList.add(getVersionedFileStatusFromEntry(entry, uri));
416-
}
417-
AbfsRestOperation listOp = getAbfsRestOperation(
418-
AbfsRestOperationType.ListBlobs,
419-
HTTP_METHOD_GET,
420-
url,
421-
requestHeaders);
422-
listOp.hardSetGetListStatusResult(HTTP_OK, listResultSchema);
423-
listResponseData.setFileStatusList(fileStatusList);
424-
listResponseData.setContinuationToken(null);
425-
listResponseData.setRenamePendingJsonPaths(null);
426-
listResponseData.setOp(listOp);
427-
return listResponseData;
428-
}
429401
return listResponseData;
430402
}
431403

@@ -434,11 +406,11 @@ public ListResponseData listPath(final String relativePath, final boolean recurs
434406
public List<FileStatus> postListProcessing(String relativePath, List<FileStatus> fileStatuses,
435407
TracingContext tracingContext, URI uri) throws AzureBlobFileSystemException {
436408
List<FileStatus> rectifiedFileStatuses = new ArrayList<>();
437-
if (fileStatuses.isEmpty() && !relativePath.equals(ROOT_PATH)) {
409+
if (fileStatuses.isEmpty() && !ROOT_PATH.equals(relativePath)) {
438410
// If the list operation returns no paths, we need to check if the path is a file.
439411
// If it is a file, we need to return the file in the list.
412+
// If it is a directory or root path, we need to return an empty list.
440413
// If it is a non-existing path, we need to throw a FileNotFoundException.
441-
// Root Always exists as directory. It can be an empty listing.
442414
AbfsRestOperation pathStatus = this.getPathStatus(relativePath, tracingContext, null, false);
443415
BlobListResultSchema listResultSchema = getListResultSchemaFromPathStatus(relativePath, pathStatus);
444416
LOG.debug("ListStatus attempted on a file path. Returning file status.");
@@ -2036,6 +2008,8 @@ private static String decodeMetadataAttribute(String encoded)
20362008

20372009
/**
20382010
* Checks if the listing of the specified path is non-empty.
2011+
* Since listing is incomplete as long as continuation token is returned by server,
2012+
* we need to iterate until either we get one entry o continuation token becomes null.
20392013
*
20402014
* @param path The path to be listed.
20412015
* @param tracingContext The tracing context for tracking the operation.
@@ -2049,32 +2023,15 @@ public boolean isNonEmptyDirectory(String path,
20492023
// and hence don't need identity transformation to happen.
20502024
String continuationToken = null;
20512025
List<FileStatus> fileStatusList = new ArrayList<>();
2026+
// We need to loop on continuation token until we get an entry or continuation token becomes null.
20522027
do {
2053-
ListResponseData listResponseData = listPath(path, false, 1, null, tracingContext, null, false);
2028+
ListResponseData listResponseData = listPath(path, false, 1, null, tracingContext, null);
20542029
fileStatusList.addAll(listResponseData.getFileStatusList());
20552030
continuationToken = listResponseData.getContinuationToken();
2056-
} while (StringUtils.isNotEmpty(continuationToken));
2031+
} while (StringUtils.isNotEmpty(continuationToken) && fileStatusList.isEmpty());
20572032
return !fileStatusList.isEmpty();
20582033
}
20592034

2060-
/**
2061-
* Check if the list call returned empty results without any continuation token.
2062-
* @param listResponseData The response of listing API from the server.
2063-
* @return True if empty results without continuation token.
2064-
*/
2065-
private boolean isEmptyListResults(ListResponseData listResponseData) {
2066-
AbfsHttpOperation result = listResponseData.getOp().getResult();
2067-
boolean isEmptyList = result != null && result.getStatusCode() == HTTP_OK && // List Call was successful
2068-
result.getListResultSchema() != null && // Parsing of list response was successful
2069-
listResponseData.getFileStatusList().isEmpty() && listResponseData.getRenamePendingJsonPaths().isEmpty() &&// No paths were returned
2070-
StringUtils.isEmpty(listResponseData.getContinuationToken()); // No continuation token was returned
2071-
if (isEmptyList) {
2072-
LOG.debug("List call returned empty results without any continuation token.");
2073-
return true;
2074-
}
2075-
return false;
2076-
}
2077-
20782035
/**
20792036
* Generate the XML block list using a comma-separated string of block IDs.
20802037
*

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ public abstract AbfsRestOperation setFilesystemProperties(Hashtable<String, Stri
523523
* @throws AzureBlobFileSystemException if rest operation or response parsing fails.
524524
*/
525525
public abstract ListResponseData listPath(String relativePath, boolean recursive,
526-
int listMaxResults, String continuation, TracingContext tracingContext, URI uri, boolean is404CheckRequired) throws IOException;
526+
int listMaxResults, String continuation, TracingContext tracingContext, URI uri) throws IOException;
527527

528528
public abstract List<FileStatus> postListProcessing(String relativePath,
529529
List<FileStatus> fileStatuses, TracingContext tracingContext, URI uri) throws AzureBlobFileSystemException;

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsDfsClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ public ListResponseData listPath(final String relativePath,
323323
final boolean recursive,
324324
final int listMaxResults,
325325
final String continuation,
326-
TracingContext tracingContext, URI uri, boolean is404CheckRequired) throws IOException {
326+
TracingContext tracingContext, URI uri) throws IOException {
327327
final List<AbfsHttpHeader> requestHeaders = createDefaultHeaders();
328328

329329
final AbfsUriQueryBuilder abfsUriQueryBuilder = createDefaultUriQueryBuilder();

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/ListActionTaker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ protected String listAndEnqueue(final ListBlobQueue listBlobQueue,
239239
op = getAbfsClient().listPath(path.toUri().getPath(),
240240
true,
241241
queueAvailableSizeForProduction, continuationToken,
242-
tracingContext, null, false).getOp();
242+
tracingContext, null).getOp();
243243
} catch (AzureBlobFileSystemException ex) {
244244
throw ex;
245245
} catch (IOException ex) {

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAbfsClient.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void testContinuationTokenHavingEqualSign() throws Exception {
6565
try {
6666
AbfsRestOperation op = abfsClient
6767
.listPath("/", true, LIST_MAX_RESULTS, "===========",
68-
getTestTracingContext(fs, true), null, false).getOp();
68+
getTestTracingContext(fs, true), null).getOp();
6969
Assert.assertTrue(false);
7070
} catch (AbfsRestOperationException ex) {
7171
Assert.assertEquals("InvalidQueryParameterValue", ex.getErrorCode().getErrorCode());
@@ -106,7 +106,7 @@ public void testListPathWithValidListMaxResultsValues()
106106

107107
AbfsRestOperation op = getFileSystem().getAbfsClient().listPath(
108108
directory.toString(), false, getListMaxResults(), null,
109-
getTestTracingContext(getFileSystem(), true), null, false).getOp();
109+
getTestTracingContext(getFileSystem(), true), null).getOp();
110110

111111
List<? extends ListResultEntrySchema> list = op.getResult().getListResultSchema().paths();
112112
String continuationToken = op.getResult().getResponseHeader(HttpHeaderConfigurations.X_MS_CONTINUATION);
@@ -141,7 +141,7 @@ public void testListPathWithValueGreaterThanServerMaximum()
141141

142142
AbfsRestOperation op = getFileSystem().getAbfsClient().listPath(
143143
directory.toString(), false, getListMaxResults(), null,
144-
getTestTracingContext(getFileSystem(), true), null, false).getOp();
144+
getTestTracingContext(getFileSystem(), true), null).getOp();
145145

146146
List<? extends ListResultEntrySchema> list = op.getResult().getListResultSchema().paths();
147147
String continuationToken = op.getResult().getResponseHeader(HttpHeaderConfigurations.X_MS_CONTINUATION);
@@ -179,7 +179,7 @@ private List<? extends ListResultEntrySchema> listPath(String directory)
179179
throws IOException {
180180
return getFileSystem().getAbfsClient()
181181
.listPath(directory, false, getListMaxResults(), null,
182-
getTestTracingContext(getFileSystem(), true), null, false).getOp().getResult()
182+
getTestTracingContext(getFileSystem(), true), null).getOp().getResult()
183183
.getListResultSchema().paths();
184184
}
185185

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAbfsCustomEncryption.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ true, new BlobAppendRequestParameters(BLOCK_ID, null)),
344344
getTestTracingContext(fs, false));
345345
case LISTSTATUS:
346346
return client.listPath(path, false, 5, null,
347-
getTestTracingContext(fs, true), null, false).getOp();
347+
getTestTracingContext(fs, true), null).getOp();
348348
case RENAME:
349349
TracingContext tc = getTestTracingContext(fs, true);
350350
return client.renamePath(path, new Path(path + "_2").toString(),

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemDelegationSAS.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ public void testListAndDeleteImplicitPaths() throws Exception {
458458

459459
AbfsRestOperation op = client.listPath(
460460
implicitDir.toString(), false, 2, null,
461-
getTestTracingContext(getFileSystem(), false), null, false).getOp();
461+
getTestTracingContext(getFileSystem(), false), null).getOp();
462462
List<? extends ListResultEntrySchema> list = op.getResult()
463463
.getListResultSchema()
464464
.paths();

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemDelete.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,11 @@ public void testDeleteIdempotencyTriggerHttp404() throws Exception {
313313
doCallRealMethod().when(mockClient)
314314
.listPath(Mockito.nullable(String.class), Mockito.anyBoolean(),
315315
Mockito.anyInt(), Mockito.nullable(String.class),
316-
Mockito.nullable(TracingContext.class), Mockito.nullable(URI.class), eq(false));
316+
Mockito.nullable(TracingContext.class), Mockito.nullable(URI.class));
317317
doCallRealMethod().when((AbfsBlobClient) mockClient)
318318
.listPath(Mockito.nullable(String.class), Mockito.anyBoolean(),
319319
Mockito.anyInt(), Mockito.nullable(String.class),
320-
Mockito.nullable(TracingContext.class), Mockito.nullable(URI.class), Mockito.anyBoolean());
320+
Mockito.nullable(TracingContext.class), Mockito.nullable(URI.class));
321321
doCallRealMethod().when((AbfsBlobClient) mockClient)
322322
.getPathStatus(Mockito.nullable(String.class), Mockito.nullable(TracingContext.class),
323323
Mockito.nullable(ContextEncryptionAdapter.class), Mockito.anyBoolean());
@@ -532,12 +532,12 @@ public void testDeleteImplicitDirWithSingleListResults() throws Exception {
532532
boolean recursive = answer.getArgument(1);
533533
String continuation = answer.getArgument(3);
534534
TracingContext context = answer.getArgument(4);
535-
return client.listPath(path, recursive, 1, continuation, context, null, false);
535+
return client.listPath(path, recursive, 1, continuation, context, null);
536536
})
537537
.when(spiedClient)
538538
.listPath(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyInt(),
539539
Mockito.nullable(String.class),
540-
Mockito.any(TracingContext.class), Mockito.nullable(URI.class), eq(false));
540+
Mockito.any(TracingContext.class), Mockito.nullable(URI.class));
541541
client.deleteBlobPath(new Path("/testDir/dir1"),
542542
null, getTestTracingContext(fs, true));
543543
fs.delete(new Path("/testDir/dir1"), true);
@@ -684,14 +684,14 @@ public void testProducerStopOnDeleteFailure() throws Exception {
684684
})
685685
.when(spiedClient)
686686
.listPath(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyInt(),
687-
Mockito.nullable(String.class), Mockito.any(TracingContext.class), Mockito.nullable(URI.class), eq(false));
687+
Mockito.nullable(String.class), Mockito.any(TracingContext.class), Mockito.nullable(URI.class));
688688
intercept(AccessDeniedException.class,
689689
() -> {
690690
fs.delete(new Path("/src"), true);
691691
});
692692
Mockito.verify(spiedClient, Mockito.times(1))
693693
.listPath(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyInt(),
694-
Mockito.nullable(String.class), Mockito.any(TracingContext.class), Mockito.nullable(URI.class), eq(false));
694+
Mockito.nullable(String.class), Mockito.any(TracingContext.class), Mockito.nullable(URI.class));
695695
}
696696

697697
/**

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemFileStatus.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public void testListStatusIsCalledForImplicitPathOnBlobEndpoint() throws Excepti
259259
fs.getFileStatus(implicitPath);
260260

261261
Mockito.verify(abfsClient, Mockito.times(1)).getPathStatus(any(), eq(false), any(), any());
262-
Mockito.verify(abfsClient, Mockito.times(1)).listPath(any(), eq(false), eq(1), any(), any(), any(), eq(false));
262+
Mockito.verify(abfsClient, Mockito.times(1)).listPath(any(), eq(false), eq(1), any(), any(), any());
263263
}
264264

265265
/**

0 commit comments

Comments
 (0)