@@ -237,7 +237,8 @@ public class S3AFileSystem extends FileSystem implements StreamCapabilities,
237237 private final AtomicBoolean closed = new AtomicBoolean (false );
238238 private volatile boolean isClosed = false ;
239239 private MetadataStore metadataStore ;
240- private boolean allowAuthoritative ;
240+ private boolean allowAuthoritativeMetadataStore ;
241+ private Collection <String > allowAuthoritativePaths ;
241242
242243 /** Delegation token integration; non-empty when DT support is enabled. */
243244 private Optional <S3ADelegationTokens > delegationTokens = Optional .empty ();
@@ -397,11 +398,13 @@ public void initialize(URI name, Configuration originalConf)
397398 ttlTimeProvider = new S3Guard .TtlTimeProvider (authDirTtl );
398399
399400 setMetadataStore (S3Guard .getMetadataStore (this ));
400- allowAuthoritative = conf .getBoolean (METADATASTORE_AUTHORITATIVE ,
401+ allowAuthoritativeMetadataStore = conf .getBoolean (METADATASTORE_AUTHORITATIVE ,
401402 DEFAULT_METADATASTORE_AUTHORITATIVE );
403+ allowAuthoritativePaths = S3Guard .getAuthoritativePaths (this );
404+
402405 if (hasMetadataStore ()) {
403- LOG .debug ("Using metadata store {}, authoritative={}" ,
404- getMetadataStore (), allowAuthoritative );
406+ LOG .debug ("Using metadata store {}, authoritative store={}, authoritative path ={}" ,
407+ getMetadataStore (), allowAuthoritativeMetadataStore , allowAuthoritativePaths );
405408 }
406409 initMultipartUploads (conf );
407410 } catch (AmazonClientException e ) {
@@ -840,7 +843,8 @@ public String pathToKey(Path path) {
840843 * @param key s3 key or ""
841844 * @return the with a trailing "/", or, if it is the root key, "",
842845 */
843- private String maybeAddTrailingSlash (String key ) {
846+ @ InterfaceAudience .Private
847+ public String maybeAddTrailingSlash (String key ) {
844848 if (!key .isEmpty () && !key .endsWith ("/" )) {
845849 return key + '/' ;
846850 } else {
@@ -1446,7 +1450,7 @@ public boolean hasMetadataStore() {
14461450 */
14471451 @ VisibleForTesting
14481452 boolean hasAuthoritativeMetadataStore () {
1449- return hasMetadataStore () && allowAuthoritative ;
1453+ return hasMetadataStore () && allowAuthoritativeMetadataStore ;
14501454 }
14511455
14521456 /**
@@ -2398,6 +2402,8 @@ public FileStatus[] innerListStatus(Path f) throws FileNotFoundException,
23982402
23992403 DirListingMetadata dirMeta =
24002404 S3Guard .listChildrenWithTtl (metadataStore , path , ttlTimeProvider );
2405+ boolean allowAuthoritative = S3Guard .allowAuthoritative (f , this ,
2406+ allowAuthoritativeMetadataStore , allowAuthoritativePaths );
24012407 if (allowAuthoritative && dirMeta != null && dirMeta .isAuthoritative ()) {
24022408 return S3Guard .dirMetaToStatuses (dirMeta );
24032409 }
@@ -2415,6 +2421,7 @@ public FileStatus[] innerListStatus(Path f) throws FileNotFoundException,
24152421 result .add (files .next ());
24162422 }
24172423 // merge the results. This will update the store as needed
2424+
24182425 return S3Guard .dirListingUnion (metadataStore , path , result , dirMeta ,
24192426 allowAuthoritative , ttlTimeProvider );
24202427 } else {
@@ -2629,6 +2636,8 @@ S3AFileStatus innerGetFileStatus(final Path f,
26292636 // dest is also a directory, there's no difference.
26302637 // TODO After HADOOP-16085 the modification detection can be done with
26312638 // etags or object version instead of modTime
2639+ boolean allowAuthoritative = S3Guard .allowAuthoritative (f , this ,
2640+ allowAuthoritativeMetadataStore , allowAuthoritativePaths );
26322641 if (!pm .getFileStatus ().isDirectory () &&
26332642 !allowAuthoritative ) {
26342643 LOG .debug ("Metadata for {} found in the non-auth metastore." , path );
@@ -3554,7 +3563,8 @@ public String toString() {
35543563 sb .append (", blockFactory=" ).append (blockFactory );
35553564 }
35563565 sb .append (", metastore=" ).append (metadataStore );
3557- sb .append (", authoritative=" ).append (allowAuthoritative );
3566+ sb .append (", authoritativeStore=" ).append (allowAuthoritativeMetadataStore );
3567+ sb .append (", authoritativePath=" ).append (allowAuthoritativePaths );
35583568 sb .append (", useListV1=" ).append (useListV1 );
35593569 if (committerIntegration != null ) {
35603570 sb .append (", magicCommitter=" ).append (isMagicCommitEnabled ());
@@ -3794,10 +3804,13 @@ private RemoteIterator<S3ALocatedFileStatus> innerListFiles(Path f, boolean
37943804 key , delimiter );
37953805 final RemoteIterator <S3AFileStatus > cachedFilesIterator ;
37963806 final Set <Path > tombstones ;
3807+ boolean allowAuthoritative = S3Guard .allowAuthoritative (f , this ,
3808+ allowAuthoritativeMetadataStore , allowAuthoritativePaths );
37973809 if (recursive ) {
37983810 final PathMetadata pm = metadataStore .get (path , true );
37993811 // shouldn't need to check pm.isDeleted() because that will have
38003812 // been caught by getFileStatus above.
3813+
38013814 MetadataStoreListFilesIterator metadataStoreListFilesIterator =
38023815 new MetadataStoreListFilesIterator (metadataStore , pm ,
38033816 allowAuthoritative );
@@ -3886,6 +3899,8 @@ public RemoteIterator<LocatedFileStatus> listLocatedStatus(final Path f,
38863899 final RemoteIterator <S3AFileStatus > cachedFileStatusIterator =
38873900 listing .createProvidedFileStatusIterator (
38883901 S3Guard .dirMetaToStatuses (meta ), filter , acceptor );
3902+ boolean allowAuthoritative = S3Guard .allowAuthoritative (f , this ,
3903+ allowAuthoritativeMetadataStore , allowAuthoritativePaths );
38893904 return (allowAuthoritative && meta != null
38903905 && meta .isAuthoritative ())
38913906 ? listing .createLocatedFileStatusIterator (
0 commit comments