public abstract class SnapshotDirectory extends Object
DirectoryStateHandle
when the snapshot is completed and disposal considers
whether or not a snapshot was already completed. For a completed snapshot, the ownership for
cleanup is transferred to the created directory state handle. For incomplete snapshots, calling
cleanup()
will delete the underlying directory resource.Modifier and Type | Field and Description |
---|---|
protected Path |
directory
This path describes the underlying directory for the snapshot.
|
protected AtomicReference<org.apache.flink.runtime.state.SnapshotDirectory.State> |
state
This reference tracks the lifecycle state of the snapshot directory.
|
Modifier and Type | Method and Description |
---|---|
boolean |
cleanup()
Calling this method will attempt delete the underlying snapshot directory recursively, if the
state is "ongoing".
|
abstract DirectoryStateHandle |
completeSnapshotAndGetHandle()
Calling this method completes the snapshot for this snapshot directory, if possible, and
creates a corresponding
DirectoryStateHandle that points to the snapshot directory. |
boolean |
equals(Object o) |
boolean |
exists() |
Path |
getDirectory() |
int |
hashCode() |
boolean |
isSnapshotCompleted()
Returns
true if the snapshot is marked as completed. |
Path[] |
listDirectory()
List the files in the snapshot directory.
|
boolean |
mkdirs() |
static SnapshotDirectory |
permanent(Path directory)
Creates a permanent snapshot directory for the given path, which will not delete the
underlying directory in
cleanup() after completeSnapshotAndGetHandle() was
called. |
static SnapshotDirectory |
temporary(File directory)
Creates a local temporary snapshot directory for the given path.
|
String |
toString() |
@Nonnull protected final Path directory
@Nonnull protected AtomicReference<org.apache.flink.runtime.state.SnapshotDirectory.State> state
public boolean mkdirs() throws IOException
IOException
public boolean exists() throws IOException
IOException
public Path[] listDirectory() throws IOException
IOException
- if there is a problem creating the file statuses.public boolean cleanup() throws IOException
true
if delete is successful, false
otherwise.IOException
- if an exception happens during the delete.public boolean isSnapshotCompleted()
true
if the snapshot is marked as completed.@Nullable public abstract DirectoryStateHandle completeSnapshotAndGetHandle() throws IOException
DirectoryStateHandle
that points to the snapshot directory.
Calling this method can change the lifecycle state from ONGOING to COMPLETED if the directory
should no longer deleted in cleanup()
. This method can return Can return true
if the directory is temporary and should therefore not be referenced in a handle.true
if the directory is temporary and should therefore not be referenced in a handle.IOException
- if the state of this snapshot directory object is different from
"ongoing".public static SnapshotDirectory temporary(@Nonnull File directory) throws IOException
completeSnapshotAndGetHandle()
and always attempt to delete the
underlying directory in cleanup()
.IOException
public static SnapshotDirectory permanent(@Nonnull Path directory) throws IOException
cleanup()
after completeSnapshotAndGetHandle()
was
called.IOException
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.