Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_CONNECTION_TIMEOUT
The default connection timeout in milliseconds if not specified: 0
|
static HealthCheckFactory |
DEFAULT_HEALTHCHECK_FACTORY
The default HealthCheckFactory.
|
static int |
DEFAULT_IDLE_TIMEOUT
The default idle timeout in milliseconds for connections if not specified: 1000
|
static int |
DEFAULT_MAX_CONNECTIONS
The default maximum number of connections allowed if not specified: 0
|
static int |
DEFAULT_MIN_CONNECTIONS
The default minimum number of connections to maintain if not specified: 1
|
static String |
DEFAULT_REMOTE_ADDRESS
The default remote address to be used if not specified: "127.0.0.1"
|
static int |
DEFAULT_REMOTE_PORT
The default port number to be used if not specified: 8087
|
Constructor and Description |
---|
RiakNode.Builder()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
RiakNode |
build()
Builds a RiakNode.
|
static List<RiakNode> |
buildNodes(RiakNode.Builder builder,
List<String> remoteAddresses)
Build a set of RiakNodes.
|
RiakNode.Builder |
withAuth(String username,
String password,
KeyStore trustStore)
Set the credentials for Riak security and authentication.
|
RiakNode.Builder |
withBlockOnMaxConnections(boolean block)
Set whether to block if all connections are in use.
|
RiakNode.Builder |
withBootstrap(io.netty.bootstrap.Bootstrap bootstrap)
Provides a Netty Bootstrap for this node to use.
|
RiakNode.Builder |
withConnectionTimeout(int connectionTimeoutInMillis)
Set the connection timeout used when making new connections
|
RiakNode.Builder |
withExecutor(ScheduledExecutorService executor)
Provides an executor for this node to use for internal maintenance tasks.
|
RiakNode.Builder |
withHealthCheck(HealthCheckFactory factory)
Set the HealthCheckFactory used to determine if this RiakNode is healthy.
|
RiakNode.Builder |
withIdleTimeout(int idleTimeoutInMillis)
Set the idle timeout used to reap inactive connections.
|
RiakNode.Builder |
withMaxConnections(int maxConnections)
Set the maximum number of connections allowed.
|
RiakNode.Builder |
withMinConnections(int minConnections)
Set the minimum number of active connections to maintain.
|
RiakNode.Builder |
withRemoteAddress(String remoteAddress)
Sets the remote address for this RiakNode.
|
RiakNode.Builder |
withRemotePort(int port)
Specifies the remote port for this RiakNode.
|
public static final String DEFAULT_REMOTE_ADDRESS
public static final int DEFAULT_REMOTE_PORT
public static final int DEFAULT_MIN_CONNECTIONS
public static final int DEFAULT_MAX_CONNECTIONS
public static final int DEFAULT_IDLE_TIMEOUT
public static final int DEFAULT_CONNECTION_TIMEOUT
public static final HealthCheckFactory DEFAULT_HEALTHCHECK_FACTORY
By default this is the PingHealthCheck
HealthCheckFactory
,
HealthCheckDecoder
public RiakNode.Builder()
public RiakNode.Builder withRemoteAddress(String remoteAddress)
remoteAddress
- Can either be a FQDN or IP addressRiakNode.Builder.DEFAULT_REMOTE_ADDRESS
public RiakNode.Builder withRemotePort(int port)
port
- - the portRiakNode.Builder.DEFAULT_REMOTE_PORT
public RiakNode.Builder withMinConnections(int minConnections)
minConnections
- - number of connections to maintain.RiakNode.Builder.DEFAULT_MIN_CONNECTIONS
public RiakNode.Builder withMaxConnections(int maxConnections)
maxConnections
- - maximum number of connections to allowRiakNode.Builder.DEFAULT_MAX_CONNECTIONS
public RiakNode.Builder withIdleTimeout(int idleTimeoutInMillis)
minConnections
has been set via RiakNode.Builder.withMinConnections(int)
idleTimeoutInMillis
- - idle timeout in millisecondsRiakNode.Builder.DEFAULT_IDLE_TIMEOUT
public RiakNode.Builder withConnectionTimeout(int connectionTimeoutInMillis)
connectionTimeoutInMillis
- RiakNode.Builder.DEFAULT_CONNECTION_TIMEOUT
public RiakNode.Builder withExecutor(ScheduledExecutorService executor)
Executors.newSingleThreadScheduledExecutor()
executor
- the ScheduledExecutorService to use.public RiakNode.Builder withBootstrap(io.netty.bootstrap.Bootstrap bootstrap)
NioEventLoopGroup
.bootstrap
- public RiakNode.Builder withBlockOnMaxConnections(boolean block)
If a maximum number of connections is specified and all those connections are in use, the default behavior when an operation is submitted to a node is to fail-fast and return. Setting this to true will cause the call to block (fair-scheduled, FIFO) until a connection becomes available.
block
- whether to block when an operation is submitted and
all connections are in use.public RiakNode.Builder withAuth(String username, String password, KeyStore trustStore)
Riak supports authentication and authorization features. These credentials will be used for all connections.
Note this requires Riak to have been configured with security enabled.
username
- the riak user name.password
- the password for this user.trustStore
- A Java KeyStore loaded with the CA certificate required for TLS/SSLpublic RiakNode.Builder withHealthCheck(HealthCheckFactory factory)
If not set the PingHealthCheck
is used.
factory
- a HealthCheckFactory instance that produces HealthCheckDecodersHealthCheckDecoder
public RiakNode build() throws UnknownHostException
Bootstrap
and/or a ScheduledExecutorService
has not been provided they
will be created.UnknownHostException
- if the DNS lookup fails for the supplied hostnamepublic static List<RiakNode> buildNodes(RiakNode.Builder builder, List<String> remoteAddresses) throws UnknownHostException
builder
- a configured builderremoteAddresses
- a list of IP addresses or FQDNUnknownHostException
- if a supplied FQDN can not be resolved.Copyright © 2014. All rights reserved.