public final class Session extends DirectoryThread implements Closeable
DirectoryThread.Factory
Thread.State, Thread.UncaughtExceptionHandler
DIRECTORY_THREAD_GROUP
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
Session(Socket socket,
SSLSocket secureSocket)
Creates a new Session.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
This method is called when the session with the remote must be closed.
|
boolean |
closeInitiated()
This methods allows to determine if the session close was initiated
on this Session.
|
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.
|
HostPort |
getLocalUrl()
Retrieve the local URL in the form host:port.
|
short |
getProtocolVersion()
Returns the version of the protocol that is currently used.
|
String |
getReadableRemoteAddress()
Retrieve the human readable address of the remote server.
|
HostPort |
getRemoteAddress()
Retrieve the IP address and port of the remote server.
|
boolean |
isEncrypted()
Determine whether the session is using a security layer.
|
void |
publish(ReplicationMsg msg)
Sends a replication message to the remote peer.
|
ReplicationMsg |
receive()
Attempt to receive a ReplicationMsg.
|
void |
run()
Run method for the Session.
|
void |
setProtocolVersion(short version)
This method is called at the establishment of the session and can
be used to record the version of the protocol that is currently used.
|
void |
setSoTimeout(int timeout)
Set a timeout value.
|
void |
stopEncryption()
Stop using the security layer, if there is any.
|
void |
waitForStartup()
This method can be called to wait until the session thread is
properly started.
|
getAssociatedTask, getCreationStackTrace, getDebugProperties, getParentThread, initiateShutdown, isShutdownInitiated, setAssociatedTask, startWork, stopWork
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public Session(Socket socket, SSLSocket secureSocket) throws IOException
socket
- The regular Socket on which the SocketSession will be based.secureSocket
- The secure Socket on which the SocketSession will be based.IOException
- When an IException happens on the socket.public void close()
close
in interface Closeable
close
in interface AutoCloseable
public boolean closeInitiated()
public long getLastPublishTime()
public long getLastReceiveTime()
public HostPort getLocalUrl()
public String getReadableRemoteAddress()
public HostPort getRemoteAddress()
public boolean isEncrypted()
public void publish(ReplicationMsg msg) throws IOException
msg
- The message to be sent.IOException
- If an IO error occurred.public ReplicationMsg receive() throws IOException, DataFormatException, NotSupportedOldVersionPDUException
IOException
- When error happened during IO process.DataFormatException
- When the data received is not formatted as a
ReplicationMsg.NotSupportedOldVersionPDUException
- If the received PDU is part of
an old protocol version and we do not support it.public void setProtocolVersion(short version)
version
- The version of the protocol that is currently used.public short getProtocolVersion()
public void setSoTimeout(int timeout) throws SocketException
timeout
- the specified timeout, in milliseconds.SocketException
- if there is an error in the underlying protocol,
such as a TCP error.public void stopEncryption()
public void run()
public void waitForStartup() throws InterruptedException
InterruptedException
- when interruptedCopyright © 2010-2017 ForgeRock AS. All Rights Reserved.