Class ChangelogState


  • @Immutable
    public final class ChangelogState
    extends Object
    This is the changelog state stored in the changelogStateDB. For each replication domain, it contains:
    • its generationId
    • the list of replicaIds composing it

    This class is used during replication initialization to decouple the code that reads the changelogStateDB from the code that makes use of its data.

    • Method Detail

      • newChangelogState

        public static ChangelogState newChangelogState​(Map<Dn,​Long> domainToGenerationId,
                                                       Set<DomainReplicaId> replicas,
                                                       Set<DomainReplicaId> replicasNotProperlyStopped)
        Builds a changelog state.
        Parameters:
        domainToGenerationId - Maps domains to their generation IDs
        replicas - All the replicas having a changelog
        replicasNotProperlyStopped - Replicas whose changelog has been purged and did not send a ReplicaOfflineMsg
        Returns:
        a new changelog state
      • setDomainGenerationId

        public ChangelogState setDomainGenerationId​(Dn baseDn,
                                                    long generationId)
        Returns a new changelog state with the generationId associated to the supplied replication domain.
        Parameters:
        baseDn - the targeted replication domain baseDN
        generationId - the generation Id to set
        Returns:
        a new changelog state
      • removeDomain

        public ChangelogState removeDomain​(Dn baseDn)
        Returns a new changelog state where supplied replication domain has been removed.
        Parameters:
        baseDn - the replication domain base DN to remove
        Returns:
        a new changelog state
      • addReplica

        public ChangelogState addReplica​(DomainReplicaId replica)
        Returns a changelog state with the specified replica added if it is not already present.
        Parameters:
        replica - the replica to add
        Returns:
        a changelog state
      • removeReplica

        public ChangelogState removeReplica​(DomainReplicaId replica)
        Returns a changelog state with the specified replica removed if it was present.
        Parameters:
        replica - the replica to remove
        Returns:
        a new changelog state
      • getDomainToGenerationId

        public Map<Dn,​Long> getDomainToGenerationId()
        Returns the Map of domainBaseDN to generationId.
        Returns:
        a Map of domainBaseDN to generationId
      • getReplicas

        public Set<DomainReplicaId> getReplicas()
        Returns all the replicas which have a dedicated replica DB.

        The returned value is an unmodifiable set of replicas. If the set of replicas known to this RS does not change, then the returned set is always the same. This ensures equality tests on the set return true very quickly in case nothing changed. The change number indexer uses this trick to avoid spending too much comparing sets of DomainReplicaIds that rarely change.

        Returns:
        all the replicas as a Set of DomainReplicaId.
      • getRemovedReplicasNotProperlyStopped

        public Set<DomainReplicaId> getRemovedReplicasNotProperlyStopped()
        Returns all the replicas whose changelog has been purged and did not send a ReplicaOfflineMsg when they stopped.
        Returns:
        all the replicas whose changelog has been purged and did not send a ReplicaOfflineMsg when they stopped