| 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>
30 #include <ignite/compute/compute_func.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>
288 Future< std::vector<R> > BroadcastAsync(const F& func)
289 {
290 return impl.Get()->BroadcastAsync<R, F>(func);
291 }
292
303 template<typename F>
304 Future<void> BroadcastAsync(const F& func)
305 {
306 return impl.Get()->BroadcastAsync<F, false>(func);
307 }
308
309 private:
311 common::concurrent::SharedPointer<impl::compute::ComputeImpl> impl;
312 };
313 }
314 }
315
316 #endif //_IGNITE_COMPUTE_COMPUTE
ignite::compute::Compute::Call
R Call(const F &func)
Calls provided ComputeFunc on a node within the underlying cluster group.
Definition: compute.h:187
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::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::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.k.a.
Definition: compute.h:148
ignite::Future< void >
Specialization for void type.
Definition: future.h:167
ignite::compute::Compute
Defines compute grid functionality for executing tasks and closures over nodes in the ClusterGroup...
Definition: compute.h:74
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.k.a.
Definition: compute.h:107
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::Broadcast
void Broadcast(const F &func)
Broadcasts provided ComputeFunc to all nodes in the cluster group.
Definition: compute.h:269
ignite::compute::Compute::Compute
Compute(common::concurrent::SharedPointer< impl::compute::ComputeImpl > impl)
Constructor.
Definition: compute.h:84
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
compute_func.h
Declares ignite::compute::ComputeFunc class template.
ignite::compute::Compute::Run
void Run(const F &action)
Runs provided ComputeFunc on a node within the underlying cluster group.
Definition: compute.h:222
future.h
Declares ignite::Future class template.
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
Apache Ignite API.
Definition: cache.h:48
ignite_error.h
Declares ignite::IgniteError class.
ignite::Future
Future class template.
Definition: future.h:46
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::BroadcastAsync
Future< void > BroadcastAsync(const F &func)
Asyncronuously broadcasts provided ComputeFunc to all nodes in the cluster group. ...
Definition: compute.h:304