Skip to content

Commit 0bfe007

Browse files
committed
Rename Testcase for Blob endpoint
1 parent c5fdc3b commit 0bfe007

File tree

9 files changed

+897
-10
lines changed

9 files changed

+897
-10
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ public class AbfsConfiguration{
415415
private int producerQueueMaxSize;
416416

417417
@IntegerConfigurationValidatorAnnotation(ConfigurationKey =
418-
FS_AZURE_CONSUMER_MAX_LAG, DefaultValue = DEFAULT_FS_AZURE_CONSUMER_MAX_LAG)
418+
FS_AZURE_CONSUMER_MAX_LAG, DefaultValue = DEFAULT_FS_AZURE_CONSUMER_MAX_LAG)
419419
private int listingMaxConsumptionLag;
420420

421421
@IntegerConfigurationValidatorAnnotation(ConfigurationKey =

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import static org.apache.hadoop.fs.azurebfs.AbfsStatistic.DIRECTORIES_CREATED;
5555
import static org.apache.hadoop.fs.azurebfs.AbfsStatistic.DIRECTORIES_DELETED;
5656
import static org.apache.hadoop.fs.azurebfs.AbfsStatistic.ERROR_IGNORED;
57+
import static org.apache.hadoop.fs.azurebfs.AbfsStatistic.FILES_COPIED;
5758
import static org.apache.hadoop.fs.azurebfs.AbfsStatistic.FILES_CREATED;
5859
import static org.apache.hadoop.fs.azurebfs.AbfsStatistic.FILES_DELETED;
5960
import static org.apache.hadoop.fs.azurebfs.AbfsStatistic.GET_RESPONSES;
@@ -134,7 +135,8 @@ public class AbfsCountersImpl implements AbfsCounters {
134135
SERVER_UNAVAILABLE,
135136
RENAME_RECOVERY,
136137
METADATA_INCOMPLETE_RENAME_FAILURES,
137-
RENAME_PATH_ATTEMPTS
138+
RENAME_PATH_ATTEMPTS,
139+
FILES_COPIED
138140
};
139141

140142
private static final AbfsStatistic[] DURATION_TRACKER_LIST = {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ public enum AbfsStatistic {
109109
"Number of times rename operation failed due to metadata being "
110110
+ "incomplete"),
111111
RENAME_PATH_ATTEMPTS("rename_path_attempts",
112-
"Number of times we attempt to rename a path internally");
112+
"Number of times we attempt to rename a path internally"),
113+
FILES_COPIED("files_copied",
114+
"Total number of files copied from the object store.");
113115

114116
private String statName;
115117
private String statDescription;

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ private void fixAtomicEntriesInListResults(final AbfsRestOperation op,
424424
}
425425
List<BlobListResultEntrySchema> filteredEntries = new ArrayList<>();
426426
for (BlobListResultEntrySchema entry : listResultSchema.paths()) {
427-
if (!takeListPathAtomicRenameKeyAction(entry.path(),
427+
if (!takeListPathAtomicRenameKeyAction(entry.path(), entry.isDirectory(),
428428
entry.contentLength().intValue(), tracingContext)) {
429429
filteredEntries.add(entry);
430430
}
@@ -444,15 +444,14 @@ public void createNonRecursivePreCheck(Path parentPath,
444444
}
445445
getPathStatus(parentPath.toUri().getPath(), false,
446446
tracingContext, null);
447+
incrementAbfsGetPathStatus();
447448
} catch (AbfsRestOperationException ex) {
448449
if (ex.getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) {
449450
throw new FileNotFoundException("Cannot create file "
450451
+ parentPath.toUri().getPath()
451452
+ " because parent folder does not exist.");
452453
}
453454
throw ex;
454-
} finally {
455-
getAbfsCounters().incrementCounter(CALL_GET_FILE_STATUS, 1);
456455
}
457456
}
458457

@@ -510,6 +509,7 @@ protected AbfsRestOperation createMarkerAtPath(final String path,
510509
final String eTag,
511510
final ContextEncryptionAdapter contextEncryptionAdapter,
512511
final TracingContext tracingContext) throws AzureBlobFileSystemException {
512+
incrementAbfsCreateFile();
513513
return createPathRestOp(path, false, false, false, eTag,
514514
contextEncryptionAdapter, tracingContext);
515515
}
@@ -807,7 +807,6 @@ public AbfsClientRenameResult renamePath(final String source,
807807
BlobRenameHandler blobRenameHandler = getBlobRenameHandler(source,
808808
destination, sourceEtag, isAtomicRenameKey(source), tracingContext
809809
);
810-
incrementAbfsRenamePath();
811810
if (blobRenameHandler.execute()) {
812811
final AbfsUriQueryBuilder abfsUriQueryBuilder
813812
= createDefaultUriQueryBuilder();
@@ -1751,6 +1750,7 @@ public void takeGetPathStatusAtomicRenameKeyAction(final Path path,
17511750
pendingJsonFileStatus = getPathStatus(
17521751
pendingJsonPath.toUri().getPath(), tracingContext,
17531752
null, false);
1753+
incrementAbfsGetPathStatus();
17541754
if (checkIsDir(pendingJsonFileStatus.getResult())) {
17551755
return;
17561756
}
@@ -1805,11 +1805,11 @@ public void takeGetPathStatusAtomicRenameKeyAction(final Path path,
18051805
* @throws AzureBlobFileSystemException server error
18061806
*/
18071807
private boolean takeListPathAtomicRenameKeyAction(final Path path,
1808-
final int renamePendingJsonLen,
1808+
final boolean isDirectory, final int renamePendingJsonLen,
18091809
final TracingContext tracingContext)
18101810
throws AzureBlobFileSystemException {
18111811
if (path == null || path.isRoot() || !isAtomicRenameKey(
1812-
path.toUri().getPath()) || !path.toUri()
1812+
path.toUri().getPath()) || isDirectory || !path.toUri()
18131813
.getPath()
18141814
.endsWith(RenameAtomicity.SUFFIX)) {
18151815
return false;
@@ -1837,7 +1837,7 @@ private boolean takeListPathAtomicRenameKeyAction(final Path path,
18371837
}
18381838

18391839
@VisibleForTesting
1840-
RenameAtomicity getRedoRenameAtomicity(final Path renamePendingJsonPath,
1840+
public RenameAtomicity getRedoRenameAtomicity(final Path renamePendingJsonPath,
18411841
int fileLen,
18421842
final TracingContext tracingContext) {
18431843
return new RenameAtomicity(renamePendingJsonPath,

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@
9191
import org.apache.hadoop.util.concurrent.HadoopExecutors;
9292

9393
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
94+
import static org.apache.hadoop.fs.azurebfs.AbfsStatistic.CALL_GET_FILE_STATUS;
95+
import static org.apache.hadoop.fs.azurebfs.AbfsStatistic.DIRECTORIES_CREATED;
96+
import static org.apache.hadoop.fs.azurebfs.AbfsStatistic.DIRECTORIES_DELETED;
97+
import static org.apache.hadoop.fs.azurebfs.AbfsStatistic.FILES_COPIED;
98+
import static org.apache.hadoop.fs.azurebfs.AbfsStatistic.FILES_CREATED;
99+
import static org.apache.hadoop.fs.azurebfs.AbfsStatistic.FILES_DELETED;
94100
import static org.apache.hadoop.fs.azurebfs.AbfsStatistic.RENAME_PATH_ATTEMPTS;
95101
import static org.apache.hadoop.fs.azurebfs.AzureBlobFileSystemStore.extractEtagHeader;
96102
import static org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.APN_VERSION;
@@ -693,6 +699,34 @@ protected void incrementAbfsRenamePath() {
693699
abfsCounters.incrementCounter(RENAME_PATH_ATTEMPTS, 1);
694700
}
695701

702+
/**
703+
* Increments AbfsCounters for get path status by 1.
704+
*/
705+
protected void incrementAbfsGetPathStatus() {
706+
abfsCounters.incrementCounter(CALL_GET_FILE_STATUS, 1);
707+
}
708+
709+
/**
710+
* Increments AbfsCounters for Delete File by 1.
711+
*/
712+
protected void incrementAbfsDeleteFile() {
713+
abfsCounters.incrementCounter(FILES_DELETED, 1);
714+
}
715+
716+
/**
717+
* Increments AbfsCounters for Create File by 1.
718+
*/
719+
protected void incrementAbfsCreateFile() {
720+
abfsCounters.incrementCounter(FILES_CREATED, 1);
721+
}
722+
723+
/**
724+
* Increments AbfsCounters for Copy Files by 1.
725+
*/
726+
protected void incrementAbfsCopyFile() {
727+
abfsCounters.incrementCounter(FILES_COPIED, 1);
728+
}
729+
696730
/**
697731
* Check if the rename request failure is post a retry and if earlier rename
698732
* request might have succeeded at back-end.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ int getMaxConsumptionParallelism() {
9090
private boolean deleteInternal(final Path path)
9191
throws AzureBlobFileSystemException {
9292
getAbfsClient().deleteBlobPath(path, null, tracingContext);
93+
getAbfsClient().incrementAbfsDeleteFile();
9394
deleteCount.incrementAndGet();
9495
return true;
9596
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ int getMaxConsumptionParallelism() {
121121
* @throws AzureBlobFileSystemException if server call fails
122122
*/
123123
public boolean execute() throws AzureBlobFileSystemException {
124+
getAbfsClient().incrementAbfsRenamePath();
124125
PathInformation pathInformation = getPathInformation(src, tracingContext);
125126
boolean result = false;
126127
if (preCheck(src, dst, pathInformation)) {
@@ -439,7 +440,9 @@ private boolean renameInternal(final Path path,
439440
boolean operated = false;
440441
try {
441442
copyPath(path, destinationPathForBlobPartOfRenameSrcDir, leaseId);
443+
getAbfsClient().incrementAbfsCopyFile();
442444
getAbfsClient().deleteBlobPath(path, leaseId, tracingContext);
445+
getAbfsClient().incrementAbfsDeleteFile();
443446
operated = true;
444447
} finally {
445448
if (abfsLease != null) {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ public int preRename() throws AzureBlobFileSystemException {
267267
}
268268
}
269269
throw e;
270+
} finally {
271+
abfsClient.incrementAbfsCreateFile();
270272
}
271273
}
272274

@@ -310,6 +312,8 @@ private void deleteRenamePendingJson() throws AzureBlobFileSystemException {
310312
return;
311313
}
312314
throw e;
315+
} finally {
316+
abfsClient.incrementAbfsDeleteFile();
313317
}
314318
}
315319

0 commit comments

Comments
 (0)