public class SegmentFileStateHandle extends Object implements StreamStateHandle
FileStateHandle
for state that was written to a file segment. A SegmentFileStateHandle
represents a LogicalFile
, which has already been written to a
segment in a physical file.
TODO (FLINK-32079): serialization and deserialization of SegmentFileStateHandle
.
StateObject.StateObjectLocation, StateObject.StateObjectSizeStatsCollector
Modifier and Type | Field and Description |
---|---|
protected long |
stateSize
The size of the state in the file.
|
Constructor and Description |
---|
SegmentFileStateHandle(Path filePath,
long startPos,
long stateSize,
CheckpointedStateScope scope)
Creates a new segment file state for the given file path.
|
Modifier and Type | Method and Description |
---|---|
Optional<byte[]> |
asBytesIfInMemory() |
void |
discardState()
This method should be empty, so that JM is not in charge of the lifecycle of files in a
file-merging checkpoint.
|
boolean |
equals(Object o) |
Path |
getFilePath()
Gets the path where this handle's state is stored.
|
CheckpointedStateScope |
getScope() |
long |
getStartPos() |
long |
getStateSize()
Returns the size of the state in bytes.
|
PhysicalStateHandleID |
getStreamStateHandleID() |
int |
hashCode() |
FSDataInputStream |
openInputStream()
Returns an
FSDataInputStream that can be used to read back the data that was
previously written to the stream. |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
collectSizeStats
public SegmentFileStateHandle(Path filePath, long startPos, long stateSize, CheckpointedStateScope scope)
filePath
- The path to the file that stores the state.startPos
- Start position of the segment in the physical file.stateSize
- Size of the segment.scope
- The state's scope, whether it is exclusive or shared.public void discardState()
discardState
in interface StateObject
public Path getFilePath()
public FSDataInputStream openInputStream() throws IOException
StreamStateHandle
FSDataInputStream
that can be used to read back the data that was
previously written to the stream.openInputStream
in interface StreamStateHandle
IOException
public Optional<byte[]> asBytesIfInMemory()
asBytesIfInMemory
in interface StreamStateHandle
public PhysicalStateHandleID getStreamStateHandleID()
getStreamStateHandleID
in interface StreamStateHandle
public long getStartPos()
public long getStateSize()
StateObject
0
.
The values produced by this method are only used for informational purposes and for metrics/monitoring. If this method returns wrong values, the checkpoints and recovery will still behave correctly. However, efficiency may be impacted (wrong space pre-allocation) and functionality that depends on metrics (like monitoring) will be impacted.
Note for implementors: This method should not perform any I/O operations while obtaining
the state size (hence it does not declare throwing an IOException
). Instead, the
state size should be stored in the state object, or should be computable from the state
stored in this object. The reason is that this method is called frequently by several parts
of the checkpointing and issuing I/O requests from this method accumulates a heavy I/O load
on the storage system at higher scale.
getStateSize
in interface StateObject
public CheckpointedStateScope getScope()
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.