Class RedisNode
java.lang.Object
org.springframework.data.redis.connection.RedisNode
- All Implemented Interfaces:
NamedNode
- Direct Known Subclasses:
RedisClusterNode
,RedisServer
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasString()
boolean
static RedisNode
fromString
(String hostPortString) Parse ahostAndPort
string intoRedisNode
.static RedisNode
fromString
(String hostPortString, int defaultPort) Parse ahostAndPort
string intoRedisNode
.@Nullable String
getHost()
@Nullable String
getId()
@Nullable String
@Nullable String
getName()
@Nullable Integer
getPort()
int
getPortOr
(int defaultPort) Returns the port of this Redis Node thedefaultPort
if no port is set.Returns the required host of this Redis Node or throwsIllegalStateException
if no host is set.int
Returns the required port of this Redis Node or throwsIllegalStateException
if no port is set.@Nullable RedisNode.NodeType
getType()
int
hashCode()
boolean
boolean
isMaster()
boolean
static RedisNode.RedisNodeBuilder
GetRedisNode.RedisNodeBuilder
for creating newRedisNode
.void
void
toString()
-
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
-
RedisNode
protected RedisNode()
-
-
Method Details
-
fromString
Parse ahostAndPort
string 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 ahostAndPort
string 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 throwsIllegalStateException
if 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 thedefaultPort
if no port is set.- Returns:
- Since:
- 4.0
-
getRequiredPort
public int getRequiredPort()Returns the required port of this Redis Node or throwsIllegalStateException
if 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.RedisNodeBuilder
for creating newRedisNode
.- Returns:
- never null.
- Since:
- 1.7
-
toString
-
hashCode
-
equals
-