Package io.aeron.cluster.service
Class RecoveryState
java.lang.Object
io.aeron.cluster.service.RecoveryState
Counter representing the Recovery State for the cluster.
Key layout as follows:
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Leadership Term ID | | | +---------------------------------------------------------------+ | Log position for Snapshot | | | +---------------------------------------------------------------+ | Timestamp at beginning of Recovery | | | +---------------------------------------------------------------+ | Cluster ID | +---------------------------------------------------------------+ | Count of Services | +---------------------------------------------------------------+ | Snapshot Recording ID (Service ID 0) | | | +---------------------------------------------------------------+ | Snapshot Recording ID (Service ID n) | | | +---------------------------------------------------------------+
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intOffset of thecluster-idfield.static final intOffset of theterm-idfield.static final intOffset of thelog-positionfield.static final StringHuman-readable name for the counter.static final intType id of a recovery state counter.static final intOffset of theservice-countfield.static final intOffset of thesnapshot-recording-idsfield.static final intOffset of thetimestampfield. -
Method Summary
Modifier and TypeMethodDescriptionstatic Counterallocate(Aeron aeron, long leadershipTermId, long logPosition, long timestamp, int clusterId, long... snapshotRecordingIds) Allocate a counter to represent the snapshot services should load on start.static intfindCounterId(CountersReader counters, int clusterId) Find the active counter id for recovery state.static longgetLeadershipTermId(CountersReader counters, int counterId) Get the leadership term id for the snapshot state.static longgetLogPosition(CountersReader counters, int counterId) Get the position at which the snapshot was taken.static longgetSnapshotRecordingId(CountersReader counters, int counterId, int serviceId) Get the recording id of the snapshot for a service.static longgetTimestamp(CountersReader counters, int counterId) Get the timestamp at the beginning of recovery.
-
Field Details
-
RECOVERY_STATE_TYPE_ID
public static final int RECOVERY_STATE_TYPE_IDType id of a recovery state counter.- See Also:
-
NAME
Human-readable name for the counter.- See Also:
-
LEADERSHIP_TERM_ID_OFFSET
public static final int LEADERSHIP_TERM_ID_OFFSETOffset of theterm-idfield.- See Also:
-
LOG_POSITION_OFFSET
public static final int LOG_POSITION_OFFSETOffset of thelog-positionfield.- See Also:
-
TIMESTAMP_OFFSET
public static final int TIMESTAMP_OFFSETOffset of thetimestampfield.- See Also:
-
CLUSTER_ID_OFFSET
public static final int CLUSTER_ID_OFFSETOffset of thecluster-idfield.- See Also:
-
SERVICE_COUNT_OFFSET
public static final int SERVICE_COUNT_OFFSETOffset of theservice-countfield.- See Also:
-
SNAPSHOT_RECORDING_IDS_OFFSET
public static final int SNAPSHOT_RECORDING_IDS_OFFSETOffset of thesnapshot-recording-idsfield.- See Also:
-
-
Method Details
-
allocate
public static Counter allocate(Aeron aeron, long leadershipTermId, long logPosition, long timestamp, int clusterId, long... snapshotRecordingIds) Allocate a counter to represent the snapshot services should load on start.- Parameters:
aeron- to allocate the counter.leadershipTermId- at which the snapshot was taken.logPosition- at which the snapshot was taken.timestamp- the snapshot was taken.clusterId- which identifies the cluster instance.snapshotRecordingIds- for the services to use during recovery indexed by service id.- Returns:
- the
Counterfor the recovery state.
-
findCounterId
Find the active counter id for recovery state.- Parameters:
counters- to search within.clusterId- to constrain the search.- Returns:
- the counter id if found otherwise
CountersReader.NULL_COUNTER_ID.
-
getLeadershipTermId
Get the leadership term id for the snapshot state.Aeron.NULL_VALUEif no snapshot for recovery.- Parameters:
counters- to search within.counterId- for the active recovery counter.- Returns:
- the leadership term id if found otherwise
Aeron.NULL_VALUE.
-
getLogPosition
Get the position at which the snapshot was taken.Aeron.NULL_VALUEif no snapshot for recovery.- Parameters:
counters- to search within.counterId- for the active recovery counter.- Returns:
- the log position if found otherwise
Aeron.NULL_VALUE.
-
getTimestamp
Get the timestamp at the beginning of recovery.Aeron.NULL_VALUEif no snapshot for recovery.- Parameters:
counters- to search within.counterId- for the active recovery counter.- Returns:
- the timestamp if found otherwise
Aeron.NULL_VALUE.
-
getSnapshotRecordingId
Get the recording id of the snapshot for a service.- Parameters:
counters- to search within.counterId- for the active recovery counter.serviceId- for the snapshot required.- Returns:
- the count of replay terms if found otherwise
Aeron.NULL_VALUE.
-