public interface GridClientCompute
GridClient.compute() method. Further sub-projections may be created via
any of the projection(...) methods on this API.
You can create custom client projections based on any user-defined filtering. For example you can create a projection over a certain group of nodes, or over all nodes that have a certain attribute. Once projection is created, only nodes that belong to this projection will be contacted on remote grid for any operation. This essentially allows users to create virtual subgrids for remote task execution.
Use any of the execute(...) methods to execute tasks on remote grid. Note that tasks need
to be deployed to remote grid first prior to execution. You can also use any of the
affinityExecute(...) methods to execute tasks on node that have affinity with some data key.
This way you can collocate your computation with the data cached on remote nodes.
You can also use any of the refreshNode(...) or refreshTopology(...) methods
to eagerly refresh metrics or attributes on remote nodes (note that attributes are static,
so it is sufficient to fetch and cache them only once). Metrics and attributes will be
cached in GridClientNode instances automatically if GridClientConfiguration.isEnableMetricsCache()
or GridClientConfiguration.isEnableAttributesCache() property is set to true.
Compute client also allows fetching contents of remote log files (including backwards mode) via any of
the provided log(...) methods.
affinityExecute(String, String, Object, Object) and
affinityExecuteAsync(String, String, Object, Object) to synchronously
or asynchronously execute remote tasks on affinity nodes based on provided
affinity keys.| Modifier and Type | Method and Description |
|---|---|
<R> R |
affinityExecute(String taskName,
String cacheName,
Object affKey,
Object taskArg)
Executes task using cache affinity key for routing.
|
<R> GridClientFuture<R> |
affinityExecuteAsync(String taskName,
String cacheName,
Object affKey,
Object taskArg)
Asynchronously executes task using cache affinity key for routing.
|
GridClientLoadBalancer |
balancer()
Gets load balancer used by this projection.
|
Collection<GridClientNode> |
daemonNodes()
Gets most recently refreshed set of daemon nodes.
|
<R> R |
execute(String taskName,
Object taskArg)
Executes task on remote grid.
|
<R> GridClientFuture<R> |
executeAsync(String taskName,
Object taskArg)
Asynchronously executes task on remote grid.
|
GridClientNode |
node(UUID id)
Gets cached node with given id from most recently refreshed topology.
|
Collection<GridClientNode> |
nodes()
Gets most recently refreshed topology (only non-daemon nodes included).
|
Collection<GridClientNode> |
nodes(Collection<UUID> ids)
Gets cached nodes for the given IDs based on most recently refreshed topology.
|
Collection<GridClientNode> |
nodes(GridClientPredicate<GridClientNode> filter)
Gets all cached nodes that pass the filter.
|
GridClientCompute |
projection(Collection<GridClientNode> nodes)
Creates a projection that will communicate only with specified remote nodes.
|
GridClientCompute |
projection(Collection<GridClientNode> nodes,
GridClientLoadBalancer balancer)
Creates a projection that will communicate only with specified remote nodes.
|
GridClientCompute |
projection(GridClientNode node)
Creates a projection that will communicate only with specified remote node.
|
GridClientCompute |
projection(GridClientPredicate<? super GridClientNode> filter)
Creates a projection that will communicate only with nodes that are accepted by the passed filter.
|
GridClientCompute |
projection(GridClientPredicate<? super GridClientNode> filter,
GridClientLoadBalancer balancer)
Creates a projection that will communicate only with nodes that are accepted by the passed filter.
|
@Nullable GridClientNode |
refreshNode(String ip,
boolean includeAttrs,
boolean includeMetrics)
Refreshes and returns node by its IP address from remote grid.
|
GridClientNode |
refreshNode(UUID id,
boolean includeAttrs,
boolean includeMetrics)
Refreshes and returns node by its ID from remote grid.
|
GridClientFuture<GridClientNode> |
refreshNodeAsync(String ip,
boolean includeAttrs,
boolean includeMetrics)
Asynchronously refreshes and returns node by its IP address from remote grid.
|
GridClientFuture<GridClientNode> |
refreshNodeAsync(UUID id,
boolean includeAttrs,
boolean includeMetrics)
Asynchronously refreshes and returns node by its ID from remote grid.
|
List<GridClientNode> |
refreshTopology(boolean includeAttrs,
boolean includeMetrics)
Refreshes and returns all nodes within topology.
|
GridClientFuture<List<GridClientNode>> |
refreshTopologyAsync(boolean includeAttrs,
boolean includeMetrics)
Asynchronously refreshes and returns all nodes within topology.
|
GridClientCompute |
withKeepBinaries()
Sets keep binary flag for the next task execution in the current thread.
|
GridClientCompute projection(GridClientNode node) throws GridClientException
If current projection is dynamic projection, then this method will check is passed node is in topology. If any filters were specified in current topology, this method will check if passed node is accepted by the filter. If current projection was restricted to any subset of nodes, this method will check if passed node is in that subset. If any of the checks fails an exception will be thrown.
node - Single node to which this projection will be restricted.GridClientException - If resulting projection is empty.GridClientCompute projection(GridClientPredicate<? super GridClientNode> filter) throws GridClientException
If current projection is dynamic projection, then filter will be applied to the most relevant topology snapshot every time a node to communicate is selected. If current projection is a static projection, then resulting projection will only be restricted to nodes that were in parent projection and were accepted by the passed filter. If any of the checks fails an exception will be thrown.
filter - Filter that will select nodes for projection. If null,
then no filter would be applied to nodes in projection.GridClientException - If resulting projection is empty.GridClientCompute projection(Collection<GridClientNode> nodes) throws GridClientException
If current projection is dynamic projection, then this method will check is passed nodes are in topology. If any filters were specified in current topology, this method will check if passed nodes are accepted by the filter. If current projection was restricted to any subset of nodes, this method will check if passed nodes are in that subset (i.e. calculate the intersection of two collections). If any of the checks fails an exception will be thrown.
nodes - Collection of nodes to which this projection will be restricted. If null,
created projection is dynamic and will take nodes from topology.GridClientException - If resulting projection is empty.GridClientCompute projection(GridClientPredicate<? super GridClientNode> filter, GridClientLoadBalancer balancer) throws GridClientException
If current projection is dynamic projection, then filter will be applied to the most relevant topology snapshot every time a node to communicate is selected. If current projection is a static projection, then resulting projection will only be restricted to nodes that were in parent projection and were accepted by the passed filter. If any of the checks fails an exception will be thrown.
filter - Filter that will select nodes for projection. If null,
then no filter would be applied to nodes in projection.balancer - Balancer that will select balanced node in resulting projection. If null,
then balancer which was specified while projection construction will be used.GridClientException - If resulting projection is empty.GridClientCompute projection(Collection<GridClientNode> nodes, GridClientLoadBalancer balancer) throws GridClientException
If current projection is dynamic projection, then this method will check is passed nodes are in topology. If any filters were specified in current topology, this method will check if passed nodes are accepted by the filter. If current projection was restricted to any subset of nodes, this method will check if passed nodes are in that subset (i.e. calculate the intersection of two collections). If any of the checks fails an exception will be thrown.
nodes - Collection of nodes to which this projection will be restricted. If null,
then no filter would be applied to nodes in projection.balancer - Balancer that will select nodes in resulting projection. If null,
then balancer which was specified while projection construction will be used.GridClientException - If resulting projection is empty.GridClientLoadBalancer balancer()
GridClientConfiguration.getBalancer() property is used. User can
provide custom balancers for different projections via
projection(GridClientPredicate, GridClientLoadBalancer) method.GridClientLoadBalancer used by this projection.<R> R execute(String taskName, Object taskArg) throws GridClientException
taskName - Task name or task class name.taskArg - Optional task argument.GridClientException - In case of error.GridServerUnreachableException - If none of the servers can be reached.GridClientClosedException - If client was closed manually.<R> GridClientFuture<R> executeAsync(String taskName, Object taskArg)
taskName - Task name or task class name.taskArg - Optional task argument.<R> R affinityExecute(String taskName, String cacheName, Object affKey, Object taskArg) throws GridClientException
taskName - Task name or task class name.cacheName - Name of the cache on which affinity should be calculated. If null,
then default cache will be used.affKey - Affinity key.taskArg - Optional task argument.GridClientException - In case of error.GridServerUnreachableException - If none of the servers can be reached.GridClientClosedException - If client was closed manually.<R> GridClientFuture<R> affinityExecuteAsync(String taskName, String cacheName, Object affKey, Object taskArg)
taskName - Task name or task class name.cacheName - Name of the cache on which affinity should be calculated. If null,
then balancer which was specified while projection construction will be used.affKey - Affinity key.taskArg - Optional task argument.Collection<GridClientNode> nodes() throws GridClientException
GridClientException - If client doesn't have an actual topology version.GridClientNode node(UUID id) throws GridClientException
id - Node ID.null if node with given id was not found.GridClientException - If client doesn't have an actual topology version.Collection<GridClientNode> nodes(Collection<UUID> ids) throws GridClientException
ids - Node IDs.GridClientException - If client doesn't have an actual topology version.Collection<GridClientNode> nodes(GridClientPredicate<GridClientNode> filter) throws GridClientException
filter - Node filter.GridClientException - If client doesn't have an actual topology version.Collection<GridClientNode> daemonNodes() throws GridClientException
GridClientException - If client doesn't have an actual topology version.GridClientNode refreshNode(UUID id, boolean includeAttrs, boolean includeMetrics) throws GridClientException
includeAttrs and
includeMetrics parameters to automatically fetch remote node attributes and
metrics.
Note that fetched attributes and metrics may or may note be cached in GridClientNode
based on GridClientConfiguration.isEnableMetricsCache() and
GridClientConfiguration.isEnableAttributesCache() parameters. Even though topology
is refreshed automatically every GridClientConfiguration.getTopologyRefreshFrequency()
interval, node metrics and attributes will be fetched in background only if
GridClientConfiguration.isAutoFetchMetrics() or
GridClientConfiguration.isAutoFetchAttributes() set to true.
Also note that node attributes are static and, if cached, there is no need to refresh them again.
id - Node ID.includeAttrs - Whether to include node attributes.includeMetrics - Whether to include node metrics.null if node doesn't exist.GridClientException - In case request failed.GridServerUnreachableException - If none of the servers can be reached.GridClientClosedException - If client was closed manually.GridClientFuture<GridClientNode> refreshNodeAsync(UUID id, boolean includeAttrs, boolean includeMetrics)
includeAttrs and
includeMetrics parameters to automatically fetch remote node attributes and
metrics.
Note that fetched attributes and metrics may or may note be cached in GridClientNode
based on GridClientConfiguration.isEnableMetricsCache() and
GridClientConfiguration.isEnableAttributesCache() parameters. Even though topology
is refreshed automatically every GridClientConfiguration.getTopologyRefreshFrequency()
interval, node metrics and attributes will be fetched in background only if
GridClientConfiguration.isAutoFetchMetrics() or
GridClientConfiguration.isAutoFetchAttributes() set to true.
Also note that node attributes are static and, if cached, there is no need to refresh them again.
id - Node ID.includeAttrs - Whether to include node attributes.includeMetrics - Whether to include node metrics.@Nullable @Nullable GridClientNode refreshNode(String ip, boolean includeAttrs, boolean includeMetrics) throws GridClientException
includeAttrs and
includeMetrics parameters to automatically fetch remote node attributes and
metrics.
Note that fetched attributes and metrics may or may note be cached in GridClientNode
based on GridClientConfiguration.isEnableMetricsCache() and
GridClientConfiguration.isEnableAttributesCache() parameters. Even though topology
is refreshed automatically every GridClientConfiguration.getTopologyRefreshFrequency()
interval, node metrics and attributes will be fetched in background only if
GridClientConfiguration.isAutoFetchMetrics() or
GridClientConfiguration.isAutoFetchAttributes() set to true.
Also note that node attributes are static and, if cached, there is no need to refresh them again.
ip - IP address.includeAttrs - Whether to include node attributes.includeMetrics - Whether to include node metrics.null if node doesn't exist.GridClientException - In case of error.GridServerUnreachableException - If none of the servers can be reached.GridClientClosedException - If client was closed manually.GridClientFuture<GridClientNode> refreshNodeAsync(String ip, boolean includeAttrs, boolean includeMetrics)
includeAttrs and
includeMetrics parameters to automatically fetch remote node attributes and
metrics.
Note that fetched attributes and metrics may or may note be cached in GridClientNode
based on GridClientConfiguration.isEnableMetricsCache() and
GridClientConfiguration.isEnableAttributesCache() parameters. Even though topology
is refreshed automatically every GridClientConfiguration.getTopologyRefreshFrequency()
interval, node metrics and attributes will be fetched in background only if
GridClientConfiguration.isAutoFetchMetrics() or
GridClientConfiguration.isAutoFetchAttributes() set to true.
Also note that node attributes are static and, if cached, there is no need to refresh them again.
ip - IP address.includeAttrs - Whether to include node attributes.includeMetrics - Whether to include node metrics.List<GridClientNode> refreshTopology(boolean includeAttrs, boolean includeMetrics) throws GridClientException
includeAttrs and
includeMetrics parameters to automatically fetch remote node attributes and
metrics.
Note that fetched attributes and metrics may or may note be cached in GridClientNode
based on GridClientConfiguration.isEnableMetricsCache() and
GridClientConfiguration.isEnableAttributesCache() parameters. Even though topology
is refreshed automatically every GridClientConfiguration.getTopologyRefreshFrequency()
interval, node metrics and attributes will be fetched in background only if
GridClientConfiguration.isAutoFetchMetrics() or
GridClientConfiguration.isAutoFetchAttributes() set to true.
Also note that node attributes are static and, if cached, there is no need to refresh them again.
includeAttrs - Whether to include node attributes.includeMetrics - Whether to include node metrics.GridClientException - In case of error.GridServerUnreachableException - If none of the servers can be reached.GridClientClosedException - If client was closed manually.GridClientFuture<List<GridClientNode>> refreshTopologyAsync(boolean includeAttrs, boolean includeMetrics)
includeAttrs and
includeMetrics parameters to automatically fetch remote node attributes and
metrics.
Note that fetched attributes and metrics may or may note be cached in GridClientNode
based on GridClientConfiguration.isEnableMetricsCache() and
GridClientConfiguration.isEnableAttributesCache()parameters. Even though topology
is refreshed automatically every GridClientConfiguration.getTopologyRefreshFrequency()
interval, node metrics and attributes will be fetched in background only if
GridClientConfiguration.isAutoFetchMetrics() or
GridClientConfiguration.isAutoFetchAttributes() set to true.
Also note that node attributes are static and, if cached, there is no need to refresh them again.
includeAttrs - Whether to include node attributes.includeMetrics - Whether to include node metrics.GridClientCompute withKeepBinaries()
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.10.0 Release Date : March 10 2021