org.opends.server.replication.protocol
Interface ProtocolSession

All Known Implementing Classes:
SocketSession, TLSSocketSession

public interface ProtocolSession

The ProtocolSession interface should be implemented by a class that implement the send/reception part of the Multi-master replication protocol. This interface is designed to make easy the move from one format of the ReplicationMessage on the wire to another format.


Method Summary
 void close()
          This method is called when the session with the remote must be closed.
 long getLastPublishTime()
          Gets the time the last replication message was published on this session.
 long getLastReceiveTime()
          Gets the time the last replication message was received on this session.
 java.lang.String getRemoteAddress()
          Retrieve the IP address of the remote server.
 boolean isEncrypted()
          Determine whether the session is using a security layer.
 void publish(ReplicationMessage msg)
          This method is called when a ReplicationMessage must be sent to the remote entity.
 ReplicationMessage receive()
          Attempt to receive a ReplicationMessage.
 void setSoTimeout(int timeout)
          Set a timeout value.
 void stopEncryption()
          Stop using the security layer, if there is any.
 

Method Detail

close

void close()
           throws java.io.IOException
This method is called when the session with the remote must be closed. This object won't be used anymore after this method is called.

Throws:
java.io.IOException - If an error happen during the close process.

publish

void publish(ReplicationMessage msg)
             throws java.io.IOException
This method is called when a ReplicationMessage must be sent to the remote entity. It can be called by several threads and must implement appropriate replication (typically, this method or a part of it should be synchronized).

Parameters:
msg - The ReplicationMessage that must be sent.
Throws:
java.io.IOException - If an IO error happen during the publish process.

receive

ReplicationMessage receive()
                           throws java.io.IOException,
                                  java.lang.ClassNotFoundException,
                                  java.util.zip.DataFormatException
Attempt to receive a ReplicationMessage. This method should block the calling thread until a ReplicationMessage is available or until an error condition. This method can only be called by a single thread and therefore does not neet to implement any replication.

Returns:
The ReplicationMessage that was received.
Throws:
java.io.IOException - When error happened durin IO process.
java.lang.ClassNotFoundException - When the data received does extend the ReplicationMessage class.
java.util.zip.DataFormatException - When the data received is not formatted as a ReplicationMessage.

stopEncryption

void stopEncryption()
Stop using the security layer, if there is any.


isEncrypted

boolean isEncrypted()
Determine whether the session is using a security layer.

Returns:
true if the connection is encrypted, false otherwise.

getRemoteAddress

java.lang.String getRemoteAddress()
Retrieve the IP address of the remote server.

Returns:
The IP address of the remote server.

setSoTimeout

void setSoTimeout(int timeout)
                  throws java.net.SocketException
Set a timeout value. With this option set to a non-zero value, calls to the receive() method block for only this amount of time after which a java.net.SocketTimeoutException is raised. The Broker is valid and useable even after such an Exception is raised.

Parameters:
timeout - the specified timeout, in milliseconds.
Throws:
java.net.SocketException - if there is an error in the underlying protocol, such as a TCP error.

getLastPublishTime

long getLastPublishTime()
Gets the time the last replication message was published on this session.

Returns:
The timestamp in milliseconds of the last message published.

getLastReceiveTime

long getLastReceiveTime()
Gets the time the last replication message was received on this session.

Returns:
The timestamp in milliseconds of the last message received.