Interface Snapshot
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
StandardSnapshot
Represents a loaded and limited snapshot of the database. In order to provide fine-grained access, this specifies a
subset of
Path
and ResourceId
instances which must be locked. Changes to the Snapshot
only
happen in memory and do not write data to disk.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionadd
(ResourceId resourceId) Adds a newResourceEntry
with the suppliedResourceId
, returning the result.void
close()
Closes this snapshot, releasing any underlying system resources associated with this snapshot.findResourceEntry
(ResourceId resourceId) Finds theResourceEntry
at the supplied ResourceId.findResourceEntry
(Path path) Finds theResourceEntry
at the supplied path.findTaskEntry
(ResourceId resourceId) Finds theTaskEntry
associated with the suppliedResourceId
.getOrCreateTaskEntry
(ResourceId resourceId) Gets theTaskEntry
or throws an instance ofSnapshotMissException
.Gets allResourceEntry
instances in thisSnapshot
.default ResourceEntry
getResourceEntry
(ResourceId resourceId) Gets theResourceEntry
or throws an instance ofSnapshotMissException
.default ResourceEntry
getResourceEntry
(Path path) Gets theResourceEntry
or throws an instance ofSnapshotMissException
.Collection
<TaskEntry<?>> List allResourceEntry
instances matching thePath
.
-
Method Details
-
list
List allResourceEntry
instances matching thePath
. As aSnapshot
may be backed by aStream
from theDataStore
, it is required that the Stream reach a terminal state or be explicitly closed. Closing thisSnapshot
will close the stream associatd with it.- Parameters:
path
- the path- Returns:
- the
Stream<ResourceEntry>
-
findTaskEntry
Finds theTaskEntry
associated with the suppliedResourceId
.- Parameters:
resourceId
- theResourceId
- Returns:
- the
Optional
containing theTaskEntry<ResourceId>
-
getOrCreateTaskEntry
Gets theTaskEntry
or throws an instance ofSnapshotMissException
. -
getResourceEntry
Gets theResourceEntry
or throws an instance ofSnapshotMissException
.- Parameters:
path
- the Resource id- Returns:
- the
ResourceEntry
, never null
-
findResourceEntry
Finds theResourceEntry
at the supplied path.- Parameters:
path
- the path- Returns:
- an
Optional
containing the Entry.
-
getResourceEntry
Gets theResourceEntry
or throws an instance ofSnapshotMissException
.- Parameters:
resourceId
- the Resource id- Returns:
- the
ResourceEntry
, never null - Throws:
SnapshotMissException
- if the snapshot entry was never loaded
-
findResourceEntry
Finds theResourceEntry
at the supplied ResourceId.- Parameters:
resourceId
- the path- Returns:
- an
Optional
containing the Entry.
-
getTaskEntries
Collection<TaskEntry<?>> getTaskEntries() -
getResourceEntries
Collection<ResourceEntry> getResourceEntries()Gets allResourceEntry
instances in thisSnapshot
.- Returns:
- gets all
ResourceEntry
instances associated with thisSnapshot
-
add
Adds a newResourceEntry
with the suppliedResourceId
, returning the result. Any previously accessedResourceEntry
instances.- Parameters:
resourceId
- theResourceId
- Returns:
- the
ResourceEntry
which was added. - Throws:
SnapshotMissException
- if the snapshot entry was never loadedDuplicateException
- if aResourceId
already exists
-
close
void close()Closes this snapshot, releasing any underlying system resources associated with this snapshot.- Specified by:
close
in interfaceAutoCloseable
-