org.apache.directory.mitosis.service
Interface ReplicationContext

All Known Implementing Classes:
DefaultReplicationContext

public interface ReplicationContext

A context object that provides the functions required for a client or a server to implement networking code related with replication communication. This is provided to and used by ReplicationClientContextHandler and ReplicationServerContextHandler.

Author:
The Apache Directory Project Team

Nested Class Summary
static class ReplicationContext.State
          Represents the state of the connection between two Replicas.
 
Method Summary
 void cancelAllExpirations()
          Cancells all scheduled expirations.
 java.lang.Object cancelExpiration(int sequence)
          Cancels the expiration scheduled by calling 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.
 

Method Detail

getSession

org.apache.mina.common.IoSession getSession()
Returns MINA IoSession instance that is associated with the current connection to the remote Replica.


getConfiguration

ReplicationConfiguration getConfiguration()
Returns the current ReplicationConfiguration of the Replica which is managing this context.


getService

ReplicationInterceptor getService()
Returns the ReplicationInterceptor which is managing this context.


getDirectoryService

DirectoryService getDirectoryService()
Returns the DirectoryService which owns the ReplicationInterceptor which is managing this context.


getNextSequence

int getNextSequence()
Generates a new and unique sequence number of protocol message.

Returns:
the new sequence number.

getPeer

Replica getPeer()
Returns the remote peer Replica that this context is connected to.


setPeer

void setPeer(Replica peer)
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.


getState

ReplicationContext.State getState()
Returns the current state of the Replica this context is managing.


setState

void setState(ReplicationContext.State state)
Sets the current state of the Replica this context is managing.


scheduleExpiration

void scheduleExpiration(java.lang.Object message)
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 cancelExpiration(int) method is not invoked within a certain timeout, an exception will be raised to ReplicationContextHandler.exceptionCaught(ReplicationContext, Throwable).


cancelExpiration

java.lang.Object cancelExpiration(int sequence)
Cancels the expiration scheduled by calling 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.

Returns:
the request message with the specified sequence number

cancelAllExpirations

void cancelAllExpirations()
Cancells all scheduled expirations. A user of this context could call this method when the current connection is closed.


getScheduledExpirations

int getScheduledExpirations()
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.


replicate

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

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.


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