public class GridClientConfiguration extends Object
| Modifier and Type | Field and Description |
|---|---|
static GridClientProtocol |
DFLT_CLIENT_PROTOCOL
Default client protocol.
|
static int |
DFLT_CONNECT_TIMEOUT
Default connect timeout in milliseconds.
|
static long |
DFLT_MAX_CONN_IDLE_TIME
Default maximum time connection can be idle.
|
static long |
DFLT_PING_INTERVAL
Default ping interval in milliseconds.
|
static long |
DFLT_PING_TIMEOUT
Default ping timeout in milliseconds.
|
static boolean |
DFLT_TCP_NODELAY
Default flag setting for TCP_NODELAY option.
|
static int |
DFLT_TOP_REFRESH_FREQ
Default topology refresh frequency is 2 sec.
|
| Constructor and Description |
|---|
GridClientConfiguration()
Creates default configuration.
|
GridClientConfiguration(GridClientConfiguration cfg)
Copy constructor.
|
GridClientConfiguration(Properties in)
Creates properties-based configuration based on passed in properties.
|
GridClientConfiguration(String prefix,
Properties in)
Creates properties-based configuration.
|
| Modifier and Type | Method and Description |
|---|---|
GridClientLoadBalancer |
getBalancer()
Default balancer to be used for computational client.
|
int |
getConnectTimeout()
Gets timeout for socket connect operation in milliseconds.
|
GridClientDataConfiguration |
getDataConfiguration(String name)
Gets data configuration for a cache with specified name.
|
Collection<GridClientDataConfiguration> |
getDataConfigurations()
Gets a collection of data configurations specified by user.
|
ExecutorService |
getExecutorService()
Gets
ExecutorService where client could run asynchronous operations. |
GridClientMarshaller |
getMarshaller()
Gets the marshaller, that is used to communicate between client and server.
|
long |
getMaxConnectionIdleTime()
Gets maximum amount of time that client connection can be idle before it is closed.
|
long |
getPingInterval()
Gets time interval in milliseconds between ping requests.
|
long |
getPingTimeout()
Gets ping timeout.
|
GridClientProtocol |
getProtocol()
Gets protocol for communication between client and remote grid.
|
Collection<String> |
getRouters()
Collection of
'host:port' pairs representing
grid routers used to establish connection to the grid. |
GridSecurityCredentialsProvider |
getSecurityCredentialsProvider()
Gets client credentials provider to authenticate with.
|
Collection<String> |
getServers()
Collection of
'host:port' pairs representing
remote grid servers used to establish initial connection to
the grid. |
GridSslContextFactory |
getSslContextFactory()
Gets a factory that should be used for SSL context creation.
|
long |
getTopologyRefreshFrequency()
Gets topology refresh frequency.
|
boolean |
isAutoFetchAttributes()
Allows client to fetch node attributes automatically with background topology refresh.
|
boolean |
isAutoFetchMetrics()
Allows client to fetch node metrics automatically with background topology refresh.
|
boolean |
isDaemon()
Get the daemon flag.
|
boolean |
isEnableAttributesCache()
Enables client to cache per-node attributes internally.
|
boolean |
isEnableMetricsCache()
Enables client to cache per-node and per-cache metrics internally.
|
boolean |
isTcpNoDelay()
Gets flag indicating whether
TCP_NODELAY flag should be enabled for outgoing connections. |
void |
load(String prefix,
Properties in)
Load client configuration from the properties map.
|
void |
setAutoFetchAttributes(boolean autoFetchAttrs)
Sets flag indicating whether node attributes should be fetched by client automatically.
|
void |
setAutoFetchMetrics(boolean autoFetchMetrics)
Sets flag indicating whether node metrics should be fetched by client automatically.
|
void |
setBalancer(GridClientLoadBalancer balancer)
Sets default compute balancer.
|
void |
setConnectTimeout(int connectTimeout)
Sets timeout for socket connect operation.
|
void |
setDaemon(boolean daemon)
Set the daemon flag value.
|
void |
setDataConfigurations(Collection<? extends GridClientDataConfiguration> dataCfgs)
Sets data configurations.
|
void |
setEnableAttributesCache(boolean enableAttrsCache)
Sets flag indicating whether node attributes should be cached by client.
|
void |
setEnableMetricsCache(boolean enableMetricsCache)
Sets flag indicating whether node and cache metrics should be cached by client.
|
void |
setExecutorService(ExecutorService executor)
Sets executor service.
|
void |
setMarshaller(GridClientMarshaller marshaller)
Sets the marshaller to use for communication.
|
void |
setMaxConnectionIdleTime(long maxConnIdleTime)
Sets maximum time in milliseconds which connection can be idle before it is closed by client.
|
void |
setPingInterval(long pingInterval)
Sets ping interval in milliseconds.
|
void |
setPingTimeout(long pingTimeout)
Sets ping timeout in milliseconds.
|
void |
setProtocol(GridClientProtocol proto)
Sets protocol type that should be used in communication.
|
void |
setRouters(Collection<String> routers)
Sets list of routers this client should connect to.
|
void |
setSecurityCredentialsProvider(GridSecurityCredentialsProvider credProvider)
Sets client credentials provider used in authentication process.
|
void |
setServers(Collection<String> srvs)
Sets list of servers this client should connect to.
|
void |
setSslContextFactory(GridSslContextFactory sslCtxFactory)
Sets SSL context factory that will be used for creation of secure connections.
|
void |
setTcpNoDelay(boolean tcpNoDelay)
Sets whether
TCP_NODELAY flag should be set on underlying socket connections. |
void |
setTopologyRefreshFrequency(long topRefreshFreq)
Sets topology refresh frequency.
|
public static final GridClientProtocol DFLT_CLIENT_PROTOCOL
public static final int DFLT_TOP_REFRESH_FREQ
public static final long DFLT_MAX_CONN_IDLE_TIME
public static final long DFLT_PING_INTERVAL
public static final long DFLT_PING_TIMEOUT
public static final int DFLT_CONNECT_TIMEOUT
public static final boolean DFLT_TCP_NODELAY
public GridClientConfiguration()
public GridClientConfiguration(GridClientConfiguration cfg)
cfg - Configuration to be copied.public GridClientConfiguration(Properties in) throws GridClientException
in - Client configuration in properties format.GridClientException - If parsing configuration failed.public GridClientConfiguration(String prefix, Properties in) throws GridClientException
prefix - Prefix for the client properties.in - Properties map to load configuration from.GridClientException - If parsing configuration failed.public Collection<String> getServers()
'host:port' pairs representing
remote grid servers used to establish initial connection to
the grid. Once connection is established, Ignite will get
a full view on grid topology and will be able to connect to
any available remote node.
Note that only these addresses are used to perform topology updates in background and to detect Grid connectivity status.
'host:port' pairs representing remote
grid servers.GridClient.connected()public Collection<String> getRouters()
'host:port' pairs representing
grid routers used to establish connection to the grid.
Addresses here could be owned by Routers as well as by individual Grid nodes. No additional connections will be made even if other Grid nodes are available.
This configuration mode is designated for cases when some Grid nodes are unavailable (due to security restrictions for example). So only few nodes acting as routers or dedicated router components used to access entire Grid.
This configuration parameter will not be used and direct
connections to all grid nodes will be established if
getServers() return non-empty collection value.
Note that only these addresses are used to perform topology updates in background and to detect Grid connectivity status.
'host:port' pairs
representing routers.GridClient.connected()public void setServers(Collection<String> srvs)
srvs - List of servers.public void setRouters(Collection<String> routers)
routers - List of routers.public GridClientProtocol getProtocol()
DFLT_CLIENT_PROTOCOL constant.public void setProtocol(GridClientProtocol proto)
proto - Protocol type.GridClientProtocolpublic int getConnectTimeout()
0 -
then wait infinitely. Default is defined by DFLT_CONNECT_TIMEOUT constant.public boolean isTcpNoDelay()
TCP_NODELAY flag should be enabled for outgoing connections.
This flag reduces communication latency and in the majority of cases should be set to true. For more
information, see Socket.setTcpNoDelay(boolean)
If not set, default value is DFLT_TCP_NODELAY
TCP_NODELAY should be set on underlying sockets.public void setTcpNoDelay(boolean tcpNoDelay)
TCP_NODELAY flag should be set on underlying socket connections.tcpNoDelay - True if flag should be set.public void setConnectTimeout(int connectTimeout)
connectTimeout - Connect timeout in milliseconds.public GridSslContextFactory getSslContextFactory()
null then SSL is considered disabled.GridSslContextFactorypublic void setSslContextFactory(GridSslContextFactory sslCtxFactory)
sslCtxFactory - Context factory.public GridClientLoadBalancer getBalancer()
GridClientRandomBalancer
is used.public void setBalancer(GridClientLoadBalancer balancer)
balancer - Balancer to use.public GridSecurityCredentialsProvider getSecurityCredentialsProvider()
public void setSecurityCredentialsProvider(GridSecurityCredentialsProvider credProvider)
credProvider - Client credentials provider.public Collection<GridClientDataConfiguration> getDataConfigurations()
public void setDataConfigurations(Collection<? extends GridClientDataConfiguration> dataCfgs)
dataCfgs - Data configurations.public GridClientDataConfiguration getDataConfiguration(@Nullable String name)
name - Name of grid cache.null if there is not configuration for specified name.public void setEnableMetricsCache(boolean enableMetricsCache)
enableMetricsCache - True if cache should be enabled.public boolean isEnableMetricsCache()
false.
Note that topology is refreshed automatically every getTopologyRefreshFrequency()
interval, and if isAutoFetchMetrics() enabled then metrics will be updated
with that frequency.
By default this value is true which means that metrics will be cached
on the client side.
True if metrics cache is enabled, false otherwise.public void setEnableAttributesCache(boolean enableAttrsCache)
enableAttrsCache - True if cache should be enabled.public boolean isEnableAttributesCache()
false.
Note that node attributes are static and, if cached, there is no need
to refresh them again. If isAutoFetchAttributes() is enabled then
attributes will be cached during client initialization.
By default this value is true which means that node attributes
will be cached on the client side.
True if attributes cache is enabled, false otherwise.public void setAutoFetchMetrics(boolean autoFetchMetrics)
autoFetchMetrics - True if metrics should be fetched.public boolean isAutoFetchMetrics()
Note that this parameter will only affect auto-fetching of node metrics.
Cache metrics still need to be fetched explicitly via
GridClientData.metrics() or GridClientData.metricsAsync() methods.
By default this value is true which means that metrics will be fetched
automatically.
true if client should fetch metrics on topology refresh,
false otherwise.public void setAutoFetchAttributes(boolean autoFetchAttrs)
autoFetchAttrs - True if attributes should be fetched.public boolean isAutoFetchAttributes()
By default this value is true which means that attributes will be fetched
automatically.
True if client should fetch attributes once on topology refresh,
false otherwise.public long getTopologyRefreshFrequency()
DFLT_TOP_REFRESH_FREQ
constant.public void setTopologyRefreshFrequency(long topRefreshFreq)
topRefreshFreq milliseconds.topRefreshFreq - Topology refresh frequency in milliseconds.public long getMaxConnectionIdleTime()
DFLT_MAX_CONN_IDLE_TIME constant.public void setMaxConnectionIdleTime(long maxConnIdleTime)
maxConnIdleTime - Maximum time of connection idleness in milliseconds.public long getPingInterval()
DFLT_PING_INTERVAL constant.
Ping requests used by GridClientProtocol.TCP protocol
to detect network failures and half-opened sockets.
public void setPingInterval(long pingInterval)
pingInterval - Ping interval in milliseconds.public long getPingTimeout()
DFLT_PING_TIMEOUT constant.
Ping requests used by GridClientProtocol.TCP protocol
to detect network failures and half-opened sockets.
If no response received in period equal to this timeout than connection
considered broken and closed.
public void setPingTimeout(long pingTimeout)
pingTimeout - Ping interval in milliseconds.public ExecutorService getExecutorService()
ExecutorService where client could run asynchronous operations.
When using GridClientProtocol.TCP this executor should be able to serve at least
Runtime.getRuntime().availableProcessors() parallel tasks.
Note that this executor will be automatically shut down when client get closed.
ExecutorService instance to use.public void setExecutorService(ExecutorService executor)
executor - Executor service to use in client.public GridClientMarshaller getMarshaller()
Options, that can be used out-of-the-box:
GridClientOptimizedMarshaller (default) - Ignite's optimized marshaller.GridClientPortableMarshaller - Marshaller that supports portable objects.GridClientJdkMarshaller - JDK marshaller (not recommended).public void setMarshaller(GridClientMarshaller marshaller)
marshaller - A marshaller to use.public void load(String prefix, Properties in) throws GridClientException
prefix - Prefix for the client properties.in - Properties map to load configuration from.GridClientException - If parsing configuration failed.public void setDaemon(boolean daemon)
daemon - Daemon flag.public boolean isDaemon()
Follow @ApacheIgnite
Ignite Fabric : ver. 1.0.0 Release Date : March 31 2015