Class ReplicatedDomain

java.lang.Object
org.forgerock.opendj.server.leaderbasedreplication.ReplicatedDomain

public abstract class ReplicatedDomain extends Object
Represents a replicated domain.

The replicated domain is identified by its base DN. It maintains a data state that provides details about the current state of the data in this domain, and also a status that indicates its capacity to reach consistency with the topology.

The status is computed based on whether the local changelog or the topology combined changelog, as known by the consistent core, contain the changes required to cover the data state. If they do not, the status is set to Topology.RegisteredStatus.TOO_OLD.

When start() is called, it starts periodically registering to the consistent core to update this domain status, and so that the consistent core can compute the SCP and PP by taking into account the state of this domain. It also starts fetching and applying changes for this domain from the changelog based on the data state, specifically all changes that are newer than the current state.

  • Field Details

    • baseDn

      protected final Dn baseDn
      The domain base DN.
    • domain

      protected final Domain domain
      The domain.
    • dataState

      protected ReplicaState dataState
      The domain data state.
    • replicaId

      protected final ReplicaId replicaId
      The replica ID.
    • location

      protected Topology.Location location
      The location of the replica, used for registration to the consistent core.
    • status

      protected volatile Topology.RegisteredStatus status
      The status of the domain, indicating its capacity to reach consistency with the topology.
    • serverContext

      protected final ServerContext serverContext
      The server context.
    • executor

      protected ExecutorService executor
      The executor service used to fetch changes from the changelog.
  • Constructor Details

    • ReplicatedDomain

      protected ReplicatedDomain(Dn baseDn, ServerContext serverContext)
      Creates a new replicated domain.
      Parameters:
      baseDn - the base DN of the domain
      serverContext - the server context
  • Method Details

    • getDomain

      public Domain getDomain()
      Returns the domain.
      Returns:
      the domain
    • getStatus

      public Topology.RegisteredStatus getStatus()
      Returns the status of this domain.
      Returns:
      the status of this domain
    • getStreamSeqNumGen

      public CSNGenerator.StreamSequenceNumberGenerator getStreamSeqNumGen()
      Returns the CSN generator of this domain.
      Returns:
      the CSN generator of this domain
    • getReplicaState

      public ReplicaState getReplicaState()
      Returns the data state of this replica for this domain.
      Returns:
      the data state of this replica for this domain
    • updateReplicaState

      public void updateReplicaState(CSN csn)
      Update the data state with the given CSN.
      Parameters:
      csn - the update CSN
    • purgeDataState

      protected void purgeDataState(CSN purgeCsn)
      Purge the data state by deleting streams (excepting the newest for each replica) which have an older CSN than the provided CSN.
      Parameters:
      purgeCsn - the CSN to purge from
    • fetchChangelogAndReplayChanges

      public abstract void fetchChangelogAndReplayChanges()
      Fetches and applies changes for this domain from the changelog based on the data state, specifically all changes that are newer than the current state.
    • registerToConsistentCore

      public abstract void registerToConsistentCore()
      Registers to the consistent core to update this domain status, and so that the consistent core can advance the SCP and PP by taking into account the state of this replica.
    • isTooOldForLocalChangelog

      protected abstract boolean isTooOldForLocalChangelog()
      Returns true if the local changelog does not contain the changes required to cover the data state.
      Returns:
      true if the local changelog does not contain the changes required to cover the data state
    • start

      public void start()
      Start the replicated domain.

      This method starts registering to the consistent core, and fetching and applying this domain changes from the changelog based on the data state, specifically the changes that are newer than the current state.

    • stop

      public void stop()
      Stop the replicated domain. This method stops fetching changes from the changelog.
    • shutdown

      public void shutdown()
      Shutdown the replicated domain.
    • persistDataState

      protected void persistDataState()
      Persist the data state.