1818
1919package org .apache .hadoop .fs .s3a ;
2020
21- import org .apache .hadoop .util .Lists ;
2221import software .amazon .awssdk .services .s3 .model .CommonPrefix ;
2322import software .amazon .awssdk .services .s3 .model .S3Object ;
2423
@@ -130,7 +129,7 @@ public static RemoteIterator<S3AFileStatus> toProvidedFileStatusIterator(
130129 * @param listPath path of the listing
131130 * @param request initial request to make
132131 * @param filter the filter on which paths to accept
133- * @param acceptors the class/predicate to decide which entries to accept
132+ * @param acceptor the class/predicate to decide which entries to accept
134133 * in the listing based on the full file status.
135134 * @param span audit span for this iterator
136135 * @return the iterator
@@ -141,12 +140,12 @@ public FileStatusListingIterator createFileStatusListingIterator(
141140 Path listPath ,
142141 S3ListRequest request ,
143142 PathFilter filter ,
144- List < FileStatusAcceptor > acceptors ,
143+ FileStatusAcceptor acceptor ,
145144 AuditSpan span ) throws IOException {
146145 return new FileStatusListingIterator (
147146 createObjectListingIterator (listPath , request , span ),
148147 filter ,
149- FileStatusAcceptor . resolveFileStatusAcceptors ( acceptors )
148+ acceptor
150149 );
151150 }
152151
@@ -194,14 +193,14 @@ public RemoteIterator<S3ALocatedFileStatus> createSingleStatusIterator(
194193 * List files under a path assuming the path to be a directory.
195194 * @param path input path.
196195 * @param recursive recursive listing?
197- * @param acceptors file status filter
196+ * @param acceptor file status filter
198197 * @param span audit span for this iterator
199198 * @return an iterator over listing.
200199 * @throws IOException any exception.
201200 */
202201 public RemoteIterator <S3ALocatedFileStatus > getListFilesAssumingDir (
203202 Path path ,
204- boolean recursive , List < FileStatusAcceptor > acceptors ,
203+ boolean recursive , FileStatusAcceptor acceptor ,
205204 AuditSpan span ) throws IOException {
206205
207206 String key = maybeAddTrailingSlash (pathToKey (path ));
@@ -219,7 +218,7 @@ public RemoteIterator<S3ALocatedFileStatus> getListFilesAssumingDir(
219218 delimiter ,
220219 span ),
221220 ACCEPT_ALL ,
222- acceptors ,
221+ acceptor ,
223222 span ));
224223 }
225224
@@ -241,7 +240,7 @@ public RemoteIterator<S3ALocatedFileStatus> getLocatedFileStatusIteratorForDir(
241240 listingOperationCallbacks
242241 .createListObjectsRequest (key , "/" , span ),
243242 filter ,
244- Lists . newArrayList ( new GlacierStatusAcceptor ( s3ObjectStorageClassFilter ), new AcceptAllButSelfAndS3nDirs (dir ) ),
243+ new AcceptAllButSelfAndS3nDirs (dir ),
245244 span ));
246245 }
247246
@@ -270,8 +269,7 @@ public RemoteIterator<S3ALocatedFileStatus> getLocatedFileStatusIteratorForDir(
270269 path ,
271270 request ,
272271 ACCEPT_ALL ,
273- Lists .newArrayList (new GlacierStatusAcceptor (s3ObjectStorageClassFilter ),
274- new AcceptAllButSelfAndS3nDirs (path )),
272+ new AcceptAllButSelfAndS3nDirs (path ),
275273 span );
276274 }
277275
@@ -491,7 +489,8 @@ private boolean buildNextStatusBatch(S3ListResult objects) {
491489 LOG .debug ("{}: {}" , keyPath , stringify (s3Object ));
492490 }
493491 // Skip over keys that are ourselves and old S3N _$folder$ files
494- if (acceptor .accept (keyPath , s3Object ) && filter .accept (keyPath )) {
492+ // Handle Glacier Storage Class objects based on the config fs.s3a.glacier.read.restored.objects value set
493+ if ( s3ObjectStorageClassFilter .getFilter ().apply (s3Object ) && acceptor .accept (keyPath , s3Object ) && filter .accept (keyPath )) {
495494 S3AFileStatus status = createFileStatus (keyPath , s3Object ,
496495 listingOperationCallbacks .getDefaultBlockSize (keyPath ),
497496 getStoreContext ().getUsername (),
@@ -860,56 +859,6 @@ public boolean accept(FileStatus status) {
860859 }
861860 }
862861
863-
864- /**
865- * Accept all entries except unrestored Glacier objects if the config fs.s3a.glacier.read.restored.objects,
866- * is set to READ_RESTORED_GLACIER_OBJECTS
867- * Accept all entries except Glacier objects if the config fs.s3a.glacier.read.restored.objects,
868- * is set to SKIP_ALL_GLACIER
869- */
870- public static class GlacierStatusAcceptor implements FileStatusAcceptor {
871-
872- private final S3ObjectStorageClassFilter s3ObjectStorageClassFilter ;
873-
874-
875- public GlacierStatusAcceptor (S3ObjectStorageClassFilter s3ObjectStorageClassFilter ) {
876- this .s3ObjectStorageClassFilter = s3ObjectStorageClassFilter ;
877- }
878-
879- /**
880- * Reject a s3Object entry with the Glacier storage class if the config fs.s3a.glacier.read.restored.objects is set to SKIP_ALL_GLACIER
881- * Reject a s3Object entry with the Glacier storage class if the config fs.s3a.glacier.read.restored.objects is set to READ_RESTORED_GLACIER_OBJECTS
882- * Accept a s3Object entry with the Glacier storage class if the config fs.s3a.glacier.read.restored.objects is set to READ_RESTORED_GLACIER_OBJECTS and the Glacier file is restored completely
883- * Reject a s3Object entry with any other storage class
884- * @param keyPath key path of the entry
885- * @param s3Object s3Object entry
886- * @return true if the entry is accepted (i.e. that a status entry
887- * should be generated.)
888- */
889- @ Override
890- public boolean accept (Path keyPath , S3Object s3Object ) {
891- return s3ObjectStorageClassFilter .getFilter ().apply (s3Object );
892- }
893-
894- /**
895- * Accept all prefixes
896- * @param keyPath qualified path to the entry
897- * @param prefix common prefix in listing.
898- * @return true if the entry is accepted (i.e. that a status entry
899- * should be generated.
900- */
901- @ Override
902- public boolean accept (Path keyPath , String prefix ) {
903- return true ;
904- }
905-
906- @ Override
907- public boolean accept (FileStatus status ) {
908- return true ;
909- }
910-
911- }
912-
913862 @ SuppressWarnings ("unchecked" )
914863 public static RemoteIterator <LocatedFileStatus > toLocatedFileStatusIterator (
915864 RemoteIterator <? extends LocatedFileStatus > iterator ) {
0 commit comments