Class RedisNode
java.lang.Object
org.springframework.data.redis.connection.RedisNode
- All Implemented Interfaces:
NamedNode
- Direct Known Subclasses:
RedisClusterNode,RedisServer
- Since:
- 1.4
- Author:
- Christoph Strobl, Thomas Darimont, Mark Paluch, LeeHyungGeol
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasString()booleanstatic RedisNodefromString(String hostPortString) Parse ahostAndPortstring intoRedisNode.static RedisNodefromString(String hostPortString, int defaultPort) Parse ahostAndPortstring intoRedisNode.@Nullable StringgetHost()@Nullable StringgetId()@Nullable String@Nullable StringgetName()@Nullable IntegergetPort()intgetPortOr(int defaultPort) Returns the port of this Redis Node thedefaultPortif no port is set.Returns the required host of this Redis Node or throwsIllegalStateExceptionif no host is set.intReturns the required port of this Redis Node or throwsIllegalStateExceptionif no port is set.@Nullable RedisNode.NodeTypegetType()inthashCode()booleanbooleanisMaster()booleanstatic RedisNode.RedisNodeBuilderGetRedisNode.RedisNodeBuilderfor creating newRedisNode.voidvoidtoString()
-
Field Details
-
DEFAULT_PORT
public static final int DEFAULT_PORT- See Also:
-
DEFAULT_SENTINEL_PORT
public static final int DEFAULT_SENTINEL_PORT- See Also:
-
-
Constructor Details
-
RedisNode
- Parameters:
host- must not be nullport-
-
RedisNode
protected RedisNode()
-
-
Method Details
-
fromString
Parse ahostAndPortstring intoRedisNode. 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
Parse ahostAndPortstring intoRedisNode. 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
- Returns:
- can be null.
-
getRequiredHost
Returns the required host of this Redis Node or throwsIllegalStateExceptionif no host is set.- Returns:
- Throws:
IllegalStateException- if no host is associated with this Redis Node.- Since:
- 4.0
-
hasValidHost
public boolean hasValidHost()- Returns:
- whether this node has a valid host (not null and not empty).
- Since:
- 2.3.8
-
getPort
- Returns:
- can be null.
-
getPortOr
public int getPortOr(int defaultPort) Returns the port of this Redis Node thedefaultPortif no port is set.- Returns:
- Since:
- 4.0
-
getRequiredPort
public int getRequiredPort()Returns the required port of this Redis Node or throwsIllegalStateExceptionif no port is set.- Returns:
- Throws:
IllegalStateException- if no host is associated with this Redis Node.- Since:
- 4.0
-
asString
-
getName
-
setName
-
getMasterId
- Returns:
- can be null.
- Since:
- 1.7
-
getId
- Returns:
- can be null.
- Since:
- 1.7
-
setId
- Parameters:
id-- Since:
- 1.7
-
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
GetRedisNode.RedisNodeBuilderfor creating newRedisNode.- Returns:
- never null.
- Since:
- 1.7
-
toString
-
hashCode
public int hashCode() -
equals
-