Class ReplicaClient

java.lang.Object
org.forgerock.opendj.server.leaderbasedreplication.ReplicaClient
All Implemented Interfaces:
Closeable, AutoCloseable, ConfigurationChangeListener<LeaderBasedReplicationSynchronizationProviderCfg>

Represents a client that interacts with a remote replica, either regular or providing the Core feature.

Three operations are provided:

  • Fetch changes from a replica: fetchChangesFromReplica()
  • Register to the core: registerToCore()
  • Fetch the topology from the core: ReplicaClient#fetchTopologyFromCore()
  • Constructor Details

  • Method Details

    • fetchChangesFromReplica

      public Result fetchChangesFromReplica(ReplicaId localReplicaId, ReplicaId peerReplicaId, com.forgerock.opendj.util.HostPort peerHostPort, Map<Domain, ReplicaState> changelogState, SearchResultHandler searchResultHandler, String logContext) throws LdapException
      Fetches changes from a remote replica.
      Parameters:
      localReplicaId - the replica id
      peerReplicaId - the replica id to fetch changes from
      peerHostPort - the address of the replica to fetch changes from
      changelogState - the state of the changelog by domain
      searchResultHandler - the handler to process the search results
      logContext - provides context for logging (originator of the request)
      Returns:
      the result of the search
      Throws:
      LdapException - if an error occurs while fetching the changes
    • fetchChangesFromReplica

      public Result fetchChangesFromReplica(ReplicaId localReplicaId, Connection replicaConnection, Map<Domain, ReplicaState> changelogState, SearchResultHandler searchResultHandler, String logContext) throws LdapException
      Fetches changes from a remote replica.
      Parameters:
      localReplicaId - the replica id
      replicaConnection - the connection to the replica
      changelogState - the state of the changelog by domain
      searchResultHandler - the handler to process the search results
      logContext - provides context for logging (originator of the request)
      Returns:
      the result of the search
      Throws:
      LdapException - if an error occurs while fetching the changes
    • registerToCore

      Registers a replica to the core.
      Parameters:
      request - the registration request from the replica
      Returns:
      the response from the core
      Throws:
      LdapException - if an error occurs while registering to the core
    • fetchTopologyFromCore

      public Topology fetchTopologyFromCore() throws LdapException
      Fetches the topology from the core.
      Returns:
      the topology
      Throws:
      LdapException - if an error occurs while fetching the topology
    • isConfigurationChangeAcceptable

      public boolean isConfigurationChangeAcceptable(LeaderBasedReplicationSynchronizationProviderCfg configuration, List<LocalizableMessage> unacceptableReasons)
      Description copied from interface: ConfigurationChangeListener
      Indicates whether the proposed change to the configuration is acceptable to this change listener.
      Specified by:
      isConfigurationChangeAcceptable in interface ConfigurationChangeListener<LeaderBasedReplicationSynchronizationProviderCfg>
      Parameters:
      configuration - The new configuration containing the changes.
      unacceptableReasons - A list that can be used to hold messages about why the provided configuration is not acceptable.
      Returns:
      Returns true if the proposed change is acceptable, or false if it is not.
    • applyConfigurationChange

      public ConfigChangeResult applyConfigurationChange(LeaderBasedReplicationSynchronizationProviderCfg newConfig)
      Description copied from interface: ConfigurationChangeListener
      Applies the configuration changes to this change listener.
      Specified by:
      applyConfigurationChange in interface ConfigurationChangeListener<LeaderBasedReplicationSynchronizationProviderCfg>
      Parameters:
      newConfig - The new configuration containing the changes.
      Returns:
      Returns information about the result of changing the configuration.
    • close

      public void close()
      Closes all active connections opened by this client with remote replicas.

      This method must be called once this `ReplicaClient` is no longer used to release resources.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • logChangelogEntry

      public static void logChangelogEntry(SearchResultEntry searchResultEntry, String logContext)
      Logs the provided changelog entry.
      Parameters:
      searchResultEntry - the changelog entry
      logContext - provides context for logging (originator of the request)