Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id DECCC200CD3 for ; Fri, 28 Jul 2017 14:07:17 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id DD37D16CA7A; Fri, 28 Jul 2017 12:07:17 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5A3B516CA3D for ; Fri, 28 Jul 2017 14:07:16 +0200 (CEST) Received: (qmail 33939 invoked by uid 500); 28 Jul 2017 12:07:15 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 33774 invoked by uid 99); 28 Jul 2017 12:07:15 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Jul 2017 12:07:15 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 05D43F324B; Fri, 28 Jul 2017 12:07:14 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: yzhdanov@apache.org To: commits@ignite.apache.org Date: Fri, 28 Jul 2017 12:07:55 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [43/50] [abbrv] ignite git commit: IGNITE-5771: Added Ignite::SetActive() for C++ archived-at: Fri, 28 Jul 2017 12:07:18 -0000 IGNITE-5771: Added Ignite::SetActive() for C++ Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/47fea40b Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/47fea40b Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/47fea40b Branch: refs/heads/ignite-5658 Commit: 47fea40b07857a08727ac2e062cb9a3e0f464fdc Parents: 2941392 Author: Igor Sapego Authored: Thu Jul 27 19:39:51 2017 +0300 Committer: Igor Sapego Committed: Thu Jul 27 19:39:51 2017 +0300 ---------------------------------------------------------------------- .../cpp/core-test/src/cluster_test.cpp | 13 ++++++ .../platforms/cpp/core/include/ignite/ignite.h | 15 +++++++ .../ignite/impl/cluster/cluster_group_impl.h | 15 +++++++ .../cpp/core/include/ignite/impl/ignite_impl.h | 46 ++++++++++---------- modules/platforms/cpp/core/src/ignite.cpp | 10 +++++ .../src/impl/cluster/cluster_group_impl.cpp | 26 ++++++++++- .../platforms/cpp/core/src/impl/ignite_impl.cpp | 24 ++++++++++ 7 files changed, 124 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/47fea40b/modules/platforms/cpp/core-test/src/cluster_test.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core-test/src/cluster_test.cpp b/modules/platforms/cpp/core-test/src/cluster_test.cpp index e9d6728..4ee3f39 100644 --- a/modules/platforms/cpp/core-test/src/cluster_test.cpp +++ b/modules/platforms/cpp/core-test/src/cluster_test.cpp @@ -83,4 +83,17 @@ BOOST_AUTO_TEST_CASE(IgniteImplForServers) BOOST_REQUIRE(clusterGroup.Get()->ForServers().IsValid()); } +BOOST_AUTO_TEST_CASE(IgniteSetActive) +{ + BOOST_REQUIRE(node.IsActive()); + + node.SetActive(false); + + BOOST_REQUIRE(!node.IsActive()); + + node.SetActive(true); + + BOOST_REQUIRE(node.IsActive()); +} + BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/47fea40b/modules/platforms/cpp/core/include/ignite/ignite.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/ignite.h b/modules/platforms/cpp/core/include/ignite/ignite.h index 07134a1..e953b8f 100644 --- a/modules/platforms/cpp/core/include/ignite/ignite.h +++ b/modules/platforms/cpp/core/include/ignite/ignite.h @@ -182,6 +182,21 @@ namespace ignite } /** + * Check if the Ignite grid is active. + * + * @return True if grid is active and false otherwise. + */ + bool IsActive(); + + /** + * Change Ignite grid state to active or inactive. + * + * @param active If true start activation process. If false start + * deactivation process. + */ + void SetActive(bool active); + + /** * Get transactions. * * This method should only be used on the valid instance. http://git-wip-us.apache.org/repos/asf/ignite/blob/47fea40b/modules/platforms/cpp/core/include/ignite/impl/cluster/cluster_group_impl.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/impl/cluster/cluster_group_impl.h b/modules/platforms/cpp/core/include/ignite/impl/cluster/cluster_group_impl.h index 3cfd700..d81e899 100644 --- a/modules/platforms/cpp/core/include/ignite/impl/cluster/cluster_group_impl.h +++ b/modules/platforms/cpp/core/include/ignite/impl/cluster/cluster_group_impl.h @@ -71,6 +71,21 @@ namespace ignite */ SP_ComputeImpl GetCompute(); + /** + * Check if the Ignite grid is active. + * + * @return True if grid is active and false otherwise. + */ + bool IsActive(); + + /** + * Change Ignite grid state to active or inactive. + * + * @param active If true start activation process. If false start + * deactivation process. + */ + void SetActive(bool active); + private: IGNITE_NO_COPY_ASSIGNMENT(ClusterGroupImpl); http://git-wip-us.apache.org/repos/asf/ignite/blob/47fea40b/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h b/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h index d1763c4..5461d1c 100644 --- a/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h +++ b/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h @@ -182,6 +182,27 @@ namespace ignite */ SP_ComputeImpl GetCompute(); + /** + * Check if the Ignite grid is active. + * + * @return True if grid is active and false otherwise. + */ + bool IsActive() + { + return prjImpl.Get()->IsActive(); + } + + /** + * Change Ignite grid state to active or inactive. + * + * @param active If true start activation process. If false start + * deactivation process. + */ + void SetActive(bool active) + { + prjImpl.Get()->SetActive(active); + } + private: /** * Get transactions internal call. @@ -215,30 +236,7 @@ namespace ignite * @param err Error. * @param op Operation code. */ - cache::CacheImpl* GetOrCreateCache(const char* name, IgniteError& err, int32_t op) - { - SharedPointer mem = env.Get()->AllocateMemory(); - InteropMemory* mem0 = mem.Get(); - InteropOutputStream out(mem0); - BinaryWriterImpl writer(&out, env.Get()->GetTypeManager()); - BinaryRawWriter rawWriter(&writer); - - rawWriter.WriteString(name); - - out.Synchronize(); - - jobject cacheJavaRef = InStreamOutObject(op, *mem0, err); - - if (!cacheJavaRef) - { - return NULL; - } - - char* name0 = common::CopyChars(name); - - return new cache::CacheImpl(name0, env, cacheJavaRef); - } - + cache::CacheImpl* GetOrCreateCache(const char* name, IgniteError& err, int32_t op); }; } } http://git-wip-us.apache.org/repos/asf/ignite/blob/47fea40b/modules/platforms/cpp/core/src/ignite.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/src/ignite.cpp b/modules/platforms/cpp/core/src/ignite.cpp index 9c42f1d..6eaae01 100644 --- a/modules/platforms/cpp/core/src/ignite.cpp +++ b/modules/platforms/cpp/core/src/ignite.cpp @@ -45,6 +45,16 @@ namespace ignite return impl.Get()->GetConfiguration(); } + bool Ignite::IsActive() + { + return impl.Get()->IsActive(); + } + + void Ignite::SetActive(bool active) + { + impl.Get()->SetActive(active); + } + transactions::Transactions Ignite::GetTransactions() { using ignite::common::concurrent::SharedPointer; http://git-wip-us.apache.org/repos/asf/ignite/blob/47fea40b/modules/platforms/cpp/core/src/impl/cluster/cluster_group_impl.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/src/impl/cluster/cluster_group_impl.cpp b/modules/platforms/cpp/core/src/impl/cluster/cluster_group_impl.cpp index c34e828..91f9d30 100644 --- a/modules/platforms/cpp/core/src/impl/cluster/cluster_group_impl.cpp +++ b/modules/platforms/cpp/core/src/impl/cluster/cluster_group_impl.cpp @@ -30,7 +30,11 @@ namespace ignite { enum Type { - FOR_SERVERS = 23 + FOR_SERVERS = 23, + + SET_ACTIVE = 28, + + IS_ACTIVE = 29 }; }; @@ -61,6 +65,26 @@ namespace ignite return computeImpl; } + bool ClusterGroupImpl::IsActive() + { + IgniteError err; + + int64_t res = OutInOpLong(Command::IS_ACTIVE, 0, err); + + IgniteError::ThrowIfNeeded(err); + + return res == 1; + } + + void ClusterGroupImpl::SetActive(bool active) + { + IgniteError err; + + int64_t res = OutInOpLong(Command::SET_ACTIVE, active ? 1 : 0, err); + + IgniteError::ThrowIfNeeded(err); + } + SP_ClusterGroupImpl ClusterGroupImpl::FromTarget(jobject javaRef) { return SP_ClusterGroupImpl(new ClusterGroupImpl(GetEnvironmentPointer(), javaRef)); http://git-wip-us.apache.org/repos/asf/ignite/blob/47fea40b/modules/platforms/cpp/core/src/impl/ignite_impl.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/src/impl/ignite_impl.cpp b/modules/platforms/cpp/core/src/impl/ignite_impl.cpp index f7ff185..f2132d4 100644 --- a/modules/platforms/cpp/core/src/impl/ignite_impl.cpp +++ b/modules/platforms/cpp/core/src/impl/ignite_impl.cpp @@ -91,5 +91,29 @@ namespace ignite return res; } + + cache::CacheImpl* IgniteImpl::GetOrCreateCache(const char* name, IgniteError& err, int32_t op) + { + SharedPointer mem = env.Get()->AllocateMemory(); + InteropMemory* mem0 = mem.Get(); + InteropOutputStream out(mem0); + BinaryWriterImpl writer(&out, env.Get()->GetTypeManager()); + BinaryRawWriter rawWriter(&writer); + + rawWriter.WriteString(name); + + out.Synchronize(); + + jobject cacheJavaRef = InStreamOutObject(op, *mem0, err); + + if (!cacheJavaRef) + { + return NULL; + } + + char* name0 = common::CopyChars(name); + + return new cache::CacheImpl(name0, env, cacheJavaRef); + } } }