@InterfaceAudience.Private @InterfaceStability.Evolving public interface MetadataStore extends Closeable
MetadataStore defines the set of operations that any metadata store
implementation must provide. Note that all Path objects provided
to methods must be absolute, not relative paths.
Implementations must implement any retries needed internally, such that
transient errors are generally recovered from without throwing exceptions
from this API.| Modifier and Type | Interface and Description |
|---|---|
static class |
MetadataStore.PruneMode
Modes of operation for prune.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAncestors(org.apache.hadoop.fs.Path qualifiedPath,
BulkOperationState operationState)
This adds all new ancestors of a path as directories.
|
void |
delete(org.apache.hadoop.fs.Path path,
BulkOperationState operationState)
Deletes exactly one path, leaving a tombstone to prevent lingering,
inconsistent copies of it from being listed.
|
void |
deletePaths(Collection<org.apache.hadoop.fs.Path> paths,
BulkOperationState operationState)
Delete the paths.
|
void |
deleteSubtree(org.apache.hadoop.fs.Path path,
BulkOperationState operationState)
Deletes the entire sub-tree rooted at the given path, leaving tombstones
to prevent lingering, inconsistent copies of it from being listed.
|
void |
destroy()
Destroy all resources associated with the metadata store.
|
void |
forgetMetadata(org.apache.hadoop.fs.Path path)
Removes the record of exactly one path.
|
PathMetadata |
get(org.apache.hadoop.fs.Path path)
Gets metadata for a path.
|
PathMetadata |
get(org.apache.hadoop.fs.Path path,
boolean wantEmptyDirectoryFlag)
Gets metadata for a path.
|
Map<String,String> |
getDiagnostics()
Get any diagnostics information from a store, as a list of (key, value)
tuples for display.
|
default MetastoreInstrumentation |
getInstrumentation()
Get any S3GuardInstrumentation for this store...must not be null.
|
void |
initialize(org.apache.hadoop.conf.Configuration conf,
ITtlTimeProvider ttlTimeProvider)
Performs one-time initialization of the metadata store via configuration.
|
void |
initialize(org.apache.hadoop.fs.FileSystem fs,
ITtlTimeProvider ttlTimeProvider)
Performs one-time initialization of the metadata store.
|
default BulkOperationState |
initiateBulkWrite(BulkOperationState.OperationType operation,
org.apache.hadoop.fs.Path dest)
Initiate a bulk update and create an operation state for it.
|
RenameTracker |
initiateRenameOperation(StoreContext storeContext,
org.apache.hadoop.fs.Path source,
S3AFileStatus sourceStatus,
org.apache.hadoop.fs.Path dest)
Start a rename operation.
|
DirListingMetadata |
listChildren(org.apache.hadoop.fs.Path path)
Lists metadata for all direct children of a path.
|
default int |
markAsAuthoritative(org.apache.hadoop.fs.Path dest,
BulkOperationState operationState)
Mark all directories created/touched in an operation as authoritative.
|
void |
move(Collection<org.apache.hadoop.fs.Path> pathsToDelete,
Collection<PathMetadata> pathsToCreate,
BulkOperationState operationState)
Record the effects of a
FileSystem.rename(Path, Path) in the
MetadataStore. |
void |
prune(MetadataStore.PruneMode pruneMode,
long cutoff)
Prune method with two modes of operation:
MetadataStore.PruneMode.ALL_BY_MODTIME
Clear any metadata older than a specified mod_time from the store. |
long |
prune(MetadataStore.PruneMode pruneMode,
long cutoff,
String keyPrefix)
Same as
prune(PruneMode, long), but with an
additional keyPrefix parameter to filter the pruned keys with a prefix. |
void |
put(Collection<? extends PathMetadata> metas,
BulkOperationState operationState)
Saves metadata for any number of paths.
|
void |
put(DirListingMetadata meta,
List<org.apache.hadoop.fs.Path> unchangedEntries,
BulkOperationState operationState)
Save directory listing metadata.
|
void |
put(PathMetadata meta)
Saves metadata for exactly one path.
|
void |
put(PathMetadata meta,
BulkOperationState operationState)
Saves metadata for exactly one path, potentially
using any bulk operation state to eliminate duplicate work.
|
void |
setTtlTimeProvider(ITtlTimeProvider ttlTimeProvider)
The TtlTimeProvider has to be set during the initialization for the
metadatastore, but this method can be used for testing, and change the
instance during runtime.
|
void |
updateParameters(Map<String,String> parameters)
Tune/update parameters for an existing table.
|
void initialize(org.apache.hadoop.fs.FileSystem fs,
ITtlTimeProvider ttlTimeProvider)
throws IOException
fs - FileSystem associated with the MetadataStorettlTimeProvider - the time provider to use for metadata expiryIOException - if there is an errorvoid initialize(org.apache.hadoop.conf.Configuration conf,
ITtlTimeProvider ttlTimeProvider)
throws IOException
conf - Configuration.ttlTimeProvider - the time provider to use for metadata expiryIOException - if there is an errorinitialize(FileSystem, ITtlTimeProvider)void delete(org.apache.hadoop.fs.Path path,
@Nullable
BulkOperationState operationState)
throws IOException
S3Guard.TtlTimeProvider because
the lastUpdated field of the record has to be updated to now.
path - the path to deleteoperationState - (nullable) operational state for a bulk updateIOException - if there is an errorvoid forgetMetadata(org.apache.hadoop.fs.Path path)
throws IOException
delete(Path, BulkOperationState). It is currently
intended for testing only, and a need to use it as part of normal
FileSystem usage is not anticipated.path - the path to deleteIOException - if there is an error@Retries.RetryTranslated void deleteSubtree(org.apache.hadoop.fs.Path path, @Nullable BulkOperationState operationState) throws IOException
get(Path),
implementations must also update any stored DirListingMetadata
objects which track the parent of this file.
Deleting a subtree with a tombstone needs a
S3Guard.TtlTimeProvider because
the lastUpdated field of all records have to be updated to now.
path - the root of the sub-tree to deleteoperationState - (nullable) operational state for a bulk updateIOException - if there is an error@Retries.RetryTranslated void deletePaths(Collection<org.apache.hadoop.fs.Path> paths, @Nullable BulkOperationState operationState) throws IOException
paths - paths to delete.operationState - Nullable operation stateIOException - failurePathMetadata get(org.apache.hadoop.fs.Path path) throws IOException
path - the path to getpath, null if not foundIOException - if there is an errorPathMetadata get(org.apache.hadoop.fs.Path path, boolean wantEmptyDirectoryFlag) throws IOException
PathMetadata.isEmptyDirectory(). Since determining emptiness
may be an expensive operation, this can save wasted work.path - the path to getwantEmptyDirectoryFlag - Set to true to give a hint to the
MetadataStore that it should try to compute the empty directory flag.path, null if not foundIOException - if there is an error@Retries.RetryTranslated DirListingMetadata listChildren(org.apache.hadoop.fs.Path path) throws IOException
path - the path to listpath which are being
tracked by the MetadataStore, or null if the path was not found
in the MetadataStore.IOException - if there is an error@Retries.RetryTranslated void addAncestors(org.apache.hadoop.fs.Path qualifiedPath, @Nullable BulkOperationState operationState) throws IOException
Important: to propagate TTL information, any new ancestors added
must have their last updated timestamps set through
S3Guard.patchLastUpdated(Collection, ITtlTimeProvider).
qualifiedPath - path to updateoperationState - (nullable) operational state for a bulk updateIOException - failurevoid move(@Nullable Collection<org.apache.hadoop.fs.Path> pathsToDelete, @Nullable Collection<PathMetadata> pathsToCreate, @Nullable BulkOperationState operationState) throws IOException
FileSystem.rename(Path, Path) in the
MetadataStore. Clients provide explicit enumeration of the affected
paths (recursively), before and after the rename.
This operation is not atomic, unless specific implementations claim
otherwise.
On the need to provide an enumeration of directory trees instead of just
source and destination paths:
Since a MetadataStore does not have to track all metadata for the
underlying storage system, and a new MetadataStore may be created on an
existing underlying filesystem, this move() may be the first time the
MetadataStore sees the affected paths. Therefore, simply providing src
and destination paths may not be enough to record the deletions (under
src path) and creations (at destination) that are happening during the
rename().pathsToDelete - Collection of all paths that were removed from the
source directory tree of the move.pathsToCreate - Collection of all PathMetadata for the new paths
that were created at the destination of the rename().operationState - Any ongoing state supplied to the rename tracker
which is to be passed in with each move operation.IOException - if there is an error@Retries.RetryTranslated void put(PathMetadata meta) throws IOException
DirListingMetadata objects which
track the immediate parent of this file.meta - the metadata to saveIOException - if there is an error@Retries.RetryTranslated void put(PathMetadata meta, @Nullable BulkOperationState operationState) throws IOException
DirListingMetadata objects which
track the immediate parent of this file.meta - the metadata to saveoperationState - operational state for a bulk updateIOException - if there is an errorvoid put(Collection<? extends PathMetadata> metas, @Nullable BulkOperationState operationState) throws IOException
metas - the metadata to saveoperationState - (nullable) operational state for a bulk updateIOException - if there is an errorvoid put(DirListingMetadata meta, List<org.apache.hadoop.fs.Path> unchangedEntries, @Nullable BulkOperationState operationState) throws IOException
MetadataStore implementations may
subsequently keep track of all modifications to the directory contents at
this path, and return authoritative results from subsequent calls to
listChildren(Path). See DirListingMetadata.
Any authoritative results returned are only authoritative for the scope
of the MetadataStore: A per-process MetadataStore, for
example, would only show results visible to that process, potentially
missing metadata updates (create, delete) made to the same path by
another process.
To optimize updates and avoid overwriting existing entries which
may contain extra data, entries in the list of unchangedEntries may
be excluded. That is: the listing metadata has the full list of
what it believes are children, but implementations can opt to ignore
some.meta - Directory listing metadata.unchangedEntries - list of entries in the dir listing which have
not changed since the directory was list scanned on s3guard.operationState - operational state for a bulk updateIOException - if there is an errorvoid destroy()
throws IOException
IOException - if there is an errorvoid prune(MetadataStore.PruneMode pruneMode, long cutoff) throws IOException, UnsupportedOperationException
MetadataStore.PruneMode.ALL_BY_MODTIME
Clear any metadata older than a specified mod_time from the store.
Note that this modification time is the S3 modification time from the
object's metadata - from the object store.
Implementations MUST clear file metadata, and MAY clear directory
metadata (s3a itself does not track modification time for directories).
Implementations may also choose to throw UnsupportedOperationException
instead. Note that modification times must be in UTC, as returned by
System.currentTimeMillis at the time of modification.
MetadataStore.PruneMode.TOMBSTONES_BY_LASTUPDATED
Clear any tombstone updated earlier than a specified time from the
store. Note that this last_updated is the time when the metadata
entry was last updated and maintained by the metadata store.
Implementations MUST clear file metadata, and MAY clear directory
metadata (s3a itself does not track modification time for directories).
Implementations may also choose to throw UnsupportedOperationException
instead. Note that last_updated must be in UTC, as returned by
System.currentTimeMillis at the time of modification.
pruneMode - Prune Modecutoff - Oldest time to allow (UTC)IOException - if there is an errorUnsupportedOperationException - if not implementedlong prune(MetadataStore.PruneMode pruneMode, long cutoff, String keyPrefix) throws IOException, UnsupportedOperationException
prune(PruneMode, long), but with an
additional keyPrefix parameter to filter the pruned keys with a prefix.pruneMode - Prune Modecutoff - Oldest time in milliseconds to allow (UTC)keyPrefix - The prefix for the keys that should be removedIOException - if there is an errorUnsupportedOperationException - if not implementedMap<String,String> getDiagnostics() throws IOException
IOException - if there is an errorvoid updateParameters(Map<String,String> parameters) throws IOException
parameters - map of params to change.IOException - if there is an errordefault int markAsAuthoritative(org.apache.hadoop.fs.Path dest,
BulkOperationState operationState)
throws IOException
dest - destination path.operationState - active state.IOException - failure.RenameTracker initiateRenameOperation(StoreContext storeContext, org.apache.hadoop.fs.Path source, S3AFileStatus sourceStatus, org.apache.hadoop.fs.Path dest) throws IOException
storeContext - store context.source - source pathsourceStatus - status of the source file/dirdest - destination path.IOException - Failure.default BulkOperationState initiateBulkWrite(BulkOperationState.OperationType operation, org.apache.hadoop.fs.Path dest) throws IOException
operation - the type of the operation.dest - path under which updates will be explicitly put.IOException - failurevoid setTtlTimeProvider(ITtlTimeProvider ttlTimeProvider)
ttlTimeProvider - default MetastoreInstrumentation getInstrumentation()
Copyright © 2008–2022 Apache Software Foundation. All rights reserved.