Apache Ignite C++
compute.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
23 #ifndef _IGNITE_COMPUTE_COMPUTE
24 #define _IGNITE_COMPUTE_COMPUTE
25 
26 #include <ignite/common/common.h>
27 
28 #include <ignite/ignite_error.h>
29 #include <ignite/future.h>
31 
32 #include <ignite/impl/compute/compute_impl.h>
33 
34 namespace ignite
35 {
36  namespace compute
37  {
74  class IGNITE_IMPORT_EXPORT Compute
75  {
76  public:
84  Compute(common::concurrent::SharedPointer<impl::compute::ComputeImpl> impl) :
85  impl(impl)
86  {
87  // No-op.
88  }
89 
106  template<typename R, typename K, typename F>
107  R AffinityCall(const std::string& cacheName, const K& key, const F& func)
108  {
109  return impl.Get()->AffinityCallAsync<R, K, F>(cacheName, key, func).GetValue();
110  }
111 
129  template<typename R, typename K, typename F>
130  Future<R> AffinityCallAsync(const std::string& cacheName, const K& key, const F& func)
131  {
132  return impl.Get()->AffinityCallAsync<R, K, F>(cacheName, key, func);
133  }
134 
147  template<typename K, typename F>
148  void AffinityRun(const std::string& cacheName, const K& key, const F& action)
149  {
150  return impl.Get()->AffinityRunAsync<K, F>(cacheName, key, action).GetValue();
151  }
152 
167  template<typename K, typename F>
168  Future<void> AffinityRunAsync(const std::string& cacheName, const K& key, const F& action)
169  {
170  return impl.Get()->AffinityRunAsync<K, F>(cacheName, key, action);
171  }
172 
186  template<typename R, typename F>
187  R Call(const F& func)
188  {
189  return impl.Get()->CallAsync<R, F>(func).GetValue();
190  }
191 
206  template<typename R, typename F>
207  Future<R> CallAsync(const F& func)
208  {
209  return impl.Get()->CallAsync<R, F>(func);
210  }
211 
221  template<typename F>
222  void Run(const F& action)
223  {
224  return impl.Get()->RunAsync<F>(action).GetValue();
225  }
226 
237  template<typename F>
238  Future<void> RunAsync(const F& action)
239  {
240  return impl.Get()->RunAsync<F>(action);
241  }
242 
254  template<typename R, typename F>
255  std::vector<R> Broadcast(const F& func)
256  {
257  return impl.Get()->BroadcastAsync<R, F>(func).GetValue();
258  }
259 
268  template<typename F>
269  void Broadcast(const F& func)
270  {
271  impl.Get()->BroadcastAsync<F, false>(func).GetValue();
272  }
273 
287  template<typename R, typename F>
289  {
290  return impl.Get()->BroadcastAsync<R, F>(func);
291  }
292 
303  template<typename F>
305  {
306  return impl.Get()->BroadcastAsync<F, false>(func);
307  }
308 
320  template<typename R, typename A>
321  R ExecuteJavaTask(const std::string& taskName, const A& taskArg)
322  {
323  return impl.Get()->ExecuteJavaTask<R, A>(taskName, taskArg);
324  }
325 
335  template<typename R>
336  R ExecuteJavaTask(const std::string& taskName)
337  {
338  return impl.Get()->ExecuteJavaTask<R>(taskName);
339  }
340 
352  template<typename R, typename A>
353  Future<R> ExecuteJavaTaskAsync(const std::string& taskName, const A& taskArg)
354  {
355  return impl.Get()->ExecuteJavaTaskAsync<R, A>(taskName, taskArg);
356  }
357 
367  template<typename R>
368  Future<R> ExecuteJavaTaskAsync(const std::string& taskName)
369  {
370  return impl.Get()->ExecuteJavaTaskAsync<R>(taskName);
371  }
372 
373  private:
375  common::concurrent::SharedPointer<impl::compute::ComputeImpl> impl;
376  };
377  }
378 }
379 
380 #endif //_IGNITE_COMPUTE_COMPUTE
ignite::compute::Compute
Defines compute grid functionality for executing tasks and closures over nodes in the ClusterGroup.
Definition: compute.h:74
ignite
Apache Ignite API.
Definition: cache.h:48
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:255
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:238
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:207
ignite::Future
Future class template.
Definition: future.h:46
ignite::compute::Compute::ExecuteJavaTaskAsync
Future< R > ExecuteJavaTaskAsync(const std::string &taskName)
Asynchronously executes given Java task on the grid projection.
Definition: compute.h:368
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:288
ignite::compute::Compute::Broadcast
void Broadcast(const F &func)
Broadcasts provided ComputeFunc to all nodes in the cluster group.
Definition: compute.h:269
ignite::Future< void >
Specialization for void type.
Definition: future.h:167
ignite::compute::Compute::Run
void Run(const F &action)
Runs provided ComputeFunc on a node within the underlying cluster group.
Definition: compute.h:222
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:168
ignite::compute::Compute::Compute
Compute(common::concurrent::SharedPointer< impl::compute::ComputeImpl > impl)
Constructor.
Definition: compute.h:84
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:353
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:130
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:107
ignite::compute::Compute::ExecuteJavaTask
R ExecuteJavaTask(const std::string &taskName, const A &taskArg)
Executes given Java task on the grid projection.
Definition: compute.h:321
ignite::compute::Compute::ExecuteJavaTask
R ExecuteJavaTask(const std::string &taskName)
Executes given Java task on the grid projection.
Definition: compute.h:336
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:304
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:148
ignite::compute::Compute::Call
R Call(const F &func)
Calls provided ComputeFunc on a node within the underlying cluster group.
Definition: compute.h:187