public interface NodeStateListener extends AutoCloseable
An implementation of this interface can be registered in the configuration, or with SessionBuilder.withNodeStateListener(NodeStateListener)
.
Note that the methods defined by this interface will be executed by internal driver threads, and are therefore expected to have short execution times. If you need to perform long computations or blocking calls in response to schema change events, it is strongly recommended to schedule them asynchronously on a separate thread provided by your application code.
If you implement this interface but don't need to implement all the methods, extend NodeStateListenerBase
.
Modifier and Type | Method and Description |
---|---|
void |
onAdd(Node node)
Invoked when a node is first added to the cluster.
|
void |
onDown(Node node)
Invoked when a node's state switches to
NodeState.DOWN or NodeState.FORCED_DOWN . |
void |
onRemove(Node node)
Invoked when a node leaves the cluster.
|
void |
onUp(Node node)
Invoked when a node's state switches to
NodeState.UP . |
close
void onAdd(@NonNull Node node)
The node is not up yet at this point. onUp(Node)
will be notified later if the
driver successfully connects to the node (provided that a session is opened and the node is not
ignored
), or receives a topology event for it.
This method is not invoked for the contact points provided at initialization. It is however for new nodes discovered during the full node list refresh after the first connection.
void onUp(@NonNull Node node)
NodeState.UP
.void onDown(@NonNull Node node)
NodeState.DOWN
or NodeState.FORCED_DOWN
.void onRemove(@NonNull Node node)
This can be triggered by a topology event, or during a full node list refresh if the node is absent from the new list.
Copyright © 2017–2019. All rights reserved.