Package com.clickhouse.client
Interface ClickHouseNodeManager
- All Superinterfaces:
Function<ClickHouseNodeSelector,,ClickHouseNode> Serializable
- All Known Implementing Classes:
ClickHouseCluster,ClickHouseNodes
public interface ClickHouseNodeManager
extends Function<ClickHouseNodeSelector,ClickHouseNode>, Serializable
Node manager is responsible for managing list of nodes and their status. It
also runs scheduled tasks in background for node discovery and health check.
-
Method Summary
Modifier and TypeMethodDescriptionGets a copy of faulty nodes.getFaultyNodes(ClickHouseNodeSelector selector, int groupSize) Gets a copy of filtered faulty nodes.getNodes()Gets a copy of nodes, which in most cases are in healthy status.getNodes(ClickHouseNodeSelector selector, int groupSize) Gets a copy of filtered nodes.Gets node selector for filtering out nodes.Gets load balancing policy.Schedule node discovery task immediately.Schedule node discovery task immediately.voidshutdown()Shuts down scheduled tasks if any.suggestNode(ClickHouseNode server, Throwable failure) Suggests a different node in order to recover from a failure, which is usually a connection error.voidupdate(ClickHouseNode node, ClickHouseNode.Status status) Updates node status to one ofClickHouseNode.Status.
-
Method Details
-
getNodes
List<ClickHouseNode> getNodes()Gets a copy of nodes, which in most cases are in healthy status. However, this really depends on howClickHouseLoadBalancingPolicymanages node status. In first-alive policy, it's acutally a full list regardless node status.- Returns:
- non-null nodes
-
getNodes
Gets a copy of filtered nodes.- Parameters:
selector- node selector for filtering out nodes, null means no filtergroupSize- maximum number of nodes to get, zero or negative value means all- Returns:
- non-null nodes
-
getFaultyNodes
List<ClickHouseNode> getFaultyNodes()Gets a copy of faulty nodes.- Returns:
- non-null faulty nodes
-
getFaultyNodes
Gets a copy of filtered faulty nodes.- Parameters:
selector- node selector for filtering out nodes, null means no filtergroupSize- maximum number of nodes to get, zero or negative value means all- Returns:
- non-null faulty nodes
-
getPolicy
ClickHouseLoadBalancingPolicy getPolicy()Gets load balancing policy.- Returns:
- non-null load balancing policy
-
getNodeSelector
ClickHouseNodeSelector getNodeSelector()Gets node selector for filtering out nodes.- Returns:
- non-null node selector
-
scheduleDiscovery
Optional<ScheduledFuture<?>> scheduleDiscovery()Schedule node discovery task immediately. Nothing will happen when task scheduler does not exist(e.g.getPolicy().getScheduler()returns null) or there's a task running for node discovery.- Returns:
- optional future for retrieving the running task
-
scheduleHealthCheck
Optional<ScheduledFuture<?>> scheduleHealthCheck()Schedule node discovery task immediately. Nothing will happen when task scheduler does not exist(e.g.getPolicy().getScheduler()returns null) or there's a task running for health check.- Returns:
- optional future for retrieving the running task
-
suggestNode
Suggests a different node in order to recover from a failure, which is usually a connection error.- Parameters:
server- node related to the failure(e.g. the node couldn't be connected)failure- recoverable failure- Returns:
- non-null node which may or may not be same as the given one
-
update
Updates node status to one ofClickHouseNode.Status. It simply delegates the call togetPolicy().update(node, status)in a thread-safe manner.- Parameters:
node- non-null node to updatestatus- non-null status of the node
-
shutdown
void shutdown()Shuts down scheduled tasks if any.
-