| Apache Ignite C++

Public Member Functions | List of all members
ignite::compute::Compute Class Reference

Defines compute grid functionality for executing tasks and closures over nodes in the ClusterGroup. More...

`#include <compute.h>`

## Public Member Functions
| Compute (common::concurrent::SharedPointer< impl::compute::ComputeImpl > impl)
| Constructor. More...
template<typename R , typename K , typename F >
R | AffinityCall (const std::string &cacheName, const K &key, const F &func)
| Executes given job on the node where data for provided affinity key is located (a.k.a. More...
template<typename R , typename K , typename F >
Future< R > | AffinityCallAsync (const std::string &cacheName, const K &key, const F &func)
| Executes given job asynchronously on the node where data for provided affinity key is located (a.k.a. More...
template<typename K , typename F >
void | AffinityRun (const std::string &cacheName, const K &key, const F &action)
| Executes given job on the node where data for provided affinity key is located (a.k.a. More...
template<typename K , typename F >
Future< void > | AffinityRunAsync (const std::string &cacheName, const K &key, const F &action)
| Executes given job asynchronously on the node where data for provided affinity key is located (a.k.a. More...
template<typename R , typename F >
R | Call (const F &func)
| Calls provided ComputeFunc on a node within the underlying cluster group. More...
template<typename R , typename F >
Future< R > | CallAsync (const F &func)
| Asyncronuously calls provided ComputeFunc on a node within the underlying cluster group. More...
template<typename F >
void | Run (const F &action)
| Runs provided ComputeFunc on a node within the underlying cluster group. More...
template<typename F >
Future< void > | RunAsync (const F &action)
| Asyncronuously runs provided ComputeFunc on a node within the underlying cluster group. More...
template<typename R , typename F >
std::vector< R > | Broadcast (const F &func)
| Broadcasts provided ComputeFunc to all nodes in the cluster group. More...
template<typename F >
void | Broadcast (const F &func)
| Broadcasts provided ComputeFunc to all nodes in the cluster group. More...
template<typename R , typename F >
Future< std::vector< R > > | BroadcastAsync (const F &func)
| Asyncronuously broadcasts provided ComputeFunc to all nodes in the cluster group. More...
template<typename F >
Future< void > | BroadcastAsync (const F &func)
| Asyncronuously broadcasts provided ComputeFunc to all nodes in the cluster group. More...
template<typename R , typename A >
R | ExecuteJavaTask (const std::string &taskName, const A &taskArg)
| Executes given Java task on the grid projection. More...
template<typename R >
R | ExecuteJavaTask (const std::string &taskName)
| Executes given Java task on the grid projection. More...
template<typename R , typename A >
Future< R > | ExecuteJavaTaskAsync (const std::string &taskName, const A &taskArg)
| Asynchronously executes given Java task on the grid projection. More...
template<typename R >
Future< R > | ExecuteJavaTaskAsync (const std::string &taskName)
| Asynchronously executes given Java task on the grid projection. More...

## Detailed Description

Defines compute grid functionality for executing tasks and closures over nodes in the ClusterGroup.

Instance of Compute is obtained from Ignite as follows:

Ignite node = Ignition::Get();
// Compute over all nodes in the cluster.
Compute c = node.GetCompute();

Load Balancing
  In all cases other than `Broadcast(...)`, Ignite must select a node for a computation to be executed. The node will be selected based on the underlying `LoadBalancingSpi`, which by default sequentially picks next available node from the underlying cluster group. Other load balancing policies, such as `random` or `adaptive`, can be configured as well by selecting a different load balancing SPI in Ignite configuration.

Fault Tolerance
  Ignite guarantees that as long as there is at least one grid node standing, every job will be executed. Jobs will automatically failover to another node if a remote node crashed or has rejected execution due to lack of resources. By default, in case of failover, next load balanced node will be picked for job execution. Also jobs will never be re-routed to the nodes they have failed on. This behavior can be changed by configuring any of the existing or a custom FailoverSpi in grid configuration.

Computation SPIs
  Note that regardless of which method is used for executing computations, all relevant SPI implementations configured for this compute instance will be used (i.e. failover, load balancing, collision resolution, checkpoints, etc.).

## Constructor & Destructor Documentation

## ◆ Compute()

ignite::compute::Compute::Compute | ( | common::concurrent::SharedPointer< impl::compute::ComputeImpl > | impl | ) |
| inline

Constructor.

Internal method. Should not be used by user.

Parameters

  impl | Implementation.

## Member Function Documentation

## ◆ AffinityCall()

template<typename R , typename K , typename F >

R ignite::compute::Compute::AffinityCall | ( | const std::string & | cacheName,
|  | const K & | key,
|  | const F & | func
| ) |  |
| inline

Executes given job on the node where data for provided affinity key is located (a.k.a.

affinity co-location).

Template Parameters

  R | Call return type. BinaryType should be specialized for the type if it is not primitive. Should not be void. For non-returning methods see Compute::AffinityRun().
  K | Affinity key type.
  F | Compute function type. Should implement ComputeFunc<R> class.

Parameters

  cacheName | Cache name to use for affinity co-location.
  key | Affinity key.
  func | Compute function to call.

Returns
  Computation result.

Exceptions

  IgniteError | in case of error.

## ◆ AffinityCallAsync()

template<typename R , typename K , typename F >

Future<R> ignite::compute::Compute::AffinityCallAsync | ( | const std::string & | cacheName,
|  | const K & | key,
|  | const F & | func
| ) |  |
| inline

Executes given job asynchronously on the node where data for provided affinity key is located (a.k.a.

affinity co-location).

Template Parameters

  R | Call return type. BinaryType should be specialized for the type if it is not primitive. Should not be void. For non-returning methods see Compute::AffinityRun().
  K | Affinity key type.
  F | Compute function type. Should implement ComputeFunc<R> class.

Parameters

  cacheName | Cache name to use for affinity co-location.
  key | Affinity key.
  func | Compute function to call.

Returns
  Future that can be used to access computation result once it's ready.

Exceptions

  IgniteError | in case of error.

## ◆ AffinityRun()

template<typename K , typename F >

void ignite::compute::Compute::AffinityRun | ( | const std::string & | cacheName,
|  | const K & | key,
|  | const F & | action
| ) |  |
| inline

Executes given job on the node where data for provided affinity key is located (a.k.a.

affinity co-location).

Template Parameters

  K | Affinity key type.
  F | Compute function type. Should implement ComputeFunc<R> class.

Parameters

  cacheName | Cache names to use for affinity co-location.
  key | Affinity key.
  action | Compute action to call.

Exceptions

  IgniteError | in case of error.

## ◆ AffinityRunAsync()

template<typename K , typename F >

Future<void> ignite::compute::Compute::AffinityRunAsync | ( | const std::string & | cacheName,
|  | const K & | key,
|  | const F & | action
| ) |  |
| inline

Executes given job asynchronously on the node where data for provided affinity key is located (a.k.a.

affinity co-location).

Template Parameters

  K | Affinity key type.
  F | Compute function type. Should implement ComputeFunc<R> class.

Parameters

  cacheName | Cache names to use for affinity co-location.
  key | Affinity key.
  action | Compute action to call.

Returns
  Future that can be used to access computation result once it's ready.

Exceptions

  IgniteError | in case of error.

## ◆ Broadcast() [1/2]

template<typename R , typename F >

std::vector<R> ignite::compute::Compute::Broadcast | ( | const F & | func | ) |
| inline

Broadcasts provided ComputeFunc to all nodes in the cluster group.

Template Parameters

  R | Function return type. BinaryType should be specialized for the type if it is not primitive.
  F | Compute function type. Should implement ComputeFunc<R> class.

Parameters

  func | Compute function to call.

Returns
  Vector containing computation results.

Exceptions

  IgniteError | in case of error.

## ◆ Broadcast() [2/2]

template<typename F >

void ignite::compute::Compute::Broadcast | ( | const F & | func | ) |
| inline

Broadcasts provided ComputeFunc to all nodes in the cluster group.

Template Parameters

  F | Compute function type. Should implement ComputeFunc<R> class.

Parameters

  func | Compute function to call.

Exceptions

  IgniteError | in case of error.

## ◆ BroadcastAsync() [1/2]

template<typename R , typename F >

Future< std::vector<R> > ignite::compute::Compute::BroadcastAsync | ( | const F & | func | ) |
| inline

Asyncronuously broadcasts provided ComputeFunc to all nodes in the cluster group.

Template Parameters

  R | Function return type. BinaryType should be specialized for the type if it is not primitive.
  F | Compute function type. Should implement ComputeFunc<R> class.

Parameters

  func | Compute function to call.

Returns
  Future that can be used to access computation results once they are ready.

Exceptions

  IgniteError | in case of error.

## ◆ BroadcastAsync() [2/2]

template<typename F >

Future<void> ignite::compute::Compute::BroadcastAsync | ( | const F & | func | ) |
| inline

Asyncronuously broadcasts provided ComputeFunc to all nodes in the cluster group.

Template Parameters

  F | Compute function type. Should implement ComputeFunc<R> class.

Parameters

  func | Compute function to call.

Returns
  Future that can be used to wait for action to complete.

Exceptions

  IgniteError | in case of error.

## ◆ Call()

template<typename R , typename F >

R ignite::compute::Compute::Call | ( | const F & | func | ) |
| inline

Calls provided ComputeFunc on a node within the underlying cluster group.

Template Parameters

  R | Call return type. BinaryType should be specialized for the type if it is not primitive. Should not be void. For non-returning methods see Compute::Run().
  F | Compute function type. Should implement ComputeFunc<R> class.

Parameters

  func | Compute function to call.

Returns
  Computation result.

Exceptions

  IgniteError | in case of error.

## ◆ CallAsync()

template<typename R , typename F >

Future<R> ignite::compute::Compute::CallAsync | ( | const F & | func | ) |
| inline

Asyncronuously calls provided ComputeFunc on a node within the underlying cluster group.

Template Parameters

  R | Call return type. BinaryType should be specialized for the type if it is not primitive. Should not be void. For non-returning methods see Compute::Run().
  F | Compute function type. Should implement ComputeFunc<R> class.

Parameters

  func | Compute function to call.

Returns
  Future that can be used to access computation result once it's ready.

Exceptions

  IgniteError | in case of error.

## ◆ ExecuteJavaTask() [1/2]

template<typename R >

R ignite::compute::Compute::ExecuteJavaTask | ( | const std::string & | taskName | ) |
| inline

Executes given Java task on the grid projection.

If task for given name has not been deployed yet, then 'taskName' will be used as task class name to auto-deploy the task.

Parameters

  taskName | Java task name.

Returns
  Task result of type `R`.

Template Parameters

  R | Type of task result.

## ◆ ExecuteJavaTask() [2/2]

template<typename R , typename A >

R ignite::compute::Compute::ExecuteJavaTask | ( | const std::string & | taskName,
|  | const A & | taskArg
| ) |  |
| inline

Executes given Java task on the grid projection.

If task for given name has not been deployed yet, then 'taskName' will be used as task class name to auto-deploy the task.

Parameters

  taskName | Java task name.
  taskArg | Argument of task execution of type A.

Returns
  Task result of type `R`.

Template Parameters

  R | Type of task result.
  A | Type of task argument.

## ◆ ExecuteJavaTaskAsync() [1/2]

template<typename R >

Future<R> ignite::compute::Compute::ExecuteJavaTaskAsync | ( | const std::string & | taskName | ) |
| inline

Asynchronously executes given Java task on the grid projection.

If task for given name has not been deployed yet, then 'taskName' will be used as task class name to auto-deploy the task.

Parameters

  taskName | Java task name.

Returns
  Future containing a result of type `R`.

Template Parameters

  R | Type of task result.

## ◆ ExecuteJavaTaskAsync() [2/2]

template<typename R , typename A >

Future<R> ignite::compute::Compute::ExecuteJavaTaskAsync | ( | const std::string & | taskName,
|  | const A & | taskArg
| ) |  |
| inline

Asynchronously executes given Java task on the grid projection.

If task for given name has not been deployed yet, then 'taskName' will be used as task class name to auto-deploy the task.

Parameters

  taskName | Java task name.
  taskArg | Argument of task execution of type A.

Returns
  Future containing a result of type `R`.

Template Parameters

  R | Type of task result.
  A | Type of task argument.

## ◆ Run()

template<typename F >

void ignite::compute::Compute::Run | ( | const F & | action | ) |
| inline

Runs provided ComputeFunc on a node within the underlying cluster group.

Template Parameters

  F | Compute function type. Should implement ComputeFunc<void> class.

Parameters

  action | Compute function to call.

Exceptions

  IgniteError | in case of error.

## ◆ RunAsync()

template<typename F >

Future<void> ignite::compute::Compute::RunAsync | ( | const F & | action | ) |
| inline

Asyncronuously runs provided ComputeFunc on a node within the underlying cluster group.

Template Parameters

  F | Compute function type. Should implement ComputeFunc<void> class.

Parameters

  action | Compute function to call.

Returns
  Future that can be used to wait for action to complete.

Exceptions

  IgniteError | in case of error.

The documentation for this class was generated from the following file:

- compute.h

ignite::compute::Compute::Compute
Compute(common::concurrent::SharedPointer< impl::compute::ComputeImpl > impl)
Constructor.
Definition: compute.h:84
ignite::Ignition::Get
static Ignite Get()
Get default Ignite instance.
Definition: ignition.cpp:364