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 F >
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...
 

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

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

Constructor.

Internal method. Should not be used by user.

Parameters
implImplementation.

Member Function Documentation

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
RFunction return type. BinaryType should be specialized for the type if it is not primitive.
FCompute function type. Should implement ComputeFunc<R> class.
Parameters
funcCompute function to call.
Returns
Vector containing computation results.
Exceptions
IgniteErrorin case of error.
template<typename F >
void ignite::compute::Compute::Broadcast ( const F &  func)
inline

Broadcasts provided ComputeFunc to all nodes in the cluster group.

Template Parameters
FCompute function type. Should implement ComputeFunc<R> class.
Parameters
funcCompute function to call.
Exceptions
IgniteErrorin case of error.
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
RFunction return type. BinaryType should be specialized for the type if it is not primitive.
FCompute function type. Should implement ComputeFunc<R> class.
Parameters
funcCompute function to call.
Returns
Future that can be used to access computation results once they are ready.
Exceptions
IgniteErrorin case of error.
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
FCompute function type. Should implement ComputeFunc<R> class.
Parameters
funcCompute function to call.
Returns
Future that can be used to wait for action to complete.
Exceptions
IgniteErrorin case of error.
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
RCall 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().
FCompute function type. Should implement ComputeFunc<R> class.
Parameters
funcCompute function to call.
Returns
Computation result.
Exceptions
IgniteErrorin case of error.
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
RCall 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().
FCompute function type. Should implement ComputeFunc<R> class.
Parameters
funcCompute function to call.
Returns
Future that can be used to access computation result once it's ready.
Exceptions
IgniteErrorin case of error.
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
FCompute function type. Should implement ComputeFunc<void> class.
Parameters
actionCompute function to call.
Exceptions
IgniteErrorin case of error.
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
FCompute function type. Should implement ComputeFunc<void> class.
Parameters
actionCompute function to call.
Returns
Future that can be used to wait for action to complete.
Exceptions
IgniteErrorin case of error.

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