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(@Nullable 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. |
SecurityCredentialsProvider |
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.
|
Map<String,String> |
getUserAttributes()
Returns user attributes which can be used on server node.
|
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.
|
GridClientConfiguration |
setAutoFetchAttributes(boolean autoFetchAttrs)
Sets flag indicating whether node attributes should be fetched by client automatically.
|
GridClientConfiguration |
setAutoFetchMetrics(boolean autoFetchMetrics)
Sets flag indicating whether node metrics should be fetched by client automatically.
|
GridClientConfiguration |
setBalancer(GridClientLoadBalancer balancer)
Sets default compute balancer.
|
GridClientConfiguration |
setConnectTimeout(int connectTimeout)
Sets timeout for socket connect operation.
|
GridClientConfiguration |
setDaemon(boolean daemon)
Set the daemon flag value.
|
GridClientConfiguration |
setDataConfigurations(Collection<? extends GridClientDataConfiguration> dataCfgs)
Sets data configurations.
|
GridClientConfiguration |
setEnableAttributesCache(boolean enableAttrsCache)
Sets flag indicating whether node attributes should be cached by client.
|
GridClientConfiguration |
setEnableMetricsCache(boolean enableMetricsCache)
Sets flag indicating whether node and cache metrics should be cached by client.
|
GridClientConfiguration |
setExecutorService(ExecutorService executor)
Sets executor service.
|
GridClientConfiguration |
setMarshaller(GridClientMarshaller marshaller)
Sets the marshaller to use for communication.
|
GridClientConfiguration |
setMaxConnectionIdleTime(long maxConnIdleTime)
Sets maximum time in milliseconds which connection can be idle before it is closed by client.
|
GridClientConfiguration |
setPingInterval(long pingInterval)
Sets ping interval in milliseconds.
|
GridClientConfiguration |
setPingTimeout(long pingTimeout)
Sets ping timeout in milliseconds.
|
GridClientConfiguration |
setProtocol(GridClientProtocol proto)
Sets protocol type that should be used in communication.
|
GridClientConfiguration |
setRouters(Collection<String> routers)
Sets list of routers this client should connect to.
|
GridClientConfiguration |
setSecurityCredentialsProvider(SecurityCredentialsProvider credProvider)
Sets client credentials provider used in authentication process.
|
GridClientConfiguration |
setServers(Collection<String> srvs)
Sets list of servers this client should connect to.
|
GridClientConfiguration |
setSslContextFactory(GridSslContextFactory sslCtxFactory)
Sets SSL context factory that will be used for creation of secure connections.
|
GridClientConfiguration |
setTcpNoDelay(boolean tcpNoDelay)
Sets whether
TCP_NODELAY flag should be set on underlying socket connections. |
GridClientConfiguration |
setTopologyRefreshFrequency(long topRefreshFreq)
Sets topology refresh frequency.
|
GridClientConfiguration |
setUserAttributes(Map<String,String> userAttrs)
Sets user attributes which can be used to send additional info to the server nodes.
|
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 GridClientConfiguration setServers(Collection<String> srvs)
srvs
- List of servers.this
for chaining.public GridClientConfiguration setRouters(Collection<String> routers)
routers
- List of routers.this
for chaining.public GridClientProtocol getProtocol()
DFLT_CLIENT_PROTOCOL
constant.public GridClientConfiguration setProtocol(GridClientProtocol proto)
proto
- Protocol type.this
for chaining.GridClientProtocol
public 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 GridClientConfiguration setTcpNoDelay(boolean tcpNoDelay)
TCP_NODELAY
flag should be set on underlying socket connections.tcpNoDelay
- True
if flag should be set.this
for chaining.public GridClientConfiguration setConnectTimeout(int connectTimeout)
connectTimeout
- Connect timeout in milliseconds.this
for chaining.public GridSslContextFactory getSslContextFactory()
null
then SSL is considered disabled.GridSslContextFactory
public GridClientConfiguration setSslContextFactory(GridSslContextFactory sslCtxFactory)
sslCtxFactory
- Context factory.this
for chaining.public GridClientLoadBalancer getBalancer()
GridClientRandomBalancer
is used.public GridClientConfiguration setBalancer(GridClientLoadBalancer balancer)
balancer
- Balancer to use.this
for chaining.public SecurityCredentialsProvider getSecurityCredentialsProvider()
public GridClientConfiguration setSecurityCredentialsProvider(SecurityCredentialsProvider credProvider)
credProvider
- Client credentials provider.this
for chaining.public Collection<GridClientDataConfiguration> getDataConfigurations()
public GridClientConfiguration setDataConfigurations(Collection<? extends GridClientDataConfiguration> dataCfgs)
dataCfgs
- Data configurations.this
for chaining.public GridClientDataConfiguration getDataConfiguration(@Nullable @Nullable String name)
name
- Name of grid cache.null
if there is not configuration for specified name.public GridClientConfiguration setEnableMetricsCache(boolean enableMetricsCache)
enableMetricsCache
- True
if cache should be enabled.this
for chaining.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 GridClientConfiguration setEnableAttributesCache(boolean enableAttrsCache)
enableAttrsCache
- True
if cache should be enabled.this
for chaining.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 GridClientConfiguration setAutoFetchMetrics(boolean autoFetchMetrics)
autoFetchMetrics
- True
if metrics should be fetched.this
for chaining.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 GridClientConfiguration setAutoFetchAttributes(boolean autoFetchAttrs)
autoFetchAttrs
- True
if attributes should be fetched.this
for chaining.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 GridClientConfiguration setTopologyRefreshFrequency(long topRefreshFreq)
topRefreshFreq
milliseconds.topRefreshFreq
- Topology refresh frequency in milliseconds.this
for chaining.public long getMaxConnectionIdleTime()
DFLT_MAX_CONN_IDLE_TIME
constant.public GridClientConfiguration setMaxConnectionIdleTime(long maxConnIdleTime)
maxConnIdleTime
- Maximum time of connection idleness in milliseconds.this
for chaining.public long getPingInterval()
DFLT_PING_INTERVAL
constant.
Ping requests used by GridClientProtocol.TCP
protocol
to detect network failures and half-opened sockets.
public GridClientConfiguration setPingInterval(long pingInterval)
pingInterval
- Ping interval in milliseconds.this
for chaining.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 GridClientConfiguration setPingTimeout(long pingTimeout)
pingTimeout
- Ping interval in milliseconds.this
for chaining.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 GridClientConfiguration setExecutorService(ExecutorService executor)
executor
- Executor service to use in client.this
for chaining.public GridClientMarshaller getMarshaller()
Options, that can be used out-of-the-box:
GridClientOptimizedMarshaller
(default) - Ignite's optimized marshaller.GridClientBinaryMarshaller
- Marshaller that supports binary objects.GridClientJdkMarshaller
- JDK marshaller (not recommended).public GridClientConfiguration setMarshaller(GridClientMarshaller marshaller)
marshaller
- A marshaller to use.this
for chaining.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 GridClientConfiguration setDaemon(boolean daemon)
daemon
- Daemon flag.this
for chaining.public boolean isDaemon()
public Map<String,String> getUserAttributes()
public GridClientConfiguration setUserAttributes(Map<String,String> userAttrs)
GridRestRequest
or
ClientListenerAbstractConnectionContext
(depends on client type).userAttrs
- User attributes.this
for chaining.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.10.0 Release Date : March 10 2021