public interface Session extends Closeable
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.
|
String |
getName()
Returns the name of this replication session.
|
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.
|
ExtendedStartMsg |
performExtendedHandshake(ServerId<?> serverId,
GroupId groupId,
ServerState state)
Performs extended handshake to exchange additional informations.
|
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 |
setName(String name)
Sets the name of this replication 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 |
start()
Starts this session.
|
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.
|
void close()
close
in interface AutoCloseable
close
in interface Closeable
boolean closeInitiated()
ExtendedStartMsg performExtendedHandshake(ServerId<?> serverId, GroupId groupId, ServerState state) throws IOException, DataFormatException, NotSupportedOldVersionPDUException
It expects to get the remote server groupId and processId in response; since the exchange is done during handshaking it does not matter who sends it first as the global loop for reading messages is not running yet, so we'll be receiving the remote server message here.
serverId
- the serverId for this servergroupId
- the groupId for this serverstate
- the server state of this serverNotSupportedOldVersionPDUException
- if the remote server is not using the correct protocol versionIOException
- if the remote server does not send its groupID in response to oursDataFormatException
- if a network error prevents getting the remote server groupIDlong getLastPublishTime()
long getLastReceiveTime()
String getReadableRemoteAddress()
HostPort getRemoteAddress()
boolean isEncrypted()
void publish(ReplicationMsg msg) throws IOException
msg
- The message to be sent.IOException
- If an IO error occurred.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.void setProtocolVersion(short version)
version
- The version of the protocol that is currently used.short getProtocolVersion()
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.void stopEncryption()
void run()
void waitForStartup() throws InterruptedException
InterruptedException
- when interruptedString getName()
void setName(String name)
name
- the name of this replication session.void start()
Copyright 2010-2022 ForgeRock AS.