org.apache.directory.mitosis.service
Class ReplicationInterceptor

java.lang.Object
  extended by org.apache.directory.server.core.interceptor.BaseInterceptor
      extended by org.apache.directory.mitosis.service.ReplicationInterceptor
All Implemented Interfaces:
Interceptor

public class ReplicationInterceptor
extends BaseInterceptor

An Interceptor that intercepts LDAP operations and propagates the changes occurred by the operations into other ReplicaIds so the DIT of each ReplicaId in the cluster has the same content without any conflict.

Once an operation is invoked, this interceptor transforms it into one or more operations that makes the requested operation more proper and robust for replication. The transformation process is actually just calling a respective factory method in OperationFactory. The methods in OperationFactory returns a new Operation instance.

The newly created Operation is used for three purposes.

The first two actions (modifying the local DIT and storing the Operation to ReplicationStore) are performed automatically when Operation#execute(PartitionNexus, ReplicationStore, Registries) method is invoked. ReplicationInterceptor always call it instead of forwarding the requested operation to the next Interceptor.

The last action takes place by ReplicationClientContextHandler, which handles TCP/IP connection managed by ClientConnectionManager.

There are two special attributes in the entries to be replicated:

Version:
$Rev$, $Date$
Author:
The Apache Directory Project (dev@directory.apache.org)
'XBean'

Field Summary
static java.lang.String DEFAULT_SERVICE_NAME
          The service name
 
Constructor Summary
ReplicationInterceptor()
          Creates a new instance of ReplicationInterceptor.
 
Method Summary
 void add(NextInterceptor nextInterceptor, AddOperationContext addContext)
          Filters Partition.add( AddOperationContext ) call.
 void delete(NextInterceptor next, DeleteOperationContext deleteContext)
          Filters Partition.delete( DeleteOperationContext ) call.
 void destroy()
          This method does nothing by default.
 ReplicationConfiguration getConfiguration()
           
 DirectoryService getDirectoryService()
           
 java.lang.String getName()
          This interceptor has configuration so it might be useful to allow several instances in a chain.
 boolean hasEntry(NextInterceptor nextInterceptor, EntryOperationContext entryContext)
          Filters Partition.hasEntry( EntryOperationContext ) call.
 void init(DirectoryService directoryService)
          Initialize the Replication service.
 void interruptConnectors()
          Wake the sleeping (unconnected) replicas.
 EntryFilteringCursor list(NextInterceptor nextInterceptor, ListOperationContext opContext)
          Filters Partition.list( ListOperationContext ) call.
 ClonedServerEntry lookup(NextInterceptor nextInterceptor, LookupOperationContext lookupContext)
          Filters Partition.lookup( LookupOperationContext ) call.
 void modify(NextInterceptor next, ModifyOperationContext modifyContext)
          Filters Partition.modify( ModifyOperationContext ) call.
 void move(NextInterceptor next, MoveOperationContext moveOpContext)
          Filters Partition.move( MoveOperationContext ) call.
 void moveAndRename(NextInterceptor next, MoveAndRenameOperationContext moveAndRenameOpContext)
          Filters Partition.moveAndRename( MoveAndRenameOperationContext) call.
 void purgeAgedData()
          Purges old replication logs and the old entries marked as 'deleted' (i.e.
 void rename(NextInterceptor next, RenameOperationContext renameOpContext)
          Filters Partition.rename( RenameOperationContext ) call.
 void replicate()
          Forces this context to send replication data to the peer replica immediately.
 EntryFilteringCursor search(NextInterceptor nextInterceptor, SearchOperationContext opContext)
          Filters Partition.search( SearchOperationContext ) call.
 void setConfiguration(ReplicationConfiguration configuration)
           
 void setName(java.lang.String name)
          Set the name for this service instance
 
Methods inherited from class org.apache.directory.server.core.interceptor.BaseInterceptor
addContextPartition, bind, compare, getContext, getMatchedName, getPrincipal, getRootDSE, getSuffix, listSuffixes, removeContextPartition, unbind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SERVICE_NAME

public static final java.lang.String DEFAULT_SERVICE_NAME
The service name

See Also:
Constant Field Values
Constructor Detail

ReplicationInterceptor

public ReplicationInterceptor()
Creates a new instance of ReplicationInterceptor.

Method Detail

getName

public java.lang.String getName()
This interceptor has configuration so it might be useful to allow several instances in a chain.

Specified by:
getName in interface Interceptor
Overrides:
getName in class BaseInterceptor
Returns:
configured name for this interceptor.

setName

public void setName(java.lang.String name)
Set the name for this service instance

Parameters:
name - The new name

getConfiguration

public ReplicationConfiguration getConfiguration()

setConfiguration

public void setConfiguration(ReplicationConfiguration configuration)

init

public void init(DirectoryService directoryService)
          throws java.lang.Exception
Initialize the Replication service. We have to check that the configuration is valid, initialize a store for pending operations, and start the communication with the other LDAP servers.

Specified by:
init in interface Interceptor
Overrides:
init in class BaseInterceptor
Parameters:
directoryService - the DirectoryService instance
Throws:
java.lang.Exception

destroy

public void destroy()
Description copied from class: BaseInterceptor
This method does nothing by default.

Specified by:
destroy in interface Interceptor
Overrides:
destroy in class BaseInterceptor

replicate

public void replicate()
Forces this context to send replication data to the peer replica immediately.


interruptConnectors

public void interruptConnectors()
Wake the sleeping (unconnected) replicas.


purgeAgedData

public void purgeAgedData()
                   throws java.lang.Exception
Purges old replication logs and the old entries marked as 'deleted' (i.e. Constants.ENTRY_DELETED is TRUE). This method should be called periodically to make sure the size of the DIT and ReplicationStore increase limitlessly.

Throws:
javax.naming.NamingException - on error
java.lang.Exception
See Also:
ReplicationConfiguration.setLogMaxAge(int), ReplicationLogCleanJob

add

public void add(NextInterceptor nextInterceptor,
                AddOperationContext addContext)
         throws java.lang.Exception
Description copied from interface: Interceptor
Filters Partition.add( AddOperationContext ) call.

Specified by:
add in interface Interceptor
Overrides:
add in class BaseInterceptor
Throws:
java.lang.Exception

delete

public void delete(NextInterceptor next,
                   DeleteOperationContext deleteContext)
            throws java.lang.Exception
Description copied from interface: Interceptor
Filters Partition.delete( DeleteOperationContext ) call.

Specified by:
delete in interface Interceptor
Overrides:
delete in class BaseInterceptor
Throws:
java.lang.Exception

modify

public void modify(NextInterceptor next,
                   ModifyOperationContext modifyContext)
            throws java.lang.Exception
Description copied from interface: Interceptor
Filters Partition.modify( ModifyOperationContext ) call.

Specified by:
modify in interface Interceptor
Overrides:
modify in class BaseInterceptor
Throws:
java.lang.Exception

move

public void move(NextInterceptor next,
                 MoveOperationContext moveOpContext)
          throws java.lang.Exception
Description copied from interface: Interceptor
Filters Partition.move( MoveOperationContext ) call.

Specified by:
move in interface Interceptor
Overrides:
move in class BaseInterceptor
Throws:
java.lang.Exception

moveAndRename

public void moveAndRename(NextInterceptor next,
                          MoveAndRenameOperationContext moveAndRenameOpContext)
                   throws java.lang.Exception
Description copied from interface: Interceptor
Filters Partition.moveAndRename( MoveAndRenameOperationContext) call.

Specified by:
moveAndRename in interface Interceptor
Overrides:
moveAndRename in class BaseInterceptor
Throws:
java.lang.Exception

rename

public void rename(NextInterceptor next,
                   RenameOperationContext renameOpContext)
            throws java.lang.Exception
Description copied from interface: Interceptor
Filters Partition.rename( RenameOperationContext ) call.

Specified by:
rename in interface Interceptor
Overrides:
rename in class BaseInterceptor
Throws:
java.lang.Exception

hasEntry

public boolean hasEntry(NextInterceptor nextInterceptor,
                        EntryOperationContext entryContext)
                 throws java.lang.Exception
Description copied from interface: Interceptor
Filters Partition.hasEntry( EntryOperationContext ) call.

Specified by:
hasEntry in interface Interceptor
Overrides:
hasEntry in class BaseInterceptor
Throws:
java.lang.Exception

lookup

public ClonedServerEntry lookup(NextInterceptor nextInterceptor,
                                LookupOperationContext lookupContext)
                         throws java.lang.Exception
Description copied from interface: Interceptor
Filters Partition.lookup( LookupOperationContext ) call.

Specified by:
lookup in interface Interceptor
Overrides:
lookup in class BaseInterceptor
Throws:
java.lang.Exception

list

public EntryFilteringCursor list(NextInterceptor nextInterceptor,
                                 ListOperationContext opContext)
                          throws java.lang.Exception
Description copied from interface: Interceptor
Filters Partition.list( ListOperationContext ) call.

Specified by:
list in interface Interceptor
Overrides:
list in class BaseInterceptor
Throws:
java.lang.Exception

search

public EntryFilteringCursor search(NextInterceptor nextInterceptor,
                                   SearchOperationContext opContext)
                            throws java.lang.Exception
Description copied from interface: Interceptor
Filters Partition.search( SearchOperationContext ) call.

Specified by:
search in interface Interceptor
Overrides:
search in class BaseInterceptor
Throws:
java.lang.Exception

getDirectoryService

public DirectoryService getDirectoryService()


Copyright © 2003-2009 Apache Software Foundation. All Rights Reserved.