-
Notifications
You must be signed in to change notification settings - Fork 8.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HADOOP-16396. Allow authoritative mode on a subdirectory. #1043
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -237,7 +237,8 @@ public class S3AFileSystem extends FileSystem implements StreamCapabilities, | |
private final AtomicBoolean closed = new AtomicBoolean(false); | ||
private volatile boolean isClosed = false; | ||
private MetadataStore metadataStore; | ||
private boolean allowAuthoritative; | ||
private boolean allowAuthoritativeMetadataStore; | ||
private Collection<String> allowAuthoritativePaths; | ||
|
||
/** Delegation token integration; non-empty when DT support is enabled. */ | ||
private Optional<S3ADelegationTokens> delegationTokens = Optional.empty(); | ||
|
@@ -397,11 +398,13 @@ public void initialize(URI name, Configuration originalConf) | |
ttlTimeProvider = new S3Guard.TtlTimeProvider(authDirTtl); | ||
|
||
setMetadataStore(S3Guard.getMetadataStore(this)); | ||
allowAuthoritative = conf.getBoolean(METADATASTORE_AUTHORITATIVE, | ||
allowAuthoritativeMetadataStore = conf.getBoolean(METADATASTORE_AUTHORITATIVE, | ||
DEFAULT_METADATASTORE_AUTHORITATIVE); | ||
allowAuthoritativePaths = S3Guard.getAuthoritativePaths(this); | ||
|
||
if (hasMetadataStore()) { | ||
LOG.debug("Using metadata store {}, authoritative={}", | ||
getMetadataStore(), allowAuthoritative); | ||
LOG.debug("Using metadata store {}, authoritative store={}, authoritative path={}", | ||
getMetadataStore(), allowAuthoritativeMetadataStore, allowAuthoritativePaths); | ||
} | ||
initMultipartUploads(conf); | ||
} catch (AmazonClientException e) { | ||
|
@@ -840,7 +843,8 @@ public String pathToKey(Path path) { | |
* @param key s3 key or "" | ||
* @return the with a trailing "/", or, if it is the root key, "", | ||
*/ | ||
private String maybeAddTrailingSlash(String key) { | ||
@InterfaceAudience.Private | ||
public String maybeAddTrailingSlash(String key) { | ||
if (!key.isEmpty() && !key.endsWith("/")) { | ||
return key + '/'; | ||
} else { | ||
|
@@ -1446,7 +1450,7 @@ public boolean hasMetadataStore() { | |
*/ | ||
@VisibleForTesting | ||
boolean hasAuthoritativeMetadataStore() { | ||
return hasMetadataStore() && allowAuthoritative; | ||
return hasMetadataStore() && allowAuthoritativeMetadataStore; | ||
} | ||
|
||
/** | ||
|
@@ -2398,6 +2402,8 @@ public FileStatus[] innerListStatus(Path f) throws FileNotFoundException, | |
|
||
DirListingMetadata dirMeta = | ||
S3Guard.listChildrenWithTtl(metadataStore, path, ttlTimeProvider); | ||
boolean allowAuthoritative = S3Guard.allowAuthoritative(f, this, | ||
allowAuthoritativeMetadataStore, allowAuthoritativePaths); | ||
if (allowAuthoritative && dirMeta != null && dirMeta.isAuthoritative()) { | ||
return S3Guard.dirMetaToStatuses(dirMeta); | ||
} | ||
|
@@ -2415,6 +2421,7 @@ public FileStatus[] innerListStatus(Path f) throws FileNotFoundException, | |
result.add(files.next()); | ||
} | ||
// merge the results. This will update the store as needed | ||
|
||
return S3Guard.dirListingUnion(metadataStore, path, result, dirMeta, | ||
allowAuthoritative, ttlTimeProvider); | ||
} else { | ||
|
@@ -2629,6 +2636,8 @@ S3AFileStatus innerGetFileStatus(final Path f, | |
// dest is also a directory, there's no difference. | ||
// TODO After HADOOP-16085 the modification detection can be done with | ||
// etags or object version instead of modTime | ||
boolean allowAuthoritative = S3Guard.allowAuthoritative(f, this, | ||
allowAuthoritativeMetadataStore, allowAuthoritativePaths); | ||
if (!pm.getFileStatus().isDirectory() && | ||
!allowAuthoritative) { | ||
LOG.debug("Metadata for {} found in the non-auth metastore.", path); | ||
|
@@ -3554,7 +3563,8 @@ public String toString() { | |
sb.append(", blockFactory=").append(blockFactory); | ||
} | ||
sb.append(", metastore=").append(metadataStore); | ||
sb.append(", authoritative=").append(allowAuthoritative); | ||
sb.append(", authoritativeStore=").append(allowAuthoritativeMetadataStore); | ||
sb.append(", authoritativePath=").append(allowAuthoritativePaths); | ||
sb.append(", useListV1=").append(useListV1); | ||
if (committerIntegration != null) { | ||
sb.append(", magicCommitter=").append(isMagicCommitEnabled()); | ||
|
@@ -3794,10 +3804,13 @@ private RemoteIterator<S3ALocatedFileStatus> innerListFiles(Path f, boolean | |
key, delimiter); | ||
final RemoteIterator<S3AFileStatus> cachedFilesIterator; | ||
final Set<Path> tombstones; | ||
boolean allowAuthoritative = S3Guard.allowAuthoritative(f, this, | ||
allowAuthoritativeMetadataStore, allowAuthoritativePaths); | ||
if (recursive) { | ||
final PathMetadata pm = metadataStore.get(path, true); | ||
// shouldn't need to check pm.isDeleted() because that will have | ||
// been caught by getFileStatus above. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: newline without purpose |
||
MetadataStoreListFilesIterator metadataStoreListFilesIterator = | ||
new MetadataStoreListFilesIterator(metadataStore, pm, | ||
allowAuthoritative); | ||
|
@@ -3886,6 +3899,8 @@ public RemoteIterator<LocatedFileStatus> listLocatedStatus(final Path f, | |
final RemoteIterator<S3AFileStatus> cachedFileStatusIterator = | ||
listing.createProvidedFileStatusIterator( | ||
S3Guard.dirMetaToStatuses(meta), filter, acceptor); | ||
boolean allowAuthoritative = S3Guard.allowAuthoritative(f, this, | ||
allowAuthoritativeMetadataStore, allowAuthoritativePaths); | ||
return (allowAuthoritative && meta != null | ||
&& meta.isAuthoritative()) | ||
? listing.createLocatedFileStatusIterator( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1321,7 +1321,6 @@ public void put( | |
final DirListingMetadata meta, | ||
@Nullable final BulkOperationState operationState) throws IOException { | ||
LOG.debug("Saving to table {} in region {}: {}", tableName, region, meta); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: newline removed without purpose |
||
// directory path | ||
Path path = meta.getPath(); | ||
DDBPathMetadata ddbPathMeta = | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: newline without purpose