Interface Session

    • Method Detail

      • newDsSession

        static org.opends.server.replication.protocol.DsSession newDsSession​(ServerContext serverContext,
                                                                             Socket socket,
                                                                             com.forgerock.opendj.util.Host host,
                                                                             int soTimeout,
                                                                             ReplSessionSecurity securityConfiguration,
                                                                             BooleanSupplier shuttingDown)
                                                                      throws ConfigException,
                                                                             IOException
        Creates a new DS Session.
        Parameters:
        serverContext - The directory server context
        socket - The regular Socket on which the SocketSession will be based.
        host - The host the socket is connected to.
        soTimeout - The socket timeout option to use for the protocol session.
        securityConfiguration - Provides the security configuration for replication protocol sessions.
        shuttingDown - The Supplier returning if domain shutdown is in progress
        Returns:
        a new DS Session
        Throws:
        ConfigException - If the session could not be established due to a configuration problem.
        IOException - If the session could not be established for some other reason.
      • newRsClientSession

        static org.opends.server.replication.protocol.RsSession newRsClientSession​(ServerContext serverContext,
                                                                                   Socket socket,
                                                                                   com.forgerock.opendj.util.Host host,
                                                                                   int soTimeout,
                                                                                   ReplSessionSecurity securityConfiguration)
                                                                            throws ConfigException,
                                                                                   IOException
        Creates a new RS Session in the client role.
        Parameters:
        serverContext - The directory server context
        socket - The regular Socket on which the SocketSession will be based.
        host - The host the socket is connected to.
        soTimeout - The socket timeout option to use for the protocol session.
        securityConfiguration - Provides the security configuration for replication protocol sessions.
        Returns:
        a new RS Session in the client role
        Throws:
        ConfigException - If the session could not be established due to a configuration problem.
        IOException - If the session could not be established for some other reason.
      • newRsServerSession

        static org.opends.server.replication.protocol.RsSession newRsServerSession​(ServerContext serverContext,
                                                                                   Socket socket,
                                                                                   int soTimeout,
                                                                                   ReplSessionSecurity securityConfiguration)
                                                                            throws ConfigException,
                                                                                   IOException
        Creates a new RS Session in the server role.
        Parameters:
        serverContext - The directory server context
        socket - The regular Socket on which the SocketSession will be based.
        soTimeout - The socket timeout option to use for the protocol session.
        securityConfiguration - Provides the security configuration for replication protocol sessions.
        Returns:
        a new RS Session in the server role or null if the underlying SSL socket cannot be created
        Throws:
        ConfigException - If the session could not be established due to a configuration problem.
        IOException - If the session could not be established for some other reason.
      • close

        void close()
        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 AutoCloseable
        Specified by:
        close in interface Closeable
      • closeInitiated

        boolean closeInitiated()
        This methods allows to determine if the session close was initiated on this Session.
        Returns:
        A boolean allowing to determine if the session close was initiated on this Session.
      • performExtendedHandshake

        ExtendedStartMsg performExtendedHandshake​(ServerId<?> serverId,
                                                  com.forgerock.opendj.discovery.GroupId groupId,
                                                  ServerState state,
                                                  long heartbeatInterval)
                                           throws IOException,
                                                  DataFormatException,
                                                  NotSupportedOldVersionPDUException
        Performs extended handshake to exchange additional information.

        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.

        Parameters:
        serverId - the serverId for this server
        groupId - the groupId for this server
        state - the server state of this server
        heartbeatInterval - the heartbeat interval to use
        Returns:
        the remote server GroupIdMsg
        Throws:
        NotSupportedOldVersionPDUException - if the remote server is not using the correct protocol version
        IOException - if the remote server does not send its groupID in response to ours
        DataFormatException - if a network error prevents getting the remote server groupID
      • 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.
      • resetReceiveTime

        void resetReceiveTime()
        Reset the time the last message was received to restart accounting from scratch.
      • getReadableRemoteAddress

        String getReadableRemoteAddress()
        Retrieve the human readable address of the remote server.
        Returns:
        The human readable address of the remote server.
      • getRemoteAddress

        com.forgerock.opendj.util.HostPort getRemoteAddress()
        Retrieve the IP address and port of the remote server.
        Returns:
        The IP address and port of the remote server.
      • isEncrypted

        boolean isEncrypted()
        Determine whether the session is using a security layer.
        Returns:
        true if the connection is encrypted, false otherwise.
      • publish

        void publish​(ReplicationMsg msg)
              throws IOException
        Sends a replication message to the remote peer.
        Parameters:
        msg - The message to be sent.
        Throws:
        IOException - If an IO error occurred.
      • setProtocolVersion

        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.
        Parameters:
        version - The version of the protocol that is currently used.
      • getProtocolVersion

        short getProtocolVersion()
        Returns the version of the protocol that is currently used.
        Returns:
        The version of the protocol that is currently used.
      • setSoTimeout

        void setSoTimeout​(int timeout)
                   throws 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 usable even after such an Exception is raised.
        Parameters:
        timeout - the specified timeout, in milliseconds.
        Throws:
        SocketException - if there is an error in the underlying protocol, such as a TCP error.
      • setHandshakeComplete

        void setHandshakeComplete()
        Signals that handshake is complete (i.e. it was not ended prematurely).

        Closing of the session is handled differently when handshake ends prematurely.

      • stopEncryption

        void stopEncryption()
                     throws IOException,
                            InterruptedException
        Stops using the security layer, if there is any, possibly waiting during the process to ensure encryption is not removed during reception or sending of a message.
        Throws:
        IOException - if the StopEncryptionMsg could not be published
        InterruptedException - if thread is interrupted during the waiting process
      • setName

        void setName​(String sourceServer,
                     String peerServer)
        Sets name of the source server and peer server, in order to identify the session in thread name and logging statements.
        Parameters:
        sourceServer - identifies the source server.
        peerServer - identifies the peer server.
      • start

        void start()
        Starts the publisher thread of this session.
      • writer

        org.reactivestreams.Publisher<UpdateMsg> writer​(Flowable<UpdateMsg> upstream)
        Returns a Publisher that:
        1. writes update messages to the remote server with back-pressure support and
        2. publishes in return each written message.
        This method is only implemented by subclasses providing reactive support.
        Parameters:
        upstream - the upstream (or source) of update messages.
        Returns:
        a Publisher that 1) writes received messages to the remote server with back-pressure support and 2) publishes in return each written message.
        Throws:
        UnsupportedOperationException - if the subclass does not support reactive implementation.
      • getPeerCertificate

        Certificate getPeerCertificate()
                                throws SSLPeerUnverifiedException
        Returns the certificate presented by the peer during TLS handshake.
        Returns:
        the certificate presented by the peer during TLS handshake
        Throws:
        SSLPeerUnverifiedException - if the peer did not present a certificate or an authentication error occurred