@InterfaceAudience.Private @InterfaceStability.Unstable public final class S3Guard extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
S3Guard.DisabledWarnLevel
Warning levels to use when reporting S3Guard as disabled.
|
static class |
S3Guard.TtlTimeProvider
Runtime implementation for TTL Time Provider interface.
|
| Modifier and Type | Field and Description |
|---|---|
static boolean |
DIR_MERGE_UPDATES_ALL_RECORDS_NONAUTH
Hard-coded policy : false.
|
static String |
DISABLED_LOG_MSG
Format string to use when warning that S3Guard is disabled.
|
static String |
S3GUARD_DDB_CLIENT_FACTORY_IMPL |
static String |
UNKNOWN_WARN_LEVEL
Error string use in exception raised on an unknown log level.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addAncestors(MetadataStore metadataStore,
org.apache.hadoop.fs.Path qualifiedPath,
ITtlTimeProvider timeProvider,
BulkOperationState operationState)
This adds all new ancestors of a path as directories.
|
static void |
addMoveAncestors(MetadataStore ms,
Collection<org.apache.hadoop.fs.Path> srcPaths,
Collection<PathMetadata> dstMetas,
org.apache.hadoop.fs.Path srcRoot,
org.apache.hadoop.fs.Path srcPath,
org.apache.hadoop.fs.Path dstPath,
String owner)
Helper method that records the move of all ancestors of a path.
|
static void |
addMoveDir(MetadataStore ms,
Collection<org.apache.hadoop.fs.Path> srcPaths,
Collection<PathMetadata> dstMetas,
org.apache.hadoop.fs.Path srcPath,
org.apache.hadoop.fs.Path dstPath,
String owner)
Helper function that records the move of directory paths, adding
resulting metadata to the supplied lists.
|
static void |
addMoveFile(MetadataStore ms,
Collection<org.apache.hadoop.fs.Path> srcPaths,
Collection<PathMetadata> dstMetas,
org.apache.hadoop.fs.Path srcPath,
org.apache.hadoop.fs.Path dstPath,
long size,
long blockSize,
String owner,
String eTag,
String versionId)
Like
addMoveDir(MetadataStore, Collection, Collection, Path,
Path, String) (), but for files. |
static boolean |
allowAuthoritative(org.apache.hadoop.fs.Path p,
S3AFileSystem fs,
boolean authMetadataStore,
Collection<String> authPaths)
Is the path for the given FS instance authoritative?
|
static void |
assertQualified(org.apache.hadoop.fs.Path... paths)
Assert that all paths are valid.
|
static void |
assertQualified(org.apache.hadoop.fs.Path p)
Assert that the path is qualified with a host and scheme.
|
static org.apache.hadoop.fs.RemoteIterator<S3AFileStatus> |
dirListingUnion(MetadataStore ms,
org.apache.hadoop.fs.Path path,
org.apache.hadoop.fs.RemoteIterator<S3AFileStatus> backingStatuses,
DirListingMetadata dirMeta,
boolean isAuthoritative,
ITtlTimeProvider timeProvider,
Function<S3AFileStatus[],org.apache.hadoop.fs.RemoteIterator<S3AFileStatus>> toStatusItr)
Given directory listing metadata from both the backing store and the
MetadataStore, merge the two sources of truth to create a consistent
view of the current directory contents, which can be returned to clients.
|
static S3AFileStatus[] |
dirMetaToStatuses(DirListingMetadata dirMeta)
Convert the data of a directory listing to an array of
FileStatus
entries. |
static Collection<String> |
getAuthoritativePaths(S3AFileSystem fs) |
static MetadataStore |
getMetadataStore(org.apache.hadoop.fs.FileSystem fs,
ITtlTimeProvider ttlTimeProvider)
Create a new instance of the configured MetadataStore.
|
static PathMetadata |
getWithTtl(MetadataStore ms,
org.apache.hadoop.fs.Path path,
ITtlTimeProvider timeProvider,
boolean needEmptyDirectoryFlag,
boolean allowAuthoritative)
Get a path entry provided it is not considered expired.
|
static BulkOperationState |
initiateBulkWrite(MetadataStore metastore,
BulkOperationState.OperationType operation,
org.apache.hadoop.fs.Path path)
Initiate a bulk write and create an operation state for it.
|
static boolean |
isNullMetadataStore(MetadataStore ms)
Although NullMetadataStore does nothing, callers may wish to avoid work
(fast path) when the NullMetadataStore is in use.
|
static DirListingMetadata |
listChildrenWithTtl(MetadataStore ms,
org.apache.hadoop.fs.Path path,
ITtlTimeProvider timeProvider,
boolean allowAuthoritative)
List children; mark the result as non-auth if the TTL has expired.
|
static void |
logS3GuardDisabled(org.slf4j.Logger logger,
String warnLevelStr,
String bucket)
Log that S3Guard is disabled -optionally raise an exception.
|
static void |
makeDirsOrdered(MetadataStore ms,
List<org.apache.hadoop.fs.Path> dirs,
String owner,
boolean authoritative,
ITtlTimeProvider timeProvider)
Deprecated.
this is no longer called by
S3AFilesystem.innerMkDirs.
See: HADOOP-15079 (January 2018).
It is currently retained because of its discussion in the method on
atomicity and in case we need to reinstate it or adapt the current
process of directory marker creation.
But it is not being tested and so may age with time...consider
deleting it in future if it's clear there's no need for it. |
static S3AFileStatus |
putAndReturn(MetadataStore ms,
S3AFileStatus status,
ITtlTimeProvider timeProvider)
Helper function which puts a given S3AFileStatus into the MetadataStore and
returns the same S3AFileStatus.
|
static S3AFileStatus |
putAndReturn(MetadataStore ms,
S3AFileStatus status,
ITtlTimeProvider timeProvider,
BulkOperationState operationState)
Helper function which puts a given S3AFileStatus into the MetadataStore and
returns the same S3AFileStatus.
|
static void |
putAuthDirectoryMarker(MetadataStore ms,
S3AFileStatus status,
ITtlTimeProvider timeProvider,
BulkOperationState operationState)
Creates an authoritative directory marker for the store.
|
static void |
putWithTtl(MetadataStore ms,
Collection<? extends PathMetadata> fileMetas,
ITtlTimeProvider timeProvider,
BulkOperationState operationState)
Put entries, using the time provider to set their timestamp.
|
static void |
putWithTtl(MetadataStore ms,
DirListingMetadata dirMeta,
List<org.apache.hadoop.fs.Path> unchangedEntries,
ITtlTimeProvider timeProvider,
BulkOperationState operationState)
Put a directory entry, setting the updated timestamp of the
directory and its children.
|
static void |
putWithTtl(MetadataStore ms,
PathMetadata fileMeta,
ITtlTimeProvider timeProvider,
BulkOperationState operationState)
Put an entry, using the time provider to set its timestamp.
|
static boolean |
refreshEntry(MetadataStore metadataStore,
PathMetadata pm,
S3AFileStatus s3AFileStatus,
ITtlTimeProvider timeProvider)
We update the metastore for the specific case of S3 value == S3Guard value
so as to place a more recent modtime in the store.
|
@InterfaceAudience.Private @InterfaceStability.Unstable public static final String S3GUARD_DDB_CLIENT_FACTORY_IMPL
public static final boolean DIR_MERGE_UPDATES_ALL_RECORDS_NONAUTH
public static final String DISABLED_LOG_MSG
public static final String UNKNOWN_WARN_LEVEL
@Retries.OnceTranslated public static MetadataStore getMetadataStore(org.apache.hadoop.fs.FileSystem fs, ITtlTimeProvider ttlTimeProvider) throws IOException
MetadataStore.initialize(FileSystem, ITtlTimeProvider)
by this function before returning it. Callers must clean up by calling
Closeable.close() when done using the MetadataStore.fs - FileSystem whose Configuration specifies which
implementation to use.ttlTimeProvider - IOException - if the metadata store cannot be instantiated@Retries.RetryTranslated public static boolean refreshEntry(MetadataStore metadataStore, PathMetadata pm, S3AFileStatus s3AFileStatus, ITtlTimeProvider timeProvider) throws IOException
metadataStore - MetadataStore to put() into.pm - current datas3AFileStatus - status to storetimeProvider - Time provider to use when writing entriesIOException - if metadata store update failed@Retries.RetryTranslated public static S3AFileStatus putAndReturn(MetadataStore ms, S3AFileStatus status, ITtlTimeProvider timeProvider) throws IOException
ms - MetadataStore to put() into.status - status to storetimeProvider - Time provider to use when writing entriesIOException - if metadata store update failed@Retries.RetryTranslated public static S3AFileStatus putAndReturn(MetadataStore ms, S3AFileStatus status, ITtlTimeProvider timeProvider, @Nullable BulkOperationState operationState) throws IOException
ms - MetadataStore to put() into.status - status to storetimeProvider - Time provider to use when writing entriesoperationState - possibly-null metastore state tracker.IOException - if metadata store update failed@Retries.RetryTranslated public static void putAuthDirectoryMarker(MetadataStore ms, S3AFileStatus status, ITtlTimeProvider timeProvider, @Nullable BulkOperationState operationState) throws IOException
ms - MetadataStore to put() into.status - status to storetimeProvider - Time provider to use when writing entriesoperationState - possibly-null metastore state tracker.IOException - if metadata store update failedpublic static BulkOperationState initiateBulkWrite(@Nullable MetadataStore metastore, BulkOperationState.OperationType operation, org.apache.hadoop.fs.Path path) throws IOException
metastore - storeoperation - the type of the operation.path - path under which updates will be explicitly put.IOException - failurepublic static S3AFileStatus[] dirMetaToStatuses(DirListingMetadata dirMeta)
FileStatus
entries. Tombstones are filtered out at this point. If the listing is null
an empty array is returned.dirMeta - directory listing -may be nullpublic static org.apache.hadoop.fs.RemoteIterator<S3AFileStatus> dirListingUnion(MetadataStore ms, org.apache.hadoop.fs.Path path, org.apache.hadoop.fs.RemoteIterator<S3AFileStatus> backingStatuses, DirListingMetadata dirMeta, boolean isAuthoritative, ITtlTimeProvider timeProvider, Function<S3AFileStatus[],org.apache.hadoop.fs.RemoteIterator<S3AFileStatus>> toStatusItr) throws IOException
ms - MetadataStore to use.path - path to directorybackingStatuses - Directory listing from the backing store.dirMeta - Directory listing from MetadataStore. May be null.isAuthoritative - State of authoritative modetimeProvider - Time provider to use when updating entriestoStatusItr - function to convert array of file status to
RemoteIterator.IOException - if metadata store update failedpublic static boolean isNullMetadataStore(MetadataStore ms)
ms - The MetadataStore to test@Deprecated @Retries.OnceExceptionsSwallowed public static void makeDirsOrdered(MetadataStore ms, List<org.apache.hadoop.fs.Path> dirs, String owner, boolean authoritative, ITtlTimeProvider timeProvider)
S3AFilesystem.innerMkDirs.
See: HADOOP-15079 (January 2018).
It is currently retained because of its discussion in the method on
atomicity and in case we need to reinstate it or adapt the current
process of directory marker creation.
But it is not being tested and so may age with time...consider
deleting it in future if it's clear there's no need for it.ms - MetadataStore to update.dirs - null, or an ordered list of directories from leaf to root.
E.g. if /a/ exists, and mkdirs(/a/b/c/d) is called, this
list will contain [/a/b/c/d, /a/b/c, /a/b]. /a/b/c/d is
an empty, dir, and the other dirs only contain their child
dir.owner - Hadoop user name.authoritative - Whether to mark new directories as authoritative.timeProvider - Time provider.public static void addMoveDir(MetadataStore ms, Collection<org.apache.hadoop.fs.Path> srcPaths, Collection<PathMetadata> dstMetas, org.apache.hadoop.fs.Path srcPath, org.apache.hadoop.fs.Path dstPath, String owner)
ms - MetadataStore, used to make this a no-op, when it is
NullMetadataStore.srcPaths - stores the source path heredstMetas - stores destination metadata heresrcPath - source path to storedstPath - destination path to storeowner - file owner to use in created recordspublic static void addMoveFile(MetadataStore ms, Collection<org.apache.hadoop.fs.Path> srcPaths, Collection<PathMetadata> dstMetas, org.apache.hadoop.fs.Path srcPath, org.apache.hadoop.fs.Path dstPath, long size, long blockSize, String owner, String eTag, String versionId)
addMoveDir(MetadataStore, Collection, Collection, Path,
Path, String) (), but for files.ms - MetadataStore, used to make this a no-op, when it is
NullMetadataStore.srcPaths - stores the source path heredstMetas - stores destination metadata heresrcPath - source path to storedstPath - destination path to storesize - length of file movedblockSize - blocksize to associate with destination fileowner - file owner to use in created recordseTag - the s3 object eTag of file movedversionId - the s3 object versionId of file movedpublic static void addMoveAncestors(MetadataStore ms, Collection<org.apache.hadoop.fs.Path> srcPaths, Collection<PathMetadata> dstMetas, org.apache.hadoop.fs.Path srcRoot, org.apache.hadoop.fs.Path srcPath, org.apache.hadoop.fs.Path dstPath, String owner)
addMoveFile(org.apache.hadoop.fs.s3a.s3guard.MetadataStore, java.util.Collection<org.apache.hadoop.fs.Path>, java.util.Collection<org.apache.hadoop.fs.s3a.s3guard.PathMetadata>, org.apache.hadoop.fs.Path, org.apache.hadoop.fs.Path, long, long, java.lang.String, java.lang.String, java.lang.String) and addMoveDir(org.apache.hadoop.fs.s3a.s3guard.MetadataStore, java.util.Collection<org.apache.hadoop.fs.Path>, java.util.Collection<org.apache.hadoop.fs.s3a.s3guard.PathMetadata>, org.apache.hadoop.fs.Path, org.apache.hadoop.fs.Path, java.lang.String), this method adds resulting
metadata to the supplied lists. It does not update the MetadataStore.ms - MetadataStore, no-op if it is NullMetadataStoresrcPaths - stores the source path heredstMetas - stores destination metadata heresrcRoot - source root up to which (exclusive) should we add ancestorssrcPath - source path of the child to add ancestorsdstPath - destination path of the child to add ancestorsowner - Hadoop user name@Retries.RetryTranslated public static void addAncestors(MetadataStore metadataStore, org.apache.hadoop.fs.Path qualifiedPath, ITtlTimeProvider timeProvider, @Nullable BulkOperationState operationState) throws IOException
MetadataStore.addAncestors(Path, BulkOperationState).
Originally it implemented the logic to probe for an add ancestors, but with the addition of a store-specific bulk operation state it became unworkable.
metadataStore - storequalifiedPath - path to updateoperationState - (nullable) operational state for a bulk updateIOException - failurepublic static void assertQualified(org.apache.hadoop.fs.Path p)
p - path to checkNullPointerException - if either argument does not holdpublic static void assertQualified(org.apache.hadoop.fs.Path... paths)
paths - path to checkNullPointerException - if either argument does not holdpublic static void putWithTtl(MetadataStore ms, DirListingMetadata dirMeta, List<org.apache.hadoop.fs.Path> unchangedEntries, ITtlTimeProvider timeProvider, @Nullable BulkOperationState operationState) throws IOException
ms - metastoredirMeta - directoryunchangedEntries - list of unchanged entries from the listingtimeProvider - nullable time providerIOException - failure.public static void putWithTtl(MetadataStore ms, PathMetadata fileMeta, @Nullable ITtlTimeProvider timeProvider, @Nullable BulkOperationState operationState) throws IOException
ms - metastorefileMeta - entry to writetimeProvider - nullable time provideroperationState - nullable state for a bulk updateIOException - failure.public static void putWithTtl(MetadataStore ms, Collection<? extends PathMetadata> fileMetas, @Nullable ITtlTimeProvider timeProvider, @Nullable BulkOperationState operationState) throws IOException
ms - metastorefileMetas - file metadata entries.timeProvider - nullable time provideroperationState - nullable state for a bulk updateIOException - failure.public static PathMetadata getWithTtl(MetadataStore ms, org.apache.hadoop.fs.Path path, @Nullable ITtlTimeProvider timeProvider, boolean needEmptyDirectoryFlag, boolean allowAuthoritative) throws IOException
ms - metastorepath - path to look up.timeProvider - nullable time providerneedEmptyDirectoryFlag - if true, implementation will
return known state of directory emptiness.allowAuthoritative - if this flag is true, the ttl won't apply to the
metadata - so it will be returned regardless of it's expiry.IOException - failure.@Retries.RetryTranslated public static DirListingMetadata listChildrenWithTtl(MetadataStore ms, org.apache.hadoop.fs.Path path, @Nullable ITtlTimeProvider timeProvider, boolean allowAuthoritative) throws IOException
ms - metastorepath - path to look up.timeProvider - nullable time providerallowAuthoritative - if this flag is true, the ttl won't apply to the
metadata - so it will be returned regardless of it's expiry.IOException - failure.public static Collection<String> getAuthoritativePaths(S3AFileSystem fs)
public static boolean allowAuthoritative(org.apache.hadoop.fs.Path p,
S3AFileSystem fs,
boolean authMetadataStore,
Collection<String> authPaths)
p - pathfs - filesystemauthMetadataStore - is the MS authoritative.authPaths - possibly empty list of authoritative pathspublic static void logS3GuardDisabled(org.slf4j.Logger logger,
String warnLevelStr,
String bucket)
throws org.apache.hadoop.util.ExitUtil.ExitException,
IllegalArgumentException
logger - Log to log towarnLevelStr - string value of warn action.bucket - bucket to use in log/error messagesExitUtil.ExitException - if s3guard was disabled
and the log level is "fail"IllegalArgumentException - unknown warning level.Copyright © 2008–2022 Apache Software Foundation. All rights reserved.