Skip to content

Commit 73a4ca5

Browse files
committed
HADOOP-13230 operation cost tests
* defined constants for the Head/List cost of various ops, use them in the asserts over "1", "2" etc to make clearer origin of operations * Cut the standalone marker HEAD request. We don't need it, ever. That will simplify backporting too; I have a clear plan of the minimum needed for backporting to branch-3.3 and then again for 3.0-3.2 Change-Id: I33f9ccf2b477c027afe70137993c8344554f07c6
1 parent 58a2279 commit 73a4ca5

File tree

4 files changed

+332
-377
lines changed

4 files changed

+332
-377
lines changed

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2544,7 +2544,7 @@ private void createFakeDirectoryIfNecessary(Path f)
25442544
// we only make the LIST call; the codepaths to get here should not
25452545
// be reached if there is an empty dir marker -and if they do, it
25462546
// is mostly harmless to create a new one.
2547-
if (!key.isEmpty() && !s3Exists(f, EnumSet.of(StatusProbeEnum.List))) {
2547+
if (!key.isEmpty() && !s3Exists(f, StatusProbeEnum.DIRECTORIES)) {
25482548
LOG.debug("Creating new fake directory at {}", f);
25492549
createFakeDirectory(key);
25502550
}
@@ -3058,8 +3058,7 @@ S3AFileStatus s3GetFileStatus(final Path path,
30583058
}
30593059

30603060
// execute the list
3061-
boolean executeList = probes.contains(StatusProbeEnum.List);
3062-
if (executeList) {
3061+
if (probes.contains(StatusProbeEnum.List)) {
30633062
try {
30643063
// this will find a marker dir / as well as an entry.
30653064
// When making a simple "is this a dir check" all is good.
@@ -3119,45 +3118,6 @@ S3AFileStatus s3GetFileStatus(final Path path,
31193118
}
31203119
}
31213120

3122-
// Neither any normal file HEAD nor a LIST found an object
3123-
// Look for the dir marker
3124-
// TODO: decide whether to cut or not. We currently skip this entire probe.
3125-
boolean checkMarker = false && probes.contains(StatusProbeEnum.DirMarker);
3126-
if (!key.isEmpty() && checkMarker) {
3127-
String newKey = maybeAddTrailingSlash(key);
3128-
try {
3129-
ObjectMetadata meta = getObjectMetadata(newKey);
3130-
3131-
if (objectRepresentsDirectory(newKey, meta.getContentLength())) {
3132-
LOG.debug("Found file (with /): fake directory");
3133-
// this used to self-declare as empty; now it decides
3134-
// based on whether a list was also executed in the current
3135-
// series of probes
3136-
return new S3AFileStatus(
3137-
executeList
3138-
? Tristate.TRUE
3139-
: Tristate.UNKNOWN,
3140-
path, username);
3141-
} else {
3142-
LOG.warn("Found file (with /): real file? should not happen: {}",
3143-
key);
3144-
3145-
return new S3AFileStatus(meta.getContentLength(),
3146-
dateToLong(meta.getLastModified()),
3147-
path,
3148-
getDefaultBlockSize(path),
3149-
username,
3150-
meta.getETag(),
3151-
meta.getVersionId());
3152-
}
3153-
} catch (AmazonServiceException e) {
3154-
if (e.getStatusCode() != SC_404 || isUnknownBucket(e)) {
3155-
throw translateException("getFileStatus", newKey, e);
3156-
}
3157-
} catch (AmazonClientException e) {
3158-
throw translateException("getFileStatus", newKey, e);
3159-
}
3160-
}
31613121
LOG.debug("Not Found: {}", path);
31623122
throw new FileNotFoundException("No such file or directory: " + path);
31633123
}
@@ -3560,6 +3520,7 @@ private CopyResult copyFile(String srcKey, String dstKey, long size,
35603520
copyObjectRequest.setNewObjectMetadata(dstom);
35613521
Optional.ofNullable(srcom.getStorageClass())
35623522
.ifPresent(copyObjectRequest::setStorageClass);
3523+
incrementStatistic(OBJECT_COPY_REQUESTS);
35633524
Copy copy = transfers.copy(copyObjectRequest);
35643525
copy.addProgressListener(progressListener);
35653526
CopyOutcome copyOutcome = CopyOutcome.waitForCopy(copy);

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/impl/StatusProbeEnum.java

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,32 +34,24 @@ public enum StatusProbeEnum {
3434
List;
3535

3636
/** Look for files and directories. */
37-
public static final Set<StatusProbeEnum> FILES_AND_DIRECTORIES =
37+
public static final Set<StatusProbeEnum> ALL =
3838
EnumSet.of(Head, List);
3939

40-
/**
41-
* This used to mean "all probes", now it means "all file type.
42-
*/
43-
public static final Set<StatusProbeEnum> ALL = FILES_AND_DIRECTORIES;
44-
45-
/** Skip the HEAD and only look for directories. */
46-
public static final Set<StatusProbeEnum> DIRECTORIES =
47-
EnumSet.of(DirMarker, List);
48-
49-
/** We only want the HEAD or dir marker. */
50-
public static final Set<StatusProbeEnum> HEAD_OR_DIR_MARKER =
51-
EnumSet.of(Head, DirMarker);
52-
5340
/** We only want the HEAD. */
5441
public static final Set<StatusProbeEnum> HEAD_ONLY =
5542
EnumSet.of(Head);
5643

57-
/** We only want the dir marker. */
58-
public static final Set<StatusProbeEnum> DIR_MARKER_ONLY =
59-
EnumSet.of(DirMarker);
60-
61-
/** We only want the dir marker. */
44+
/** List operation only. */
6245
public static final Set<StatusProbeEnum> LIST_ONLY =
6346
EnumSet.of(List);
6447

48+
/** Look for files and directories. */
49+
public static final Set<StatusProbeEnum> FILE =
50+
HEAD_ONLY;
51+
52+
/** Skip the HEAD and only look for directories. */
53+
public static final Set<StatusProbeEnum> DIRECTORIES =
54+
LIST_ONLY;
55+
56+
6557
}

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AEmptyDirectory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void testDirectoryBecomesNonEmpty() throws Exception {
8080
private S3AFileStatus getS3AFileStatus(S3AFileSystem fs, Path p) throws
8181
IOException {
8282
return fs.innerGetFileStatus(p, true,
83-
StatusProbeEnum.FILES_AND_DIRECTORIES);
83+
StatusProbeEnum.ALL);
8484
}
8585

8686
}

0 commit comments

Comments
 (0)