GridGain C++
compute.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 GridGain Systems, Inc. and Contributors.
3  *
4  * Licensed under the GridGain Community Edition License (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * https://www.gridgain.com/products/software/community-edition/gridgain-community-edition-license
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
22 #ifndef _IGNITE_COMPUTE_COMPUTE
23 #define _IGNITE_COMPUTE_COMPUTE
24 
25 #include <ignite/common/common.h>
26 
27 #include <ignite/ignite_error.h>
28 #include <ignite/future.h>
30 
31 #include <ignite/impl/compute/compute_impl.h>
32 
33 namespace ignite
34 {
35  namespace compute
36  {
73  class IGNITE_IMPORT_EXPORT Compute
74  {
75  public:
83  Compute(common::concurrent::SharedPointer<impl::compute::ComputeImpl> impl) :
84  impl(impl)
85  {
86  // No-op.
87  }
88 
105  template<typename R, typename K, typename F>
106  R AffinityCall(const std::string& cacheName, const K& key, const F& func)
107  {
108  return impl.Get()->AffinityCallAsync<R, K, F>(cacheName, key, func).GetValue();
109  }
110 
128  template<typename R, typename K, typename F>
129  Future<R> AffinityCallAsync(const std::string& cacheName, const K& key, const F& func)
130  {
131  return impl.Get()->AffinityCallAsync<R, K, F>(cacheName, key, func);
132  }
133 
146  template<typename K, typename F>
147  void AffinityRun(const std::string& cacheName, const K& key, const F& action)
148  {
149  return impl.Get()->AffinityRunAsync<K, F>(cacheName, key, action).GetValue();
150  }
151 
166  template<typename K, typename F>
167  Future<void> AffinityRunAsync(const std::string& cacheName, const K& key, const F& action)
168  {
169  return impl.Get()->AffinityRunAsync<K, F>(cacheName, key, action);
170  }
171 
185  template<typename R, typename F>
186  R Call(const F& func)
187  {
188  return impl.Get()->CallAsync<R, F>(func).GetValue();
189  }
190 
205  template<typename R, typename F>
206  Future<R> CallAsync(const F& func)
207  {
208  return impl.Get()->CallAsync<R, F>(func);
209  }
210 
220  template<typename F>
221  void Run(const F& action)
222  {
223  return impl.Get()->RunAsync<F>(action).GetValue();
224  }
225 
236  template<typename F>
237  Future<void> RunAsync(const F& action)
238  {
239  return impl.Get()->RunAsync<F>(action);
240  }
241 
253  template<typename R, typename F>
254  std::vector<R> Broadcast(const F& func)
255  {
256  return impl.Get()->BroadcastAsync<R, F>(func).GetValue();
257  }
258 
267  template<typename F>
268  void Broadcast(const F& func)
269  {
270  impl.Get()->BroadcastAsync<F, false>(func).GetValue();
271  }
272 
286  template<typename R, typename F>
288  {
289  return impl.Get()->BroadcastAsync<R, F>(func);
290  }
291 
302  template<typename F>
304  {
305  return impl.Get()->BroadcastAsync<F, false>(func);
306  }
307 
319  template<typename R, typename A>
320  R ExecuteJavaTask(const std::string& taskName, const A& taskArg)
321  {
322  return impl.Get()->ExecuteJavaTask<R, A>(taskName, taskArg);
323  }
324 
334  template<typename R>
335  R ExecuteJavaTask(const std::string& taskName)
336  {
337  return impl.Get()->ExecuteJavaTask<R>(taskName);
338  }
339 
351  template<typename R, typename A>
352  Future<R> ExecuteJavaTaskAsync(const std::string& taskName, const A& taskArg)
353  {
354  return impl.Get()->ExecuteJavaTaskAsync<R, A>(taskName, taskArg);
355  }
356 
366  template<typename R>
367  Future<R> ExecuteJavaTaskAsync(const std::string& taskName)
368  {
369  return impl.Get()->ExecuteJavaTaskAsync<R>(taskName);
370  }
371 
372  private:
374  common::concurrent::SharedPointer<impl::compute::ComputeImpl> impl;
375  };
376  }
377 }
378 
379 #endif //_IGNITE_COMPUTE_COMPUTE
ignite::compute::Compute
Defines compute grid functionality for executing tasks and closures over nodes in the ClusterGroup.
Definition: compute.h:73
ignite
Ignite API.
Definition: cache.h:47
future.h
ignite::compute::Compute::Broadcast
std::vector< R > Broadcast(const F &func)
Broadcasts provided ComputeFunc to all nodes in the cluster group.
Definition: compute.h:254
ignite::compute::Compute::RunAsync
Future< void > RunAsync(const F &action)
Asyncronuously runs provided ComputeFunc on a node within the underlying cluster group.
Definition: compute.h:237
ignite::compute::Compute::CallAsync
Future< R > CallAsync(const F &func)
Asyncronuously calls provided ComputeFunc on a node within the underlying cluster group.
Definition: compute.h:206
ignite::Future
Future class template.
Definition: future.h:51
ignite::compute::Compute::ExecuteJavaTaskAsync
Future< R > ExecuteJavaTaskAsync(const std::string &taskName)
Asynchronously executes given Java task on the grid projection.
Definition: compute.h:367
ignite::compute::Compute::BroadcastAsync
Future< std::vector< R > > BroadcastAsync(const F &func)
Asyncronuously broadcasts provided ComputeFunc to all nodes in the cluster group.
Definition: compute.h:287
ignite::compute::Compute::Broadcast
void Broadcast(const F &func)
Broadcasts provided ComputeFunc to all nodes in the cluster group.
Definition: compute.h:268
ignite::Future< void >
Specialization for void type.
Definition: future.h:172
ignite::compute::Compute::Run
void Run(const F &action)
Runs provided ComputeFunc on a node within the underlying cluster group.
Definition: compute.h:221
ignite::compute::Compute::AffinityRunAsync
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....
Definition: compute.h:167
ignite::compute::Compute::Compute
Compute(common::concurrent::SharedPointer< impl::compute::ComputeImpl > impl)
Constructor.
Definition: compute.h:83
ignite::compute::Compute::ExecuteJavaTaskAsync
Future< R > ExecuteJavaTaskAsync(const std::string &taskName, const A &taskArg)
Asynchronously executes given Java task on the grid projection.
Definition: compute.h:352
ignite::compute::Compute::AffinityCallAsync
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....
Definition: compute.h:129
ignite::compute::Compute::AffinityCall
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....
Definition: compute.h:106
ignite::compute::Compute::ExecuteJavaTask
R ExecuteJavaTask(const std::string &taskName, const A &taskArg)
Executes given Java task on the grid projection.
Definition: compute.h:320
ignite::compute::Compute::ExecuteJavaTask
R ExecuteJavaTask(const std::string &taskName)
Executes given Java task on the grid projection.
Definition: compute.h:335
ignite_error.h
compute_func.h
ignite::compute::Compute::BroadcastAsync
Future< void > BroadcastAsync(const F &func)
Asyncronuously broadcasts provided ComputeFunc to all nodes in the cluster group.
Definition: compute.h:303
ignite::compute::Compute::AffinityRun
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....
Definition: compute.h:147
ignite::compute::Compute::Call
R Call(const F &func)
Calls provided ComputeFunc on a node within the underlying cluster group.
Definition: compute.h:186