This is an automated email from the ASF dual-hosted git repository.
jbarrett pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git
The following commit(s) were added to refs/heads/develop by this push:
new fc41344 GEODE-5018: Fixing PIMPL pattern for Cache (#278)
fc41344 is described below
commit fc413448d12c63a1588a2f0300159ea7b570acd0
Author: Ryan McMahon <[email protected]>
AuthorDate: Tue Apr 17 12:51:15 2018 -0700
GEODE-5018: Fixing PIMPL pattern for Cache (#278)
* Moving type registry out and using forward decl
* Using initializer list in Cache constructor
---
cppcache/include/geode/AuthenticatedView.hpp | 7 +-
cppcache/include/geode/Cache.hpp | 42 +++---
cppcache/include/geode/Pool.hpp | 2 +-
cppcache/include/geode/RegionService.hpp | 2 +-
cppcache/integration-test-2/ExampleTest.cpp | 3 +-
.../integration-test-2/RegionPutGetAllTest.cpp | 3 +
cppcache/integration-test/CacheHelper.cpp | 5 +-
cppcache/integration-test/QueryHelper.hpp | 25 ++--
.../integration-test/ThinClientMultipleCaches.hpp | 4 +-
.../integration-test/testAttributesMutator.cpp | 13 +-
cppcache/integration-test/testCache.cpp | 4 +
cppcache/integration-test/testExpiration.cpp | 87 ++++++++-----
cppcache/integration-test/testLinkage.cpp | 3 +
.../integration-test/testOverflowPutGetSqLite.cpp | 8 +-
.../testRegionAttributesFactory.cpp | 8 +-
.../integration-test/testRegionTemplateArgs.cpp | 8 +-
.../integration-test/testThinClientCqDurable.cpp | 25 ++--
.../testThinClientSecurityMultiUserTest.cpp | 2 +
.../testXmlCacheCreationWithRefid.cpp | 17 ++-
cppcache/src/AuthenticatedView.cpp | 9 +-
cppcache/src/Cache.cpp | 129 +++++--------------
cppcache/src/CacheImpl.cpp | 143 +++++++++++++++++----
cppcache/src/CacheImpl.hpp | 50 ++++---
cppcache/src/ClientMetadataService.cpp | 5 +-
cppcache/src/EvictionController.cpp | 19 ++-
cppcache/src/FunctionService.cpp | 3 +-
cppcache/src/PdxInstanceFactoryImpl.cpp | 2 +-
cppcache/src/PdxInstanceFactoryImpl.hpp | 3 +-
cppcache/src/PdxType.cpp | 136 ++++++++++----------
cppcache/src/PdxType.hpp | 2 +-
cppcache/src/PoolManagerImpl.cpp | 1 +
cppcache/src/RegionEntry.cpp | 1 +
cppcache/src/RegionFactory.cpp | 18 +--
cppcache/src/TcrEndpoint.cpp | 8 +-
cppcache/src/ThinClientPoolDM.cpp | 23 ++--
examples/cpp/customserializable/main.cpp | 4 +-
examples/cpp/customserializer/main.cpp | 4 +
examples/cpp/put-get-remove/main.cpp | 16 ++-
tests/cpp/fwklib/RegionHelper.hpp | 2 +
39 files changed, 484 insertions(+), 362 deletions(-)
diff --git a/cppcache/include/geode/AuthenticatedView.hpp
b/cppcache/include/geode/AuthenticatedView.hpp
index 44f5c2d..586a44d 100644
--- a/cppcache/include/geode/AuthenticatedView.hpp
+++ b/cppcache/include/geode/AuthenticatedView.hpp
@@ -82,8 +82,7 @@ class APACHE_GEODE_EXPORT AuthenticatedView : public
RegionService {
* @param path the region's path, such as <code>RootA/Sub1/Sub1A</code>.
* @returns region, or nullptr if no such region exists.
*/
- std::shared_ptr<Region> getRegion(
- const std::string& path) const override;
+ std::shared_ptr<Region> getRegion(const std::string& path) const override;
/**
* Gets the QueryService from which a new Query can be obtained.
@@ -109,7 +108,7 @@ class APACHE_GEODE_EXPORT AuthenticatedView : public
RegionService {
/**
* @brief constructors
- */
+ */
AuthenticatedView(std::shared_ptr<Properties> credentials,
std::shared_ptr<Pool> pool, CacheImpl* cacheImpl);
AuthenticatedView(AuthenticatedView&& other) = default;
@@ -123,7 +122,7 @@ class APACHE_GEODE_EXPORT AuthenticatedView : public
RegionService {
* @return the factory
*/
std::shared_ptr<PdxInstanceFactory> createPdxInstanceFactory(
- std::string className) const override;
+ const std::string& className) const override;
AuthenticatedView& operator=(AuthenticatedView&& other) = default;
AuthenticatedView& operator=(const AuthenticatedView& other) = delete;
diff --git a/cppcache/include/geode/Cache.hpp b/cppcache/include/geode/Cache.hpp
index bd8ff4c..fc21add 100644
--- a/cppcache/include/geode/Cache.hpp
+++ b/cppcache/include/geode/Cache.hpp
@@ -24,13 +24,6 @@
#include "internal/geode_globals.hpp"
#include "GeodeCache.hpp"
-#include "Region.hpp"
-#include "DistributedSystem.hpp"
-#include "QueryService.hpp"
-#include "PoolFactory.hpp"
-#include "RegionShortcut.hpp"
-#include "RegionFactory.hpp"
-#include "TypeRegistry.hpp"
/**
* @file
@@ -40,15 +33,24 @@ namespace apache {
namespace geode {
namespace client {
-class PoolManager;
+class AuthenticatedView;
+class AuthInitialize;
class CacheFactory;
-class CacheRegionHelper;
-class Pool;
class CacheImpl;
-class AuthInitialize;
+class CacheRegionHelper;
class CacheTransactionManager;
+class DataInput;
+class DataOutput;
+class DistributedSystem;
+class Pool;
+class PoolFactory;
+class PoolManager;
+class Properties;
+class QueryService;
+class Region;
class RegionFactory;
-class AuthenticatedView;
+class TypeRegistry;
+enum class RegionShortcut;
/**
* @class Cache Cache.hpp
@@ -108,6 +110,12 @@ class APACHE_GEODE_EXPORT Cache : public GeodeCache {
virtual DistributedSystem& getDistributedSystem() const override;
/**
+ * Returns the type registry that this cache was
+ * {@link CacheFactory::create created} with.
+ */
+ virtual TypeRegistry& getTypeRegistry();
+
+ /**
* Terminates this object cache and releases all the local resources.
* After this cache is closed, any further
* method call on this cache or any region object will throw
@@ -198,7 +206,7 @@ class APACHE_GEODE_EXPORT Cache : public GeodeCache {
*/
virtual AuthenticatedView createAuthenticatedView(
- std::shared_ptr<Properties> userSecurityProperties,
+ const std::shared_ptr<Properties>& userSecurityProperties,
const std::string& poolName);
/**
@@ -220,8 +228,6 @@ class APACHE_GEODE_EXPORT Cache : public GeodeCache {
*/
virtual bool getPdxReadSerialized() const override;
- virtual TypeRegistry& getTypeRegistry();
-
/**
* Returns a factory that can create a {@link PdxInstance}.
* @param className the fully qualified class name that the PdxInstance will
@@ -231,7 +237,7 @@ class APACHE_GEODE_EXPORT Cache : public GeodeCache {
* @return the factory
*/
virtual std::shared_ptr<PdxInstanceFactory> createPdxInstanceFactory(
- std::string className) const override;
+ const std::string& className) const override;
virtual std::unique_ptr<DataInput> createDataInput(const uint8_t* m_buffer,
size_t len) const;
@@ -250,19 +256,17 @@ class APACHE_GEODE_EXPORT Cache : public GeodeCache {
/**
* @brief constructors
*/
- Cache(std::shared_ptr<Properties> dsProp, bool ignorePdxUnreadFields,
+ Cache(const std::shared_ptr<Properties>& dsProp, bool ignorePdxUnreadFields,
bool readPdxSerialized,
const std::shared_ptr<AuthInitialize>& authInitialize);
std::unique_ptr<CacheImpl> m_cacheImpl;
- std::unique_ptr<TypeRegistry> m_typeRegistry;
protected:
static bool isPoolInMultiuserMode(std::shared_ptr<Region> regionPtr);
friend class CacheFactory;
friend class CacheRegionHelper;
- friend class Pool;
friend class FunctionService;
friend class CacheXmlCreation;
friend class RegionXmlCreation;
diff --git a/cppcache/include/geode/Pool.hpp b/cppcache/include/geode/Pool.hpp
index 5345f2f..8befcfa 100644
--- a/cppcache/include/geode/Pool.hpp
+++ b/cppcache/include/geode/Pool.hpp
@@ -305,7 +305,7 @@ class APACHE_GEODE_EXPORT Pool : public
std::enable_shared_from_this<Pool> {
friend class PoolFactory;
friend class CacheFactory;
- friend class Cache;
+ friend class CacheImpl;
};
} // namespace client
diff --git a/cppcache/include/geode/RegionService.hpp
b/cppcache/include/geode/RegionService.hpp
index 227f24a..8190953 100644
--- a/cppcache/include/geode/RegionService.hpp
+++ b/cppcache/include/geode/RegionService.hpp
@@ -116,7 +116,7 @@ class APACHE_GEODE_EXPORT RegionService {
* @return the factory
*/
virtual std::shared_ptr<PdxInstanceFactory> createPdxInstanceFactory(
- std::string className) const = 0;
+ const std::string& className) const = 0;
};
} // namespace client
} // namespace geode
diff --git a/cppcache/integration-test-2/ExampleTest.cpp
b/cppcache/integration-test-2/ExampleTest.cpp
index 8013fd0..9a1da24 100644
--- a/cppcache/integration-test-2/ExampleTest.cpp
+++ b/cppcache/integration-test-2/ExampleTest.cpp
@@ -24,6 +24,8 @@
#include <geode/Cache.hpp>
#include <geode/PoolManager.hpp>
+#include <geode/RegionFactory.hpp>
+#include <geode/RegionShortcut.hpp>
#include "framework/Framework.h"
#include "framework/Gfsh.h"
@@ -122,7 +124,6 @@ TEST(ExampleTest, DISABLED_putGetAndUpdateWith1Server) {
region->put(1, "two");
updatePromise.set_value();
-
});
ASSERT_EQ(std::future_status::ready, task2.wait_for(debug_safe(minutes(1))));
}
diff --git a/cppcache/integration-test-2/RegionPutGetAllTest.cpp
b/cppcache/integration-test-2/RegionPutGetAllTest.cpp
index a9361f9..b9726ba 100644
--- a/cppcache/integration-test-2/RegionPutGetAllTest.cpp
+++ b/cppcache/integration-test-2/RegionPutGetAllTest.cpp
@@ -25,6 +25,9 @@
#include <geode/Cache.hpp>
#include <geode/PoolManager.hpp>
+#include <geode/RegionFactory.hpp>
+#include <geode/RegionShortcut.hpp>
+#include <geode/TypeRegistry.hpp>
#include <VariousPdxTypes.hpp>
diff --git a/cppcache/integration-test/CacheHelper.cpp
b/cppcache/integration-test/CacheHelper.cpp
index 9d11b34..ac67cd9 100644
--- a/cppcache/integration-test/CacheHelper.cpp
+++ b/cppcache/integration-test/CacheHelper.cpp
@@ -27,6 +27,8 @@
#include <geode/SystemProperties.hpp>
#include <geode/PoolManager.hpp>
#include <geode/internal/chrono/duration.hpp>
+#include <geode/RegionShortcut.hpp>
+#include <geode/RegionFactory.hpp>
#include "CacheRegionHelper.hpp"
#include "DistributedSystemImpl.hpp"
@@ -705,7 +707,8 @@ std::shared_ptr<Region>
CacheHelper::createRegionDiscOverFlow(
"SqLiteRegionData" +
std::to_string(static_cast<long long int>(ACE_OS::getpid()));
sqLiteProps->insert("PersistenceDirectory", sqlite_dir.c_str());
- regionAttributeFactory.setPersistenceManager("SqLiteImpl",
"createSqLiteInstance", sqLiteProps);
+ regionAttributeFactory.setPersistenceManager(
+ "SqLiteImpl", "createSqLiteInstance", sqLiteProps);
}
auto regionAttributes = regionAttributeFactory.create();
diff --git a/cppcache/integration-test/QueryHelper.hpp
b/cppcache/integration-test/QueryHelper.hpp
index e0a8459..ebd969d 100644
--- a/cppcache/integration-test/QueryHelper.hpp
+++ b/cppcache/integration-test/QueryHelper.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_INTEGRATION_TEST_QUERYHELPER_H_
-#define GEODE_INTEGRATION_TEST_QUERYHELPER_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,21 +15,29 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_INTEGRATION_TEST_QUERYHELPER_H_
+#define GEODE_INTEGRATION_TEST_QUERYHELPER_H_
+
#include <cstdlib>
-#include <geode/SystemProperties.hpp>
+
#include <ace/OS.h>
-#include "DistributedSystemImpl.hpp"
+#include <geode/Region.hpp>
+#include <geode/ResultSet.hpp>
+#include <geode/StructSet.hpp>
+#include <geode/SystemProperties.hpp>
+#include "CacheImpl.hpp"
+#include "CacheRegionHelper.hpp"
+#include "DistributedSystemImpl.hpp"
#include "testobject/Portfolio.hpp"
#include "testobject/Position.hpp"
#include "testobject/PdxType.hpp"
#include "testobject/PortfolioPdx.hpp"
#include "testobject/PositionPdx.hpp"
-#include <geode/ResultSet.hpp>
-#include <geode/StructSet.hpp>
-#include "CacheRegionHelper.hpp"
-#include "CacheImpl.hpp"
+
//#include <geode/Struct.hpp>
//#ifndef ROOT_NAME
diff --git a/cppcache/integration-test/ThinClientMultipleCaches.hpp
b/cppcache/integration-test/ThinClientMultipleCaches.hpp
index 505bead..98fc92d 100644
--- a/cppcache/integration-test/ThinClientMultipleCaches.hpp
+++ b/cppcache/integration-test/ThinClientMultipleCaches.hpp
@@ -22,10 +22,12 @@
#include <string>
-#include "fw_dunit.hpp"
#include <geode/CacheFactory.hpp>
+#include <geode/RegionFactory.hpp>
+#include <geode/RegionShortcut.hpp>
#include "CacheHelper.hpp"
+#include "fw_dunit.hpp"
using namespace apache::geode::client;
using namespace test;
diff --git a/cppcache/integration-test/testAttributesMutator.cpp
b/cppcache/integration-test/testAttributesMutator.cpp
index e45ea96..558bfb8 100644
--- a/cppcache/integration-test/testAttributesMutator.cpp
+++ b/cppcache/integration-test/testAttributesMutator.cpp
@@ -15,9 +15,14 @@
* limitations under the License.
*/
-#include "fw_dunit.hpp"
-#include "CacheRegionHelper.hpp"
+#include <geode/CacheFactory.hpp>
+#include <geode/Region.hpp>
+#include <geode/RegionAttributesFactory.hpp>
+
#include "CacheImpl.hpp"
+#include "CacheRegionHelper.hpp"
+
+#include "fw_dunit.hpp"
// this is a test.
@@ -39,8 +44,8 @@ DUNIT_TASK(A, Init)
Test.m_cache = std::make_shared<Cache>(cacheFactory.create());
RegionAttributesFactory regionAttributesFactory;
-
regionAttributesFactory.setEntryTimeToLive(ExpirationAction::LOCAL_INVALIDATE,
- std::chrono::seconds(5));
+ regionAttributesFactory.setEntryTimeToLive(
+ ExpirationAction::LOCAL_INVALIDATE, std::chrono::seconds(5));
auto regionAttributes = regionAttributesFactory.create();
CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(Test.m_cache.get());
diff --git a/cppcache/integration-test/testCache.cpp
b/cppcache/integration-test/testCache.cpp
index 567aea0..799d1ee 100644
--- a/cppcache/integration-test/testCache.cpp
+++ b/cppcache/integration-test/testCache.cpp
@@ -18,6 +18,10 @@
#include <string>
#include <iostream>
+#include <geode/CacheFactory.hpp>
+#include <geode/RegionAttributesFactory.hpp>
+#include <geode/Region.hpp>
+
#include "CacheRegionHelper.hpp"
#include "CacheImpl.hpp"
#include "fw_helper.hpp"
diff --git a/cppcache/integration-test/testExpiration.cpp
b/cppcache/integration-test/testExpiration.cpp
index 48d8bbd..bdabc21 100644
--- a/cppcache/integration-test/testExpiration.cpp
+++ b/cppcache/integration-test/testExpiration.cpp
@@ -15,6 +15,9 @@
* limitations under the License.
*/
+#include <geode/ExpirationAction.hpp>
+#include <geode/Region.hpp>
+
#include "fw_helper.hpp"
#include "CacheRegionHelper.hpp"
#include "CacheImpl.hpp"
@@ -74,10 +77,11 @@ std::shared_ptr<CacheableKey>
do1Put(std::shared_ptr<Region>& rptr) {
}
RegionAttributes setRegionAttributesTimeouts(
- const std::chrono::seconds &entryTimeToLive = std::chrono::seconds::zero(),
- const std::chrono::seconds &entryIdleTimeout =
std::chrono::seconds::zero(),
- const std::chrono::seconds ®ionTimeToLive =
std::chrono::seconds::zero(),
- const std::chrono::seconds ®ionIdleTimeout =
std::chrono::seconds::zero()) {
+ const std::chrono::seconds& entryTimeToLive = std::chrono::seconds::zero(),
+ const std::chrono::seconds& entryIdleTimeout =
std::chrono::seconds::zero(),
+ const std::chrono::seconds& regionTimeToLive =
std::chrono::seconds::zero(),
+ const std::chrono::seconds& regionIdleTimeout =
+ std::chrono::seconds::zero()) {
RegionAttributesFactory regionAttributesFactory;
regionAttributesFactory.setEntryTimeToLive(action, entryTimeToLive);
@@ -118,8 +122,9 @@ BEGIN_TEST(TEST_EXPIRATION)
RegionAttributes attrs_2;
- attrs_2 = setRegionAttributesTimeouts(std::chrono::seconds(20),
std::chrono::seconds(2),
- std::chrono::seconds(0),
std::chrono::seconds(0));
+ attrs_2 = setRegionAttributesTimeouts(
+ std::chrono::seconds(20), std::chrono::seconds(2),
+ std::chrono::seconds(0), std::chrono::seconds(0));
std::shared_ptr<Region> R2;
cacheImpl->createRegion("R2", attrs_2, R2);
@@ -136,8 +141,9 @@ BEGIN_TEST(TEST_EXPIRATION)
RegionAttributes attrs_3;
// rttl = 20, reit = 2
- attrs_3 = setRegionAttributesTimeouts(std::chrono::seconds(0),
std::chrono::seconds(0),
- std::chrono::seconds(20),
std::chrono::seconds(2));
+ attrs_3 = setRegionAttributesTimeouts(
+ std::chrono::seconds(0), std::chrono::seconds(0),
+ std::chrono::seconds(20), std::chrono::seconds(2));
std::shared_ptr<Region> R3;
cacheImpl->createRegion("R3", attrs_3, R3);
@@ -149,8 +155,9 @@ BEGIN_TEST(TEST_EXPIRATION)
RegionAttributes attrs_4;
- attrs_4 = setRegionAttributesTimeouts(std::chrono::seconds(5),
std::chrono::seconds(0),
- std::chrono::seconds(0),
std::chrono::seconds(0));
+ attrs_4 = setRegionAttributesTimeouts(
+ std::chrono::seconds(5), std::chrono::seconds(0),
+ std::chrono::seconds(0), std::chrono::seconds(0));
std::shared_ptr<Region> R4;
cacheImpl->createRegion("R4", attrs_4, R4);
@@ -168,8 +175,9 @@ BEGIN_TEST(TEST_EXPIRATION)
RegionAttributes attrs_5;
// ettl = 0, eit = 0, rttl = 0, reit = 0
- attrs_5 = setRegionAttributesTimeouts(std::chrono::seconds(0),
std::chrono::seconds(5),
- std::chrono::seconds(0),
std::chrono::seconds(0));
+ attrs_5 = setRegionAttributesTimeouts(
+ std::chrono::seconds(0), std::chrono::seconds(5),
+ std::chrono::seconds(0), std::chrono::seconds(0));
std::shared_ptr<Region> R5;
cacheImpl->createRegion("R5", attrs_5, R5);
@@ -196,8 +204,9 @@ BEGIN_TEST(TEST_EXPIRATION)
RegionAttributes attrs_6;
// ettl = 0, eit = 0, rttl = 0, reit = 0
- attrs_6 = setRegionAttributesTimeouts(std::chrono::seconds(0),
std::chrono::seconds(0),
- std::chrono::seconds(5),
std::chrono::seconds(0));
+ attrs_6 = setRegionAttributesTimeouts(
+ std::chrono::seconds(0), std::chrono::seconds(0),
+ std::chrono::seconds(5), std::chrono::seconds(0));
std::shared_ptr<Region> R6;
cacheImpl->createRegion("R6", attrs_6, R6);
@@ -215,8 +224,9 @@ BEGIN_TEST(TEST_EXPIRATION)
RegionAttributes attrs_7;
// ettl = 0, eit = 0, rttl = 0, reit = 0
- attrs_7 = setRegionAttributesTimeouts(std::chrono::seconds(0),
std::chrono::seconds(0),
- std::chrono::seconds(0),
std::chrono::seconds(5));
+ attrs_7 = setRegionAttributesTimeouts(
+ std::chrono::seconds(0), std::chrono::seconds(0),
+ std::chrono::seconds(0), std::chrono::seconds(5));
std::shared_ptr<Region> R7;
cacheImpl->createRegion("R7", attrs_7, R7);
@@ -234,8 +244,9 @@ BEGIN_TEST(TEST_EXPIRATION)
RegionAttributes attrs_8;
// ettl = 0, eit = 0, rttl = 0, reit = 0
- attrs_8 = setRegionAttributesTimeouts(std::chrono::seconds(10),
std::chrono::seconds(0),
- std::chrono::seconds(0),
std::chrono::seconds(0));
+ attrs_8 = setRegionAttributesTimeouts(
+ std::chrono::seconds(10), std::chrono::seconds(0),
+ std::chrono::seconds(0), std::chrono::seconds(0));
std::shared_ptr<Region> R8;
cacheImpl->createRegion("R8", attrs_8, R8);
@@ -254,8 +265,9 @@ BEGIN_TEST(TEST_EXPIRATION)
RegionAttributes attrs_9;
// ettl = 0, eit = 0, rttl = 0, reit = 0
- attrs_9 = setRegionAttributesTimeouts(std::chrono::seconds(0),
std::chrono::seconds(0),
- std::chrono::seconds(0),
std::chrono::seconds(8));
+ attrs_9 = setRegionAttributesTimeouts(
+ std::chrono::seconds(0), std::chrono::seconds(0),
+ std::chrono::seconds(0), std::chrono::seconds(8));
std::shared_ptr<Region> R9;
cacheImpl->createRegion("R9", attrs_9, R9);
@@ -276,8 +288,9 @@ BEGIN_TEST(TEST_EXPIRATION)
RegionAttributes attrs_10;
// ettl = 0, eit = 0, rttl = 0, reit = 0
- attrs_10 = setRegionAttributesTimeouts(std::chrono::seconds(6),
std::chrono::seconds(0),
- std::chrono::seconds(0),
std::chrono::seconds(12));
+ attrs_10 = setRegionAttributesTimeouts(
+ std::chrono::seconds(6), std::chrono::seconds(0),
+ std::chrono::seconds(0), std::chrono::seconds(12));
std::shared_ptr<Region> R10;
cacheImpl->createRegion("R10", attrs_10, R10);
@@ -297,8 +310,9 @@ BEGIN_TEST(TEST_EXPIRATION)
RegionAttributes attrs_11;
// ettl = 0, eit = 0, rttl = 0, reit = 0
- attrs_11 = setRegionAttributesTimeouts(std::chrono::seconds(0),
std::chrono::seconds(4),
- std::chrono::seconds(0),
std::chrono::seconds(7));
+ attrs_11 = setRegionAttributesTimeouts(
+ std::chrono::seconds(0), std::chrono::seconds(4),
+ std::chrono::seconds(0), std::chrono::seconds(7));
std::shared_ptr<Region> R11;
cacheImpl->createRegion("R11", attrs_11, R11);
@@ -324,8 +338,9 @@ BEGIN_TEST(TEST_EXPIRATION)
RegionAttributes attrs_12;
// ettl = 0, eit = 0, rttl = 0, reit = 0
- attrs_12 = setRegionAttributesTimeouts(std::chrono::seconds(5),
std::chrono::seconds(0),
- std::chrono::seconds(0),
std::chrono::seconds(0));
+ attrs_12 = setRegionAttributesTimeouts(
+ std::chrono::seconds(5), std::chrono::seconds(0),
+ std::chrono::seconds(0), std::chrono::seconds(0));
std::shared_ptr<Region> R12;
cacheImpl->createRegion("R12", attrs_12, R12);
@@ -343,8 +358,9 @@ BEGIN_TEST(TEST_EXPIRATION)
RegionAttributes attrs_14;
// ettl = 0, eit = 0, rttl = 0, reit = 0
- attrs_14 = setRegionAttributesTimeouts(std::chrono::seconds(0),
std::chrono::seconds(0),
- std::chrono::seconds(10),
std::chrono::seconds(0));
+ attrs_14 = setRegionAttributesTimeouts(
+ std::chrono::seconds(0), std::chrono::seconds(0),
+ std::chrono::seconds(10), std::chrono::seconds(0));
std::shared_ptr<Region> R14;
cacheImpl->createRegion("R14", attrs_14, R14);
@@ -358,8 +374,9 @@ BEGIN_TEST(TEST_EXPIRATION)
RegionAttributes attrs_15;
// ettl = 0, eit = 0, rttl = 0, reit = 0
- attrs_15 = setRegionAttributesTimeouts(std::chrono::seconds(0),
std::chrono::seconds(5),
- std::chrono::seconds(0),
std::chrono::seconds(0));
+ attrs_15 = setRegionAttributesTimeouts(
+ std::chrono::seconds(0), std::chrono::seconds(5),
+ std::chrono::seconds(0), std::chrono::seconds(0));
std::shared_ptr<Region> R15;
cacheImpl->createRegion("R15", attrs_15, R15);
@@ -378,8 +395,9 @@ BEGIN_TEST(TEST_EXPIRATION)
//////////////
RegionAttributes attrs_18;
// ettl = 0, eit = 0, rttl = 0, reit = 0
- attrs_18 = setRegionAttributesTimeouts(std::chrono::seconds(6),
std::chrono::seconds(3),
- std::chrono::seconds(0),
std::chrono::seconds(0));
+ attrs_18 = setRegionAttributesTimeouts(
+ std::chrono::seconds(6), std::chrono::seconds(3),
+ std::chrono::seconds(0), std::chrono::seconds(0));
std::shared_ptr<Region> R18;
cacheImpl->createRegion("R18", attrs_18, R18);
@@ -398,8 +416,9 @@ BEGIN_TEST(TEST_EXPIRATION)
RegionAttributes attrs_19;
// ettl = 0, eit = 0, rttl = 0, reit = 0
- attrs_19 = setRegionAttributesTimeouts(std::chrono::seconds(0),
std::chrono::seconds(0),
- std::chrono::seconds(6),
std::chrono::seconds(3));
+ attrs_19 = setRegionAttributesTimeouts(
+ std::chrono::seconds(0), std::chrono::seconds(0),
+ std::chrono::seconds(6), std::chrono::seconds(3));
std::shared_ptr<Region> R19;
cacheImpl->createRegion("R19x", attrs_19, R19);
diff --git a/cppcache/integration-test/testLinkage.cpp
b/cppcache/integration-test/testLinkage.cpp
index 51a32f4..777a522 100644
--- a/cppcache/integration-test/testLinkage.cpp
+++ b/cppcache/integration-test/testLinkage.cpp
@@ -15,7 +15,10 @@
* limitations under the License.
*/
+#include <geode/AttributesMutator.hpp>
+#include <geode/Region.hpp>
#include <geode/RegionAttributesFactory.hpp>
+
#include "fw_helper.hpp"
using namespace apache::geode::client;
diff --git a/cppcache/integration-test/testOverflowPutGetSqLite.cpp
b/cppcache/integration-test/testOverflowPutGetSqLite.cpp
index e624fee..e10f19b 100644
--- a/cppcache/integration-test/testOverflowPutGetSqLite.cpp
+++ b/cppcache/integration-test/testOverflowPutGetSqLite.cpp
@@ -20,10 +20,14 @@
#include <ace/OS.h>
-#include "fw_helper.hpp"
+#include <geode/RegionShortcut.hpp>
+#include <geode/RegionFactory.hpp>
+
#include <CacheableToken.hpp>
-#include <MapEntry.hpp>
#include <CacheRegionHelper.hpp>
+#include <MapEntry.hpp>
+
+#include "fw_helper.hpp"
using namespace apache::geode::client;
diff --git a/cppcache/integration-test/testRegionAttributesFactory.cpp
b/cppcache/integration-test/testRegionAttributesFactory.cpp
index 526643d..b0a8a46 100644
--- a/cppcache/integration-test/testRegionAttributesFactory.cpp
+++ b/cppcache/integration-test/testRegionAttributesFactory.cpp
@@ -15,9 +15,15 @@
* limitations under the License.
*/
-#include "fw_helper.hpp"
+#include <geode/CacheFactory.hpp>
+#include <geode/Region.hpp>
+#include <geode/RegionFactory.hpp>
+#include <geode/RegionShortcut.hpp>
+
#include <CacheRegionHelper.hpp>
+#include "fw_helper.hpp"
+
using namespace apache::geode::client;
/* testing attributes with invalid value */
diff --git a/cppcache/integration-test/testRegionTemplateArgs.cpp
b/cppcache/integration-test/testRegionTemplateArgs.cpp
index 38ba8df..fcec68a 100644
--- a/cppcache/integration-test/testRegionTemplateArgs.cpp
+++ b/cppcache/integration-test/testRegionTemplateArgs.cpp
@@ -15,8 +15,14 @@
* limitations under the License.
*/
-#include "CacheRegionHelper.hpp"
+#include <geode/CacheFactory.hpp>
+#include <geode/Region.hpp>
+#include <geode/RegionEntry.hpp>
+#include <geode/RegionAttributesFactory.hpp>
+
#include "CacheImpl.hpp"
+#include "CacheRegionHelper.hpp"
+
#include "fw_helper.hpp"
using namespace apache::geode::client;
diff --git a/cppcache/integration-test/testThinClientCqDurable.cpp
b/cppcache/integration-test/testThinClientCqDurable.cpp
index 07539d3..ced2e40 100644
--- a/cppcache/integration-test/testThinClientCqDurable.cpp
+++ b/cppcache/integration-test/testThinClientCqDurable.cpp
@@ -14,26 +14,31 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include "fw_dunit.hpp"
-#include "ThinClientHelper.hpp"
+
+#include <string>
+#include <thread>
+#include <chrono>
+
+#include <ace/OS.h>
+#include <ace/High_Res_Timer.h>
+
#include <geode/CqAttributesFactory.hpp>
#include <geode/CqAttributes.hpp>
#include <geode/CqListener.hpp>
#include <geode/CqQuery.hpp>
-#include <ace/OS.h>
-#include <ace/High_Res_Timer.h>
-#include <string>
-#include <thread>
-#include <chrono>
+#include <geode/RegionFactory.hpp>
-#define ROOT_SCOPE DISTRIBUTED_ACK
+#include "fw_dunit.hpp"
+#include "ThinClientHelper.hpp"
-#include "QueryStrings.hpp"
-#include "QueryHelper.hpp"
+#define ROOT_SCOPE DISTRIBUTED_ACK
#include <geode/Query.hpp>
#include <geode/QueryService.hpp>
+#include <geode/RegionShortcut.hpp>
+#include "QueryStrings.hpp"
+#include "QueryHelper.hpp"
#include "ThinClientCQ.hpp"
using namespace apache::geode::client;
diff --git a/cppcache/integration-test/testThinClientSecurityMultiUserTest.cpp
b/cppcache/integration-test/testThinClientSecurityMultiUserTest.cpp
index ffc0a60..1da4069 100644
--- a/cppcache/integration-test/testThinClientSecurityMultiUserTest.cpp
+++ b/cppcache/integration-test/testThinClientSecurityMultiUserTest.cpp
@@ -16,6 +16,8 @@
*/
#include <geode/AuthInitialize.hpp>
+#include <geode/RegionFactory.hpp>
+#include <geode/RegionShortcut.hpp>
#include "fw_dunit.hpp"
#include "ThinClientSecurity.hpp"
diff --git a/cppcache/integration-test/testXmlCacheCreationWithRefid.cpp
b/cppcache/integration-test/testXmlCacheCreationWithRefid.cpp
index ff1b5b3..56d34fc 100644
--- a/cppcache/integration-test/testXmlCacheCreationWithRefid.cpp
+++ b/cppcache/integration-test/testXmlCacheCreationWithRefid.cpp
@@ -20,6 +20,7 @@
#include <math.h>
#include <geode/CacheFactory.hpp>
+#include <geode/Region.hpp>
#include "fw_helper.hpp"
@@ -35,8 +36,8 @@ int testXmlCacheCreationWithRefid(const char* fileName) {
std::cout << "create DistributedSytem with name=" << host_name << std::endl;
std::cout << "Create cache with the configurations provided in "
- "valid_cache_refid.xml"
- << std::endl;
+ "valid_cache_refid.xml"
+ << std::endl;
try {
const auto filePath = directory + fileName;
@@ -77,7 +78,8 @@ int testXmlCacheCreationWithRefid(const char* fileName) {
return -1;
}
- std::cout << "Verify whether region 'SubRegion11' has correct attributes" <<
std::endl;
+ std::cout << "Verify whether region 'SubRegion11' has correct attributes"
+ << std::endl;
auto atts = SubRegion11->getAttributes();
@@ -101,7 +103,8 @@ int testXmlCacheCreationWithRefid(const char* fileName) {
return -1;
}
- std::cout << "Verify whether region 'SubRegion2' has correct attributes" <<
std::endl;
+ std::cout << "Verify whether region 'SubRegion2' has correct attributes"
+ << std::endl;
atts = SubRegion2->getAttributes();
@@ -125,7 +128,8 @@ int testXmlCacheCreationWithRefid(const char* fileName) {
return -1;
}
- std::cout << "Verify whether region 'SubRegion21' has correct attributes" <<
std::endl;
+ std::cout << "Verify whether region 'SubRegion21' has correct attributes"
+ << std::endl;
atts = SubRegion21->getAttributes();
@@ -169,7 +173,8 @@ int testXmlCacheCreationWithRefid(const char* fileName) {
return -1;
}
- std::cout << "Verify whether region 'Root2' has correct attributes" <<
std::endl;
+ std::cout << "Verify whether region 'Root2' has correct attributes"
+ << std::endl;
atts = Root2->getAttributes();
diff --git a/cppcache/src/AuthenticatedView.cpp
b/cppcache/src/AuthenticatedView.cpp
index 08363e5..e6bc77e 100644
--- a/cppcache/src/AuthenticatedView.cpp
+++ b/cppcache/src/AuthenticatedView.cpp
@@ -89,7 +89,7 @@ std::shared_ptr<Region> AuthenticatedView::getRegion(
std::shared_ptr<Region> result;
if (m_cacheImpl != nullptr && !m_cacheImpl->isClosed()) {
- m_cacheImpl->getRegion(path.c_str(), result);
+ result = m_cacheImpl->getRegion(path);
}
if (result != nullptr) {
@@ -136,11 +136,9 @@ std::vector<std::shared_ptr<Region>>
AuthenticatedView::rootRegions() const {
std::vector<std::shared_ptr<Region>> regions;
if (!m_isAuthenticatedViewClosed && m_cacheImpl && !m_cacheImpl->isClosed())
{
- std::vector<std::shared_ptr<Region>> tmp;
-
// this can cause issue when pool attached with region in multiuserSecure
// mode
- m_cacheImpl->rootRegions(tmp);
+ auto tmp = m_cacheImpl->rootRegions();
regions.reserve(tmp.size());
for (const auto& reg : tmp) {
@@ -167,8 +165,9 @@
AuthenticatedView::AuthenticatedView(std::shared_ptr<Properties> credentials,
m_cacheImpl(cacheImpl) {}
AuthenticatedView::~AuthenticatedView() {}
+
std::shared_ptr<PdxInstanceFactory>
AuthenticatedView::createPdxInstanceFactory(
- std::string className) const {
+ const std::string& className) const {
return std::make_shared<PdxInstanceFactoryImpl>(
className.c_str(), &(m_cacheImpl->getCachePerfStats()),
m_cacheImpl->getPdxTypeRegistry(), m_cacheImpl,
diff --git a/cppcache/src/Cache.cpp b/cppcache/src/Cache.cpp
index 56e5baf..4aed84c 100644
--- a/cppcache/src/Cache.cpp
+++ b/cppcache/src/Cache.cpp
@@ -22,22 +22,20 @@
#include <geode/PoolManager.hpp>
#include <geode/DistributedSystem.hpp>
#include <geode/Cache.hpp>
+#include <geode/RegionFactory.hpp>
#include "DistributedSystemImpl.hpp"
-#include "CacheXmlParser.hpp"
#include "CacheRegionHelper.hpp"
#include "CacheImpl.hpp"
#include "UserAttributes.hpp"
#include "ProxyRegion.hpp"
-#include "PdxInstanceFactoryImpl.hpp"
-
-#define DEFAULT_DS_NAME "default_GeodeDS"
namespace apache {
namespace geode {
namespace client {
-/** Returns the name of this cache.
+/**
+ * Returns the name of this cache.
* This method does not throw
* <code>CacheClosedException</code> if the cache is closed.
* @return the string name of this cache
@@ -63,6 +61,14 @@ DistributedSystem& Cache::getDistributedSystem() const {
return m_cacheImpl->getDistributedSystem();
}
+/**
+ * Returns the type registry that this cache was
+ * {@link CacheFactory::create created} with.
+ */
+TypeRegistry& Cache::getTypeRegistry() {
+ return m_cacheImpl->getTypeRegistry();
+}
+
void Cache::close() { close(false); }
/**
@@ -73,32 +79,10 @@ void Cache::close() { close(false); }
* @param keepalive whether to keep the durable client's queue
* @throws CacheClosedException, if the cache is already closed.
*/
-void Cache::close(bool keepalive) {
- m_cacheImpl->close(keepalive);
-
- try {
- getDistributedSystem().disconnect();
- } catch (const apache::geode::client::NotConnectedException&) {
- } catch (const apache::geode::client::Exception&) {
- } catch (...) {
- }
-}
+void Cache::close(bool keepalive) { m_cacheImpl->close(keepalive); }
std::shared_ptr<Region> Cache::getRegion(const std::string& path) const {
- LOGDEBUG("Cache::getRegion " + path);
- std::shared_ptr<Region> result;
- m_cacheImpl->getRegion(path.c_str(), result);
-
- if (result != nullptr) {
- if (isPoolInMultiuserMode(result)) {
- LOGWARN("Pool " + result->getAttributes().getPoolName() +
- " attached with region " + result->getFullPath() +
- " is in multiuser authentication mode. Operations may fail as "
- "this instance does not have any credentials.");
- }
- }
-
- return result;
+ return m_cacheImpl->getRegion(path);
}
/**
@@ -109,11 +93,8 @@ std::shared_ptr<Region> Cache::getRegion(const std::string&
path) const {
* @param regions the region collection object containing the returned set of
* regions when the function returns
*/
-
std::vector<std::shared_ptr<Region>> Cache::rootRegions() const {
- std::vector<std::shared_ptr<Region>> regions;
- m_cacheImpl->rootRegions(regions);
- return regions;
+ return m_cacheImpl->rootRegions();
}
RegionFactory Cache::createRegionFactory(RegionShortcut preDefinedRegion) {
@@ -123,39 +104,32 @@ RegionFactory Cache::createRegionFactory(RegionShortcut
preDefinedRegion) {
std::shared_ptr<QueryService> Cache::getQueryService() {
return m_cacheImpl->getQueryService();
}
+
std::shared_ptr<QueryService> Cache::getQueryService(
const std::string& poolName) const {
return m_cacheImpl->getQueryService(poolName.c_str());
}
+
std::shared_ptr<CacheTransactionManager> Cache::getCacheTransactionManager()
const {
return m_cacheImpl->getCacheTransactionManager();
}
-TypeRegistry& Cache::getTypeRegistry() { return *(m_typeRegistry.get()); }
-
-Cache::Cache(std::shared_ptr<Properties> dsProp, bool ignorePdxUnreadFields,
- bool readPdxSerialized,
- const std::shared_ptr<AuthInitialize>& authInitialize) {
- auto distributedSystem = DistributedSystem::create(DEFAULT_DS_NAME, dsProp);
- m_cacheImpl = std::unique_ptr<CacheImpl>(
- new CacheImpl(this, std::move(distributedSystem), ignorePdxUnreadFields,
- readPdxSerialized, authInitialize));
- m_cacheImpl->getDistributedSystem().connect(this);
- m_typeRegistry =
- std::unique_ptr<TypeRegistry>(new TypeRegistry(m_cacheImpl.get()));
-}
+Cache::Cache(const std::shared_ptr<Properties>& dsProp,
+ bool ignorePdxUnreadFields, bool readPdxSerialized,
+ const std::shared_ptr<AuthInitialize>& authInitialize)
+ : m_cacheImpl(std::unique_ptr<CacheImpl>(
+ new CacheImpl(this, dsProp, ignorePdxUnreadFields, readPdxSerialized,
+ authInitialize))) {}
Cache::Cache(Cache&& other) noexcept
- : m_cacheImpl(std::move(other.m_cacheImpl)),
- m_typeRegistry(std::move(other.m_typeRegistry)) {
+ : m_cacheImpl(std::move(other.m_cacheImpl)) {
m_cacheImpl->setCache(this);
}
Cache& Cache::operator=(Cache&& other) noexcept {
if (this != &other) {
m_cacheImpl = std::move(other.m_cacheImpl);
- m_typeRegistry = std::move(other.m_typeRegistry);
m_cacheImpl->setCache(this);
}
return *this;
@@ -164,26 +138,13 @@ Cache& Cache::operator=(Cache&& other) noexcept {
Cache::~Cache() = default;
void Cache::initializeDeclarativeCache(const std::string& cacheXml) {
- CacheXmlParser* xmlParser = CacheXmlParser::parse(cacheXml.c_str(), this);
- xmlParser->setAttributes(this);
- m_cacheImpl->initServices();
- xmlParser->create(this);
- delete xmlParser;
- xmlParser = nullptr;
+ m_cacheImpl->initializeDeclarativeCache(cacheXml);
}
void Cache::readyForEvents() { m_cacheImpl->readyForEvents(); }
bool Cache::isPoolInMultiuserMode(std::shared_ptr<Region> regionPtr) {
- const auto& poolName = regionPtr->getAttributes().getPoolName();
-
- if (!poolName.empty()) {
- auto poolPtr = regionPtr->getCache().getPoolManager().find(poolName);
- if (poolPtr != nullptr && !poolPtr->isDestroyed()) {
- return poolPtr->getMultiuserAuthentication();
- }
- }
- return false;
+ return CacheImpl::isPoolInMultiuserMode(regionPtr);
}
bool Cache::getPdxIgnoreUnreadFields() const {
@@ -193,44 +154,16 @@ bool Cache::getPdxIgnoreUnreadFields() const {
bool Cache::getPdxReadSerialized() const {
return m_cacheImpl->getPdxReadSerialized();
}
+
std::shared_ptr<PdxInstanceFactory> Cache::createPdxInstanceFactory(
- std::string className) const {
- return std::make_shared<PdxInstanceFactoryImpl>(
- className.c_str(), m_cacheImpl->m_cacheStats,
- m_cacheImpl->getPdxTypeRegistry(), m_cacheImpl.get(),
- m_cacheImpl->getDistributedSystem()
- .getSystemProperties()
- .getEnableTimeStatistics());
+ const std::string& className) const {
+ return m_cacheImpl->createPdxInstanceFactory(className);
}
+
AuthenticatedView Cache::createAuthenticatedView(
- std::shared_ptr<Properties> userSecurityProperties,
+ const std::shared_ptr<Properties>& userSecurityProperties,
const std::string& poolName) {
- if (poolName.empty()) {
- auto pool = m_cacheImpl->getPoolManager().getDefaultPool();
- if (!this->isClosed() && pool != nullptr) {
- return pool->createAuthenticatedView(userSecurityProperties,
- m_cacheImpl.get());
- }
-
- throw IllegalStateException(
- "Either cache has been closed or there are more than two pool."
- "Pass poolname to get the secure Cache");
- } else {
- if (!this->isClosed()) {
- if (!poolName.empty()) {
- auto poolPtr = m_cacheImpl->getPoolManager().find(poolName);
- if (poolPtr != nullptr && !poolPtr->isDestroyed()) {
- return poolPtr->createAuthenticatedView(userSecurityProperties,
- m_cacheImpl.get());
- }
- throw IllegalStateException(
- "Either pool not found or it has been destroyed");
- }
- throw IllegalArgumentException("poolname is nullptr");
- }
-
- throw IllegalStateException("Cache has been closed");
- }
+ return m_cacheImpl->createAuthenticatedView(userSecurityProperties,
poolName);
}
PoolManager& Cache::getPoolManager() const {
diff --git a/cppcache/src/CacheImpl.cpp b/cppcache/src/CacheImpl.cpp
index 330933c..549960d 100644
--- a/cppcache/src/CacheImpl.cpp
+++ b/cppcache/src/CacheImpl.cpp
@@ -23,6 +23,7 @@
#include <geode/PoolManager.hpp>
#include <geode/RegionAttributes.hpp>
#include <geode/PersistenceManager.hpp>
+#include <geode/RegionFactory.hpp>
#include "CacheImpl.hpp"
#include "Utils.hpp"
@@ -42,10 +43,14 @@
#include "PdxTypeRegistry.hpp"
#include "SerializationRegistry.hpp"
#include "ThreadPool.hpp"
+#include "PdxInstanceFactoryImpl.hpp"
+#include "CacheXmlParser.hpp"
+
+#define DEFAULT_DS_NAME "default_GeodeDS"
using namespace apache::geode::client;
-CacheImpl::CacheImpl(Cache* c, DistributedSystem&& distributedSystem,
+CacheImpl::CacheImpl(Cache* c, const std::shared_ptr<Properties>& dsProps,
bool ignorePdxUnreadFields, bool readPdxSerialized,
const std::shared_ptr<AuthInitialize>& authInitialize)
: m_ignorePdxUnreadFields(ignorePdxUnreadFields),
@@ -55,7 +60,7 @@ CacheImpl::CacheImpl(Cache* c, DistributedSystem&&
distributedSystem,
m_statisticsManager(nullptr),
m_closed(false),
m_initialized(false),
- m_distributedSystem(std::move(distributedSystem)),
+ m_distributedSystem(DistributedSystem::create(DEFAULT_DS_NAME, dsProps)),
m_clientProxyMembershipIDFactory(m_distributedSystem.getName()),
m_cache(c),
m_cond(m_mutex),
@@ -73,7 +78,6 @@ CacheImpl::CacheImpl(Cache* c, DistributedSystem&&
distributedSystem,
m_threadPool(new ThreadPool(
m_distributedSystem.getSystemProperties().threadPoolSize())),
m_authInitialize(authInitialize) {
-
m_cacheTXManager = std::shared_ptr<InternalCacheTransactionManager2PC>(
new InternalCacheTransactionManager2PCImpl(this));
@@ -91,6 +95,7 @@ CacheImpl::CacheImpl(Cache* c, DistributedSystem&&
distributedSystem,
m_initialized = true;
m_pdxTypeRegistry = std::make_shared<PdxTypeRegistry>(this);
m_poolManager = std::unique_ptr<PoolManager>(new PoolManager(this));
+ m_typeRegistry = std::unique_ptr<TypeRegistry>(new TypeRegistry(this));
try {
m_statisticsManager =
@@ -104,6 +109,8 @@ CacheImpl::CacheImpl(Cache* c, DistributedSystem&&
distributedSystem,
Log::close();
throw;
}
+
+ m_distributedSystem.connect(m_cache);
}
void CacheImpl::initServices() {
@@ -246,6 +253,8 @@ DistributedSystem& CacheImpl::getDistributedSystem() {
return m_distributedSystem;
}
+TypeRegistry& CacheImpl::getTypeRegistry() { return *m_typeRegistry.get(); }
+
void CacheImpl::sendNotificationCloseMsgs() {
for (const auto& iter : getPoolManager().getAll()) {
if (const auto& pool =
@@ -333,6 +342,13 @@ void CacheImpl::close(bool keepalive) {
m_expiryTaskManager->stopExpiryTaskManager();
+ try {
+ getDistributedSystem().disconnect();
+ } catch (const apache::geode::client::NotConnectedException&) {
+ } catch (const apache::geode::client::Exception&) {
+ } catch (...) {
+ }
+
m_closed = true;
LOGFINE("Cache closed.");
@@ -475,13 +491,13 @@ void CacheImpl::createRegion(std::string name,
* @throws IllegalArgumentException if path is null, the empty string, or "/"
*/
-void CacheImpl::getRegion(const std::string& path,
- std::shared_ptr<Region>& rptr) {
+std::shared_ptr<Region> CacheImpl::getRegion(const std::string& path) {
+ LOGDEBUG("Cache::getRegion " + path);
+
TryReadGuard guardCacheDestroy(m_destroyCacheMutex, m_destroyPending);
- rptr = nullptr;
if (m_destroyPending) {
- return;
+ return nullptr;
}
MapOfRegionGuard guard(m_regions->mutex());
@@ -494,24 +510,31 @@ void CacheImpl::getRegion(const std::string& path,
if (fullname.substr(0, 1) == slash) {
fullname = path.substr(1);
}
+
// find second separator
- uint32_t idx = static_cast<uint32_t>(fullname.find('/'));
+ auto idx = static_cast<uint32_t>(fullname.find('/'));
auto stepname = fullname.substr(0, idx);
- std::shared_ptr<Region> region;
+
+ std::shared_ptr<Region> region = nullptr;
+
if (0 == m_regions->find(stepname, region)) {
- if (stepname == fullname) {
- // done...
- rptr = region;
- return;
- }
- auto remainder = fullname.substr(stepname.length() + 1);
- if (region != nullptr) {
- rptr = region->getSubregion(remainder.c_str());
- } else {
- rptr = nullptr;
- return; // Return null if the parent region was not found.
+ if (stepname != fullname) {
+ auto remainder = fullname.substr(stepname.length() + 1);
+
+ if (region != nullptr) {
+ region = region->getSubregion(remainder.c_str());
+ }
}
}
+
+ if (region != nullptr && isPoolInMultiuserMode(region)) {
+ LOGWARN("Pool " + region->getAttributes().getPoolName() +
+ " attached with region " + region->getFullPath() +
+ " is in multiuser authentication mode. Operations may fail as "
+ "this instance does not have any credentials.");
+ }
+
+ return region;
}
std::shared_ptr<RegionInternal> CacheImpl::createRegion_internal(
@@ -580,17 +603,32 @@ std::shared_ptr<RegionInternal>
CacheImpl::createRegion_internal(
return rptr;
}
-void CacheImpl::rootRegions(std::vector<std::shared_ptr<Region>>& regions) {
- regions.clear();
+std::vector<std::shared_ptr<Region>> CacheImpl::rootRegions() {
+ std::vector<std::shared_ptr<Region>> regions;
+
MapOfRegionGuard guard(m_regions->mutex());
- if (m_regions->current_size() == 0) return;
- regions.reserve(static_cast<int32_t>(m_regions->current_size()));
- for (MapOfRegionWithLock::iterator q = m_regions->begin();
- q != m_regions->end(); ++q) {
- if (!(*q).int_id_->isDestroyed()) {
- regions.push_back((*q).int_id_);
+
+ if (m_regions->current_size() != 0) {
+ regions.reserve(static_cast<int32_t>(m_regions->current_size()));
+
+ for (MapOfRegionWithLock::iterator q = m_regions->begin();
+ q != m_regions->end(); ++q) {
+ if (!(*q).int_id_->isDestroyed()) {
+ regions.push_back((*q).int_id_);
+ }
}
}
+
+ return regions;
+}
+
+void CacheImpl::initializeDeclarativeCache(const std::string& cacheXml) {
+ CacheXmlParser* xmlParser = CacheXmlParser::parse(cacheXml.c_str(), m_cache);
+ xmlParser->setAttributes(m_cache);
+ initServices();
+ xmlParser->create(m_cache);
+ delete xmlParser;
+ xmlParser = nullptr;
}
EvictionController* CacheImpl::getEvictionController() {
@@ -636,6 +674,19 @@ void CacheImpl::readyForEvents() {
}
}
+bool CacheImpl::isPoolInMultiuserMode(std::shared_ptr<Region> regionPtr) {
+ const auto& poolName = regionPtr->getAttributes().getPoolName();
+
+ if (!poolName.empty()) {
+ auto poolPtr = regionPtr->getCache().getPoolManager().find(poolName);
+ if (poolPtr != nullptr && !poolPtr->isDestroyed()) {
+ return poolPtr->getMultiuserAuthentication();
+ }
+ }
+
+ return false;
+}
+
bool CacheImpl::getEndpointStatus(const std::string& endpoint) {
const auto& pools = getPoolManager().getAll();
std::string fullName = endpoint;
@@ -784,4 +835,40 @@ std::unique_ptr<DataInput>
CacheImpl::createDataInput(const uint8_t* buffer,
return std::unique_ptr<DataInput>(new DataInput(buffer, len, this, pool));
}
+std::shared_ptr<PdxInstanceFactory> CacheImpl::createPdxInstanceFactory(
+ const std::string& className) const {
+ return std::make_shared<PdxInstanceFactoryImpl>(
+ className, m_cacheStats, m_pdxTypeRegistry, this,
+ m_distributedSystem.getSystemProperties().getEnableTimeStatistics());
+}
+
+AuthenticatedView CacheImpl::createAuthenticatedView(
+ std::shared_ptr<Properties> userSecurityProperties,
+ const std::string& poolName) {
+ if (poolName.empty()) {
+ auto pool = m_poolManager->getDefaultPool();
+ if (!this->isClosed() && pool != nullptr) {
+ return pool->createAuthenticatedView(userSecurityProperties, this);
+ }
+
+ throw IllegalStateException(
+ "Either cache has been closed or there are more than two pool."
+ "Pass poolname to get the secure Cache");
+ } else {
+ if (!this->isClosed()) {
+ if (!poolName.empty()) {
+ auto poolPtr = m_poolManager->find(poolName);
+ if (poolPtr != nullptr && !poolPtr->isDestroyed()) {
+ return poolPtr->createAuthenticatedView(userSecurityProperties,
this);
+ }
+ throw IllegalStateException(
+ "Either pool not found or it has been destroyed");
+ }
+ throw IllegalArgumentException("poolname is nullptr");
+ }
+
+ throw IllegalStateException("Cache has been closed");
+ }
+}
+
void CacheImpl::setCache(Cache* cache) { m_cache = cache; }
diff --git a/cppcache/src/CacheImpl.hpp b/cppcache/src/CacheImpl.hpp
index efeb409..6477009 100644
--- a/cppcache/src/CacheImpl.hpp
+++ b/cppcache/src/CacheImpl.hpp
@@ -21,18 +21,20 @@
#define GEODE_CACHEIMPL_H_
#include <atomic>
-
-#include <geode/internal/geode_globals.hpp>
#include <memory>
-#include <geode/Cache.hpp>
-#include <geode/CacheAttributes.hpp>
-#include <geode/DistributedSystem.hpp>
-#include "MapWithLock.hpp"
#include <ace/ACE.h>
#include <ace/Time_Value.h>
#include <ace/Guard_T.h>
#include <ace/Recursive_Thread_Mutex.h>
+
+#include <geode/internal/geode_globals.hpp>
+#include <geode/Cache.hpp>
+#include <geode/CacheAttributes.hpp>
+#include <geode/DistributedSystem.hpp>
+#include <geode/TypeRegistry.hpp>
+
+#include "MapWithLock.hpp"
#include "Condition.hpp"
#include "TcrConnectionManager.hpp"
#include "EvictionController.hpp"
@@ -42,12 +44,8 @@
#include "PdxTypeRegistry.hpp"
#include "MemberListForVersionStamp.hpp"
#include "ClientProxyMembershipIDFactory.hpp"
-
-#include <string>
-#include <string>
-#include <map>
-
#include "NonCopyable.hpp"
+
#define DEFAULT_LRU_MAXIMUM_ENTRIES 100000
/** @todo period '.' consistency */
/** @todo fix returns to param documentation of result ptr... */
@@ -60,11 +58,14 @@ namespace apache {
namespace geode {
namespace client {
-class ThreadPool;
class CacheFactory;
+class CacheStatistics;
class ExpiryTaskManager;
class PdxTypeRegistry;
+class Pool;
+class RegionAttributes;
class SerializationRegistry;
+class ThreadPool;
/**
* @class Cache Cache.hpp
@@ -146,6 +147,12 @@ class APACHE_GEODE_EXPORT CacheImpl : private NonCopyable,
DistributedSystem& getDistributedSystem();
/**
+ * Returns the type registry that this cache was
+ * {@link CacheFactory::create created} with.
+ */
+ TypeRegistry& getTypeRegistry();
+
+ /**
* Terminates this object cache and releases all the local resources.
* After this cache is closed, any further
* method call on this cache or any region object will throw
@@ -175,7 +182,7 @@ class APACHE_GEODE_EXPORT CacheImpl : private NonCopyable,
void createRegion(std::string name, RegionAttributes aRegionAttributes,
std::shared_ptr<Region>& regionPtr);
- void getRegion(const std::string& path, std::shared_ptr<Region>& rptr);
+ std::shared_ptr<Region> getRegion(const std::string& path);
/**
* Returns a set of root regions in the cache. Does not cause any
@@ -185,20 +192,23 @@ class APACHE_GEODE_EXPORT CacheImpl : private NonCopyable,
* @param regions the region collection object containing the returned set of
* regions when the function returns
*/
- void rootRegions(std::vector<std::shared_ptr<Region>>& regions);
+ std::vector<std::shared_ptr<Region>> rootRegions();
virtual RegionFactory createRegionFactory(RegionShortcut preDefinedRegion);
+ void initializeDeclarativeCache(const std::string& cacheXml);
+
std::shared_ptr<CacheTransactionManager> getCacheTransactionManager();
/**
* @brief destructor
*/
virtual ~CacheImpl();
+
/**
* @brief constructors
*/
- CacheImpl(Cache* c, DistributedSystem&& distributedSystem,
+ CacheImpl(Cache* c, const std::shared_ptr<Properties>& dsProps,
bool ignorePdxUnreadFields, bool readPdxSerialized,
const std::shared_ptr<AuthInitialize>& authInitialize);
@@ -234,6 +244,8 @@ class APACHE_GEODE_EXPORT CacheImpl : private NonCopyable,
*/
void readyForEvents();
+ static bool isPoolInMultiuserMode(std::shared_ptr<Region> regionPtr);
+
// TESTING: Durable clients. Not thread safe.
bool getEndpointStatus(const std::string& endpoint);
@@ -288,6 +300,13 @@ class APACHE_GEODE_EXPORT CacheImpl : private NonCopyable,
size_t len,
Pool* pool) const;
+ std::shared_ptr<PdxInstanceFactory> createPdxInstanceFactory(
+ const std::string& className) const;
+
+ AuthenticatedView createAuthenticatedView(
+ std::shared_ptr<Properties> userSecurityProperties,
+ const std::string& poolName);
+
private:
std::atomic<bool> m_networkhop;
std::atomic<int> m_blacklistBucketTimeout;
@@ -353,6 +372,7 @@ class APACHE_GEODE_EXPORT CacheImpl : private NonCopyable,
std::shared_ptr<PdxTypeRegistry> m_pdxTypeRegistry;
ThreadPool* m_threadPool;
const std::shared_ptr<AuthInitialize> m_authInitialize;
+ std::unique_ptr<TypeRegistry> m_typeRegistry;
friend class CacheFactory;
friend class Cache;
diff --git a/cppcache/src/ClientMetadataService.cpp
b/cppcache/src/ClientMetadataService.cpp
index 8109692..26d9302 100644
--- a/cppcache/src/ClientMetadataService.cpp
+++ b/cppcache/src/ClientMetadataService.cpp
@@ -199,7 +199,7 @@ std::shared_ptr<ClientMetadata>
ClientMetadataService::SendClientPRMetadata(
GfErrType err = tcrdm->sendSyncRequest(request, reply);
if (err == GF_NOERR &&
reply.getMessageType() == TcrMessage::RESPONSE_CLIENT_PR_METADATA) {
- tcrdm->getConnectionManager().getCacheImpl()->getRegion(regionPath,
region);
+ region =
tcrdm->getConnectionManager().getCacheImpl()->getRegion(regionPath);
if (region != nullptr) {
LocalRegion* lregion = dynamic_cast<LocalRegion*>(region.get());
lregion->getRegionStats()->incMetaDataRefreshCount();
@@ -302,10 +302,9 @@ void ClientMetadataService::enqueueForMetadataRefresh(
throw IllegalArgumentException(
"ClientMetaData: pool cast to ThinClientPoolDM failed");
}
- std::shared_ptr<Region> region;
auto cache = tcrdm->getConnectionManager().getCacheImpl();
- cache->getRegion(regionFullPath, region);
+ auto region = cache->getRegion(regionFullPath);
std::string serverGroup = tcrdm->getServerGroup();
if (serverGroup.length() != 0) {
diff --git a/cppcache/src/EvictionController.cpp
b/cppcache/src/EvictionController.cpp
index 2590e70..e6b3278 100644
--- a/cppcache/src/EvictionController.cpp
+++ b/cppcache/src/EvictionController.cpp
@@ -147,22 +147,21 @@ void EvictionController::evict(int32_t percentage) {
// On the flip side, this requires a copy of the registered region list
// every time eviction is ordered and that might not be cheap
//@TODO: Discuss with team
- VectorOfString regionTmpVector;
+ VectorOfString regionTempVector;
{
ReadGuard guard(m_regionLock);
for (size_t i = 0; i < m_regions.size(); i++) {
- regionTmpVector.push_back(m_regions.at(i));
+ regionTempVector.push_back(m_regions.at(i));
}
}
- for (size_t i = 0; i < regionTmpVector.size(); i++) {
- std::string str = regionTmpVector.at(i);
- std::shared_ptr<Region> rptr;
- m_cacheImpl->getRegion(str.c_str(), rptr);
- if (rptr != nullptr) {
- RegionInternal* rimpl = dynamic_cast<RegionInternal*>(rptr.get());
- if (rimpl != nullptr) {
- rimpl->evict(percentage);
+ for (size_t i = 0; i < regionTempVector.size(); i++) {
+ std::string region_name = regionTempVector.at(i);
+ auto region = m_cacheImpl->getRegion(region_name);
+ if (region != nullptr) {
+ RegionInternal* regionImpl = dynamic_cast<RegionInternal*>(region.get());
+ if (regionImpl != nullptr) {
+ regionImpl->evict(percentage);
}
}
}
diff --git a/cppcache/src/FunctionService.cpp b/cppcache/src/FunctionService.cpp
index 098bc99..f4a7f54 100644
--- a/cppcache/src/FunctionService.cpp
+++ b/cppcache/src/FunctionService.cpp
@@ -57,8 +57,7 @@ Execution FunctionService::onRegion(const
std::shared_ptr<Region>& region) {
}
// getting real region to execute function on region
if (!realRegion->getCache().isClosed()) {
- realRegion->getCache().m_cacheImpl->getRegion(realRegion->getName(),
- realRegion);
+ realRegion =
realRegion->getCache().m_cacheImpl->getRegion(realRegion->getName());
} else {
throw IllegalStateException("Cache has been closed");
}
diff --git a/cppcache/src/PdxInstanceFactoryImpl.cpp
b/cppcache/src/PdxInstanceFactoryImpl.cpp
index ef6860d..bf28168 100644
--- a/cppcache/src/PdxInstanceFactoryImpl.cpp
+++ b/cppcache/src/PdxInstanceFactoryImpl.cpp
@@ -27,7 +27,7 @@ namespace client {
PdxInstanceFactoryImpl::~PdxInstanceFactoryImpl() {}
PdxInstanceFactoryImpl::PdxInstanceFactoryImpl(
- std::string className, CachePerfStats* cachePerfStats,
+ const std::string& className, CachePerfStats* cachePerfStats,
std::shared_ptr<PdxTypeRegistry> pdxTypeRegistry, const CacheImpl* cache,
bool enableTimeStatistics)
: m_created(false),
diff --git a/cppcache/src/PdxInstanceFactoryImpl.hpp
b/cppcache/src/PdxInstanceFactoryImpl.hpp
index 975bac6..b8beebf 100644
--- a/cppcache/src/PdxInstanceFactoryImpl.hpp
+++ b/cppcache/src/PdxInstanceFactoryImpl.hpp
@@ -137,7 +137,8 @@ class APACHE_GEODE_EXPORT PdxInstanceFactoryImpl
virtual std::shared_ptr<PdxInstanceFactory> markIdentityField(
const std::string& fieldName) override;
- PdxInstanceFactoryImpl(std::string className, CachePerfStats* cachePerfStats,
+ PdxInstanceFactoryImpl(const std::string& className,
+ CachePerfStats* cachePerfStats,
std::shared_ptr<PdxTypeRegistry> m_pdxTypeRegistry,
const CacheImpl* cache, bool enableTimeStatistics);
diff --git a/cppcache/src/PdxType.cpp b/cppcache/src/PdxType.cpp
index fe56b90..9034942 100644
--- a/cppcache/src/PdxType.cpp
+++ b/cppcache/src/PdxType.cpp
@@ -42,10 +42,8 @@ PdxType::~PdxType() noexcept {
_GEODE_SAFE_DELETE_ARRAY(m_localToRemoteFieldMap);
}
-// PdxType::PdxType() : PdxType(nullptr, false) {}
-
PdxType::PdxType(std::shared_ptr<PdxTypeRegistry> pdxTypeRegistryPtr,
- std::string pdxDomainClassName, bool isLocal)
+ const std::string& pdxDomainClassName, bool isLocal)
: Serializable(),
m_pdxFieldTypes(new std::vector<std::shared_ptr<PdxFieldType>>()),
m_className(pdxDomainClassName),
@@ -88,8 +86,8 @@ void PdxType::toData(DataOutput& output) const {
}
void PdxType::fromData(DataInput& input) {
- input.read(); // ignore dsByte
- input.read(); // ignore classByte
+ input.read(); // ignore dsByte
+ input.read(); // ignore classByte
input.readString(); // ignore classtypeId
m_className = input.readString();
@@ -405,77 +403,79 @@ std::shared_ptr<PdxType>
PdxType::isContains(std::shared_ptr<PdxType> first,
}
return first;
}
- std::shared_ptr<PdxType> PdxType::clone() {
- auto clone =
- std::make_shared<PdxType>(m_pdxTypeRegistryPtr, m_className, false);
- clone->m_geodeTypeId = 0;
- clone->m_numberOfVarLenFields = m_numberOfVarLenFields;
-
- for (std::vector<std::shared_ptr<PdxFieldType>>::iterator it =
- m_pdxFieldTypes->begin();
- it != m_pdxFieldTypes->end(); ++it) {
- auto pdxPtr = *it;
- clone->m_pdxFieldTypes->push_back(pdxPtr);
- }
- return clone;
- }
- std::shared_ptr<PdxType> PdxType::isLocalTypeContains(
- std::shared_ptr<PdxType> otherType) {
- if (m_pdxFieldTypes->size() >= otherType->m_pdxFieldTypes->size()) {
- return isContains(shared_from_this(), otherType);
- }
- return nullptr;
+std::shared_ptr<PdxType> PdxType::clone() {
+ auto clone =
+ std::make_shared<PdxType>(m_pdxTypeRegistryPtr, m_className, false);
+ clone->m_geodeTypeId = 0;
+ clone->m_numberOfVarLenFields = m_numberOfVarLenFields;
+
+ for (std::vector<std::shared_ptr<PdxFieldType>>::iterator it =
+ m_pdxFieldTypes->begin();
+ it != m_pdxFieldTypes->end(); ++it) {
+ auto pdxPtr = *it;
+ clone->m_pdxFieldTypes->push_back(pdxPtr);
+ }
+ return clone;
+}
+std::shared_ptr<PdxType> PdxType::isLocalTypeContains(
+ std::shared_ptr<PdxType> otherType) {
+ if (m_pdxFieldTypes->size() >= otherType->m_pdxFieldTypes->size()) {
+ return isContains(shared_from_this(), otherType);
+ }
+ return nullptr;
}
- std::shared_ptr<PdxType>
PdxType::isRemoteTypeContains(std::shared_ptr<PdxType> remoteType) {
+std::shared_ptr<PdxType> PdxType::isRemoteTypeContains(
+ std::shared_ptr<PdxType> remoteType) {
if (m_pdxFieldTypes->size() <= remoteType->m_pdxFieldTypes->size()) {
return isContains(remoteType, shared_from_this());
}
return nullptr;
}
- std::shared_ptr<PdxType> PdxType::mergeVersion(std::shared_ptr<PdxType>
otherVersion) {
+std::shared_ptr<PdxType> PdxType::mergeVersion(
+ std::shared_ptr<PdxType> otherVersion) {
// int nTotalFields = otherVersion->m_pdxFieldTypes->size();
-std::shared_ptr<PdxType> contains = nullptr;
-
-if (isLocalTypeContains(otherVersion) != nullptr) return shared_from_this();
-
-if (isRemoteTypeContains(otherVersion) != nullptr) return otherVersion;
-
-// need to create new one, clone of local
-auto newone = clone();
-int varLenFields = newone->getNumberOfVarLenFields();
-
-for (std::vector<std::shared_ptr<PdxFieldType>>::iterator it =
- otherVersion->m_pdxFieldTypes->begin();
- it != otherVersion->m_pdxFieldTypes->end(); ++it) {
- bool found = false;
- // for each(PdxFieldType^ tmpNew in newone->m_pdxFieldTypes)
- for (std::vector<std::shared_ptr<PdxFieldType>>::iterator it2 =
- newone->m_pdxFieldTypes->begin();
- it2 != newone->m_pdxFieldTypes->end(); ++it2) {
- if ((*it2)->equals(*it)) {
- found = true;
- break;
+ std::shared_ptr<PdxType> contains = nullptr;
+
+ if (isLocalTypeContains(otherVersion) != nullptr) return shared_from_this();
+
+ if (isRemoteTypeContains(otherVersion) != nullptr) return otherVersion;
+
+ // need to create new one, clone of local
+ auto newone = clone();
+ int varLenFields = newone->getNumberOfVarLenFields();
+
+ for (std::vector<std::shared_ptr<PdxFieldType>>::iterator it =
+ otherVersion->m_pdxFieldTypes->begin();
+ it != otherVersion->m_pdxFieldTypes->end(); ++it) {
+ bool found = false;
+ // for each(PdxFieldType^ tmpNew in newone->m_pdxFieldTypes)
+ for (std::vector<std::shared_ptr<PdxFieldType>>::iterator it2 =
+ newone->m_pdxFieldTypes->begin();
+ it2 != newone->m_pdxFieldTypes->end(); ++it2) {
+ if ((*it2)->equals(*it)) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ auto newFt = std::make_shared<PdxFieldType>(
+ (*it)->getFieldName(), (*it)->getClassName(), (*it)->getTypeId(),
+ static_cast<int32_t>(newone->m_pdxFieldTypes->size()), // sequence
id
+ (*it)->IsVariableLengthType(), (*it)->getFixedSize(),
+ ((*it)->IsVariableLengthType()
+ ? varLenFields++ /*it increase after that*/
+ : 0));
+ newone->m_pdxFieldTypes->push_back(
+ newFt); // fieldnameVsPFT will happen after that
}
}
- if (!found) {
- auto newFt = std::make_shared<PdxFieldType>(
- (*it)->getFieldName(), (*it)->getClassName(), (*it)->getTypeId(),
- static_cast<int32_t>(newone->m_pdxFieldTypes->size()), // sequence id
- (*it)->IsVariableLengthType(), (*it)->getFixedSize(),
- ((*it)->IsVariableLengthType()
- ? varLenFields++ /*it increase after that*/
- : 0));
- newone->m_pdxFieldTypes->push_back(
- newFt); // fieldnameVsPFT will happen after that
- }
-}
-newone->setNumberOfVarLenFields(varLenFields);
-if (varLenFields > 0) newone->setVarLenFieldIdx(varLenFields);
+ newone->setNumberOfVarLenFields(varLenFields);
+ if (varLenFields > 0) newone->setVarLenFieldIdx(varLenFields);
-// need to keep all versions in local version
-// m_otherVersions->Add(newone);
-return newone;
+ // need to keep all versions in local version
+ // m_otherVersions->Add(newone);
+ return newone;
}
void PdxType::generatePositionMap() {
@@ -483,10 +483,10 @@ void PdxType::generatePositionMap() {
int lastVarLenSeqId = 0;
int prevFixedSizeOffsets = 0;
// set offsets from back first
-std::shared_ptr<PdxFieldType> previousField = nullptr;
+ std::shared_ptr<PdxFieldType> previousField = nullptr;
for (int i = static_cast<int>(m_pdxFieldTypes->size()) - 1; i >= 0; i--) {
- auto tmpft = m_pdxFieldTypes->at(i);
+ auto tmpft = m_pdxFieldTypes->at(i);
std::string temp = tmpft->getFieldName();
std::pair<std::string, std::shared_ptr<PdxFieldType>> pc(temp, tmpft);
m_fieldNameVsPdxType.insert(pc);
@@ -520,7 +520,7 @@ std::shared_ptr<PdxFieldType> previousField = nullptr;
prevFixedSizeOffsets = 0;
// now do optimization till you don't fine var len
for (uint32_t i = 0; (i < m_pdxFieldTypes->size()) && !foundVarLen; i++) {
- auto tmpft = m_pdxFieldTypes->at(i);
+ auto tmpft = m_pdxFieldTypes->at(i);
if (tmpft->IsVariableLengthType()) {
tmpft->setVarLenOffsetIndex(-1); // first var len field
diff --git a/cppcache/src/PdxType.hpp b/cppcache/src/PdxType.hpp
index e04226d..adccd5f 100644
--- a/cppcache/src/PdxType.hpp
+++ b/cppcache/src/PdxType.hpp
@@ -105,7 +105,7 @@ class PdxType : public Serializable,
public:
PdxType(std::shared_ptr<PdxTypeRegistry> pdxTypeRegistryPtr,
- std::string pdxDomainClassName, bool isLocal);
+ const std::string& pdxDomainClassName, bool isLocal);
~PdxType() noexcept override;
diff --git a/cppcache/src/PoolManagerImpl.cpp b/cppcache/src/PoolManagerImpl.cpp
index 9bdb42d..4f55824 100644
--- a/cppcache/src/PoolManagerImpl.cpp
+++ b/cppcache/src/PoolManagerImpl.cpp
@@ -17,6 +17,7 @@
#include <geode/Pool.hpp>
#include <geode/PoolFactory.hpp>
+#include <geode/Region.hpp>
#include "PoolManagerImpl.hpp"
#include "CacheImpl.hpp"
diff --git a/cppcache/src/RegionEntry.cpp b/cppcache/src/RegionEntry.cpp
index 3238c8e..939433a 100644
--- a/cppcache/src/RegionEntry.cpp
+++ b/cppcache/src/RegionEntry.cpp
@@ -17,6 +17,7 @@
#include <geode/Cache.hpp>
#include <geode/CacheableKey.hpp>
+#include <geode/RegionEntry.hpp>
#include "CacheableToken.hpp"
diff --git a/cppcache/src/RegionFactory.cpp b/cppcache/src/RegionFactory.cpp
index c367d3f..fdd7acb 100644
--- a/cppcache/src/RegionFactory.cpp
+++ b/cppcache/src/RegionFactory.cpp
@@ -18,19 +18,20 @@
#include <map>
#include <string>
-#include <ace/Recursive_Thread_Mutex.h>
#include <ace/Guard_T.h>
+#include <ace/Recursive_Thread_Mutex.h>
+#include <geode/Cache.hpp>
#include <geode/CacheFactory.hpp>
+#include <geode/PoolManager.hpp>
#include <geode/RegionFactory.hpp>
-#include <geode/Cache.hpp>
+#include <geode/RegionShortcut.hpp>
#include <geode/SystemProperties.hpp>
-#include <geode/PoolManager.hpp>
-#include "CppCacheLibrary.hpp"
#include "CacheImpl.hpp"
#include "CacheConfig.hpp"
#include "CacheRegionHelper.hpp"
+#include "CppCacheLibrary.hpp"
namespace apache {
namespace geode {
@@ -70,12 +71,14 @@ void RegionFactory::setRegionShortcut() {
} break;
case RegionShortcut::CACHING_PROXY_ENTRY_LRU: {
m_regionAttributesFactory->setCachingEnabled(true);
-
m_regionAttributesFactory->setLruEntriesLimit(DEFAULT_LRU_MAXIMUM_ENTRIES);
+ m_regionAttributesFactory->setLruEntriesLimit(
+ DEFAULT_LRU_MAXIMUM_ENTRIES);
} break;
case RegionShortcut::LOCAL: {
} break;
case RegionShortcut::LOCAL_ENTRY_LRU: {
-
m_regionAttributesFactory->setLruEntriesLimit(DEFAULT_LRU_MAXIMUM_ENTRIES);
+ m_regionAttributesFactory->setLruEntriesLimit(
+ DEFAULT_LRU_MAXIMUM_ENTRIES);
} break;
}
}
@@ -178,8 +181,7 @@ RegionFactory& RegionFactory::setLruEntriesLimit(const
uint32_t entriesLimit) {
return *this;
}
-RegionFactory& RegionFactory::setDiskPolicy(
- const DiskPolicyType diskPolicy) {
+RegionFactory& RegionFactory::setDiskPolicy(const DiskPolicyType diskPolicy) {
m_regionAttributesFactory->setDiskPolicy(diskPolicy);
return *this;
}
diff --git a/cppcache/src/TcrEndpoint.cpp b/cppcache/src/TcrEndpoint.cpp
index e46fc07..d0cfcd0 100644
--- a/cppcache/src/TcrEndpoint.cpp
+++ b/cppcache/src/TcrEndpoint.cpp
@@ -638,8 +638,8 @@ int TcrEndpoint::receiveNotification(volatile bool&
isRunning) {
if (!msg->hasCqPart()) {
if (msg->getMessageType() != TcrMessage::CLIENT_MARKER) {
const std::string& regionFullPath1 = msg->getRegionName();
- std::shared_ptr<Region> region1;
- m_cacheImpl->getRegion(regionFullPath1.c_str(), region1);
+ auto region1 = m_cacheImpl->getRegion(regionFullPath1);
+
if (region1 != nullptr &&
!static_cast<ThinClientRegion*>(region1.get())
->getDistMgr()
@@ -672,8 +672,8 @@ int TcrEndpoint::receiveNotification(volatile bool&
isRunning) {
if (!msg->hasCqPart()) // || msg->isInterestListPassed())
{
const std::string& regionFullPath = msg->getRegionName();
- std::shared_ptr<Region> region;
- m_cacheImpl->getRegion(regionFullPath.c_str(), region);
+ auto region = m_cacheImpl->getRegion(regionFullPath);
+
if (region != nullptr) {
static_cast<ThinClientRegion*>(region.get())
->receiveNotification(msg);
diff --git a/cppcache/src/ThinClientPoolDM.cpp
b/cppcache/src/ThinClientPoolDM.cpp
index c397f58..61b1bbb 100644
--- a/cppcache/src/ThinClientPoolDM.cpp
+++ b/cppcache/src/ThinClientPoolDM.cpp
@@ -1173,8 +1173,7 @@ TcrEndpoint* ThinClientPoolDM::getSingleHopServer(
auto region = nullptr == r ? nullptr : r->shared_from_this();
TcrEndpoint* ep = nullptr;
if (region == nullptr) {
- m_connManager.getCacheImpl()->getRegion(request.getRegionName().c_str(),
- region);
+ region = m_connManager.getCacheImpl()->getRegion(request.getRegionName());
}
if (region != nullptr) {
m_clientMetadataService->getBucketServerLocation(
@@ -1270,9 +1269,8 @@ GfErrType ThinClientPoolDM::sendSyncRequest(TcrMessage&
request,
type == TcrMessage::GET_ALL_WITH_CALLBACK) &&
m_clientMetadataService != nullptr) {
GfErrType error = GF_NOERR;
- std::shared_ptr<Region> region;
- m_connManager.getCacheImpl()->getRegion(request.getRegionName().c_str(),
- region);
+
+ auto region =
m_connManager.getCacheImpl()->getRegion(request.getRegionName());
auto locationMap = m_clientMetadataService->getServerToFilterMap(
*(request.getKeys()), region, request.forPrimary());
@@ -1429,9 +1427,8 @@ GfErrType ThinClientPoolDM::sendSyncRequest(
return GF_CLIENT_WAIT_TIMEOUT;
} else if (queueErr == GF_CLIENT_WAIT_TIMEOUT_REFRESH_PRMETADATA) {
// need to refresh meta data
- std::shared_ptr<Region> region;
- m_connManager.getCacheImpl()->getRegion(request.getRegionName().c_str(),
- region);
+ auto region =
m_connManager.getCacheImpl()->getRegion(request.getRegionName());
+
if (region != nullptr) {
LOGFINE(
"Need to refresh pr-meta-data timeout in client only with refresh
"
@@ -1558,9 +1555,8 @@ GfErrType ThinClientPoolDM::sendSyncRequest(
request.getKeyRef() != nullptr && reply.isFEAnotherHop()))) {
// Need to get direct access to Region's name to avoid referencing
// temp data and causing crashes
- std::shared_ptr<Region> region;
-
m_connManager.getCacheImpl()->getRegion(request.getRegionName().c_str(),
- region);
+ auto region =
m_connManager.getCacheImpl()->getRegion(request.getRegionName());
+
if (region != nullptr) {
if (!connFound) // max limit case then don't refresh otherwise
always
// refresh
@@ -2449,9 +2445,8 @@ TcrConnection* ThinClientPoolDM::getConnectionFromQueueW(
if (m_clientMetadataService == nullptr || request.getKey() == nullptr)
{
return nullptr;
}
- std::shared_ptr<Region> region;
-
m_connManager.getCacheImpl()->getRegion(request.getRegionName().c_str(),
- region);
+
+ auto region =
m_connManager.getCacheImpl()->getRegion(request.getRegionName());
if (region != nullptr) {
slTmp = nullptr;
m_clientMetadataService
diff --git a/examples/cpp/customserializable/main.cpp
b/examples/cpp/customserializable/main.cpp
index a7c9017..ec14839 100644
--- a/examples/cpp/customserializable/main.cpp
+++ b/examples/cpp/customserializable/main.cpp
@@ -19,8 +19,10 @@
#include <sstream>
#include <geode/CacheFactory.hpp>
-#include <geode/PdxWrapper.hpp>
#include <geode/PoolManager.hpp>
+#include <geode/RegionFactory.hpp>
+#include <geode/RegionShortcut.hpp>
+#include <geode/TypeRegistry.hpp>
#include "Order.hpp"
diff --git a/examples/cpp/customserializer/main.cpp
b/examples/cpp/customserializer/main.cpp
index 8460e30..51cc9f6 100644
--- a/examples/cpp/customserializer/main.cpp
+++ b/examples/cpp/customserializer/main.cpp
@@ -21,6 +21,10 @@
#include <geode/PoolManager.hpp>
#include <geode/PdxSerializer.hpp>
#include <geode/PdxWrapper.hpp>
+#include <geode/RegionFactory.hpp>
+#include <geode/RegionShortcut.hpp>
+#include <geode/TypeRegistry.hpp>
+
#include "Order.hpp"
#include "OrderSerializer.hpp"
diff --git a/examples/cpp/put-get-remove/main.cpp
b/examples/cpp/put-get-remove/main.cpp
index 87bcdb6..8005682 100644
--- a/examples/cpp/put-get-remove/main.cpp
+++ b/examples/cpp/put-get-remove/main.cpp
@@ -19,11 +19,12 @@
#include <geode/CacheFactory.hpp>
#include <geode/PoolManager.hpp>
+#include <geode/RegionFactory.hpp>
+#include <geode/RegionShortcut.hpp>
using namespace apache::geode::client;
int main(int argc, char** argv) {
-
auto cacheFactory = CacheFactory();
cacheFactory.set("log-level", "none");
auto cache = cacheFactory.create();
@@ -41,16 +42,19 @@ int main(int argc, char** argv) {
std::cout << "Getting the user info from the region" << std::endl;
auto user1 = region->get("rtimmons");
auto user2 = region->get("scharles");
- std::cout << " rtimmons = " <<
std::dynamic_pointer_cast<CacheableString>(user1)->value() << std::endl;
- std::cout << " scharles = " <<
std::dynamic_pointer_cast<CacheableString>(user2)->value() << std::endl;
+ std::cout << " rtimmons = "
+ << std::dynamic_pointer_cast<CacheableString>(user1)->value()
+ << std::endl;
+ std::cout << " scharles = "
+ << std::dynamic_pointer_cast<CacheableString>(user2)->value()
+ << std::endl;
std::cout << "Removing rtimmons info from the region" << std::endl;
region->remove("rtimmons");
- if(region->existsValue("rtimmons")) {
+ if (region->existsValue("rtimmons")) {
std::cout << "rtimmons's info not deleted" << std::endl;
- }
- else {
+ } else {
std::cout << "rtimmons's info successfully deleted" << std::endl;
}
diff --git a/tests/cpp/fwklib/RegionHelper.hpp
b/tests/cpp/fwklib/RegionHelper.hpp
index 5a4f8b1..b45f8c7 100644
--- a/tests/cpp/fwklib/RegionHelper.hpp
+++ b/tests/cpp/fwklib/RegionHelper.hpp
@@ -25,6 +25,8 @@
#include <map>
#include <geode/internal/chrono/duration.hpp>
+#include <geode/RegionFactory.hpp>
+#include <geode/RegionShortcut.hpp>
#include "fwklib/FrameworkTest.hpp"
#include "fwklib/FwkObjects.hpp"
--
To stop receiving notification emails like this one, please contact
[email protected].