Class RedundantConnectionManagerImpl

    • Method Detail

      • create

        public static RedundantConnectionManager create​(java.util.List<ConnectionParameters> connectionParameters,
                                                        RedundantConnectionEventListener listener,
                                                        long retryTime,
                                                        java.util.concurrent.TimeUnit retryUnit,
                                                        boolean disconnectStandBySessions)
        Create new instance of RedundantConnectionManager for handling direct connections.

        Instance runs background job that tries to keep opened D2Connector instances for each item of connectionParameters list.

        When request for new D2Session occurs, it tries to create a new session with each of opened connector and returns the one connected to HOT kernel. Other sessions are closed. It repeats its attempts until HOT session is obtained with (retryTime, retryUnit) sleep interval.

        Parameters:
        connectionParameters - list of address:port pairs with optional path to certificate file.
        listener - optional listener that receives events about underlying D2Connectors.
        retryTime - sleep period size
        retryUnit - sleep period time unit
        disconnectStandBySessions - automatically disconnects all active sessions when attached
        Returns:
        new instance of RedundantConnectionManager
      • create

        public static RedundantConnectionManager create​(java.lang.String localInterface,
                                                        int localPort,
                                                        java.lang.String certificatePath,
                                                        java.util.List<java.lang.String> allowedHosts,
                                                        RedundantConnectionEventListener listener,
                                                        long retryTime,
                                                        java.util.concurrent.TimeUnit retryUnit,
                                                        boolean disconnectStandBySessions)
                                                 throws ConnectorException
        Create new instance of RedundantConnectionManager for handling reverse connections using TLS socket.

        Instance opens socket for listening at specified address and waits for incoming connections. It compares each incoming connection address with list of allowedHosts (resolves the list to IP addresses) and accepts one that is found in the list. Other connections are rejected.

        When request for new D2Session occurs, it tries to create a new session with each of opened connector and returns the one connected to HOT kernel. Other sessions are closed. It repeats its attempts until HOT session is obtained with (retryTime, retryUnit) sleep interval.

        Parameters:
        localInterface - address of specific interface or null for all interfaces
        localPort - number of port for listening socket from range 1 .. 0xFFFF.
        certificatePath - optional path to file with certificate for TLS connection
        allowedHosts - list of host names or IP addresses that are allowed to connect
        listener - optional listener that receives events about underlying D2Connectors.
        retryTime - sleep period size
        retryUnit - sleep period time unit
        disconnectStandBySessions - automatically disconnects all active sessions when attached
        Returns:
        new instance of RedundantConnectionManager
        Throws:
        ConnectorException - when unable to open listening socket
      • isClosed

        public boolean isClosed​()
        Description copied from interface: D2SessionFactory
        Get true after D2SessionFactory.close() has been called. Indicates that no new session can be created and all created sessions has been terminated.
        Specified by:
        isClosed in interface D2SessionFactory
        Returns:
        true when closed;
      • createSession

        public java.util.concurrent.Future<D2Session> createSession​(D2SessionParameters sessionParams,
                                                                    D2SessionEventsListener eventsListener)
        Description copied from interface: D2SessionFactory
        Create new session object, connect it to D2000 and authorize it with valid D2000 user account.

        Operation is executed in background thread and goes through following steps:

        1. Create new instance.
        2. Connect session to the D2000 kernel.
        3. Logon to the D2000 kernel with provided user account.
        Future result may throw ExecutionException with cause:
        ConnectSessionException - when kernel refused connection of the session
        LoginFailedException - when kernel refused to logon with provided user account
        Specified by:
        createSession in interface D2SessionFactory
        Parameters:
        sessionParams - authentication information
        eventsListener - instance of event listener object to receive asynchronous events from D2000 session
        Returns:
        upcoming session object in form of future
      • createSession

        public java.util.concurrent.Future<D2Session> createSession​(D2SessionParameters sessionParams,
                                                                    D2SessionEventsListener eventsListener,
                                                                    java.util.Set<SharedResourceType> interestSet)
        Description copied from interface: D2SessionFactory
        Create new session object, connect it to D2000 and authorise it with valid D2000 user account.

        Operation is executed in background thread and goes through following steps:

        1. Create new instance.
        2. Report current state of shared resources to the sharedResourcesListener.
        3. Connect session to the D2000 kernel.
        4. Logon to the D2000 kernel with provided user account.
        Future result may throw ExecutionException with cause:
        ConnectSessionException - when kernel refused connection of the session
        LoginFailedException - when kernel refused to logon with provided user account
        Specified by:
        createSession in interface D2SessionFactory
        Parameters:
        sessionParams - authentication information
        eventsListener - instance of event listener object to receive asynchronous events from D2000 session
        interestSet - interesting shared resource types
        Returns:
        upcoming session object in form of future