Class SnapshotTaker

java.lang.Object
io.aeron.cluster.service.SnapshotTaker

public class SnapshotTaker extends Object
Base class of common functions required to take a snapshot of cluster state.
  • Field Details

    • bufferClaim

      protected final BufferClaim bufferClaim
      Reusable BufferClaim to avoid allocation.
    • messageHeaderEncoder

      protected final io.aeron.cluster.codecs.MessageHeaderEncoder messageHeaderEncoder
      Reusable MessageHeaderEncoder to avoid allocation.
    • publication

      protected final ExclusivePublication publication
      Publication to which the snapshot will be written.
    • idleStrategy

      protected final IdleStrategy idleStrategy
      IdleStrategy to be called when back pressure is propagated from the publication.
  • Constructor Details

    • SnapshotTaker

      public SnapshotTaker(ExclusivePublication publication, IdleStrategy idleStrategy, AgentInvoker aeronAgentInvoker)
      Construct a SnapshotTaker which 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 from ClusteredServiceContainer.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 from ClusteredServiceContainer.Context.appVersion().
    • markSnapshot

      public void markSnapshot(long snapshotTypeId, long logPosition, long leadershipTermId, int snapshotIndex, io.aeron.cluster.codecs.SnapshotMark snapshotMark, TimeUnit timeUnit, int appVersion)
      Generically SnapshotMark a 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 from ClusteredServiceContainer.Context.appVersion().
    • checkInterruptStatus

      protected static void checkInterruptStatus()
      Check for thread interrupt and throw an AgentTerminationException if interrupted.
    • checkResult

      protected static void checkResult(long position, Publication publication)
      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

      protected final void offer(DirectBuffer buffer, int offset, int length)
      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.