Package com.clickhouse.client
Class ClickHouseNodeSelector
- java.lang.Object
-
- com.clickhouse.client.ClickHouseNodeSelector
-
- All Implemented Interfaces:
Serializable
public class ClickHouseNodeSelector extends Object implements Serializable
This class maintains two immutable lists: preferred protocols and tags. Usually it will be used in two scenarios: 1) find suitableClickHouseClient
according to preferred protocol(s); and 2) pick suitableClickHouseNode
to connect to.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static ClickHouseNodeSelector
EMPTY
-
Constructor Summary
Constructors Modifier Constructor Description protected
ClickHouseNodeSelector(Collection<ClickHouseProtocol> protocols, Collection<String> tags)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<ClickHouseProtocol>
getPreferredProtocols()
Set<String>
getPreferredTags()
boolean
match(ClickHouseClient client)
Test if the given client supports any ofgetPreferredProtocols()
.boolean
match(ClickHouseNode node)
boolean
matchAllPreferredTags(Collection<String> tags)
boolean
matchAnyOfPreferredProtocols(ClickHouseProtocol protocol)
boolean
matchAnyOfPreferredTags(Collection<String> tags)
static ClickHouseNodeSelector
of(ClickHouseProtocol protocol, ClickHouseProtocol... more)
static ClickHouseNodeSelector
of(String tag, String... more)
static ClickHouseNodeSelector
of(Collection<ClickHouseProtocol> protocols, Collection<String> tags)
-
-
-
Field Detail
-
EMPTY
public static final ClickHouseNodeSelector EMPTY
-
-
Constructor Detail
-
ClickHouseNodeSelector
protected ClickHouseNodeSelector(Collection<ClickHouseProtocol> protocols, Collection<String> tags)
-
-
Method Detail
-
of
public static ClickHouseNodeSelector of(ClickHouseProtocol protocol, ClickHouseProtocol... more)
-
of
public static ClickHouseNodeSelector of(String tag, String... more)
-
of
public static ClickHouseNodeSelector of(Collection<ClickHouseProtocol> protocols, Collection<String> tags)
-
getPreferredProtocols
public List<ClickHouseProtocol> getPreferredProtocols()
-
match
public boolean match(ClickHouseClient client)
Test if the given client supports any ofgetPreferredProtocols()
. It's alwaysfalse
if 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
public boolean match(ClickHouseNode node)
-
matchAnyOfPreferredProtocols
public boolean matchAnyOfPreferredProtocols(ClickHouseProtocol protocol)
-
matchAllPreferredTags
public boolean matchAllPreferredTags(Collection<String> tags)
-
matchAnyOfPreferredTags
public boolean matchAnyOfPreferredTags(Collection<String> tags)
-
-