Interface ReplicationDomainDB

  • All Known Implementing Classes:
    FileChangelogDB

    public interface ReplicationDomainDB
    This interface allows to query or control the replication domain database(s) (composed of one or more ReplicaDBs) and query/update each ReplicaDB.

    In particular, the getCursorFom() methods allow to obtain a cursor at any level:

    • Across all the domains, provided a MultiDomainServerState
    • Across all replicaDBs of a domain, provided a ServerState
    • On one replica DB for a domain and serverId, provided a CSN
    The cursor starting point is specified by providing a key, a DBCursor.KeyMatchingStrategy and a DBCursor.PositionStrategy.
    • Method Detail

      • getDomainOldestCSNs

        ServerState getDomainOldestCSNs​(DN baseDN)
        Returns the oldest CSNs from the replicaDBs for each serverId in the specified replication domain.
        Parameters:
        baseDN - the replication domain baseDN
        Returns:
        a new ServerState object holding the {serverId => oldest CSN} mapping. If a replica DB is empty or closed, the oldest CSN will be null for that replica. The caller owns the generated ServerState.
      • getDomainNewestCSNs

        ServerState getDomainNewestCSNs​(DN baseDN)
        Returns the newest CSNs from the replicaDBs for each serverId in the specified replication domain.
        Parameters:
        baseDN - the replication domain baseDN
        Returns:
        a new ServerState object holding the {serverId => newest CSN} Map. If a replica DB is empty or closed, the newest CSN will be null for that replica. The caller owns the generated ServerState.
      • removeDomain

        void removeDomain​(DN baseDN)
                   throws ChangelogException
        Removes all the data relating to the specified replication domain and shutdown all its replica databases. In particular, it will:
        1. remove all the changes from the replica databases
        2. remove all knowledge of the serverIds in this domain
        3. remove any knowledge of the current generationId for this domain
        Parameters:
        baseDN - the replication domain baseDN
        Throws:
        ChangelogException - If a database problem happened
      • getCursorFrom

        DBCursor<UpdateMsg> getCursorFrom​(DN baseDN,
                                          ServerState startState,
                                          DBCursor.CursorOptions options)
                                   throws ChangelogException
        Generates a DBCursor across all the replicaDBs for the specified replication domain starting before, at or after the provided ServerState for each replicaDB, depending on the provided matching and positioning strategies.

        When the cursor is not used anymore, client code MUST call the DBCursor.close() method to free the resources and locks used by the cursor.

        Parameters:
        baseDN - the replication domain baseDN
        startState - Starting point for each ReplicaDB cursor. If any CSN for a replicaDB is null, then start from the oldest CSN for this replicaDB
        options - The cursor options
        Returns:
        a non null DBCursor
        Throws:
        ChangelogException - If a database problem happened
        See Also:
        getCursorFrom(DN, int, CSN, CursorOptions)
      • getCursorFrom

        DBCursor<UpdateMsg> getCursorFrom​(DN baseDN,
                                          int serverId,
                                          CSN startCSN,
                                          DBCursor.CursorOptions options)
                                   throws ChangelogException
        Generates a DBCursor for one replicaDB for the specified replication domain and serverId starting before, at or after the provided CSN, depending on the provided matching and positioning strategies.

        When the cursor is not used anymore, client code MUST call the DBCursor.close() method to free the resources and locks used by the cursor.

        Parameters:
        baseDN - the replication domain baseDN of the replicaDB
        serverId - the serverId of the replicaDB
        startCSN - Starting point for the ReplicaDB cursor. If the CSN is null, then start from the oldest CSN for this replicaDB
        options - The cursor options
        Returns:
        a non null DBCursor
        Throws:
        ChangelogException - If a database problem happened
      • unregisterCursor

        void unregisterCursor​(DBCursor<?> cursor)
        Unregisters the provided cursor from this replication domain.
        Parameters:
        cursor - the cursor to unregister.
      • publishUpdateMsg

        boolean publishUpdateMsg​(DN baseDN,
                                 UpdateMsg updateMsg)
                          throws ChangelogException
        Publishes the provided change to the changelog DB for the specified serverId and replication domain. After a change has been successfully published, it becomes available to be returned by the External ChangeLog.
        Parameters:
        baseDN - the replication domain baseDN
        updateMsg - the update message to publish to the replicaDB
        Returns:
        true if a db had to be created to publish this message
        Throws:
        ChangelogException - If a database problem happened
      • replicaHeartbeat

        void replicaHeartbeat​(DN baseDN,
                              CSN heartbeatCSN)
                       throws ChangelogException
        Let the DB know this replica is alive.

        This method allows the medium consistency point to move forward in case this replica did not publish new changes.

        Parameters:
        baseDN - the replication domain baseDN
        heartbeatCSN - The CSN heartbeat sent by this replica (contains the serverId and timestamp of the heartbeat)
        Throws:
        ChangelogException - If a database problem happened
      • notifyReplicaOffline

        void notifyReplicaOffline​(DN baseDN,
                                  CSN offlineCSN)
                           throws ChangelogException
        Let the DB know this replica is going down.

        This method allows to let the medium consistency point move forward while this replica is offline.

        Note: This method must not be called to let the DB know the replica is not sending heartbeats anymore, i.e. it must not be used in case of suspected network partition.

        Parameters:
        baseDN - the replication domain baseDN
        offlineCSN - The CSN (serverId and timestamp) for the replica's going offline
        Throws:
        ChangelogException - If a database problem happened