Package com.clickhouse.client
Class ClickHouseNodeSelector
java.lang.Object
com.clickhouse.client.ClickHouseNodeSelector
- All Implemented Interfaces:
Serializable
This class maintains two immutable collections: preferred protocols and tags.
Usually it will be used in two scenarios: 1) find suitable
ClickHouseClient according to preferred protocol(s); and 2) pick
suitable ClickHouseNode to connect to.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ClickHouseNodeSelectorEmpty node selector matches all clients and nodes. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedClickHouseNodeSelector(Collection<ClickHouseProtocol> protocols, Collection<String> tags) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanGets preferred protocols.Gets preferred tags.inthashCode()booleanmatch(ClickHouseClient client) Test if the given client supports any ofgetPreferredProtocols().booleanmatch(ClickHouseNode node) Checks if the given node matches any of preferred protocols and tags.booleanChecks if the preferred tags contain all of given tags.booleanChecks if the given protocol matches any of the preferred protocols.booleanChecks if the preferred tags contain any of given tags.static ClickHouseNodeSelectorof(ClickHouseProtocol protocol, ClickHouseProtocol... more) Creates a node selector by specifying preferred protocols.static ClickHouseNodeSelectorCreates a node selector by specifying preferred tags.static ClickHouseNodeSelectorof(Collection<ClickHouseProtocol> protocols, Collection<String> tags) Creates a node selector by specifying preferred protocols and tags.toString()
-
Field Details
-
EMPTY
Empty node selector matches all clients and nodes.
-
-
Constructor Details
-
ClickHouseNodeSelector
Default constructor.- Parameters:
protocols- preferred protocolstags- preferred tags
-
-
Method Details
-
of
Creates a node selector by specifying preferred protocols.- Parameters:
protocol- preferred protocolmore- more protocols- Returns:
- non-null node selector
-
of
Creates a node selector by specifying preferred tags.- Parameters:
tag- preferred tagmore- more tags- Returns:
- non-null selector
-
of
public static ClickHouseNodeSelector of(Collection<ClickHouseProtocol> protocols, Collection<String> tags) Creates a node selector by specifying preferred protocols and tags.- Parameters:
protocols- preferred protocolstags- preferred tags- Returns:
- non-null selector
-
getPreferredProtocols
Gets preferred protocols. Empty list means all.- Returns:
- non-null preferred protocols
-
getPreferredTags
Gets preferred tags. Empty set means all.- Returns:
- non-null preferred tags
-
match
Test if the given client supports any ofgetPreferredProtocols(). It's alwaysfalseif either the client is null or there's no preferred protocol.- Parameters:
client- client to test- Returns:
- true if any of the preferred protocols is supported by the client
-
match
Checks if the given node matches any of preferred protocols and tags.- Parameters:
node- node to check- Returns:
- true if the node matches at least one of preferred protocols and tags; false otherwise
-
matchAnyOfPreferredProtocols
Checks if the given protocol matches any of the preferred protocols.- Parameters:
protocol- protocol to check- Returns:
- true if the protocol matches at least one of preferred protocols; false otherwise
-
matchAllPreferredTags
Checks if the preferred tags contain all of given tags.- Parameters:
tags- tags to check- Returns:
- true if the preferred tags contain all of given tags; false otherwise
-
matchAnyOfPreferredTags
Checks if the preferred tags contain any of given tags.- Parameters:
tags- tags to check- Returns:
- true if the preferred tags contain any of given tags; false otherwise
-
hashCode
public int hashCode() -
equals
-
toString
-