@ThreadSafe public class UfsSyncPathCache extends Object
InodeSyncStream
.
Each path contains the following values concerning synchronization:
- recursiveSyncTime: the last time a sync was successful on this path
- directChildSyncTime: the last time a sync was successful on the path which (at least)
included itself and its direct children
- recursiveSyncTime: the last time a sync was successful on this path which
included itself and all its children
Each path additionally contains the following values considering invalidation:
- invalidationTime: the last time this exact path was invalidated
- directChildInvalidation: the last time a direct child of this path was invalidated
- recursiveChildInvalidation: the last time a non-direct child of this path was invalidated
- isFile: when checking if a file needs to be synced, any descendant type from the most
recent sync will be valid
Whenever an invalidation is received the path, and its parents up to the root have their
appropriate invalidation times updated. Validation times are updated on the path
when notifySyncedPath(alluxio.AlluxioURI, alluxio.file.options.DescendantType, long, java.lang.Long, boolean)
is called on the root sync path after a successful sync.
An invalidation is received either when a client calls
DefaultFileSystemMaster.needsSync(alluxio.AlluxioURI)
to notify that a path
needs synchronization, or when a file is updated by an external Alluxio cluster, and
cross cluster sync is enabled.
Checking if a path needs to be synchronized involves checking the appropriate validation
and invalidation times at each path component up to the root.Modifier and Type | Field and Description |
---|---|
com.google.common.cache.Cache<String,alluxio.master.file.meta.SyncState> |
mItems |
Constructor and Description |
---|
UfsSyncPathCache(java.time.Clock clock)
Creates a new instance of
UfsSyncPathCache . |
Modifier and Type | Method and Description |
---|---|
Optional<Pair<Long,Long>> |
getSyncTimesForPath(AlluxioURI path)
Get sync times for a given path if they exist in the cache.
|
void |
notifyInvalidation(AlluxioURI path)
Notify that a path has been invalidated.
|
alluxio.master.file.meta.SyncState |
notifySyncedPath(AlluxioURI path,
DescendantType descendantType,
long startTime,
Long syncTime,
boolean isFile)
Notify sync happened.
|
long |
recordStartSync()
Called when starting a sync.
|
SyncCheck |
shouldSyncPath(AlluxioURI path,
long intervalMs,
DescendantType descendantType)
Check if sync should happen.
|
public final com.google.common.cache.Cache<String,alluxio.master.file.meta.SyncState> mItems
public UfsSyncPathCache(java.time.Clock clock)
UfsSyncPathCache
.clock
- the clock to use to compute sync timespublic long recordStartSync()
public Optional<Pair<Long,Long>> getSyncTimesForPath(AlluxioURI path)
path
- the path to checkpublic SyncCheck shouldSyncPath(AlluxioURI path, long intervalMs, DescendantType descendantType) throws InvalidPathException
path
- the path to checkintervalMs
- the frequency in ms that the sync should happendescendantType
- the descendant type of the operation being performedSyncCheck
object indicating if a sync should be performedInvalidPathException
public void notifyInvalidation(AlluxioURI path) throws InvalidPathException
path
- the pathInvalidPathException
public alluxio.master.file.meta.SyncState notifySyncedPath(AlluxioURI path, DescendantType descendantType, long startTime, @Nullable Long syncTime, boolean isFile)
path
- the synced pathdescendantType
- the descendant type for the performed operationstartTime
- the time at which the sync was startedsyncTime
- the time to set the sync success to, if null then the current
clock time is usedisFile
- true if the synced path is a fileCopyright © 2023. All Rights Reserved.