org.opends.server.replication.server
Class DbHandler

java.lang.Object
  extended by org.opends.server.replication.server.DbHandler
All Implemented Interfaces:
java.lang.Runnable

public class DbHandler
extends java.lang.Object
implements java.lang.Runnable

This class is used for managing the replicationServer database for each server in the topology. It is responsible for efficiently saving the updates that is received from each master server into stable storage. This class is also able to generate a ReplicationIterator that can be used to read all changes from a given ChangeNUmber. This class publish some monitoring information below cn=monitor.


Constructor Summary
DbHandler(short id, DN baseDn, ReplicationServer replicationServer, ReplicationDbEnv dbenv)
          Creates a new dbHandler associated to a given LDAP server.
 
Method Summary
 void add(UpdateMessage update)
          Add an update to the list of messages that must be saved to the db managed by this db handler.
 void clear()
          Clear the changes from this DB (from both memory cache and DB storage).
 ReplicationIterator generateIterator(ChangeNumber changeNumber)
          Generate a new ReplicationIterator that allows to browse the db managed by this dbHandler and starting at the position defined by a given changeNumber.
 long getChangesCount()
          Get the number of changes.
 ChangeNumber getFirstChange()
          Get the firstChange.
 ChangeNumber getLastChange()
          Get the lastChange.
 void run()
          Run method for this class.
 void setPurgeDelay(long delay)
          Set the Purge delay for this db Handler.
 void shutdown()
          Shutdown this dbHandler.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DbHandler

public DbHandler(short id,
                 DN baseDn,
                 ReplicationServer replicationServer,
                 ReplicationDbEnv dbenv)
          throws com.sleepycat.je.DatabaseException
Creates a new dbHandler associated to a given LDAP server.

Parameters:
id - Identifier of the DB.
baseDn - the baseDn for which this DB was created.
replicationServer - The ReplicationServer that creates this dbHandler.
dbenv - the Database Env to use to create the ReplicationServer DB. server for this domain.
Throws:
com.sleepycat.je.DatabaseException - If a database problem happened
Method Detail

add

public void add(UpdateMessage update)
Add an update to the list of messages that must be saved to the db managed by this db handler. This method is blocking if the size of the list of message is larger than its maximum.

Parameters:
update - The update that must be saved to the db managed by this db handler.

getFirstChange

public ChangeNumber getFirstChange()
Get the firstChange.

Returns:
Returns the firstChange.

getLastChange

public ChangeNumber getLastChange()
Get the lastChange.

Returns:
Returns the lastChange.

getChangesCount

public long getChangesCount()
Get the number of changes.

Returns:
Returns the number of changes.

generateIterator

public ReplicationIterator generateIterator(ChangeNumber changeNumber)
                                     throws com.sleepycat.je.DatabaseException,
                                            java.lang.Exception
Generate a new ReplicationIterator that allows to browse the db managed by this dbHandler and starting at the position defined by a given changeNumber.

Parameters:
changeNumber - The position where the iterator must start.
Returns:
a new ReplicationIterator that allows to browse the db managed by this dbHandler and starting at the position defined by a given changeNumber.
Throws:
com.sleepycat.je.DatabaseException - if a database problem happened.
java.lang.Exception - If there is no other change to push after change with changeNumber number.

shutdown

public void shutdown()
Shutdown this dbHandler.


run

public void run()
Run method for this class. Periodically Flushes the ReplicationServerDomain cache from memory to the stable storage and trims the old updates.

Specified by:
run in interface java.lang.Runnable

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

setPurgeDelay

public void setPurgeDelay(long delay)
Set the Purge delay for this db Handler.

Parameters:
delay - The purge delay in Milliseconds.

clear

public void clear()
           throws com.sleepycat.je.DatabaseException,
                  java.lang.Exception
Clear the changes from this DB (from both memory cache and DB storage).

Throws:
com.sleepycat.je.DatabaseException - When an exception occurs while removing the changes from the DB.
java.lang.Exception - When an exception occurs while accessing a resource from the DB.