Class ReplicaClient
java.lang.Object
org.forgerock.opendj.server.leaderbasedreplication.ReplicaClient
- All Implemented Interfaces:
Closeable, AutoCloseable, ConfigurationChangeListener<LeaderBasedReplicationSynchronizationProviderCfg>
public final class ReplicaClient
extends Object
implements ConfigurationChangeListener<LeaderBasedReplicationSynchronizationProviderCfg>, Closeable
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()
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRepresents information that a replica must provide to register to the core regularly. -
Constructor Summary
ConstructorsConstructorDescriptionReplicaClient(LeaderBasedReplicationSynchronizationProviderCfg replicationCfg, ServerContext serverContext) Constructs a new `ReplicaClient` instance. -
Method Summary
Modifier and TypeMethodDescriptionApplies the configuration changes to this change listener.voidclose()Closes all active connections opened by this client with remote replicas.fetchChangesFromReplica(ReplicaId localReplicaId, Connection replicaConnection, Map<Domain, ReplicaState> changelogState, SearchResultHandler searchResultHandler, String logContext) Fetches changes from a remote replica.fetchChangesFromReplica(ReplicaId localReplicaId, ReplicaId peerReplicaId, com.forgerock.opendj.util.HostPort peerHostPort, Map<Domain, ReplicaState> changelogState, SearchResultHandler searchResultHandler, String logContext) Fetches changes from a remote replica.Fetches the topology from the core.booleanisConfigurationChangeAcceptable(LeaderBasedReplicationSynchronizationProviderCfg configuration, List<LocalizableMessage> unacceptableReasons) Indicates whether the proposed change to the configuration is acceptable to this change listener.static voidlogChangelogEntry(SearchResultEntry searchResultEntry, String logContext) Logs the provided changelog entry.Registers a replica to the core.
-
Constructor Details
-
ReplicaClient
public ReplicaClient(LeaderBasedReplicationSynchronizationProviderCfg replicationCfg, ServerContext serverContext) throws ConfigException Constructs a new `ReplicaClient` instance.- Parameters:
replicationCfg- the configuration for the synchronization provider.serverContext- the server context.- Throws:
ConfigException- if an error occurs while initializing the LDAP connection options.
-
-
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 idpeerReplicaId- the replica id to fetch changes frompeerHostPort- the address of the replica to fetch changes fromchangelogState- the state of the changelog by domainsearchResultHandler- the handler to process the search resultslogContext- 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 idreplicaConnection- the connection to the replicachangelogState- the state of the changelog by domainsearchResultHandler- the handler to process the search resultslogContext- 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
public RegistrationToCoreExtendedResult registerToCore(ReplicaClient.RegistrationToCoreRequest request) throws LdapException 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
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:ConfigurationChangeListenerIndicates whether the proposed change to the configuration is acceptable to this change listener.- Specified by:
isConfigurationChangeAcceptablein interfaceConfigurationChangeListener<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
trueif the proposed change is acceptable, orfalseif it is not.
-
applyConfigurationChange
public ConfigChangeResult applyConfigurationChange(LeaderBasedReplicationSynchronizationProviderCfg newConfig) Description copied from interface:ConfigurationChangeListenerApplies the configuration changes to this change listener.- Specified by:
applyConfigurationChangein interfaceConfigurationChangeListener<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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
logChangelogEntry
Logs the provided changelog entry.- Parameters:
searchResultEntry- the changelog entrylogContext- provides context for logging (originator of the request)
-