This is an automated email from the ASF dual-hosted git repository. dmagda pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push: new 8df8e0b IGNITE-14133 Document cluster API implementation for CPP (#8761) 8df8e0b is described below commit 8df8e0b10238b5c1d0d22120bb3141998799bfbc Author: Nikita Safonov <73828260+nikita-tech-wri...@users.noreply.github.com> AuthorDate: Sat Feb 6 01:48:24 2021 +0300 IGNITE-14133 Document cluster API implementation for CPP (#8761) --- .../cpp/src/broadcast_jobs_to_remote_nodes.cpp | 44 ++++++++++++++++++++++ .../cpp/src/predefined_cluster_groups.cpp | 27 +++++++++++++ .../distributed-computing/cluster-groups.adoc | 12 +++++- 3 files changed, 81 insertions(+), 2 deletions(-) diff --git a/docs/_docs/code-snippets/cpp/src/broadcast_jobs_to_remote_nodes.cpp b/docs/_docs/code-snippets/cpp/src/broadcast_jobs_to_remote_nodes.cpp new file mode 100644 index 0000000..5fc7b4e --- /dev/null +++ b/docs/_docs/code-snippets/cpp/src/broadcast_jobs_to_remote_nodes.cpp @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +//tag::remote-nodes[] +class PrintNodeIdAction : public ComputeFunc<void> { +public: + virtual void Call() { + std::cout << "Hello node " << Ignition::Get().GetCluster().GetLocalNode().GetId() << std::endl; + } +}; +namespace ignite { namespace binary { + template<> struct BinaryType<PrintNodeIdAction>: BinaryTypeDefaultAll<PrintNodeIdAction> { + static void GetTypeName(std::string& dst) { + dst = "PrintNodeIdAction"; + } + static void Write(BinaryWriter& writer, const PrintNodeIdAction& obj) {} + static void Read(BinaryReader& reader, PrintNodeIdAction& dst) {} + }; +}} +void void RemotesBroadcastDemo() +{ + Ignite ignite = Ignition::Get(); + IgniteCluster cluster = ignite.GetCluster(); + // Get compute instance which will only execute + // over remote nodes, i.e. all the nodes except for this one. + Compute compute = ignite.GetCompute(cluster.AsClusterGroup().ForRemotes()); + // Broadcast to all remote nodes and print the ID of the node + // on which this closure is executing. + compute.Broadcast(PrintNodeIdAction()); +} +//end::remote-nodes[] \ No newline at end of file diff --git a/docs/_docs/code-snippets/cpp/src/predefined_cluster_groups.cpp b/docs/_docs/code-snippets/cpp/src/predefined_cluster_groups.cpp new file mode 100644 index 0000000..4cbc514 --- /dev/null +++ b/docs/_docs/code-snippets/cpp/src/predefined_cluster_groups.cpp @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +//tag::cluster-groups[] +Ignite ignite = Ignition::Get(); +ClusterGroup cluster = ignite.GetCluster().AsClusterGroup(); +// All nodes on which cache with name "myCache" is deployed, +// either in client or server mode. +ClusterGroup cacheGroup = cluster.ForCacheNodes("myCache"); +// All data nodes responsible for caching data for "myCache". +ClusterGroup dataGroup = cluster.ForDataNodes("myCache"); +// All client nodes that access "myCache". +ClusterGroup clientGroup = cluster.ForClientNodes("myCache"); +//end::cluster-groups[] diff --git a/docs/_docs/distributed-computing/cluster-groups.adoc b/docs/_docs/distributed-computing/cluster-groups.adoc index d8acc4f..47b8468 100644 --- a/docs/_docs/distributed-computing/cluster-groups.adoc +++ b/docs/_docs/distributed-computing/cluster-groups.adoc @@ -38,7 +38,11 @@ tab:C#/.NET[] ---- include::code-snippets/dotnet/ClusterGroups.cs[tag=broadcastAction,indent=0] ---- -tab:C++[unsupported] +tab:C++[] +[source,cpp] +---- +include::code-snippets/cpp/src/broadcast_jobs_to_remote_nodes.cpp[tag=remote-nodes,indent=0] +---- -- @@ -57,6 +61,10 @@ tab:C#/.NET[] ---- include::code-snippets/dotnet/ClusterGroups.cs[tag=clusterGroups,indent=0] ---- -tab:C++[unsupported] +tab:C++[] +[source,cpp] +---- +include::code-snippets/cpp/src/predefined_cluster_groups.cpp[tag=cluster-groups,indent=0] +---- --