public class RiakNode extends Object implements RiakResponseListener
Modifier and Type | Class and Description |
---|---|
static class |
RiakNode.Builder
Builder used to construct a RiakNode.
|
static class |
RiakNode.State |
Modifier and Type | Method and Description |
---|---|
void |
addStateListener(NodeStateListener listener) |
int |
availablePermits()
Returns the number of permits currently available.
|
boolean |
execute(FutureOperation operation)
Submits the operation to be executed on this node.
|
boolean |
getBlockOnMaxConnections()
Returns if this node is set to block when all connections are in use.
|
int |
getConnectionTimeout()
Returns the connection timeout in milliseconds.
|
int |
getIdleTimeout()
Returns the connection idle timeout for connections in milliseconds.
|
int |
getMaxConnections()
Returns the maximum number of connections allowed.
|
int |
getMinConnections()
Returns the current minimum number of active connections to be maintained.
|
RiakNode.State |
getNodeState()
Returns the current state of this node.
|
int |
getPort()
returns the remote port for this RiakNode
|
String |
getRemoteAddress()
Returns the
remoteAddress for this RiakNode |
void |
onException(io.netty.channel.Channel channel,
Throwable t) |
void |
onRiakErrorResponse(io.netty.channel.Channel channel,
RiakResponseException ex) |
void |
onSuccess(io.netty.channel.Channel channel,
RiakMessage response) |
boolean |
removeStateListener(NodeStateListener listener) |
void |
setBlockOnMaxConnections(boolean block)
Set whether to block when all connections are in use.
|
RiakNode |
setBootstrap(io.netty.bootstrap.Bootstrap bootstrap)
Sets the Netty
Bootstrap for this Node's connections. |
RiakNode |
setConnectionTimeout(int connectionTimeoutInMillis)
Sets the connection timeout for new connections.
|
RiakNode |
setExecutor(ScheduledExecutorService executor)
Sets the
ScheduledExecutorService for this Node and its pool(s). |
RiakNode |
setIdleTimeout(int idleTimeoutInMillis)
Sets the connection idle timeout for connections.
|
RiakNode |
setMaxConnections(int maxConnections)
Sets the maximum number of connections allowed.
|
RiakNode |
setMinConnections(int minConnections)
Sets the minimum number of active connections to be maintained.
|
Future<Boolean> |
shutdown() |
RiakNode |
start() |
public RiakNode start()
public RiakNode setBootstrap(io.netty.bootstrap.Bootstrap bootstrap)
Bootstrap
for this Node's connections.
Bootstrap.clone()
is called to clone the bootstrap.bootstrap
- - the Netty Bootstrap to useIllegalArgumentException
- if it was already set via the builder.IllegalStateException
- if the node has already been started.RiakNode.Builder.withBootstrap(io.netty.bootstrap.Bootstrap)
public RiakNode setExecutor(ScheduledExecutorService executor)
ScheduledExecutorService
for this Node and its pool(s).executor
- - the ScheduledExecutorService to use.IllegalArgumentException
- if it was already set via the builder.IllegalStateException
- if the node has already been started.RiakNode.Builder.withExecutor(java.util.concurrent.ScheduledExecutorService)
public RiakNode setMaxConnections(int maxConnections)
maxConnections
- the maxConnections to set.RiakNode.Builder.withMaxConnections(int)
public int getMaxConnections()
RiakNode.Builder.withMaxConnections(int)
public RiakNode setMinConnections(int minConnections)
minConnections
- the minConnections to setRiakNode.Builder.withMinConnections(int)
public int getMinConnections()
RiakNode.Builder.withMinConnections(int)
public void setBlockOnMaxConnections(boolean block)
block
- true to block.RiakNode.Builder.withBlockOnMaxConnections(boolean)
public boolean getBlockOnMaxConnections()
RiakNode.Builder.withBlockOnMaxConnections(boolean)
public RiakNode setIdleTimeout(int idleTimeoutInMillis)
idleTimeoutInMillis
- the idleTimeout to setRiakNode.Builder.withIdleTimeout(int)
public int getIdleTimeout()
RiakNode.Builder.withIdleTimeout(int)
public RiakNode setConnectionTimeout(int connectionTimeoutInMillis)
connectionTimeoutInMillis
- the connectionTimeout to setRiakNode.Builder.withConnectionTimeout(int)
public int getConnectionTimeout()
RiakNode.Builder.withConnectionTimeout(int)
public int availablePermits()
RiakNode.Builder.withMaxConnections(int)
public void addStateListener(NodeStateListener listener)
public boolean removeStateListener(NodeStateListener listener)
public boolean execute(FutureOperation operation)
operation
- The operation to performtrue
if this operation was accepted, false
if there
were no available connections.IllegalStateException
- if this node is not in the RUNNING
or HEALTH_CHECKING
stateIllegalArgumentException
- if the protocol required for the operation is not supported by this nodepublic void onSuccess(io.netty.channel.Channel channel, RiakMessage response)
onSuccess
in interface RiakResponseListener
public void onRiakErrorResponse(io.netty.channel.Channel channel, RiakResponseException ex)
onRiakErrorResponse
in interface RiakResponseListener
public void onException(io.netty.channel.Channel channel, Throwable t)
onException
in interface RiakResponseListener
public String getRemoteAddress()
remoteAddress
for this RiakNodeString
public int getPort()
public RiakNode.State getNodeState()
Copyright © 2014. All rights reserved.