IGNITE-5771: Added Ignite::SetActive() for C++ (cherry picked from commit 47fea40)
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/98a52406 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/98a52406 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/98a52406 Branch: refs/heads/master Commit: 98a524067b2d2349c558256ee38efdf81e0ba7ff Parents: a07d7b9 Author: Igor Sapego <isap...@gridgain.com> Authored: Thu Jul 27 19:39:51 2017 +0300 Committer: Igor Sapego <isap...@gridgain.com> Committed: Thu Jul 27 20:02:16 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 | 23 ++++++++++++++++- modules/platforms/cpp/core/src/ignite.cpp | 10 ++++++++ .../src/impl/cluster/cluster_group_impl.cpp | 26 +++++++++++++++++++- 6 files changed, 100 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/98a52406/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/98a52406/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 b3b06f0..135f215 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/98a52406/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/98a52406/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 baddec4..ea192e2 100644 --- a/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h +++ b/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h @@ -82,7 +82,7 @@ namespace ignite * @param name Cache name. * @param err Error. */ - template<typename K, typename V> + template<typename K, typename V> cache::CacheImpl* GetCache(const char* name, IgniteError& err) { ignite::jni::java::JniErrorInfo jniErr; @@ -209,6 +209,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. http://git-wip-us.apache.org/repos/asf/ignite/blob/98a52406/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/98a52406/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));