org.apache.directory.mitosis.service
Class DefaultReplicationContext

java.lang.Object
  extended by org.apache.directory.mitosis.service.DefaultReplicationContext
All Implemented Interfaces:
ReplicationContext

public class DefaultReplicationContext
extends java.lang.Object
implements ReplicationContext

The default implementation of ReplicationContext

Author:
The Apache Directory Project Team

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.directory.mitosis.service.ReplicationContext
ReplicationContext.State
 
Constructor Summary
DefaultReplicationContext(ReplicationInterceptor interceptor, DirectoryService directoryService, ReplicationConfiguration configuration, org.apache.mina.common.IoSession session)
           
 
Method Summary
 void cancelAllExpirations()
          Cancells all scheduled expirations.
 java.lang.Object cancelExpiration(int sequence)
          Cancels the expiration scheduled by calling ReplicationContext.scheduleExpiration(Object).
 ReplicationConfiguration getConfiguration()
          Returns the current ReplicationConfiguration of the Replica which is managing this context.
 DirectoryService getDirectoryService()
          Returns the DirectoryService which owns the ReplicationInterceptor which is managing this context.
 int getNextSequence()
          Generates a new and unique sequence number of protocol message.
 Replica getPeer()
          Returns the remote peer Replica that this context is connected to.
 int getScheduledExpirations()
          Returns the number of the scheduled experations.
 ReplicationInterceptor getService()
          Returns the ReplicationInterceptor which is managing this context.
 org.apache.mina.common.IoSession getSession()
          Returns MINA IoSession instance that is associated with the current connection to the remote Replica.
 ReplicationContext.State getState()
          Returns the current state of the Replica this context is managing.
 boolean replicate()
          Forces this context to send replication data to the peer replica immediately.
 void scheduleExpiration(java.lang.Object message)
          Schedules an expiration of the specified message.
 void setPeer(Replica peer)
          Sets the remote peer Replica that this context is connected to.
 void setState(ReplicationContext.State state)
          Sets the current state of the Replica this context is managing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultReplicationContext

public DefaultReplicationContext(ReplicationInterceptor interceptor,
                                 DirectoryService directoryService,
                                 ReplicationConfiguration configuration,
                                 org.apache.mina.common.IoSession session)
Method Detail

getService

public ReplicationInterceptor getService()
Description copied from interface: ReplicationContext
Returns the ReplicationInterceptor which is managing this context.

Specified by:
getService in interface ReplicationContext

getConfiguration

public ReplicationConfiguration getConfiguration()
Description copied from interface: ReplicationContext
Returns the current ReplicationConfiguration of the Replica which is managing this context.

Specified by:
getConfiguration in interface ReplicationContext

getDirectoryService

public DirectoryService getDirectoryService()
Description copied from interface: ReplicationContext
Returns the DirectoryService which owns the ReplicationInterceptor which is managing this context.

Specified by:
getDirectoryService in interface ReplicationContext

getSession

public org.apache.mina.common.IoSession getSession()
Description copied from interface: ReplicationContext
Returns MINA IoSession instance that is associated with the current connection to the remote Replica.

Specified by:
getSession in interface ReplicationContext

getNextSequence

public int getNextSequence()
Description copied from interface: ReplicationContext
Generates a new and unique sequence number of protocol message.

Specified by:
getNextSequence in interface ReplicationContext
Returns:
the new sequence number.

getPeer

public Replica getPeer()
Description copied from interface: ReplicationContext
Returns the remote peer Replica that this context is connected to.

Specified by:
getPeer in interface ReplicationContext

setPeer

public void setPeer(Replica peer)
Description copied from interface: ReplicationContext
Sets the remote peer Replica that this context is connected to. A user has authenticate the remote peer first and call this method manually to prevent unauthorized access.

Specified by:
setPeer in interface ReplicationContext

getState

public ReplicationContext.State getState()
Description copied from interface: ReplicationContext
Returns the current state of the Replica this context is managing.

Specified by:
getState in interface ReplicationContext

setState

public void setState(ReplicationContext.State state)
Description copied from interface: ReplicationContext
Sets the current state of the Replica this context is managing.

Specified by:
setState in interface ReplicationContext

scheduleExpiration

public void scheduleExpiration(java.lang.Object message)
Description copied from interface: ReplicationContext
Schedules an expiration of the specified message. A user of this context could call this method with the message it has written out to the remote peer. If ReplicationContext.cancelExpiration(int) method is not invoked within a certain timeout, an exception will be raised to ReplicationContextHandler.exceptionCaught(ReplicationContext, Throwable).

Specified by:
scheduleExpiration in interface ReplicationContext

cancelExpiration

public java.lang.Object cancelExpiration(int sequence)
Description copied from interface: ReplicationContext
Cancels the expiration scheduled by calling ReplicationContext.scheduleExpiration(Object). A user of this context could call this method when the response message has been received to stop the expiration for the message with the specified sequence number.

Specified by:
cancelExpiration in interface ReplicationContext
Returns:
the request message with the specified sequence number

replicate

public boolean replicate()
Description copied from interface: ReplicationContext
Forces this context to send replication data to the peer replica immediately.

Specified by:
replicate in interface ReplicationContext
Returns:
true if the replication has been started, false if the replication didn't start because the replication process is already in progress or the client is currently logging in to the server yet.

cancelAllExpirations

public void cancelAllExpirations()
Description copied from interface: ReplicationContext
Cancells all scheduled expirations. A user of this context could call this method when the current connection is closed.

Specified by:
cancelAllExpirations in interface ReplicationContext

getScheduledExpirations

public int getScheduledExpirations()
Description copied from interface: ReplicationContext
Returns the number of the scheduled experations. A user of this contexst could check this value before sending a new message to the remote peer to prevent OutOfMemoryError by limiting the number of the messages which didn't get their responses.

Specified by:
getScheduledExpirations in interface ReplicationContext


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