org.opends.server.replication.server
Class ReplicationServer

java.lang.Object
  extended by java.lang.Thread
      extended by org.opends.server.api.DirectoryThread
          extended by org.opends.server.api.MonitorProvider<MonitorProviderCfg>
              extended by org.opends.server.replication.server.ReplicationServer
All Implemented Interfaces:
java.lang.Runnable, ConfigurationChangeListener<ReplicationServerCfg>, BackupTaskListener, ExportTaskListener, ImportTaskListener, RestoreTaskListener

public class ReplicationServer
extends MonitorProvider<MonitorProviderCfg>
implements java.lang.Runnable, ConfigurationChangeListener<ReplicationServerCfg>, BackupTaskListener, RestoreTaskListener, ImportTaskListener, ExportTaskListener

ReplicationServer Listener. This singleton is the main object of the replication server It waits for the incoming connections and create listener and publisher objects for connection with LDAP servers and with replication servers It is responsible for creating the replication server replicationServerDomain and managing it


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ReplicationServer(ReplicationServerCfg configuration)
          Creates a new Replication server using the provided configuration entry.
 
Method Summary
 ConfigChangeResult applyConfigurationChange(ReplicationServerCfg configuration)
          Applies the configuration changes to this change listener.
 void clearDb()
          Clears the Db associated with that server.
 void clearGenerationId(DN baseDn)
          Clears the generationId for the replicationServerDomain related to the provided baseDn.
 java.util.Iterator<ReplicationServerDomain> getCacheIterator()
          Returns an iterator on the list of replicationServerDomain.
 long getGenerationId(DN baseDN)
          Get the value of generationId for the replication replicationServerDomain associated with the provided baseDN.
 java.util.ArrayList<Attribute> getMonitorData()
          Retrieves a set of attributes containing monitor data that should be returned to the client if the corresponding monitor entry is requested.
 java.lang.String getMonitorInstanceName()
          Retrieves the name of this monitor provider.
 ReplicationServerDomain getReplicationServerDomain(DN baseDn, boolean create)
          Get the ReplicationServerDomain associated to the base DN given in parameter.
 short getServerId()
          Get the serverId for this replication server.
 long getUpdateInterval()
          Retrieves the length of time in milliseconds that should elapse between calls to the updateMonitorData method.
 void initializeMonitorProvider(MonitorProviderCfg configuraiton)
          Initializes this monitor provider based on the information in the provided configuration entry.
static boolean isConfigurationAcceptable(ReplicationServerCfg configuration, java.util.List<Message> unacceptableReasons)
          Check if the provided configuration is acceptable for add.
 boolean isConfigurationChangeAcceptable(ReplicationServerCfg configuration, java.util.List<Message> unacceptableReasons)
          Indicates whether the proposed change to the configuration is acceptable to this change listener.
 DbHandler newDbHandler(short id, DN baseDn)
          Creates a new DB handler for this ReplicationServer and the serverId and DN given in parameter.
 void processBackupBegin(Backend backend, BackupConfig config)
          Performs any processing that might be necessary just before the server begins processing on a backup task.
 void processBackupEnd(Backend backend, BackupConfig config, boolean successful)
          Performs any processing that might be necessary after the server has completed processing on a backup task.
 void processExportBegin(Backend backend, LDIFExportConfig config)
          Performs any processing that might be necessary just before the server begins processing on an LDIF export task.
 void processExportEnd(Backend backend, LDIFExportConfig config, boolean successful)
          Performs any processing that might be necessary after the server has completed processing on an LDIF export task.
 void processImportBegin(Backend backend, LDIFImportConfig config)
          Performs any processing that might be necessary just before the server begins processing on an LDIF import task.
 void processImportEnd(Backend backend, LDIFImportConfig config, boolean successful)
          Performs any processing that might be necessary after the server has completed processing on an LDIF import task.
 void processRestoreBegin(Backend backend, RestoreConfig config)
          Performs any processing that might be necessary just before the server begins processing on a restore task.
 void processRestoreEnd(Backend backend, RestoreConfig config, boolean successful)
          Performs any processing that might be necessary after the server has completed processing on a restore task.
 void remove()
          Do what needed when the config object related to this replication server is deleted from the server configuration.
protected  void removeBackend()
          Removes the backend associated to this Replication Server that has been created when this replication server was created.
 void shutdown()
          Shutdown the Replication Server service and all its connections.
 void updateMonitorData()
          Performs any processing periodic processing that may be desired to update the information associated with this monitor.
 
Methods inherited from class org.opends.server.api.MonitorProvider
finalizeMonitorProvider, getMonitorObjectClass, isConfigurationAcceptable, run
 
Methods inherited from class org.opends.server.api.DirectoryThread
getAssociatedTask, getCreationStackTrace, getDebugProperties, getParentThread, setAssociatedTask
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.lang.Runnable
run
 

Constructor Detail

ReplicationServer

public ReplicationServer(ReplicationServerCfg configuration)
                  throws ConfigException
Creates a new Replication server using the provided configuration entry.

Parameters:
configuration - The configuration of this replication server.
Throws:
ConfigException - When Configuration is invalid.
Method Detail

getReplicationServerDomain

public ReplicationServerDomain getReplicationServerDomain(DN baseDn,
                                                          boolean create)
Get the ReplicationServerDomain associated to the base DN given in parameter.

Parameters:
baseDn - The base Dn for which the ReplicationServerDomain must be returned.
create - Specifies whether to create the ReplicationServerDomain if it does not already exist.
Returns:
The ReplicationServerDomain associated to the base DN given in parameter.

shutdown

public void shutdown()
Shutdown the Replication Server service and all its connections.


newDbHandler

public DbHandler newDbHandler(short id,
                              DN baseDn)
                       throws com.sleepycat.je.DatabaseException
Creates a new DB handler for this ReplicationServer and the serverId and DN given in parameter.

Parameters:
id - The serverId for which the dbHandler must be created.
baseDn - The DN for which the dbHandler muste be created.
Returns:
The new DB handler for this ReplicationServer and the serverId and DN given in parameter.
Throws:
com.sleepycat.je.DatabaseException - in case of underlying database problem.

clearGenerationId

public void clearGenerationId(DN baseDn)
                       throws com.sleepycat.je.DatabaseException
Clears the generationId for the replicationServerDomain related to the provided baseDn.

Parameters:
baseDn - The baseDn for which to delete the generationId.
Throws:
com.sleepycat.je.DatabaseException - When it occurs.

isConfigurationAcceptable

public static boolean isConfigurationAcceptable(ReplicationServerCfg configuration,
                                                java.util.List<Message> unacceptableReasons)
Check if the provided configuration is acceptable for add.

Parameters:
configuration - The configuration to check.
unacceptableReasons - When the configuration is not acceptable, this table is use to return the reasons why this configuration is not acceptbale.
Returns:
true if the configuration is acceptable, false other wise.

applyConfigurationChange

public ConfigChangeResult applyConfigurationChange(ReplicationServerCfg configuration)
Applies the configuration changes to this change listener.

Specified by:
applyConfigurationChange in interface ConfigurationChangeListener<ReplicationServerCfg>
Parameters:
configuration - The new configuration containing the changes.
Returns:
Returns information about the result of changing the configuration.

isConfigurationChangeAcceptable

public boolean isConfigurationChangeAcceptable(ReplicationServerCfg configuration,
                                               java.util.List<Message> unacceptableReasons)
Indicates whether the proposed change to the configuration is acceptable to this change listener.

Specified by:
isConfigurationChangeAcceptable in interface ConfigurationChangeListener<ReplicationServerCfg>
Parameters:
configuration - The new configuration containing the changes.
unacceptableReasons - A list that can be used to hold messages about why the provided configuration is not acceptable.
Returns:
Returns true if the proposed change is acceptable, or false if it is not.

initializeMonitorProvider

public void initializeMonitorProvider(MonitorProviderCfg configuraiton)
Initializes this monitor provider based on the information in the provided configuration entry.

Specified by:
initializeMonitorProvider in class MonitorProvider<MonitorProviderCfg>
Parameters:
configuraiton - The configuration to use to initialize this monitor provider.

getMonitorInstanceName

public java.lang.String getMonitorInstanceName()
Retrieves the name of this monitor provider. It should be unique among all monitor providers, including all instances of the same monitor provider.

Specified by:
getMonitorInstanceName in class MonitorProvider<MonitorProviderCfg>
Returns:
The name of this monitor provider.

getUpdateInterval

public long getUpdateInterval()
Retrieves the length of time in milliseconds that should elapse between calls to the updateMonitorData method. A negative or zero return value indicates that the updateMonitorData method should not be periodically invoked.

Specified by:
getUpdateInterval in class MonitorProvider<MonitorProviderCfg>
Returns:
The length of time in milliseconds that should elapse between calls to the updateMonitorData() method.

updateMonitorData

public void updateMonitorData()
Performs any processing periodic processing that may be desired to update the information associated with this monitor. Note that best-effort attempts will be made to ensure that calls to this method come getUpdateInterval milliseconds apart, but no guarantees will be made.

Specified by:
updateMonitorData in class MonitorProvider<MonitorProviderCfg>

getMonitorData

public java.util.ArrayList<Attribute> getMonitorData()
Retrieves a set of attributes containing monitor data that should be returned to the client if the corresponding monitor entry is requested.

Specified by:
getMonitorData in class MonitorProvider<MonitorProviderCfg>
Returns:
A set of attributes containing monitor data that should be returned to the client if the corresponding monitor entry is requested.

getGenerationId

public long getGenerationId(DN baseDN)
Get the value of generationId for the replication replicationServerDomain associated with the provided baseDN.

Parameters:
baseDN - The baseDN of the replicationServerDomain.
Returns:
The value of the generationID.

getServerId

public short getServerId()
Get the serverId for this replication server.

Returns:
The value of the serverId.

remove

public void remove()
Do what needed when the config object related to this replication server is deleted from the server configuration.


removeBackend

protected void removeBackend()
Removes the backend associated to this Replication Server that has been created when this replication server was created.


processBackupBegin

public void processBackupBegin(Backend backend,
                               BackupConfig config)
Performs any processing that might be necessary just before the server begins processing on a backup task. This may include flushing any outstanding writes to disk so they are included in the backup and/or pausing interaction with the provided backend while the backup is in progress.

Specified by:
processBackupBegin in interface BackupTaskListener
Parameters:
backend - The backend to be archived.
config - Configuration information about the backup to be performed.

processBackupEnd

public void processBackupEnd(Backend backend,
                             BackupConfig config,
                             boolean successful)
Performs any processing that might be necessary after the server has completed processing on a backup task. Note that this will always be called when backup processing completes, regardless of whether it was successful.

Specified by:
processBackupEnd in interface BackupTaskListener
Parameters:
backend - The backend that was archived.
config - Configuration information about the backup that was performed.
successful - Indicates whether the backup operation completed successfully.

processRestoreBegin

public void processRestoreBegin(Backend backend,
                                RestoreConfig config)
Performs any processing that might be necessary just before the server begins processing on a restore task. This should include pausing interaction with the provided backend while the restore is in progress.

Specified by:
processRestoreBegin in interface RestoreTaskListener
Parameters:
backend - The backend to be restored.
config - Configuration information about the restore to be performed.

processRestoreEnd

public void processRestoreEnd(Backend backend,
                              RestoreConfig config,
                              boolean successful)
Performs any processing that might be necessary after the server has completed processing on a restore task. Note that this will always be called when restore processing completes, regardless of whether it was successful.

Specified by:
processRestoreEnd in interface RestoreTaskListener
Parameters:
backend - The backend that was restored.
config - Configuration information about the restore that was performed.
successful - Indicates whether the restore operation completed successfully.

processImportBegin

public void processImportBegin(Backend backend,
                               LDIFImportConfig config)
Performs any processing that might be necessary just before the server begins processing on an LDIF import task. This should include pausing interaction with the provided backend while the import is in progress.

Specified by:
processImportBegin in interface ImportTaskListener
Parameters:
backend - The backend to be imported.
config - Configuration information about the LDIF import to be performed.

processImportEnd

public void processImportEnd(Backend backend,
                             LDIFImportConfig config,
                             boolean successful)
Performs any processing that might be necessary after the server has completed processing on an LDIF import task. Note that this will always be called when import processing completes, regardless of whether it was successful.

Specified by:
processImportEnd in interface ImportTaskListener
Parameters:
backend - The backend that was imported.
config - Configuration information about the LDIF import that was performed.
successful - Indicates whether the import operation completed successfully.

processExportBegin

public void processExportBegin(Backend backend,
                               LDIFExportConfig config)
Performs any processing that might be necessary just before the server begins processing on an LDIF export task. This may include flushing any outstanding writes to disk so they are included in the export and/or pausing interaction with the provided backend while the export is in progress.

Specified by:
processExportBegin in interface ExportTaskListener
Parameters:
backend - The backend to be exported.
config - Configuration information about the LDIF export to be performed.

processExportEnd

public void processExportEnd(Backend backend,
                             LDIFExportConfig config,
                             boolean successful)
Performs any processing that might be necessary after the server has completed processing on an LDIF export task. Note that this will always be called when export processing completes, regardless of whether it was successful.

Specified by:
processExportEnd in interface ExportTaskListener
Parameters:
backend - The backend that was exported.
config - Configuration information about the LDIF export that was performed.
successful - Indicates whether the export operation completed successfully.

getCacheIterator

public java.util.Iterator<ReplicationServerDomain> getCacheIterator()
Returns an iterator on the list of replicationServerDomain. Returns null if none.

Returns:
the iterator.

clearDb

public void clearDb()
Clears the Db associated with that server.