Package io.aeron.cluster.service
Class SnapshotTaker
java.lang.Object
io.aeron.cluster.service.SnapshotTaker
Base class of common functions required to take a snapshot of cluster state.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final BufferClaimReusableBufferClaimto avoid allocation.protected final IdleStrategyIdleStrategyto be called when back pressure is propagated from thepublication.protected final io.aeron.cluster.codecs.MessageHeaderEncoderReusableMessageHeaderEncoderto avoid allocation.protected final ExclusivePublicationPublicationto which the snapshot will be written. -
Constructor Summary
ConstructorsConstructorDescriptionSnapshotTaker(ExclusivePublication publication, IdleStrategy idleStrategy, AgentInvoker aeronAgentInvoker) Construct aSnapshotTakerwhich will encode the snapshot to a publication. -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidCheck for thread interrupt and throw anAgentTerminationExceptionif interrupted.protected static voidcheckResult(long position, Publication publication) Check the result of offering to a publication when writing a snapshot.protected voidcheckResultAndIdle(long position) Check the result of offering to a publication when writing a snapshot and then idle after invoking the client agent if necessary.protected voidInvoke the Aeron client agent if necessary.voidmarkBegin(long snapshotTypeId, long logPosition, long leadershipTermId, int snapshotIndex, TimeUnit timeUnit, int appVersion) Mark the beginning of the encoded snapshot.voidmarkEnd(long snapshotTypeId, long logPosition, long leadershipTermId, int snapshotIndex, TimeUnit timeUnit, int appVersion) Mark the end of the encoded snapshot.voidmarkSnapshot(long snapshotTypeId, long logPosition, long leadershipTermId, int snapshotIndex, io.aeron.cluster.codecs.SnapshotMark snapshotMark, TimeUnit timeUnit, int appVersion) GenericallySnapshotMarka snapshot.protected final voidoffer(DirectBuffer buffer, int offset, int length) Helper method to offer a message into the snapshot publication.
-
Field Details
-
bufferClaim
ReusableBufferClaimto avoid allocation. -
messageHeaderEncoder
protected final io.aeron.cluster.codecs.MessageHeaderEncoder messageHeaderEncoderReusableMessageHeaderEncoderto avoid allocation. -
publication
Publicationto which the snapshot will be written. -
idleStrategy
IdleStrategyto be called when back pressure is propagated from thepublication.
-
-
Constructor Details
-
SnapshotTaker
public SnapshotTaker(ExclusivePublication publication, IdleStrategy idleStrategy, AgentInvoker aeronAgentInvoker) Construct aSnapshotTakerwhich will encode the snapshot to a publication.- Parameters:
publication- into which the snapshot will be encoded.idleStrategy- to call when the publication is back pressured.aeronAgentInvoker- to call when idling so it stays active.
-
-
Method Details
-
markBegin
public void markBegin(long snapshotTypeId, long logPosition, long leadershipTermId, int snapshotIndex, TimeUnit timeUnit, int appVersion) Mark the beginning of the encoded snapshot.- Parameters:
snapshotTypeId- type to identify snapshot within a cluster.logPosition- at which the snapshot was taken.leadershipTermId- at which the snapshot was taken.snapshotIndex- so the snapshot can be sectioned.timeUnit- of the cluster timestamps stored in the snapshot.appVersion- associated with the snapshot fromClusteredServiceContainer.Context.appVersion().
-
markEnd
public void markEnd(long snapshotTypeId, long logPosition, long leadershipTermId, int snapshotIndex, TimeUnit timeUnit, int appVersion) Mark the end of the encoded snapshot.- Parameters:
snapshotTypeId- type to identify snapshot within a cluster.logPosition- at which the snapshot was taken.leadershipTermId- at which the snapshot was taken.snapshotIndex- so the snapshot can be sectioned.timeUnit- of the cluster timestamps stored in the snapshot.appVersion- associated with the snapshot fromClusteredServiceContainer.Context.appVersion().
-
markSnapshot
public void markSnapshot(long snapshotTypeId, long logPosition, long leadershipTermId, int snapshotIndex, io.aeron.cluster.codecs.SnapshotMark snapshotMark, TimeUnit timeUnit, int appVersion) GenericallySnapshotMarka snapshot.- Parameters:
snapshotTypeId- type to identify snapshot within a cluster.logPosition- at which the snapshot was taken.leadershipTermId- at which the snapshot was taken.snapshotIndex- so the snapshot can be sectioned.snapshotMark- which specifies the type of snapshot mark.timeUnit- of the cluster timestamps stored in the snapshot.appVersion- associated with the snapshot fromClusteredServiceContainer.Context.appVersion().
-
checkInterruptStatus
protected static void checkInterruptStatus()Check for thread interrupt and throw anAgentTerminationExceptionif interrupted. -
checkResult
Check the result of offering to a publication when writing a snapshot.- Parameters:
position- of an offer or try claim to a publication.publication- on which the offer or try claim was attempted.
-
checkResultAndIdle
protected void checkResultAndIdle(long position) Check the result of offering to a publication when writing a snapshot and then idle after invoking the client agent if necessary.- Parameters:
position- of an offer or try claim to a publication.
-
invokeAgentClient
protected void invokeAgentClient()Invoke the Aeron client agent if necessary. -
offer
Helper method to offer a message into the snapshot publication.- Parameters:
buffer- containing the message.offset- at which the message begins.length- of the message.
-