Interface StatefulRedisClusterConnection<K,​V>

    • Method Detail

      • getConnection

        default StatefulRedisConnection<K,​V> getConnection​(String nodeId)
        Retrieve a connection to the specified cluster node using the nodeId suitable for write operations. Host and port are looked up in the node list. This connection is bound to the node id. Once the cluster topology view is updated, the connection will try to reconnect the to the node with the specified nodeId, that behavior can also lead to a closed connection once the node with the specified nodeId is no longer part of the cluster.

        Do not close the connections. Otherwise, unpredictable behavior will occur. The nodeId must be part of the cluster and is validated against the current topology view in Partitions.

        Calling this method is equivalent to calling getConnection(String, ConnectionIntent) with the connectionIntent parameter set to ConnectionIntent.WRITE

        In contrast to the StatefulRedisClusterConnection, node-connections do not route commands to other cluster nodes.

        Parameters:
        nodeId - the node Id
        Returns:
        a connection to the requested cluster node
        Throws:
        RedisException - if the requested node identified by nodeId is not part of the cluster
      • getConnection

        StatefulRedisConnection<K,​V> getConnection​(String nodeId,
                                                         ConnectionIntent connectionIntent)
        Retrieve a connection to the specified cluster node using the nodeId for the given ConnectionIntent. Host and port are looked up in the node list. This connection is bound to the node id. Once the cluster topology view is updated, the connection will try to reconnect the to the node with the specified nodeId, that behavior can also lead to a closed connection once the node with the specified nodeId is no longer part of the cluster.

        Do not close the connections. Otherwise, unpredictable behavior will occur. The nodeId must be part of the cluster and is validated against the current topology view in Partitions.

        This method is intended to be used for cases where the caller requires a specific connection type (READ or WRITE) to a given node in a cluster.

        In contrast to the StatefulRedisClusterConnection, node-connections do not route commands to other cluster nodes.

        Parameters:
        nodeId - the node Id
        connectionIntent - the intent for usage of the connection.
        Returns:
        a connection to the requested cluster node
        Throws:
        RedisException - if the requested node identified by nodeId is not part of the cluster
        Since:
        6.2
      • getConnectionAsync

        default CompletableFuture<StatefulRedisConnection<K,​V>> getConnectionAsync​(String nodeId)
        Retrieve asynchronously a connection to the specified cluster node using the nodeId suitable for write operations. Host and port are looked up in the node list. This connection is bound to the node id. Once the cluster topology view is updated, the connection will try to reconnect the to the node with the specified nodeId, that behavior can also lead to a closed connection once the node with the specified nodeId is no longer part of the cluster.

        Do not close the connections. Otherwise, unpredictable behavior will occur. The nodeId must be part of the cluster and is validated against the current topology view in Partitions.

        Calling this method is equivalent to calling getConnectionAsync(String, ConnectionIntent) with the connectionIntent parameter set to ConnectionIntent.WRITE

        In contrast to the StatefulRedisClusterConnection, node-connections do not route commands to other cluster nodes.

        Parameters:
        nodeId - the node Id
        Returns:
        CompletableFuture to indicate success or failure to connect to the requested cluster node.
        Throws:
        RedisException - if the requested node identified by nodeId is not part of the cluster
        Since:
        5.0
      • getConnectionAsync

        CompletableFuture<StatefulRedisConnection<K,​V>> getConnectionAsync​(String nodeId,
                                                                                 ConnectionIntent connectionIntent)
        Retrieve asynchronously a connection to the specified cluster node using the nodeId for the given ConnectionIntent. Host and port are looked up in the node list. This connection is bound to the node id. Once the cluster topology view is updated, the connection will try to reconnect the to the node with the specified nodeId, that behavior can also lead to a closed connection once the node with the specified nodeId is no longer part of the cluster.

        Do not close the connections. Otherwise, unpredictable behavior will occur. The nodeId must be part of the cluster and is validated against the current topology view in Partitions.

        This method is intended to be used for cases where the caller requires a specific connection type (READ or WRITE) to a given node in a cluster.

        In contrast to the StatefulRedisClusterConnection, node-connections do not route commands to other cluster nodes.

        Parameters:
        nodeId - the node Id
        connectionIntent - the intent for usage of the connection.
        Returns:
        CompletableFuture to indicate success or failure to connect to the requested cluster node.
        Throws:
        RedisException - if the requested node identified by nodeId is not part of the cluster
        Since:
        6.2
      • getConnection

        default StatefulRedisConnection<K,​V> getConnection​(String host,
                                                                 int port)
        Retrieve a connection to the specified cluster node using host and port suitable for write operations. This connection is bound to a host and port. Updates to the cluster topology view can close the connection once the host, identified by host and port, are no longer part of the cluster.

        Do not close the connections. Otherwise, unpredictable behavior will occur. Host and port connections are verified by default for cluster membership, see ClusterClientOptions.isValidateClusterNodeMembership().

        Calling this method is equivalent to calling getConnection(String, int, ConnectionIntent) with the connectionIntent parameter set to ConnectionIntent.WRITE

        In contrast to the StatefulRedisClusterConnection, node-connections do not route commands to other cluster nodes.

        Parameters:
        host - the host
        port - the port
        Returns:
        a connection to the requested cluster node
        Throws:
        RedisException - if the requested node identified by host and port is not part of the cluster
      • getConnection

        StatefulRedisConnection<K,​V> getConnection​(String host,
                                                         int port,
                                                         ConnectionIntent connectionIntent)
        Retrieve a connection to the specified cluster node using host and port. This connection is bound to a host and port. Updates to the cluster topology view can close the connection once the host, identified by host and port, are no longer part of the cluster.

        Do not close the connections. Otherwise, unpredictable behavior will occur. Host and port connections are verified by default for cluster membership, see ClusterClientOptions.isValidateClusterNodeMembership().

        In contrast to the StatefulRedisClusterConnection, node-connections do not route commands to other cluster nodes.

        Parameters:
        host - the host
        port - the port
        connectionIntent - the intent of the connection see getConnection(String, ConnectionIntent)
        Returns:
        a connection to the requested cluster node
        Throws:
        RedisException - if the requested node identified by host and port is not part of the cluster
        Since:
        6.2
      • setReadFrom

        void setReadFrom​(ReadFrom readFrom)
        Set from which nodes data is read. The setting is used as default for read operations on this connection. See the documentation for ReadFrom for more information.
        Parameters:
        readFrom - the read from setting, must not be null
      • getPartitions

        Partitions getPartitions()
        Returns:
        Known partitions for this connection.
      • addListener

        void addListener​(RedisClusterPushListener listener)
        Add a new listener to consume push messages.
        Parameters:
        listener - the listener, must not be null.
        Since:
        6.0
      • removeListener

        void removeListener​(RedisClusterPushListener listener)
        Remove an existing listener.
        Parameters:
        listener - the listener, must not be null.
        Since:
        6.0