public class SyncReplSearchListener extends java.lang.Object implements DirectoryListener, org.apache.directory.api.ldap.model.message.AbandonListener
| Modifier and Type | Field and Description |
|---|---|
private ReplicaEventLog |
consumerMsgLog
The consumer configuration
|
private static org.slf4j.Logger |
LOG
Logger for this class
|
private boolean |
pushInRealTime
A flag telling if we push the response to the consumer or if we store them in a queue
|
private static java.lang.String |
replConsumerConfigDn |
private static java.lang.String |
replConsumerDn |
private static java.lang.String |
schemaDn |
private org.apache.directory.api.ldap.model.message.SearchRequest |
searchRequest
The search request we are processing
|
private LdapSession |
session
The ldap session
|
| Constructor and Description |
|---|
SyncReplSearchListener(LdapSession session,
org.apache.directory.api.ldap.model.message.SearchRequest searchRequest,
ReplicaEventLog consumerMsgLog,
boolean pushInRealTime)
Create a new instance of a consumer listener
|
| Modifier and Type | Method and Description |
|---|---|
private org.apache.directory.api.ldap.extras.controls.syncrepl.syncState.SyncStateValue |
createControl(DirectoryService directoryService,
org.apache.directory.api.ldap.extras.controls.syncrepl.syncState.SyncStateTypeEnum operation,
org.apache.directory.api.ldap.model.entry.Entry entry)
Create the SyncStateValue control
|
void |
entryAdded(AddOperationContext addContext)
Process a ADD operation.
|
void |
entryDeleted(DeleteOperationContext deleteContext)
Process a Delete operation.
|
void |
entryModified(ModifyOperationContext modifyContext)
Process a Modify operation.
|
void |
entryMoved(MoveOperationContext moveContext)
Process a Move operation.
|
void |
entryMovedAndRenamed(MoveAndRenameOperationContext moveAndRenameContext)
Process a MoveAndRename operation.
|
void |
entryRenamed(RenameOperationContext renameContext)
Process a Rename operation.
|
private byte[] |
getCookie(org.apache.directory.api.ldap.model.entry.Entry entry)
Get the cookie from the entry
|
private void |
handleWriteFuture(org.apache.mina.core.future.WriteFuture future,
org.apache.directory.api.ldap.model.entry.Entry entry,
EventType event)
Process the writing of the replicated entry to the consumer
|
private boolean |
isConfigEntry(org.apache.directory.api.ldap.model.entry.Entry entry)
checks if the given entry belongs to the ou=config or ou=schema partition
We don't replicate those two partitions
|
private boolean |
isMmrConfiguredToReceiver(AbstractChangeOperationContext ctx)
checks if the sender of this replication event is setup with MMR
(Note: this method is used to prevent sending a replicated event back to the sender after
performing local update)
|
private boolean |
isNotValidForReplication(AbstractChangeOperationContext ctx) |
boolean |
isPushInRealTime() |
boolean |
isSynchronous()
indicates if this listener needs to be invoked synchronously
|
void |
requestAbandoned(org.apache.directory.api.ldap.model.message.AbandonableRequest searchRequest)
Abandon a SearchRequest
|
private void |
sendDeletedEntry(org.apache.directory.api.ldap.model.entry.Entry entry)
A helper method, as the delete opertaionis used by the ModDN operations.
|
private void |
sendResult(org.apache.directory.api.ldap.model.message.SearchResultEntry searchResultEntry,
org.apache.directory.api.ldap.model.entry.Entry entry,
EventType eventType,
org.apache.directory.api.ldap.extras.controls.syncrepl.syncState.SyncStateValue syncStateValue)
Send the result to the consumer.
|
void |
setPushInRealTime(boolean pushInRealTime)
Set the pushInRealTime parameter
|
void |
setSearchRequest(org.apache.directory.api.ldap.model.message.SearchRequest searchRequest)
Stores the SearchRequest, and associate a AbandonListener to it
|
void |
setSession(LdapSession session)
Store the Ldap session to use
|
java.lang.String |
toString() |
private static final org.slf4j.Logger LOG
private LdapSession session
private org.apache.directory.api.ldap.model.message.SearchRequest searchRequest
private volatile boolean pushInRealTime
private final ReplicaEventLog consumerMsgLog
private static java.lang.String replConsumerConfigDn
private static java.lang.String schemaDn
private static java.lang.String replConsumerDn
SyncReplSearchListener(LdapSession session, org.apache.directory.api.ldap.model.message.SearchRequest searchRequest, ReplicaEventLog consumerMsgLog, boolean pushInRealTime)
session - The LDAP session to use for this listenersearchRequest - The searchRequest to processconsumerMsgLog - The consumer configurationpushInRealTime - Tells if we push the results to the consumer in real timepublic void setSession(LdapSession session)
session - The Ldap Session to usepublic void setSearchRequest(org.apache.directory.api.ldap.model.message.SearchRequest searchRequest)
searchRequest - The SearchRequest instance to storepublic boolean isSynchronous()
DirectoryListenerisSynchronous in interface DirectoryListenerpublic void requestAbandoned(org.apache.directory.api.ldap.model.message.AbandonableRequest searchRequest)
requestAbandoned in interface org.apache.directory.api.ldap.model.message.AbandonListenersearchRequest - The SearchRequest to abandonprivate org.apache.directory.api.ldap.extras.controls.syncrepl.syncState.SyncStateValue createControl(DirectoryService directoryService, org.apache.directory.api.ldap.extras.controls.syncrepl.syncState.SyncStateTypeEnum operation, org.apache.directory.api.ldap.model.entry.Entry entry) throws org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException
org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueExceptionprivate void sendResult(org.apache.directory.api.ldap.model.message.SearchResultEntry searchResultEntry,
org.apache.directory.api.ldap.model.entry.Entry entry,
EventType eventType,
org.apache.directory.api.ldap.extras.controls.syncrepl.syncState.SyncStateValue syncStateValue)
public void entryAdded(AddOperationContext addContext)
entryAdded in interface DirectoryListeneraddContext - The Addition operation contextpublic void entryDeleted(DeleteOperationContext deleteContext)
entryDeleted in interface DirectoryListenerdeleteContext - The delete operation contextprivate void sendDeletedEntry(org.apache.directory.api.ldap.model.entry.Entry entry)
public void entryModified(ModifyOperationContext modifyContext)
entryModified in interface DirectoryListenermodifyContext - The modify operation contextpublic void entryMoved(MoveOperationContext moveContext)
entryMoved in interface DirectoryListenermoveContext - The move operation contextpublic void entryMovedAndRenamed(MoveAndRenameOperationContext moveAndRenameContext)
entryMovedAndRenamed in interface DirectoryListenermoveAndRenameContext - The move and rename operation contextpublic void entryRenamed(RenameOperationContext renameContext)
entryRenamed in interface DirectoryListenerrenameContext - The rename operation contextpublic boolean isPushInRealTime()
public void setPushInRealTime(boolean pushInRealTime)
pushInRealTime - true if the entries must be push to the consumer directlyprivate byte[] getCookie(org.apache.directory.api.ldap.model.entry.Entry entry)
throws org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException
org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueExceptionprivate void handleWriteFuture(org.apache.mina.core.future.WriteFuture future,
org.apache.directory.api.ldap.model.entry.Entry entry,
EventType event)
private boolean isConfigEntry(org.apache.directory.api.ldap.model.entry.Entry entry)
entry - the entryprivate boolean isNotValidForReplication(AbstractChangeOperationContext ctx)
private boolean isMmrConfiguredToReceiver(AbstractChangeOperationContext ctx)
ctx - the operation's contextpublic java.lang.String toString()
toString in class java.lang.Object