public class ReplicationConsumerImpl extends java.lang.Object implements org.apache.directory.ldap.client.api.ConnectionClosedEventListener, ReplicationConsumer
| Modifier and Type | Field and Description |
|---|---|
private org.apache.directory.api.ldap.model.schema.AttributeType |
adsDsReplicaIdAT |
private org.apache.directory.api.ldap.model.schema.AttributeType |
adsReplCookieAT
AttributeTypes used for replication
|
private SyncReplConfiguration |
config
the syncrepl configuration
|
private org.apache.directory.ldap.client.api.LdapNetworkConnection |
connection
connection to the syncrepl provider
|
private static org.slf4j.Logger |
CONSUMER_LOG
A dedicated logger for the consumer
|
private org.apache.directory.api.ldap.model.entry.Modification |
cookieMod |
private DirectoryService |
directoryService
a reference to the directoryService
|
private boolean |
disconnected
flag to indicate whether the consumer was disconnected
|
private static org.apache.directory.api.ldap.model.filter.PresenceNode |
ENTRY_UUID_PRESENCE_FILTER
The (entrtyUuid=*) filter
|
private byte[] |
lastSavedCookie
the cookie that was saved last time
|
private static java.lang.String[] |
MOD_IGNORE_AT
attributes on which modification should be ignored
|
private boolean |
reload |
private org.apache.directory.api.ldap.model.entry.Modification |
ridMod |
private org.apache.directory.api.ldap.model.schema.SchemaManager |
schemaManager
the schema manager
|
private org.apache.directory.api.ldap.model.message.SearchRequest |
searchRequest
the search request with control
|
private CoreSession |
session
the core session
|
private byte[] |
syncCookie
the sync cookie sent by the server
|
private static java.util.Map<java.lang.String,java.lang.Object> |
UUID_LOCK_MAP |
DIFFERED, NOW| Constructor and Description |
|---|
ReplicationConsumerImpl() |
| Modifier and Type | Method and Description |
|---|---|
private void |
applyModDnOperation(org.apache.directory.api.ldap.model.entry.Entry remoteEntry,
java.lang.String entryUuid,
int rid) |
private java.lang.String[] |
computeAttributes(java.lang.String[] attributes,
java.lang.String addedAttribute)
Create a new list combining a list and a newly added attribute
|
boolean |
connect()
Connect to the remote server.
|
boolean |
connect(boolean now)
Connect the consumer, connection immediately or wait before reconnection
|
void |
connectionClosed() |
private void |
deleteEntries(java.util.List<byte[]> uuidList,
boolean isRefreshPresent,
int replicaId)
deletes the entries having the UUID given in the list
|
private void |
deleteRecursive(org.apache.directory.api.ldap.model.name.Dn rootDn,
int rid)
removes all child entries present under the given Dn and finally the Dn itself
|
private void |
disconnect()
Disconnect from the producer
|
private ReplicationStatusEnum |
doRefreshOnly() |
private ReplicationStatusEnum |
doSyncSearch(org.apache.directory.api.ldap.extras.controls.SynchronizationModeEnum syncType,
boolean reloadHint)
Performs a search on connection with updated syncRequest control.
|
SyncReplConfiguration |
getConfig() |
java.lang.String |
getId() |
private java.lang.Object |
getLockFor(java.lang.String uuid) |
private void |
handleSearchReference(org.apache.directory.api.ldap.model.message.SearchResultReference searchRef) |
private org.apache.directory.api.ldap.model.message.ResultCodeEnum |
handleSearchResultDone(org.apache.directory.api.ldap.model.message.SearchResultDone searchDone) |
private void |
handleSearchResultEntry(org.apache.directory.api.ldap.model.message.SearchResultEntry syncResult)
Process a SearchResultEntry received from a consumer.
|
private void |
handleSyncInfo(org.apache.directory.api.ldap.model.message.IntermediateResponse syncInfoResp) |
void |
init(DirectoryService directoryservice)
Init the replication service
|
private void |
modify(org.apache.directory.api.ldap.model.entry.Entry remoteEntry,
int rid) |
void |
ping()
Test the connection with the provider.
|
private void |
prepareSyncSearchRequest()
prepares a SearchRequest for syncing DIT content.
|
private void |
processDelete(java.util.List<byte[]> limitedUuidList,
boolean isRefreshPresent,
int replicaId)
do not call this method directly, instead call deleteEntries()
|
private void |
readCookie()
Read the cookie for a consumer
|
private void |
removeCookie()
deletes the cookie and resets the syncCookie to null
|
void |
setConfig(ReplicationConsumerConfig config)
Sets the configuration of the consumer
|
ReplicationStatusEnum |
startSync()
Starts the synchronization operation
|
void |
stop()
Stops the consumer
|
private void |
storeCookie()
stores the cookie.
|
java.lang.String |
toString() |
private static final org.slf4j.Logger CONSUMER_LOG
private SyncReplConfiguration config
private byte[] syncCookie
private org.apache.directory.ldap.client.api.LdapNetworkConnection connection
private org.apache.directory.api.ldap.model.message.SearchRequest searchRequest
private DirectoryService directoryService
private org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager
private volatile boolean disconnected
private CoreSession session
private static final java.lang.String[] MOD_IGNORE_AT
private byte[] lastSavedCookie
private volatile boolean reload
private static final org.apache.directory.api.ldap.model.filter.PresenceNode ENTRY_UUID_PRESENCE_FILTER
private org.apache.directory.api.ldap.model.entry.Modification cookieMod
private org.apache.directory.api.ldap.model.entry.Modification ridMod
private org.apache.directory.api.ldap.model.schema.AttributeType adsReplCookieAT
private org.apache.directory.api.ldap.model.schema.AttributeType adsDsReplicaIdAT
private static final java.util.Map<java.lang.String,java.lang.Object> UUID_LOCK_MAP
public SyncReplConfiguration getConfig()
getConfig in interface ReplicationConsumerpublic void init(DirectoryService directoryservice) throws java.lang.Exception
init in interface ReplicationConsumerdirectoryservice - The directory servicejava.lang.Exception - If the initialization failedpublic boolean connect()
private void prepareSyncSearchRequest()
throws org.apache.directory.api.ldap.model.exception.LdapException
org.apache.directory.api.ldap.model.exception.LdapExceptionprivate org.apache.directory.api.ldap.model.message.ResultCodeEnum handleSearchResultDone(org.apache.directory.api.ldap.model.message.SearchResultDone searchDone)
private void handleSearchReference(org.apache.directory.api.ldap.model.message.SearchResultReference searchRef)
private void handleSearchResultEntry(org.apache.directory.api.ldap.model.message.SearchResultEntry syncResult)
syncResult - private void handleSyncInfo(org.apache.directory.api.ldap.model.message.IntermediateResponse syncInfoResp)
public void connectionClosed()
connectionClosed in interface org.apache.directory.ldap.client.api.ConnectionClosedEventListenerpublic ReplicationStatusEnum startSync()
startSync in interface ReplicationConsumerprivate ReplicationStatusEnum doRefreshOnly()
public void setConfig(ReplicationConsumerConfig config)
setConfig in interface ReplicationConsumerconfig - the configuration of the consumerpublic boolean connect(boolean now)
connect in interface ReplicationConsumernow - A param that tells the consumer to connect immediately or notpublic void ping()
ping in interface ReplicationConsumerpublic void stop()
stop in interface ReplicationConsumerpublic java.lang.String getId()
getId in interface ReplicationConsumerprivate ReplicationStatusEnum doSyncSearch(org.apache.directory.api.ldap.extras.controls.SynchronizationModeEnum syncType, boolean reloadHint) throws java.lang.Exception
syncType - The synchornization type, either REFRESH_ONLY or REFRESH_AND_PERSISTreloadHint - A flag used to tell the server that we want a reloadjava.lang.Exception - in case of any problems encountered while searchingprivate void disconnect()
private void storeCookie()
private void readCookie()
private void removeCookie()
private void applyModDnOperation(org.apache.directory.api.ldap.model.entry.Entry remoteEntry,
java.lang.String entryUuid,
int rid)
throws java.lang.Exception
java.lang.Exceptionprivate void modify(org.apache.directory.api.ldap.model.entry.Entry remoteEntry,
int rid)
throws java.lang.Exception
java.lang.Exceptionprivate java.lang.String[] computeAttributes(java.lang.String[] attributes,
java.lang.String addedAttribute)
private void deleteEntries(java.util.List<byte[]> uuidList,
boolean isRefreshPresent,
int replicaId)
throws java.lang.Exception
uuidList - the list of UUIDsreplicaId - TODOjava.lang.Exception - in case of any problems while deleting the entriesprivate void processDelete(java.util.List<byte[]> limitedUuidList,
boolean isRefreshPresent,
int replicaId)
throws java.lang.Exception
limitedUuidList - a list of UUIDs whose size is less than or equal to #NODE_LIMIT (node limit applies only for refreshDeletes list)isRefreshPresent - a flag indicating the type of entries present in the UUID listreplicaId - TODOjava.lang.Exceptionprivate java.lang.Object getLockFor(java.lang.String uuid)
private void deleteRecursive(org.apache.directory.api.ldap.model.name.Dn rootDn,
int rid)
throws java.lang.Exception
rootDn - the Dn which will be removed after removing its childrenrid - the replica IDjava.lang.Exception - If the Dn is not valid or if the deletion failedpublic java.lang.String toString()
toString in class java.lang.ObjectObject.toString()