org.opends.server.replication.protocol
Class TLSSocketSession

java.lang.Object
  extended by org.opends.server.replication.protocol.TLSSocketSession
All Implemented Interfaces:
ProtocolSession

public class TLSSocketSession
extends java.lang.Object
implements ProtocolSession

This class implements a protocol session using TLS.


Constructor Summary
TLSSocketSession(java.net.Socket socket, javax.net.ssl.SSLSocket secureSocket)
          Creates a new TLSSocketSession.
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TLSSocketSession

public TLSSocketSession(java.net.Socket socket,
                        javax.net.ssl.SSLSocket secureSocket)
                 throws java.io.IOException
Creates a new TLSSocketSession.

Parameters:
socket - The regular Socket on which the SocketSession will be based.
secureSocket - The secure Socket on which the SocketSession will be based.
Throws:
java.io.IOException - When an IException happens on the socket.
Method Detail

close

public 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.

Specified by:
close in interface ProtocolSession
Throws:
java.io.IOException - If an error happen during the close process.

publish

public 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).

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

receive

public 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.

Specified by:
receive in interface ProtocolSession
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

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

Specified by:
stopEncryption in interface ProtocolSession

isEncrypted

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

Specified by:
isEncrypted in interface ProtocolSession
Returns:
true if the connection is encrypted, false otherwise.

getLastPublishTime

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

Specified by:
getLastPublishTime in interface ProtocolSession
Returns:
The timestamp in milliseconds of the last message published.

getLastReceiveTime

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

Specified by:
getLastReceiveTime in interface ProtocolSession
Returns:
The timestamp in milliseconds of the last message received.

getRemoteAddress

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

Specified by:
getRemoteAddress in interface ProtocolSession
Returns:
The IP address of the remote server.

setSoTimeout

public 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.

Specified by:
setSoTimeout in interface ProtocolSession
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.