java.lang.Object
org.springframework.data.redis.connection.RedisNode
All Implemented Interfaces:
NamedNode
Direct Known Subclasses:
RedisClusterNode, RedisServer

public class RedisNode extends Object implements NamedNode
Since:
1.4
Author:
Christoph Strobl, Thomas Darimont, Mark Paluch, LeeHyungGeol
  • Field Details

  • Constructor Details

    • RedisNode

      public RedisNode(String host, int port)
      Creates a new RedisNode with the given host, port.
      Parameters:
      host - must not be null
      port -
    • RedisNode

      protected RedisNode()
  • Method Details

    • fromString

      public static RedisNode fromString(String hostPortString)
      Parse a hostAndPort string into RedisNode. Supports IPv4, IPv6, and hostname notations including the port. For example:
       RedisNode.fromString("127.0.0.1");
       RedisNode.fromString("127.0.0.1:6379");
       RedisNode.fromString("[aaaa:bbbb::dddd:eeee]");
       RedisNode.fromString("[aaaa:bbbb::dddd:eeee]:6379");
       RedisNode.fromString("my.redis.server");
       RedisNode.fromString("my.redis.server:6379");
       
      Parameters:
      hostPortString - must not be null or empty.
      Returns:
      the parsed RedisNode.
      Since:
      2.7.4
    • fromString

      public static RedisNode fromString(String hostPortString, int defaultPort)
      Parse a hostAndPort string into RedisNode. Supports IPv4, IPv6, and hostname notations including the port. For example:
       RedisNode.fromString("127.0.0.1");
       RedisNode.fromString("127.0.0.1:6379");
       RedisNode.fromString("[aaaa:bbbb::dddd:eeee]");
       RedisNode.fromString("[aaaa:bbbb::dddd:eeee]:6379");
       RedisNode.fromString("my.redis.server");
       RedisNode.fromString("my.redis.server:6379");
       
      Parameters:
      hostPortString - must not be null or empty.
      Returns:
      the parsed RedisNode.
      Since:
      3.4
    • getHost

      @Nullable public String getHost()
      Returns:
      can be null.
    • hasValidHost

      public boolean hasValidHost()
      Returns:
      whether this node has a valid host (not null and not empty).
      Since:
      2.3.8
    • getPort

      @Nullable public Integer getPort()
      Returns:
      can be null.
    • asString

      public String asString()
    • getName

      @Nullable public String getName()
      Specified by:
      getName in interface NamedNode
      Returns:
      the node name. Can be null.
    • setName

      public void setName(String name)
    • getMasterId

      @Nullable public String getMasterId()
      Returns:
      can be null.
      Since:
      1.7
    • getId

      @Nullable public String getId()
      Returns:
      can be null.
      Since:
      1.7
    • setId

      public void setId(String id)
      Parameters:
      id -
      Since:
      1.7
    • getType

      @Nullable public RedisNode.NodeType getType()
      Returns:
      can be null.
      Since:
      1.7
    • isMaster

      public boolean isMaster()
      Returns:
      Since:
      1.7
    • isReplica

      public boolean isReplica()
      Returns:
      Since:
      2.1
    • newRedisNode

      public static RedisNode.RedisNodeBuilder newRedisNode()
      Returns:
      never null.
      Since:
      1.7
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object