org.apache.directory.server.ldap.replication.provider
Class ReplicaEventLog

java.lang.Object
  extended by org.apache.directory.server.ldap.replication.provider.ReplicaEventLog
All Implemented Interfaces:
Comparable<ReplicaEventLog>

public class ReplicaEventLog
extends Object
implements Comparable<ReplicaEventLog>

A structure storing the configuration on each consumer registered on a producer. It stores the following informations :

A separate log is maintained for each syncrepl consumer.
We also associate a Queue with each structure, which will store the messages to send to the consumer.

Author:
Apache Directory Project

Field Summary
static int DEFAULT_MAX_IDLE_PERIOD
           
static int DEFAULT_PURGE_THRESHOLD_COUNT
           
static String REPLICA_EVENT_LOG_NAME_PREFIX
           
 
Constructor Summary
ReplicaEventLog(org.apache.directory.server.core.api.DirectoryService directoryService, int replicaId)
          Creates a new instance of EventLog for a replica
 
Method Summary
 int compareTo(ReplicaEventLog o)
          
 int count()
           
 boolean equals(Object obj)
          
 org.apache.directory.api.ldap.model.name.Dn getConsumerEntryDn()
           
 ReplicaJournalCursor getCursor(String consumerCsn)
           
 String getHostName()
           
 int getId()
           
 String getLastSentCsn()
           
 long getMaxIdlePeriod()
           
 String getName()
           
 SyncReplSearchListener getPersistentListener()
           
 int getPurgeThresholdCount()
           
 String getQueueName()
           
 org.apache.directory.server.core.api.event.NotificationCriteria getSearchCriteria()
           
 String getSearchFilter()
           
 int hashCode()
          
 boolean isDirty()
           
 boolean isRefreshNPersist()
           
 void log(ReplicaEventMessage message)
          Stores the given message in the queue
 void recreate()
          Re-create the queue
 void setConsumerEntryDn(org.apache.directory.api.ldap.model.name.Dn consumerEntryDn)
           
 void setDirty(boolean dirty)
          Set the dirty flag
 void setHostName(String hostName)
          Set the consumer hostname
 void setLastSentCsn(String lastSentCsn)
          Update the last Sent CSN.
 void setMaxIdlePeriod(long maxIdlePeriod)
           
 void setPersistentListener(SyncReplSearchListener persistentListener)
          Set the listener
 void setPurgeThresholdCount(int purgeThresholdCount)
           
 void setRefreshNPersist(boolean refreshNPersist)
           
 void setSearchCriteria(org.apache.directory.server.core.api.event.NotificationCriteria searchCriteria)
          Stores the search criteria
 void setSearchFilter(String searchFilter)
          Set the searchFilter
 void stop()
          Stop the EventLog
 String toString()
           
 void truncate()
          Deletes the queue (to remove the log) and recreates a new queue instance with the same queue name.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

REPLICA_EVENT_LOG_NAME_PREFIX

public static final String REPLICA_EVENT_LOG_NAME_PREFIX
See Also:
Constant Field Values

DEFAULT_PURGE_THRESHOLD_COUNT

public static final int DEFAULT_PURGE_THRESHOLD_COUNT
See Also:
Constant Field Values

DEFAULT_MAX_IDLE_PERIOD

public static final int DEFAULT_MAX_IDLE_PERIOD
See Also:
Constant Field Values
Constructor Detail

ReplicaEventLog

public ReplicaEventLog(org.apache.directory.server.core.api.DirectoryService directoryService,
                       int replicaId)
                throws IOException
Creates a new instance of EventLog for a replica

Parameters:
directoryService - The DirectoryService instance
replicaId - The replica ID
Throws:
IOException
Method Detail

log

public void log(ReplicaEventMessage message)
Stores the given message in the queue

Parameters:
message - The message to store

truncate

public void truncate()
              throws Exception
Deletes the queue (to remove the log) and recreates a new queue instance with the same queue name. Also creates the corresponding message producer

Throws:
Exception - If the queue can't be deleted

recreate

public void recreate()
              throws Exception
Re-create the queue

Throws:
Exception - If the creation has failed

stop

public void stop()
          throws Exception
Stop the EventLog

Throws:
Exception - If the stop failed

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

compareTo

public int compareTo(ReplicaEventLog o)

Specified by:
compareTo in interface Comparable<ReplicaEventLog>

getPersistentListener

public SyncReplSearchListener getPersistentListener()
Returns:
The listener

setPersistentListener

public void setPersistentListener(SyncReplSearchListener persistentListener)
Set the listener

Parameters:
persistentListener - The listener

getSearchCriteria

public org.apache.directory.server.core.api.event.NotificationCriteria getSearchCriteria()
Returns:
The search criteria

setSearchCriteria

public void setSearchCriteria(org.apache.directory.server.core.api.event.NotificationCriteria searchCriteria)
Stores the search criteria

Parameters:
searchCriteria - The search criteria

isRefreshNPersist

public boolean isRefreshNPersist()
Returns:
true if the consumer is in Refresh And Persist mode

setRefreshNPersist

public void setRefreshNPersist(boolean refreshNPersist)
Parameters:
refreshNPersist - if true, set the EventLog in Refresh and Persist mode

getId

public int getId()
Returns:
The replica ID

getLastSentCsn

public String getLastSentCsn()
Returns:
The last CSN sent by the consumer

setLastSentCsn

public void setLastSentCsn(String lastSentCsn)
Update the last Sent CSN. If it's different from the present one, we will set the dirty flag to true, and it will be stored in DIT.

Parameters:
lastSentCsn - The new Sent CSN

getHostName

public String getHostName()
Returns:
The consumer Hostname

setHostName

public void setHostName(String hostName)
Set the consumer hostname

Parameters:
hostName - The consumer hostname

getSearchFilter

public String getSearchFilter()
Returns:
The searchFilter

setSearchFilter

public void setSearchFilter(String searchFilter)
Set the searchFilter

Parameters:
searchFilter - The searchFilter

isDirty

public boolean isDirty()
Returns:
True if the consumer is not up to date

setDirty

public void setDirty(boolean dirty)
Set the dirty flag

Parameters:
dirty - The current consumer status

getQueueName

public String getQueueName()
Returns:
The queue name

getCursor

public ReplicaJournalCursor getCursor(String consumerCsn)
                               throws Exception
Parameters:
consumerCsn - the consumer's CSN extracted from cookie
Returns:
A cursor on top of the queue
Throws:
Exception - If the cursor can't be created

getName

public String getName()
Returns:
the name of this replica log

count

public int count()
Returns:
the number of entries present in the replica log

getMaxIdlePeriod

public long getMaxIdlePeriod()

setMaxIdlePeriod

public void setMaxIdlePeriod(long maxIdlePeriod)

getPurgeThresholdCount

public int getPurgeThresholdCount()

setPurgeThresholdCount

public void setPurgeThresholdCount(int purgeThresholdCount)

getConsumerEntryDn

public org.apache.directory.api.ldap.model.name.Dn getConsumerEntryDn()

setConsumerEntryDn

public void setConsumerEntryDn(org.apache.directory.api.ldap.model.name.Dn consumerEntryDn)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2003-2013 The Apache Software Foundation. All Rights Reserved.