Class NetworkServiceFactory

    • Constructor Detail

      • NetworkServiceFactory

        public NetworkServiceFactory()
    • Method Detail

      • setHostSelector

        public void setHostSelector​(AddressSelector hostSelector)
        Sets the host address selector that will be used to select an address of the local cluster node.
        Parameters:
        hostSelector - Address selector.
        See Also:
        setHost(String)
      • getHost

        public String getHost()
        Supplementary getter for setHost(String). Returns the host selection pattern if this factory is configured with AddressPattern; returns null otherwise.
        Returns:
        host selection pattern if this factory is configured with AddressPattern; returns null otherwise.
      • setHost

        public void setHost​(String pattern)
        Sets the host address selection pattern (see AddressPattern).

        The following patterns can be specified:

        • any - any non-loopback address
        • any-ip4 - any IPv6 non-loopback address
        • ip~regex - any IP address that matches the specified regular expression
        • ip4~regex - any IPv4 address that matches the specified regular expression
        • ip6~regex - any IPv6 address that matches the specified regular expression
        • !ip~regex - any IP address that does NOT match the specified regular expression
        • !ip4~regex - any IPv4 address that does NOT match the specified regular expression
        • !ip6~regex - any IPv6 address that does NOT match the specified regular expression
        • net~regex - any IP address of a network interface who's name matches the specified regular expression
        • net4~regex - IPv4 address of a network interface who's name matches the specified regular expression
        • net6~regex - IPv6 address of a network interface who's name matches the specified regular expression
        • !net~regex - any IP address of a network interface who's name does NOT match the specified regular expression
        • !net4~regex - IPv4 address of a network interface who's name does NOT match the specified regular expression
        • !net6~regex - IPv6 address of a network interface who's name does NOT match the specified regular expression
        • ...all other values will be treated as a directly specified address (see InetAddress.getByName(String))

        If multiple addresses match the specified pattern then the first one will be selected (order is not guaranteed).

        Parameters:
        pattern - Address selection pattern (see AddressPattern).
        See Also:
        setHostSelector(AddressSelector), AddressPattern
      • getPort

        public int getPort()
        Returns communications port of the local node (see setPort(int)).
        Returns:
        The port number.
      • setPort

        public void setPort​(int port)
        Sets port number that will be used by the local node to accept network connections.

        If specified port number is 0 then ephemeral port will be assigned by the underlying OS.

        Note that it is possible to specify port ranges via setPortRange(int) method.

        Default value of this parameter is 10012

        Parameters:
        port - The port number.
        See Also:
        setPortRange(int)
      • getPortRange

        public int getPortRange()
        Returns the port range (see setPortRange(int)).
        Returns:
        Port range.
      • setPortRange

        public void setPortRange​(int portRange)
        Sets maximum value that can be used for port auto-incrementing.

        Local node will try to bind on the first available port starting with getPort() up to getPort() + getPortRange(). If value of this property is less than or equals to zero then port auto-incrementing will be disabled.

        Default value of this parameter is 100

        Parameters:
        portRange - Port range.
      • getConnectTimeout

        public int getConnectTimeout()
        Returns the TCP connect timeout in milliseconds (see setConnectTimeout(int)).
        Returns:
        Timeout in milliseconds.
      • setConnectTimeout

        public void setConnectTimeout​(int connectTimeout)
        Sets the timeout in milliseconds for establishing a TCP socket connection to a remote node.

        Negative value or zero means that no timeout should happen.

        The default value of this parameter is 3000.

        Parameters:
        connectTimeout - Timeout in milliseconds.
      • withConnectTimeout

        public NetworkServiceFactory withConnectTimeout​(int connectTimeout)
        Fluent-style version of setConnectTimeout(int).
        Parameters:
        connectTimeout - Timeout in milliseconds.
        Returns:
        This instance.
      • getAcceptRetryInterval

        public long getAcceptRetryInterval()
        Returns the number of milliseconds to wait before trying to re-create a TCP socket acceptor in case of a failure (see setAcceptRetryInterval(long)).
        Returns:
        Number of milliseconds.
      • setAcceptRetryInterval

        public void setAcceptRetryInterval​(long acceptRetryInterval)
        Sets the number of milliseconds to wait before trying to re-create a TCP socket acceptor in case of its failure.

        Negative value or zero means that retrying should not take place and Hekate instance must stop with an error.

        The default value of this parameter is 1000.

        Parameters:
        acceptRetryInterval - Number of milliseconds to wait.
      • withAcceptRetryInterval

        public NetworkServiceFactory withAcceptRetryInterval​(long acceptRetryInterval)
        Fluent-style version of setAcceptRetryInterval(long).
        Parameters:
        acceptRetryInterval - Number of milliseconds to wait.
        Returns:
        This instance.
      • getHeartbeatInterval

        public int getHeartbeatInterval()
        Returns the heartbeat sending interval in milliseconds (see setHeartbeatInterval(int)).
        Returns:
        Heartbeat interval in milliseconds.
      • setHeartbeatInterval

        public void setHeartbeatInterval​(int heartbeatInterval)
        Sets the heartbeat sending interval in milliseconds for keeping a TCP socket connection alive.

        This setting is used by a TCP connection peer to notify other peer that it is alive. This is archived by sending a small dummy message if there was no other activity (i.e. no other messages sent) for the specified time interval. Also please see setHeartbeatLossThreshold(int) for details of how this parameter is used for connection failure detection.

        Value of this parameter must be above zero.

        Default value of this parameter is 1000.

        Parameters:
        heartbeatInterval - Heartbeat interval in milliseconds.
        See Also:
        setHeartbeatLossThreshold(int)
      • withHeartbeatInterval

        public NetworkServiceFactory withHeartbeatInterval​(int heartbeatInterval)
        Fluent-style version of setHeartbeatInterval(int).
        Parameters:
        heartbeatInterval - Heartbeat interval in milliseconds.
        Returns:
        This instance.
      • getHeartbeatLossThreshold

        public int getHeartbeatLossThreshold()
        Returns the maximum number of lost heartbeats (see setHeartbeatLossThreshold(int)).
        Returns:
        Maximum number of lost heartbeats.
      • setHeartbeatLossThreshold

        public void setHeartbeatLossThreshold​(int heartbeatLossThreshold)
        Sets the maximum number of lost heartbeats before considering a TCP connection to be failed.

        This setting works in conjunction with setHeartbeatInterval(int) to calculate the total amount of time for a TCP connection to stay inactive (i.e. do not send any heartbeats or application data). When this timeout elapses then connection is considered to be failed and will be closed with a NetworkTimeoutException.

        For example: if heartbeat interval is 500 and loss threshold is 3 then a TCP connection will be closed with and error after 1500 milliseconds of inactivity.

        Value of this parameter must be above zero.

        Default value of this parameter is 3.

        Parameters:
        heartbeatLossThreshold - Maximum number of lost heartbeats.
      • withHeartbeatLossThreshold

        public NetworkServiceFactory withHeartbeatLossThreshold​(int heartbeatLossThreshold)
        Fluent-style version of setHeartbeatLossThreshold(int).
        Parameters:
        heartbeatLossThreshold - Maximum number of lost heartbeats.
        Returns:
        This instance.
      • getNioThreads

        public int getNioThreads()
        Returns the number of threads to be used for NIO event processing (see setNioThreads(int)).
        Returns:
        Number of threads for NIO event processing.
      • setNioThreads

        public void setNioThreads​(int nioThreads)
        Sets the number of threads to be used for NIO event processing.

        Value of this parameter must be above zero.

        Default value of this parameter is the number of CPUs available to the JVM (see Runtime.availableProcessors()).

        Parameters:
        nioThreads - Number of threads for NIO event processing.
      • withNioThreads

        public NetworkServiceFactory withNioThreads​(int nioThreads)
        Fluent-style version of setNioThreads(int).
        Parameters:
        nioThreads - Number of threads for NIO event processing.
        Returns:
        This instance.
      • setTcpNoDelay

        public void setTcpNoDelay​(boolean tcpNoDelay)
        Sets the flag indicating that TCP_NODELAY option must be set on TCP socket connections.

        Please see Nagle's algorithm for more info.

        Default value of this parameter is true.

        Parameters:
        tcpNoDelay - true if TCP_NODELAY option must be set.
      • getTcpReceiveBufferSize

        public Integer getTcpReceiveBufferSize()
        Returns the size of the socket receive buffer in bytes (see setTcpReceiveBufferSize(Integer)).
        Returns:
        Buffer size in bytes or null if it wasn't set.
      • setTcpReceiveBufferSize

        public void setTcpReceiveBufferSize​(Integer tcpReceiveBufferSize)
        Sets the size of the socket receive buffer in bytes (see StandardSocketOptions.SO_RCVBUF for more details).

        Default value of this parameter is null.

        Parameters:
        tcpReceiveBufferSize - Buffer size in bytes.
      • getTcpSendBufferSize

        public Integer getTcpSendBufferSize()
        Returns the size of the socket send buffer in bytes (see setTcpSendBufferSize(Integer)).
        Returns:
        Buffer size in bytes or null if it wasn't set.
      • setTcpSendBufferSize

        public void setTcpSendBufferSize​(Integer tcpSendBufferSize)
        Sets the size of the socket send buffer in bytes (see StandardSocketOptions.SO_SNDBUF for more details).

        Default value of this parameter is null.

        Parameters:
        tcpSendBufferSize - Buffer size in bytes.
      • getTcpReuseAddress

        public Boolean getTcpReuseAddress()
        Sets flag indicating that socket addresses should be re-used (see setTcpReuseAddress(Boolean)).
        Returns:
        Flag value or null if it wasn't set.
      • setTcpReuseAddress

        public void setTcpReuseAddress​(Boolean tcpReuseAddress)
        Sets flag indicating that socket addresses should be re-used (see StandardSocketOptions.SO_REUSEADDR for more details).

        Default value of this parameter is null.

        Parameters:
        tcpReuseAddress - Flag indicating that socket addresses should be re-used.
      • getTcpBacklog

        public Integer getTcpBacklog()
        Returns the maximum number of pending connections that can be queued on the server socket channel (see setTcpBacklog(Integer)).
        Returns:
        The maximum number of pending connections or null if it wasn't set.
      • setTcpBacklog

        public void setTcpBacklog​(Integer tcpBacklog)
        Sets the maximum number of pending connections that can be queued on the server socket channel (see ServerSocketChannel.bind(SocketAddress, int) for more details).

        Default value of this parameter is null.

        Parameters:
        tcpBacklog - The maximum number of pending connections.
      • setConfigProviders

        public void setConfigProviders​(List<NetworkConfigProvider> configProviders)
        Sets the list of connector configuration providers.
        Parameters:
        configProviders - Connector configuration providers.
        See Also:
        NetworkConfigProvider
      • setSsl

        public void setSsl​(NetworkSslConfig ssl)
        Sets the SSL configuration.

        If the specified configuration is not null then SSL encryption will be applied to all network communications. Note that SSL must be enabled/disabled on all nodes in the cluster. Mixed mode where some nodes have SSL enabled and some nodes have SSL disabled is not supported.

        Parameters:
        ssl - SSL configuration.