public class SyncReplRequestHandler extends java.lang.Object implements ReplicationRequestHandler
| Modifier and Type | Class and Description |
|---|---|
private class |
SyncReplRequestHandler.ConsumerLogEntryChangeListener
an event listener for handling deletions and updates of replication event log entries present under ou=consumers,ou=system
|
| Modifier and Type | Field and Description |
|---|---|
private SyncReplRequestHandler.ConsumerLogEntryChangeListener |
cledListener |
private java.lang.Thread |
consumerInfoUpdateThread
thread used for updating consumer infor
|
private org.apache.directory.api.ldap.model.schema.AttributeType |
csnAT
The CSN AttributeType instance
|
private DirectoryService |
dirService
The directory service instance
|
private boolean |
initialized
Tells if the replication handler is already started
|
protected LdapServer |
ldapServer
The reference on the Ldap server instance
|
private ReplicaEventLogJanitor |
logJanitor |
private org.apache.directory.api.ldap.model.schema.AttributeType |
objectClassAT
An ObjectClass AT instance
|
private static org.slf4j.Logger |
PROVIDER_LOG
A logger for the replication provider
|
private java.util.concurrent.atomic.AtomicInteger |
replicaCount |
private java.util.Map<java.lang.Integer,ReplicaEventLog> |
replicaLogMap |
private ReplConsumerManager |
replicaUtil |
private org.apache.directory.api.ldap.model.schema.AttributeType |
replLogMaxIdleAT |
private org.apache.directory.api.ldap.model.schema.AttributeType |
replLogPurgeThresholdCountAT |
private java.io.File |
syncReplData |
| Constructor and Description |
|---|
SyncReplRequestHandler()
Create a SyncReplRequestHandler empty instance
|
| Modifier and Type | Method and Description |
|---|---|
private java.lang.Runnable |
createConsumerInfoUpdateTask(java.util.concurrent.CountDownLatch latch)
Create a thread to process replication communication with a consumer
|
private ReplicaEventLog |
createReplicaEventLog(java.lang.String hostName,
java.lang.String filter)
Create a new ReplicaEventLog.
|
private void |
doContentUpdate(LdapSession session,
org.apache.directory.api.ldap.model.message.SearchRequest req,
ReplicaEventLog replicaLog,
java.lang.String consumerCsn)
process the update of the consumer, starting from the given LastEntryCSN the consumer
has sent with the sync request.
|
private void |
doInitialRefresh(LdapSession session,
org.apache.directory.api.ldap.model.message.SearchRequest request)
Process the initial refresh : we will send all the entries
|
private org.apache.directory.api.ldap.model.message.SearchResultDone |
doSimpleSearch(LdapSession session,
org.apache.directory.api.ldap.model.message.SearchRequest req,
ReplicaEventLog replicaLog)
Process a search on the provider to get all the modified entries.
|
private org.apache.directory.api.ldap.model.message.Response |
generateResponse(LdapSession session,
org.apache.directory.api.ldap.model.message.SearchRequest req,
org.apache.directory.api.ldap.model.entry.Entry entry)
Build the response to be sent to the client
|
private java.io.File[] |
getAllReplJournalNames() |
ReplicaEventLogJanitor |
getLogJanitor() |
private ReplicaEventLog |
getReplicaEventLog(java.lang.String cookieString)
Get the Replica event log from the replica ID found in the cookie
|
java.util.Map<java.lang.Integer,ReplicaEventLog> |
getReplicaLogMap() |
private long |
getServerSizeLimit(LdapSession session,
org.apache.directory.api.ldap.model.message.SearchRequest request)
Return the server size limit
|
void |
handleSyncRequest(LdapSession session,
org.apache.directory.api.ldap.model.message.SearchRequest request)
Process the incoming search request sent by a remote server when trying to replicate.
|
private boolean |
isRefreshNPersist(org.apache.directory.api.ldap.model.message.SearchRequest req)
Tells if the control contains the REFRESHNPERSIST mode
|
private void |
loadReplicaInfo()
Read and store the consumer's informations
|
org.apache.directory.api.ldap.model.filter.ExprNode |
modifyFilter(LdapSession session,
org.apache.directory.api.ldap.model.message.SearchRequest req) |
private org.apache.directory.api.ldap.model.filter.EqualityNode<java.lang.String> |
newIsReferralEqualityNode(LdapSession session) |
private void |
readResults(LdapSession session,
org.apache.directory.api.ldap.model.message.SearchRequest req,
org.apache.directory.api.ldap.model.message.LdapResult ldapResult,
org.apache.directory.api.ldap.model.cursor.Cursor<org.apache.directory.api.ldap.model.entry.Entry> cursor,
long sizeLimit,
ReplicaEventLog replicaLog)
Process the results get from a search request.
|
private void |
registerPersistentSearches()
Register the listeners for each existing consumers
|
private void |
sendContentFromLog(LdapSession session,
org.apache.directory.api.ldap.model.message.SearchRequest req,
ReplicaEventLog clientMsgLog,
java.lang.String fromCsn)
Send all the stored modifications to the consumer
|
private void |
sendESyncRefreshRequired(LdapSession session,
org.apache.directory.api.ldap.model.message.SearchRequest req)
Send an error response to he consue r: it has to send a SYNC_REFRESH request first.
|
private void |
sendSearchResultEntry(LdapSession session,
org.apache.directory.api.ldap.model.message.SearchRequest req,
org.apache.directory.api.ldap.model.entry.Entry entry,
org.apache.directory.api.ldap.extras.controls.syncrepl.syncState.SyncStateTypeEnum syncStateType)
Prepare and send a search result entry response, with the associated
SyncState control.
|
private void |
setTimeLimitsOnCursor(org.apache.directory.api.ldap.model.message.SearchRequest req,
LdapSession session,
org.apache.directory.api.ldap.model.cursor.Cursor<org.apache.directory.api.ldap.model.entry.Entry> cursor) |
void |
start(LdapServer server)
initializes the replication provider
|
void |
stop()
stops the replication provider
|
private void |
storeReplicaInfo()
Update the consumer configuration entries if they are 'dirty' (ie, if
the consumer lastCSN is not up to date)
|
private static final org.slf4j.Logger PROVIDER_LOG
private boolean initialized
private DirectoryService dirService
protected LdapServer ldapServer
private org.apache.directory.api.ldap.model.schema.AttributeType objectClassAT
private org.apache.directory.api.ldap.model.schema.AttributeType csnAT
private java.util.Map<java.lang.Integer,ReplicaEventLog> replicaLogMap
private java.io.File syncReplData
private java.util.concurrent.atomic.AtomicInteger replicaCount
private ReplConsumerManager replicaUtil
private SyncReplRequestHandler.ConsumerLogEntryChangeListener cledListener
private ReplicaEventLogJanitor logJanitor
private org.apache.directory.api.ldap.model.schema.AttributeType replLogMaxIdleAT
private org.apache.directory.api.ldap.model.schema.AttributeType replLogPurgeThresholdCountAT
private java.lang.Thread consumerInfoUpdateThread
public SyncReplRequestHandler()
public void start(LdapServer server)
start in interface ReplicationRequestHandlerserver - the LdapServer instancepublic void stop()
stop in interface ReplicationRequestHandlerpublic void handleSyncRequest(LdapSession session, org.apache.directory.api.ldap.model.message.SearchRequest request) throws org.apache.directory.api.ldap.model.exception.LdapException
handleSyncRequest in interface ReplicationRequestHandlersession - The used LdapSession. Should be the dedicated userrequest - The search requestorg.apache.directory.api.ldap.model.exception.LdapExceptionprivate void sendContentFromLog(LdapSession session, org.apache.directory.api.ldap.model.message.SearchRequest req, ReplicaEventLog clientMsgLog, java.lang.String fromCsn) throws java.lang.Exception
java.lang.Exceptionprivate void doContentUpdate(LdapSession session, org.apache.directory.api.ldap.model.message.SearchRequest req, ReplicaEventLog replicaLog, java.lang.String consumerCsn) throws java.lang.Exception
java.lang.Exceptionprivate void doInitialRefresh(LdapSession session, org.apache.directory.api.ldap.model.message.SearchRequest request) throws java.lang.Exception
java.lang.Exceptionprivate org.apache.directory.api.ldap.model.message.SearchResultDone doSimpleSearch(LdapSession session, org.apache.directory.api.ldap.model.message.SearchRequest req, ReplicaEventLog replicaLog) throws java.lang.Exception
java.lang.Exceptionprivate void readResults(LdapSession session, org.apache.directory.api.ldap.model.message.SearchRequest req, org.apache.directory.api.ldap.model.message.LdapResult ldapResult, org.apache.directory.api.ldap.model.cursor.Cursor<org.apache.directory.api.ldap.model.entry.Entry> cursor, long sizeLimit, ReplicaEventLog replicaLog) throws java.lang.Exception
java.lang.Exceptionprivate void sendSearchResultEntry(LdapSession session, org.apache.directory.api.ldap.model.message.SearchRequest req, org.apache.directory.api.ldap.model.entry.Entry entry, org.apache.directory.api.ldap.extras.controls.syncrepl.syncState.SyncStateTypeEnum syncStateType) throws java.lang.Exception
java.lang.Exceptionprivate org.apache.directory.api.ldap.model.message.Response generateResponse(LdapSession session, org.apache.directory.api.ldap.model.message.SearchRequest req, org.apache.directory.api.ldap.model.entry.Entry entry) throws java.lang.Exception
java.lang.Exceptionprivate long getServerSizeLimit(LdapSession session, org.apache.directory.api.ldap.model.message.SearchRequest request)
private void setTimeLimitsOnCursor(org.apache.directory.api.ldap.model.message.SearchRequest req,
LdapSession session,
org.apache.directory.api.ldap.model.cursor.Cursor<org.apache.directory.api.ldap.model.entry.Entry> cursor)
public org.apache.directory.api.ldap.model.filter.ExprNode modifyFilter(LdapSession session, org.apache.directory.api.ldap.model.message.SearchRequest req) throws java.lang.Exception
java.lang.Exceptionpublic ReplicaEventLogJanitor getLogJanitor()
public java.util.Map<java.lang.Integer,ReplicaEventLog> getReplicaLogMap()
private org.apache.directory.api.ldap.model.filter.EqualityNode<java.lang.String> newIsReferralEqualityNode(LdapSession session) throws java.lang.Exception
java.lang.Exceptionprivate void storeReplicaInfo()
private void loadReplicaInfo()
private void registerPersistentSearches()
throws java.lang.Exception
java.lang.Exceptionprivate java.lang.Runnable createConsumerInfoUpdateTask(java.util.concurrent.CountDownLatch latch)
private ReplicaEventLog getReplicaEventLog(java.lang.String cookieString) throws java.lang.Exception
java.lang.Exceptionprivate ReplicaEventLog createReplicaEventLog(java.lang.String hostName, java.lang.String filter) throws java.lang.Exception
java.lang.Exceptionprivate void sendESyncRefreshRequired(LdapSession session, org.apache.directory.api.ldap.model.message.SearchRequest req) throws java.lang.Exception
java.lang.Exceptionprivate boolean isRefreshNPersist(org.apache.directory.api.ldap.model.message.SearchRequest req)
private java.io.File[] getAllReplJournalNames()