public class RiakCluster extends Object implements OperationRetrier, NodeStateListener
This class represents a Riak Cluster upon which operations are executed.
Instances are created using the RiakCluster.Builder
Modifier and Type | Class and Description |
---|---|
static class |
RiakCluster.Builder
Builder used to create
RiakCluster instances. |
Modifier and Type | Method and Description |
---|---|
void |
addNode(RiakNode node)
Adds a
RiakNode to this cluster. |
static RiakCluster.Builder |
builder(List<RiakNode> nodes) |
static RiakCluster.Builder |
builder(RiakNode node) |
void |
cleanup()
Cleans up any Thread-Local variables after shutdown.
|
<V,S> RiakFuture<V,S> |
execute(FutureOperation<V,?,S> operation) |
<V,S> StreamingRiakFuture<V,S> |
execute(PBStreamingFutureOperation<V,?,S> operation) |
List<RiakNode> |
getNodes()
Returns a copy of the list of nodes in this cluster.
|
void |
nodeStateChanged(RiakNode node,
RiakNode.State state) |
void |
operationComplete(FutureOperation operation,
int remainingRetries) |
void |
operationFailed(FutureOperation operation,
int remainingRetries) |
void |
registerNodeStateListener(NodeStateListener listener)
Register a NodeStateListener.
|
boolean |
removeNode(RiakNode node)
Removes the provided node from the cluster.
|
void |
removeNodeStateListener(NodeStateListener listener)
Remove a NodeStateListener.
|
Future<Boolean> |
shutdown() |
void |
start() |
public void start()
public <V,S> RiakFuture<V,S> execute(FutureOperation<V,?,S> operation)
public <V,S> StreamingRiakFuture<V,S> execute(PBStreamingFutureOperation<V,?,S> operation)
public void addNode(RiakNode node) throws UnknownHostException
RiakNode
to this cluster.
The node can not have been started nor have its Bootstrap or Executor
asSet.
The node will be started as part of this process.node
- the RiakNode to addUnknownHostException
- if the RiakNode's hostname cannot be resolvedIllegalArgumentException
- if the node's Bootstrap or Executor are already asSet.public boolean removeNode(RiakNode node)
node
- public List<RiakNode> getNodes()
public void nodeStateChanged(RiakNode node, RiakNode.State state)
nodeStateChanged
in interface NodeStateListener
public void operationFailed(FutureOperation operation, int remainingRetries)
operationFailed
in interface OperationRetrier
public void operationComplete(FutureOperation operation, int remainingRetries)
operationComplete
in interface OperationRetrier
public void registerNodeStateListener(NodeStateListener listener)
Any state change by any of the nodes in the cluster will be sent to the registered NodeStateListener.
When registering, the current state of all the nodes is sent to the listener.
listener
- The NodeStateListener to register.public void removeNodeStateListener(NodeStateListener listener)
The supplied NodeStateListener will be unregistered and no longer receive state updates.
listener
- The NodeStateListener to unregister.public static RiakCluster.Builder builder(List<RiakNode> nodes)
public static RiakCluster.Builder builder(RiakNode node)
public void cleanup()
RiakNode
, RiakCluster
, and RiakClient
objects are in the shutdown state.Copyright © 2016. All rights reserved.