T
- The type of the operator state.ListCheckpointed
as illustrated above, or
CheckpointedFunction
for more control over the checkpointing process.@Deprecated @PublicEvolving public interface Checkpointed<T extends Serializable> extends CheckpointedRestoring<T>
ListCheckpointed
and works
as shown in the example below. The ListCheckpointed
interface returns a list of
elements (
public class ExampleFunction<T> implements MapFunction<T, T>, ListCheckpointed<Integer> {
private int count;
public List<Integer> snapshotState(long checkpointId, long timestamp) throws Exception {
return Collections.singletonList(this.count);
}
public void restoreState(List<Integer> state) throws Exception {
this.value = state.count.isEmpty() ? 0 : state.get(0);
}
public T map(T value) {
count++;
return value;
}
}
Modifier and Type | Method and Description |
---|---|
T |
snapshotState(long checkpointId,
long checkpointTimestamp)
Deprecated.
Gets the current state of the function of operator.
|
restoreState
T snapshotState(long checkpointId, long checkpointTimestamp) throws Exception
checkpointId
- The ID of the checkpoint.checkpointTimestamp
- The timestamp of the checkpoint, as derived by
System.currentTimeMillis() on the JobManager.Exception
- Thrown if the creation of the state object failed. This causes the
checkpoint to fail. The system may decide to fail the operation (and trigger
recovery), or to discard this checkpoint attempt and to continue running
and to try again with the next checkpoint attempt.Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.