You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ec...@apache.org on 2017/08/10 15:20:09 UTC
[01/27] geode-native git commit: GEODE-2729: Remove global variables
Repository: geode-native
Updated Branches:
refs/heads/develop 5b1634a34 -> da389793e
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cpp/fwklib/FwkObjects.hpp
----------------------------------------------------------------------
diff --git a/src/tests/cpp/fwklib/FwkObjects.hpp b/src/tests/cpp/fwklib/FwkObjects.hpp
index 6068616..b8a3793 100644
--- a/src/tests/cpp/fwklib/FwkObjects.hpp
+++ b/src/tests/cpp/fwklib/FwkObjects.hpp
@@ -21,14 +21,15 @@
*/
/**
- * @file FwkObjects.hpp
- * @since 1.0
- * @version 1.0
- * @see
- */
+ * @file FwkObjects.hpp
+ * @since 1.0
+ * @version 1.0
+ * @see
+ */
// ----------------------------------------------------------------------------
+#include <geode/Cache.hpp>
#include <geode/Properties.hpp>
#include <geode/ExpirationAction.hpp>
#include <geode/RegionAttributes.hpp>
@@ -124,10 +125,10 @@ class FwkObject {
// ----------------------------------------------------------------------------
/**
- * @class TFwkSet
- *
- * @brief Framework base data object set template
- */
+ * @class TFwkSet
+ *
+ * @brief Framework base data object set template
+ */
template <class FWK_OBJECT>
class TFwkSet {
@@ -157,8 +158,8 @@ class TFwkSet {
}
/** @brief Find a object in collection
- * @param key Object key to find
- */
+ * @param key Object key to find
+ */
const FWK_OBJECT* find(const std::string& key) const {
const FWK_OBJECT* obj = NULL;
int32_t pos = findIdx(key);
@@ -209,8 +210,8 @@ class TFwkSet {
}
/** @brief Add an object
- * @param obj Object to add
- */
+ * @param obj Object to add
+ */
void add(const FWK_OBJECT* obj) {
if (obj != NULL) {
m_vec.push_back(obj);
@@ -251,9 +252,9 @@ typedef std::vector<std::string> StringVector;
// ----------------------------------------------------------------------------
/** @class XMLStringConverter
- * @brief This is a simple class that lets us do easy (though not
- * terribly efficient) trancoding of char* data to XMLCh data.
- */
+ * @brief This is a simple class that lets us do easy (though not
+ * terribly efficient) trancoding of char* data to XMLCh data.
+ */
class XMLStringConverter {
public:
XMLStringConverter(const char* const toTranscode) {
@@ -492,6 +493,8 @@ class FwkRegion {
class FwkPool {
std::string m_name;
+ CachePtr m_cache;
+ PoolManager* m_poolManager;
PoolFactoryPtr m_poolFactory;
bool m_locators;
bool m_servers;
@@ -600,16 +603,17 @@ class FwkPool {
}
}
- PoolPtr createPoolForPerf() { return m_poolFactory->create(m_name.c_str()); }
+ // PoolPtr createPoolForPerf() { return
+ // m_poolFactory->create(m_name.c_str()); }
- PoolPtr createPool() const {
- if (m_name.empty()) {
- FWKEXCEPTION("Pool name not specified.");
- } else {
- return m_poolFactory->create(m_name.c_str());
- }
- return nullptr;
- }
+ // PoolPtr createPool() const {
+ // if (m_name.empty()) {
+ // FWKEXCEPTION("Pool name not specified.");
+ // } else {
+ // return m_poolFactory->create(m_name.c_str());
+ // }
+ // return nullptr;
+ // }
const std::string& getName() const { return m_name; }
void print() const { FWKINFO("FwkPool " << m_name); }
};
@@ -899,11 +903,11 @@ class FwkData : public FwkObject {
// ----------------------------------------------------------------------------
/**
- * @class FwkDataSet
- *
- * @brief Container to hold FwkData objects
- * @see FwkData
- */
+ * @class FwkDataSet
+ *
+ * @brief Container to hold FwkData objects
+ * @see FwkData
+ */
class FwkDataSet : public TFwkSet<FwkData> {
public:
FwkDataSet() {}
@@ -913,10 +917,10 @@ class FwkDataSet : public TFwkSet<FwkData> {
// ----------------------------------------------------------------------------
/**
- * @class FwkClient
- *
- * @brief FwkClient object
- */
+ * @class FwkClient
+ *
+ * @brief FwkClient object
+ */
class FwkClient : public FwkObject {
public:
FwkClient(const DOMNode* node);
@@ -973,11 +977,11 @@ class FwkClient : public FwkObject {
// ----------------------------------------------------------------------------
/**
- * @class FwkClientSet
- *
- * @brief Container to hold FwkClient objects
- * @see FwkClient
- */
+ * @class FwkClientSet
+ *
+ * @brief Container to hold FwkClient objects
+ * @see FwkClient
+ */
class FwkClientSet : public TFwkSet<FwkClient> {
bool m_exclude;
int32_t m_count;
@@ -1030,10 +1034,10 @@ typedef std::list<uint32_t> TaskClientIdxList;
class FwkTest;
/**
- * @class FwkTask
- *
- * @brief FwkTask object
- */
+ * @class FwkTask
+ *
+ * @brief FwkTask object
+ */
class FwkTask : public FwkObject {
public:
FwkTask(const DOMNode* node);
@@ -1201,8 +1205,8 @@ class FwkTask : public FwkObject {
}
/** @brief Add ClientSet
- * @param set ClientSet to add
- */
+ * @param set ClientSet to add
+ */
void addClientSet(FwkClientSet* set) {
const FwkClient* client = set->getFirst();
while (client != NULL) {
@@ -1253,21 +1257,21 @@ class FwkTask : public FwkObject {
// ----------------------------------------------------------------------------
/**
-* @class FwkTaskSet
-*
-* @brief Container to hold FwkTask objects
-* @see FwkTask
-*/
+ * @class FwkTaskSet
+ *
+ * @brief Container to hold FwkTask objects
+ * @see FwkTask
+ */
class FwkTaskSet : public TFwkSet<FwkTask> {};
// ----------------------------------------------------------------------------
class TestDriver;
/**
- * @class FwkTest
- *
- * @brief FwkTest object
- */
+ * @class FwkTest
+ *
+ * @brief FwkTest object
+ */
class FwkTest : public FwkObject {
public:
FwkTest(const DOMNode* node);
@@ -1355,11 +1359,11 @@ class FwkTest : public FwkObject {
// ----------------------------------------------------------------------------
/**
-* @class FwkTestSet
-*
-* @brief Container to hold FwkTest objects
-* @see FwkTest
-*/
+ * @class FwkTestSet
+ *
+ * @brief Container to hold FwkTest objects
+ * @see FwkTest
+ */
class FwkTestSet : public TFwkSet<FwkTest> {};
// ----------------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cpp/fwklib/PoolHelper.hpp
----------------------------------------------------------------------
diff --git a/src/tests/cpp/fwklib/PoolHelper.hpp b/src/tests/cpp/fwklib/PoolHelper.hpp
index 2d7d1a4..f397992 100644
--- a/src/tests/cpp/fwklib/PoolHelper.hpp
+++ b/src/tests/cpp/fwklib/PoolHelper.hpp
@@ -40,9 +40,9 @@ namespace testframework {
// ----------------------------------------------------------------------------
/** @class PoolHelper
- * @brief Class used to define a valid combination of attributes and
- * specifications for a pool.
- */
+ * @brief Class used to define a valid combination of attributes and
+ * specifications for a pool.
+ */
class PoolHelper {
const FwkPool* m_pool;
std::string m_spec;
@@ -128,7 +128,7 @@ class PoolHelper {
PoolPtr createPool() {
const char* poolName = m_pool->getName().c_str();
- PoolPtr pptr = PoolManager::find(poolName);
+ PoolPtr pptr = m_pool->m_poolManager.find(poolName);
if (pptr == nullptr) {
pptr = m_pool->createPool();
}
@@ -143,9 +143,9 @@ class PoolHelper {
};
} // namespace testframework
-}
-}
-}
+} // namespace client
+} // namespace geode
+} // namespace apache
// ----------------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cpp/fwklib/QueryHelper.hpp
----------------------------------------------------------------------
diff --git a/src/tests/cpp/fwklib/QueryHelper.hpp b/src/tests/cpp/fwklib/QueryHelper.hpp
index ecf6c1c..c509bdc 100644
--- a/src/tests/cpp/fwklib/QueryHelper.hpp
+++ b/src/tests/cpp/fwklib/QueryHelper.hpp
@@ -36,7 +36,8 @@
#include <geode/ResultSet.hpp>
#include <geode/StructSet.hpp>
-
+#include "SerializationRegistry.hpp"
+#include "DataOutputInternal.hpp"
#ifndef ROOT_SCOPE
#define ROOT_SCOPE LOCAL
#endif
@@ -806,7 +807,7 @@ bool QueryHelper::compareTwoPositionObjects(SerializablePtr pos1,
return false;
}
- DataOutput o1, o2;
+ DataOutputInternal o1, o2;
p1->toData(o1);
p2->toData(o2);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cpp/security/PkcsAuthInit.cpp
----------------------------------------------------------------------
diff --git a/src/tests/cpp/security/PkcsAuthInit.cpp b/src/tests/cpp/security/PkcsAuthInit.cpp
index f77de9b..f17b59e 100644
--- a/src/tests/cpp/security/PkcsAuthInit.cpp
+++ b/src/tests/cpp/security/PkcsAuthInit.cpp
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+#include "SerializationRegistry.hpp"
#include "PkcsAuthInit.hpp"
#include <geode/Properties.hpp>
#include <geode/CacheableBuiltins.hpp>
@@ -109,8 +109,8 @@ static bool s_initDone = openSSLInit();
}
// end of extern "C"
-PropertiesPtr PKCSAuthInitInternal::getCredentials(PropertiesPtr& securityprops,
- const char* server) {
+PropertiesPtr PKCSAuthInitInternal::getCredentials(
+ const PropertiesPtr& securityprops, const char* server) {
if (!s_initDone) {
throw AuthenticationFailedException(
"PKCSAuthInit::getCredentials: "
@@ -151,7 +151,6 @@ PropertiesPtr PKCSAuthInitInternal::getCredentials(PropertiesPtr& securityprops,
"PKCSAuthInit::getCredentials: "
"key-store password property KEYSTORE_PASSWORD not set.");
}
- DataOutput additionalMsg;
FILE* keyStoreFP = fopen(keyStorePath, "r");
if (keyStoreFP == NULL) {
@@ -176,17 +175,10 @@ PropertiesPtr PKCSAuthInitInternal::getCredentials(PropertiesPtr& securityprops,
}
fclose(keyStoreFP);
-
- additionalMsg.writeUTF(alias);
-
- uint32_t dataLen;
- char* data = (char*)additionalMsg.getBuffer(&dataLen);
unsigned int lengthEncryptedData = 0;
- // Skip first two bytes of the java UTF-8 encoded string
- // containing the length of the string.
uint8_t* signatureData = createSignature(
- privateKey, cert, reinterpret_cast<unsigned char*>(data + 2), dataLen - 2,
+ privateKey, cert, reinterpret_cast<const unsigned char*>(alias), strlen(alias),
&lengthEncryptedData);
EVP_PKEY_free(privateKey);
X509_free(cert);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cpp/security/PkcsAuthInit.hpp
----------------------------------------------------------------------
diff --git a/src/tests/cpp/security/PkcsAuthInit.hpp b/src/tests/cpp/security/PkcsAuthInit.hpp
index 6649bfa..e094b1b 100644
--- a/src/tests/cpp/security/PkcsAuthInit.hpp
+++ b/src/tests/cpp/security/PkcsAuthInit.hpp
@@ -88,7 +88,7 @@ class PKCSAuthInitInternal : public AuthInitialize {
* The format expected is "host:port".
* @returns the credentials to be used for the given <code>server</code>
*/
- PropertiesPtr getCredentials(PropertiesPtr& securityprops,
+ PropertiesPtr getCredentials(const PropertiesPtr& securityprops,
const char* server);
/**
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cpp/testobject/ArrayOfByte.hpp
----------------------------------------------------------------------
diff --git a/src/tests/cpp/testobject/ArrayOfByte.hpp b/src/tests/cpp/testobject/ArrayOfByte.hpp
index 58fe730..a898468 100644
--- a/src/tests/cpp/testobject/ArrayOfByte.hpp
+++ b/src/tests/cpp/testobject/ArrayOfByte.hpp
@@ -26,6 +26,10 @@
#include "fwklib/FrameworkTest.hpp"
#include <ace/Time_Value.h>
+#include "SerializationRegistry.hpp"
+#include "DataInputInternal.hpp"
+#include "DataOutputInternal.hpp"
+
#ifdef _WIN32
#ifdef BUILD_TESTOBJECT
#define TESTOBJECT_EXPORT LIBEXP
@@ -46,7 +50,7 @@ class TESTOBJECT_EXPORT ArrayOfByte {
static CacheableBytesPtr init(int size, bool encodeKey,
bool encodeTimestamp) {
if (encodeKey) {
- DataOutput dos;
+ DataOutputInternal dos;
try {
int32_t index = 1234;
dos.writeInt(index);
@@ -76,12 +80,13 @@ class TESTOBJECT_EXPORT ArrayOfByte {
}
}
- static int64_t getTimestamp(CacheableBytesPtr bytes) {
+ static int64_t getTimestamp(CacheableBytesPtr bytes,
+ SerializationRegistry &serializationRegistry) {
if (bytes == nullptr) {
throw apache::geode::client::IllegalArgumentException(
"the bytes arg was null");
}
- DataInput di(bytes->value(), bytes->length());
+ DataInputInternal di(bytes->value(), bytes->length(), nullptr);
try {
int32_t index;
di.readInt(&index);
@@ -96,8 +101,9 @@ class TESTOBJECT_EXPORT ArrayOfByte {
}
}
- static void resetTimestamp(CacheableBytesPtr bytes) {
- DataInput di(bytes->value(), bytes->length());
+ static void resetTimestamp(CacheableBytesPtr bytes,
+ SerializationRegistry &serializationRegistry) {
+ DataInputInternal di(bytes->value(), bytes->length(), nullptr);
int32_t index;
try {
di.readInt(&index);
@@ -109,7 +115,7 @@ class TESTOBJECT_EXPORT ArrayOfByte {
} catch (Exception &e) {
FWKEXCEPTION("Unable to read from stream " << e.getMessage());
}
- DataOutput dos;
+ DataOutputInternal dos;
try {
dos.writeInt(index);
ACE_Time_Value startTime;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cpp/testobject/DeltaFastAssetAccount.cpp
----------------------------------------------------------------------
diff --git a/src/tests/cpp/testobject/DeltaFastAssetAccount.cpp b/src/tests/cpp/testobject/DeltaFastAssetAccount.cpp
index 3094b2d..8530b63 100644
--- a/src/tests/cpp/testobject/DeltaFastAssetAccount.cpp
+++ b/src/tests/cpp/testobject/DeltaFastAssetAccount.cpp
@@ -23,7 +23,7 @@ using namespace testobject;
DeltaFastAssetAccount::DeltaFastAssetAccount(int index, bool encodeTimestp,
int maxVal, int asstSize,
bool getbfrUpdate)
- : encodeTimestamp(encodeTimestp), acctId(index) {
+ : Delta(nullptr), encodeTimestamp(encodeTimestp), acctId(index) {
customerName = CacheableString::create("Milton Moneybags");
netWorth = 0.0;
assets = CacheableHashMap::create();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cpp/testobject/DeltaFastAssetAccount.hpp
----------------------------------------------------------------------
diff --git a/src/tests/cpp/testobject/DeltaFastAssetAccount.hpp b/src/tests/cpp/testobject/DeltaFastAssetAccount.hpp
index e08e6b3..f27cb09 100644
--- a/src/tests/cpp/testobject/DeltaFastAssetAccount.hpp
+++ b/src/tests/cpp/testobject/DeltaFastAssetAccount.hpp
@@ -63,7 +63,8 @@ class TESTOBJECT_EXPORT DeltaFastAssetAccount : public Cacheable, public Delta {
public:
DeltaFastAssetAccount()
- : encodeTimestamp(0),
+ : Delta(nullptr),
+ encodeTimestamp(0),
acctId(0),
customerName(nullptr),
netWorth(0.0),
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cpp/testobject/DeltaPSTObject.cpp
----------------------------------------------------------------------
diff --git a/src/tests/cpp/testobject/DeltaPSTObject.cpp b/src/tests/cpp/testobject/DeltaPSTObject.cpp
index 4f3dfdc..94246e6 100644
--- a/src/tests/cpp/testobject/DeltaPSTObject.cpp
+++ b/src/tests/cpp/testobject/DeltaPSTObject.cpp
@@ -22,7 +22,8 @@ using namespace apache::geode::client;
using namespace testframework;
using namespace testobject;
-DeltaPSTObject::DeltaPSTObject(int size, bool encodeKey, bool encodeTimestamp) {
+DeltaPSTObject::DeltaPSTObject(int size, bool encodeKey, bool encodeTimestamp)
+ : Delta(nullptr) {
ACE_Time_Value startTime;
startTime = ACE_OS::gettimeofday();
ACE_UINT64 tusec = 0;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cpp/testobject/DeltaPSTObject.hpp
----------------------------------------------------------------------
diff --git a/src/tests/cpp/testobject/DeltaPSTObject.hpp b/src/tests/cpp/testobject/DeltaPSTObject.hpp
index b06cee3..2b581a1 100644
--- a/src/tests/cpp/testobject/DeltaPSTObject.hpp
+++ b/src/tests/cpp/testobject/DeltaPSTObject.hpp
@@ -59,7 +59,7 @@ class TESTOBJECT_EXPORT DeltaPSTObject : public Cacheable, public Delta {
}
public:
- DeltaPSTObject() : timestamp(0), valueData(nullptr) {}
+ DeltaPSTObject() : Delta(nullptr), timestamp(0), valueData(nullptr) {}
DeltaPSTObject(int size, bool encodeKey, bool encodeTimestamp);
virtual ~DeltaPSTObject() {}
void toData(apache::geode::client::DataOutput& output) const;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cpp/testobject/DeltaTestImpl.cpp
----------------------------------------------------------------------
diff --git a/src/tests/cpp/testobject/DeltaTestImpl.cpp b/src/tests/cpp/testobject/DeltaTestImpl.cpp
index 43ddd7c..f77bdcc 100644
--- a/src/tests/cpp/testobject/DeltaTestImpl.cpp
+++ b/src/tests/cpp/testobject/DeltaTestImpl.cpp
@@ -31,7 +31,7 @@ uint8_t DeltaTestImpl::BYTE_ARR_MASK = 0x8;
uint8_t DeltaTestImpl::TEST_OBJ_MASK = 0x10;
uint8_t DeltaTestImpl::COMPLETE_MASK = 0x1F;
-DeltaTestImpl::DeltaTestImpl() {
+DeltaTestImpl::DeltaTestImpl() : Delta(nullptr) {
intVar = 1;
str = CacheableString::create("test");
doubleVar = 1.1;
@@ -44,18 +44,20 @@ DeltaTestImpl::DeltaTestImpl() {
fromDeltaCounter = 0;
}
DeltaTestImpl::DeltaTestImpl(int intValue, CacheableStringPtr strptr)
- : intVar(intValue),
+ : Delta(nullptr),
+ intVar(intValue),
str(strptr),
doubleVar(0),
toDeltaCounter(0),
fromDeltaCounter(0) {}
-DeltaTestImpl::DeltaTestImpl(DeltaTestImplPtr rhs) {
+DeltaTestImpl::DeltaTestImpl(DeltaTestImplPtr rhs) : Delta(nullptr) {
intVar = rhs->intVar;
str = CacheableString::create(rhs->str->asChar());
doubleVar = rhs->doubleVar;
- byteArr = (rhs->byteArr == nullptr ? nullptr : CacheableBytes::create(
- rhs->byteArr->value(),
- rhs->byteArr->length()));
+ byteArr = (rhs->byteArr == nullptr
+ ? nullptr
+ : CacheableBytes::create(rhs->byteArr->value(),
+ rhs->byteArr->length()));
testObj = (rhs->testObj == nullptr
? nullptr
: TestObject1Ptr(new TestObject1(*(rhs->testObj.get()))));
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cpp/testobject/NonPdxType.hpp
----------------------------------------------------------------------
diff --git a/src/tests/cpp/testobject/NonPdxType.hpp b/src/tests/cpp/testobject/NonPdxType.hpp
index b7f5989..2641870 100644
--- a/src/tests/cpp/testobject/NonPdxType.hpp
+++ b/src/tests/cpp/testobject/NonPdxType.hpp
@@ -27,7 +27,7 @@
*/
#include <geode/GeodeCppCache.hpp>
-
+#include "SerializationRegistry.hpp"
#ifdef _WIN32
#ifdef BUILD_TESTOBJECT
#define TESTOBJECT_EXPORT LIBEXP
@@ -163,7 +163,7 @@ class TESTOBJECT_EXPORT NonPdxType {
public:
bool selfCheck();
- inline void init() {
+ inline void init(PdxSerializerPtr pdxSerializer) {
m_char = 'C';
m_bool = true;
m_byte = 0x74;
@@ -300,27 +300,36 @@ class TESTOBJECT_EXPORT NonPdxType {
m_add[9] = new NonPdxAddress(10, "street9", "city9");
m_objectArray = CacheableObjectArray::create();
-
- m_objectArray->push_back(PdxWrapperPtr(new PdxWrapper(
- new NonPdxAddress(1, "street0", "city0"), "PdxTests.Address")));
- m_objectArray->push_back(PdxWrapperPtr(new PdxWrapper(
- new NonPdxAddress(2, "street1", "city1"), "PdxTests.Address")));
- m_objectArray->push_back(PdxWrapperPtr(new PdxWrapper(
- new NonPdxAddress(3, "street2", "city2"), "PdxTests.Address")));
- m_objectArray->push_back(PdxWrapperPtr(new PdxWrapper(
- new NonPdxAddress(4, "street3", "city3"), "PdxTests.Address")));
- m_objectArray->push_back(PdxWrapperPtr(new PdxWrapper(
- new NonPdxAddress(5, "street4", "city4"), "PdxTests.Address")));
- m_objectArray->push_back(PdxWrapperPtr(new PdxWrapper(
- new NonPdxAddress(6, "street5", "city5"), "PdxTests.Address")));
- m_objectArray->push_back(PdxWrapperPtr(new PdxWrapper(
- new NonPdxAddress(7, "street6", "city6"), "PdxTests.Address")));
- m_objectArray->push_back(PdxWrapperPtr(new PdxWrapper(
- new NonPdxAddress(8, "street7", "city7"), "PdxTests.Address")));
- m_objectArray->push_back(PdxWrapperPtr(new PdxWrapper(
- new NonPdxAddress(9, "street8", "city8"), "PdxTests.Address")));
- m_objectArray->push_back(PdxWrapperPtr(new PdxWrapper(
- new NonPdxAddress(10, "street9", "city9"), "PdxTests.Address")));
+ m_objectArray->push_back(
+ PdxWrapperPtr(new PdxWrapper(new NonPdxAddress(1, "street0", "city0"),
+ "PdxTests.Address", pdxSerializer)));
+ m_objectArray->push_back(
+ PdxWrapperPtr(new PdxWrapper(new NonPdxAddress(2, "street1", "city1"),
+ "PdxTests.Address", pdxSerializer)));
+ m_objectArray->push_back(
+ PdxWrapperPtr(new PdxWrapper(new NonPdxAddress(3, "street2", "city2"),
+ "PdxTests.Address", pdxSerializer)));
+ m_objectArray->push_back(
+ PdxWrapperPtr(new PdxWrapper(new NonPdxAddress(4, "street3", "city3"),
+ "PdxTests.Address", pdxSerializer)));
+ m_objectArray->push_back(
+ PdxWrapperPtr(new PdxWrapper(new NonPdxAddress(5, "street4", "city4"),
+ "PdxTests.Address", pdxSerializer)));
+ m_objectArray->push_back(
+ PdxWrapperPtr(new PdxWrapper(new NonPdxAddress(6, "street5", "city5"),
+ "PdxTests.Address", pdxSerializer)));
+ m_objectArray->push_back(
+ PdxWrapperPtr(new PdxWrapper(new NonPdxAddress(7, "street6", "city6"),
+ "PdxTests.Address", pdxSerializer)));
+ m_objectArray->push_back(
+ PdxWrapperPtr(new PdxWrapper(new NonPdxAddress(8, "street7", "city7"),
+ "PdxTests.Address", pdxSerializer)));
+ m_objectArray->push_back(
+ PdxWrapperPtr(new PdxWrapper(new NonPdxAddress(9, "street8", "city8"),
+ "PdxTests.Address", pdxSerializer)));
+ m_objectArray->push_back(
+ PdxWrapperPtr(new PdxWrapper(new NonPdxAddress(10, "street9", "city9"),
+ "PdxTests.Address", pdxSerializer)));
m_byte252 = new int8_t[252];
for (int i = 0; i < 252; i++) {
@@ -359,7 +368,7 @@ class TESTOBJECT_EXPORT NonPdxType {
lengthArr[1] = 2;
}
- NonPdxType() { init(); }
+ NonPdxType(PdxSerializerPtr pdxSerializer) { init(pdxSerializer); }
inline bool compareBool(bool b, bool b2) {
if (b == b2) return b;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cpp/testobject/NoopAuthInit.cpp
----------------------------------------------------------------------
diff --git a/src/tests/cpp/testobject/NoopAuthInit.cpp b/src/tests/cpp/testobject/NoopAuthInit.cpp
index b502894..94704c8 100644
--- a/src/tests/cpp/testobject/NoopAuthInit.cpp
+++ b/src/tests/cpp/testobject/NoopAuthInit.cpp
@@ -31,7 +31,7 @@ LIBEXP AuthInitialize* createNoopAuthInitInstance() {
}
}
-PropertiesPtr NoopAuthInit::getCredentials(PropertiesPtr& securityprops,
+PropertiesPtr NoopAuthInit::getCredentials(const PropertiesPtr& securityprops,
const char* server) {
LOGINFO("rjk: calling NoopAuthInit::getCredentials");
PropertiesPtr credentials = Properties::create();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cpp/testobject/NoopAuthInit.hpp
----------------------------------------------------------------------
diff --git a/src/tests/cpp/testobject/NoopAuthInit.hpp b/src/tests/cpp/testobject/NoopAuthInit.hpp
index e5a996c..cf3c240 100644
--- a/src/tests/cpp/testobject/NoopAuthInit.hpp
+++ b/src/tests/cpp/testobject/NoopAuthInit.hpp
@@ -68,7 +68,7 @@ class NoopAuthInit : public AuthInitialize {
* @remarks This method can modify the given set of properties. For
* example it may invoke external agents or even interact with the user.
*/
- PropertiesPtr getCredentials(PropertiesPtr& securityprops,
+ PropertiesPtr getCredentials(const PropertiesPtr& securityprops,
const char* server);
/**
[08/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/TcrEndpoint.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TcrEndpoint.cpp b/src/cppcache/src/TcrEndpoint.cpp
index 8e99010..ac480ea 100644
--- a/src/cppcache/src/TcrEndpoint.cpp
+++ b/src/cppcache/src/TcrEndpoint.cpp
@@ -42,15 +42,16 @@ This is replaced by the connect-timeout (times 3) system property for SR # 6525.
*/
const char* TcrEndpoint::NC_Notification = "NC Notification";
-TcrEndpoint::TcrEndpoint(const std::string& name, CacheImpl* cache,
+TcrEndpoint::TcrEndpoint(const std::string& name, CacheImpl* cacheImpl,
ACE_Semaphore& failoverSema,
ACE_Semaphore& cleanupSema,
ACE_Semaphore& redundancySema, ThinClientBaseDM* DM,
bool isMultiUserMode)
: m_needToConnectInLock(false),
m_connectLockCond(m_connectLock),
- m_maxConnections(
- DistributedSystem::getSystemProperties()->javaConnectionPoolSize()),
+ m_maxConnections(cacheImpl->getDistributedSystem()
+ .getSystemProperties()
+ .javaConnectionPoolSize()),
m_notifyConnection(0),
m_notifyReceiver(0),
m_numRegionListener(0),
@@ -67,7 +68,7 @@ TcrEndpoint::TcrEndpoint(const std::string& name, CacheImpl* cache,
m_numRegions(0),
m_pingTimeouts(0),
m_notifyCount(0),
- m_cache(cache),
+ m_cacheImpl(cacheImpl),
m_failoverSema(failoverSema),
m_cleanupSema(cleanupSema),
m_notificationCleanupSema(0),
@@ -115,7 +116,9 @@ TcrEndpoint::~TcrEndpoint() {
inline bool TcrEndpoint::needtoTakeConnectLock() {
#ifdef __linux
- if (DistributedSystem::getSystemProperties()->connectWaitTimeout() > 0) {
+ if (m_cacheImpl->getDistributedSystem()
+ .getSystemProperties()
+ .connectWaitTimeout() > 0) {
return m_needToConnectInLock; // once pipe or other socket error will take
// lock to connect.
}
@@ -130,9 +133,10 @@ GfErrType TcrEndpoint::createNewConnectionWL(TcrConnection*& newConn,
bool isSecondary,
uint32_t connectTimeout) {
LOGFINE("TcrEndpoint::createNewConnectionWL");
- uint32_t connectWaitTimeout =
- DistributedSystem::getSystemProperties()->connectWaitTimeout() *
- 1000; // need to change
+ uint32_t connectWaitTimeout = m_cacheImpl->getDistributedSystem()
+ .getSystemProperties()
+ .connectWaitTimeout() *
+ 1000; // need to change
ACE_Time_Value interval(0, connectWaitTimeout);
ACE_Time_Value stopAt(ACE_OS::gettimeofday());
stopAt += interval;
@@ -148,7 +152,8 @@ GfErrType TcrEndpoint::createNewConnectionWL(TcrConnection*& newConn,
if (ret != -1) { // got lock
try {
LOGFINE("TcrEndpoint::createNewConnectionWL got lock");
- newConn = new TcrConnection(m_connected);
+ newConn =
+ new TcrConnection(m_cacheImpl->tcrConnectionManager(), m_connected);
newConn->InitTcrConnection(this, m_name.c_str(), m_ports,
isClientNotification, isSecondary,
connectTimeout);
@@ -204,7 +209,8 @@ GfErrType TcrEndpoint::createNewConnection(
try {
if (newConn == nullptr) {
if (!needtoTakeConnectLock() || !appThreadRequest) {
- newConn = new TcrConnection(m_connected);
+ newConn = new TcrConnection(m_cacheImpl->tcrConnectionManager(),
+ m_connected);
bool authenticate = newConn->InitTcrConnection(
this, m_name.c_str(), m_ports, isClientNotification, isSecondary,
connectTimeout);
@@ -231,6 +237,10 @@ GfErrType TcrEndpoint::createNewConnection(
LOGFINE("Sending update notification message to endpoint %s",
m_name.c_str());
TcrMessageUpdateClientNotification updateNotificationMsg(
+ newConn->getConnectionManager()
+ .getCacheImpl()
+ ->getCache()
+ ->createDataOutput(),
static_cast<int32_t>(newConn->getPort()));
newConn->send(updateNotificationMsg.getMsgData(),
updateNotificationMsg.getMsgLength());
@@ -290,12 +300,12 @@ void TcrEndpoint::authenticateEndpoint(TcrConnection*& conn) {
LOGDEBUG(
"TcrEndpoint::authenticateEndpoint m_isAuthenticated = %d "
"this->m_baseDM = %d",
- m_isAuthenticated, this->m_baseDM);
- if (!m_isAuthenticated && this->m_baseDM) {
+ m_isAuthenticated, m_baseDM);
+ if (!m_isAuthenticated && m_baseDM) {
this->setConnected();
ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_endpointAuthenticationLock);
GfErrType err = GF_NOERR;
- PropertiesPtr creds = this->getCredentials();
+ PropertiesPtr creds = getCredentials();
if (creds != nullptr) {
LOGDEBUG("TcrEndpoint::authenticateEndpoint got creds from app = %d",
@@ -304,7 +314,8 @@ void TcrEndpoint::authenticateEndpoint(TcrConnection*& conn) {
LOGDEBUG("TcrEndpoint::authenticateEndpoint no creds from app ");
}
- TcrMessageUserCredential request(creds, this->m_baseDM);
+ TcrMessageUserCredential request(
+ m_cacheImpl->getCache()->createDataOutput(), creds, m_baseDM);
LOGDEBUG("request is created");
TcrMessageReply reply(true, this->m_baseDM);
@@ -339,27 +350,17 @@ void TcrEndpoint::authenticateEndpoint(TcrConnection*& conn) {
}
PropertiesPtr TcrEndpoint::getCredentials() {
- PropertiesPtr tmpSecurityProperties =
- DistributedSystem::getSystemProperties()->getSecurityProperties();
+ const auto& distributedSystem = m_cacheImpl->getDistributedSystem();
+ const auto& tmpSecurityProperties =
+ distributedSystem.getSystemProperties().getSecurityProperties();
- AuthInitializePtr authInitialize = DistributedSystem::m_impl->getAuthLoader();
-
- if (authInitialize != nullptr) {
+ if (const auto& authInitialize = distributedSystem.m_impl->getAuthLoader()) {
LOGFINER(
"Acquired handle to AuthInitialize plugin, "
"getting credentials for %s",
m_name.c_str());
- /* adongre
- * CID 28899: Copy into fixed size buffer (STRING_OVERFLOW)
- * You might overrun the 100 byte fixed-size string "tmpEndpoint" by copying
- * the return value of
- * "stlp_std::basic_string<char, stlp_std::char_traits<char>,
- * stlp_std::allocator<char> >::c_str() const" without checking the length.
- */
- // char tmpEndpoint[100] = { '\0' } ;
- // strcpy(tmpEndpoint, m_name.c_str());
- PropertiesPtr tmpAuthIniSecurityProperties = authInitialize->getCredentials(
- tmpSecurityProperties, /*tmpEndpoint*/ m_name.c_str());
+ const auto& tmpAuthIniSecurityProperties =
+ authInitialize->getCredentials(tmpSecurityProperties, m_name.c_str());
LOGFINER("Done getting credentials");
return tmpAuthIniSecurityProperties;
}
@@ -372,9 +373,10 @@ ServerQueueStatus TcrEndpoint::getFreshServerQueueStatus(
TcrConnection* newConn;
ServerQueueStatus status = NON_REDUNDANT_SERVER;
- err = createNewConnection(
- newConn, false, false,
- DistributedSystem::getSystemProperties()->connectTimeout());
+ err = createNewConnection(newConn, false, false,
+ m_cacheImpl->getDistributedSystem()
+ .getSystemProperties()
+ .connectTimeout());
if (err == GF_NOERR) {
status = newConn->getServerQueueStatus(queueSize);
@@ -438,10 +440,11 @@ GfErrType TcrEndpoint::registerDM(bool clientNotification, bool isSecondary,
m_name.c_str());
for (int connNum = 0; connNum < maxConnections; ++connNum) {
TcrConnection* newConn;
- if ((err = createNewConnection(
- newConn, false, false,
- DistributedSystem::getSystemProperties()->connectTimeout(), 0,
- m_connected)) != GF_NOERR) {
+ if ((err = createNewConnection(newConn, false, false,
+ m_cacheImpl->getDistributedSystem()
+ .getSystemProperties()
+ .connectTimeout(),
+ 0, m_connected)) != GF_NOERR) {
m_connected = false;
m_isActiveEndpoint = false;
closeConnections();
@@ -471,10 +474,12 @@ GfErrType TcrEndpoint::registerDM(bool clientNotification, bool isSecondary,
// setup notification channel for the first region
ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_notifyReceiverLock);
if (m_numRegionListener == 0) {
- if ((err = createNewConnection(
- m_notifyConnection, true, isSecondary,
- DistributedSystem::getSystemProperties()->connectTimeout() * 3,
- 0)) != GF_NOERR) {
+ if ((err = createNewConnection(m_notifyConnection, true, isSecondary,
+ m_cacheImpl->getDistributedSystem()
+ .getSystemProperties()
+ .connectTimeout() *
+ 3,
+ 0)) != GF_NOERR) {
m_connected = false;
m_isActiveEndpoint = false;
closeConnections();
@@ -545,7 +550,8 @@ void TcrEndpoint::pingServer(ThinClientPoolDM* poolDM) {
}
if (!m_msgSent && !m_pingSent) {
- TcrMessagePing* pingMsg = TcrMessage::getPingMessage();
+ TcrMessagePing* pingMsg =
+ TcrMessage::getPingMessage(m_cacheImpl->getCache());
TcrMessageReply reply(true, nullptr);
LOGFINEST("Sending ping message to endpoint %s", m_name.c_str());
GfErrType error;
@@ -584,19 +590,17 @@ void TcrEndpoint::pingServer(ThinClientPoolDM* poolDM) {
}
bool TcrEndpoint::checkDupAndAdd(EventIdPtr eventid) {
- return m_cache->tcrConnectionManager().checkDupAndAdd(eventid);
+ return m_cacheImpl->tcrConnectionManager().checkDupAndAdd(eventid);
}
int TcrEndpoint::receiveNotification(volatile bool& isRunning) {
- char* data = 0;
-
LOGFINE("Started subscription channel for endpoint %s", m_name.c_str());
while (isRunning) {
TcrMessageReply* msg = nullptr;
try {
size_t dataLen;
ConnErrType opErr = CONN_NOERR;
- data = m_notifyConnection->receive(&dataLen, &opErr, 5);
+ auto data = m_notifyConnection->receive(&dataLen, &opErr, 5);
if (opErr == CONN_IOERR) {
// Endpoint is disconnected, this exception is expected
@@ -616,11 +620,12 @@ int TcrEndpoint::receiveNotification(volatile bool& isRunning) {
}
if (data) {
- msg = new TcrMessageReply(true, nullptr);
+ msg = new TcrMessageReply(true, m_baseDM);
msg->initCqMap();
msg->setData(data, static_cast<int32_t>(dataLen),
- this->getDistributedMemberID());
- data = nullptr; // memory is released by TcrMessage setData().
+ this->getDistributedMemberID(),
+ *(m_cacheImpl->getSerializationRegistry()),
+ *(m_cacheImpl->getMemberListForVersionStamp()));
handleNotificationStats(static_cast<int64_t>(dataLen));
LOGDEBUG("receive notification %d", msg->getMessageType());
@@ -644,7 +649,7 @@ int TcrEndpoint::receiveNotification(volatile bool& isRunning) {
if (msg->getMessageType() != TcrMessage::CLIENT_MARKER) {
const std::string& regionFullPath1 = msg->getRegionName();
RegionPtr region1;
- m_cache->getRegion(regionFullPath1.c_str(), region1);
+ m_cacheImpl->getRegion(regionFullPath1.c_str(), region1);
if (region1 != nullptr &&
!static_cast<ThinClientRegion*>(region1.get())
->getDistMgr()
@@ -670,7 +675,7 @@ int TcrEndpoint::receiveNotification(volatile bool& isRunning) {
if (isMarker) {
LOGFINE("Got a marker message on endpont %s", m_name.c_str());
- m_cache->processMarker();
+ m_cacheImpl->processMarker();
processMarker();
GF_SAFE_DELETE(msg);
} else {
@@ -678,14 +683,14 @@ int TcrEndpoint::receiveNotification(volatile bool& isRunning) {
{
const std::string& regionFullPath = msg->getRegionName();
RegionPtr region;
- m_cache->getRegion(regionFullPath.c_str(), region);
+ m_cacheImpl->getRegion(regionFullPath.c_str(), region);
if (region != nullptr) {
static_cast<ThinClientRegion*>(region.get())
->receiveNotification(msg);
} else {
LOGWARN(
"Notification for region %s that does not exist in "
- "client cache.",
+ "client cacheImpl.",
regionFullPath.c_str());
}
} else {
@@ -842,13 +847,16 @@ GfErrType TcrEndpoint::sendRequestConn(const TcrMessage& request,
}
size_t dataLen;
LOGDEBUG("sendRequestConn: calling sendRequest");
- char* data = conn->sendRequest(
- request.getMsgData(), request.getMsgLength(), &dataLen,
- request.getTimeout(), reply.getTimeout(), request.getMessageType());
+ auto data = conn->sendRequest(request.getMsgData(), request.getMsgLength(),
+ &dataLen, request.getTimeout(),
+ reply.getTimeout(), request.getMessageType());
reply.setMessageTypeRequest(type);
- reply.setData(data, static_cast<int32_t>(dataLen),
- this->getDistributedMemberID()); // memory is released by
- // TcrMessage setData().
+ reply.setData(
+ data, static_cast<int32_t>(dataLen), this->getDistributedMemberID(),
+ *(m_cacheImpl->getSerializationRegistry()),
+ *(m_cacheImpl
+ ->getMemberListForVersionStamp())); // memory is released by
+ // TcrMessage setData().
}
// reset idle timeout of the connection for pool connection manager
@@ -923,10 +931,11 @@ GfErrType TcrEndpoint::sendRequestWithRetry(
LOGFINE(
"Creating a new connection when connection-pool-size system "
"property set to 0");
- if ((error =
- createNewConnection(conn, false, false,
- DistributedSystem::getSystemProperties()
- ->connectTimeout())) != GF_NOERR) {
+ if ((error = createNewConnection(conn, false, false,
+ m_cacheImpl->getDistributedSystem()
+ .getSystemProperties()
+ .connectTimeout())) !=
+ GF_NOERR) {
epFailure = true;
continue;
}
@@ -940,11 +949,12 @@ GfErrType TcrEndpoint::sendRequestWithRetry(
createNewConn = false;
if (!m_connected) {
return GF_NOTCON;
- } else if ((error = createNewConnection(
- conn, false, false,
- DistributedSystem::getSystemProperties()
- ->connectTimeout(),
- 0, true)) != GF_NOERR) {
+ } else if ((error =
+ createNewConnection(conn, false, false,
+ m_cacheImpl->getDistributedSystem()
+ .getSystemProperties()
+ .connectTimeout(),
+ 0, true)) != GF_NOERR) {
epFailure = true;
continue;
}
@@ -1227,8 +1237,9 @@ void TcrEndpoint::closeConnection(TcrConnection*& conn) {
void TcrEndpoint::closeConnections() {
m_opConnections.close();
m_ports.clear();
- m_maxConnections =
- DistributedSystem::getSystemProperties()->javaConnectionPoolSize();
+ m_maxConnections = m_cacheImpl->getDistributedSystem()
+ .getSystemProperties()
+ .javaConnectionPoolSize();
}
/*
@@ -1245,7 +1256,7 @@ void TcrEndpoint::closeNotification() {
LOGFINEST("Closing subscription channel for endpoint %s", m_name.c_str());
m_notifyConnection->close();
m_notifyReceiver->stopNoblock();
- TcrConnectionManager& tccm = m_cache->tcrConnectionManager();
+ TcrConnectionManager& tccm = m_cacheImpl->tcrConnectionManager();
tccm.addNotificationForDeletion(m_notifyReceiver, m_notifyConnection,
m_notificationCleanupSema);
m_notifyCount++;
@@ -1328,11 +1339,11 @@ void TcrEndpoint::setServerQueueStatus(ServerQueueStatus queueStatus,
bool TcrEndpoint::isQueueHosted() { return m_isQueueHosted; }
void TcrEndpoint::processMarker() {
- m_cache->tcrConnectionManager().processMarker();
+ m_cacheImpl->tcrConnectionManager().processMarker();
}
QueryServicePtr TcrEndpoint::getQueryService() {
- return m_cache->getQueryService(true);
+ return m_cacheImpl->getQueryService(true);
}
void TcrEndpoint::sendRequestForChunkedResponse(const TcrMessage& request,
TcrMessageReply& reply,
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/TcrEndpoint.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TcrEndpoint.hpp b/src/cppcache/src/TcrEndpoint.hpp
index 117535b..e259d40 100644
--- a/src/cppcache/src/TcrEndpoint.hpp
+++ b/src/cppcache/src/TcrEndpoint.hpp
@@ -44,9 +44,9 @@ class ThinClientPoolDM;
class CPPCACHE_EXPORT TcrEndpoint {
public:
TcrEndpoint(
- const std::string& name, CacheImpl* cache, ACE_Semaphore& failoverSema,
- ACE_Semaphore& cleanupSema, ACE_Semaphore& redundancySema,
- ThinClientBaseDM* dm = nullptr,
+ const std::string& name, CacheImpl* cacheImpl,
+ ACE_Semaphore& failoverSema, ACE_Semaphore& cleanupSema,
+ ACE_Semaphore& redundancySema, ThinClientBaseDM* dm = nullptr,
bool isMultiUserMode = false); // TODO: need to look for endpoint case
/* adongre
@@ -206,6 +206,7 @@ class CPPCACHE_EXPORT TcrEndpoint {
ACE_Recursive_Thread_Mutex m_notifyReceiverLock;
virtual bool handleIOException(const std::string& message,
TcrConnection*& conn, bool isBgThread = false);
+ CacheImpl* m_cacheImpl;
private:
int64_t m_uniqueId;
@@ -232,7 +233,6 @@ class CPPCACHE_EXPORT TcrEndpoint {
int m_notifyCount;
- CacheImpl* m_cache;
ACE_Semaphore& m_failoverSema;
ACE_Semaphore& m_cleanupSema;
ACE_Semaphore m_notificationCleanupSema;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/TcrMessage.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TcrMessage.cpp b/src/cppcache/src/TcrMessage.cpp
index cfba9c7..10f4986 100644
--- a/src/cppcache/src/TcrMessage.cpp
+++ b/src/cppcache/src/TcrMessage.cpp
@@ -32,6 +32,7 @@
#include "TXState.hpp"
#include "DiskStoreId.hpp"
#include "DiskVersionTag.hpp"
+#include "CacheRegionHelper.hpp"
using namespace apache::geode::client;
static const uint32_t REGULAR_EXPRESSION =
@@ -42,49 +43,28 @@ uint32_t g_headerLen = 17;
} // namespace
// AtomicInc TcrMessage::m_transactionId = 0;
-TcrMessagePing* TcrMessage::m_pingMsg = nullptr;
-TcrMessage* TcrMessage::m_closeConnMsg = nullptr;
-TcrMessage* TcrMessage::m_allEPDisconnected = nullptr;
uint8_t* TcrMessage::m_keepalive = nullptr;
const int TcrMessage::m_flag_empty = 0x01;
const int TcrMessage::m_flag_concurrency_checks = 0x02;
-bool TcrMessage::init() {
- bool ret = true;
- if (m_pingMsg == nullptr) {
- try {
- m_pingMsg = new TcrMessagePing(true);
- m_closeConnMsg = new TcrMessageCloseConnection(true);
-
- } catch (std::exception& ex) {
- ret = false;
- LOGERROR(ex.what());
- } catch (Exception& ex) {
- ret = false;
- LOGERROR(ex.getMessage());
- } catch (...) {
- ret = false;
- LOGERROR("unknown exception");
- }
- }
- if (m_allEPDisconnected == nullptr) {
- m_allEPDisconnected = new TcrMessageReply(true, nullptr);
- }
- return ret;
+TcrMessagePing* TcrMessage::getPingMessage(Cache* cache) {
+ static auto pingMsg = new TcrMessagePing(cache->createDataOutput(), true);
+ return pingMsg;
}
-void TcrMessage::cleanup() {
- GF_SAFE_DELETE(m_pingMsg);
- GF_SAFE_DELETE(m_closeConnMsg);
+TcrMessage* TcrMessage::getAllEPDisMess() {
+ static auto allEPDisconnected = new TcrMessageReply(true, nullptr);
+ return allEPDisconnected;
}
-/* we need a static method to generate ping */
-TcrMessagePing* TcrMessage::getPingMessage() { return m_pingMsg; }
-
-TcrMessage* TcrMessage::getAllEPDisMess() { return m_allEPDisconnected; }
-TcrMessage* TcrMessage::getCloseConnMessage() { return m_closeConnMsg; }
+TcrMessage* TcrMessage::getCloseConnMessage(Cache* cache) {
+ static auto closeConnMsg =
+ new TcrMessageCloseConnection(cache->createDataOutput(), true);
+ return closeConnMsg;
+}
void TcrMessage::setKeepAlive(bool keepalive) {
+ // TODO global
if (TcrMessage::m_keepalive != nullptr) {
*TcrMessage::m_keepalive = keepalive ? 1 : 0;
}
@@ -170,8 +150,9 @@ void TcrMessage::readPrMetaData(DataInput& input) {
}
}
-VersionTagPtr TcrMessage::readVersionTagPart(DataInput& input,
- uint16_t endpointMemId) {
+VersionTagPtr TcrMessage::readVersionTagPart(
+ DataInput& input, uint16_t endpointMemId,
+ MemberListForVersionStamp& memberListForVersionStamp) {
int8_t isObj;
input.read(&isObj);
VersionTagPtr versionTag;
@@ -179,7 +160,7 @@ VersionTagPtr TcrMessage::readVersionTagPart(DataInput& input,
if (isObj == GeodeTypeIds::NullObj) return versionTag;
if (isObj == GeodeTypeIdsImpl::FixedIDByte) {
- versionTag = std::make_shared<VersionTag>();
+ versionTag = std::make_shared<VersionTag>(memberListForVersionStamp);
int8_t fixedId;
input.read(&fixedId);
if (fixedId == GeodeTypeIdsImpl::VersionTag) {
@@ -191,7 +172,7 @@ VersionTagPtr TcrMessage::readVersionTagPart(DataInput& input,
int16_t fixedId;
input.readInt(&fixedId);
if (fixedId == GeodeTypeIdsImpl::DiskVersionTag) {
- DiskVersionTag* disk = new DiskVersionTag();
+ DiskVersionTag* disk = new DiskVersionTag(memberListForVersionStamp);
disk->fromData(input);
versionTag.reset(disk);
return versionTag;
@@ -200,14 +181,17 @@ VersionTagPtr TcrMessage::readVersionTagPart(DataInput& input,
return versionTag;
}
-void TcrMessage::readVersionTag(DataInput& input, uint16_t endpointMemId) {
+void TcrMessage::readVersionTag(
+ DataInput& input, uint16_t endpointMemId,
+ MemberListForVersionStamp& memberListForVersionStamp) {
int32_t lenObj;
int8_t isObj;
input.readInt(&lenObj);
input.read(&isObj);
if (lenObj == 0) return;
- auto versionTag = TcrMessage::readVersionTagPart(input, endpointMemId);
+ auto versionTag = TcrMessage::readVersionTagPart(input, endpointMemId,
+ memberListForVersionStamp);
this->setVersionTag(versionTag);
}
@@ -386,9 +370,10 @@ void TcrMessage::readUniqueIDObjectPart(DataInput& input) {
int64_t TcrMessage::getConnectionId(TcrConnection* conn) {
if (m_connectionIDBytes != nullptr) {
CacheableBytesPtr tmp = conn->decryptBytes(m_connectionIDBytes);
- DataInput di(tmp->value(), tmp->length());
+ auto di = m_tcdm->getConnectionManager().getCacheImpl()->getCache()->createDataInput(
+ tmp->value(), tmp->length());
int64_t connid;
- di.readInt(&connid);
+ di->readInt(&connid);
return connid;
} else {
LOGWARN("Returning 0 as internal connection ID msgtype = %d ", m_msgType);
@@ -402,9 +387,10 @@ int64_t TcrMessage::getUniqueId(TcrConnection* conn) {
CacheableBytesPtr tmp = conn->decryptBytes(encryptBytes);
- DataInput di(tmp->value(), tmp->length());
+ auto di = m_tcdm->getConnectionManager().getCacheImpl()->getCache()->createDataInput(
+ tmp->value(), tmp->length());
int64_t uniqueid;
- di.readInt(&uniqueid);
+ di->readInt(&uniqueid);
return uniqueid;
}
@@ -859,7 +845,8 @@ void TcrMessage::processChunk(const uint8_t* bytes, int32_t len,
} else if (m_msgTypeRequest == TcrMessage::PUTALL ||
m_msgTypeRequest == TcrMessage::PUT_ALL_WITH_CALLBACK) {
TcrChunkedContext* chunk = new TcrChunkedContext(
- bytes, len, m_chunkedResult, isLastChunkAndisSecurityHeader);
+ bytes, len, m_chunkedResult, isLastChunkAndisSecurityHeader,
+ m_tcdm->getConnectionManager().getCacheImpl()->getCache());
m_chunkedResult->setEndpointMemId(endpointmemId);
m_tcdm->queueChunk(chunk);
if (bytes == nullptr) {
@@ -882,7 +869,8 @@ void TcrMessage::processChunk(const uint8_t* bytes, int32_t len,
if (m_chunkedResult != nullptr) {
LOGDEBUG("tcrmessage in case22 ");
TcrChunkedContext* chunk = new TcrChunkedContext(
- bytes, len, m_chunkedResult, isLastChunkAndisSecurityHeader);
+ bytes, len, m_chunkedResult, isLastChunkAndisSecurityHeader,
+ m_tcdm->getConnectionManager().getCacheImpl()->getCache());
m_chunkedResult->setEndpointMemId(endpointmemId);
m_tcdm->queueChunk(chunk);
if (bytes == nullptr) {
@@ -930,9 +918,10 @@ void TcrMessage::processChunk(const uint8_t* bytes, int32_t len,
case TcrMessage::EXCEPTION: {
if (bytes != nullptr) {
DeleteArray<const uint8_t> delChunk(bytes);
- DataInput input(bytes, len);
- readExceptionPart(input, isLastChunkAndisSecurityHeader);
- readSecureObjectPart(input, false, true,
+ auto input = m_tcdm->getConnectionManager().getCacheImpl()->getCache()->createDataInput(
+ bytes, len);
+ readExceptionPart(*input, isLastChunkAndisSecurityHeader);
+ readSecureObjectPart(*input, false, true,
isLastChunkAndisSecurityHeader);
}
break;
@@ -995,27 +984,31 @@ void TcrMessage::chunkSecurityHeader(int skipPart, const uint8_t* bytes,
uint8_t isLastChunkAndSecurityHeader) {
LOGDEBUG("TcrMessage::chunkSecurityHeader:: skipParts = %d", skipPart);
if ((isLastChunkAndSecurityHeader & 0x3) == 0x3) {
- DataInput di(bytes, len);
- skipParts(di, skipPart);
- readSecureObjectPart(di, false, true, isLastChunkAndSecurityHeader);
+ auto di = m_tcdm->getConnectionManager().getCacheImpl()->getCache()->createDataInput(
+ bytes, len);
+ skipParts(*di, skipPart);
+ readSecureObjectPart(*di, false, true, isLastChunkAndSecurityHeader);
}
}
-void TcrMessage::handleByteArrayResponse(const char* bytearray, int32_t len,
- uint16_t endpointMemId) {
- DataInput input((uint8_t*)bytearray, len);
+void TcrMessage::handleByteArrayResponse(
+ const char* bytearray, int32_t len, uint16_t endpointMemId,
+ const SerializationRegistry& serializationRegistry,
+ MemberListForVersionStamp& memberListForVersionStamp) {
+ auto input = m_tcdm->getConnectionManager().getCacheImpl()->getCache()->createDataInput(
+ (uint8_t*)bytearray, len);
// TODO:: this need to make sure that pool is there
// if(m_tcdm == nullptr)
// throw IllegalArgumentException("Pool is nullptr in TcrMessage");
- input.setPoolName(getPoolName());
- input.readInt(&m_msgType);
+ input->setPoolName(getPoolName());
+ input->readInt(&m_msgType);
int32_t msglen;
- input.readInt(&msglen);
+ input->readInt(&msglen);
int32_t numparts;
- input.readInt(&numparts);
- input.readInt(&m_txId);
+ input->readInt(&numparts);
+ input->readInt(&m_txId);
int8_t earlyack;
- input.read(&earlyack);
+ input->read(&earlyack);
LOGDEBUG(
"handleByteArrayResponse m_msgType = %d isSecurityOn = %d requesttype "
"=%d",
@@ -1032,46 +1025,46 @@ void TcrMessage::handleByteArrayResponse(const char* bytearray, int32_t len,
switch (m_msgType) {
case TcrMessage::RESPONSE: {
if (m_msgTypeRequest == TcrMessage::CONTAINS_KEY) {
- readBooleanPartAsObject(input, &m_boolValue);
+ readBooleanPartAsObject(*input, &m_boolValue);
} else if (m_msgTypeRequest == TcrMessage::USER_CREDENTIAL_MESSAGE) {
- readUniqueIDObjectPart(input);
+ readUniqueIDObjectPart(*input);
} else if (m_msgTypeRequest == TcrMessage::GET_PDX_ID_FOR_TYPE ||
m_msgTypeRequest == TcrMessage::GET_PDX_ID_FOR_ENUM) {
// int will come in response
uint32_t typeId;
- readIntPart(input, &typeId);
+ readIntPart(*input, &typeId);
m_value = CacheableInt32::create(typeId);
} else if (m_msgTypeRequest == TcrMessage::GET_PDX_TYPE_BY_ID) {
// PdxType will come in response
- input.advanceCursor(5); // part header
+ input->advanceCursor(5); // part header
m_value =
- SerializationRegistry::deserialize(input, GeodeTypeIds::PdxType);
+ serializationRegistry.deserialize(*input, GeodeTypeIds::PdxType);
} else if (m_msgTypeRequest == TcrMessage::GET_PDX_ENUM_BY_ID) {
// PdxType will come in response
- input.advanceCursor(5); // part header
- m_value = SerializationRegistry::deserialize(input);
+ input->advanceCursor(5); // part header
+ m_value = serializationRegistry.deserialize(*input);
} else if (m_msgTypeRequest == TcrMessage::GET_FUNCTION_ATTRIBUTES) {
int32_t lenObj;
- input.readInt(&lenObj);
+ input->readInt(&lenObj);
int8_t isObj;
- input.read(&isObj);
+ input->read(&isObj);
int8_t hR;
- input.read(&hR);
+ input->read(&hR);
int8_t isHA;
- input.read(&isHA);
+ input->read(&isHA);
int8_t oFW;
- input.read(&oFW);
+ input->read(&oFW);
m_functionAttributes = new std::vector<int8_t>();
m_functionAttributes->push_back(hR);
m_functionAttributes->push_back(isHA);
m_functionAttributes->push_back(oFW);
} else if (m_msgTypeRequest == TcrMessage::REQUEST) {
int32_t receivednumparts = 2;
- readObjectPart(input);
+ readObjectPart(*input);
uint32_t flag = 0;
- readIntPart(input, &flag);
+ readIntPart(*input, &flag);
if (flag & 0x01) {
- readCallbackObjectPart(input);
+ readCallbackObjectPart(*input);
receivednumparts++;
}
@@ -1080,7 +1073,7 @@ void TcrMessage::handleByteArrayResponse(const char* bytearray, int32_t len,
}
if (flag & 0x02) {
- readVersionTag(input, endpointMemId);
+ readVersionTag(*input, endpointMemId, memberListForVersionStamp);
receivednumparts++;
}
@@ -1088,37 +1081,37 @@ void TcrMessage::handleByteArrayResponse(const char* bytearray, int32_t len,
m_value = CacheableToken::tombstone();
}
- if (numparts > receivednumparts) readPrMetaData(input);
+ if (numparts > receivednumparts) readPrMetaData(*input);
} else if (m_decodeAll) {
- readObjectPart(input);
+ readObjectPart(*input);
if (numparts == 2) {
if (m_isCallBackArguement) {
- readCallbackObjectPart(input);
+ readCallbackObjectPart(*input);
} else {
int32_t lenObj;
- input.readInt(&lenObj);
+ input->readInt(&lenObj);
bool isObj;
- input.readBoolean(&isObj);
- input.read(&m_metaDataVersion);
+ input->readBoolean(&isObj);
+ input->read(&m_metaDataVersion);
if (lenObj == 2) {
- input.read(&m_serverGroupVersion);
+ input->read(&m_serverGroupVersion);
LOGDEBUG(
"Single-hop m_serverGroupVersion in message response is %d",
m_serverGroupVersion);
}
}
} else if (numparts > 2) {
- skipParts(input, 1);
+ skipParts(*input, 1);
int32_t lenObj;
- input.readInt(&lenObj);
+ input->readInt(&lenObj);
bool isObj;
- input.readBoolean(&isObj);
- input.read(&m_metaDataVersion);
+ input->readBoolean(&isObj);
+ input->read(&m_metaDataVersion);
LOGFINE("Single-hop metadata version in message response is %d",
m_metaDataVersion);
if (lenObj == 2) {
- input.read(&m_serverGroupVersion);
+ input->read(&m_serverGroupVersion);
LOGDEBUG(
"Single-hop m_serverGroupVersion in message response is %d",
m_serverGroupVersion);
@@ -1131,16 +1124,16 @@ void TcrMessage::handleByteArrayResponse(const char* bytearray, int32_t len,
case TcrMessage::EXCEPTION: {
uint8_t lastChunk = static_cast<uint8_t>(numparts);
lastChunk = (lastChunk << 5);
- readExceptionPart(input, lastChunk);
+ readExceptionPart(*input, lastChunk);
// if (isSecurityOn)
- // readSecureObjectPart( input );
+ // readSecureObjectPart( *input );
break;
}
case TcrMessage::INVALID: {
// Read the string in the reply
LOGWARN("Received invalid message type as reply from server");
- readObjectPart(input, true);
+ readObjectPart(*input, true);
break;
}
@@ -1170,41 +1163,43 @@ void TcrMessage::handleByteArrayResponse(const char* bytearray, int32_t len,
case TcrMessage::REPLY: {
switch (m_msgTypeRequest) {
case TcrMessage::PUT: {
- readPrMetaData(input);
+ readPrMetaData(*input);
uint32_t flags = 0;
- readIntPart(input, &flags);
+ readIntPart(*input, &flags);
if (flags & 0x01) { // has old value
- readOldValue(input);
+ readOldValue(*input);
}
if (flags & 0x04) {
- readVersionTag(input, endpointMemId);
+ readVersionTag(*input, endpointMemId, memberListForVersionStamp);
}
break;
}
case TcrMessage::INVALIDATE: {
uint32_t flags = 0;
- readIntPart(input, &flags);
- if (flags & 0x01) readVersionTag(input, endpointMemId);
- readPrMetaData(input);
+ readIntPart(*input, &flags);
+ if (flags & 0x01)
+ readVersionTag(*input, endpointMemId, memberListForVersionStamp);
+ readPrMetaData(*input);
break;
}
case TcrMessage::DESTROY: {
uint32_t flags = 0;
- readIntPart(input, &flags);
- if (flags & 0x01) readVersionTag(input, endpointMemId);
- readPrMetaData(input);
+ readIntPart(*input, &flags);
+ if (flags & 0x01)
+ readVersionTag(*input, endpointMemId, memberListForVersionStamp);
+ readPrMetaData(*input);
// skip the Destroy65.java response entryNotFound int part so
// that the readSecureObjectPart() call below gets the security part
- // skipParts(input, 1);
- readIntPart(input, &m_entryNotFound);
+ // skipParts(*input, 1);
+ readIntPart(*input, &m_entryNotFound);
LOGDEBUG("Inside TcrMessage::REPLY::DESTROY m_entryNotFound = %d ",
m_entryNotFound);
break;
}
case TcrMessage::PING:
default: {
- readPrMetaData(input);
+ readPrMetaData(*input);
break;
}
}
@@ -1213,36 +1208,36 @@ void TcrMessage::handleByteArrayResponse(const char* bytearray, int32_t len,
case TcrMessage::LOCAL_INVALIDATE:
case TcrMessage::LOCAL_DESTROY: {
int32_t regionLen;
- input.readInt(®ionLen);
+ input->readInt(®ionLen);
int8_t isObj;
- input.read(&isObj);
+ input->read(&isObj);
char* regname = nullptr;
regname = new char[regionLen + 1];
DeleteArray<char> delRegName(regname);
- input.readBytesOnly(reinterpret_cast<int8_t*>(regname), regionLen);
+ input->readBytesOnly(reinterpret_cast<int8_t*>(regname), regionLen);
regname[regionLen] = '\0';
m_regionName = regname;
- readKeyPart(input);
+ readKeyPart(*input);
- // skipParts(input, 1); // skip callbackarg parts
- readCallbackObjectPart(input);
- readVersionTag(input, endpointMemId);
- readBooleanPartAsObject(input, &m_isInterestListPassed);
- readBooleanPartAsObject(input, &m_hasCqsPart);
+ // skipParts(*input, 1); // skip callbackarg parts
+ readCallbackObjectPart(*input);
+ readVersionTag(*input, endpointMemId, memberListForVersionStamp);
+ readBooleanPartAsObject(*input, &m_isInterestListPassed);
+ readBooleanPartAsObject(*input, &m_hasCqsPart);
if (m_hasCqsPart) {
if (m_msgType == TcrMessage::LOCAL_INVALIDATE) {
- readIntPart(input, &m_msgTypeForCq);
+ readIntPart(*input, &m_msgTypeForCq);
} else {
m_msgTypeForCq = static_cast<uint32_t>(m_msgType);
}
// LOGINFO("got cq local local_invalidate/local_destroy read
// m_hasCqsPart");
- readCqsPart(input);
+ readCqsPart(*input);
}
// read eventid part
- readEventIdPart(input, false);
+ readEventIdPart(*input, false);
break;
}
@@ -1250,79 +1245,80 @@ void TcrMessage::handleByteArrayResponse(const char* bytearray, int32_t len,
case TcrMessage::LOCAL_CREATE:
case TcrMessage::LOCAL_UPDATE: {
int32_t regionLen;
- input.readInt(®ionLen);
+ input->readInt(®ionLen);
int8_t isObj;
- input.read(&isObj);
+ input->read(&isObj);
char* regname = nullptr;
regname = new char[regionLen + 1];
DeleteArray<char> delRegName(regname);
- input.readBytesOnly(reinterpret_cast<int8_t*>(regname), regionLen);
+ input->readBytesOnly(reinterpret_cast<int8_t*>(regname), regionLen);
regname[regionLen] = '\0';
m_regionName = regname;
- readKeyPart(input);
+ readKeyPart(*input);
// Read delta flag
bool isDelta = false;
- readBooleanPartAsObject(input, &isDelta);
+ readBooleanPartAsObject(*input, &isDelta);
if (isDelta) {
- input.readInt(&m_deltaBytesLen);
+ input->readInt(&m_deltaBytesLen);
int8_t isObj;
- input.read(&isObj);
+ input->read(&isObj);
m_deltaBytes = new uint8_t[m_deltaBytesLen];
- input.readBytesOnly(m_deltaBytes, m_deltaBytesLen);
- m_delta = new DataInput(m_deltaBytes, m_deltaBytesLen);
+ input->readBytesOnly(m_deltaBytes, m_deltaBytesLen);
+ m_delta = m_tcdm->getConnectionManager().getCacheImpl()->getCache()->createDataInput(
+ m_deltaBytes, m_deltaBytesLen);
} else {
- readObjectPart(input);
+ readObjectPart(*input);
}
// skip callbackarg part
- // skipParts(input, 1);
- readCallbackObjectPart(input);
- readVersionTag(input, endpointMemId);
- readBooleanPartAsObject(input, &m_isInterestListPassed);
- readBooleanPartAsObject(input, &m_hasCqsPart);
+ // skipParts(*input, 1);
+ readCallbackObjectPart(*input);
+ readVersionTag(*input, endpointMemId, memberListForVersionStamp);
+ readBooleanPartAsObject(*input, &m_isInterestListPassed);
+ readBooleanPartAsObject(*input, &m_hasCqsPart);
if (m_hasCqsPart) {
// LOGINFO("got cq local_create/local_create");
- readCqsPart(input);
+ readCqsPart(*input);
m_msgTypeForCq = static_cast<uint32_t>(m_msgType);
}
// read eventid part
- readEventIdPart(input, false);
+ readEventIdPart(*input, false);
GF_SAFE_DELETE_ARRAY(regname); // COVERITY ---> 30299 Resource leak
break;
}
case TcrMessage::CLIENT_MARKER: {
// dont skip (non-existent) callbackarg part, just read eventid part
- readEventIdPart(input, false);
+ readEventIdPart(*input, false);
break;
}
case TcrMessage::LOCAL_DESTROY_REGION:
case TcrMessage::CLEAR_REGION: {
int32_t regionLen;
- input.readInt(®ionLen);
+ input->readInt(®ionLen);
int8_t isObj;
- input.read(&isObj);
+ input->read(&isObj);
char* regname = nullptr;
regname = new char[regionLen + 1];
DeleteArray<char> delRegName(regname);
- input.readBytesOnly(reinterpret_cast<int8_t*>(regname), regionLen);
+ input->readBytesOnly(reinterpret_cast<int8_t*>(regname), regionLen);
regname[regionLen] = '\0';
m_regionName = regname;
// skip callbackarg part
- // skipParts(input, 1);
- readCallbackObjectPart(input);
- readBooleanPartAsObject(input, &m_hasCqsPart);
+ // skipParts(*input, 1);
+ readCallbackObjectPart(*input);
+ readBooleanPartAsObject(*input, &m_hasCqsPart);
if (m_hasCqsPart) {
// LOGINFO("got cq region_destroy read m_hasCqsPart");
- readCqsPart(input);
+ readCqsPart(*input);
}
// read eventid part
- readEventIdPart(input, false);
+ readEventIdPart(*input, false);
break;
}
@@ -1334,27 +1330,27 @@ void TcrMessage::handleByteArrayResponse(const char* bytearray, int32_t len,
m_metadata = new std::vector<std::vector<BucketServerLocationPtr> >();
for (int32_t i = 0; i < numparts; i++) {
int32_t bits32;
- input.readInt(&bits32); // partlen;
+ input->readInt(&bits32); // partlen;
int8_t bits8;
- input.read(&bits8); // isObj;
- input.read(&bits8); // cacheable vector typeid
+ input->read(&bits8); // isObj;
+ input->read(&bits8); // cacheable vector typeid
LOGDEBUG("Expected typeID %d, got %d", GeodeTypeIds::CacheableArrayList,
bits8);
- input.readArrayLen(&bits32); // array length
+ input->readArrayLen(&bits32); // array length
LOGDEBUG("Array length = %d ", bits32);
if (bits32 > 0) {
std::vector<BucketServerLocationPtr> bucketServerLocations;
for (int32_t index = 0; index < bits32; index++) {
int8_t header;
- input.read(&header); // ignore DS typeid
- input.read(&header); // ignore CLASS typeid
- input.read(&header); // ignore string typeid
+ input->read(&header); // ignore DS typeid
+ input->read(&header); // ignore CLASS typeid
+ input->read(&header); // ignore string typeid
uint16_t classLen;
- input.readInt(&classLen); // Read classLen
- input.advanceCursor(classLen);
+ input->readInt(&classLen); // Read classLen
+ input->advanceCursor(classLen);
auto location = std::make_shared<BucketServerLocation>();
- location->fromData(input);
+ location->fromData(*input);
LOGFINE("location contains %d\t%s\t%d\t%d\t%s",
location->getBucketId(), location->getServerName().c_str(),
location->getPort(), location->getVersion(),
@@ -1375,43 +1371,43 @@ void TcrMessage::handleByteArrayResponse(const char* bytearray, int32_t len,
case TcrMessage::RESPONSE_CLIENT_PARTITION_ATTRIBUTES: {
int32_t bits32;
- input.readInt(&bits32); // partlen;
+ input->readInt(&bits32); // partlen;
int8_t bits8;
- input.read(&bits8); // isObj;
+ input->read(&bits8); // isObj;
- m_bucketCount = input.readNativeInt32(); // PART1 = bucketCount
+ m_bucketCount = input->readNativeInt32(); // PART1 = bucketCount
- input.readInt(&bits32); // partlen;
- input.read(&bits8); // isObj;
+ input->readInt(&bits32); // partlen;
+ input->read(&bits8); // isObj;
if (bits32 > 0) {
- input.readNativeString(m_colocatedWith); // PART2 = colocatedwith
+ input->readNativeString(m_colocatedWith); // PART2 = colocatedwith
}
if (numparts == 4) {
- input.readInt(&bits32); // partlen;
- input.read(&bits8); // isObj;
+ input->readInt(&bits32); // partlen;
+ input->read(&bits8); // isObj;
if (bits32 > 0) {
- input.readNativeString(
+ input->readNativeString(
m_partitionResolverName); // PART3 = partitionresolvername
}
- input.readInt(&bits32); // partlen;
- input.read(&bits8); // isObj;
- input.read(&bits8); // cacheable CacheableHashSet typeid
+ input->readInt(&bits32); // partlen;
+ input->read(&bits8); // isObj;
+ input->read(&bits8); // cacheable CacheableHashSet typeid
- input.readArrayLen(&bits32); // array length
+ input->readArrayLen(&bits32); // array length
if (bits32 > 0) {
m_fpaSet = new std::vector<FixedPartitionAttributesImplPtr>();
for (int32_t index = 0; index < bits32; index++) {
int8_t header;
- input.read(&header); // ignore DS typeid
- input.read(&header); // ignore CLASS typeid
- input.read(&header); // ignore string typeid
+ input->read(&header); // ignore DS typeid
+ input->read(&header); // ignore CLASS typeid
+ input->read(&header); // ignore string typeid
uint16_t classLen;
- input.readInt(&classLen); // Read classLen
- input.advanceCursor(classLen);
+ input->readInt(&classLen); // Read classLen
+ input->advanceCursor(classLen);
auto fpa = std::make_shared<FixedPartitionAttributesImpl>();
- fpa->fromData(input); // PART4 = set of FixedAttributes.
+ fpa->fromData(*input); // PART4 = set of FixedAttributes.
LOGDEBUG("fpa contains %d\t%s\t%d\t%d", fpa->getNumBuckets(),
fpa->getPartitionName().c_str(), fpa->isPrimary(),
fpa->getStartingBucketID());
@@ -1424,38 +1420,38 @@ void TcrMessage::handleByteArrayResponse(const char* bytearray, int32_t len,
case TcrMessage::TOMBSTONE_OPERATION: {
uint32_t tombstoneOpType;
int32_t regionLen;
- input.readInt(®ionLen);
+ input->readInt(®ionLen);
int8_t isObj;
- input.read(&isObj);
+ input->read(&isObj);
char* regname = nullptr;
regname = new char[regionLen + 1];
DeleteArray<char> delRegName(regname);
- input.readBytesOnly(reinterpret_cast<int8_t*>(regname), regionLen);
+ input->readBytesOnly(reinterpret_cast<int8_t*>(regname), regionLen);
regname[regionLen] = '\0';
m_regionName = regname;
- readIntPart(input, &tombstoneOpType); // partlen;
+ readIntPart(*input, &tombstoneOpType); // partlen;
int32_t len;
- input.readInt(&len);
- input.read(&isObj);
+ input->readInt(&len);
+ input->read(&isObj);
if (tombstoneOpType == 0) {
if (m_tombstoneVersions == nullptr) {
m_tombstoneVersions = CacheableHashMap::create();
}
- readHashMapForGCVersions(input, m_tombstoneVersions);
+ readHashMapForGCVersions(*input, m_tombstoneVersions);
} else if (tombstoneOpType == 1) {
if (m_tombstoneKeys == nullptr) {
m_tombstoneKeys = CacheableHashSet::create();
}
- // input.readObject(m_tombstoneKeys);
- readHashSetForGCVersions(input, m_tombstoneKeys);
+ // input->readObject(m_tombstoneKeys);
+ readHashSetForGCVersions(*input, m_tombstoneKeys);
} else {
LOGERROR("Failed to read the tombstone versions");
break;
}
// readEventId Part
- readEventIdPart(input, false);
+ readEventIdPart(*input, false);
break;
}
case TcrMessage::GET_CLIENT_PARTITION_ATTRIBUTES_ERROR: {
@@ -1483,12 +1479,14 @@ void TcrMessage::handleByteArrayResponse(const char* bytearray, int32_t len,
throw MessageException("handleByteArrayResponse: unknown message type");
}
LOGDEBUG("handleByteArrayResponse earlyack = %d ", earlyack);
- if (earlyack & 0x2) readSecureObjectPart(input);
+ if (earlyack & 0x2) readSecureObjectPart(*input);
}
TcrMessageDestroyRegion::TcrMessageDestroyRegion(
- const Region* region, const UserDataPtr& aCallbackArgument,
- int messageResponsetimeout, ThinClientBaseDM* connectionDM) {
+ std::unique_ptr<DataOutput> dataOutput, const Region* region,
+ const UserDataPtr& aCallbackArgument, int messageResponsetimeout,
+ ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::DESTROY_REGION;
m_tcdm = connectionDM;
m_regionName =
@@ -1519,8 +1517,10 @@ TcrMessageDestroyRegion::TcrMessageDestroyRegion(
}
TcrMessageClearRegion::TcrMessageClearRegion(
- const Region* region, const UserDataPtr& aCallbackArgument,
- int messageResponsetimeout, ThinClientBaseDM* connectionDM) {
+ std::unique_ptr<DataOutput> dataOutput, const Region* region,
+ const UserDataPtr& aCallbackArgument, int messageResponsetimeout,
+ ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::CLEAR_REGION;
m_tcdm = connectionDM;
m_regionName =
@@ -1553,10 +1553,11 @@ TcrMessageClearRegion::TcrMessageClearRegion(
writeMessageLength();
}
-TcrMessageQuery::TcrMessageQuery(const std::string& regionName,
+TcrMessageQuery::TcrMessageQuery(std::unique_ptr<DataOutput> dataOutput,
+ const std::string& regionName,
int messageResponsetimeout,
ThinClientBaseDM* connectionDM) {
- m_request = new DataOutput;
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::QUERY;
m_tcdm = connectionDM;
m_regionName = regionName; // this is querystri;
@@ -1577,9 +1578,11 @@ TcrMessageQuery::TcrMessageQuery(const std::string& regionName,
writeMessageLength();
}
-TcrMessageStopCQ::TcrMessageStopCQ(const std::string& regionName,
+TcrMessageStopCQ::TcrMessageStopCQ(std::unique_ptr<DataOutput> dataOutput,
+ const std::string& regionName,
int messageResponsetimeout,
ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::STOPCQ_MSG_TYPE;
m_tcdm = connectionDM;
m_regionName = regionName; // this is querystring
@@ -1603,9 +1606,11 @@ TcrMessageStopCQ::TcrMessageStopCQ(const std::string& regionName,
writeMessageLength();
}
-TcrMessageCloseCQ::TcrMessageCloseCQ(const std::string& regionName,
+TcrMessageCloseCQ::TcrMessageCloseCQ(std::unique_ptr<DataOutput> dataOutput,
+ const std::string& regionName,
int messageResponsetimeout,
ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::CLOSECQ_MSG_TYPE;
m_tcdm = connectionDM;
m_regionName = regionName; // this is querystring
@@ -1627,9 +1632,10 @@ TcrMessageCloseCQ::TcrMessageCloseCQ(const std::string& regionName,
}
TcrMessageQueryWithParameters::TcrMessageQueryWithParameters(
- const std::string& regionName, const UserDataPtr& aCallbackArgument,
- CacheableVectorPtr paramList, int messageResponsetimeout,
- ThinClientBaseDM* connectionDM) {
+ std::unique_ptr<DataOutput> dataOutput, const std::string& regionName,
+ const UserDataPtr& aCallbackArgument, CacheableVectorPtr paramList,
+ int messageResponsetimeout, ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::QUERY_WITH_PARAMETERS;
m_tcdm = connectionDM;
m_regionName = regionName;
@@ -1664,9 +1670,10 @@ TcrMessageQueryWithParameters::TcrMessageQueryWithParameters(
}
TcrMessageContainsKey::TcrMessageContainsKey(
- const Region* region, const CacheableKeyPtr& key,
- const UserDataPtr& aCallbackArgument, bool isContainsKey,
- ThinClientBaseDM* connectionDM) {
+ std::unique_ptr<DataOutput> dataOutput, const Region* region,
+ const CacheableKeyPtr& key, const UserDataPtr& aCallbackArgument,
+ bool isContainsKey, ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::CONTAINS_KEY;
m_tcdm = connectionDM;
m_regionName =
@@ -1682,7 +1689,6 @@ TcrMessageContainsKey::TcrMessageContainsKey(
numOfParts++;
if (key == nullptr) {
- delete m_request;
throw IllegalArgumentException(
"key passed to the constructor can't be nullptr");
}
@@ -1699,7 +1705,8 @@ TcrMessageContainsKey::TcrMessageContainsKey(
}
TcrMessageGetDurableCqs::TcrMessageGetDurableCqs(
- ThinClientBaseDM* connectionDM) {
+ std::unique_ptr<DataOutput> dataOutput, ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::GETDURABLECQS_MSG_TYPE;
m_tcdm = connectionDM;
m_timeout = DEFAULT_TIMEOUT_SECONDS;
@@ -1711,10 +1718,12 @@ TcrMessageGetDurableCqs::TcrMessageGetDurableCqs(
writeMessageLength();
}
-TcrMessageRequest::TcrMessageRequest(const Region* region,
+TcrMessageRequest::TcrMessageRequest(std::unique_ptr<DataOutput> dataOutput,
+ const Region* region,
const CacheableKeyPtr& key,
const UserDataPtr& aCallbackArgument,
ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::REQUEST;
m_tcdm = connectionDM;
m_key = key;
@@ -1731,7 +1740,6 @@ TcrMessageRequest::TcrMessageRequest(const Region* region,
numOfParts++;
if (key == nullptr) {
- delete m_request;
throw IllegalArgumentException(
"key passed to the constructor can't be nullptr");
}
@@ -1748,10 +1756,11 @@ TcrMessageRequest::TcrMessageRequest(const Region* region,
writeMessageLength();
}
-TcrMessageInvalidate::TcrMessageInvalidate(const Region* region,
- const CacheableKeyPtr& key,
- const UserDataPtr& aCallbackArgument,
- ThinClientBaseDM* connectionDM) {
+TcrMessageInvalidate::TcrMessageInvalidate(
+ std::unique_ptr<DataOutput> dataOutput, const Region* region,
+ const CacheableKeyPtr& key, const UserDataPtr& aCallbackArgument,
+ ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::INVALIDATE;
m_tcdm = connectionDM;
m_key = key;
@@ -1768,7 +1777,6 @@ TcrMessageInvalidate::TcrMessageInvalidate(const Region* region,
numOfParts++;
if (key == nullptr) {
- delete m_request;
throw IllegalArgumentException(
"key passed to the constructor can't be nullptr");
}
@@ -1785,11 +1793,13 @@ TcrMessageInvalidate::TcrMessageInvalidate(const Region* region,
writeMessageLength();
}
-TcrMessageDestroy::TcrMessageDestroy(const Region* region,
+TcrMessageDestroy::TcrMessageDestroy(std::unique_ptr<DataOutput> dataOutput,
+ const Region* region,
const CacheableKeyPtr& key,
const CacheablePtr& value,
const UserDataPtr& aCallbackArgument,
ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::DESTROY;
m_tcdm = connectionDM;
m_key = key;
@@ -1805,7 +1815,6 @@ TcrMessageDestroy::TcrMessageDestroy(const Region* region,
numOfParts++;
if (key == nullptr) {
- delete m_request;
throw IllegalArgumentException(
"key passed to the constructor can't be nullptr");
}
@@ -1839,12 +1848,14 @@ TcrMessageDestroy::TcrMessageDestroy(const Region* region,
}
}
-TcrMessagePut::TcrMessagePut(const Region* region, const CacheableKeyPtr& key,
+TcrMessagePut::TcrMessagePut(std::unique_ptr<DataOutput> dataOutput,
+ const Region* region, const CacheableKeyPtr& key,
const CacheablePtr& value,
const UserDataPtr& aCallbackArgument, bool isDelta,
ThinClientBaseDM* connectionDM, bool isMetaRegion,
bool fullValueAfterDeltaFail,
const char* regionName) {
+ m_request = std::move(dataOutput);
// m_securityHeaderLength = 0;
m_isMetaRegion = isMetaRegion;
m_msgType = TcrMessage::PUT;
@@ -1864,7 +1875,6 @@ TcrMessagePut::TcrMessagePut(const Region* region, const CacheableKeyPtr& key,
numOfParts++;
if (key == nullptr) {
- delete m_request;
throw IllegalArgumentException(
"key passed to the constructor can't be nullptr");
}
@@ -1893,10 +1903,11 @@ TcrMessageReply::TcrMessageReply(bool decodeAll,
if (connectionDM != nullptr) isSecurityOn = connectionDM->isSecurityOn();
}
-TcrMessagePing::TcrMessagePing(bool decodeAll) {
+TcrMessagePing::TcrMessagePing(std::unique_ptr<DataOutput> dataOutput,
+ bool decodeAll) {
m_msgType = TcrMessage::PING;
m_decodeAll = decodeAll;
-
+ m_request = std::move(dataOutput);
m_request->writeInt(m_msgType);
m_request->writeInt(
(int32_t)0); // 17 is fixed message len ... PING only has a header.
@@ -1911,10 +1922,11 @@ TcrMessagePing::TcrMessagePing(bool decodeAll) {
m_txId = 0;
}
-TcrMessageCloseConnection::TcrMessageCloseConnection(bool decodeAll) {
+TcrMessageCloseConnection::TcrMessageCloseConnection(
+ std::unique_ptr<DataOutput> dataOutput, bool decodeAll) {
m_msgType = TcrMessage::CLOSE_CONNECTION;
m_decodeAll = decodeAll;
-
+ m_request = std::move(dataOutput);
m_request->writeInt(m_msgType);
m_request->writeInt((int32_t)6);
m_request->writeInt((int32_t)1); // Number of parts.
@@ -1929,15 +1941,19 @@ TcrMessageCloseConnection::TcrMessageCloseConnection(bool decodeAll) {
m_request->write(static_cast<int8_t>(0)); // keepalive is '0'.
}
-TcrMessageClientMarker::TcrMessageClientMarker(bool decodeAll) {
+TcrMessageClientMarker::TcrMessageClientMarker(
+ std::unique_ptr<DataOutput> dataOutput, bool decodeAll) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::CLIENT_MARKER;
m_decodeAll = decodeAll;
}
TcrMessageRegisterInterestList::TcrMessageRegisterInterestList(
- const Region* region, const VectorOfCacheableKey& keys, bool isDurable,
- bool isCachingEnabled, bool receiveValues,
- InterestResultPolicy interestPolicy, ThinClientBaseDM* connectionDM) {
+ std::unique_ptr<DataOutput> dataOutput, const Region* region,
+ const VectorOfCacheableKey& keys, bool isDurable, bool isCachingEnabled,
+ bool receiveValues, InterestResultPolicy interestPolicy,
+ ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::REGISTER_INTEREST_LIST;
m_tcdm = connectionDM;
m_keyList = &keys;
@@ -1964,7 +1980,6 @@ TcrMessageRegisterInterestList::TcrMessageRegisterInterestList(
for (uint32_t i = 0; i < numInItrestList; i++) {
if (keys[i] == nullptr) {
- delete m_request;
throw IllegalArgumentException(
"keys in the interest list cannot be nullptr");
}
@@ -1987,9 +2002,11 @@ TcrMessageRegisterInterestList::TcrMessageRegisterInterestList(
}
TcrMessageUnregisterInterestList::TcrMessageUnregisterInterestList(
- const Region* region, const VectorOfCacheableKey& keys, bool isDurable,
- bool isCachingEnabled, bool receiveValues,
- InterestResultPolicy interestPolicy, ThinClientBaseDM* connectionDM) {
+ std::unique_ptr<DataOutput> dataOutput, const Region* region,
+ const VectorOfCacheableKey& keys, bool isDurable, bool isCachingEnabled,
+ bool receiveValues, InterestResultPolicy interestPolicy,
+ ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::UNREGISTER_INTEREST_LIST;
m_tcdm = connectionDM;
m_keyList = &keys;
@@ -2014,7 +2031,6 @@ TcrMessageUnregisterInterestList::TcrMessageUnregisterInterestList(
for (uint32_t i = 0; i < numInItrestList; i++) {
if (keys[i] == nullptr) {
- delete m_request;
throw IllegalArgumentException(
"keys in the interest list cannot be nullptr");
}
@@ -2026,9 +2042,11 @@ TcrMessageUnregisterInterestList::TcrMessageUnregisterInterestList(
}
TcrMessageCreateRegion::TcrMessageCreateRegion(
- const std::string& str1, const std::string& str2,
- InterestResultPolicy interestPolicy, bool isDurable, bool isCachingEnabled,
- bool receiveValues, ThinClientBaseDM* connectionDM) {
+ std::unique_ptr<DataOutput> dataOutput, const std::string& str1,
+ const std::string& str2, InterestResultPolicy interestPolicy,
+ bool isDurable, bool isCachingEnabled, bool receiveValues,
+ ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::CREATE_REGION;
m_tcdm = connectionDM;
m_isDurable = isDurable;
@@ -2043,9 +2061,11 @@ TcrMessageCreateRegion::TcrMessageCreateRegion(
}
TcrMessageRegisterInterest::TcrMessageRegisterInterest(
- const std::string& str1, const std::string& str2,
- InterestResultPolicy interestPolicy, bool isDurable, bool isCachingEnabled,
- bool receiveValues, ThinClientBaseDM* connectionDM) {
+ std::unique_ptr<DataOutput> dataOutput, const std::string& str1,
+ const std::string& str2, InterestResultPolicy interestPolicy,
+ bool isDurable, bool isCachingEnabled, bool receiveValues,
+ ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::REGISTER_INTEREST;
m_tcdm = connectionDM;
m_isDurable = isDurable;
@@ -2078,9 +2098,11 @@ TcrMessageRegisterInterest::TcrMessageRegisterInterest(
}
TcrMessageUnregisterInterest::TcrMessageUnregisterInterest(
- const std::string& str1, const std::string& str2,
- InterestResultPolicy interestPolicy, bool isDurable, bool isCachingEnabled,
- bool receiveValues, ThinClientBaseDM* connectionDM) {
+ std::unique_ptr<DataOutput> dataOutput, const std::string& str1,
+ const std::string& str2, InterestResultPolicy interestPolicy,
+ bool isDurable, bool isCachingEnabled, bool receiveValues,
+ ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::UNREGISTER_INTEREST;
m_tcdm = connectionDM;
m_isDurable = isDurable;
@@ -2100,8 +2122,9 @@ TcrMessageUnregisterInterest::TcrMessageUnregisterInterest(
m_interestPolicy = interestPolicy.ordinal;
}
-TcrMessageTxSynchronization::TcrMessageTxSynchronization(int ordinal, int txid,
- int status) {
+TcrMessageTxSynchronization::TcrMessageTxSynchronization(
+ std::unique_ptr<DataOutput> dataOutput, int ordinal, int txid, int status) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::TX_SYNCHRONIZATION;
writeHeader(m_msgType, ordinal == 1 ? 3 : 2);
@@ -2114,7 +2137,9 @@ TcrMessageTxSynchronization::TcrMessageTxSynchronization(int ordinal, int txid,
writeMessageLength();
}
-TcrMessageClientReady::TcrMessageClientReady() {
+TcrMessageClientReady::TcrMessageClientReady(
+ std::unique_ptr<DataOutput> dataOutput) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::CLIENT_READY;
writeHeader(m_msgType, 1);
@@ -2123,8 +2148,9 @@ TcrMessageClientReady::TcrMessageClientReady() {
writeMessageLength();
}
-TcrMessageCommit::TcrMessageCommit() {
+TcrMessageCommit::TcrMessageCommit(std::unique_ptr<DataOutput> dataOutput) {
m_msgType = TcrMessage::COMMIT;
+ m_request = std::move(dataOutput);
writeHeader(m_msgType, 1);
// the server expects at least 1 part, so writing a dummy
@@ -2132,8 +2158,9 @@ TcrMessageCommit::TcrMessageCommit() {
writeMessageLength();
}
-TcrMessageRollback::TcrMessageRollback() {
+TcrMessageRollback::TcrMessageRollback(std::unique_ptr<DataOutput> dataOutput) {
m_msgType = TcrMessage::ROLLBACK;
+ m_request = std::move(dataOutput);
writeHeader(m_msgType, 1);
// the server expects at least 1 part, so writing a dummy
@@ -2141,8 +2168,10 @@ TcrMessageRollback::TcrMessageRollback() {
writeMessageLength();
}
-TcrMessageTxFailover::TcrMessageTxFailover() {
+TcrMessageTxFailover::TcrMessageTxFailover(
+ std::unique_ptr<DataOutput> dataOutput) {
m_msgType = TcrMessage::TX_FAILOVER;
+ m_request = std::move(dataOutput);
writeHeader(m_msgType, 1);
// the server expects at least 1 part, so writing a dummy
@@ -2151,8 +2180,10 @@ TcrMessageTxFailover::TcrMessageTxFailover() {
}
// constructor for MAKE_PRIMARY message.
-TcrMessageMakePrimary::TcrMessageMakePrimary(bool processedMarker) {
+TcrMessageMakePrimary::TcrMessageMakePrimary(
+ std::unique_ptr<DataOutput> dataOutput, bool processedMarker) {
m_msgType = TcrMessage::MAKE_PRIMARY;
+ m_request = std::move(dataOutput);
writeHeader(m_msgType, 1);
writeBytePart(processedMarker ? 1 : 0); // boolean processedMarker
@@ -2161,8 +2192,10 @@ TcrMessageMakePrimary::TcrMessageMakePrimary(bool processedMarker) {
// constructor for PERIODIC_ACK of notified eventids
TcrMessagePeriodicAck::TcrMessagePeriodicAck(
+ std::unique_ptr<DataOutput> dataOutput,
const EventIdMapEntryList& entries) {
m_msgType = TcrMessage::PERIODIC_ACK;
+ m_request = std::move(dataOutput);
uint32_t numParts = static_cast<uint32_t>(entries.size());
GF_D_ASSERT(numParts > 0);
@@ -2178,7 +2211,8 @@ TcrMessagePeriodicAck::TcrMessagePeriodicAck(
writeMessageLength();
}
-TcrMessagePutAll::TcrMessagePutAll(const Region* region,
+TcrMessagePutAll::TcrMessagePutAll(std::unique_ptr<DataOutput> dataOutput,
+ const Region* region,
const HashMapOfCacheable& map,
int messageResponsetimeout,
ThinClientBaseDM* connectionDM,
@@ -2187,6 +2221,7 @@ TcrMessagePutAll::TcrMessagePutAll(const Region* region,
m_regionName = region->getFullPath();
m_region = region;
m_messageResponseTimeout = messageResponsetimeout;
+ m_request = std::move(dataOutput);
// TODO check the number of parts in this constructor. doubt because in PUT
// value can be nullptr also.
@@ -2245,7 +2280,8 @@ TcrMessagePutAll::TcrMessagePutAll(const Region* region,
writeMessageLength();
}
-TcrMessageRemoveAll::TcrMessageRemoveAll(const Region* region,
+TcrMessageRemoveAll::TcrMessageRemoveAll(std::unique_ptr<DataOutput> dataOutput,
+ const Region* region,
const VectorOfCacheableKey& keys,
const UserDataPtr& aCallbackArgument,
ThinClientBaseDM* connectionDM) {
@@ -2253,6 +2289,7 @@ TcrMessageRemoveAll::TcrMessageRemoveAll(const Region* region,
m_tcdm = connectionDM;
m_regionName = region->getFullPath();
m_region = region;
+ m_request = std::move(dataOutput);
// TODO check the number of parts in this constructor. doubt because in PUT
// value can be nullptr also.
@@ -2288,15 +2325,17 @@ TcrMessageRemoveAll::TcrMessageRemoveAll(const Region* region,
}
TcrMessageUpdateClientNotification::TcrMessageUpdateClientNotification(
- int32_t port) {
+ std::unique_ptr<DataOutput> dataOutput, int32_t port) {
m_msgType = TcrMessage::UPDATE_CLIENT_NOTIFICATION;
+ m_request = std::move(dataOutput);
writeHeader(m_msgType, 1);
writeIntPart(port);
writeMessageLength();
}
-TcrMessageGetAll::TcrMessageGetAll(const Region* region,
+TcrMessageGetAll::TcrMessageGetAll(std::unique_ptr<DataOutput> dataOutput,
+ const Region* region,
const VectorOfCacheableKey* keys,
ThinClientBaseDM* connectionDM,
const UserDataPtr& aCallbackArgument) {
@@ -2306,6 +2345,7 @@ TcrMessageGetAll::TcrMessageGetAll(const Region* region,
m_callbackArgument = aCallbackArgument;
m_regionName = region->getFullPath();
m_region = region;
+ m_request = std::move(dataOutput);
/*CacheableObjectArrayPtr keyArr = nullptr;
if (keys != nullptr) {
@@ -2348,10 +2388,13 @@ void TcrMessage::InitializeGetallMsg(const UserDataPtr& aCallbackArgument) {
writeMessageLength();
}
-TcrMessageExecuteCq::TcrMessageExecuteCq(const std::string& str1,
+TcrMessageExecuteCq::TcrMessageExecuteCq(std::unique_ptr<DataOutput> dataOutput,
+ const std::string& str1,
const std::string& str2, int state,
bool isDurable,
ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
+
m_msgType = TcrMessage::EXECUTECQ_MSG_TYPE;
m_tcdm = connectionDM;
m_isDurable = isDurable;
@@ -2374,8 +2417,11 @@ TcrMessageExecuteCq::TcrMessageExecuteCq(const std::string& str1,
}
TcrMessageExecuteCqWithIr::TcrMessageExecuteCqWithIr(
- const std::string& str1, const std::string& str2, int state, bool isDurable,
+ std::unique_ptr<DataOutput> dataOutput, const std::string& str1,
+ const std::string& str2, int state, bool isDurable,
ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
+
m_msgType = TcrMessage::EXECUTECQ_WITH_IR_MSG_TYPE;
m_tcdm = connectionDM;
m_isDurable = isDurable;
@@ -2398,33 +2444,31 @@ TcrMessageExecuteCqWithIr::TcrMessageExecuteCqWithIr(
}
TcrMessageExecuteFunction::TcrMessageExecuteFunction(
- const std::string& funcName, const CacheablePtr& args, uint8_t getResult,
- ThinClientBaseDM* connectionDM, int32_t timeout) {
+ std::unique_ptr<DataOutput> dataOutput, const std::string& funcName,
+ const CacheablePtr& args, uint8_t getResult, ThinClientBaseDM* connectionDM,
+ int32_t timeout) {
+ m_request = std::move(dataOutput);
+
m_msgType = TcrMessage::EXECUTE_FUNCTION;
m_tcdm = connectionDM;
m_hasResult = getResult;
uint32_t numOfParts = 3;
writeHeader(m_msgType, numOfParts);
- // writeBytePart(getResult ? 1 : 0);
- // if gfcpp property unit set then timeout will be in millisecond
- // otherwise it will be in second
- if ((DistributedSystem::getSystemProperties() != nullptr) &&
- (DistributedSystem::getSystemProperties()->readTimeoutUnitInMillis())) {
- writeByteAndTimeOutPart(getResult, timeout);
- } else {
- writeByteAndTimeOutPart(getResult, (timeout * 1000));
- }
+ writeByteAndTimeOutPart(getResult, timeout);
writeRegionPart(funcName); // function name string
writeObjectPart(args);
writeMessageLength();
}
TcrMessageExecuteRegionFunction::TcrMessageExecuteRegionFunction(
- const std::string& funcName, const Region* region, const CacheablePtr& args,
+ std::unique_ptr<DataOutput> dataOutput, const std::string& funcName,
+ const Region* region, const CacheablePtr& args,
CacheableVectorPtr routingObj, uint8_t getResult,
CacheableHashSetPtr failedNodes, int32_t timeout,
ThinClientBaseDM* connectionDM, int8_t reExecute) {
+ m_request = std::move(dataOutput);
+
m_msgType = TcrMessage::EXECUTE_REGION_FUNCTION;
m_tcdm = connectionDM;
m_regionName =
@@ -2445,15 +2489,7 @@ TcrMessageExecuteRegionFunction::TcrMessageExecuteRegionFunction(
numOfParts++;
}
writeHeader(m_msgType, numOfParts);
-
- // if gfcpp property unit set then timeout will be in millisecond
- // otherwise it will be in second
- if ((DistributedSystem::getSystemProperties() != nullptr) &&
- (DistributedSystem::getSystemProperties()->readTimeoutUnitInMillis())) {
- writeByteAndTimeOutPart(getResult, timeout);
- } else {
- writeByteAndTimeOutPart(getResult, (timeout * 1000));
- }
+ writeByteAndTimeOutPart(getResult, timeout);
writeRegionPart(m_regionName);
writeRegionPart(funcName); // function name string
writeObjectPart(args);
@@ -2466,7 +2502,7 @@ TcrMessageExecuteRegionFunction::TcrMessageExecuteRegionFunction(
writeObjectPart(value);
}
} else {
- writeIntPart(0);
+ writeIntPart(0);
}
if (failedNodes) {
writeIntPart(static_cast<int32_t>(failedNodes->size()));
@@ -2479,10 +2515,13 @@ TcrMessageExecuteRegionFunction::TcrMessageExecuteRegionFunction(
TcrMessageExecuteRegionFunctionSingleHop::
TcrMessageExecuteRegionFunctionSingleHop(
- const std::string& funcName, const Region* region,
- const CacheablePtr& args, CacheableHashSetPtr routingObj,
- uint8_t getResult, CacheableHashSetPtr failedNodes, bool allBuckets,
- int32_t timeout, ThinClientBaseDM* connectionDM) {
+ std::unique_ptr<DataOutput> dataOutput, const std::string& funcName,
+ const Region* region, const CacheablePtr& args,
+ CacheableHashSetPtr routingObj, uint8_t getResult,
+ CacheableHashSetPtr failedNodes, bool allBuckets, int32_t timeout,
+ ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
+
m_msgType = TcrMessage::EXECUTE_REGION_FUNCTION_SINGLE_HOP;
m_tcdm = connectionDM;
m_regionName =
@@ -2498,15 +2537,7 @@ TcrMessageExecuteRegionFunctionSingleHop::
numOfParts++;
}
writeHeader(m_msgType, numOfParts);
-
- // if gfcpp property unit set then timeout will be in millisecond
- // otherwise it will be in second
- if ((DistributedSystem::getSystemProperties() != nullptr) &&
- (DistributedSystem::getSystemProperties()->readTimeoutUnitInMillis())) {
- writeByteAndTimeOutPart(getResult, timeout);
- } else {
- writeByteAndTimeOutPart(getResult, (timeout * 1000));
- }
+ writeByteAndTimeOutPart(getResult, timeout);
writeRegionPart(m_regionName);
writeRegionPart(funcName); // function name string
writeObjectPart(args);
@@ -2541,7 +2572,9 @@ TcrMessageExecuteRegionFunctionSingleHop::
}
TcrMessageGetClientPartitionAttributes::TcrMessageGetClientPartitionAttributes(
- const char* regionName) {
+ std::unique_ptr<DataOutput> dataOutput, const char* regionName) {
+ m_request = std::move(dataOutput);
+
m_msgType = TcrMessage::GET_CLIENT_PARTITION_ATTRIBUTES;
writeHeader(m_msgType, 1);
writeRegionPart(regionName);
@@ -2549,14 +2582,19 @@ TcrMessageGetClientPartitionAttributes::TcrMessageGetClientPartitionAttributes(
}
TcrMessageGetClientPrMetadata::TcrMessageGetClientPrMetadata(
- const char* regionName) {
+ std::unique_ptr<DataOutput> dataOutput, const char* regionName) {
+ m_request = std::move(dataOutput);
+
m_msgType = TcrMessage::GET_CLIENT_PR_METADATA;
writeHeader(m_msgType, 1);
writeRegionPart(regionName);
writeMessageLength();
}
-TcrMessageSize::TcrMessageSize(const char* regionName) {
+TcrMessageSize::TcrMessageSize(std::unique_ptr<DataOutput> dataOutput,
+ const char* regionName) {
+ m_request = std::move(dataOutput);
+
m_msgType = TcrMessage::SIZE;
writeHeader(m_msgType, 1);
writeRegionPart(regionName);
@@ -2564,7 +2602,10 @@ TcrMessageSize::TcrMessageSize(const char* regionName) {
}
TcrMessageUserCredential::TcrMessageUserCredential(
- PropertiesPtr creds, ThinClientBaseDM* connectionDM) {
+ std::unique_ptr<DataOutput> dataOutput, PropertiesPtr creds,
+ ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
+
m_msgType = TcrMessage::USER_CREDENTIAL_MESSAGE;
m_tcdm = connectionDM;
@@ -2584,7 +2625,10 @@ TcrMessageUserCredential::TcrMessageUserCredential(
}
TcrMessageRemoveUserAuth::TcrMessageRemoveUserAuth(
- bool keepAlive, ThinClientBaseDM* connectionDM) {
+ std::unique_ptr<DataOutput> dataOutput, bool keepAlive,
+ ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
+
m_msgType = TcrMessage::REMOVE_USER_AUTH;
m_tcdm = connectionDM;
LOGDEBUG("Tcrmessage sending REMOVE_USER_AUTH message to server");
@@ -2605,12 +2649,12 @@ void TcrMessage::createUserCredentialMessage(TcrConnection* conn) {
m_isSecurityHeaderAdded = false;
writeHeader(m_msgType, 1);
- DataOutput dOut;
+ auto dOut = m_tcdm->getConnectionManager().getCacheImpl()->getCache()->createDataOutput();
- if (m_creds != nullptr) m_creds->toData(dOut);
+ if (m_creds != nullptr) m_creds->toData(*dOut);
CacheableBytesPtr credBytes =
- CacheableBytes::create(dOut.getBuffer(), dOut.getBufferLength());
+ CacheableBytes::create(dOut->getBuffer(), dOut->getBufferLength());
CacheableBytesPtr encryptBytes = conn->encryptBytes(credBytes);
writeObjectPart(encryptBytes);
@@ -2633,13 +2677,13 @@ void TcrMessage::addSecurityPart(int64_t connectionId, int64_t unique_id,
}
m_isSecurityHeaderAdded = true;
LOGDEBUG("addSecurityPart( , ) ");
- DataOutput dOutput;
+ auto dOutput = m_tcdm->getConnectionManager().getCacheImpl()->getCache()->createDataOutput();
- dOutput.writeInt(connectionId);
- dOutput.writeInt(unique_id);
+ dOutput->writeInt(connectionId);
+ dOutput->writeInt(unique_id);
CacheableBytesPtr bytes =
- CacheableBytes::create(dOutput.getBuffer(), dOutput.getBufferLength());
+ CacheableBytes::create(dOutput->getBuffer(), dOutput->getBufferLength());
CacheableBytesPtr encryptBytes = conn->encryptBytes(bytes);
@@ -2663,12 +2707,12 @@ void TcrMessage::addSecurityPart(int64_t connectionId, TcrConnection* conn) {
}
m_isSecurityHeaderAdded = true;
LOGDEBUG("TcrMessage::addSecurityPart only connid");
- DataOutput dOutput;
+ auto dOutput = m_tcdm->getConnectionManager().getCacheImpl()->getCache()->createDataOutput();
- dOutput.writeInt(connectionId);
+ dOutput->writeInt(connectionId);
CacheableBytesPtr bytes =
- CacheableBytes::create(dOutput.getBuffer(), dOutput.getBufferLength());
+ CacheableBytes::create(dOutput->getBuffer(), dOutput->getBufferLength());
CacheableBytesPtr encryptBytes = conn->encryptBytes(bytes);
@@ -2681,7 +2725,9 @@ void TcrMessage::addSecurityPart(int64_t connectionId, TcrConnection* conn) {
->asChar());
}
-TcrMessageRequestEventValue::TcrMessageRequestEventValue(EventIdPtr eventId) {
+TcrMessageRequestEventValue::TcrMessageRequestEventValue(
+ std::unique_ptr<DataOutput> dataOutput, EventIdPtr eventId) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::REQUEST_EVENT_VALUE;
uint32_t numOfParts = 1;
@@ -2691,8 +2737,9 @@ TcrMessageRequestEventValue::TcrMessageRequestEventValue(EventIdPtr eventId) {
}
TcrMessageGetPdxIdForType::TcrMessageGetPdxIdForType(
- const CacheablePtr& pdxType, ThinClientBaseDM* connectionDM,
- int32_t pdxTypeId) {
+ std::unique_ptr<DataOutput> dataOutput, const CacheablePtr& pdxType,
+ ThinClientBaseDM* connectionDM, int32_t pdxTypeId) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::GET_PDX_ID_FOR_TYPE;
m_tcdm = connectionDM;
@@ -2706,9 +2753,10 @@ TcrMessageGetPdxIdForType::TcrMessageGetPdxIdForType(
->asChar());
}
-TcrMessageAddPdxType::TcrMessageAddPdxType(const CacheablePtr& pdxType,
- ThinClientBaseDM* connectionDM,
- int32_t pdxTypeId) {
+TcrMessageAddPdxType::TcrMessageAddPdxType(
+ std::unique_ptr<DataOutput> dataOutput, const CacheablePtr& pdxType,
+ ThinClientBaseDM* connectionDM, int32_t pdxTypeId) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::ADD_PDX_TYPE;
m_tcdm = connectionDM;
@@ -2724,8 +2772,9 @@ TcrMessageAddPdxType::TcrMessageAddPdxType(const CacheablePtr& pdxType,
}
TcrMessageGetPdxIdForEnum::TcrMessageGetPdxIdForEnum(
- const CacheablePtr& pdxType, ThinClientBaseDM* connectionDM,
- int32_t pdxTypeId) {
+ std::unique_ptr<DataOutput> dataOutput, const CacheablePtr& pdxType,
+ ThinClientBaseDM* connectionDM, int32_t pdxTypeId) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::GET_PDX_ID_FOR_ENUM;
m_tcdm = connectionDM;
@@ -2739,9 +2788,10 @@ TcrMessageGetPdxIdForEnum::TcrMessageGetPdxIdForEnum(
->asChar());
}
-TcrMessageAddPdxEnum::TcrMessageAddPdxEnum(const CacheablePtr& pdxType,
- ThinClientBaseDM* connectionDM,
- int32_t pdxTypeId) {
+TcrMessageAddPdxEnum::TcrMessageAddPdxEnum(
+ std::unique_ptr<DataOutput> dataOutput, const CacheablePtr& pdxType,
+ ThinClientBaseDM* connectionDM, int32_t pdxTypeId) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::ADD_PDX_ENUM;
m_tcdm = connectionDM;
@@ -2757,7 +2807,9 @@ TcrMessageAddPdxEnum::TcrMessageAddPdxEnum(const CacheablePtr& pdxType,
}
TcrMessageGetPdxTypeById::TcrMessageGetPdxTypeById(
- int32_t typeId, ThinClientBaseDM* connectionDM) {
+ std::unique_ptr<DataOutput> dataOutput, int32_t typeId,
+ ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::GET_PDX_TYPE_BY_ID;
m_tcdm = connectionDM;
@@ -2774,7 +2826,9 @@ TcrMessageGetPdxTypeById::TcrMessageGetPdxTypeById(
}
TcrMessageGetPdxEnumById::TcrMessageGetPdxEnumById(
- int32_t typeId, ThinClientBaseDM* connectionDM) {
+ std::unique_ptr<DataOutput> dataOutput, int32_t typeId,
+ ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::GET_PDX_ENUM_BY_ID;
m_tcdm = connectionDM;
@@ -2791,7 +2845,9 @@ TcrMessageGetPdxEnumById::TcrMessageGetPdxEnumById(
}
TcrMessageGetFunctionAttributes::TcrMessageGetFunctionAttributes(
- const std::string& funcName, ThinClientBaseDM* connectionDM) {
+ std::unique_ptr<DataOutput> dataOutput, const std::string& funcName,
+ ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::GET_FUNCTION_ATTRIBUTES;
m_tcdm = connectionDM;
@@ -2801,8 +2857,10 @@ TcrMessageGetFunctionAttributes::TcrMessageGetFunctionAttributes(
writeMessageLength();
}
-TcrMessageKeySet::TcrMessageKeySet(const std::string& funcName,
+TcrMessageKeySet::TcrMessageKeySet(std::unique_ptr<DataOutput> dataOutput,
+ const std::string& funcName,
ThinClientBaseDM* connectionDM) {
+ m_request = std::move(dataOutput);
m_msgType = TcrMessage::KEY_SET;
m_tcdm = connectionDM;
@@ -2812,17 +2870,21 @@ TcrMessageKeySet::TcrMessageKeySet(const std::string& funcName,
writeMessageLength();
}
-void TcrMessage::setData(const char* bytearray, int32_t len, uint16_t memId) {
+void TcrMessage::setData(const char* bytearray, int32_t len, uint16_t memId,
+ const SerializationRegistry& serializationRegistry,
+ MemberListForVersionStamp& memberListForVersionStamp) {
+ if (m_request == nullptr) {
+ m_request = m_tcdm->getConnectionManager().getCacheImpl()->getCache()->createDataOutput();
+ }
if (bytearray) {
DeleteArray<const char> delByteArr(bytearray);
- handleByteArrayResponse(bytearray, len, memId);
+ handleByteArrayResponse(bytearray, len, memId, serializationRegistry,
+ memberListForVersionStamp);
}
}
TcrMessage::~TcrMessage() {
- GF_SAFE_DELETE(m_request);
GF_SAFE_DELETE(m_cqs);
- GF_SAFE_DELETE(m_delta);
/* adongre
* CID 29167: Non-array delete for scalars (DELETE_ARRAY)
* Coverity - II
[16/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientPdxTests.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientPdxTests.cpp b/src/cppcache/integration-test/testThinClientPdxTests.cpp
index e10bee4..23b6737 100644
--- a/src/cppcache/integration-test/testThinClientPdxTests.cpp
+++ b/src/cppcache/integration-test/testThinClientPdxTests.cpp
@@ -107,8 +107,8 @@ void stepOneN(bool isPdxIgnoreUnreadFields = false,
bool isPdxReadSerialized = false,
PropertiesPtr config = nullptr) {
try {
- // Serializable::registerType(Position::createDeserializable);
- // Serializable::registerType(Portfolio::createDeserializable);
+ // serializationRegistry->addType(Position::createDeserializable);
+ // serializationRegistry->addType(Portfolio::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
@@ -188,8 +188,8 @@ void stepOneForClient2(bool isPdxIgnoreUnreadFields = false) {
void stepOne(bool isPdxIgnoreUnreadFields = false,
PropertiesPtr config = nullptr) {
try {
- // Serializable::registerType(Position::createDeserializable);
- // Serializable::registerType(Portfolio::createDeserializable);
+ // serializationRegistry->addType(Position::createDeserializable);
+ // serializationRegistry->addType(Portfolio::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
@@ -396,14 +396,15 @@ void checkPdxInstanceToStringAtServer(RegionPtr regionPtr) {
// testPdxWriterAPIsWithInvalidArgs
DUNIT_TASK_DEFINITION(CLIENT1, testPdxWriterAPIsWithInvalidArgs)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
try {
- Serializable::registerPdxType(InvalidPdxUsage::createDeserializable);
+ serializationRegistry->addPdxType(InvalidPdxUsage::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(
+ serializationRegistry->addPdxType(
AddressWithInvalidAPIUsage::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
@@ -445,13 +446,14 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, testPdxReaderAPIsWithInvalidArgs)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
try {
- Serializable::registerPdxType(InvalidPdxUsage::createDeserializable);
+ serializationRegistry->addPdxType(InvalidPdxUsage::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(
+ serializationRegistry->addPdxType(
AddressWithInvalidAPIUsage::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
@@ -480,8 +482,10 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, testPutWithMultilevelInheritance)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
try {
- Serializable::registerPdxType(PdxTests::Child::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::Child::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
@@ -513,8 +517,10 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, testGetWithMultilevelInheritance)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
try {
- Serializable::registerPdxType(PdxTests::Child::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::Child::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
@@ -599,14 +605,16 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, JavaPutGet)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
try {
- Serializable::registerPdxType(PdxTests::PdxType::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxType::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(Address::createDeserializable);
+ serializationRegistry->addPdxType(Address::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
@@ -626,32 +634,21 @@ DUNIT_TASK_DEFINITION(CLIENT1, JavaPutGet)
LOGDEBUG("Task:JavaPutGet: isEqual = %d", isEqual);
ASSERT(isEqual == true,
"Task JavaPutGet:Objects of type PdxType should be equal");
- /*
- LOGINFO("NILKATH JavaPutGet new test.");
- dynamic_cast<CacheImpl*>(cacheHelper->getCache().get())->setPdxReadSerialized(true);
- LOGINFO("NILKATH JavaPutGet PDX-ON read-serialized = %d",
- cacheHelper->getCache()->getPdxReadSerialized());
- auto jsonDoc =
- std::dynamic_pointer_cast<PdxInstance>(regPtr0->get("jsondoc1")); int age =
- 0; jsonDoc->getField("age", age); LOGINFO("NILKATH:: Task:JavaPutGet: age =
- %d", age);
- dynamic_cast<CacheImpl*>(cacheHelper->getCache().get())->setPdxReadSerialized(false);
- LOGINFO("NILKATH JavaPutGet PDX-OFF read-serialized = %d",
- cacheHelper->getCache()->getPdxReadSerialized());
- */
}
END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, JavaGet)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
try {
- Serializable::registerPdxType(PdxTests::PdxType::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxType::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(Address::createDeserializable);
+ serializationRegistry->addPdxType(Address::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
@@ -674,8 +671,10 @@ END_TASK_DEFINITION
/***************************************************************/
DUNIT_TASK_DEFINITION(CLIENT2, putAtVersionTwoR21)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
try {
- Serializable::registerPdxType(
+ serializationRegistry->addPdxType(
PdxTests::PdxTypesR2V2::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
@@ -700,8 +699,10 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, getPutAtVersionOneR22)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
try {
- Serializable::registerPdxType(
+ serializationRegistry->addPdxType(
PdxTests::PdxTypesV1R2::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
@@ -765,8 +766,10 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, putAtVersionOne31)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
try {
- Serializable::registerPdxType(PdxTests::PdxType3V1::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxType3V1::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
@@ -789,8 +792,10 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, getPutAtVersionTwo32)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
try {
- Serializable::registerPdxType(
+ serializationRegistry->addPdxType(
PdxTests::PdxTypes3V2::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
@@ -853,8 +858,10 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, putAtVersionOne21)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
try {
- Serializable::registerPdxType(PdxTests::PdxType2V1::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxType2V1::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
@@ -876,8 +883,10 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, getPutAtVersionTwo22)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
try {
- Serializable::registerPdxType(
+ serializationRegistry->addPdxType(
PdxTests::PdxTypes2V2::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
@@ -939,8 +948,10 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, putAtVersionOne11)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
try {
- Serializable::registerPdxType(PdxTests::PdxType1V1::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxType1V1::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
@@ -965,8 +976,10 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, putAtVersionTwo1)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
try {
- Serializable::registerPdxType(
+ serializationRegistry->addPdxType(
PdxTests::PdxTypesR1V2::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
@@ -992,8 +1005,10 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, getPutAtVersionOne2)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
try {
- Serializable::registerPdxType(
+ serializationRegistry->addPdxType(
PdxTests::PdxTypesV1R1::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
@@ -1093,8 +1108,10 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, putV2PdxUI)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
try {
- Serializable::registerPdxType(
+ serializationRegistry->addPdxType(
PdxTests::PdxTypesIgnoreUnreadFieldsV2::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
@@ -1121,8 +1138,10 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, putV1PdxUI)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
try {
- Serializable::registerPdxType(
+ serializationRegistry->addPdxType(
PdxTests::PdxTypesIgnoreUnreadFieldsV1::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
@@ -1156,8 +1175,10 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, getPutAtVersionTwo12)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
try {
- Serializable::registerPdxType(
+ serializationRegistry->addPdxType(
PdxTests::PdxTypes1V2::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
@@ -1237,16 +1258,19 @@ DUNIT_TASK_DEFINITION(CLIENT1, getPutAtVersionOne15)
"Line_272");
regPtr0->put(keyport, pRet);
+ auto testNumberOfPreservedData =
+ TestUtils::testNumberOfPreservedData(*CacheRegionHelper::getCacheImpl(
+ CacheHelper::getHelper().getCache().get()));
LOGDEBUG(
"NIL:getPutAtVersionOne15 m_useWeakHashMap = %d and "
"TestUtils::testNumberOfPreservedData() = %d",
- m_useWeakHashMap, TestUtils::testNumberOfPreservedData());
+ m_useWeakHashMap, testNumberOfPreservedData);
if (m_useWeakHashMap == false) {
- ASSERT(TestUtils::testNumberOfPreservedData() == 0,
+ ASSERT(testNumberOfPreservedData == 0,
"testNumberOfPreservedData should be zero at Line_288");
} else {
ASSERT(
- TestUtils::testNumberOfPreservedData() > 0,
+ testNumberOfPreservedData > 0,
"testNumberOfPreservedData should be Greater than zero at Line_292");
}
}
@@ -1267,13 +1291,15 @@ DUNIT_TASK_DEFINITION(CLIENT2, getPutAtVersionTwo16)
"Objects of type PdxTypes1V2 should be equal at getPutAtVersionTwo14");
regPtr0->put(keyport, pRet);
-
+ auto testNumberOfPreservedData =
+ TestUtils::testNumberOfPreservedData(*CacheRegionHelper::getCacheImpl(
+ CacheHelper::getHelper().getCache().get()));
if (m_useWeakHashMap == false) {
- ASSERT(TestUtils::testNumberOfPreservedData() == 0,
+ ASSERT(testNumberOfPreservedData == 0,
"getPutAtVersionTwo16:testNumberOfPreservedData should be zero");
} else {
// it has extra fields, so no need to preserve data
- ASSERT(TestUtils::testNumberOfPreservedData() == 0,
+ ASSERT(testNumberOfPreservedData == 0,
"getPutAtVersionTwo16:testNumberOfPreservedData should be zero");
}
}
@@ -1281,9 +1307,11 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, Puts2)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
try {
- Serializable::registerPdxType(PdxTests::PdxTypes1::createDeserializable);
- Serializable::registerPdxType(PdxTests::PdxTypes2::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxTypes1::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxTypes2::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
@@ -1302,9 +1330,9 @@ DUNIT_TASK_DEFINITION(CLIENT1, Puts2)
regPtr0->put(keyport2, pdxobj2);
- // ASSERT(lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes()
+ // ASSERT(lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializationBytes()
// ==
- // lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes(),
+ // lregPtr->getCacheImpl()->getCachePerfStats().getPdxDeSerializationBytes(),
//"Total pdxDeserializationBytes should be equal to Total
// pdxSerializationsBytes.");
@@ -1346,9 +1374,9 @@ DUNIT_TASK_DEFINITION(CLIENT1, Puts22)
regPtr0->put(keyport2, pdxobj2);
- // ASSERT(lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes()
+ // ASSERT(lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializationBytes()
// ==
- // lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes(),
+ // lregPtr->getCacheImpl()->getCachePerfStats().getPdxDeSerializationBytes(),
//"Total pdxDeserializationBytes should be equal to Total
// pdxSerializationsBytes.");
@@ -1358,9 +1386,12 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, Get2)
{
+
try {
- Serializable::registerPdxType(PdxTests::PdxTypes1::createDeserializable);
- Serializable::registerPdxType(PdxTests::PdxTypes2::createDeserializable);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
+ serializationRegistry->addPdxType(PdxTests::PdxTypes1::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxTypes2::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
@@ -1376,14 +1407,15 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, PutAndVerifyPdxInGet)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
try {
- Serializable::registerPdxType(PdxTests::PdxType::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxType::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(Address::createDeserializable);
+ serializationRegistry->addPdxType(Address::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
@@ -1405,24 +1437,34 @@ DUNIT_TASK_DEFINITION(CLIENT1, PutAndVerifyPdxInGet)
"Pdx read serialized property should be false.");
LocalRegion* lregPtr = (dynamic_cast<LocalRegion*>(regPtr0.get()));
- LOGINFO("PdxSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations());
- LOGINFO("PdxDeSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations());
- LOGINFO("PdxSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes());
LOGINFO(
- "PdxDeSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes());
- ASSERT(lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations() ==
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations(),
- "Total pdxDeserializations should be equal to Total "
- "pdxSerializations.");
+ "PdxSerializations = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations());
+ LOGINFO(
+ "PdxDeSerializations = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxDeSerializations());
+ LOGINFO("PdxSerializationBytes = %ld ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes());
+ LOGINFO("PdxDeSerializationBytes = %ld ",
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes());
ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes() ==
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes(),
- "Total pdxDeserializationBytes should be equal to Total "
- "pdxSerializationsBytes.");
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations() ==
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations(),
+ "Total pdxDeserializations should be equal to Total "
+ "pdxSerializations.");
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes() ==
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes(),
+ "Total pdxDeserializationBytes should be equal to Total "
+ "pdxSerializationsBytes.");
LOG("StepThree complete.\n");
}
@@ -1431,21 +1473,22 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, PutAndVerifyNestedPdxInGet)
{
LOG("PutAndVerifyNestedPdxInGet started.");
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
try {
- Serializable::registerPdxType(NestedPdx::createDeserializable);
+ serializationRegistry->addPdxType(NestedPdx::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTests::PdxTypes1::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxTypes1::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTests::PdxTypes2::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxTypes2::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
@@ -1468,22 +1511,23 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, PutMixedVersionNestedPdx)
{
LOG("PutMixedVersionNestedPdx started.");
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
try {
- Serializable::registerPdxType(
+ serializationRegistry->addPdxType(
MixedVersionNestedPdx::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTests::PdxTypes1::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxTypes1::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTests::PdxTypes2::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxTypes2::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
@@ -1512,60 +1556,61 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, PutAndVerifyPdxInGFSInGet)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
try {
- Serializable::registerType(
+ serializationRegistry->addType(
PdxInsideIGeodeSerializable::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(NestedPdx::createDeserializable);
+ serializationRegistry->addPdxType(NestedPdx::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes1::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes1::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes2::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes2::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes3::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes3::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes4::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes4::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes5::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes5::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes6::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes6::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes7::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes7::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes8::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes8::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
@@ -1588,60 +1633,61 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, VerifyPdxInGFSGetOnly)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
try {
- Serializable::registerType(
+ serializationRegistry->addType(
PdxInsideIGeodeSerializable::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(NestedPdx::createDeserializable);
+ serializationRegistry->addPdxType(NestedPdx::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes1::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes1::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes2::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes2::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes3::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes3::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes4::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes4::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes5::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes5::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes6::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes6::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes7::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes7::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes8::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes8::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
@@ -1664,21 +1710,22 @@ DUNIT_TASK_DEFINITION(CLIENT2, VerifyMixedVersionNestedGetOnly)
{
LOG("VerifyMixedVersionNestedGetOnly started.");
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
try {
- Serializable::registerPdxType(
+ serializationRegistry->addPdxType(
MixedVersionNestedPdx::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTests::PdxTypes1::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxTypes1::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTests::PdxTypes2::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxTypes2::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
@@ -1707,20 +1754,21 @@ DUNIT_TASK_DEFINITION(CLIENT2, VerifyNestedGetOnly)
{
LOG("VerifyNestedGetOnly started.");
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
try {
- Serializable::registerPdxType(NestedPdx::createDeserializable);
+ serializationRegistry->addPdxType(NestedPdx::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTests::PdxTypes1::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxTypes1::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTests::PdxTypes2::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxTypes2::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
@@ -1740,14 +1788,15 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, VerifyGetOnly)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
try {
- Serializable::registerPdxType(PdxTests::PdxType::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxType::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(Address::createDeserializable);
+ serializationRegistry->addPdxType(Address::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
@@ -1761,22 +1810,31 @@ DUNIT_TASK_DEFINITION(CLIENT2, VerifyGetOnly)
checkPdxInstanceToStringAtServer(regPtr0);
LocalRegion* lregPtr = (dynamic_cast<LocalRegion*>(regPtr0.get()));
- LOGINFO("PdxSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations());
- LOGINFO("PdxDeSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations());
- LOGINFO("PdxSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes());
LOGINFO(
- "PdxDeSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes());
- ASSERT(lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations() <
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations(),
+ "PdxSerializations = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations());
+ LOGINFO(
+ "PdxDeSerializations = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxDeSerializations());
+ LOGINFO("PdxSerializationBytes = %ld ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes());
+ LOGINFO("PdxDeSerializationBytes = %ld ",
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes());
+ ASSERT(lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations() <
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations(),
"Total pdxDeserializations should be less than Total "
"pdxSerializations.");
ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes() <
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes(),
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes() < lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes(),
"Total pdxDeserializationBytes should be less than Total "
"pdxSerializationsBytes.");
LOG("StepFour complete.\n");
@@ -1785,65 +1843,66 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, PutAndVerifyVariousPdxTypes)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
try {
- Serializable::registerPdxType(PdxTypes1::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes1::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes2::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes2::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes3::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes3::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes4::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes4::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes5::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes5::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes6::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes6::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes7::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes7::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes8::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes8::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes9::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes9::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes10::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes10::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
// TODO
- // Serializable::registerPdxType(PdxTests.PortfolioPdx.CreateDeserializable);
- // Serializable::registerPdxType(PdxTests.PositionPdx.CreateDeserializable);
+ // serializationRegistry->addPdxType(PdxTests.PortfolioPdx.CreateDeserializable);
+ // serializationRegistry->addPdxType(PdxTests.PositionPdx.CreateDeserializable);
// Region region0 = CacheHelper.GetVerifyRegion<object,
// object>(m_regionNames[0]);
@@ -1861,27 +1920,34 @@ DUNIT_TASK_DEFINITION(CLIENT1, PutAndVerifyVariousPdxTypes)
checkPdxInstanceToStringAtServer(regPtr0);
LocalRegion* lregPtr = (dynamic_cast<LocalRegion*>(regPtr0.get()));
- LOGINFO("PdxSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations());
- LOGINFO("PdxDeSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations());
- LOGINFO(
- "PdxSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes());
LOGINFO(
- "PdxDeSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes());
+ "PdxSerializations = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations());
+ LOGINFO("PdxDeSerializations = %d ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations());
+ LOGINFO("PdxSerializationBytes = %ld ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes());
+ LOGINFO("PdxDeSerializationBytes = %ld ",
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes());
ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations() ==
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations(),
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations() ==
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations(),
"Total pdxDeserializations should be equal to Total "
"pdxSerializations.");
- ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes() ==
- lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxDeSerializationBytes(),
- "Total pdxDeserializationBytes should be equal to Total "
- "pdxSerializationsBytes.");
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes() ==
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes(),
+ "Total pdxDeserializationBytes should be equal to Total "
+ "pdxSerializationsBytes.");
}
{
@@ -1896,27 +1962,34 @@ DUNIT_TASK_DEFINITION(CLIENT1, PutAndVerifyVariousPdxTypes)
checkPdxInstanceToStringAtServer(regPtr0);
LocalRegion* lregPtr = (dynamic_cast<LocalRegion*>(regPtr0.get()));
- LOGINFO("PdxSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations());
- LOGINFO("PdxDeSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations());
LOGINFO(
- "PdxSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes());
- LOGINFO(
- "PdxDeSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes());
+ "PdxSerializations = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations());
+ LOGINFO("PdxDeSerializations = %d ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations());
+ LOGINFO("PdxSerializationBytes = %ld ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes());
+ LOGINFO("PdxDeSerializationBytes = %ld ",
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes());
ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations() ==
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations(),
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations() ==
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations(),
"Total pdxDeserializations should be equal to Total "
"pdxSerializations.");
- ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes() ==
- lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxDeSerializationBytes(),
- "Total pdxDeserializationBytes should be equal to Total "
- "pdxSerializationsBytes.");
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes() ==
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes(),
+ "Total pdxDeserializationBytes should be equal to Total "
+ "pdxSerializationsBytes.");
}
{
@@ -1931,27 +2004,34 @@ DUNIT_TASK_DEFINITION(CLIENT1, PutAndVerifyVariousPdxTypes)
checkPdxInstanceToStringAtServer(regPtr0);
LocalRegion* lregPtr = (dynamic_cast<LocalRegion*>(regPtr0.get()));
- LOGINFO("PdxSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations());
- LOGINFO("PdxDeSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations());
LOGINFO(
- "PdxSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes());
- LOGINFO(
- "PdxDeSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes());
+ "PdxSerializations = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations());
+ LOGINFO("PdxDeSerializations = %d ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations());
+ LOGINFO("PdxSerializationBytes = %ld ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes());
+ LOGINFO("PdxDeSerializationBytes = %ld ",
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes());
ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations() ==
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations(),
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations() ==
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations(),
"Total pdxDeserializations should be equal to Total "
"pdxSerializations.");
- ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes() ==
- lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxDeSerializationBytes(),
- "Total pdxDeserializationBytes should be equal to Total "
- "pdxSerializationsBytes.");
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes() ==
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes(),
+ "Total pdxDeserializationBytes should be equal to Total "
+ "pdxSerializationsBytes.");
}
{
@@ -1966,27 +2046,34 @@ DUNIT_TASK_DEFINITION(CLIENT1, PutAndVerifyVariousPdxTypes)
checkPdxInstanceToStringAtServer(regPtr0);
LocalRegion* lregPtr = (dynamic_cast<LocalRegion*>(regPtr0.get()));
- LOGINFO("PdxSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations());
- LOGINFO("PdxDeSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations());
LOGINFO(
- "PdxSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes());
- LOGINFO(
- "PdxDeSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes());
+ "PdxSerializations = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations());
+ LOGINFO("PdxDeSerializations = %d ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations());
+ LOGINFO("PdxSerializationBytes = %ld ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes());
+ LOGINFO("PdxDeSerializationBytes = %ld ",
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes());
ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations() ==
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations(),
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations() ==
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations(),
"Total pdxDeserializations should be equal to Total "
"pdxSerializations.");
- ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes() ==
- lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxDeSerializationBytes(),
- "Total pdxDeserializationBytes should be equal to Total "
- "pdxSerializationsBytes.");
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes() ==
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes(),
+ "Total pdxDeserializationBytes should be equal to Total "
+ "pdxSerializationsBytes.");
}
{
@@ -2001,27 +2088,34 @@ DUNIT_TASK_DEFINITION(CLIENT1, PutAndVerifyVariousPdxTypes)
checkPdxInstanceToStringAtServer(regPtr0);
LocalRegion* lregPtr = (dynamic_cast<LocalRegion*>(regPtr0.get()));
- LOGINFO("PdxSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations());
- LOGINFO("PdxDeSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations());
LOGINFO(
- "PdxSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes());
- LOGINFO(
- "PdxDeSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes());
+ "PdxSerializations = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations());
+ LOGINFO("PdxDeSerializations = %d ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations());
+ LOGINFO("PdxSerializationBytes = %ld ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes());
+ LOGINFO("PdxDeSerializationBytes = %ld ",
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes());
ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations() ==
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations(),
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations() ==
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations(),
"Total pdxDeserializations should be equal to Total "
"pdxSerializations.");
- ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes() ==
- lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxDeSerializationBytes(),
- "Total pdxDeserializationBytes should be equal to Total "
- "pdxSerializationsBytes.");
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes() ==
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes(),
+ "Total pdxDeserializationBytes should be equal to Total "
+ "pdxSerializationsBytes.");
}
{
@@ -2036,27 +2130,34 @@ DUNIT_TASK_DEFINITION(CLIENT1, PutAndVerifyVariousPdxTypes)
checkPdxInstanceToStringAtServer(regPtr0);
LocalRegion* lregPtr = (dynamic_cast<LocalRegion*>(regPtr0.get()));
- LOGINFO("PdxSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations());
- LOGINFO("PdxDeSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations());
- LOGINFO(
- "PdxSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes());
LOGINFO(
- "PdxDeSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes());
+ "PdxSerializations = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations());
+ LOGINFO("PdxDeSerializations = %d ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations());
+ LOGINFO("PdxSerializationBytes = %ld ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes());
+ LOGINFO("PdxDeSerializationBytes = %ld ",
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes());
ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations() ==
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations(),
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations() ==
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations(),
"Total pdxDeserializations should be equal to Total "
"pdxSerializations.");
- ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes() ==
- lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxDeSerializationBytes(),
- "Total pdxDeserializationBytes should be equal to Total "
- "pdxSerializationsBytes.");
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes() ==
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes(),
+ "Total pdxDeserializationBytes should be equal to Total "
+ "pdxSerializationsBytes.");
}
{
@@ -2071,27 +2172,34 @@ DUNIT_TASK_DEFINITION(CLIENT1, PutAndVerifyVariousPdxTypes)
checkPdxInstanceToStringAtServer(regPtr0);
LocalRegion* lregPtr = (dynamic_cast<LocalRegion*>(regPtr0.get()));
- LOGINFO("PdxSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations());
- LOGINFO("PdxDeSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations());
LOGINFO(
- "PdxSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes());
- LOGINFO(
- "PdxDeSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes());
+ "PdxSerializations = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations());
+ LOGINFO("PdxDeSerializations = %d ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations());
+ LOGINFO("PdxSerializationBytes = %ld ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes());
+ LOGINFO("PdxDeSerializationBytes = %ld ",
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes());
ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations() ==
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations(),
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations() ==
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations(),
"Total pdxDeserializations should be equal to Total "
"pdxSerializations.");
- ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes() ==
- lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxDeSerializationBytes(),
- "Total pdxDeserializationBytes should be equal to Total "
- "pdxSerializationsBytes.");
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes() ==
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes(),
+ "Total pdxDeserializationBytes should be equal to Total "
+ "pdxSerializationsBytes.");
}
{
@@ -2106,27 +2214,34 @@ DUNIT_TASK_DEFINITION(CLIENT1, PutAndVerifyVariousPdxTypes)
checkPdxInstanceToStringAtServer(regPtr0);
LocalRegion* lregPtr = (dynamic_cast<LocalRegion*>(regPtr0.get()));
- LOGINFO("PdxSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations());
- LOGINFO("PdxDeSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations());
LOGINFO(
- "PdxSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes());
- LOGINFO(
- "PdxDeSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes());
+ "PdxSerializations = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations());
+ LOGINFO("PdxDeSerializations = %d ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations());
+ LOGINFO("PdxSerializationBytes = %ld ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes());
+ LOGINFO("PdxDeSerializationBytes = %ld ",
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes());
ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations() ==
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations(),
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations() ==
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations(),
"Total pdxDeserializations should be equal to Total "
"pdxSerializations.");
- ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes() ==
- lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxDeSerializationBytes(),
- "Total pdxDeserializationBytes should be equal to Total "
- "pdxSerializationsBytes.");
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes() ==
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes(),
+ "Total pdxDeserializationBytes should be equal to Total "
+ "pdxSerializationsBytes.");
}
{
@@ -2141,27 +2256,34 @@ DUNIT_TASK_DEFINITION(CLIENT1, PutAndVerifyVariousPdxTypes)
checkPdxInstanceToStringAtServer(regPtr0);
LocalRegion* lregPtr = (dynamic_cast<LocalRegion*>(regPtr0.get()));
- LOGINFO("PdxSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations());
- LOGINFO("PdxDeSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations());
LOGINFO(
- "PdxSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes());
- LOGINFO(
- "PdxDeSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes());
+ "PdxSerializations = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations());
+ LOGINFO("PdxDeSerializations = %d ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations());
+ LOGINFO("PdxSerializationBytes = %ld ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes());
+ LOGINFO("PdxDeSerializationBytes = %ld ",
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes());
ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations() ==
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations(),
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations() ==
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations(),
"Total pdxDeserializations should be equal to Total "
"pdxSerializations.");
- ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes() ==
- lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxDeSerializationBytes(),
- "Total pdxDeserializationBytes should be equal to Total "
- "pdxSerializationsBytes.");
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes() ==
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes(),
+ "Total pdxDeserializationBytes should be equal to Total "
+ "pdxSerializationsBytes.");
}
{
@@ -2177,27 +2299,34 @@ DUNIT_TASK_DEFINITION(CLIENT1, PutAndVerifyVariousPdxTypes)
checkPdxInstanceToStringAtServer(regPtr0);
LocalRegion* lregPtr = (dynamic_cast<LocalRegion*>(regPtr0.get()));
- LOGINFO("PdxSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations());
- LOGINFO("PdxDeSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations());
LOGINFO(
- "PdxSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes());
- LOGINFO(
- "PdxDeSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes());
+ "PdxSerializations = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations());
+ LOGINFO("PdxDeSerializations = %d ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations());
+ LOGINFO("PdxSerializationBytes = %ld ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes());
+ LOGINFO("PdxDeSerializationBytes = %ld ",
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes());
ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations() ==
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations(),
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations() ==
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations(),
"Total pdxDeserializations should be equal to Total "
"pdxSerializations.");
- ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes() ==
- lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxDeSerializationBytes(),
- "Total pdxDeserializationBytes should be equal to Total "
- "pdxSerializationsBytes.");
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes() ==
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes(),
+ "Total pdxDeserializationBytes should be equal to Total "
+ "pdxSerializationsBytes.");
}
LOG("NIL:329:StepFive complete.\n");
@@ -2270,59 +2399,61 @@ END_TASK_DEFINITION
// C1.putAllPdxTypes
DUNIT_TASK_DEFINITION(CLIENT1, putAllPdxTypes)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
try {
- Serializable::registerPdxType(PdxTypes1::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes1::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes2::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes2::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes3::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes3::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes4::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes4::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes5::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes5::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes6::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes6::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes7::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes7::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes8::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes8::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes9::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes9::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes10::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes10::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
// TODO::Uncomment it once PortfolioPdx/PositionPdx Classes are ready
- // Serializable::registerPdxType(PdxTests.PortfolioPdx.CreateDeserializable);
- // Serializable::registerPdxType(PdxTests.PositionPdx.CreateDeserializable);
+ // serializationRegistry->addPdxType(PdxTests.PortfolioPdx.CreateDeserializable);
+ // serializationRegistry->addPdxType(PdxTests.PositionPdx.CreateDeserializable);
RegionPtr regPtr0 = getHelper()->getRegion("DistRegionAck");
@@ -2438,8 +2569,10 @@ END_TASK_DEFINITION
// c1.client1PutsV1Object
DUNIT_TASK_DEFINITION(CLIENT1, client1PutsV1Object)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
try {
- Serializable::registerPdxType(PdxTests::PdxType3V1::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxType3V1::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
@@ -2455,8 +2588,10 @@ END_TASK_DEFINITION
// c2.client2GetsV1ObjectAndPutsV2Object
DUNIT_TASK_DEFINITION(CLIENT2, client2GetsV1ObjectAndPutsV2Object)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
try {
- Serializable::registerPdxType(
+ serializationRegistry->addPdxType(
PdxTests::PdxTypes3V2::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
@@ -2539,59 +2674,61 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, VerifyVariousPdxGets)
{
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
try {
- Serializable::registerPdxType(PdxTypes1::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes1::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes2::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes2::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes3::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes3::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes4::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes4::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes5::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes5::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes6::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes6::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes7::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes7::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes8::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes8::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes9::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes9::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes10::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes10::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
// TODO::Uncomment it once PortfolioPdx/PositionPdx Classes are ready
- // Serializable::registerPdxType(PdxTests.PortfolioPdx.CreateDeserializable);
- // Serializable::registerPdxType(PdxTests.PositionPdx.CreateDeserializable);
+ // serializationRegistry->addPdxType(PdxTests.PortfolioPdx.CreateDeserializable);
+ // serializationRegistry->addPdxType(PdxTests.PositionPdx.CreateDeserializable);
RegionPtr regPtr0 = getHelper()->getRegion("DistRegionAck");
bool flag = false;
@@ -2607,24 +2744,32 @@ DUNIT_TASK_DEFINITION(CLIENT2, VerifyVariousPdxGets)
checkPdxInstanceToStringAtServer(regPtr0);
LocalRegion* lregPtr = (dynamic_cast<LocalRegion*>(regPtr0.get()));
- LOGINFO("PdxSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations());
- LOGINFO("PdxDeSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations());
- LOGINFO(
- "PdxSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes());
LOGINFO(
- "PdxDeSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes());
+ "PdxSerializations = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations());
+ LOGINFO("PdxDeSerializations = %d ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations());
+ LOGINFO("PdxSerializationBytes = %ld ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes());
+ LOGINFO("PdxDeSerializationBytes = %ld ",
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes());
ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations() <
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations(),
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations() <
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations(),
"Total pdxDeserializations should be less than Total "
"pdxSerializations.");
- ASSERT(lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes() <
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes() <
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxDeSerializationBytes(),
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes(),
"Total pdxDeserializationBytes should be less than Total "
"pdxSerializationsBytes.");
}
@@ -2641,24 +2786,32 @@ DUNIT_TASK_DEFINITION(CLIENT2, VerifyVariousPdxGets)
checkPdxInstanceToStringAtServer(regPtr0);
LocalRegion* lregPtr = (dynamic_cast<LocalRegion*>(regPtr0.get()));
- LOGINFO("PdxSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations());
- LOGINFO("PdxDeSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations());
LOGINFO(
- "PdxSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes());
- LOGINFO(
- "PdxDeSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes());
+ "PdxSerializations = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations());
+ LOGINFO("PdxDeSerializations = %d ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations());
+ LOGINFO("PdxSerializationBytes = %ld ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes());
+ LOGINFO("PdxDeSerializationBytes = %ld ",
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes());
ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations() <
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations(),
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations() <
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations(),
"Total pdxDeserializations should be less than Total "
"pdxSerializations.");
- ASSERT(lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes() <
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes() <
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxDeSerializationBytes(),
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes(),
"Total pdxDeserializationBytes should be less than Total "
"pdxSerializationsBytes.");
}
@@ -2675,24 +2828,32 @@ DUNIT_TASK_DEFINITION(CLIENT2, VerifyVariousPdxGets)
checkPdxInstanceToStringAtServer(regPtr0);
LocalRegion* lregPtr = (dynamic_cast<LocalRegion*>(regPtr0.get()));
- LOGINFO("PdxSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations());
- LOGINFO("PdxDeSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations());
LOGINFO(
- "PdxSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes());
- LOGINFO(
- "PdxDeSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes());
+ "PdxSerializations = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations());
+ LOGINFO("PdxDeSerializations = %d ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations());
+ LOGINFO("PdxSerializationBytes = %ld ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes());
+ LOGINFO("PdxDeSerializationBytes = %ld ",
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes());
ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations() <
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations(),
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations() <
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations(),
"Total pdxDeserializations should be less than Total "
"pdxSerializations.");
- ASSERT(lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes() <
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes() <
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxDeSerializationBytes(),
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes(),
"Total pdxDeserializationBytes should be less than Total "
"pdxSerializationsBytes.");
}
@@ -2709,24 +2870,32 @@ DUNIT_TASK_DEFINITION(CLIENT2, VerifyVariousPdxGets)
checkPdxInstanceToStringAtServer(regPtr0);
LocalRegion* lregPtr = (dynamic_cast<LocalRegion*>(regPtr0.get()));
- LOGINFO("PdxSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations());
- LOGINFO("PdxDeSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations());
- LOGINFO(
- "PdxSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes());
LOGINFO(
- "PdxDeSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes());
+ "PdxSerializations = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations());
+ LOGINFO("PdxDeSerializations = %d ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations());
+ LOGINFO("PdxSerializationBytes = %ld ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes());
+ LOGINFO("PdxDeSerializationBytes = %ld ",
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes());
ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations() <
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations(),
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations() <
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations(),
"Total pdxDeserializations should be less than Total "
"pdxSerializations.");
- ASSERT(lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes() <
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes() <
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxDeSerializationBytes(),
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes(),
"Total pdxDeserializationBytes should be less than Total "
"pdxSerializationsBytes.");
}
@@ -2743,24 +2912,32 @@ DUNIT_TASK_DEFINITION(CLIENT2, VerifyVariousPdxGets)
checkPdxInstanceToStringAtServer(regPtr0);
LocalRegion* lregPtr = (dynamic_cast<LocalRegion*>(regPtr0.get()));
- LOGINFO("PdxSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations());
- LOGINFO("PdxDeSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations());
LOGINFO(
- "PdxSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes());
- LOGINFO(
- "PdxDeSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes());
+ "PdxSerializations = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations());
+ LOGINFO("PdxDeSerializations = %d ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations());
+ LOGINFO("PdxSerializationBytes = %ld ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes());
+ LOGINFO("PdxDeSerializationBytes = %ld ",
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes());
ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations() <
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations(),
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations() <
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations(),
"Total pdxDeserializations should be less than Total "
"pdxSerializations.");
- ASSERT(lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes() <
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes() <
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxDeSerializationBytes(),
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes(),
"Total pdxDeserializationBytes should be less than Total "
"pdxSerializationsBytes.");
}
@@ -2777,24 +2954,32 @@ DUNIT_TASK_DEFINITION(CLIENT2, VerifyVariousPdxGets)
checkPdxInstanceToStringAtServer(regPtr0);
LocalRegion* lregPtr = (dynamic_cast<LocalRegion*>(regPtr0.get()));
- LOGINFO("PdxSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations());
- LOGINFO("PdxDeSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations());
- LOGINFO(
- "PdxSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes());
LOGINFO(
- "PdxDeSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes());
+ "PdxSerializations = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations());
+ LOGINFO("PdxDeSerializations = %d ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations());
+ LOGINFO("PdxSerializationBytes = %ld ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes());
+ LOGINFO("PdxDeSerializationBytes = %ld ",
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes());
ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations() <
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations(),
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations() <
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations(),
"Total pdxDeserializations should be less than Total "
"pdxSerializations.");
- ASSERT(lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes() <
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes() <
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxDeSerializationBytes(),
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes(),
"Total pdxDeserializationBytes should be less than Total "
"pdxSerializationsBytes.");
}
@@ -2811,24 +2996,32 @@ DUNIT_TASK_DEFINITION(CLIENT2, VerifyVariousPdxGets)
checkPdxInstanceToStringAtServer(regPtr0);
LocalRegion* lregPtr = (dynamic_cast<LocalRegion*>(regPtr0.get()));
- LOGINFO("PdxSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations());
- LOGINFO("PdxDeSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations());
LOGINFO(
- "PdxSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes());
- LOGINFO(
- "PdxDeSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes());
+ "PdxSerializations = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations());
+ LOGINFO("PdxDeSerializations = %d ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations());
+ LOGINFO("PdxSerializationBytes = %ld ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes());
+ LOGINFO("PdxDeSerializationBytes = %ld ",
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes());
ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations() <
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations(),
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations() <
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations(),
"Total pdxDeserializations should be less than Total "
"pdxSerializations.");
- ASSERT(lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes() <
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes() <
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxDeSerializationBytes(),
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes(),
"Total pdxDeserializationBytes should be less than Total "
"pdxSerializationsBytes.");
}
@@ -2845,24 +3038,32 @@ DUNIT_TASK_DEFINITION(CLIENT2, VerifyVariousPdxGets)
checkPdxInstanceToStringAtServer(regPtr0);
LocalRegion* lregPtr = (dynamic_cast<LocalRegion*>(regPtr0.get()));
- LOGINFO("PdxSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations());
- LOGINFO("PdxDeSerializations = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations());
- LOGINFO(
- "PdxSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes());
LOGINFO(
- "PdxDeSerializationBytes = %ld ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializationBytes());
+ "PdxSerializations = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations());
+ LOGINFO("PdxDeSerializations = %d ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations());
+ LOGINFO("PdxSerializationBytes = %ld ", lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes());
+ LOGINFO("PdxDeSerializationBytes = %ld ",
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes());
ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializations() <
- lregPtr->getCacheImpl()->m_cacheStats->getPdxDeSerializations(),
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxSerializations() <
+ lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxDeSerializations(),
"Total pdxDeserializations should be less than Total "
"pdxSerializations.");
- ASSERT(lregPtr->getCacheImpl()->m_cacheStats->getPdxSerializationBytes() <
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxSerializationBytes() <
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxDeSerializationBytes(),
+ ->getCachePerfStats()
+ .getPdxDeSerializationBytes(),
"Total pdxDeserializationBytes should be less than Total "
"pdxSerializationsBytes
<TRUNCATED>
[09/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/SerializationRegistry.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/SerializationRegistry.cpp b/src/cppcache/src/SerializationRegistry.cpp
index a4e593c..4f308b4 100644
--- a/src/cppcache/src/SerializationRegistry.cpp
+++ b/src/cppcache/src/SerializationRegistry.cpp
@@ -49,304 +49,80 @@
#include "ThinClientPoolDM.hpp"
#include "PdxType.hpp"
#include <geode/PdxWrapper.hpp>
-#include <geode/PdxSerializable.hpp>
#include "EnumInfo.hpp"
#include "VersionTag.hpp"
#include "DiskStoreId.hpp"
#include "DiskVersionTag.hpp"
#include "CachedDeserializableHelper.hpp"
-
-#include "NonCopyable.hpp"
-
#include <mutex>
-#include "util/concurrent/spinlock_mutex.hpp"
+#include <functional>
namespace apache {
namespace geode {
namespace client {
-/* adongre
- * CID 28729: Other violation (MISSING_COPY)
- * Class "apache::geode::client::TheTypeMap" owns resources that are managed in
- * its
- * constructor and destructor but has no user-written copy constructor.
- *
- * CID 28715: Other violation (MISSING_ASSIGN)
- * Class "apache::geode::client::TheTypeMap" owns resources that are managed
- * in its constructor and destructor but has no user-written assignment
- * operator.
- *
- * FIX : Make the class NonCopyable
- */
-
-class TheTypeMap : private NonCopyable, private NonAssignable {
- private:
- IdToFactoryMap* m_map;
- IdToFactoryMap* m_map2; // to hold Fixed IDs since GFE 5.7.
- StrToPdxFactoryMap* m_pdxTypemap;
- spinlock_mutex m_mapLock;
- spinlock_mutex m_map2Lock;
- spinlock_mutex m_pdxTypemapLock;
-
- public:
- TheTypeMap();
-
- virtual ~TheTypeMap() {
- if (m_map != nullptr) {
- delete m_map;
- }
-
- if (m_map2 != nullptr) {
- delete m_map2;
- }
-
- if (m_pdxTypemap != nullptr) {
- delete m_pdxTypemap;
- }
- }
-
- inline void setup() {
- // Register Geode builtins here!!
- // update type ids in GeodeTypeIds.hpp
-
- bind(CacheableByte::createDeserializable);
- bind(CacheableBoolean::createDeserializable);
- bind(BooleanArray::createDeserializable);
- bind(CacheableBytes::createDeserializable);
- bind(CacheableFloat::createDeserializable);
- bind(CacheableFloatArray::createDeserializable);
- bind(CacheableDouble::createDeserializable);
- bind(CacheableDoubleArray::createDeserializable);
- bind(CacheableDate::createDeserializable);
- bind(CacheableFileName::createDeserializable);
- bind(CacheableHashMap::createDeserializable);
- bind(CacheableHashSet::createDeserializable);
- bind(CacheableHashTable::createDeserializable);
- bind(CacheableIdentityHashMap::createDeserializable);
- bind(CacheableLinkedHashSet::createDeserializable);
- bind(CacheableInt16::createDeserializable);
- bind(CacheableInt16Array::createDeserializable);
- bind(CacheableInt32::createDeserializable);
- bind(CacheableInt32Array::createDeserializable);
- bind(CacheableInt64::createDeserializable);
- bind(CacheableInt64Array::createDeserializable);
- bind(CacheableObjectArray::createDeserializable);
- bind(CacheableString::createDeserializable);
- bind(CacheableString::createDeserializableHuge);
- bind(CacheableString::createUTFDeserializable);
- bind(CacheableString::createUTFDeserializableHuge);
- bind(CacheableStringArray::createDeserializable);
- bind(CacheableVector::createDeserializable);
- bind(CacheableArrayList::createDeserializable);
- bind(CacheableLinkedList::createDeserializable);
- bind(CacheableStack::createDeserializable);
- bind(CacheableWideChar::createDeserializable);
- bind(CharArray::createDeserializable);
- bind(CacheableToken::createDeserializable);
- bind(RegionAttributes::createDeserializable);
- bind(Properties::createDeserializable);
- // bind(CacheableObjectPartList::createDeserializable);
- // bind internal/fixed classes - since GFE 5.7
- bind2(CacheableUndefined::createDeserializable);
- bind2(EventId::createDeserializable);
- bind2(Struct::createDeserializable);
- bind2(ClientConnectionResponse::create);
- bind2(QueueConnectionResponse::create);
- bind2(LocatorListResponse::create);
- bind2(ClientProxyMembershipID::createDeserializable);
- bind2(GatewayEventCallbackArgument::createDeserializable);
- bind2(GatewaySenderEventCallbackArgument::createDeserializable);
- bind2(GetAllServersResponse::create);
- bind2(TXCommitMessage::create);
- bind2(EnumInfo::createDeserializable);
- bind2(VersionTag::createDeserializable);
- rebind2(GeodeTypeIdsImpl::DiskStoreId, DiskStoreId::createDeserializable);
- rebind2(GeodeTypeIdsImpl::DiskVersionTag,
- DiskVersionTag::createDeserializable);
- bind2(CachedDeserializableHelper::createForVmCachedDeserializable);
- bind2(CachedDeserializableHelper::createForPreferBytesDeserializable);
- // bind2(VersionedCacheableObjectPartList::createDeserializable);
- }
-
- inline void clear() {
- std::lock_guard<spinlock_mutex> guard(m_mapLock);
- m_map->unbind_all();
-
- std::lock_guard<spinlock_mutex> guard2(m_map2Lock);
- m_map2->unbind_all();
-
- std::lock_guard<spinlock_mutex> guard3(m_pdxTypemapLock);
- m_pdxTypemap->unbind_all();
- }
-
- inline void find(int64_t id, TypeFactoryMethod& func) {
- std::lock_guard<spinlock_mutex> guard(m_mapLock);
- m_map->find(id, func);
- }
-
- inline void find2(int64_t id, TypeFactoryMethod& func) {
- std::lock_guard<spinlock_mutex> guard(m_map2Lock);
- m_map2->find(id, func);
- }
-
- inline void bind(TypeFactoryMethod func) {
- Serializable* obj = func();
- std::lock_guard<spinlock_mutex> guard(m_mapLock);
- int64_t compId = static_cast<int64_t>(obj->typeId());
- if (compId == GeodeTypeIdsImpl::CacheableUserData ||
- compId == GeodeTypeIdsImpl::CacheableUserData2 ||
- compId == GeodeTypeIdsImpl::CacheableUserData4) {
- compId |= ((static_cast<int64_t>(obj->classId())) << 32);
- }
- delete obj;
- int bindRes = m_map->bind(compId, func);
- if (bindRes == 1) {
- LOGERROR(
- "A class with "
- "ID %d is already registered.",
- compId);
- throw IllegalStateException(
- "A class with "
- "given ID is already registered.");
- } else if (bindRes == -1) {
- LOGERROR(
- "Unknown error "
- "while adding class ID %d to map.",
- compId);
- throw IllegalStateException(
- "Unknown error "
- "while adding type to map.");
- }
- }
- inline void rebind(int64_t compId, TypeFactoryMethod func) {
- std::lock_guard<spinlock_mutex> guard(m_mapLock);
- int bindRes = m_map->rebind(compId, func);
- if (bindRes == -1) {
- LOGERROR(
- "Unknown error "
- "while adding class ID %d to map.",
- compId);
- throw IllegalStateException(
- "Unknown error "
- "while adding type to map.");
- }
- }
-
- inline void unbind(int64_t compId) {
- std::lock_guard<spinlock_mutex> guard(m_mapLock);
- m_map->unbind(compId);
- }
-
- inline void bind2(TypeFactoryMethod func) {
- Serializable* obj = func();
- std::lock_guard<spinlock_mutex> guard(m_map2Lock);
- int8_t dsfid = obj->DSFID();
-
- int64_t compId = 0;
- if (dsfid == GeodeTypeIdsImpl::FixedIDShort) {
- compId = compId = static_cast<int64_t>(obj->classId());
- } else {
- compId = static_cast<int64_t>(obj->typeId());
- }
- delete obj;
- int bindRes = m_map2->bind(compId, func);
- if (bindRes == 1) {
- LOGERROR(
- "A fixed class with "
- "ID %d is already registered.",
- compId);
- throw IllegalStateException(
- "A fixed class with "
- "given ID is already registered.");
- } else if (bindRes == -1) {
- LOGERROR(
- "Unknown error "
- "while adding class ID %d to map2.",
- compId);
- throw IllegalStateException(
- "Unknown error "
- "while adding to map2.");
- }
- }
-
- inline void rebind2(int64_t compId, TypeFactoryMethod func) {
- std::lock_guard<spinlock_mutex> guard(m_map2Lock);
- m_map2->rebind(compId, func);
- }
-
- inline void unbind2(int64_t compId) {
- std::lock_guard<spinlock_mutex> guard(m_map2Lock);
- m_map2->unbind(compId);
- }
-
- inline void bindPdxType(TypeFactoryMethodPdx func) {
- PdxSerializable* obj = func();
- std::lock_guard<spinlock_mutex> guard(m_pdxTypemapLock);
- const char* objFullName = obj->getClassName();
-
- int bindRes = m_pdxTypemap->bind(objFullName, func);
-
- delete obj;
-
- if (bindRes == 1) {
- LOGERROR("A object with FullName %s is already registered.", objFullName);
- throw IllegalStateException(
- "A Object with "
- "given FullName is already registered.");
- } else if (bindRes == -1) {
- LOGERROR(
- "Unknown error "
- "while adding Pdx Object named %s to map.",
- objFullName);
- throw IllegalStateException(
- "Unknown error "
- "while adding type to map.");
- }
- }
-
- inline void findPdxType(const char* objFullName, TypeFactoryMethodPdx& func) {
- std::lock_guard<spinlock_mutex> guard(m_pdxTypemapLock);
- m_pdxTypemap->find(objFullName, func);
- }
-
- inline void rebindPdxType(const char* objFullName,
- TypeFactoryMethodPdx func) {
- std::lock_guard<spinlock_mutex> guard(m_pdxTypemapLock);
- int bindRes = m_pdxTypemap->rebind(objFullName, func);
- if (bindRes == -1) {
- LOGERROR(
- "Unknown error "
- "while adding Pdx Object FullName %s to map.",
- objFullName);
- throw IllegalStateException(
- "Unknown error "
- "while adding type to map.");
- }
- }
-
- inline void unbindPdxType(const char* objFullName) {
- std::lock_guard<spinlock_mutex> guard(m_pdxTypemapLock);
- m_pdxTypemap->unbind(objFullName);
- }
-};
-
-TheTypeMap::TheTypeMap() {
- m_map = new IdToFactoryMap();
-
- // second map to hold internal Data Serializable Fixed IDs - since GFE 5.7
- m_map2 = new IdToFactoryMap();
-
- // map to hold PDX types <string, funptr>.
- m_pdxTypemap = new StrToPdxFactoryMap();
+void TheTypeMap::setup() {
+ // Register Geode builtins here!!
+ // update type ids in GeodeTypeIds.hpp
+
+ bind(CacheableByte::createDeserializable);
+ bind(CacheableBoolean::createDeserializable);
+ bind(BooleanArray::createDeserializable);
+ bind(CacheableBytes::createDeserializable);
+ bind(CacheableFloat::createDeserializable);
+ bind(CacheableFloatArray::createDeserializable);
+ bind(CacheableDouble::createDeserializable);
+ bind(CacheableDoubleArray::createDeserializable);
+ bind(CacheableDate::createDeserializable);
+ bind(CacheableFileName::createDeserializable);
+ bind(CacheableHashMap::createDeserializable);
+ bind(CacheableHashSet::createDeserializable);
+ bind(CacheableHashTable::createDeserializable);
+ bind(CacheableIdentityHashMap::createDeserializable);
+ bind(CacheableLinkedHashSet::createDeserializable);
+ bind(CacheableInt16::createDeserializable);
+ bind(CacheableInt16Array::createDeserializable);
+ bind(CacheableInt32::createDeserializable);
+ bind(CacheableInt32Array::createDeserializable);
+ bind(CacheableInt64::createDeserializable);
+ bind(CacheableInt64Array::createDeserializable);
+ bind(CacheableObjectArray::createDeserializable);
+ bind(CacheableString::createDeserializable);
+ bind(CacheableString::createDeserializableHuge);
+ bind(CacheableString::createUTFDeserializable);
+ bind(CacheableString::createUTFDeserializableHuge);
+ bind(CacheableStringArray::createDeserializable);
+ bind(CacheableVector::createDeserializable);
+ bind(CacheableArrayList::createDeserializable);
+ bind(CacheableLinkedList::createDeserializable);
+ bind(CacheableStack::createDeserializable);
+ bind(CacheableWideChar::createDeserializable);
+ bind(CharArray::createDeserializable);
+ bind(CacheableToken::createDeserializable);
+ bind(RegionAttributes::createDeserializable);
+ bind(Properties::createDeserializable);
+
+ bind2(CacheableUndefined::createDeserializable);
+ bind2(EventId::createDeserializable);
+ bind2(Struct::createDeserializable);
+ bind2(ClientConnectionResponse::create);
+ bind2(QueueConnectionResponse::create);
+ bind2(LocatorListResponse::create);
+ bind2(ClientProxyMembershipID::createDeserializable);
+ bind2(GatewayEventCallbackArgument::createDeserializable);
+ bind2(GatewaySenderEventCallbackArgument::createDeserializable);
+ bind2(GetAllServersResponse::create);
+ bind2(EnumInfo::createDeserializable);
+
+ rebind2(GeodeTypeIdsImpl::DiskStoreId, DiskStoreId::createDeserializable);
+
+ bind2(CachedDeserializableHelper::createForVmCachedDeserializable);
+ bind2(CachedDeserializableHelper::createForPreferBytesDeserializable);
}
-typedef ACE_Singleton<TheTypeMap, ACE_Thread_Mutex> theTypeMap;
-
-PdxSerializerPtr SerializationRegistry::m_pdxSerializer = nullptr;
-
/** This starts at reading the typeid.. assumes the length has been read. */
SerializablePtr SerializationRegistry::deserialize(DataInput& input,
- int8_t typeId) {
+ int8_t typeId) const {
bool findinternal = false;
int8_t currentTypeId = typeId;
@@ -393,9 +169,9 @@ SerializablePtr SerializationRegistry::deserialize(DataInput& input,
}
if (findinternal) {
- theTypeMap::instance()->find2(compId, createType);
+ theTypeMap.find2(compId, createType);
} else {
- theTypeMap::instance()->find(compId, createType);
+ theTypeMap.find(compId, createType);
}
if (createType == nullptr) {
if (findinternal) {
@@ -425,47 +201,41 @@ SerializablePtr SerializationRegistry::deserialize(DataInput& input,
}
void SerializationRegistry::addType(TypeFactoryMethod func) {
- theTypeMap::instance()->bind(func);
+ theTypeMap.bind(func);
}
void SerializationRegistry::addPdxType(TypeFactoryMethodPdx func) {
- theTypeMap::instance()->bindPdxType(func);
+ theTypeMap.bindPdxType(func);
}
void SerializationRegistry::addType(int64_t compId, TypeFactoryMethod func) {
- theTypeMap::instance()->rebind(compId, func);
+ theTypeMap.rebind(compId, func);
}
void SerializationRegistry::removeType(int64_t compId) {
- theTypeMap::instance()->unbind(compId);
+ theTypeMap.unbind(compId);
}
void SerializationRegistry::addType2(TypeFactoryMethod func) {
- theTypeMap::instance()->bind2(func);
+ theTypeMap.bind2(func);
}
void SerializationRegistry::addType2(int64_t compId, TypeFactoryMethod func) {
- theTypeMap::instance()->rebind2(compId, func);
+ theTypeMap.rebind2(compId, func);
}
void SerializationRegistry::removeType2(int64_t compId) {
- theTypeMap::instance()->unbind2(compId);
+ theTypeMap.unbind2(compId);
}
-void SerializationRegistry::init() {
- // Everything here is done in the constructor for TheTypeMap...
- theTypeMap::instance();
- theTypeMap::instance()->clear();
- theTypeMap::instance()->setup();
-}
-
-PdxSerializablePtr SerializationRegistry::getPdxType(const char* className) {
+PdxSerializablePtr SerializationRegistry::getPdxType(char* className) {
TypeFactoryMethodPdx objectType = nullptr;
- theTypeMap::instance()->findPdxType(className, objectType);
+ theTypeMap.findPdxType(className, objectType);
PdxSerializablePtr pdxObj;
if (nullptr == objectType) {
try {
- pdxObj = std::make_shared<PdxWrapper>(className);
+ pdxObj =
+ std::make_shared<PdxWrapper>((const char*)className, m_pdxSerializer);
} catch (const Exception&) {
LOGERROR(
"Unregistered class %s during PDX deserialization: Did the "
@@ -488,19 +258,8 @@ PdxSerializerPtr SerializationRegistry::getPdxSerializer() {
return m_pdxSerializer;
}
-int32_t SerializationRegistry::GetPDXIdForType(const char* poolName,
- SerializablePtr pdxType) {
- PoolPtr pool = nullptr;
-
- if (poolName == nullptr) {
- for (const auto& iter : PoolManager::getAll()) {
- pool = iter.second;
- break;
- }
- } else {
- pool = PoolManager::find(poolName);
- }
-
+int32_t SerializationRegistry::GetPDXIdForType(PoolPtr pool,
+ SerializablePtr pdxType) const {
if (pool == nullptr) {
throw IllegalStateException("Pool not found, Pdx operation failed");
}
@@ -508,19 +267,8 @@ int32_t SerializationRegistry::GetPDXIdForType(const char* poolName,
return static_cast<ThinClientPoolDM*>(pool.get())->GetPDXIdForType(pdxType);
}
-SerializablePtr SerializationRegistry::GetPDXTypeById(const char* poolName,
- int32_t typeId) {
- PoolPtr pool = nullptr;
-
- if (poolName == nullptr) {
- for (const auto& iter : PoolManager::getAll()) {
- pool = iter.second;
- break;
- }
- } else {
- pool = PoolManager::find(poolName);
- }
-
+SerializablePtr SerializationRegistry::GetPDXTypeById(PoolPtr pool,
+ int32_t typeId) const {
if (pool == nullptr) {
throw IllegalStateException("Pool not found, Pdx operation failed");
}
@@ -528,16 +276,16 @@ SerializablePtr SerializationRegistry::GetPDXTypeById(const char* poolName,
return static_cast<ThinClientPoolDM*>(pool.get())->GetPDXTypeById(typeId);
}
-int32_t SerializationRegistry::GetEnumValue(SerializablePtr enumInfo) {
- PoolPtr pool = getPool();
+int32_t SerializationRegistry::GetEnumValue(PoolPtr pool,
+ SerializablePtr enumInfo) const {
if (pool == nullptr) {
throw IllegalStateException("Pool not found, Pdx operation failed");
}
return static_cast<ThinClientPoolDM*>(pool.get())->GetEnumValue(enumInfo);
}
-SerializablePtr SerializationRegistry::GetEnum(int32_t val) {
- PoolPtr pool = getPool();
+SerializablePtr SerializationRegistry::GetEnum(PoolPtr pool,
+ int32_t val) const {
if (pool == nullptr) {
throw IllegalStateException("Pool not found, Pdx operation failed");
}
@@ -545,14 +293,167 @@ SerializablePtr SerializationRegistry::GetEnum(int32_t val) {
return static_cast<ThinClientPoolDM*>(pool.get())->GetEnum(val);
}
-PoolPtr SerializationRegistry::getPool() {
- PoolPtr pool = nullptr;
- for (const auto& iter: PoolManager::getAll()) {
- pool = iter.second;
- break;
+void TheTypeMap::clear() {
+ std::lock_guard<util::concurrent::spinlock_mutex> guard(m_mapLock);
+ m_map->unbind_all();
+
+ std::lock_guard<util::concurrent::spinlock_mutex> guard2(m_map2Lock);
+ m_map2->unbind_all();
+
+ std::lock_guard<util::concurrent::spinlock_mutex> guard3(m_pdxTypemapLock);
+ m_pdxTypemap->unbind_all();
+}
+
+void TheTypeMap::find(int64_t id, TypeFactoryMethod& func) const {
+ std::lock_guard<util::concurrent::spinlock_mutex> guard(m_mapLock);
+ m_map->find(id, func);
+}
+
+void TheTypeMap::find2(int64_t id, TypeFactoryMethod& func) const {
+ std::lock_guard<util::concurrent::spinlock_mutex> guard(m_map2Lock);
+ m_map2->find(id, func);
+}
+
+void TheTypeMap::bind(TypeFactoryMethod func) {
+ Serializable* obj = func();
+ std::lock_guard<util::concurrent::spinlock_mutex> guard(m_mapLock);
+ int64_t compId = static_cast<int64_t>(obj->typeId());
+ if (compId == GeodeTypeIdsImpl::CacheableUserData ||
+ compId == GeodeTypeIdsImpl::CacheableUserData2 ||
+ compId == GeodeTypeIdsImpl::CacheableUserData4) {
+ compId |= ((static_cast<int64_t>(obj->classId())) << 32);
+ }
+ delete obj;
+ int bindRes = m_map->bind(compId, func);
+ if (bindRes == 1) {
+ LOGERROR(
+ "A class with "
+ "ID %d is already registered.",
+ compId);
+ throw IllegalStateException(
+ "A class with "
+ "given ID is already registered.");
+ } else if (bindRes == -1) {
+ LOGERROR(
+ "Unknown error "
+ "while adding class ID %d to map.",
+ compId);
+ throw IllegalStateException(
+ "Unknown error "
+ "while adding type to map.");
+ }
+}
+
+void TheTypeMap::rebind(int64_t compId, TypeFactoryMethod func) {
+ std::lock_guard<util::concurrent::spinlock_mutex> guard(m_mapLock);
+ int bindRes = m_map->rebind(compId, func);
+ if (bindRes == -1) {
+ LOGERROR(
+ "Unknown error "
+ "while adding class ID %d to map.",
+ compId);
+ throw IllegalStateException(
+ "Unknown error "
+ "while adding type to map.");
+ }
+}
+
+void TheTypeMap::unbind(int64_t compId) {
+ std::lock_guard<util::concurrent::spinlock_mutex> guard(m_mapLock);
+ m_map->unbind(compId);
+}
+
+void TheTypeMap::bind2(TypeFactoryMethod func) {
+ Serializable* obj = func();
+ std::lock_guard<util::concurrent::spinlock_mutex> guard(m_map2Lock);
+ int8_t dsfid = obj->DSFID();
+
+ int64_t compId = 0;
+ if (dsfid == GeodeTypeIdsImpl::FixedIDShort) {
+ compId = compId = static_cast<int64_t>(obj->classId());
+ } else {
+ compId = static_cast<int64_t>(obj->typeId());
+ }
+ delete obj;
+ int bindRes = m_map2->bind(compId, func);
+ if (bindRes == 1) {
+ LOGERROR(
+ "A fixed class with "
+ "ID %d is already registered.",
+ compId);
+ throw IllegalStateException(
+ "A fixed class with "
+ "given ID is already registered.");
+ } else if (bindRes == -1) {
+ LOGERROR(
+ "Unknown error "
+ "while adding class ID %d to map2.",
+ compId);
+ throw IllegalStateException(
+ "Unknown error "
+ "while adding to map2.");
}
- return pool;
}
+
+void TheTypeMap::rebind2(int64_t compId, TypeFactoryMethod func) {
+ std::lock_guard<util::concurrent::spinlock_mutex> guard(m_map2Lock);
+ m_map2->rebind(compId, func);
+}
+
+void TheTypeMap::unbind2(int64_t compId) {
+ std::lock_guard<util::concurrent::spinlock_mutex> guard(m_map2Lock);
+ m_map2->unbind(compId);
+}
+
+void TheTypeMap::bindPdxType(TypeFactoryMethodPdx func) {
+ PdxSerializable* obj = func();
+ std::lock_guard<util::concurrent::spinlock_mutex> guard(m_pdxTypemapLock);
+ const char* objFullName = obj->getClassName();
+
+ int bindRes = m_pdxTypemap->bind(objFullName, func);
+
+ delete obj;
+
+ if (bindRes == 1) {
+ LOGERROR("A object with FullName %s is already registered.", objFullName);
+ throw IllegalStateException(
+ "A Object with "
+ "given FullName is already registered.");
+ } else if (bindRes == -1) {
+ LOGERROR(
+ "Unknown error "
+ "while adding Pdx Object named %s to map.",
+ objFullName);
+ throw IllegalStateException(
+ "Unknown error "
+ "while adding type to map.");
+ }
+}
+
+void TheTypeMap::findPdxType(char* objFullName, TypeFactoryMethodPdx& func) {
+ std::lock_guard<util::concurrent::spinlock_mutex> guard(m_pdxTypemapLock);
+ m_pdxTypemap->find(objFullName, func);
+}
+
+void TheTypeMap::rebindPdxType(char* objFullName, TypeFactoryMethodPdx func) {
+ std::lock_guard<util::concurrent::spinlock_mutex> guard(m_pdxTypemapLock);
+ int bindRes = m_pdxTypemap->rebind(objFullName, func);
+ if (bindRes == -1) {
+ LOGERROR(
+ "Unknown error "
+ "while adding Pdx Object FullName %s to map.",
+ objFullName);
+ throw IllegalStateException(
+ "Unknown error "
+ "while adding type to map.");
+ }
+}
+
+void TheTypeMap::unbindPdxType(char* objFullName) {
+ std::lock_guard<util::concurrent::spinlock_mutex> guard(m_pdxTypemapLock);
+ m_pdxTypemap->unbind(objFullName);
+}
+
} // namespace client
} // namespace geode
} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/SerializationRegistry.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/SerializationRegistry.hpp b/src/cppcache/src/SerializationRegistry.hpp
index 33cc86b..9803a8a 100644
--- a/src/cppcache/src/SerializationRegistry.hpp
+++ b/src/cppcache/src/SerializationRegistry.hpp
@@ -33,6 +33,10 @@
#include <geode/ExceptionTypes.hpp>
#include <geode/Delta.hpp>
#include <string>
+#include "util/concurrent/spinlock_mutex.hpp"
+#include "NonCopyable.hpp"
+#include <geode/PdxSerializable.hpp>
+#include "MemberListForVersionStamp.hpp"
#if defined(_MACOSX)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -58,14 +62,75 @@ typedef ACE_Hash_Map_Manager<int64_t, TypeFactoryMethod, ACE_Null_Mutex>
typedef ACE_Hash_Map_Manager<std::string, TypeFactoryMethodPdx, ACE_Null_Mutex>
StrToPdxFactoryMap;
+class TheTypeMap : private NonCopyable {
+ private:
+ IdToFactoryMap* m_map;
+ IdToFactoryMap* m_map2; // to hold Fixed IDs since GFE 5.7.
+ StrToPdxFactoryMap* m_pdxTypemap;
+ mutable util::concurrent::spinlock_mutex m_mapLock;
+ mutable util::concurrent::spinlock_mutex m_map2Lock;
+ mutable util::concurrent::spinlock_mutex m_pdxTypemapLock;
+
+ public:
+ TheTypeMap() {
+ m_map = new IdToFactoryMap();
+
+ // second map to hold internal Data Serializable Fixed IDs - since GFE 5.7
+ m_map2 = new IdToFactoryMap();
+
+ // map to hold PDX types <string, funptr>.
+ m_pdxTypemap = new StrToPdxFactoryMap();
+
+ setup();
+ }
+
+ virtual ~TheTypeMap() {
+ if (m_map != nullptr) {
+ delete m_map;
+ }
+
+ if (m_map2 != nullptr) {
+ delete m_map2;
+ }
+
+ if (m_pdxTypemap != nullptr) {
+ delete m_pdxTypemap;
+ }
+ }
+
+ void setup();
+
+ void clear();
+
+ void find(int64_t id, TypeFactoryMethod& func) const;
+ void find2(int64_t id, TypeFactoryMethod& func) const;
+
+ void bind(TypeFactoryMethod func);
+
+ inline void rebind(int64_t compId, TypeFactoryMethod func);
+ inline void unbind(int64_t compId);
+ inline void bind2(TypeFactoryMethod func);
+
+ inline void rebind2(int64_t compId, TypeFactoryMethod func);
+
+ inline void unbind2(int64_t compId);
+ inline void bindPdxType(TypeFactoryMethodPdx func);
+ inline void findPdxType(char* objFullName, TypeFactoryMethodPdx& func);
+ inline void unbindPdxType(char* objFullName);
+
+ void rebindPdxType(char* objFullName, TypeFactoryMethodPdx func);
+};
+
class CPPCACHE_EXPORT SerializationRegistry {
public:
+ SerializationRegistry() : theTypeMap() {}
+
/** write the length of the serialization, write the typeId of the object,
* then write whatever the object's toData requires. The length at the
* front is backfilled after the serialization.
*/
- inline static void serialize(const Serializable* obj, DataOutput& output,
- bool isDelta = false) {
+ inline void serialize(const Serializable* obj, DataOutput& output,
+ bool isDelta = false) const {
if (obj == nullptr) {
output.write(static_cast<int8_t>(GeodeTypeIds::NullObj));
} else {
@@ -106,7 +171,7 @@ class CPPCACHE_EXPORT SerializationRegistry {
}
}
- inline static void serialize(const SerializablePtr& obj, DataOutput& output) {
+ inline void serialize(const SerializablePtr& obj, DataOutput& output) const {
serialize(obj.get(), output);
}
@@ -114,45 +179,44 @@ class CPPCACHE_EXPORT SerializationRegistry {
* Read the length, typeid, and run the objs fromData. Returns the New
* object.
*/
- static SerializablePtr deserialize(DataInput& input, int8_t typeId = -1);
-
- static void addType(TypeFactoryMethod func);
+ SerializablePtr deserialize(DataInput& input, int8_t typeId = -1) const;
- static void addType(int64_t compId, TypeFactoryMethod func);
+ void addType(TypeFactoryMethod func);
- static void addPdxType(TypeFactoryMethodPdx func);
+ void addType(int64_t compId, TypeFactoryMethod func);
- static void setPdxSerializer(PdxSerializerPtr pdxSerializer);
+ void addPdxType(TypeFactoryMethodPdx func);
- static PdxSerializerPtr getPdxSerializer();
+ void setPdxSerializer(PdxSerializerPtr pdxSerializer);
- static void removeType(int64_t compId);
+ PdxSerializerPtr getPdxSerializer();
- static void init();
+ void removeType(int64_t compId);
// following for internal types with Data Serializable Fixed IDs - since GFE
// 5.7
- static void addType2(TypeFactoryMethod func);
+ void addType2(TypeFactoryMethod func);
- static void addType2(int64_t compId, TypeFactoryMethod func);
+ void addType2(int64_t compId, TypeFactoryMethod func);
- static void removeType2(int64_t compId);
+ void removeType2(int64_t compId);
- static int32_t GetPDXIdForType(const char* poolName, SerializablePtr pdxType);
+ int32_t GetPDXIdForType(PoolPtr pool, SerializablePtr pdxType) const;
- static SerializablePtr GetPDXTypeById(const char* poolName, int32_t typeId);
+ SerializablePtr GetPDXTypeById(PoolPtr pool, int32_t typeId) const;
- static int32_t GetEnumValue(SerializablePtr enumInfo);
- static SerializablePtr GetEnum(int32_t val);
+ int32_t GetEnumValue(PoolPtr pool, SerializablePtr enumInfo) const;
+ SerializablePtr GetEnum(PoolPtr pool, int32_t val) const;
- static PdxSerializablePtr getPdxType(const char* className);
+ PdxSerializablePtr getPdxType(char* className);
private:
- static PoolPtr getPool();
- static IdToFactoryMap* s_typeMap;
- static PdxSerializerPtr m_pdxSerializer;
+ PdxSerializerPtr m_pdxSerializer;
+ TheTypeMap theTypeMap;
};
+
+typedef std::shared_ptr<SerializationRegistry> SerializationRegistryPtr;
} // namespace client
} // namespace geode
} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/TXCommitMessage.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TXCommitMessage.cpp b/src/cppcache/src/TXCommitMessage.cpp
index 211450f..933d980 100644
--- a/src/cppcache/src/TXCommitMessage.cpp
+++ b/src/cppcache/src/TXCommitMessage.cpp
@@ -33,7 +33,7 @@ namespace apache {
namespace geode {
namespace client {
-TXCommitMessage::TXCommitMessage()
+TXCommitMessage::TXCommitMessage(MemberListForVersionStamp & memberListForVersionStamp) : m_memberListForVersionStamp(memberListForVersionStamp)
// UNUSED : m_processorId(0)
{}
@@ -88,7 +88,7 @@ m_processorId = -1;
int32_t regionSize;
input.readInt(®ionSize);
for (int32_t i = 0; i < regionSize; i++) {
- auto rc = std::make_shared<RegionCommit>();
+ auto rc = std::make_shared<RegionCommit>(m_memberListForVersionStamp);
rc->fromData(input);
m_regions.push_back(rc);
}
@@ -159,7 +159,7 @@ int8_t TXCommitMessage::typeId() const {
return static_cast<int8_t>(GeodeTypeIdsImpl::TXCommitMessage);
}
-Serializable* TXCommitMessage::create() { return new TXCommitMessage(); }
+Serializable* TXCommitMessage::create(MemberListForVersionStamp & memberListForVersionStamp) { return new TXCommitMessage(memberListForVersionStamp); }
void TXCommitMessage::apply(Cache* cache) {
for (std::vector<RegionCommitPtr>::iterator iter = m_regions.begin();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/TXCommitMessage.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TXCommitMessage.hpp b/src/cppcache/src/TXCommitMessage.hpp
index eb1b89b..09bc702 100644
--- a/src/cppcache/src/TXCommitMessage.hpp
+++ b/src/cppcache/src/TXCommitMessage.hpp
@@ -32,14 +32,14 @@ _GF_PTR_DEF_(TXCommitMessage, TXCommitMessagePtr);
class TXCommitMessage : public apache::geode::client::Cacheable {
public:
- TXCommitMessage();
+ TXCommitMessage(MemberListForVersionStamp & memberListForVersionStamp);
virtual ~TXCommitMessage();
virtual Serializable* fromData(DataInput& input);
virtual void toData(DataOutput& output) const;
virtual int32_t classId() const;
int8_t typeId() const;
- static Serializable* create();
+ static Serializable* create(MemberListForVersionStamp & memberListForVersionStamp);
// VectorOfEntryEvent getEvents(Cache* cache);
void apply(Cache* cache);
@@ -47,7 +47,7 @@ class TXCommitMessage : public apache::geode::client::Cacheable {
private:
// UNUSED int32_t m_processorId;
bool isAckRequired();
-
+ MemberListForVersionStamp & m_memberListForVersionStamp;
std::vector<RegionCommitPtr> m_regions;
};
} // namespace client
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/TcpConn.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TcpConn.cpp b/src/cppcache/src/TcpConn.cpp
index b80aa51..581d267 100644
--- a/src/cppcache/src/TcpConn.cpp
+++ b/src/cppcache/src/TcpConn.cpp
@@ -27,11 +27,9 @@
#include <ace/SOCK_Connector.h>
#include <ace/SOCK_Acceptor.h>
#include <ace/OS.h>
-
+#include "CacheImpl.hpp"
using namespace apache::geode::client;
-int TcpConn::m_chunkSize = TcpConn::setChunkSize();
-
void TcpConn::clearNagle(ACE_SOCKET sock) {
int32_t val = 1;
#ifdef WIN32
@@ -60,19 +58,10 @@ int32_t TcpConn::maxSize(ACE_SOCKET sock, int32_t flag, int32_t size) {
socklen_t plen = sizeof(val);
socklen_t clen = sizeof(val);
- static int32_t max = 32000;
- if (m_maxBuffSizePool <= 0) {
- SystemProperties *props = DistributedSystem::getSystemProperties();
- if (props != nullptr) {
- max = props->maxSocketBufferSize();
- }
- } else {
- max = m_maxBuffSizePool;
- }
int32_t inc = 32120;
val = size - (3 * inc);
if (val < 0) val = 0;
- if (size == 0) size = max;
+ if (size == 0) size = m_maxBuffSizePool;
int32_t red = 0;
int32_t lastRed = -1;
while (lastRed != red) {
@@ -92,7 +81,7 @@ int32_t TcpConn::maxSize(ACE_SOCKET sock, int32_t flag, int32_t size) {
#ifdef _LINUX
val /= 2;
#endif
- if ((val >= max) || (val >= size)) continue;
+ if ((val >= m_maxBuffSizePool) || (val >= size)) continue;
red = val;
}
return val;
@@ -105,17 +94,7 @@ void TcpConn::createSocket(ACE_SOCKET sock) {
}
void TcpConn::init() {
- /* adongre
- * CID 28736: Improper use of negative value (NEGATIVE_RETURNS)
- * Function "socket(2, 1, 0)" returns a negative number.
- * Assigning: unsigned variable "sock" = "socket".
- *
- * CID 28737: Unsigned compared against 0 (NO_EFFECT)
- * This less-than-zero comparison of an unsigned value is never true. "sock <
- * 0U".
- */
ACE_SOCKET sock = socket(AF_INET, SOCK_STREAM, 0);
- // if ( sock < 0 ) {
if (sock == -1) {
int32_t lastError = ACE_OS::last_error();
LOGERROR("Failed to create socket. Errno: %d: %s", lastError,
@@ -128,19 +107,19 @@ void TcpConn::init() {
clearNagle(sock);
- static int32_t readSize = 0;
- static int32_t writeSize = 0;
+ int32_t readSize = 0;
+ int32_t writeSize = 0;
int32_t originalReadSize = readSize;
readSize = maxSize(sock, SO_SNDBUF, readSize);
if (originalReadSize != readSize) {
// This should get logged once at startup and again only if it changes
- LOGINFO("Using socket send buffer size of %d.", readSize);
+ LOGFINEST("Using socket send buffer size of %d.", readSize);
}
int32_t originalWriteSize = writeSize;
writeSize = maxSize(sock, SO_RCVBUF, writeSize);
if (originalWriteSize != writeSize) {
// This should get logged once at startup and again only if it changes
- LOGINFO("Using socket receive buffer size of %d.", writeSize);
+ LOGFINEST("Using socket receive buffer size of %d.", writeSize);
}
createSocket(sock);
@@ -148,21 +127,21 @@ void TcpConn::init() {
connect();
}
-TcpConn::TcpConn() : m_io(nullptr), m_waitSeconds(0), m_maxBuffSizePool(0) {}
-
TcpConn::TcpConn(const char *ipaddr, uint32_t waitSeconds,
int32_t maxBuffSizePool)
: m_io(nullptr),
m_addr(ipaddr),
- m_waitSeconds(waitSeconds),
- m_maxBuffSizePool(maxBuffSizePool) {}
+ m_waitMilliSeconds(waitSeconds * 1000),
+ m_maxBuffSizePool(maxBuffSizePool),
+ m_chunkSize(getDefaultChunkSize()) {}
TcpConn::TcpConn(const char *hostname, int32_t port, uint32_t waitSeconds,
int32_t maxBuffSizePool)
: m_io(nullptr),
m_addr(port, hostname),
- m_waitSeconds(waitSeconds),
- m_maxBuffSizePool(maxBuffSizePool) {}
+ m_waitMilliSeconds(waitSeconds * 1000),
+ m_maxBuffSizePool(maxBuffSizePool),
+ m_chunkSize(getDefaultChunkSize()) {}
void TcpConn::listen(const char *hostname, int32_t port, uint32_t waitSeconds) {
ACE_INET_Addr addr(port, hostname);
@@ -216,14 +195,14 @@ void TcpConn::connect(const char *hostname, int32_t port,
uint32_t waitSeconds) {
ACE_INET_Addr addr(port, hostname);
m_addr = addr;
- m_waitSeconds = waitSeconds;
+ m_waitMilliSeconds = waitSeconds;
connect();
}
void TcpConn::connect(const char *ipaddr, uint32_t waitSeconds) {
ACE_INET_Addr addr(ipaddr);
m_addr = addr;
- m_waitSeconds = waitSeconds;
+ m_waitMilliSeconds = waitSeconds;
connect();
}
@@ -231,25 +210,18 @@ void TcpConn::connect() {
GF_DEV_ASSERT(m_io != nullptr);
ACE_INET_Addr ipaddr = m_addr;
- uint32_t waitSeconds = m_waitSeconds;
+ uint32_t waitMicroSeconds = m_waitMilliSeconds * 1000;
ACE_OS::signal(SIGPIPE, SIG_IGN); // Ignore broken pipe
- // passing waittime as microseconds
- if (DistributedSystem::getSystemProperties()->readTimeoutUnitInMillis()) {
- waitSeconds = waitSeconds * 1000;
- } else {
- waitSeconds = waitSeconds * (1000 * 1000);
- }
-
LOGFINER("Connecting plain socket stream to %s:%d waiting %d micro sec",
- ipaddr.get_host_name(), ipaddr.get_port_number(), waitSeconds);
+ ipaddr.get_host_name(), ipaddr.get_port_number(), waitMicroSeconds);
ACE_SOCK_Connector conn;
int32_t retVal = 0;
- if (waitSeconds > 0) {
+ if (waitMicroSeconds > 0) {
// passing waittime as microseconds
- ACE_Time_Value wtime(0, waitSeconds);
+ ACE_Time_Value wtime(0, waitMicroSeconds);
retVal = conn.connect(*m_io, ipaddr, &wtime);
} else {
retVal = conn.connect(*m_io, ipaddr);
@@ -258,10 +230,10 @@ void TcpConn::connect() {
char msg[256];
int32_t lastError = ACE_OS::last_error();
if (lastError == ETIME || lastError == ETIMEDOUT) {
- ACE_OS::snprintf(
- msg, 256,
- "TcpConn::connect Attempt to connect timed out after %d seconds.",
- waitSeconds);
+ ACE_OS::snprintf(msg, 256,
+ "TcpConn::connect Attempt to connect timed out after %d "
+ "microseconds.",
+ waitMicroSeconds);
// this is only called by constructor, so we must delete m_io
GF_SAFE_DELETE(m_io);
throw TimeoutException(msg);
@@ -269,7 +241,7 @@ void TcpConn::connect() {
ACE_OS::snprintf(msg, 256, "TcpConn::connect failed with errno: %d: %s",
lastError, ACE_OS::strerror(lastError));
// this is only called by constructor, so we must delete m_io
- close();
+ close();
throw GeodeIOException(msg);
}
int rc = this->m_io->enable(ACE_NONBLOCK);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/TcpConn.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TcpConn.hpp b/src/cppcache/src/TcpConn.hpp
index 60ee0a9..13964d4 100644
--- a/src/cppcache/src/TcpConn.hpp
+++ b/src/cppcache/src/TcpConn.hpp
@@ -50,7 +50,7 @@ class CPPCACHE_EXPORT TcpConn : public Connector {
protected:
ACE_INET_Addr m_addr;
- uint32_t m_waitSeconds;
+ uint32_t m_waitMilliSeconds;
int32_t m_maxBuffSizePool;
@@ -65,9 +65,9 @@ class CPPCACHE_EXPORT TcpConn : public Connector {
virtual void createSocket(ACE_SOCKET sock);
public:
- static int m_chunkSize;
+ int m_chunkSize;
- static int setChunkSize() {
+ static int getDefaultChunkSize() {
// Attempt to set chunk size to nearest OS page size
// for perf improvement
int pageSize = ACE_OS::getpagesize();
@@ -80,12 +80,9 @@ class CPPCACHE_EXPORT TcpConn : public Connector {
return 16000000;
}
- TcpConn();
- TcpConn(const char* hostname, int32_t port,
- uint32_t waitSeconds = DEFAULT_CONNECT_TIMEOUT,
- int32_t maxBuffSizePool = 0);
- TcpConn(const char* ipaddr, uint32_t waitSeconds = DEFAULT_CONNECT_TIMEOUT,
- int32_t maxBuffSizePool = 0);
+ TcpConn(const char* hostname, int32_t port, uint32_t waitSeconds,
+ int32_t maxBuffSizePool);
+ TcpConn(const char* ipaddr, uint32_t waitSeconds, int32_t maxBuffSizePool);
virtual ~TcpConn() { close(); }
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/TcpSslConn.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TcpSslConn.cpp b/src/cppcache/src/TcpSslConn.cpp
index 3f4935f..74b999d 100644
--- a/src/cppcache/src/TcpSslConn.cpp
+++ b/src/cppcache/src/TcpSslConn.cpp
@@ -19,7 +19,7 @@
#include <geode/SystemProperties.hpp>
#include <geode/DistributedSystem.hpp>
#include "../../cryptoimpl/Ssl.hpp"
-
+#include "CacheImpl.hpp"
using namespace apache::geode::client;
Ssl* TcpSslConn::getSSLImpl(ACE_SOCKET sock, const char* pubkeyfile,
@@ -42,20 +42,13 @@ Ssl* TcpSslConn::getSSLImpl(ACE_SOCKET sock, const char* pubkeyfile,
LOGERROR(msg);
throw IllegalStateException(msg);
}
- // adongre: Added for Ticket #758
- const char* pemPassword =
- DistributedSystem::getSystemProperties()->sslKeystorePassword();
-
return reinterpret_cast<Ssl*>(
- func(sock, pubkeyfile, privkeyfile, pemPassword));
+ func(sock, pubkeyfile, privkeyfile, m_pemPassword));
}
void TcpSslConn::createSocket(ACE_SOCKET sock) {
- SystemProperties* props = DistributedSystem::getSystemProperties();
- const char* pubkeyfile = props->sslTrustStore();
- const char* privkeyfile = props->sslKeyStore();
LOGDEBUG("Creating SSL socket stream");
- m_ssl = getSSLImpl(sock, pubkeyfile, privkeyfile);
+ m_ssl = getSSLImpl(sock, m_pubkeyfile, m_privkeyfile);
}
void TcpSslConn::listen(ACE_INET_Addr addr, uint32_t waitSeconds) {
@@ -101,28 +94,21 @@ void TcpSslConn::connect() {
// m_ssl->init();
- uint32_t waitSeconds = m_waitSeconds;
-
- // passing waittime as microseconds
- if (DistributedSystem::getSystemProperties()->readTimeoutUnitInMillis()) {
- waitSeconds = waitSeconds * 1000;
- } else {
- waitSeconds = waitSeconds * (1000 * 1000);
- }
+ uint32_t waitMicroSeconds = m_waitMilliSeconds * 1000;
- LOGDEBUG("Connecting SSL socket stream to %s:%d waiting %d sec",
- m_addr.get_host_name(), m_addr.get_port_number(), m_waitSeconds);
+ LOGDEBUG("Connecting SSL socket stream to %s:%d waiting %d micro sec",
+ m_addr.get_host_name(), m_addr.get_port_number(), waitMicroSeconds);
- int32_t retVal = m_ssl->connect(m_addr, waitSeconds);
+ int32_t retVal = m_ssl->connect(m_addr, waitMicroSeconds);
if (retVal == -1) {
char msg[256];
int32_t lastError = ACE_OS::last_error();
if (lastError == ETIME || lastError == ETIMEDOUT) {
- ACE_OS::snprintf(
- msg, 256,
- "TcpSslConn::connect Attempt to connect timed out after %d seconds.",
- m_waitSeconds);
+ ACE_OS::snprintf(msg, 256,
+ "TcpSslConn::connect Attempt to connect timed out after "
+ "%d micro-seconds.",
+ waitMicroSeconds);
// this is only called by constructor, so we must delete m_ssl
GF_SAFE_DELETE(m_ssl);
throw TimeoutException(msg);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/TcpSslConn.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TcpSslConn.hpp b/src/cppcache/src/TcpSslConn.hpp
index 387a95c..1ebf3db 100644
--- a/src/cppcache/src/TcpSslConn.hpp
+++ b/src/cppcache/src/TcpSslConn.hpp
@@ -32,6 +32,9 @@ class TcpSslConn : public TcpConn {
private:
Ssl* m_ssl;
ACE_DLL m_dll;
+ const char* m_pubkeyfile;
+ const char* m_privkeyfile;
+ const char* m_pemPassword;
// adongre: Added for Ticket #758
// Pass extra parameter for the password
typedef void* (*gf_create_SslImpl)(ACE_SOCKET, const char*, const char*,
@@ -47,16 +50,23 @@ class TcpSslConn : public TcpConn {
void createSocket(ACE_SOCKET sock);
public:
- TcpSslConn() : TcpConn(), m_ssl(nullptr){};
-
- TcpSslConn(const char* hostname, int32_t port,
- uint32_t waitSeconds = DEFAULT_CONNECT_TIMEOUT,
- int32_t maxBuffSizePool = 0)
- : TcpConn(hostname, port, waitSeconds, maxBuffSizePool), m_ssl(nullptr){};
-
- TcpSslConn(const char* ipaddr, uint32_t waitSeconds = DEFAULT_CONNECT_TIMEOUT,
- int32_t maxBuffSizePool = 0)
- : TcpConn(ipaddr, waitSeconds, maxBuffSizePool), m_ssl(nullptr){};
+ TcpSslConn(const char* hostname, int32_t port, uint32_t waitSeconds,
+ int32_t maxBuffSizePool, const char* pubkeyfile,
+ const char* privkeyfile, const char* pemPassword)
+ : TcpConn(hostname, port, waitSeconds, maxBuffSizePool),
+ m_ssl(nullptr),
+ m_pubkeyfile(pubkeyfile),
+ m_privkeyfile(privkeyfile),
+ m_pemPassword(pemPassword){};
+
+ TcpSslConn(const char* ipaddr, uint32_t waitSeconds, int32_t maxBuffSizePool,
+ const char* pubkeyfile, const char* privkeyfile,
+ const char* pemPassword)
+ : TcpConn(ipaddr, waitSeconds, maxBuffSizePool),
+ m_ssl(nullptr),
+ m_pubkeyfile(pubkeyfile),
+ m_privkeyfile(privkeyfile),
+ m_pemPassword(pemPassword){};
// TODO: Watch out for virt dtor calling virt methods!
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/TcrChunkedContext.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TcrChunkedContext.hpp b/src/cppcache/src/TcrChunkedContext.hpp
index c07c22c..068bb09 100644
--- a/src/cppcache/src/TcrChunkedContext.hpp
+++ b/src/cppcache/src/TcrChunkedContext.hpp
@@ -53,7 +53,8 @@ class TcrChunkedResult {
/** handle a chunk of response message from server */
virtual void handleChunk(const uint8_t* bytes, int32_t len,
- uint8_t isLastChunkWithSecurity) = 0;
+ uint8_t isLastChunkWithSecurity,
+ const Cache* cache) = 0;
public:
inline TcrChunkedResult()
@@ -75,13 +76,14 @@ class TcrChunkedResult {
virtual void reset() = 0;
void fireHandleChunk(const uint8_t* bytes, int32_t len,
- uint8_t isLastChunkWithSecurity) {
+ uint8_t isLastChunkWithSecurity, const Cache* cache) {
if (appDomainContext) {
- appDomainContext->run([this, bytes, len, isLastChunkWithSecurity]() {
- handleChunk(bytes, len, isLastChunkWithSecurity);
- });
+ appDomainContext->run(
+ [this, bytes, len, isLastChunkWithSecurity, &cache]() {
+ handleChunk(bytes, len, isLastChunkWithSecurity, cache);
+ });
} else {
- handleChunk(bytes, len, isLastChunkWithSecurity);
+ handleChunk(bytes, len, isLastChunkWithSecurity, cache);
}
}
@@ -135,15 +137,17 @@ class TcrChunkedContext {
const uint8_t* m_bytes;
const int32_t m_len;
const uint8_t m_isLastChunkWithSecurity;
+ const Cache* m_cache;
TcrChunkedResult* m_result;
public:
inline TcrChunkedContext(const uint8_t* bytes, int32_t len,
TcrChunkedResult* result,
- uint8_t isLastChunkWithSecurity)
+ uint8_t isLastChunkWithSecurity, const Cache* cache)
: m_bytes(bytes),
m_len(len),
m_isLastChunkWithSecurity(isLastChunkWithSecurity),
+ m_cache(cache),
m_result(result) {}
inline ~TcrChunkedContext() { GF_SAFE_DELETE_ARRAY(m_bytes); }
@@ -158,7 +162,8 @@ class TcrChunkedContext {
m_result->finalize(inSameThread);
} else if (!m_result->exceptionOccurred()) {
try {
- m_result->fireHandleChunk(m_bytes, m_len, m_isLastChunkWithSecurity);
+ m_result->fireHandleChunk(m_bytes, m_len, m_isLastChunkWithSecurity,
+ m_cache);
} catch (Exception& ex) {
LOGERROR("HandleChunk error message %s, name = %s", ex.getMessage(),
ex.getName());
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/TcrConnection.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TcrConnection.cpp b/src/cppcache/src/TcrConnection.cpp
index f11db0c..dafaed2 100644
--- a/src/cppcache/src/TcrConnection.cpp
+++ b/src/cppcache/src/TcrConnection.cpp
@@ -62,6 +62,9 @@ bool TcrConnection::InitTcrConnection(
m_creationTime = ACE_OS::gettimeofday();
connectionId = INITIAL_CONNECTION_ID;
m_lastAccessed = ACE_OS::gettimeofday();
+ const auto& distributedSystem =
+ m_poolDM->getConnectionManager().getCacheImpl()->getDistributedSystem();
+ const auto& sysProp = distributedSystem.getSystemProperties();
LOGDEBUG(
"Tcrconnection const isSecondary = %d and isClientNotification = %d, "
@@ -77,8 +80,6 @@ bool TcrConnection::InitTcrConnection(
GF_DEV_ASSERT(!isSecondary || isClientNotification);
- DistributedSystemPtr dsys = DistributedSystem::getInstance();
-
// Create TcpConn object which manages a socket connection with the endpoint.
if (endpointObj && endpointObj->getPoolHADM()) {
m_conn = createConnection(
@@ -87,33 +88,34 @@ bool TcrConnection::InitTcrConnection(
endpointObj->getPoolHADM()->getSocketBufferSize()));
isPool = true;
} else {
- m_conn = createConnection(m_endpoint, connectTimeout, 0);
+ m_conn = createConnection(m_endpoint, connectTimeout,
+ sysProp.maxSocketBufferSize());
}
GF_DEV_ASSERT(m_conn != nullptr);
- DataOutput handShakeMsg;
+ auto handShakeMsg = m_poolDM->getConnectionManager().getCacheImpl()->getCache()->createDataOutput();
bool isNotificationChannel = false;
// Send byte Acceptor.CLIENT_TO_SERVER = (byte) 100;
// Send byte Acceptor.SERVER_TO_CLIENT = (byte) 101;
if (isClientNotification) {
isNotificationChannel = true;
if (isSecondary) {
- handShakeMsg.write(static_cast<int8_t>(SECONDARY_SERVER_TO_CLIENT));
+ handShakeMsg->write(static_cast<int8_t>(SECONDARY_SERVER_TO_CLIENT));
} else {
- handShakeMsg.write(static_cast<int8_t>(PRIMARY_SERVER_TO_CLIENT));
+ handShakeMsg->write(static_cast<int8_t>(PRIMARY_SERVER_TO_CLIENT));
}
} else {
- handShakeMsg.write(static_cast<int8_t>(CLIENT_TO_SERVER));
+ handShakeMsg->write(static_cast<int8_t>(CLIENT_TO_SERVER));
}
// added for versioned client
int8_t versionOrdinal = Version::getOrdinal();
- handShakeMsg.write(versionOrdinal);
+ handShakeMsg->write(versionOrdinal);
LOGFINE("Client version ordinal is %d", versionOrdinal);
- handShakeMsg.write(static_cast<int8_t>(REPLY_OK));
+ handShakeMsg->write(static_cast<int8_t>(REPLY_OK));
// Send byte REPLY_OK = (byte)58;
if (!isClientNotification) {
@@ -122,9 +124,9 @@ bool TcrConnection::InitTcrConnection(
} else {
// add the local ports to message
Set<uint16_t>::Iterator iter = ports.iterator();
- handShakeMsg.writeInt(static_cast<int32_t>(ports.size()));
+ handShakeMsg->writeInt(static_cast<int32_t>(ports.size()));
while (iter.hasNext()) {
- handShakeMsg.writeInt(static_cast<int32_t>(iter.next()));
+ handShakeMsg->writeInt(static_cast<int32_t>(iter.next()));
}
}
@@ -134,21 +136,21 @@ bool TcrConnection::InitTcrConnection(
// permissible value for bug #232 for now.
// minus 10 sec because the GFE 5.7 gridDev branch adds a
// 5 sec buffer which was causing an int overflow.
- handShakeMsg.writeInt((int32_t)0x7fffffff - 10000);
+ handShakeMsg->writeInt((int32_t)0x7fffffff - 10000);
}
// Write header for byte FixedID since GFE 5.7
- handShakeMsg.write(static_cast<int8_t>(GeodeTypeIdsImpl::FixedIDByte));
+ handShakeMsg->write(static_cast<int8_t>(GeodeTypeIdsImpl::FixedIDByte));
// Writing byte for ClientProxyMembershipID class id=38 as registered on the
// java server.
- handShakeMsg.write(
+ handShakeMsg->write(
static_cast<int8_t>(GeodeTypeIdsImpl::ClientProxyMembershipId));
if (endpointObj->getPoolHADM()) {
ClientProxyMembershipID* memId =
endpointObj->getPoolHADM()->getMembershipId();
uint32_t memIdBufferLength;
const char* memIdBuffer = memId->getDSMemberId(memIdBufferLength);
- handShakeMsg.writeBytes((int8_t*)memIdBuffer, memIdBufferLength);
+ handShakeMsg->writeBytes((int8_t*)memIdBuffer, memIdBufferLength);
} else {
ACE_TCHAR hostName[256];
ACE_OS::hostname(hostName, sizeof(hostName) - 1);
@@ -158,42 +160,37 @@ bool TcrConnection::InitTcrConnection(
uint16_t hostPort = 0;
// Add 3 durable Subcription properties to ClientProxyMembershipID
- SystemProperties* sysProp = DistributedSystem::getSystemProperties();
- const char* durableId =
- (sysProp != nullptr) ? sysProp->durableClientId() : nullptr;
- const uint32_t durableTimeOut =
- (sysProp != nullptr) ? sysProp->durableTimeout() : 0;
+ const char* durableId = sysProp.durableClientId();
+ const uint32_t durableTimeOut = sysProp.durableTimeout();
// Write ClientProxyMembershipID serialized object.
uint32_t memIdBufferLength;
- ClientProxyMembershipID memId(hostName, hostAddr, hostPort, durableId,
- durableTimeOut);
- const char* memIdBuffer = memId.getDSMemberId(memIdBufferLength);
- handShakeMsg.writeBytes((int8_t*)memIdBuffer, memIdBufferLength);
+ const auto memId =
+ m_connectionManager->getCacheImpl()
+ ->getClientProxyMembershipIDFactory()
+ .create(hostName, hostAddr, hostPort, durableId, durableTimeOut);
+ const auto memIdBuffer = memId->getDSMemberId(memIdBufferLength);
+ handShakeMsg->writeBytes((int8_t*)memIdBuffer, memIdBufferLength);
}
- handShakeMsg.writeInt((int32_t)1);
+ handShakeMsg->writeInt((int32_t)1);
bool isDhOn = false;
bool requireServerAuth = false;
PropertiesPtr credentials;
CacheableBytesPtr serverChallenge;
- SystemProperties* tmpSystemProperties =
- DistributedSystem::getSystemProperties();
-
// Write overrides (just conflation for now)
- handShakeMsg.write(getOverrides(tmpSystemProperties));
+ handShakeMsg->write(getOverrides(&sysProp));
- bool tmpIsSecurityOn = tmpSystemProperties->isSecurityOn();
- isDhOn = tmpSystemProperties->isDhOn();
+ bool tmpIsSecurityOn = sysProp.isSecurityOn();
+ isDhOn = sysProp.isDhOn();
if (m_endpointObj) {
- tmpIsSecurityOn = tmpSystemProperties->isSecurityOn() ||
- this->m_endpointObj->isMultiUserMode();
+ tmpIsSecurityOn =
+ sysProp.isSecurityOn() || this->m_endpointObj->isMultiUserMode();
CacheableStringPtr dhalgo =
- tmpSystemProperties->getSecurityProperties()->find(
- "security-client-dhalgo");
+ sysProp.getSecurityProperties()->find("security-client-dhalgo");
LOGDEBUG("TcrConnection this->m_endpointObj->isMultiUserMode() = %d ",
this->m_endpointObj->isMultiUserMode());
@@ -205,7 +202,7 @@ bool TcrConnection::InitTcrConnection(
LOGDEBUG(
"TcrConnection algo name %s tmpIsSecurityOn = %d isDhOn = %d "
"isNotificationChannel = %d ",
- tmpSystemProperties->securityClientDhAlgo(), tmpIsSecurityOn, isDhOn,
+ sysProp.securityClientDhAlgo(), tmpIsSecurityOn, isDhOn,
isNotificationChannel);
bool doIneedToSendCreds = true;
if (isNotificationChannel && m_endpointObj &&
@@ -216,48 +213,35 @@ bool TcrConnection::InitTcrConnection(
}
if (isNotificationChannel && !doIneedToSendCreds) {
- handShakeMsg.write(
+ handShakeMsg->write(
static_cast<uint8_t>(SECURITY_MULTIUSER_NOTIFICATIONCHANNEL));
} else if (isDhOn) {
m_dh = new DiffieHellman();
- m_dh->initDhKeys(tmpSystemProperties->getSecurityProperties());
- handShakeMsg.write(static_cast<uint8_t>(SECURITY_CREDENTIALS_DHENCRYPT));
+ m_dh->initDhKeys(sysProp.getSecurityProperties());
+ handShakeMsg->write(static_cast<uint8_t>(SECURITY_CREDENTIALS_DHENCRYPT));
} else if (tmpIsSecurityOn) {
- handShakeMsg.write(static_cast<uint8_t>(SECURITY_CREDENTIALS_NORMAL));
+ handShakeMsg->write(static_cast<uint8_t>(SECURITY_CREDENTIALS_NORMAL));
} else {
- handShakeMsg.write(static_cast<uint8_t>(SECURITY_CREDENTIALS_NONE));
+ handShakeMsg->write(static_cast<uint8_t>(SECURITY_CREDENTIALS_NONE));
}
if (tmpIsSecurityOn) {
try {
LOGFINER("TcrConnection: about to invoke authloader");
- PropertiesPtr tmpSecurityProperties =
- tmpSystemProperties->getSecurityProperties();
+ const auto& tmpSecurityProperties = sysProp.getSecurityProperties();
if (tmpSecurityProperties == nullptr) {
LOGWARN("TcrConnection: security properties not found.");
}
- // AuthInitializePtr authInitialize =
- // tmpSystemProperties->getAuthLoader();
- //:only for backward connection
+ // only for backward connection
if (isClientNotification) {
- AuthInitializePtr authInitialize =
- DistributedSystem::m_impl->getAuthLoader();
- if (authInitialize != nullptr) {
+ if (const auto& authInitialize =
+ distributedSystem.m_impl->getAuthLoader()) {
LOGFINER(
"TcrConnection: acquired handle to authLoader, "
"invoking getCredentials");
- /* adongre
- * CID 28898: Copy into fixed size buffer (STRING_OVERFLOW)
- * You might overrun the 100 byte fixed-size string "tmpEndpoint" by
- * copying "this->m_endpoint" without checking the length.
- * Note: This defect has an elevated risk because the source argument
- * is a parameter of the current function.
- */
- // char tmpEndpoint[100] = { '\0' } ;
- // strcpy(tmpEndpoint, m_endpoint);
- PropertiesPtr tmpAuthIniSecurityProperties =
- authInitialize->getCredentials(tmpSecurityProperties,
- /*tmpEndpoint*/ m_endpoint);
+
+ const auto& tmpAuthIniSecurityProperties =
+ authInitialize->getCredentials(tmpSecurityProperties, m_endpoint);
LOGFINER("TcrConnection: after getCredentials ");
credentials = tmpAuthIniSecurityProperties;
}
@@ -267,20 +251,20 @@ bool TcrConnection::InitTcrConnection(
CacheableStringPtr ksPath =
tmpSecurityProperties->find("security-client-kspath");
requireServerAuth = (ksPath != nullptr && ksPath->length() > 0);
- handShakeMsg.writeBoolean(requireServerAuth);
+ handShakeMsg->writeBoolean(requireServerAuth);
LOGFINE(
"HandShake: Server authentication using RSA signature %s required",
requireServerAuth ? "is" : "not");
// Send the symmetric key algorithm name string
- handShakeMsg.write(static_cast<int8_t>(GeodeTypeIds::CacheableString));
- handShakeMsg.writeASCII(tmpSystemProperties->securityClientDhAlgo());
+ handShakeMsg->write(static_cast<int8_t>(GeodeTypeIds::CacheableString));
+ handShakeMsg->writeASCII(sysProp.securityClientDhAlgo());
// Send the client's DH public key to the server
// CacheableBytesPtr dhPubKey = DiffieHellman::getPublicKey();
CacheableBytesPtr dhPubKey = m_dh->getPublicKey();
LOGDEBUG("DH pubkey send len is %d", dhPubKey->length());
- dhPubKey->toData(handShakeMsg);
+ dhPubKey->toData(*handShakeMsg);
if (requireServerAuth) {
char serverChallengeBytes[64] = {0};
@@ -290,11 +274,11 @@ bool TcrConnection::InitTcrConnection(
}
serverChallenge = CacheableBytes::create(
reinterpret_cast<const uint8_t*>(serverChallengeBytes), 64);
- serverChallenge->toData(handShakeMsg);
+ serverChallenge->toData(*handShakeMsg);
}
} else { // if isDhOn
if (isClientNotification) { //:only for backward connection
- credentials->toData(handShakeMsg);
+ credentials->toData(*handShakeMsg);
}
} // else isDhOn
} catch (const AuthenticationRequiredException&) {
@@ -314,7 +298,7 @@ bool TcrConnection::InitTcrConnection(
}
uint32_t msgLengh;
- char* data = (char*)handShakeMsg.getBuffer(&msgLengh);
+ char* data = (char*)handShakeMsg->getBuffer(&msgLengh);
LOGFINE("Attempting handshake with endpoint %s for %s%s connection", endpoint,
isClientNotification ? (isSecondary ? "secondary " : "primary ") : "",
isClientNotification ? "subscription" : "client");
@@ -325,8 +309,7 @@ bool TcrConnection::InitTcrConnection(
LOGDEBUG(" Handshake: Got Accept Code %d", (*acceptanceCode)[0]);
/* adongre */
- if ((*acceptanceCode)[0] == REPLY_SSL_ENABLED &&
- !tmpSystemProperties->sslEnabled()) {
+ if ((*acceptanceCode)[0] == REPLY_SSL_ENABLED && !sysProp.sslEnabled()) {
LOGERROR("SSL is enabled on server, enable SSL in client as well");
AuthenticationRequiredException ex(
"SSL is enabled on server, enable SSL in client as well");
@@ -370,18 +353,18 @@ bool TcrConnection::InitTcrConnection(
LOGDEBUG("Handshake: Got challengeSize %d", challengeBytes->length());
// encrypt the credentials and challenge bytes
- DataOutput cleartext;
+ auto cleartext = m_poolDM->getConnectionManager().getCacheImpl()->getCache()->createDataOutput();
if (isClientNotification) { //:only for backward connection
- credentials->toData(cleartext);
+ credentials->toData(*cleartext);
}
- challengeBytes->toData(cleartext);
+ challengeBytes->toData(*cleartext);
CacheableBytesPtr ciphertext =
- m_dh->encrypt(cleartext.getBuffer(), cleartext.getBufferLength());
+ m_dh->encrypt(cleartext->getBuffer(), cleartext->getBufferLength());
- DataOutput sendCreds;
- ciphertext->toData(sendCreds);
+ auto sendCreds = m_poolDM->getConnectionManager().getCacheImpl()->getCache()->createDataOutput();
+ ciphertext->toData(*sendCreds);
uint32_t credLen;
- char* credData = (char*)sendCreds.getBuffer(&credLen);
+ char* credData = (char*)sendCreds->getBuffer(&credLen);
// send the encrypted bytes and check the response
error = sendData(credData, credLen, connectTimeout, false);
@@ -418,9 +401,9 @@ bool TcrConnection::InitTcrConnection(
m_hasServerQueue = NON_REDUNDANT_SERVER;
}
CacheableBytesPtr queueSizeMsg = readHandshakeData(4, connectTimeout);
- DataInput dI(queueSizeMsg->value(), queueSizeMsg->length());
+ auto dI = m_connectionManager->getCacheImpl()->getCache()->createDataInput(queueSizeMsg->value(), queueSizeMsg->length());
int32_t queueSize = 0;
- dI.readInt(&queueSize);
+ dI->readInt(&queueSize);
m_queueSize = queueSize > 0 ? queueSize : 0;
m_endpointObj->setServerQueueStatus(m_hasServerQueue, m_queueSize);
@@ -449,43 +432,49 @@ bool TcrConnection::InitTcrConnection(
if (static_cast<int8_t>((*arrayLenHeader)[0]) == -2) {
CacheableBytesPtr recvMsgLenBytes =
readHandshakeData(2, connectTimeout);
- DataInput dI2(recvMsgLenBytes->value(), recvMsgLenBytes->length());
+ auto dI2 = m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+ recvMsgLenBytes->value(), recvMsgLenBytes->length());
int16_t recvMsgLenShort = 0;
- dI2.readInt(&recvMsgLenShort);
+ dI2->readInt(&recvMsgLenShort);
recvMsgLen = recvMsgLenShort;
} else if (static_cast<int8_t>((*arrayLenHeader)[0]) == -3) {
CacheableBytesPtr recvMsgLenBytes =
readHandshakeData(4, connectTimeout);
- DataInput dI2(recvMsgLenBytes->value(), recvMsgLenBytes->length());
- dI2.readInt(&recvMsgLen);
+ auto dI2 = m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+ recvMsgLenBytes->value(), recvMsgLenBytes->length());
+ dI2->readInt(&recvMsgLen);
}
- CacheableBytesPtr recvMessage =
- readHandshakeData(recvMsgLen, connectTimeout);
+ auto recvMessage = readHandshakeData(recvMsgLen, connectTimeout);
// If the distributed member has not been set yet, set it.
if (getEndpointObject()->getDistributedMemberID() == 0) {
LOGDEBUG("Deserializing distributed member Id");
- DataInput diForClient(recvMessage->value(), recvMessage->length());
+ auto diForClient = m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+ recvMessage->value(), recvMessage->length());
ClientProxyMembershipIDPtr member;
- diForClient.readObject(member);
- uint16_t memId = CacheImpl::getMemberListForVersionStamp()->add(
- (DSMemberForVersionStampPtr)member);
+ diForClient->readObject(member);
+ auto memId = m_poolDM->getConnectionManager()
+ .getCacheImpl()
+ ->getMemberListForVersionStamp()
+ ->add(member);
getEndpointObject()->setDistributedMemberID(memId);
LOGDEBUG("Deserialized distributed member Id %d", memId);
}
}
CacheableBytesPtr recvMsgLenBytes = readHandshakeData(2, connectTimeout);
- DataInput dI3(recvMsgLenBytes->value(), recvMsgLenBytes->length());
+ auto dI3 = m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+ recvMsgLenBytes->value(), recvMsgLenBytes->length());
uint16_t recvMsgLen2 = 0;
- dI3.readInt(&recvMsgLen2);
+ dI3->readInt(&recvMsgLen2);
CacheableBytesPtr recvMessage =
readHandshakeData(recvMsgLen2, connectTimeout);
if (!isClientNotification) {
CacheableBytesPtr deltaEnabledMsg = readHandshakeData(1, connectTimeout);
- DataInput di(deltaEnabledMsg->value(), 1);
+ auto di = m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+ deltaEnabledMsg->value(), 1);
bool isDeltaEnabledOnServer;
- di.readBoolean(&isDeltaEnabledOnServer);
+ di->readBoolean(&isDeltaEnabledOnServer);
ThinClientBaseDM::setDeltaEnabledOnServer(isDeltaEnabledOnServer);
}
@@ -579,8 +568,14 @@ Connector* TcrConnection::createConnection(const char* endpoint,
uint32_t connectTimeout,
int32_t maxBuffSizePool) {
Connector* socket = nullptr;
- if (DistributedSystem::getSystemProperties()->sslEnabled()) {
- socket = new TcpSslConn(endpoint, connectTimeout, maxBuffSizePool);
+ auto& systemProperties = m_connectionManager->getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties();
+ if (systemProperties.sslEnabled()) {
+ socket = new TcpSslConn(endpoint, connectTimeout, maxBuffSizePool,
+ systemProperties.sslKeystorePassword(),
+ systemProperties.sslTrustStore(),
+ systemProperties.sslKeyStore());
} else {
socket = new TcpConn(endpoint, connectTimeout, maxBuffSizePool);
}
@@ -611,7 +606,11 @@ inline ConnErrType TcrConnection::receiveData(char* buffer, int32_t length,
// if gfcpp property unit set then sendTimeoutSec will be in millisecond
// otherwise it will be in second
- if (DistributedSystem::getSystemProperties()->readTimeoutUnitInMillis()) {
+ if (m_poolDM->getConnectionManager()
+ .getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties()
+ .readTimeoutUnitInMillis()) {
LOGFINER("recieveData %d %d ", receiveTimeoutSec, notPublicApiWithTimeout);
if (notPublicApiWithTimeout == TcrMessage::QUERY ||
notPublicApiWithTimeout == TcrMessage::QUERY_WITH_PARAMETERS ||
@@ -694,7 +693,11 @@ inline ConnErrType TcrConnection::sendData(uint32_t& timeSpent,
bool isPublicApiTimeout = false;
// if gfcpp property unit set then sendTimeoutSec will be in millisecond
// otherwise it will be in second
- if (DistributedSystem::getSystemProperties()->readTimeoutUnitInMillis()) {
+ if (m_poolDM->getConnectionManager()
+ .getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties()
+ .readTimeoutUnitInMillis()) {
LOGFINER("sendData %d %d", sendTimeoutSec, notPublicApiWithTimeout);
if (notPublicApiWithTimeout == TcrMessage::QUERY ||
notPublicApiWithTimeout == TcrMessage::QUERY_WITH_PARAMETERS ||
@@ -950,9 +953,10 @@ char* TcrConnection::readMessage(size_t* recvLen, uint32_t receiveTimeoutSec,
m_endpoint,
Utils::convertBytesToString(msg_header, HEADER_LENGTH)->asChar());
- DataInput input(reinterpret_cast<uint8_t*>(msg_header), HEADER_LENGTH);
- input.readInt(&msgType);
- input.readInt(&msgLen);
+ auto input = m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+ reinterpret_cast<uint8_t*>(msg_header), HEADER_LENGTH);
+ input->readInt(&msgType);
+ input->readInt(&msgLen);
// check that message length is valid.
if (!(msgLen > 0) && request == TcrMessage::GET_CLIENT_PR_METADATA) {
char* fullMessage;
@@ -1059,17 +1063,18 @@ void TcrConnection::readMessageChunked(TcrMessageReply& reply,
m_endpoint,
Utils::convertBytesToString(msg_header, HDR_LEN_12)->asChar());
- DataInput input(msg_header, HDR_LEN_12);
+ auto input = m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+ msg_header, HDR_LEN_12);
int32_t msgType;
- input.readInt(&msgType);
+ input->readInt(&msgType);
reply.setMessageType(msgType);
int32_t txId;
int32_t numOfParts;
- input.readInt(&numOfParts);
+ input->readInt(&numOfParts);
LOGDEBUG("TcrConnection::readMessageChunked numberof parts = %d ",
numOfParts);
- // input.advanceCursor(4);
- input.readInt(&txId);
+ // input->advanceCursor(4);
+ input->readInt(&txId);
reply.setTransId(txId);
// bool isLastChunk = false;
@@ -1125,13 +1130,14 @@ void TcrConnection::readMessageChunked(TcrMessageReply& reply,
Utils::convertBytesToString((msg_header + HDR_LEN_12), HDR_LEN)
->asChar());
- DataInput inp((msg_header + HDR_LEN_12), HDR_LEN);
+ auto input = m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+ msg_header + HDR_LEN_12, HDR_LEN);
int32_t chunkLen;
- inp.readInt(&chunkLen);
+ input->readInt(&chunkLen);
// check that chunk length is valid.
GF_DEV_ASSERT(chunkLen > 0);
- // inp.readBoolean(&isLastChunk);
- inp.read(&isLastChunk);
+ // input->readBoolean(&isLastChunk);
+ input->read(&isLastChunk);
uint8_t* chunk_body;
GF_NEW(chunk_body, uint8_t[chunkLen]);
@@ -1172,17 +1178,19 @@ void TcrConnection::readMessageChunked(TcrMessageReply& reply,
void TcrConnection::close() {
// If this is a short lived grid client, don't bother with this close ack
// message
- if (DistributedSystem::getSystemProperties()->isGridClient()) {
+ if (m_poolDM->getConnectionManager()
+ .getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties()
+ .isGridClient()) {
return;
}
- TcrMessage* closeMsg = TcrMessage::getCloseConnMessage();
+ TcrMessage* closeMsg = TcrMessage::getCloseConnMessage(
+ m_poolDM->getConnectionManager().getCacheImpl()->getCache());
try {
- // LOGINFO("TcrConnection::close DC = %d; netdown = %d endpoint %s",
- // TcrConnectionManager::TEST_DURABLE_CLIENT_CRASH,
- // TcrConnectionManager::isNetDown, m_endpoint);
if (!TcrConnectionManager::TEST_DURABLE_CLIENT_CRASH &&
- !TcrConnectionManager::isNetDown) {
+ !m_connectionManager->isNetDown()) {
send(closeMsg->getMsgData(), closeMsg->getMsgLength(), 2, false);
}
} catch (Exception& e) {
@@ -1285,9 +1293,10 @@ CacheableBytesPtr TcrConnection::readHandshakeByteArray(
// read a byte array
uint32_t TcrConnection::readHandshakeArraySize(uint32_t connectTimeout) {
CacheableBytesPtr codeBytes = readHandshakeData(1, connectTimeout);
- DataInput codeDI(codeBytes->value(), codeBytes->length());
+ auto codeDI = m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+ codeBytes->value(), codeBytes->length());
uint8_t code = 0;
- codeDI.read(&code);
+ codeDI->read(&code);
uint32_t arraySize = 0;
if (code == 0xFF) {
return 0;
@@ -1296,15 +1305,15 @@ uint32_t TcrConnection::readHandshakeArraySize(uint32_t connectTimeout) {
if (tempLen > 252) { // 252 is java's ((byte)-4 && 0xFF)
if (code == 0xFE) {
CacheableBytesPtr lenBytes = readHandshakeData(2, connectTimeout);
- DataInput lenDI(lenBytes->value(), lenBytes->length());
+ auto lenDI = m_connectionManager->getCacheImpl()->getCache()->createDataInput(lenBytes->value(), lenBytes->length());
uint16_t val;
- lenDI.readInt(&val);
+ lenDI->readInt(&val);
tempLen = val;
} else if (code == 0xFD) {
CacheableBytesPtr lenBytes = readHandshakeData(4, connectTimeout);
- DataInput lenDI(lenBytes->value(), lenBytes->length());
+ auto lenDI = m_connectionManager->getCacheImpl()->getCache()->createDataInput(lenBytes->value(), lenBytes->length());
uint32_t val;
- lenDI.readInt(&val);
+ lenDI->readInt(&val);
tempLen = val;
} else {
GF_SAFE_DELETE_CON(m_conn);
@@ -1393,9 +1402,9 @@ int32_t TcrConnection::readHandShakeInt(uint32_t connectTimeout) {
}
}
- DataInput di(recvMessage, 4);
+ auto di = m_connectionManager->getCacheImpl()->getCache()->createDataInput(recvMessage, 4);
int32_t val;
- di.readInt(&val);
+ di->readInt(&val);
GF_SAFE_DELETE_ARRAY(recvMessage);
@@ -1431,8 +1440,8 @@ CacheableStringPtr TcrConnection::readHandshakeString(uint32_t connectTimeout) {
case GF_STRING: {
uint16_t shortLen = 0;
CacheableBytesPtr lenBytes = readHandshakeData(2, connectTimeout);
- DataInput lenDI(lenBytes->value(), lenBytes->length());
- lenDI.readInt(&shortLen);
+ auto lenDI = m_connectionManager->getCacheImpl()->getCache()->createDataInput(lenBytes->value(), lenBytes->length());
+ lenDI->readInt(&shortLen);
length = shortLen;
break;
}
@@ -1512,7 +1521,7 @@ void TcrConnection::touch() { m_lastAccessed = ACE_OS::gettimeofday(); }
ACE_Time_Value TcrConnection::getLastAccessed() { return m_lastAccessed; }
-uint8_t TcrConnection::getOverrides(SystemProperties* props) {
+uint8_t TcrConnection::getOverrides(const SystemProperties* props) {
const char* conflate = props->conflateEvents();
uint8_t conflateByte = 0;
if (conflate != nullptr) {
@@ -1522,27 +1531,7 @@ uint8_t TcrConnection::getOverrides(SystemProperties* props) {
conflateByte = 2;
}
}
- /*
- const char * removeUnresponsive = props->removeUnresponsiveClientOverride();
- uint8_t removeByte = 0;
- if (removeUnresponsive != nullptr ) {
- if ( ACE_OS::strcasecmp(removeUnresponsive, "true") == 0 ) {
- removeByte = 1;
- } else if ( ACE_OS::strcasecmp(removeUnresponsive, "false") == 0 ) {
- removeByte = 2;
- }
- }
- const char * notify = props->notifyBySubscriptionOverride();
- uint8_t notifyByte = 0;
- if (notify != nullptr ) {
- if ( ACE_OS::strcasecmp(notify, "true") == 0 ) {
- notifyByte = 1;
- } else if ( ACE_OS::strcasecmp(notify, "false") == 0 ) {
- notifyByte = 2;
- }
- }
- return (((notifyByte << 2) | removeByte) << 2) | conflateByte;
- */
+
return conflateByte;
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/TcrConnection.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TcrConnection.hpp b/src/cppcache/src/TcrConnection.hpp
index 9e8d873..fc8f54f 100644
--- a/src/cppcache/src/TcrConnection.hpp
+++ b/src/cppcache/src/TcrConnection.hpp
@@ -79,6 +79,7 @@ enum ServerQueueStatus {
class TcrEndpoint;
class SystemProperties;
class ThinClientPoolDM;
+class TcrConnectionManager;
class CPPCACHE_EXPORT TcrConnection {
public:
/** Create one connection, endpoint is in format of hostname:portno
@@ -111,8 +112,10 @@ class CPPCACHE_EXPORT TcrConnection {
bool isSecondary = false,
uint32_t connectTimeout = DEFAULT_CONNECT_TIMEOUT);
- TcrConnection(volatile const bool& isConnected)
+ TcrConnection(const TcrConnectionManager& connectionManager,
+ volatile const bool& isConnected)
: connectionId(0),
+ m_connectionManager(&connectionManager),
m_dh(nullptr),
m_endpoint(nullptr),
m_endpointObj(nullptr),
@@ -279,6 +282,10 @@ class CPPCACHE_EXPORT TcrConnection {
connectionId = id;
}
+ const TcrConnectionManager& getConnectionManager() {
+ return *m_connectionManager;
+ }
+
CacheableBytesPtr encryptBytes(CacheableBytesPtr data) {
if (m_dh != nullptr) {
return m_dh->encrypt(data);
@@ -297,6 +304,7 @@ class CPPCACHE_EXPORT TcrConnection {
private:
int64_t connectionId;
+ const TcrConnectionManager* m_connectionManager;
DiffieHellman* m_dh;
/**
* To read Intantiator message(which meant for java client), here we are
@@ -308,7 +316,7 @@ class CPPCACHE_EXPORT TcrConnection {
* Packs the override settings bits into bytes - currently a single byte for
* conflation, remove-unresponsive-client and notify-by-subscription.
*/
- uint8_t getOverrides(SystemProperties* props);
+ uint8_t getOverrides(const SystemProperties* props);
/**
* To read the from stream
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/TcrConnectionManager.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TcrConnectionManager.cpp b/src/cppcache/src/TcrConnectionManager.cpp
index 71d2347..714f479 100644
--- a/src/cppcache/src/TcrConnectionManager.cpp
+++ b/src/cppcache/src/TcrConnectionManager.cpp
@@ -39,7 +39,6 @@
namespace apache {
namespace geode {
namespace client {
-volatile bool TcrConnectionManager::isNetDown = false;
volatile bool TcrConnectionManager::TEST_DURABLE_CLIENT_CRASH = false;
const char *TcrConnectionManager::NC_Redundancy = "NC Redundancy";
@@ -59,7 +58,8 @@ TcrConnectionManager::TcrConnectionManager(CacheImpl *cache)
m_notifyCleanupSemaList(false),
m_redundancySema(0),
m_redundancyTask(nullptr),
- m_isDurable(false) {
+ m_isDurable(false),
+ m_isNetDown(false) {
m_redundancyManager = new ThinClientRedundancyManager(this);
}
@@ -70,14 +70,14 @@ void TcrConnectionManager::init(bool isPool) {
} else {
return;
}
- SystemProperties *props = DistributedSystem::getSystemProperties();
- m_isDurable = strlen(props->durableClientId()) > 0;
- int32_t pingInterval = (props->pingInterval() / 2);
- if (!props->isGridClient() && !isPool) {
+ auto &props = m_cache->getDistributedSystem().getSystemProperties();
+ m_isDurable = strlen(props.durableClientId()) > 0;
+ int32_t pingInterval = (props.pingInterval() / 2);
+ if (!props.isGridClient() && !isPool) {
ACE_Event_Handler *connectionChecker =
new ExpiryHandler_T<TcrConnectionManager>(
this, &TcrConnectionManager::checkConnection);
- m_pingTaskId = CacheImpl::expiryTaskManager->scheduleExpiryTask(
+ m_pingTaskId = m_cache->getExpiryTaskManager().scheduleExpiryTask(
connectionChecker, 10, pingInterval, false);
LOGFINE(
"TcrConnectionManager::TcrConnectionManager Registered ping "
@@ -105,9 +105,9 @@ void TcrConnectionManager::init(bool isPool) {
ACE_Event_Handler *redundancyChecker =
new ExpiryHandler_T<TcrConnectionManager>(
this, &TcrConnectionManager::checkRedundancy);
- int32_t redundancyMonitorInterval = props->redundancyMonitorInterval();
+ int32_t redundancyMonitorInterval = props.redundancyMonitorInterval();
- m_servermonitorTaskId = CacheImpl::expiryTaskManager->scheduleExpiryTask(
+ m_servermonitorTaskId = m_cache->getExpiryTaskManager().scheduleExpiryTask(
redundancyChecker, 1, redundancyMonitorInterval, false);
LOGFINE(
"TcrConnectionManager::TcrConnectionManager Registered server "
@@ -125,7 +125,7 @@ void TcrConnectionManager::init(bool isPool) {
m_redundancyManager->m_HAenabled = true;
}
- if (!props->isGridClient()) {
+ if (!props.isGridClient()) {
startFailoverAndCleanupThreads(isPool);
}
}
@@ -152,7 +152,7 @@ void TcrConnectionManager::startFailoverAndCleanupThreads(bool isPool) {
void TcrConnectionManager::close() {
LOGFINE("TcrConnectionManager is closing");
if (m_pingTaskId > 0) {
- CacheImpl::expiryTaskManager->cancelTask(m_pingTaskId);
+ m_cache->getExpiryTaskManager().cancelTask(m_pingTaskId);
}
if (m_failoverTask != nullptr) {
@@ -166,7 +166,7 @@ void TcrConnectionManager::close() {
if (cacheAttributes != nullptr &&
(cacheAttributes->getRedundancyLevel() > 0 || m_isDurable)) {
if (m_servermonitorTaskId > 0) {
- CacheImpl::expiryTaskManager->cancelTask(m_servermonitorTaskId);
+ m_cache->getExpiryTaskManager().cancelTask(m_servermonitorTaskId);
}
if (m_redundancyTask != nullptr) {
m_redundancyTask->stopNoblock();
@@ -344,7 +344,7 @@ int TcrConnectionManager::checkConnection(const ACE_Time_Value &,
ACE_Recursive_Thread_Mutex>::iterator currItr =
m_endpoints.begin();
while (currItr != m_endpoints.end()) {
- if ((*currItr).int_id_->connected() && !isNetDown) {
+ if ((*currItr).int_id_->connected() && !m_isNetDown) {
(*currItr).int_id_->pingServer();
}
currItr++;
@@ -362,7 +362,7 @@ int TcrConnectionManager::failover(volatile bool &isRunning) {
LOGFINE("TcrConnectionManager: starting failover thread");
while (isRunning) {
m_failoverSema.acquire();
- if (isRunning && !isNetDown) {
+ if (isRunning && !m_isNetDown) {
try {
ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_distMngrsLock);
for (std::list<ThinClientBaseDM *>::iterator it = m_distMngrs.begin();
@@ -477,7 +477,7 @@ void TcrConnectionManager::removeHAEndpoints() {
}
void TcrConnectionManager::netDown() {
- isNetDown = true;
+ m_isNetDown = true;
// sleep for 15 seconds to allow ping and redundancy threads to pause.
std::this_thread::sleep_for(std::chrono::seconds(15));
@@ -499,7 +499,7 @@ void TcrConnectionManager::netDown() {
/* Need to do a get on unknown key after calling this Fn to restablish all
* connection */
void TcrConnectionManager::revive() {
- isNetDown = false;
+ m_isNetDown = false;
// sleep for 15 seconds to allow redundancy thread to reestablish
// connections.
@@ -510,7 +510,7 @@ int TcrConnectionManager::redundancy(volatile bool &isRunning) {
LOGFINE("Starting subscription maintain redundancy thread.");
while (isRunning) {
m_redundancySema.acquire();
- if (isRunning && !isNetDown) {
+ if (isRunning && !m_isNetDown) {
m_redundancyManager->maintainRedundancyLevel();
while (m_redundancySema.tryacquire() != -1) {
;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/TcrConnectionManager.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TcrConnectionManager.hpp b/src/cppcache/src/TcrConnectionManager.hpp
index c902286..bb9afbc 100644
--- a/src/cppcache/src/TcrConnectionManager.hpp
+++ b/src/cppcache/src/TcrConnectionManager.hpp
@@ -76,7 +76,6 @@ class CPPCACHE_EXPORT TcrConnectionManager {
void netDown();
void revive();
void setClientCrashTEST() { TEST_DURABLE_CLIENT_CRASH = true; }
- volatile static bool isNetDown;
volatile static bool TEST_DURABLE_CLIENT_CRASH;
inline ACE_Map_Manager<std::string, TcrEndpoint*, ACE_Recursive_Thread_Mutex>&
@@ -106,7 +105,7 @@ class CPPCACHE_EXPORT TcrConnectionManager {
bool isDurable() { return m_isDurable; };
bool haEnabled() { return m_redundancyManager->m_HAenabled; };
- CacheImpl* getCacheImpl() { return m_cache; };
+ CacheImpl* getCacheImpl() const { return m_cache; };
GfErrType sendSyncRequestCq(TcrMessage& request, TcrMessageReply& reply,
TcrHADistributionManager* theHADM);
@@ -140,6 +139,8 @@ class CPPCACHE_EXPORT TcrConnectionManager {
return m_redundancyManager->sendRequestToPrimary(request, reply);
}
+ bool isNetDown() const { return m_isNetDown; }
+
private:
CacheImpl* m_cache;
volatile bool m_initGuard;
@@ -175,6 +176,8 @@ class CPPCACHE_EXPORT TcrConnectionManager {
ACE_Recursive_Thread_Mutex m_notificationLock;
bool m_isDurable;
+ bool m_isNetDown;
+
ThinClientRedundancyManager* m_redundancyManager;
int failover(volatile bool& isRunning);
[24/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/Execution.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/Execution.cpp b/src/clicache/src/Execution.cpp
index 0a43e9b..2ba9187 100644
--- a/src/clicache/src/Execution.cpp
+++ b/src/clicache/src/Execution.cpp
@@ -49,7 +49,7 @@ namespace Apache
for each(TFilter item in routingObj)
{
- rsptr->push_back(Serializable::GetUnmanagedValueGeneric<TFilter>( item ));
+ rsptr->push_back(Serializable::GetUnmanagedValueGeneric<TFilter>( item, nullptr ));
}
try
@@ -74,7 +74,7 @@ namespace Apache
_GF_MG_EXCEPTION_TRY2/* due to auto replace */
try
{
- auto argsptr = Serializable::GetUnmanagedValueGeneric<TArgs>( args );
+ auto argsptr = Serializable::GetUnmanagedValueGeneric<TArgs>( args, nullptr );
return Execution<TResult>::Create(m_nativeptr->get()->withArgs(argsptr), this->m_rc);
}
finally
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/LocalRegion.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/LocalRegion.cpp b/src/clicache/src/LocalRegion.cpp
index 143f51a..1313558 100644
--- a/src/clicache/src/LocalRegion.cpp
+++ b/src/clicache/src/LocalRegion.cpp
@@ -15,6 +15,11 @@
* limitations under the License.
*/
+#include "begin_native.hpp"
+#include "geode/Region.hpp"
+#include "geode/Cache.hpp"
+#include "end_native.hpp"
+
#include "LocalRegion.hpp"
#include "Cache.hpp"
#include "CacheStatistics.hpp"
@@ -35,7 +40,7 @@ namespace Apache
generic<class TKey, class TValue>
TValue LocalRegion<TKey, TValue>::Get(TKey key, Object^ callbackArg)
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key );
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key, m_nativeptr->get()->getCache().get() );
auto nativeptr= this->getRegionEntryValue(keyptr);
if (nativeptr == nullptr)
{
@@ -72,9 +77,9 @@ namespace Apache
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key );
- native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>( value );
- native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg );
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key, m_nativeptr->get()->getCache().get() );
+ native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>( value, m_nativeptr->get()->getCache().get() );
+ native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg, m_nativeptr->get()->getCache().get() );
m_nativeptr->get()->localPut( keyptr, valueptr, callbackptr );
}
finally
@@ -88,7 +93,7 @@ namespace Apache
generic<class TKey, class TValue>
TValue LocalRegion<TKey, TValue>::default::get(TKey key)
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key );
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key, m_nativeptr->get()->getCache().get() );
auto nativeptr = this->getRegionEntryValue(keyptr);
if (nativeptr == nullptr)
{
@@ -105,8 +110,8 @@ namespace Apache
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key );
- native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>( value );
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key, m_nativeptr->get()->getCache().get() );
+ native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>( value, m_nativeptr->get()->getCache().get() );
m_nativeptr->get()->localPut( keyptr, valueptr );
}
finally
@@ -195,15 +200,15 @@ namespace Apache
{
return false;
}
- apache::geode::client::DataOutput out1;
- apache::geode::client::DataOutput out2;
- val1->toData(out1);
- val2->toData(out2);
- if ( out1.getBufferLength() != out2.getBufferLength() )
+ std::unique_ptr<apache::geode::client::DataOutput> out1 = m_nativeptr->get_shared_ptr()->getCache()->createDataOutput();
+ std::unique_ptr<apache::geode::client::DataOutput> out2 = m_nativeptr->get_shared_ptr()->getCache()->createDataOutput();
+ val1->toData(*out1);
+ val2->toData(*out2);
+ if ( out1->getBufferLength() != out2->getBufferLength() )
{
return false;
}
- else if (memcmp(out1.getBuffer(), out2.getBuffer(), out1.getBufferLength()) != 0)
+ else if (memcmp(out1->getBuffer(), out2->getBuffer(), out1->getBufferLength()) != 0)
{
return false;
}
@@ -215,7 +220,7 @@ namespace Apache
generic<class TKey, class TValue>
bool LocalRegion<TKey, TValue>::Contains(KeyValuePair<TKey,TValue> keyValuePair)
{
- auto keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( keyValuePair.Key );
+ auto keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( keyValuePair.Key, m_nativeptr->get()->getCache().get() );
auto nativeptr = this->getRegionEntryValue(keyptr);
//This means that key is not present.
if (nativeptr == nullptr) {
@@ -232,7 +237,7 @@ namespace Apache
try
{
- auto keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key );
+ auto keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key, m_nativeptr->get()->getCache().get() );
return m_nativeptr->get()->containsKey(keyptr);
}
finally
@@ -246,7 +251,7 @@ namespace Apache
generic<class TKey, class TValue>
bool LocalRegion<TKey, TValue>::TryGetValue(TKey key, TValue %val)
{
- auto keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key );
+ auto keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key, m_nativeptr->get()->getCache().get() );
auto nativeptr = this->getRegionEntryValue(keyptr);
if (nativeptr == nullptr) {
val = TValue();
@@ -320,8 +325,8 @@ namespace Apache
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key );
- native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>( value );
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key, m_nativeptr->get()->getCache().get() );
+ native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>( value, m_nativeptr->get()->getCache().get() );
m_nativeptr->get()->localCreate( keyptr, valueptr );
}
finally
@@ -339,8 +344,8 @@ namespace Apache
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( keyValuePair.Key );
- native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>( keyValuePair.Value );
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( keyValuePair.Key, m_nativeptr->get()->getCache().get() );
+ native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>( keyValuePair.Value, m_nativeptr->get()->getCache().get() );
m_nativeptr->get()->localCreate( keyptr, valueptr );
}
finally
@@ -358,9 +363,9 @@ namespace Apache
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key );
- native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>( value );
- native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg );
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key, m_nativeptr->get()->getCache().get() );
+ native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>( value, m_nativeptr->get()->getCache().get() );
+ native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg, m_nativeptr->get()->getCache().get() );
m_nativeptr->get()->localCreate( keyptr, valueptr, callbackptr );
}
finally
@@ -378,7 +383,7 @@ namespace Apache
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key, m_nativeptr->get()->getCache().get());
m_nativeptr->get()->localDestroy(keyptr);
return true;
}
@@ -401,8 +406,8 @@ namespace Apache
_GF_MG_EXCEPTION_TRY2/* due to auto replace */
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key);
- native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key, m_nativeptr->get()->getCache().get());
+ native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg, m_nativeptr->get()->getCache().get());
m_nativeptr->get()->localDestroy(keyptr, callbackptr);
return true;
}
@@ -424,8 +429,8 @@ namespace Apache
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( keyValuePair.Key );
- native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>( keyValuePair.Value );
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( keyValuePair.Key, m_nativeptr->get()->getCache().get() );
+ native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>( keyValuePair.Value, m_nativeptr->get()->getCache().get() );
return m_nativeptr->get()->localRemove(keyptr, valueptr);
}
finally
@@ -443,9 +448,9 @@ namespace Apache
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key);
- native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>(value);
- native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key, m_nativeptr->get()->getCache().get());
+ native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>(value, m_nativeptr->get()->getCache().get());
+ native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg, m_nativeptr->get()->getCache().get());
return m_nativeptr->get()->localRemove(keyptr, valueptr, callbackptr);
}
finally
@@ -473,7 +478,7 @@ namespace Apache
try
{
- native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg );
+ native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg, m_nativeptr->get()->getCache().get() );
m_nativeptr->get()->localInvalidateRegion( callbackptr );
}
finally
@@ -500,7 +505,7 @@ namespace Apache
_GF_MG_EXCEPTION_TRY2/* due to auto replace */
try
{
- native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg );
+ native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg, m_nativeptr->get()->getCache().get() );
m_nativeptr->get()->localDestroyRegion( callbackptr );
}
finally
@@ -528,8 +533,8 @@ namespace Apache
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key );
- native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg );
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key, m_nativeptr->get()->getCache().get() );
+ native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg, m_nativeptr->get()->getCache().get() );
m_nativeptr->get()->localInvalidate( keyptr, callbackptr );
}
finally
@@ -774,7 +779,7 @@ namespace Apache
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key, m_nativeptr->get()->getCache().get());
auto nativeptr = m_nativeptr->get()->getEntry(keyptr);
return RegionEntry<TKey, TValue>::Create(nativeptr);
}
@@ -846,7 +851,7 @@ namespace Apache
try
{
- return m_nativeptr->get()->containsValueForKey(Serializable::GetUnmanagedValueGeneric<TKey>(key));
+ return m_nativeptr->get()->containsValueForKey(Serializable::GetUnmanagedValueGeneric<TKey>(key, m_nativeptr->get()->getCache().get()));
}
finally
{
@@ -881,7 +886,7 @@ namespace Apache
_GF_MG_EXCEPTION_TRY2/* due to auto replace */
try
{
- m_nativeptr->get()->localClear(Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg ) );
+ m_nativeptr->get()->localClear(Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg, m_nativeptr->get()->getCache().get() ) );
}
finally
{
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/Pool.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/Pool.cpp b/src/clicache/src/Pool.cpp
index 32921fb..6bb1f91 100644
--- a/src/clicache/src/Pool.cpp
+++ b/src/clicache/src/Pool.cpp
@@ -20,7 +20,7 @@
#include "QueryService.hpp"
#include "CacheableString.hpp"
#include "Cache.hpp"
-#include "Properties.hpp"
+//#include "Properties.hpp"
#include "impl/ManagedString.hpp"
#include "ExceptionTypes.hpp"
#include "impl/SafeConvert.hpp"
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/PoolFactory.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/PoolFactory.cpp b/src/clicache/src/PoolFactory.cpp
index e17bdee..bf3c0b1 100644
--- a/src/clicache/src/PoolFactory.cpp
+++ b/src/clicache/src/PoolFactory.cpp
@@ -23,6 +23,8 @@
#include "impl/ManagedString.hpp"
#include "ExceptionTypes.hpp"
+#include "Cache.hpp"
+
using namespace System;
namespace Apache
@@ -429,7 +431,7 @@ namespace Apache
}
- Pool^ PoolFactory::Create(String^ name)
+ Pool^ PoolFactory::Create(String^ name, Cache^ cache)
{
_GF_MG_EXCEPTION_TRY2/* due to auto replace */
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/PoolFactory.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/PoolFactory.hpp b/src/clicache/src/PoolFactory.hpp
index 49665bb..cf16906 100644
--- a/src/clicache/src/PoolFactory.hpp
+++ b/src/clicache/src/PoolFactory.hpp
@@ -390,7 +390,7 @@ namespace Apache
/// throws IllegalStateException if a pool with name already exists
/// throws IllegalStateException if a locator or server has not been added.
/// </exception>
- Pool^ Create(String^ name);
+ Pool^ Create(String^ name, Cache^ cache);
internal:
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/PoolManager.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/PoolManager.cpp b/src/clicache/src/PoolManager.cpp
index 5136442..3f641a7 100644
--- a/src/clicache/src/PoolManager.cpp
+++ b/src/clicache/src/PoolManager.cpp
@@ -35,12 +35,12 @@ namespace Apache
PoolFactory^ PoolManager::CreateFactory()
{
- return PoolFactory::Create(native::PoolManager::createFactory());
+ return PoolFactory::Create(m_nativeref.createFactory());
}
const Dictionary<String^, Pool^>^ PoolManager::GetAll()
{
- auto pools = native::PoolManager::getAll();
+ auto pools = m_nativeref.getAll();
auto result = gcnew Dictionary<String^, Pool^>();
for (const auto& iter : pools)
{
@@ -54,23 +54,23 @@ namespace Apache
Pool^ PoolManager::Find(String^ name)
{
ManagedString mg_name( name );
- auto pool = native::PoolManager::find(mg_name.CharPtr);
+ auto pool = m_nativeref.find(mg_name.CharPtr);
return Pool::Create(pool);
}
Pool^ PoolManager::Find(Client::Region<Object^, Object^>^ region)
{
- return Pool::Create(native::PoolManager::find(region->GetNative()));
+ return Pool::Create(m_nativeref.find(region->GetNative()));
}
void PoolManager::Close(Boolean KeepAlive)
{
- native::PoolManager::close(KeepAlive);
+ m_nativeref.close(KeepAlive);
}
void PoolManager::Close()
{
- native::PoolManager::close();
+ m_nativeref.close();
}
} // namespace Client
} // namespace Geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/PoolManager.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/PoolManager.hpp b/src/clicache/src/PoolManager.hpp
index f47d553..0ea139d 100644
--- a/src/clicache/src/PoolManager.hpp
+++ b/src/clicache/src/PoolManager.hpp
@@ -23,7 +23,6 @@
#include "end_native.hpp"
-
using namespace System;
namespace Apache
@@ -38,44 +37,64 @@ namespace Apache
// generic<class TKey, class TValue>
ref class PoolFactory;
+ namespace native = apache::geode::client;
+
/// <summary>
/// This interface provides for the configuration and creation of instances of PoolFactory.
/// </summary>
// generic<class TKey, class TValue>
- public ref class PoolManager STATICCLASS
+ public ref class PoolManager
{
public:
/// <summary>
/// Creates a new PoolFactory which is used to configure and create Pools.
/// </summary>
- static PoolFactory/*<TKey, TValue>*/^ CreateFactory();
+ PoolFactory/*<TKey, TValue>*/^ CreateFactory();
/// <summary>
/// Returns a map containing all the pools in this manager.
/// The keys are pool names and the values are Pool instances.
/// </summary>
- static const Dictionary<String^, Pool/*<TKey, TValue>*/^>^ GetAll();
+ const Dictionary<String^, Pool/*<TKey, TValue>*/^>^ GetAll();
/// <summary>
/// Find by name an existing connection pool.
/// </summary>
- static Pool/*<TKey, TValue>*/^ Find(String^ name);
+ Pool/*<TKey, TValue>*/^ Find(String^ name);
/// <summary>
/// Find the pool used by the given region.
/// </summary>
- static Pool/*<TKey, TValue>*/^ Find(Client::Region<Object^, Object^>^ region);
+ Pool/*<TKey, TValue>*/^ Find(Client::Region<Object^, Object^>^ region);
/// <summary>
/// Destroys all created pools.
/// </summary>
- static void Close(Boolean KeepAlive);
+ void Close(Boolean KeepAlive);
/// <summary>
/// Destroys all created pools.
/// </summary>
- static void Close();
+ void Close();
+
+ internal:
+
+ native::PoolManager& GetNative()
+ {
+ return m_nativeref;
+ }
+
+ /// <summary>
+ /// Private constructor to wrap a native object pointer
+ /// </summary>
+ /// <param name="nativeptr">The native object pointer</param>
+ inline PoolManager(native::PoolManager& nativeref)
+ : m_nativeref(nativeref)
+ {
+ }
+
+ native::PoolManager& m_nativeref;
};
} // namespace Client
} // namespace Geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/Properties.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/Properties.cpp b/src/clicache/src/Properties.cpp
index b499369..af41931 100644
--- a/src/clicache/src/Properties.cpp
+++ b/src/clicache/src/Properties.cpp
@@ -15,13 +15,17 @@
* limitations under the License.
*/
+#include "begin_native.hpp"
+#include "CacheImpl.hpp"
+#include "SerializationRegistry.hpp"
+#include "end_native.hpp"
+
#include "Properties.hpp"
#include "impl/ManagedVisitor.hpp"
#include "impl/ManagedString.hpp"
#include "impl/SafeConvert.hpp"
#include "ExceptionTypes.hpp"
-
using namespace System;
@@ -65,7 +69,7 @@ namespace Apache
{
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TPropKey>(key);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TPropKey>(key, nullptr);
auto nativeptr = m_nativeptr->get()->find(keyptr);
return Serializable::GetManagedValueGeneric<TPropValue>(nativeptr);
}
@@ -78,8 +82,8 @@ namespace Apache
generic<class TPropKey, class TPropValue>
void Properties<TPropKey, TPropValue>::Insert( TPropKey key, TPropValue value )
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TPropKey>(key, true);
- native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TPropValue>(value, true);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TPropKey>(key, true, nullptr);
+ native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TPropValue>(value, true, nullptr);
_GF_MG_EXCEPTION_TRY2
@@ -98,7 +102,7 @@ namespace Apache
generic<class TPropKey, class TPropValue>
void Properties<TPropKey, TPropValue>::Remove( TPropKey key)
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TPropKey>(key);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TPropKey>(key, nullptr);
_GF_MG_EXCEPTION_TRY2
@@ -294,57 +298,59 @@ namespace Apache
// ISerializable methods
- generic<class TPropKey, class TPropValue>
- void Properties<TPropKey, TPropValue>::GetObjectData( SerializationInfo^ info,
- StreamingContext context )
- {
- native::DataOutput output;
-
- _GF_MG_EXCEPTION_TRY2
-
- try
- {
- m_nativeptr->get()->toData( output );
- }
- finally
- {
- GC::KeepAlive(m_nativeptr);
- }
-
- _GF_MG_EXCEPTION_CATCH_ALL2
-
- auto bytes = gcnew array<Byte>( output.getBufferLength( ) );
- {
- pin_ptr<const Byte> pin_bytes = &bytes[0];
- memcpy( (System::Byte*)pin_bytes, output.getBuffer( ),
- output.getBufferLength( ) );
- }
- info->AddValue( "bytes", bytes, array<Byte>::typeid );
- }
-
- generic<class TPropKey, class TPropValue>
- Properties<TPropKey, TPropValue>::Properties( SerializationInfo^ info,
- StreamingContext context )
- : Properties()
- {
- array<Byte>^ bytes = nullptr;
- try {
- bytes = dynamic_cast<array<Byte>^>( info->GetValue( "bytes",
- array<Byte>::typeid ) );
- }
- catch ( System::Exception^ ) {
- // could not find the header -- null value
- }
- if (bytes != nullptr) {
- pin_ptr<const Byte> pin_bytes = &bytes[0];
+ //generic<class TPropKey, class TPropValue>
+ //void Properties<TPropKey, TPropValue>::GetObjectData( SerializationInfo^ info,
+ // StreamingContext context )
+ //{
+ // auto output = std::unique_ptr<native::DataOutput>(new native::DataOutput(*m_serializationRegistry->get_shared_ptr()));
+
+ // _GF_MG_EXCEPTION_TRY2
+
+ // try
+ // {
+ // m_nativeptr->get()->toData( *output );
+ // }
+ // finally
+ // {
+ // GC::KeepAlive(m_nativeptr);
+ // }
+
+ // _GF_MG_EXCEPTION_CATCH_ALL2
+
+ // auto bytes = gcnew array<Byte>( output->getBufferLength( ) );
+ // {
+ // pin_ptr<const Byte> pin_bytes = &bytes[0];
+ // memcpy( (System::Byte*)pin_bytes, output->getBuffer( ),
+ // output->getBufferLength( ) );
+ // }
+ // info->AddValue( "bytes", bytes, array<Byte>::typeid );
+ //}
+ //
+ //generic<class TPropKey, class TPropValue>
+ //Properties<TPropKey, TPropValue>::Properties( SerializationInfo^ info,
+ // StreamingContext context, native::SerializationRegistryPtr serializationRegistry)
+ // : Properties(serializationRegistry)
+ //{
+ // array<Byte>^ bytes = nullptr;
+ // try {
+ // bytes = dynamic_cast<array<Byte>^>( info->GetValue( "bytes",
+ // array<Byte>::typeid ) );
+ // }
+ // catch ( System::Exception^ ) {
+ // // could not find the header -- null value
+ // }
+ // if (bytes != nullptr) {
+ // pin_ptr<const Byte> pin_bytes = &bytes[0];
+
+ // _GF_MG_EXCEPTION_TRY2
+
+ // native::DataInput input( (System::Byte*)pin_bytes, bytes->Length, *CacheImpl::getInstance()->getSerializationRegistry().get());
+ // FromData(input);
+ // _GF_MG_EXCEPTION_CATCH_ALL2
+ // }
+ //}
- _GF_MG_EXCEPTION_TRY2
- native::DataInput input( (System::Byte*)pin_bytes, bytes->Length );
- FromData(input);
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
- }
} // namespace Client
} // namespace Geode
} // namespace Apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/Properties.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/Properties.hpp b/src/clicache/src/Properties.hpp
index cf798b6..c175fff 100644
--- a/src/clicache/src/Properties.hpp
+++ b/src/clicache/src/Properties.hpp
@@ -21,6 +21,7 @@
#include "begin_native.hpp"
#include <geode/Properties.hpp>
+#include "SerializationRegistry.hpp"
#include "end_native.hpp"
#include "IGeodeSerializable.hpp"
@@ -31,7 +32,6 @@
#include "native_shared_ptr.hpp"
#include "impl/SafeConvert.hpp"
#include "Serializable.hpp"
-#include "native_shared_ptr.hpp"
using namespace System;
using namespace System::Runtime::Serialization;
@@ -71,28 +71,30 @@ namespace Apache
/// or an integer.
/// </summary>
public ref class Properties sealed
- : public IGeodeSerializable,
- public ISerializable
+ : public IGeodeSerializable //,public ISerializable
{
public:
/// <summary>
/// Default constructor: returns an empty collection.
/// </summary>
- inline Properties( )
+ inline Properties()
: Properties(native::Properties::create())
- {}
+ {
+
+ }
/// <summary>
/// Factory method to create an empty collection of properties.
/// </summary>
/// <returns>empty collection of properties</returns>
generic<class TPropKey, class TPropValue>
- inline static Properties<TPropKey, TPropValue>^ Create( )
+ inline static Properties<TPropKey, TPropValue>^ Create()
{
- return gcnew Properties<TPropKey, TPropValue>( );
+ return gcnew Properties<TPropKey, TPropValue>();
}
+
/// <summary>
/// Return the value for the given key, or NULL if not found.
/// </summary>
@@ -204,15 +206,15 @@ namespace Apache
// ISerializable members
- virtual void GetObjectData( SerializationInfo^ info,
- StreamingContext context );
+ //virtual void GetObjectData( SerializationInfo^ info,
+ // StreamingContext context);
// End: ISerializable members
protected:
// For deserialization using the .NET serialization (ISerializable)
- Properties( SerializationInfo^ info, StreamingContext context );
+ //Properties(SerializationInfo^ info, StreamingContext context, native::SerializationRegistryPtr serializationRegistry);
internal:
@@ -237,9 +239,9 @@ namespace Apache
return m_nativeptr->get_shared_ptr();
}
- inline static IGeodeSerializable^ CreateDeserializable( )
+ inline static IGeodeSerializable^ CreateDeserializable()
{
- return Create<String^, String^>();
+ return Create<TPropKey, TPropValue>();
}
private:
@@ -283,6 +285,19 @@ namespace Apache
Apache::Geode::Client::PropertyVisitorGeneric<TPropKey, TPropValue>^ m_visitor;
};
+
+ /* ref class PropertiesFactory {
+ public:
+ PropertiesFactory(native::SerializationRegistryPtr serializationRegistry)
+ {
+ m_serializationRegistry = gcnew native_shared_ptr<native::SerializationRegistry>(serializationRegistry);
+ }
+ IGeodeSerializable^ CreateDeserializable() {
+ return Properties<String^, String^>::CreateDeserializable(m_serializationRegistry->get_shared_ptr());
+ }
+ private:
+ native_shared_ptr<native::SerializationRegistry>^ m_serializationRegistry;
+ };*/
} // namespace Client
} // namespace Geode
} // namespace Apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/Query.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/Query.cpp b/src/clicache/src/Query.cpp
index f1041f8..071c51f 100644
--- a/src/clicache/src/Query.cpp
+++ b/src/clicache/src/Query.cpp
@@ -70,7 +70,7 @@ namespace Apache
auto rsptr = apache::geode::client::CacheableVector::create();
for( int index = 0; index < paramList->Length; index++ )
{
- auto valueptr = Serializable::GetUnmanagedValueGeneric<Object^>(paramList[index]->GetType(), (Object^)paramList[index]);
+ auto valueptr = Serializable::GetUnmanagedValueGeneric<Object^>(paramList[index]->GetType(), (Object^)paramList[index], nullptr);
rsptr->push_back(valueptr);
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/Region.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/Region.cpp b/src/clicache/src/Region.cpp
index f7d4b23..17e9a62 100644
--- a/src/clicache/src/Region.cpp
+++ b/src/clicache/src/Region.cpp
@@ -15,6 +15,11 @@
* limitations under the License.
*/
+#include "begin_native.hpp"
+#include "geode/Region.hpp"
+#include "geode/Cache.hpp"
+#include "end_native.hpp"
+
#include "Region.hpp"
#include "Cache.hpp"
#include "CacheStatistics.hpp"
@@ -45,8 +50,9 @@ namespace Apache
generic<class TKey, class TValue>
TValue Region<TKey, TValue>::Get(TKey key, Object^ callbackArg)
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key);
- native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key, m_nativeptr->get()->getCache().get());
+ native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg, m_nativeptr->get()->getCache().get());
+ GC::KeepAlive(m_nativeptr);
auto nativeptr = this->get(keyptr, callbackptr);
if (nativeptr == nullptr)
{
@@ -93,7 +99,8 @@ namespace Apache
auto rAttributes = this->Attributes;
auto poolName = rAttributes->PoolName;
if (poolName != nullptr) {
- auto pool = PoolManager::Find(poolName);
+ auto poolManager = gcnew PoolManager(m_nativeptr->get()->getCache()->getPoolManager());
+ auto pool = poolManager->Find(poolName);
if (pool != nullptr && !pool->Destroyed) {
return pool->MultiuserAuthentication;
}
@@ -109,9 +116,9 @@ namespace Apache
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key);
- native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>(value);
- native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key, m_nativeptr->get()->getCache().get());
+ native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>(value, m_nativeptr->get()->getCache().get());
+ native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg, m_nativeptr->get()->getCache().get());
m_nativeptr->get()->put(keyptr, valueptr, callbackptr);
}
finally
@@ -125,7 +132,8 @@ namespace Apache
generic<class TKey, class TValue>
TValue Region<TKey, TValue>::default::get(TKey key)
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key, m_nativeptr->get()->getCache().get());
+ GC::KeepAlive(m_nativeptr);
auto nativeptr = this->get(keyptr);
if (nativeptr == nullptr)
{
@@ -142,8 +150,8 @@ namespace Apache
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key);
- native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>(value);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key, m_nativeptr->get()->getCache().get());
+ native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>(value, m_nativeptr->get()->getCache().get());
m_nativeptr->get()->put(keyptr, valueptr);
}
finally
@@ -233,15 +241,17 @@ namespace Apache
{
return false;
}
- native::DataOutput out1;
- native::DataOutput out2;
- val1->toData(out1);
- val2->toData(out2);
- if (out1.getBufferLength() != out2.getBufferLength())
+ std::unique_ptr<native::DataOutput> out1 = m_nativeptr->get_shared_ptr()->getCache()->createDataOutput();
+ std::unique_ptr<native::DataOutput> out2 = m_nativeptr->get_shared_ptr()->getCache()->createDataOutput();
+ val1->toData(*out1);
+ val2->toData(*out2);
+
+ GC::KeepAlive(m_nativeptr);
+ if (out1->getBufferLength() != out2->getBufferLength())
{
return false;
}
- else if (memcmp(out1.getBuffer(), out2.getBuffer(), out1.getBufferLength()) != 0)
+ else if (memcmp(out1->getBuffer(), out2->getBuffer(), out1->getBufferLength()) != 0)
{
return false;
}
@@ -253,7 +263,8 @@ namespace Apache
generic<class TKey, class TValue>
bool Region<TKey, TValue>::Contains(KeyValuePair<TKey, TValue> keyValuePair)
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(keyValuePair.Key);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(keyValuePair.Key, m_nativeptr->get()->getCache().get());
+ GC::KeepAlive(m_nativeptr);
auto nativeptr = this->get(keyptr);
//This means that key is not present.
if (nativeptr == nullptr) {
@@ -270,7 +281,7 @@ namespace Apache
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key, m_nativeptr->get()->getCache().get());
return m_nativeptr->get()->containsKeyOnServer(keyptr);
}
finally
@@ -285,7 +296,8 @@ namespace Apache
bool Region<TKey, TValue>::TryGetValue(TKey key, TValue %val)
{
_GF_MG_EXCEPTION_TRY2/* due to auto replace */
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key, m_nativeptr->get()->getCache().get());
+ GC::KeepAlive(m_nativeptr);
auto nativeptr = this->get(keyptr);
if (nativeptr == nullptr) {
val = TValue();
@@ -358,8 +370,8 @@ namespace Apache
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key);
- native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>(value);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key, m_nativeptr->get()->getCache().get());
+ native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>(value, m_nativeptr->get()->getCache().get());
m_nativeptr->get()->create(keyptr, valueptr);
}
finally
@@ -377,8 +389,8 @@ namespace Apache
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(keyValuePair.Key);
- native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>(keyValuePair.Value);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(keyValuePair.Key, m_nativeptr->get()->getCache().get());
+ native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>(keyValuePair.Value, m_nativeptr->get()->getCache().get());
m_nativeptr->get()->create(keyptr, valueptr);
}
finally
@@ -396,9 +408,9 @@ namespace Apache
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key);
- native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>(value);
- native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key, m_nativeptr->get()->getCache().get());
+ native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>(value, m_nativeptr->get()->getCache().get());
+ native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg, m_nativeptr->get()->getCache().get());
m_nativeptr->get()->create(keyptr, valueptr, callbackptr);
}
finally
@@ -416,7 +428,7 @@ namespace Apache
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key, m_nativeptr->get()->getCache().get());
return m_nativeptr->get()->removeEx(keyptr);
}
finally
@@ -435,8 +447,8 @@ namespace Apache
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key);
- native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key, m_nativeptr->get()->getCache().get());
+ native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg, m_nativeptr->get()->getCache().get());
return m_nativeptr->get()->removeEx(keyptr, callbackptr);
}
finally
@@ -454,8 +466,8 @@ namespace Apache
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(keyValuePair.Key);
- native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>(keyValuePair.Value);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(keyValuePair.Key, m_nativeptr->get()->getCache().get());
+ native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>(keyValuePair.Value, m_nativeptr->get()->getCache().get());
return m_nativeptr->get()->remove(keyptr, valueptr);
}
finally
@@ -473,9 +485,10 @@ namespace Apache
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key);
- native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>(value);
- native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key, m_nativeptr->get()->getCache().get());
+ native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>(value, m_nativeptr->get()->getCache().get());
+ native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg, m_nativeptr->get()->getCache().get());
+ GC::KeepAlive(m_nativeptr);
return m_nativeptr->get()->remove(keyptr, valueptr, callbackptr);
}
finally
@@ -503,7 +516,7 @@ namespace Apache
try
{
- native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg);
+ native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg, m_nativeptr->get()->getCache().get());
m_nativeptr->get()->invalidateRegion(callbackptr);
}
finally
@@ -531,7 +544,7 @@ namespace Apache
try
{
- native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg);
+ native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg, m_nativeptr->get()->getCache().get());
m_nativeptr->get()->destroyRegion(callbackptr);
}
finally
@@ -560,8 +573,8 @@ namespace Apache
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key);
- native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key, m_nativeptr->get()->getCache().get());
+ native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg, m_nativeptr->get()->getCache().get());
m_nativeptr->get()->invalidate(keyptr, callbackptr);
}
finally
@@ -591,8 +604,8 @@ namespace Apache
native::HashMapOfCacheable nativeMap;
for each (KeyValuePair<TKey, TValue> keyValPair in map)
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(keyValPair.Key);
- native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>(keyValPair.Value);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(keyValPair.Key, m_nativeptr->get()->getCache().get());
+ native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>(keyValPair.Value, m_nativeptr->get()->getCache().get());
nativeMap.emplace(keyptr, valueptr);
}
try
@@ -616,11 +629,11 @@ namespace Apache
native::HashMapOfCacheable nativeMap;
for each (KeyValuePair<TKey, TValue> keyValPair in map)
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(keyValPair.Key);
- native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>(keyValPair.Value);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(keyValPair.Key, m_nativeptr->get()->getCache().get());
+ native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>(keyValPair.Value, m_nativeptr->get()->getCache().get());
nativeMap.emplace(keyptr, valueptr);
}
- native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg);
+ native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg, m_nativeptr->get()->getCache().get());
try
{
m_nativeptr->get()->putAll(nativeMap, timeout, callbackptr);
@@ -661,7 +674,7 @@ namespace Apache
for each(TKey item in keys)
{
vecKeys.push_back(
- Serializable::GetUnmanagedValueGeneric<TKey>(item));
+ Serializable::GetUnmanagedValueGeneric<TKey>(item, m_nativeptr->get()->getCache().get()));
}
native::HashMapOfCacheablePtr valuesPtr;
@@ -716,7 +729,7 @@ namespace Apache
for each(TKey item in keys)
{
vecKeys.push_back(
- Serializable::GetUnmanagedValueGeneric<TKey>(item));
+ Serializable::GetUnmanagedValueGeneric<TKey>(item, m_nativeptr->get()->getCache().get()));
}
native::HashMapOfCacheablePtr valuesPtr;
@@ -728,7 +741,7 @@ namespace Apache
exceptionsPtr = std::make_shared<native::HashMapOfException>();
}
- native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg);
+ native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg, m_nativeptr->get()->getCache().get());
try
{
@@ -779,9 +792,9 @@ namespace Apache
native::VectorOfCacheableKey vecKeys;
for each(TKey item in keys)
- vecKeys.push_back(Serializable::GetUnmanagedValueGeneric<TKey>(item));
+ vecKeys.push_back(Serializable::GetUnmanagedValueGeneric<TKey>(item, m_nativeptr->get()->getCache().get()));
- native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg);
+ native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg, m_nativeptr->get()->getCache().get());
try
{
@@ -968,7 +981,7 @@ namespace Apache
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key, m_nativeptr->get()->getCache().get());
auto nativeptr = m_nativeptr->get()->getEntry(keyptr);
return RegionEntry<TKey, TValue>::Create(nativeptr);
}
@@ -1041,7 +1054,7 @@ namespace Apache
try
{
- native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key);
+ native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key, m_nativeptr->get()->getCache().get());
return m_nativeptr->get()->containsValueForKey(keyptr);
}
finally
@@ -1079,7 +1092,7 @@ namespace Apache
_GF_MG_EXCEPTION_TRY2/* due to auto replace */
try
{
- native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg);
+ native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg, m_nativeptr->get()->getCache().get());
m_nativeptr->get()->clear(callbackptr);
}
finally
@@ -1170,7 +1183,7 @@ namespace Apache
for each(TKey item in keys)
{
- vecKeys.push_back(Serializable::GetUnmanagedValueGeneric<TKey>(item));
+ vecKeys.push_back(Serializable::GetUnmanagedValueGeneric<TKey>(item, m_nativeptr->get()->getCache().get()));
}
try
{
@@ -1197,7 +1210,7 @@ namespace Apache
for each(TKey item in keys)
{
vecKeys.push_back(
- Serializable::GetUnmanagedValueGeneric<TKey>(item));
+ Serializable::GetUnmanagedValueGeneric<TKey>(item, m_nativeptr->get()->getCache().get()));
}
try
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/ResultCollector.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/ResultCollector.cpp b/src/clicache/src/ResultCollector.cpp
index 9b0e249..595bd9c 100644
--- a/src/clicache/src/ResultCollector.cpp
+++ b/src/clicache/src/ResultCollector.cpp
@@ -40,7 +40,7 @@ namespace Apache
try
{
- auto result = std::shared_ptr<native::Cacheable>(SafeGenericMSerializableConvert((IGeodeSerializable^)rs));
+ auto result = std::shared_ptr<native::Cacheable>(SafeGenericMSerializableConvert((IGeodeSerializable^)rs, nullptr));
m_nativeptr->get()->addResult(result);
}
finally
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/Serializable.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/Serializable.cpp b/src/clicache/src/Serializable.cpp
index 5771095..8760bab 100644
--- a/src/clicache/src/Serializable.cpp
+++ b/src/clicache/src/Serializable.cpp
@@ -16,7 +16,11 @@
*/
#include "begin_native.hpp"
+#include <geode/Cache.hpp>
#include <SerializationRegistry.hpp>
+#include <geode/PoolManager.hpp>
+#include <CacheImpl.hpp>
+#include "CacheRegionHelper.hpp"
#include "end_native.hpp"
#include <msclr/lock.h>
@@ -42,6 +46,9 @@
#include "CacheableIdentityHashMap.hpp"
#include "IPdxSerializer.hpp"
#include "impl/DotNetTypes.hpp"
+#include "CacheRegionHelper.hpp"
+#include "Cache.hpp"
+
#pragma warning(disable:4091)
using namespace System::Reflection;
@@ -255,27 +262,27 @@ namespace Apache
return (Apache::Geode::Client::Serializable^)CacheableStringArray::Create(value);
}
- System::Int32 Serializable::GetPDXIdForType(const char* poolName, IGeodeSerializable^ pdxType)
+ System::Int32 Serializable::GetPDXIdForType(const char* poolName, IGeodeSerializable^ pdxType, const native::Cache* cache)
{
native::CacheablePtr kPtr(SafeMSerializableConvertGeneric(pdxType));
- return native::SerializationRegistry::GetPDXIdForType(poolName, kPtr);
+ return CacheRegionHelper::getCacheImpl(cache)->getSerializationRegistry()->GetPDXIdForType(cache->getPoolManager().find(poolName), kPtr);
}
- IGeodeSerializable^ Serializable::GetPDXTypeById(const char* poolName, System::Int32 typeId)
- {
- SerializablePtr sPtr = native::SerializationRegistry::GetPDXTypeById(poolName, typeId);
+ IGeodeSerializable^ Serializable::GetPDXTypeById(const char* poolName, System::Int32 typeId, const native::Cache* cache)
+ {
+ SerializablePtr sPtr = CacheRegionHelper::getCacheImpl(cache)->getSerializationRegistry()->GetPDXTypeById(cache->getPoolManager().find(poolName), typeId);
return SafeUMSerializableConvertGeneric(sPtr);
}
- int Serializable::GetEnumValue(Internal::EnumInfo^ ei)
+ int Serializable::GetEnumValue(Internal::EnumInfo^ ei, const native::Cache* cache)
{
native::CacheablePtr kPtr(SafeMSerializableConvertGeneric(ei));
- return native::SerializationRegistry::GetEnumValue(kPtr);
+ return CacheRegionHelper::getCacheImpl(cache)->getSerializationRegistry()->GetEnumValue(cache->getPoolManager().getAll().begin()->second, kPtr);
}
- Internal::EnumInfo^ Serializable::GetEnum(int val)
+ Internal::EnumInfo^ Serializable::GetEnum(int val, const native::Cache* cache)
{
- SerializablePtr sPtr = native::SerializationRegistry::GetEnum(val);
+ SerializablePtr sPtr = CacheRegionHelper::getCacheImpl(cache)->getSerializationRegistry()->GetEnum(cache->getPoolManager().getAll().begin()->second, val);
return (Internal::EnumInfo^)SafeUMSerializableConvertGeneric(sPtr);
}
@@ -511,21 +518,22 @@ namespace Apache
return retVal();
}
- void Serializable::RegisterPDXManagedCacheableKey(bool appDomainEnable)
+ void Serializable::RegisterPDXManagedCacheableKey(bool appDomainEnable, Cache^ cache)
{
+ CacheImpl *cacheImpl = CacheRegionHelper::getCacheImpl(cache->GetNative().get());
if (!appDomainEnable)
{
- native::SerializationRegistry::addType(native::GeodeTypeIdsImpl::PDX,
+ cacheImpl->getSerializationRegistry()->addType(native::GeodeTypeIdsImpl::PDX,
&native::PdxManagedCacheableKey::CreateDeserializable);
}
else
{
- native::SerializationRegistry::addType(native::GeodeTypeIdsImpl::PDX,
- &native::PdxManagedCacheableKeyBytes::CreateDeserializable);
+ cacheImpl->getSerializationRegistry()->addType(native::GeodeTypeIdsImpl::PDX,
+ std::bind(native::PdxManagedCacheableKeyBytes::CreateDeserializable, cache->GetNative().get()));
}
}
- void Apache::Geode::Client::Serializable::RegisterTypeGeneric(TypeFactoryMethodGeneric^ creationMethod)
+ void Apache::Geode::Client::Serializable::RegisterTypeGeneric(TypeFactoryMethodGeneric^ creationMethod, Cache^ cache)
{
if (creationMethod == nullptr) {
throw gcnew IllegalArgumentException("Serializable.RegisterType(): "
@@ -539,7 +547,7 @@ namespace Apache
if (!ManagedDelegatesGeneric->ContainsKey(classId))
ManagedDelegatesGeneric->Add(classId, creationMethod);
- DelegateWrapperGeneric^ delegateObj = gcnew DelegateWrapperGeneric(creationMethod);
+ DelegateWrapperGeneric^ delegateObj = gcnew DelegateWrapperGeneric(creationMethod, cache);
TypeFactoryNativeMethodGeneric^ nativeDelegate =
gcnew TypeFactoryNativeMethodGeneric(delegateObj,
&DelegateWrapperGeneric::NativeDelegateGeneric);
@@ -554,22 +562,20 @@ namespace Apache
DelegateMapGeneric[tmp->ClassId] = creationMethod;
_GF_MG_EXCEPTION_TRY2
-
- native::Serializable::registerType((native::TypeFactoryMethod)
- System::Runtime::InteropServices::Marshal::
- GetFunctionPointerForDelegate(nativeDelegate).ToPointer());
+ CacheImpl *cacheImpl = CacheRegionHelper::getCacheImpl(cache->GetNative().get());
+ cacheImpl->getSerializationRegistry()->addType((native::Serializable*(*)())System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(nativeDelegate).ToPointer());
_GF_MG_EXCEPTION_CATCH_ALL2
}
void Apache::Geode::Client::Serializable::RegisterTypeGeneric(Byte typeId,
- TypeFactoryMethodGeneric^ creationMethod, Type^ type)
+ TypeFactoryMethodGeneric^ creationMethod, Type^ type, Cache^ cache)
{
if (creationMethod == nullptr) {
throw gcnew IllegalArgumentException("Serializable.RegisterType(): "
"null TypeFactoryMethod delegate passed");
}
- DelegateWrapperGeneric^ delegateObj = gcnew DelegateWrapperGeneric(creationMethod);
+ DelegateWrapperGeneric^ delegateObj = gcnew DelegateWrapperGeneric(creationMethod, cache);
TypeFactoryNativeMethodGeneric^ nativeDelegate =
gcnew TypeFactoryNativeMethodGeneric(delegateObj,
&DelegateWrapperGeneric::NativeDelegateGeneric);
@@ -591,17 +597,18 @@ namespace Apache
try
{
+ CacheImpl *cacheImpl = CacheRegionHelper::getCacheImpl(cache->GetNative().get());
if (tmp->ClassId < 0xa0000000)
{
- native::SerializationRegistry::addType(typeId,
- (native::TypeFactoryMethod)System::Runtime::InteropServices::
+ cacheImpl->getSerializationRegistry()->addType(typeId,
+ (native::Serializable*(*)())System::Runtime::InteropServices::
Marshal::GetFunctionPointerForDelegate(
nativeDelegate).ToPointer());
}
else
{//special case for CacheableUndefined type
- native::SerializationRegistry::addType2(typeId,
- (native::TypeFactoryMethod)System::Runtime::InteropServices::
+ cacheImpl->getSerializationRegistry()->addType2(typeId,
+ (native::Serializable*(*)())System::Runtime::InteropServices::
Marshal::GetFunctionPointerForDelegate(
nativeDelegate).ToPointer());
}
@@ -613,12 +620,12 @@ namespace Apache
}
}
- void Apache::Geode::Client::Serializable::UnregisterTypeGeneric(Byte typeId)
+ void Apache::Geode::Client::Serializable::UnregisterTypeGeneric(Byte typeId, Cache^ cache)
{
BuiltInDelegatesGeneric->Remove(typeId);
_GF_MG_EXCEPTION_TRY2
- native::SerializationRegistry::removeType(typeId);
+ CacheRegionHelper::getCacheImpl(cache->GetNative().get())->getSerializationRegistry()->removeType(typeId);
_GF_MG_EXCEPTION_CATCH_ALL2
}
@@ -935,23 +942,23 @@ namespace Apache
}
generic<class TKey>
- native::CacheableKeyPtr Serializable::GetUnmanagedValueGeneric(TKey key)
+ native::CacheableKeyPtr Serializable::GetUnmanagedValueGeneric(TKey key, native::Cache* cache)
{
//System::Type^ managedType = TKey::typeid;
if (key != nullptr) {
//System::Type^ managedType = key->GetType();
- return GetUnmanagedValueGeneric(key->GetType(), key);
+ return GetUnmanagedValueGeneric(key->GetType(), key, cache);
}
return nullptr;
}
generic<class TKey>
- native::CacheableKeyPtr Serializable::GetUnmanagedValueGeneric(TKey key, bool isAciiChar)
+ native::CacheableKeyPtr Serializable::GetUnmanagedValueGeneric(TKey key, bool isAciiChar, native::Cache* cache)
{
//System::Type^ managedType = TKey::typeid;
if (key != nullptr) {
//System::Type^ managedType = key->GetType();
- return GetUnmanagedValueGeneric(key->GetType(), key, isAciiChar);
+ return GetUnmanagedValueGeneric(key->GetType(), key, isAciiChar, cache);
}
return nullptr;
}
@@ -1066,14 +1073,14 @@ namespace Apache
generic<class TKey>
native::CacheableKeyPtr Serializable::GetUnmanagedValueGeneric(
- Type^ managedType, TKey key)
+ Type^ managedType, TKey key, native::Cache* cache)
{
- return GetUnmanagedValueGeneric(managedType, key, false);
+ return GetUnmanagedValueGeneric(managedType, key, false, cache);
}
generic<class TKey>
native::CacheableKeyPtr Serializable::GetUnmanagedValueGeneric(
- Type^ managedType, TKey key, bool isAsciiChar)
+ Type^ managedType, TKey key, bool isAsciiChar, native::Cache* cache)
{
Byte typeId = Apache::Geode::Client::Serializable::GetManagedTypeMappingGeneric(managedType);
@@ -1107,122 +1114,122 @@ namespace Apache
}
case native::GeodeTypeIds::CacheableBytes:
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableBytes::Create((array<Byte>^)key)));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableBytes::Create((array<Byte>^)key), cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
case native::GeodeTypeIds::CacheableDoubleArray:
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableDoubleArray::Create((array<Double>^)key)));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableDoubleArray::Create((array<Double>^)key), cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
case native::GeodeTypeIds::CacheableFloatArray:
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableFloatArray::Create((array<float>^)key)));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableFloatArray::Create((array<float>^)key), cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
case native::GeodeTypeIds::CacheableInt16Array:
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableInt16Array::Create((array<Int16>^)key)));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableInt16Array::Create((array<Int16>^)key), cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
case native::GeodeTypeIds::CacheableInt32Array:
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableInt32Array::Create((array<Int32>^)key)));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableInt32Array::Create((array<Int32>^)key), cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
case native::GeodeTypeIds::CacheableInt64Array:
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableInt64Array::Create((array<Int64>^)key)));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableInt64Array::Create((array<Int64>^)key), cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
case native::GeodeTypeIds::CacheableStringArray:
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableStringArray::Create((array<String^>^)key)));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableStringArray::Create((array<String^>^)key), cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
case native::GeodeTypeIds::CacheableFileName:
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)(Apache::Geode::Client::CacheableFileName^)key));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)(Apache::Geode::Client::CacheableFileName^)key, cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
case native::GeodeTypeIds::CacheableHashTable://collection::hashtable
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableHashTable::Create((System::Collections::Hashtable^)key)));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableHashTable::Create((System::Collections::Hashtable^)key), cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
case native::GeodeTypeIds::CacheableHashMap://generic dictionary
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableHashMap::Create((System::Collections::IDictionary^)key)));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableHashMap::Create((System::Collections::IDictionary^)key), cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
case native::GeodeTypeIds::CacheableVector://collection::arraylist
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)CacheableVector::Create((System::Collections::IList^)key)));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)CacheableVector::Create((System::Collections::IList^)key), cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
case native::GeodeTypeIds::CacheableArrayList://generic ilist
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableArrayList::Create((System::Collections::IList^)key)));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableArrayList::Create((System::Collections::IList^)key), cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
case native::GeodeTypeIds::CacheableLinkedList://generic linked list
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableLinkedList::Create((System::Collections::Generic::LinkedList<Object^>^)key)));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableLinkedList::Create((System::Collections::Generic::LinkedList<Object^>^)key), cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
case native::GeodeTypeIds::CacheableStack:
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert(Apache::Geode::Client::CacheableStack::Create((System::Collections::ICollection^)key)));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert(Apache::Geode::Client::CacheableStack::Create((System::Collections::ICollection^)key), cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
case 7: //GeodeClassIds::CacheableManagedObject
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert((Apache::Geode::Client::CacheableObject^)key));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert((Apache::Geode::Client::CacheableObject^)key, cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
case 8://GeodeClassIds::CacheableManagedObjectXml
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert((Apache::Geode::Client::CacheableObjectXml^)key));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert((Apache::Geode::Client::CacheableObjectXml^)key, cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
case native::GeodeTypeIds::CacheableObjectArray:
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert((Apache::Geode::Client::CacheableObjectArray^)key));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert((Apache::Geode::Client::CacheableObjectArray^)key, cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
case native::GeodeTypeIds::CacheableIdentityHashMap:
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert(Apache::Geode::Client::CacheableIdentityHashMap::Create((System::Collections::IDictionary^)key)));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert(Apache::Geode::Client::CacheableIdentityHashMap::Create((System::Collections::IDictionary^)key), cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
case native::GeodeTypeIds::CacheableHashSet://no need of it, default case should work
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert((Apache::Geode::Client::CacheableHashSet^)key));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert((Apache::Geode::Client::CacheableHashSet^)key, cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
case native::GeodeTypeIds::CacheableLinkedHashSet://no need of it, default case should work
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert((Apache::Geode::Client::CacheableLinkedHashSet^)key));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert((Apache::Geode::Client::CacheableLinkedHashSet^)key, cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
case native::GeodeTypeIds::CacheableDate:
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableDate::Create((System::DateTime)key)));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CacheableDate::Create((System::DateTime)key), cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
case native::GeodeTypeIds::BooleanArray:
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::BooleanArray::Create((array<bool>^)key)));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::BooleanArray::Create((array<bool>^)key), cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
case native::GeodeTypeIds::CharArray:
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CharArray::Create((array<Char>^)key)));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGeodeSerializable^)Apache::Geode::Client::CharArray::Create((array<Char>^)key), cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
default:
{
- native::CacheablePtr kPtr(SafeGenericMSerializableConvert(key));
+ native::CacheablePtr kPtr(SafeGenericMSerializableConvert(key, cache));
return std::dynamic_pointer_cast<native::CacheableKey>(kPtr);
}
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/Serializable.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/Serializable.hpp b/src/clicache/src/Serializable.hpp
index 999dc80..6f9e51f 100644
--- a/src/clicache/src/Serializable.hpp
+++ b/src/clicache/src/Serializable.hpp
@@ -31,6 +31,7 @@
#include "Log.hpp"
#include <vcclr.h>
#include "IPdxTypeMapper.hpp"
+
using namespace System::Reflection;
using namespace System;
using namespace System::Collections::Generic;
@@ -45,6 +46,8 @@ namespace Apache
interface class IPdxSerializable;
interface class IPdxSerializer;
+ ref class Cache;
+
/// <summary>
/// Signature of native function delegates passed to native
/// <c>native::Serializable::registerType</c>.
@@ -246,7 +249,8 @@ namespace Apache
/// to a <c>Serializable</c>.
/// </summary>
static operator Apache::Geode::Client::Serializable^ (array<String^>^ value);
-
+
+
/// <summary>
/// Register an instance factory method for a given type.
/// This should be used when registering types that implement
@@ -263,7 +267,7 @@ namespace Apache
/// in registering the type; check <c>Utils::LastError</c> for more
/// information in the latter case.
/// </exception>
- static void RegisterTypeGeneric(TypeFactoryMethodGeneric^ creationMethod);
+ static void RegisterTypeGeneric(TypeFactoryMethodGeneric^ creationMethod, Cache^ cache);
/// <summary>
/// Set the PDX serializer for the cache. If this serializer is set,
@@ -298,10 +302,10 @@ namespace Apache
internal:
- static System::Int32 GetPDXIdForType(const char* poolName, IGeodeSerializable^ pdxType);
- static IGeodeSerializable^ GetPDXTypeById(const char* poolName, System::Int32 typeId);
+ static System::Int32 GetPDXIdForType(const char* poolName, IGeodeSerializable^ pdxType, const native::Cache* cache);
+ static IGeodeSerializable^ GetPDXTypeById(const char* poolName, System::Int32 typeId, const native::Cache* cache);
static IPdxSerializable^ Serializable::GetPdxType(String^ className);
- static void RegisterPDXManagedCacheableKey(bool appDomainEnable);
+ static void RegisterPDXManagedCacheableKey(bool appDomainEnable, Cache^ cache);
static bool IsObjectAndPdxSerializerRegistered(String^ className);
static IPdxSerializer^ GetPdxSerializer();
@@ -311,8 +315,8 @@ namespace Apache
static Type^ GetType(String^ className);
- static int GetEnumValue(Internal::EnumInfo^ ei);
- static Internal::EnumInfo^ GetEnum(int val);
+ static int GetEnumValue(Internal::EnumInfo^ ei, const native::Cache* cache);
+ static Internal::EnumInfo^ GetEnum(int val, const native::Cache* cache);
static Dictionary<String^, PdxTypeFactoryMethod^>^ PdxDelegateMap =
gcnew Dictionary<String^, PdxTypeFactoryMethod^>();
@@ -441,31 +445,31 @@ namespace Apache
/// <exception cref="IllegalArgumentException">
/// if the method is null
/// </exception>
- static void RegisterTypeGeneric(Byte typeId,
- TypeFactoryMethodGeneric^ creationMethod, Type^ type);
+ static void RegisterTypeGeneric(Byte typeId, TypeFactoryMethodGeneric^ creationMethod, Type^ type, Cache^ cache);
+
/// <summary>
/// Unregister the type with the given typeId
/// </summary>
/// <param name="typeId">typeId of the type to unregister.</param>
- static void UnregisterTypeGeneric(Byte typeId);
+ static void UnregisterTypeGeneric(Byte typeId, Cache^ cache);
generic<class TValue>
static TValue GetManagedValueGeneric(native::SerializablePtr val);
generic<class TKey>
- static native::CacheableKeyPtr GetUnmanagedValueGeneric(TKey key);
+ static native::CacheableKeyPtr GetUnmanagedValueGeneric(TKey key, native::Cache* cache);
generic<class TKey>
- static native::CacheableKeyPtr GetUnmanagedValueGeneric(TKey key, bool isAciiChar);
+ static native::CacheableKeyPtr GetUnmanagedValueGeneric(TKey key, bool isAciiChar, native::Cache* cache);
generic<class TKey>
static native::CacheableKeyPtr GetUnmanagedValueGeneric(
- Type^ managedType, TKey key);
+ Type^ managedType, TKey key, native::Cache* cache);
generic<class TKey>
static native::CacheableKeyPtr GetUnmanagedValueGeneric(
- Type^ managedType, TKey key, bool isAsciiChar);
+ Type^ managedType, TKey key, bool isAsciiChar, native::Cache* cache);
/// <summary>
/// Static map of <c>TypeFactoryMethod</c> delegates created
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/StatisticsFactory.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/StatisticsFactory.cpp b/src/clicache/src/StatisticsFactory.cpp
index dd100e1..79cfc44 100644
--- a/src/clicache/src/StatisticsFactory.cpp
+++ b/src/clicache/src/StatisticsFactory.cpp
@@ -16,13 +16,14 @@
*/
+#include "begin_native.hpp"
+#include "statistics/StatisticsManager.hpp"
+#include "end_native.hpp"
-//#include "geode_includes.hpp"
#include "StatisticsFactory.hpp"
#include "StatisticsType.hpp"
#include "StatisticDescriptor.hpp"
#include "Statistics.hpp"
-
#include "impl/ManagedString.hpp"
#include "ExceptionTypes.hpp"
#include "impl/SafeConvert.hpp"
@@ -35,21 +36,23 @@ namespace Apache
namespace Client
{
- StatisticsFactory^ StatisticsFactory::GetExistingInstance()
- {
- _GF_MG_EXCEPTION_TRY2/* due to auto replace */
+ // TODO globals - pass in distributed system
+ //StatisticsFactory^ StatisticsFactory::GetExistingInstance(DistributedSystem^ distributedSystem)
+ //{
+ // _GF_MG_EXCEPTION_TRY2/* due to auto replace */
- return StatisticsFactory::Create(apache::geode::statistics::StatisticsFactory::getExistingInstance());
- _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
- }
+ // return StatisticsFactory::Create(distributedSystem->getStatisticsManager()->getStatisticsFactory());
+
+ // _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
+ //}
StatisticDescriptor^ StatisticsFactory::CreateIntCounter( String^ name, String^ description,String^ units )
{
return CreateIntCounter(name,description,units,true);
}
- StatisticDescriptor^ StatisticsFactory::CreateIntCounter(String^ name, String^ description,String^ units, int8_t largerBetter)
+ StatisticDescriptor^ StatisticsFactory::CreateIntCounter(String^ name, String^ description,String^ units, bool largerBetter)
{
ManagedString mg_name( name );
ManagedString mg_description( description );
@@ -66,7 +69,7 @@ namespace Apache
return CreateLongCounter(name,description,units,true);
}
- StatisticDescriptor^ StatisticsFactory::CreateLongCounter( String^ name, String^ description,String^ units, int8_t largerBetter )
+ StatisticDescriptor^ StatisticsFactory::CreateLongCounter( String^ name, String^ description,String^ units, bool largerBetter )
{
ManagedString mg_name( name );
ManagedString mg_description( description );
@@ -83,7 +86,7 @@ namespace Apache
return CreateDoubleCounter(name,description,units,true);
}
- StatisticDescriptor^ StatisticsFactory::CreateDoubleCounter( String^ name, String^ description, String^ units, int8_t largerBetter )
+ StatisticDescriptor^ StatisticsFactory::CreateDoubleCounter( String^ name, String^ description, String^ units, bool largerBetter )
{
ManagedString mg_name( name );
ManagedString mg_description( description );
@@ -101,7 +104,7 @@ namespace Apache
return CreateIntGauge(name,description,units,false);
}
- StatisticDescriptor^ StatisticsFactory::CreateIntGauge( String^ name, String^ description, String^ units, int8_t largerBetter )
+ StatisticDescriptor^ StatisticsFactory::CreateIntGauge( String^ name, String^ description, String^ units, bool largerBetter )
{
ManagedString mg_name( name );
ManagedString mg_description( description );
@@ -118,7 +121,7 @@ namespace Apache
return CreateLongGauge(name,description,units,false);
}
- StatisticDescriptor^ StatisticsFactory::CreateLongGauge( String^ name, String^ description, String^ units, int8_t largerBetter )
+ StatisticDescriptor^ StatisticsFactory::CreateLongGauge( String^ name, String^ description, String^ units, bool largerBetter )
{
ManagedString mg_name( name );
ManagedString mg_description( description );
@@ -135,7 +138,7 @@ namespace Apache
return CreateDoubleGauge(name,description,units,false);
}
- StatisticDescriptor^ StatisticsFactory::CreateDoubleGauge( String^ name, String^ description, String^ units,int8_t largerBetter )
+ StatisticDescriptor^ StatisticsFactory::CreateDoubleGauge( String^ name, String^ description, String^ units, bool largerBetter )
{
ManagedString mg_name( name );
ManagedString mg_description( description );
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/StatisticsFactory.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/StatisticsFactory.hpp b/src/clicache/src/StatisticsFactory.hpp
index 7a5d330..efce9c5 100644
--- a/src/clicache/src/StatisticsFactory.hpp
+++ b/src/clicache/src/StatisticsFactory.hpp
@@ -66,14 +66,14 @@ namespace Apache
/// Return a pre-existing statistics factory. Typically configured through
/// creation of a distributed system.
/// </summary>
- static StatisticsFactory^ GetExistingInstance();
+ //static StatisticsFactory^ GetExistingInstance();
/// <summary>
/// Creates and returns an int counter <see cref="StatisticDescriptor" />
/// with the given <c>name</c>, <c>description</c>,
/// <c>units</c>, and with larger values indicating better performance.
/// </summary>
- virtual StatisticDescriptor^ CreateIntCounter(String^ name, String^ description, String^ units, int8_t largerBetter);
+ virtual StatisticDescriptor^ CreateIntCounter(String^ name, String^ description, String^ units, bool largerBetter);
/// <summary>
/// Creates and returns an int counter <see cref="StatisticDescriptor" />
@@ -87,7 +87,7 @@ namespace Apache
/// with the given <c>name</c>, <c>description</c>,
/// <c>units</c>, and with larger values indicating better performance.
/// </summary>
- virtual StatisticDescriptor^ CreateLongCounter(String^ name, String^ description, String^ units, int8_t largerBetter);
+ virtual StatisticDescriptor^ CreateLongCounter(String^ name, String^ description, String^ units, bool largerBetter);
/// <summary>
/// Creates and returns an long counter <see cref="StatisticDescriptor" />
@@ -102,7 +102,7 @@ namespace Apache
/// <c>units</c>, and with larger values indicating better performance.
/// </summary>
- virtual StatisticDescriptor^ CreateDoubleCounter(String^ name, String^ description, String^ units, int8_t largerBetter);
+ virtual StatisticDescriptor^ CreateDoubleCounter(String^ name, String^ description, String^ units, bool largerBetter);
/// <summary>
/// Creates and returns an double counter <see cref="StatisticDescriptor" />
@@ -116,7 +116,7 @@ namespace Apache
/// with the given <c>name</c>, <c>description</c>,
/// <c>units</c>, and with smaller values indicating better performance.
/// </summary>
- virtual StatisticDescriptor^ CreateIntGauge(String^ name, String^ description, String^ units, int8_t largerBetter);
+ virtual StatisticDescriptor^ CreateIntGauge(String^ name, String^ description, String^ units, bool largerBetter);
/// <summary>
/// Creates and returns an int gauge <see cref="StatisticDescriptor" />
@@ -130,7 +130,7 @@ namespace Apache
/// with the given <c>name</c>, <c>description</c>,
/// <c>units</c>, and with smaller values indicating better performance.
/// </summary>
- virtual StatisticDescriptor^ CreateLongGauge(String^ name, String^ description, String^ units, int8_t largerBetter);
+ virtual StatisticDescriptor^ CreateLongGauge(String^ name, String^ description, String^ units, bool largerBetter);
/// <summary>
/// Creates and returns an long gauge <see cref="StatisticDescriptor" />
@@ -144,7 +144,7 @@ namespace Apache
/// with the given <c>name</c>, <c>description</c>,
/// <c>units</c>, and with smaller values indicating better performance.
/// </summary>
- virtual StatisticDescriptor^ CreateDoubleGauge(String^ name, String^ description, String^ units, int8_t largerBetter);
+ virtual StatisticDescriptor^ CreateDoubleGauge(String^ name, String^ description, String^ units, bool largerBetter);
/// <summary>
/// Creates and returns an double gauge <see cref="StatisticDescriptor" />
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/AuthenticatedCache.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/AuthenticatedCache.cpp b/src/clicache/src/impl/AuthenticatedCache.cpp
index a8e2b15..acd96c0 100644
--- a/src/clicache/src/impl/AuthenticatedCache.cpp
+++ b/src/clicache/src/impl/AuthenticatedCache.cpp
@@ -15,7 +15,12 @@
* limitations under the License.
*/
-//#include "../geode_includes.hpp"
+
+#include "begin_native.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
+#include "end_native.hpp"
+
#include "../Cache.hpp"
#include "../DistributedSystem.hpp"
#include "../Region.hpp"
@@ -25,6 +30,7 @@
#include "../Execution.hpp"
#include "AuthenticatedCache.hpp"
#include "PdxInstanceFactoryImpl.hpp"
+
using namespace System;
namespace Apache
@@ -123,7 +129,7 @@ namespace Apache
IPdxInstanceFactory^ AuthenticatedCache::CreatePdxInstanceFactory(String^ className)
{
- return gcnew Internal::PdxInstanceFactoryImpl(className);
+ return gcnew Internal::PdxInstanceFactoryImpl(className, native::CacheRegionHelper::getCacheImpl(m_nativeptr->get())->getCache());
}
} // namespace Client
} // namespace Geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/CacheLoader.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/CacheLoader.hpp b/src/clicache/src/impl/CacheLoader.hpp
index 9f8a049..c785338 100644
--- a/src/clicache/src/impl/CacheLoader.hpp
+++ b/src/clicache/src/impl/CacheLoader.hpp
@@ -70,7 +70,7 @@ namespace Apache
Object^ ghelper = Serializable::GetManagedValueGeneric<Object^>(helper);
//return SafeMSerializableConvertGeneric(m_loader->Load(gregion, gkey, ghelper));
- return Serializable::GetUnmanagedValueGeneric<TValue>(m_loader->Load(gregion, gkey, ghelper));
+ return Serializable::GetUnmanagedValueGeneric<TValue>(m_loader->Load(gregion, gkey, ghelper), nullptr);
}
virtual void close( const apache::geode::client::RegionPtr& region )
[07/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/TcrMessage.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TcrMessage.hpp b/src/cppcache/src/TcrMessage.hpp
index 30e95e0..60dd5a6 100644
--- a/src/cppcache/src/TcrMessage.hpp
+++ b/src/cppcache/src/TcrMessage.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_TCRMESSAGE_H_
-#define GEODE_TCRMESSAGE_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,6 +15,13 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_TCRMESSAGE_H_
+#define GEODE_TCRMESSAGE_H_
+
+#include <ace/OS.h>
+
#include <geode/geode_globals.hpp>
#include <atomic>
#include <geode/Cacheable.hpp>
@@ -40,6 +42,7 @@
#include "FixedPartitionAttributesImpl.hpp"
#include "VersionTag.hpp"
#include "VersionedCacheableObjectPartList.hpp"
+#include "SerializationRegistry.hpp"
#include <string>
#include <map>
#include <vector>
@@ -175,8 +178,6 @@ class CPPCACHE_EXPORT TcrMessage {
} MsgType;
- static bool init();
- static void cleanup();
static bool isKeepAlive() { return *m_keepalive; }
static bool isUserInitiativeOps(const TcrMessage& msg) {
int32_t msgType = msg.getMessageType();
@@ -207,11 +208,14 @@ class CPPCACHE_EXPORT TcrMessage {
}
return false;
}
- static VersionTagPtr readVersionTagPart(DataInput& input,
- uint16_t endpointMemId);
+ static VersionTagPtr readVersionTagPart(
+ DataInput& input, uint16_t endpointMemId,
+ MemberListForVersionStamp& memberListForVersionStamp);
/* constructors */
- void setData(const char* bytearray, int32_t len, uint16_t memId);
+ void setData(const char* bytearray, int32_t len, uint16_t memId,
+ const SerializationRegistry& serializationRegistry,
+ MemberListForVersionStamp& memberListForVersionStamp);
void startProcessChunk(ACE_Semaphore& finalizeSema);
// nullptr chunk means that this is the last chunk
@@ -336,11 +340,11 @@ class CPPCACHE_EXPORT TcrMessage {
/* we need a static method to generate ping */
/* The caller should not delete the message since it is global. */
- static TcrMessagePing* getPingMessage();
+ static TcrMessagePing* getPingMessage(Cache* cache);
static TcrMessage* getAllEPDisMess();
/* we need a static method to generate close connection message */
/* The caller should not delete the message since it is global. */
- static TcrMessage* getCloseConnMessage();
+ static TcrMessage* getCloseConnMessage(Cache* cache);
static void setKeepAlive(bool keepalive);
bool isDurable() const { return m_isDurable; }
bool receiveValues() const { return m_receiveValues; }
@@ -372,7 +376,7 @@ class CPPCACHE_EXPORT TcrMessage {
return m_versionObjPartListptr;
}
- DataInput* getDelta() { return m_delta; }
+ DataInput* getDelta() { return m_delta.get(); }
// getDeltaBytes( ) is called *only* by CqService, returns a CacheableBytes
// that
@@ -456,7 +460,7 @@ class CPPCACHE_EXPORT TcrMessage {
m_securityHeaderLength(0),
m_isMetaRegion(false),
exceptionMessage(),
- m_request(new DataOutput),
+ m_request(nullptr),
m_msgType(TcrMessage::INVALID),
m_msgLength(-1),
m_msgTypeRequest(0),
@@ -514,9 +518,6 @@ class CPPCACHE_EXPORT TcrMessage {
SerializablePtr readCacheableString(DataInput& input, int lenObj);
static std::atomic<int32_t> m_transactionId;
- static TcrMessagePing* m_pingMsg;
- static TcrMessage* m_closeConnMsg;
- static TcrMessage* m_allEPDisconnected;
static uint8_t* m_keepalive;
const static int m_flag_empty;
const static int m_flag_concurrency_checks;
@@ -531,13 +532,14 @@ class CPPCACHE_EXPORT TcrMessage {
CacheableStringPtr exceptionMessage;
- // Disallow copy constructor and assignment operator.
- TcrMessage(const TcrMessage&);
- TcrMessage& operator=(const TcrMessage&);
+ TcrMessage(const TcrMessage&) = delete;
+ TcrMessage& operator=(const TcrMessage&) = delete;
// some private methods to handle things internally.
- void handleByteArrayResponse(const char* bytearray, int32_t len,
- uint16_t endpointMemId);
+ void handleByteArrayResponse(
+ const char* bytearray, int32_t len, uint16_t endpointMemId,
+ const SerializationRegistry& serializationRegistry,
+ MemberListForVersionStamp& memberListForVersionStamp);
void readObjectPart(DataInput& input, bool defaultString = false);
void readFailedNodePart(DataInput& input, bool defaultString = false);
void readCallbackObjectPart(DataInput& input, bool defaultString = false);
@@ -547,7 +549,8 @@ class CPPCACHE_EXPORT TcrMessage {
void readLongPart(DataInput& input, uint64_t* intValue);
bool readExceptionPart(DataInput& input, uint8_t isLastChunk,
bool skipFirstPart = true);
- void readVersionTag(DataInput& input, uint16_t endpointMemId);
+ void readVersionTag(DataInput& input, uint16_t endpointMemId,
+ MemberListForVersionStamp& memberListForVersionStamp);
void readOldValue(DataInput& input);
void readPrMetaData(DataInput& input);
void writeObjectPart(const SerializablePtr& se, bool isDelta = false,
@@ -578,7 +581,7 @@ class CPPCACHE_EXPORT TcrMessage {
CacheableHashSetPtr& value);
DSMemberForVersionStampPtr readDSMember(
apache::geode::client::DataInput& input);
- DataOutput* m_request;
+ std::unique_ptr<DataOutput> m_request;
int32_t m_msgType;
int32_t m_msgLength;
int32_t m_msgTypeRequest; // the msgType of the request if this TcrMessage is
@@ -622,7 +625,7 @@ class CPPCACHE_EXPORT TcrMessage {
std::map<std::string, int>* m_cqs;
int32_t m_messageResponseTimeout;
bool m_boolValue;
- DataInput* m_delta;
+ std::unique_ptr<DataInput> m_delta;
uint8_t* m_deltaBytes;
int32_t m_deltaBytesLen;
bool m_isCallBackArguement;
@@ -641,425 +644,568 @@ class CPPCACHE_EXPORT TcrMessage {
class TcrMessageDestroyRegion : public TcrMessage {
public:
- TcrMessageDestroyRegion(const Region* region,
+ TcrMessageDestroyRegion(std::unique_ptr<DataOutput> dataOutput,
+ const Region* region,
const UserDataPtr& aCallbackArgument,
int messageResponsetimeout,
ThinClientBaseDM* connectionDM);
virtual ~TcrMessageDestroyRegion() {}
+
+ private:
};
class TcrMessageClearRegion : public TcrMessage {
public:
- TcrMessageClearRegion(const Region* region,
+ TcrMessageClearRegion(std::unique_ptr<DataOutput> dataOutput,
+ const Region* region,
const UserDataPtr& aCallbackArgument,
int messageResponsetimeout,
ThinClientBaseDM* connectionDM);
virtual ~TcrMessageClearRegion() {}
+
+ private:
};
class TcrMessageQuery : public TcrMessage {
public:
- TcrMessageQuery(const std::string& regionName, int messageResponsetimeout,
+ TcrMessageQuery(std::unique_ptr<DataOutput> dataOutput,
+ const std::string& regionName, int messageResponsetimeout,
ThinClientBaseDM* connectionDM);
virtual ~TcrMessageQuery() {}
+
+ private:
};
class TcrMessageStopCQ : public TcrMessage {
public:
- TcrMessageStopCQ(const std::string& regionName, int messageResponsetimeout,
+ TcrMessageStopCQ(std::unique_ptr<DataOutput> dataOutput,
+ const std::string& regionName, int messageResponsetimeout,
ThinClientBaseDM* connectionDM);
virtual ~TcrMessageStopCQ() {}
+
+ private:
};
class TcrMessageCloseCQ : public TcrMessage {
public:
- TcrMessageCloseCQ(const std::string& regionName, int messageResponsetimeout,
+ TcrMessageCloseCQ(std::unique_ptr<DataOutput> dataOutput,
+ const std::string& regionName, int messageResponsetimeout,
ThinClientBaseDM* connectionDM);
virtual ~TcrMessageCloseCQ() {}
+
+ private:
};
class TcrMessageQueryWithParameters : public TcrMessage {
public:
- TcrMessageQueryWithParameters(const std::string& regionName,
+ TcrMessageQueryWithParameters(std::unique_ptr<DataOutput> dataOutput,
+ const std::string& regionName,
const UserDataPtr& aCallbackArgument,
CacheableVectorPtr paramList,
int messageResponsetimeout,
ThinClientBaseDM* connectionDM);
virtual ~TcrMessageQueryWithParameters() {}
+
+ private:
};
class TcrMessageContainsKey : public TcrMessage {
public:
- TcrMessageContainsKey(const Region* region, const CacheableKeyPtr& key,
+ TcrMessageContainsKey(std::unique_ptr<DataOutput> dataOutput,
+ const Region* region, const CacheableKeyPtr& key,
const UserDataPtr& aCallbackArgument,
bool isContainsKey, ThinClientBaseDM* connectionDM);
virtual ~TcrMessageContainsKey() {}
+
+ private:
};
class TcrMessageGetDurableCqs : public TcrMessage {
public:
- TcrMessageGetDurableCqs(ThinClientBaseDM* connectionDM);
+ TcrMessageGetDurableCqs(std::unique_ptr<DataOutput> dataOutput,
+ ThinClientBaseDM* connectionDM);
virtual ~TcrMessageGetDurableCqs() {}
+
+ private:
};
class TcrMessageRequest : public TcrMessage {
public:
- TcrMessageRequest(const Region* region, const CacheableKeyPtr& key,
+ TcrMessageRequest(std::unique_ptr<DataOutput> dataOutput,
+ const Region* region, const CacheableKeyPtr& key,
const UserDataPtr& aCallbackArgument,
ThinClientBaseDM* connectionDM = nullptr);
virtual ~TcrMessageRequest() {}
+
+ private:
};
class TcrMessageInvalidate : public TcrMessage {
public:
- TcrMessageInvalidate(const Region* region, const CacheableKeyPtr& key,
+ TcrMessageInvalidate(std::unique_ptr<DataOutput> dataOutput,
+ const Region* region, const CacheableKeyPtr& key,
const UserDataPtr& aCallbackArgument,
ThinClientBaseDM* connectionDM = nullptr);
+
+ private:
};
class TcrMessageDestroy : public TcrMessage {
public:
- TcrMessageDestroy(const Region* region, const CacheableKeyPtr& key,
+ TcrMessageDestroy(std::unique_ptr<DataOutput> dataOutput,
+ const Region* region, const CacheableKeyPtr& key,
const CacheablePtr& value,
const UserDataPtr& aCallbackArgument,
ThinClientBaseDM* connectionDM = nullptr);
+
+ private:
};
class TcrMessageRegisterInterestList : public TcrMessage {
public:
TcrMessageRegisterInterestList(
- const Region* region, const VectorOfCacheableKey& keys,
- bool isDurable = false, bool isCachingEnabled = false,
- bool receiveValues = true,
+ std::unique_ptr<DataOutput> dataOutput, const Region* region,
+ const VectorOfCacheableKey& keys, bool isDurable = false,
+ bool isCachingEnabled = false, bool receiveValues = true,
InterestResultPolicy interestPolicy = InterestResultPolicy::NONE,
ThinClientBaseDM* connectionDM = nullptr);
virtual ~TcrMessageRegisterInterestList() {}
+
+ private:
};
class TcrMessageUnregisterInterestList : public TcrMessage {
public:
TcrMessageUnregisterInterestList(
- const Region* region, const VectorOfCacheableKey& keys,
- bool isDurable = false, bool isCachingEnabled = false,
- bool receiveValues = true,
+ std::unique_ptr<DataOutput> dataOutput, const Region* region,
+ const VectorOfCacheableKey& keys, bool isDurable = false,
+ bool isCachingEnabled = false, bool receiveValues = true,
InterestResultPolicy interestPolicy = InterestResultPolicy::NONE,
ThinClientBaseDM* connectionDM = nullptr);
virtual ~TcrMessageUnregisterInterestList() {}
+
+ private:
};
class TcrMessagePut : public TcrMessage {
public:
- TcrMessagePut(const Region* region, const CacheableKeyPtr& key,
- const CacheablePtr& value, const UserDataPtr& aCallbackArgument,
- bool isDelta = false, ThinClientBaseDM* connectionDM = nullptr,
+ TcrMessagePut(std::unique_ptr<DataOutput> dataOutput, const Region* region,
+ const CacheableKeyPtr& key, const CacheablePtr& value,
+ const UserDataPtr& aCallbackArgument, bool isDelta = false,
+ ThinClientBaseDM* connectionDM = nullptr,
bool isMetaRegion = false, bool fullValueAfterDeltaFail = false,
const char* regionName = nullptr);
virtual ~TcrMessagePut() {}
+
+ private:
};
class TcrMessageCreateRegion : public TcrMessage {
public:
TcrMessageCreateRegion(
- const std::string& str1, const std::string& str2,
+ std::unique_ptr<DataOutput> dataOutput, const std::string& str1,
+ const std::string& str2,
InterestResultPolicy interestPolicy = InterestResultPolicy::NONE,
bool isDurable = false, bool isCachingEnabled = false,
bool receiveValues = true, ThinClientBaseDM* connectionDM = nullptr);
virtual ~TcrMessageCreateRegion() {}
+
+ private:
};
class TcrMessageRegisterInterest : public TcrMessage {
public:
TcrMessageRegisterInterest(
- const std::string& str1, const std::string& str2,
+ std::unique_ptr<DataOutput> dataOutput, const std::string& str1,
+ const std::string& str2,
InterestResultPolicy interestPolicy = InterestResultPolicy::NONE,
bool isDurable = false, bool isCachingEnabled = false,
bool receiveValues = true, ThinClientBaseDM* connectionDM = nullptr);
virtual ~TcrMessageRegisterInterest() {}
+
+ private:
};
class TcrMessageUnregisterInterest : public TcrMessage {
public:
TcrMessageUnregisterInterest(
- const std::string& str1, const std::string& str2,
+ std::unique_ptr<DataOutput> dataOutput, const std::string& str1,
+ const std::string& str2,
InterestResultPolicy interestPolicy = InterestResultPolicy::NONE,
bool isDurable = false, bool isCachingEnabled = false,
bool receiveValues = true, ThinClientBaseDM* connectionDM = nullptr);
virtual ~TcrMessageUnregisterInterest() {}
+
+ private:
};
class TcrMessageTxSynchronization : public TcrMessage {
public:
- TcrMessageTxSynchronization(int ordinal, int txid, int status);
+ TcrMessageTxSynchronization(std::unique_ptr<DataOutput> dataOutput,
+ int ordinal, int txid, int status);
virtual ~TcrMessageTxSynchronization() {}
+
+ private:
};
class TcrMessageClientReady : public TcrMessage {
public:
- TcrMessageClientReady();
+ TcrMessageClientReady(std::unique_ptr<DataOutput> dataOutput);
virtual ~TcrMessageClientReady() {}
+
+ private:
};
class TcrMessageCommit : public TcrMessage {
public:
- TcrMessageCommit();
+ TcrMessageCommit(std::unique_ptr<DataOutput> dataOutput);
virtual ~TcrMessageCommit() {}
+
+ private:
};
class TcrMessageRollback : public TcrMessage {
public:
- TcrMessageRollback();
+ TcrMessageRollback(std::unique_ptr<DataOutput> dataOutput);
virtual ~TcrMessageRollback() {}
+
+ private:
};
class TcrMessageTxFailover : public TcrMessage {
public:
- TcrMessageTxFailover();
+ TcrMessageTxFailover(std::unique_ptr<DataOutput> dataOutput);
virtual ~TcrMessageTxFailover() {}
+
+ private:
};
class TcrMessageMakePrimary : public TcrMessage {
public:
- TcrMessageMakePrimary(bool processedMarker);
+ TcrMessageMakePrimary(std::unique_ptr<DataOutput> dataOutput,
+ bool processedMarker);
virtual ~TcrMessageMakePrimary() {}
+
+ private:
};
class TcrMessagePutAll : public TcrMessage {
public:
- TcrMessagePutAll(const Region* region, const HashMapOfCacheable& map,
- int messageResponsetimeout, ThinClientBaseDM* connectionDM,
+ TcrMessagePutAll(std::unique_ptr<DataOutput> dataOutput, const Region* region,
+ const HashMapOfCacheable& map, int messageResponsetimeout,
+ ThinClientBaseDM* connectionDM,
const UserDataPtr& aCallbackArgument);
virtual ~TcrMessagePutAll() {}
+
+ private:
};
class TcrMessageRemoveAll : public TcrMessage {
public:
- TcrMessageRemoveAll(const Region* region, const VectorOfCacheableKey& keys,
+ TcrMessageRemoveAll(std::unique_ptr<DataOutput> dataOutput,
+ const Region* region, const VectorOfCacheableKey& keys,
const UserDataPtr& aCallbackArgument,
ThinClientBaseDM* connectionDM = nullptr);
virtual ~TcrMessageRemoveAll() {}
+
+ private:
};
class TcrMessageExecuteCq : public TcrMessage {
public:
- TcrMessageExecuteCq(const std::string& str1, const std::string& str2,
+ TcrMessageExecuteCq(std::unique_ptr<DataOutput> dataOutput,
+ const std::string& str1, const std::string& str2,
int state, bool isDurable,
ThinClientBaseDM* connectionDM);
virtual ~TcrMessageExecuteCq() {}
+
+ private:
};
class TcrMessageExecuteCqWithIr : public TcrMessage {
public:
- TcrMessageExecuteCqWithIr(const std::string& str1, const std::string& str2,
+ TcrMessageExecuteCqWithIr(std::unique_ptr<DataOutput> dataOutput,
+ const std::string& str1, const std::string& str2,
int state, bool isDurable,
ThinClientBaseDM* connectionDM);
virtual ~TcrMessageExecuteCqWithIr() {}
+
+ private:
};
class TcrMessageExecuteRegionFunction : public TcrMessage {
public:
TcrMessageExecuteRegionFunction(
- const std::string& funcName, const Region* region,
- const CacheablePtr& args, CacheableVectorPtr routingObj,
- uint8_t getResult, CacheableHashSetPtr failedNodes, int32_t timeout,
+ std::unique_ptr<DataOutput> dataOutput, const std::string& funcName,
+ const Region* region, const CacheablePtr& args,
+ CacheableVectorPtr routingObj, uint8_t getResult,
+ CacheableHashSetPtr failedNodes, int32_t timeout,
ThinClientBaseDM* connectionDM = nullptr, int8_t reExecute = 0);
virtual ~TcrMessageExecuteRegionFunction() {}
+
+ private:
};
class TcrMessageExecuteRegionFunctionSingleHop : public TcrMessage {
public:
TcrMessageExecuteRegionFunctionSingleHop(
- const std::string& funcName, const Region* region,
- const CacheablePtr& args, CacheableHashSetPtr routingObj,
- uint8_t getResult, CacheableHashSetPtr failedNodes, bool allBuckets,
- int32_t timeout, ThinClientBaseDM* connectionDM);
+ std::unique_ptr<DataOutput> dataOutput, const std::string& funcName,
+ const Region* region, const CacheablePtr& args,
+ CacheableHashSetPtr routingObj, uint8_t getResult,
+ CacheableHashSetPtr failedNodes, bool allBuckets, int32_t timeout,
+ ThinClientBaseDM* connectionDM);
virtual ~TcrMessageExecuteRegionFunctionSingleHop() {}
+
+ private:
};
class TcrMessageGetClientPartitionAttributes : public TcrMessage {
public:
- TcrMessageGetClientPartitionAttributes(const char* regionName);
+ TcrMessageGetClientPartitionAttributes(std::unique_ptr<DataOutput> dataOutput,
+ const char* regionName);
virtual ~TcrMessageGetClientPartitionAttributes() {}
+
+ private:
};
class TcrMessageGetClientPrMetadata : public TcrMessage {
public:
- TcrMessageGetClientPrMetadata(const char* regionName);
+ TcrMessageGetClientPrMetadata(std::unique_ptr<DataOutput> dataOutput,
+ const char* regionName);
virtual ~TcrMessageGetClientPrMetadata() {}
+
+ private:
};
class TcrMessageSize : public TcrMessage {
public:
- TcrMessageSize(const char* regionName);
+ TcrMessageSize(std::unique_ptr<DataOutput> dataOutput,
+ const char* regionName);
virtual ~TcrMessageSize() {}
+
+ private:
};
class TcrMessageUserCredential : public TcrMessage {
public:
- TcrMessageUserCredential(PropertiesPtr creds,
+ TcrMessageUserCredential(std::unique_ptr<DataOutput> dataOutput,
+ PropertiesPtr creds,
ThinClientBaseDM* connectionDM = nullptr);
virtual ~TcrMessageUserCredential() {}
+
+ private:
};
class TcrMessageRemoveUserAuth : public TcrMessage {
public:
- TcrMessageRemoveUserAuth(bool keepAlive, ThinClientBaseDM* connectionDM);
+ TcrMessageRemoveUserAuth(std::unique_ptr<DataOutput> dataOutput,
+ bool keepAlive, ThinClientBaseDM* connectionDM);
virtual ~TcrMessageRemoveUserAuth() {}
+
+ private:
};
class TcrMessageGetPdxIdForType : public TcrMessage {
public:
- TcrMessageGetPdxIdForType(const CacheablePtr& pdxType,
+ TcrMessageGetPdxIdForType(std::unique_ptr<DataOutput> dataOutput,
+ const CacheablePtr& pdxType,
ThinClientBaseDM* connectionDM,
int32_t pdxTypeId = 0);
virtual ~TcrMessageGetPdxIdForType() {}
+
+ private:
};
class TcrMessageAddPdxType : public TcrMessage {
public:
- TcrMessageAddPdxType(const CacheablePtr& pdxType,
+ TcrMessageAddPdxType(std::unique_ptr<DataOutput> dataOutput,
+ const CacheablePtr& pdxType,
ThinClientBaseDM* connectionDM, int32_t pdxTypeId = 0);
virtual ~TcrMessageAddPdxType() {}
+
+ private:
};
class TcrMessageGetPdxIdForEnum : public TcrMessage {
public:
- TcrMessageGetPdxIdForEnum(const CacheablePtr& pdxType,
+ TcrMessageGetPdxIdForEnum(std::unique_ptr<DataOutput> dataOutput,
+ const CacheablePtr& pdxType,
ThinClientBaseDM* connectionDM,
int32_t pdxTypeId = 0);
virtual ~TcrMessageGetPdxIdForEnum() {}
+
+ private:
};
class TcrMessageAddPdxEnum : public TcrMessage {
public:
- TcrMessageAddPdxEnum(const CacheablePtr& pdxType,
+ TcrMessageAddPdxEnum(std::unique_ptr<DataOutput> dataOutput,
+ const CacheablePtr& pdxType,
ThinClientBaseDM* connectionDM, int32_t pdxTypeId = 0);
virtual ~TcrMessageAddPdxEnum() {}
+
+ private:
};
class TcrMessageGetPdxTypeById : public TcrMessage {
public:
- TcrMessageGetPdxTypeById(int32_t typeId, ThinClientBaseDM* connectionDM);
+ TcrMessageGetPdxTypeById(std::unique_ptr<DataOutput> dataOutput,
+ int32_t typeId, ThinClientBaseDM* connectionDM);
virtual ~TcrMessageGetPdxTypeById() {}
+
+ private:
};
class TcrMessageGetPdxEnumById : public TcrMessage {
public:
- TcrMessageGetPdxEnumById(int32_t typeId, ThinClientBaseDM* connectionDM);
+ TcrMessageGetPdxEnumById(std::unique_ptr<DataOutput> dataOutput,
+ int32_t typeId, ThinClientBaseDM* connectionDM);
virtual ~TcrMessageGetPdxEnumById() {}
+
+ private:
};
class TcrMessageGetFunctionAttributes : public TcrMessage {
public:
- TcrMessageGetFunctionAttributes(const std::string& funcName,
+ TcrMessageGetFunctionAttributes(std::unique_ptr<DataOutput> dataOutput,
+ const std::string& funcName,
ThinClientBaseDM* connectionDM = nullptr);
virtual ~TcrMessageGetFunctionAttributes() {}
+
+ private:
};
class TcrMessageKeySet : public TcrMessage {
public:
- TcrMessageKeySet(const std::string& funcName,
+ TcrMessageKeySet(std::unique_ptr<DataOutput> dataOutput,
+ const std::string& funcName,
ThinClientBaseDM* connectionDM = nullptr);
virtual ~TcrMessageKeySet() {}
+
+ private:
};
class TcrMessageRequestEventValue : public TcrMessage {
public:
- TcrMessageRequestEventValue(EventIdPtr eventId);
+ TcrMessageRequestEventValue(std::unique_ptr<DataOutput> dataOutput,
+ EventIdPtr eventId);
virtual ~TcrMessageRequestEventValue() {}
+
+ private:
};
class TcrMessagePeriodicAck : public TcrMessage {
public:
- TcrMessagePeriodicAck(const EventIdMapEntryList& entries);
+ TcrMessagePeriodicAck(std::unique_ptr<DataOutput> dataOutput,
+ const EventIdMapEntryList& entries);
virtual ~TcrMessagePeriodicAck() {}
+
+ private:
};
class TcrMessageUpdateClientNotification : public TcrMessage {
public:
- TcrMessageUpdateClientNotification(int32_t port);
+ TcrMessageUpdateClientNotification(std::unique_ptr<DataOutput> dataOutput,
+ int32_t port);
virtual ~TcrMessageUpdateClientNotification() {}
+
+ private:
};
class TcrMessageGetAll : public TcrMessage {
public:
- TcrMessageGetAll(const Region* region, const VectorOfCacheableKey* keys,
+ TcrMessageGetAll(std::unique_ptr<DataOutput> dataOutput, const Region* region,
+ const VectorOfCacheableKey* keys,
ThinClientBaseDM* connectionDM = nullptr,
const UserDataPtr& aCallbackArgument = nullptr);
virtual ~TcrMessageGetAll() {}
+
+ private:
};
class TcrMessageExecuteFunction : public TcrMessage {
public:
- TcrMessageExecuteFunction(const std::string& funcName,
+ TcrMessageExecuteFunction(std::unique_ptr<DataOutput> dataOutput,
+ const std::string& funcName,
const CacheablePtr& args, uint8_t getResult,
ThinClientBaseDM* connectionDM, int32_t timeout);
virtual ~TcrMessageExecuteFunction() {}
+
+ private:
};
class TcrMessagePing : public TcrMessage {
public:
- TcrMessagePing(bool decodeAll);
+ TcrMessagePing(std::unique_ptr<DataOutput> dataOutput, bool decodeAll);
virtual ~TcrMessagePing() {}
+
+ private:
};
class TcrMessageCloseConnection : public TcrMessage {
public:
- TcrMessageCloseConnection(bool decodeAll);
+ TcrMessageCloseConnection(std::unique_ptr<DataOutput> dataOutput,
+ bool decodeAll);
virtual ~TcrMessageCloseConnection() {}
+
+ private:
};
class TcrMessageClientMarker : public TcrMessage {
public:
- TcrMessageClientMarker(bool decodeAll);
+ TcrMessageClientMarker(std::unique_ptr<DataOutput> dataOutput,
+ bool decodeAll);
virtual ~TcrMessageClientMarker() {}
+
+ private:
};
class TcrMessageReply : public TcrMessage {
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/TcrPoolEndPoint.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TcrPoolEndPoint.cpp b/src/cppcache/src/TcrPoolEndPoint.cpp
index c88554d..9021fcd 100644
--- a/src/cppcache/src/TcrPoolEndPoint.cpp
+++ b/src/cppcache/src/TcrPoolEndPoint.cpp
@@ -64,13 +64,12 @@ GfErrType TcrPoolEndPoint::registerDM(bool clientNotification, bool isSecondary,
GfErrType err = GF_NOERR;
ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_dm->getPoolLock());
ACE_Guard<ACE_Recursive_Thread_Mutex> guardQueueHosted(getQueueHostedMutex());
-
+ auto& sysProp = m_cacheImpl->getDistributedSystem().getSystemProperties();
if (!connected()) {
TcrConnection* newConn;
- if ((err = createNewConnection(
- newConn, false, false,
- DistributedSystem::getSystemProperties()->connectTimeout(), 0,
- connected())) != GF_NOERR) {
+ if ((err = createNewConnection(newConn, false, false,
+ sysProp.connectTimeout(), 0, connected())) !=
+ GF_NOERR) {
setConnected(false);
return err;
}
@@ -85,10 +84,9 @@ GfErrType TcrPoolEndPoint::registerDM(bool clientNotification, bool isSecondary,
name().c_str());
if (m_numRegionListener == 0) {
- if ((err = createNewConnection(
- m_notifyConnection, true, isSecondary,
- DistributedSystem::getSystemProperties()->connectTimeout() * 3,
- 0)) != GF_NOERR) {
+ if ((err = createNewConnection(m_notifyConnection, true, isSecondary,
+ sysProp.connectTimeout() * 3, 0)) !=
+ GF_NOERR) {
setConnected(false);
LOGWARN("Failed to start subscription channel for endpoint %s",
name().c_str());
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ThinClientBaseDM.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ThinClientBaseDM.cpp b/src/cppcache/src/ThinClientBaseDM.cpp
index 0291c5a..adf882e 100644
--- a/src/cppcache/src/ThinClientBaseDM.cpp
+++ b/src/cppcache/src/ThinClientBaseDM.cpp
@@ -43,19 +43,21 @@ ThinClientBaseDM::ThinClientBaseDM(TcrConnectionManager& connManager,
ThinClientBaseDM::~ThinClientBaseDM() {}
void ThinClientBaseDM::init() {
- if (!DistributedSystem::getSystemProperties()->isGridClient()) {
- // start the chunk processing thread
- if (!DistributedSystem::getSystemProperties()
- ->disableChunkHandlerThread()) {
- startChunkProcessor();
- }
+ const auto& systemProperties = m_connManager.getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties();
+ if (!(systemProperties.isGridClient() &&
+ systemProperties.disableChunkHandlerThread())) {
+ startChunkProcessor();
}
m_initDone = true;
}
bool ThinClientBaseDM::isSecurityOn() {
- SystemProperties* sysProp = DistributedSystem::getSystemProperties();
- return sysProp->isSecurityOn();
+ return m_connManager.getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties()
+ .isSecurityOn();
}
void ThinClientBaseDM::destroy(bool keepalive) {
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ThinClientBaseDM.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ThinClientBaseDM.hpp b/src/cppcache/src/ThinClientBaseDM.hpp
index ad10981..b3d3f74 100644
--- a/src/cppcache/src/ThinClientBaseDM.hpp
+++ b/src/cppcache/src/ThinClientBaseDM.hpp
@@ -124,8 +124,10 @@ class ThinClientBaseDM {
LOGFINE("Delta enabled on server: %s",
s_isDeltaEnabledOnServer ? "true" : "false");
}
- TcrConnectionManager& getConnectionManager() { return m_connManager; }
+ TcrConnectionManager& getConnectionManager() const { return m_connManager; }
+
virtual size_t getNumberOfEndPoints() const { return 0; }
+
bool isNotAuthorizedException(const char* exceptionMsg) {
if (exceptionMsg != nullptr &&
strstr(exceptionMsg,
@@ -138,6 +140,7 @@ class ThinClientBaseDM {
}
return false;
}
+
bool isPutAllPartialResultException(const char* exceptionMsg) {
if (exceptionMsg != nullptr &&
strstr(
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ThinClientCacheDistributionManager.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ThinClientCacheDistributionManager.hpp b/src/cppcache/src/ThinClientCacheDistributionManager.hpp
index 1d859a9..20a5fb8 100644
--- a/src/cppcache/src/ThinClientCacheDistributionManager.hpp
+++ b/src/cppcache/src/ThinClientCacheDistributionManager.hpp
@@ -48,8 +48,8 @@ class CPPCACHE_EXPORT ThinClientCacheDistributionManager
GfErrType sendRequestToPrimary(TcrMessage& request, TcrMessageReply& reply);
protected:
- bool preFailoverAction();
- bool postFailoverAction(TcrEndpoint* endpoint);
+ virtual bool preFailoverAction();
+ virtual bool postFailoverAction(TcrEndpoint* endpoint);
private:
// Disallow default/copy constructor and assignment operator.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ThinClientDistributionManager.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ThinClientDistributionManager.cpp b/src/cppcache/src/ThinClientDistributionManager.cpp
index bc97b96..5fd092d 100644
--- a/src/cppcache/src/ThinClientDistributionManager.cpp
+++ b/src/cppcache/src/ThinClientDistributionManager.cpp
@@ -306,31 +306,23 @@ bool ThinClientDistributionManager::postFailoverAction(TcrEndpoint* endpoint) {
}
PropertiesPtr ThinClientDistributionManager::getCredentials(TcrEndpoint* ep) {
- PropertiesPtr tmpSecurityProperties =
- DistributedSystem::getSystemProperties()->getSecurityProperties();
+ const auto& distributedSystem =
+ m_connManager.getCacheImpl()->getDistributedSystem();
+ const auto& tmpSecurityProperties =
+ distributedSystem.getSystemProperties().getSecurityProperties();
- AuthInitializePtr authInitialize = DistributedSystem::m_impl->getAuthLoader();
-
- if (authInitialize != nullptr) {
+ if (const auto& authInitialize = distributedSystem.m_impl->getAuthLoader()) {
LOGFINER(
"ThinClientDistributionManager::getCredentials: acquired handle to "
"authLoader, "
"invoking getCredentials %s",
ep->name().c_str());
- /* adongre
- * CID 28900: Copy into fixed size buffer (STRING_OVERFLOW)
- * You might overrun the 100 byte fixed-size string "tmpEndpoint" by copying
- * the return
- * value of "stlp_std::basic_string<char, stlp_std::char_traits<char>,
- * stlp_std::allocator<char> >::c_str() const" without checking the
- * length.
- */
- // char tmpEndpoint[100] = { '\0' } ;
- // strcpy(tmpEndpoint, ep->name().c_str());
- PropertiesPtr tmpAuthIniSecurityProperties = authInitialize->getCredentials(
- tmpSecurityProperties, /*tmpEndpoint*/ ep->name().c_str());
+ const auto& tmpAuthIniSecurityProperties = authInitialize->getCredentials(
+ tmpSecurityProperties, ep->name().c_str());
+ LOGFINER("Done getting credentials");
return tmpAuthIniSecurityProperties;
}
+
return nullptr;
}
@@ -340,7 +332,9 @@ GfErrType ThinClientDistributionManager::sendUserCredentials(
GfErrType err = GF_NOERR;
- TcrMessageUserCredential request(credentials, this);
+ TcrMessageUserCredential request(
+ m_connManager.getCacheImpl()->getCache()->createDataOutput(), credentials,
+ this);
TcrMessageReply reply(true, this);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ThinClientHARegion.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ThinClientHARegion.cpp b/src/cppcache/src/ThinClientHARegion.cpp
index d59366e..5fd63fb 100644
--- a/src/cppcache/src/ThinClientHARegion.cpp
+++ b/src/cppcache/src/ThinClientHARegion.cpp
@@ -43,7 +43,9 @@ void ThinClientHARegion::initTCR() {
try {
bool isPool = m_attribute->getPoolName() != nullptr &&
strlen(m_attribute->getPoolName()) > 0;
- if (DistributedSystem::getSystemProperties()->isGridClient()) {
+ if (m_cacheImpl->getDistributedSystem()
+ .getSystemProperties()
+ .isGridClient()) {
LOGWARN(
"Region: HA region having notification channel created for grid "
"client; force starting required notification, cleanup and "
@@ -61,7 +63,10 @@ void ThinClientHARegion::initTCR() {
m_tcrdm->init();
} else {
m_tcrdm = dynamic_cast<ThinClientPoolHADM*>(
- PoolManager::find(m_attribute->getPoolName()).get());
+ m_cacheImpl->getCache()
+ ->getPoolManager()
+ .find(m_attribute->getPoolName())
+ .get());
if (m_tcrdm) {
m_poolDM = true;
// Pool DM should only be inited once and it
@@ -109,7 +114,7 @@ void ThinClientHARegion::handleMarker() {
if (m_listener != nullptr && !m_processedMarker) {
RegionEvent event(shared_from_this(), nullptr, false);
- int64_t sampleStartNanos = Utils::startStatOpTime();
+ int64_t sampleStartNanos = startStatOpTime();
try {
m_listener->afterRegionLive(event);
} catch (const Exception& ex) {
@@ -118,11 +123,9 @@ void ThinClientHARegion::handleMarker() {
} catch (...) {
LOGERROR("Unknown exception in CacheListener::afterRegionLive");
}
- m_cacheImpl->m_cacheStats->incListenerCalls();
- Utils::updateStatOpTime(
- m_regionStats->getStat(),
- RegionStatType::getInstance()->getListenerCallTimeId(),
- sampleStartNanos);
+ m_cacheImpl->getCachePerfStats().incListenerCalls();
+ updateStatOpTime(m_regionStats->getStat(),
+ m_regionStats->getListenerCallTimeId(), sampleStartNanos);
m_regionStats->incListenerCallsCompleted();
}
m_processedMarker = true;
@@ -155,7 +158,8 @@ void ThinClientHARegion::addDisMessToQueue() {
if (poolDM->m_redundancyManager->m_globalProcessedMarker &&
!m_processedMarker) {
- TcrMessage* regionMsg = new TcrMessageClientMarker(true);
+ TcrMessage* regionMsg =
+ new TcrMessageClientMarker(m_cache->createDataOutput(), true);
receiveNotification(regionMsg);
}
}
@@ -164,7 +168,8 @@ void ThinClientHARegion::addDisMessToQueue() {
GfErrType ThinClientHARegion::getNoThrow_FullObject(EventIdPtr eventId,
CacheablePtr& fullObject,
VersionTagPtr& versionTag) {
- TcrMessageRequestEventValue fullObjectMsg(eventId);
+ TcrMessageRequestEventValue fullObjectMsg(m_cache->createDataOutput(),
+ eventId);
TcrMessageReply reply(true, nullptr);
ThinClientPoolHADM* poolHADM = dynamic_cast<ThinClientPoolHADM*>(m_tcrdm);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ThinClientLocatorHelper.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ThinClientLocatorHelper.cpp b/src/cppcache/src/ThinClientLocatorHelper.cpp
index bb67290..59075f5 100644
--- a/src/cppcache/src/ThinClientLocatorHelper.cpp
+++ b/src/cppcache/src/ThinClientLocatorHelper.cpp
@@ -65,8 +65,15 @@ Connector* ThinClientLocatorHelper::createConnection(Connector*& conn,
uint32_t waitSeconds,
int32_t maxBuffSizePool) {
Connector* socket = nullptr;
- if (DistributedSystem::getSystemProperties()->sslEnabled()) {
- socket = new TcpSslConn(hostname, port, waitSeconds, maxBuffSizePool);
+ auto& systemProperties = m_poolDM->getConnectionManager()
+ .getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties();
+ if (m_poolDM && systemProperties.sslEnabled()) {
+ socket = new TcpSslConn(hostname, port, waitSeconds, maxBuffSizePool,
+ systemProperties.sslTrustStore(),
+ systemProperties.sslKeyStore(),
+ systemProperties.sslKeystorePassword());
} else {
socket = new TcpConn(hostname, port, waitSeconds, maxBuffSizePool);
}
@@ -78,6 +85,11 @@ Connector* ThinClientLocatorHelper::createConnection(Connector*& conn,
GfErrType ThinClientLocatorHelper::getAllServers(
std::vector<ServerLocation>& servers, const std::string& serverGrp) {
ACE_Guard<ACE_Thread_Mutex> guard(m_locatorLock);
+
+ auto& sysProps = m_poolDM->getConnectionManager()
+ .getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties();
for (unsigned i = 0; i < m_locHostPort.size(); i++) {
ServerLocation loc = m_locHostPort[i];
try {
@@ -89,15 +101,14 @@ GfErrType ThinClientLocatorHelper::getAllServers(
}
Connector* conn = nullptr;
ConnectionWrapper cw(conn);
- createConnection(
- conn, loc.getServerName().c_str(), loc.getPort(),
- DistributedSystem::getSystemProperties()->connectTimeout(), buffSize);
+ createConnection(conn, loc.getServerName().c_str(), loc.getPort(),
+ sysProps.connectTimeout(), buffSize);
GetAllServersRequest request(serverGrp);
- DataOutput data;
- data.writeInt((int32_t)1001); // GOSSIPVERSION
- data.writeObject(&request);
+ auto data = m_poolDM->getConnectionManager().getCacheImpl()->getCache()->createDataOutput();
+ data->writeInt((int32_t)1001); // GOSSIPVERSION
+ data->writeObject(&request);
int sentLength = conn->send(
- (char*)(data.getBuffer()), data.getBufferLength(),
+ (char*)(data->getBuffer()), data->getBufferLength(),
m_poolDM ? (m_poolDM->getReadTimeout() / 1000) * 1000 * 1000
: 10 * 1000 * 1000,
0);
@@ -117,23 +128,23 @@ GfErrType ThinClientLocatorHelper::getAllServers(
continue;
}
- DataInput di(reinterpret_cast<uint8_t*>(buff), receivedLength);
+ auto di = m_poolDM->getConnectionManager().getCacheImpl()->getCache()->createDataInput(
+ reinterpret_cast<uint8_t*>(buff), receivedLength);
GetAllServersResponsePtr response(nullptr);
/* adongre
* SSL Enabled on Location and not in the client
*/
int8_t acceptanceCode;
- di.read(&acceptanceCode);
- if (acceptanceCode == REPLY_SSL_ENABLED &&
- !DistributedSystem::getSystemProperties()->sslEnabled()) {
+ di->read(&acceptanceCode);
+ if (acceptanceCode == REPLY_SSL_ENABLED && !sysProps.sslEnabled()) {
LOGERROR("SSL is enabled on locator, enable SSL in client as well");
throw AuthenticationRequiredException(
"SSL is enabled on locator, enable SSL in client as well");
}
- di.rewindCursor(1);
+ di->rewindCursor(1);
- di.readObject(response);
+ di->readObject(response);
servers = response->getServers();
return GF_NOERR;
} catch (const AuthenticationRequiredException&) {
@@ -154,6 +165,10 @@ GfErrType ThinClientLocatorHelper::getEndpointForNewCallBackConn(
/*const std::set<TcrEndpoint*>& exclEndPts,*/
const std::string& serverGrp) {
ACE_Guard<ACE_Thread_Mutex> guard(m_locatorLock);
+ auto& sysProps = m_poolDM->getConnectionManager()
+ .getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties();
int locatorsRetry = 3;
if (m_poolDM) {
int poolRetry = m_poolDM->getRetryAttempts();
@@ -183,20 +198,17 @@ GfErrType ThinClientLocatorHelper::getEndpointForNewCallBackConn(
}
Connector* conn = nullptr;
ConnectionWrapper cw(conn);
- createConnection(
- conn, loc.getServerName().c_str(), loc.getPort(),
- DistributedSystem::getSystemProperties()->connectTimeout(), buffSize);
+ createConnection(conn, loc.getServerName().c_str(), loc.getPort(),
+ sysProps.connectTimeout(), buffSize);
QueueConnectionRequest request(memId, exclEndPts, redundancy, false,
serverGrp);
- DataOutput data;
- data.writeInt((int32_t)1001); // GOSSIPVERSION
- data.writeObject(&request);
+ auto data = m_poolDM->getConnectionManager().getCacheImpl()->getCache()->createDataOutput();
+ data->writeInt((int32_t)1001); // GOSSIPVERSION
+ data->writeObject(&request);
int sentLength = conn->send(
- (char*)(data.getBuffer()), data.getBufferLength(),
- m_poolDM
- ? (m_poolDM->getReadTimeout() / 1000) * 1000 * 1000
- : DistributedSystem::getSystemProperties()->connectTimeout() *
- 1000 * 1000,
+ (char*)(data->getBuffer()), data->getBufferLength(),
+ m_poolDM ? (m_poolDM->getReadTimeout() / 1000) * 1000 * 1000
+ : sysProps.connectTimeout() * 1000 * 1000,
0);
if (sentLength <= 0) {
// conn->close(); delete conn; conn = nullptr;
@@ -205,32 +217,30 @@ GfErrType ThinClientLocatorHelper::getEndpointForNewCallBackConn(
char buff[BUFF_SIZE];
int receivedLength = conn->receive(
buff, BUFF_SIZE,
- m_poolDM
- ? (m_poolDM->getReadTimeout() / 1000) * 1000 * 1000
- : DistributedSystem::getSystemProperties()->connectTimeout() *
- 1000 * 1000,
+ m_poolDM ? (m_poolDM->getReadTimeout() / 1000) * 1000 * 1000
+ : sysProps.connectTimeout() * 1000 * 1000,
0);
// conn->close();
// delete conn; conn = nullptr;
if (receivedLength <= 0) {
continue;
}
- DataInput di(reinterpret_cast<uint8_t*>(buff), receivedLength);
+ auto di = m_poolDM->getConnectionManager().getCacheImpl()->getCache()->createDataInput(
+ reinterpret_cast<uint8_t*>(buff), receivedLength);
QueueConnectionResponsePtr response(nullptr);
/* adongre
* ssl defect
*/
int8_t acceptanceCode;
- di.read(&acceptanceCode);
- if (acceptanceCode == REPLY_SSL_ENABLED &&
- !DistributedSystem::getSystemProperties()->sslEnabled()) {
+ di->read(&acceptanceCode);
+ if (acceptanceCode == REPLY_SSL_ENABLED && !sysProps.sslEnabled()) {
LOGERROR("SSL is enabled on locator, enable SSL in client as well");
throw AuthenticationRequiredException(
"SSL is enabled on locator, enable SSL in client as well");
}
- di.rewindCursor(1);
- di.readObject(response);
+ di->rewindCursor(1);
+ di->readObject(response);
outEndpoint = response->getServers();
return GF_NOERR;
} catch (const AuthenticationRequiredException& excp) {
@@ -251,6 +261,11 @@ GfErrType ThinClientLocatorHelper::getEndpointForNewFwdConn(
bool locatorFound = false;
int locatorsRetry = 3;
ACE_Guard<ACE_Thread_Mutex> guard(m_locatorLock);
+ auto& sysProps = m_poolDM->getConnectionManager()
+ .getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties();
+
if (m_poolDM) {
int poolRetry = m_poolDM->getRetryAttempts();
locatorsRetry = poolRetry <= 0 ? locatorsRetry : poolRetry;
@@ -278,28 +293,25 @@ GfErrType ThinClientLocatorHelper::getEndpointForNewFwdConn(
}
Connector* conn = nullptr;
ConnectionWrapper cw(conn);
- createConnection(
- conn, serLoc.getServerName().c_str(), serLoc.getPort(),
- DistributedSystem::getSystemProperties()->connectTimeout(), buffSize);
- DataOutput data;
- data.writeInt(1001); // GOSSIPVERSION
+ createConnection(conn, serLoc.getServerName().c_str(), serLoc.getPort(),
+ sysProps.connectTimeout(), buffSize);
+ auto data = m_poolDM->getConnectionManager().getCacheImpl()->getCache()->createDataOutput();
+ data->writeInt(1001); // GOSSIPVERSION
if (currentServer == nullptr) {
LOGDEBUG("Creating ClientConnectionRequest");
ClientConnectionRequest request(exclEndPts, serverGrp);
- data.writeObject(&request);
+ data->writeObject(&request);
} else {
LOGDEBUG("Creating ClientReplacementRequest for connection: ",
currentServer->getEndpointObject()->name().c_str());
ClientReplacementRequest request(
currentServer->getEndpointObject()->name(), exclEndPts, serverGrp);
- data.writeObject(&request);
+ data->writeObject(&request);
}
int sentLength = conn->send(
- (char*)(data.getBuffer()), data.getBufferLength(),
- m_poolDM
- ? (m_poolDM->getReadTimeout() / 1000) * 1000 * 1000
- : DistributedSystem::getSystemProperties()->connectTimeout() *
- 1000 * 1000,
+ (char*)(data->getBuffer()), data->getBufferLength(),
+ m_poolDM ? (m_poolDM->getReadTimeout() / 1000) * 1000 * 1000
+ : sysProps.connectTimeout() * 1000 * 1000,
0);
if (sentLength <= 0) {
// conn->close();
@@ -309,33 +321,31 @@ GfErrType ThinClientLocatorHelper::getEndpointForNewFwdConn(
char buff[BUFF_SIZE];
int receivedLength = conn->receive(
buff, BUFF_SIZE,
- m_poolDM
- ? (m_poolDM->getReadTimeout() / 1000) * 1000 * 1000
- : DistributedSystem::getSystemProperties()->connectTimeout() *
- 1000 * 1000,
+ m_poolDM ? (m_poolDM->getReadTimeout() / 1000) * 1000 * 1000
+ : sysProps.connectTimeout() * 1000 * 1000,
0);
// conn->close();
// delete conn;
if (receivedLength <= 0) {
continue; // return GF_EUNDEF;
}
- DataInput di(reinterpret_cast<uint8_t*>(buff), receivedLength);
+ auto di = m_poolDM->getConnectionManager().getCacheImpl()->getCache()->createDataInput(
+ reinterpret_cast<uint8_t*>(buff), receivedLength);
ClientConnectionResponsePtr response;
/* adongre
* SSL is enabled on locator and not in the client
*/
int8_t acceptanceCode;
- di.read(&acceptanceCode);
- if (acceptanceCode == REPLY_SSL_ENABLED &&
- !DistributedSystem::getSystemProperties()->sslEnabled()) {
+ di->read(&acceptanceCode);
+ if (acceptanceCode == REPLY_SSL_ENABLED && !sysProps.sslEnabled()) {
LOGERROR("SSL is enabled on locator, enable SSL in client as well");
throw AuthenticationRequiredException(
"SSL is enabled on locator, enable SSL in client as well");
}
- di.rewindCursor(1);
+ di->rewindCursor(1);
- di.readObject(response);
+ di->readObject(response);
response->printInfo();
if (!response->serverFound()) {
LOGFINE("Server not found");
@@ -366,6 +376,11 @@ GfErrType ThinClientLocatorHelper::getEndpointForNewFwdConn(
GfErrType ThinClientLocatorHelper::updateLocators(
const std::string& serverGrp) {
ACE_Guard<ACE_Thread_Mutex> guard(m_locatorLock);
+ auto& sysProps = m_poolDM->getConnectionManager()
+ .getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties();
+
for (unsigned attempts = 0; attempts < m_locHostPort.size(); attempts++) {
ServerLocation serLoc = m_locHostPort[attempts];
Connector* conn = nullptr;
@@ -378,19 +393,16 @@ GfErrType ThinClientLocatorHelper::updateLocators(
serLoc.getServerName().c_str(), serLoc.getPort(),
serverGrp.c_str());
ConnectionWrapper cw(conn);
- createConnection(
- conn, serLoc.getServerName().c_str(), serLoc.getPort(),
- DistributedSystem::getSystemProperties()->connectTimeout(), buffSize);
+ createConnection(conn, serLoc.getServerName().c_str(), serLoc.getPort(),
+ sysProps.connectTimeout(), buffSize);
LocatorListRequest request(serverGrp);
- DataOutput data;
- data.writeInt((int32_t)1001); // GOSSIPVERSION
- data.writeObject(&request);
+ auto data = m_poolDM->getConnectionManager().getCacheImpl()->getCache()->createDataOutput();
+ data->writeInt((int32_t)1001); // GOSSIPVERSION
+ data->writeObject(&request);
int sentLength = conn->send(
- (char*)(data.getBuffer()), data.getBufferLength(),
- m_poolDM
- ? (m_poolDM->getReadTimeout() / 1000) * 1000 * 1000
- : DistributedSystem::getSystemProperties()->connectTimeout() *
- 1000 * 1000,
+ (char*)(data->getBuffer()), data->getBufferLength(),
+ m_poolDM ? (m_poolDM->getReadTimeout() / 1000) * 1000 * 1000
+ : sysProps.connectTimeout() * 1000 * 1000,
0);
if (sentLength <= 0) {
// conn->close();
@@ -401,33 +413,31 @@ GfErrType ThinClientLocatorHelper::updateLocators(
char buff[BUFF_SIZE];
int receivedLength = conn->receive(
buff, BUFF_SIZE,
- m_poolDM
- ? (m_poolDM->getReadTimeout() / 1000) * 1000 * 1000
- : DistributedSystem::getSystemProperties()->connectTimeout() *
- 1000 * 1000,
+ m_poolDM ? (m_poolDM->getReadTimeout() / 1000) * 1000 * 1000
+ : sysProps.connectTimeout() * 1000 * 1000,
0);
// conn->close();
// delete conn; conn = nullptr;
if (receivedLength <= 0) {
continue;
}
- DataInput di(reinterpret_cast<uint8_t*>(buff), receivedLength);
+ auto di = m_poolDM->getConnectionManager().getCacheImpl()->getCache()->createDataInput(
+ reinterpret_cast<uint8_t*>(buff), receivedLength);
auto response = std::make_shared<LocatorListResponse>();
/* adongre
* SSL Enabled on Location and not in the client
*/
int8_t acceptanceCode;
- di.read(&acceptanceCode);
- if (acceptanceCode == REPLY_SSL_ENABLED &&
- !DistributedSystem::getSystemProperties()->sslEnabled()) {
+ di->read(&acceptanceCode);
+ if (acceptanceCode == REPLY_SSL_ENABLED && !sysProps.sslEnabled()) {
LOGERROR("SSL is enabled on locator, enable SSL in client as well");
throw AuthenticationRequiredException(
"SSL is enabled on locator, enable SSL in client as well");
}
- di.rewindCursor(1);
+ di->rewindCursor(1);
- di.readObject(response);
+ di->readObject(response);
std::vector<ServerLocation> locators = response->getLocators();
if (locators.size() > 0) {
RandGen randGen;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ThinClientPoolDM.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ThinClientPoolDM.cpp b/src/cppcache/src/ThinClientPoolDM.cpp
index 8205ba6..3950e5c 100644
--- a/src/cppcache/src/ThinClientPoolDM.cpp
+++ b/src/cppcache/src/ThinClientPoolDM.cpp
@@ -35,9 +35,6 @@
using namespace apache::geode::client;
using namespace apache::geode::statistics;
-ExpiryTaskManager* getCacheImplExpiryTaskManager();
-void removePool(const char*);
-
/* adongre
* CID 28730: Other violation (MISSING_COPY)
* Class "GetAllWork" owns resources that are managed in its constructor and
@@ -81,7 +78,8 @@ class GetAllWork : public PooledWork<GfErrType>,
m_keys(keys),
m_region(region),
m_aCallbackArgument(aCallbackArgument) {
- m_request = new TcrMessageGetAll(region.get(), m_keys.get(), m_poolDM,
+ m_request = new TcrMessageGetAll(region->getCache()->createDataOutput(),
+ region.get(), m_keys.get(), m_poolDM,
m_aCallbackArgument);
m_reply = new TcrMessageReply(true, m_poolDM);
if (m_poolDM->isMultiUserMode()) {
@@ -159,17 +157,19 @@ ThinClientPoolDM::ThinClientPoolDM(const char* name,
if (firstGurd) ClientProxyMembershipID::increaseSynchCounter();
firstGurd = true;
- SystemProperties* sysProp = DistributedSystem::getSystemProperties();
+ auto& distributedSystem =
+ m_connManager.getCacheImpl()->getDistributedSystem();
+
+ auto& sysProp = distributedSystem.getSystemProperties();
// to set security flag at pool level
- this->m_isSecurityOn = sysProp->isSecurityOn();
+ this->m_isSecurityOn = sysProp.isSecurityOn();
ACE_TCHAR hostName[256];
ACE_OS::hostname(hostName, sizeof(hostName) - 1);
ACE_INET_Addr driver(hostName);
uint32_t hostAddr = driver.get_ip_address();
uint16_t hostPort = 0;
- const char* durableId =
- (sysProp != nullptr) ? sysProp->durableClientId() : nullptr;
+ const char* durableId = sysProp.durableClientId();
std::string poolSeparator = "_gem_";
std::string clientDurableId =
@@ -179,10 +179,11 @@ ThinClientPoolDM::ThinClientPoolDM(const char* name,
? (poolSeparator + m_poolName)
: "");
- const uint32_t durableTimeOut =
- (sysProp != nullptr) ? sysProp->durableTimeout() : 0;
- m_memId = new ClientProxyMembershipID(
- hostName, hostAddr, hostPort, clientDurableId.c_str(), durableTimeOut);
+ const uint32_t durableTimeOut = sysProp.durableTimeout();
+ m_memId =
+ m_connManager.getCacheImpl()->getClientProxyMembershipIDFactory().create(
+ hostName, hostAddr, hostPort, clientDurableId.c_str(),
+ durableTimeOut);
if (m_attrs->m_initLocList.size() == 0 &&
m_attrs->m_initServList.size() == 0) {
@@ -193,9 +194,12 @@ ThinClientPoolDM::ThinClientPoolDM(const char* name,
reset();
m_locHelper = new ThinClientLocatorHelper(m_attrs->m_initLocList, this);
- m_stats = new PoolStats(m_poolName.c_str());
+ auto statisticsManager = distributedSystem.getStatisticsManager();
+ m_stats =
+ new PoolStats(statisticsManager->getStatisticsFactory(), m_poolName);
+ statisticsManager->forceSample();
- if (!sysProp->isEndpointShufflingDisabled()) {
+ if (!sysProp.isEndpointShufflingDisabled()) {
if (m_attrs->m_initServList.size() > 0) {
RandGen randgen;
m_server = randgen(static_cast<uint32_t>(m_attrs->m_initServList.size()));
@@ -210,26 +214,26 @@ ThinClientPoolDM::ThinClientPoolDM(const char* name,
void ThinClientPoolDM::init() {
LOGDEBUG("ThinClientPoolDM::init: Starting pool initialization");
- SystemProperties* sysProp = DistributedSystem::getSystemProperties();
+ auto& sysProp = m_connManager.getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties();
m_isMultiUserMode = this->getMultiuserAuthentication();
if (m_isMultiUserMode) {
LOGINFO("Multiuser authentication is enabled for pool %s",
m_poolName.c_str());
}
// to set security flag at pool level
- this->m_isSecurityOn = sysProp->isSecurityOn();
+ this->m_isSecurityOn = sysProp.isSecurityOn();
LOGDEBUG("ThinClientPoolDM::init: security in on/off = %d ",
this->m_isSecurityOn);
m_connManager.init(true);
- SystemProperties* props = DistributedSystem::getSystemProperties();
-
LOGDEBUG("ThinClientPoolDM::init: is grid client = %d ",
- props->isGridClient());
+ sysProp.isGridClient());
- if (!props->isGridClient()) {
+ if (!sysProp.isGridClient()) {
ThinClientPoolDM::startBackgroundThreads();
}
@@ -237,20 +241,22 @@ void ThinClientPoolDM::init() {
}
PropertiesPtr ThinClientPoolDM::getCredentials(TcrEndpoint* ep) {
- PropertiesPtr tmpSecurityProperties =
- DistributedSystem::getSystemProperties()->getSecurityProperties();
+ const auto& distributedSystem =
+ m_connManager.getCacheImpl()->getDistributedSystem();
+ const auto& tmpSecurityProperties =
+ distributedSystem.getSystemProperties().getSecurityProperties();
- AuthInitializePtr authInitialize = DistributedSystem::m_impl->getAuthLoader();
-
- if (authInitialize != nullptr) {
+ if (const auto& authInitialize = distributedSystem.m_impl->getAuthLoader()) {
LOGFINER(
"ThinClientPoolDM::getCredentials: acquired handle to authLoader, "
"invoking getCredentials %s",
ep->name().c_str());
- PropertiesPtr tmpAuthIniSecurityProperties = authInitialize->getCredentials(
+ const auto& tmpAuthIniSecurityProperties = authInitialize->getCredentials(
tmpSecurityProperties, ep->name().c_str());
+ LOGFINER("Done getting credentials");
return tmpAuthIniSecurityProperties;
}
+
return nullptr;
}
@@ -260,9 +266,11 @@ void ThinClientPoolDM::startBackgroundThreads() {
NC_Ping_Thread);
m_pingTask->start();
- SystemProperties* props = DistributedSystem::getSystemProperties();
+ auto& props = m_connManager.getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties();
- if (props->onClientDisconnectClearPdxTypeIds() == true) {
+ if (props.onClientDisconnectClearPdxTypeIds() == true) {
m_cliCallbackTask =
new Task<ThinClientPoolDM>(this, &ThinClientPoolDM::cliCallback);
m_cliCallbackTask->start();
@@ -277,8 +285,9 @@ void ThinClientPoolDM::startBackgroundThreads() {
LOGDEBUG(
"ThinClientPoolDM::startBackgroundThreads: Scheduling ping task at %ld",
pingInterval);
- m_pingTaskId = getCacheImplExpiryTaskManager()->scheduleExpiryTask(
- pingHandler, 1, pingInterval, false);
+ m_pingTaskId =
+ m_connManager.getCacheImpl()->getExpiryTaskManager().scheduleExpiryTask(
+ pingHandler, 1, pingInterval, false);
} else {
LOGDEBUG(
"ThinClientPoolDM::startBackgroundThreads: Not Scheduling ping task as "
@@ -306,7 +315,7 @@ void ThinClientPoolDM::startBackgroundThreads() {
"task at %ld",
updateLocatorListInterval);
m_updateLocatorListTaskId =
- getCacheImplExpiryTaskManager()->scheduleExpiryTask(
+ m_connManager.getCacheImpl()->getExpiryTaskManager().scheduleExpiryTask(
updateLocatorListHandler, 1, updateLocatorListInterval, false);
}
@@ -337,8 +346,9 @@ void ThinClientPoolDM::startBackgroundThreads() {
LOGDEBUG(
"ThinClientPoolDM::startBackgroundThreads: Scheduling "
"manageConnections task");
- m_connManageTaskId = getCacheImplExpiryTaskManager()->scheduleExpiryTask(
- connHandler, 1, idle / 1000 + 1, false);
+ m_connManageTaskId =
+ m_connManager.getCacheImpl()->getExpiryTaskManager().scheduleExpiryTask(
+ connHandler, 1, idle / 1000 + 1, false);
}
LOGDEBUG(
@@ -352,7 +362,7 @@ void ThinClientPoolDM::startBackgroundThreads() {
LOGDEBUG(
"ThinClientPoolDM::startBackgroundThreads: Starting pool stat sampler");
if (m_PoolStatsSampler == nullptr && getStatisticInterval() > -1 &&
- DistributedSystem::getSystemProperties()->statisticsEnabled()) {
+ props.statisticsEnabled()) {
m_PoolStatsSampler = new PoolStatsSampler(
getStatisticInterval() / 1000 + 1, m_connManager.getCacheImpl(), this);
m_PoolStatsSampler->start();
@@ -470,7 +480,7 @@ void ThinClientPoolDM::cleanStaleConnections(volatile bool& isRunning) {
}
}
if (m_connManageTaskId >= 0 && isRunning &&
- getCacheImplExpiryTaskManager()->resetTask(
+ m_connManager.getCacheImpl()->getExpiryTaskManager().resetTask(
m_connManageTaskId, static_cast<uint32_t>(_nextIdle.sec() + 1))) {
LOGERROR("Failed to reschedule connection manager");
} else {
@@ -619,7 +629,7 @@ GfErrType ThinClientPoolDM::sendRequestToAllServers(
int feIndex = 0;
FunctionExecution* fePtrList = new FunctionExecution[csArray->length()];
- ThreadPool* threadPool = TPSingleton::instance();
+ auto* threadPool = m_connManager.getCacheImpl()->getThreadPool();
UserAttributesPtr userAttr =
TSSUserAttributesWrapper::s_geodeTSSUserAttributes->getUserAttributes();
for (int i = 0; i < csArray->length(); i++) {
@@ -746,7 +756,8 @@ void ThinClientPoolDM::stopPingThread() {
m_pingTask->wait();
GF_SAFE_DELETE(m_pingTask);
if (m_pingTaskId >= 0) {
- getCacheImplExpiryTaskManager()->cancelTask(m_pingTaskId);
+ m_connManager.getCacheImpl()->getExpiryTaskManager().cancelTask(
+ m_pingTaskId);
}
}
}
@@ -759,7 +770,8 @@ void ThinClientPoolDM::stopUpdateLocatorListThread() {
m_updateLocatorListTask->wait();
GF_SAFE_DELETE(m_updateLocatorListTask);
if (m_updateLocatorListTaskId >= 0) {
- getCacheImplExpiryTaskManager()->cancelTask(m_updateLocatorListTaskId);
+ m_connManager.getCacheImpl()->getExpiryTaskManager().cancelTask(
+ m_updateLocatorListTaskId);
}
}
}
@@ -798,7 +810,8 @@ void ThinClientPoolDM::destroy(bool keepAlive) {
m_connManageTask->wait();
GF_SAFE_DELETE(m_connManageTask);
if (m_connManageTaskId >= 0) {
- getCacheImplExpiryTaskManager()->cancelTask(m_connManageTaskId);
+ m_connManager.getCacheImpl()->getExpiryTaskManager().cancelTask(
+ m_connManageTaskId);
}
}
@@ -827,12 +840,17 @@ void ThinClientPoolDM::destroy(bool keepAlive) {
// Close Stats
getStats().close();
+ m_connManager.getCacheImpl()
+ ->getDistributedSystem()
+ .getStatisticsManager()
+ ->forceSample();
if (m_clientMetadataService != nullptr) {
GF_SAFE_DELETE(m_clientMetadataService);
}
- removePool(m_poolName.c_str());
+ m_connManager.getCacheImpl()->getCache()->getPoolManager().removePool(
+ m_poolName.c_str());
stopChunkProcessor();
m_manager->closeAllStickyConnections();
@@ -868,9 +886,11 @@ QueryServicePtr ThinClientPoolDM::getQueryServiceWithoutCheck() {
if (!(m_remoteQueryServicePtr == nullptr)) {
return m_remoteQueryServicePtr;
}
- SystemProperties* props = DistributedSystem::getSystemProperties();
+ auto& props = m_connManager.getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties();
- if (props->isGridClient()) {
+ if (props.isGridClient()) {
LOGWARN("Initializing query service while grid-client setting is enabled.");
// Init Query Service
m_remoteQueryServicePtr = std::make_shared<RemoteQueryService>(
@@ -895,7 +915,9 @@ void ThinClientPoolDM::sendUserCacheCloseMessage(bool keepAlive) {
for (it = uca.begin(); it != uca.end(); it++) {
UserConnectionAttributes* uca = (*it).second;
if (uca->isAuthenticated() && uca->getEndpoint()->connected()) {
- TcrMessageRemoveUserAuth request(keepAlive, this);
+ TcrMessageRemoveUserAuth request(
+ m_connManager.getCacheImpl()->getCache()->createDataOutput(),
+ keepAlive, this);
TcrMessageReply reply(true, this);
sendRequestToEP(request, reply, uca->getEndpoint());
@@ -927,7 +949,9 @@ int32_t ThinClientPoolDM::GetPDXIdForType(SerializablePtr pdxType) {
GfErrType err = GF_NOERR;
- TcrMessageGetPdxIdForType request(pdxType, this);
+ TcrMessageGetPdxIdForType request(
+ m_connManager.getCacheImpl()->getCache()->createDataOutput(), pdxType,
+ this);
TcrMessageReply reply(true, this);
@@ -946,7 +970,9 @@ int32_t ThinClientPoolDM::GetPDXIdForType(SerializablePtr pdxType) {
// need to broadcast this id to all other pool
{
- for (const auto& iter : PoolManager::getAll()) {
+ auto& poolManager =
+ m_connManager.getCacheImpl()->getCache()->getPoolManager();
+ for (const auto& iter : poolManager.getAll()) {
auto currPool = static_cast<ThinClientPoolDM*>(iter.second.get());
if (currPool != this) {
@@ -963,7 +989,9 @@ void ThinClientPoolDM::AddPdxType(SerializablePtr pdxType, int32_t pdxTypeId) {
GfErrType err = GF_NOERR;
- TcrMessageAddPdxType request(pdxType, this, pdxTypeId);
+ TcrMessageAddPdxType request(
+ m_connManager.getCacheImpl()->getCache()->createDataOutput(), pdxType,
+ this, pdxTypeId);
TcrMessageReply reply(true, this);
@@ -983,7 +1011,9 @@ SerializablePtr ThinClientPoolDM::GetPDXTypeById(int32_t typeId) {
GfErrType err = GF_NOERR;
- TcrMessageGetPdxTypeById request(typeId, this);
+ TcrMessageGetPdxTypeById request(
+ m_connManager.getCacheImpl()->getCache()->createDataOutput(), typeId,
+ this);
TcrMessageReply reply(true, this);
@@ -1005,7 +1035,9 @@ int32_t ThinClientPoolDM::GetEnumValue(SerializablePtr enumInfo) {
GfErrType err = GF_NOERR;
- TcrMessageGetPdxIdForEnum request(enumInfo, this);
+ TcrMessageGetPdxIdForEnum request(
+ m_connManager.getCacheImpl()->getCache()->createDataOutput(), enumInfo,
+ this);
TcrMessageReply reply(true, this);
@@ -1024,7 +1056,9 @@ int32_t ThinClientPoolDM::GetEnumValue(SerializablePtr enumInfo) {
// need to broadcast this id to all other pool
{
- for (const auto& iter : PoolManager::getAll()) {
+ auto& poolManager =
+ m_connManager.getCacheImpl()->getCache()->getPoolManager();
+ for (const auto& iter : poolManager.getAll()) {
const auto& currPool =
std::dynamic_pointer_cast<ThinClientPoolDM>(iter.second);
@@ -1042,7 +1076,8 @@ SerializablePtr ThinClientPoolDM::GetEnum(int32_t val) {
GfErrType err = GF_NOERR;
- TcrMessageGetPdxEnumById request(val, this);
+ TcrMessageGetPdxEnumById request(
+ m_connManager.getCacheImpl()->getCache()->createDataOutput(), val, this);
TcrMessageReply reply(true, this);
@@ -1064,7 +1099,9 @@ void ThinClientPoolDM::AddEnum(SerializablePtr enumInfo, int enumVal) {
GfErrType err = GF_NOERR;
- TcrMessageAddPdxEnum request(enumInfo, this, enumVal);
+ TcrMessageAddPdxEnum request(
+ m_connManager.getCacheImpl()->getCache()->createDataOutput(), enumInfo,
+ this, enumVal);
TcrMessageReply reply(true, this);
@@ -1087,7 +1124,9 @@ GfErrType ThinClientPoolDM::sendUserCredentials(PropertiesPtr credentials,
GfErrType err = GF_NOERR;
- TcrMessageUserCredential request(credentials, this);
+ TcrMessageUserCredential request(
+ m_connManager.getCacheImpl()->getCache()->createDataOutput(), credentials,
+ this);
TcrMessageReply reply(true, this);
@@ -1257,7 +1296,7 @@ GfErrType ThinClientPoolDM::sendSyncRequest(TcrMessage& request,
nullptr);
}
std::vector<GetAllWork*> getAllWorkers;
- ThreadPool* threadPool = TPSingleton::instance();
+ auto* threadPool = m_connManager.getCacheImpl()->getThreadPool();
ChunkedGetAllResponse* responseHandler =
static_cast<ChunkedGetAllResponse*>(reply.getChunkedResultHandler());
@@ -1719,10 +1758,12 @@ GfErrType ThinClientPoolDM::createPoolConnectionToAEndPoint(
"connection to the endpoint %s",
theEP->name().c_str());
// if the pool size is within limits, create a new connection.
- error = theEP->createNewConnection(
- conn, false, false,
- DistributedSystem::getSystemProperties()->connectTimeout(), false, true,
- appThreadrequest);
+ error = theEP->createNewConnection(conn, false, false,
+ m_connManager.getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties()
+ .connectTimeout(),
+ false, true, appThreadrequest);
if (conn == nullptr || error != GF_NOERR) {
LOGFINE("2Failed to connect to %s", theEP->name().c_str());
if (conn != nullptr) GF_SAFE_DELETE(conn);
@@ -1801,9 +1842,12 @@ GfErrType ThinClientPoolDM::createPoolConnection(
conn->updateCreationTime();
break;
} else {
- error = ep->createNewConnection(
- conn, false, false,
- DistributedSystem::getSystemProperties()->connectTimeout(), false);
+ error = ep->createNewConnection(conn, false, false,
+ m_connManager.getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties()
+ .connectTimeout(),
+ false);
}
if (conn == nullptr || error != GF_NOERR) {
@@ -1854,14 +1898,20 @@ TcrConnection* ThinClientPoolDM::getConnectionFromQueue(
getStats().incWaitingConnections();
/*get the start time for connectionWaitTime stat*/
- int64_t sampleStartNanos = Utils::startStatOpTime();
+ bool enableTimeStatistics = m_connManager.getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties()
+ .getEnableTimeStatistics();
+ int64_t sampleStartNanos =
+ enableTimeStatistics ? Utils::startStatOpTime() : 0;
TcrConnection* mp =
getUntil(timeoutTime, error, excludeServers, maxConnLimit);
/*Update the time stat for clientOpsTime */
- Utils::updateStatOpTime(
- getStats().getStats(),
- PoolStatType::getInstance()->getTotalWaitingConnTimeId(),
- sampleStartNanos);
+ if (enableTimeStatistics) {
+ Utils::updateStatOpTime(getStats().getStats(),
+ getStats().getTotalWaitingConnTimeId(),
+ sampleStartNanos);
+ }
return mp;
}
@@ -1892,9 +1942,13 @@ GfErrType ThinClientPoolDM::sendRequestToEP(const TcrMessage& request,
LOGDEBUG(
"ThinClientPoolDM::sendRequestToEP(): couldnt create a pool "
"connection, creating a temporary connection.");
- error = currentEndpoint->createNewConnection(
- conn, false, false,
- DistributedSystem::getSystemProperties()->connectTimeout(), false);
+ error =
+ currentEndpoint->createNewConnection(conn, false, false,
+ m_connManager.getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties()
+ .connectTimeout(),
+ false);
putConnInPool = false;
currentEndpoint->setConnectionStatus(true);
}
@@ -2076,7 +2130,7 @@ int ThinClientPoolDM::updateLocatorList(volatile bool& isRunning) {
LOGFINE("Starting updateLocatorList thread for pool %s", m_poolName.c_str());
while (isRunning) {
m_updateLocatorListSema.acquire();
- if (isRunning && !TcrConnectionManager::isNetDown) {
+ if (isRunning && !m_connManager.isNetDown()) {
((ThinClientLocatorHelper*)m_locHelper)
->updateLocators(this->getServerGroup());
}
@@ -2089,7 +2143,7 @@ int ThinClientPoolDM::pingServer(volatile bool& isRunning) {
LOGFINE("Starting ping thread for pool %s", m_poolName.c_str());
while (isRunning) {
m_pingSema.acquire();
- if (isRunning && !TcrConnectionManager::isNetDown) {
+ if (isRunning && !m_connManager.isNetDown()) {
pingServerLocal();
while (m_pingSema.tryacquire() != -1) {
;
@@ -2107,9 +2161,10 @@ int ThinClientPoolDM::cliCallback(volatile bool& isRunning) {
if (isRunning) {
LOGFINE("Clearing Pdx Type Registry");
// this call for csharp client
- DistributedSystemImpl::CallCliCallBack();
+ DistributedSystemImpl::CallCliCallBack(
+ *(m_connManager.getCacheImpl()->getCache()));
// this call for cpp client
- PdxTypeRegistry::clear();
+ m_connManager.getCacheImpl()->getPdxTypeRegistry()->clear();
while (m_cliCallbackSema.tryacquire() != -1) {
;
}
@@ -2317,7 +2372,8 @@ void ThinClientPoolDM::updateNotificationStats(bool isDeltaSuccess,
GfErrType ThinClientPoolDM::doFailover(TcrConnection* conn) {
m_manager->setStickyConnection(conn, true);
- TcrMessageTxFailover request;
+ TcrMessageTxFailover request(
+ m_connManager.getCacheImpl()->getCache()->createDataOutput());
TcrMessageReply reply(true, nullptr);
GfErrType err = this->sendSyncRequest(request, reply);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ThinClientPoolDM.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ThinClientPoolDM.hpp b/src/cppcache/src/ThinClientPoolDM.hpp
index 73802f7..1da32d8 100644
--- a/src/cppcache/src/ThinClientPoolDM.hpp
+++ b/src/cppcache/src/ThinClientPoolDM.hpp
@@ -119,16 +119,13 @@ class ThinClientPoolDM
virtual ~ThinClientPoolDM() {
destroy();
- GF_SAFE_DELETE(m_memId);
GF_SAFE_DELETE(m_locHelper);
GF_SAFE_DELETE(m_stats);
GF_SAFE_DELETE(m_clientMetadataService);
GF_SAFE_DELETE(m_manager);
}
// void updateQueue(const char* regionPath) ;
- ClientProxyMembershipID* getMembershipId() {
- return (ClientProxyMembershipID*)m_memId;
- }
+ ClientProxyMembershipID* getMembershipId() { return m_memId.get(); }
virtual void processMarker(){};
virtual bool checkDupAndAdd(EventIdPtr eventid) {
return m_connManager.checkDupAndAdd(eventid);
@@ -386,7 +383,8 @@ class ThinClientPoolDM
std::string selectEndpoint(std::set<ServerLocation>&,
const TcrConnection* currentServer = nullptr);
- volatile ClientProxyMembershipID* m_memId;
+ // TODO global - m_memId was volatile
+ std::unique_ptr<ClientProxyMembershipID> m_memId;
virtual TcrEndpoint* createEP(const char* endpointName) {
return new TcrPoolEndPoint(endpointName, m_connManager.getCacheImpl(),
m_connManager.m_failoverSema,
@@ -491,7 +489,11 @@ class FunctionExecution : public PooledWork<GfErrType> {
if (m_userAttr != nullptr) gua.setProxyCache(m_userAttr->getProxyCache());
std::string funcName(m_func);
- TcrMessageExecuteFunction request(funcName, m_args, m_getResult, m_poolDM,
+ TcrMessageExecuteFunction request(m_poolDM->getConnectionManager()
+ .getCacheImpl()
+ ->getCache()
+ ->createDataOutput(),
+ funcName, m_args, m_getResult, m_poolDM,
m_timeout);
TcrMessageReply reply(true, m_poolDM);
ChunkedFunctionExecutionResponse* resultProcessor(
@@ -509,29 +511,7 @@ class FunctionExecution : public PooledWork<GfErrType> {
m_error = m_poolDM->handleEPError(m_ep, reply, m_error);
if (m_error != GF_NOERR) {
if (m_error == GF_NOTCON || m_error == GF_IOERR) {
- /*
- ==25848== 650 (72 direct, 578 indirect) bytes in 2 blocks are definitely
- lost in loss record 184 of 218
- ==25848== at 0x4007D75: operator new(unsigned int)
- (vg_replace_malloc.c:313)
- ==25848== by 0x439BD41:
- apache::geode::client::FunctionExecution::execute()
- (ThinClientPoolDM.hpp:417)
- ==25848== by 0x439A5A1:
- apache::geode::client::PooledWork<GfErrType>::call()
- (ThreadPool.hpp:25)
- ==25848== by 0x43C335F:
- apache::geode::client::ThreadPoolWorker::svc()
- (ThreadPool.cpp:43)
- ==25848== by 0x440521D: ACE_6_1_0::ACE_Task_Base::svc_run(void*) (in
- /export/pnq-gst-dev01a/users/adongre/cedar_dev_Nov12/build-artifacts/linux/product/lib/libgfcppcache.so)
- ==25848== by 0x441E16A: ACE_6_1_0::ACE_Thread_Adapter::invoke_i() (in
- /export/pnq-gst-dev01a/users/adongre/cedar_dev_Nov12/build-artifacts/linux/product/lib/libgfcppcache.so)
- ==25848== by 0x441E307: ACE_6_1_0::ACE_Thread_Adapter::invoke() (in
- /export/pnq-gst-dev01a/users/adongre/cedar_dev_Nov12/build-artifacts/linux/product/lib/libgfcppcache.so)
- ==25848== by 0x8CFA48: start_thread (in /lib/libpthread-2.12.so)
- ==25848== by 0x34BE1D: clone (in /lib/libc-2.12.so)
- */
+
delete resultProcessor;
resultProcessor = nullptr;
return GF_NOERR; // if server is unavailable its not an error for
@@ -543,26 +523,7 @@ class FunctionExecution : public PooledWork<GfErrType> {
if (reply.getMessageType() == TcrMessage::EXCEPTION) {
exceptionPtr = CacheableString::create(reply.getException());
}
- /**
- * ==13294== 48,342 (1,656 direct, 46,686 indirect) bytes in 46 blocks are
-definitely lost in loss record 241 of 244
-==13294== at 0x4007D75: operator new(unsigned int) (vg_replace_malloc.c:313)
-==13294== by 0x439BE11: apache::geode::client::FunctionExecution::execute()
-(ThinClientPoolDM.hpp:417)
-==13294== by 0x439A671: apache::geode::client::PooledWork<GfErrType>::call()
-(ThreadPool.hpp:25)
-==13294== by 0x43C33FF: apache::geode::client::ThreadPoolWorker::svc()
-(ThreadPool.cpp:43)
-==13294== by 0x44052BD: ACE_6_1_0::ACE_Task_Base::svc_run(void*) (in
-/export/pnq-gst-dev01a/users/adongre/cedar_dev_Nov12/build-artifacts/linux/product/lib/libgfcppcache.so)
-==13294== by 0x441E20A: ACE_6_1_0::ACE_Thread_Adapter::invoke_i() (in
-/export/pnq-gst-dev01a/users/adongre/cedar_dev_Nov12/build-artifacts/linux/product/lib/libgfcppcache.so)
-==13294== by 0x441E3A7: ACE_6_1_0::ACE_Thread_Adapter::invoke() (in
-/export/pnq-gst-dev01a/users/adongre/cedar_dev_Nov12/build-artifacts/linux/product/lib/libgfcppcache.so)
-==13294== by 0x8CFA48: start_thread (in /lib/libpthread-2.12.so)
-==13294== by 0x34BE1D: clone (in /lib/libc-2.12.so)
- *
- */
+
delete resultProcessor;
resultProcessor = nullptr;
return m_error;
@@ -573,13 +534,7 @@ definitely lost in loss record 241 of 244
exceptionPtr = CacheableString::create(reply.getException());
}
if (resultProcessor->getResult() == true) {
- // CacheableVectorPtr values =
- // resultProcessor->getFunctionExecutionResults();
- // ACE_Guard< ACE_Recursive_Thread_Mutex > guard(
- // *m_resultCollectorLock );
- // //(*m_rc)->addResult(values);
- // ExecutionImpl::addResults(*m_rc,values);
- // resultProcessor->reset();
+
}
delete resultProcessor;
resultProcessor = nullptr;
@@ -629,6 +584,10 @@ class OnRegionFunctionExecution : public PooledWork<GfErrType> {
std::string funcName(m_func);
m_request = new TcrMessageExecuteRegionFunctionSingleHop(
+ m_poolDM->getConnectionManager()
+ .getCacheImpl()
+ ->getCache()
+ ->createDataOutput(),
funcName, m_region, m_args, m_routingObj, m_getResult, nullptr,
m_allBuckets, timeout, m_poolDM);
m_reply = new TcrMessageReply(true, m_poolDM);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ThinClientPoolHADM.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ThinClientPoolHADM.cpp b/src/cppcache/src/ThinClientPoolHADM.cpp
index b18aeeb..6c44296 100644
--- a/src/cppcache/src/ThinClientPoolHADM.cpp
+++ b/src/cppcache/src/ThinClientPoolHADM.cpp
@@ -40,9 +40,11 @@ void ThinClientPoolHADM::init() {
}
void ThinClientPoolHADM::startBackgroundThreads() {
- SystemProperties* props = DistributedSystem::getSystemProperties();
+ auto& props = m_connManager.getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties();
- if (props->isGridClient()) {
+ if (props.isGridClient()) {
LOGWARN("Starting background threads and ignoring grid-client setting");
ThinClientPoolDM::startBackgroundThreads();
}
@@ -55,10 +57,11 @@ void ThinClientPoolHADM::startBackgroundThreads() {
ACE_Event_Handler* redundancyChecker =
new ExpiryHandler_T<ThinClientPoolHADM>(
this, &ThinClientPoolHADM::checkRedundancy);
- int32_t redundancyMonitorInterval = props->redundancyMonitorInterval();
+ int32_t redundancyMonitorInterval = props.redundancyMonitorInterval();
- m_servermonitorTaskId = CacheImpl::expiryTaskManager->scheduleExpiryTask(
- redundancyChecker, 1, redundancyMonitorInterval, false);
+ m_servermonitorTaskId =
+ m_connManager.getCacheImpl()->getExpiryTaskManager().scheduleExpiryTask(
+ redundancyChecker, 1, redundancyMonitorInterval, false);
LOGFINE(
"ThinClientPoolHADM::ThinClientPoolHADM Registered server "
"monitor task with id = %ld, interval = %ld",
@@ -133,7 +136,7 @@ GfErrType ThinClientPoolHADM::sendSyncRequestCq(TcrMessage& request,
bool ThinClientPoolHADM::preFailoverAction() { return true; }
bool ThinClientPoolHADM::postFailoverAction(TcrEndpoint* endpoint) {
- m_theTcrConnManager.triggerRedundancyThread();
+ m_connManager.triggerRedundancyThread();
return true;
}
@@ -141,7 +144,7 @@ int ThinClientPoolHADM::redundancy(volatile bool& isRunning) {
LOGFINE("ThinClientPoolHADM: Starting maintain redundancy thread.");
while (isRunning) {
m_redundancySema.acquire();
- if (isRunning && !TcrConnectionManager::isNetDown) {
+ if (isRunning && !m_connManager.isNetDown()) {
m_redundancyManager->maintainRedundancyLevel();
while (m_redundancySema.tryacquire() != -1) {
;
@@ -183,7 +186,8 @@ void ThinClientPoolHADM::destroy(bool keepAlive) {
void ThinClientPoolHADM::sendNotificationCloseMsgs() {
if (m_redundancyTask) {
if (m_servermonitorTaskId >= 0) {
- CacheImpl::expiryTaskManager->cancelTask(m_servermonitorTaskId);
+ m_connManager.getCacheImpl()->getExpiryTaskManager().cancelTask(
+ m_servermonitorTaskId);
}
m_redundancyTask->stopNoblock();
m_redundancySema.release();
@@ -193,21 +197,6 @@ void ThinClientPoolHADM::sendNotificationCloseMsgs() {
}
}
-/*
-void ThinClientPoolHADM::stopNotificationThreads()
-{
- ACE_Guard< ACE_Recursive_Thread_Mutex > guard( m_endpointsLock );
- for( ACE_Map_Manager< std::string, TcrEndpoint *, ACE_Recursive_Thread_Mutex
->::iterator it = m_endpoints.begin(); it != m_endpoints.end(); it++){
- ((*it).int_id_)->stopNoBlock();
- }
- for( ACE_Map_Manager< std::string, TcrEndpoint *, ACE_Recursive_Thread_Mutex
->::iterator it = m_endpoints.begin(); it != m_endpoints.end(); it++){
- ((*it).int_id_)->stopNotifyReceiverAndCleanup();
- }
-}
-*/
-
GfErrType ThinClientPoolHADM::registerInterestAllRegions(
TcrEndpoint* ep, const TcrMessage* request, TcrMessageReply* reply) {
GfErrType err = GF_NOERR;
@@ -248,12 +237,14 @@ void ThinClientPoolHADM::removeRegion(ThinClientRegion* theTCR) {
}
void ThinClientPoolHADM::readyForEvents() {
- if (!DistributedSystem::getSystemProperties()->autoReadyForEvents()) {
+ auto& sysProp = m_connManager.getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties();
+ if (!sysProp.autoReadyForEvents()) {
init();
}
- const char* durable =
- DistributedSystem::getSystemProperties()->durableClientId();
+ const char* durable = sysProp.durableClientId();
if (durable != nullptr && strlen(durable) > 0) {
m_redundancyManager->readyForEvents();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ThinClientPoolHADM.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ThinClientPoolHADM.hpp b/src/cppcache/src/ThinClientPoolHADM.hpp
index 9783293..ab5dc78 100644
--- a/src/cppcache/src/ThinClientPoolHADM.hpp
+++ b/src/cppcache/src/ThinClientPoolHADM.hpp
@@ -110,8 +110,8 @@ class ThinClientPoolHADM : public ThinClientPoolDM {
// Disallow copy constructor and assignment operator.
ThinClientRedundancyManager* m_redundancyManager;
ThinClientPoolHADM(const ThinClientPoolHADM&);
- ThinClientPoolHADM& operator=(const ThinClientPoolHADM&);
- // const char* m_name; // COVERITY -> 30305 Uninitialized pointer field
+ ThinClientPoolHADM& operator=(const ThinClientPoolHADM&) = delete;
+
TcrConnectionManager& m_theTcrConnManager;
ACE_Semaphore m_redundancySema;
Task<ThinClientPoolHADM>* m_redundancyTask;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ThinClientPoolRegion.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ThinClientPoolRegion.cpp b/src/cppcache/src/ThinClientPoolRegion.cpp
index 834520c..b888e1c 100644
--- a/src/cppcache/src/ThinClientPoolRegion.cpp
+++ b/src/cppcache/src/ThinClientPoolRegion.cpp
@@ -40,7 +40,10 @@ ThinClientPoolRegion::~ThinClientPoolRegion() { m_tcrdm = nullptr; }
void ThinClientPoolRegion::initTCR() {
try {
ThinClientPoolDM* poolDM = dynamic_cast<ThinClientPoolDM*>(
- PoolManager::find(m_regionAttributes->getPoolName()).get());
+ getCache()
+ ->getPoolManager()
+ .find(m_regionAttributes->getPoolName())
+ .get());
m_tcrdm = dynamic_cast<ThinClientBaseDM*>(poolDM);
if (!m_tcrdm) {
// TODO: create a PoolNotFound exception.
[26/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/ThinClientDurableCqTestsN.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/ThinClientDurableCqTestsN.cs b/src/clicache/integration-test/ThinClientDurableCqTestsN.cs
index 4864b23..b6b0a01 100644
--- a/src/clicache/integration-test/ThinClientDurableCqTestsN.cs
+++ b/src/clicache/integration-test/ThinClientDurableCqTestsN.cs
@@ -61,7 +61,7 @@ namespace Apache.Geode.Client.UnitTests
Util.Log("Registering Cqs for client1.");
CqAttributesFactory<object, object> cqAf = new CqAttributesFactory<object, object>();
CqAttributes<object, object> attributes = cqAf.Create();
- QueryService<object, object> qs = Client.PoolManager.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ QueryService<object, object> qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
if (!isRecycle)
{
@@ -85,7 +85,7 @@ namespace Apache.Geode.Client.UnitTests
Util.Log("Registering Cqs for client1 for multiple chunks.");
CqAttributesFactory<object, object> cqAf = new CqAttributesFactory<object, object>();
CqAttributes<object, object> attributes = cqAf.Create();
- QueryService<object, object> qs = Client.PoolManager.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ QueryService<object, object> qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
for (int i = 0; i < m_NumberOfCqs; i++)
qs.NewCq("MyCq_" + i.ToString(), "Select * From /" + QueryRegionNames[0] + " where id = 1", attributes, true).ExecuteWithInitialResults();
@@ -97,7 +97,7 @@ namespace Apache.Geode.Client.UnitTests
Util.Log("Registering Cqs for client2.");
CqAttributesFactory<object, object> cqAf = new CqAttributesFactory<object, object>();
CqAttributes<object, object> attributes = cqAf.Create();
- QueryService<object, object> qs = Client.PoolManager.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ QueryService<object, object> qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
if (!isRecycle)
{
@@ -118,7 +118,7 @@ namespace Apache.Geode.Client.UnitTests
public void VerifyDurableCqListClient1MultipleChunks()
{
Util.Log("Verifying durable Cqs for client1.");
- QueryService<object, object> qs = Client.PoolManager.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ QueryService<object, object> qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
System.Collections.Generic.List<string> durableCqList = qs.GetAllDurableCqsFromServer();
Assert.AreNotEqual(null, durableCqList);
@@ -130,7 +130,7 @@ namespace Apache.Geode.Client.UnitTests
public void VerifyDurableCqListClient1(bool isRecycle)
{
Util.Log("Verifying durable Cqs for client1.");
- QueryService<object, object> qs = Client.PoolManager.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ QueryService<object, object> qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
System.Collections.Generic.List<string> durableCqList = qs.GetAllDurableCqsFromServer();
Assert.AreNotEqual(null, durableCqList);
@@ -154,7 +154,7 @@ namespace Apache.Geode.Client.UnitTests
public void VerifyDurableCqListClient2(bool isRecycle)
{
Util.Log("Verifying durable Cqs for client2.");
- QueryService<object, object> qs = Client.PoolManager.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ QueryService<object, object> qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
System.Collections.Generic.List<string> durableCqList = qs.GetAllDurableCqsFromServer();
Assert.AreNotEqual(null, durableCqList);
@@ -183,7 +183,7 @@ namespace Apache.Geode.Client.UnitTests
public void VerifyEmptyDurableCqListClient1()
{
Util.Log("Verifying empty durable Cqs for client1.");
- QueryService<object, object> qs = Client.PoolManager.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ QueryService<object, object> qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
System.Collections.Generic.List<string> durableCqList = qs.GetAllDurableCqsFromServer();
Assert.AreNotEqual(null, durableCqList);
Assert.AreEqual(0, durableCqList.Count, "Durable CQ list sholuld be empty");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/ThinClientDurableTestsN.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/ThinClientDurableTestsN.cs b/src/clicache/integration-test/ThinClientDurableTestsN.cs
index 473cfc7..e75856e 100644
--- a/src/clicache/integration-test/ThinClientDurableTestsN.cs
+++ b/src/clicache/integration-test/ThinClientDurableTestsN.cs
@@ -127,13 +127,13 @@ namespace Apache.Geode.Client.UnitTests
Assert.Fail("RegisterAllKeys threw unexpected exception: {0}", other.Message);
}
- Pool pool0 = PoolManager.Find(region0.Attributes.PoolName);
+ Pool pool0 = CacheHelper.DCache.GetPoolManager().Find(region0.Attributes.PoolName);
int pendingEventCount0 = pool0.PendingEventCount;
Util.Log("pendingEventCount0 for pool = {0} {1} ", pendingEventCount0, region0.Attributes.PoolName);
string msg = string.Format("Expected Value ={0}, Actual = {1}", expectedQ0, pendingEventCount0);
Assert.AreEqual(expectedQ0, pendingEventCount0, msg);
- Pool pool1 = PoolManager.Find(region1.Attributes.PoolName);
+ Pool pool1 = CacheHelper.DCache.GetPoolManager().Find(region1.Attributes.PoolName);
int pendingEventCount1 = pool1.PendingEventCount;
Util.Log("pendingEventCount1 for pool = {0} {1} ", pendingEventCount1, region1.Attributes.PoolName);
string msg1 = string.Format("Expected Value ={0}, Actual = {1}", expectedQ1, pendingEventCount1);
@@ -214,7 +214,7 @@ namespace Apache.Geode.Client.UnitTests
if (poolName != null)
{
Util.Log("PendingEventCount poolName = {0} ", poolName);
- Pool pool = PoolManager.Find(poolName);
+ Pool pool = CacheHelper.DCache.GetPoolManager().Find(poolName);
if (exception)
{
try
@@ -796,10 +796,10 @@ namespace Apache.Geode.Client.UnitTests
pp.Insert("durable-timeout", "30");
CacheFactory cacheFactory = CacheFactory.CreateCacheFactory(pp);
- Cache cache = cacheFactory.SetSubscriptionEnabled(true)
- .SetSubscriptionAckInterval(5000)
- .SetSubscriptionMessageTrackingTimeout(5000)
- .Create();
+ Cache cache = cacheFactory.Create();
+ cache.GetPoolFactory().SetSubscriptionEnabled(true);
+ cache.GetPoolFactory().SetSubscriptionAckInterval(5000);
+ cache.GetPoolFactory().SetSubscriptionMessageTrackingTimeout(5000);
Util.Log("Created the Geode Cache Programmatically");
RegionFactory regionFactory = cache.CreateRegionFactory(RegionShortcut.CACHING_PROXY);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/ThinClientFunctionExecutionTestsN.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/ThinClientFunctionExecutionTestsN.cs b/src/clicache/integration-test/ThinClientFunctionExecutionTestsN.cs
index e41fff6..2fcb1ba 100644
--- a/src/clicache/integration-test/ThinClientFunctionExecutionTestsN.cs
+++ b/src/clicache/integration-test/ThinClientFunctionExecutionTestsN.cs
@@ -328,7 +328,7 @@ namespace Apache.Geode.Client.UnitTests
//---------------------Test for function execution with sendException Done-----------------------//
- Pool/*<object, object>*/ pl = PoolManager/*<object, object>*/.Find(poolName);
+ Pool/*<object, object>*/ pl = CacheHelper.DCache.GetPoolManager().Find(poolName);
//test date independant fucntion execution on one server
// test get function with result
@@ -420,7 +420,7 @@ namespace Apache.Geode.Client.UnitTests
public void genericFEResultIntTest(string locators)
{
IRegion<int, int> region = CacheHelper.GetVerifyRegion<int, int>(QERegionName);
- Pool pl = PoolManager.Find(poolName);
+ Pool pl = CacheHelper.DCache.GetPoolManager().Find(poolName);
for (int n = 0; n < 34; n++)
{
@@ -463,7 +463,7 @@ namespace Apache.Geode.Client.UnitTests
public void genericFEResultStringTest(string locators)
{
IRegion<string, string> region = CacheHelper.GetVerifyRegion<string, string>(QERegionName);
- Pool pl = PoolManager.Find(poolName);
+ Pool pl = CacheHelper.DCache.GetPoolManager().Find(poolName);
for (int n = 0; n < 34; n++)
{
@@ -513,7 +513,7 @@ namespace Apache.Geode.Client.UnitTests
public void genericFEResultDCStringTest(string locators)
{
IRegion<string, string> region = CacheHelper.GetVerifyRegion<string, string>(QERegionName);
- Pool pl = PoolManager.Find(poolName);
+ Pool pl = CacheHelper.DCache.GetPoolManager().Find(poolName);
for (int n = 0; n < 34; n++)
{
@@ -560,7 +560,7 @@ namespace Apache.Geode.Client.UnitTests
Serializable.RegisterPdxType(PdxTests.PdxTypes1.CreateDeserializable);
Serializable.RegisterPdxType(PdxTests.PdxTypes8.CreateDeserializable);
IRegion<string, IPdxSerializable> region = CacheHelper.GetVerifyRegion<string, IPdxSerializable>(QERegionName);
- Pool pl = PoolManager.Find(poolName);
+ Pool pl = CacheHelper.DCache.GetPoolManager().Find(poolName);
for (int n = 0; n < 34; n++)
{
@@ -985,7 +985,7 @@ namespace Apache.Geode.Client.UnitTests
Util.Log("ExecuteFETimeOut onRegion Done");
}
- Pool pool = PoolManager.Find(poolName);
+ Pool pool = CacheHelper.DCache.GetPoolManager().Find(poolName);
Execution<object> excs = Client.FunctionService<object>.OnServer(pool);
IResultCollector<object> rcs = excs.WithArgs<Object>(args).Execute(FuncTimeOutName, 5000);
ICollection<object> ServerFunctionResult = rcs.GetResult();
@@ -1319,7 +1319,7 @@ namespace Apache.Geode.Client.UnitTests
}
//test data independant function execution with result onServer
- Pool/*<TKey, TValue>*/ pool = PoolManager/*<TKey, TValue>*/.Find(poolName);
+ Pool/*<TKey, TValue>*/ pool = CacheHelper.DCache.GetPoolManager().Find(poolName);
Apache.Geode.Client.Execution<object> exc = Client.FunctionService<object>.OnServer(pool);
Assert.IsTrue(exc != null, "onServer Returned NULL");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/ThinClientHARegionTestsN.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/ThinClientHARegionTestsN.cs b/src/clicache/integration-test/ThinClientHARegionTestsN.cs
index 935cd44..5a00367 100644
--- a/src/clicache/integration-test/ThinClientHARegionTestsN.cs
+++ b/src/clicache/integration-test/ThinClientHARegionTestsN.cs
@@ -641,8 +641,8 @@ namespace Apache.Geode.Client.UnitTests
try
{
- Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable);
- Serializable.RegisterTypeGeneric(Position.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable, CacheHelper.DCache);
+ Serializable.RegisterTypeGeneric(Position.CreateDeserializable, CacheHelper.DCache);
}
catch (IllegalStateException)
{
@@ -674,7 +674,7 @@ namespace Apache.Geode.Client.UnitTests
KillServerDelegate ksd = new KillServerDelegate(KillServer);
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
for (int i = 0; i < 10000; i++)
{
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/ThinClientPdxTests.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/ThinClientPdxTests.cs b/src/clicache/integration-test/ThinClientPdxTests.cs
index e598ff7..66a7935 100755
--- a/src/clicache/integration-test/ThinClientPdxTests.cs
+++ b/src/clicache/integration-test/ThinClientPdxTests.cs
@@ -160,22 +160,6 @@ namespace Apache.Geode.Client.UnitTests
Assert.AreEqual(CacheHelper.DCache.GetPdxReadSerialized(), false, "Pdx read serialized property should be false.");
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.AreEqual(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be equal to Total pdxSerializations.");
- Assert.AreEqual(rStats.GetLong((string)"pdxSerializedBytes"), rStats.GetLong((string)"pdxDeserializedBytes"),
- "Total pdxDeserializedBytes should be equal to Total pdxSerializationsBytes");
- }
- }
}
void VerifyGetOnly()
@@ -187,22 +171,7 @@ namespace Apache.Geode.Client.UnitTests
PdxType pRet = (PdxType)region0[1];
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.Greater(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be greater than Total pdxSerializations.");
- Assert.Greater(rStats.GetLong((string)"pdxDeserializedBytes"), rStats.GetLong((string)"pdxSerializedBytes"),
- "Total pdxDeserializedBytes should be greater than Total pdxSerializationsBytes");
- }
- }
+
}
void PutAndVerifyVariousPdxTypes()
@@ -229,22 +198,7 @@ namespace Apache.Geode.Client.UnitTests
PdxTypes1 pRet = (PdxTypes1)region0[11];
Assert.AreEqual(p1, pRet);
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.AreEqual(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be equal to Total pdxSerializations.");
- Assert.AreEqual(rStats.GetLong((string)"pdxSerializedBytes"), rStats.GetLong((string)"pdxDeserializedBytes"),
- "Total pdxDeserializedBytes should be equal to Total pdxSerializationsBytes");
- }
- }
+
}
{
@@ -253,22 +207,7 @@ namespace Apache.Geode.Client.UnitTests
PdxTypes2 pRet2 = (PdxTypes2)region0[12];
Assert.AreEqual(p2, pRet2);
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.AreEqual(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be equal to Total pdxSerializations.");
- Assert.AreEqual(rStats.GetLong((string)"pdxSerializedBytes"), rStats.GetLong((string)"pdxDeserializedBytes"),
- "Total pdxDeserializedBytes should be equal to Total pdxSerializationsBytes");
- }
- }
+
}
{
@@ -277,22 +216,7 @@ namespace Apache.Geode.Client.UnitTests
PdxTypes3 pRet3 = (PdxTypes3)region0[13];
Assert.AreEqual(p3, pRet3);
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.AreEqual(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be equal to Total pdxSerializations.");
- Assert.AreEqual(rStats.GetLong((string)"pdxSerializedBytes"), rStats.GetLong((string)"pdxDeserializedBytes"),
- "Total pdxDeserializedBytes should be equal to Total pdxSerializationsBytes");
- }
- }
+
}
{
@@ -301,22 +225,7 @@ namespace Apache.Geode.Client.UnitTests
PdxTypes4 pRet4 = (PdxTypes4)region0[14];
Assert.AreEqual(p4, pRet4);
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.AreEqual(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be equal to Total pdxSerializations.");
- Assert.AreEqual(rStats.GetLong((string)"pdxSerializedBytes"), rStats.GetLong((string)"pdxDeserializedBytes"),
- "Total pdxDeserializedBytes should be equal to Total pdxSerializationsBytes");
- }
- }
+
}
{
@@ -325,22 +234,6 @@ namespace Apache.Geode.Client.UnitTests
PdxTypes5 pRet5 = (PdxTypes5)region0[15];
Assert.AreEqual(p5, pRet5);
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.AreEqual(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be equal to Total pdxSerializations.");
- Assert.AreEqual(rStats.GetLong((string)"pdxSerializedBytes"), rStats.GetLong((string)"pdxDeserializedBytes"),
- "Total pdxDeserializedBytes should be equal to Total pdxSerializationsBytes");
- }
- }
}
{
@@ -349,22 +242,6 @@ namespace Apache.Geode.Client.UnitTests
PdxTypes6 pRet6 = (PdxTypes6)region0[16];
Assert.AreEqual(p6, pRet6);
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.AreEqual(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be equal to Total pdxSerializations.");
- Assert.AreEqual(rStats.GetLong((string)"pdxSerializedBytes"), rStats.GetLong((string)"pdxDeserializedBytes"),
- "Total pdxDeserializedBytes should be equal to Total pdxSerializationsBytes");
- }
- }
}
{
@@ -373,22 +250,6 @@ namespace Apache.Geode.Client.UnitTests
PdxTypes7 pRet7 = (PdxTypes7)region0[17];
Assert.AreEqual(p7, pRet7);
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.AreEqual(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be equal to Total pdxSerializations.");
- Assert.AreEqual(rStats.GetLong((string)"pdxSerializedBytes"), rStats.GetLong((string)"pdxDeserializedBytes"),
- "Total pdxDeserializedBytes should be equal to Total pdxSerializationsBytes");
- }
- }
}
{
@@ -397,22 +258,6 @@ namespace Apache.Geode.Client.UnitTests
PdxTypes8 pRet8 = (PdxTypes8)region0[18];
Assert.AreEqual(p8, pRet8);
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.AreEqual(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be equal to Total pdxSerializations.");
- Assert.AreEqual(rStats.GetLong((string)"pdxSerializedBytes"), rStats.GetLong((string)"pdxDeserializedBytes"),
- "Total pdxDeserializedBytes should be equal to Total pdxSerializationsBytes");
- }
- }
}
{
PdxTypes9 p9 = new PdxTypes9();
@@ -420,22 +265,6 @@ namespace Apache.Geode.Client.UnitTests
PdxTypes9 pRet9 = (PdxTypes9)region0[19];
Assert.AreEqual(p9, pRet9);
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.AreEqual(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be equal to Total pdxSerializations.");
- Assert.AreEqual(rStats.GetLong((string)"pdxSerializedBytes"), rStats.GetLong((string)"pdxDeserializedBytes"),
- "Total pdxDeserializedBytes should be equal to Total pdxSerializationsBytes");
- }
- }
}
{
@@ -443,22 +272,6 @@ namespace Apache.Geode.Client.UnitTests
region0[20] = pf;
PortfolioPdx retpf = (PortfolioPdx)region0[20];
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.AreEqual(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be equal to Total pdxSerializations.");
- Assert.AreEqual(rStats.GetLong((string)"pdxSerializedBytes"), rStats.GetLong((string)"pdxDeserializedBytes"),
- "Total pdxDeserializedBytes should be equal to Total pdxSerializationsBytes");
- }
- }
//Assert.AreEqual(p9, pRet9);
}
@@ -467,22 +280,6 @@ namespace Apache.Geode.Client.UnitTests
region0[21] = pf;
PortfolioPdx retpf = (PortfolioPdx)region0[21];
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.AreEqual(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be equal to Total pdxSerializations.");
- Assert.AreEqual(rStats.GetLong((string)"pdxSerializedBytes"), rStats.GetLong((string)"pdxDeserializedBytes"),
- "Total pdxDeserializedBytes should be equal to Total pdxSerializationsBytes");
- }
- }
//Assert.AreEqual(p9, pRet9);
}
{
@@ -491,22 +288,6 @@ namespace Apache.Geode.Client.UnitTests
PdxTypes10 pRet10 = (PdxTypes10)region0[22];
Assert.AreEqual(p10, pRet10);
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.AreEqual(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be equal to Total pdxSerializations.");
- Assert.AreEqual(rStats.GetLong((string)"pdxSerializedBytes"), rStats.GetLong((string)"pdxDeserializedBytes"),
- "Total pdxDeserializedBytes should be equal to Total pdxSerializationsBytes");
- }
- }
}
{
AllPdxTypes apt = new AllPdxTypes(true);
@@ -514,22 +295,6 @@ namespace Apache.Geode.Client.UnitTests
AllPdxTypes aptRet = (AllPdxTypes)region0[23];
Assert.AreEqual(apt, aptRet);
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.AreEqual(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be equal to Total pdxSerializations.");
- Assert.AreEqual(rStats.GetLong((string)"pdxSerializedBytes"), rStats.GetLong((string)"pdxDeserializedBytes"),
- "Total pdxDeserializedBytes should be equal to Total pdxSerializationsBytes");
- }
- }
}
}
@@ -555,22 +320,6 @@ namespace Apache.Geode.Client.UnitTests
PdxTypes1 pRet = (PdxTypes1)region0[11];
Assert.AreEqual(p1, pRet);
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.Greater(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be greater than Total pdxSerializations.");
- Assert.Greater(rStats.GetLong((string)"pdxDeserializedBytes"), rStats.GetLong((string)"pdxSerializedBytes"),
- "Total pdxDeserializedBytes should be greater than Total pdxSerializationsBytes");
- }
- }
}
{
@@ -578,22 +327,6 @@ namespace Apache.Geode.Client.UnitTests
PdxTypes2 pRet2 = (PdxTypes2)region0[12];
Assert.AreEqual(p2, pRet2);
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.Greater(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be greater than Total pdxSerializations.");
- Assert.Greater(rStats.GetLong((string)"pdxDeserializedBytes"), rStats.GetLong((string)"pdxSerializedBytes"),
- "Total pdxDeserializedBytes should be greater than Total pdxSerializationsBytes");
- }
- }
}
{
@@ -601,22 +334,6 @@ namespace Apache.Geode.Client.UnitTests
PdxTypes3 pRet3 = (PdxTypes3)region0[13];
Assert.AreEqual(p3, pRet3);
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.Greater(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be greater than Total pdxSerializations.");
- Assert.Greater(rStats.GetLong((string)"pdxDeserializedBytes"), rStats.GetLong((string)"pdxSerializedBytes"),
- "Total pdxDeserializedBytes should be greater than Total pdxSerializationsBytes");
- }
- }
}
{
@@ -624,22 +341,6 @@ namespace Apache.Geode.Client.UnitTests
PdxTypes4 pRet4 = (PdxTypes4)region0[14];
Assert.AreEqual(p4, pRet4);
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.Greater(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be greater than Total pdxSerializations.");
- Assert.Greater(rStats.GetLong((string)"pdxDeserializedBytes"), rStats.GetLong((string)"pdxSerializedBytes"),
- "Total pdxDeserializedBytes should be greater than Total pdxSerializationsBytes");
- }
- }
}
{
@@ -647,22 +348,6 @@ namespace Apache.Geode.Client.UnitTests
PdxTypes5 pRet5 = (PdxTypes5)region0[15];
Assert.AreEqual(p5, pRet5);
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.Greater(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be greater than Total pdxSerializations.");
- Assert.Greater(rStats.GetLong((string)"pdxDeserializedBytes"), rStats.GetLong((string)"pdxSerializedBytes"),
- "Total pdxDeserializedBytes should be greater than Total pdxSerializationsBytes");
- }
- }
}
{
@@ -670,22 +355,6 @@ namespace Apache.Geode.Client.UnitTests
PdxTypes6 pRet6 = (PdxTypes6)region0[16];
Assert.AreEqual(p6, pRet6);
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.Greater(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be greater than Total pdxSerializations.");
- Assert.Greater(rStats.GetLong((string)"pdxDeserializedBytes"), rStats.GetLong((string)"pdxSerializedBytes"),
- "Total pdxDeserializedBytes should be greater than Total pdxSerializationsBytes");
- }
- }
}
{
@@ -693,22 +362,6 @@ namespace Apache.Geode.Client.UnitTests
PdxTypes7 pRet7 = (PdxTypes7)region0[17];
Assert.AreEqual(p7, pRet7);
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.Greater(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be greater than Total pdxSerializations.");
- Assert.Greater(rStats.GetLong((string)"pdxDeserializedBytes"), rStats.GetLong((string)"pdxSerializedBytes"),
- "Total pdxDeserializedBytes should be greater than Total pdxSerializationsBytes");
- }
- }
}
{
@@ -716,128 +369,32 @@ namespace Apache.Geode.Client.UnitTests
PdxTypes8 pRet8 = (PdxTypes8)region0[18];
Assert.AreEqual(p8, pRet8);
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.Greater(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be greater than Total pdxSerializations.");
- Assert.Greater(rStats.GetLong((string)"pdxDeserializedBytes"), rStats.GetLong((string)"pdxSerializedBytes"),
- "Total pdxDeserializedBytes should be greater than Total pdxSerializationsBytes");
- }
- }
}
{
PdxTypes9 p9 = new PdxTypes9();
PdxTypes9 pRet9 = (PdxTypes9)region0[19];
Assert.AreEqual(p9, pRet9);
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.Greater(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be greater than Total pdxSerializations.");
- Assert.Greater(rStats.GetLong((string)"pdxDeserializedBytes"), rStats.GetLong((string)"pdxSerializedBytes"),
- "Total pdxDeserializedBytes should be greater than Total pdxSerializationsBytes");
- }
- }
}
{
PortfolioPdx retpf = (PortfolioPdx)region0[20];
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.Greater(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be greater than Total pdxSerializations.");
- Assert.Greater(rStats.GetLong((string)"pdxDeserializedBytes"), rStats.GetLong((string)"pdxSerializedBytes"),
- "Total pdxDeserializedBytes should be greater than Total pdxSerializationsBytes");
- }
- }
}
{
PortfolioPdx retpf = (PortfolioPdx)region0[21];
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.Greater(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be greater than Total pdxSerializations.");
- Assert.Greater(rStats.GetLong((string)"pdxDeserializedBytes"), rStats.GetLong((string)"pdxSerializedBytes"),
- "Total pdxDeserializedBytes should be greater than Total pdxSerializationsBytes");
- }
- }
}
{
PdxTypes10 p10 = new PdxTypes10();
PdxTypes10 pRet10 = (PdxTypes10)region0[22];
Assert.AreEqual(p10, pRet10);
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.Greater(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be greater than Total pdxSerializations.");
- Assert.Greater(rStats.GetLong((string)"pdxDeserializedBytes"), rStats.GetLong((string)"pdxSerializedBytes"),
- "Total pdxDeserializedBytes should be greater than Total pdxSerializationsBytes");
- }
- }
}
{
AllPdxTypes apt = new AllPdxTypes(true);
AllPdxTypes aptRet = (AllPdxTypes)region0[23];
Assert.AreEqual(apt, aptRet);
checkPdxInstanceToStringAtServer(region0);
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.Greater(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be greater than Total pdxSerializations.");
- Assert.Greater(rStats.GetLong((string)"pdxDeserializedBytes"), rStats.GetLong((string)"pdxSerializedBytes"),
- "Total pdxDeserializedBytes should be greater than Total pdxSerializationsBytes");
- }
- }
}
}
@@ -1128,7 +685,7 @@ namespace Apache.Geode.Client.UnitTests
{
try
{
- Serializable.RegisterTypeGeneric(PdxTests.PdxInsideIGeodeSerializable.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(PdxTests.PdxInsideIGeodeSerializable.CreateDeserializable, CacheHelper.DCache);
Serializable.RegisterPdxType(NestedPdx.CreateDeserializable);
Serializable.RegisterPdxType(PdxTypes1.CreateDeserializable);
Serializable.RegisterPdxType(PdxTypes2.CreateDeserializable);
@@ -1156,7 +713,7 @@ namespace Apache.Geode.Client.UnitTests
{
try
{
- Serializable.RegisterTypeGeneric(PdxTests.PdxInsideIGeodeSerializable.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(PdxTests.PdxInsideIGeodeSerializable.CreateDeserializable, CacheHelper.DCache);
Serializable.RegisterPdxType(NestedPdx.CreateDeserializable);
Serializable.RegisterPdxType(PdxTypes1.CreateDeserializable);
Serializable.RegisterPdxType(PdxTypes2.CreateDeserializable);
@@ -1371,7 +928,7 @@ namespace Apache.Geode.Client.UnitTests
{
try
{
- Serializable.RegisterTypeGeneric(PdxTests.PdxInsideIGeodeSerializable.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(PdxTests.PdxInsideIGeodeSerializable.CreateDeserializable, CacheHelper.DCache);
Serializable.RegisterPdxType(NestedPdx.CreateDeserializable);
Serializable.RegisterPdxType(PdxTypes1.CreateDeserializable);
Serializable.RegisterPdxType(PdxTypes2.CreateDeserializable);
@@ -1438,25 +995,6 @@ namespace Apache.Geode.Client.UnitTests
object origVal = all[key];
Assert.AreEqual(kv.Value, origVal);
}
-
-
-
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxSerializations {0} ", rStats.GetInt((string)"pdxSerializations"));
- Util.Log("pdxDeserializations = {0} ", rStats.GetInt((string)"pdxDeserializations"));
- Util.Log("pdxSerializedBytes = {0} ", rStats.GetLong((string)"pdxSerializedBytes"));
- Util.Log("pdxDeserializedBytes = {0} ", rStats.GetLong((string)"pdxDeserializedBytes"));
- Assert.AreEqual(rStats.GetInt((string)"pdxDeserializations"), rStats.GetInt((string)"pdxSerializations"),
- "Total pdxDeserializations should be equal to Total pdxSerializations.");
- Assert.AreEqual(rStats.GetLong((string)"pdxSerializedBytes"), rStats.GetLong((string)"pdxDeserializedBytes"),
- "Total pdxDeserializedBytes should be equal to Total pdxSerializationsBytes");
- }
- }
}
@@ -1502,7 +1040,7 @@ namespace Apache.Geode.Client.UnitTests
{
try
{
- Serializable.RegisterTypeGeneric(PdxTests.PdxInsideIGeodeSerializable.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(PdxTests.PdxInsideIGeodeSerializable.CreateDeserializable, CacheHelper.DCache);
Serializable.RegisterPdxType(NestedPdx.CreateDeserializable);
Serializable.RegisterPdxType(PdxTypes1.CreateDeserializable);
Serializable.RegisterPdxType(PdxTypes2.CreateDeserializable);
@@ -3487,20 +3025,6 @@ namespace Apache.Geode.Client.UnitTests
Assert.AreEqual(pp, ppOrig, "Parent pdx should be equal ");
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxInstanceDeserializations for PdxInstance getObject = {0} ", rStats.GetInt((string)"pdxInstanceDeserializations"));
- Util.Log("pdxInstanceCreations for PdxInstance getObject = {0} ", rStats.GetInt((string)"pdxInstanceCreations"));
- Util.Log("pdxInstanceDeserializationTime for PdxInstance getObject = {0} ", rStats.GetLong((string)"pdxInstanceDeserializationTime"));
- Assert.AreEqual(rStats.GetInt((string)"pdxInstanceDeserializations"), 2, "pdxInstanceDeserializations should be 2.");
- Assert.AreEqual(rStats.GetInt((string)"pdxInstanceCreations"), 2, "pdxInstanceCreations should be 2");
- Assert.Greater(rStats.GetLong((string)"pdxInstanceDeserializationTime"), 0, "pdxInstanceDeserializationTime should be greater than 0");
- }
- }
}
void verifyPdxInstanceEquals()
@@ -3520,21 +3044,6 @@ namespace Apache.Geode.Client.UnitTests
ret = (IPdxInstance)region0["pdxput2"];
ret2 = (IPdxInstance)region0["pdxput2"];
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxInstanceDeserializations for PdxInstance getObject = {0} ", rStats.GetInt((string)"pdxInstanceDeserializations"));
- Util.Log("pdxInstanceCreations for PdxInstance getObject = {0} ", rStats.GetInt((string)"pdxInstanceCreations"));
- Util.Log("pdxInstanceDeserializationTime for PdxInstance getObject = {0} ", rStats.GetLong((string)"pdxInstanceDeserializationTime"));
- Assert.AreEqual(rStats.GetInt((string)"pdxInstanceDeserializations"), 2, "pdxInstanceDeserializations should be 2.");
- Assert.Greater(rStats.GetInt((string)"pdxInstanceCreations"), 2, "pdxInstanceCreations should be greater than 2");
- Assert.Greater(rStats.GetLong((string)"pdxInstanceDeserializationTime"), 0, "pdxInstanceDeserializationTime should be greater than 0");
- }
- }
-
Assert.AreEqual(ret, ret2, "parent pdx equals are not matched.");
}
@@ -3558,21 +3067,6 @@ namespace Apache.Geode.Client.UnitTests
ret = (IPdxInstance)region0["pdxput2"];
pdxInstHashcode = ret.GetHashCode();
Assert.AreEqual(javaPdxHC, pdxInstHashcode, "Pdxhashcode hashcode not matched with java padx hash code for Parentpdx class.");
-
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxInstanceDeserializations for PdxInstance getObject = {0} ", rStats.GetInt((string)"pdxInstanceDeserializations"));
- Util.Log("pdxInstanceCreations for PdxInstance getObject = {0} ", rStats.GetInt((string)"pdxInstanceCreations"));
- Util.Log("pdxInstanceDeserializationTime for PdxInstance getObject = {0} ", rStats.GetLong((string)"pdxInstanceDeserializationTime"));
- Assert.AreEqual(rStats.GetInt((string)"pdxInstanceDeserializations"), 2, "pdxInstanceDeserializations should be 2.");
- Assert.Greater(rStats.GetInt((string)"pdxInstanceCreations"), 2, "pdxInstanceCreations should be greater than 2");
- Assert.Greater(rStats.GetLong((string)"pdxInstanceDeserializationTime"), 0, "pdxInstanceDeserializationTime should be greater than 0");
- }
- }
}
void accessPdxInstance()
@@ -3992,21 +3486,6 @@ namespace Apache.Geode.Client.UnitTests
Assert.AreNotEqual(pdxins, newpdxins, "parent pdx should be not equal");
Assert.AreNotEqual(cpi, newpdxins.GetField("_childPdx"), "child pdx instance should be equal");
Assert.AreEqual(new ChildPdx(2), ((IPdxInstance)(newpdxins.GetField("_childPdx"))).GetObject(), "child pdx instance should be equal");
-
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxInstanceDeserializations for PdxInstance getObject = {0} ", rStats.GetInt((string)"pdxInstanceDeserializations"));
- Util.Log("pdxInstanceCreations for PdxInstance getObject = {0} ", rStats.GetInt((string)"pdxInstanceCreations"));
- Util.Log("pdxInstanceDeserializationTime for PdxInstance getObject = {0} ", rStats.GetLong((string)"pdxInstanceDeserializationTime"));
- Assert.AreEqual(rStats.GetInt((string)"pdxInstanceDeserializations"), 6, "pdxInstanceDeserializations should be 6.");
- Assert.Greater(rStats.GetInt((string)"pdxInstanceCreations"), 2, "pdxInstanceCreations should be greater than 2");
- Assert.Greater(rStats.GetLong((string)"pdxInstanceDeserializationTime"), 0, "pdxInstanceDeserializationTime should be greater than 0");
- }
- }
}
void runPdxInstanceTest()
@@ -4097,21 +3576,6 @@ namespace Apache.Geode.Client.UnitTests
IPdxInstance pi2 = (IPdxInstance)region0[1];
Assert.AreEqual(pi, pi2, "Both pdx instance should equal.");
-
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxInstanceDeserializations for PdxInstance getObject = {0} ", rStats.GetInt((string)"pdxInstanceDeserializations"));
- Util.Log("pdxInstanceCreations for PdxInstance getObject = {0} ", rStats.GetInt((string)"pdxInstanceCreations"));
- Util.Log("pdxInstanceDeserializationTime for PdxInstance getObject = {0} ", rStats.GetLong((string)"pdxInstanceDeserializationTime"));
- Assert.AreEqual(rStats.GetInt((string)"pdxInstanceDeserializations"), 0, "pdxInstanceDeserializations should be 0.");
- Assert.AreEqual(rStats.GetInt((string)"pdxInstanceCreations"), 2, "pdxInstanceCreations should be 2");
- Assert.AreEqual(rStats.GetLong((string)"pdxInstanceDeserializationTime"), 0, "pdxInstanceDeserializationTime should be 0");
- }
- }
}
void putPdxWithNullIdentityFields()
@@ -4144,21 +3608,6 @@ namespace Apache.Geode.Client.UnitTests
region0.GetAll(keys, values, null);
Assert.AreEqual(values.Count, 2, "Getall count should be two");
-
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxInstanceDeserializations for PdxInstance getObject = {0} ", rStats.GetInt((string)"pdxInstanceDeserializations"));
- Util.Log("pdxInstanceCreations for PdxInstance getObject = {0} ", rStats.GetInt((string)"pdxInstanceCreations"));
- Util.Log("pdxInstanceDeserializationTime for PdxInstance getObject = {0} ", rStats.GetLong((string)"pdxInstanceDeserializationTime"));
- Assert.AreEqual(rStats.GetInt((string)"pdxInstanceDeserializations"), 0, "pdxInstanceDeserializations should be 0.");
- Assert.AreEqual(rStats.GetInt((string)"pdxInstanceCreations"), 6, "pdxInstanceCreations should be 6");
- Assert.AreEqual(rStats.GetLong((string)"pdxInstanceDeserializationTime"), 0, "pdxInstanceDeserializationTime should be 0");
- }
- }
}
void runPdxReadSerializedTest()
@@ -4553,21 +4002,6 @@ namespace Apache.Geode.Client.UnitTests
newpdxins = (IPdxInstance)lRegion["pdxput"];
Assert.AreEqual((CacheableLinkedHashSet)newpdxins.GetField("m_clhs"), clhs, "CacheableLinkedHashSet is not equal");
Assert.AreNotEqual(pdxins, newpdxins, "PdxInstance should not be equal");
-
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxInstanceDeserializations for PdxInstance getObject = {0} ", rStats.GetInt((string)"pdxInstanceDeserializations"));
- Util.Log("pdxInstanceCreations for PdxInstance getObject = {0} ", rStats.GetInt((string)"pdxInstanceCreations"));
- Util.Log("pdxInstanceDeserializationTime for PdxInstance getObject = {0} ", rStats.GetLong((string)"pdxInstanceDeserializationTime"));
- Assert.AreEqual(rStats.GetInt((string)"pdxInstanceDeserializations"), 0, "pdxInstanceDeserializations should be 0.");
- Assert.Greater(rStats.GetInt((string)"pdxInstanceCreations"), 0, "pdxInstanceCreations should be greater than 0");
- Assert.AreEqual(rStats.GetLong((string)"pdxInstanceDeserializationTime"), 0, "pdxInstanceDeserializationTime should be 0");
- }
- }
}
void runPdxInstanceLocalTest()
@@ -4693,20 +4127,6 @@ namespace Apache.Geode.Client.UnitTests
ret = region0["pp"];
Assert.AreEqual(ret, pp, "parent pdx should be same");
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxInstanceDeserializations for PdxInstance getObject = {0} ", rStats.GetInt((string)"pdxInstanceDeserializations"));
- Util.Log("pdxInstanceCreations for PdxInstance getObject = {0} ", rStats.GetInt((string)"pdxInstanceCreations"));
- Util.Log("pdxInstanceDeserializationTime for PdxInstance getObject = {0} ", rStats.GetLong((string)"pdxInstanceDeserializationTime"));
- Assert.AreEqual(rStats.GetInt((string)"pdxInstanceDeserializations"), 1, "pdxInstanceDeserializations should be 1.");
- Assert.AreEqual(rStats.GetInt((string)"pdxInstanceCreations"), 0, "pdxInstanceCreations should be 0");
- Assert.Greater(rStats.GetLong((string)"pdxInstanceDeserializationTime"), 0, "pdxInstanceDeserializationTime should be greater than 0");
- }
- }
}
//this test use write field Api
@@ -4795,21 +4215,6 @@ namespace Apache.Geode.Client.UnitTests
ret = region0["ppwf"];
Assert.AreEqual(ret, pp, "parent pdx should be same");
-
- //Statistics chk for Pdx.
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("CachePerfStats");
- if (type != null) {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null) {
- Util.Log("pdxInstanceDeserializations for PdxInstance getObject = {0} ", rStats.GetInt((string)"pdxInstanceDeserializations"));
- Util.Log("pdxInstanceCreations for PdxInstance getObject = {0} ", rStats.GetInt((string)"pdxInstanceCreations"));
- Util.Log("pdxInstanceDeserializationTime for PdxInstance getObject = {0} ", rStats.GetLong((string)"pdxInstanceDeserializationTime"));
- Assert.AreEqual(rStats.GetInt((string)"pdxInstanceDeserializations"), 2, "pdxInstanceDeserializations should be 2.");
- Assert.AreEqual(rStats.GetInt((string)"pdxInstanceCreations"), 0, "pdxInstanceCreations should be 0");
- Assert.Greater(rStats.GetLong((string)"pdxInstanceDeserializationTime"), 0, "pdxInstanceDeserializationTime should be greater than 0");
- }
- }
}
public void runPdxInstanceFactoryTest()
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/ThinClientPoolTestsN.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/ThinClientPoolTestsN.cs b/src/clicache/integration-test/ThinClientPoolTestsN.cs
index 42b0bcd..32e0d5e 100644
--- a/src/clicache/integration-test/ThinClientPoolTestsN.cs
+++ b/src/clicache/integration-test/ThinClientPoolTestsN.cs
@@ -263,9 +263,9 @@ namespace Apache.Geode.Client.UnitTests
Assert.AreEqual("test_pool_2", poolNameRegion2);
Assert.AreEqual("test_pool_2", poolNameSubRegion);
- Pool poolOfRegion1 = PoolManager.Find(poolNameRegion1);
- Pool poolOfRegion2 = PoolManager.Find(poolNameRegion2);
- Pool poolOfSubRegion = PoolManager.Find(poolNameSubRegion);
+ Pool poolOfRegion1 = CacheHelper.DCache.GetPoolManager().Find(poolNameRegion1);
+ Pool poolOfRegion2 = CacheHelper.DCache.GetPoolManager().Find(poolNameRegion2);
+ Pool poolOfSubRegion = CacheHelper.DCache.GetPoolManager().Find(poolNameSubRegion);
string[] locators = new string[1] { "localhost:" + CacheHelper.LOCATOR_PORT_1 };
string[] servers = new string[2] { "localhost:" + CacheHelper.HOST_PORT_1, "localhost:" + CacheHelper.HOST_PORT_2 };
@@ -360,7 +360,7 @@ namespace Apache.Geode.Client.UnitTests
{
CacheHelper.Init();
- PoolFactory factory = PoolManager.CreateFactory();
+ PoolFactory factory = CacheHelper.DCache.GetPoolManager().CreateFactory();
factory.SetFreeConnectionTimeout(10000);
factory.SetLoadConditioningInterval(1);
factory.SetSocketBufferSize(1024);
@@ -380,7 +380,7 @@ namespace Apache.Geode.Client.UnitTests
factory.AddLocator("localhost", CacheHelper.LOCATOR_PORT_1);
factory.SetPRSingleHopEnabled(false);
- Pool pool = factory.Create(poolName);
+ Pool pool = factory.Create(poolName, CacheHelper.DCache);
Assert.AreEqual(10000, pool.FreeConnectionTimeout, "FreeConnectionTimeout");
Assert.AreEqual(1, pool.LoadConditioningInterval, "LoadConditioningInterval");
@@ -411,7 +411,7 @@ namespace Apache.Geode.Client.UnitTests
config.Insert("cache-xml-file", xmlFile);
CacheHelper.InitConfig(config);
- Pool pool = PoolManager.Find(poolName);
+ Pool pool = CacheHelper.DCache.GetPoolManager().Find(poolName);
Assert.AreEqual("clientPool", pool.Name, "Pool Name");
Assert.AreEqual(10000, pool.FreeConnectionTimeout, "FreeConnectionTimeout");
@@ -435,10 +435,10 @@ namespace Apache.Geode.Client.UnitTests
public void testExistingPool(string poolName)
{
- PoolFactory factory = PoolManager.CreateFactory();
+ PoolFactory factory = CacheHelper.DCache.GetPoolManager().CreateFactory();
try
{
- factory.Create(poolName);
+ factory.Create(poolName, CacheHelper.DCache);
Assert.Fail("Did not get expected IllegalStateException");
}
catch (IllegalStateException /*excp*/)
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/ThinClientQueryTestsN.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/ThinClientQueryTestsN.cs b/src/clicache/integration-test/ThinClientQueryTestsN.cs
index c03aa1d..ef6c0e1 100644
--- a/src/clicache/integration-test/ThinClientQueryTestsN.cs
+++ b/src/clicache/integration-test/ThinClientQueryTestsN.cs
@@ -59,8 +59,6 @@ namespace Apache.Geode.Client.UnitTests
public override void InitTests()
{
base.InitTests();
- m_client1.Call(InitClient);
- m_client2.Call(InitClient);
}
[TearDown]
@@ -70,32 +68,31 @@ namespace Apache.Geode.Client.UnitTests
base.EndTest();
}
+ [SetUp]
+ public override void InitTest()
+ {
+ m_client1.Call(InitClient);
+ m_client2.Call(InitClient);
+ }
+
#region Functions invoked by the tests
public void InitClient()
{
CacheHelper.Init();
- try
- {
- Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable);
- Serializable.RegisterTypeGeneric(Position.CreateDeserializable);
- Serializable.RegisterPdxType(Apache.Geode.Client.Tests.PortfolioPdx.CreateDeserializable);
- Serializable.RegisterPdxType(Apache.Geode.Client.Tests.PositionPdx.CreateDeserializable);
- }
- catch (IllegalStateException)
- {
- // ignore since we run multiple iterations for pool and non pool configs
- }
+ Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable, CacheHelper.DCache);
+ Serializable.RegisterTypeGeneric(Position.CreateDeserializable, CacheHelper.DCache);
+ Serializable.RegisterPdxType(Apache.Geode.Client.Tests.PortfolioPdx.CreateDeserializable);
+ Serializable.RegisterPdxType(Apache.Geode.Client.Tests.PositionPdx.CreateDeserializable);
}
public void StepOneQE(string locators, bool isPdx)
{
m_isPdx = isPdx;
- CacheHelper.Init();
try
{
QueryService<object, object> qsFail = null;
- qsFail = PoolManager/*<object, object>*/.CreateFactory().Create("_TESTFAILPOOL_").GetQueryService<object, object>();
+ qsFail = CacheHelper.DCache.GetPoolManager().CreateFactory().Create("_TESTFAILPOOL_", CacheHelper.DCache).GetQueryService<object, object>();
Query<object> qryFail = qsFail.NewQuery("select distinct * from /" + QERegionName);
ISelectResults<object> resultsFail = qryFail.Execute();
Assert.Fail("Since no endpoints defined, so exception expected");
@@ -134,7 +131,7 @@ namespace Apache.Geode.Client.UnitTests
}
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
Query<object> qry = qs.NewQuery("select distinct * from /" + QERegionName);
ISelectResults<object> results = qry.Execute();
@@ -148,7 +145,7 @@ namespace Apache.Geode.Client.UnitTests
public void StepTwoQE()
{
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
Util.Log("Going to execute the query");
Query<object> qry = qs.NewQuery("select distinct * from /" + QERegionName);
ISelectResults<object> results = qry.Execute();
@@ -182,7 +179,7 @@ namespace Apache.Geode.Client.UnitTests
IRegion<object, object> region2 = CacheHelper.GetRegion<object, object>(QueryRegionNames[2]);
IRegion<object, object> region3 = CacheHelper.GetRegion<object, object>(QueryRegionNames[3]);
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
Util.Log("SetSize {0}, NumSets {1}.", qh.PortfolioSetSize,
qh.PortfolioNumSets);
@@ -219,7 +216,7 @@ namespace Apache.Geode.Client.UnitTests
IRegion<object, object> region0 = CacheHelper.GetRegion<object, object>(QueryRegionNames[0]);
IRegion<object, object> subRegion0 = region0.GetSubRegion(QueryRegionNames[1]);
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
if (!m_isPdx)
{
@@ -237,11 +234,11 @@ namespace Apache.Geode.Client.UnitTests
{
bool ErrorOccurred = false;
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
int qryIdx = 0;
@@ -353,11 +350,11 @@ namespace Apache.Geode.Client.UnitTests
{
bool ErrorOccurred = false;
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
int qryIdx = 0;
@@ -481,11 +478,11 @@ namespace Apache.Geode.Client.UnitTests
{
bool ErrorOccurred = false;
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
int qryIdx = 0;
@@ -529,11 +526,11 @@ namespace Apache.Geode.Client.UnitTests
{
bool ErrorOccurred = false;
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
int qryIdx = 0;
@@ -598,11 +595,11 @@ namespace Apache.Geode.Client.UnitTests
{
bool ErrorOccurred = false;
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
int qryIdx = 0;
@@ -670,11 +667,11 @@ namespace Apache.Geode.Client.UnitTests
{
bool ErrorOccurred = false;
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
int qryIdx = 0;
@@ -764,11 +761,11 @@ namespace Apache.Geode.Client.UnitTests
{
bool ErrorOccurred = false;
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
int qryIdx = 0;
@@ -812,11 +809,11 @@ namespace Apache.Geode.Client.UnitTests
{
bool ErrorOccurred = false;
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
int qryIdx = 0;
@@ -939,7 +936,7 @@ namespace Apache.Geode.Client.UnitTests
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
for (int i = 0; i < 10000; i++)
{
@@ -976,7 +973,7 @@ namespace Apache.Geode.Client.UnitTests
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
for (int i = 0; i < 10000; i++)
{
@@ -1009,9 +1006,9 @@ namespace Apache.Geode.Client.UnitTests
public void StepThreeQT()
{
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
Util.Log("query " + QueryStatics.ResultSetQueries[34].Query);
Query<object> query = qs.NewQuery(QueryStatics.ResultSetQueries[34].Query);
@@ -1031,9 +1028,9 @@ namespace Apache.Geode.Client.UnitTests
public void StepFourQT()
{
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
Query<object> query = qs.NewQuery(QueryStatics.ResultSetQueries[35].Query);
@@ -1052,9 +1049,9 @@ namespace Apache.Geode.Client.UnitTests
public void StepFiveQT()
{
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
Query<object> query = qs.NewQuery(QueryStatics.StructSetQueries[17].Query);
@@ -1074,9 +1071,9 @@ namespace Apache.Geode.Client.UnitTests
public void StepSixQT()
{
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
Query<object> query = qs.NewQuery(QueryStatics.StructSetQueries[17].Query);
try
@@ -1094,9 +1091,9 @@ namespace Apache.Geode.Client.UnitTests
public void StepThreePQT()
{
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
Query<object> query = qs.NewQuery(QueryStatics.StructSetParamQueries[5].Query);
@@ -1137,9 +1134,9 @@ namespace Apache.Geode.Client.UnitTests
public void StepFourPQT()
{
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
Query<object> query = qs.NewQuery(QueryStatics.StructSetParamQueries[5].Query);
@@ -1500,7 +1497,7 @@ namespace Apache.Geode.Client.UnitTests
// List<ICacheableKey> PortKeys = new List<ICacheableKey>();
// CacheableHashMap ExpectedPosMap = new CacheableHashMap();
// CacheableHashMap ExpectedPortMap = new CacheableHashMap();
- // QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ // QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
// int SetSize = qh.PositionSetSize;
// int NumSets = qh.PositionNumSets;
// for (int set = 1; set <= NumSets; set++)
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/ThinClientRegionTestsN.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/ThinClientRegionTestsN.cs b/src/clicache/integration-test/ThinClientRegionTestsN.cs
index 2e974a6..3f3242e 100644
--- a/src/clicache/integration-test/ThinClientRegionTestsN.cs
+++ b/src/clicache/integration-test/ThinClientRegionTestsN.cs
@@ -376,7 +376,7 @@ namespace Apache.Geode.Client.UnitTests
{
try
{
- Serializable.RegisterTypeGeneric(OtherType.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(OtherType.CreateDeserializable, CacheHelper.DCache);
}
catch (IllegalStateException)
{
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/ThinClientSecurityAuthzTestBaseN.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/ThinClientSecurityAuthzTestBaseN.cs b/src/clicache/integration-test/ThinClientSecurityAuthzTestBaseN.cs
index 19bd388..a66c41d 100644
--- a/src/clicache/integration-test/ThinClientSecurityAuthzTestBaseN.cs
+++ b/src/clicache/integration-test/ThinClientSecurityAuthzTestBaseN.cs
@@ -406,7 +406,7 @@ namespace Apache.Geode.Client.UnitTests
region.RemoveAll(keys);
break;
case OperationCode.ExecuteCQ:
- Pool/*<object, object>*/ pool = PoolManager/*<object, object>*/.Find("__TESTPOOL1_");
+ Pool/*<object, object>*/ pool = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_");
QueryService<object, object> qs;
if (pool != null)
{
@@ -429,7 +429,7 @@ namespace Apache.Geode.Client.UnitTests
case OperationCode.ExecuteFunction:
if (!isMultiuser)
{
- Pool/*<object, object>*/ pool2 = PoolManager/*<object, object>*/.Find("__TESTPOOL1_");
+ Pool/*<object, object>*/ pool2 = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_");
if (pool2 != null)
{
Client.FunctionService<object>.OnServer(pool2).Execute("securityTest");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/ThinClientSecurityAuthzTestsMUN.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/ThinClientSecurityAuthzTestsMUN.cs b/src/clicache/integration-test/ThinClientSecurityAuthzTestsMUN.cs
index 2ac9a12..3d697bb 100644
--- a/src/clicache/integration-test/ThinClientSecurityAuthzTestsMUN.cs
+++ b/src/clicache/integration-test/ThinClientSecurityAuthzTestsMUN.cs
@@ -238,8 +238,8 @@ namespace Apache.Geode.Client.UnitTests
try
{
- Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable);
- Serializable.RegisterTypeGeneric(Position.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable, CacheHelper.DCache);
+ Serializable.RegisterTypeGeneric(Position.CreateDeserializable, CacheHelper.DCache);
Util.Log("registerCQ portfolio registered");
}
catch (IllegalStateException)
@@ -267,8 +267,8 @@ namespace Apache.Geode.Client.UnitTests
try
{
- Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable);
- Serializable.RegisterTypeGeneric(Position.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable, CacheHelper.DCache);
+ Serializable.RegisterTypeGeneric(Position.CreateDeserializable, CacheHelper.DCache);
Util.Log("doCQPut portfolio registered");
}
catch (IllegalStateException)
[18/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testExpiration.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testExpiration.cpp b/src/cppcache/integration-test/testExpiration.cpp
index 342b8bb..7fc5c00 100644
--- a/src/cppcache/integration-test/testExpiration.cpp
+++ b/src/cppcache/integration-test/testExpiration.cpp
@@ -19,7 +19,8 @@
#include "fw_helper.hpp"
#include <geode/GeodeCppCache.hpp>
-#include <CacheRegionHelper.hpp>
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
using namespace apache::geode::client;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testOverflowPutGetSqLite.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testOverflowPutGetSqLite.cpp b/src/cppcache/integration-test/testOverflowPutGetSqLite.cpp
index ffac596..7467539 100644
--- a/src/cppcache/integration-test/testOverflowPutGetSqLite.cpp
+++ b/src/cppcache/integration-test/testOverflowPutGetSqLite.cpp
@@ -512,7 +512,7 @@ END_TEST(OverFlowTest_SqLiteFull)
// BEGIN_TEST(OverFlowTest_LargeData)
//{
// /** Connecting to a distributed system. */
-// DistributedSystemPtr dsysPtr;
+// DistributedSystem& dsysPtr;
//
// /** Creating a cache to manage regions. */
// CachePtr cachePtr ;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testRegionTemplateArgs.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testRegionTemplateArgs.cpp b/src/cppcache/integration-test/testRegionTemplateArgs.cpp
index 457825c..1418bea 100644
--- a/src/cppcache/integration-test/testRegionTemplateArgs.cpp
+++ b/src/cppcache/integration-test/testRegionTemplateArgs.cpp
@@ -18,7 +18,8 @@
#define ROOT_NAME "testRegionTemplateArgs"
#include <geode/GeodeCppCache.hpp>
-#include <CacheRegionHelper.hpp>
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
#include "fw_helper.hpp"
using namespace apache::geode::client;
@@ -77,10 +78,12 @@ BEGIN_TEST(CheckTemplates)
resValPtr = std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(keyPtr));
ASSERT(CheckBytesEqual(resValPtr, valPtr),
"put/get:: incorrect valPtr value");
- resValPtr = std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(stringPtr));
+ resValPtr =
+ std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(stringPtr));
ASSERT(CheckBytesEqual(resValPtr, valPtr),
"put/get:: incorrect valPtr value");
- resValPtr = std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(int32Ptr));
+ resValPtr =
+ std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(int32Ptr));
ASSERT(CheckBytesEqual(resValPtr, valPtr),
"put/get:: incorrect valPtr value");
resValPtr = std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(intKey));
@@ -103,10 +106,12 @@ BEGIN_TEST(CheckTemplates)
resValPtr = std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(keyPtr));
ASSERT(CheckBytesEqual(resValPtr, bytesPtr),
"put/get:: incorrect bytesPtr value");
- resValPtr = std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(stringPtr));
+ resValPtr =
+ std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(stringPtr));
ASSERT(CheckBytesEqual(resValPtr, bytesPtr),
"put/get:: incorrect bytesPtr value");
- resValPtr = std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(int32Ptr));
+ resValPtr =
+ std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(int32Ptr));
ASSERT(CheckBytesEqual(resValPtr, bytesPtr),
"put/get:: incorrect bytesPtr value");
resValPtr = std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(intKey));
@@ -126,19 +131,24 @@ BEGIN_TEST(CheckTemplates)
regPtr->put(charKey, stringPtr);
regPtr->put(intKey, stringPtr);
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr));
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr));
ASSERT(resStringPtr.get() == stringPtr.get(),
"put/get:: incorrect stringPtr value");
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(stringPtr));
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(regPtr->get(stringPtr));
ASSERT(resStringPtr.get() == stringPtr.get(),
"put/get:: incorrect stringPtr value");
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(int32Ptr));
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(regPtr->get(int32Ptr));
ASSERT(resStringPtr.get() == stringPtr.get(),
"put/get:: incorrect stringPtr value");
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(intKey));
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(regPtr->get(intKey));
ASSERT(resStringPtr.get() == stringPtr.get(),
"put/get:: incorrect stringPtr value");
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(charKey));
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(regPtr->get(charKey));
ASSERT(resStringPtr.get() == stringPtr.get(),
"put/get:: incorrect stringPtr value");
@@ -152,19 +162,24 @@ BEGIN_TEST(CheckTemplates)
regPtr->put(charKey, int32Ptr);
regPtr->put(intKey, int32Ptr);
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(keyPtr));
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(keyPtr));
ASSERT(resInt32Ptr.get() == int32Ptr.get(),
"put/get:: incorrect int32Ptr value");
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(stringPtr));
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(stringPtr));
ASSERT(resInt32Ptr.get() == int32Ptr.get(),
"put/get:: incorrect int32Ptr value");
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(int32Ptr));
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(int32Ptr));
ASSERT(resInt32Ptr.get() == int32Ptr.get(),
"put/get:: incorrect int32Ptr value");
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(intKey));
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(intKey));
ASSERT(resInt32Ptr.get() == int32Ptr.get(),
"put/get:: incorrect int32Ptr value");
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(charKey));
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(charKey));
ASSERT(resInt32Ptr.get() == int32Ptr.get(),
"put/get:: incorrect int32Ptr value");
@@ -178,19 +193,24 @@ BEGIN_TEST(CheckTemplates)
regPtr->put(charKey, charVal);
regPtr->put(intKey, charVal);
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr));
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr));
ASSERT(strcmp(resStringPtr->asChar(), charVal) == 0,
"put/get:: incorrect charVal value");
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(stringPtr));
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(regPtr->get(stringPtr));
ASSERT(strcmp(resStringPtr->asChar(), charVal) == 0,
"put/get:: incorrect charVal value");
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(int32Ptr));
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(regPtr->get(int32Ptr));
ASSERT(strcmp(resStringPtr->asChar(), charVal) == 0,
"put/get:: incorrect charVal value");
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(intKey));
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(regPtr->get(intKey));
ASSERT(strcmp(resStringPtr->asChar(), charVal) == 0,
"put/get:: incorrect charVal value");
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(charKey));
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(regPtr->get(charKey));
ASSERT(strcmp(resStringPtr->asChar(), charVal) == 0,
"put/get:: incorrect charVal value");
@@ -204,15 +224,20 @@ BEGIN_TEST(CheckTemplates)
regPtr->put(charKey, intVal);
regPtr->put(intKey, intVal);
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(keyPtr));
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(keyPtr));
ASSERT(resInt32Ptr->value() == intVal, "put/get:: incorrect intVal value");
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(stringPtr));
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(stringPtr));
ASSERT(resInt32Ptr->value() == intVal, "put/get:: incorrect intVal value");
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(int32Ptr));
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(int32Ptr));
ASSERT(resInt32Ptr->value() == intVal, "put/get:: incorrect intVal value");
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(intKey));
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(intKey));
ASSERT(resInt32Ptr->value() == intVal, "put/get:: incorrect intVal value");
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(charKey));
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(charKey));
ASSERT(resInt32Ptr->value() == intVal, "put/get:: incorrect intVal value");
// End with intVal
@@ -239,10 +264,12 @@ BEGIN_TEST(CheckTemplates)
resValPtr = std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(keyPtr));
ASSERT(CheckBytesEqual(resValPtr, valPtr),
"create/get/localDestroy:: incorrect valPtr value");
- resValPtr = std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(stringPtr));
+ resValPtr =
+ std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(stringPtr));
ASSERT(CheckBytesEqual(resValPtr, valPtr),
"create/get/localDestroy:: incorrect valPtr value");
- resValPtr = std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(int32Ptr));
+ resValPtr =
+ std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(int32Ptr));
ASSERT(CheckBytesEqual(resValPtr, valPtr),
"create/get/localDestroy:: incorrect valPtr value");
resValPtr = std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(intKey));
@@ -306,10 +333,12 @@ BEGIN_TEST(CheckTemplates)
resValPtr = std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(keyPtr));
ASSERT(CheckBytesEqual(resValPtr, bytesPtr),
"create/get/localDestroy:: incorrect bytesPtr value");
- resValPtr = std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(stringPtr));
+ resValPtr =
+ std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(stringPtr));
ASSERT(CheckBytesEqual(resValPtr, bytesPtr),
"create/get/localDestroy:: incorrect bytesPtr value");
- resValPtr = std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(int32Ptr));
+ resValPtr =
+ std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(int32Ptr));
ASSERT(CheckBytesEqual(resValPtr, bytesPtr),
"create/get/localDestroy:: incorrect bytesPtr value");
resValPtr = std::dynamic_pointer_cast<CacheableBytes>(regPtr->get(intKey));
@@ -370,19 +399,24 @@ BEGIN_TEST(CheckTemplates)
regPtr->create(charKey, stringPtr);
regPtr->create(intKey, stringPtr);
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr));
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr));
ASSERT(resStringPtr.get() == stringPtr.get(),
"create/get/localDestroy:: incorrect stringPtr value");
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(stringPtr));
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(regPtr->get(stringPtr));
ASSERT(resStringPtr.get() == stringPtr.get(),
"create/get/localDestroy:: incorrect stringPtr value");
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(int32Ptr));
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(regPtr->get(int32Ptr));
ASSERT(resStringPtr.get() == stringPtr.get(),
"create/get/localDestroy:: incorrect stringPtr value");
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(intKey));
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(regPtr->get(intKey));
ASSERT(resStringPtr.get() == stringPtr.get(),
"create/get/localDestroy:: incorrect stringPtr value");
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(charKey));
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(regPtr->get(charKey));
ASSERT(resStringPtr.get() == stringPtr.get(),
"create/get/localDestroy:: incorrect stringPtr value");
@@ -437,19 +471,24 @@ BEGIN_TEST(CheckTemplates)
regPtr->create(charKey, int32Ptr);
regPtr->create(intKey, int32Ptr);
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(keyPtr));
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(keyPtr));
ASSERT(resInt32Ptr.get() == int32Ptr.get(),
"create/get/localDestroy:: incorrect int32Ptr value");
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(stringPtr));
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(stringPtr));
ASSERT(resInt32Ptr.get() == int32Ptr.get(),
"create/get/localDestroy:: incorrect int32Ptr value");
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(int32Ptr));
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(int32Ptr));
ASSERT(resInt32Ptr.get() == int32Ptr.get(),
"create/get/localDestroy:: incorrect int32Ptr value");
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(intKey));
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(intKey));
ASSERT(resInt32Ptr.get() == int32Ptr.get(),
"create/get/localDestroy:: incorrect int32Ptr value");
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(charKey));
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(charKey));
ASSERT(resInt32Ptr.get() == int32Ptr.get(),
"create/get/localDestroy:: incorrect int32Ptr value");
@@ -504,19 +543,24 @@ BEGIN_TEST(CheckTemplates)
regPtr->create(charKey, charVal);
regPtr->create(intKey, charVal);
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr));
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr));
ASSERT(strcmp(resStringPtr->asChar(), charVal) == 0,
"create/get/localDestroy:: incorrect charVal value");
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(stringPtr));
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(regPtr->get(stringPtr));
ASSERT(strcmp(resStringPtr->asChar(), charVal) == 0,
"create/get/localDestroy:: incorrect charVal value");
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(int32Ptr));
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(regPtr->get(int32Ptr));
ASSERT(strcmp(resStringPtr->asChar(), charVal) == 0,
"create/get/localDestroy:: incorrect charVal value");
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(intKey));
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(regPtr->get(intKey));
ASSERT(strcmp(resStringPtr->asChar(), charVal) == 0,
"create/get/localDestroy:: incorrect charVal value");
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(charKey));
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(regPtr->get(charKey));
ASSERT(strcmp(resStringPtr->asChar(), charVal) == 0,
"create/get/localDestroy:: incorrect charVal value");
@@ -571,19 +615,24 @@ BEGIN_TEST(CheckTemplates)
regPtr->create(charKey, intVal);
regPtr->create(intKey, intVal);
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(keyPtr));
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(keyPtr));
ASSERT(resInt32Ptr->value() == intVal,
"create/get/localDestroy:: incorrect intVal value");
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(stringPtr));
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(stringPtr));
ASSERT(resInt32Ptr->value() == intVal,
"create/get/localDestroy:: incorrect intVal value");
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(int32Ptr));
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(int32Ptr));
ASSERT(resInt32Ptr->value() == intVal,
"create/get/localDestroy:: incorrect intVal value");
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(intKey));
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(intKey));
ASSERT(resInt32Ptr->value() == intVal,
"create/get/localDestroy:: incorrect intVal value");
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(charKey));
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(charKey));
ASSERT(resInt32Ptr->value() == intVal,
"create/get/localDestroy:: incorrect intVal value");
@@ -644,23 +693,28 @@ BEGIN_TEST(CheckTemplates)
regPtr->create(intKey, valPtr);
resEntryPtr = regPtr->getEntry(keyPtr);
- resValPtr = std::dynamic_pointer_cast<CacheableBytes>(resEntryPtr->getValue());
+ resValPtr =
+ std::dynamic_pointer_cast<CacheableBytes>(resEntryPtr->getValue());
ASSERT(CheckBytesEqual(resValPtr, valPtr),
"create/getEntry/destroy:: incorrect valPtr value");
resEntryPtr = regPtr->getEntry(stringPtr);
- resValPtr = std::dynamic_pointer_cast<CacheableBytes>(resEntryPtr->getValue());
+ resValPtr =
+ std::dynamic_pointer_cast<CacheableBytes>(resEntryPtr->getValue());
ASSERT(CheckBytesEqual(resValPtr, valPtr),
"create/getEntry/destroy:: incorrect valPtr value");
resEntryPtr = regPtr->getEntry(int32Ptr);
- resValPtr = std::dynamic_pointer_cast<CacheableBytes>(resEntryPtr->getValue());
+ resValPtr =
+ std::dynamic_pointer_cast<CacheableBytes>(resEntryPtr->getValue());
ASSERT(CheckBytesEqual(resValPtr, valPtr),
"create/getEntry/destroy:: incorrect valPtr value");
resEntryPtr = regPtr->getEntry(charKey);
- resValPtr = std::dynamic_pointer_cast<CacheableBytes>(resEntryPtr->getValue());
+ resValPtr =
+ std::dynamic_pointer_cast<CacheableBytes>(resEntryPtr->getValue());
ASSERT(CheckBytesEqual(resValPtr, valPtr),
"create/getEntry/destroy:: incorrect valPtr value");
resEntryPtr = regPtr->getEntry(intKey);
- resValPtr = std::dynamic_pointer_cast<CacheableBytes>(resEntryPtr->getValue());
+ resValPtr =
+ std::dynamic_pointer_cast<CacheableBytes>(resEntryPtr->getValue());
ASSERT(CheckBytesEqual(resValPtr, valPtr),
"create/getEntry/destroy:: incorrect valPtr value");
@@ -716,23 +770,28 @@ BEGIN_TEST(CheckTemplates)
regPtr->create(intKey, bytesPtr);
resEntryPtr = regPtr->getEntry(keyPtr);
- resValPtr = std::dynamic_pointer_cast<CacheableBytes>(resEntryPtr->getValue());
+ resValPtr =
+ std::dynamic_pointer_cast<CacheableBytes>(resEntryPtr->getValue());
ASSERT(CheckBytesEqual(resValPtr, bytesPtr),
"create/getEntry/destroy:: incorrect bytesPtr value");
resEntryPtr = regPtr->getEntry(stringPtr);
- resValPtr = std::dynamic_pointer_cast<CacheableBytes>(resEntryPtr->getValue());
+ resValPtr =
+ std::dynamic_pointer_cast<CacheableBytes>(resEntryPtr->getValue());
ASSERT(CheckBytesEqual(resValPtr, bytesPtr),
"create/getEntry/destroy:: incorrect bytesPtr value");
resEntryPtr = regPtr->getEntry(int32Ptr);
- resValPtr = std::dynamic_pointer_cast<CacheableBytes>(resEntryPtr->getValue());
+ resValPtr =
+ std::dynamic_pointer_cast<CacheableBytes>(resEntryPtr->getValue());
ASSERT(CheckBytesEqual(resValPtr, bytesPtr),
"create/getEntry/destroy:: incorrect bytesPtr value");
resEntryPtr = regPtr->getEntry(charKey);
- resValPtr = std::dynamic_pointer_cast<CacheableBytes>(resEntryPtr->getValue());
+ resValPtr =
+ std::dynamic_pointer_cast<CacheableBytes>(resEntryPtr->getValue());
ASSERT(CheckBytesEqual(resValPtr, bytesPtr),
"create/getEntry/destroy:: incorrect bytesPtr value");
resEntryPtr = regPtr->getEntry(intKey);
- resValPtr = std::dynamic_pointer_cast<CacheableBytes>(resEntryPtr->getValue());
+ resValPtr =
+ std::dynamic_pointer_cast<CacheableBytes>(resEntryPtr->getValue());
ASSERT(CheckBytesEqual(resValPtr, bytesPtr),
"create/getEntry/destroy:: incorrect bytesPtr value");
@@ -788,23 +847,28 @@ BEGIN_TEST(CheckTemplates)
regPtr->create(intKey, stringPtr);
resEntryPtr = regPtr->getEntry(keyPtr);
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(resEntryPtr->getValue());
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(resEntryPtr->getValue());
ASSERT(resStringPtr.get() == stringPtr.get(),
"create/getEntry/destroy:: incorrect stringPtr value");
resEntryPtr = regPtr->getEntry(stringPtr);
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(resEntryPtr->getValue());
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(resEntryPtr->getValue());
ASSERT(resStringPtr.get() == stringPtr.get(),
"create/getEntry/destroy:: incorrect stringPtr value");
resEntryPtr = regPtr->getEntry(int32Ptr);
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(resEntryPtr->getValue());
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(resEntryPtr->getValue());
ASSERT(resStringPtr.get() == stringPtr.get(),
"create/getEntry/destroy:: incorrect stringPtr value");
resEntryPtr = regPtr->getEntry(intKey);
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(resEntryPtr->getValue());
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(resEntryPtr->getValue());
ASSERT(resStringPtr.get() == stringPtr.get(),
"create/getEntry/destroy:: incorrect stringPtr value");
resEntryPtr = regPtr->getEntry(charKey);
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(resEntryPtr->getValue());
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(resEntryPtr->getValue());
ASSERT(resStringPtr.get() == stringPtr.get(),
"create/getEntry/destroy:: incorrect stringPtr value");
@@ -860,23 +924,28 @@ BEGIN_TEST(CheckTemplates)
regPtr->create(intKey, int32Ptr);
resEntryPtr = regPtr->getEntry(keyPtr);
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(resEntryPtr->getValue());
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(resEntryPtr->getValue());
ASSERT(resInt32Ptr.get() == int32Ptr.get(),
"create/getEntry/destroy:: incorrect int32Ptr value");
resEntryPtr = regPtr->getEntry(stringPtr);
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(resEntryPtr->getValue());
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(resEntryPtr->getValue());
ASSERT(resInt32Ptr.get() == int32Ptr.get(),
"create/getEntry/destroy:: incorrect int32Ptr value");
resEntryPtr = regPtr->getEntry(int32Ptr);
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(resEntryPtr->getValue());
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(resEntryPtr->getValue());
ASSERT(resInt32Ptr.get() == int32Ptr.get(),
"create/getEntry/destroy:: incorrect int32Ptr value");
resEntryPtr = regPtr->getEntry(intKey);
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(resEntryPtr->getValue());
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(resEntryPtr->getValue());
ASSERT(resInt32Ptr.get() == int32Ptr.get(),
"create/getEntry/destroy:: incorrect int32Ptr value");
resEntryPtr = regPtr->getEntry(charKey);
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(resEntryPtr->getValue());
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(resEntryPtr->getValue());
ASSERT(resInt32Ptr.get() == int32Ptr.get(),
"create/getEntry/destroy:: incorrect int32Ptr value");
@@ -932,23 +1001,28 @@ BEGIN_TEST(CheckTemplates)
regPtr->create(intKey, charVal);
resEntryPtr = regPtr->getEntry(keyPtr);
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(resEntryPtr->getValue());
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(resEntryPtr->getValue());
ASSERT(strcmp(resStringPtr->asChar(), charVal) == 0,
"create/getEntry/destroy:: incorrect charVal value");
resEntryPtr = regPtr->getEntry(stringPtr);
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(resEntryPtr->getValue());
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(resEntryPtr->getValue());
ASSERT(strcmp(resStringPtr->asChar(), charVal) == 0,
"create/getEntry/destroy:: incorrect charVal value");
resEntryPtr = regPtr->getEntry(int32Ptr);
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(resEntryPtr->getValue());
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(resEntryPtr->getValue());
ASSERT(strcmp(resStringPtr->asChar(), charVal) == 0,
"create/getEntry/destroy:: incorrect charVal value");
resEntryPtr = regPtr->getEntry(intKey);
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(resEntryPtr->getValue());
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(resEntryPtr->getValue());
ASSERT(strcmp(resStringPtr->asChar(), charVal) == 0,
"create/getEntry/destroy:: incorrect charVal value");
resEntryPtr = regPtr->getEntry(charKey);
- resStringPtr = std::dynamic_pointer_cast<CacheableString>(resEntryPtr->getValue());
+ resStringPtr =
+ std::dynamic_pointer_cast<CacheableString>(resEntryPtr->getValue());
ASSERT(strcmp(resStringPtr->asChar(), charVal) == 0,
"create/getEntry/destroy:: incorrect charVal value");
@@ -1004,23 +1078,28 @@ BEGIN_TEST(CheckTemplates)
regPtr->create(intKey, intVal);
resEntryPtr = regPtr->getEntry(keyPtr);
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(resEntryPtr->getValue());
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(resEntryPtr->getValue());
ASSERT(resInt32Ptr->value() == intVal,
"create/getEntry/destroy:: incorrect intVal value");
resEntryPtr = regPtr->getEntry(stringPtr);
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(resEntryPtr->getValue());
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(resEntryPtr->getValue());
ASSERT(resInt32Ptr->value() == intVal,
"create/getEntry/destroy:: incorrect intVal value");
resEntryPtr = regPtr->getEntry(int32Ptr);
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(resEntryPtr->getValue());
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(resEntryPtr->getValue());
ASSERT(resInt32Ptr->value() == intVal,
"create/getEntry/destroy:: incorrect intVal value");
resEntryPtr = regPtr->getEntry(intKey);
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(resEntryPtr->getValue());
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(resEntryPtr->getValue());
ASSERT(resInt32Ptr->value() == intVal,
"create/getEntry/destroy:: incorrect intVal value");
resEntryPtr = regPtr->getEntry(charKey);
- resInt32Ptr = std::dynamic_pointer_cast<CacheableInt32>(resEntryPtr->getValue());
+ resInt32Ptr =
+ std::dynamic_pointer_cast<CacheableInt32>(resEntryPtr->getValue());
ASSERT(resInt32Ptr->value() == intVal,
"create/getEntry/destroy:: incorrect intVal value");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testSerialization.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testSerialization.cpp b/src/cppcache/integration-test/testSerialization.cpp
index 52ae925..8f9bf79 100644
--- a/src/cppcache/integration-test/testSerialization.cpp
+++ b/src/cppcache/integration-test/testSerialization.cpp
@@ -45,15 +45,13 @@ int32_t g_classIdToReturn4 = 0x123456;
template <class T>
std::shared_ptr<T> duplicate(const std::shared_ptr<T>& orig) {
std::shared_ptr<T> result;
- DataOutput dout;
- SerializationRegistry::serialize(orig, dout);
- // dout.writeObject(orig);
+ auto dout = getHelper()->getCache()->createDataOutput();
+ dout->writeObject(orig);
uint32_t length = 0;
- const uint8_t* buffer = dout.getBuffer(&length);
- DataInput din(buffer, length);
- result = std::static_pointer_cast<T>(SerializationRegistry::deserialize(din));
- // din.readObject(result);
+ const uint8_t* buffer = dout->getBuffer(&length);
+ auto din = getHelper()->getCache()->createDataInput(buffer, length);
+ din->readObject(result);
return result;
}
@@ -150,81 +148,6 @@ class OtherType : public Serializable {
#define Sender s1p1
#define Receiver s1p2
-DUNIT_TASK(NoDist, SerializeInMemory)
- {
- CppCacheLibrary::initLib();
-
- CacheableStringPtr str = CacheableString::create("hello");
- ASSERT(str->length() == 5, "expected length 5.");
-
- CacheableStringPtr copy = duplicate(str);
-
- ASSERT(*str == *copy, "expected copy to be hello.");
- ASSERT(str != copy, "expected copy to be different object.");
-
- str = CacheableString::create("");
- copy = duplicate(str);
- ASSERT(copy != nullptr, "error null copy.");
- ASSERT(copy->length() == 0, "expected 0 length.");
-
- CacheableInt32Ptr intkey = CacheableInt32::create(1);
- CacheableInt32Ptr intcopy = duplicate(intkey);
- ASSERT(intcopy->value() == 1, "expected value 1.");
-
- CacheableInt64Ptr longkey = CacheableInt64::create(0x1122334455667788LL);
- CacheableInt64Ptr longcopy = duplicate(longkey);
- ASSERT(longcopy->value() == 0x1122334455667788LL,
- "expected value 0x1122334455667788.");
-
- struct blob {
- int m_a;
- bool m_b;
- char m_name[100];
- };
- struct blob borig;
- borig.m_a = 1;
- borig.m_b = true;
- strcpy(borig.m_name, "Joe Cool Coder");
-
- CacheableBytesPtr bytes = CacheableBytes::create(
- reinterpret_cast<uint8_t*>(&borig), sizeof(blob));
- CacheableBytesPtr bytesCopy = duplicate(bytes);
- struct blob* bcopy = (struct blob*)bytesCopy->value();
- ASSERT(0 == strcmp(bcopy->m_name, borig.m_name), "expected Joe Cool Coder");
- ASSERT(1 == bcopy->m_a, "expected value 1");
- }
-ENDTASK
-
-DUNIT_TASK(NoDist, OtherTypeInMemory)
- {
- Serializable::registerType(OtherType::createDeserializable);
- std::shared_ptr<OtherType> ot(new OtherType());
- ot->m_struct.a = 1;
- ot->m_struct.b = true;
- ot->m_struct.c = 2;
- ot->m_struct.d = 3.0;
-
- std::shared_ptr<OtherType> copy = duplicate(ot);
-
- ASSERT(copy->classId() == g_classIdToReturn, "unexpected classId");
- if (copy->classId() > 0xFFFF) {
- ASSERT(copy->typeId() == GeodeTypeIdsImpl::CacheableUserData4,
- "typeId should be equal to GeodeTypeIdsImpl::CacheableUserData4.");
- } else if (copy->classId() > 0xFF) {
- ASSERT(copy->typeId() == GeodeTypeIdsImpl::CacheableUserData2,
- "typeId should be equal to GeodeTypeIdsImpl::CacheableUserData2.");
- } else {
- ASSERT(copy->typeId() == GeodeTypeIdsImpl::CacheableUserData,
- "typeId should be equal to GeodeTypeIdsImpl::CacheableUserData.");
- }
- ASSERT(copy != ot, "expected different instance.");
- ASSERT(copy->m_struct.a == 1, "a == 1");
- ASSERT(copy->m_struct.b == true, "b == true");
- ASSERT(copy->m_struct.c == 2, "c == 2");
- ASSERT(copy->m_struct.d == 3.0, "d == 3.0");
- }
-ENDTASK
-
RegionPtr regionPtr;
DUNIT_TASK(Receiver, SetupR)
@@ -238,11 +161,15 @@ ENDTASK
DUNIT_TASK(Sender, SetupAndPutInts)
{
- Serializable::registerType(OtherType::createDeserializable);
- Serializable::registerType(OtherType::createDeserializable2);
- Serializable::registerType(OtherType::createDeserializable4);
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ true);
+ SerializationRegistryPtr serializationRegistry =
+ CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
+ ->getSerializationRegistry();
+ serializationRegistry->addType(OtherType::createDeserializable);
+ serializationRegistry->addType(OtherType::createDeserializable2);
+ serializationRegistry->addType(OtherType::createDeserializable4);
+
getHelper()->createPooledRegion("DistRegionAck", USE_ACK, locatorsG,
"__TEST_POOL1__", true, true);
LOG("SenderInit complete.");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientAfterRegionLive.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientAfterRegionLive.cpp b/src/cppcache/integration-test/testThinClientAfterRegionLive.cpp
index 9dd5695..3bcdfe0 100644
--- a/src/cppcache/integration-test/testThinClientAfterRegionLive.cpp
+++ b/src/cppcache/integration-test/testThinClientAfterRegionLive.cpp
@@ -58,10 +58,11 @@ auto cptr4 = std::make_shared<DisconnectCacheListioner>(3);
#include "LocatorHelper.hpp"
void createPooledRegionMine(bool callReadyForEventsAPI = false) {
- PoolFactoryPtr poolFacPtr = PoolManager::createFactory();
+ auto& poolManager = getHelper()->getCache()->getPoolManager();
+ PoolFactoryPtr poolFacPtr = poolManager.createFactory();
poolFacPtr->setSubscriptionEnabled(true);
getHelper()->addServerLocatorEPs(locatorsG, poolFacPtr);
- if ((PoolManager::find("__TEST_POOL1__")) ==
+ if ((poolManager.find("__TEST_POOL1__")) ==
nullptr) { // Pool does not exist with the same name.
PoolPtr pptr = poolFacPtr->create("__TEST_POOL1__");
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientBigValue.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientBigValue.cpp b/src/cppcache/integration-test/testThinClientBigValue.cpp
index 7be59f5..361d594 100644
--- a/src/cppcache/integration-test/testThinClientBigValue.cpp
+++ b/src/cppcache/integration-test/testThinClientBigValue.cpp
@@ -108,8 +108,8 @@ END_TASK(StartServer)
DUNIT_TASK(CLIENT1, SetupClient1)
{
- initClientWithPool(true, "__TEST_POOL1__", locHostPort, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locHostPort, nullptr, nullptr, 0,
+ true);
getHelper()->createPooledRegion(regionNames[0], false, locHostPort,
"__TEST_POOL1__", true, true);
}
@@ -117,8 +117,8 @@ END_TASK(SetupClient1)
DUNIT_TASK(CLIENT2, SetupClient2)
{
- initClientWithPool(true, "__TEST_POOL1__", locHostPort, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locHostPort, nullptr, nullptr, 0,
+ true);
getHelper()->createPooledRegion(regionNames[0], false, locHostPort,
"__TEST_POOL1__", true, true);
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientCacheableStringArray.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientCacheableStringArray.cpp b/src/cppcache/integration-test/testThinClientCacheableStringArray.cpp
index 5e621b3..b6f5696 100644
--- a/src/cppcache/integration-test/testThinClientCacheableStringArray.cpp
+++ b/src/cppcache/integration-test/testThinClientCacheableStringArray.cpp
@@ -33,6 +33,10 @@
#include <geode/Query.hpp>
#include <geode/QueryService.hpp>
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
+
using namespace apache::geode::client;
using namespace test;
using namespace testobject;
@@ -63,11 +67,15 @@ END_TASK(CreateServer1)
DUNIT_TASK(CLIENT1, StepOne)
{
- Serializable::registerType(Position::createDeserializable);
- Serializable::registerType(Portfolio::createDeserializable);
+ initClientWithPool(true, "__TEST_POOL1__", locHostPort, nullptr, nullptr, 0,
+ true);
+ SerializationRegistryPtr serializationRegistry =
+ CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
+ ->getSerializationRegistry();
+
+ serializationRegistry->addType(Position::createDeserializable);
+ serializationRegistry->addType(Portfolio::createDeserializable);
- initClientWithPool(true, "__TEST_POOL1__", locHostPort, "ServerGroup1",
- nullptr, 0, true);
RegionPtr regptr = getHelper()->createPooledRegion(
_regionNames[0], USE_ACK, locHostPort, "__TEST_POOL1__", true, true);
RegionAttributesPtr lattribPtr = regptr->getAttributes();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientCacheablesLimits.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientCacheablesLimits.cpp b/src/cppcache/integration-test/testThinClientCacheablesLimits.cpp
index 4f2b44c..7f59aea 100644
--- a/src/cppcache/integration-test/testThinClientCacheablesLimits.cpp
+++ b/src/cppcache/integration-test/testThinClientCacheablesLimits.cpp
@@ -90,8 +90,8 @@ const char* _regionNames[] = {"DistRegionAck", "DistRegionNoAck"};
DUNIT_TASK_DEFINITION(CLIENT1, StepOne)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ true);
getHelper()->createPooledRegion(_regionNames[1], NO_ACK, locatorsG,
"__TEST_POOL1__", false, false);
LOG("StepOne complete.");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientClearRegion.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientClearRegion.cpp b/src/cppcache/integration-test/testThinClientClearRegion.cpp
index 480af07..17307d0 100644
--- a/src/cppcache/integration-test/testThinClientClearRegion.cpp
+++ b/src/cppcache/integration-test/testThinClientClearRegion.cpp
@@ -67,8 +67,8 @@ END_TASK(StartServer)
DUNIT_TASK(CLIENT1, SetupClient1)
{
- initClientWithPool(true, "__TEST_POOL1__", locHostPort, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locHostPort, nullptr, nullptr, 0,
+ true);
getHelper()->createPooledRegion(regionNames[0], false, locHostPort,
"__TEST_POOL1__", true, true);
RegionPtr regPtr = getHelper()->getRegion(regionNames[0]);
@@ -83,8 +83,8 @@ END_TASK(SetupClient1)
DUNIT_TASK(CLIENT2, SetupClient2)
{
- initClientWithPool(true, "__TEST_POOL1__", locHostPort, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locHostPort, nullptr, nullptr, 0,
+ true);
getHelper()->createPooledRegion(regionNames[0], false, locHostPort,
"__TEST_POOL1__", true, true);
RegionPtr regPtr = getHelper()->getRegion(regionNames[0]);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientConflation.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientConflation.cpp b/src/cppcache/integration-test/testThinClientConflation.cpp
index 5be6103..15932f5 100644
--- a/src/cppcache/integration-test/testThinClientConflation.cpp
+++ b/src/cppcache/integration-test/testThinClientConflation.cpp
@@ -164,8 +164,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(FEEDER, CreateRegionsAndFirstFeederUpdate)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ true);
getHelper()->createPooledRegion(regions[0], USE_ACK, locatorsG,
"__TEST_POOL1__", true, true);
getHelper()->createPooledRegion(regions[1], USE_ACK, locatorsG,
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientContainsKeyOnServer.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientContainsKeyOnServer.cpp b/src/cppcache/integration-test/testThinClientContainsKeyOnServer.cpp
index a9ab4fb..b07bf1a 100644
--- a/src/cppcache/integration-test/testThinClientContainsKeyOnServer.cpp
+++ b/src/cppcache/integration-test/testThinClientContainsKeyOnServer.cpp
@@ -40,8 +40,8 @@ END_TASK(StartServer)
DUNIT_TASK(CLIENT1, SetupClient1)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ true);
getHelper()->createPooledRegion(regionNames[0], false, locatorsG,
"__TEST_POOL1__", true, true);
RegionPtr regPtr = getHelper()->getRegion(regionNames[0]);
@@ -52,8 +52,8 @@ END_TASK(SetupClient1)
DUNIT_TASK(CLIENT2, SetupClient2)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ true);
getHelper()->createPooledRegion(regionNames[0], false, locatorsG,
"__TEST_POOL1__", true, true);
RegionPtr regPtr = getHelper()->getRegion(regionNames[0]);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientCq.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientCq.cpp b/src/cppcache/integration-test/testThinClientCq.cpp
index 5317e4a..19db32e 100644
--- a/src/cppcache/integration-test/testThinClientCq.cpp
+++ b/src/cppcache/integration-test/testThinClientCq.cpp
@@ -77,21 +77,24 @@ const char* queryStrings[MAX_LISTNER] = {
"select * from /Portfolios p where p.ID != 7"};
void initClientCq(const bool isthinClient) {
+ if (cacheHelper == nullptr) {
+ cacheHelper = new CacheHelper(isthinClient);
+ }
+ ASSERT(cacheHelper, "Failed to create a CacheHelper client instance.");
+
try {
- Serializable::registerType(Position::createDeserializable);
- Serializable::registerType(Portfolio::createDeserializable);
+ SerializationRegistryPtr serializationRegistry =
+ CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
+ ->getSerializationRegistry();
+ serializationRegistry->addType(Position::createDeserializable);
+ serializationRegistry->addType(Portfolio::createDeserializable);
- Serializable::registerPdxType(PositionPdx::createDeserializable);
- Serializable::registerPdxType(PortfolioPdx::createDeserializable);
+ serializationRegistry->addPdxType(PositionPdx::createDeserializable);
+ serializationRegistry->addPdxType(PortfolioPdx::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
-
- if (cacheHelper == nullptr) {
- cacheHelper = new CacheHelper(isthinClient);
- }
- ASSERT(cacheHelper, "Failed to create a CacheHelper client instance.");
}
const char* regionNamesCq[] = {"Portfolios", "Positions", "Portfolios2",
@@ -380,7 +383,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThree)
uint8_t i = 0;
QueryHelper* qh ATTR_UNUSED = &QueryHelper::getHelper();
- PoolPtr pool = PoolManager::find(regionNamesCq[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
QueryServicePtr qs;
if (pool != nullptr) {
// Using region name as pool name as in ThinClientCq.hpp
@@ -482,7 +486,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFour)
{
QueryHelper* qh ATTR_UNUSED = &QueryHelper::getHelper();
- PoolPtr pool = PoolManager::find(regionNamesCq[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
QueryServicePtr qs;
if (pool != nullptr) {
// Using region name as pool name as in ThinClientCq.hpp
@@ -792,7 +797,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, createCQ)
{
SLEEP(10000);
// Create CqAttributes and Install Listener
- PoolPtr pool = PoolManager::find(regionName);
+ PoolPtr pool = getHelper()->getCache()->getPoolManager().find(regionName);
QueryServicePtr qs = pool->getQueryService();
CqAttributesFactory cqFac;
auto cqLstner = std::make_shared<MyCqStatusListener>(100);
@@ -818,7 +823,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, createCQ_Pool)
{
- PoolPtr pool = PoolManager::find("__TEST_POOL1__");
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find("__TEST_POOL1__");
QueryServicePtr qs = pool->getQueryService();
CqAttributesFactory cqFac;
auto cqLstner = std::make_shared<MyCqStatusListener>(100);
@@ -839,7 +845,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, createCQ_Pool)
ASSERT(myStatusCq->getCqsConnectedCount() == 1,
"incorrect number of CqStatus Connected count.");
- PoolPtr pool2 = PoolManager::find("__TEST_POOL2__");
+ PoolPtr pool2 =
+ getHelper()->getCache()->getPoolManager().find("__TEST_POOL2__");
QueryServicePtr qs2 = pool2->getQueryService();
CqAttributesFactory cqFac1;
auto cqLstner1 = std::make_shared<MyCqStatusListener>(101);
@@ -889,7 +896,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, createCQ_Pool)
END_TASK_DEFINITION
void executeCq(const char* poolName, const char* name) {
- PoolPtr pool = PoolManager::find(poolName);
+ PoolPtr pool = getHelper()->getCache()->getPoolManager().find(poolName);
QueryServicePtr qs;
if (pool != nullptr) {
qs = pool->getQueryService();
@@ -909,7 +916,7 @@ END_TASK_DEFINITION
void checkCQStatusOnConnect(const char* poolName, const char* name,
int connect) {
- PoolPtr pool = PoolManager::find(poolName);
+ PoolPtr pool = getHelper()->getCache()->getPoolManager().find(poolName);
QueryServicePtr qs;
if (pool != nullptr) {
qs = pool->getQueryService();
@@ -953,7 +960,7 @@ END_TASK_DEFINITION
void checkCQStatusOnDisConnect(const char* poolName, const char* cqName,
int disconnect) {
- PoolPtr pool = PoolManager::find(poolName);
+ PoolPtr pool = getHelper()->getCache()->getPoolManager().find(poolName);
QueryServicePtr qs;
if (pool != nullptr) {
qs = pool->getQueryService();
@@ -1025,7 +1032,7 @@ END_TASK_DEFINITION
void checkCQStatusOnPutEvent(const char* poolName, const char* cqName,
int count) {
- PoolPtr pool = PoolManager::find(poolName);
+ PoolPtr pool = getHelper()->getCache()->getPoolManager().find(poolName);
QueryServicePtr qs;
if (pool != nullptr) {
qs = pool->getQueryService();
@@ -1060,7 +1067,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, ProcessCQ)
{
SLEEP(10000);
// Create CqAttributes and Install Listener
- PoolPtr pool = PoolManager::find(regionName);
+ PoolPtr pool = getHelper()->getCache()->getPoolManager().find(regionName);
QueryServicePtr qs = pool->getQueryService();
CqAttributesFactory cqFac;
auto cqLstner = std::make_shared<MyCqListener>(1);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientCqDelta.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientCqDelta.cpp b/src/cppcache/integration-test/testThinClientCqDelta.cpp
index ab07d5a..8372c06 100644
--- a/src/cppcache/integration-test/testThinClientCqDelta.cpp
+++ b/src/cppcache/integration-test/testThinClientCqDelta.cpp
@@ -30,6 +30,11 @@
#include <geode/CqListener.hpp>
#include <geode/CqQuery.hpp>
#include <geode/CqServiceStatistics.hpp>
+#include <geode/Cache.hpp>
+
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
using namespace apache::geode::client;
using namespace test;
@@ -44,6 +49,11 @@ CacheHelper* cacheHelper = nullptr;
#define SERVER1 s2p1
#include "LocatorHelper.hpp"
+CacheHelper* getHelper() {
+ ASSERT(cacheHelper != nullptr, "No cacheHelper initialized.");
+ return cacheHelper;
+}
+
class CqDeltaListener : public CqListener {
public:
CqDeltaListener() : m_deltaCount(0), m_valueCount(0) {}
@@ -51,8 +61,9 @@ class CqDeltaListener : public CqListener {
virtual void onEvent(const CqEvent& aCqEvent) {
CacheableBytesPtr deltaValue = aCqEvent.getDeltaValue();
DeltaTestImpl newValue;
- DataInput input(deltaValue->value(), deltaValue->length());
- newValue.fromDelta(input);
+ auto input = getHelper()->getCache()->createDataInput(
+ deltaValue->value(), deltaValue->length());
+ newValue.fromDelta(*input);
if (newValue.getIntVar() == 5) {
m_deltaCount++;
}
@@ -92,11 +103,6 @@ void cleanProc() {
}
}
-CacheHelper* getHelper() {
- ASSERT(cacheHelper != nullptr, "No cacheHelper initialized.");
- return cacheHelper;
-}
-
void createPooledRegion(const char* name, bool ackMode, const char* locators,
const char* poolname,
bool clientNotificationEnabled = false,
@@ -146,7 +152,11 @@ DUNIT_TASK_DEFINITION(CLIENT1, CreateClient1)
createPooledRegion(regionNames[0], USE_ACK, locatorsG, "__TESTPOOL1_",
true);
try {
- Serializable::registerType(DeltaTestImpl::create);
+ SerializationRegistryPtr serializationRegistry =
+ CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
+ ->getSerializationRegistry();
+
+ serializationRegistry->addType(DeltaTestImpl::create);
} catch (IllegalStateException&) {
// ignore exception caused by type reregistration.
}
@@ -159,13 +169,18 @@ DUNIT_TASK_DEFINITION(CLIENT2, CreateClient2)
createPooledRegion(regionNames[0], USE_ACK, locatorsG, "__TESTPOOL1_",
true);
try {
- Serializable::registerType(DeltaTestImpl::create);
+ SerializationRegistryPtr serializationRegistry =
+ CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
+ ->getSerializationRegistry();
+
+ serializationRegistry->addType(DeltaTestImpl::create);
} catch (IllegalStateException&) {
// ignore exception caused by type reregistration.
}
RegionPtr regPtr = getHelper()->getRegion(regionNames[0]);
- PoolPtr pool = PoolManager::find("__TESTPOOL1_");
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find("__TESTPOOL1_");
QueryServicePtr qs;
qs = pool->getQueryService();
CqAttributesFactory cqFac;
@@ -185,7 +200,11 @@ DUNIT_TASK_DEFINITION(CLIENT1, CreateClient1_NoPools)
initClientNoPools();
createRegion(regionNames[0], USE_ACK, true);
try {
- Serializable::registerType(DeltaTestImpl::create);
+ SerializationRegistryPtr serializationRegistry =
+ CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
+ ->getSerializationRegistry();
+
+ serializationRegistry->addType(DeltaTestImpl::create);
} catch (IllegalStateException&) {
// ignore exception caused by type reregistration.
}
@@ -197,7 +216,11 @@ DUNIT_TASK_DEFINITION(CLIENT2, CreateClient2_NoPools)
initClientNoPools();
createRegion(regionNames[0], USE_ACK, true);
try {
- Serializable::registerType(DeltaTestImpl::create);
+ SerializationRegistryPtr serializationRegistry =
+ CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
+ ->getSerializationRegistry();
+
+ serializationRegistry->addType(DeltaTestImpl::create);
} catch (IllegalStateException&) {
// ignore exception caused by type reregistration.
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientCqDurable.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientCqDurable.cpp b/src/cppcache/integration-test/testThinClientCqDurable.cpp
index 1039d07..35c3892 100644
--- a/src/cppcache/integration-test/testThinClientCqDurable.cpp
+++ b/src/cppcache/integration-test/testThinClientCqDurable.cpp
@@ -61,23 +61,27 @@ const char* durableCQNamesClient2[] = {
static bool m_isPdx = false;
void initClientWithId(int ClientIdx, bool typeRegistered = false) {
- if (typeRegistered == false) {
- try {
- Serializable::registerType(Position::createDeserializable);
- Serializable::registerType(Portfolio::createDeserializable);
-
- Serializable::registerPdxType(PositionPdx::createDeserializable);
- Serializable::registerPdxType(PortfolioPdx::createDeserializable);
- } catch (const IllegalStateException&) {
- // ignore exception
- }
- }
PropertiesPtr pp = Properties::create();
pp->insert("durable-client-id", durableIds[ClientIdx]);
pp->insert("durable-timeout", 60);
pp->insert("notify-ack-interval", 1);
initClient(true, pp);
+
+ if (typeRegistered == false) {
+ try {
+ SerializationRegistryPtr serializationRegistry =
+ CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
+ ->getSerializationRegistry();
+ serializationRegistry->addType(Position::createDeserializable);
+ serializationRegistry->addType(Portfolio::createDeserializable);
+
+ serializationRegistry->addPdxType(PositionPdx::createDeserializable);
+ serializationRegistry->addPdxType(PortfolioPdx::createDeserializable);
+ } catch (const IllegalStateException&) {
+ // ignore exception
+ }
+ }
}
class MyCqListener1 : public CqListener {
@@ -188,10 +192,12 @@ void RunDurableCqClient() {
// Create a Geode Cache Programmatically.
CacheFactoryPtr cacheFactory = CacheFactory::createCacheFactory(pp);
- CachePtr cachePtr = cacheFactory->setSubscriptionEnabled(true)
- ->setSubscriptionAckInterval(5000)
- ->setSubscriptionMessageTrackingTimeout(50000)
- ->create();
+ CachePtr cachePtr = cacheFactory->create();
+ auto poolFactory = cachePtr->getPoolManager().createFactory();
+ poolFactory->setSubscriptionEnabled(true);
+ poolFactory->setSubscriptionAckInterval(5000);
+ poolFactory->setSubscriptionMessageTrackingTimeout(50000);
+ poolFactory->create("");
LOGINFO("Created the Geode Cache Programmatically");
@@ -369,7 +375,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThree)
{
QueryHelper* qh ATTR_UNUSED = &QueryHelper::getHelper();
- PoolPtr pool = PoolManager::find(regionNamesCq[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
QueryServicePtr qs;
if (pool != nullptr) {
qs = pool->getQueryService();
@@ -459,7 +466,11 @@ void client1Up() {
QueryServicePtr qs;
- qs = PoolManager::find(regionNamesCq[0])->getQueryService();
+ qs = getHelper()
+ ->getCache()
+ ->getPoolManager()
+ .find(regionNamesCq[0])
+ ->getQueryService();
CqAttributesFactory cqFac;
auto cqLstner = std::make_shared<MyCqListener>();
cqFac.addCqListener(cqLstner);
@@ -522,7 +533,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFour)
{
QueryHelper* qh ATTR_UNUSED = &QueryHelper::getHelper();
- PoolPtr pool = PoolManager::find(regionNamesCq[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
QueryServicePtr qs;
if (pool != nullptr) {
qs = pool->getQueryService();
@@ -669,7 +681,8 @@ void doThinClientCqDurable() {
DUNIT_TASK_DEFINITION(CLIENT1, RegisterCqs1)
{
- PoolPtr pool = PoolManager::find(regionNamesCq[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
QueryServicePtr qs;
if (pool != nullptr) {
qs = pool->getQueryService();
@@ -696,7 +709,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, RegisterCqsAfterClientup1)
{
- PoolPtr pool = PoolManager::find(regionNamesCq[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
QueryServicePtr qs;
if (pool != nullptr) {
qs = pool->getQueryService();
@@ -723,7 +737,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, RegisterCqs2)
{
- PoolPtr pool = PoolManager::find(regionNamesCq[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
QueryServicePtr qs;
if (pool != nullptr) {
qs = pool->getQueryService();
@@ -750,7 +765,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, RegisterCqsAfterClientup2)
{
- PoolPtr pool = PoolManager::find(regionNamesCq[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
QueryServicePtr qs;
if (pool != nullptr) {
qs = pool->getQueryService();
@@ -777,7 +793,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, VerifyCqs1)
{
- PoolPtr pool = PoolManager::find(regionNamesCq[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
QueryServicePtr qs;
if (pool != nullptr) {
qs = pool->getQueryService();
@@ -800,7 +817,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, VerifyCqsAfterClientup1)
{
- PoolPtr pool = PoolManager::find(regionNamesCq[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
QueryServicePtr qs;
if (pool != nullptr) {
qs = pool->getQueryService();
@@ -828,7 +846,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, VerifyCqs2)
{
- PoolPtr pool = PoolManager::find(regionNamesCq[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
QueryServicePtr qs;
if (pool != nullptr) {
qs = pool->getQueryService();
@@ -855,7 +874,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, VerifyCqsAfterClientup2)
{
- PoolPtr pool = PoolManager::find(regionNamesCq[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
QueryServicePtr qs;
if (pool != nullptr) {
qs = pool->getQueryService();
@@ -893,7 +913,8 @@ DUNIT_TASK_DEFINITION(CLIENT2, VerifyCqsAfterClientup2)
END_TASK_DEFINITION
void verifyEmptyDurableCQList() {
- PoolPtr pool = PoolManager::find(regionNamesCq[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
QueryServicePtr qs;
if (pool != nullptr) {
qs = pool->getQueryService();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientCqFailover.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientCqFailover.cpp b/src/cppcache/integration-test/testThinClientCqFailover.cpp
index 51cb013..2c4f2da 100644
--- a/src/cppcache/integration-test/testThinClientCqFailover.cpp
+++ b/src/cppcache/integration-test/testThinClientCqFailover.cpp
@@ -38,6 +38,10 @@
#include "ThinClientCQ.hpp"
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
+
using namespace apache::geode::client;
using namespace test;
using namespace testobject;
@@ -108,17 +112,20 @@ class KillServerThread : public ACE_Task_Base {
};
void initClientCq(const bool isthinClient) {
- try {
- Serializable::registerType(Position::createDeserializable);
- Serializable::registerType(Portfolio::createDeserializable);
- } catch (const IllegalStateException&) {
- // ignore exception
- }
-
if (cacheHelper == nullptr) {
cacheHelper = new CacheHelper(isthinClient);
}
ASSERT(cacheHelper, "Failed to create a CacheHelper client instance.");
+
+ try {
+ SerializationRegistryPtr serializationRegistry =
+ CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
+ ->getSerializationRegistry();
+ serializationRegistry->addType(Position::createDeserializable);
+ serializationRegistry->addType(Portfolio::createDeserializable);
+ } catch (const IllegalStateException&) {
+ // ignore exception
+ }
}
const char* regionNamesCq[] = {"Portfolios", "Positions"};
@@ -196,7 +203,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, StepThree)
{
try {
- PoolPtr pool = PoolManager::find(regionNamesCq[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
QueryServicePtr qs;
if (pool != nullptr) {
// Using region name as pool name as in ThinClientCq.hpp
@@ -258,7 +266,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, StepThree3)
{
- auto pool = PoolManager::find(regionNamesCq[0]);
+ auto pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
QueryServicePtr qs;
if (pool != nullptr) {
// Using region name as pool name as in ThinClientCq.hpp
@@ -345,7 +354,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, CloseCache1)
{
- auto pool = PoolManager::find(regionNamesCq[0]);
+ auto pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
QueryServicePtr qs;
if (pool != nullptr) {
// Using region name as pool name as in ThinClientCq.hpp
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientCqHAFailover.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientCqHAFailover.cpp b/src/cppcache/integration-test/testThinClientCqHAFailover.cpp
index 6227991..dc7cdea 100644
--- a/src/cppcache/integration-test/testThinClientCqHAFailover.cpp
+++ b/src/cppcache/integration-test/testThinClientCqHAFailover.cpp
@@ -110,17 +110,21 @@ class KillServerThread : public ACE_Task_Base {
};
void initClientCq(int redundancyLevel) {
- try {
- Serializable::registerType(Position::createDeserializable);
- Serializable::registerType(Portfolio::createDeserializable);
- } catch (const IllegalStateException&) {
- // ignore exception
- }
-
if (cacheHelper == nullptr) {
cacheHelper = new CacheHelper(true);
}
ASSERT(cacheHelper, "Failed to create a CacheHelper client instance.");
+
+ try {
+ SerializationRegistryPtr serializationRegistry =
+ CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
+ ->getSerializationRegistry();
+
+ serializationRegistry->addType(Position::createDeserializable);
+ serializationRegistry->addType(Portfolio::createDeserializable);
+ } catch (const IllegalStateException&) {
+ // ignore exception
+ }
}
KillServerThread* kst = nullptr;
@@ -197,7 +201,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, StepThree)
{
try {
- PoolPtr pool = PoolManager::find(regionNamesCq[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
QueryServicePtr qs;
if (pool != nullptr) {
qs = pool->getQueryService();
@@ -295,7 +300,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, StepThree3)
{
// using region name as pool name
- PoolPtr pool = PoolManager::find(regionNamesCq[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
QueryServicePtr qs;
if (pool != nullptr) {
qs = pool->getQueryService();
@@ -382,7 +388,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, CloseCache1)
{
// using region name as pool name
- PoolPtr pool = PoolManager::find(regionNamesCq[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
QueryServicePtr qs;
if (pool != nullptr) {
qs = pool->getQueryService();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientCqIR.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientCqIR.cpp b/src/cppcache/integration-test/testThinClientCqIR.cpp
index 8f0db1f..c1dabf8 100644
--- a/src/cppcache/integration-test/testThinClientCqIR.cpp
+++ b/src/cppcache/integration-test/testThinClientCqIR.cpp
@@ -49,20 +49,23 @@ using namespace testData;
const char* cqName = "MyCq";
void initClientCq(const bool isthinClient) {
- try {
- Serializable::registerType(Position::createDeserializable);
- Serializable::registerType(Portfolio::createDeserializable);
-
- Serializable::registerPdxType(PositionPdx::createDeserializable);
- Serializable::registerPdxType(PortfolioPdx::createDeserializable);
- } catch (const IllegalStateException&) {
- // ignore exception
- }
-
if (cacheHelper == nullptr) {
cacheHelper = new CacheHelper(isthinClient);
}
ASSERT(cacheHelper, "Failed to create a CacheHelper client instance.");
+
+ try {
+ SerializationRegistryPtr serializationRegistry =
+ CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
+ ->getSerializationRegistry();
+ serializationRegistry->addType(Position::createDeserializable);
+ serializationRegistry->addType(Portfolio::createDeserializable);
+
+ serializationRegistry->addPdxType(PositionPdx::createDeserializable);
+ serializationRegistry->addPdxType(PortfolioPdx::createDeserializable);
+ } catch (const IllegalStateException&) {
+ // ignore exception
+ }
}
const char* regionNamesCq[] = {"Portfolios", "Positions", "Portfolios2",
"Portfolios3"};
@@ -157,7 +160,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, QueryData)
auto& qh ATTR_UNUSED = QueryHelper::getHelper();
// using region name as pool name
- auto pool = PoolManager::find(regionNamesCq[0]);
+ auto pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
QueryServicePtr qs;
if (pool != nullptr) {
qs = pool->getQueryService();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientDeltaWithNotification.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientDeltaWithNotification.cpp b/src/cppcache/integration-test/testThinClientDeltaWithNotification.cpp
index 77e26c1..4d79837 100644
--- a/src/cppcache/integration-test/testThinClientDeltaWithNotification.cpp
+++ b/src/cppcache/integration-test/testThinClientDeltaWithNotification.cpp
@@ -26,6 +26,11 @@
#include "DeltaEx.hpp"
#include "fw_dunit.hpp"
#include <string>
+
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
+
using namespace apache::geode::client;
using namespace test;
@@ -190,7 +195,11 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, Client1_Init)
{
try {
- Serializable::registerType(DeltaEx::create);
+ SerializationRegistryPtr serializationRegistry =
+ CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
+ ->getSerializationRegistry();
+
+ serializationRegistry->addType(DeltaEx::create);
} catch (IllegalStateException&) {
// ignore type reregistration exception.
}
@@ -200,7 +209,11 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, Client2_Init)
{
try {
- Serializable::registerType(DeltaEx::create);
+ SerializationRegistryPtr serializationRegistry =
+ CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
+ ->getSerializationRegistry();
+
+ serializationRegistry->addType(DeltaEx::create);
} catch (IllegalStateException&) {
// ignore type reregistration exception.
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientExecuteFunctionPrSHOP.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientExecuteFunctionPrSHOP.cpp b/src/cppcache/integration-test/testThinClientExecuteFunctionPrSHOP.cpp
index 3a11922..d08b440 100644
--- a/src/cppcache/integration-test/testThinClientExecuteFunctionPrSHOP.cpp
+++ b/src/cppcache/integration-test/testThinClientExecuteFunctionPrSHOP.cpp
@@ -178,8 +178,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, StartC1)
{
- initClientWithPool(true, nullptr, locHostPort, serverGroup, nullptr, 0,
- true, -1, -1, 60000, /*singlehop*/ true,
+ initClientWithPool(true, poolRegNames[0], locHostPort, serverGroup, nullptr,
+ 0, true, -1, -1, 60000, /*singlehop*/ true,
/*threadLocal*/ true);
RegionPtr regPtr0 =
@@ -568,7 +568,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, Client1OpTest2)
ExecutionPtr RexecutionPtr = FunctionService::onRegion(regPtr0);
CacheableVectorPtr fe =
RexecutionPtr->withArgs(CacheableInt32::create(5000 * 1000))
- ->execute(FETimeOut, 5000)
+ ->execute(FETimeOut, 5000 * 1000)
->getResult();
if (fe == nullptr) {
ASSERT(false, "functionResult is nullptr");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientGetInterests.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientGetInterests.cpp b/src/cppcache/integration-test/testThinClientGetInterests.cpp
index 4197f4c..3910b8c 100644
--- a/src/cppcache/integration-test/testThinClientGetInterests.cpp
+++ b/src/cppcache/integration-test/testThinClientGetInterests.cpp
@@ -47,8 +47,7 @@ DUNIT_TASK(CLIENT1, SetupClient1)
pp->insert("durable-timeout", 300);
pp->insert("notify-ack-interval", 1);
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1", pp, 0,
- true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, pp, 0, true);
getHelper()->createPooledRegion(regionNames[0], false, locatorsG,
"__TEST_POOL1__", true, true);
CacheableKeyPtr keyPtr0 = CacheableString::create(keys[0]);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientHAQueryFailover.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientHAQueryFailover.cpp b/src/cppcache/integration-test/testThinClientHAQueryFailover.cpp
index 9f71ab5..18299df 100644
--- a/src/cppcache/integration-test/testThinClientHAQueryFailover.cpp
+++ b/src/cppcache/integration-test/testThinClientHAQueryFailover.cpp
@@ -26,7 +26,9 @@
#include "CacheHelper.hpp"
-//#include "QueryHelper.hpp"
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
#include <geode/Query.hpp>
#include <geode/QueryService.hpp>
@@ -78,23 +80,27 @@ class KillServerThread : public ACE_Task_Base {
};
void initClient() {
- try {
- Serializable::registerType(Portfolio::createDeserializable);
- Serializable::registerType(Position::createDeserializable);
- } catch (const IllegalStateException&) {
- // ignore reregistration exception
- }
if (cacheHelper == nullptr) {
cacheHelper = new CacheHelper(true);
}
ASSERT(cacheHelper, "Failed to create a CacheHelper client instance.");
+ try {
+ SerializationRegistryPtr serializationRegistry =
+ CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
+ ->getSerializationRegistry();
+
+ serializationRegistry->addType(Portfolio::createDeserializable);
+ serializationRegistry->addType(Position::createDeserializable);
+ } catch (const IllegalStateException&) {
+ // ignore reregistration exception
+ }
}
/*
void initClient( const bool isthinClient )
{
- Serializable::registerType( Portfolio::createDeserializable);
- Serializable::registerType( Position::createDeserializable);
+ serializationRegistry->addType( Portfolio::createDeserializable);
+ serializationRegistry->addType( Position::createDeserializable);
if ( cacheHelper == nullptr ) {
cacheHelper = new CacheHelper(isthinClient);
@@ -195,7 +201,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThree)
QueryServicePtr qs = nullptr;
- PoolPtr pool = PoolManager::find("__TESTPOOL1_");
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find("__TESTPOOL1_");
qs = pool->getQueryService();
LOG("Got query service from pool");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientHeapLRU.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientHeapLRU.cpp b/src/cppcache/integration-test/testThinClientHeapLRU.cpp
index d2f2343..e70b5c0 100644
--- a/src/cppcache/integration-test/testThinClientHeapLRU.cpp
+++ b/src/cppcache/integration-test/testThinClientHeapLRU.cpp
@@ -75,8 +75,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepOne)
PropertiesPtr pp = Properties::create();
pp->insert("heap-lru-limit", 1);
pp->insert("heap-lru-delta", 10);
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1", pp, 0,
- true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, pp, 0, true);
getHelper()->createPooledRegion(_regionNames[0], USE_ACK, locatorsG,
"__TEST_POOL1__", true, true);
LOG("StepOne complete.");
@@ -88,8 +87,7 @@ DUNIT_TASK_DEFINITION(CLIENT2, StepTwo)
PropertiesPtr pp = Properties::create();
pp->insert("heap-lru-limit", 1);
pp->insert("heap-lru-delta", 10);
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1", pp, 0,
- true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, pp, 0, true);
getHelper()->createPooledRegion(_regionNames[0], USE_ACK, locatorsG,
"__TEST_POOL1__", true, true);
LOG("StepTwo complete.");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientIntResPolKeysInv.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientIntResPolKeysInv.cpp b/src/cppcache/integration-test/testThinClientIntResPolKeysInv.cpp
index f25c5c8..d629560 100644
--- a/src/cppcache/integration-test/testThinClientIntResPolKeysInv.cpp
+++ b/src/cppcache/integration-test/testThinClientIntResPolKeysInv.cpp
@@ -40,7 +40,7 @@ CacheHelper *cacheHelper = nullptr;
void initClient(const bool isthinClient) {
if (cacheHelper == nullptr) {
cacheHelper = new CacheHelper(isthinClient, "__TEST_POOL1__", locatorsG,
- "ServerGroup1", nullptr, 0, true);
+ nullptr, nullptr, 0, true);
}
ASSERT(cacheHelper, "Failed to create a CacheHelper client instance.");
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientInterest1Cacheless.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientInterest1Cacheless.cpp b/src/cppcache/integration-test/testThinClientInterest1Cacheless.cpp
index 8e628b2..d390710 100644
--- a/src/cppcache/integration-test/testThinClientInterest1Cacheless.cpp
+++ b/src/cppcache/integration-test/testThinClientInterest1Cacheless.cpp
@@ -81,8 +81,8 @@ END_TASK(StartServer)
DUNIT_TASK(CLIENT1, SetupClient1)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ true);
getHelper()->createPooledRegion(regionNames[0], false, locatorsG,
"__TEST_POOL1__", true, true);
}
@@ -90,8 +90,8 @@ END_TASK(SetupClient1)
DUNIT_TASK(CLIENT2, setupClient2)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ true);
getHelper()->createPooledRegion(regionNames[0], false, locatorsG,
"__TEST_POOL1__", true, true);
mylistner = std::make_shared<MyListener>();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientInterest1_Bug1001.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientInterest1_Bug1001.cpp b/src/cppcache/integration-test/testThinClientInterest1_Bug1001.cpp
index fe225e3..d1761e1 100644
--- a/src/cppcache/integration-test/testThinClientInterest1_Bug1001.cpp
+++ b/src/cppcache/integration-test/testThinClientInterest1_Bug1001.cpp
@@ -48,8 +48,8 @@ CacheableStringPtr getUAString(int index) {
DUNIT_TASK_DEFINITION(CLIENT1, SetupClient1)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ true);
getHelper()->createPooledRegion(regionNames[0], false, locatorsG,
"__TEST_POOL1__", true, true);
}
@@ -68,8 +68,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, setupClient2)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ true);
getHelper()->createPooledRegion(regionNames[0], false, locatorsG,
"__TEST_POOL1__", true, true);
RegionPtr regPtr = getHelper()->getRegion(regionNames[0]);
@@ -108,7 +108,8 @@ DUNIT_TASK_DEFINITION(CLIENT2, verifyUpdates)
char buf[1024];
sprintf(buf, "key[%s] should have been found", keys[index]);
ASSERT(regPtr->containsKey(keyPtr), buf);
- auto val = std::dynamic_pointer_cast<CacheableString>(regPtr->getEntry(keyPtr)->getValue());
+ auto val = std::dynamic_pointer_cast<CacheableString>(
+ regPtr->getEntry(keyPtr)->getValue());
ASSERT(strcmp(val->asChar(), nvals[index]) == 0,
"Incorrect value for key");
}
@@ -165,7 +166,8 @@ DUNIT_TASK_DEFINITION(CLIENT2, CheckUpdateUnicodeStrings)
RegionPtr reg0 = getHelper()->getRegion(regionNames[0]);
for (int index = 0; index < 5; ++index) {
CacheableStringPtr key = getUString(index);
- auto val = std::dynamic_pointer_cast<CacheableFloat>(reg0->getEntry(key)->getValue());
+ auto val = std::dynamic_pointer_cast<CacheableFloat>(
+ reg0->getEntry(key)->getValue());
ASSERT(val != nullptr, "expected non-null value in get");
ASSERT(val->value() == (index + 20.0F), "unexpected value in get");
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientInterestNotify.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientInterestNotify.cpp b/src/cppcache/integration-test/testThinClientInterestNotify.cpp
index 222d979..4d44cc7 100644
--- a/src/cppcache/integration-test/testThinClientInterestNotify.cpp
+++ b/src/cppcache/integration-test/testThinClientInterestNotify.cpp
@@ -269,8 +269,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(SERVER_AND_FEEDER, FeederUpAndFeed)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ true);
getHelper()->createPooledRegion(regions[0], USE_ACK, locatorsG,
"__TEST_POOL1__", true, true);
getHelper()->createPooledRegion(regions[1], USE_ACK, locatorsG,
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientListenerCallbackArgTest.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientListenerCallbackArgTest.cpp b/src/cppcache/integration-test/testThinClientListenerCallbackArgTest.cpp
index 69fcac2..03312e2 100644
--- a/src/cppcache/integration-test/testThinClientListenerCallbackArgTest.cpp
+++ b/src/cppcache/integration-test/testThinClientListenerCallbackArgTest.cpp
@@ -25,6 +25,11 @@
#include "TallyWriter.hpp"
#include "testobject/PdxType.hpp"
#include "testobject/VariousPdxTypes.hpp"
+
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
+
#define CLIENT1 s1p1
#define CLIENT2 s1p2
#define SERVER1 s2p1
@@ -222,9 +227,9 @@ DUNIT_TASK_DEFINITION(CLIENT1, SetupClient1_Pool_Locator)
createPooledRegion(regionNames[0], false /*ack mode*/, locatorsG,
"__TEST_POOL1__", true /*client notification*/);
-
- Serializable::registerType(Portfolio::createDeserializable);
- Serializable::registerType(Position::createDeserializable);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->addType(Portfolio::createDeserializable);
+ serializationRegistry->addType(Position::createDeserializable);
reg1Listener1 = std::make_shared<CallbackListener>();
callBackPortFolioPtr = std::make_shared<Portfolio>(1, 0, nullptr);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientListenerEvents.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientListenerEvents.cpp b/src/cppcache/integration-test/testThinClientListenerEvents.cpp
index 1db1bda..136a830 100644
--- a/src/cppcache/integration-test/testThinClientListenerEvents.cpp
+++ b/src/cppcache/integration-test/testThinClientListenerEvents.cpp
@@ -79,8 +79,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, SetupClient1)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ true);
getHelper()->createPooledRegion(regionNames[0], false, locatorsG,
"__TEST_POOL1__", true, true);
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientLocator.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientLocator.cpp b/src/cppcache/integration-test/testThinClientLocator.cpp
index 4e73d3f..f5d6e4f 100644
--- a/src/cppcache/integration-test/testThinClientLocator.cpp
+++ b/src/cppcache/integration-test/testThinClientLocator.cpp
@@ -45,8 +45,8 @@ END_TASK(CreateServer12)
DUNIT_TASK(CLIENT1, StepOne)
{
// starting client 1
- initClientWithPool(true, "__TEST_POOL1__", locHostPort, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locHostPort, nullptr, nullptr, 0,
+ true);
getHelper()->createPooledRegion(regionNames[0], USE_ACK, locHostPort,
"__TEST_POOL1__", true, true);
getHelper()->createPooledRegion(regionNames[1], NO_ACK, locHostPort,
@@ -56,8 +56,8 @@ DUNIT_TASK(CLIENT1, StepOne)
END_TASK(StepOne)
DUNIT_TASK(CLIENT2, StepTwo)
{
- initClientWithPool(true, "__TEST_POOL1__", locHostPort, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locHostPort, nullptr, nullptr, 0,
+ true);
getHelper()->createPooledRegion(regionNames[0], USE_ACK, locHostPort,
"__TEST_POOL1__", true, true);
getHelper()->createPooledRegion(regionNames[1], NO_ACK, locHostPort,
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientMultipleCaches.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientMultipleCaches.cpp b/src/cppcache/integration-test/testThinClientMultipleCaches.cpp
new file mode 100644
index 0000000..1dfc42d
--- /dev/null
+++ b/src/cppcache/integration-test/testThinClientMultipleCaches.cpp
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+#include "ThinClientMultipleCaches.hpp"
+DUNIT_MAIN
+ { run(); }
+END_MAIN
[27/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
GEODE-2729: Remove global variables
- Remove CacheImpl::getInstance calls
- Converted PdxTypeRegistry clear to non-static method
- Adding Type Registry to cpp code as a public object.
- Convert static PoolManager method calls into instance method calls
- Remove PoolFactory/PoolManager global connectionPool singleton
- Allows multiple PoolFactories per Cache
- Remove default pool logic from Cache into PoolManager
- Add mutli-cache integration test
Project: http://git-wip-us.apache.org/repos/asf/geode-native/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode-native/commit/da389793
Tree: http://git-wip-us.apache.org/repos/asf/geode-native/tree/da389793
Diff: http://git-wip-us.apache.org/repos/asf/geode-native/diff/da389793
Branch: refs/heads/develop
Commit: da389793ef291fd812d0aa0c2b714b6e4ced92e5
Parents: 5b1634a
Author: David Kimura <dk...@pivotal.io>
Authored: Tue Jun 6 21:46:43 2017 +0000
Committer: David Kimura <dk...@pivotal.io>
Committed: Thu Aug 10 07:52:15 2017 -0700
----------------------------------------------------------------------
src/clicache/integration-test/CacheHelperN.cs | 101 +-
.../integration-test/DataOutputTests.cs | 8 +-
.../integration-test/DistributedSystemTests.cs | 2 +-
src/clicache/integration-test/PutGetTestsN.cs | 505 +-----
.../integration-test/SerializationTestsN.cs | 41 +-
...ThinClientAppDomainFunctionExecutionTests.cs | 2 +-
.../ThinClientAppDomainQueryTests.cs | 14 +-
.../integration-test/ThinClientCallbackArgN.cs | 6 +-
.../integration-test/ThinClientCqIRTestsN.cs | 10 +-
.../integration-test/ThinClientCqTestsN.cs | 24 +-
.../integration-test/ThinClientDeltaTestN.cs | 20 +-
.../ThinClientDurableCqTestsN.cs | 14 +-
.../integration-test/ThinClientDurableTestsN.cs | 14 +-
.../ThinClientFunctionExecutionTestsN.cs | 14 +-
.../ThinClientHARegionTestsN.cs | 6 +-
.../integration-test/ThinClientPdxTests.cs | 613 +------
.../integration-test/ThinClientPoolTestsN.cs | 16 +-
.../integration-test/ThinClientQueryTestsN.cs | 97 +-
.../integration-test/ThinClientRegionTestsN.cs | 2 +-
.../ThinClientSecurityAuthzTestBaseN.cs | 4 +-
.../ThinClientSecurityAuthzTestsMUN.cs | 8 +-
.../ThinClientStatisticTestsN.cs | 28 +-
.../ThinClientStringArrayTestsN.cs | 10 +-
src/clicache/src/Cache.cpp | 47 +-
src/clicache/src/Cache.hpp | 10 +
src/clicache/src/CacheFactory.cpp | 414 +----
src/clicache/src/CacheFactory.hpp | 442 +----
src/clicache/src/CacheableHashSet.hpp | 6 +-
src/clicache/src/DataInput.cpp | 25 +-
src/clicache/src/DataInput.hpp | 12 +-
src/clicache/src/DataOutput.cpp | 4 +-
src/clicache/src/DataOutput.hpp | 10 +-
src/clicache/src/DistributedSystem.cpp | 416 +----
src/clicache/src/DistributedSystem.hpp | 48 +-
src/clicache/src/Execution.cpp | 4 +-
src/clicache/src/LocalRegion.cpp | 81 +-
src/clicache/src/Pool.cpp | 2 +-
src/clicache/src/PoolFactory.cpp | 4 +-
src/clicache/src/PoolFactory.hpp | 2 +-
src/clicache/src/PoolManager.cpp | 12 +-
src/clicache/src/PoolManager.hpp | 35 +-
src/clicache/src/Properties.cpp | 114 +-
src/clicache/src/Properties.hpp | 39 +-
src/clicache/src/Query.cpp | 2 +-
src/clicache/src/Region.cpp | 117 +-
src/clicache/src/ResultCollector.cpp | 2 +-
src/clicache/src/Serializable.cpp | 123 +-
src/clicache/src/Serializable.hpp | 32 +-
src/clicache/src/StatisticsFactory.cpp | 31 +-
src/clicache/src/StatisticsFactory.hpp | 14 +-
src/clicache/src/impl/AuthenticatedCache.cpp | 10 +-
src/clicache/src/impl/CacheLoader.hpp | 2 +-
src/clicache/src/impl/CliCallbackDelgate.cpp | 40 +
src/clicache/src/impl/CliCallbackDelgate.hpp | 18 +-
src/clicache/src/impl/DelegateWrapper.hpp | 16 +-
.../src/impl/FixedPartitionResolver.hpp | 2 +-
src/clicache/src/impl/ManagedAuthInitialize.cpp | 2 +-
src/clicache/src/impl/ManagedAuthInitialize.hpp | 2 +-
src/clicache/src/impl/ManagedCacheableDelta.cpp | 4 +-
src/clicache/src/impl/ManagedCacheableDelta.hpp | 4 +-
.../src/impl/ManagedCacheableDeltaBytes.cpp | 24 +-
.../src/impl/ManagedCacheableDeltaBytes.hpp | 41 +-
src/clicache/src/impl/ManagedCacheableKey.cpp | 21 +-
src/clicache/src/impl/ManagedCacheableKey.hpp | 9 +-
.../src/impl/ManagedCacheableKeyBytes.cpp | 16 +-
.../src/impl/ManagedCacheableKeyBytes.hpp | 3 +-
src/clicache/src/impl/ManagedString.hpp | 3 +-
src/clicache/src/impl/PartitionResolver.hpp | 2 +-
src/clicache/src/impl/PdxHelper.cpp | 88 +-
src/clicache/src/impl/PdxHelper.hpp | 13 +-
.../src/impl/PdxInstanceFactoryImpl.cpp | 9 +-
.../src/impl/PdxInstanceFactoryImpl.hpp | 13 +-
src/clicache/src/impl/PdxInstanceImpl.cpp | 51 +-
src/clicache/src/impl/PdxInstanceImpl.hpp | 11 +-
.../src/impl/PdxManagedCacheableKey.cpp | 11 +-
.../src/impl/PdxManagedCacheableKey.hpp | 6 +-
.../src/impl/PdxManagedCacheableKeyBytes.cpp | 114 +-
.../src/impl/PdxManagedCacheableKeyBytes.hpp | 29 +-
src/clicache/src/impl/PdxTypeRegistry.cpp | 16 +-
src/clicache/src/impl/PdxTypeRegistry.hpp | 48 +-
.../src/impl/PersistenceManagerProxy.hpp | 2 +-
src/clicache/src/impl/SafeConvert.hpp | 28 +-
src/cppcache/include/geode/AuthInitialize.hpp | 2 +-
src/cppcache/include/geode/Cache.hpp | 34 +-
src/cppcache/include/geode/CacheFactory.hpp | 434 +----
src/cppcache/include/geode/CqOperation.hpp | 1 -
src/cppcache/include/geode/DataInput.hpp | 33 +-
src/cppcache/include/geode/DataOutput.hpp | 27 +-
src/cppcache/include/geode/Delta.hpp | 4 +
.../include/geode/DistributedSystem.hpp | 75 +-
src/cppcache/include/geode/GeodeCache.hpp | 18 +-
src/cppcache/include/geode/PdxInstance.hpp | 12 +-
src/cppcache/include/geode/PdxSerializable.hpp | 2 -
src/cppcache/include/geode/PdxWrapper.hpp | 17 +-
src/cppcache/include/geode/Pool.hpp | 11 +-
src/cppcache/include/geode/PoolFactory.hpp | 8 +-
src/cppcache/include/geode/PoolManager.hpp | 30 +-
src/cppcache/include/geode/Region.hpp | 1668 +++++++++---------
src/cppcache/include/geode/RegionFactory.hpp | 37 +-
src/cppcache/include/geode/Serializable.hpp | 30 +-
src/cppcache/include/geode/SystemProperties.hpp | 8 +-
src/cppcache/include/geode/TypeRegistry.hpp | 69 +
src/cppcache/include/geode/geode_types.hpp | 1 -
.../geode/statistics/StatisticsFactory.hpp | 18 +-
.../BuiltinCacheableWrappers.hpp | 18 +-
src/cppcache/integration-test/CMakeLists.txt | 2 -
src/cppcache/integration-test/CacheHelper.cpp | 126 +-
src/cppcache/integration-test/CacheHelper.hpp | 1 -
src/cppcache/integration-test/DeltaEx.hpp | 20 +-
src/cppcache/integration-test/QueryHelper.hpp | 6 +-
.../integration-test/ThinClientDistOps.hpp | 12 +-
.../integration-test/ThinClientDistOps2.hpp | 8 +-
.../integration-test/ThinClientDurable.hpp | 4 +-
.../ThinClientDurableFailover.hpp | 4 +-
.../ThinClientDurableInterest.hpp | 4 +-
.../ThinClientFailoverInterestAllWithCache.hpp | 4 +-
.../integration-test/ThinClientHelper.hpp | 2 +-
.../ThinClientLocalCacheLoader.hpp | 2 -
.../ThinClientMultipleCaches.hpp | 104 ++
.../integration-test/ThinClientNotification.hpp | 2 +-
.../ThinClientPdxSerializer.hpp | 53 +-
.../ThinClientPdxSerializers.hpp | 5 +-
.../integration-test/ThinClientPutAll.hpp | 26 +-
.../ThinClientPutAllWithCallBack.hpp | 28 +-
.../integration-test/ThinClientPutGetAll.hpp | 79 +-
.../integration-test/ThinClientSecurity.hpp | 7 +-
.../integration-test/ThinClientTransactions.hpp | 15 +-
.../ThinClientTransactionsXA.hpp | 15 +-
src/cppcache/integration-test/fw_dunit.cpp | 2 -
.../integration-test/testAttributesMutator.cpp | 6 +-
src/cppcache/integration-test/testCache.cpp | 3 +-
src/cppcache/integration-test/testCacheless.cpp | 19 +-
src/cppcache/integration-test/testConnect.cpp | 18 +-
.../integration-test/testDataOutput.cpp | 44 +-
.../integration-test/testEntriesMap.cpp | 777 --------
.../testEntriesMapForVersioning.cpp | 1297 --------------
.../integration-test/testExpiration.cpp | 3 +-
.../testOverflowPutGetSqLite.cpp | 2 +-
.../integration-test/testRegionTemplateArgs.cpp | 237 ++-
.../integration-test/testSerialization.cpp | 101 +-
.../testThinClientAfterRegionLive.cpp | 5 +-
.../integration-test/testThinClientBigValue.cpp | 8 +-
.../testThinClientCacheableStringArray.cpp | 16 +-
.../testThinClientCacheablesLimits.cpp | 4 +-
.../testThinClientClearRegion.cpp | 8 +-
.../testThinClientConflation.cpp | 4 +-
.../testThinClientContainsKeyOnServer.cpp | 8 +-
.../integration-test/testThinClientCq.cpp | 45 +-
.../integration-test/testThinClientCqDelta.cpp | 47 +-
.../testThinClientCqDurable.cpp | 75 +-
.../testThinClientCqFailover.cpp | 30 +-
.../testThinClientCqHAFailover.cpp | 27 +-
.../integration-test/testThinClientCqIR.cpp | 26 +-
.../testThinClientDeltaWithNotification.cpp | 17 +-
.../testThinClientExecuteFunctionPrSHOP.cpp | 6 +-
.../testThinClientGetInterests.cpp | 3 +-
.../testThinClientHAQueryFailover.cpp | 27 +-
.../integration-test/testThinClientHeapLRU.cpp | 6 +-
.../testThinClientIntResPolKeysInv.cpp | 2 +-
.../testThinClientInterest1Cacheless.cpp | 8 +-
.../testThinClientInterest1_Bug1001.cpp | 14 +-
.../testThinClientInterestNotify.cpp | 4 +-
.../testThinClientListenerCallbackArgTest.cpp | 11 +-
.../testThinClientListenerEvents.cpp | 4 +-
.../integration-test/testThinClientLocator.cpp | 8 +-
.../testThinClientMultipleCaches.cpp | 21 +
...nClientNotificationWithDeltaWithoutcache.cpp | 17 +-
.../testThinClientPRSingleHop.cpp | 33 +-
.../testThinClientPRSingleHopServerGroup.cpp | 27 +-
.../testThinClientPdxDeltaWithNotification.cpp | 9 +-
.../integration-test/testThinClientPdxEnum.cpp | 3 +-
.../testThinClientPdxInstance.cpp | 259 +--
.../integration-test/testThinClientPdxTests.cpp | 1234 +++++++------
.../testThinClientPoolAttrTest.cpp | 31 +-
.../testThinClientPoolExecuteFunction.cpp | 16 +-
...ExecuteFunctionDisableChunkHandlerThread.cpp | 4 +-
.../testThinClientPoolExecuteFunctionPrSHOP.cpp | 21 +-
...ClientPoolExecuteFunctionThrowsException.cpp | 4 +-
.../testThinClientPoolExecuteHAFunction.cpp | 7 +-
...estThinClientPoolExecuteHAFunctionPrSHOP.cpp | 7 +-
.../testThinClientPutAllPRSingleHop.cpp | 22 +-
.../testThinClientPutWithDelta.cpp | 10 +-
...nClientRegionQueryDifferentServerConfigs.cpp | 14 +-
.../testThinClientRegionQueryExclusiveness.cpp | 29 +-
.../testThinClientRemoteQueryFailover.cpp | 18 +-
.../testThinClientRemoteQueryFailoverPdx.cpp | 16 +-
.../testThinClientRemoteQueryRS.cpp | 20 +-
.../testThinClientRemoteQuerySS.cpp | 17 +-
.../testThinClientRemoteQueryTimeout.cpp | 16 +-
.../testThinClientRemoteRegionQuery.cpp | 13 +-
.../testThinClientSSLWithSecurityAuthz.cpp | 9 +-
.../testThinClientSecurityAuthorization.cpp | 11 +-
.../testThinClientSecurityAuthorizationMU.cpp | 22 -
.../testThinClientSecurityCQAuthorization.cpp | 27 +-
.../testThinClientSecurityCQAuthorizationMU.cpp | 27 +-
...inClientSecurityDurableCQAuthorizationMU.cpp | 23 +-
.../testThinClientSecurityMultiUserTest.cpp | 1 -
.../testThinClientStatistics.cpp | 50 +-
.../testThinClientTicket317.cpp | 8 +-
src/cppcache/integration-test/testUtils.hpp | 12 +-
.../testXmlCacheCreationWithPools.cpp | 27 +-
src/cppcache/src/AdminRegion.cpp | 13 +-
src/cppcache/src/AttributesFactory.cpp | 13 -
src/cppcache/src/Cache.cpp | 78 +-
src/cppcache/src/CacheFactory.cpp | 458 +----
src/cppcache/src/CacheImpl.cpp | 243 +--
src/cppcache/src/CacheImpl.hpp | 108 +-
src/cppcache/src/CachePerfStats.hpp | 19 +-
src/cppcache/src/CacheRegionHelper.cpp | 48 +
src/cppcache/src/CacheRegionHelper.hpp | 31 +-
.../src/CacheTransactionManagerImpl.cpp | 27 +-
.../src/CacheTransactionManagerImpl.hpp | 9 +-
src/cppcache/src/CacheXmlCreation.cpp | 33 +-
src/cppcache/src/CacheXmlCreation.hpp | 10 +-
src/cppcache/src/CacheXmlParser.cpp | 166 +-
src/cppcache/src/CacheXmlParser.hpp | 9 +-
src/cppcache/src/CacheableEnum.cpp | 10 +-
src/cppcache/src/CacheableObjectPartList.hpp | 11 +
src/cppcache/src/CacheableString.cpp | 4 +-
src/cppcache/src/ClientMetadata.hpp | 1 +
src/cppcache/src/ClientMetadataService.cpp | 45 +-
src/cppcache/src/ClientProxyMembershipID.cpp | 151 +-
src/cppcache/src/ClientProxyMembershipID.hpp | 13 +-
.../src/ClientProxyMembershipIDFactory.cpp | 44 +
.../src/ClientProxyMembershipIDFactory.hpp | 49 +
src/cppcache/src/ConcurrentEntriesMap.cpp | 19 +-
src/cppcache/src/ConcurrentEntriesMap.hpp | 14 +-
src/cppcache/src/CppCacheLibrary.cpp | 8 -
src/cppcache/src/CqEventImpl.cpp | 6 +-
src/cppcache/src/CqQueryImpl.cpp | 42 +-
src/cppcache/src/CqQueryImpl.hpp | 3 +-
src/cppcache/src/CqQueryVsdStats.cpp | 92 +-
src/cppcache/src/CqQueryVsdStats.hpp | 48 +-
src/cppcache/src/CqService.cpp | 24 +-
src/cppcache/src/CqService.hpp | 3 +-
src/cppcache/src/CqServiceVsdStats.cpp | 103 +-
src/cppcache/src/CqServiceVsdStats.hpp | 52 +-
src/cppcache/src/DataInput.cpp | 10 +-
src/cppcache/src/DataInputInternal.hpp | 43 +
src/cppcache/src/DataOutput.cpp | 14 +-
src/cppcache/src/DataOutputInternal.hpp | 44 +
src/cppcache/src/Delta.cpp | 13 +-
src/cppcache/src/DiffieHellman.cpp | 27 +-
src/cppcache/src/DiffieHellman.hpp | 9 +-
src/cppcache/src/DiskVersionTag.hpp | 40 +-
src/cppcache/src/DistributedSystem.cpp | 351 ++--
src/cppcache/src/DistributedSystemImpl.cpp | 32 +-
src/cppcache/src/DistributedSystemImpl.hpp | 2 +-
src/cppcache/src/EntriesMap.hpp | 8 +-
src/cppcache/src/EntriesMapFactory.cpp | 52 +-
src/cppcache/src/EntryExpiryHandler.cpp | 6 +-
src/cppcache/src/ExecutionImpl.cpp | 12 +-
src/cppcache/src/ExpMapEntry.cpp | 24 +-
src/cppcache/src/ExpMapEntry.hpp | 26 +-
src/cppcache/src/FarSideEntryOp.cpp | 9 +-
src/cppcache/src/FarSideEntryOp.hpp | 4 +-
src/cppcache/src/FunctionService.cpp | 33 +-
.../InternalCacheTransactionManager2PCImpl.cpp | 13 +-
src/cppcache/src/LRUAction.cpp | 2 +-
src/cppcache/src/LRUEntriesMap.cpp | 10 +-
src/cppcache/src/LRUEntriesMap.hpp | 9 +-
src/cppcache/src/LRUExpMapEntry.cpp | 24 +-
src/cppcache/src/LRUExpMapEntry.hpp | 27 +-
src/cppcache/src/LRUMapEntry.cpp | 19 +-
src/cppcache/src/LRUMapEntry.hpp | 8 +-
src/cppcache/src/LocalRegion.cpp | 283 +--
src/cppcache/src/LocalRegion.hpp | 8 +-
src/cppcache/src/MapEntry.cpp | 18 +-
src/cppcache/src/MapEntry.hpp | 34 +-
src/cppcache/src/MapEntryT.hpp | 18 +-
src/cppcache/src/MapSegment.cpp | 24 +-
src/cppcache/src/MapSegment.hpp | 24 +-
src/cppcache/src/PdxHelper.cpp | 188 +-
src/cppcache/src/PdxHelper.hpp | 4 +-
src/cppcache/src/PdxInstanceFactoryImpl.cpp | 16 +-
src/cppcache/src/PdxInstanceFactoryImpl.hpp | 11 +-
src/cppcache/src/PdxInstanceImpl.cpp | 421 ++---
src/cppcache/src/PdxInstanceImpl.hpp | 71 +-
src/cppcache/src/PdxLocalReader.cpp | 37 +-
src/cppcache/src/PdxLocalReader.hpp | 9 +-
src/cppcache/src/PdxLocalWriter.cpp | 88 +-
src/cppcache/src/PdxLocalWriter.hpp | 30 +-
src/cppcache/src/PdxReaderWithTypeCollector.cpp | 13 +-
src/cppcache/src/PdxReaderWithTypeCollector.hpp | 5 +-
src/cppcache/src/PdxRemoteReader.hpp | 5 +-
src/cppcache/src/PdxRemoteWriter.cpp | 42 +-
src/cppcache/src/PdxRemoteWriter.hpp | 28 +-
src/cppcache/src/PdxType.cpp | 71 +-
src/cppcache/src/PdxType.hpp | 32 +-
src/cppcache/src/PdxTypeRegistry.cpp | 173 +-
src/cppcache/src/PdxTypeRegistry.hpp | 97 +-
src/cppcache/src/PdxWrapper.cpp | 14 +-
src/cppcache/src/PdxWriterWithTypeCollector.cpp | 9 +-
src/cppcache/src/PdxWriterWithTypeCollector.hpp | 5 +-
src/cppcache/src/Pool.cpp | 26 +-
src/cppcache/src/PoolFactory.cpp | 43 +-
src/cppcache/src/PoolManager.cpp | 116 +-
src/cppcache/src/PoolStatistics.cpp | 229 +--
src/cppcache/src/PoolStatistics.hpp | 120 +-
src/cppcache/src/PoolXmlCreation.cpp | 5 +-
src/cppcache/src/PoolXmlCreation.hpp | 2 +-
src/cppcache/src/PreservedDataExpiryHandler.cpp | 10 +-
src/cppcache/src/PreservedDataExpiryHandler.hpp | 4 +-
src/cppcache/src/ProxyCache.cpp | 35 +-
src/cppcache/src/ProxyCache.hpp | 30 +-
src/cppcache/src/ProxyRegion.hpp | 9 +-
src/cppcache/src/ProxyRemoteQueryService.cpp | 36 +-
src/cppcache/src/Region.cpp | 2 +-
src/cppcache/src/RegionCommit.cpp | 6 +-
src/cppcache/src/RegionCommit.hpp | 5 +-
src/cppcache/src/RegionExpiryHandler.cpp | 9 +-
src/cppcache/src/RegionFactory.cpp | 55 +-
src/cppcache/src/RegionInternal.cpp | 5 +-
src/cppcache/src/RegionInternal.hpp | 40 +-
src/cppcache/src/RegionStats.cpp | 179 +-
src/cppcache/src/RegionStats.hpp | 119 +-
src/cppcache/src/RegionXmlCreation.cpp | 35 +-
src/cppcache/src/RegionXmlCreation.hpp | 6 +-
src/cppcache/src/RemoteQuery.cpp | 27 +-
src/cppcache/src/RemoteQueryService.cpp | 17 +-
src/cppcache/src/RemoteQueryService.hpp | 22 +-
src/cppcache/src/Serializable.cpp | 13 +-
src/cppcache/src/SerializationRegistry.cpp | 577 +++---
src/cppcache/src/SerializationRegistry.hpp | 110 +-
src/cppcache/src/TXCommitMessage.cpp | 6 +-
src/cppcache/src/TXCommitMessage.hpp | 6 +-
src/cppcache/src/TcpConn.cpp | 76 +-
src/cppcache/src/TcpConn.hpp | 15 +-
src/cppcache/src/TcpSslConn.cpp | 36 +-
src/cppcache/src/TcpSslConn.hpp | 30 +-
src/cppcache/src/TcrChunkedContext.hpp | 21 +-
src/cppcache/src/TcrConnection.cpp | 283 ++-
src/cppcache/src/TcrConnection.hpp | 12 +-
src/cppcache/src/TcrConnectionManager.cpp | 34 +-
src/cppcache/src/TcrConnectionManager.hpp | 7 +-
src/cppcache/src/TcrEndpoint.cpp | 157 +-
src/cppcache/src/TcrEndpoint.hpp | 8 +-
src/cppcache/src/TcrMessage.cpp | 688 ++++----
src/cppcache/src/TcrMessage.hpp | 320 +++-
src/cppcache/src/TcrPoolEndPoint.cpp | 16 +-
src/cppcache/src/ThinClientBaseDM.cpp | 18 +-
src/cppcache/src/ThinClientBaseDM.hpp | 5 +-
.../src/ThinClientCacheDistributionManager.hpp | 4 +-
.../src/ThinClientDistributionManager.cpp | 30 +-
src/cppcache/src/ThinClientHARegion.cpp | 25 +-
src/cppcache/src/ThinClientLocatorHelper.cpp | 168 +-
src/cppcache/src/ThinClientPoolDM.cpp | 202 ++-
src/cppcache/src/ThinClientPoolDM.hpp | 71 +-
src/cppcache/src/ThinClientPoolHADM.cpp | 43 +-
src/cppcache/src/ThinClientPoolHADM.hpp | 4 +-
src/cppcache/src/ThinClientPoolRegion.cpp | 5 +-
src/cppcache/src/ThinClientPoolStickyHADM.cpp | 74 -
src/cppcache/src/ThinClientPoolStickyHADM.hpp | 22 +-
.../src/ThinClientRedundancyManager.cpp | 44 +-
src/cppcache/src/ThinClientRegion.cpp | 432 +++--
src/cppcache/src/ThinClientRegion.hpp | 16 +-
src/cppcache/src/ThreadPool.cpp | 10 +-
src/cppcache/src/ThreadPool.hpp | 37 +-
src/cppcache/src/TombstoneExpiryHandler.cpp | 11 +-
src/cppcache/src/TombstoneExpiryHandler.hpp | 8 +-
src/cppcache/src/TombstoneList.cpp | 48 +-
src/cppcache/src/TombstoneList.hpp | 12 +-
src/cppcache/src/TypeRegistry.cpp | 44 +
src/cppcache/src/Utils.cpp | 13 +-
src/cppcache/src/Utils.hpp | 28 +-
src/cppcache/src/VersionStamp.cpp | 2 +-
src/cppcache/src/VersionTag.cpp | 51 +-
src/cppcache/src/VersionTag.hpp | 9 +-
.../src/VersionedCacheableObjectPartList.cpp | 20 +-
.../src/VersionedCacheableObjectPartList.hpp | 35 +-
.../src/statistics/GeodeStatisticsFactory.cpp | 30 -
.../src/statistics/GeodeStatisticsFactory.hpp | 48 +-
src/cppcache/src/statistics/HostStatHelper.cpp | 9 +-
src/cppcache/src/statistics/HostStatHelper.hpp | 17 +-
src/cppcache/src/statistics/HostStatSampler.cpp | 103 +-
src/cppcache/src/statistics/HostStatSampler.hpp | 14 +-
.../src/statistics/LinuxProcessStats.cpp | 8 +-
.../src/statistics/LinuxProcessStats.hpp | 19 +-
.../src/statistics/PoolStatsSampler.cpp | 15 +-
.../src/statistics/PoolStatsSampler.hpp | 15 +-
.../src/statistics/SolarisProcessStats.cpp | 8 +-
.../src/statistics/SolarisProcessStats.hpp | 18 +-
.../src/statistics/StatArchiveWriter.cpp | 34 +-
.../src/statistics/StatArchiveWriter.hpp | 17 +-
.../src/statistics/StatSamplerStats.cpp | 4 +-
.../src/statistics/StatSamplerStats.hpp | 4 +-
.../src/statistics/StatisticDescriptorImpl.hpp | 17 +-
.../src/statistics/StatisticsFactory.cpp | 29 -
.../src/statistics/StatisticsManager.cpp | 41 +-
.../src/statistics/StatisticsManager.hpp | 76 +-
.../src/statistics/WindowsProcessStats.cpp | 11 +-
.../src/statistics/WindowsProcessStats.hpp | 22 +-
src/cppcache/test/CacheXmlParserTest.cpp | 4 +-
.../test/ClientProxyMembershipIDFactoryTest.cpp | 45 +
src/cppcache/test/DataInputTest.cpp | 184 +-
src/cppcache/test/DataOutputTest.cpp | 83 +-
src/cppcache/test/PdxLocalReaderTest.cpp | 40 +-
src/cppcache/test/TcrMessage_unittest.cpp | 212 ++-
src/quickstart/cpp/CqQuery.cpp | 4 +-
src/quickstart/cpp/Delta.cpp | 2 +-
src/quickstart/cpp/DistributedSystem.cpp | 4 +-
src/quickstart/cpp/PdxRemoteQuery.cpp | 4 +-
src/quickstart/cpp/PdxSerializer.cpp | 44 +-
src/quickstart/cpp/PoolCqQuery.cpp | 4 +-
src/quickstart/cpp/PoolRemoteQuery.cpp | 4 +-
src/quickstart/cpp/PoolWithEndpoints.cpp | 2 +-
src/quickstart/cpp/RemoteQuery.cpp | 4 +-
src/quickstart/csharp/CqQuery.cs | 4 +-
src/quickstart/csharp/Delta.cs | 2 +-
src/quickstart/csharp/PoolCqQuery.cs | 4 +-
src/quickstart/csharp/PoolRemoteQuery.cs | 4 +-
src/quickstart/csharp/RemoteQuery.cs | 4 +-
src/sqliteimpl/SqLiteImpl.cpp | 31 +-
src/templates/security/PkcsAuthInit.cpp | 14 +-
src/templates/security/PkcsAuthInit.hpp | 2 +-
src/templates/security/UserPasswordAuthInit.cpp | 4 +-
src/templates/security/UserPasswordAuthInit.hpp | 2 +-
src/tests/cli/FwkUtil/FwkData.cs | 206 +--
src/tests/cli/NewFwkLib/CacheHelper.cs | 20 +-
src/tests/cli/NewFwkLib/CacheServer.cs | 29 +-
src/tests/cli/NewFwkLib/DeltaTest/DeltaTest.cs | 4 +-
src/tests/cli/NewFwkLib/EventTest/EventTests.cs | 32 +-
.../FunctionExecution/FunctionExecution.cs | 4 +-
src/tests/cli/NewFwkLib/FwkTest.cs | 25 +-
src/tests/cli/NewFwkLib/NewFwkLib.csproj.in | 45 +-
src/tests/cli/NewFwkLib/PdxTest/PdxTests.cs | 19 +-
src/tests/cli/NewFwkLib/PerfTest/PerfTests.cs | 10 +-
src/tests/cli/NewFwkLib/QueryTest/QueryTests.cs | 31 +-
.../cli/NewFwkLib/SecurityTest/Security.cs | 2 +-
.../cli/NewFwkLib/SmokePerf/ObjectHelper.cs | 73 -
src/tests/cli/NewFwkLib/SmokePerf/PerfStat.cs | 295 ----
src/tests/cli/NewFwkLib/SmokePerf/SmokePerf.cs | 1580 -----------------
src/tests/cli/NewFwkLib/SmokePerf/SmokeTasks.cs | 829 ---------
src/tests/cli/PkcsWrapper/PkcsAuthInitMN.hpp | 1 +
src/tests/cli/QueryHelper/QueryHelperN.cs | 13 +-
src/tests/cli/QueryHelper/QueryStringsM.cpp | 4 -
src/tests/cpp/fwklib/FrameworkTest.cpp | 10 +-
src/tests/cpp/fwklib/FwkObjects.cpp | 5 +-
src/tests/cpp/fwklib/FwkObjects.hpp | 122 +-
src/tests/cpp/fwklib/PoolHelper.hpp | 14 +-
src/tests/cpp/fwklib/QueryHelper.hpp | 5 +-
src/tests/cpp/security/PkcsAuthInit.cpp | 16 +-
src/tests/cpp/security/PkcsAuthInit.hpp | 2 +-
src/tests/cpp/testobject/ArrayOfByte.hpp | 18 +-
.../cpp/testobject/DeltaFastAssetAccount.cpp | 2 +-
.../cpp/testobject/DeltaFastAssetAccount.hpp | 3 +-
src/tests/cpp/testobject/DeltaPSTObject.cpp | 3 +-
src/tests/cpp/testobject/DeltaPSTObject.hpp | 2 +-
src/tests/cpp/testobject/DeltaTestImpl.cpp | 14 +-
src/tests/cpp/testobject/NonPdxType.hpp | 57 +-
src/tests/cpp/testobject/NoopAuthInit.cpp | 2 +-
src/tests/cpp/testobject/NoopAuthInit.hpp | 2 +-
452 files changed, 9645 insertions(+), 17236 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/CacheHelperN.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/CacheHelperN.cs b/src/clicache/integration-test/CacheHelperN.cs
index 8236e78..5824fd7 100644
--- a/src/clicache/integration-test/CacheHelperN.cs
+++ b/src/clicache/integration-test/CacheHelperN.cs
@@ -440,7 +440,7 @@ namespace Apache.Geode.Client.UnitTests
public static void DSConnectAD()
{
- m_dsys = DistributedSystem.Connect("DSName", null);
+ m_dsys = DistributedSystem.Connect("DSName", null, m_cache);
}
private static void SetLogConfig(ref Properties<string, string> config)
@@ -467,7 +467,7 @@ namespace Apache.Geode.Client.UnitTests
private static void DSConnect(string dsName, Properties<string, string> config)
{
SetLogConfig(ref config);
- m_dsys = DistributedSystem.Connect(dsName, config);
+ m_dsys = DistributedSystem.Connect(dsName, config, m_cache);
}
public static void ConnectName(string dsName)
@@ -477,17 +477,7 @@ namespace Apache.Geode.Client.UnitTests
public static void ConnectConfig(string dsName, Properties<string, string> config)
{
- if (DistributedSystem.IsConnected)
- {
- if (m_dsys == null)
- {
- m_dsys = DistributedSystem.GetInstance();
- }
- }
- else
- {
DSConnect(dsName, config);
- }
}
public static void Init()
@@ -625,7 +615,7 @@ namespace Apache.Geode.Client.UnitTests
}
catch (CacheExistsException)
{
- m_cache = CacheFactory.GetAnyInstance();
+ m_cache = CacheFactory.CreateCacheFactory(config).Create();
}
}
@@ -648,7 +638,7 @@ namespace Apache.Geode.Client.UnitTests
public static void Close()
{
- Util.Log("in cache close " + DistributedSystem.IsConnected + " : " + System.Threading.Thread.GetDomainID());
+ Util.Log("in cache close : " + System.Threading.Thread.GetDomainID());
//if (DistributedSystem.IsConnected)
{
CloseCache();
@@ -680,14 +670,7 @@ namespace Apache.Geode.Client.UnitTests
public static void CloseKeepAlive()
{
- if (DistributedSystem.IsConnected)
- {
- CloseCacheKeepAlive();
- if (m_doDisconnect)
- {
- DistributedSystem.Disconnect();
- }
- }
+ CloseCacheKeepAlive();
m_dsys = null;
}
@@ -929,7 +912,7 @@ namespace Apache.Geode.Client.UnitTests
Util.Log("resolver is null {0}", resolver);
}
- PoolFactory/*<TKey, TVal>*/ poolFactory = PoolManager/*<TKey, TVal>*/.CreateFactory();
+ PoolFactory poolFactory = m_cache.GetPoolFactory();
if (locators != null)
{
@@ -947,7 +930,7 @@ namespace Apache.Geode.Client.UnitTests
}
poolFactory.SetSubscriptionEnabled(clientNotification);
- poolFactory.Create("__TESTPOOL__");
+ poolFactory.Create("__TESTPOOL__", CacheHelper.DCache);
region = regionFactory.SetPoolName("__TESTPOOL__").Create<TradeKey, Object>(name);
Assert.IsNotNull(region, "IRegion<TradeKey, Object> {0} was not created.", name);
@@ -998,11 +981,11 @@ namespace Apache.Geode.Client.UnitTests
{
Init();
- Pool/*<TKey, TValue>*/ existing = PoolManager/*<TKey, TValue>*/.Find(name);
+ Pool/*<TKey, TValue>*/ existing = m_cache.GetPoolManager().Find(name);
if (existing == null)
{
- PoolFactory/*<TKey, TValue>*/ fact = PoolManager/*<TKey, TValue>*/.CreateFactory();
+ PoolFactory/*<TKey, TValue>*/ fact = m_cache.GetPoolFactory();
if (locators != null)
{
string[] list = locators.Split(',');
@@ -1035,7 +1018,7 @@ namespace Apache.Geode.Client.UnitTests
fact.SetMinConnections(numConnections);
fact.SetMaxConnections(numConnections);
}
- Pool/*<TKey, TValue>*/ pool = fact.Create(name);
+ Pool/*<TKey, TValue>*/ pool = fact.Create(name, CacheHelper.DCache);
if (pool == null)
{
Util.Log("Pool creation failed");
@@ -1088,9 +1071,9 @@ namespace Apache.Geode.Client.UnitTests
Assert.IsTrue(region.IsDestroyed, "IRegion<object, object> {0} was not destroyed.", name);
}
- if (PoolManager/*<TKey, TValue>*/.Find(poolName) == null)
+ if (m_cache.GetPoolManager().Find(poolName) == null)
{
- PoolFactory/*<TKey, TValue>*/ fact = PoolManager/*<TKey, TValue>*/.CreateFactory();
+ PoolFactory/*<TKey, TValue>*/ fact = m_cache.GetPoolFactory();
fact.SetSubscriptionEnabled(clientNotification);
if (locators != null)
{
@@ -1105,7 +1088,7 @@ namespace Apache.Geode.Client.UnitTests
{
Util.Log("No locators or servers specified for pool");
}
- Pool/*<TKey, TValue>*/ pool = fact.Create(poolName);
+ Pool/*<TKey, TValue>*/ pool = fact.Create(poolName, CacheHelper.DCache);
if (pool == null)
{
Util.Log("Pool creation failed");
@@ -1165,14 +1148,14 @@ namespace Apache.Geode.Client.UnitTests
region.GetLocalView().DestroyRegion();
Assert.IsTrue(region.IsDestroyed, "IRegion<object, object> {0} was not destroyed.", name);
}
- Pool pl = PoolManager/*<TKey, TValue>*/.Find(poolName);
+ Pool pl = m_cache.GetPoolManager().Find(poolName);
if (pl != null)
{
Util.Log("Pool is not closed " + poolName);
}
if (pl == null)
{
- PoolFactory/*<TKey, TValue>*/ fact = PoolManager/*<TKey, TValue>*/.CreateFactory();
+ PoolFactory/*<TKey, TValue>*/ fact = m_cache.GetPoolFactory();
fact.SetSubscriptionEnabled(clientNotification);
if (locators != null)
{
@@ -1187,7 +1170,7 @@ namespace Apache.Geode.Client.UnitTests
{
Util.Log("No locators or servers specified for pool");
}
- Pool/*<TKey, TValue>*/ pool = fact.Create(poolName);
+ Pool/*<TKey, TValue>*/ pool = fact.Create(poolName, CacheHelper.DCache);
if (pool == null)
{
Util.Log("Pool creation failed");
@@ -1240,9 +1223,9 @@ namespace Apache.Geode.Client.UnitTests
Assert.IsTrue(region.IsDestroyed, "IRegion<object, object> {0} was not destroyed.", name);
}
- if (PoolManager/*<TKey, TValue>*/.Find(poolName) == null)
+ if (m_cache.GetPoolManager().Find(poolName) == null)
{
- PoolFactory/*<TKey, TValue>*/ fact = PoolManager/*<TKey, TValue>*/.CreateFactory();
+ PoolFactory/*<TKey, TValue>*/ fact = m_cache.GetPoolFactory();
fact.SetSubscriptionEnabled(clientNotification);
if (locators != null)
{
@@ -1257,7 +1240,7 @@ namespace Apache.Geode.Client.UnitTests
{
Util.Log("No locators or servers specified for pool");
}
- Pool/*<TKey, TValue>*/ pool = fact.Create(poolName);
+ Pool/*<TKey, TValue>*/ pool = fact.Create(poolName, CacheHelper.DCache);
if (pool == null)
{
Util.Log("Pool creation failed");
@@ -1306,9 +1289,9 @@ namespace Apache.Geode.Client.UnitTests
Assert.IsTrue(region.IsDestroyed, "IRegion<object, object> {0} was not destroyed.", name);
}
- if (PoolManager/*<TKey, TValue>*/.Find(poolName) == null)
+ if (m_cache.GetPoolManager().Find(poolName) == null)
{
- PoolFactory/*<TKey, TValue>*/ fact = PoolManager/*<TKey, TValue>*/.CreateFactory();
+ PoolFactory/*<TKey, TValue>*/ fact = m_cache.GetPoolFactory();
fact.SetSubscriptionEnabled(clientNotification);
if (locators != null)
{
@@ -1323,7 +1306,7 @@ namespace Apache.Geode.Client.UnitTests
{
Util.Log("No locators or servers specified for pool");
}
- Pool/*<TKey, TValue>*/ pool = fact.Create(poolName);
+ Pool/*<TKey, TValue>*/ pool = fact.Create(poolName, CacheHelper.DCache);
if (pool == null)
{
Util.Log("Pool creation failed");
@@ -1374,9 +1357,9 @@ namespace Apache.Geode.Client.UnitTests
Assert.IsTrue(region.IsDestroyed, "IRegion<object, object> {0} was not destroyed.", name);
}
- if (PoolManager/*<TKey, TValue>*/.Find(poolName) == null)
+ if (m_cache.GetPoolManager().Find(poolName) == null)
{
- PoolFactory/*<TKey, TValue>*/ fact = PoolManager/*<TKey, TValue>*/.CreateFactory();
+ PoolFactory/*<TKey, TValue>*/ fact = m_cache.GetPoolFactory();
fact.SetSubscriptionEnabled(clientNotification);
if (serverGroup != null)
{
@@ -1395,7 +1378,7 @@ namespace Apache.Geode.Client.UnitTests
{
Util.Log("No locators or servers specified for pool");
}
- Pool/*<TKey, TValue>*/ pool = fact.Create(poolName);
+ Pool/*<TKey, TValue>*/ pool = fact.Create(poolName, CacheHelper.DCache);
if (pool == null)
{
Util.Log("Pool creation failed");
@@ -1448,9 +1431,9 @@ namespace Apache.Geode.Client.UnitTests
Assert.IsTrue(region.IsDestroyed, "IRegion<object, object> {0} was not destroyed.", name);
}
- if (PoolManager.Find(poolName) == null)
+ if (m_cache.GetPoolManager().Find(poolName) == null)
{
- PoolFactory fact = PoolManager.CreateFactory();
+ PoolFactory fact = m_cache.GetPoolFactory();
fact.SetSubscriptionEnabled(clientNotification);
if (locators != null)
{
@@ -1465,7 +1448,7 @@ namespace Apache.Geode.Client.UnitTests
{
Util.Log("No locators or servers specified for pool");
}
- Pool pool = fact.Create(poolName);
+ Pool pool = fact.Create(poolName, m_cache);
if (pool == null)
{
Util.Log("Pool creation failed");
@@ -1598,19 +1581,6 @@ namespace Apache.Geode.Client.UnitTests
return null;
}
- public static IRegion<TKey, TValue> GetRegionAD<TKey, TValue>(string path)
- {
- if (m_cache != null)
- {
- return m_cache.GetRegion<TKey, TValue>(path);
- }
- else if (DistributedSystem.IsConnected)
- {
- return CacheFactory.GetAnyInstance().GetRegion<TKey, TValue>(path);
- }
- return null;
- }
-
public static Properties<string, object> GetPkcsCredentialsForMU(Properties<string, string> credentials)
{
if (credentials == null)
@@ -1632,7 +1602,7 @@ namespace Apache.Geode.Client.UnitTests
Assert.IsNotNull(region, "IRegion<object, object> [" + path + "] not found.");
Assert.IsNotNull(region.Attributes.PoolName, "IRegion<object, object> is created without pool.");
- Pool/*<TKey, TValue>*/ pool = PoolManager/*<TKey, TValue>*/.Find(region.Attributes.PoolName);
+ Pool/*<TKey, TValue>*/ pool = m_cache.GetPoolManager().Find(region.Attributes.PoolName);
Assert.IsNotNull(pool, "Pool is null in GetVerifyRegion.");
@@ -1651,7 +1621,7 @@ namespace Apache.Geode.Client.UnitTests
{
if (m_cacheForMultiUser == null)
{
- Pool/*<TKey, TValue>*/ pool = PoolManager/*<TKey, TValue>*/.Find("__TESTPOOL1_");
+ Pool/*<TKey, TValue>*/ pool = m_cache.GetPoolManager().Find("__TESTPOOL1_");
Assert.IsNotNull(pool, "Pool is null in getMultiuserCache.");
Assert.IsTrue(!pool.Destroyed);
@@ -1674,15 +1644,6 @@ namespace Apache.Geode.Client.UnitTests
return region;
}
- public static IRegion<TKey, TValue> GetVerifyRegionAD<TKey, TValue>(string path)
- {
- IRegion<TKey, TValue> region = GetRegionAD<TKey, TValue>(path);
-
- Assert.IsNotNull(region, "IRegion<object, object> [" + path + "] not found.");
- Util.Log("Found region '{0}'", path);
- return region;
- }
-
public static IRegion<TKey, TValue> GetVerifyRegion<TKey, TValue>(string path, Properties<string, string> credentials)
{
Util.Log("GetVerifyRegion " + m_cacheForMultiUser);
@@ -1692,7 +1653,7 @@ namespace Apache.Geode.Client.UnitTests
Assert.IsNotNull(region, "IRegion<object, object> [" + path + "] not found.");
Assert.IsNotNull(region.Attributes.PoolName, "IRegion<object, object> is created without pool.");
- Pool/*<TKey, TValue>*/ pool = PoolManager/*<TKey, TValue>*/.Find(region.Attributes.PoolName);
+ Pool/*<TKey, TValue>*/ pool = m_cache.GetPoolManager().Find(region.Attributes.PoolName);
Assert.IsNotNull(pool, "Pool is null in GetVerifyRegion.");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/DataOutputTests.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/DataOutputTests.cs b/src/clicache/integration-test/DataOutputTests.cs
index a247b10..5c253ee 100755
--- a/src/clicache/integration-test/DataOutputTests.cs
+++ b/src/clicache/integration-test/DataOutputTests.cs
@@ -24,7 +24,7 @@ namespace Apache.Geode.Client.UnitTests
using NUnit.Framework;
using Apache.Geode.DUnitFramework;
using Apache.Geode.Client;
-
+
[TestFixture]
[Category("unicast_only")]
public class DataOutputTests : UnitTests
@@ -39,8 +39,10 @@ namespace Apache.Geode.Client.UnitTests
[Test]
public void StringExcedesBufferCapacity()
{
-
- DataOutput dataOutput = new DataOutput();
+
+ CacheHelper.InitConfig((String) null);
+
+ DataOutput dataOutput = CacheHelper.DCache.CreateDataOutput();
// Chcek that native buffer is unused and get initial capacity.
Assert.AreEqual(0, dataOutput.BufferLength);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/DistributedSystemTests.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/DistributedSystemTests.cs b/src/clicache/integration-test/DistributedSystemTests.cs
index 441f057..157eee2 100644
--- a/src/clicache/integration-test/DistributedSystemTests.cs
+++ b/src/clicache/integration-test/DistributedSystemTests.cs
@@ -36,7 +36,7 @@ namespace Apache.Geode.Client.UnitTests
{
try
{
- DistributedSystem.Disconnect();
+ DistributedSystem.Disconnect(CacheHelper.getCache());
Assert.Fail("NotConnectedException should have occurred when "
+ "disconnecting without having connected.");
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/PutGetTestsN.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/PutGetTestsN.cs b/src/clicache/integration-test/PutGetTestsN.cs
index d38e045..2147821 100644
--- a/src/clicache/integration-test/PutGetTestsN.cs
+++ b/src/clicache/integration-test/PutGetTestsN.cs
@@ -153,7 +153,7 @@ namespace Apache.Geode.Client.UnitTests
public void SetRegion(string regionName)
{
- m_region = CacheHelper.GetVerifyRegionAD<object, object>(regionName);
+ m_region = CacheHelper.GetVerifyRegion<object, object>(regionName);
}
public void DoPuts()
@@ -208,443 +208,12 @@ namespace Apache.Geode.Client.UnitTests
public void DoPRSHPartitionResolverPuts(string rname)
{
- IRegion<object, object> region = CacheHelper.GetRegion<object, object>(rname);
- int metadatarefreshCount = 0;
- int metadatarefreshCount1 = 0;
- Assert.IsNotNull(region, "DoPRSHPartitionResolverPuts: null region.");
- if (rname.CompareTo("DistRegionNoAck") == 0)
- {
- Util.Log("Inside DoPRSHPartitionResolverPuts region name is {0} ", region.Name.ToString());
- for (int i = 0; i < 1000; i++)
- {
- try
- {
- int key = i;
- int val = key.GetHashCode();
- region[key] = val;
- Util.Log("Put inside DoPRSHPartitionResolverPuts successfull {0} {1}", key, val);
- }
- catch (CacheServerException ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got CacheServerException (0}", ex.Message);
- }
- catch (CacheWriterException ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got CacheWriterException (0}", ex.Message);
- }
- catch (Exception ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got Exception (0}", ex.Message);
- }
- }
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("RegionStatistics");
- if (type != null)
- {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null)
- {
- metadatarefreshCount = rStats.GetInt((string)"metaDataRefreshCount");
- }
- }
- //Assert.AreEqual(1, nonSingleHopCount, "nonSingleHopCount should be equal to 1");
- //Assert.AreEqual(1, metadatarefreshCount, "metadatarefreshCount should be equal to 1");
-
- Util.Log("DoPRSHPartitionResolverPuts WarmUp Task completed.");
-
- for (int i = 1000; i < 2000; i++)
- {
- try
- {
- //CacheableInt32 key = new CacheableInt32(i);
- int key = i;
- int val = key.GetHashCode();
- region[key] = val;
- Util.Log("Put inside DoPRSHPartitionResolverPuts successfull {0} {1}", key, val);
- }
- catch (CacheServerException ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got CacheServerException (0}", ex.Message);
- }
- catch (CacheWriterException ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got CacheWriterException (0}", ex.Message);
- }
- catch (Exception ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got Exception (0}", ex.Message);
- }
-
- try
- {
- //CacheableInt32 key = new CacheableInt32(i);
- int key = i;
- Object val = region[key];
- Util.Log("Get inside DoPRSHPartitionResolverPuts successfull {0}", key);
- }
- catch (CacheServerException ex)
- {
- Util.Log("CPPTEST: Get caused networkhop");
- Assert.Fail("Got CacheServerException (0}", ex.Message);
- }
- catch (CacheWriterException ex)
- {
- Util.Log("CPPTEST: Get caused networkhop");
- Assert.Fail("Got CacheWriterException (0}", ex.Message);
- }
- catch (Exception ex)
- {
- Util.Log("CPPTEST: Get caused networkhop");
- Assert.Fail("Got Exception (0}", ex.Message);
- }
-
- try
- {
- //CacheableInt32 key = new CacheableInt32(i);
- int key = i;
- region.Remove(key); //Destroy() replaced by Remove
- Util.Log("Destroy inside DoPRSHPartitionResolverPuts successfull {0}", key);
- }
- catch (CacheServerException ex)
- {
- Util.Log("CPPTEST: Destroy caused networkhop");
- Assert.Fail("Got CacheServerException (0}", ex.Message);
- }
- catch (CacheWriterException ex)
- {
- Util.Log("CPPTEST: Destroy caused networkhop");
- Assert.Fail("Got CacheWriterException (0}", ex.Message);
- }
- catch (Exception ex)
- {
- Util.Log("CPPTEST: Destroy caused networkhop");
- Assert.Fail("Got Exception (0}", ex.Message);
- }
- }
- if (type != null)
- {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null)
- {
- metadatarefreshCount1 = rStats.GetInt((string)"metaDataRefreshCount");
- Assert.AreEqual(metadatarefreshCount1, metadatarefreshCount, "metadatarefreshCount1 should be equal to metadatarefreshCount");
- }
- }
- }
- metadatarefreshCount = 0;
- if (rname.CompareTo("DistRegionAck") == 0)
- {
- Util.Log("Inside DoPRSHPartitionResolverPuts region name is {0} ", region.Name.ToString());
- for (int i = 0; i < 1000; i++)
- {
- try
- {
- int key = i;
- int val = key.GetHashCode();
- region[key] = val;
- Util.Log("Put inside DoPRSHPartitionResolverPuts successfull {0} {1}", key, val);
- }
- catch (CacheServerException ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got CacheServerException (0}", ex.Message);
- }
- catch (CacheWriterException ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got CacheWriterException (0}", ex.Message);
- }
- catch (Exception ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got Exception (0}", ex.Message);
- }
- }
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("RegionStatistics");
- if (type != null)
- {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null)
- {
- metadatarefreshCount = rStats.GetInt((string)"metaDataRefreshCount");
- }
- }
- //Assert.AreEqual(1, metadatarefreshCount, "metadatarefreshCount should be equal to 1");
-
- Util.Log("DoPRSHPartitionResolverPuts WarmUp Task completed.");
-
- Util.Log("Inside DoPRSHPartitionResolverPuts region name is {0} ", region.Name.ToString());
- for (int i = 1000; i < 2000; i++)
- {
- try
- {
- //CacheableInt32 key = new CacheableInt32(i);
- int key = i;
- int val = key.GetHashCode();
- region[key] = val;
- Util.Log("Put inside DoPRSHPartitionResolverPuts successfull {0} {1}", key, val);
- }
- catch (CacheServerException ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got CacheServerException (0}", ex.Message);
- }
- catch (CacheWriterException ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got CacheWriterException (0}", ex.Message);
- }
- catch (Exception ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got Exception (0}", ex.Message);
- }
- try
- {
- //CacheableInt32 key = new CacheableInt32(i);
- int key = i;
- Object val = region[key];
- Util.Log("Get inside DoPRSHPartitionResolverPuts successfull {0}", key);
- }
- catch (CacheServerException ex)
- {
- Util.Log("CPPTEST: Get caused networkhop");
- Assert.Fail("Got CacheServerException (0}", ex.Message);
- }
- catch (CacheWriterException ex)
- {
- Util.Log("CPPTEST: Get caused networkhop");
- Assert.Fail("Got CacheWriterException (0}", ex.Message);
- }
- catch (Exception ex)
- {
- Util.Log("CPPTEST: Get caused networkhop");
- Assert.Fail("Got Exception (0}", ex.Message);
- }
- try
- {
- //CacheableInt32 key = new CacheableInt32(i);
- int key = i;
- region.Remove(key); //Destroy() -> Remove()
- Util.Log("Destroy inside DoPRSHPartitionResolverPuts successfull {0}", key);
- }
- catch (CacheServerException ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got CacheServerException (0}", ex.Message);
- }
- catch (CacheWriterException ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got CacheWriterException (0}", ex.Message);
- }
- catch (Exception ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got Exception (0}", ex.Message);
- }
- }
-
- if (type != null)
- {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null)
- {
- metadatarefreshCount1 = rStats.GetInt((string)"metaDataRefreshCount");
- Assert.AreEqual(metadatarefreshCount1, metadatarefreshCount, "metadatarefreshCount1 should be equal to metadatarefreshCount");
- }
- }
- }
}
public void DoPRSHTradeResolverTasks(string rname)
{
- Util.Log("DoPRSHTradeResolverTasks rname = {0} ", rname);
- IRegion<TradeKey, Object> region = CacheHelper.GetRegion<TradeKey, Object>(rname);
- int metadatarefreshCount = 0;
- int metadatarefreshCount1 = 0;
- Assert.IsNotNull(region, "DoPRSHTradeResolverTasks: null region.");
- for (int i = 0; i < 1000; i++)
- {
- try
- {
- region[new TradeKey(i)] = "Value" + i;
- Util.Log("Put inside DoPRSHTradeResolverTasks successfull ");
- }
- catch (CacheServerException ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got CacheServerException (0}", ex.Message);
- }
- catch (CacheWriterException ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got CacheWriterException (0}", ex.Message);
- }
- catch (Exception ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got Exception (0}", ex.Message);
- }
- }
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("RegionStatistics");
- if (type != null)
- {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null)
- {
- metadatarefreshCount = rStats.GetInt((string)"metaDataRefreshCount");
- }
- }
- Util.Log("metadatarefreshCount = {0} ", metadatarefreshCount);
- Assert.GreaterOrEqual(metadatarefreshCount, 1, "metadatarefreshCount should be equal to 1");
-
- Util.Log("DoPRSHTradeResolverTasks WarmUp Task completed.");
-
- for (int i = 1000; i < 2000; i++)
- {
- try
- {
- region[new TradeKey(i)] = "Value" + i;
- Util.Log("Put inside DoPRSHTradeResolverTasks successfull");
- }
- catch (CacheServerException ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got CacheServerException (0}", ex.Message);
- }
- catch (CacheWriterException ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got CacheWriterException (0}", ex.Message);
- }
- catch (Exception ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got Exception (0}", ex.Message);
- }
-
- try
- {
- Object val = region[new TradeKey(i)];
- Util.Log("Get inside DoPRSHTradeResolverTasks successfull ");
- }
- catch (CacheServerException ex)
- {
- Util.Log("CPPTEST: Get caused networkhop");
- Assert.Fail("Got CacheServerException (0}", ex.Message);
- }
- catch (CacheWriterException ex)
- {
- Util.Log("CPPTEST: Get caused networkhop");
- Assert.Fail("Got CacheWriterException (0}", ex.Message);
- }
- catch (Exception ex)
- {
- Util.Log("CPPTEST: Get caused networkhop");
- Assert.Fail("Got Exception (0}", ex.Message);
- }
- try
- {
- region.Remove(new TradeKey(i)); //Destroy() replaced by Remove
- Util.Log("Destroy inside DoPRSHTradeResolverTasks successfull ");
- }
- catch (CacheServerException ex)
- {
- Util.Log("CPPTEST: Destroy caused networkhop");
- Assert.Fail("Got CacheServerException (0}", ex.Message);
- }
- catch (CacheWriterException ex)
- {
- Util.Log("CPPTEST: Destroy caused networkhop");
- Assert.Fail("Got CacheWriterException (0}", ex.Message);
- }
- catch (Exception ex)
- {
- Util.Log("CPPTEST: Destroy caused networkhop");
- Assert.Fail("Got Exception (0}", ex.Message);
- }
- }
- if (type != null)
- {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null)
- {
- metadatarefreshCount1 = rStats.GetInt((string)"metaDataRefreshCount");
- Util.Log("metadatarefreshCount1 = {0} ", metadatarefreshCount1);
- Assert.AreEqual(metadatarefreshCount1, metadatarefreshCount, "metadatarefreshCount1 should be equal to metadatarefreshCount");
- }
- }
-
- Util.Log("Executing onRegion FE with custom key and custom partitionResolver");
- Apache.Geode.Client.Execution<object> exc = Client.FunctionService<object>.OnRegion<TradeKey, object>(region);
- Assert.IsTrue(exc != null, "onRegion Returned NULL");
-
- TradeKey[] filter = new TradeKey[901];
- int j = 0;
- for (int i = 100; i < 1001; i++)
- {
- filter[j] = new TradeKey(i);
- j++;
- }
- Util.Log("filter count= {0}.", filter.Length);
-
- Client.IResultCollector<object> rc = exc.WithFilter<TradeKey>(filter).Execute(FEOnRegionPrSHOP_OptimizeForWrite, 15);
- Util.Log("FEOnRegionPrSHOP_OptimizeForWrite executed");
- ICollection<object> executeFunctionResult = rc.GetResult();
- Util.Log("OnRegionPrSHOP for filter executeFunctionResult.Count = {0} ", executeFunctionResult.Count);
- Assert.AreEqual(3, executeFunctionResult.Count, "executeFunctionResult count check failed");
- foreach (Boolean item in executeFunctionResult)
- {
- Util.Log("on region:FEOnRegionPrSHOP:= {0}.", item);
- Assert.AreEqual(true, item, "FEOnRegionPrSHOP item not true");
- }
- Util.Log("FEOnRegionPrSHOP_OptimizeForWrite done");
-
- rc = exc.WithFilter<TradeKey>(filter).Execute(FEOnRegionPrSHOP, 15);
- Util.Log("FEOnRegionPrSHOP executed");
- executeFunctionResult = rc.GetResult();
- Util.Log("OnRegionPrSHOP for filter executeFunctionResult.Count = {0} ", executeFunctionResult.Count);
- Assert.AreEqual(3, executeFunctionResult.Count, "executeFunctionResult count check failed");
- foreach (Boolean item in executeFunctionResult)
- {
- Util.Log("on region:FEOnRegionPrSHOP:= {0}.", item);
- Assert.AreEqual(true, item, "FEOnRegionPrSHOP item not true");
- }
- Util.Log("FEOnRegionPrSHOP done");
-
- object args = true;
-
- rc = exc.WithFilter<TradeKey>(filter).Execute(getFuncName);
- executeFunctionResult = rc.GetResult();
-
- Util.Log("ExecuteFunctionOnRegion for filter executeFunctionResult.Count = {0} ", executeFunctionResult.Count);
-
- List<object> resultList = new List<object>();
- foreach (List<object> item in executeFunctionResult)
- {
- foreach (object item2 in item)
- {
- resultList.Add(item2);
- }
- }
-
- Util.Log("on region: result count= {0}.", resultList.Count);
- Assert.AreEqual(1802, resultList.Count, "result count check failed");
- for (int i = 0; i < resultList.Count; i++)
- {
- Util.Log("on region:get:= {0}.", resultList[i]);
- }
}
public void DoPRSHFixedPartitionResolverTests(string rname)
@@ -680,77 +249,7 @@ namespace Apache.Geode.Client.UnitTests
Assert.Fail("Got Exception (0} {1} {2} ", ex.Message, ex.StackTrace, ex.Source);
}
}
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- StatisticsType type = factory.FindType("RegionStatistics");
- if (type != null)
- {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null)
- {
- metadatarefreshCount = rStats.GetInt((string)"metaDataRefreshCount");
- }
- }
- Util.Log("DoPRSHFixedPartitionResolverTests Put Task completed metadatarefreshCount = {0}.", metadatarefreshCount);
- Assert.Greater(metadatarefreshCount, 1, "metadatarefreshCount should be Greater than 1");
-
- for (int i = 0; i < 1000; i++)
- {
- try
- {
- int key = i;
- Object val = region[key];
- Util.Log("Get inside DoPRSHFixedPartitionResolverTests successfull {0}", key);
- }
- catch (CacheServerException ex)
- {
- Util.Log("CPPTEST: Get caused networkhop");
- Assert.Fail("Got CacheServerException (0}", ex.Message);
- }
- catch (CacheWriterException ex)
- {
- Util.Log("CPPTEST: Get caused networkhop");
- Assert.Fail("Got CacheWriterException (0}", ex.Message);
- }
- catch (Exception ex)
- {
- Util.Log("CPPTEST: Get caused networkhop");
- Assert.Fail("Got Exception (0}", ex.Message);
- }
- try
- {
- int key = i;
- region.Remove(key); //Destroy() -> Remove()
- Util.Log("Remove inside DoPRSHFixedPartitionResolverTests successfull {0}", key);
- }
- catch (CacheServerException ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got CacheServerException (0}", ex.Message);
- }
- catch (CacheWriterException ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got CacheWriterException (0}", ex.Message);
- }
- catch (Exception ex)
- {
- Util.Log("CPPTEST: Put caused networkhop");
- Assert.Fail("Got Exception (0}", ex.Message);
- }
- }
- if (type != null)
- {
- Statistics rStats = factory.FindFirstStatisticsByType(type);
- if (rStats != null)
- {
- metadatarefreshCount1 = rStats.GetInt((string)"metaDataRefreshCount");
- }
- }
- Util.Log("DoPRSHFixedPartitionResolverTests All Task completed ");
- Util.Log("metadatarefreshCount = {0} .", metadatarefreshCount);
- Util.Log("metadatarefreshCount1 = {0} .", metadatarefreshCount1);
- Assert.AreEqual(metadatarefreshCount, metadatarefreshCount1, "metadatarefreshCount should be equal to {0}", metadatarefreshCount);
}
public void DoPRSHFixedPartitionResolverTasks(ClientBase client1, string regionName)
@@ -820,7 +319,7 @@ namespace Apache.Geode.Client.UnitTests
else
{
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find(m_region.Attributes.PoolName).GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find(m_region.Attributes.PoolName).GetQueryService<object, object>();
Query<object> qry = qs.NewQuery("SELECT * FROM " + m_region.FullPath);
ISelectResults<object> results = qry.Execute();
// not really interested in results but loop through them neverthless
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/SerializationTestsN.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/SerializationTestsN.cs b/src/clicache/integration-test/SerializationTestsN.cs
index 8a3648e..9fb63f6 100644
--- a/src/clicache/integration-test/SerializationTestsN.cs
+++ b/src/clicache/integration-test/SerializationTestsN.cs
@@ -92,19 +92,19 @@ namespace Apache.Geode.Client.UnitTests
{
CacheHelper.CreateTCRegion2<object, object>(RegionNames[0], true, false,
null, locators, false);
- Serializable.RegisterTypeGeneric(OtherType.CreateDeserializable);
- Serializable.RegisterTypeGeneric(OtherType2.CreateDeserializable);
- Serializable.RegisterTypeGeneric(OtherType22.CreateDeserializable);
- Serializable.RegisterTypeGeneric(OtherType4.CreateDeserializable);
- Serializable.RegisterTypeGeneric(OtherType42.CreateDeserializable);
- Serializable.RegisterTypeGeneric(OtherType43.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(OtherType.CreateDeserializable, CacheHelper.DCache);
+ Serializable.RegisterTypeGeneric(OtherType2.CreateDeserializable, CacheHelper.DCache);
+ Serializable.RegisterTypeGeneric(OtherType22.CreateDeserializable, CacheHelper.DCache);
+ Serializable.RegisterTypeGeneric(OtherType4.CreateDeserializable, CacheHelper.DCache);
+ Serializable.RegisterTypeGeneric(OtherType42.CreateDeserializable, CacheHelper.DCache);
+ Serializable.RegisterTypeGeneric(OtherType43.CreateDeserializable, CacheHelper.DCache);
}
public void DoNPuts(int n)
{
try
{
- Serializable.RegisterTypeGeneric(OtherType.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(OtherType.CreateDeserializable, CacheHelper.DCache);
Assert.Fail("Expected exception in registering the type again.");
}
catch (IllegalStateException ex)
@@ -126,7 +126,7 @@ namespace Apache.Geode.Client.UnitTests
{
try
{
- Serializable.RegisterTypeGeneric(OtherType.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(OtherType.CreateDeserializable, CacheHelper.DCache);
Assert.Fail("Expected exception in registering the type again.");
}
catch (IllegalStateException ex)
@@ -429,10 +429,11 @@ namespace Apache.Geode.Client.UnitTests
public static IGeodeSerializable Duplicate(IGeodeSerializable orig)
{
- DataOutput dout = new DataOutput();
+ DataOutput dout = CacheHelper.DCache.CreateDataOutput();
orig.ToData(dout);
- DataInput din = new DataInput(dout.GetBuffer());
+ //DataInput din = new DataInput(dout.GetBuffer());
+ DataInput din = CacheHelper.DCache.CreateDataInput(dout.GetBuffer());
IGeodeSerializable dup = (IGeodeSerializable)din.ReadObject();
return dup;
}
@@ -577,10 +578,10 @@ namespace Apache.Geode.Client.UnitTests
public static IGeodeSerializable Duplicate(IGeodeSerializable orig)
{
- DataOutput dout = new DataOutput();
+ DataOutput dout = CacheHelper.DCache.CreateDataOutput();
orig.ToData(dout);
- DataInput din = new DataInput(dout.GetBuffer());
+ DataInput din = CacheHelper.DCache.CreateDataInput(dout.GetBuffer());
IGeodeSerializable dup = (IGeodeSerializable)din.ReadObject();
return dup;
}
@@ -726,10 +727,10 @@ namespace Apache.Geode.Client.UnitTests
public static IGeodeSerializable Duplicate(IGeodeSerializable orig)
{
- DataOutput dout = new DataOutput();
+ DataOutput dout = CacheHelper.DCache.CreateDataOutput();
orig.ToData(dout);
- DataInput din = new DataInput(dout.GetBuffer());
+ DataInput din = CacheHelper.DCache.CreateDataInput(dout.GetBuffer());
IGeodeSerializable dup = (IGeodeSerializable)din.ReadObject();
return dup;
}
@@ -874,10 +875,10 @@ namespace Apache.Geode.Client.UnitTests
public static IGeodeSerializable Duplicate(IGeodeSerializable orig)
{
- DataOutput dout = new DataOutput();
+ DataOutput dout = CacheHelper.DCache.CreateDataOutput();
orig.ToData(dout);
- DataInput din = new DataInput(dout.GetBuffer());
+ DataInput din = CacheHelper.DCache.CreateDataInput(dout.GetBuffer());
IGeodeSerializable dup = (IGeodeSerializable)din.ReadObject();
return dup;
}
@@ -1023,10 +1024,10 @@ namespace Apache.Geode.Client.UnitTests
public static IGeodeSerializable Duplicate(IGeodeSerializable orig)
{
- DataOutput dout = new DataOutput();
+ DataOutput dout = CacheHelper.DCache.CreateDataOutput();
orig.ToData(dout);
- DataInput din = new DataInput(dout.GetBuffer());
+ DataInput din = CacheHelper.DCache.CreateDataInput(dout.GetBuffer());
IGeodeSerializable dup = (IGeodeSerializable)din.ReadObject();
return dup;
}
@@ -1172,10 +1173,10 @@ namespace Apache.Geode.Client.UnitTests
public static IGeodeSerializable Duplicate(IGeodeSerializable orig)
{
- DataOutput dout = new DataOutput();
+ DataOutput dout = CacheHelper.DCache.CreateDataOutput();
orig.ToData(dout);
- DataInput din = new DataInput(dout.GetBuffer());
+ DataInput din = CacheHelper.DCache.CreateDataInput(dout.GetBuffer());
IGeodeSerializable dup = (IGeodeSerializable)din.ReadObject();
return dup;
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/ThinClientAppDomainFunctionExecutionTests.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/ThinClientAppDomainFunctionExecutionTests.cs b/src/clicache/integration-test/ThinClientAppDomainFunctionExecutionTests.cs
index c238118..0d9129c 100644
--- a/src/clicache/integration-test/ThinClientAppDomainFunctionExecutionTests.cs
+++ b/src/clicache/integration-test/ThinClientAppDomainFunctionExecutionTests.cs
@@ -181,7 +181,7 @@ namespace Apache.Geode.Client.UnitTests
Boolean getResult = true;
//test data independant function execution with result onServer
- Pool/*<TKey, TValue>*/ pool = PoolManager/*<TKey, TValue>*/.Find(poolName);
+ Pool/*<TKey, TValue>*/ pool = CacheHelper.DCache.GetPoolManager().Find(poolName);
Apache.Geode.Client.Execution<object> exc = FunctionService<object>.OnServer(pool);
Assert.IsTrue(exc != null, "onServer Returned NULL");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/ThinClientAppDomainQueryTests.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/ThinClientAppDomainQueryTests.cs b/src/clicache/integration-test/ThinClientAppDomainQueryTests.cs
index 63ba85a..90aabf7 100644
--- a/src/clicache/integration-test/ThinClientAppDomainQueryTests.cs
+++ b/src/clicache/integration-test/ThinClientAppDomainQueryTests.cs
@@ -72,8 +72,8 @@ namespace Apache.Geode.Client.UnitTests
public void InitClient()
{
- Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable);
- Serializable.RegisterTypeGeneric(Position.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable, CacheHelper.DCache);
+ Serializable.RegisterTypeGeneric(Position.CreateDeserializable, CacheHelper.DCache);
Serializable.RegisterPdxType(Apache.Geode.Client.Tests.PortfolioPdx.CreateDeserializable);
Serializable.RegisterPdxType(Apache.Geode.Client.Tests.PositionPdx.CreateDeserializable);
}
@@ -102,7 +102,7 @@ namespace Apache.Geode.Client.UnitTests
IRegion<object, object> region2 = CacheHelper.GetRegion<object, object>(QueryRegionNames[2]);
IRegion<object, object> region3 = CacheHelper.GetRegion<object, object>(QueryRegionNames[3]);
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
Util.Log("SetSize {0}, NumSets {1}.", qh.PortfolioSetSize,
qh.PortfolioNumSets);
@@ -122,9 +122,9 @@ namespace Apache.Geode.Client.UnitTests
{
bool ErrorOccurred = false;
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
- QueryService<object, object> qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ QueryService<object, object> qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
int qryIdx = 0;
@@ -202,9 +202,9 @@ namespace Apache.Geode.Client.UnitTests
{
bool ErrorOccurred = false;
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
- QueryService<object, object> qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ QueryService<object, object> qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
int qryIdx = 0;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/ThinClientCallbackArgN.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/ThinClientCallbackArgN.cs b/src/clicache/integration-test/ThinClientCallbackArgN.cs
index e62d2a0..8d8ff5b 100644
--- a/src/clicache/integration-test/ThinClientCallbackArgN.cs
+++ b/src/clicache/integration-test/ThinClientCallbackArgN.cs
@@ -342,8 +342,8 @@ namespace Apache.Geode.Client.UnitTests
m_isSet = true;
m_callbackarg = new Portfolio(1, 1);
//TODO:;split
- Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable);
- Serializable.RegisterTypeGeneric(Position.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable, CacheHelper.DCache);
+ Serializable.RegisterTypeGeneric(Position.CreateDeserializable, CacheHelper.DCache);
}
}
@@ -455,7 +455,7 @@ namespace Apache.Geode.Client.UnitTests
{
if (!isRegistered)
{
- Serializable.RegisterTypeGeneric(DefaultType.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(DefaultType.CreateDeserializable, CacheHelper.DCache);
isRegistered = true;
}
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/ThinClientCqIRTestsN.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/ThinClientCqIRTestsN.cs b/src/clicache/integration-test/ThinClientCqIRTestsN.cs
index 6df4e7a..ea90850 100644
--- a/src/clicache/integration-test/ThinClientCqIRTestsN.cs
+++ b/src/clicache/integration-test/ThinClientCqIRTestsN.cs
@@ -73,8 +73,8 @@ namespace Apache.Geode.Client.UnitTests
CacheHelper.Init();
try
{
- Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable);
- Serializable.RegisterTypeGeneric(Position.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable, CacheHelper.DCache);
+ Serializable.RegisterTypeGeneric(Position.CreateDeserializable, CacheHelper.DCache);
}
catch (IllegalStateException)
{
@@ -105,7 +105,7 @@ namespace Apache.Geode.Client.UnitTests
IRegion<object, object> region2 = CacheHelper.GetRegion<object, object>(QueryRegionNames[2]);
IRegion<object, object> region3 = CacheHelper.GetRegion<object, object>(QueryRegionNames[3]);
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
Util.Log("SetSize {0}, NumSets {1}.", qh.PortfolioSetSize,
qh.PortfolioNumSets);
@@ -126,7 +126,7 @@ namespace Apache.Geode.Client.UnitTests
IRegion<object, object> region0 = CacheHelper.GetRegion<object, object>(QueryRegionNames[0]);
IRegion<object, object> subRegion0 = region0.GetSubRegion(QueryRegionNames[1]);
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
qh.PopulatePortfolioData(region0, 100, 20, 100);
qh.PopulatePositionData(subRegion0, 100, 20);
@@ -149,7 +149,7 @@ namespace Apache.Geode.Client.UnitTests
region["4"] = p4;
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
CqAttributesFactory<object, object> cqFac = new CqAttributesFactory<object, object>();
ICqListener<object, object> cqLstner = new MyCqListener<object, object>();
cqFac.AddCqListener(cqLstner);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/ThinClientCqTestsN.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/ThinClientCqTestsN.cs b/src/clicache/integration-test/ThinClientCqTestsN.cs
index 6b5cf6e..2dd8118 100644
--- a/src/clicache/integration-test/ThinClientCqTestsN.cs
+++ b/src/clicache/integration-test/ThinClientCqTestsN.cs
@@ -298,8 +298,8 @@ namespace Apache.Geode.Client.UnitTests
CacheHelper.Init();
try
{
- Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable);
- Serializable.RegisterTypeGeneric(Position.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable, CacheHelper.DCache);
+ Serializable.RegisterTypeGeneric(Position.CreateDeserializable, CacheHelper.DCache);
}
catch (IllegalStateException)
{
@@ -331,7 +331,7 @@ namespace Apache.Geode.Client.UnitTests
IRegion<object, object> region2 = CacheHelper.GetRegion<object, object>(QueryRegionNames[2]);
IRegion<object, object> region3 = CacheHelper.GetRegion<object, object>(QueryRegionNames[3]);
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
Util.Log("Object type is pdx = " + m_usePdxObjects);
Util.Log("SetSize {0}, NumSets {1}.", qh.PortfolioSetSize,
@@ -372,7 +372,7 @@ namespace Apache.Geode.Client.UnitTests
IRegion<object, object> region0 = CacheHelper.GetRegion<object, object>(QueryRegionNames[0]);
IRegion<object, object> subRegion0 = region0.GetSubRegion(QueryRegionNames[1]);
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
qh.PopulatePortfolioData(region0, 100, 20, 100);
qh.PopulatePositionData(subRegion0, 100, 20);
@@ -395,7 +395,7 @@ namespace Apache.Geode.Client.UnitTests
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
CqAttributesFactory<object, object> cqFac = new CqAttributesFactory<object, object>();
ICqListener<object, object> cqLstner = new MyCqListener<object, object>();
cqFac.AddCqListener(cqLstner);
@@ -456,7 +456,7 @@ namespace Apache.Geode.Client.UnitTests
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
CqAttributesFactory<object, object> cqFac = new CqAttributesFactory<object, object>();
ICqListener<object, object> cqLstner = new MyCqListener<object, object>();
cqFac.AddCqListener(cqLstner);
@@ -618,7 +618,7 @@ namespace Apache.Geode.Client.UnitTests
QueryService<object, object> qs = null;
- qs = PoolManager.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
CqAttributesFactory<object, object> cqFac = new CqAttributesFactory<object, object>();
ICqListener<object, object> cqLstner = new MyCqListener<object, object>();
@@ -733,7 +733,7 @@ namespace Apache.Geode.Client.UnitTests
public void CreateAndExecuteCQ_StatusListener(string poolName, string cqName, string cqQuery, int id)
{
QueryService<object, object> qs = null;
- qs = PoolManager.Find(poolName).GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find(poolName).GetQueryService<object, object>();
CqAttributesFactory<object, object> cqFac = new CqAttributesFactory<object, object>();
cqFac.AddCqListener(new MyCqStatusListener<object, object>(id));
CqAttributes<object, object> cqAttr = cqFac.Create();
@@ -745,7 +745,7 @@ namespace Apache.Geode.Client.UnitTests
public void CreateAndExecuteCQ_Listener(string poolName, string cqName, string cqQuery, int id)
{
QueryService<object, object> qs = null;
- qs = PoolManager.Find(poolName).GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find(poolName).GetQueryService<object, object>();
CqAttributesFactory<object, object> cqFac = new CqAttributesFactory<object, object>();
cqFac.AddCqListener(new MyCqListener<object, object>(/*id*/));
CqAttributes<object, object> cqAttr = cqFac.Create();
@@ -757,7 +757,7 @@ namespace Apache.Geode.Client.UnitTests
public void CheckCQStatusOnConnect(string poolName, string cqName, int onCqStatusConnect)
{
QueryService<object, object> qs = null;
- qs = PoolManager.Find(poolName).GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find(poolName).GetQueryService<object, object>();
CqQuery<object, object> query = qs.GetCq(cqName);
CqAttributes<object, object> cqAttr = query.GetCqAttributes();
ICqListener<object, object>[] vl = cqAttr.getCqListeners();
@@ -769,7 +769,7 @@ namespace Apache.Geode.Client.UnitTests
public void CheckCQStatusOnDisConnect(string poolName, string cqName, int onCqStatusDisConnect)
{
QueryService<object, object> qs = null;
- qs = PoolManager.Find(poolName).GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find(poolName).GetQueryService<object, object>();
CqQuery<object, object> query = qs.GetCq(cqName);
CqAttributes<object, object> cqAttr = query.GetCqAttributes();
ICqListener<object, object>[] vl = cqAttr.getCqListeners();
@@ -790,7 +790,7 @@ namespace Apache.Geode.Client.UnitTests
public void CheckCQStatusOnPutEvent(string poolName, string cqName, int onCreateCount)
{
QueryService<object, object> qs = null;
- qs = PoolManager.Find(poolName).GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find(poolName).GetQueryService<object, object>();
CqQuery<object, object> query = qs.GetCq(cqName);
CqAttributes<object, object> cqAttr = query.GetCqAttributes();
ICqListener<object, object>[] vl = cqAttr.getCqListeners();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/ThinClientDeltaTestN.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/ThinClientDeltaTestN.cs b/src/clicache/integration-test/ThinClientDeltaTestN.cs
index c4530f6..a7ee6b3 100644
--- a/src/clicache/integration-test/ThinClientDeltaTestN.cs
+++ b/src/clicache/integration-test/ThinClientDeltaTestN.cs
@@ -43,7 +43,7 @@ namespace Apache.Geode.Client.UnitTests
{
byte[] deltaValue = aCqEvent.getDeltaValue();
DeltaTestImpl newValue = new DeltaTestImpl();
- DataInput input = new DataInput(deltaValue);
+ DataInput input = CacheHelper.DCache.CreateDataInput(deltaValue);
newValue.FromDelta(input);
if (newValue.GetIntVar() == 5)
{
@@ -281,7 +281,7 @@ namespace Apache.Geode.Client.UnitTests
{
try
{
- Serializable.RegisterTypeGeneric(DeltaEx.create);
+ Serializable.RegisterTypeGeneric(DeltaEx.create, CacheHelper.DCache);
}
catch (IllegalStateException)
{
@@ -316,7 +316,7 @@ namespace Apache.Geode.Client.UnitTests
{
try
{
- Serializable.RegisterTypeGeneric(DeltaEx.create);
+ Serializable.RegisterTypeGeneric(DeltaEx.create, CacheHelper.DCache);
}
catch (IllegalStateException)
{
@@ -364,7 +364,7 @@ namespace Apache.Geode.Client.UnitTests
{
try
{
- Serializable.RegisterTypeGeneric(DeltaEx.create);
+ Serializable.RegisterTypeGeneric(DeltaEx.create, CacheHelper.DCache);
}
catch (IllegalStateException)
{
@@ -408,7 +408,7 @@ namespace Apache.Geode.Client.UnitTests
{
try
{
- Serializable.RegisterTypeGeneric(DeltaEx.create);
+ Serializable.RegisterTypeGeneric(DeltaEx.create, CacheHelper.DCache);
}
catch (IllegalStateException)
{
@@ -441,7 +441,7 @@ namespace Apache.Geode.Client.UnitTests
{
try
{
- Serializable.RegisterTypeGeneric(DeltaEx.create);
+ Serializable.RegisterTypeGeneric(DeltaEx.create, CacheHelper.DCache);
}
catch (IllegalStateException)
{
@@ -474,7 +474,7 @@ namespace Apache.Geode.Client.UnitTests
{
try
{
- Serializable.RegisterTypeGeneric(DeltaTestAD.Create);
+ Serializable.RegisterTypeGeneric(DeltaTestAD.Create, CacheHelper.DCache);
}
catch (IllegalStateException)
{
@@ -598,7 +598,7 @@ namespace Apache.Geode.Client.UnitTests
{
try
{
- Serializable.RegisterTypeGeneric(DeltaEx.create);
+ Serializable.RegisterTypeGeneric(DeltaEx.create, CacheHelper.DCache);
}
catch (IllegalStateException)
{
@@ -615,7 +615,7 @@ namespace Apache.Geode.Client.UnitTests
{
try
{
- Serializable.RegisterTypeGeneric(DeltaTestImpl.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(DeltaTestImpl.CreateDeserializable, CacheHelper.DCache);
}
catch (IllegalStateException)
{
@@ -637,7 +637,7 @@ namespace Apache.Geode.Client.UnitTests
void registerCq()
{
- Pool thePool = PoolManager.Find("__TEST_POOL1__");
+ Pool thePool = CacheHelper.DCache.GetPoolManager().Find("__TEST_POOL1__");
QueryService<object, DeltaTestImpl> cqService = null;
cqService = thePool.GetQueryService<object, DeltaTestImpl>();
CqAttributesFactory<object, DeltaTestImpl> attrFac = new CqAttributesFactory<object, DeltaTestImpl>();
[22/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/include/geode/Cache.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/Cache.hpp b/src/cppcache/include/geode/Cache.hpp
index 30332a6..b414d5e 100644
--- a/src/cppcache/include/geode/Cache.hpp
+++ b/src/cppcache/include/geode/Cache.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_CACHE_H_
-#define GEODE_CACHE_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -19,6 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+#pragma once
+
+#ifndef GEODE_CACHE_H_
+#define GEODE_CACHE_H_
+
+#include <string>
+
#include "geode_globals.hpp"
#include "geode_types.hpp"
#include "GeodeCache.hpp"
@@ -30,7 +33,8 @@
#include "RegionShortcut.hpp"
#include "RegionFactory.hpp"
#include "InternalCacheTransactionManager2PC.hpp"
-
+#include "statistics/StatisticsFactory.hpp"
+#include "geode/TypeRegistry.hpp"
/**
* @file
*/
@@ -39,6 +43,7 @@ namespace apache {
namespace geode {
namespace client {
+class PoolManager;
class CacheFactory;
class CacheRegionHelper;
class Pool;
@@ -84,7 +89,7 @@ class CPPCACHE_EXPORT Cache : public GeodeCache,
/** Returns the name of this cache.
* @return the string name of this cache
*/
- virtual const char* getName() const;
+ virtual const std::string& getName() const;
/**
* Indicates if this cache has been closed.
@@ -100,7 +105,7 @@ class CPPCACHE_EXPORT Cache : public GeodeCache,
* Returns the distributed system that this cache was
* {@link CacheFactory::createCacheFactory created} with.
*/
- virtual DistributedSystemPtr getDistributedSystem() const;
+ virtual DistributedSystem& getDistributedSystem() const;
/**
* Terminates this object cache and releases all the local resources.
@@ -211,6 +216,8 @@ class CPPCACHE_EXPORT Cache : public GeodeCache,
*/
virtual bool getPdxReadSerialized();
+ virtual TypeRegistry& getTypeRegistry();
+
/**
* Returns a factory that can create a {@link PdxInstance}.
* @param className the fully qualified class name that the PdxInstance will
@@ -221,6 +228,14 @@ class CPPCACHE_EXPORT Cache : public GeodeCache,
*/
virtual PdxInstanceFactoryPtr createPdxInstanceFactory(const char* className);
+ virtual statistics::StatisticsFactory* getStatisticsFactory() const;
+
+ virtual std::unique_ptr<DataInput> createDataInput(const uint8_t* m_buffer,
+ int32_t len) const;
+ virtual std::unique_ptr<DataOutput> createDataOutput() const;
+
+ virtual PoolManager& getPoolManager() const;
+
/**
* @brief destructor
*/
@@ -230,10 +245,11 @@ class CPPCACHE_EXPORT Cache : public GeodeCache,
/**
* @brief constructors
*/
- Cache(const char* name, DistributedSystemPtr sys, const char* id_data,
+ Cache(const std::string& name, PropertiesPtr dsProp,
bool ignorePdxUnreadFields, bool readPdxSerialized);
std::unique_ptr<CacheImpl> m_cacheImpl;
+ std::unique_ptr<TypeRegistry> m_typeRegistry;
protected:
Cache() = delete;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/include/geode/CacheFactory.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/CacheFactory.hpp b/src/cppcache/include/geode/CacheFactory.hpp
index 885b8d1..82dc9a9 100644
--- a/src/cppcache/include/geode/CacheFactory.hpp
+++ b/src/cppcache/include/geode/CacheFactory.hpp
@@ -30,8 +30,6 @@
* @file
*/
-#define DEFAULT_POOL_NAME "default_geodeClientPool"
-
namespace apache {
namespace geode {
namespace client {
@@ -45,7 +43,8 @@ class CppCacheLibrary;
* For the default values for the pool attributes see {@link PoolFactory}.
* To create additional {@link Pool}s see {@link PoolManager}
*/
-class CPPCACHE_EXPORT CacheFactory : public std::enable_shared_from_this<CacheFactory> {
+class CPPCACHE_EXPORT CacheFactory
+ : public std::enable_shared_from_this<CacheFactory> {
public:
/**
* To create the instance of {@link CacheFactory}
@@ -60,38 +59,6 @@ class CPPCACHE_EXPORT CacheFactory : public std::enable_shared_from_this<CacheFa
*/
CachePtr create();
- /**
- * Gets the instance of {@link Cache} produced by an
- * earlier call to {@link CacheFactory::create}.
- * @param system the <code>DistributedSystem</code> the cache was created
- * with.
- * @return the {@link Cache} associated with the specified system.
- * @throws CacheClosedException if a cache has not been created
- * or the created one is {@link Cache::isClosed closed}
- * @throws EntryNotFoundException if a cache with specified system not found
- */
- static CachePtr getInstance(const DistributedSystemPtr& system);
-
- /**
- * Gets the instance of {@link Cache} produced by an
- * earlier call to {@link CacheFactory::create}, even if it has been closed.
- * @param system the <code>DistributedSystem</code> the cache was created
- * with.
- * @return the {@link Cache} associated with the specified system.
- * @throws CacheClosedException if a cache has not been created
- * @throws EntryNotFoundException if a cache with specified system is not
- * found
- */
- static CachePtr getInstanceCloseOk(const DistributedSystemPtr& system);
-
- /**
- * Gets an arbitrary open instance of {@link Cache} produced by an
- * earlier call to {@link CacheFactory::create}.
- * @throws CacheClosedException if a cache has not been created
- * or the only created one is {@link Cache::isClosed closed}
- */
- static CachePtr getAnyInstance();
-
/** Returns the version of the cache implementation.
* For the 1.0 release of Geode, the string returned is <code>1.0</code>.
* @return the version of the cache implementation as a <code>String</code>
@@ -103,350 +70,46 @@ class CPPCACHE_EXPORT CacheFactory : public std::enable_shared_from_this<CacheFa
static const char* getProductDescription();
/**
- * Sets the free connection timeout for this pool.
- * If the pool has a max connections setting, operations will block
- * if all of the connections are in use. The free connection timeout
- * specifies how long those operations will block waiting for
- * a free connection before receiving
- * an {@link AllConnectionsInUseException}. If max connections
- * is not set this setting has no effect.
- * @see #setMaxConnections(int)
- * @param connectionTimeout is the connection timeout in milliseconds
- * @return a reference to <code>this</code>
- * @throws IllegalArgumentException if <code>connectionTimeout</code>
- * is less than or equal to <code>0</code>.
- */
- CacheFactoryPtr setFreeConnectionTimeout(int connectionTimeout);
- /**
- * Sets the load conditioning interval for this pool.
- * This interval controls how frequently the pool will check to see if
- * a connection to a given server should be moved to a different
- * server to improve the load balance.
- * <p>A value of <code>-1</code> disables load conditioning
- * @param loadConditioningInterval is the connection lifetime in milliseconds
- * @return a reference to <code>this</code>
- * @throws IllegalArgumentException if <code>connectionLifetime</code>
- * is less than <code>-1</code>.
- */
- CacheFactoryPtr setLoadConditioningInterval(int loadConditioningInterval);
- /**
- * Sets the socket buffer size for each connection made in this pool.
- * Large messages can be received and sent faster when this buffer is larger.
- * Larger buffers also optimize the rate at which servers can send events
- * for client subscriptions.
- * @param bufferSize is the size of the socket buffers used for reading and
- * writing on each connection in this pool.
- * @return a reference to <code>this</code>
- * @throws IllegalArgumentException if <code>bufferSize</code>
- * is less than or equal to <code>0</code>.
- */
- CacheFactoryPtr setSocketBufferSize(int bufferSize);
-
- /**
- * Sets the thread local connections policy for this pool.
- * If <code>true</code> then any time a thread goes to use a connection
- * from this pool it will check a thread local cache and see if it already
- * has a connection in it. If so it will use it. If not it will get one from
- * this pool and cache it in the thread local. This gets rid of thread
- * contention
- * for the connections but increases the number of connections the servers
- * see.
- * <p>If <code>false</code> then connections are returned to the pool as soon
- * as the operation being done with the connection completes. This allows
- * connections to be shared amonst multiple threads keeping the number of
- * connections down.
- * @param threadLocalConnections if <code>true</code> then enable thread local
- * connections.
- * @return a reference to <code>this</code>
- */
- CacheFactoryPtr setThreadLocalConnections(bool threadLocalConnections);
-
- /**
- * Sets the number of milliseconds to wait for a response from a server before
- * timing out the operation and trying another server (if any are available).
- * @param timeout is the number of milliseconds to wait for a response from a
- * server
- * @return a reference to <code>this</code>
- * @throws IllegalArgumentException if <code>timeout</code>
- * is less than or equal to <code>0</code>.
- */
- CacheFactoryPtr setReadTimeout(int timeout);
-
- /**
- * Sets the minimum number of connections to keep available at all times.
- * When the pool is created, it will create this many connections.
- * If <code>0</code> then connections will not be made until an actual
- * operation
- * is done that requires client-to-server communication.
- * @param minConnections is the initial number of connections
- * this pool will create.
- * @return a reference to <code>this</code>
- * @throws IllegalArgumentException if <code>minConnections</code>
- * is less than <code>0</code>.
- */
- CacheFactoryPtr setMinConnections(int minConnections);
-
- /**
- * Sets the max number of client to server connections that the pool will
- * create. If all of
- * the connections are in use, an operation requiring a client to server
- * connection
- * will block until a connection is available.
- * @see #setFreeConnectionTimeout(int)
- * @param maxConnections is the maximum number of connections in the pool.
- * <code>-1</code> indicates that there is no maximum number of connections
- * @return a reference to <code>this</code>
- * @throws IllegalArgumentException if <code>maxConnections</code>
- * is less than <code>minConnections</code>.
- */
- CacheFactoryPtr setMaxConnections(int maxConnections);
-
- /**
- * Sets the amount of time a connection can be idle before expiring the
- * connection.
- * If the pool size is greater than the minimum specified by
- * {@link PoolFactory#setMinConnections(int)}, connections which have been
- * idle
- * for longer than the idleTimeout will be closed.
- * @param idleTimeout is the amount of time in milliseconds that an idle
- * connection
- * should live before expiring. -1 indicates that connections should never
- * expire.
- * @return a reference to <code>this</code>
- * @throws IllegalArgumentException if <code>idleTimout</code>
- * is less than <code>0</code>.
- */
- CacheFactoryPtr setIdleTimeout(long idleTimeout);
-
- /**
- * Set the number of times to retry a request after timeout/exception.
- * @param retryAttempts is the number of times to retry a request
- * after timeout/exception. -1 indicates that a request should be
- * tried against every available server before failing
- * @return a reference to <code>this</code>
- * @throws IllegalArgumentException if <code>idleTimout</code>
- * is less than <code>0</code>.
- */
- CacheFactoryPtr setRetryAttempts(int retryAttempts);
-
- /**
- * The frequency with which servers must be pinged to verify that they are
- * still alive.
- * Each server will be sent a ping every <code>pingInterval</code> if there
- * has not
- * been any other communication with the server.
+ * Control whether pdx ignores fields that were unread during deserialization.
+ * The default is to preserve unread fields be including their data during
+ * serialization.
+ * But if you configure the cache to ignore unread fields then their data will
+ * be lost
+ * during serialization.
+ * <P>You should only set this attribute to <code>true</code> if you know this
+ * member
+ * will only be reading cache data. In this use case you do not need to pay
+ * the cost of preserving the unread fields since you will never be
+ * reserializing pdx data.
*
- * These pings are used by the server to monitor the health of
- * the client. Make sure that the <code>pingInterval</code> is less than the
- * maximum time between pings allowed by the bridge server.
- * @param pingInterval is the amount of time in milliseconds between
- * pings.
- * @return a reference to <code>this</code>
- * @throws IllegalArgumentException if <code>pingInterval</code>
- * is less than <code>0</code>.
- */
- CacheFactoryPtr setPingInterval(long pingInterval);
-
- /**
- * The frequency with which client updates the locator list. To disable this
- * set its
- * value to 0.
- * @param updateLocatorListInterval is the amount of time in milliseconds
- * between
- * checking locator list at locator.
- */
- CacheFactoryPtr setUpdateLocatorListInterval(long updateLocatorListInterval);
-
- /**
- * The frequency with which the client statistics must be sent to the server.
- * Doing this allows <code>GFMon</code> to monitor clients.
- * <p>A value of <code>-1</code> disables the sending of client statistics
- * to the server.
+ * @param ignore <code>true</code> if fields not read during pdx
+ * deserialization should be ignored;
+ * <code>false</code>, the default, if they should be preserved.
*
- * @param statisticInterval is the amount of time in milliseconds between
- * sends of client statistics to the server.
- * @return a reference to <code>this</code>
- * @throws IllegalArgumentException if <code>statisticInterval</code>
- * is less than <code>-1</code>.
- */
- CacheFactoryPtr setStatisticInterval(int statisticInterval);
-
- /**
- * Configures the group which contains all the servers that this pool connects
- * to.
- * @param group is the server group that this pool will connect to.
- * If the value is <code>null</code> or <code>""</code> then the pool connects
- * to all servers.
- * @return a reference to <code>this</code>
- */
- CacheFactoryPtr setServerGroup(const char* group);
-
- /**
- * Adds a locator, given its host and port, to this factory.
- * The locator must be a server locator and will be used to discover other
- * running
- * bridge servers and locators.
- * @param host is the host name or ip address that the locator is listening
- * on.
- * @param port is the port that the locator is listening on.
- * @return a reference to <code>this</code>
- * @throws IllegalArgumentException if the <code>host</code> is an unknown
- * host
- * according to {@link java.net.InetAddress#getByName} or if the port is
- * outside
- * the valid range of [1..65535] inclusive.
- * @throws IllegalStateException if the locator has already been {@link
- * #addServer added} to this factory.
- */
- CacheFactoryPtr addLocator(const char* host, int port);
-
- /**
- * Adds a server, given its host and port, to this factory.
- * The server must be a bridge server and this client will
- * directly connect to the server without consulting a server locator.
- * @param host is the host name or ip address that the server is listening on.
- * @param port is the port that the server is listening on.
- * @return a reference to <code>this</code>
- * @throws IllegalArgumentException if the <code>host</code> is an unknown
- * host
- * according to {@link java.net.InetAddress#getByName} or if the port is
- * outside
- * the valid range of [1..65535] inclusive.
- * @throws IllegalStateException if the server has already been {@link
- * #addLocator added} to this factory.
- */
- CacheFactoryPtr addServer(const char* host, int port);
-
- /**
- * If set to <code>true</code> then the created pool will have
- * server-to-client
- * subscriptions enabled.
- * If set to <code>false</code> then all <code>Subscription*</code> attributes
- * are ignored at the time of creation.
- * @return a reference to <code>this</code>
- */
- CacheFactoryPtr setSubscriptionEnabled(bool enabled);
- /**
- * Sets the redundancy level for this pools server-to-client subscriptions.
- * If <code>0</code> then no redundant copies are kept on the servers.
- * Otherwise an effort is made to maintain the requested number of
- * copies of the server-to-client subscriptions. At most, one copy per server
- * is
- * made up to the requested level.
- * @param redundancy is the number of redundant servers for this client's
- * subscriptions.
- * @return a reference to <code>this</code>
- * @throws IllegalArgumentException if <code>redundancyLevel</code>
- * is less than <code>-1</code>.
- */
- CacheFactoryPtr setSubscriptionRedundancy(int redundancy);
- /**
- * Sets the messageTrackingTimeout attribute which is the time-to-live period,
- * in
- * milliseconds, for subscription events the client has received from the
- * server. It is used
- * to minimize duplicate events.
- * Entries that have not been modified for this amount of time
- * are expired from the list.
- * @param messageTrackingTimeout is the number of milliseconds to set the
- * timeout to.
- * @return a reference to <code>this</code>
- * @throws IllegalArgumentException if <code>messageTrackingTimeout</code>
- * is less than or equal to <code>0</code>.
- */
- CacheFactoryPtr setSubscriptionMessageTrackingTimeout(
- int messageTrackingTimeout);
-
- /**
- * Sets the is the interval in milliseconds
- * to wait before sending acknowledgements to the bridge server for
- * events received from the server subscriptions.
*
- * @param ackInterval is the number of milliseconds to wait before sending
- * event
- * acknowledgements.
- * @return a reference to <code>this</code>
- * @throws IllegalArgumentException if <code>ackInterval</code>
- * is less than or equal to <code>0</code>.
- */
- CacheFactoryPtr setSubscriptionAckInterval(int ackInterval);
-
- /**
- * Sets whether Pool is in multi user secure mode.
- * If its in multiuser mode then app needs to get RegionService instance of
- * Cache, to do the operations on cache.
- * Deafult value is false.
- * @param multiuserAuthentication
- * to set the pool in multiuser mode.
- * @return a reference to <code>this</code>
+ * @return this CacheFactory
+ * @since 3.6
*/
- CacheFactoryPtr setMultiuserAuthentication(bool multiuserAuthentication);
-
- /**
- * By default setPRSingleHopEnabled is true<br>
- * The client is aware of location of partitions on servers hosting
- * {@link Region}s.
- * Using this information, the client routes the client cache operations
- * directly to the server which is hosting the required partition for the
- * cache operation.
- * If setPRSingleHopEnabled is false the client can do an extra hop on servers
- * to go to the required partition for that cache operation.
- * The setPRSingleHopEnabled avoids extra hops only for following cache
- * operations:<br>
- * 1. {@link Region#put(Object, Object)}<br>
- * 2. {@link Region#get(Object)}<br>
- * 3. {@link Region#destroy(Object)}<br>
- * 4. {@link Region#getAll(Object, object)}<br>
- * If true, works best when {@link PoolFactory#setMaxConnections(int)} is set
- * to -1.
- * @param name is boolean whether PR Single Hop optimization is enabled or
- * not.
- * @return a reference to <code>this</code>
- */
- CacheFactoryPtr setPRSingleHopEnabled(bool enabled);
-
- /**
- * Control whether pdx ignores fields that were unread during deserialization.
- * The default is to preserve unread fields be including their data during
- * serialization.
- * But if you configure the cache to ignore unread fields then their data will
- * be lost
- * during serialization.
- * <P>You should only set this attribute to <code>true</code> if you know this
- * member
- * will only be reading cache data. In this use case you do not need to pay the
- * cost
- * of preserving the unread fields since you will never be reserializing pdx
- * data.
- *
- * @param ignore <code>true</code> if fields not read during pdx
- * deserialization should be ignored;
- * <code>false</code>, the default, if they should be preserved.
- *
- *
- * @return this CacheFactory
- * @since 3.6
- */
CacheFactoryPtr setPdxIgnoreUnreadFields(bool ignore);
/** Sets the object preference to PdxInstance type.
- * When a cached object that was serialized as a PDX is read
- * from the cache a {@link PdxInstance} will be returned instead of the actual
- * domain class.
- * The PdxInstance is an interface that provides run time access to
- * the fields of a PDX without deserializing the entire PDX.
- * The PdxInstance implementation is a light weight wrapper
- * that simply refers to the raw bytes of the PDX that are kept
- * in the cache. Using this method applications can choose to
- * access PdxInstance instead of C++ object.
- * <p>Note that a PdxInstance is only returned if a serialized PDX is found in
- * the cache.
- * If the cache contains a deserialized PDX, then a domain class instance is
- * returned instead of a PdxInstance.
- *
- * @param pdxReadSerialized true to prefer PdxInstance
- * @return this ClientCacheFactory
- */
+ * When a cached object that was serialized as a PDX is read
+ * from the cache a {@link PdxInstance} will be returned instead of the actual
+ * domain class.
+ * The PdxInstance is an interface that provides run time access to
+ * the fields of a PDX without deserializing the entire PDX.
+ * The PdxInstance implementation is a light weight wrapper
+ * that simply refers to the raw bytes of the PDX that are kept
+ * in the cache. Using this method applications can choose to
+ * access PdxInstance instead of C++ object.
+ * <p>Note that a PdxInstance is only returned if a serialized PDX is found in
+ * the cache.
+ * If the cache contains a deserialized PDX, then a domain class instance is
+ * returned instead of a PdxInstance.
+ *
+ * @param pdxReadSerialized true to prefer PdxInstance
+ * @return this ClientCacheFactory
+ */
CacheFactoryPtr setPdxReadSerialized(bool pdxReadSerialized);
/**
@@ -459,20 +122,16 @@ class CPPCACHE_EXPORT CacheFactory : public std::enable_shared_from_this<CacheFa
CacheFactoryPtr set(const char* name, const char* value);
private:
- PoolFactoryPtr pf;
PropertiesPtr dsProp;
bool ignorePdxUnreadFields;
bool pdxReadSerialized;
- PoolFactoryPtr getPoolFactory();
-
- CachePtr create(const char* name, DistributedSystemPtr system = nullptr,
- const char* cacheXml = 0,
+ CachePtr create(const char* name,
const CacheAttributesPtr& attrs = nullptr);
- static void create_(const char* name, DistributedSystemPtr& system,
- const char* id_data, CachePtr& cptr,
- bool ignorePdxUnreadFields, bool readPdxSerialized);
+ void create_(const char* name, const char* id_data,
+ CachePtr& cptr,
+ bool readPdxSerialized);
// no instances allowed
CacheFactory();
@@ -481,21 +140,6 @@ class CPPCACHE_EXPORT CacheFactory : public std::enable_shared_from_this<CacheFa
private:
~CacheFactory();
- PoolPtr determineDefaultPool(CachePtr cachePtr);
-
- static CachePtr getAnyInstance(bool throwException);
- static GfErrType basicGetInstance(const DistributedSystemPtr& system,
- bool closeOk, CachePtr& cptr);
-
- // Set very first time some creates cache
- // TODO shared_ptr - remove or refactor with global work
- static CacheFactoryPtr* default_CacheFactory;
- static PoolPtr createOrGetDefaultPool();
- static void* m_cacheMap;
- static void init();
- static void cleanup();
- static void handleXML(CachePtr& cachePtr, const char* cachexml,
- DistributedSystemPtr& system);
friend class CppCacheLibrary;
friend class RegionFactory;
friend class RegionXmlCreation;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/include/geode/CqOperation.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/CqOperation.hpp b/src/cppcache/include/geode/CqOperation.hpp
index b625ae6..a779de8 100644
--- a/src/cppcache/include/geode/CqOperation.hpp
+++ b/src/cppcache/include/geode/CqOperation.hpp
@@ -34,7 +34,6 @@ namespace client {
* Enumerated type for Operation actions.
*/
class CPPCACHE_EXPORT CqOperation {
- // public static methods
public:
// types of operation CORESPONDING TO THE ONES in geode.cache.Operation
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/include/geode/DataInput.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/DataInput.hpp b/src/cppcache/include/geode/DataInput.hpp
index 1976dde..61b768e 100644
--- a/src/cppcache/include/geode/DataInput.hpp
+++ b/src/cppcache/include/geode/DataInput.hpp
@@ -46,6 +46,9 @@ namespace client {
extern int gf_sprintf(char* buffer, const char* fmt, ...);
+class SerializationRegistry;
+class DataInputInternal;
+
/**
* Provide operations for reading primitive data values, byte arrays,
* strings, <code>Serializable</code> objects from a byte stream.
@@ -891,13 +894,6 @@ class CPPCACHE_EXPORT DataInput {
return decodedLen;
}
- /** constructor given a pre-allocated byte array with size */
- DataInput(const uint8_t* m_buffer, int32_t len)
- : m_buf(m_buffer),
- m_bufHead(m_buffer),
- m_bufLength(len),
- m_poolName(nullptr) {}
-
/** destructor */
~DataInput() {}
@@ -964,11 +960,25 @@ class CPPCACHE_EXPORT DataInput {
*/
void setPoolName(const char* poolName) { m_poolName = poolName; }
+ virtual const Cache* getCache();
+
+ protected:
+ /** constructor given a pre-allocated byte array with size */
+ DataInput(const uint8_t* m_buffer, int32_t len, const Cache* cache)
+ : m_buf(m_buffer),
+ m_bufHead(m_buffer),
+ m_bufLength(len),
+ m_poolName(nullptr),
+ m_cache(cache) {}
+
+ virtual const SerializationRegistry& getSerializationRegistry() const;
+
private:
const uint8_t* m_buf;
const uint8_t* m_bufHead;
int32_t m_bufLength;
const char* m_poolName;
+ const Cache* m_cache;
void readObjectInternal(SerializablePtr& ptr, int8_t typeId = -1);
@@ -1072,9 +1082,12 @@ class CPPCACHE_EXPORT DataInput {
}
// disable other constructors and assignment
- DataInput();
- DataInput(const DataInput&);
- DataInput& operator=(const DataInput&);
+ DataInput() = delete;
+ DataInput(const DataInput&) = delete;
+ DataInput& operator=(const DataInput&) = delete;
+
+ friend Cache;
+ friend DataInputInternal;
};
} // namespace client
} // namespace geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/include/geode/DataOutput.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/DataOutput.hpp b/src/cppcache/include/geode/DataOutput.hpp
index c087c4d..7c2aa84 100644
--- a/src/cppcache/include/geode/DataOutput.hpp
+++ b/src/cppcache/include/geode/DataOutput.hpp
@@ -37,7 +37,8 @@
namespace apache {
namespace geode {
namespace client {
-
+class SerializationRegistry;
+class DataOutputInternal;
/**
* C style memory allocation that throws OutOfMemoryException
* if it fails
@@ -74,11 +75,6 @@ namespace client {
class CPPCACHE_EXPORT DataOutput {
public:
/**
- * Construct a new DataOutput.
- */
- DataOutput();
-
- /**
* Write an unsigned byte to the <code>DataOutput</code>.
*
* @param value the unsigned byte to be written
@@ -724,10 +720,17 @@ class CPPCACHE_EXPORT DataOutput {
static void safeDelete(uint8_t* src) { GF_SAFE_DELETE(src); }
- static DataOutput* getDataOutput() { return new DataOutput(); }
- static void releaseDataOutput(DataOutput* dataOutput) {
- GF_SAFE_DELETE(dataOutput);
- }
+ virtual const Cache* getCache();
+
+ protected:
+ /**
+ * Construct a new DataOutput.
+ */
+ DataOutput(const Cache* cache);
+
+ DataOutput() : DataOutput(nullptr) {}
+
+ virtual const SerializationRegistry& getSerializationRegistry() const;
private:
void writeObjectInternal(const Serializable* ptr, bool isDelta = false);
@@ -747,6 +750,7 @@ class CPPCACHE_EXPORT DataOutput {
static uint32_t m_highWaterMark;
// flag to indicate we have a big buffer
volatile bool m_haveBigBuffer;
+ const Cache* m_cache;
inline static void getEncodedLength(const char val, int32_t& encodedLen) {
if ((val == 0) || (val & 0x80)) {
@@ -813,6 +817,9 @@ class CPPCACHE_EXPORT DataOutput {
// disable copy constructor and assignment
DataOutput(const DataOutput&);
DataOutput& operator=(const DataOutput&);
+
+ friend Cache;
+ friend DataOutputInternal;
};
} // namespace client
} // namespace geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/include/geode/Delta.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/Delta.hpp b/src/cppcache/include/geode/Delta.hpp
index c0c4285..8b9f8dc 100644
--- a/src/cppcache/include/geode/Delta.hpp
+++ b/src/cppcache/include/geode/Delta.hpp
@@ -91,6 +91,10 @@ class Delta {
virtual DeltaPtr clone();
virtual ~Delta() {}
+
+ protected:
+ Delta(Cache* cache);
+ Cache* m_cache;
};
} // namespace client
} // namespace geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/include/geode/DistributedSystem.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/DistributedSystem.hpp b/src/cppcache/include/geode/DistributedSystem.hpp
index c633616..b547e6e 100644
--- a/src/cppcache/include/geode/DistributedSystem.hpp
+++ b/src/cppcache/include/geode/DistributedSystem.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_DISTRIBUTEDSYSTEM_H_
-#define GEODE_DISTRIBUTEDSYSTEM_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,9 +15,15 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_DISTRIBUTEDSYSTEM_H_
+#define GEODE_DISTRIBUTEDSYSTEM_H_
+
/**
* @file
*/
+#include <memory>
#include "geode_globals.hpp"
#include "geode_types.hpp"
@@ -32,6 +33,11 @@
namespace apache {
namespace geode {
+
+namespace statistics {
+class StatisticsManager;
+} // namespace statistics
+
namespace client {
/**
* @class DistributedSystem DistributedSystem.hpp
@@ -56,44 +62,39 @@ class CPPCACHE_EXPORT DistributedSystem {
* Initializes the Native Client system to be able to connect to the
* Geode Java servers. If the name string is empty, then the default
* "NativeDS" is used as the name of distributed system.
- * @throws LicenseException if no valid license is found.
* @throws IllegalStateException if GFCPP variable is not set and
* product installation directory cannot be determined
- * @throws IllegalArgument exception if DS name is nullptr
- * @throws AlreadyConnectedException if this call has succeeded once before
- *for this process
**/
- static DistributedSystemPtr connect(const char* name,
- const PropertiesPtr& configPtr = nullptr);
+ static std::unique_ptr<DistributedSystem> create(
+ const std::string& name, Cache* cache,
+ const PropertiesPtr& configPtr = nullptr);
+
+ /**
+ * @brief connects from the distributed system
+ * @throws AlreadyConnectedException if this call has succeeded once before
+ */
+ void connect();
/**
- *@brief disconnect from the distributed system
- *@throws IllegalStateException if not connected
+ * @brief disconnect from the distributed system
+ * @throws IllegalStateException if not connected
*/
- static void disconnect();
+ void disconnect();
/** Returns the SystemProperties that were used to create this instance of the
* DistributedSystem
- * @return SystemProperties
+ * @return SystemProperties
*/
- static SystemProperties* getSystemProperties();
+ SystemProperties& getSystemProperties() const;
/** Returns the name that identifies the distributed system instance
* @return name
*/
- virtual const char* getName() const;
+ virtual const std::string& getName() const;
- /** Returns true if connected, false otherwise
- *
- * @return true if connected, false otherwise
- */
- static bool isConnected();
-
- /** Returns a pointer to the DistributedSystem instance
- *
- * @return instance
- */
- static DistributedSystemPtr getInstance();
+ statistics::StatisticsManager* getStatisticsManager() {
+ return m_statisticsManager.get();
+ }
/**
* @brief destructor
@@ -104,16 +105,20 @@ class CPPCACHE_EXPORT DistributedSystem {
/**
* @brief constructors
*/
- DistributedSystem(const char* name);
+ DistributedSystem(const std::string& name,
+ std::unique_ptr<statistics::StatisticsManager> statMngr,
+ std::unique_ptr<SystemProperties> sysProps);
private:
- char* m_name;
- static bool m_connected;
- static DistributedSystemPtr* m_instance_ptr;
- // static DistributedSystemImpl *m_impl;
+ std::string m_name;
+ bool m_connected;
+
+ std::unique_ptr<statistics::StatisticsManager> m_statisticsManager;
+
+ std::unique_ptr<SystemProperties> m_sysProps;
public:
- static DistributedSystemImpl* m_impl;
+ DistributedSystemImpl* m_impl;
friend class CacheRegionHelper;
friend class DistributedSystemImpl;
friend class TcrConnection;
@@ -121,6 +126,8 @@ class CPPCACHE_EXPORT DistributedSystem {
private:
DistributedSystem(const DistributedSystem&);
const DistributedSystem& operator=(const DistributedSystem&);
+
+ void logSystemInformation();
};
} // namespace client
} // namespace geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/include/geode/GeodeCache.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/GeodeCache.hpp b/src/cppcache/include/geode/GeodeCache.hpp
index 37ac98d..78c91de 100644
--- a/src/cppcache/include/geode/GeodeCache.hpp
+++ b/src/cppcache/include/geode/GeodeCache.hpp
@@ -32,6 +32,8 @@ namespace apache {
namespace geode {
namespace client {
+class DistributedSystem;
+
/**
* GeodeCache represents the singleton cache that must be created
* in order to connect to Geode server.
@@ -52,7 +54,7 @@ class CPPCACHE_EXPORT GeodeCache : public RegionService {
/** Returns the name of this cache.
* @return the string name of this cache
*/
- virtual const char* getName() const = 0;
+ virtual const std::string& getName() const = 0;
/**
* Initializes the cache from an xml file
@@ -63,10 +65,10 @@ class CPPCACHE_EXPORT GeodeCache : public RegionService {
virtual void initializeDeclarativeCache(const char* cacheXml) = 0;
/**
- * Returns the distributed system that this cache was
- * {@link CacheFactory::createCacheFactory created} with.
- */
- virtual DistributedSystemPtr getDistributedSystem() const = 0;
+ * Returns the distributed system that this cache was
+ * {@link CacheFactory::createCacheFactory created} with.
+ */
+ virtual DistributedSystem& getDistributedSystem() const = 0;
/**
* Returns whether Cache saves unread fields for Pdx types.
@@ -74,9 +76,9 @@ class CPPCACHE_EXPORT GeodeCache : public RegionService {
virtual bool getPdxIgnoreUnreadFields() = 0;
/**
- * Returns whether { @link PdxInstance} is preferred for PDX types instead of
- * C++ object.
- */
+ * Returns whether { @link PdxInstance} is preferred for PDX types instead of
+ * C++ object.
+ */
virtual bool getPdxReadSerialized() = 0;
};
} // namespace client
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/include/geode/PdxInstance.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/PdxInstance.hpp b/src/cppcache/include/geode/PdxInstance.hpp
index e5b8b53..3e92515 100644
--- a/src/cppcache/include/geode/PdxInstance.hpp
+++ b/src/cppcache/include/geode/PdxInstance.hpp
@@ -60,7 +60,7 @@ class CPPCACHE_EXPORT PdxInstance : public PdxSerializable {
* registered.
* @return the deserialized domain object.
*
- * @see Serializable::registerPdxType
+ * @see serializationRegistry->addPdxType
*/
virtual PdxSerializablePtr getObject() = 0;
@@ -83,7 +83,7 @@ class CPPCACHE_EXPORT PdxInstance : public PdxSerializable {
* For deserialization C++ Native Client requires the domain class to be
* registered.
*
- * @see Serializable::registerPdxType
+ * @see serializationRegistry->addPdxType
* @see PdxInstance#hasField
*/
virtual void getField(const char* fieldname, CacheablePtr& value) const = 0;
@@ -432,7 +432,7 @@ class CPPCACHE_EXPORT PdxInstance : public PdxSerializable {
* @param value value of the field to be set with CacheableObjectArrayPtr type.
* @throws IllegalStateException if PdxInstance doesn't has the named field.
*
- * @see Serializable::registerPdxType
+ * @see serializationRegistry->addPdxType
* @see PdxInstance#hasField
*/
virtual void getField(const char* fieldname,
@@ -476,7 +476,7 @@ class CPPCACHE_EXPORT PdxInstance : public PdxSerializable {
* @throws IllegalStateException if the field contains an element that is not
* of CacheableKey derived type.
*
- * @see Serializable::registerPdxType
+ * @see serializationRegistry->addPdxType
*/
virtual int32_t hashcode() const = 0;
@@ -489,7 +489,7 @@ class CPPCACHE_EXPORT PdxInstance : public PdxSerializable {
* For deserialization C++ Native Client requires the domain class to be
* registered.
*
- * @see Serializable::registerPdxType
+ * @see serializationRegistry->addPdxType
*/
virtual CacheableStringPtr toString() const = 0;
@@ -549,7 +549,7 @@ class CPPCACHE_EXPORT PdxInstance : public PdxSerializable {
* @throws IllegalStateException if the field contains an element that is not
* of CacheableKey derived type.
*
- * @see Serializable::registerPdxType
+ * @see serializationRegistry->addPdxType
*/
virtual bool operator==(const CacheableKey& other) const = 0;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/include/geode/PdxSerializable.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/PdxSerializable.hpp b/src/cppcache/include/geode/PdxSerializable.hpp
index e38abbc..eb096d0 100644
--- a/src/cppcache/include/geode/PdxSerializable.hpp
+++ b/src/cppcache/include/geode/PdxSerializable.hpp
@@ -26,8 +26,6 @@ namespace apache {
namespace geode {
namespace client {
-typedef PdxSerializable* (*PdxTypeFactoryMethod)();
-
class CPPCACHE_EXPORT PdxSerializable : public CacheableKey {
public:
PdxSerializable();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/include/geode/PdxWrapper.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/PdxWrapper.hpp b/src/cppcache/include/geode/PdxWrapper.hpp
index 4212328..594fb08 100644
--- a/src/cppcache/include/geode/PdxWrapper.hpp
+++ b/src/cppcache/include/geode/PdxWrapper.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_PDXWRAPPER_H_
-#define GEODE_PDXWRAPPER_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,6 +15,11 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_PDXWRAPPER_H_
+#define GEODE_PDXWRAPPER_H_
+
#include "PdxSerializer.hpp"
#include "PdxSerializable.hpp"
@@ -43,7 +43,8 @@ class CPPCACHE_EXPORT PdxWrapper : public PdxSerializable {
* @param className the fully qualified class name to map this user object to
* the Java side.
*/
- PdxWrapper(void* userObject, const char* className);
+ PdxWrapper(void* userObject, const char* className,
+ PdxSerializerPtr pdxSerializerPtr);
/**
* Returns the pointer to the user object which is deserialized with a
@@ -112,7 +113,7 @@ class CPPCACHE_EXPORT PdxWrapper : public PdxSerializable {
private:
/** hide default constructor */
PdxWrapper();
- PdxWrapper(const char* className);
+ PdxWrapper(const char* className, PdxSerializerPtr pdxSerializerPtr);
FRIEND_STD_SHARED_PTR(PdxWrapper)
@@ -122,7 +123,7 @@ class CPPCACHE_EXPORT PdxWrapper : public PdxSerializable {
UserObjectSizer m_sizer;
char* m_className;
- friend class SerializationRegistry;
+ // friend class SerializationRegistry;
PdxWrapper(const PdxWrapper&);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/include/geode/Pool.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/Pool.hpp b/src/cppcache/include/geode/Pool.hpp
index e3a0d7d..40ad247 100644
--- a/src/cppcache/include/geode/Pool.hpp
+++ b/src/cppcache/include/geode/Pool.hpp
@@ -114,10 +114,10 @@ class CPPCACHE_EXPORT Pool : public std::enable_shared_from_this<Pool> {
*/
int getRetryAttempts() const;
/**
- * Returns the true if a server-to-client subscriptions are enabled on this
- * pool.
- * @see PoolFactory#setSubscriptionEnabled
- */
+ * Returns the true if a server-to-client subscriptions are enabled on this
+ * pool.
+ * @see PoolFactory#setSubscriptionEnabled
+ */
bool getSubscriptionEnabled() const;
/**
* Returns the subscription redundancy level of this pool.
@@ -272,7 +272,8 @@ class CPPCACHE_EXPORT Pool : public std::enable_shared_from_this<Pool> {
* @returns Logical instance of cache to do operations on behalf of one
* particular user.
*/
- virtual RegionServicePtr createSecureUserCache(PropertiesPtr credentials);
+ virtual RegionServicePtr createSecureUserCache(PropertiesPtr credentials,
+ CacheImpl* cacheImpl);
Pool(const Pool&);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/include/geode/PoolFactory.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/PoolFactory.hpp b/src/cppcache/include/geode/PoolFactory.hpp
index 3d39009..5369f97 100644
--- a/src/cppcache/include/geode/PoolFactory.hpp
+++ b/src/cppcache/include/geode/PoolFactory.hpp
@@ -62,7 +62,7 @@ class PoolAttributes;
* </ul>
*
*/
-class CPPCACHE_EXPORT PoolFactory {
+class CPPCACHE_EXPORT PoolFactory {
public:
/**
* The default amount of time, in milliseconds, which we will wait for a free
@@ -180,7 +180,7 @@ class CPPCACHE_EXPORT PoolFactory {
* The default server group.
* <p>Current value: <code>""</code>.
*/
- static const char* DEFAULT_SERVER_GROUP;
+ static constexpr const char* DEFAULT_SERVER_GROUP = "";
/**
* Whether thread local connection is enabled.
* <p>Current value: <code>"false"</code>.
@@ -520,12 +520,14 @@ class CPPCACHE_EXPORT PoolFactory {
~PoolFactory();
private:
- PoolFactory();
+ PoolFactory(const Cache& cache);
PoolFactory(const PoolFactory&);
void addCheck(const char* host, int port);
PoolAttributesPtr m_attrs;
bool m_isSubscriptionRedundancy;
bool m_addedServerOrLocator;
+ const Cache& m_cache;
+
friend class Cache;
friend class PoolManager;
friend class CacheFactory;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/include/geode/PoolManager.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/PoolManager.hpp b/src/cppcache/include/geode/PoolManager.hpp
index 6b808ae..26dd85a 100644
--- a/src/cppcache/include/geode/PoolManager.hpp
+++ b/src/cppcache/include/geode/PoolManager.hpp
@@ -26,6 +26,7 @@
#include "geode_globals.hpp"
#include "geode_types.hpp"
+#include "Cache.hpp"
#include "Pool.hpp"
#include "PoolFactory.hpp"
#include "Region.hpp"
@@ -34,6 +35,7 @@ namespace apache {
namespace geode {
namespace client {
+class ThinClientPoolDM;
typedef std::unordered_map<std::string, PoolPtr> HashMapOfPools;
/**
@@ -49,12 +51,14 @@ typedef std::unordered_map<std::string, PoolPtr> HashMapOfPools;
*/
class CPPCACHE_EXPORT PoolManager {
public:
+ PoolManager(const Cache& cache);
+
/**
* Creates a new {@link PoolFactory pool factory},
* which is used to configure and create new {@link Pool}s.
* @return the new pool factory
*/
- static PoolFactoryPtr createFactory();
+ PoolFactoryPtr createFactory();
/**
* Returns a map containing all the pools in this manager.
@@ -66,7 +70,7 @@ class CPPCACHE_EXPORT PoolManager {
* @return a Map that is a snapshot of all the pools currently known to this
* manager.
*/
- static const HashMapOfPools& getAll();
+ const HashMapOfPools& getAll();
/**
* Find by name an existing connection pool returning
@@ -75,7 +79,7 @@ class CPPCACHE_EXPORT PoolManager {
* @return the existing connection pool or <code>nullptr</code> if it does not
* exist.
*/
- static PoolPtr find(const char* name);
+ PoolPtr find(const char* name);
/**
* Find the pool used by the given region.
@@ -84,7 +88,7 @@ class CPPCACHE_EXPORT PoolManager {
* region does
* not have a pool.
*/
- static PoolPtr find(RegionPtr region);
+ PoolPtr find(RegionPtr region);
/**
* Unconditionally destroys all created pools that are in this manager.
@@ -93,10 +97,24 @@ class CPPCACHE_EXPORT PoolManager {
* @see DistributedSystem#connect for a description of
* <code>durable-client-timeout</code>.
*/
- static void close(bool keepAlive = false);
+ void close(bool keepAlive = false);
private:
- PoolManager();
+ void removePool(const char* name);
+
+ void addPool(const char* name, const PoolPtr& pool);
+
+ PoolPtr getDefaultPool();
+
+ class Impl;
+ std::unique_ptr<Impl, void (*)(Impl*)> m_pimpl;
+
+ friend Cache;
+ friend CacheImpl;
+ friend RegionFactory;
+ friend PoolFactory;
+ friend ThinClientPoolDM;
+ friend FunctionService;
};
} // namespace client
} // namespace geode
[15/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientPoolAttrTest.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientPoolAttrTest.cpp b/src/cppcache/integration-test/testThinClientPoolAttrTest.cpp
index 283223e..c600969 100644
--- a/src/cppcache/integration-test/testThinClientPoolAttrTest.cpp
+++ b/src/cppcache/integration-test/testThinClientPoolAttrTest.cpp
@@ -71,7 +71,8 @@ class putThread : public ACE_Task_Base {
};
void doAttrTestingAndCreatePool(const char* poolName) {
- PoolFactoryPtr poolFacPtr = PoolManager::createFactory();
+ PoolFactoryPtr poolFacPtr =
+ getHelper()->getCache()->getPoolManager().createFactory();
poolFacPtr->setFreeConnectionTimeout(10000);
poolFacPtr->setLoadConditioningInterval(60000);
poolFacPtr->setSocketBufferSize(1024);
@@ -130,7 +131,7 @@ void doAttrTestingAndCreatePool(const char* poolName) {
void doAttrTesting(const char* poolName1) {
// PoolFactoryPtr poolFacPtr = cachePtr->getPoolFactory();
- PoolPtr pptr = PoolManager::find(poolName1);
+ PoolPtr pptr = getHelper()->getCache()->getPoolManager().find(poolName1);
// PoolPtr pptr = poolFacPtr->find(poolName1);
ASSERT(strcmp(pptr->getName(), "clientPool") == 0,
@@ -196,7 +197,8 @@ DUNIT_TASK(CLIENT1, StartC1)
doAttrTestingAndCreatePool(poolName);
// Do PoolCreation testing , create another pool with same name
- PoolFactoryPtr poolFacPtr = PoolManager::createFactory();
+ PoolFactoryPtr poolFacPtr =
+ getHelper()->getCache()->getPoolManager().createFactory();
try {
PoolPtr pptr = poolFacPtr->create(poolName);
FAIL("Pool creation with same name should fail");
@@ -224,7 +226,10 @@ DUNIT_TASK(CLIENT2, StartC2)
LOG(" starts client");
initClient(true, props);
LOG(" started client");
- ASSERT(PoolManager::find("clientPoolMultiUser")
+ ASSERT(getHelper()
+ ->getCache()
+ ->getPoolManager()
+ .find("clientPoolMultiUser")
->getMultiuserAuthentication() == true,
"MultiUser secure mode should be true for Pool");
} catch (const Exception& excp) {
@@ -247,7 +252,11 @@ DUNIT_TASK(CLIENT1, ClientOp)
getHelper()->getRegion(poolRegNames[0])->getAttributes()->getPoolName();
int level = TestUtils::getCacheImpl(getHelper()->cachePtr)
->getPoolSize(poolName.c_str());
- int min = PoolManager::find(poolName.c_str())->getMinConnections();
+ int min = getHelper()
+ ->getCache()
+ ->getPoolManager()
+ .find(poolName.c_str())
+ ->getMinConnections();
char logmsg[100] = {0};
sprintf(logmsg, "Pool level not equal to min level. Expected %d, actual %d",
min, level);
@@ -264,7 +273,11 @@ DUNIT_TASK(CLIENT1, ClientOp)
// Check current # connections they should be == max
level = TestUtils::getCacheImpl(getHelper()->cachePtr)
->getPoolSize(poolName.c_str());
- int max = PoolManager::find(poolName.c_str())->getMaxConnections();
+ int max = getHelper()
+ ->getCache()
+ ->getPoolManager()
+ .find(poolName.c_str())
+ ->getMaxConnections();
sprintf(logmsg, "Pool level not equal to max level. Expected %d, actual %d",
max, level);
ASSERT(level == max, logmsg);
@@ -280,7 +293,11 @@ DUNIT_TASK(CLIENT1, ClientOp)
level = TestUtils::getCacheImpl(getHelper()->cachePtr)
->getPoolSize(poolName.c_str());
- min = PoolManager::find(poolName.c_str())->getMinConnections();
+ min = getHelper()
+ ->getCache()
+ ->getPoolManager()
+ .find(poolName.c_str())
+ ->getMinConnections();
sprintf(logmsg,
"Pool level not equal to min level after idle timeout. "
"Expected %d, actual %d",
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientPoolExecuteFunction.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientPoolExecuteFunction.cpp b/src/cppcache/integration-test/testThinClientPoolExecuteFunction.cpp
index c6a90cb..fd187bb 100644
--- a/src/cppcache/integration-test/testThinClientPoolExecuteFunction.cpp
+++ b/src/cppcache/integration-test/testThinClientPoolExecuteFunction.cpp
@@ -245,8 +245,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, StartC1)
{
- initClientWithPool(true, nullptr, locHostPort, serverGroup, nullptr, 0,
- true);
+ initClientWithPool(true, poolRegNames[0], locHostPort, serverGroup, nullptr,
+ 0, true);
auto regPtr0 = createRegionAndAttachPool(poolRegNames[0], USE_ACK, nullptr);
regPtr0->registerAllKeys();
@@ -632,7 +632,6 @@ DUNIT_TASK_DEFINITION(CLIENT1, Client1OpTest)
// test data independant function
// test get function with result
getResult = true;
- // PoolPtr pptr = PoolManager::find(poolName);
args = routingObj;
// ExecutionPtr exc=nullptr;
// CacheableVectorPtr executeFunctionResult = nullptr;
@@ -694,7 +693,10 @@ DUNIT_TASK_DEFINITION(CLIENT1, Client1OpTest)
getResult = true;
try {
- Serializable::registerPdxType(
+ SerializationRegistryPtr serializationRegistry =
+ CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
+ ->getSerializationRegistry();
+ serializationRegistry->addPdxType(
PdxTests::PdxTypes8::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
@@ -1038,7 +1040,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, Client2OpTest)
LOGINFO("FETimeOut begin onRegion");
auto RexecutionPtr = FunctionService::onRegion(regPtr0);
auto fe = RexecutionPtr->withArgs(CacheableInt32::create(5000 * 1000))
- ->execute(FETimeOut, 5000)
+ ->execute(FETimeOut, 5000 * 1000)
->getResult();
if (fe == nullptr) {
ASSERT(false, "functionResult is nullptr");
@@ -1058,7 +1060,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, Client2OpTest)
LOGINFO("FETimeOut begin onServer");
auto serverExc = FunctionService::onServer(getHelper()->cachePtr);
auto vec = serverExc->withArgs(CacheableInt32::create(5000 * 1000))
- ->execute(FETimeOut, 5000)
+ ->execute(FETimeOut, 5000 * 1000)
->getResult();
if (vec == nullptr) {
ASSERT(false, "functionResult is nullptr");
@@ -1078,7 +1080,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, Client2OpTest)
LOGINFO("FETimeOut begin onServers");
auto serversExc = FunctionService::onServers(getHelper()->cachePtr);
auto vecs = serversExc->withArgs(CacheableInt32::create(5000 * 1000))
- ->execute(FETimeOut, 5000)
+ ->execute(FETimeOut, 5000 * 1000)
->getResult();
if (vecs == nullptr) {
ASSERT(false, "functionResult is nullptr");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientPoolExecuteFunctionDisableChunkHandlerThread.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientPoolExecuteFunctionDisableChunkHandlerThread.cpp b/src/cppcache/integration-test/testThinClientPoolExecuteFunctionDisableChunkHandlerThread.cpp
index f75c881..3fa4429 100644
--- a/src/cppcache/integration-test/testThinClientPoolExecuteFunctionDisableChunkHandlerThread.cpp
+++ b/src/cppcache/integration-test/testThinClientPoolExecuteFunctionDisableChunkHandlerThread.cpp
@@ -338,8 +338,8 @@ void verifyTimeoutFirst() {
LOGINFO("Total timeout %d", totalTimeoutCount);
- int blackListBucketTimeouts =
- TestUtils::getCacheImpl(getHelper()->cachePtr)->blackListBucketTimeouts();
+ int blackListBucketTimeouts = TestUtils::getCacheImpl(getHelper()->cachePtr)
+ ->getBlackListBucketTimeouts();
LOGINFO("blackListBucketTimeouts %d", blackListBucketTimeouts);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientPoolExecuteFunctionPrSHOP.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientPoolExecuteFunctionPrSHOP.cpp b/src/cppcache/integration-test/testThinClientPoolExecuteFunctionPrSHOP.cpp
index 307ec1b..43be8f6 100644
--- a/src/cppcache/integration-test/testThinClientPoolExecuteFunctionPrSHOP.cpp
+++ b/src/cppcache/integration-test/testThinClientPoolExecuteFunctionPrSHOP.cpp
@@ -21,6 +21,10 @@
#include "ThinClientHelper.hpp"
#include "testobject/VariousPdxTypes.hpp"
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
+
using namespace PdxTests;
/* This is to test
1- funtion execution on pool
@@ -235,8 +239,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, StartC1)
{
- initClientWithPool(true, nullptr, locHostPort, serverGroup, nullptr, 0,
- true, -1, -1, 60000, /*singlehop*/ true,
+ initClientWithPool(true, poolRegNames[0], locHostPort, serverGroup, nullptr,
+ 0, true, -1, -1, 60000, /*singlehop*/ true,
/*threadLocal*/ true);
auto regPtr0 = createRegionAndAttachPool(poolRegNames[0], USE_ACK, nullptr);
@@ -623,7 +627,6 @@ DUNIT_TASK_DEFINITION(CLIENT1, Client1OpTest)
// test data independant function
// test get function with result
getResult = true;
- // PoolPtr pptr = PoolManager::find(poolName);
args = routingObj;
// ExecutionPtr exc=nullptr;
// CacheableVectorPtr executeFunctionResult = nullptr;
@@ -685,7 +688,11 @@ DUNIT_TASK_DEFINITION(CLIENT1, Client1OpTest)
getResult = true;
try {
- Serializable::registerPdxType(
+ SerializationRegistryPtr serializationRegistry =
+ CacheRegionHelper::getCacheImpl(getHelper()->getCache().get())
+ ->getSerializationRegistry();
+
+ serializationRegistry->addPdxType(
PdxTests::PdxTypes8::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
@@ -1064,7 +1071,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, Client1OpTest)
LOGINFO("FETimeOut begin onRegion");
auto RexecutionPtr = FunctionService::onRegion(regPtr0);
auto fe = RexecutionPtr->withArgs(CacheableInt32::create(5000 * 1000))
- ->execute(FETimeOut, 5000)
+ ->execute(FETimeOut, 5000 * 1000)
->getResult();
if (fe == nullptr) {
ASSERT(false, "functionResult is nullptr");
@@ -1086,7 +1093,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, Client1OpTest)
LOGINFO("FETimeOut begin onServer");
auto serverExc = FunctionService::onServer(getHelper()->cachePtr);
auto vec = serverExc->withArgs(CacheableInt32::create(5000 * 1000))
- ->execute(FETimeOut, 5000)
+ ->execute(FETimeOut, 5000 * 1000)
->getResult();
if (vec == nullptr) {
ASSERT(false, "functionResult is nullptr");
@@ -1107,7 +1114,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, Client1OpTest)
LOGINFO("FETimeOut begin onServers");
auto serversExc = FunctionService::onServers(getHelper()->cachePtr);
auto vecs = serversExc->withArgs(CacheableInt32::create(5000 * 1000))
- ->execute(FETimeOut, 5000)
+ ->execute(FETimeOut, 5000 * 1000)
->getResult();
if (vecs == nullptr) {
ASSERT(false, "functionResult is nullptr");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientPoolExecuteFunctionThrowsException.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientPoolExecuteFunctionThrowsException.cpp b/src/cppcache/integration-test/testThinClientPoolExecuteFunctionThrowsException.cpp
index 64d5811..25cca23 100644
--- a/src/cppcache/integration-test/testThinClientPoolExecuteFunctionThrowsException.cpp
+++ b/src/cppcache/integration-test/testThinClientPoolExecuteFunctionThrowsException.cpp
@@ -188,8 +188,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, StartC1)
{
// initClient(true);
- initClientWithPool(true, nullptr, locHostPort, serverGroup, nullptr, 0,
- true, -1, -1, 60000, /*singlehop*/ true,
+ initClientWithPool(true, poolRegNames[0], locHostPort, serverGroup, nullptr,
+ 0, true, -1, -1, 60000, /*singlehop*/ true,
/*threadLocal*/ true);
// createPool(poolName, locHostPort,serverGroup, nullptr, 0, true );
// createRegionAndAttachPool(poolRegNames[0],USE_ACK, poolName);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientPoolExecuteHAFunction.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientPoolExecuteHAFunction.cpp b/src/cppcache/integration-test/testThinClientPoolExecuteHAFunction.cpp
index baf1703..5dee8b9 100644
--- a/src/cppcache/integration-test/testThinClientPoolExecuteHAFunction.cpp
+++ b/src/cppcache/integration-test/testThinClientPoolExecuteHAFunction.cpp
@@ -153,8 +153,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, StartC1)
{
- initClientWithPool(true, nullptr, locHostPort, serverGroup, nullptr, 0,
- true, -1, 5, 60000);
+ initClientWithPool(true, poolRegNames[0], locHostPort, serverGroup, nullptr,
+ 0, true, -1, 5, 60000);
// createPool(poolName, locHostPort,serverGroup, nullptr, 0, true );
// createRegionAndAttachPool(poolRegNames[0],USE_ACK, poolName);
@@ -327,7 +327,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, Client1OnServerHATest)
}
// UNUSED bool getResult = true;
- auto pool = apache::geode::client::PoolManager::find("__TEST_POOL1__");
+ auto pool =
+ getHelper()->getCache()->getPoolManager().find("__TEST_POOL1__");
auto exc = FunctionService::onServer(pool);
ASSERT(exc != nullptr, "onServer Returned nullptr");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientPoolExecuteHAFunctionPrSHOP.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientPoolExecuteHAFunctionPrSHOP.cpp b/src/cppcache/integration-test/testThinClientPoolExecuteHAFunctionPrSHOP.cpp
index 14a274a..56f70f4 100644
--- a/src/cppcache/integration-test/testThinClientPoolExecuteHAFunctionPrSHOP.cpp
+++ b/src/cppcache/integration-test/testThinClientPoolExecuteHAFunctionPrSHOP.cpp
@@ -150,8 +150,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, StartC1)
{
// initClient(true);
- initClientWithPool(true, nullptr, locHostPort, serverGroup, nullptr, 1,
- true, -1, 5, 60000, /*singlehop*/ true,
+ initClientWithPool(true, poolRegNames[0], locHostPort, serverGroup, nullptr,
+ 1, true, -1, 5, 60000, /*singlehop*/ true,
/*threadLocal*/ true);
// createPool(poolName, locHostPort,serverGroup, nullptr, 0, true );
// createRegionAndAttachPool(poolRegNames[0],USE_ACK, poolName);
@@ -279,7 +279,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, Client1OnServerHATest)
}
// UNUSED bool getResult = true;
- auto pool = apache::geode::client::PoolManager::find("__TEST_POOL1__");
+ auto pool =
+ getHelper()->getCache()->getPoolManager().find("__TEST_POOL1__");
auto exc = FunctionService::onServer(pool);
ASSERT(exc != nullptr, "onServer Returned nullptr");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientPutAllPRSingleHop.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientPutAllPRSingleHop.cpp b/src/cppcache/integration-test/testThinClientPutAllPRSingleHop.cpp
index a204da5..a2ffc8c 100644
--- a/src/cppcache/integration-test/testThinClientPutAllPRSingleHop.cpp
+++ b/src/cppcache/integration-test/testThinClientPutAllPRSingleHop.cpp
@@ -14,17 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include "fw_dunit.hpp"
-#include <geode/GeodeCppCache.hpp>
-#include "BuiltinCacheableWrappers.hpp"
-#include <Utils.hpp>
-#include <geode/statistics/StatisticsFactory.hpp>
+#include <string>
+
+#include <ace/ACE.h>
#include <ace/OS.h>
#include <ace/High_Res_Timer.h>
-#include <ace/ACE.h>
+#include <geode/GeodeCppCache.hpp>
+#include <geode/statistics/StatisticsFactory.hpp>
-#include <string>
+#include "fw_dunit.hpp"
+#include "BuiltinCacheableWrappers.hpp"
+#include "Utils.hpp"
#define ROOT_NAME "testThinClientPutAllPRSingleHop"
#define ROOT_SCOPE DISTRIBUTED_ACK
@@ -137,8 +138,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, WarmUpTask)
if (networkhop) {
failureCount++;
}
- StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
- StatisticsType* type = factory->findType("RegionStatistics");
+ auto factory = cacheHelper->getCache()->getStatisticsFactory();
+ auto type = factory->findType("RegionStatistics");
if (type) {
Statistics* rStats = factory->findFirstStatisticsByType(type);
if (rStats) {
@@ -334,7 +335,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, CloseCache1)
{
- PoolPtr pool = PoolManager::find("__TEST_POOL1__");
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find("__TEST_POOL1__");
if (pool->getThreadLocalConnections()) {
LOG("releaseThreadLocalConnection1 doing...");
pool->releaseThreadLocalConnection();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientPutWithDelta.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientPutWithDelta.cpp b/src/cppcache/integration-test/testThinClientPutWithDelta.cpp
index 2ba2e3b..568d93d 100644
--- a/src/cppcache/integration-test/testThinClientPutWithDelta.cpp
+++ b/src/cppcache/integration-test/testThinClientPutWithDelta.cpp
@@ -20,6 +20,9 @@
#include "DeltaEx.hpp"
#include "fw_dunit.hpp"
#include <string>
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
using namespace apache::geode::client;
using namespace test;
@@ -108,7 +111,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepOne)
{
LOG("Step one entered");
try {
- Serializable::registerType(DeltaEx::create);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->addType(DeltaEx::create);
} catch (IllegalStateException&) {
// ignore exception caused by type reregistration.
}
@@ -143,7 +147,9 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepOne_DisableDelta)
DeltaEx::toDeltaCount = 0;
DeltaEx::toDataCount = 0;
try {
- Serializable::registerType(DeltaEx::create);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
+ serializationRegistry->addType(DeltaEx::create);
} catch (IllegalStateException&) {
// Ignore the exception caused by re-registration of DeltaEx.
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientRegionQueryDifferentServerConfigs.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientRegionQueryDifferentServerConfigs.cpp b/src/cppcache/integration-test/testThinClientRegionQueryDifferentServerConfigs.cpp
index f9ae075..893bfdc 100644
--- a/src/cppcache/integration-test/testThinClientRegionQueryDifferentServerConfigs.cpp
+++ b/src/cppcache/integration-test/testThinClientRegionQueryDifferentServerConfigs.cpp
@@ -29,6 +29,8 @@
#include "QueryStrings.hpp"
#include "QueryHelper.hpp"
#include "ThinClientHelper.hpp"
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
using namespace apache::geode::client;
using namespace test;
@@ -49,14 +51,16 @@ const char* qRegionNames[] = {"Portfolios", "Positions"};
const char* sGNames[] = {"ServerGroup1", "ServerGroup2"};
void initClient() {
+ initClient(true);
+ ASSERT(getHelper() != nullptr, "null CacheHelper");
try {
- Serializable::registerType(Position::createDeserializable);
- Serializable::registerType(Portfolio::createDeserializable);
- } catch (const IllegalStateException&) {
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->addType(Position::createDeserializable);
+ serializationRegistry->addType(Portfolio::createDeserializable);
+ }
+ catch (const IllegalStateException&) {
// ignore exception
}
- initClient(true);
- ASSERT(getHelper() != nullptr, "null CacheHelper");
}
DUNIT_TASK_DEFINITION(LOCATOR, StartLocator)
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientRegionQueryExclusiveness.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientRegionQueryExclusiveness.cpp b/src/cppcache/integration-test/testThinClientRegionQueryExclusiveness.cpp
index 8dd51e4..3575b7b 100644
--- a/src/cppcache/integration-test/testThinClientRegionQueryExclusiveness.cpp
+++ b/src/cppcache/integration-test/testThinClientRegionQueryExclusiveness.cpp
@@ -34,6 +34,10 @@
#include <geode/StructSet.hpp>
#include <geode/SelectResultsIterator.hpp>
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
+
using namespace apache::geode::client;
using namespace test;
using namespace testobject;
@@ -52,28 +56,17 @@ const char* locHostPort =
const char* qRegionNames[] = {"Portfolios", "Positions"};
void clientOperations() {
+ initClient(true);
try {
- Serializable::registerType(Position::createDeserializable);
- Serializable::registerType(Portfolio::createDeserializable);
+ SerializationRegistryPtr serializationRegistry =
+ CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
+ ->getSerializationRegistry();
+
+ serializationRegistry->addType(Position::createDeserializable);
+ serializationRegistry->addType(Portfolio::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
- initClient(true);
-
- try {
- QueryServicePtr qs = nullptr; // getHelper()->cachePtr->getQueryService();
-
- qs = createPool2("_TESTFAILPOOL_", nullptr, nullptr)->getQueryService();
-
- SelectResultsPtr results;
- QueryPtr qry = qs->newQuery("select distinct * from /Portfolios");
- results = qry->execute();
- FAIL("Since no region has been created yet, so exception expected");
- } catch (IllegalStateException& ex) {
- const char* err_msg = ex.getMessage();
- LOG("Good expected exception");
- LOG(err_msg);
- }
PoolPtr pool1 = nullptr;
pool1 = createPool(poolNames[0], locHostPort, nullptr, 0, true);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientRemoteQueryFailover.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientRemoteQueryFailover.cpp b/src/cppcache/integration-test/testThinClientRemoteQueryFailover.cpp
index 41d3466..d770a39 100644
--- a/src/cppcache/integration-test/testThinClientRemoteQueryFailover.cpp
+++ b/src/cppcache/integration-test/testThinClientRemoteQueryFailover.cpp
@@ -35,6 +35,10 @@
#include "testobject/Portfolio.hpp"
#include "testobject/PortfolioPdx.hpp"
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
+
using namespace apache::geode::client;
using namespace test;
using namespace testobject;
@@ -109,18 +113,20 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, RegisterTypesAndCreatePoolAndRegion)
{
LOG("Starting Step One with Pool + Locator lists");
+
+ initClient(true);
try {
- Serializable::registerType(Position::createDeserializable);
- Serializable::registerType(Portfolio::createDeserializable);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
- Serializable::registerPdxType(PositionPdx::createDeserializable);
- Serializable::registerPdxType(PortfolioPdx::createDeserializable);
+ serializationRegistry->addType(Position::createDeserializable);
+ serializationRegistry->addType(Portfolio::createDeserializable);
+
+ serializationRegistry->addPdxType(PositionPdx::createDeserializable);
+ serializationRegistry->addPdxType(PortfolioPdx::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
- initClient(true);
-
isPoolConfig = true;
createPool(poolNames[0], locHostPort, nullptr, 0, true);
createRegionAndAttachPool(qRegionNames[0], USE_ACK, poolNames[0]);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientRemoteQueryFailoverPdx.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientRemoteQueryFailoverPdx.cpp b/src/cppcache/integration-test/testThinClientRemoteQueryFailoverPdx.cpp
index 70ae63f..3242cc2 100644
--- a/src/cppcache/integration-test/testThinClientRemoteQueryFailoverPdx.cpp
+++ b/src/cppcache/integration-test/testThinClientRemoteQueryFailoverPdx.cpp
@@ -34,7 +34,8 @@
#include "testobject/Portfolio.hpp"
#include "testobject/PortfolioPdx.hpp"
-
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
using namespace apache::geode::client;
using namespace test;
using namespace testobject;
@@ -109,18 +110,19 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, RegisterTypesAndCreatePoolAndRegion)
{
LOG("Starting Step One with Pool + Locator lists");
+
+ initClient(true);
try {
- Serializable::registerType(Position::createDeserializable);
- Serializable::registerType(Portfolio::createDeserializable);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->addType(Position::createDeserializable);
+ serializationRegistry->addType(Portfolio::createDeserializable);
- Serializable::registerPdxType(PositionPdx::createDeserializable);
- Serializable::registerPdxType(PortfolioPdx::createDeserializable);
+ serializationRegistry->addPdxType(PositionPdx::createDeserializable);
+ serializationRegistry->addPdxType(PortfolioPdx::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
- initClient(true);
-
isPoolConfig = true;
createPool(poolNames[0], locHostPort, nullptr, 0, true);
createRegionAndAttachPool(qRegionNames[0], USE_ACK, poolNames[0]);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientRemoteQueryRS.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientRemoteQueryRS.cpp b/src/cppcache/integration-test/testThinClientRemoteQueryRS.cpp
index 788214a..ddff1dc 100644
--- a/src/cppcache/integration-test/testThinClientRemoteQueryRS.cpp
+++ b/src/cppcache/integration-test/testThinClientRemoteQueryRS.cpp
@@ -31,6 +31,10 @@
#include <geode/Query.hpp>
#include <geode/QueryService.hpp>
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
+
using namespace apache::geode::client;
using namespace test;
using namespace testData;
@@ -50,16 +54,18 @@ const char* qRegionNames[] = {"Portfolios", "Positions", "Portfolios2",
"Portfolios3"};
static bool m_isPdx = false;
void stepOne() {
+ // Create just one pool and attach all regions to that.
+ initClient(true);
try {
- Serializable::registerType(Position::createDeserializable);
- Serializable::registerType(Portfolio::createDeserializable);
- Serializable::registerPdxType(PositionPdx::createDeserializable);
- Serializable::registerPdxType(PortfolioPdx::createDeserializable);
- } catch (const IllegalStateException&) {
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->addType(Position::createDeserializable);
+ serializationRegistry->addType(Portfolio::createDeserializable);
+ serializationRegistry->addPdxType(PositionPdx::createDeserializable);
+ serializationRegistry->addPdxType(PortfolioPdx::createDeserializable);
+ }
+ catch (const IllegalStateException&) {
// ignore exception
}
- // Create just one pool and attach all regions to that.
- initClient(true);
isPoolConfig = true;
createPool(poolNames[0], locHostPort, nullptr, 0, true);
createRegionAndAttachPool(qRegionNames[0], USE_ACK, poolNames[0]);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientRemoteQuerySS.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientRemoteQuerySS.cpp b/src/cppcache/integration-test/testThinClientRemoteQuerySS.cpp
index 2fff7be..8f07c1b 100644
--- a/src/cppcache/integration-test/testThinClientRemoteQuerySS.cpp
+++ b/src/cppcache/integration-test/testThinClientRemoteQuerySS.cpp
@@ -31,6 +31,10 @@
#include <geode/Query.hpp>
#include <geode/QueryService.hpp>
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
+
using namespace apache::geode::client;
using namespace test;
using namespace testData;
@@ -224,18 +228,19 @@ void compareMaps(HashMapOfCacheable& map, HashMapOfCacheable& expectedMap) {
}
void stepOne() {
+ initGridClient(true);
try {
- Serializable::registerType(Position::createDeserializable);
- Serializable::registerType(Portfolio::createDeserializable);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
+ serializationRegistry->addType(Position::createDeserializable);
+ serializationRegistry->addType(Portfolio::createDeserializable);
- Serializable::registerPdxType(PositionPdx::createDeserializable);
- Serializable::registerPdxType(PortfolioPdx::createDeserializable);
+ serializationRegistry->addPdxType(PositionPdx::createDeserializable);
+ serializationRegistry->addPdxType(PortfolioPdx::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
- initGridClient(true);
-
isPoolConfig = true;
createPool(poolNames[0], locHostPort, nullptr, 0, true);
createRegionAndAttachPool(qRegionNames[0], USE_ACK, poolNames[0]);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientRemoteQueryTimeout.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientRemoteQueryTimeout.cpp b/src/cppcache/integration-test/testThinClientRemoteQueryTimeout.cpp
index 6aca3d0..82d6e97 100644
--- a/src/cppcache/integration-test/testThinClientRemoteQueryTimeout.cpp
+++ b/src/cppcache/integration-test/testThinClientRemoteQueryTimeout.cpp
@@ -27,10 +27,15 @@
#include "QueryStrings.hpp"
#include "QueryHelper.hpp"
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
#include <geode/Query.hpp>
#include <geode/QueryService.hpp>
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
+
using namespace apache::geode::client;
using namespace test;
using namespace testData;
@@ -51,16 +56,17 @@ const char* qRegionNames[] = {"Portfolios", "Positions", "Portfolios2",
bool isPoolConfig = false; // To track if pool case is running
static bool m_isPdx = false;
void stepOne() {
+ initClient(true);
try {
- Serializable::registerType(Position::createDeserializable);
- Serializable::registerType(Portfolio::createDeserializable);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->addType(Position::createDeserializable);
+ serializationRegistry->addType(Portfolio::createDeserializable);
- Serializable::registerPdxType(PositionPdx::createDeserializable);
- Serializable::registerPdxType(PortfolioPdx::createDeserializable);
+ serializationRegistry->addPdxType(PositionPdx::createDeserializable);
+ serializationRegistry->addPdxType(PortfolioPdx::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
- initClient(true);
isPoolConfig = true;
createPool(poolNames[0], locHostPort, nullptr, 0, true);
createRegionAndAttachPool(qRegionNames[0], USE_ACK, poolNames[0]);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientRemoteRegionQuery.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientRemoteRegionQuery.cpp b/src/cppcache/integration-test/testThinClientRemoteRegionQuery.cpp
index 629bdf5..ab41a4c 100644
--- a/src/cppcache/integration-test/testThinClientRemoteRegionQuery.cpp
+++ b/src/cppcache/integration-test/testThinClientRemoteRegionQuery.cpp
@@ -31,6 +31,8 @@
#include <geode/Query.hpp>
#include <geode/QueryService.hpp>
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
using namespace apache::geode::client;
using namespace test;
using namespace testData;
@@ -83,16 +85,17 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, StepOnePoolLocator)
{
+ initClient(true);
try {
- Serializable::registerType(Position::createDeserializable);
- Serializable::registerType(Portfolio::createDeserializable);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->addType(Position::createDeserializable);
+ serializationRegistry->addType(Portfolio::createDeserializable);
- Serializable::registerPdxType(PositionPdx::createDeserializable);
- Serializable::registerPdxType(PortfolioPdx::createDeserializable);
+ serializationRegistry->addPdxType(PositionPdx::createDeserializable);
+ serializationRegistry->addPdxType(PortfolioPdx::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
- initClient(true);
createPool(poolNames[0], locHostPort, nullptr, 0, true);
createRegionAndAttachPool(qRegionNames[0], USE_ACK, poolNames[0]);
createRegionAndAttachPool(qRegionNames[1], USE_ACK, poolNames[0]);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientSSLWithSecurityAuthz.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientSSLWithSecurityAuthz.cpp b/src/cppcache/integration-test/testThinClientSSLWithSecurityAuthz.cpp
index e386709..8e8d20f 100644
--- a/src/cppcache/integration-test/testThinClientSSLWithSecurityAuthz.cpp
+++ b/src/cppcache/integration-test/testThinClientSSLWithSecurityAuthz.cpp
@@ -252,7 +252,8 @@ DUNIT_TASK_DEFINITION(ADMIN_CLIENT, StepOne)
}
regPtr->query("1=1");
LOG("Query completed successfully");
- PoolPtr pool = PoolManager::find(regionNamesAuth[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesAuth[0]);
QueryServicePtr qs;
if (pool != nullptr) {
// Using region name as pool name
@@ -385,7 +386,8 @@ DUNIT_TASK_DEFINITION(WRITER_CLIENT, StepTwo)
}
HANDLE_NOT_AUTHORIZED_EXCEPTION
- PoolPtr pool = PoolManager::find(regionNamesAuth[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesAuth[0]);
try {
QueryServicePtr qs;
@@ -527,7 +529,8 @@ DUNIT_TASK_DEFINITION(READER_CLIENT, StepThree)
}
HANDLE_NOT_AUTHORIZED_EXCEPTION
- PoolPtr pool = PoolManager::find(regionNamesAuth[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesAuth[0]);
try {
QueryServicePtr qs;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientSecurityAuthorization.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientSecurityAuthorization.cpp b/src/cppcache/integration-test/testThinClientSecurityAuthorization.cpp
index d90604b..534009b 100644
--- a/src/cppcache/integration-test/testThinClientSecurityAuthorization.cpp
+++ b/src/cppcache/integration-test/testThinClientSecurityAuthorization.cpp
@@ -264,7 +264,8 @@ DUNIT_TASK_DEFINITION(ADMIN_CLIENT, StepOne)
regPtr->query("1=1");
LOG("Query completed successfully");
- PoolPtr pool = PoolManager::find(regionNamesAuth[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesAuth[0]);
QueryServicePtr qs;
if (pool != nullptr) {
// Using region name as pool name
@@ -418,7 +419,8 @@ DUNIT_TASK_DEFINITION(WRITER_CLIENT, StepTwo)
}
HANDLE_NOT_AUTHORIZED_EXCEPTION
- PoolPtr pool = PoolManager::find(regionNamesAuth[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesAuth[0]);
try {
QueryServicePtr qs;
@@ -579,7 +581,8 @@ DUNIT_TASK_DEFINITION(READER_CLIENT, StepThree)
}
HANDLE_NOT_AUTHORIZED_EXCEPTION
- PoolPtr pool = PoolManager::find(regionNamesAuth[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesAuth[0]);
try {
QueryServicePtr qs;
@@ -599,7 +602,7 @@ DUNIT_TASK_DEFINITION(READER_CLIENT, StepThree)
}
HANDLE_NO_NOT_AUTHORIZED_EXCEPTION
- pool = PoolManager::find(regionNamesAuth[0]);
+ pool = getHelper()->getCache()->getPoolManager().find(regionNamesAuth[0]);
try {
if (pool != nullptr) {
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientSecurityAuthorizationMU.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientSecurityAuthorizationMU.cpp b/src/cppcache/integration-test/testThinClientSecurityAuthorizationMU.cpp
index 0463a7b..2480c24 100644
--- a/src/cppcache/integration-test/testThinClientSecurityAuthorizationMU.cpp
+++ b/src/cppcache/integration-test/testThinClientSecurityAuthorizationMU.cpp
@@ -680,8 +680,6 @@ DUNIT_TASK_DEFINITION(WRITER_CLIENT, StepTwo)
}
HANDLE_NOT_AUTHORIZED_EXCEPTION
- // PoolPtr pool = PoolManager::find(regionNamesAuth[0]);
-
try {
RegionServicePtr virtualCache;
PoolPtr pool = getPool(regionNamesAuth[0]);
@@ -1010,26 +1008,6 @@ DUNIT_TASK_DEFINITION(READER_CLIENT, StepThree)
}
HANDLE_NOT_AUTHORIZED_EXCEPTION
- // PoolPtr pool = PoolManager::find(regionNamesAuth[0]);
-
- try {
- /*QueryServicePtr qs;
- if (pool != nullptr) {
- // Using region name as pool name
- qs = pool->getQueryService();
- } else {
- qs = getHelper()->cachePtr->getQueryService();
- }
- char queryString[100];
- sprintf(queryString, "select * from /%s", regionNamesAuth[0]);
- CqAttributesFactory cqFac;
- CqAttributesPtr cqAttrs(cqFac.create());
- CqQueryPtr qry = qs->newCq("cq_security", queryString, cqAttrs);
- qs->executeCqs();
- FAIL("CQ should not have completed successfully");*/
- }
- HANDLE_NOT_AUTHORIZED_EXCEPTION
-
try {
// FunctionService::onServer(pool)->execute("securityTest",
// true)->getResult();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientSecurityCQAuthorization.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientSecurityCQAuthorization.cpp b/src/cppcache/integration-test/testThinClientSecurityCQAuthorization.cpp
index 3692041..0e93eb3 100644
--- a/src/cppcache/integration-test/testThinClientSecurityCQAuthorization.cpp
+++ b/src/cppcache/integration-test/testThinClientSecurityCQAuthorization.cpp
@@ -38,6 +38,10 @@
#include "ThinClientCQ.hpp"
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
+
using namespace test;
using namespace testData;
@@ -147,13 +151,6 @@ void initCredentialGenerator() {
PropertiesPtr userCreds;
void initClientCq(const bool isthinClient) {
- try {
- Serializable::registerType(Position::createDeserializable);
- Serializable::registerType(Portfolio::createDeserializable);
- } catch (const IllegalStateException&) {
- // ignore exception
- }
-
userCreds = Properties::create();
PropertiesPtr config = Properties::create();
credentialGeneratorHandler->getAuthInit(config);
@@ -163,6 +160,16 @@ void initClientCq(const bool isthinClient) {
cacheHelper = new CacheHelper(isthinClient, config);
}
ASSERT(cacheHelper, "Failed to create a CacheHelper client instance.");
+ try {
+ SerializationRegistryPtr serializationRegistry =
+ CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
+ ->getSerializationRegistry();
+
+ serializationRegistry->addType(Position::createDeserializable);
+ serializationRegistry->addType(Portfolio::createDeserializable);
+ } catch (const IllegalStateException&) {
+ // ignore exception
+ }
}
DUNIT_TASK_DEFINITION(CLIENT1, CreateServer1_Locator)
@@ -237,7 +244,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThree)
uint8_t i = 0;
QueryHelper* qh ATTR_UNUSED = &QueryHelper::getHelper();
- PoolPtr pool = PoolManager::find(regionNamesCq[0]);
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
QueryServicePtr qs;
if (pool != nullptr) {
// Using region name as pool name as in ThinClientCq.hpp
@@ -298,7 +306,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFour)
{
auto qh ATTR_UNUSED = &QueryHelper::getHelper();
- auto pool = PoolManager::find(regionNamesCq[0]);
+ auto pool =
+ getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
QueryServicePtr qs;
if (pool != nullptr) {
// Using region name as pool name as in ThinClientCq.hpp
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientSecurityCQAuthorizationMU.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientSecurityCQAuthorizationMU.cpp b/src/cppcache/integration-test/testThinClientSecurityCQAuthorizationMU.cpp
index 39d5bb7..3f50c38 100644
--- a/src/cppcache/integration-test/testThinClientSecurityCQAuthorizationMU.cpp
+++ b/src/cppcache/integration-test/testThinClientSecurityCQAuthorizationMU.cpp
@@ -151,13 +151,6 @@ void initCredentialGenerator() {
PropertiesPtr userCreds;
void initClientCq(const bool isthinClient) {
- try {
- Serializable::registerType(Position::createDeserializable);
- Serializable::registerType(Portfolio::createDeserializable);
- } catch (const IllegalStateException&) {
- // ignore exception
- }
-
userCreds = Properties::create();
PropertiesPtr config = Properties::create();
// credentialGeneratorHandler->getAuthInit(config);
@@ -167,6 +160,15 @@ void initClientCq(const bool isthinClient) {
cacheHelper = new CacheHelper(isthinClient, config);
}
ASSERT(cacheHelper, "Failed to create a CacheHelper client instance.");
+ try {
+ SerializationRegistryPtr serializationRegistry =
+ CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
+ ->getSerializationRegistry();
+ serializationRegistry->addType(Position::createDeserializable);
+ serializationRegistry->addType(Portfolio::createDeserializable);
+ } catch (const IllegalStateException&) {
+ // ignore exception
+ }
}
DUNIT_TASK_DEFINITION(CLIENT1, CreateServer1)
@@ -244,11 +246,11 @@ DUNIT_TASK_DEFINITION(CLIENT2, StepOne2_PoolEP)
}
END_TASK_DEFINITION
-PoolPtr getPool(const char* name) { return PoolManager::find(name); }
+PoolPtr getPool(const char* name) {
+ return getHelper()->getCache()->getPoolManager().find(name);
+}
RegionServicePtr getVirtualCache(PropertiesPtr creds, const char* name) {
- // PoolPtr pool = getPool(name);
- // return pool->createSecureUserCache(creds);
return getHelper()->getCache()->createAuthenticatedView(creds, name);
}
@@ -268,11 +270,6 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepTwo)
RegionPtr regPtr0 = userCache->getRegion(regionNamesCq[0]);
RegionPtr subregPtr0 = regPtr0->getSubregion(regionNamesCq[1]);
- // QueryHelper * qh = &QueryHelper::getHelper();
-
- // qh->populatePortfolioData(regPtr0 , 2, 1, 1);
- // qh->populatePositionData(subregPtr0, 2, 1);
-
LOG("StepTwo complete.");
}
END_TASK_DEFINITION
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientSecurityDurableCQAuthorizationMU.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientSecurityDurableCQAuthorizationMU.cpp b/src/cppcache/integration-test/testThinClientSecurityDurableCQAuthorizationMU.cpp
index 8655d61..14ae2df 100644
--- a/src/cppcache/integration-test/testThinClientSecurityDurableCQAuthorizationMU.cpp
+++ b/src/cppcache/integration-test/testThinClientSecurityDurableCQAuthorizationMU.cpp
@@ -152,13 +152,6 @@ void initCredentialGenerator() {
PropertiesPtr userCreds;
const char* durableIds[] = {"DurableId1", "DurableId2"};
void initClientCq(const bool isthinClient, int clientIdx) {
- try {
- Serializable::registerType(Position::createDeserializable);
- Serializable::registerType(Portfolio::createDeserializable);
- } catch (const IllegalStateException&) {
- // ignore exception
- }
-
userCreds = Properties::create();
PropertiesPtr config = Properties::create();
// credentialGeneratorHandler->getAuthInit(config);
@@ -172,6 +165,16 @@ void initClientCq(const bool isthinClient, int clientIdx) {
cacheHelper = new CacheHelper(isthinClient, config);
}
ASSERT(cacheHelper, "Failed to create a CacheHelper client instance.");
+ try {
+ CacheImpl* cacheImpl =
+ CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get());
+ cacheImpl->getSerializationRegistry()->addType(
+ Position::createDeserializable);
+ cacheImpl->getSerializationRegistry()->addType(
+ Portfolio::createDeserializable);
+ } catch (const IllegalStateException&) {
+ // ignore exception
+ }
}
bool closeLogicalCache = false;
@@ -262,11 +265,11 @@ DUNIT_TASK_DEFINITION(CLIENT2, StepOne2_PoolEP)
}
END_TASK_DEFINITION
-PoolPtr getPool(const char* name) { return PoolManager::find(name); }
+PoolPtr getPool(const char* name) {
+ return getHelper()->getCache()->getPoolManager().find(name);
+}
RegionServicePtr getVirtualCache(PropertiesPtr creds, const char* name) {
- // PoolPtr pool = getPool(name);
- // return pool->createSecureUserCache(creds);
return getHelper()->getCache()->createAuthenticatedView(creds, name);
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientSecurityMultiUserTest.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientSecurityMultiUserTest.cpp b/src/cppcache/integration-test/testThinClientSecurityMultiUserTest.cpp
index 42327fb..75a741b 100644
--- a/src/cppcache/integration-test/testThinClientSecurityMultiUserTest.cpp
+++ b/src/cppcache/integration-test/testThinClientSecurityMultiUserTest.cpp
@@ -253,7 +253,6 @@ class UserThread : public ACE_Task_Base {
creds->insert("security-password", tmp);
m_numberOfOps = numberOfOps;
- // m_userCache = pool->createSecureUserCache(creds);
m_userCache = getVirtualCache(creds, pool);
m_userRegion = m_userCache->getRegion(regionNamesAuth[0]);
m_numberOfUsers = numberOfUsers;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientStatistics.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientStatistics.cpp b/src/cppcache/integration-test/testThinClientStatistics.cpp
index 461a09f..05c437f 100644
--- a/src/cppcache/integration-test/testThinClientStatistics.cpp
+++ b/src/cppcache/integration-test/testThinClientStatistics.cpp
@@ -14,8 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include "fw_dunit.hpp"
-#include "ThinClientHelper.hpp"
#include <geode/statistics/StatisticsFactory.hpp>
#include <ace/ACE.h>
@@ -30,6 +28,9 @@
#include <ace/Dirent_Selector.h>
#include <ace/OS_NS_sys_stat.h>
+#include "fw_dunit.hpp"
+#include "ThinClientHelper.hpp"
+
/* This is to test Statistics Functionality, Following Parameters are considered
1- Creation of Stats Type / Statistics / Statistics Descriptors ( int_t/ Long /
Double , Counter / Gauge ) .
@@ -125,8 +126,7 @@ void initClientWithStats() {
pp->insert("statistic-archive-file", "./statArchive.gfs");
pp->insert("notify-ack-interval", 1);
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1", pp, 0,
- true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, pp, 0, true);
getHelper()->createPooledRegion(regionNames[0], USE_ACK, locatorsG,
"__TEST_POOL1__", true, true);
}
@@ -137,8 +137,7 @@ void initClientWithStatsDisabled() {
// pp->insert("statistic-sample-rate", 1);
// pp->insert("statistic-archive-file", "./statArchive.gfs");
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1", pp, 0,
- true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, pp, 0, true);
getHelper()->createPooledRegion(regionNames[0], USE_ACK, locatorsG,
"__TEST_POOL1__", true, true);
}
@@ -186,9 +185,8 @@ void DoRegionOpsAndVerify() {
auto cache = std::dynamic_pointer_cast<Cache>(
regPtr0->getRegionService()); // This depends on LocalCache
// implementing RegionService...
- bool flag = cache->getDistributedSystem()
- ->getSystemProperties()
- ->statisticsEnabled();
+ bool flag =
+ cache->getDistributedSystem().getSystemProperties().statisticsEnabled();
LOGINFO("statisticsEnabled = %d ", flag);
regEntry->getStatistics(cacheStatptr);
} catch (StatisticsDisabledException& ex) {
@@ -321,7 +319,7 @@ void testGetSetIncFunctions(Statistics* stat, TestStatisticsType& type) {
void statisticsTest() {
/* Create Statistics in right and wrong manner */
- StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
+ auto factory = cacheHelper->getCache()->getStatisticsFactory();
/* Register a type */
TestStatisticsType testType;
@@ -527,14 +525,24 @@ DUNIT_TASK_DEFINITION(SERVER1, CloseThirdServer)
END_TASK_DEFINITION
DUNIT_MAIN
-{CALL_TASK(CreateLocator1)
-
- CALL_TASK(StartFirstServer) CALL_TASK(ClientFirstInit) CALL_TASK(StatTest)
- CALL_TASK(CloseFirstClient) CALL_TASK(GFSFileTest)
- CALL_TASK(CloseFirstServer) CALL_TASK(StartSecondServer)
- CALL_TASK(ClientSecondInit) CALL_TASK(CloseSecondServer)
- CALL_TASK(StartThirdServer) CALL_TASK(ClientThirdInit)
- CALL_TASK(RegionOps) CALL_TASK(CloseThirdClient)
- CALL_TASK(CloseThirdServer)
-
- CALL_TASK(CloseLocator1)} END_MAIN
+ {
+ CALL_TASK(CreateLocator1);
+
+ CALL_TASK(StartFirstServer);
+ CALL_TASK(ClientFirstInit);
+ CALL_TASK(StatTest);
+ CALL_TASK(CloseFirstClient);
+ CALL_TASK(GFSFileTest);
+ CALL_TASK(CloseFirstServer);
+ CALL_TASK(StartSecondServer);
+ CALL_TASK(ClientSecondInit);
+ CALL_TASK(CloseSecondServer);
+ CALL_TASK(StartThirdServer);
+ CALL_TASK(ClientThirdInit);
+ CALL_TASK(RegionOps);
+ CALL_TASK(CloseThirdClient);
+ CALL_TASK(CloseThirdServer);
+
+ CALL_TASK(CloseLocator1);
+ }
+END_MAIN
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientTicket317.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientTicket317.cpp b/src/cppcache/integration-test/testThinClientTicket317.cpp
index bcd4e0e..91dcb88 100644
--- a/src/cppcache/integration-test/testThinClientTicket317.cpp
+++ b/src/cppcache/integration-test/testThinClientTicket317.cpp
@@ -36,8 +36,8 @@ DUNIT_TASK_DEFINITION(SERVER1, CreateServerWithNBSTrue)
END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, SetupClient1)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ true);
getHelper()->createPooledRegion(regionNames[0], false, locatorsG,
"__TEST_POOL1__", true, true);
LOG("Client1 started");
@@ -45,8 +45,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, SetupClient1)
END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, SetupClient2)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ true);
getHelper()->createPooledRegion(regionNames[0], false, locatorsG,
"__TEST_POOL1__", true, true);
LOG("Client2 started");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testUtils.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testUtils.hpp b/src/cppcache/integration-test/testUtils.hpp
index d1a6d3f..cca8822 100644
--- a/src/cppcache/integration-test/testUtils.hpp
+++ b/src/cppcache/integration-test/testUtils.hpp
@@ -55,16 +55,8 @@ class TestUtils {
return CacheRegionHelper::getCacheImpl(cptr.get());
}
- static size_t testGetNumberOfPdxIds() {
- return PdxTypeRegistry::testGetNumberOfPdxIds();
- }
-
- static size_t testNumberOfPreservedData() {
- return PdxTypeRegistry::testNumberOfPreservedData();
- }
-
- static DistributedSystemImpl* getDistributedSystemImpl() {
- return CacheRegionHelper::getDistributedSystemImpl();
+ static size_t testNumberOfPreservedData(const CacheImpl& cacheImpl) {
+ return cacheImpl.getPdxTypeRegistry()->testNumberOfPreservedData();
}
static bool waitForKey(CacheableKeyPtr& keyPtr, RegionPtr& rptr, int maxTry,
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testXmlCacheCreationWithPools.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testXmlCacheCreationWithPools.cpp b/src/cppcache/integration-test/testXmlCacheCreationWithPools.cpp
index 675f876..d7a5ca6 100644
--- a/src/cppcache/integration-test/testXmlCacheCreationWithPools.cpp
+++ b/src/cppcache/integration-test/testXmlCacheCreationWithPools.cpp
@@ -264,8 +264,7 @@ int testXmlCacheCreationWithPools() {
CacheHelper::createDuplicateXMLFile(duplicateFile, filePath);
cptr = cacheFactory->set("cache-xml-file", duplicateFile.c_str())->create();
if (cptr->getPdxIgnoreUnreadFields() != true) {
- std::cout << "getPdxIgnoreUnreadFields should return true."
- << std::endl;
+ std::cout << "getPdxIgnoreUnreadFields should return true." << std::endl;
return -1;
} else {
std::cout << "getPdxIgnoreUnreadFields returned true." << std::endl;
@@ -291,16 +290,15 @@ int testXmlCacheCreationWithPools() {
std::cout << "Root regions in Cache :" << std::endl;
for (int32_t i = 0; i < vrp.size(); i++) {
- std::cout << "vc[" << i << "].m_regionPtr=" << vrp.at(i).get()
- << std::endl;
+ std::cout << "vc[" << i << "].m_regionPtr=" << vrp.at(i).get() << std::endl;
std::cout << "vc[" << i << "]=" << vrp.at(i)->getName() << std::endl;
}
RegionPtr regPtr1 = vrp.at(0);
VectorOfRegion vr;
std::cout << "Test if the number of sub regions with the root region Root1 "
- "are correct"
- << std::endl;
+ "are correct"
+ << std::endl;
regPtr1->subregions(true, vr);
std::cout << " vr.size=" << vr.size() << std::endl;
if (vr.size() != 1) {
@@ -309,21 +307,22 @@ int testXmlCacheCreationWithPools() {
}
std::cout << "get subregions from the root region :" << vrp.at(0)->getName()
- << std::endl;
+ << std::endl;
for (int32_t i = 0; i < vr.size(); i++) {
- std::cout << "vc[" << i << "].m_regionPtr=" << vr.at(i).get()
- << std::endl;
+ std::cout << "vc[" << i << "].m_regionPtr=" << vr.at(i).get() << std::endl;
std::cout << "vc[" << i << "]=" << vr.at(i)->getName() << std::endl;
}
+ // TODO - global Issue is that we cannot have config with server and locator
+ // pools. Check if this assumption is valid and if so then break up this test.
RegionPtr subRegPtr = vr.at(0);
vr.clear();
RegionPtr regPtr2 = vrp.at(1);
std::cout << "Test if the number of sub regions with the root region Root2 "
- "are correct"
- << std::endl;
+ "are correct"
+ << std::endl;
regPtr2->subregions(true, vr);
std::cout << " vr.size=" << vr.size() << std::endl;
if (vr.size() != 0) {
@@ -353,9 +352,9 @@ int testXmlCacheCreationWithPools() {
return -1;
}
- PoolPtr poolOfReg1 = PoolManager::find(poolNameReg1);
- PoolPtr poolOfSubReg = PoolManager::find(poolNameSubReg);
- PoolPtr poolOfReg2 = PoolManager::find(poolNameReg2);
+ PoolPtr poolOfReg1 = cptr->getPoolManager().find(poolNameReg1);
+ PoolPtr poolOfSubReg = cptr->getPoolManager().find(poolNameSubReg);
+ PoolPtr poolOfReg2 = cptr->getPoolManager().find(poolNameReg2);
SLIST locators;
SLIST servers;
SLIST emptylist;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/AdminRegion.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/AdminRegion.cpp b/src/cppcache/src/AdminRegion.cpp
index 3d21b0a..b3cea1b 100644
--- a/src/cppcache/src/AdminRegion.cpp
+++ b/src/cppcache/src/AdminRegion.cpp
@@ -29,15 +29,14 @@ AdminRegionPtr AdminRegion::create(CacheImpl* cache,
ThinClientBaseDM* distMan) {
auto adminRegion = std::make_shared<AdminRegion>();
- SystemProperties* props =
- cache->getCache()->getDistributedSystem()->getSystemProperties();
- if (props && props->statisticsEnabled()) {
+ auto& props = cache->getDistributedSystem().getSystemProperties();
+ if (props.statisticsEnabled()) {
// no need to create a region .. just create a cacheDistribution Manager
adminRegion->m_connectionMgr = &(cache->tcrConnectionManager());
if (!distMan) {
adminRegion->m_distMngr =
new ThinClientCacheDistributionManager(*adminRegion->m_connectionMgr);
- StatisticsManager* mngr = StatisticsManager::getExistingInstance();
+ auto mngr = cache->getDistributedSystem().getStatisticsManager();
if (mngr) {
// Register it with StatisticsManager
mngr->RegisterAdminRegion(adminRegion);
@@ -78,8 +77,10 @@ GfErrType AdminRegion::putNoThrow(const CacheableKeyPtr& keyPtr,
// put obj to region
GfErrType err = GF_NOERR;
- TcrMessagePut request(nullptr, keyPtr, valuePtr, nullptr, false, m_distMngr,
- true, false, m_fullPath.c_str());
+ TcrMessagePut request(
+ m_connectionMgr->getCacheImpl()->getCache()->createDataOutput(), nullptr,
+ keyPtr, valuePtr, nullptr, false, m_distMngr, true, false,
+ m_fullPath.c_str());
request.setMetaRegion(true);
TcrMessageReply reply(true, m_distMngr);
reply.setMetaRegion(true);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/AttributesFactory.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/AttributesFactory.cpp b/src/cppcache/src/AttributesFactory.cpp
index f562522..4d7535d 100644
--- a/src/cppcache/src/AttributesFactory.cpp
+++ b/src/cppcache/src/AttributesFactory.cpp
@@ -114,19 +114,6 @@ void AttributesFactory::setStatisticsEnabled( bool statisticsEnabled)
std::unique_ptr<RegionAttributes> AttributesFactory::createRegionAttributes() {
RegionAttributesPtr res;
- /*
- if( m_regionAttributes.m_poolName != nullptr )
- {
- PoolPtr pool= PoolManager::find( m_regionAttributes.m_poolName );
- if (pool == nullptr) {
- throw IllegalStateException("Pool not found while creating region
- attributes");
- }
- setClientNotificationEnabled(pool->getSubscriptionEnabled());
- if( pool->getSubscriptionRedundancy() >0 )
- setClientNotificationEnabled(true);
- }
- */
validateAttributes(m_regionAttributes);
return std::unique_ptr<RegionAttributes>(
new RegionAttributes(m_regionAttributes));
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/Cache.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/Cache.cpp b/src/cppcache/src/Cache.cpp
index 5bda631..37ca223 100644
--- a/src/cppcache/src/Cache.cpp
+++ b/src/cppcache/src/Cache.cpp
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#include <geode/geode_globals.hpp>
#include <memory>
@@ -29,17 +30,20 @@
#include <geode/PoolManager.hpp>
#include <PdxInstanceFactoryImpl.hpp>
-using namespace apache::geode::client;
-
-extern bool Cache_CreatedFromCacheFactory;
extern ACE_Recursive_Thread_Mutex* g_disconnectLock;
+#define DEFAULT_DS_NAME "default_GeodeDS"
+
+namespace apache {
+namespace geode {
+namespace client {
+
/** 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
*/
-const char* Cache::getName() const { return m_cacheImpl->getName(); }
+const std::string& Cache::getName() const { return m_cacheImpl->getName(); }
/**
* Indicates if this cache has been closed.
@@ -56,10 +60,8 @@ bool Cache::isClosed() const { return m_cacheImpl->isClosed(); }
* {@link CacheFactory::create created} with. This method does not throw
* <code>CacheClosedException</code> if the cache is closed.
*/
-DistributedSystemPtr Cache::getDistributedSystem() const {
- DistributedSystemPtr result;
- m_cacheImpl->getDistributedSystem(result);
- return result;
+DistributedSystem& Cache::getDistributedSystem() const {
+ return m_cacheImpl->getDistributedSystem();
}
void Cache::close() { close(false); }
@@ -78,10 +80,7 @@ void Cache::close(bool keepalive) {
m_cacheImpl->close(keepalive);
try {
- if (Cache_CreatedFromCacheFactory) {
- Cache_CreatedFromCacheFactory = false;
- DistributedSystem::disconnect();
- }
+ getDistributedSystem().disconnect();
} catch (const apache::geode::client::NotConnectedException&) {
} catch (const apache::geode::client::Exception&) {
} catch (...) {
@@ -149,10 +148,15 @@ CacheTransactionManagerPtr Cache::getCacheTransactionManager() {
return m_cacheImpl->getCacheTransactionManager();
}
-Cache::Cache(const char* name, DistributedSystemPtr sys, const char* id_data,
+TypeRegistry& Cache::getTypeRegistry() { return *(m_typeRegistry.get()); }
+
+Cache::Cache(const std::string& name, PropertiesPtr dsProp,
bool ignorePdxUnreadFields, bool readPdxSerialized) {
+ auto dsPtr = DistributedSystem::create(DEFAULT_DS_NAME, this, dsProp);
+ dsPtr->connect();
m_cacheImpl = std::unique_ptr<CacheImpl>(new CacheImpl(
- this, name, sys, id_data, ignorePdxUnreadFields, readPdxSerialized));
+ this, name, std::move(dsPtr), ignorePdxUnreadFields, readPdxSerialized));
+ m_typeRegistry = std::unique_ptr<TypeRegistry>(new TypeRegistry(*this));
}
Cache::~Cache() = default;
@@ -172,7 +176,7 @@ Cache::~Cache() = default;
* @throws UnknownException otherwise
*/
void Cache::initializeDeclarativeCache(const char* cacheXml) {
- CacheXmlParser* xmlParser = CacheXmlParser::parse(cacheXml);
+ CacheXmlParser* xmlParser = CacheXmlParser::parse(cacheXml, this);
xmlParser->setAttributes(this);
m_cacheImpl->initServices();
xmlParser->create(this);
@@ -186,7 +190,7 @@ bool Cache::isPoolInMultiuserMode(RegionPtr regionPtr) {
const char* poolName = regionPtr->getAttributes()->getPoolName();
if (poolName != nullptr) {
- PoolPtr poolPtr = PoolManager::find(poolName);
+ PoolPtr poolPtr = regionPtr->getCache()->getPoolManager().find(poolName);
if (poolPtr != nullptr && !poolPtr->isDestroyed()) {
return poolPtr->getMultiuserAuthentication();
}
@@ -203,15 +207,21 @@ bool Cache::getPdxReadSerialized() {
}
PdxInstanceFactoryPtr Cache::createPdxInstanceFactory(const char* className) {
- return std::make_shared<PdxInstanceFactoryImpl>(className);
+ return std::make_shared<PdxInstanceFactoryImpl>(
+ className, m_cacheImpl->m_cacheStats, m_cacheImpl->getPdxTypeRegistry(),
+ this,
+ m_cacheImpl->getDistributedSystem()
+ .getSystemProperties()
+ .getEnableTimeStatistics());
}
RegionServicePtr Cache::createAuthenticatedView(
PropertiesPtr userSecurityProperties, const char* poolName) {
if (poolName == nullptr) {
- if (!this->isClosed() && m_cacheImpl->getDefaultPool() != nullptr) {
- return m_cacheImpl->getDefaultPool()->createSecureUserCache(
- userSecurityProperties);
+ auto pool = m_cacheImpl->getPoolManager().getDefaultPool();
+ if (!this->isClosed() && pool != nullptr) {
+ return pool->createSecureUserCache(userSecurityProperties,
+ m_cacheImpl.get());
}
throw IllegalStateException(
@@ -220,9 +230,10 @@ RegionServicePtr Cache::createAuthenticatedView(
} else {
if (!this->isClosed()) {
if (poolName != nullptr) {
- PoolPtr poolPtr = PoolManager::find(poolName);
+ PoolPtr poolPtr = m_cacheImpl->getPoolManager().find(poolName);
if (poolPtr != nullptr && !poolPtr->isDestroyed()) {
- return poolPtr->createSecureUserCache(userSecurityProperties);
+ return poolPtr->createSecureUserCache(userSecurityProperties,
+ m_cacheImpl.get());
}
throw IllegalStateException(
"Either pool not found or it has been destroyed");
@@ -234,3 +245,26 @@ RegionServicePtr Cache::createAuthenticatedView(
}
return nullptr;
}
+
+StatisticsFactory* Cache::getStatisticsFactory() const {
+ return m_cacheImpl->getDistributedSystem()
+ .getStatisticsManager()
+ ->getStatisticsFactory();
+}
+
+PoolManager& Cache::getPoolManager() const {
+ return m_cacheImpl->getPoolManager();
+}
+
+std::unique_ptr<DataInput> Cache::createDataInput(const uint8_t* m_buffer,
+ int32_t len) const {
+ return std::unique_ptr<DataInput>(new DataInput(m_buffer, len, this));
+}
+
+std::unique_ptr<DataOutput> Cache::createDataOutput() const {
+ return std::unique_ptr<DataOutput>(new DataOutput(this));
+}
+
+} // namespace client
+} // namespace geode
+} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheFactory.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheFactory.cpp b/src/cppcache/src/CacheFactory.cpp
index 1ee293c..fc2b442 100644
--- a/src/cppcache/src/CacheFactory.cpp
+++ b/src/cppcache/src/CacheFactory.cpp
@@ -34,81 +34,30 @@
#include <PdxEnumInstantiator.hpp>
#include <PdxType.hpp>
#include <PdxTypeRegistry.hpp>
-
+#include "DiskVersionTag.hpp"
+#include "TXCommitMessage.hpp"
+#include <functional>
#include "version.h"
-#define DEFAULT_DS_NAME "default_GeodeDS"
#define DEFAULT_CACHE_NAME "default_GeodeCache"
-#define DEFAULT_SERVER_PORT 40404
-#define DEFAULT_SERVER_HOST "localhost"
extern ACE_Recursive_Thread_Mutex* g_disconnectLock;
-bool Cache_CreatedFromCacheFactory = false;
-
namespace apache {
namespace geode {
namespace client {
-ACE_Recursive_Thread_Mutex g_cfLock;
-
-typedef std::map<std::string, CachePtr> StringToCachePtrMap;
-
-void* CacheFactory::m_cacheMap = (void*)nullptr;
-
-CacheFactoryPtr* CacheFactory::default_CacheFactory = nullptr;
-
-PoolPtr CacheFactory::createOrGetDefaultPool() {
- ACE_Guard<ACE_Recursive_Thread_Mutex> connectGuard(*g_disconnectLock);
-
- CachePtr cache = CacheFactory::getAnyInstance();
-
- if (cache != nullptr && cache->isClosed() == false &&
- cache->m_cacheImpl->getDefaultPool() != nullptr) {
- return cache->m_cacheImpl->getDefaultPool();
- }
-
- PoolPtr pool = PoolManager::find(DEFAULT_POOL_NAME);
-
- // if default_poolFactory is null then we are not using latest API....
- if (pool == nullptr && Cache_CreatedFromCacheFactory) {
- if (default_CacheFactory && (*default_CacheFactory)) {
- pool = (*default_CacheFactory)->determineDefaultPool(cache);
- }
- (*default_CacheFactory) = nullptr;
- default_CacheFactory = nullptr;
- }
-
- return pool;
-}
CacheFactoryPtr CacheFactory::createCacheFactory(
const PropertiesPtr& configPtr) {
return std::make_shared<CacheFactory>(configPtr);
}
-void CacheFactory::init() {
- if (m_cacheMap == (void*)nullptr) {
- m_cacheMap = (void*)new StringToCachePtrMap();
- }
- if (!reinterpret_cast<StringToCachePtrMap*>(m_cacheMap)) {
- throw OutOfMemoryException("CacheFactory::create: ");
- }
-}
-
-void CacheFactory::create_(const char* name, DistributedSystemPtr& system,
+void CacheFactory::create_(const char* name,
const char* id_data, CachePtr& cptr,
- bool ignorePdxUnreadFields, bool readPdxSerialized) {
+ bool readPdxSerialized) {
CppCacheLibrary::initLib();
cptr = nullptr;
- if (!reinterpret_cast<StringToCachePtrMap*>(m_cacheMap)) {
- throw IllegalArgumentException(
- "CacheFactory::create: cache map is not initialized");
- }
- if (system == nullptr) {
- throw IllegalArgumentException(
- "CacheFactory::create: system uninitialized");
- }
if (name == nullptr) {
throw IllegalArgumentException("CacheFactory::create: name is nullptr");
}
@@ -116,74 +65,9 @@ void CacheFactory::create_(const char* name, DistributedSystemPtr& system,
name = "NativeCache";
}
- CachePtr cp = nullptr;
- basicGetInstance(system, true, cp);
- if ((cp == nullptr) || (cp->isClosed() == true)) {
- cptr = std::make_shared<Cache>(name, system, id_data, ignorePdxUnreadFields,
- readPdxSerialized);
- std::string key(system->getName());
- if (cp != nullptr) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(g_cfLock);
- (reinterpret_cast<StringToCachePtrMap*>(m_cacheMap))
- ->erase(
- (reinterpret_cast<StringToCachePtrMap*>(m_cacheMap))->find(key));
- }
- std::pair<std::string, CachePtr> pc(key, cptr);
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(g_cfLock);
- (reinterpret_cast<StringToCachePtrMap*>(m_cacheMap))->insert(pc);
- return;
- }
- throw CacheExistsException("an open cache exists with the specified system");
-}
-
-CachePtr CacheFactory::getInstance(const DistributedSystemPtr& system) {
- CachePtr cptr;
- CppCacheLibrary::initLib();
- if (system == nullptr) {
- throw IllegalArgumentException(
- "CacheFactory::getInstance: system uninitialized");
- }
- GfErrType err = basicGetInstance(system, false, cptr);
- GfErrTypeToException("CacheFactory::getInstance", err);
- return cptr;
-}
-
-CachePtr CacheFactory::getInstanceCloseOk(const DistributedSystemPtr& system) {
- CachePtr cptr;
- CppCacheLibrary::initLib();
- if (system == nullptr) {
- throw IllegalArgumentException(
- "CacheFactory::getInstanceClosedOK: system uninitialized");
- }
- GfErrType err = basicGetInstance(system, true, cptr);
- GfErrTypeToException("CacheFactory::getInstanceCloseOk", err);
- return cptr;
-}
-
-CachePtr CacheFactory::getAnyInstance() { return getAnyInstance(true); }
-
-CachePtr CacheFactory::getAnyInstance(bool throwException) {
- CachePtr cptr;
- CppCacheLibrary::initLib();
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(g_cfLock);
- if ((reinterpret_cast<StringToCachePtrMap*>(m_cacheMap))->empty() == true) {
- if (throwException) {
- throw EntryNotFoundException(
- "CacheFactory::getAnyInstance: not found, no cache created yet");
- } else {
- return nullptr;
- }
- }
- for (StringToCachePtrMap::iterator p =
- (reinterpret_cast<StringToCachePtrMap*>(m_cacheMap))->begin();
- p != (reinterpret_cast<StringToCachePtrMap*>(m_cacheMap))->end(); ++p) {
- if (!(p->second->isClosed())) {
- cptr = p->second;
- return cptr;
- }
- }
- return nullptr;
-}
+ cptr = std::make_shared<Cache>(name, dsProp, ignorePdxUnreadFields,
+ readPdxSerialized);
+} // namespace client
const char* CacheFactory::getVersion() { return PRODUCT_VERSION; }
@@ -196,89 +80,64 @@ CacheFactory::CacheFactory() {
ignorePdxUnreadFields = false;
pdxReadSerialized = false;
dsProp = nullptr;
- pf = nullptr;
}
CacheFactory::CacheFactory(const PropertiesPtr dsProps) {
ignorePdxUnreadFields = false;
pdxReadSerialized = false;
this->dsProp = dsProps;
- this->pf = nullptr;
}
CachePtr CacheFactory::create() {
- // bool pdxIgnoreUnreadFields = false;
- // bool pdxReadSerialized = false;
-
ACE_Guard<ACE_Recursive_Thread_Mutex> connectGuard(*g_disconnectLock);
- DistributedSystemPtr dsPtr = nullptr;
- // should we compare deafult DS properties here??
- if (DistributedSystem::isConnected()) {
- dsPtr = DistributedSystem::getInstance();
- } else {
- dsPtr = DistributedSystem::connect(DEFAULT_DS_NAME, dsProp);
- LOGFINE("CacheFactory called DistributedSystem::connect");
- }
-
- CachePtr cache = nullptr;
-
- cache = getAnyInstance(false);
-
- if (cache == nullptr) {
- default_CacheFactory = new CacheFactoryPtr(shared_from_this());
- Cache_CreatedFromCacheFactory = true;
- cache = create(DEFAULT_CACHE_NAME, dsPtr,
- dsPtr->getSystemProperties()->cacheXMLFile(), nullptr);
- // if(cache->m_cacheImpl->getDefaultPool() == nullptr)
- // determineDefaultPool(cache);
- } else {
- if (cache->m_cacheImpl->getDefaultPool() != nullptr) {
- // we already choose or created deafult pool
- determineDefaultPool(cache);
- } else {
- // not yet created, create from first cacheFactory instance
- if (default_CacheFactory && (*default_CacheFactory)) {
- (*default_CacheFactory)->determineDefaultPool(cache);
- (*default_CacheFactory) = nullptr;
- default_CacheFactory = nullptr;
- }
- determineDefaultPool(cache);
- }
- }
-
- SerializationRegistry::addType(GeodeTypeIdsImpl::PDX,
- PdxInstantiator::createDeserializable);
- SerializationRegistry::addType(GeodeTypeIds::CacheableEnum,
- PdxEnumInstantiator::createDeserializable);
- SerializationRegistry::addType(GeodeTypeIds::PdxType,
- PdxType::CreateDeserializable);
- PdxTypeRegistry::setPdxIgnoreUnreadFields(cache->getPdxIgnoreUnreadFields());
- PdxTypeRegistry::setPdxReadSerialized(cache->getPdxReadSerialized());
+ LOGFINE("CacheFactory called DistributedSystem::connect");
+ auto cache = create(DEFAULT_CACHE_NAME, nullptr);
+
+ cache->m_cacheImpl->getSerializationRegistry()->addType2(std::bind(
+ TXCommitMessage::create,
+ std::ref(*(cache->m_cacheImpl->getMemberListForVersionStamp()))));
+
+ cache->m_cacheImpl->getSerializationRegistry()->addType(
+ GeodeTypeIdsImpl::PDX, PdxInstantiator::createDeserializable);
+ cache->m_cacheImpl->getSerializationRegistry()->addType(
+ GeodeTypeIds::CacheableEnum, PdxEnumInstantiator::createDeserializable);
+ cache->m_cacheImpl->getSerializationRegistry()->addType(
+ GeodeTypeIds::PdxType,
+ std::bind(PdxType::CreateDeserializable,
+ cache->m_cacheImpl->getPdxTypeRegistry()));
+
+ cache->m_cacheImpl->getSerializationRegistry()->addType(std::bind(
+ VersionTag::createDeserializable,
+ std::ref(*(cache->m_cacheImpl->getMemberListForVersionStamp()))));
+ cache->m_cacheImpl->getSerializationRegistry()->addType2(
+ GeodeTypeIdsImpl::DiskVersionTag,
+ std::bind(
+ DiskVersionTag::createDeserializable,
+ std::ref(*(cache->m_cacheImpl->getMemberListForVersionStamp()))));
+
+ cache->m_cacheImpl->getPdxTypeRegistry()->setPdxIgnoreUnreadFields(
+ cache->getPdxIgnoreUnreadFields());
+ cache->m_cacheImpl->getPdxTypeRegistry()->setPdxReadSerialized(
+ cache->getPdxReadSerialized());
return cache;
}
CachePtr CacheFactory::create(const char* name,
- DistributedSystemPtr system /*= nullptr*/,
- const char* cacheXml /*= 0*/,
const CacheAttributesPtr& attrs /*= nullptr*/) {
ACE_Guard<ACE_Recursive_Thread_Mutex> connectGuard(*g_disconnectLock);
CachePtr cptr;
- CacheFactory::create_(name, system, "", cptr, ignorePdxUnreadFields,
- pdxReadSerialized);
+ create_(name, "", cptr, pdxReadSerialized);
cptr->m_cacheImpl->setAttributes(attrs);
try {
+ const char* cacheXml =
+ cptr->getDistributedSystem().getSystemProperties().cacheXMLFile();
if (cacheXml != 0 && strlen(cacheXml) > 0) {
cptr->initializeDeclarativeCache(cacheXml);
} else {
- std::string file = system->getSystemProperties()->cacheXMLFile();
- if (file != "") {
- cptr->initializeDeclarativeCache(file.c_str());
- } else {
- cptr->m_cacheImpl->initServices();
- }
+ cptr->m_cacheImpl->initServices();
}
} catch (const apache::geode::client::RegionExistsException&) {
LOGWARN("Attempt to create existing regions declaratively");
@@ -300,245 +159,16 @@ CachePtr CacheFactory::create(const char* name,
return cptr;
}
-PoolPtr CacheFactory::determineDefaultPool(CachePtr cachePtr) {
- PoolPtr pool = nullptr;
- auto allPools = PoolManager::getAll();
- size_t currPoolSize = allPools.size();
-
- // means user has not set any pool attributes
- if (this->pf == nullptr) {
- this->pf = getPoolFactory();
- if (currPoolSize == 0) {
- if (!this->pf->m_addedServerOrLocator) {
- this->pf->addServer(DEFAULT_SERVER_HOST, DEFAULT_SERVER_PORT);
- }
-
- pool = this->pf->create(DEFAULT_POOL_NAME);
- // creatubg default pool so setting this as default pool
- LOGINFO("Set default pool with localhost:40404");
- cachePtr->m_cacheImpl->setDefaultPool(pool);
- return pool;
- } else if (currPoolSize == 1) {
- pool = allPools.begin()->second;
- LOGINFO("Set default pool from existing pool.");
- cachePtr->m_cacheImpl->setDefaultPool(pool);
- return pool;
- } else {
- // can't set anything as deafult pool
- return nullptr;
- }
- } else {
- PoolPtr defaulPool = cachePtr->m_cacheImpl->getDefaultPool();
-
- if (!this->pf->m_addedServerOrLocator) {
- this->pf->addServer(DEFAULT_SERVER_HOST, DEFAULT_SERVER_PORT);
- }
-
- if (defaulPool != nullptr) {
- // once default pool is created, we will not create
- if (*(defaulPool->m_attrs) == *(this->pf->m_attrs)) {
- return defaulPool;
- } else {
- throw IllegalStateException(
- "Existing cache's default pool was not compatible");
- }
- }
-
- pool = nullptr;
-
- // return any existing pool if it matches
- for (const auto& iter : allPools) {
- auto currPool = iter.second;
- if (*(currPool->m_attrs) == *(this->pf->m_attrs)) {
- return currPool;
- }
- }
-
- // defaul pool is null
- GF_DEV_ASSERT(defaulPool == nullptr);
-
- if (defaulPool == nullptr) {
- pool = this->pf->create(DEFAULT_POOL_NAME);
- LOGINFO("Created default pool");
- // creating default so setting this as defaul pool
- cachePtr->m_cacheImpl->setDefaultPool(pool);
- }
-
- return pool;
- }
-}
-
-PoolFactoryPtr CacheFactory::getPoolFactory() {
- if (this->pf == nullptr) {
- this->pf = PoolManager::createFactory();
- }
- return this->pf;
-}
-
CacheFactory::~CacheFactory() {}
-void CacheFactory::cleanup() {
- if (m_cacheMap != nullptr) {
- if ((reinterpret_cast<StringToCachePtrMap*>(m_cacheMap))->empty() == true) {
- (reinterpret_cast<StringToCachePtrMap*>(m_cacheMap))->clear();
- }
- delete (reinterpret_cast<StringToCachePtrMap*>(m_cacheMap));
- m_cacheMap = nullptr;
- }
-}
-
-GfErrType CacheFactory::basicGetInstance(const DistributedSystemPtr& system,
- const bool closeOk, CachePtr& cptr) {
- GfErrType err = GF_NOERR;
- if (system == nullptr) {
- return GF_CACHE_ILLEGAL_ARGUMENT_EXCEPTION;
- }
- cptr = nullptr;
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(g_cfLock);
- if ((reinterpret_cast<StringToCachePtrMap*>(m_cacheMap))->empty() == true) {
- return GF_CACHE_ENTRY_NOT_FOUND;
- }
- std::string key(system->getName());
- StringToCachePtrMap::iterator p =
- (reinterpret_cast<StringToCachePtrMap*>(m_cacheMap))->find(key);
- if (p != (reinterpret_cast<StringToCachePtrMap*>(m_cacheMap))->end()) {
- if ((closeOk == true) || (!(p->second->isClosed()))) {
- cptr = p->second;
- } else {
- return GF_CACHE_ENTRY_NOT_FOUND;
- }
- } else {
- return GF_CACHE_ENTRY_NOT_FOUND;
- }
- return err;
-}
-
-void CacheFactory::handleXML(CachePtr& cachePtr, const char* cachexml,
- DistributedSystemPtr& system) {
- CacheConfig config(cachexml);
-
- RegionConfigMapT regionMap = config.getRegionList();
- RegionConfigMapT::const_iterator iter = regionMap.begin();
- while (iter != regionMap.end()) {
- std::string regionName = (*iter).first;
- RegionConfigPtr regConfPtr = (*iter).second;
-
- AttributesFactory af;
- af.setLruEntriesLimit(regConfPtr->getLruEntriesLimit());
- af.setConcurrencyLevel(regConfPtr->getConcurrency());
- af.setInitialCapacity(regConfPtr->entries());
- af.setCachingEnabled(regConfPtr->getCaching());
-
- RegionAttributesPtr regAttrsPtr;
- regAttrsPtr = af.createRegionAttributes();
-
- const RegionShortcut regionShortcut =
- (regAttrsPtr->getCachingEnabled() ? RegionShortcut::CACHING_PROXY
- : RegionShortcut::PROXY);
- RegionFactoryPtr regionFactoryPtr =
- cachePtr->createRegionFactory(regionShortcut);
- regionFactoryPtr->create(regionName.c_str());
- ++iter;
- }
-}
CacheFactoryPtr CacheFactory::set(const char* name, const char* value) {
- if (this->dsProp == nullptr) this->dsProp = Properties::create();
+ if (this->dsProp == nullptr) {
+ this->dsProp = Properties::create();
+ }
this->dsProp->insert(name, value);
return shared_from_this();
}
-CacheFactoryPtr CacheFactory::setFreeConnectionTimeout(int connectionTimeout) {
- getPoolFactory()->setFreeConnectionTimeout(connectionTimeout);
- return shared_from_this();
-}
-CacheFactoryPtr CacheFactory::setLoadConditioningInterval(
- int loadConditioningInterval) {
- getPoolFactory()->setLoadConditioningInterval(loadConditioningInterval);
- return shared_from_this();
-}
-CacheFactoryPtr CacheFactory::setSocketBufferSize(int bufferSize) {
- getPoolFactory()->setSocketBufferSize(bufferSize);
- return shared_from_this();
-}
-CacheFactoryPtr CacheFactory::setThreadLocalConnections(
- bool threadLocalConnections) {
- getPoolFactory()->setThreadLocalConnections(threadLocalConnections);
- return shared_from_this();
-}
-CacheFactoryPtr CacheFactory::setReadTimeout(int timeout) {
- getPoolFactory()->setReadTimeout(timeout);
- return shared_from_this();
-}
-CacheFactoryPtr CacheFactory::setMinConnections(int minConnections) {
- getPoolFactory()->setMinConnections(minConnections);
- return shared_from_this();
-}
-CacheFactoryPtr CacheFactory::setMaxConnections(int maxConnections) {
- getPoolFactory()->setMaxConnections(maxConnections);
- return shared_from_this();
-}
-CacheFactoryPtr CacheFactory::setIdleTimeout(long idleTimeout) {
- getPoolFactory()->setIdleTimeout(idleTimeout);
- return shared_from_this();
-}
-CacheFactoryPtr CacheFactory::setRetryAttempts(int retryAttempts) {
- getPoolFactory()->setRetryAttempts(retryAttempts);
- return shared_from_this();
-}
-CacheFactoryPtr CacheFactory::setPingInterval(long pingInterval) {
- getPoolFactory()->setPingInterval(pingInterval);
- return shared_from_this();
-}
-CacheFactoryPtr CacheFactory::setUpdateLocatorListInterval(
- long updateLocatorListInterval) {
- getPoolFactory()->setUpdateLocatorListInterval(updateLocatorListInterval);
- return shared_from_this();
-}
-CacheFactoryPtr CacheFactory::setStatisticInterval(int statisticInterval) {
- getPoolFactory()->setStatisticInterval(statisticInterval);
- return shared_from_this();
-}
-CacheFactoryPtr CacheFactory::setServerGroup(const char* group) {
- getPoolFactory()->setServerGroup(group);
- return shared_from_this();
-}
-CacheFactoryPtr CacheFactory::addLocator(const char* host, int port) {
- getPoolFactory()->addLocator(host, port);
- return shared_from_this();
-}
-CacheFactoryPtr CacheFactory::addServer(const char* host, int port) {
- getPoolFactory()->addServer(host, port);
- return shared_from_this();
-}
-CacheFactoryPtr CacheFactory::setSubscriptionEnabled(bool enabled) {
- getPoolFactory()->setSubscriptionEnabled(enabled);
- return shared_from_this();
-}
-CacheFactoryPtr CacheFactory::setSubscriptionRedundancy(int redundancy) {
- getPoolFactory()->setSubscriptionRedundancy(redundancy);
- return shared_from_this();
-}
-CacheFactoryPtr CacheFactory::setSubscriptionMessageTrackingTimeout(
- int messageTrackingTimeout) {
- getPoolFactory()->setSubscriptionMessageTrackingTimeout(
- messageTrackingTimeout);
- return shared_from_this();
-}
-CacheFactoryPtr CacheFactory::setSubscriptionAckInterval(int ackInterval) {
- getPoolFactory()->setSubscriptionAckInterval(ackInterval);
- return shared_from_this();
-}
-CacheFactoryPtr CacheFactory::setMultiuserAuthentication(
- bool multiuserAuthentication) {
- getPoolFactory()->setMultiuserAuthentication(multiuserAuthentication);
- return shared_from_this();
-}
-
-CacheFactoryPtr CacheFactory::setPRSingleHopEnabled(bool enabled) {
- getPoolFactory()->setPRSingleHopEnabled(enabled);
- return shared_from_this();
-}
-
CacheFactoryPtr CacheFactory::setPdxIgnoreUnreadFields(bool ignore) {
ignorePdxUnreadFields = ignore;
return shared_from_this();
[17/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientNotificationWithDeltaWithoutcache.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientNotificationWithDeltaWithoutcache.cpp b/src/cppcache/integration-test/testThinClientNotificationWithDeltaWithoutcache.cpp
index a206a29..5dfc70b 100644
--- a/src/cppcache/integration-test/testThinClientNotificationWithDeltaWithoutcache.cpp
+++ b/src/cppcache/integration-test/testThinClientNotificationWithDeltaWithoutcache.cpp
@@ -26,6 +26,11 @@
#include "DeltaEx.hpp"
#include "fw_dunit.hpp"
#include <string>
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
+
+
using namespace apache::geode::client;
using namespace test;
@@ -105,7 +110,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, CreateClient1)
createPooledRegion(regionNames[0], USE_ACK, locatorsG, "__TESTPOOL1_", true,
false); // without LRU
try {
- Serializable::registerType(DeltaEx::create);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->addType(DeltaEx::create);
} catch (IllegalStateException&) {
// ignore exception caused by type reregistration.
}
@@ -117,7 +123,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, CreateClient1_NoPools)
initClientNoPools();
createRegionCachingDisabled(regionNames[0], USE_ACK, true); // without LRU
try {
- Serializable::registerType(DeltaEx::create);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->addType(DeltaEx::create);
} catch (IllegalStateException&) {
// ignore exception caused by type reregistration.
}
@@ -130,7 +137,8 @@ DUNIT_TASK_DEFINITION(CLIENT2, CreateClient2)
createPooledRegion(regionNames[0], USE_ACK, locatorsG, "__TESTPOOL1_", true,
false);
try {
- Serializable::registerType(DeltaEx::create);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->addType(DeltaEx::create);
} catch (IllegalStateException&) {
// ignore exception caused by type reregistration.
}
@@ -144,7 +152,8 @@ DUNIT_TASK_DEFINITION(CLIENT2, CreateClient2_NoPools)
initClientNoPools();
createRegionCachingDisabled(regionNames[0], USE_ACK, true); // without LRU
try {
- Serializable::registerType(DeltaEx::create);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->addType(DeltaEx::create);
} catch (IllegalStateException&) {
// ignore exception caused by type reregistration.
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientPRSingleHop.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientPRSingleHop.cpp b/src/cppcache/integration-test/testThinClientPRSingleHop.cpp
index afcec63..da68451 100644
--- a/src/cppcache/integration-test/testThinClientPRSingleHop.cpp
+++ b/src/cppcache/integration-test/testThinClientPRSingleHop.cpp
@@ -14,17 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include "fw_dunit.hpp"
-#include <geode/GeodeCppCache.hpp>
-#include "BuiltinCacheableWrappers.hpp"
-#include <Utils.hpp>
-#include <geode/statistics/StatisticsFactory.hpp>
+#include <string>
+
#include <ace/OS.h>
#include <ace/High_Res_Timer.h>
-
#include <ace/ACE.h>
-#include <string>
+#include <geode/GeodeCppCache.hpp>
+#include <geode/statistics/StatisticsFactory.hpp>
+
+#include "fw_dunit.hpp"
+#include "BuiltinCacheableWrappers.hpp"
+#include "Utils.hpp"
#define ROOT_NAME "testThinClientPRSingleHop"
#define ROOT_SCOPE DISTRIBUTED_ACK
@@ -172,7 +173,8 @@ class putThread : public ACE_Task_Base {
}
}
LOG("releaseThreadLocalConnection PutThread");
- PoolPtr pool = PoolManager::find("__TEST_POOL1__");
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find("__TEST_POOL1__");
pool->releaseThreadLocalConnection();
LOG("releaseThreadLocalConnection PutThread done");
return 0;
@@ -302,10 +304,10 @@ DUNIT_TASK_DEFINITION(CLIENT1, WarmUpTask)
if (networkhop) {
failureCount++;
}
- StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
- StatisticsType* type = factory->findType("RegionStatistics");
+ auto factory = cacheHelper->getCache()->getStatisticsFactory();
+ auto type = factory->findType("RegionStatistics");
if (type) {
- Statistics* rStats = factory->findFirstStatisticsByType(type);
+ auto rStats = factory->findFirstStatisticsByType(type);
if (rStats) {
metadatarefreshCount =
rStats->getInt((char*)"metaDataRefreshCount");
@@ -383,10 +385,10 @@ DUNIT_TASK_DEFINITION(CLIENT1, WarmUpTask3)
if (networkhop) {
failureCount++;
}
- StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
- StatisticsType* type = factory->findType("RegionStatistics");
+ auto factory = cacheHelper->getCache()->getStatisticsFactory();
+ auto type = factory->findType("RegionStatistics");
if (type) {
- Statistics* rStats = factory->findFirstStatisticsByType(type);
+ auto rStats = factory->findFirstStatisticsByType(type);
if (rStats) {
metadatarefreshCount =
rStats->getInt((char*)"metaDataRefreshCount");
@@ -1158,7 +1160,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, CloseCache1)
{
- PoolPtr pool = PoolManager::find("__TEST_POOL1__");
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find("__TEST_POOL1__");
if (pool->getThreadLocalConnections()) {
LOG("releaseThreadLocalConnection1 doing...");
pool->releaseThreadLocalConnection();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientPRSingleHopServerGroup.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientPRSingleHopServerGroup.cpp b/src/cppcache/integration-test/testThinClientPRSingleHopServerGroup.cpp
index 8e21576..8fa2232 100644
--- a/src/cppcache/integration-test/testThinClientPRSingleHopServerGroup.cpp
+++ b/src/cppcache/integration-test/testThinClientPRSingleHopServerGroup.cpp
@@ -14,17 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include "fw_dunit.hpp"
-#include <geode/GeodeCppCache.hpp>
-#include "BuiltinCacheableWrappers.hpp"
-#include <Utils.hpp>
-#include <geode/statistics/StatisticsFactory.hpp>
+#include <string>
+
#include <ace/OS.h>
#include <ace/High_Res_Timer.h>
-
#include <ace/ACE.h>
-#include <string>
+#include <geode/GeodeCppCache.hpp>
+#include <geode/statistics/StatisticsFactory.hpp>
+
+#include "fw_dunit.hpp"
+#include "BuiltinCacheableWrappers.hpp"
+#include "Utils.hpp"
#define ROOT_NAME "testThinClientPRSingleHopServerGroup"
#define ROOT_SCOPE DISTRIBUTED_ACK
@@ -112,8 +113,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, CheckPrSingleHopForIntKeysTask_CLIENT1)
ASSERT(serverGroupFlag != 2,
"serverGroupFlag should not be equal to 2");
- StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
- StatisticsType* type = factory->findType("RegionStatistics");
+ auto factory = cacheHelper->getCache()->getStatisticsFactory();
+ auto type = factory->findType("RegionStatistics");
if (type) {
Statistics* rStats = factory->findFirstStatisticsByType(type);
if (rStats) {
@@ -287,8 +288,8 @@ DUNIT_TASK_DEFINITION(CLIENT2, CheckPrSingleHopForIntKeysTask_CLIENT2)
ASSERT(serverGroupFlag != 2,
"serverGroupFlag should not be equal to 2");
- StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
- StatisticsType* type = factory->findType("RegionStatistics");
+ auto factory = cacheHelper->getCache()->getStatisticsFactory();
+ auto type = factory->findType("RegionStatistics");
if (type) {
Statistics* rStats = factory->findFirstStatisticsByType(type);
if (rStats) {
@@ -453,8 +454,8 @@ DUNIT_TASK_DEFINITION(CLIENT3, CheckPrSingleHopForIntKeysTask_CLIENT3)
ASSERT(serverGroupFlag != 2,
"serverGroupFlag should not be equal to 2");
- StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
- StatisticsType* type = factory->findType("RegionStatistics");
+ auto factory = cacheHelper->getCache()->getStatisticsFactory();
+ auto type = factory->findType("RegionStatistics");
if (type) {
Statistics* rStats = factory->findFirstStatisticsByType(type);
if (rStats) {
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientPdxDeltaWithNotification.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientPdxDeltaWithNotification.cpp b/src/cppcache/integration-test/testThinClientPdxDeltaWithNotification.cpp
index c498e5f..2dc2dd5 100644
--- a/src/cppcache/integration-test/testThinClientPdxDeltaWithNotification.cpp
+++ b/src/cppcache/integration-test/testThinClientPdxDeltaWithNotification.cpp
@@ -26,6 +26,9 @@
#include "DeltaEx.hpp"
#include "fw_dunit.hpp"
#include <string>
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
using namespace apache::geode::client;
using namespace test;
@@ -189,7 +192,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, Client1_PdxInit)
{
try {
- Serializable::registerPdxType(PdxDeltaEx::createDeserializable);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->addPdxType(PdxDeltaEx::createDeserializable);
} catch (IllegalStateException&) {
// ignore type reregistration exception.
}
@@ -199,7 +203,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, Client2_PdxInit)
{
try {
- Serializable::registerPdxType(PdxDeltaEx::createDeserializable);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->addPdxType(PdxDeltaEx::createDeserializable);
} catch (IllegalStateException&) {
// ignore type reregistration exception.
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientPdxEnum.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientPdxEnum.cpp b/src/cppcache/integration-test/testThinClientPdxEnum.cpp
index 17ecb1d..8d8ea75 100644
--- a/src/cppcache/integration-test/testThinClientPdxEnum.cpp
+++ b/src/cppcache/integration-test/testThinClientPdxEnum.cpp
@@ -105,7 +105,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, pdxEnumQuery)
LOG("pdxEnumQuery started ");
try {
- Serializable::registerPdxType(PdxEnumTestClass::createDeserializable);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->addPdxType(PdxEnumTestClass::createDeserializable);
LOG("PdxEnumTestClass Registered Successfully....");
} catch (apache::geode::client::IllegalStateException& /* ex*/) {
LOG("PdxEnumTestClass IllegalStateException");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testThinClientPdxInstance.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientPdxInstance.cpp b/src/cppcache/integration-test/testThinClientPdxInstance.cpp
index d832d7d..2899b1f 100644
--- a/src/cppcache/integration-test/testThinClientPdxInstance.cpp
+++ b/src/cppcache/integration-test/testThinClientPdxInstance.cpp
@@ -28,9 +28,10 @@
#define ROOT_SCOPE DISTRIBUTED_ACK
#include "CacheHelper.hpp"
-
+#include "CacheImpl.hpp"
#include <ace/Date_Time.h>
-
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
using namespace apache::geode::client;
using namespace test;
using namespace testobject;
@@ -228,7 +229,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, putPdxWithIdentityField)
LOG("putPdxWithIdentityField started ");
try {
- Serializable::registerPdxType(SerializePdx::createDeserializable);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->addPdxType(SerializePdx::createDeserializable);
LOG("SerializePdx Registered Successfully....");
} catch (apache::geode::client::IllegalStateException& /* ex*/) {
LOG("SerializePdx IllegalStateException");
@@ -251,7 +253,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, putCacheableObjectArrayWithPdxFields)
LOG("putCacheableObjectArrayWithPdxFields started ");
try {
- Serializable::registerPdxType(Address::createDeserializable);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->addPdxType(Address::createDeserializable);
LOG("Address Registered Successfully....");
} catch (apache::geode::client::IllegalStateException& /* ex*/) {
LOG("Address IllegalStateException");
@@ -285,7 +288,8 @@ DUNIT_TASK_DEFINITION(CLIENT2, verifyPdxIdentityField)
LOG("verifyPdxIdentityField started ");
try {
- Serializable::registerPdxType(SerializePdx::createDeserializable);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->addPdxType(SerializePdx::createDeserializable);
LOG("SerializePdx Registered Successfully....");
} catch (apache::geode::client::IllegalStateException& /* ex*/) {
LOG("SerializePdx IllegalStateException");
@@ -303,23 +307,29 @@ DUNIT_TASK_DEFINITION(CLIENT2, verifyPdxIdentityField)
LOGINFO(
"pdxInstanceDeserializations for (PdxTests.PdxType) PdxInstance = %d ",
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializations());
- LOGINFO("pdxInstanceCreations for (PdxTests.PdxType) PdxInstance = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxInstanceCreations());
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializations());
+ LOGINFO(
+ "pdxInstanceCreations for (PdxTests.PdxType) PdxInstance = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxInstanceCreations());
LOGINFO(
"pdxInstanceDeserializationTime for(PdxTests.PdxType) PdxInstance = "
"%d ",
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializationTime());
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializationTime());
ASSERT(lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializations() == 0,
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializations() == 0,
"pdxInstanceDeserialization should be equal to 0.");
- ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxInstanceCreations() == 1,
- "pdxInstanceCreations should be equal to 1.");
ASSERT(lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializationTime() > 0,
+ ->getCachePerfStats()
+ .getPdxInstanceCreations() == 1,
+ "pdxInstanceCreations should be equal to 1.");
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializationTime() > 0,
"pdxInstanceDeserializationTime should be greater than equal to 0.");
ASSERT(pi->getFieldNames()->length() == 4,
@@ -358,23 +368,29 @@ DUNIT_TASK_DEFINITION(CLIENT2, verifyPdxIdentityField)
LOGINFO(
"pdxInstanceDeserializations for (PdxTests.PdxType) PdxInstance = %d ",
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializations());
- LOGINFO("pdxInstanceCreations for (PdxTests.PdxType) PdxInstance = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxInstanceCreations());
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializations());
+ LOGINFO(
+ "pdxInstanceCreations for (PdxTests.PdxType) PdxInstance = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxInstanceCreations());
LOGINFO(
"pdxInstanceDeserializationTime for(PdxTests.PdxType) PdxInstance = "
"%d ",
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializationTime());
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializationTime());
ASSERT(lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializations() == 0,
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializations() == 0,
"pdxInstanceDeserialization should be equal to 0.");
- ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxInstanceCreations() == 2,
- "pdxInstanceCreations should be equal to 2.");
ASSERT(lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializationTime() > 0,
+ ->getCachePerfStats()
+ .getPdxInstanceCreations() == 2,
+ "pdxInstanceCreations should be equal to 2.");
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializationTime() > 0,
"pdxInstanceDeserializationTime should be greater than 0.");
bool ret = false;
@@ -391,7 +407,8 @@ DUNIT_TASK_DEFINITION(CLIENT2, verifyCacheableObjectArrayWithPdxField)
LOG("verifyCacheableObjectArrayWithPdxField started ");
try {
- Serializable::registerPdxType(Address::createDeserializable);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->addPdxType(Address::createDeserializable);
LOG("Address Registered Successfully....");
} catch (apache::geode::client::IllegalStateException& /* ex*/) {
LOG("Address IllegalStateException");
@@ -505,9 +522,9 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, pdxPut)
{
LOG("pdxPut started ");
-
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
try {
- Serializable::registerPdxType(PdxTests::PdxType::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxType::createDeserializable);
LOG("PdxObject Registered Successfully....");
} catch (apache::geode::client::IllegalStateException& /* ex*/) {
LOG("PdxObject IllegalStateException");
@@ -532,23 +549,29 @@ DUNIT_TASK_DEFINITION(CLIENT1, pdxPut)
LOGINFO(
"pdxInstanceDeserializations for (PdxTests.PdxType) PdxInstance = %d ",
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializations());
- LOGINFO("pdxInstanceCreations for (PdxTests.PdxType) PdxInstance = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxInstanceCreations());
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializations());
+ LOGINFO(
+ "pdxInstanceCreations for (PdxTests.PdxType) PdxInstance = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxInstanceCreations());
LOGINFO(
"pdxInstanceDeserializationTime for(PdxTests.PdxType) PdxInstance = "
"%d ",
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializationTime());
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializationTime());
ASSERT(lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializations() == 0,
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializations() == 0,
"pdxInstanceDeserialization should be equal to 0.");
- ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxInstanceCreations() == 1,
- "pdxInstanceCreations should be equal to 1.");
ASSERT(lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializationTime() > 0,
+ ->getCachePerfStats()
+ .getPdxInstanceCreations() == 1,
+ "pdxInstanceCreations should be equal to 1.");
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializationTime() > 0,
"pdxInstanceDeserializationTime should be greater than 0.");
CacheableStringPtr toString = pIPtr1->toString();
@@ -582,23 +605,23 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, getObject)
{
LOG("getObject started ");
-
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
try {
- Serializable::registerPdxType(PdxTests::PdxType::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxType::createDeserializable);
LOG("PdxObject Registered Successfully....");
} catch (apache::geode::client::IllegalStateException& /* ex*/) {
LOG("PdxObject IllegalStateException");
}
try {
- Serializable::registerPdxType(ChildPdx::createDeserializable);
+ serializationRegistry->addPdxType(ChildPdx::createDeserializable);
LOG("ChildPdx Registered Successfully....");
} catch (apache::geode::client::IllegalStateException& /* ex*/) {
LOG("ChildPdx IllegalStateException");
}
try {
- Serializable::registerPdxType(ParentPdx::createDeserializable);
+ serializationRegistry->addPdxType(ParentPdx::createDeserializable);
LOG("ParentPdx Registered Successfully....");
} catch (apache::geode::client::IllegalStateException& /* ex*/) {
LOG("ParentPdx IllegalStateException");
@@ -625,22 +648,29 @@ DUNIT_TASK_DEFINITION(CLIENT2, getObject)
LOGINFO(
"pdxInstanceDeserializations for (PdxTests.PdxType) PdxInstance = %d ",
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializations());
- LOGINFO("pdxInstanceCreations for (PdxTests.PdxType) PdxInstance = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxInstanceCreations());
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializations());
+ LOGINFO(
+ "pdxInstanceCreations for (PdxTests.PdxType) PdxInstance = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxInstanceCreations());
LOGINFO(
"pdxInstanceDeserializationTime for(PdxTests.PdxType) PdxInstance = "
"%d ",
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializationTime());
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializationTime());
ASSERT(lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializations() == 1,
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializations() == 1,
"pdxInstanceDeserialization should be equal to 1.");
- ASSERT(lregPtr->getCacheImpl()->m_cacheStats->getPdxInstanceCreations() > 1,
- "pdxInstanceCreations should be greater than 1.");
+ ASSERT(
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxInstanceCreations() >
+ 1,
+ "pdxInstanceCreations should be greater than 1.");
ASSERT(lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializationTime() > 0,
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializationTime() > 0,
"pdxInstanceDeserializationTime should be greater than 0.");
auto ptorig = std::make_shared<PdxTests::PdxType>();
@@ -663,22 +693,29 @@ DUNIT_TASK_DEFINITION(CLIENT2, getObject)
LOGINFO(
"pdxInstanceDeserializations for (PdxTests.PdxType) PdxInstance = %d ",
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializations());
- LOGINFO("pdxInstanceCreations for (PdxTests.PdxType) PdxInstance = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxInstanceCreations());
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializations());
+ LOGINFO(
+ "pdxInstanceCreations for (PdxTests.PdxType) PdxInstance = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxInstanceCreations());
LOGINFO(
"pdxInstanceDeserializationTime for(PdxTests.PdxType) PdxInstance = "
"%d ",
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializationTime());
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializationTime());
ASSERT(lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializations() == 2,
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializations() == 2,
"pdxInstanceDeserialization should be equal to 2.");
- ASSERT(lregPtr->getCacheImpl()->m_cacheStats->getPdxInstanceCreations() > 1,
- "pdxInstanceCreations should be greater than 1.");
+ ASSERT(
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxInstanceCreations() >
+ 1,
+ "pdxInstanceCreations should be greater than 1.");
ASSERT(lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializationTime() > 0,
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializationTime() > 0,
"pdxInstanceDeserializationTime should be greater than 0.");
auto parentPdxObj = std::make_shared<ParentPdx>(1);
@@ -700,7 +737,8 @@ DUNIT_TASK_DEFINITION(CLIENT2, verifyPdxInstanceEquals)
LOG("Task verifyPdxInstanceEquals started.");
try {
- Serializable::registerPdxType(PdxTests::PdxType::createDeserializable);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->addPdxType(PdxTests::PdxType::createDeserializable);
LOG("PdxObject Registered Successfully....");
} catch (apache::geode::client::IllegalStateException& /* ex*/) {
LOG("PdxObject IllegalStateException");
@@ -762,16 +800,16 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, accessPdxInstance)
{
LOG("accessPdxInstance started ");
-
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
try {
- Serializable::registerPdxType(PdxTests::PdxType::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxType::createDeserializable);
LOG("PdxObject Registered Successfully....");
} catch (apache::geode::client::IllegalStateException& /* ex*/) {
LOG("PdxObject IllegalStateException");
}
try {
- Serializable::registerPdxType(Address::createDeserializable);
+ serializationRegistry->addPdxType(Address::createDeserializable);
LOG("Address Registered Successfully....");
} catch (apache::geode::client::IllegalStateException& /* ex*/) {
LOG("Address IllegalStateException");
@@ -1998,23 +2036,29 @@ DUNIT_TASK_DEFINITION(CLIENT2, modifyPdxInstanceAndCheckLocally)
LOGINFO(
"pdxInstanceDeserializations for (PdxTests.PdxType) PdxInstance = %d ",
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializations());
- LOGINFO("pdxInstanceCreations for (PdxTests.PdxType) PdxInstance = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxInstanceCreations());
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializations());
+ LOGINFO(
+ "pdxInstanceCreations for (PdxTests.PdxType) PdxInstance = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxInstanceCreations());
LOGINFO(
"pdxInstanceDeserializationTime for(PdxTests.PdxType) PdxInstance = "
"%d ",
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializationTime());
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializationTime());
ASSERT(lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializations() == 0,
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializations() == 0,
"pdxInstanceDeserialization should be equal to 0.");
- ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxInstanceCreations() == 1,
- "pdxInstanceCreations should be equal to 1.");
ASSERT(lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializationTime() > 0,
+ ->getCachePerfStats()
+ .getPdxInstanceCreations() == 1,
+ "pdxInstanceCreations should be equal to 1.");
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializationTime() > 0,
"pdxInstanceDeserializationTime should be greater than 0.");
WritablePdxInstancePtr wpiPtr(pIPtr->createWriter());
@@ -2328,30 +2372,30 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, pdxIFPutGetTest)
{
LOG("pdxIFPutGetTest started ");
-
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
try {
- Serializable::registerPdxType(Address::createDeserializable);
+ serializationRegistry->addPdxType(Address::createDeserializable);
LOG("Address Registered Successfully....");
} catch (apache::geode::client::IllegalStateException& /* ex*/) {
LOG("Address IllegalStateException");
}
try {
- Serializable::registerPdxType(PdxTests::PdxType::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxType::createDeserializable);
LOG("PdxObject Registered Successfully....");
} catch (apache::geode::client::IllegalStateException& /* ex*/) {
LOG("PdxObject IllegalStateException");
}
try {
- Serializable::registerPdxType(ChildPdx::createDeserializable);
+ serializationRegistry->addPdxType(ChildPdx::createDeserializable);
LOG("ChildPdx Registered Successfully....");
} catch (apache::geode::client::IllegalStateException& /* ex*/) {
LOG("ChildPdx IllegalStateException");
}
try {
- Serializable::registerPdxType(ParentPdx::createDeserializable);
+ serializationRegistry->addPdxType(ParentPdx::createDeserializable);
LOG("ParentPdx Registered Successfully....");
} catch (apache::geode::client::IllegalStateException& /* ex*/) {
LOG("ParentPdx IllegalStateException");
@@ -2483,23 +2527,29 @@ DUNIT_TASK_DEFINITION(CLIENT1, pdxIFPutGetTest)
LOGINFO(
"pdxInstanceDeserializations for (PdxTests.PdxType) PdxInstance = %d ",
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializations());
- LOGINFO("pdxInstanceCreations for (PdxTests.PdxType) PdxInstance = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxInstanceCreations());
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializations());
+ LOGINFO(
+ "pdxInstanceCreations for (PdxTests.PdxType) PdxInstance = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxInstanceCreations());
LOGINFO(
"pdxInstanceDeserializationTime for(PdxTests.PdxType) PdxInstance = "
"%d ",
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializationTime());
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializationTime());
ASSERT(lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializations() == 1,
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializations() == 1,
"pdxInstanceDeserialization should be equal to 1.");
- ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxInstanceCreations() == 0,
- "pdxInstanceCreations should be equal to 0.");
ASSERT(lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializationTime() == 0,
+ ->getCachePerfStats()
+ .getPdxInstanceCreations() == 0,
+ "pdxInstanceCreations should be equal to 0.");
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializationTime() == 0,
"pdxInstanceDeserializationTime should be equal to 0.");
PdxTests::PdxType* obj2 = pdxobj.get();
@@ -2519,23 +2569,29 @@ DUNIT_TASK_DEFINITION(CLIENT1, pdxIFPutGetTest)
LOGINFO(
"pdxInstanceDeserializations for (PdxTests.PdxType) PdxInstance = %d ",
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializations());
- LOGINFO("pdxInstanceCreations for (PdxTests.PdxType) PdxInstance = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxInstanceCreations());
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializations());
+ LOGINFO(
+ "pdxInstanceCreations for (PdxTests.PdxType) PdxInstance = %d ",
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxInstanceCreations());
LOGINFO(
"pdxInstanceDeserializationTime for(PdxTests.PdxType) PdxInstance = "
"%d ",
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializationTime());
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializationTime());
ASSERT(lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializations() == 1,
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializations() == 1,
"pdxInstanceDeserialization should be equal to 1.");
- ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxInstanceCreations() == 0,
- "pdxInstanceCreations should be equal to 0.");
ASSERT(lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializationTime() > 0,
+ ->getCachePerfStats()
+ .getPdxInstanceCreations() == 0,
+ "pdxInstanceCreations should be equal to 0.");
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializationTime() > 0,
"pdxInstanceDeserializationTime should be greater than 0.");
PdxTests::PdxType* obj3 = dynamic_cast<PdxTests::PdxType*>(newPiPtr.get());
@@ -2592,25 +2648,30 @@ DUNIT_TASK_DEFINITION(CLIENT1, pdxIFPutGetTest)
"= "
"%d ",
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializations());
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializations());
LOGINFO(
"pdxInstanceCreations for (testobject::ParentPdx) PdxInstance = %d ",
- lregPtr->getCacheImpl()->m_cacheStats->getPdxInstanceCreations());
+ lregPtr->getCacheImpl()->getCachePerfStats().getPdxInstanceCreations());
LOGINFO(
"pdxInstanceDeserializationTime for(testobject::ParentPdx) PdxInstance "
" "
"= %d ",
lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializationTime());
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializationTime());
ASSERT(lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializations() == 1,
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializations() == 1,
"pdxInstanceDeserialization should be equal to 1.");
- ASSERT(
- lregPtr->getCacheImpl()->m_cacheStats->getPdxInstanceCreations() == 0,
- "pdxInstanceCreations should be equal to 0.");
ASSERT(lregPtr->getCacheImpl()
- ->m_cacheStats->getPdxInstanceDeserializationTime() > 0,
+ ->getCachePerfStats()
+ .getPdxInstanceCreations() == 0,
+ "pdxInstanceCreations should be equal to 0.");
+ ASSERT(lregPtr->getCacheImpl()
+ ->getCachePerfStats()
+ .getPdxInstanceDeserializationTime() > 0,
"pdxInstanceDeserializationTime should be greater than 0.");
auto pp1 = std::dynamic_pointer_cast<ParentPdx>(newPiPtr);
[11/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PdxInstanceImpl.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PdxInstanceImpl.cpp b/src/cppcache/src/PdxInstanceImpl.cpp
index 401db41..5ce5e43 100644
--- a/src/cppcache/src/PdxInstanceImpl.cpp
+++ b/src/cppcache/src/PdxInstanceImpl.cpp
@@ -23,7 +23,6 @@
#include <geode/PdxReader.hpp>
#include "CacheRegionHelper.hpp"
#include <geode/Cache.hpp>
-#include "CacheImpl.hpp"
#include "Utils.hpp"
#include <algorithm>
@@ -78,23 +77,21 @@ PdxInstanceImpl::~PdxInstanceImpl() { GF_SAFE_DELETE_ARRAY(m_buffer); }
PdxInstanceImpl::PdxInstanceImpl(
apache::geode::client::FieldVsValues fieldVsValue,
- apache::geode::client::PdxTypePtr pdxType) {
- m_pdxType = pdxType;
- m_updatedFields = fieldVsValue;
- m_buffer = nullptr;
- m_bufferLength = 0;
- m_typeId = 0;
-
+ apache::geode::client::PdxTypePtr pdxType, CachePerfStats* cacheStats,
+ PdxTypeRegistryPtr pdxTypeRegistry, const Cache* cache,
+ bool enableTimeStatistics)
+ : m_pdxType(pdxType),
+ m_updatedFields(fieldVsValue),
+ m_buffer(nullptr),
+ m_bufferLength(0),
+ m_typeId(0),
+ m_cacheStats(cacheStats),
+ m_pdxTypeRegistry(pdxTypeRegistry),
+ m_cache(cache),
+ m_enableTimeStatistics(enableTimeStatistics) {
m_pdxType->InitializeType(); // to generate static position map
}
-PdxInstanceImpl::PdxInstanceImpl() {
- m_pdxType = nullptr;
- m_buffer = nullptr;
- m_bufferLength = 0;
- m_typeId = 0;
-}
-
void PdxInstanceImpl::writeField(PdxWriterPtr writer, const char* fieldName,
int typeId, CacheablePtr value) {
switch (typeId) {
@@ -302,8 +299,9 @@ WritablePdxInstancePtr PdxInstanceImpl::createWriter() {
LOGDEBUG("PdxInstanceImpl::createWriter m_bufferLength = %d m_typeId = %d ",
m_bufferLength, m_typeId);
return std::make_shared<PdxInstanceImpl>(
- m_buffer, m_bufferLength,
- m_typeId); // need to create duplicate byte stream);
+ m_buffer, m_bufferLength, m_typeId, m_cacheStats, m_pdxTypeRegistry,
+ m_cache,
+ m_enableTimeStatistics); // need to create duplicate byte stream);
}
bool PdxInstanceImpl::enumerateObjectArrayEquals(
@@ -702,7 +700,7 @@ int32_t PdxInstanceImpl::hashcode() const {
std::vector<PdxFieldTypePtr> pdxIdentityFieldList = getIdentityPdxFields(pt);
- DataInput dataInput(m_buffer, m_bufferLength);
+ auto dataInput = m_cache->createDataInput(m_buffer, m_bufferLength);
for (uint32_t i = 0; i < pdxIdentityFieldList.size(); i++) {
PdxFieldTypePtr pField = pdxIdentityFieldList.at(i);
@@ -730,23 +728,23 @@ int32_t PdxInstanceImpl::hashcode() const {
case PdxFieldTypes::DOUBLE_ARRAY:
case PdxFieldTypes::STRING_ARRAY:
case PdxFieldTypes::ARRAY_OF_BYTE_ARRAYS: {
- int retH = getRawHashCode(pt, pField, dataInput);
+ int retH = getRawHashCode(pt, pField, *dataInput);
if (retH != 0) hashCode = 31 * hashCode + retH;
break;
}
case PdxFieldTypes::OBJECT: {
- setOffsetForObject(dataInput, pt, pField->getSequenceId());
+ setOffsetForObject(*dataInput, pt, pField->getSequenceId());
CacheablePtr object = nullptr;
- dataInput.readObject(object);
+ dataInput->readObject(object);
if (object != nullptr) {
hashCode = 31 * hashCode + deepArrayHashCode(object);
}
break;
}
case PdxFieldTypes::OBJECT_ARRAY: {
- setOffsetForObject(dataInput, pt, pField->getSequenceId());
+ setOffsetForObject(*dataInput, pt, pField->getSequenceId());
CacheableObjectArrayPtr objectArray = CacheableObjectArray::create();
- objectArray->fromData(dataInput);
+ objectArray->fromData(*dataInput);
hashCode =
31 * hashCode +
((objectArray != nullptr) ? deepArrayHashCode(objectArray) : 0);
@@ -785,7 +783,7 @@ PdxTypePtr PdxInstanceImpl::getPdxType() const {
}
return m_pdxType;
}
- PdxTypePtr pType = PdxTypeRegistry::getPdxType(m_typeId);
+ auto pType = getPdxTypeRegistry()->getPdxType(m_typeId);
return pType;
}
@@ -805,358 +803,180 @@ bool PdxInstanceImpl::hasField(const char* fieldname) {
}
void PdxInstanceImpl::getField(const char* fieldname, bool& value) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
-
- VERIFY_PDX_INSTANCE_FIELD_THROW;
-
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
-
- dataInput.reset();
- dataInput.advanceCursor(pos);
- dataInput.readBoolean(&value);
+ auto dataInput = getDataInputForField(fieldname);
+ dataInput->readBoolean(&value);
}
void PdxInstanceImpl::getField(const char* fieldname,
signed char& value) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
-
- VERIFY_PDX_INSTANCE_FIELD_THROW;
-
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
-
- dataInput.reset();
- dataInput.advanceCursor(pos);
+ auto dataInput = getDataInputForField(fieldname);
int8_t tmp = 0;
- dataInput.read(&tmp);
+ dataInput->read(&tmp);
value = (signed char)tmp;
}
void PdxInstanceImpl::getField(const char* fieldname,
unsigned char& value) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
-
- VERIFY_PDX_INSTANCE_FIELD_THROW;
-
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
-
- dataInput.reset();
- dataInput.advanceCursor(pos);
+ auto dataInput = getDataInputForField(fieldname);
int8_t tmp = 0;
- dataInput.read(&tmp);
+ dataInput->read(&tmp);
value = static_cast<unsigned char>(tmp);
}
void PdxInstanceImpl::getField(const char* fieldname, int16_t& value) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
- dataInput.readInt(&value);
+ auto dataInput = getDataInputForField(fieldname);
+ dataInput->readInt(&value);
}
void PdxInstanceImpl::getField(const char* fieldname, int32_t& value) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
-
- dataInput.reset();
- dataInput.advanceCursor(pos);
- dataInput.readInt(&value);
+ auto dataInput = getDataInputForField(fieldname);
+ dataInput->readInt(&value);
}
void PdxInstanceImpl::getField(const char* fieldname, int64_t& value) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
- dataInput.readInt(&value);
+ auto dataInput = getDataInputForField(fieldname);
+ dataInput->readInt(&value);
}
void PdxInstanceImpl::getField(const char* fieldname, float& value) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
- dataInput.readFloat(&value);
+ auto dataInput = getDataInputForField(fieldname);
+ dataInput->readFloat(&value);
}
void PdxInstanceImpl::getField(const char* fieldname, double& value) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
- dataInput.readDouble(&value);
+ auto dataInput = getDataInputForField(fieldname);
+ dataInput->readDouble(&value);
}
void PdxInstanceImpl::getField(const char* fieldname, wchar_t& value) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
+ auto dataInput = getDataInputForField(fieldname);
uint16_t temp = 0;
- dataInput.readInt(&temp);
+ dataInput->readInt(&temp);
value = static_cast<wchar_t>(temp);
}
void PdxInstanceImpl::getField(const char* fieldname, char& value) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
+ auto dataInput = getDataInputForField(fieldname);
uint16_t temp = 0;
- dataInput.readInt(&temp);
+ dataInput->readInt(&temp);
value = static_cast<char>(temp);
}
void PdxInstanceImpl::getField(const char* fieldname, bool** value,
int32_t& length) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
- dataInput.readBooleanArray(value, length);
+ auto dataInput = getDataInputForField(fieldname);
+ dataInput->readBooleanArray(value, length);
}
void PdxInstanceImpl::getField(const char* fieldname, signed char** value,
int32_t& length) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
+ auto dataInput = getDataInputForField(fieldname);
int8_t* temp = nullptr;
- dataInput.readByteArray(&temp, length);
+ dataInput->readByteArray(&temp, length);
*value = (signed char*)temp;
}
void PdxInstanceImpl::getField(const char* fieldname, unsigned char** value,
int32_t& length) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
+ auto dataInput = getDataInputForField(fieldname);
int8_t* temp = nullptr;
- dataInput.readByteArray(&temp, length);
+ dataInput->readByteArray(&temp, length);
*value = reinterpret_cast<unsigned char*>(temp);
}
void PdxInstanceImpl::getField(const char* fieldname, int16_t** value,
int32_t& length) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
- dataInput.readShortArray(value, length);
+ auto dataInput = getDataInputForField(fieldname);
+ dataInput->readShortArray(value, length);
}
void PdxInstanceImpl::getField(const char* fieldname, int32_t** value,
int32_t& length) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
- dataInput.readIntArray(value, length);
+ auto dataInput = getDataInputForField(fieldname);
+ dataInput->readIntArray(value, length);
}
void PdxInstanceImpl::getField(const char* fieldname, int64_t** value,
int32_t& length) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
- dataInput.readLongArray(value, length);
+ auto dataInput = getDataInputForField(fieldname);
+ dataInput->readLongArray(value, length);
}
void PdxInstanceImpl::getField(const char* fieldname, float** value,
int32_t& length) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
- dataInput.readFloatArray(value, length);
+ auto dataInput = getDataInputForField(fieldname);
+ dataInput->readFloatArray(value, length);
}
void PdxInstanceImpl::getField(const char* fieldname, double** value,
int32_t& length) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
- dataInput.readDoubleArray(value, length);
+ auto dataInput = getDataInputForField(fieldname);
+ dataInput->readDoubleArray(value, length);
}
void PdxInstanceImpl::getField(const char* fieldname, wchar_t** value,
int32_t& length) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
- dataInput.readWideCharArray(value, length);
+ auto dataInput = getDataInputForField(fieldname);
+ dataInput->readWideCharArray(value, length);
}
void PdxInstanceImpl::getField(const char* fieldname, char** value,
int32_t& length) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
- dataInput.readCharArray(value, length);
+ auto dataInput = getDataInputForField(fieldname);
+ dataInput->readCharArray(value, length);
}
void PdxInstanceImpl::getField(const char* fieldname, wchar_t** value) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
+ auto dataInput = getDataInputForField(fieldname);
wchar_t* temp = nullptr;
- dataInput.readWideString(&temp);
+ dataInput->readWideString(&temp);
*value = temp;
}
void PdxInstanceImpl::getField(const char* fieldname, char** value) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
+ auto dataInput = getDataInputForField(fieldname);
char* temp = nullptr;
- dataInput.readString(&temp);
+ dataInput->readString(&temp);
*value = temp;
}
void PdxInstanceImpl::getField(const char* fieldname, wchar_t*** value,
int32_t& length) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
- dataInput.readWideStringArray(value, length);
+ auto dataInput = getDataInputForField(fieldname);
+ dataInput->readWideStringArray(value, length);
}
void PdxInstanceImpl::getField(const char* fieldname, char*** value,
int32_t& length) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
- dataInput.readStringArray(value, length);
+ auto dataInput = getDataInputForField(fieldname);
+ dataInput->readStringArray(value, length);
}
void PdxInstanceImpl::getField(const char* fieldname,
CacheableDatePtr& value) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
+ auto dataInput = getDataInputForField(fieldname);
value = CacheableDate::create();
- value->fromData(dataInput);
+ value->fromData(*dataInput);
}
void PdxInstanceImpl::getField(const char* fieldname,
CacheablePtr& value) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
- dataInput.readObject(value);
+ auto dataInput = getDataInputForField(fieldname);
+ dataInput->readObject(value);
}
void PdxInstanceImpl::getField(const char* fieldname,
CacheableObjectArrayPtr& value) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
+ auto dataInput = getDataInputForField(fieldname);
value = CacheableObjectArray::create();
- value->fromData(dataInput);
+ value->fromData(*dataInput);
}
void PdxInstanceImpl::getField(const char* fieldname, int8_t*** value,
int32_t& arrayLength,
int32_t*& elementLength) const {
- PdxTypePtr pt = getPdxType();
- PdxFieldTypePtr pft = pt->getPdxField(fieldname);
- VERIFY_PDX_INSTANCE_FIELD_THROW;
- DataInput dataInput(m_buffer, m_bufferLength);
- int pos = getOffset(dataInput, pt, pft->getSequenceId());
- dataInput.reset();
- dataInput.advanceCursor(pos);
- dataInput.readArrayOfByteArrays(value, arrayLength, &elementLength);
+ auto dataInput = getDataInputForField(fieldname);
+ dataInput->readArrayOfByteArrays(value, arrayLength, &elementLength);
}
CacheableStringPtr PdxInstanceImpl::toString() const {
@@ -1418,26 +1238,21 @@ CacheableStringPtr PdxInstanceImpl::toString() const {
}
PdxSerializablePtr PdxInstanceImpl::getObject() {
- DataInput dataInput(m_buffer, m_bufferLength);
- int64_t sampleStartNanos = Utils::startStatOpTime();
+ auto dataInput = m_cache->createDataInput(m_buffer, m_bufferLength);
+ int64_t sampleStartNanos =
+ m_enableTimeStatistics ? Utils::startStatOpTime() : 0;
//[ToDo] do we have to call incPdxDeSerialization here?
PdxSerializablePtr ret =
- PdxHelper::deserializePdx(dataInput, true, m_typeId, m_bufferLength);
- CachePtr cache = CacheFactory::getAnyInstance();
- if (cache == nullptr) {
- throw IllegalStateException("cache has not been created yet.");
- ;
- }
- if (cache->isClosed()) {
- throw IllegalStateException("cache has been closed. ");
- }
- CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(cache.get());
- if (cacheImpl != nullptr) {
- Utils::updateStatOpTime(
- cacheImpl->m_cacheStats->getStat(),
- cacheImpl->m_cacheStats->getPdxInstanceDeserializationTimeId(),
- sampleStartNanos);
- cacheImpl->m_cacheStats->incPdxInstanceDeserializations();
+ PdxHelper::deserializePdx(*dataInput, true, m_typeId, m_bufferLength);
+
+ if (m_cacheStats != nullptr) {
+ if (m_enableTimeStatistics) {
+ Utils::updateStatOpTime(
+ m_cacheStats->getStat(),
+ m_cacheStats->getPdxInstanceDeserializationTimeId(),
+ sampleStartNanos);
+ }
+ m_cacheStats->incPdxInstanceDeserializations();
}
return ret;
}
@@ -1502,8 +1317,8 @@ bool PdxInstanceImpl::operator==(const CacheableKey& other) const {
equatePdxFields(myPdxIdentityFieldList, otherPdxIdentityFieldList);
equatePdxFields(otherPdxIdentityFieldList, myPdxIdentityFieldList);
- DataInput myDataInput(m_buffer, m_bufferLength);
- DataInput otherDataInput(otherPdx->m_buffer, otherPdx->m_bufferLength);
+ auto myDataInput = m_cache->createDataInput(m_buffer, m_bufferLength);
+ auto otherDataInput = m_cache->createDataInput(otherPdx->m_buffer, otherPdx->m_bufferLength);
int fieldTypeId = -1;
for (size_t i = 0; i < myPdxIdentityFieldList.size(); i++) {
@@ -1542,8 +1357,8 @@ bool PdxInstanceImpl::operator==(const CacheableKey& other) const {
case PdxFieldTypes::DOUBLE_ARRAY:
case PdxFieldTypes::STRING_ARRAY:
case PdxFieldTypes::ARRAY_OF_BYTE_ARRAYS: {
- if (!compareRawBytes(*otherPdx, myPdxType, myPFT, myDataInput,
- otherPdxType, otherPFT, otherDataInput)) {
+ if (!compareRawBytes(*otherPdx, myPdxType, myPFT, *myDataInput,
+ otherPdxType, otherPFT, *otherDataInput)) {
return false;
}
break;
@@ -1552,14 +1367,14 @@ bool PdxInstanceImpl::operator==(const CacheableKey& other) const {
CacheablePtr object = nullptr;
CacheablePtr otherObject = nullptr;
if (!myPFT->equals(m_DefaultPdxFieldType)) {
- setOffsetForObject(myDataInput, myPdxType, myPFT->getSequenceId());
- myDataInput.readObject(object);
+ setOffsetForObject(*myDataInput, myPdxType, myPFT->getSequenceId());
+ myDataInput->readObject(object);
}
if (!otherPFT->equals(m_DefaultPdxFieldType)) {
- otherPdx->setOffsetForObject(otherDataInput, otherPdxType,
+ otherPdx->setOffsetForObject(*otherDataInput, otherPdxType,
otherPFT->getSequenceId());
- otherDataInput.readObject(otherObject);
+ otherDataInput->readObject(otherObject);
}
if (object != nullptr) {
@@ -1577,14 +1392,14 @@ bool PdxInstanceImpl::operator==(const CacheableKey& other) const {
CacheableObjectArrayPtr objectArray = CacheableObjectArray::create();
if (!myPFT->equals(m_DefaultPdxFieldType)) {
- setOffsetForObject(myDataInput, myPdxType, myPFT->getSequenceId());
- objectArray->fromData(myDataInput);
+ setOffsetForObject(*myDataInput, myPdxType, myPFT->getSequenceId());
+ objectArray->fromData(*myDataInput);
}
if (!otherPFT->equals(m_DefaultPdxFieldType)) {
- otherPdx->setOffsetForObject(otherDataInput, otherPdxType,
+ otherPdx->setOffsetForObject(*otherDataInput, otherPdxType,
otherPFT->getSequenceId());
- otherObjectArray->fromData(otherDataInput);
+ otherObjectArray->fromData(*otherDataInput);
}
if (!deepArrayEquals(objectArray, otherObjectArray)) {
return false;
@@ -1711,7 +1526,7 @@ void PdxInstanceImpl::toData(PdxWriterPtr writer) /*const*/ {
if (m_buffer != nullptr) {
uint8_t* copy = apache::geode::client::DataInput::getBufferCopy(
m_buffer, m_bufferLength);
- DataInput dataInput(copy, m_bufferLength); // this will delete buffer
+ auto dataInput = m_cache->createDataInput(copy, m_bufferLength);
for (size_t i = 0; i < pdxFieldList->size(); i++) {
PdxFieldTypePtr currPf = pdxFieldList->at(i);
LOGDEBUG("toData filedname = %s , isVarLengthType = %d ",
@@ -1727,7 +1542,7 @@ void PdxInstanceImpl::toData(PdxWriterPtr writer) /*const*/ {
}
if (value != nullptr) {
writeField(writer, currPf->getFieldName(), currPf->getTypeId(), value);
- position = getNextFieldPosition(dataInput, static_cast<int>(i) + 1, pt);
+ position = getNextFieldPosition(*dataInput, static_cast<int>(i) + 1, pt);
} else {
if (currPf->IsVariableLengthType()) {
// need to add offset
@@ -1735,8 +1550,8 @@ void PdxInstanceImpl::toData(PdxWriterPtr writer) /*const*/ {
}
// write raw byte array...
nextFieldPosition =
- getNextFieldPosition(dataInput, static_cast<int>(i) + 1, pt);
- writeUnmodifieldField(dataInput, position, nextFieldPosition,
+ getNextFieldPosition(*dataInput, static_cast<int>(i) + 1, pt);
+ writeUnmodifieldField(*dataInput, position, nextFieldPosition,
std::static_pointer_cast<PdxLocalWriter>(writer));
position = nextFieldPosition; // mark next field;
}
@@ -1761,7 +1576,7 @@ void PdxInstanceImpl::fromData(PdxReaderPtr input) {
const char* PdxInstanceImpl::getClassName() const {
if (m_typeId != 0) {
- PdxTypePtr pdxtype = PdxTypeRegistry::getPdxType(m_typeId);
+ auto pdxtype = getPdxTypeRegistry()->getPdxType(m_typeId);
if (pdxtype == nullptr) {
char excpStr[256] = {0};
ACE_OS::snprintf(excpStr, 256,
@@ -2753,6 +2568,26 @@ uint32_t PdxInstanceImpl::objectSize() const {
}
return size;
}
+
+PdxTypeRegistryPtr PdxInstanceImpl::getPdxTypeRegistry() const {
+ return m_pdxTypeRegistry;
+}
+
+std::unique_ptr<DataInput> PdxInstanceImpl::getDataInputForField(const char* fieldname) const {
+ auto pt = getPdxType();
+ auto pft = pt->getPdxField(fieldname);
+
+ VERIFY_PDX_INSTANCE_FIELD_THROW;
+
+ auto dataInput = m_cache->createDataInput(m_buffer, m_bufferLength);
+ auto pos = getOffset(*dataInput, pt, pft->getSequenceId());
+
+ dataInput->reset();
+ dataInput->advanceCursor(pos);
+
+ return dataInput;
+}
+
} // namespace client
} // namespace geode
} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PdxInstanceImpl.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PdxInstanceImpl.hpp b/src/cppcache/src/PdxInstanceImpl.hpp
index 825c89a..643400d 100644
--- a/src/cppcache/src/PdxInstanceImpl.hpp
+++ b/src/cppcache/src/PdxInstanceImpl.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_PDXINSTANCEIMPL_H_
-#define GEODE_PDXINSTANCEIMPL_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,14 +15,22 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_PDXINSTANCEIMPL_H_
+#define GEODE_PDXINSTANCEIMPL_H_
+
+#include <vector>
+#include <map>
+
#include <geode/PdxInstance.hpp>
#include <geode/WritablePdxInstance.hpp>
#include <geode/PdxSerializable.hpp>
+#include <geode/PdxFieldTypes.hpp>
+
#include "PdxType.hpp"
#include "PdxLocalWriter.hpp"
-#include <geode/PdxFieldTypes.hpp>
-#include <vector>
-#include <map>
+#include "PdxTypeRegistry.hpp"
namespace apache {
namespace geode {
@@ -48,7 +51,7 @@ class CPPCACHE_EXPORT PdxInstanceImpl : public WritablePdxInstance {
* registered.
* @return the deserialized domain object.
*
- * @see Serializable::registerPdxType
+ * @see serializationRegistry->addPdxType
*/
virtual PdxSerializablePtr getObject();
@@ -402,7 +405,7 @@ class CPPCACHE_EXPORT PdxInstanceImpl : public WritablePdxInstance {
* For deserialization C++ Native Client requires the domain class to be
* registered.
*
- * @see Serializable::registerPdxType
+ * @see serializationRegistry->addPdxType
* @see PdxInstance#hasField
*/
virtual void getField(const char* fieldname, CacheablePtr& value) const;
@@ -418,7 +421,7 @@ class CPPCACHE_EXPORT PdxInstanceImpl : public WritablePdxInstance {
* type.
* @throws IllegalStateException if PdxInstance doesn't has the named field.
*
- * @see Serializable::registerPdxType
+ * @see serializationRegistry->addPdxType
* @see PdxInstance#hasField
*/
virtual void getField(const char* fieldname,
@@ -930,7 +933,7 @@ class CPPCACHE_EXPORT PdxInstanceImpl : public WritablePdxInstance {
* @throws IllegalStateException if the field contains an element that is not
* of CacheableKey derived type.
*
- * @see Serializable::registerPdxType
+ * @see serializationRegistry->addPdxType
*/
virtual int32_t hashcode() const;
@@ -943,7 +946,7 @@ class CPPCACHE_EXPORT PdxInstanceImpl : public WritablePdxInstance {
* For deserialization C++ Native Client requires the domain class to be
* registered.
*
- * @see Serializable::registerPdxType
+ * @see serializationRegistry->addPdxType
*/
virtual CacheableStringPtr toString() const;
@@ -1000,7 +1003,7 @@ class CPPCACHE_EXPORT PdxInstanceImpl : public WritablePdxInstance {
* @throws IllegalStateException if the field contains an element that is not
* of CacheableKey derived type.
*
- * @see Serializable::registerPdxType
+ * @see serializationRegistry->addPdxType
*/
virtual bool operator==(const CacheableKey& other) const;
@@ -1047,32 +1050,46 @@ class CPPCACHE_EXPORT PdxInstanceImpl : public WritablePdxInstance {
/**
* @brief constructors
*/
- PdxInstanceImpl();
- PdxInstanceImpl(uint8_t* buffer, int length, int typeId) {
- m_buffer = DataInput::getBufferCopy(buffer, length);
- m_bufferLength = length;
+ PdxInstanceImpl(uint8_t* buffer, int length, int typeId,
+ CachePerfStats* cacheStats,
+ PdxTypeRegistryPtr pdxTypeRegistry, const Cache* cache,
+ bool enableTimeStatistics)
+ : m_buffer(DataInput::getBufferCopy(buffer, length)),
+ m_bufferLength(length),
+ m_typeId(typeId),
+ m_pdxType(nullptr),
+ m_cacheStats(cacheStats),
+ m_pdxTypeRegistry(pdxTypeRegistry),
+ m_cache(cache),
+ m_enableTimeStatistics(enableTimeStatistics) {
LOGDEBUG("PdxInstanceImpl::m_bufferLength = %d ", m_bufferLength);
- m_typeId = typeId;
- m_pdxType = nullptr;
}
- PdxInstanceImpl(FieldVsValues fieldVsValue, PdxTypePtr pdxType);
+ PdxInstanceImpl(FieldVsValues fieldVsValue, PdxTypePtr pdxType,
+ CachePerfStats* cacheStats,
+ PdxTypeRegistryPtr pdxTypeRegistry, const Cache* cache,
+ bool enableTimeStatistics);
+
+ PdxInstanceImpl(const PdxInstanceImpl& other) = delete;
+
+ void operator=(const PdxInstanceImpl& other) = delete;
PdxTypePtr getPdxType() const;
void updatePdxStream(uint8_t* newPdxStream, int len);
private:
- // never implemented.
- PdxInstanceImpl(const PdxInstanceImpl& other);
- void operator=(const PdxInstanceImpl& other);
-
uint8_t* m_buffer;
int m_bufferLength;
int m_typeId;
PdxTypePtr m_pdxType;
FieldVsValues m_updatedFields;
+ CachePerfStats* m_cacheStats;
+
+ PdxTypeRegistryPtr m_pdxTypeRegistry;
+ const Cache* m_cache;
+ bool m_enableTimeStatistics;
std::vector<PdxFieldTypePtr> getIdentityPdxFields(PdxTypePtr pt) const;
@@ -1109,6 +1126,8 @@ class CPPCACHE_EXPORT PdxInstanceImpl : public WritablePdxInstance {
void equatePdxFields(std::vector<PdxFieldTypePtr>& my,
std::vector<PdxFieldTypePtr>& other) const;
+ PdxTypeRegistryPtr getPdxTypeRegistry() const;
+
static int deepArrayHashCode(CacheablePtr obj);
static int enumerateMapHashCode(CacheableHashMapPtr map);
@@ -1150,6 +1169,8 @@ class CPPCACHE_EXPORT PdxInstanceImpl : public WritablePdxInstance {
static bool enumerateHashTableEquals(CacheableHashTablePtr Obj,
CacheableHashTablePtr OtherObj);
+ std::unique_ptr<DataInput> getDataInputForField(const char* fieldname) const;
+
static int8_t m_BooleanDefaultBytes[];
static int8_t m_ByteDefaultBytes[];
static int8_t m_CharDefaultBytes[];
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PdxLocalReader.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PdxLocalReader.cpp b/src/cppcache/src/PdxLocalReader.cpp
index 425f629..e32cf66 100644
--- a/src/cppcache/src/PdxLocalReader.cpp
+++ b/src/cppcache/src/PdxLocalReader.cpp
@@ -27,7 +27,7 @@ namespace apache {
namespace geode {
namespace client {
-PdxLocalReader::PdxLocalReader()
+PdxLocalReader::PdxLocalReader(PdxTypeRegistryPtr pdxTypeRegistry)
: m_dataInput(nullptr),
m_startBuffer(nullptr),
m_startPosition(0),
@@ -38,20 +38,21 @@ PdxLocalReader::PdxLocalReader()
m_isDataNeedToPreserve(false),
m_localToRemoteMap(nullptr),
m_remoteToLocalMap(nullptr),
- m_remoteToLocalMapSize(0) {}
+ m_remoteToLocalMapSize(0),
+ m_pdxTypeRegistry(pdxTypeRegistry) {}
PdxLocalReader::PdxLocalReader(DataInput& input, PdxTypePtr remoteType,
- int32_t pdxLen) {
- m_dataInput = &input;
- m_pdxType = remoteType;
- m_serializedLengthWithOffsets = pdxLen;
-
- m_localToRemoteMap = remoteType->getLocalToRemoteMap();
- m_remoteToLocalMap = remoteType->getRemoteToLocalMap();
- m_remoteToLocalMapSize = remoteType->getTotalFields();
-
- m_pdxRemotePreserveData = std::make_shared<PdxRemotePreservedData>();
- m_isDataNeedToPreserve = true;
+ int32_t pdxLen,
+ PdxTypeRegistryPtr pdxTypeRegistry)
+ : m_dataInput(&input),
+ m_pdxType(remoteType),
+ m_serializedLengthWithOffsets(pdxLen),
+ m_localToRemoteMap(remoteType->getLocalToRemoteMap()),
+ m_remoteToLocalMap(remoteType->getRemoteToLocalMap()),
+ m_remoteToLocalMapSize(remoteType->getTotalFields()),
+ m_pdxRemotePreserveData(std::make_shared<PdxRemotePreservedData>()),
+ m_isDataNeedToPreserve(true),
+ m_pdxTypeRegistry(pdxTypeRegistry) {
initialize();
}
@@ -303,8 +304,9 @@ PdxRemotePreservedDataPtr PdxLocalReader::getPreservedData(
LOGDEBUG(
"PdxLocalReader::getPreservedData::nFieldExtra = %d AND "
"PdxTypeRegistry::getPdxIgnoreUnreadFields = %d ",
- nFieldExtra, PdxTypeRegistry::getPdxIgnoreUnreadFields());
- if (nFieldExtra > 0 && PdxTypeRegistry::getPdxIgnoreUnreadFields() == false) {
+ nFieldExtra, m_pdxTypeRegistry->getPdxIgnoreUnreadFields());
+ if (nFieldExtra > 0 &&
+ m_pdxTypeRegistry->getPdxIgnoreUnreadFields() == false) {
m_pdxRemotePreserveData->initialize(
m_pdxType != nullptr ? m_pdxType->getTypeId() : 0,
mergedVersion->getTypeId(), nFieldExtra, pdxObject);
@@ -374,11 +376,12 @@ void PdxLocalReader::readCollection(const char* fieldName,
PdxUnreadFieldsPtr PdxLocalReader::readUnreadFields() {
LOGDEBUG("readUnreadFields:: %d ignore property %d", m_isDataNeedToPreserve,
- PdxTypeRegistry::getPdxIgnoreUnreadFields());
- if (PdxTypeRegistry::getPdxIgnoreUnreadFields() == true) return nullptr;
+ m_pdxTypeRegistry->getPdxIgnoreUnreadFields());
+ if (m_pdxTypeRegistry->getPdxIgnoreUnreadFields() == true) return nullptr;
m_isDataNeedToPreserve = false;
return m_pdxRemotePreserveData;
}
+
} // namespace client
} // namespace geode
} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PdxLocalReader.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PdxLocalReader.hpp b/src/cppcache/src/PdxLocalReader.hpp
index 7f0c724..439626f 100644
--- a/src/cppcache/src/PdxLocalReader.hpp
+++ b/src/cppcache/src/PdxLocalReader.hpp
@@ -51,9 +51,10 @@ class PdxLocalReader : public PdxReader {
void checkEmptyFieldName(const char* fieldName);
public:
- PdxLocalReader();
+ PdxLocalReader(PdxTypeRegistryPtr pdxTypeRegistry);
- PdxLocalReader(DataInput& input, PdxTypePtr remoteType, int32_t pdxLen);
+ PdxLocalReader(DataInput& input, PdxTypePtr remoteType, int32_t pdxLen,
+ PdxTypeRegistryPtr pdxTypeRegistry);
virtual ~PdxLocalReader();
@@ -213,6 +214,10 @@ class PdxLocalReader : public PdxReader {
CacheableArrayListPtr& collection);
virtual PdxUnreadFieldsPtr readUnreadFields();
+
+ protected:
+
+ PdxTypeRegistryPtr m_pdxTypeRegistry;
};
typedef std::shared_ptr<PdxLocalReader> PdxLocalReaderPtr;
} // namespace client
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PdxLocalWriter.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PdxLocalWriter.cpp b/src/cppcache/src/PdxLocalWriter.cpp
index b30f31e..7b88893 100644
--- a/src/cppcache/src/PdxLocalWriter.cpp
+++ b/src/cppcache/src/PdxLocalWriter.cpp
@@ -31,76 +31,29 @@ namespace apache {
namespace geode {
namespace client {
-/* adongre - Coverity II
- * Non-static class member "m_currentOffsetIndex" is not initialized in this
- * constructor nor in any functions that it calls.
- * Non-static class member "m_startPositionOffset" is not initialized in this
- * constructor nor in any functions that it calls.
- */
-PdxLocalWriter::PdxLocalWriter()
- : m_dataOutput(nullptr),
- m_pdxType(nullptr),
+PdxLocalWriter::PdxLocalWriter(DataOutput& output, PdxTypePtr pdxType,
+ PdxTypeRegistryPtr pdxTypeRegistry)
+ : PdxLocalWriter(output, pdxType,
+ pdxType ? pdxType->getPdxClassName() : nullptr,
+ pdxTypeRegistry)
+
+{}
+
+PdxLocalWriter::PdxLocalWriter(DataOutput& dataOutput, PdxTypePtr pdxType,
+ const char* pdxClassName,
+ PdxTypeRegistryPtr pdxTypeRegistry)
+ : m_dataOutput(&dataOutput),
+ m_pdxType(pdxType),
+ m_pdxClassName(pdxClassName),
m_startPosition(nullptr),
m_startPositionOffset(0),
m_domainClassName(nullptr),
m_currentOffsetIndex(0),
- m_pdxClassName(
- nullptr) { // COVERITY --> 29282 Uninitialized pointer field
- // m_dataOutput = nullptr;
- // m_pdxType =nullptr;
-}
-
-PdxLocalWriter::PdxLocalWriter(DataOutput& output, PdxTypePtr pdxType) {
- m_dataOutput = &output;
- m_pdxType = pdxType;
- m_currentOffsetIndex = 0;
- m_preserveData = nullptr;
- m_pdxClassName = nullptr;
- if (pdxType != nullptr) m_pdxClassName = pdxType->getPdxClassName();
- ;
+ m_pdxTypeRegistry(pdxTypeRegistry) {
initialize();
- /* adongre - Coverity II
- * CID 29281: Uninitialized pointer field (UNINIT_CTOR)
- * Non-static class member "m_domainClassName" is not initialized in this
- * constructor nor in any functions that it calls.
- * Fix :
- */
- m_domainClassName = nullptr;
}
-PdxLocalWriter::PdxLocalWriter(DataOutput& dataOutput, PdxTypePtr pdxType,
- const char* pdxClassName) {
- m_dataOutput = &dataOutput;
- m_pdxType = pdxType;
- m_currentOffsetIndex = 0;
- m_preserveData = nullptr;
- m_pdxClassName = pdxClassName;
- initialize();
- /* adongre - Coverity II
- * CID 29281: Uninitialized pointer field (UNINIT_CTOR)
- * Non-static class member "m_domainClassName" is not initialized in this
- * constructor nor in any functions that it calls.
- * Fix :
- */
- m_domainClassName = nullptr;
-}
-
-PdxLocalWriter::~PdxLocalWriter() {
- /*if (m_dataOutput != nullptr) {
- delete m_dataOutput;
- m_dataOutput = nullptr;
- }
- */
- /*if (m_startPosition != nullptr) {
- delete m_startPosition;
- m_startPosition = nullptr;
- }*/
-
- /*if (m_domainClassName != nullptr) {
- delete m_domainClassName;
- m_domainClassName = nullptr;
- }*/
-}
+PdxLocalWriter::~PdxLocalWriter() {}
void PdxLocalWriter::initialize() {
if (m_pdxType != nullptr) {
@@ -171,11 +124,11 @@ PdxWriterPtr PdxLocalWriter::writeUnreadFields(PdxUnreadFieldsPtr unread) {
m_preserveData = std::dynamic_pointer_cast<PdxRemotePreservedData>(unread);
if (m_preserveData != nullptr) {
m_pdxType =
- PdxTypeRegistry::getPdxType(m_preserveData->getMergedTypeId());
+ getPdxTypeRegistry()->getPdxType(m_preserveData->getMergedTypeId());
if (m_pdxType == nullptr) {
// its local type
// this needs to fix for IPdxTypemapper
- m_pdxType = PdxTypeRegistry::getLocalPdxType(m_pdxClassName);
+ m_pdxType = getPdxTypeRegistry()->getLocalPdxType(m_pdxClassName);
}
} else {
throw IllegalStateException(
@@ -526,6 +479,11 @@ uint8_t* PdxLocalWriter::getPdxStream(int& pdxLen) {
}
void PdxLocalWriter::writeByte(int8_t byte) { m_dataOutput->write(byte); }
+
+PdxTypeRegistryPtr PdxLocalWriter::getPdxTypeRegistry() const {
+ return m_pdxTypeRegistry;
+}
+
} // namespace client
} // namespace geode
} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PdxLocalWriter.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PdxLocalWriter.hpp b/src/cppcache/src/PdxLocalWriter.hpp
index 230eea3..4c78635 100644
--- a/src/cppcache/src/PdxLocalWriter.hpp
+++ b/src/cppcache/src/PdxLocalWriter.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_PDXLOCALWRITER_H_
-#define GEODE_PDXLOCALWRITER_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,13 +15,21 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_PDXLOCALWRITER_H_
+#define GEODE_PDXLOCALWRITER_H_
+
+#include <vector>
+
#include <geode/PdxWriter.hpp>
-#include "PdxType.hpp"
#include <geode/DataOutput.hpp>
-#include <vector>
-#include "PdxRemotePreservedData.hpp"
#include <geode/CacheableObjectArray.hpp>
+#include "PdxType.hpp"
+#include "PdxRemotePreservedData.hpp"
+#include "PdxTypeRegistry.hpp"
+
namespace apache {
namespace geode {
namespace client {
@@ -43,6 +46,7 @@ class PdxLocalWriter : public PdxWriter,
int32_t m_currentOffsetIndex;
PdxRemotePreservedDataPtr m_preserveData;
+ PdxTypeRegistryPtr m_pdxTypeRegistry;
const char* m_pdxClassName;
PdxWriterPtr writeStringwithoutOffset(const char* value);
@@ -50,12 +54,11 @@ class PdxLocalWriter : public PdxWriter,
PdxWriterPtr writeWideStringwithoutOffset(const wchar_t* value);
public:
- PdxLocalWriter();
-
- PdxLocalWriter(DataOutput& output, PdxTypePtr pdxType);
+ PdxLocalWriter(DataOutput& output, PdxTypePtr pdxType,
+ PdxTypeRegistryPtr pdxTypeRegistry);
PdxLocalWriter(DataOutput& output, PdxTypePtr pdxType,
- const char* pdxDomainType);
+ const char* pdxDomainType, PdxTypeRegistryPtr pdxTypeRegistry);
virtual ~PdxLocalWriter();
@@ -334,6 +337,9 @@ class PdxLocalWriter : public PdxWriter,
void writeByte(int8_t byte);
inline int32_t getStartPositionOffset() { return m_startPositionOffset; }
+
+ private:
+ PdxTypeRegistryPtr getPdxTypeRegistry() const;
};
typedef std::shared_ptr<PdxLocalWriter> PdxLocalWriterPtr;
} // namespace client
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PdxReaderWithTypeCollector.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PdxReaderWithTypeCollector.cpp b/src/cppcache/src/PdxReaderWithTypeCollector.cpp
index 54fa121..32d4f01 100644
--- a/src/cppcache/src/PdxReaderWithTypeCollector.cpp
+++ b/src/cppcache/src/PdxReaderWithTypeCollector.cpp
@@ -25,20 +25,19 @@
#include "PdxTypes.hpp"
#include <ace/OS_NS_stdio.h>
#include <geode/PdxFieldTypes.hpp>
+#include "CacheImpl.hpp"
namespace apache {
namespace geode {
namespace client {
-PdxReaderWithTypeCollector::PdxReaderWithTypeCollector(DataInput& dataInput,
- PdxTypePtr pdxType,
- int32_t pdxlen)
- : PdxLocalReader(dataInput, pdxType, pdxlen) {
- m_newPdxType = std::make_shared<PdxType>(pdxType->getPdxClassName(), true);
+PdxReaderWithTypeCollector::PdxReaderWithTypeCollector(
+ DataInput& dataInput, PdxTypePtr pdxType, int32_t pdxlen,
+ PdxTypeRegistryPtr pdxTypeRegistry)
+ : PdxLocalReader(dataInput, pdxType, pdxlen, pdxTypeRegistry) {
+ m_newPdxType = std::make_shared<PdxType>(m_pdxTypeRegistry ,pdxType->getPdxClassName(), true);
}
-PdxReaderWithTypeCollector::PdxReaderWithTypeCollector() {}
-
PdxReaderWithTypeCollector::~PdxReaderWithTypeCollector() {}
void PdxReaderWithTypeCollector::checkType(const char* fieldName, int8_t typeId,
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PdxReaderWithTypeCollector.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PdxReaderWithTypeCollector.hpp b/src/cppcache/src/PdxReaderWithTypeCollector.hpp
index 8d89434..fff07a0 100644
--- a/src/cppcache/src/PdxReaderWithTypeCollector.hpp
+++ b/src/cppcache/src/PdxReaderWithTypeCollector.hpp
@@ -21,6 +21,7 @@
*/
#include "PdxLocalReader.hpp"
+#include "PdxTypeRegistry.hpp"
namespace apache {
namespace geode {
@@ -33,10 +34,8 @@ class PdxReaderWithTypeCollector : public PdxLocalReader {
void checkType(const char* fieldName, int8_t typeId, const char* fieldType);
public:
- PdxReaderWithTypeCollector();
-
PdxReaderWithTypeCollector(DataInput& dataInput, PdxTypePtr pdxType,
- int pdxlen);
+ int pdxlen, PdxTypeRegistryPtr pdxTypeRegistry);
virtual ~PdxReaderWithTypeCollector();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PdxRemoteReader.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PdxRemoteReader.hpp b/src/cppcache/src/PdxRemoteReader.hpp
index b036513..8459832 100644
--- a/src/cppcache/src/PdxRemoteReader.hpp
+++ b/src/cppcache/src/PdxRemoteReader.hpp
@@ -31,8 +31,9 @@ class PdxRemoteReader : public PdxLocalReader {
int32_t m_currentIndex;
public:
- PdxRemoteReader(DataInput& dataInput, PdxTypePtr remoteType, int32_t pdxLen)
- : PdxLocalReader(dataInput, remoteType, pdxLen) {
+ PdxRemoteReader(DataInput& dataInput, PdxTypePtr remoteType, int32_t pdxLen,
+ PdxTypeRegistryPtr pdxTypeRegistry)
+ : PdxLocalReader(dataInput, remoteType, pdxLen, pdxTypeRegistry) {
m_currentIndex = 0;
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PdxRemoteWriter.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PdxRemoteWriter.cpp b/src/cppcache/src/PdxRemoteWriter.cpp
index dd3f522..7a9b760 100644
--- a/src/cppcache/src/PdxRemoteWriter.cpp
+++ b/src/cppcache/src/PdxRemoteWriter.cpp
@@ -27,32 +27,15 @@
namespace apache {
namespace geode {
namespace client {
-/* adongre
- * Coverity - II
- * Non-static class member "m_currentDataIdx" is not initialized in this
- * constructor nor in any functions that it calls.
- * Non-static class member "m_preserveDataIdx" is not initialized in this
- * constructor nor in any functions that it calls.
- * Non-static class member "m_remoteTolocalMapLength" is not initialized in this
- * constructor nor in any functions that it calls.
- * Fix : Initialize the members
- */
-PdxRemoteWriter::PdxRemoteWriter()
- : m_preserveDataIdx(0), m_currentDataIdx(-1), m_remoteTolocalMapLength(0) {
- if (m_pdxType != nullptr) {
- m_remoteTolocalMap =
- m_pdxType->getRemoteToLocalMap(); // COVERITY --> 29286 Uninitialized
- // pointer field
- m_remoteTolocalMapLength = m_pdxType->getTotalFields();
- }
-}
PdxRemoteWriter::PdxRemoteWriter(DataOutput& output, PdxTypePtr pdxType,
- PdxRemotePreservedDataPtr preservedData)
- : PdxLocalWriter(output, pdxType),
+ PdxRemotePreservedDataPtr preservedData,
+ PdxTypeRegistryPtr pdxTypeRegistry)
+ : PdxLocalWriter(output, pdxType, pdxTypeRegistry),
m_preserveDataIdx(0),
m_currentDataIdx(-1),
- m_remoteTolocalMapLength(0) {
+ m_remoteTolocalMapLength(0),
+ m_pdxTypeRegistry(pdxTypeRegistry) {
m_preserveData = preservedData;
if (m_pdxType != nullptr) {
m_remoteTolocalMap = m_pdxType->getRemoteToLocalMap();
@@ -63,11 +46,13 @@ PdxRemoteWriter::PdxRemoteWriter(DataOutput& output, PdxTypePtr pdxType,
initialize();
}
-PdxRemoteWriter::PdxRemoteWriter(DataOutput& output, const char* pdxClassName)
- : PdxLocalWriter(output, nullptr, pdxClassName),
+PdxRemoteWriter::PdxRemoteWriter(DataOutput& output, const char* pdxClassName,
+ PdxTypeRegistryPtr pdxTypeRegistry)
+ : PdxLocalWriter(output, nullptr, pdxClassName, pdxTypeRegistry),
m_preserveDataIdx(0),
m_currentDataIdx(-1),
- m_remoteTolocalMapLength(0) {
+ m_remoteTolocalMapLength(0),
+ m_pdxTypeRegistry(pdxTypeRegistry) {
m_preserveData = nullptr;
if (m_pdxType != nullptr) {
m_remoteTolocalMapLength = m_pdxType->getTotalFields();
@@ -130,7 +115,7 @@ void PdxRemoteWriter::writePreserveData() {
void PdxRemoteWriter::initialize() {
// this is default case
if (m_preserveData == nullptr) {
- m_pdxType = PdxTypeRegistry::getLocalPdxType(m_pdxClassName);
+ m_pdxType = getPdxTypeRegistry()->getLocalPdxType(m_pdxClassName);
}
}
@@ -323,6 +308,11 @@ PdxWriterPtr PdxRemoteWriter::writeArrayOfByteArrays(const char* fieldName,
elementLength);
return shared_from_this();
}
+
+PdxTypeRegistryPtr PdxRemoteWriter::getPdxTypeRegistry() const {
+ return m_pdxTypeRegistry;
+}
+
} // namespace client
} // namespace geode
} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PdxRemoteWriter.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PdxRemoteWriter.hpp b/src/cppcache/src/PdxRemoteWriter.hpp
index 809833b..2e7a4b4 100644
--- a/src/cppcache/src/PdxRemoteWriter.hpp
+++ b/src/cppcache/src/PdxRemoteWriter.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_PDXREMOTEWRITER_H_
-#define GEODE_PDXREMOTEWRITER_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -19,12 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * PdxRemoteWriter.hpp
- *
- * Created on: Nov 3, 2011
- * Author: npatel
- */
+
+#pragma once
+
+#ifndef GEODE_PDXREMOTEWRITER_H_
+#define GEODE_PDXREMOTEWRITER_H_
#include "PdxLocalWriter.hpp"
@@ -40,18 +34,22 @@ class PdxRemoteWriter : public PdxLocalWriter {
int32_t m_remoteTolocalMapLength;
+ PdxTypeRegistryPtr m_pdxTypeRegistry;
+
void initialize();
void writePreserveData();
- public:
- PdxRemoteWriter();
+ PdxTypeRegistryPtr getPdxTypeRegistry() const;
+ public:
virtual ~PdxRemoteWriter();
PdxRemoteWriter(DataOutput& output, PdxTypePtr pdxType,
- PdxRemotePreservedDataPtr preservedData);
+ PdxRemotePreservedDataPtr preservedData,
+ PdxTypeRegistryPtr pdxTypeRegistry);
- PdxRemoteWriter(DataOutput& output, const char* pdxClassName);
+ PdxRemoteWriter(DataOutput& output, const char* pdxClassName,
+ PdxTypeRegistryPtr pdxTypeRegistry);
virtual void endObjectWriting();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PdxType.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PdxType.cpp b/src/cppcache/src/PdxType.cpp
index f505be3..50bfa38 100644
--- a/src/cppcache/src/PdxType.cpp
+++ b/src/cppcache/src/PdxType.cpp
@@ -43,53 +43,22 @@ PdxType::~PdxType() {
GF_SAFE_DELETE_ARRAY(m_className);
}
-PdxType::PdxType() : Serializable() {
- // m_lockObj = nullptr;
- m_className = nullptr;
- m_isLocal = false;
- m_numberOfVarLenFields = 0;
- m_varLenFieldIdx = 0; // start with 0
- m_isVarLenFieldAdded = false;
- // m_fieldNameVsPdxType = CacheableHashMap::create();
- m_noJavaClass = false;
- // m_pdxDomainType = nullptr;
- m_pdxFieldTypes = new std::vector<PdxFieldTypePtr>();
- m_localToRemoteFieldMap = nullptr;
- m_remoteToLocalFieldMap = nullptr;
- m_geodeTypeId = 0;
- /* adongre
- * Coverity - II
- * CID 29288: Uninitialized scalar field (UNINIT_CTOR)
- * Non-static class member "m_numberOfFieldsExtra" is not
- * initialized in this constructor nor in any functions that it calls.
- * Fix : Initialized the memeber
- */
- m_numberOfFieldsExtra = 0;
-}
-
-PdxType::PdxType(const char* pdxDomainClassName, bool isLocal)
- : Serializable() {
- // m_lockObj = nullptr;
- m_className = Utils::copyString(pdxDomainClassName);
- m_isLocal = isLocal;
- m_numberOfVarLenFields = 0;
- m_varLenFieldIdx = 0; // start with 0
- m_isVarLenFieldAdded = false;
- // m_fieldNameVsPdxType = CacheableHashMap::create();
- m_noJavaClass = false;
- m_pdxFieldTypes = new std::vector<PdxFieldTypePtr>();
- m_localToRemoteFieldMap = nullptr;
- m_remoteToLocalFieldMap = nullptr;
- m_geodeTypeId = 0;
- /* adongre
- * Coverity - II
- * CID 29287: Uninitialized scalar field (UNINIT_CTOR)
- * Non-static class member "m_numberOfFieldsExtra" is not
- * initialized in this constructor nor in any functions that it calls.
- * Fix : Initialized the memeber
- */
- m_numberOfFieldsExtra = 0;
-}
+//PdxType::PdxType() : PdxType(nullptr, false) {}
+
+PdxType::PdxType(PdxTypeRegistryPtr pdxTypeRegistryPtr, const char* pdxDomainClassName, bool isLocal)
+ : Serializable(),
+ m_className(Utils::copyString(pdxDomainClassName)),
+ m_isLocal(isLocal),
+ m_numberOfVarLenFields(0),
+ m_varLenFieldIdx(0),
+ m_isVarLenFieldAdded(false),
+ m_noJavaClass(false),
+ m_pdxFieldTypes(new std::vector<PdxFieldTypePtr>()),
+ m_localToRemoteFieldMap(nullptr),
+ m_remoteToLocalFieldMap(nullptr),
+ m_geodeTypeId(0),
+ m_numberOfFieldsExtra(0),
+ m_pdxTypeRegistryPtr(pdxTypeRegistryPtr) {}
void PdxType::toData(DataOutput& output) const {
output.write(static_cast<int8_t>(GeodeTypeIdsImpl::DataSerializable)); // 45
@@ -242,7 +211,7 @@ void PdxType::initRemoteToLocal() {
PdxTypePtr localPdxType = nullptr;
//[TODO - open this up once PdxTypeRegistry is done]
- localPdxType = PdxTypeRegistry::getLocalPdxType(m_className);
+ localPdxType = m_pdxTypeRegistryPtr->getLocalPdxType(m_className);
m_numberOfFieldsExtra = 0;
if (localPdxType != nullptr) {
@@ -302,7 +271,7 @@ void PdxType::initLocalToRemote() {
// 5. else if local field is not in remote type then -1
PdxTypePtr localPdxType = nullptr;
- localPdxType = PdxTypeRegistry::getLocalPdxType(m_className);
+ localPdxType = m_pdxTypeRegistryPtr->getLocalPdxType(m_className);
if (localPdxType != nullptr) {
std::vector<PdxFieldTypePtr>* localPdxFields =
@@ -478,7 +447,7 @@ PdxTypePtr PdxType::isContains(PdxTypePtr first, PdxTypePtr second) {
}
PdxTypePtr PdxType::clone() {
- auto clone = std::make_shared<PdxType>(m_className, false);
+ auto clone = std::make_shared<PdxType>(m_pdxTypeRegistryPtr, m_className, false);
clone->m_geodeTypeId = 0;
clone->m_numberOfVarLenFields = m_numberOfVarLenFields;
@@ -628,6 +597,8 @@ bool PdxType::Equals(PdxTypePtr otherObj) {
bool PdxType::operator<(const PdxType& other) const {
return ACE_OS::strcmp(this->m_className, other.m_className) < 0;
}
+
+
} // namespace client
} // namespace geode
} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PdxType.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PdxType.hpp b/src/cppcache/src/PdxType.hpp
index 3a90a78..5b094b4 100644
--- a/src/cppcache/src/PdxType.hpp
+++ b/src/cppcache/src/PdxType.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_PDXTYPE_H_
-#define GEODE_PDXTYPE_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,6 +15,11 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_PDXTYPE_H_
+#define GEODE_PDXTYPE_H_
+
#include <geode/Serializable.hpp>
#include "PdxFieldType.hpp"
#include <geode/CacheableBuiltins.hpp>
@@ -40,18 +40,9 @@ namespace client {
typedef std::map<std::string, PdxFieldTypePtr> NameVsPdxType;
class PdxType;
typedef std::shared_ptr<PdxType> PdxTypePtr;
-/* adongre
- * Coverity - II
- * CID 29178: Other violation (MISSING_COPY)
- * Class "apache::geode::client::PdxType" owns resources that are managed
- * in its constructor and destructor but has no user-written copy constructor.
- * Fix : Make the class Non Copyable
- *
- * CID 29173: Other violation (MISSING_ASSIGN)
- * Class "apache::geode::client::PdxType" owns resources that are managed in its
- * constructor and destructor but has no user-written assignment operator.
- * Fix : Make the class Non Assignable
- */
+class PdxTypeRegistry;
+typedef std::shared_ptr <PdxTypeRegistry> PdxTypeRegistryPtr;
+
class PdxType : public Serializable,
private NonCopyable,
private NonAssignable {
@@ -86,6 +77,8 @@ class PdxType : public Serializable,
bool m_noJavaClass;
+ PdxTypeRegistryPtr m_pdxTypeRegistryPtr;
+
void initRemoteToLocal();
void initLocalToRemote();
int32_t fixedLengthFieldPosition(PdxFieldTypePtr fixLenField,
@@ -107,9 +100,8 @@ class PdxType : public Serializable,
}
public:
- PdxType();
- PdxType(const char* pdxDomainClassName, bool isLocal);
+ PdxType(PdxTypeRegistryPtr pdxTypeRegistryPtr, const char* pdxDomainClassName, bool isLocal);
virtual ~PdxType();
@@ -119,7 +111,7 @@ class PdxType : public Serializable,
virtual int32_t classId() const { return GeodeTypeIds::PdxType; }
- static Serializable* CreateDeserializable() { return new PdxType(); }
+ static Serializable* CreateDeserializable(PdxTypeRegistryPtr pdxTypeRegistryPtr) { return new PdxType(pdxTypeRegistryPtr, nullptr, false); }
virtual uint32_t objectSize() const {
uint32_t size = sizeof(PdxType);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PdxTypeRegistry.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PdxTypeRegistry.cpp b/src/cppcache/src/PdxTypeRegistry.cpp
index 713341a..fc9e45d 100644
--- a/src/cppcache/src/PdxTypeRegistry.cpp
+++ b/src/cppcache/src/PdxTypeRegistry.cpp
@@ -14,82 +14,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * PdxTypeRegistry.cpp
- *
- * Created on: Dec 9, 2011
- * Author: npatel
- */
+
+#include <geode/PoolManager.hpp>
#include "PdxTypeRegistry.hpp"
-#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
+#include "ThinClientPoolDM.hpp"
namespace apache {
namespace geode {
namespace client {
-TypeIdVsPdxType* PdxTypeRegistry::typeIdToPdxType = nullptr;
-
-TypeIdVsPdxType* PdxTypeRegistry::remoteTypeIdToMergedPdxType = nullptr;
-
-TypeNameVsPdxType* PdxTypeRegistry::localTypeToPdxType = nullptr;
-
-// TODO::Add support for weakhashmap
-// std::map<PdxSerializablePtr, PdxRemotePreservedDataPtr>
-// *PdxTypeRegistry::preserveData = nullptr;
-PreservedHashMap PdxTypeRegistry::preserveData;
-
-CacheableHashMapPtr PdxTypeRegistry::enumToInt = nullptr;
-
-CacheableHashMapPtr PdxTypeRegistry::intToEnum = nullptr;
-
-ACE_RW_Thread_Mutex PdxTypeRegistry::g_readerWriterLock;
-
-ACE_RW_Thread_Mutex PdxTypeRegistry::g_preservedDataLock;
-
-PdxTypeToTypeIdMap* PdxTypeRegistry::pdxTypeToTypeIdMap = nullptr;
-bool PdxTypeRegistry::pdxReadSerialized;
-bool PdxTypeRegistry::pdxIgnoreUnreadFields;
-
-PdxTypeRegistry::PdxTypeRegistry() /*:pdxIgnoreUnreadFields (false),
- pdxReadSerialized(false)*/
-{}
+PdxTypeRegistry::PdxTypeRegistry(Cache* cache)
+ : cache(cache),
+ typeIdToPdxType(),
+ remoteTypeIdToMergedPdxType(),
+ localTypeToPdxType(),
+ pdxTypeToTypeIdMap(),
+ enumToInt(CacheableHashMap::create()),
+ intToEnum(CacheableHashMap::create()) {}
PdxTypeRegistry::~PdxTypeRegistry() {}
-void PdxTypeRegistry::init() {
- // try{
- typeIdToPdxType = new TypeIdVsPdxType();
- remoteTypeIdToMergedPdxType = new TypeIdVsPdxType();
- localTypeToPdxType = new TypeNameVsPdxType();
- // preserveData = CacheableHashMap::create();
- // preserveData = PreservedHashMapPtr(new PreservedHashMap());
- enumToInt = CacheableHashMap::create();
- intToEnum = CacheableHashMap::create();
- pdxTypeToTypeIdMap = new PdxTypeToTypeIdMap();
- /*}catch(const std::bad_alloc&){
- throw apache::geode::client::OutOfMemoryException( "Out of Memory while
- executing new in
- PdxTypeRegistry::init()");
- }*/
-}
-
-void PdxTypeRegistry::cleanup() {
- clear();
- GF_SAFE_DELETE(typeIdToPdxType);
- GF_SAFE_DELETE(remoteTypeIdToMergedPdxType);
- GF_SAFE_DELETE(localTypeToPdxType);
- GF_SAFE_DELETE(pdxTypeToTypeIdMap);
- intToEnum = nullptr;
- enumToInt = nullptr;
- // GF_SAFE_DELETE(preserveData);
-}
-
-size_t PdxTypeRegistry::testGetNumberOfPdxIds() {
- return typeIdToPdxType->size();
-}
-
-size_t PdxTypeRegistry::testNumberOfPreservedData() {
+size_t PdxTypeRegistry::testNumberOfPreservedData() const {
return preserveData.size();
}
@@ -106,7 +53,10 @@ int32_t PdxTypeRegistry::getPDXIdForType(const char* type, const char* poolname,
}
}
- int typeId = SerializationRegistry::GetPDXIdForType(poolname, nType);
+ int typeId =
+ CacheRegionHelper::getCacheImpl(cache)
+ ->getSerializationRegistry()
+ ->GetPDXIdForType(cache->getPoolManager().find(poolname), nType);
nType->setTypeId(typeId);
PdxTypeRegistry::addPdxType(typeId, nType);
@@ -115,48 +65,51 @@ int32_t PdxTypeRegistry::getPDXIdForType(const char* type, const char* poolname,
int32_t PdxTypeRegistry::getPDXIdForType(PdxTypePtr nType,
const char* poolname) {
- PdxTypeToTypeIdMap* tmp = pdxTypeToTypeIdMap;
int32_t typeId = 0;
- PdxTypeToTypeIdMap::iterator iter = tmp->find(nType);
- if (iter != tmp->end()) {
- typeId = iter->second;
- if (typeId != 0) {
- return typeId;
+ {
+ ReadGuard read(g_readerWriterLock);
+ PdxTypeToTypeIdMap::iterator iter = pdxTypeToTypeIdMap.find(nType);
+ if (iter != pdxTypeToTypeIdMap.end()) {
+ typeId = iter->second;
+ if (typeId != 0) {
+ return typeId;
+ }
}
}
- /*WriteGuard guard(g_readerWriterLock);
- tmp = pdxTypeToTypeIdMap;
- if(tmp->find(nType) != tmp->end()) {
- typeId = tmp->operator[](nType);
+
+ WriteGuard write(g_readerWriterLock);
+
+ PdxTypeToTypeIdMap::iterator iter = pdxTypeToTypeIdMap.find(nType);
+ if (iter != pdxTypeToTypeIdMap.end()) {
+ typeId = iter->second;
if (typeId != 0) {
return typeId;
}
- }*/
- typeId = SerializationRegistry::GetPDXIdForType(poolname, nType);
+ }
+
+ typeId = CacheRegionHelper::getCacheImpl(cache)
+ ->getSerializationRegistry()
+ ->GetPDXIdForType(cache->getPoolManager().find(poolname), nType);
nType->setTypeId(typeId);
- tmp = pdxTypeToTypeIdMap;
- tmp->insert(std::make_pair(nType, typeId));
- pdxTypeToTypeIdMap = tmp;
- PdxTypeRegistry::addPdxType(typeId, nType);
+ pdxTypeToTypeIdMap.insert(std::make_pair(nType, typeId));
+ addPdxType(typeId, nType);
return typeId;
}
void PdxTypeRegistry::clear() {
{
WriteGuard guard(g_readerWriterLock);
- if (typeIdToPdxType != nullptr) typeIdToPdxType->clear();
+ typeIdToPdxType.clear();
- if (remoteTypeIdToMergedPdxType != nullptr) {
- remoteTypeIdToMergedPdxType->clear();
- }
+ remoteTypeIdToMergedPdxType.clear();
- if (localTypeToPdxType != nullptr) localTypeToPdxType->clear();
+ localTypeToPdxType.clear();
- if (intToEnum != nullptr) intToEnum->clear();
+ if (intToEnum) intToEnum->clear();
- if (enumToInt != nullptr) enumToInt->clear();
+ if (enumToInt) enumToInt->clear();
- if (pdxTypeToTypeIdMap != nullptr) pdxTypeToTypeIdMap->clear();
+ pdxTypeToTypeIdMap.clear();
}
{
WriteGuard guard(getPreservedDataLock());
@@ -167,15 +120,15 @@ void PdxTypeRegistry::clear() {
void PdxTypeRegistry::addPdxType(int32_t typeId, PdxTypePtr pdxType) {
WriteGuard guard(g_readerWriterLock);
std::pair<int32_t, PdxTypePtr> pc(typeId, pdxType);
- typeIdToPdxType->insert(pc);
+ typeIdToPdxType.insert(pc);
}
PdxTypePtr PdxTypeRegistry::getPdxType(int32_t typeId) {
ReadGuard guard(g_readerWriterLock);
PdxTypePtr retValue = nullptr;
TypeIdVsPdxType::iterator iter;
- iter = typeIdToPdxType->find(typeId);
- if (iter != typeIdToPdxType->end()) {
+ iter = typeIdToPdxType.find(typeId);
+ if (iter != typeIdToPdxType.end()) {
retValue = (*iter).second;
return retValue;
}
@@ -185,7 +138,7 @@ PdxTypePtr PdxTypeRegistry::getPdxType(int32_t typeId) {
void PdxTypeRegistry::addLocalPdxType(const char* localType,
PdxTypePtr pdxType) {
WriteGuard guard(g_readerWriterLock);
- localTypeToPdxType->insert(
+ localTypeToPdxType.insert(
std::pair<std::string, PdxTypePtr>(localType, pdxType));
}
@@ -193,8 +146,8 @@ PdxTypePtr PdxTypeRegistry::getLocalPdxType(const char* localType) {
ReadGuard guard(g_readerWriterLock);
PdxTypePtr localTypePtr = nullptr;
TypeNameVsPdxType::iterator it;
- it = localTypeToPdxType->find(localType);
- if (it != localTypeToPdxType->end()) {
+ it = localTypeToPdxType.find(localType);
+ if (it != localTypeToPdxType.end()) {
localTypePtr = (*it).second;
return localTypePtr;
}
@@ -205,14 +158,14 @@ void PdxTypeRegistry::setMergedType(int32_t remoteTypeId,
PdxTypePtr mergedType) {
WriteGuard guard(g_readerWriterLock);
std::pair<int32_t, PdxTypePtr> mergedTypePair(remoteTypeId, mergedType);
- remoteTypeIdToMergedPdxType->insert(mergedTypePair);
+ remoteTypeIdToMergedPdxType.insert(mergedTypePair);
}
PdxTypePtr PdxTypeRegistry::getMergedType(int32_t remoteTypeId) {
PdxTypePtr retVal = nullptr;
TypeIdVsPdxType::iterator it;
- it = remoteTypeIdToMergedPdxType->find(remoteTypeId);
- if (it != remoteTypeIdToMergedPdxType->end()) {
+ it = remoteTypeIdToMergedPdxType.find(remoteTypeId);
+ if (it != remoteTypeIdToMergedPdxType.end()) {
retVal = (*it).second;
return retVal;
}
@@ -220,22 +173,22 @@ PdxTypePtr PdxTypeRegistry::getMergedType(int32_t remoteTypeId) {
}
void PdxTypeRegistry::setPreserveData(PdxSerializablePtr obj,
- PdxRemotePreservedDataPtr pData) {
+ PdxRemotePreservedDataPtr pData,
+ ExpiryTaskManager& expiryTaskManager) {
WriteGuard guard(getPreservedDataLock());
pData->setOwner(obj);
if (preserveData.find(obj) != preserveData.end()) {
// reset expiry task
// TODO: check value for nullptr
auto expTaskId = preserveData[obj]->getPreservedDataExpiryTaskId();
- CacheImpl::expiryTaskManager->resetTask(expTaskId, 5);
+ expiryTaskManager.resetTask(expTaskId, 5);
LOGDEBUG("PdxTypeRegistry::setPreserveData Reset expiry task Done");
pData->setPreservedDataExpiryTaskId(expTaskId);
preserveData[obj] = pData;
} else {
// schedule new expiry task
- auto handler = new PreservedDataExpiryHandler(obj, 20);
- auto id =
- CacheImpl::expiryTaskManager->scheduleExpiryTask(handler, 20, 0, false);
+ auto handler = new PreservedDataExpiryHandler(shared_from_this(), obj, 20);
+ long id = expiryTaskManager.scheduleExpiryTask(handler, 20, 0, false);
pData->setPreservedDataExpiryTaskId(id);
LOGDEBUG(
"PdxTypeRegistry::setPreserveData Schedule new expirt task with id=%ld",
@@ -275,7 +228,11 @@ int32_t PdxTypeRegistry::getEnumValue(EnumInfoPtr ei) {
const auto val2 = std::static_pointer_cast<CacheableInt32>(entry2->second);
return val2->value();
}
- int val = SerializationRegistry::GetEnumValue(ei);
+
+ int val = static_cast<ThinClientPoolDM*>(
+ cache->getPoolManager().getAll().begin()->second.get())
+ ->GetEnumValue(ei);
+
tmp = enumToInt;
tmp->emplace(ei, CacheableInt32::create(val));
enumToInt = tmp;
@@ -314,7 +271,9 @@ EnumInfoPtr PdxTypeRegistry::getEnum(int32_t enumVal) {
}
ret = std::static_pointer_cast<EnumInfo>(
- SerializationRegistry::GetEnum(enumVal));
+ static_cast<ThinClientPoolDM*>(
+ cache->getPoolManager().getAll().begin()->second.get())
+ ->GetEnum(enumVal));
tmp = intToEnum;
(*tmp)[enumValPtr] = ret;
intToEnum = tmp;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PdxTypeRegistry.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PdxTypeRegistry.hpp b/src/cppcache/src/PdxTypeRegistry.hpp
index 2c2177f..491a347 100644
--- a/src/cppcache/src/PdxTypeRegistry.hpp
+++ b/src/cppcache/src/PdxTypeRegistry.hpp
@@ -28,12 +28,14 @@
#include <geode/utils.hpp>
#include <geode/PdxSerializable.hpp>
+#include <geode/Cache.hpp>
#include "PdxRemotePreservedData.hpp"
#include "ReadWriteLock.hpp"
#include "PdxType.hpp"
#include "EnumInfo.hpp"
#include "PreservedDataExpiryHandler.hpp"
+#include "ExpiryTaskManager.hpp"
namespace apache {
namespace geode {
@@ -54,95 +56,88 @@ typedef std::unordered_map<PdxSerializablePtr, PdxRemotePreservedDataPtr,
PreservedHashMap;
typedef std::map<PdxTypePtr, int32_t, PdxTypeLessThan> PdxTypeToTypeIdMap;
-class CPPCACHE_EXPORT PdxTypeRegistry {
+class CPPCACHE_EXPORT PdxTypeRegistry
+ : public std::enable_shared_from_this<PdxTypeRegistry> {
private:
- static TypeIdVsPdxType* typeIdToPdxType;
+ Cache* cache;
- static TypeIdVsPdxType* remoteTypeIdToMergedPdxType;
+ TypeIdVsPdxType typeIdToPdxType;
- static TypeNameVsPdxType* localTypeToPdxType;
+ TypeIdVsPdxType remoteTypeIdToMergedPdxType;
+
+ TypeNameVsPdxType localTypeToPdxType;
+
+ PdxTypeToTypeIdMap pdxTypeToTypeIdMap;
// TODO:: preserveData need to be of type WeakHashMap
- // static std::map<PdxSerializablePtr , PdxRemotePreservedDataPtr>
- // *preserveData;
- // static CacheableHashMapPtr preserveData;
- static PreservedHashMap preserveData;
+ PreservedHashMap preserveData;
- static ACE_RW_Thread_Mutex g_readerWriterLock;
+ ACE_RW_Thread_Mutex g_readerWriterLock;
- static ACE_RW_Thread_Mutex g_preservedDataLock;
+ ACE_RW_Thread_Mutex g_preservedDataLock;
- static bool pdxIgnoreUnreadFields;
+ bool pdxIgnoreUnreadFields;
- static bool pdxReadSerialized;
+ bool pdxReadSerialized;
- static CacheableHashMapPtr enumToInt;
+ CacheableHashMapPtr enumToInt;
- static CacheableHashMapPtr intToEnum;
+ CacheableHashMapPtr intToEnum;
public:
- PdxTypeRegistry();
+ PdxTypeRegistry(Cache* cache);
+ PdxTypeRegistry(const PdxTypeRegistry& other) = delete;
virtual ~PdxTypeRegistry();
- static void init();
-
- static void cleanup();
-
- // test hook;
- static size_t testGetNumberOfPdxIds();
-
// test hook
- static size_t testNumberOfPreservedData();
+ size_t testNumberOfPreservedData() const;
- static void addPdxType(int32_t typeId, PdxTypePtr pdxType);
+ void addPdxType(int32_t typeId, PdxTypePtr pdxType);
- static PdxTypePtr getPdxType(int32_t typeId);
+ PdxTypePtr getPdxType(int32_t typeId);
- static void addLocalPdxType(const char* localType, PdxTypePtr pdxType);
+ void addLocalPdxType(const char* localType, PdxTypePtr pdxType);
// newly added
- static PdxTypePtr getLocalPdxType(const char* localType);
+ PdxTypePtr getLocalPdxType(const char* localType);
- static void setMergedType(int32_t remoteTypeId, PdxTypePtr mergedType);
+ void setMergedType(int32_t remoteTypeId, PdxTypePtr mergedType);
- static PdxTypePtr getMergedType(int32_t remoteTypeId);
+ PdxTypePtr getMergedType(int32_t remoteTypeId);
- static void setPreserveData(PdxSerializablePtr obj,
- PdxRemotePreservedDataPtr preserveDataPtr);
+ void setPreserveData(PdxSerializablePtr obj,
+ PdxRemotePreservedDataPtr preserveDataPtr,
+ ExpiryTaskManager& expiryTaskManager);
- static PdxRemotePreservedDataPtr getPreserveData(PdxSerializablePtr obj);
+ PdxRemotePreservedDataPtr getPreserveData(PdxSerializablePtr obj);
- static void clear();
+ void clear();
- static int32_t getPDXIdForType(const char* type, const char* poolname,
- PdxTypePtr nType, bool checkIfThere);
+ int32_t getPDXIdForType(const char* type, const char* poolname,
+ PdxTypePtr nType, bool checkIfThere);
- static bool getPdxIgnoreUnreadFields() { return pdxIgnoreUnreadFields; }
+ bool getPdxIgnoreUnreadFields() const { return pdxIgnoreUnreadFields; }
- static void setPdxIgnoreUnreadFields(bool value) {
- pdxIgnoreUnreadFields = value;
- }
+ void setPdxIgnoreUnreadFields(bool value) { pdxIgnoreUnreadFields = value; }
- static void setPdxReadSerialized(bool value) { pdxReadSerialized = value; }
+ void setPdxReadSerialized(bool value) { pdxReadSerialized = value; }
- static bool getPdxReadSerialized() { return pdxReadSerialized; }
+ bool getPdxReadSerialized() const { return pdxReadSerialized; }
- static inline PreservedHashMap& getPreserveDataMap() { return preserveData; };
+ inline PreservedHashMap& getPreserveDataMap() { return preserveData; };
- static int32_t getEnumValue(EnumInfoPtr ei);
+ int32_t getEnumValue(EnumInfoPtr ei);
- static EnumInfoPtr getEnum(int32_t enumVal);
+ EnumInfoPtr getEnum(int32_t enumVal);
- static int32_t getPDXIdForType(PdxTypePtr nType, const char* poolname);
+ int32_t getPDXIdForType(PdxTypePtr nType, const char* poolname);
- static ACE_RW_Thread_Mutex& getPreservedDataLock() {
- return g_preservedDataLock;
- }
-
- private:
- static PdxTypeToTypeIdMap* pdxTypeToTypeIdMap;
+ ACE_RW_Thread_Mutex& getPreservedDataLock() { return g_preservedDataLock; }
};
+
+typedef std::shared_ptr<PdxTypeRegistry> PdxTypeRegistryPtr;
+
} // namespace client
} // namespace geode
} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PdxWrapper.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PdxWrapper.cpp b/src/cppcache/src/PdxWrapper.cpp
index 9306660..1c73947 100644
--- a/src/cppcache/src/PdxWrapper.cpp
+++ b/src/cppcache/src/PdxWrapper.cpp
@@ -30,9 +30,9 @@ namespace apache {
namespace geode {
namespace client {
-PdxWrapper::PdxWrapper(void *userObject, const char *className) {
- m_userObject = userObject;
-
+PdxWrapper::PdxWrapper(void *userObject, const char *className,
+ PdxSerializerPtr pdxSerializerPtr)
+ : m_userObject(userObject), m_serializer(pdxSerializerPtr) {
if (className != nullptr) {
m_className = Utils::copyString(className);
} else {
@@ -41,8 +41,6 @@ PdxWrapper::PdxWrapper(void *userObject, const char *className) {
"Class name not provided to PdxWrapper constructor");
}
- m_serializer = SerializationRegistry::getPdxSerializer();
-
if (m_serializer == nullptr) {
LOGERROR("No registered PDX serializer found for PdxWrapper");
throw IllegalArgumentException(
@@ -64,7 +62,8 @@ PdxWrapper::PdxWrapper(void *userObject, const char *className) {
m_sizer = m_serializer->getObjectSizer(className);
}
-PdxWrapper::PdxWrapper(const char *className) {
+PdxWrapper::PdxWrapper(const char *className, PdxSerializerPtr pdxSerializerPtr)
+ : m_serializer(pdxSerializerPtr) {
if (className != nullptr) {
m_className = Utils::copyString(className);
} else {
@@ -73,8 +72,6 @@ PdxWrapper::PdxWrapper(const char *className) {
"Class name not provided to PdxWrapper for deserialization");
}
- m_serializer = SerializationRegistry::getPdxSerializer();
-
if (m_serializer == nullptr) {
LOGERROR(
"No registered PDX serializer found for PdxWrapper deserialization");
@@ -173,6 +170,7 @@ PdxWrapper::~PdxWrapper() {
}
delete[] m_className;
}
+
} // namespace client
} // namespace geode
} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PdxWriterWithTypeCollector.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PdxWriterWithTypeCollector.cpp b/src/cppcache/src/PdxWriterWithTypeCollector.cpp
index f60fc53..c143cf5 100644
--- a/src/cppcache/src/PdxWriterWithTypeCollector.cpp
+++ b/src/cppcache/src/PdxWriterWithTypeCollector.cpp
@@ -31,17 +31,16 @@ namespace apache {
namespace geode {
namespace client {
-PdxWriterWithTypeCollector::PdxWriterWithTypeCollector() {}
-
PdxWriterWithTypeCollector::PdxWriterWithTypeCollector(
- DataOutput& output, const char* domainClassName)
- : PdxLocalWriter(output, nullptr) {
+ DataOutput& output, const char* domainClassName,
+ PdxTypeRegistryPtr pdxTypeRegistry)
+ : PdxLocalWriter(output, nullptr, pdxTypeRegistry) {
m_domainClassName = domainClassName;
initialize();
}
void PdxWriterWithTypeCollector::initialize() {
- m_pdxType = std::make_shared<PdxType>(m_domainClassName, true);
+ m_pdxType = std::make_shared<PdxType>(m_pdxTypeRegistry, m_domainClassName, true);
}
PdxWriterWithTypeCollector::~PdxWriterWithTypeCollector() {}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PdxWriterWithTypeCollector.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PdxWriterWithTypeCollector.hpp b/src/cppcache/src/PdxWriterWithTypeCollector.hpp
index 714f2cb..63e946d 100644
--- a/src/cppcache/src/PdxWriterWithTypeCollector.hpp
+++ b/src/cppcache/src/PdxWriterWithTypeCollector.hpp
@@ -33,9 +33,8 @@ class PdxWriterWithTypeCollector : public PdxLocalWriter {
void initialize();
public:
- PdxWriterWithTypeCollector();
-
- PdxWriterWithTypeCollector(DataOutput& output, const char* pdxType);
+ PdxWriterWithTypeCollector(DataOutput& output, const char* pdxType,
+ PdxTypeRegistryPtr pdxTypeRegistry);
virtual ~PdxWriterWithTypeCollector();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/Pool.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/Pool.cpp b/src/cppcache/src/Pool.cpp
index d2effd0..12c4c68 100644
--- a/src/cppcache/src/Pool.cpp
+++ b/src/cppcache/src/Pool.cpp
@@ -69,16 +69,14 @@ bool Pool::getThreadLocalConnections() const {
bool Pool::getMultiuserAuthentication() const {
return m_attrs->getMultiuserSecureModeEnabled();
}
-RegionServicePtr Pool::createSecureUserCache(PropertiesPtr credentials) {
+RegionServicePtr Pool::createSecureUserCache(PropertiesPtr credentials,
+ CacheImpl* cacheImpl) {
if (this->getMultiuserAuthentication()) {
- CachePtr realCache = CacheFactory::getAnyInstance();
-
- if (!(realCache != nullptr && realCache->m_cacheImpl != nullptr)) {
+ if (cacheImpl == nullptr) {
throw IllegalStateException("cache has not been created yet.");
- ;
}
- if (realCache->isClosed()) {
+ if (cacheImpl->isClosed()) {
throw IllegalStateException("cache has been closed. ");
}
@@ -88,7 +86,8 @@ RegionServicePtr Pool::createSecureUserCache(PropertiesPtr credentials) {
}
// TODO: this will return cache with userattribtes
- return std::make_shared<ProxyCache>(credentials, shared_from_this());
+ return std::make_shared<ProxyCache>(credentials, shared_from_this(),
+ cacheImpl);
}
throw IllegalStateException(
@@ -102,18 +101,17 @@ bool Pool::getPRSingleHopEnabled() const {
// void Pool::releaseThreadLocalConnection(){}
int Pool::getPendingEventCount() const {
- TcrConnectionManager& tccm = CacheImpl::getInstance()->tcrConnectionManager();
- if (!tccm.isDurable()) {
- LOGERROR("This operation should only be called by durable client.");
- throw IllegalStateException(
- "This operation should only be called by durable client");
- }
const auto poolHADM = dynamic_cast<const ThinClientPoolHADM*>(this);
if (nullptr == poolHADM || poolHADM->isReadyForEvent()) {
LOGERROR("This operation should only be called before readyForEvents.");
throw IllegalStateException(
"This operation should only be called before readyForEvents");
}
-
+ TcrConnectionManager& tccm = poolHADM->getConnectionManager();
+ if (!tccm.isDurable()) {
+ LOGERROR("This operation should only be called by durable client.");
+ throw IllegalStateException(
+ "This operation should only be called by durable client");
+ }
return poolHADM->getPrimaryServerQueueSize();
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PoolFactory.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PoolFactory.cpp b/src/cppcache/src/PoolFactory.cpp
index aa5f9b1..6a273ed 100644
--- a/src/cppcache/src/PoolFactory.cpp
+++ b/src/cppcache/src/PoolFactory.cpp
@@ -26,15 +26,19 @@
#include <ace/INET_Addr.h>
#include <ThinClientPoolStickyDM.hpp>
#include <ThinClientPoolStickyHADM.hpp>
+#include "CacheRegionHelper.hpp"
using namespace apache::geode::client;
-const char* PoolFactory::DEFAULT_SERVER_GROUP = "";
-extern HashMapOfPools* connectionPools;
-extern ACE_Recursive_Thread_Mutex connectionPoolsLock;
-PoolFactory::PoolFactory()
- : m_attrs(new PoolAttributes),
+#define DEFAULT_SERVER_PORT 40404
+#define DEFAULT_SERVER_HOST "localhost"
+
+constexpr const char* PoolFactory::DEFAULT_SERVER_GROUP;
+
+PoolFactory::PoolFactory(const Cache& cache)
+ : m_attrs(std::make_shared<PoolAttributes>()),
m_isSubscriptionRedundancy(false),
- m_addedServerOrLocator(false) {}
+ m_addedServerOrLocator(false),
+ m_cache(cache) {}
PoolFactory::~PoolFactory() {}
@@ -114,29 +118,27 @@ void PoolFactory::setPRSingleHopEnabled(bool enabled) {
PoolPtr PoolFactory::create(const char* name) {
ThinClientPoolDMPtr poolDM;
{
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(connectionPoolsLock);
-
- if (PoolManager::find(name) != nullptr) {
+ if (m_cache.getPoolManager().find(name) != nullptr) {
throw IllegalStateException("Pool with the same name already exists");
}
+ if (!m_addedServerOrLocator) {
+ addServer(DEFAULT_SERVER_HOST, DEFAULT_SERVER_PORT);
+ }
// Create a clone of Attr;
PoolAttributesPtr copyAttrs = m_attrs->clone();
- if (CacheImpl::getInstance() == nullptr) {
- throw IllegalStateException("Cache has not been created.");
- }
+ CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(&m_cache);
- if (CacheImpl::getInstance()->isClosed()) {
+ if (m_cache.isClosed()) {
throw CacheClosedException("Cache is closed");
}
- if (CacheImpl::getInstance()->getCacheMode() &&
- m_isSubscriptionRedundancy) {
+ if (cacheImpl->getCacheMode() && m_isSubscriptionRedundancy) {
LOGWARN(
"At least one pool has been created so ignoring cache level "
"redundancy setting");
}
- TcrConnectionManager& tccm =
- CacheImpl::getInstance()->tcrConnectionManager();
+ TcrConnectionManager& tccm = cacheImpl->tcrConnectionManager();
+
LOGDEBUG("PoolFactory::create mulitusermode = %d ",
copyAttrs->getMultiuserSecureModeEnabled());
if (copyAttrs->getMultiuserSecureModeEnabled()) {
@@ -172,12 +174,15 @@ PoolPtr PoolFactory::create(const char* name) {
}
}
- connectionPools->insert({name, std::static_pointer_cast<Pool>(poolDM)});
+ cacheImpl->getPoolManager().addPool(name,
+ std::static_pointer_cast<Pool>(poolDM));
}
// TODO: poolDM->init() should not throw exceptions!
// Pool DM should only be inited once.
- if (DistributedSystem::getSystemProperties()->autoReadyForEvents()) {
+ if (m_cache.getDistributedSystem()
+ .getSystemProperties()
+ .autoReadyForEvents()) {
poolDM->init();
}
[06/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ThinClientPoolStickyHADM.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ThinClientPoolStickyHADM.cpp b/src/cppcache/src/ThinClientPoolStickyHADM.cpp
deleted file mode 100644
index 9989328..0000000
--- a/src/cppcache/src/ThinClientPoolStickyHADM.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.
- */
-#include "ThinClientPoolStickyHADM.hpp"
-#include "TssConnectionWrapper.hpp"
-#include <algorithm>
-using namespace apache::geode::client;
-/*TcrConnection* ThinClientPoolStickyHADM::getConnectionFromQueueW( GfErrType*
-error,
- std::set< ServerLocation >& excludeServers, bool isBGThread, TcrMessage &
-request, int8_t& version, bool & dummy, const BucketServerLocationPtr&
-serverLocation )
-{
- TcrConnection* conn = nullptr;
- if( isBGThread ){
- conn = ThinClientPoolDM::getConnectionFromQueueW( error, excludeServers,
-isBGThread, request, version, dummy, serverLocation);
- return conn;
- }
-
- m_manager->getStickyConnection(conn , error, excludeServers,
-request.forTransaction());
- return conn;
-}
-void ThinClientPoolStickyHADM::putInQueue(TcrConnection* conn, bool isBGThread,
-bool isTransaction )
-{
- if( !isBGThread )
- m_manager->setStickyConnection( conn, isTransaction );
- else
- ThinClientPoolDM::putInQueue( conn, isBGThread, isTransaction);
-}
-void ThinClientPoolStickyHADM::setStickyNull( bool isBGThread )
-{
- if( !isBGThread ) m_manager->setStickyConnection( nullptr, false );
-}
-
-void ThinClientPoolStickyHADM::cleanStickyConnections(volatile bool& isRunning)
-{
- if (!isRunning) {
- return;
- }
- m_manager->cleanStaleStickyConnection();
-}
-
-bool ThinClientPoolStickyHADM::canItBeDeleted(TcrConnection* conn)
-{
- return m_manager->canThisConnBeDeleted( conn );
-}
-void ThinClientPoolStickyHADM::releaseThreadLocalConnection()
-{
- m_manager->releaseThreadLocalConnection();
-}
-void ThinClientPoolStickyHADM::setThreadLocalConnection(TcrConnection* conn)
-{
- m_manager->addStickyConnection(conn);
-}
-bool ThinClientPoolStickyHADM::canItBeDeletedNoImpl(TcrConnection* conn )
-{
- return ThinClientPoolDM::canItBeDeleted( conn );
-}*/
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ThinClientPoolStickyHADM.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ThinClientPoolStickyHADM.hpp b/src/cppcache/src/ThinClientPoolStickyHADM.hpp
index 40c1694..07fa4ed 100644
--- a/src/cppcache/src/ThinClientPoolStickyHADM.hpp
+++ b/src/cppcache/src/ThinClientPoolStickyHADM.hpp
@@ -29,29 +29,9 @@ class ThinClientPoolStickyHADM : public ThinClientPoolHADM {
ThinClientPoolStickyHADM(const char* name, PoolAttributesPtr poolAttrs,
TcrConnectionManager& connManager)
: ThinClientPoolHADM(name, poolAttrs, connManager) {
- // m_manager = new ThinClientStickyManager( this );
m_sticky = true;
}
- virtual ~ThinClientPoolStickyHADM() {
- /*m_manager->closeAllStickyConnections();
- delete m_manager; m_manager = nullptr;*/
- }
- /*bool canItBeDeletedNoImpl(TcrConnection* conn );
-protected:
- virtual void cleanStickyConnections(volatile bool& isRunning);
- virtual TcrConnection* getConnectionFromQueueW( GfErrType* error,
- std::set< ServerLocation >&, bool isBGThread, TcrMessage & request, int8_t&
-version, bool & dummy, const BucketServerLocationPtr& serverLocation = nullptr
-);
- virtual void putInQueue(TcrConnection* conn, bool isBGThread, bool
-isTransaction = false );
- virtual void setStickyNull( bool isBGThread );
- virtual bool canItBeDeleted(TcrConnection* conn);
- virtual void releaseThreadLocalConnection();
- virtual void setThreadLocalConnection(TcrConnection* conn);
-*/
- // virtual void cleanStickyConnections(volatile bool& isRunning);
- // ThinClientStickyManager* m_manager;
+ virtual ~ThinClientPoolStickyHADM() {}
};
typedef std::shared_ptr<ThinClientPoolStickyHADM> ThinClientPoolStickyHADMPtr;
} // namespace client
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ThinClientRedundancyManager.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ThinClientRedundancyManager.cpp b/src/cppcache/src/ThinClientRedundancyManager.cpp
index d356782..6ab3248 100644
--- a/src/cppcache/src/ThinClientRedundancyManager.cpp
+++ b/src/cppcache/src/ThinClientRedundancyManager.cpp
@@ -642,11 +642,13 @@ void ThinClientRedundancyManager::initialize(int redundancyLevel) {
m_redundancyLevel = redundancyLevel;
m_HAenabled = (redundancyLevel > 0 || m_theTcrConnManager->isDurable() ||
ThinClientBaseDM::isDeltaEnabledOnServer());
- SystemProperties* sysProp = DistributedSystem::getSystemProperties();
+ auto& sysProp = m_theTcrConnManager->getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties();
if (m_poolHADM) {
m_eventidmap.init(m_poolHADM->getSubscriptionMessageTrackingTimeout());
} else {
- m_eventidmap.init(sysProp->notifyDupCheckLife());
+ m_eventidmap.init(sysProp.notifyDupCheckLife());
}
int millis = 100;
if (m_HAenabled) {
@@ -655,7 +657,7 @@ void ThinClientRedundancyManager::initialize(int redundancyLevel) {
millis = m_poolHADM->getSubscriptionAckInterval();
} else {
- millis = sysProp->notifyAckInterval();
+ millis = sysProp.notifyAckInterval();
}
if (millis < 100) millis = 100;
{
@@ -719,7 +721,8 @@ void ThinClientRedundancyManager::close() {
if (m_periodicAckTask) {
if (m_processEventIdMapTaskId >= 0) {
- CacheImpl::expiryTaskManager->cancelTask(m_processEventIdMapTaskId);
+ m_theTcrConnManager->getCacheImpl()->getExpiryTaskManager().cancelTask(
+ m_processEventIdMapTaskId);
}
m_periodicAckTask->stopNoblock();
m_periodicAckSema.release();
@@ -750,7 +753,8 @@ bool ThinClientRedundancyManager::readyForEvents(
return true;
}
- TcrMessageClientReady request;
+ TcrMessageClientReady request(
+ m_theTcrConnManager->getCacheImpl()->getCache()->createDataOutput());
TcrMessageReply reply(true, nullptr);
GfErrType err = GF_NOTCON;
@@ -791,6 +795,7 @@ bool ThinClientRedundancyManager::sendMakePrimaryMesg(
}
TcrMessageReply reply(false, nullptr);
const TcrMessageMakePrimary makePrimaryRequest(
+ m_theTcrConnManager->getCacheImpl()->getCache()->createDataOutput(),
ThinClientRedundancyManager::m_sentReadyForEvents);
LOGFINE("Making primary subscription endpoint %s", ep->name().c_str());
@@ -1109,7 +1114,8 @@ bool ThinClientRedundancyManager::isDurable() {
}
void ThinClientRedundancyManager::readyForEvents() {
- TcrMessageClientReady request;
+ TcrMessageClientReady request(
+ m_theTcrConnManager->getCacheImpl()->getCache()->createDataOutput());
TcrMessageReply reply(true, nullptr);
GfErrType result = GF_NOTCON;
unsigned int epCount = 0;
@@ -1194,7 +1200,9 @@ void ThinClientRedundancyManager::doPeriodicAck() {
m_redundantEndpoints.begin();
if (endpoint != m_redundantEndpoints.end()) {
- TcrMessagePeriodicAck request(entries);
+ TcrMessagePeriodicAck request(
+ m_theTcrConnManager->getCacheImpl()->getCache()->createDataOutput(),
+ entries);
TcrMessageReply reply(true, nullptr);
GfErrType result = GF_NOERR;
@@ -1243,24 +1251,26 @@ void ThinClientRedundancyManager::startPeriodicAck() {
m_periodicAckTask = new Task<ThinClientRedundancyManager>(
this, &ThinClientRedundancyManager::periodicAck, NC_PerodicACK);
m_periodicAckTask->start();
- SystemProperties* props = DistributedSystem::getSystemProperties();
+ const auto& props = m_theTcrConnManager->getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties();
// start the periodic ACK task handler
- ACE_Event_Handler* periodicAckTask =
- new ExpiryHandler_T<ThinClientRedundancyManager>(
- this, &ThinClientRedundancyManager::processEventIdMap);
- // m_processEventIdMapTaskId = CacheImpl::expiryTaskManager->
- // scheduleExpiryTask(periodicAckTask, 1, 1, false);
- m_processEventIdMapTaskId = CacheImpl::expiryTaskManager->scheduleExpiryTask(
- periodicAckTask, m_nextAckInc, m_nextAckInc, false);
+ auto periodicAckTask = new ExpiryHandler_T<ThinClientRedundancyManager>(
+ this, &ThinClientRedundancyManager::processEventIdMap);
+ m_processEventIdMapTaskId =
+ m_theTcrConnManager->getCacheImpl()
+ ->getExpiryTaskManager()
+ .scheduleExpiryTask(periodicAckTask, m_nextAckInc, m_nextAckInc,
+ false);
LOGFINE(
"Registered subscription event "
"periodic ack task with id = %ld, notify-ack-interval = %ld, "
"notify-dupcheck-life = %ld, periodic ack is %sabled",
m_processEventIdMapTaskId,
m_poolHADM ? m_poolHADM->getSubscriptionAckInterval()
- : props->notifyAckInterval(),
+ : props.notifyAckInterval(),
m_poolHADM ? m_poolHADM->getSubscriptionMessageTrackingTimeout()
- : props->notifyDupCheckLife(),
+ : props.notifyDupCheckLife(),
m_HAenabled ? "en" : "dis");
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ThinClientRegion.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ThinClientRegion.cpp b/src/cppcache/src/ThinClientRegion.cpp
index b7a2dcb..8c7ddf3 100644
--- a/src/cppcache/src/ThinClientRegion.cpp
+++ b/src/cppcache/src/ThinClientRegion.cpp
@@ -15,24 +15,26 @@
* limitations under the License.
*/
+#include <geode/SelectResultsIterator.hpp>
+#include <geode/SystemProperties.hpp>
+#include <geode/PoolManager.hpp>
+#include <geode/UserFunctionExecutionException.hpp>
+
#include "Utils.hpp"
+#include "CacheRegionHelper.hpp"
#include "ThinClientRegion.hpp"
#include "TcrDistributionManager.hpp"
#include "ThinClientPoolDM.hpp"
#include "ThinClientBaseDM.hpp"
#include "TcrEndpoint.hpp"
-#include <geode/SystemProperties.hpp>
#include "CacheImpl.hpp"
#include "RegionGlobalLocks.hpp"
#include "ReadWriteLock.hpp"
#include "RemoteQuery.hpp"
-#include <geode/SelectResultsIterator.hpp>
#include <geode/Struct.hpp>
#include "GeodeTypeIdsImpl.hpp"
#include "AutoDelete.hpp"
-#include <geode/PoolManager.hpp>
#include "UserAttributes.hpp"
-#include <geode/UserFunctionExecutionException.hpp>
#include "PutAllPartialResultServerException.hpp"
#include "VersionedCacheableObjectPartList.hpp"
//#include "PutAllPartialResult.hpp"
@@ -88,9 +90,9 @@ class PutAllWork : public PooledWork<GfErrType>,
m_isPapeReceived(false)
// UNUSED , m_aCallbackArgument(aCallbackArgument)
{
- m_request = new TcrMessagePutAll(m_region.get(), *m_map.get(),
- static_cast<int>(m_timeout * 1000),
- m_poolDM, aCallbackArgument);
+ m_request = new TcrMessagePutAll(
+ m_region->getCache()->createDataOutput(), m_region.get(), *m_map.get(),
+ static_cast<int>(m_timeout * 1000), m_poolDM, aCallbackArgument);
m_reply = new TcrMessageReply(true, m_poolDM);
// create new instanceof VCOPL
@@ -228,8 +230,9 @@ class RemoveAllWork : public PooledWork<GfErrType>,
m_keys(keys),
m_papException(nullptr),
m_isPapeReceived(false) {
- m_request = new TcrMessageRemoveAll(m_region.get(), *keys,
- m_aCallbackArgument, m_poolDM);
+ m_request = new TcrMessageRemoveAll(
+ m_region->getCache()->createDataOutput(), m_region.get(), *keys,
+ m_aCallbackArgument, m_poolDM);
m_reply = new TcrMessageReply(true, m_poolDM);
// create new instanceof VCOPL
ACE_Recursive_Thread_Mutex responseLock;
@@ -327,30 +330,35 @@ class RemoveAllWork : public PooledWork<GfErrType>,
}
};
-ThinClientRegion::ThinClientRegion(const std::string& name, CacheImpl* cache,
+ThinClientRegion::ThinClientRegion(const std::string& name,
+ CacheImpl* cacheImpl,
const RegionInternalPtr& rPtr,
const RegionAttributesPtr& attributes,
const CacheStatisticsPtr& stats, bool shared)
- : LocalRegion(name, cache, rPtr, attributes, stats, shared),
+ : LocalRegion(name, cacheImpl, rPtr, attributes, stats, shared),
m_tcrdm((ThinClientBaseDM*)0),
m_notifyRelease(false),
m_notificationSema(1),
m_isMetaDataRefreshed(false) {
m_transactionEnabled = true;
- m_isDurableClnt =
- strlen(DistributedSystem::getSystemProperties()->durableClientId()) > 0;
+ m_isDurableClnt = strlen(cacheImpl->getDistributedSystem()
+ .getSystemProperties()
+ .durableClientId()) > 0;
}
void ThinClientRegion::initTCR() {
bool subscription = false;
- PoolPtr pool = PoolManager::find(getAttributes()->getPoolName());
+ PoolPtr pool = m_cacheImpl->getCache()->getPoolManager().find(
+ getAttributes()->getPoolName());
if (pool != nullptr) {
subscription = pool->getSubscriptionEnabled();
}
bool notificationEnabled =
getAttributes()->getClientNotificationEnabled() || subscription;
if (notificationEnabled) {
- if (DistributedSystem::getSystemProperties()->isGridClient()) {
+ if (m_cacheImpl->getDistributedSystem()
+ .getSystemProperties()
+ .isGridClient()) {
LOGWARN(
"Region %s: client subscription channel enabled for a grid "
"client; starting required internal subscription, cleanup and "
@@ -374,7 +382,8 @@ void ThinClientRegion::initTCR() {
void ThinClientRegion::registerKeys(const VectorOfCacheableKey& keys,
bool isDurable, bool getInitialValues,
bool receiveValues) {
- PoolPtr pool = PoolManager::find(getAttributes()->getPoolName());
+ PoolPtr pool = m_cacheImpl->getCache()->getPoolManager().find(
+ getAttributes()->getPoolName());
if (pool != nullptr) {
if (!pool->getSubscriptionEnabled()) {
LOGERROR(
@@ -417,7 +426,8 @@ void ThinClientRegion::registerKeys(const VectorOfCacheableKey& keys,
}
void ThinClientRegion::unregisterKeys(const VectorOfCacheableKey& keys) {
- PoolPtr pool = PoolManager::find(getAttributes()->getPoolName());
+ PoolPtr pool = m_cacheImpl->getCache()->getPoolManager().find(
+ getAttributes()->getPoolName());
if (pool != nullptr) {
if (!pool->getSubscriptionEnabled()) {
LOGERROR(
@@ -452,7 +462,8 @@ void ThinClientRegion::registerAllKeys(bool isDurable,
VectorOfCacheableKeyPtr resultKeys,
bool getInitialValues,
bool receiveValues) {
- PoolPtr pool = PoolManager::find(getAttributes()->getPoolName());
+ PoolPtr pool = m_cacheImpl->getCache()->getPoolManager().find(
+ getAttributes()->getPoolName());
if (pool != nullptr) {
if (!pool->getSubscriptionEnabled()) {
LOGERROR(
@@ -510,7 +521,8 @@ void ThinClientRegion::registerRegex(const char* regex, bool isDurable,
VectorOfCacheableKeyPtr resultKeys,
bool getInitialValues,
bool receiveValues) {
- PoolPtr pool = PoolManager::find(getAttributes()->getPoolName());
+ PoolPtr pool = m_cacheImpl->getCache()->getPoolManager().find(
+ getAttributes()->getPoolName());
if (pool != nullptr) {
if (!pool->getSubscriptionEnabled()) {
LOGERROR(
@@ -571,7 +583,8 @@ void ThinClientRegion::registerRegex(const char* regex, bool isDurable,
}
void ThinClientRegion::unregisterRegex(const char* regex) {
- PoolPtr pool = PoolManager::find(getAttributes()->getPoolName());
+ PoolPtr pool = m_cacheImpl->getCache()->getPoolManager().find(
+ getAttributes()->getPoolName());
if (pool != nullptr) {
if (!pool->getSubscriptionEnabled()) {
LOGERROR(
@@ -596,7 +609,8 @@ void ThinClientRegion::unregisterRegex(const char* regex) {
}
void ThinClientRegion::unregisterAllKeys() {
- PoolPtr pool = PoolManager::find(getAttributes()->getPoolName());
+ PoolPtr pool = m_cacheImpl->getCache()->getPoolManager().find(
+ getAttributes()->getPoolName());
if (pool != nullptr) {
if (!pool->getSubscriptionEnabled()) {
LOGERROR(
@@ -688,7 +702,8 @@ bool ThinClientRegion::existsValue(const char* predicate, uint32_t timeout) {
}
GfErrType ThinClientRegion::unregisterKeysBeforeDestroyRegion() {
- PoolPtr pool = PoolManager::find(getAttributes()->getPoolName());
+ PoolPtr pool = m_cacheImpl->getCache()->getPoolManager().find(
+ getAttributes()->getPoolName());
if (pool != nullptr) {
if (!pool->getSubscriptionEnabled()) {
LOGDEBUG(
@@ -756,7 +771,8 @@ void ThinClientRegion::serverKeys(VectorOfCacheableKey& v) {
CHECK_DESTROY_PENDING(TryReadGuard, Region::serverKeys);
TcrMessageReply reply(true, m_tcrdm);
- TcrMessageKeySet request(m_fullPath, m_tcrdm);
+ TcrMessageKeySet request(m_cacheImpl->getCache()->createDataOutput(),
+ m_fullPath, m_tcrdm);
reply.setMessageTypeRequest(TcrMessage::KEY_SET);
// need to check
ChunkedKeySetResponse* resultCollector(
@@ -812,8 +828,9 @@ bool ThinClientRegion::containsKeyOnServer(
/** @brief Create message and send to bridge server */
- TcrMessageContainsKey request(this, keyPtr, static_cast<UserDataPtr>(nullptr),
- true, m_tcrdm);
+ TcrMessageContainsKey request(m_cache->createDataOutput(), this, keyPtr,
+ static_cast<UserDataPtr>(nullptr), true,
+ m_tcrdm);
TcrMessageReply reply(true, m_tcrdm);
reply.setMessageTypeRequest(TcrMessage::CONTAINS_KEY);
err = m_tcrdm->sendSyncRequest(request, reply);
@@ -866,8 +883,9 @@ bool ThinClientRegion::containsValueForKey_remote(
/** @brief Create message and send to bridge server */
- TcrMessageContainsKey request(this, keyPtr, static_cast<UserDataPtr>(nullptr),
- false, m_tcrdm);
+ TcrMessageContainsKey request(m_cache->createDataOutput(), this, keyPtr,
+ static_cast<UserDataPtr>(nullptr), false,
+ m_tcrdm);
TcrMessageReply reply(true, m_tcrdm);
reply.setMessageTypeRequest(TcrMessage::CONTAINS_KEY);
err = m_tcrdm->sendSyncRequest(request, reply);
@@ -912,7 +930,8 @@ void ThinClientRegion::clear(const UserDataPtr& aCallbackArgument) {
/** @brief Create message and send to bridge server */
- TcrMessageClearRegion request(this, aCallbackArgument, -1, m_tcrdm);
+ TcrMessageClearRegion request(m_cache->createDataOutput(), this,
+ aCallbackArgument, -1, m_tcrdm);
TcrMessageReply reply(true, m_tcrdm);
err = m_tcrdm->sendSyncRequest(request, reply);
if (err != GF_NOERR) GfErrTypeToException("Region::clear", err);
@@ -952,7 +971,8 @@ GfErrType ThinClientRegion::getNoThrow_remote(
/** @brief Create message and send to bridge server */
- TcrMessageRequest request(this, keyPtr, aCallbackArgument, m_tcrdm);
+ TcrMessageRequest request(m_cache->createDataOutput(), this, keyPtr,
+ aCallbackArgument, m_tcrdm);
TcrMessageReply reply(true, m_tcrdm);
err = m_tcrdm->sendSyncRequest(request, reply);
if (err != GF_NOERR) return err;
@@ -991,7 +1011,8 @@ GfErrType ThinClientRegion::invalidateNoThrow_remote(
/** @brief Create message and send to bridge server */
- TcrMessageInvalidate request(this, keyPtr, aCallbackArgument, m_tcrdm);
+ TcrMessageInvalidate request(m_cache->createDataOutput(), this, keyPtr,
+ aCallbackArgument, m_tcrdm);
TcrMessageReply reply(true, m_tcrdm);
err = m_tcrdm->sendSyncRequest(request, reply);
if (err != GF_NOERR) return err;
@@ -1030,25 +1051,27 @@ GfErrType ThinClientRegion::putNoThrow_remote(
// do TCR put
// bool delta = valuePtr->hasDelta();
bool delta = false;
- const char* conFlationValue =
- DistributedSystem::getSystemProperties()->conflateEvents();
+ const char* conFlationValue = getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties()
+ .conflateEvents();
if (checkDelta && valuePtr != nullptr && conFlationValue != nullptr &&
strcmp(conFlationValue, "true") != 0 &&
ThinClientBaseDM::isDeltaEnabledOnServer()) {
Delta* temp = dynamic_cast<Delta*>(valuePtr.get());
delta = (temp && temp->hasDelta());
}
- TcrMessagePut request(this, keyPtr, valuePtr, aCallbackArgument, delta,
- m_tcrdm);
+ TcrMessagePut request(m_cache->createDataOutput(), this, keyPtr, valuePtr,
+ aCallbackArgument, delta, m_tcrdm);
TcrMessageReply* reply = new TcrMessageReply(true, m_tcrdm);
err = m_tcrdm->sendSyncRequest(request, *reply);
if (delta) {
- m_cacheImpl->m_cacheStats
- ->incDeltaPut(); // Does not chcek whether success of failure..
+ m_cacheImpl->getCachePerfStats()
+ .incDeltaPut(); // Does not chcek whether success of failure..
if (reply->getMessageType() ==
TcrMessage::PUT_DELTA_ERROR) { // Try without delta
- TcrMessagePut request(this, keyPtr, valuePtr, aCallbackArgument, false,
- m_tcrdm, false, true);
+ TcrMessagePut request(m_cache->createDataOutput(), this, keyPtr, valuePtr,
+ aCallbackArgument, false, m_tcrdm, false, true);
delete reply;
reply = new TcrMessageReply(true, m_tcrdm);
err = m_tcrdm->sendSyncRequest(request, *reply);
@@ -1096,7 +1119,8 @@ GfErrType ThinClientRegion::destroyNoThrow_remote(
GfErrType err = GF_NOERR;
// do TCR destroy
- TcrMessageDestroy request(this, keyPtr, nullptr, aCallbackArgument, m_tcrdm);
+ TcrMessageDestroy request(m_cache->createDataOutput(), this, keyPtr, nullptr,
+ aCallbackArgument, m_tcrdm);
TcrMessageReply reply(true, m_tcrdm);
err = m_tcrdm->sendSyncRequest(request, reply);
if (err != GF_NOERR) return err;
@@ -1137,7 +1161,8 @@ GfErrType ThinClientRegion::removeNoThrow_remote(
GfErrType err = GF_NOERR;
// do TCR remove
- TcrMessageDestroy request(this, keyPtr, cvalue, aCallbackArgument, m_tcrdm);
+ TcrMessageDestroy request(m_cache->createDataOutput(), this, keyPtr, cvalue,
+ aCallbackArgument, m_tcrdm);
TcrMessageReply reply(true, m_tcrdm);
err = m_tcrdm->sendSyncRequest(request, reply);
if (err != GF_NOERR) {
@@ -1178,7 +1203,8 @@ GfErrType ThinClientRegion::removeNoThrowEX_remote(
GfErrType err = GF_NOERR;
// do TCR remove
- TcrMessageDestroy request(this, keyPtr, nullptr, aCallbackArgument, m_tcrdm);
+ TcrMessageDestroy request(m_cache->createDataOutput(), this, keyPtr, nullptr,
+ aCallbackArgument, m_tcrdm);
TcrMessageReply reply(true, m_tcrdm);
err = m_tcrdm->sendSyncRequest(request, reply);
if (err != GF_NOERR) {
@@ -1239,7 +1265,7 @@ GfErrType ThinClientRegion::getAllNoThrow_remote(
}
// create the GET_ALL request
TcrMessageGetAll request(
- this, keys, m_tcrdm,
+ m_cache->createDataOutput(), this, keys, m_tcrdm,
aCallbackArgument); // now we need to initialize later
TcrMessageReply reply(true, m_tcrdm);
@@ -1347,7 +1373,8 @@ GfErrType ThinClientRegion::singleHopPutAllNoThrow_remote(
* e. insert the worker into the vector.
*/
std::vector<PutAllWork*> putAllWorkers;
- ThreadPool* threadPool = TPSingleton::instance();
+ auto* threadPool =
+ CacheRegionHelper::getCacheImpl(getCache().get())->getThreadPool();
int locationMapIndex = 0;
for (const auto& locationIter : *locationMap) {
const auto& serverLocation = locationIter.first;
@@ -1616,7 +1643,8 @@ GfErrType ThinClientRegion::multiHopPutAllNoThrow_remote(
GfErrType err = GF_NOERR;
// Construct request/reply for putAll
- TcrMessagePutAll request(this, map, static_cast<int>(timeout * 1000), m_tcrdm,
+ TcrMessagePutAll request(m_cache->createDataOutput(), this, map,
+ static_cast<int>(timeout * 1000), m_tcrdm,
aCallbackArgument);
TcrMessageReply reply(true, m_tcrdm);
request.setTimeout(timeout);
@@ -1624,7 +1652,7 @@ GfErrType ThinClientRegion::multiHopPutAllNoThrow_remote(
ACE_Recursive_Thread_Mutex responseLock;
versionedObjPartList =
- std::make_shared<VersionedCacheableObjectPartList>(responseLock);
+ std::make_shared<VersionedCacheableObjectPartList>(this, responseLock);
// need to check
ChunkedPutAllResponse* resultCollector(new ChunkedPutAllResponse(
shared_from_this(), reply, responseLock, versionedObjPartList));
@@ -1731,7 +1759,8 @@ GfErrType ThinClientRegion::singleHopRemoveAllNoThrow_remote(
* e. insert the worker into the vector.
*/
std::vector<RemoveAllWork*> removeAllWorkers;
- ThreadPool* threadPool = TPSingleton::instance();
+ auto* threadPool =
+ CacheRegionHelper::getCacheImpl(getCache().get())->getThreadPool();
int locationMapIndex = 0;
for (const auto& locationIter : *locationMap) {
const auto& serverLocation = locationIter.first;
@@ -1947,12 +1976,13 @@ GfErrType ThinClientRegion::multiHopRemoveAllNoThrow_remote(
GfErrType err = GF_NOERR;
// Construct request/reply for putAll
- TcrMessageRemoveAll request(this, keys, aCallbackArgument, m_tcrdm);
+ TcrMessageRemoveAll request(m_cache->createDataOutput(), this, keys,
+ aCallbackArgument, m_tcrdm);
TcrMessageReply reply(true, m_tcrdm);
ACE_Recursive_Thread_Mutex responseLock;
versionedObjPartList =
- std::make_shared<VersionedCacheableObjectPartList>(responseLock);
+ std::make_shared<VersionedCacheableObjectPartList>(this, responseLock);
// need to check
ChunkedRemoveAllResponse* resultCollector(new ChunkedRemoveAllResponse(
shared_from_this(), reply, responseLock, versionedObjPartList));
@@ -2023,7 +2053,7 @@ uint32_t ThinClientRegion::size_remote() {
GfErrType err = GF_NOERR;
// do TCR size
- TcrMessageSize request(m_fullPath.c_str());
+ TcrMessageSize request(m_cache->createDataOutput(), m_fullPath.c_str());
TcrMessageReply reply(true, m_tcrdm);
err = m_tcrdm->sendSyncRequest(request, reply);
@@ -2034,8 +2064,7 @@ uint32_t ThinClientRegion::size_remote() {
switch (reply.getMessageType()) {
case TcrMessage::RESPONSE: {
CacheableInt32Ptr size =
- std::static_pointer_cast<CacheableInt32>(
- reply.getValue());
+ std::static_pointer_cast<CacheableInt32>(reply.getValue());
return size->value();
// LOGINFO("Map is written into remote server at region %s",
// m_fullPath.c_str());
@@ -2229,7 +2258,8 @@ GfErrType ThinClientRegion::destroyRegionNoThrow_remote(
GfErrType err = GF_NOERR;
// do TCR destroyRegion
- TcrMessageDestroyRegion request(this, aCallbackArgument, -1, m_tcrdm);
+ TcrMessageDestroyRegion request(m_cache->createDataOutput(), this,
+ aCallbackArgument, -1, m_tcrdm);
TcrMessageReply reply(true, m_tcrdm);
err = m_tcrdm->sendSyncRequest(request, reply);
if (err != GF_NOERR) return err;
@@ -2284,8 +2314,9 @@ GfErrType ThinClientRegion::registerKeysNoThrow(
interestPolicy.ordinal);
TcrMessageRegisterInterestList request(
- this, keys, isDurable, getAttributes()->getCachingEnabled(),
- receiveValues, interestPolicy, m_tcrdm);
+ m_cache->createDataOutput(), this, keys, isDurable,
+ getAttributes()->getCachingEnabled(), receiveValues, interestPolicy,
+ m_tcrdm);
ACE_Recursive_Thread_Mutex responseLock;
TcrChunkedResult* resultCollector = nullptr;
if (interestPolicy.ordinal == InterestResultPolicy::KEYS_VALUES.ordinal) {
@@ -2348,7 +2379,8 @@ GfErrType ThinClientRegion::unregisterKeysNoThrow(
return GF_CACHE_ILLEGAL_STATE_EXCEPTION;
}
- TcrMessageUnregisterInterestList request(this, keys, false, false, true,
+ TcrMessageUnregisterInterestList request(m_cache->createDataOutput(), this,
+ keys, false, false, true,
InterestResultPolicy::NONE, m_tcrdm);
err = m_tcrdm->sendSyncRequestRegisterInterest(request, reply);
if (err == GF_NOERR /*|| err == GF_CACHE_REDUNDANCY_FAILURE*/) {
@@ -2382,7 +2414,8 @@ GfErrType ThinClientRegion::unregisterKeysNoThrowLocalDestroy(
return GF_CACHE_ILLEGAL_STATE_EXCEPTION;
}
- TcrMessageUnregisterInterestList request(this, keys, false, false, true,
+ TcrMessageUnregisterInterestList request(m_cache->createDataOutput(), this,
+ keys, false, false, true,
InterestResultPolicy::NONE, m_tcrdm);
err = m_tcrdm->sendSyncRequestRegisterInterest(request, reply);
if (err == GF_NOERR) {
@@ -2456,8 +2489,8 @@ GfErrType ThinClientRegion::registerRegexNoThrow(
// TODO:
TcrMessageRegisterInterest request(
- m_fullPath, regex.c_str(), interestPolicy, isDurable,
- getAttributes()->getCachingEnabled(), receiveValues, m_tcrdm);
+ m_cache->createDataOutput(), m_fullPath, regex.c_str(), interestPolicy,
+ isDurable, getAttributes()->getCachingEnabled(), receiveValues, m_tcrdm);
ACE_Recursive_Thread_Mutex responseLock;
if (reply == nullptr) {
reply = &replyLocal;
@@ -2527,9 +2560,9 @@ GfErrType ThinClientRegion::unregisterRegexNoThrow(const std::string& regex,
if (err == GF_NOERR) {
TcrMessageReply reply(false, m_tcrdm);
- TcrMessageUnregisterInterest request(m_fullPath, regex,
- InterestResultPolicy::NONE, false,
- false, true, m_tcrdm);
+ TcrMessageUnregisterInterest request(
+ m_cache->createDataOutput(), m_fullPath, regex,
+ InterestResultPolicy::NONE, false, false, true, m_tcrdm);
err = m_tcrdm->sendSyncRequestRegisterInterest(request, reply);
if (err == GF_NOERR /*|| err == GF_CACHE_REDUNDANCY_FAILURE*/) {
if (attemptFailover) {
@@ -2573,9 +2606,9 @@ GfErrType ThinClientRegion::unregisterRegexNoThrowLocalDestroy(
if (err == GF_NOERR) {
TcrMessageReply reply(false, m_tcrdm);
- TcrMessageUnregisterInterest request(m_fullPath, regex,
- InterestResultPolicy::NONE, false,
- false, true, m_tcrdm);
+ TcrMessageUnregisterInterest request(
+ m_cache->createDataOutput(), m_fullPath, regex,
+ InterestResultPolicy::NONE, false, false, true, m_tcrdm);
err = m_tcrdm->sendSyncRequestRegisterInterest(request, reply);
if (err == GF_NOERR) {
if (attemptFailover) {
@@ -3054,12 +3087,12 @@ void ThinClientRegion::executeFunction(const char* func,
TcrMessage* msg;
if (reExecuteForServ) {
msg = new TcrMessageExecuteRegionFunction(
- funcName, this, args, routingObj, getResult, failedNodes, timeout,
- m_tcrdm, static_cast<int8_t>(1));
+ m_cache->createDataOutput(), funcName, this, args, routingObj,
+ getResult, failedNodes, timeout, m_tcrdm, static_cast<int8_t>(1));
} else {
msg = new TcrMessageExecuteRegionFunction(
- funcName, this, args, routingObj, getResult, failedNodes, timeout,
- m_tcrdm, static_cast<int8_t>(0));
+ m_cache->createDataOutput(), funcName, this, args, routingObj,
+ getResult, failedNodes, timeout, m_tcrdm, static_cast<int8_t>(0));
}
TcrMessageReply reply(true, m_tcrdm);
// need to check
@@ -3151,9 +3184,10 @@ CacheableVectorPtr ThinClientRegion::reExecuteFunction(
do {
reExecute = false;
std::string funcName(func);
- TcrMessageExecuteRegionFunction msg(
- funcName, this, args, routingObj, getResult, failedNodes, timeout,
- m_tcrdm, /*reExecute*/ static_cast<int8_t>(1));
+ TcrMessageExecuteRegionFunction msg(m_cache->createDataOutput(), funcName,
+ this, args, routingObj, getResult,
+ failedNodes, timeout, m_tcrdm,
+ /*reExecute*/ static_cast<int8_t>(1));
TcrMessageReply reply(true, m_tcrdm);
// need to check
ChunkedFunctionExecutionResponse* resultCollector(
@@ -3222,7 +3256,8 @@ bool ThinClientRegion::executeFunctionSH(
const auto& userAttr =
TSSUserAttributesWrapper::s_geodeTSSUserAttributes->getUserAttributes();
std::vector<OnRegionFunctionExecution*> feWorkers;
- auto threadPool = TPSingleton::instance();
+ auto* threadPool =
+ CacheRegionHelper::getCacheImpl(getCache().get())->getThreadPool();
for (const auto& locationIter : *locationMap) {
const auto& serverLocation = locationIter.first;
@@ -3317,7 +3352,8 @@ GfErrType ThinClientRegion::getFuncAttributes(const char* func,
// do TCR GET_FUNCTION_ATTRIBUTES
LOGDEBUG("Tcrmessage request GET_FUNCTION_ATTRIBUTES ");
std::string funcName(func);
- TcrMessageGetFunctionAttributes request(funcName, m_tcrdm);
+ TcrMessageGetFunctionAttributes request(m_cache->createDataOutput(), funcName,
+ m_tcrdm);
TcrMessageReply reply(true, m_tcrdm);
err = m_tcrdm->sendSyncRequest(request, reply);
if (err != GF_NOERR) {
@@ -3345,7 +3381,8 @@ GfErrType ThinClientRegion::getFuncAttributes(const char* func,
GfErrType ThinClientRegion::getNoThrow_FullObject(EventIdPtr eventId,
CacheablePtr& fullObject,
VersionTagPtr& versionTag) {
- TcrMessageRequestEventValue fullObjectMsg(eventId);
+ TcrMessageRequestEventValue fullObjectMsg(m_cache->createDataOutput(),
+ eventId);
TcrMessageReply reply(true, nullptr);
GfErrType err = GF_NOTCON;
@@ -3378,12 +3415,12 @@ void ThinClientRegion::txPut(const CacheableKeyPtr& key,
const UserDataPtr& aCallbackArgument,
VersionTagPtr versionTag) {
CacheablePtr oldValue;
- int64_t sampleStartNanos = Utils::startStatOpTime();
+ int64_t sampleStartNanos = startStatOpTime();
GfErrType err = putNoThrowTX(key, value, aCallbackArgument, oldValue, -1,
CacheEventFlags::NORMAL, versionTag);
- Utils::updateStatOpTime(m_regionStats->getStat(),
- RegionStatType::getInstance()->getPutTimeId(),
- sampleStartNanos);
+
+ updateStatOpTime(m_regionStats->getStat(), m_regionStats->getPutTimeId(),
+ sampleStartNanos);
GfErrTypeToException("Region::putTX", err);
}
@@ -3395,18 +3432,19 @@ void ChunkedInterestResponse::reset() {
void ChunkedInterestResponse::handleChunk(const uint8_t* chunk,
int32_t chunkLen,
- uint8_t isLastChunkWithSecurity) {
- DataInput input(chunk, chunkLen);
+ uint8_t isLastChunkWithSecurity,
+ const Cache* cache) {
+ auto input = cache->createDataInput(chunk, chunkLen);
- input.setPoolName(m_replyMsg.getPoolName());
+ input->setPoolName(m_replyMsg.getPoolName());
uint32_t partLen;
if (TcrMessageHelper::readChunkPartHeader(
- m_msg, input, 0, GeodeTypeIds::CacheableArrayList,
+ m_msg, *input, 0, GeodeTypeIds::CacheableArrayList,
"ChunkedInterestResponse", partLen,
isLastChunkWithSecurity) != TcrMessageHelper::OBJECT) {
// encountered an exception part, so return without reading more
- m_replyMsg.readSecureObjectPart(input, false, true,
+ m_replyMsg.readSecureObjectPart(*input, false, true,
isLastChunkWithSecurity);
return;
}
@@ -3414,8 +3452,8 @@ void ChunkedInterestResponse::handleChunk(const uint8_t* chunk,
if (m_resultKeys == nullptr) {
m_resultKeys = std::make_shared<VectorOfCacheableKey>();
}
- serializer::readObject(input, *m_resultKeys);
- m_replyMsg.readSecureObjectPart(input, false, true, isLastChunkWithSecurity);
+ serializer::readObject(*input, *m_resultKeys);
+ m_replyMsg.readSecureObjectPart(*input, false, true, isLastChunkWithSecurity);
}
void ChunkedKeySetResponse::reset() {
@@ -3425,24 +3463,25 @@ void ChunkedKeySetResponse::reset() {
}
void ChunkedKeySetResponse::handleChunk(const uint8_t* chunk, int32_t chunkLen,
- uint8_t isLastChunkWithSecurity) {
- DataInput input(chunk, chunkLen);
+ uint8_t isLastChunkWithSecurity,
+ const Cache* cache) {
+ auto input = cache->createDataInput(chunk, chunkLen);
- input.setPoolName(m_replyMsg.getPoolName());
+ input->setPoolName(m_replyMsg.getPoolName());
uint32_t partLen;
if (TcrMessageHelper::readChunkPartHeader(
- m_msg, input, 0, GeodeTypeIds::CacheableArrayList,
+ m_msg, *input, 0, GeodeTypeIds::CacheableArrayList,
"ChunkedKeySetResponse", partLen,
isLastChunkWithSecurity) != TcrMessageHelper::OBJECT) {
// encountered an exception part, so return without reading more
- m_replyMsg.readSecureObjectPart(input, false, true,
+ m_replyMsg.readSecureObjectPart(*input, false, true,
isLastChunkWithSecurity);
return;
}
- serializer::readObject(input, m_resultKeys);
- m_replyMsg.readSecureObjectPart(input, false, true, isLastChunkWithSecurity);
+ serializer::readObject(*input, m_resultKeys);
+ m_replyMsg.readSecureObjectPart(*input, false, true, isLastChunkWithSecurity);
}
void ChunkedQueryResponse::reset() {
@@ -3510,31 +3549,32 @@ void ChunkedQueryResponse::readObjectPartList(DataInput& input,
}
void ChunkedQueryResponse::handleChunk(const uint8_t* chunk, int32_t chunkLen,
- uint8_t isLastChunkWithSecurity) {
+ uint8_t isLastChunkWithSecurity,
+ const Cache* cache) {
LOGDEBUG("ChunkedQueryResponse::handleChunk..");
- DataInput input(chunk, chunkLen);
- input.setPoolName(m_msg.getPoolName());
+ auto input = cache->createDataInput(chunk, chunkLen);
+ input->setPoolName(m_msg.getPoolName());
uint32_t partLen;
int8_t isObj;
TcrMessageHelper::ChunkObjectType objType;
if ((objType = TcrMessageHelper::readChunkPartHeader(
- m_msg, input, GeodeTypeIdsImpl::FixedIDByte,
+ m_msg, *input, GeodeTypeIdsImpl::FixedIDByte,
static_cast<uint8_t>(GeodeTypeIdsImpl::CollectionTypeImpl),
"ChunkedQueryResponse", partLen, isLastChunkWithSecurity)) ==
TcrMessageHelper::EXCEPTION) {
// encountered an exception part, so return without reading more
- m_msg.readSecureObjectPart(input, false, true, isLastChunkWithSecurity);
+ m_msg.readSecureObjectPart(*input, false, true, isLastChunkWithSecurity);
return;
} else if (objType == TcrMessageHelper::NULL_OBJECT) {
// special case for scalar result
- input.readInt(&partLen);
- input.read(&isObj);
+ input->readInt(&partLen);
+ input->read(&isObj);
CacheableInt32Ptr intVal;
- input.readObject(intVal, true);
+ input->readObject(intVal, true);
m_queryResults->push_back(intVal);
// TODO:
- m_msg.readSecureObjectPart(input, false, true, isLastChunkWithSecurity);
+ m_msg.readSecureObjectPart(*input, false, true, isLastChunkWithSecurity);
return;
}
@@ -3550,30 +3590,30 @@ void ChunkedQueryResponse::handleChunk(const uint8_t* chunk, int32_t chunkLen,
// If the results on server are in a bag, or the user need to manipulate
// the elements, then we have to revisit this issue.
// For now, we'll live with duplicate records, hoping they do not cost much.
- skipClass(input);
+ skipClass(*input);
// skipping CollectionTypeImpl
- // skipClass(input); // no longer, since GFE 5.7
+ // skipClass(*input); // no longer, since GFE 5.7
int8_t structType;
- input.read(&structType); // this is Fixed ID byte (1)
- input.read(&structType); // this is DataSerializable (45)
- input.read(&classByte);
+ input->read(&structType); // this is Fixed ID byte (1)
+ input->read(&structType); // this is DataSerializable (45)
+ input->read(&classByte);
uint8_t stringType;
- input.read(&stringType); // ignore string header - assume 64k string
- input.readUTF(&isStructTypeImpl, &stiLen);
+ input->read(&stringType); // ignore string header - assume 64k string
+ input->readUTF(&isStructTypeImpl, &stiLen);
DeleteArray<char> delSTI(isStructTypeImpl);
if (strcmp(isStructTypeImpl, "org.apache.geode.cache.query.Struct") == 0) {
int32_t numOfFldNames;
- input.readArrayLen(&numOfFldNames);
+ input->readArrayLen(&numOfFldNames);
bool skip = false;
if (m_structFieldNames.size() != 0) {
skip = true;
}
for (int i = 0; i < numOfFldNames; i++) {
CacheableStringPtr sptr;
- // input.readObject(sptr);
- input.readNativeString(sptr);
+ // input->readObject(sptr);
+ input->readNativeString(sptr);
if (!skip) {
m_structFieldNames.push_back(sptr);
}
@@ -3581,12 +3621,12 @@ void ChunkedQueryResponse::handleChunk(const uint8_t* chunk, int32_t chunkLen,
}
// skip the remaining part
- input.reset();
+ input->reset();
// skip the whole part including partLen and isObj (4+1)
- input.advanceCursor(partLen + 5);
+ input->advanceCursor(partLen + 5);
- input.readInt(&partLen);
- input.read(&isObj);
+ input->readInt(&partLen);
+ input->read(&isObj);
if (!isObj) {
LOGERROR(
"Query response part is not an object; possible serialization "
@@ -3599,30 +3639,30 @@ void ChunkedQueryResponse::handleChunk(const uint8_t* chunk, int32_t chunkLen,
bool isResultSet = (m_structFieldNames.size() == 0);
int8_t arrayType;
- input.read(&arrayType);
+ input->read(&arrayType);
if (arrayType == GeodeTypeIds::CacheableObjectArray) {
int32_t arraySize;
- input.readArrayLen(&arraySize);
- skipClass(input);
+ input->readArrayLen(&arraySize);
+ skipClass(*input);
for (int32_t arrayItem = 0; arrayItem < arraySize; ++arrayItem) {
SerializablePtr value;
if (isResultSet) {
- input.readObject(value);
+ input->readObject(value);
m_queryResults->push_back(value);
} else {
- input.read(&isObj);
+ input->read(&isObj);
int32_t arraySize2;
- input.readArrayLen(&arraySize2);
- skipClass(input);
+ input->readArrayLen(&arraySize2);
+ skipClass(*input);
for (int32_t index = 0; index < arraySize2; ++index) {
- input.readObject(value);
+ input->readObject(value);
m_queryResults->push_back(value);
}
}
}
} else if (arrayType == GeodeTypeIdsImpl::FixedIDByte) {
- input.read(&arrayType);
+ input->read(&arrayType);
if (arrayType != GeodeTypeIdsImpl::CacheableObjectPartList) {
LOGERROR(
"Query response got unhandled message format %d while expecting "
@@ -3632,7 +3672,7 @@ void ChunkedQueryResponse::handleChunk(const uint8_t* chunk, int32_t chunkLen,
"Query response got unhandled message format while expecting object "
"part list; possible serialization mismatch");
}
- readObjectPartList(input, isResultSet);
+ readObjectPartList(*input, isResultSet);
} else {
LOGERROR(
"Query response got unhandled message format %d; possible "
@@ -3643,7 +3683,7 @@ void ChunkedQueryResponse::handleChunk(const uint8_t* chunk, int32_t chunkLen,
"mismatch");
}
- m_msg.readSecureObjectPart(input, false, true, isLastChunkWithSecurity);
+ m_msg.readSecureObjectPart(*input, false, true, isLastChunkWithSecurity);
}
void ChunkedQueryResponse::skipClass(DataInput& input) {
@@ -3668,19 +3708,20 @@ void ChunkedFunctionExecutionResponse::reset() {
}
void ChunkedFunctionExecutionResponse::handleChunk(
- const uint8_t* chunk, int32_t chunkLen, uint8_t isLastChunkWithSecurity) {
+ const uint8_t* chunk, int32_t chunkLen, uint8_t isLastChunkWithSecurity,
+ const Cache* cache) {
LOGDEBUG("ChunkedFunctionExecutionResponse::handleChunk");
- DataInput input(chunk, chunkLen);
- input.setPoolName(m_msg.getPoolName());
+ auto input = cache->createDataInput(chunk, chunkLen);
+ input->setPoolName(m_msg.getPoolName());
uint32_t partLen;
int8_t arrayType;
if ((arrayType = static_cast<TcrMessageHelper::ChunkObjectType>(
TcrMessageHelper::readChunkPartHeader(
- m_msg, input, "ChunkedFunctionExecutionResponse", partLen,
+ m_msg, *input, "ChunkedFunctionExecutionResponse", partLen,
isLastChunkWithSecurity))) == TcrMessageHelper::EXCEPTION) {
// encountered an exception part, so return without reading more
- m_msg.readSecureObjectPart(input, false, true, isLastChunkWithSecurity);
+ m_msg.readSecureObjectPart(*input, false, true, isLastChunkWithSecurity);
return;
}
@@ -3692,20 +3733,20 @@ void ChunkedFunctionExecutionResponse::handleChunk(
TcrMessageHelper::NULL_OBJECT) {
LOGDEBUG("ChunkedFunctionExecutionResponse::handleChunk nullptr object");
// m_functionExecutionResults->push_back(nullptr);
- m_msg.readSecureObjectPart(input, false, true, isLastChunkWithSecurity);
+ m_msg.readSecureObjectPart(*input, false, true, isLastChunkWithSecurity);
return;
}
int32_t len;
int startLen =
- input.getBytesRead() -
+ input->getBytesRead() -
1; // from here need to look value part + memberid AND -1 for array type
- input.readArrayLen(&len);
+ input->readArrayLen(&len);
// read a byte to determine whether to read exception part for sendException
// or read objects.
uint8_t partType;
- input.read(&partType);
+ input->read(&partType);
bool isExceptionPart = false;
// See If partType is JavaSerializable
const int CHUNK_HDR_LEN = 5;
@@ -3718,7 +3759,7 @@ void ChunkedFunctionExecutionResponse::handleChunk(
if (partType == GeodeTypeIdsImpl::JavaSerializable) {
isExceptionPart = true;
// reset the input.
- input.reset();
+ input->reset();
if (((isLastChunkWithSecurity & 0x02) &&
(chunkLen - static_cast<int32_t>(partLen) <=
@@ -3726,54 +3767,54 @@ void ChunkedFunctionExecutionResponse::handleChunk(
(((isLastChunkWithSecurity & 0x02) == 0) &&
(chunkLen - static_cast<int32_t>(partLen) <= CHUNK_HDR_LEN))) {
readPart = false;
- input.readInt(&partLen);
- input.advanceCursor(1); // skip isObject byte
- input.advanceCursor(partLen);
+ input->readInt(&partLen);
+ input->advanceCursor(1); // skip isObject byte
+ input->advanceCursor(partLen);
} else {
// skip first part i.e JavaSerializable.
- TcrMessageHelper::skipParts(m_msg, input, 1);
+ TcrMessageHelper::skipParts(m_msg, *input, 1);
// read the second part which is string in usual manner, first its length.
- input.readInt(&partLen);
+ input->readInt(&partLen);
int8_t isObject;
// then isObject byte
- input.read(&isObject);
+ input->read(&isObject);
- startLen = input.getBytesRead(); // reset from here need to look value
+ startLen = input->getBytesRead(); // reset from here need to look value
// part + memberid AND -1 for array type
// Since it is contained as a part of other results, read arrayType which
// is arrayList = 65.
- input.read(&arrayType);
+ input->read(&arrayType);
// then its len which is 2
- input.readArrayLen(&len);
+ input->readArrayLen(&len);
}
} else {
// rewind cursor by 1 to what we had read a byte to determine whether to
// read exception part or read objects.
- input.rewindCursor(1);
+ input->rewindCursor(1);
}
// Read either object or exception string from sendException.
SerializablePtr value;
// CacheablePtr memberId;
if (readPart) {
- input.readObject(value);
+ input->readObject(value);
// TODO: track this memberId for PrFxHa
- // input.readObject(memberId);
- int objectlen = input.getBytesRead() - startLen;
+ // input->readObject(memberId);
+ int objectlen = input->getBytesRead() - startLen;
int memberIdLen = partLen - objectlen;
- input.advanceCursor(memberIdLen);
+ input->advanceCursor(memberIdLen);
LOGDEBUG("function partlen = %d , objectlen = %d, memberidlen = %d ",
partLen, objectlen, memberIdLen);
- LOGDEBUG("function input.getBytesRemaining() = %d ",
- input.getBytesRemaining());
+ LOGDEBUG("function input->getBytesRemaining() = %d ",
+ input->getBytesRemaining());
// is there any way to assert it, as after that we need to read security
// header
- /*if(input.getBytesRemaining() != 0) {
+ /*if(input->getBytesRemaining() != 0) {
LOGERROR("Function response not read all bytes");
throw IllegalStateException("Function Execution didn't read all bytes");
}*/
@@ -3796,7 +3837,7 @@ void ChunkedFunctionExecutionResponse::handleChunk(
}
}
- m_msg.readSecureObjectPart(input, false, true, isLastChunkWithSecurity);
+ m_msg.readSecureObjectPart(*input, false, true, isLastChunkWithSecurity);
// m_functionExecutionResults->push_back(value);
}
@@ -3809,16 +3850,17 @@ void ChunkedGetAllResponse::reset() {
// process a GET_ALL response chunk
void ChunkedGetAllResponse::handleChunk(const uint8_t* chunk, int32_t chunkLen,
- uint8_t isLastChunkWithSecurity) {
- DataInput input(chunk, chunkLen);
- input.setPoolName(m_msg.getPoolName());
+ uint8_t isLastChunkWithSecurity,
+ const Cache* cache) {
+ auto input = cache->createDataInput(chunk, chunkLen);
+ input->setPoolName(m_msg.getPoolName());
uint32_t partLen;
if (TcrMessageHelper::readChunkPartHeader(
- m_msg, input, GeodeTypeIdsImpl::FixedIDByte,
+ m_msg, *input, GeodeTypeIdsImpl::FixedIDByte,
GeodeTypeIdsImpl::VersionedObjectPartList, "ChunkedGetAllResponse",
partLen, isLastChunkWithSecurity) != TcrMessageHelper::OBJECT) {
// encountered an exception part, so return without reading more
- m_msg.readSecureObjectPart(input, false, true, isLastChunkWithSecurity);
+ m_msg.readSecureObjectPart(*input, false, true, isLastChunkWithSecurity);
return;
}
@@ -3827,9 +3869,9 @@ void ChunkedGetAllResponse::handleChunk(const uint8_t* chunk, int32_t chunkLen,
&m_trackerMap, m_destroyTracker, m_addToLocalCache, m_dsmemId,
m_responseLock);
- objectList.fromData(input);
+ objectList.fromData(*input);
- m_msg.readSecureObjectPart(input, false, true, isLastChunkWithSecurity);
+ m_msg.readSecureObjectPart(*input, false, true, isLastChunkWithSecurity);
}
void ChunkedGetAllResponse::add(const ChunkedGetAllResponse* other) {
@@ -3862,20 +3904,21 @@ void ChunkedPutAllResponse::reset() {
// process a PUT_ALL response chunk
void ChunkedPutAllResponse::handleChunk(const uint8_t* chunk, int32_t chunkLen,
- uint8_t isLastChunkWithSecurity) {
- DataInput input(chunk, chunkLen);
- input.setPoolName(m_msg.getPoolName());
+ uint8_t isLastChunkWithSecurity,
+ const Cache* cache) {
+ auto input = cache->createDataInput(chunk, chunkLen);
+ input->setPoolName(m_msg.getPoolName());
uint32_t partLen;
int8_t chunkType;
if ((chunkType = (TcrMessageHelper::ChunkObjectType)
TcrMessageHelper::readChunkPartHeader(
- m_msg, input, GeodeTypeIdsImpl::FixedIDByte,
+ m_msg, *input, GeodeTypeIdsImpl::FixedIDByte,
GeodeTypeIdsImpl::VersionedObjectPartList,
"ChunkedPutAllResponse", partLen, isLastChunkWithSecurity)) ==
TcrMessageHelper::NULL_OBJECT) {
LOGDEBUG("ChunkedPutAllResponse::handleChunk nullptr object");
// No issues it will be empty in case of disabled caching.
- m_msg.readSecureObjectPart(input, false, true, isLastChunkWithSecurity);
+ m_msg.readSecureObjectPart(*input, false, true, isLastChunkWithSecurity);
return;
}
@@ -3884,21 +3927,22 @@ void ChunkedPutAllResponse::handleChunk(const uint8_t* chunk, int32_t chunkLen,
LOGDEBUG("ChunkedPutAllResponse::handleChunk object");
ACE_Recursive_Thread_Mutex responseLock;
auto vcObjPart = std::make_shared<VersionedCacheableObjectPartList>(
+ dynamic_cast<ThinClientRegion*>(m_region.get()),
m_msg.getChunkedResultHandler()->getEndpointMemId(), responseLock);
- vcObjPart->fromData(input);
+ vcObjPart->fromData(*input);
m_list->addAll(vcObjPart);
- m_msg.readSecureObjectPart(input, false, true, isLastChunkWithSecurity);
+ m_msg.readSecureObjectPart(*input, false, true, isLastChunkWithSecurity);
} else {
LOGDEBUG("ChunkedPutAllResponse::handleChunk BYTES PART");
int8_t byte0;
- input.read(&byte0);
+ input->read(&byte0);
LOGDEBUG("ChunkedPutAllResponse::handleChunk single-hop bytes byte0 = %d ",
byte0);
int8_t byte1;
- input.read(&byte1);
- m_msg.readSecureObjectPart(input, false, true, isLastChunkWithSecurity);
+ input->read(&byte1);
+ m_msg.readSecureObjectPart(*input, false, true, isLastChunkWithSecurity);
- PoolPtr pool = PoolManager::find(m_msg.getPoolName());
+ PoolPtr pool = cache->getPoolManager().find(m_msg.getPoolName());
if (pool != nullptr && !pool->isDestroyed() &&
pool->getPRSingleHopEnabled()) {
ThinClientPoolDM* poolDM = dynamic_cast<ThinClientPoolDM*>(pool.get());
@@ -3924,20 +3968,21 @@ void ChunkedRemoveAllResponse::reset() {
// process a REMOVE_ALL response chunk
void ChunkedRemoveAllResponse::handleChunk(const uint8_t* chunk,
int32_t chunkLen,
- uint8_t isLastChunkWithSecurity) {
- DataInput input(chunk, chunkLen);
- input.setPoolName(m_msg.getPoolName());
+ uint8_t isLastChunkWithSecurity,
+ const Cache* cache) {
+ auto input = cache->createDataInput(chunk, chunkLen);
+ input->setPoolName(m_msg.getPoolName());
uint32_t partLen;
int8_t chunkType;
if ((chunkType = (TcrMessageHelper::ChunkObjectType)
TcrMessageHelper::readChunkPartHeader(
- m_msg, input, GeodeTypeIdsImpl::FixedIDByte,
+ m_msg, *input, GeodeTypeIdsImpl::FixedIDByte,
GeodeTypeIdsImpl::VersionedObjectPartList,
"ChunkedRemoveAllResponse", partLen, isLastChunkWithSecurity)) ==
TcrMessageHelper::NULL_OBJECT) {
LOGDEBUG("ChunkedRemoveAllResponse::handleChunk nullptr object");
// No issues it will be empty in case of disabled caching.
- m_msg.readSecureObjectPart(input, false, true, isLastChunkWithSecurity);
+ m_msg.readSecureObjectPart(*input, false, true, isLastChunkWithSecurity);
return;
}
@@ -3946,22 +3991,23 @@ void ChunkedRemoveAllResponse::handleChunk(const uint8_t* chunk,
LOGDEBUG("ChunkedRemoveAllResponse::handleChunk object");
ACE_Recursive_Thread_Mutex responseLock;
auto vcObjPart = std::make_shared<VersionedCacheableObjectPartList>(
+ dynamic_cast<ThinClientRegion*>(m_region.get()),
m_msg.getChunkedResultHandler()->getEndpointMemId(), responseLock);
- vcObjPart->fromData(input);
+ vcObjPart->fromData(*input);
m_list->addAll(vcObjPart);
- m_msg.readSecureObjectPart(input, false, true, isLastChunkWithSecurity);
+ m_msg.readSecureObjectPart(*input, false, true, isLastChunkWithSecurity);
} else {
LOGDEBUG("ChunkedRemoveAllResponse::handleChunk BYTES PART");
int8_t byte0;
- input.read(&byte0);
+ input->read(&byte0);
LOGDEBUG(
"ChunkedRemoveAllResponse::handleChunk single-hop bytes byte0 = %d ",
byte0);
int8_t byte1;
- input.read(&byte1);
- m_msg.readSecureObjectPart(input, false, true, isLastChunkWithSecurity);
+ input->read(&byte1);
+ m_msg.readSecureObjectPart(*input, false, true, isLastChunkWithSecurity);
- PoolPtr pool = PoolManager::find(m_msg.getPoolName());
+ PoolPtr pool = cache->getPoolManager().find(m_msg.getPoolName());
if (pool != nullptr && !pool->isDestroyed() &&
pool->getPRSingleHopEnabled()) {
ThinClientPoolDM* poolDM = dynamic_cast<ThinClientPoolDM*>(pool.get());
@@ -3985,17 +4031,19 @@ void ChunkedDurableCQListResponse::reset() {
}
// handles the chunk response for GETDURABLECQS_MSG_TYPE
-void ChunkedDurableCQListResponse::handleChunk(
- const uint8_t* chunk, int32_t chunkLen, uint8_t isLastChunkWithSecurity) {
- DataInput input(chunk, chunkLen);
- input.setPoolName(m_msg.getPoolName());
+void ChunkedDurableCQListResponse::handleChunk(const uint8_t* chunk,
+ int32_t chunkLen,
+ uint8_t isLastChunkWithSecurity,
+ const Cache* cache) {
+ auto input = cache->createDataInput(chunk, chunkLen);
+ input->setPoolName(m_msg.getPoolName());
// read part length
uint32_t partLen;
- input.readInt(&partLen);
+ input->readInt(&partLen);
bool isObj;
- input.readBoolean(&isObj);
+ input->readBoolean(&isObj);
if (!isObj) {
// we're currently always expecting an object
@@ -4006,16 +4054,16 @@ void ChunkedDurableCQListResponse::handleChunk(
throw MessageException(exMsg);
}
- input.advanceCursor(1); // skip the CacheableArrayList type ID byte
+ input->advanceCursor(1); // skip the CacheableArrayList type ID byte
int8_t stringParts;
- input.read(&stringParts); // read the number of strings in the message this
+ input->read(&stringParts); // read the number of strings in the message this
// is one byte
CacheableStringPtr strTemp;
for (int i = 0; i < stringParts; i++) {
- input.readObject(strTemp);
+ input->readObject(strTemp);
m_resultList->push_back(strTemp);
}
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ThinClientRegion.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ThinClientRegion.hpp b/src/cppcache/src/ThinClientRegion.hpp
index e52845e..0ed8d9d 100644
--- a/src/cppcache/src/ThinClientRegion.hpp
+++ b/src/cppcache/src/ThinClientRegion.hpp
@@ -366,7 +366,7 @@ class ChunkedInterestResponse : public TcrChunkedResult {
}
virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen,
- uint8_t isLastChunkWithSecurity);
+ uint8_t isLastChunkWithSecurity, const Cache* cache);
virtual void reset();
};
@@ -404,7 +404,7 @@ class ChunkedQueryResponse : public TcrChunkedResult {
}
virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen,
- uint8_t isLastChunkWithSecurity);
+ uint8_t isLastChunkWithSecurity, const Cache* cache);
virtual void reset();
void readObjectPartList(DataInput& input, bool isResultSet);
@@ -455,7 +455,7 @@ class ChunkedFunctionExecutionResponse : public TcrChunkedResult {
inline bool getResult() const { return m_getResult; }
virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen,
- uint8_t isLastChunkWithSecurity);
+ uint8_t isLastChunkWithSecurity, const Cache* cache);
virtual void reset();
};
typedef std::shared_ptr<ChunkedFunctionExecutionResponse>
@@ -506,7 +506,7 @@ class ChunkedGetAllResponse : public TcrChunkedResult {
m_responseLock(responseLock) {}
virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen,
- uint8_t isLastChunkWithSecurity);
+ uint8_t isLastChunkWithSecurity, const Cache* cache);
virtual void reset();
void add(const ChunkedGetAllResponse* other);
@@ -544,7 +544,7 @@ class ChunkedPutAllResponse : public TcrChunkedResult {
m_list(list) {}
virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen,
- uint8_t isLastChunkWithSecurity);
+ uint8_t isLastChunkWithSecurity, const Cache* cache);
virtual void reset();
VersionedCacheableObjectPartListPtr getList() { return m_list; }
ACE_Recursive_Thread_Mutex& getResponseLock() { return m_responseLock; }
@@ -576,7 +576,7 @@ class ChunkedRemoveAllResponse : public TcrChunkedResult {
m_list(list) {}
virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen,
- uint8_t isLastChunkWithSecurity);
+ uint8_t isLastChunkWithSecurity, const Cache* cache);
virtual void reset();
VersionedCacheableObjectPartListPtr getList() { return m_list; }
ACE_Recursive_Thread_Mutex& getResponseLock() { return m_responseLock; }
@@ -609,7 +609,7 @@ class ChunkedKeySetResponse : public TcrChunkedResult {
m_resultKeys(resultKeys) {}
virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen,
- uint8_t isLastChunkWithSecurity);
+ uint8_t isLastChunkWithSecurity, const Cache* cache);
virtual void reset();
};
@@ -632,7 +632,7 @@ class ChunkedDurableCQListResponse : public TcrChunkedResult {
inline CacheableArrayListPtr getResults() { return m_resultList; }
virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen,
- uint8_t isLastChunkWithSecurity);
+ uint8_t isLastChunkWithSecurity, const Cache* cache);
virtual void reset();
};
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ThreadPool.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ThreadPool.cpp b/src/cppcache/src/ThreadPool.cpp
index e66a25a..1efd8f9 100644
--- a/src/cppcache/src/ThreadPool.cpp
+++ b/src/cppcache/src/ThreadPool.cpp
@@ -25,6 +25,7 @@
#include <geode/DistributedSystem.hpp>
#include <geode/SystemProperties.hpp>
#include "DistributedSystemImpl.hpp"
+#include "CacheImpl.hpp"
using namespace apache::geode::client;
ThreadPoolWorker::ThreadPoolWorker(IThreadPool* manager)
@@ -67,10 +68,11 @@ int ThreadPoolWorker::shutDown(void) {
ACE_thread_t ThreadPoolWorker::threadId(void) { return threadId_; }
-ThreadPool::ThreadPool()
- : shutdown_(0), workersLock_(), workersCond_(workersLock_) {
- SystemProperties* sysProp = DistributedSystem::getSystemProperties();
- poolSize_ = sysProp->threadPoolSize();
+ThreadPool::ThreadPool(uint32_t threadPoolSize)
+ : shutdown_(0),
+ workersLock_(),
+ workersCond_(workersLock_),
+ poolSize_(threadPoolSize) {
activate();
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ThreadPool.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ThreadPool.hpp b/src/cppcache/src/ThreadPool.hpp
index ce8257f..91812b2 100644
--- a/src/cppcache/src/ThreadPool.hpp
+++ b/src/cppcache/src/ThreadPool.hpp
@@ -32,9 +32,9 @@
#include <ace/Activation_Queue.h>
#include <ace/Condition_T.h>
#include <ace/Singleton.h>
-#include <ace/Recursive_Thread_Mutex.h>
#include <ace/Guard_T.h>
-
+#include <mutex>
+#include <condition_variable>
namespace apache {
namespace geode {
namespace client {
@@ -42,43 +42,35 @@ namespace client {
template <class T>
class PooledWork : public ACE_Method_Request {
private:
- // ACE_Future<T> result_;
T m_retVal;
- ACE_Recursive_Thread_Mutex m_mutex;
- ACE_Condition<ACE_Recursive_Thread_Mutex> m_cond;
+ std::recursive_mutex m_mutex;
+ std::condition_variable_any m_cond;
bool m_done;
public:
- PooledWork() : m_mutex(), m_cond(m_mutex), m_done(false) {}
+ PooledWork() : m_mutex(), m_cond(), m_done(false) {}
virtual ~PooledWork() {}
virtual int call(void) {
T res = execute();
- ACE_Guard<ACE_Recursive_Thread_Mutex> sync(m_mutex);
+ std::lock_guard<decltype(m_mutex)> lock(m_mutex);
m_retVal = res;
m_done = true;
- m_cond.broadcast();
- // result_.set(res);
- return 0;
- }
+ m_cond.notify_all();
- /*
- void attach(ACE_Future_Observer<T> *cb) {
- result_.attach(cb);
+ return 0;
}
- */
T getResult(void) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> sync(m_mutex);
+ std::unique_lock<decltype(m_mutex)> lock(m_mutex);
while (!m_done) {
- m_cond.wait();
+ m_cond.wait(lock, [this] { return m_done; });
}
- // T res;
- // result_.get(res);
+
return m_retVal;
}
@@ -131,15 +123,14 @@ class ThreadPool : public ACE_Task_Base, IThreadPool {
friend class ACE_Singleton<ThreadPool, ACE_Recursive_Thread_Mutex>;
public:
+ ThreadPool(uint32_t threadPoolSize);
+ virtual ~ThreadPool();
int perform(ACE_Method_Request* req);
int svc(void);
int shutDown(void);
virtual int returnToWork(ThreadPoolWorker* worker);
private:
- ThreadPool();
- virtual ~ThreadPool();
-
ThreadPoolWorker* chooseWorker(void);
int createWorkerPool(void);
int done(void);
@@ -154,8 +145,6 @@ class ThreadPool : public ACE_Task_Base, IThreadPool {
ACE_Activation_Queue queue_;
static const char* NC_Pool_Thread;
};
-
-typedef ACE_Singleton<ThreadPool, ACE_Recursive_Thread_Mutex> TPSingleton;
} // namespace client
} // namespace geode
} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/TombstoneExpiryHandler.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TombstoneExpiryHandler.cpp b/src/cppcache/src/TombstoneExpiryHandler.cpp
index c5f5512..399131e 100644
--- a/src/cppcache/src/TombstoneExpiryHandler.cpp
+++ b/src/cppcache/src/TombstoneExpiryHandler.cpp
@@ -31,10 +31,12 @@ using namespace apache::geode::client;
TombstoneExpiryHandler::TombstoneExpiryHandler(TombstoneEntryPtr entryPtr,
TombstoneList* tombstoneList,
- uint32_t duration)
+ uint32_t duration,
+ CacheImpl* cacheImpl)
: m_entryPtr(entryPtr),
m_duration(duration),
- m_tombstoneList(tombstoneList) {}
+ m_tombstoneList(tombstoneList),
+ m_cacheImpl(cacheImpl) {}
int TombstoneExpiryHandler::handle_timeout(const ACE_Time_Value& current_time,
const void* arg) {
@@ -59,7 +61,7 @@ int TombstoneExpiryHandler::handle_timeout(const ACE_Time_Value& current_time,
"Resetting expiry task %d secs later for key "
"[%s]",
-sec / 1000 + 1, Utils::getCacheableKeyString(key)->asChar());
- CacheImpl::expiryTaskManager->resetTask(
+ m_cacheImpl->getExpiryTaskManager().resetTask(
static_cast<long>(m_entryPtr->getExpiryTaskId()),
uint32_t(-sec / 1000 + 1));
return 0;
@@ -71,7 +73,8 @@ int TombstoneExpiryHandler::handle_timeout(const ACE_Time_Value& current_time,
Utils::getCacheableKeyString(key)->asChar());
// we now delete the handler in GF_Timer_Heap_ImmediateReset_T
// and always return success.
- CacheImpl::expiryTaskManager->resetTask(static_cast<long>(expiryTaskId), 0);
+ m_cacheImpl->getExpiryTaskManager().resetTask(static_cast<long>(expiryTaskId),
+ 0);
return 0;
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/TombstoneExpiryHandler.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TombstoneExpiryHandler.hpp b/src/cppcache/src/TombstoneExpiryHandler.hpp
index 233b4b5..e4ef730 100644
--- a/src/cppcache/src/TombstoneExpiryHandler.hpp
+++ b/src/cppcache/src/TombstoneExpiryHandler.hpp
@@ -43,10 +43,11 @@ namespace client {
class CPPCACHE_EXPORT TombstoneExpiryHandler : public ACE_Event_Handler {
public:
/**
-* Constructor
-*/
+ * Constructor
+ */
TombstoneExpiryHandler(TombstoneEntryPtr entryPtr,
- TombstoneList* tombstoneList, uint32_t duration);
+ TombstoneList* tombstoneList, uint32_t duration,
+ CacheImpl* cacheImpl);
/** This task object will be registered with the Timer Queue.
* When the timer expires the handle_timeout is invoked.
@@ -65,6 +66,7 @@ class CPPCACHE_EXPORT TombstoneExpiryHandler : public ACE_Event_Handler {
// Duration after which the task should be reset in case of
// modification.
uint32_t m_duration;
+ CacheImpl* m_cacheImpl;
// perform the actual expiration action
void DoTheExpirationAction(const CacheableKeyPtr& key);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/TombstoneList.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TombstoneList.cpp b/src/cppcache/src/TombstoneList.cpp
index 31ab22a..d32243a 100644
--- a/src/cppcache/src/TombstoneList.cpp
+++ b/src/cppcache/src/TombstoneList.cpp
@@ -39,46 +39,39 @@ long TombstoneList::getExpiryTask(TombstoneExpiryHandler** handler) {
// This function is not guarded as all functions of this class are called from
// MapSegment
// read TombstoneTImeout from systemProperties.
- uint32_t duration =
- DistributedSystem::getSystemProperties()->tombstoneTimeoutInMSec() / 1000;
+ uint32_t duration = m_cacheImpl->getDistributedSystem()
+ .getSystemProperties()
+ .tombstoneTimeoutInMSec() /
+ 1000;
ACE_Time_Value currTime(ACE_OS::gettimeofday());
auto tombstoneEntryPtr = std::make_shared<TombstoneEntry>(
nullptr, static_cast<int64_t>(currTime.get_msec()));
- *handler = new TombstoneExpiryHandler(tombstoneEntryPtr, this, duration);
+ *handler = new TombstoneExpiryHandler(tombstoneEntryPtr, this, duration,
+ m_cacheImpl);
tombstoneEntryPtr->setHandler(*handler);
- long id =
- CacheImpl::expiryTaskManager->scheduleExpiryTask(*handler, duration, 0);
+ long id = m_cacheImpl->getExpiryTaskManager().scheduleExpiryTask(*handler,
+ duration, 0);
return id;
}
-void TombstoneList::add(RegionInternal* rptr, const MapEntryImplPtr& entry,
+void TombstoneList::add(const MapEntryImplPtr& entry,
TombstoneExpiryHandler* handler, long taskid) {
// This function is not guarded as all functions of this class are called from
// MapSegment
// read TombstoneTImeout from systemProperties.
- // uint32_t duration =
- // DistributedSystem::getSystemProperties()->tombstoneTimeoutInMSec()/1000;
ACE_Time_Value currTime(ACE_OS::gettimeofday());
auto tombstoneEntryPtr = std::make_shared<TombstoneEntry>(
entry, static_cast<int64_t>(currTime.get_msec()));
- // TombstoneExpiryHandler* handler = new
- // TombstoneExpiryHandler(tombstoneEntryPtr, this, duration);
handler->setTombstoneEntry(tombstoneEntryPtr);
tombstoneEntryPtr->setHandler(handler);
- // long id = CacheImpl::expiryTaskManager->scheduleExpiryTask(
- // handler, duration, 0);
CacheableKeyPtr key;
entry->getKeyI(key);
- /*if (Log::finestEnabled()) {
- LOGFINEST("tombstone expiry for key [%s], task id = %d, "
- "duration = %d",
- Utils::getCacheableKeyString(key)->asChar(), id, duration);
- }*/
+
tombstoneEntryPtr->setExpiryTaskId(taskid);
m_tombstoneMap[key] = tombstoneEntryPtr;
- rptr->getCacheImpl()->m_cacheStats->incTombstoneCount();
+ m_cacheImpl->getCachePerfStats().incTombstoneCount();
int32_t tombstonesize = key->objectSize() + SIZEOF_TOMBSTONEOVERHEAD;
- rptr->getCacheImpl()->m_cacheStats->incTombstoneSize(tombstonesize);
+ m_cacheImpl->getCachePerfStats().incTombstoneSize(tombstonesize);
}
// Reaps the tombstones which have been gc'ed on server.
@@ -137,36 +130,34 @@ bool TombstoneList::exists(const CacheableKeyPtr& key) const {
}
void TombstoneList::eraseEntryFromTombstoneList(const CacheableKeyPtr& key,
- RegionInternal* region,
bool cancelTask) {
// This function is not guarded as all functions of this class are called from
// MapSegment
if (exists(key)) {
if (cancelTask) {
- CacheImpl::expiryTaskManager->cancelTask(
+ m_cacheImpl->getExpiryTaskManager().cancelTask(
static_cast<long>(m_tombstoneMap[key]->getExpiryTaskId()));
delete m_tombstoneMap[key]->getHandler();
}
- region->getCacheImpl()->m_cacheStats->decTombstoneCount();
+ m_cacheImpl->getCachePerfStats().decTombstoneCount();
int32_t tombstonesize = key->objectSize() + SIZEOF_TOMBSTONEOVERHEAD;
- region->getCacheImpl()->m_cacheStats->decTombstoneSize(tombstonesize);
+ m_cacheImpl->getCachePerfStats().decTombstoneSize(tombstonesize);
m_tombstoneMap.erase(key);
}
}
long TombstoneList::eraseEntryFromTombstoneListWithoutCancelTask(
- const CacheableKeyPtr& key, RegionInternal* region,
- TombstoneExpiryHandler*& handler) {
+ const CacheableKeyPtr& key, TombstoneExpiryHandler*& handler) {
// This function is not guarded as all functions of this class are called from
// MapSegment
long taskid = -1;
if (exists(key)) {
taskid = static_cast<long>(m_tombstoneMap[key]->getExpiryTaskId());
handler = m_tombstoneMap[key]->getHandler();
- region->getCacheImpl()->m_cacheStats->decTombstoneCount();
+ m_cacheImpl->getCachePerfStats().decTombstoneCount();
int32_t tombstonesize = key->objectSize() + SIZEOF_TOMBSTONEOVERHEAD;
- region->getCacheImpl()->m_cacheStats->decTombstoneSize(tombstonesize);
+ m_cacheImpl->getCachePerfStats().decTombstoneSize(tombstonesize);
m_tombstoneMap.erase(key);
}
return taskid;
@@ -175,8 +166,9 @@ long TombstoneList::eraseEntryFromTombstoneListWithoutCancelTask(
void TombstoneList::cleanUp() {
// This function is not guarded as all functions of this class are called from
// MapSegment
+ auto& expiryTaskManager = m_cacheImpl->getExpiryTaskManager();
for (const auto& queIter : m_tombstoneMap) {
- CacheImpl::expiryTaskManager->cancelTask(queIter.second->getExpiryTaskId());
+ expiryTaskManager.cancelTask(queIter.second->getExpiryTaskId());
delete queIter.second->getHandler();
}
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/TombstoneList.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TombstoneList.hpp b/src/cppcache/src/TombstoneList.hpp
index 66260c1..3178b29 100644
--- a/src/cppcache/src/TombstoneList.hpp
+++ b/src/cppcache/src/TombstoneList.hpp
@@ -72,10 +72,11 @@ typedef std::shared_ptr<TombstoneEntry> TombstoneEntryPtr;
class TombstoneList {
public:
- TombstoneList(MapSegment* mapSegment) { m_mapSegment = mapSegment; }
+ TombstoneList(MapSegment* mapSegment, CacheImpl* cacheImpl)
+ : m_mapSegment(mapSegment), m_cacheImpl(cacheImpl) {}
virtual ~TombstoneList() { cleanUp(); }
- void add(RegionInternal* rptr, const MapEntryImplPtr& entry,
- TombstoneExpiryHandler* handler, long taskID);
+ void add(const MapEntryImplPtr& entry, TombstoneExpiryHandler* handler,
+ long taskID);
// Reaps the tombstones which have been gc'ed on server.
// A map that has identifier for ClientProxyMembershipID as key
@@ -84,11 +85,9 @@ class TombstoneList {
void reapTombstones(std::map<uint16_t, int64_t>& gcVersions);
void reapTombstones(CacheableHashSetPtr removedKeys);
void eraseEntryFromTombstoneList(const CacheableKeyPtr& key,
- RegionInternal* region,
bool cancelTask = true);
long eraseEntryFromTombstoneListWithoutCancelTask(
- const CacheableKeyPtr& key, RegionInternal* region,
- TombstoneExpiryHandler*& handler);
+ const CacheableKeyPtr& key, TombstoneExpiryHandler*& handler);
void cleanUp();
long getExpiryTask(TombstoneExpiryHandler** handler);
bool exists(const CacheableKeyPtr& key) const;
@@ -103,6 +102,7 @@ class TombstoneList {
TombstoneMap m_tombstoneMap;
ACE_Recursive_Thread_Mutex m_queueLock;
MapSegment* m_mapSegment;
+ CacheImpl* m_cacheImpl;
friend class TombstoneExpiryHandler;
};
typedef std::shared_ptr<TombstoneList> TombstoneListPtr;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/TypeRegistry.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TypeRegistry.cpp b/src/cppcache/src/TypeRegistry.cpp
new file mode 100644
index 0000000..f9ee8cd
--- /dev/null
+++ b/src/cppcache/src/TypeRegistry.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.
+ */
+
+#include "geode/TypeRegistry.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
+
+/**
+ TypeRegistry is the public facing wrapper for the serialization registry.
+**/
+
+TypeRegistry::TypeRegistry(Cache &cache) : m_cache(cache) {}
+
+void TypeRegistry::registerType(TypeFactoryMethod creationFunction) {
+ CacheRegionHelper::getCacheImpl(&m_cache)
+ ->getSerializationRegistry()
+ ->addType(creationFunction);
+}
+
+void TypeRegistry::registerPdxType(TypeFactoryMethodPdx creationFunction) {
+ CacheRegionHelper::getCacheImpl(&m_cache)
+ ->getSerializationRegistry()
+ ->addPdxType(creationFunction);
+}
+
+void TypeRegistry::registerPdxSerializer(PdxSerializerPtr pdxSerializer) {
+ CacheRegionHelper::getCacheImpl(&m_cache)
+ ->getSerializationRegistry()
+ ->setPdxSerializer(pdxSerializer);
+}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/Utils.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/Utils.cpp b/src/cppcache/src/Utils.cpp
index bc0605d..b64e3db 100644
--- a/src/cppcache/src/Utils.cpp
+++ b/src/cppcache/src/Utils.cpp
@@ -214,6 +214,17 @@ int32_t Utils::logWideString(char* buf, size_t maxLen, const wchar_t* wStr) {
}
}
+int64_t Utils::startStatOpTime() {
+ return std::chrono::duration_cast<std::chrono::nanoseconds>(
+ std::chrono::steady_clock::now().time_since_epoch())
+ .count();
+}
+
+void Utils::updateStatOpTime(statistics::Statistics* m_regionStats, int32_t statId,
+ int64_t start) {
+ m_regionStats->incLong(statId, startStatOpTime() - start);
+}
+
} // namespace client
} // namespace geode
-} // namespace apache
+} // namespace apache
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/Utils.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/Utils.hpp b/src/cppcache/src/Utils.hpp
index 8dbe76d..3e62fb0 100644
--- a/src/cppcache/src/Utils.hpp
+++ b/src/cppcache/src/Utils.hpp
@@ -24,6 +24,11 @@
* @file
*/
+#include <typeinfo>
+#include <string>
+#include <unordered_set>
+#include <memory>
+
#include <geode/geode_globals.hpp>
#include <geode/geode_base.hpp>
#include <geode/ExceptionTypes.hpp>
@@ -141,18 +146,7 @@ class CPPCACHE_EXPORT Utils {
return CacheableString::create("(null)");
}
- inline static int64_t startStatOpTime() {
- if (DistributedSystem::getSystemProperties() != nullptr) {
- return (DistributedSystem::getSystemProperties()
- ->getEnableTimeStatistics())
- ? std::chrono::duration_cast<std::chrono::nanoseconds>(
- std::chrono::steady_clock::now().time_since_epoch())
- .count()
- : 0;
- } else {
- return 0;
- }
- }
+ static int64_t startStatOpTime();
// Check objectSize() implementation return value and log a warning at most
// once.
@@ -176,14 +170,8 @@ class CPPCACHE_EXPORT Utils {
return objectSize;
}
- inline static void updateStatOpTime(statistics::Statistics* m_regionStats,
- int32_t statId, int64_t start) {
- if (DistributedSystem::getSystemProperties() != nullptr) {
- if (DistributedSystem::getSystemProperties()->getEnableTimeStatistics()) {
- m_regionStats->incLong(statId, startStatOpTime() - start);
- }
- }
- }
+ static void updateStatOpTime(statistics::Statistics* m_regionStats,
+ int32_t statId, int64_t start);
static void parseEndpointNamesString(
const char* endpoints, std::unordered_set<std::string>& endpointNames);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/VersionStamp.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/VersionStamp.cpp b/src/cppcache/src/VersionStamp.cpp
index 6c7becc..8a95356 100644
--- a/src/cppcache/src/VersionStamp.cpp
+++ b/src/cppcache/src/VersionStamp.cpp
@@ -168,7 +168,7 @@ GfErrType VersionStamp::checkForConflict(const RegionInternal* region,
}
if (!apply) {
- region->getCacheImpl()->m_cacheStats->incConflatedEvents();
+ region->getCacheImpl()->getCachePerfStats().incConflatedEvents();
return GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION;
}
return GF_NOERR;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/VersionTag.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/VersionTag.cpp b/src/cppcache/src/VersionTag.cpp
index cfb133e..8d57e81 100644
--- a/src/cppcache/src/VersionTag.cpp
+++ b/src/cppcache/src/VersionTag.cpp
@@ -22,27 +22,21 @@
using namespace apache::geode::client;
-VersionTag::VersionTag() {
- m_bits = 0;
- m_entryVersion = 0;
- m_regionVersionHighBytes = 0;
- m_regionVersionLowBytes = 0;
- m_timeStamp = 0;
- m_internalMemId = 0;
- m_previousMemId = 0;
-}
+VersionTag::VersionTag(MemberListForVersionStamp& memberListForVersionStamp)
+ : VersionTag(0, 0, 0, 0, 0, memberListForVersionStamp) {}
VersionTag::VersionTag(int32_t entryVersion, int16_t regionVersionHighBytes,
int32_t regionVersionLowBytes, uint16_t internalMemId,
- uint16_t previousMemId) {
- m_bits = 0;
- m_entryVersion = entryVersion;
- m_regionVersionHighBytes = regionVersionHighBytes;
- m_regionVersionLowBytes = regionVersionLowBytes;
- m_timeStamp = 0;
- m_internalMemId = internalMemId;
- m_previousMemId = previousMemId;
-}
+ uint16_t previousMemId,
+ MemberListForVersionStamp& memberListForVersionStamp)
+ : m_bits(0),
+ m_entryVersion(entryVersion),
+ m_regionVersionHighBytes(regionVersionHighBytes),
+ m_regionVersionLowBytes(regionVersionLowBytes),
+ m_timeStamp(0),
+ m_internalMemId(internalMemId),
+ m_previousMemId(previousMemId),
+ m_memberListForVersionStamp(memberListForVersionStamp) {}
VersionTag::~VersionTag() {}
@@ -80,7 +74,11 @@ Serializable* VersionTag::fromData(DataInput& input) {
return this;
}
-Serializable* VersionTag::createDeserializable() { return new VersionTag(); }
+Serializable* VersionTag::createDeserializable(
+ MemberListForVersionStamp& memberListForVersionStamp) {
+ return new VersionTag(memberListForVersionStamp);
+}
+
void VersionTag::replaceNullMemberId(uint16_t memId) {
if (m_previousMemId == 0) {
m_previousMemId = memId;
@@ -90,24 +88,19 @@ void VersionTag::replaceNullMemberId(uint16_t memId) {
}
}
void VersionTag::readMembers(uint16_t flags, DataInput& input) {
- ClientProxyMembershipIDPtr previousMemId, internalMemId;
- MemberListForVersionStampPtr memberList =
- CacheImpl::getMemberListForVersionStamp();
if ((flags & HAS_MEMBER_ID) != 0) {
- internalMemId = ClientProxyMembershipIDPtr(new ClientProxyMembershipID());
-
+ auto internalMemId = std::make_shared<ClientProxyMembershipID>();
internalMemId->readEssentialData(input);
- m_internalMemId =
- memberList->add((DSMemberForVersionStampPtr)internalMemId);
+ m_internalMemId = m_memberListForVersionStamp.add(
+ (DSMemberForVersionStampPtr)internalMemId);
}
if ((flags & HAS_PREVIOUS_MEMBER_ID) != 0) {
if ((flags & DUPLICATE_MEMBER_IDS) != 0) {
m_previousMemId = m_internalMemId;
} else {
- previousMemId = ClientProxyMembershipIDPtr(new ClientProxyMembershipID());
+ auto previousMemId = std::make_shared<ClientProxyMembershipID>();
previousMemId->readEssentialData(input);
- m_previousMemId =
- memberList->add((DSMemberForVersionStampPtr)previousMemId);
+ m_previousMemId = m_memberListForVersionStamp.add(previousMemId);
}
}
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/VersionTag.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/VersionTag.hpp b/src/cppcache/src/VersionTag.hpp
index d645784..0489009 100644
--- a/src/cppcache/src/VersionTag.hpp
+++ b/src/cppcache/src/VersionTag.hpp
@@ -40,6 +40,7 @@ class VersionTag : public Cacheable {
uint16_t m_internalMemId;
uint16_t m_previousMemId;
int64_t m_timeStamp;
+ MemberListForVersionStamp& m_memberListForVersionStamp;
static const uint8_t HAS_MEMBER_ID = 0x01;
static const uint8_t HAS_PREVIOUS_MEMBER_ID = 0x02;
@@ -53,7 +54,7 @@ class VersionTag : public Cacheable {
virtual void readMembers(uint16_t flags, DataInput& input);
public:
- VersionTag();
+ VersionTag(MemberListForVersionStamp& memberListForVersionStamp);
virtual ~VersionTag();
@@ -65,7 +66,8 @@ class VersionTag : public Cacheable {
virtual Serializable* fromData(DataInput& input);
- static Serializable* createDeserializable();
+ static Serializable* createDeserializable(
+ MemberListForVersionStamp& memberListForVersionStamp);
int32_t getEntryVersion() const { return m_entryVersion; }
int16_t getRegionVersionHighBytes() const { return m_regionVersionHighBytes; }
@@ -83,7 +85,8 @@ class VersionTag : public Cacheable {
*/
VersionTag(int32_t entryVersion, int16_t regionVersionHighBytes,
int32_t regionVersionLowBytes, uint16_t internalMemId,
- uint16_t previousMemId);
+ uint16_t previousMemId,
+ MemberListForVersionStamp& memberListForVersionStamp);
};
} // namespace client
} // namespace geode
[12/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/LocalRegion.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/LocalRegion.cpp b/src/cppcache/src/LocalRegion.cpp
index 2e465cb..1f31cad 100644
--- a/src/cppcache/src/LocalRegion.cpp
+++ b/src/cppcache/src/LocalRegion.cpp
@@ -14,15 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <vector>
#include "LocalRegion.hpp"
#include <geode/Log.hpp>
#include <geode/SystemProperties.hpp>
+#include <geode/PoolManager.hpp>
+
#include "CacheImpl.hpp"
#include "CacheRegionHelper.hpp"
#include "CacheableToken.hpp"
#include "Utils.hpp"
-
#include "EntryExpiryHandler.hpp"
#include "RegionExpiryHandler.hpp"
#include "ExpiryTaskManager.hpp"
@@ -30,8 +32,7 @@
#include "RegionGlobalLocks.hpp"
#include "TXState.hpp"
#include "VersionTag.hpp"
-#include <vector>
-#include <geode/PoolManager.hpp>
+#include "statistics/StatisticsManager.hpp"
namespace apache {
namespace geode {
@@ -40,8 +41,9 @@ namespace client {
LocalRegion::LocalRegion(const std::string& name, CacheImpl* cache,
const RegionInternalPtr& rPtr,
const RegionAttributesPtr& attributes,
- const CacheStatisticsPtr& stats, bool shared)
- : RegionInternal(attributes),
+ const CacheStatisticsPtr& stats, bool shared,
+ bool enableTimeStatistics)
+ : RegionInternal(cache->getCache()->shared_from_this(), attributes),
m_name(name),
m_parentRegion(rPtr),
m_cacheImpl(cache),
@@ -55,7 +57,8 @@ LocalRegion::LocalRegion(const std::string& name, CacheImpl* cache,
m_transactionEnabled(false),
m_isPRSingleHopEnabled(false),
m_attachedPool(nullptr),
- m_persistenceManager(nullptr) {
+ m_persistenceManager(nullptr),
+ m_enableTimeStatistics(enableTimeStatistics) {
if (m_parentRegion != nullptr) {
((m_fullPath = m_parentRegion->getFullPath()) += "/") += m_name;
} else {
@@ -83,8 +86,12 @@ LocalRegion::LocalRegion(const std::string& name, CacheImpl* cache,
(m_fullPath = "/") += m_name;
}
- m_regionStats = new RegionStats(m_fullPath.c_str());
- PoolPtr p = PoolManager::find(getAttributes()->getPoolName());
+ m_regionStats = new RegionStats(cache->getDistributedSystem()
+ .getStatisticsManager()
+ ->getStatisticsFactory(),
+ m_fullPath);
+ PoolPtr p =
+ cache->getCache()->getPoolManager().find(getAttributes()->getPoolName());
// m_attachedPool = p;
setPool(p);
}
@@ -121,11 +128,8 @@ void LocalRegion::updateAccessAndModifiedTime(bool modified) {
CacheStatisticsPtr LocalRegion::getStatistics() const {
CHECK_DESTROY_PENDING(TryReadGuard, LocalRegion::getStatistics);
bool m_statisticsEnabled = true;
- SystemProperties* props =
- m_cacheImpl->getCache()->getDistributedSystem()->getSystemProperties();
- if (props) {
- m_statisticsEnabled = props->statisticsEnabled();
- }
+ auto& props = m_cacheImpl->getDistributedSystem().getSystemProperties();
+ m_statisticsEnabled = props.statisticsEnabled();
if (!m_statisticsEnabled) {
throw StatisticsDisabledException(
"LocalRegion::getStatistics statistics disabled for this region");
@@ -307,11 +311,10 @@ void LocalRegion::getEntry(const CacheableKeyPtr& key, CacheablePtr& valuePtr) {
CacheablePtr LocalRegion::get(const CacheableKeyPtr& key,
const UserDataPtr& aCallbackArgument) {
CacheablePtr rptr;
- int64_t sampleStartNanos = Utils::startStatOpTime();
+ int64_t sampleStartNanos = startStatOpTime();
GfErrType err = getNoThrow(key, rptr, aCallbackArgument);
- Utils::updateStatOpTime(m_regionStats->getStat(),
- RegionStatType::getInstance()->getGetTimeId(),
- sampleStartNanos);
+ updateStatOpTime(m_regionStats->getStat(), m_regionStats->getGetTimeId(),
+ sampleStartNanos);
// rptr = handleReplay(err, rptr);
@@ -323,13 +326,12 @@ CacheablePtr LocalRegion::get(const CacheableKeyPtr& key,
void LocalRegion::put(const CacheableKeyPtr& key, const CacheablePtr& value,
const UserDataPtr& aCallbackArgument) {
CacheablePtr oldValue;
- int64_t sampleStartNanos = Utils::startStatOpTime();
+ int64_t sampleStartNanos = startStatOpTime();
VersionTagPtr versionTag;
GfErrType err = putNoThrow(key, value, aCallbackArgument, oldValue, -1,
CacheEventFlags::NORMAL, versionTag);
- Utils::updateStatOpTime(m_regionStats->getStat(),
- RegionStatType::getInstance()->getPutTimeId(),
- sampleStartNanos);
+ updateStatOpTime(m_regionStats->getStat(), m_regionStats->getPutTimeId(),
+ sampleStartNanos);
// handleReplay(err, nullptr);
GfErrTypeToException("Region::put", err);
}
@@ -351,11 +353,10 @@ void LocalRegion::putAll(const HashMapOfCacheable& map, uint32_t timeout,
"Region::putAll: timeout parameter "
"greater than maximum allowed (2^31/1000 i.e 2147483).");
}
- int64_t sampleStartNanos = Utils::startStatOpTime();
+ int64_t sampleStartNanos = startStatOpTime();
GfErrType err = putAllNoThrow(map, timeout, aCallbackArgument);
- Utils::updateStatOpTime(m_regionStats->getStat(),
- RegionStatType::getInstance()->getPutAllTimeId(),
- sampleStartNanos);
+ updateStatOpTime(m_regionStats->getStat(), m_regionStats->getPutAllTimeId(),
+ sampleStartNanos);
// handleReplay(err, nullptr);
GfErrTypeToException("Region::putAll", err);
}
@@ -365,11 +366,10 @@ void LocalRegion::removeAll(const VectorOfCacheableKey& keys,
if (keys.size() == 0) {
throw IllegalArgumentException("Region::removeAll: zero keys provided");
}
- int64_t sampleStartNanos = Utils::startStatOpTime();
+ int64_t sampleStartNanos = startStatOpTime();
GfErrType err = removeAllNoThrow(keys, aCallbackArgument);
- Utils::updateStatOpTime(m_regionStats->getStat(),
- RegionStatType::getInstance()->getRemoveAllTimeId(),
- sampleStartNanos);
+ updateStatOpTime(m_regionStats->getStat(),
+ m_regionStats->getRemoveAllTimeId(), sampleStartNanos);
GfErrTypeToException("Region::removeAll", err);
}
@@ -537,17 +537,17 @@ void LocalRegion::getAll(const VectorOfCacheableKey& keys,
!(addToLocalCache && m_regionAttributes->getCachingEnabled())) {
throw IllegalArgumentException(
"Region::getAll: either output \"values\""
- " parameter should be non-null, or \"addToLocalCache\" should be true "
+ " parameter should be non-null, or \"addToLocalCache\" should be "
+ "true "
"and caching should be enabled for the region [%s]",
getFullPath());
}
- int64_t sampleStartNanos = Utils::startStatOpTime();
+ int64_t sampleStartNanos = startStatOpTime();
GfErrType err = getAllNoThrow(keys, values, exceptions, addToLocalCache,
aCallbackArgument);
- Utils::updateStatOpTime(m_regionStats->getStat(),
- RegionStatType::getInstance()->getGetAllTimeId(),
- sampleStartNanos);
+ updateStatOpTime(m_regionStats->getStat(), m_regionStats->getGetAllTimeId(),
+ sampleStartNanos);
// handleReplay(err, nullptr);
GfErrTypeToException("Region::getAll", err);
}
@@ -650,8 +650,9 @@ void LocalRegion::setRegionExpiryTask() {
uint32_t duration = getRegionExpiryDuration();
RegionExpiryHandler* handler =
new RegionExpiryHandler(rptr, getRegionExpiryAction(), duration);
- int64_t expiryTaskId =
- CacheImpl::expiryTaskManager->scheduleExpiryTask(handler, duration, 0);
+ long expiryTaskId =
+ rptr->getCacheImpl()->getExpiryTaskManager().scheduleExpiryTask(
+ handler, duration, 0);
handler->setExpiryTaskId(expiryTaskId);
LOGFINE(
"expiry for region [%s], expiry task id = %d, duration = %d, "
@@ -670,8 +671,8 @@ void LocalRegion::registerEntryExpiryTask(MapEntryImplPtr& entry) {
uint32_t duration = getEntryExpiryDuration();
EntryExpiryHandler* handler =
new EntryExpiryHandler(rptr, entry, getEntryExpirationAction(), duration);
- int64_t id =
- CacheImpl::expiryTaskManager->scheduleExpiryTask(handler, duration, 0);
+ long id = rptr->getCacheImpl()->getExpiryTaskManager().scheduleExpiryTask(
+ handler, duration, 0);
if (Log::finestEnabled()) {
CacheableKeyPtr key;
entry->getKeyI(key);
@@ -740,7 +741,8 @@ void LocalRegion::release(bool invokeCallbacks) {
/** Returns whether the specified key currently exists in this region.
* This method is equivalent to <code>getEntry(key) != null</code>.
*
- * @param keyPtr the key to check for an existing entry, type is CacheableString
+ * @param keyPtr the key to check for an existing entry, type is
+ *CacheableString
*&
* @return true if there is an entry in this region for the specified key
*@throw RegionDestroyedException, if region is destroyed.
@@ -788,6 +790,7 @@ GfErrType LocalRegion::getNoThrow(const CacheableKeyPtr& keyPtr,
const UserDataPtr& aCallbackArgument) {
CHECK_DESTROY_PENDING_NOTHROW(TryReadGuard);
GfErrType err = GF_NOERR;
+
if (keyPtr == nullptr) {
return GF_CACHE_ILLEGAL_ARGUMENT_EXCEPTION;
}
@@ -809,7 +812,8 @@ GfErrType LocalRegion::getNoThrow(const CacheableKeyPtr& keyPtr,
}
m_regionStats->incGets();
- m_cacheImpl->m_cacheStats->incGets();
+ auto& cachePerfStats = m_cacheImpl->getCachePerfStats();
+ cachePerfStats.incGets();
// TODO: CacheableToken::isInvalid should be completely hidden
// inside MapSegment; this should be done both for the value obtained
@@ -824,7 +828,7 @@ GfErrType LocalRegion::getNoThrow(const CacheableKeyPtr& keyPtr,
isLocal = m_entries->get(keyPtr, value, me);
if (isLocal && (value != nullptr && !CacheableToken::isInvalid(value))) {
m_regionStats->incHits();
- m_cacheImpl->m_cacheStats->incHits();
+ cachePerfStats.incHits();
updateAccessAndModifiedTimeForEntry(me, false);
updateAccessAndModifiedTime(false);
return err; // found it in local cache...
@@ -867,7 +871,8 @@ GfErrType LocalRegion::getNoThrow(const CacheableKeyPtr& keyPtr,
// access times.
updateAccessAndModifiedTime(false);
m_regionStats->incMisses();
- m_cacheImpl->m_cacheStats->incMisses();
+
+ cachePerfStats.incMisses();
VersionTagPtr versionTag;
// Get from some remote source (e.g. external java server) if required.
err = getNoThrow_remote(keyPtr, value, aCallbackArgument, versionTag);
@@ -880,12 +885,10 @@ GfErrType LocalRegion::getNoThrow(const CacheableKeyPtr& keyPtr,
try {
isLoaderInvoked = true;
/*Update the statistics*/
- int64_t sampleStartNanos = Utils::startStatOpTime();
+ int64_t sampleStartNanos = startStatOpTime();
value = m_loader->load(shared_from_this(), keyPtr, aCallbackArgument);
- Utils::updateStatOpTime(
- m_regionStats->getStat(),
- RegionStatType::getInstance()->getLoaderCallTimeId(),
- sampleStartNanos);
+ updateStatOpTime(m_regionStats->getStat(),
+ m_regionStats->getLoaderCallTimeId(), sampleStartNanos);
m_regionStats->incLoaderCallsCompleted();
} catch (const Exception& ex) {
LOGERROR("Error in CacheLoader::load: %s: %s", ex.getName(),
@@ -909,7 +912,8 @@ GfErrType LocalRegion::getNoThrow(const CacheableKeyPtr& keyPtr,
// try to create the entry and if that returns an existing value
// (e.g. from another thread or notification) then return that
LOGDEBUG(
- "Region::get: creating entry with tracking update counter [%d] for key "
+ "Region::get: creating entry with tracking update counter [%d] for "
+ "key "
"[%s]",
updateCount, Utils::getCacheableKeyString(keyPtr)->asChar());
if ((err = putLocal("Region::get", false, keyPtr, value, oldValue,
@@ -975,13 +979,15 @@ GfErrType LocalRegion::getAllNoThrow(const VectorOfCacheableKey& keys,
}
// if(!txState->isReplay())
// {
- // auto args = std::make_shared<VectorOfCacheable>();
+ // auto args =
+ // std::make_shared<VectorOfCacheable>();
// args->push_back(VectorOfCacheableKeyPtr(new
// VectorOfCacheableKey(keys)));
// args->push_back(values);
// args->push_back(exceptions);
// args->push_back(CacheableBoolean::create(addToLocalCache));
- // txState->recordTXOperation(GF_GET_ALL, getFullPath(),
+ // txState->recordTXOperation(GF_GET_ALL,
+ // getFullPath(),
// nullptr,
// args);
// }
@@ -998,18 +1004,19 @@ GfErrType LocalRegion::getAllNoThrow(const VectorOfCacheableKey& keys,
VectorOfCacheableKey serverKeys;
bool cachingEnabled = m_regionAttributes->getCachingEnabled();
bool regionAccessed = false;
+ auto& cachePerfStats = m_cacheImpl->getCachePerfStats();
for (int32_t index = 0; index < keys.size(); ++index) {
const CacheableKeyPtr& key = keys[index];
MapEntryImplPtr me;
value = nullptr;
m_regionStats->incGets();
- m_cacheImpl->m_cacheStats->incGets();
+ cachePerfStats.incGets();
if (values && cachingEnabled) {
if (m_entries->get(key, value, me) && value &&
!CacheableToken::isInvalid(value)) {
m_regionStats->incHits();
- m_cacheImpl->m_cacheStats->incHits();
+ cachePerfStats.incHits();
updateAccessAndModifiedTimeForEntry(me, false);
regionAccessed = true;
values->emplace(key, value);
@@ -1022,7 +1029,7 @@ GfErrType LocalRegion::getAllNoThrow(const VectorOfCacheableKey& keys,
serverKeys.push_back(key);
m_regionStats->incMisses();
- m_cacheImpl->m_cacheStats->incMisses();
+ cachePerfStats.incMisses();
}
// TODO: No support for loaders in getAll for now.
}
@@ -1259,6 +1266,8 @@ class DestroyActions {
DataInput* delta = nullptr,
EventIdPtr eventId = nullptr,
bool afterRemote = false) {
+ auto& cachePerfStats = m_region.m_cacheImpl->getCachePerfStats();
+
if (cachingEnabled) {
MapEntryImplPtr entry;
// for notification invoke the listener even if the key does
@@ -1281,6 +1290,7 @@ class DestroyActions {
}
return err;
}
+
if (oldValue != nullptr) {
LOGDEBUG(
"Region::destroy: region [%s] destroyed key [%s] having "
@@ -1297,12 +1307,12 @@ class DestroyActions {
}
// update the stats
m_region.m_regionStats->setEntries(m_region.m_entries->size());
- m_region.m_cacheImpl->m_cacheStats->incEntries(-1);
+ cachePerfStats.incEntries(-1);
}
}
// update the stats
m_region.m_regionStats->incDestroys();
- m_region.m_cacheImpl->m_cacheStats->incDestroys();
+ cachePerfStats.incDestroys();
return GF_NOERR;
}
@@ -1361,8 +1371,10 @@ class RemoveActions {
GfErrType err = GF_NOERR;
if (!allowNULLValue && m_region.getAttributes()->getCachingEnabled()) {
m_region.getEntry(key, valuePtr);
- DataOutput out1;
- DataOutput out2;
+ std::unique_ptr<DataOutput> out1 =
+ m_region.getCacheImpl()->getCache()->createDataOutput();
+ std::unique_ptr<DataOutput> out2 =
+ m_region.getCacheImpl()->getCache()->createDataOutput();
if (valuePtr != nullptr && value != nullptr) {
if (valuePtr->classId() != value->classId() ||
@@ -1370,14 +1382,14 @@ class RemoveActions {
err = GF_ENOENT;
return err;
}
- valuePtr->toData(out1);
- value->toData(out2);
- if (out1.getBufferLength() != out2.getBufferLength()) {
+ valuePtr->toData(*out1);
+ value->toData(*out2);
+ if (out1->getBufferLength() != out2->getBufferLength()) {
err = GF_ENOENT;
return err;
}
- if (memcmp(out1.getBuffer(), out2.getBuffer(),
- out1.getBufferLength()) != 0) {
+ if (memcmp(out1->getBuffer(), out2->getBuffer(),
+ out1->getBufferLength()) != 0) {
err = GF_ENOENT;
return err;
}
@@ -1432,22 +1444,24 @@ class RemoveActions {
GfErrType err = GF_NOERR;
if (!allowNULLValue && cachingEnabled) {
m_region.getEntry(key, valuePtr);
- DataOutput out1;
- DataOutput out2;
+ std::unique_ptr<DataOutput> out1 =
+ m_region.getCacheImpl()->getCache()->createDataOutput();
+ std::unique_ptr<DataOutput> out2 =
+ m_region.getCacheImpl()->getCache()->createDataOutput();
if (valuePtr != nullptr && value != nullptr) {
if (valuePtr->classId() != value->classId() ||
valuePtr->typeId() != value->typeId()) {
err = GF_ENOENT;
return err;
}
- valuePtr->toData(out1);
- value->toData(out2);
- if (out1.getBufferLength() != out2.getBufferLength()) {
+ valuePtr->toData(*out1);
+ value->toData(*out2);
+ if (out1->getBufferLength() != out2->getBufferLength()) {
err = GF_ENOENT;
return err;
}
- if (memcmp(out1.getBuffer(), out2.getBuffer(),
- out1.getBufferLength()) != 0) {
+ if (memcmp(out1->getBuffer(), out2->getBuffer(),
+ out1->getBufferLength()) != 0) {
err = GF_ENOENT;
return err;
}
@@ -1458,9 +1472,9 @@ class RemoveActions {
if (updateCount >= 0 &&
!m_region.getAttributes()
->getConcurrencyChecksEnabled()) { // This means server has
- // deleted an entry & same
- // entry has been destroyed
- // locally
+ // deleted an entry &
+ // same entry has been
+ // destroyed locally
// So call removeTrackerForEntry to remove key that was added in the
// map during addTrackerForEntry call.
m_region.m_entries->removeTrackerForEntry(key);
@@ -1472,6 +1486,7 @@ class RemoveActions {
return err;
}
}
+ auto& cachePerfStats = m_region.m_cacheImpl->getCachePerfStats();
if (cachingEnabled) {
MapEntryImplPtr entry;
@@ -1511,12 +1526,12 @@ class RemoveActions {
}
// update the stats
m_region.m_regionStats->setEntries(m_region.m_entries->size());
- m_region.m_cacheImpl->m_cacheStats->incEntries(-1);
+ cachePerfStats.incEntries(-1);
}
}
// update the stats
m_region.m_regionStats->incDestroys();
- m_region.m_cacheImpl->m_cacheStats->incDestroys();
+ cachePerfStats.incDestroys();
return GF_NOERR;
}
@@ -1704,10 +1719,11 @@ GfErrType LocalRegion::updateNoThrow(const CacheableKeyPtr& key,
return GF_NOERR;
} else if (err == GF_INVALID_DELTA) {
LOGDEBUG(
- "Region::localUpdate: updateNoThrow<%s> for key [%s] failed because "
+ "Region::localUpdate: updateNoThrow<%s> for key [%s] failed "
+ "because "
"of invalid delta.",
TAction::name(), Utils::getCacheableKeyString(key)->asChar());
- m_cacheImpl->m_cacheStats->incFailureOnDeltaReceived();
+ m_cacheImpl->getCachePerfStats().incFailureOnDeltaReceived();
// Get full object from server.
CacheablePtr& newValue1 = const_cast<CacheablePtr&>(value);
VersionTagPtr versionTag1;
@@ -1963,9 +1979,10 @@ GfErrType LocalRegion::putAllNoThrow(const HashMapOfCacheable& map,
std::make_pair(key, std::make_pair(oldValue, updateCount)));
}
if (m_writer != nullptr) {
- // invokeCacheWriterForEntryEvent method has the check that if oldValue
- // is a CacheableToken then it sets it to nullptr; also determines if it
- // should be BEFORE_UPDATE or BEFORE_CREATE depending on oldValue
+ // invokeCacheWriterForEntryEvent method has the check that if
+ // oldValue is a CacheableToken then it sets it to nullptr; also
+ // determines if it should be BEFORE_UPDATE or BEFORE_CREATE depending
+ // on oldValue
if (!invokeCacheWriterForEntryEvent(
key, oldValue, iter.second, aCallbackArgument,
CacheEventFlags::LOCAL, BEFORE_UPDATE)) {
@@ -2002,7 +2019,8 @@ GfErrType LocalRegion::putAllNoThrow(const HashMapOfCacheable& map,
} else {
// ThrowERROR
LOGERROR(
- "ERROR :: LocalRegion::putAllNoThrow() Key must be found in the "
+ "ERROR :: LocalRegion::putAllNoThrow() Key must be found in "
+ "the "
"usermap");
}
@@ -2022,7 +2040,8 @@ GfErrType LocalRegion::putAllNoThrow(const HashMapOfCacheable& map,
versionTag)) == GF_CACHE_ENTRY_UPDATED) {
LOGFINEST(
"Region::putAll: did not change local value for key [%s] "
- "since it has been updated by another thread while operation was "
+ "since it has been updated by another thread while operation "
+ "was "
"in progress",
Utils::getCacheableKeyString(key)->asChar());
} else if (localErr == GF_CACHE_LISTENER_EXCEPTION) {
@@ -2058,7 +2077,8 @@ GfErrType LocalRegion::putAllNoThrow(const HashMapOfCacheable& map,
versionTag)) == GF_CACHE_ENTRY_UPDATED) {
LOGFINEST(
"Region::putAll: did not change local value for key [%s] "
- "since it has been updated by another thread while operation was "
+ "since it has been updated by another thread while operation "
+ "was "
"in progress",
Utils::getCacheableKeyString(key)->asChar());
} else if (localErr == GF_CACHE_LISTENER_EXCEPTION) {
@@ -2161,11 +2181,10 @@ GfErrType LocalRegion::removeAllNoThrow(const VectorOfCacheableKey& keys,
void LocalRegion::clear(const UserDataPtr& aCallbackArgument) {
/*update the stats */
- int64_t sampleStartNanos = Utils::startStatOpTime();
+ int64_t sampleStartNanos = startStatOpTime();
localClear(aCallbackArgument);
- Utils::updateStatOpTime(m_regionStats->getStat(),
- RegionStatType::getInstance()->getClearsId(),
- sampleStartNanos);
+ updateStatOpTime(m_regionStats->getStat(), m_regionStats->getClearsId(),
+ sampleStartNanos);
}
void LocalRegion::localClear(const UserDataPtr& aCallbackArgument) {
GfErrType err = localClearNoThrow(aCallbackArgument, CacheEventFlags::LOCAL);
@@ -2326,7 +2345,8 @@ GfErrType LocalRegion::destroyRegionNoThrow(
if (eventFlags == CacheEventFlags::LOCAL) {
if (unregisterKeysBeforeDestroyRegion() != GF_NOERR) {
LOGDEBUG(
- "DEBUG :: LocalRegion::destroyRegionNoThrow UnregisteredKeys Failed");
+ "DEBUG :: LocalRegion::destroyRegionNoThrow UnregisteredKeys "
+ "Failed");
}
}
@@ -2436,6 +2456,8 @@ GfErrType LocalRegion::putLocal(const char* name, bool isCreate,
EventIdPtr eventId) {
GfErrType err = GF_NOERR;
bool isUpdate = !isCreate;
+ auto& cachePerfStats = m_cacheImpl->getCachePerfStats();
+
if (cachingEnabled) {
MapEntryImplPtr entry;
LOGDEBUG("%s: region [%s] putting key [%s], value [%s]", name,
@@ -2448,7 +2470,7 @@ GfErrType LocalRegion::putLocal(const char* name, bool isCreate,
err = m_entries->put(key, value, entry, oldValue, updateCount,
destroyTracker, versionTag, isUpdate, delta);
if (err == GF_INVALID_DELTA) {
- m_cacheImpl->m_cacheStats->incFailureOnDeltaReceived();
+ cachePerfStats.incFailureOnDeltaReceived();
// PXR: Get full object from server.
CacheablePtr& newValue1 = const_cast<CacheablePtr&>(value);
VersionTagPtr versionTag1;
@@ -2461,7 +2483,7 @@ GfErrType LocalRegion::putLocal(const char* name, bool isCreate,
}
if (delta != nullptr &&
err == GF_NOERR) { // Means that delta is on and there is no failure.
- m_cacheImpl->m_cacheStats->incDeltaReceived();
+ cachePerfStats.incDeltaReceived();
}
}
if (err != GF_NOERR) {
@@ -2484,14 +2506,14 @@ GfErrType LocalRegion::putLocal(const char* name, bool isCreate,
// update the stats
if (isUpdate) {
m_regionStats->incPuts();
- m_cacheImpl->m_cacheStats->incPuts();
+ cachePerfStats.incPuts();
} else {
if (cachingEnabled) {
m_regionStats->setEntries(m_entries->size());
- m_cacheImpl->m_cacheStats->incEntries(1);
+ cachePerfStats.incEntries(1);
}
m_regionStats->incCreates();
- m_cacheImpl->m_cacheStats->incCreates();
+ cachePerfStats.incCreates();
}
return err;
}
@@ -2545,7 +2567,7 @@ bool LocalRegion::invokeCacheWriterForEntryEvent(
try {
bool updateStats = true;
/*Update the CacheWriter Stats*/
- int64_t sampleStartNanos = Utils::startStatOpTime();
+ int64_t sampleStartNanos = startStatOpTime();
switch (type) {
case BEFORE_UPDATE: {
if (oldValue != nullptr) {
@@ -2572,10 +2594,9 @@ bool LocalRegion::invokeCacheWriterForEntryEvent(
}
if (updateStats) {
- Utils::updateStatOpTime(
- m_regionStats->getStat(),
- RegionStatType::getInstance()->getWriterCallTimeId(),
- sampleStartNanos);
+ updateStatOpTime(m_regionStats->getStat(),
+ m_regionStats->getWriterCallTimeId(),
+ sampleStartNanos);
m_regionStats->incWriterCallsCompleted();
}
@@ -2603,7 +2624,7 @@ bool LocalRegion::invokeCacheWriterForRegionEvent(
try {
bool updateStats = true;
/*Update the CacheWriter Stats*/
- int64_t sampleStartNanos = Utils::startStatOpTime();
+ int64_t sampleStartNanos = startStatOpTime();
switch (type) {
case BEFORE_REGION_DESTROY: {
eventStr = "beforeRegionDestroy";
@@ -2621,10 +2642,9 @@ bool LocalRegion::invokeCacheWriterForRegionEvent(
}
}
if (updateStats) {
- Utils::updateStatOpTime(
- m_regionStats->getStat(),
- RegionStatType::getInstance()->getWriterCallTimeId(),
- sampleStartNanos);
+ updateStatOpTime(m_regionStats->getStat(),
+ m_regionStats->getWriterCallTimeId(),
+ sampleStartNanos);
m_regionStats->incWriterCallsCompleted();
}
} catch (const Exception& ex) {
@@ -2656,7 +2676,7 @@ GfErrType LocalRegion::invokeCacheListenerForEntryEvent(
try {
bool updateStats = true;
/*Update the CacheWriter Stats*/
- int64_t sampleStartNanos = Utils::startStatOpTime();
+ int64_t sampleStartNanos = startStatOpTime();
switch (type) {
case AFTER_UPDATE: {
// when CREATE is received from server for notification
@@ -2690,11 +2710,10 @@ GfErrType LocalRegion::invokeCacheListenerForEntryEvent(
}
}
if (updateStats) {
- m_cacheImpl->m_cacheStats->incListenerCalls();
- Utils::updateStatOpTime(
- m_regionStats->getStat(),
- RegionStatType::getInstance()->getListenerCallTimeId(),
- sampleStartNanos);
+ m_cacheImpl->getCachePerfStats().incListenerCalls();
+ updateStatOpTime(m_regionStats->getStat(),
+ m_regionStats->getListenerCallTimeId(),
+ sampleStartNanos);
m_regionStats->incListenerCallsCompleted();
}
} catch (const Exception& ex) {
@@ -2729,18 +2748,18 @@ GfErrType LocalRegion::invokeCacheListenerForRegionEvent(
case AFTER_REGION_DESTROY: {
eventStr = "afterRegionDestroy";
m_listener->afterRegionDestroy(event);
- m_cacheImpl->m_cacheStats->incListenerCalls();
+ m_cacheImpl->getCachePerfStats().incListenerCalls();
if (eventFlags.isCacheClose()) {
eventStr = "close";
m_listener->close(shared_from_this());
- m_cacheImpl->m_cacheStats->incListenerCalls();
+ m_cacheImpl->getCachePerfStats().incListenerCalls();
}
break;
}
case AFTER_REGION_INVALIDATE: {
eventStr = "afterRegionInvalidate";
m_listener->afterRegionInvalidate(event);
- m_cacheImpl->m_cacheStats->incListenerCalls();
+ m_cacheImpl->getCachePerfStats().incListenerCalls();
break;
}
case AFTER_REGION_CLEAR: {
@@ -2754,10 +2773,9 @@ GfErrType LocalRegion::invokeCacheListenerForRegionEvent(
}
}
if (updateStats) {
- Utils::updateStatOpTime(
- m_regionStats->getStat(),
- RegionStatType::getInstance()->getListenerCallTimeId(),
- sampleStartNanos);
+ updateStatOpTime(m_regionStats->getStat(),
+ m_regionStats->getListenerCallTimeId(),
+ sampleStartNanos);
m_regionStats->incListenerCallsCompleted();
}
} catch (const Exception& ex) {
@@ -2847,7 +2865,8 @@ ExpirationAction::Action LocalRegion::adjustEntryExpiryAction(
bool hadExpiry = (getEntryExpiryDuration() != 0);
if (!hadExpiry) {
throw IllegalStateException(
- "Cannot change entry ExpirationAction for region created without entry "
+ "Cannot change entry ExpirationAction for region created without "
+ "entry "
"expiry.");
}
ExpirationAction::Action oldValue = getEntryExpirationAction();
@@ -2865,7 +2884,8 @@ int32_t LocalRegion::adjustRegionExpiryDuration(int32_t duration) {
bool hadExpiry = (getEntryExpiryDuration() != 0);
if (!hadExpiry) {
throw IllegalStateException(
- "Cannot change region expiration duration for region created without "
+ "Cannot change region expiration duration for region created "
+ "without "
"region expiry.");
}
int32_t oldValue = getRegionExpiryDuration();
@@ -2899,14 +2919,9 @@ bool LocalRegion::isStatisticsEnabled() {
if (m_cacheImpl == nullptr) {
return false;
}
- if (m_cacheImpl->getCache() != nullptr) {
- SystemProperties* props =
- m_cacheImpl->getCache()->getDistributedSystem()->getSystemProperties();
- if (props) {
- status = props->statisticsEnabled();
- }
- }
- return status;
+ return m_cacheImpl->getDistributedSystem()
+ .getSystemProperties()
+ .statisticsEnabled();
}
bool LocalRegion::useModifiedTimeForRegionExpiry() {
@@ -3106,7 +3121,7 @@ void LocalRegion::evict(int32_t percentage) {
}
void LocalRegion::invokeAfterAllEndPointDisconnected() {
if (m_listener != nullptr) {
- int64_t sampleStartNanos = Utils::startStatOpTime();
+ int64_t sampleStartNanos = startStatOpTime();
try {
m_listener->afterRegionDisconnected(shared_from_this());
} catch (const Exception& ex) {
@@ -3115,10 +3130,8 @@ void LocalRegion::invokeAfterAllEndPointDisconnected() {
} catch (...) {
LOGERROR("Unknown exception in CacheListener::afterRegionDisconnected");
}
- Utils::updateStatOpTime(
- m_regionStats->getStat(),
- RegionStatType::getInstance()->getListenerCallTimeId(),
- sampleStartNanos);
+ updateStatOpTime(m_regionStats->getStat(),
+ m_regionStats->getListenerCallTimeId(), sampleStartNanos);
m_regionStats->incListenerCallsCompleted();
}
}
@@ -3150,6 +3163,16 @@ CacheablePtr LocalRegion::handleReplay(GfErrType& err,
TombstoneListPtr LocalRegion::getTombstoneList() { return m_tombstoneList; }
+int64_t LocalRegion::startStatOpTime() {
+ return m_enableTimeStatistics ? Utils::startStatOpTime() : 0;
+}
+void LocalRegion::updateStatOpTime(Statistics* statistics, int32_t statId,
+ int64_t start) {
+ if (m_enableTimeStatistics) {
+ Utils::updateStatOpTime(statistics, statId, start);
+ }
+}
+
} // namespace client
} // namespace geode
} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/LocalRegion.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/LocalRegion.hpp b/src/cppcache/src/LocalRegion.hpp
index 7d5a139..fee2518 100644
--- a/src/cppcache/src/LocalRegion.hpp
+++ b/src/cppcache/src/LocalRegion.hpp
@@ -131,7 +131,8 @@ class CPPCACHE_EXPORT LocalRegion : public RegionInternal {
LocalRegion(const std::string& name, CacheImpl* cache,
const RegionInternalPtr& rPtr,
const RegionAttributesPtr& attributes,
- const CacheStatisticsPtr& stats, bool shared = false);
+ const CacheStatisticsPtr& stats, bool shared = false,
+ bool enableTimeStatistics = true);
virtual ~LocalRegion();
const char* getName() const;
@@ -424,6 +425,10 @@ class CPPCACHE_EXPORT LocalRegion : public RegionInternal {
DataInput* delta = nullptr,
EventIdPtr eventId = nullptr);
+ int64_t startStatOpTime();
+ void updateStatOpTime(Statistics* m_regionStats, int32_t statId,
+ int64_t start);
+
/* protected attributes */
std::string m_name;
RegionPtr m_parentRegion;
@@ -442,6 +447,7 @@ class CPPCACHE_EXPORT LocalRegion : public RegionInternal {
TombstoneListPtr m_tombstoneList;
bool m_isPRSingleHopEnabled;
PoolPtr m_attachedPool;
+ bool m_enableTimeStatistics;
mutable ACE_RW_Thread_Mutex m_rwLock;
void keys_internal(VectorOfCacheableKey& v);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/MapEntry.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/MapEntry.cpp b/src/cppcache/src/MapEntry.cpp
index b8f1854..13a4ff3 100644
--- a/src/cppcache/src/MapEntry.cpp
+++ b/src/cppcache/src/MapEntry.cpp
@@ -14,20 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#include "MapEntry.hpp"
#include "MapEntryT.hpp"
-using namespace apache::geode::client;
+namespace apache {
+namespace geode {
+namespace client {
-EntryFactory* EntryFactory::singleton = nullptr;
MapEntryPtr MapEntry::MapEntry_NullPointer(nullptr);
-/**
- * @brief called when library is initialized... see CppCacheLibrary.
- */
-void EntryFactory::init() { singleton = new EntryFactory(); }
-
-void EntryFactory::newMapEntry(const CacheableKeyPtr& key,
+void EntryFactory::newMapEntry(ExpiryTaskManager* expiryTaskManager,
+ const CacheableKeyPtr& key,
MapEntryImplPtr& result) const {
if (m_concurrencyChecksEnabled) {
result = MapEntryT<VersionedMapEntryImpl, 0, 0>::create(key);
@@ -35,3 +33,7 @@ void EntryFactory::newMapEntry(const CacheableKeyPtr& key,
result = MapEntryT<MapEntryImpl, 0, 0>::create(key);
}
}
+
+} // namespace client
+} // namespace geode
+} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/MapEntry.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/MapEntry.hpp b/src/cppcache/src/MapEntry.hpp
index 52fb299..270a8b8 100644
--- a/src/cppcache/src/MapEntry.hpp
+++ b/src/cppcache/src/MapEntry.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_MAPENTRY_H_
-#define GEODE_MAPENTRY_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,8 +15,11 @@
* limitations under the License.
*/
-#include <atomic>
+#pragma once
+#ifndef GEODE_MAPENTRY_H_
+#define GEODE_MAPENTRY_H_
+#include <atomic>
#include <geode/geode_globals.hpp>
#include <geode/Cacheable.hpp>
#include <geode/CacheableKey.hpp>
@@ -45,6 +43,7 @@ class CPPCACHE_EXPORT MapEntryImpl;
typedef std::shared_ptr<MapEntryImpl> MapEntryImplPtr;
class CPPCACHE_EXPORT LRUEntryProperties;
+class CacheImpl;
/**
* @brief This class encapsulates expiration specific properties for
@@ -52,8 +51,11 @@ class CPPCACHE_EXPORT LRUEntryProperties;
*/
class CPPCACHE_EXPORT ExpEntryProperties {
public:
- inline ExpEntryProperties()
- : m_lastAccessTime(0), m_lastModifiedTime(0), m_expiryTaskId(-1) {
+ inline ExpEntryProperties(ExpiryTaskManager* expiryTaskManager)
+ : m_lastAccessTime(0),
+ m_lastModifiedTime(0),
+ m_expiryTaskId(-1),
+ m_expiryTaskManager(expiryTaskManager) {
// The reactor always gives +ve id while scheduling.
// -1 will indicate that an expiry task has not been scheduled
// for this entry. // TODO confirm
@@ -86,7 +88,7 @@ class CPPCACHE_EXPORT ExpEntryProperties {
inline void cancelExpiryTaskId(const CacheableKeyPtr& key) const {
LOGDEBUG("Cancelling expiration task for key [%s] with id [%d]",
Utils::getCacheableKeyString(key)->asChar(), m_expiryTaskId);
- CacheImpl::expiryTaskManager->cancelTask(m_expiryTaskId);
+ m_expiryTaskManager->cancelTask(m_expiryTaskId);
}
protected:
@@ -100,6 +102,7 @@ class CPPCACHE_EXPORT ExpEntryProperties {
std::atomic<uint32_t> m_lastModifiedTime;
/** The expiry task id for this particular entry.. **/
long m_expiryTaskId;
+ ExpiryTaskManager* m_expiryTaskManager;
};
/**
@@ -270,20 +273,15 @@ typedef std::shared_ptr<VersionedMapEntryImpl> VersionedMapEntryImplPtr;
class CPPCACHE_EXPORT EntryFactory {
public:
- static EntryFactory* singleton;
- static void init();
-
- EntryFactory() { m_concurrencyChecksEnabled = true; }
+ EntryFactory(const bool concurrencyChecksEnabled)
+ : m_concurrencyChecksEnabled(concurrencyChecksEnabled) {}
virtual ~EntryFactory() {}
- virtual void newMapEntry(const CacheableKeyPtr& key,
+ virtual void newMapEntry(ExpiryTaskManager* expiryTaskManager,
+ const CacheableKeyPtr& key,
MapEntryImplPtr& result) const;
- virtual void setConcurrencyChecksEnabled(bool enabled) {
- m_concurrencyChecksEnabled = enabled;
- }
-
protected:
bool m_concurrencyChecksEnabled;
};
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/MapEntryT.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/MapEntryT.hpp b/src/cppcache/src/MapEntryT.hpp
index 86db403..4bd354e 100644
--- a/src/cppcache/src/MapEntryT.hpp
+++ b/src/cppcache/src/MapEntryT.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_MAPENTRYT_H_
-#define GEODE_MAPENTRYT_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,6 +15,11 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_MAPENTRYT_H_
+#define GEODE_MAPENTRYT_H_
+
#include <geode/geode_globals.hpp>
#include "MapEntry.hpp"
#include "TrackedMapEntry.hpp"
@@ -116,8 +116,16 @@ class MapEntryT : public TBase {
return std::make_shared<MapEntryT>(key);
}
+ inline static std::shared_ptr<MapEntryT> create(
+ ExpiryTaskManager* expiryTaskManager, const CacheableKeyPtr& key) {
+ return std::make_shared<MapEntryT>(expiryTaskManager, key);
+ }
+
protected:
inline MapEntryT(const CacheableKeyPtr& key) : TBase(key) {}
+ inline MapEntryT(ExpiryTaskManager* expiryTaskManager,
+ const CacheableKeyPtr& key)
+ : TBase(expiryTaskManager, key) {}
private:
// disabled
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/MapSegment.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/MapSegment.cpp b/src/cppcache/src/MapSegment.cpp
index efa5f92..fe1ae59 100644
--- a/src/cppcache/src/MapSegment.cpp
+++ b/src/cppcache/src/MapSegment.cpp
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#include "MapSegment.hpp"
#include "MapEntry.hpp"
#include "TrackedMapEntry.hpp"
@@ -42,7 +43,8 @@ MapSegment::~MapSegment() {
}
void MapSegment::open(RegionInternal* region, const EntryFactory* entryFactory,
- uint32_t size, std::atomic<int32_t>* destroyTrackers,
+ ExpiryTaskManager* expiryTaskManager, uint32_t size,
+ std::atomic<int32_t>* destroyTrackers,
bool concurrencyChecksEnabled) {
m_map = new CacheableKeyHashMap();
uint32_t mapSize = TableOfPrimes::nextLargerPrime(size, m_primeIndex);
@@ -51,6 +53,9 @@ void MapSegment::open(RegionInternal* region, const EntryFactory* entryFactory,
m_map->open(mapSize);
m_entryFactory = entryFactory;
m_region = region;
+ m_tombstoneList =
+ std::make_shared<TombstoneList>(this, m_region->getCacheImpl());
+ m_expiryTaskManager = expiryTaskManager;
m_numDestroyTrackers = destroyTrackers;
m_concurrencyChecksEnabled = concurrencyChecksEnabled;
}
@@ -123,7 +128,7 @@ GfErrType MapSegment::create(const CacheableKeyPtr& key,
}
}
if (taskid != -1) {
- CacheImpl::expiryTaskManager->cancelTask(taskid);
+ m_expiryTaskManager->cancelTask(taskid);
if (handler != nullptr) delete handler;
}
return err;
@@ -194,7 +199,7 @@ GfErrType MapSegment::put(const CacheableKeyPtr& key,
}
}
if (taskid != -1) {
- CacheImpl::expiryTaskManager->cancelTask(taskid);
+ m_expiryTaskManager->cancelTask(taskid);
if (handler != nullptr) delete handler;
}
return err;
@@ -279,7 +284,7 @@ GfErrType MapSegment::removeWhenConcurrencyEnabled(
if ((err = putForTrackedEntry(key, CacheableToken::tombstone(), entry,
entryImpl, updateCount, versionStamp)) ==
GF_NOERR) {
- m_tombstoneList->add(m_region, entryImpl, handler, expiryTaskID);
+ m_tombstoneList->add(entryImpl, handler, expiryTaskID);
expTaskSet = true;
}
if (CacheableToken::isTombstone(oldValue)) {
@@ -298,8 +303,7 @@ GfErrType MapSegment::removeWhenConcurrencyEnabled(
if (_VERSION_TAG_NULL_CHK) {
MapEntryImplPtr mapEntry;
putNoEntry(key, CacheableToken::tombstone(), mapEntry, -1, 0, versionTag);
- m_tombstoneList->add(m_region, mapEntry->getImplPtr(), handler,
- expiryTaskID);
+ m_tombstoneList->add(mapEntry->getImplPtr(), handler, expiryTaskID);
expTaskSet = true;
}
oldValue = nullptr;
@@ -335,7 +339,7 @@ GfErrType MapSegment::remove(const CacheableKeyPtr& key, CacheablePtr& oldValue,
}
if (!expTaskSet) {
- CacheImpl::expiryTaskManager->cancelTask(id);
+ m_expiryTaskManager->cancelTask(id);
delete handler;
}
return err;
@@ -369,7 +373,7 @@ GfErrType MapSegment::remove(const CacheableKeyPtr& key, CacheablePtr& oldValue,
bool MapSegment::unguardedRemoveActualEntry(const CacheableKeyPtr& key,
bool cancelTask) {
MapEntryPtr entry;
- m_tombstoneList->eraseEntryFromTombstoneList(key, m_region, cancelTask);
+ m_tombstoneList->eraseEntryFromTombstoneList(key, cancelTask);
if (m_map->unbind(key, entry) == -1) {
return false;
}
@@ -381,7 +385,7 @@ bool MapSegment::unguardedRemoveActualEntryWithoutCancelTask(
int64_t& taskid) {
MapEntryPtr entry;
taskid = m_tombstoneList->eraseEntryFromTombstoneListWithoutCancelTask(
- key, m_region, handler);
+ key, handler);
if (m_map->unbind(key, entry) == -1) {
return false;
}
@@ -522,7 +526,7 @@ int MapSegment::addTrackerForEntry(const CacheableKeyPtr& key,
if (addIfAbsent) {
MapEntryImplPtr entryImpl;
// add a new entry with value as destroyed
- m_entryFactory->newMapEntry(key, entryImpl);
+ m_entryFactory->newMapEntry(m_expiryTaskManager, key, entryImpl);
entryImpl->setValueI(CacheableToken::destroyed());
entry = entryImpl;
newEntry = entryImpl;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/MapSegment.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/MapSegment.hpp b/src/cppcache/src/MapSegment.hpp
index 94609d6..6483c61 100644
--- a/src/cppcache/src/MapSegment.hpp
+++ b/src/cppcache/src/MapSegment.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_MAPSEGMENT_H_
-#define GEODE_MAPSEGMENT_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,6 +15,11 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_MAPSEGMENT_H_
+#define GEODE_MAPSEGMENT_H_
+
#include <geode/geode_globals.hpp>
#include <geode/CacheableKey.hpp>
@@ -82,6 +82,7 @@ class CPPCACHE_EXPORT MapSegment {
// does not need deletion here.
const EntryFactory* m_entryFactory;
RegionInternal* m_region;
+ ExpiryTaskManager* m_expiryTaskManager;
// index of the current prime in the primes table
uint32_t m_primeIndex;
@@ -163,7 +164,7 @@ class CPPCACHE_EXPORT MapSegment {
}
}
}
- m_entryFactory->newMapEntry(key, newEntry);
+ m_entryFactory->newMapEntry(m_expiryTaskManager, key, newEntry);
newEntry->setValueI(newValue);
if (m_concurrencyChecksEnabled) {
if (versionTag != nullptr && versionTag.get() != nullptr) {
@@ -195,15 +196,14 @@ class CPPCACHE_EXPORT MapSegment {
: m_map(nullptr),
m_entryFactory(nullptr),
m_region(nullptr),
+ m_expiryTaskManager(nullptr),
m_primeIndex(0),
m_spinlock(),
m_segmentMutex(),
m_concurrencyChecksEnabled(false),
m_numDestroyTrackers(nullptr),
- m_rehashCount(0) // COVERITY --> 30303 Uninitialized scalar field
- {
- m_tombstoneList = std::make_shared<TombstoneList>(this);
- }
+ m_rehashCount(0),
+ m_tombstoneList(nullptr) {}
~MapSegment();
@@ -217,8 +217,8 @@ class CPPCACHE_EXPORT MapSegment {
* Used when allocated in arrays by EntriesMap implementations.
*/
void open(RegionInternal* region, const EntryFactory* entryFactory,
- uint32_t size, std::atomic<int32_t>* destroyTrackers,
- bool concurrencyChecksEnabled);
+ ExpiryTaskManager* expiryTaskManager, uint32_t size,
+ std::atomic<int32_t>* destroyTrackers, bool concurrencyChecksEnabled);
void close();
void clear();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PdxHelper.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PdxHelper.cpp b/src/cppcache/src/PdxHelper.cpp
index 80ad913..7da7086 100644
--- a/src/cppcache/src/PdxHelper.cpp
+++ b/src/cppcache/src/PdxHelper.cpp
@@ -33,7 +33,10 @@
#include "Utils.hpp"
#include "PdxRemoteWriter.hpp"
#include "CacheRegionHelper.hpp"
+#include "ThinClientPoolDM.hpp"
#include <geode/Cache.hpp>
+#include <geode/DataInput.hpp>
+#include <geode/PoolManager.hpp>
namespace apache {
namespace geode {
@@ -44,18 +47,6 @@ PdxHelper::PdxHelper() {}
PdxHelper::~PdxHelper() {}
-CacheImpl* PdxHelper::getCacheImpl() {
- CachePtr cache = CacheFactory::getAnyInstance();
- if (cache == nullptr) {
- throw IllegalStateException("cache has not been created yet.");
- ;
- }
- if (cache->isClosed()) {
- throw IllegalStateException("cache has been closed. ");
- }
- return CacheRegionHelper::getCacheImpl(cache.get());
-}
-
void PdxHelper::serializePdx(DataOutput& output,
const PdxSerializable& pdxObject) {
serializePdx(
@@ -69,6 +60,9 @@ void PdxHelper::serializePdx(DataOutput& output,
const char* pdxClassname = nullptr;
auto pdxII = std::dynamic_pointer_cast<PdxInstanceImpl>(pdxObject);
+ auto cacheImpl = CacheRegionHelper::getCacheImpl(output.getCache());
+ auto pdxTypeRegistry = cacheImpl->getPdxTypeRegistry();
+ auto& cachePerfStats = cacheImpl->getCachePerfStats();
if (pdxII != nullptr) {
PdxTypePtr piPt = pdxII->getPdxType();
@@ -76,10 +70,10 @@ void PdxHelper::serializePdx(DataOutput& output,
piPt->getTypeId() ==
0) // from pdxInstance factory need to get typeid from server
{
- int typeId = PdxTypeRegistry::getPDXIdForType(piPt, output.getPoolName());
+ int typeId = pdxTypeRegistry->getPDXIdForType(piPt, output.getPoolName());
pdxII->setPdxId(typeId);
}
- auto plw = std::make_shared<PdxLocalWriter>(output, piPt);
+ auto plw = std::make_shared<PdxLocalWriter>(output, piPt, pdxTypeRegistry);
pdxII->toData(plw);
plw->endObjectWriting(); // now write typeid
int len = 0;
@@ -93,34 +87,31 @@ void PdxHelper::serializePdx(DataOutput& output,
const char* pdxType = pdxObject->getClassName();
pdxClassname = pdxType;
- PdxTypePtr localPdxType = PdxTypeRegistry::getLocalPdxType(pdxType);
+ PdxTypePtr localPdxType = pdxTypeRegistry->getLocalPdxType(pdxType);
if (localPdxType == nullptr) {
// need to grab type info, as fromdata is not called yet
PdxWriterWithTypeCollectorPtr ptc =
- std::make_shared<PdxWriterWithTypeCollector>(output, pdxType);
+ std::make_shared<PdxWriterWithTypeCollector>(output, pdxType,
+ pdxTypeRegistry);
pdxObject->toData(std::dynamic_pointer_cast<PdxWriter>(ptc));
PdxTypePtr nType = ptc->getPdxLocalType();
nType->InitializeType();
-
- // SerializationRegistry::GetPDXIdForType(output.getPoolName(), nType);
- int32_t nTypeId = PdxTypeRegistry::getPDXIdForType(
+ int32_t nTypeId = pdxTypeRegistry->getPDXIdForType(
pdxType, output.getPoolName(), nType, true);
nType->setTypeId(nTypeId);
ptc->endObjectWriting();
- PdxTypeRegistry::addLocalPdxType(pdxType, nType);
- PdxTypeRegistry::addPdxType(nTypeId, nType);
+ pdxTypeRegistry->addLocalPdxType(pdxType, nType);
+ pdxTypeRegistry->addPdxType(nTypeId, nType);
- //[ToDo] need to write bytes for stats
- CacheImpl* cacheImpl = PdxHelper::getCacheImpl();
if (cacheImpl != nullptr) {
uint8_t* stPos = const_cast<uint8_t*>(output.getBuffer()) +
ptc->getStartPositionOffset();
int pdxLen = PdxHelper::readInt32(stPos);
- cacheImpl->m_cacheStats->incPdxSerialization(
+ cachePerfStats.incPdxSerialization(
pdxLen + 1 + 2 * 4); // pdxLen + 93 DSID + len + typeID
}
@@ -129,7 +120,7 @@ void PdxHelper::serializePdx(DataOutput& output,
// if object got from server than create instance of RemoteWriter otherwise
// local writer.
- PdxRemotePreservedDataPtr pd = PdxTypeRegistry::getPreserveData(pdxObject);
+ PdxRemotePreservedDataPtr pd = pdxTypeRegistry->getPreserveData(pdxObject);
// now always remotewriter as we have API Read/WriteUnreadFields
// so we don't know whether user has used those or not;; Can we do some
@@ -138,21 +129,22 @@ void PdxHelper::serializePdx(DataOutput& output,
if (pd != nullptr) {
PdxTypePtr mergedPdxType =
- PdxTypeRegistry::getPdxType(pd->getMergedTypeId());
- prw = std::make_shared<PdxRemoteWriter>(output, mergedPdxType, pd);
+ pdxTypeRegistry->getPdxType(pd->getMergedTypeId());
+ prw = std::make_shared<PdxRemoteWriter>(output, mergedPdxType, pd,
+ pdxTypeRegistry);
} else {
- prw = std::make_shared<PdxRemoteWriter>(output, pdxClassname);
+ prw = std::make_shared<PdxRemoteWriter>(output, pdxClassname,
+ pdxTypeRegistry);
}
pdxObject->toData(std::dynamic_pointer_cast<PdxWriter>(prw));
prw->endObjectWriting();
//[ToDo] need to write bytes for stats
- CacheImpl* cacheImpl = PdxHelper::getCacheImpl();
if (cacheImpl != nullptr) {
uint8_t* stPos = const_cast<uint8_t*>(output.getBuffer()) +
prw->getStartPositionOffset();
int pdxLen = PdxHelper::readInt32(stPos);
- cacheImpl->m_cacheStats->incPdxSerialization(
+ cachePerfStats.incPdxSerialization(
pdxLen + 1 + 2 * 4); // pdxLen + 93 DSID + len + typeID
}
}
@@ -165,9 +157,13 @@ PdxSerializablePtr PdxHelper::deserializePdx(DataInput& dataInput,
PdxSerializablePtr pdxObjectptr = nullptr;
PdxTypePtr pdxLocalType = nullptr;
- PdxTypePtr pType = PdxTypeRegistry::getPdxType(typeId);
+ auto cacheImpl = CacheRegionHelper::getCacheImpl(dataInput.getCache());
+ auto pdxTypeRegistry = cacheImpl->getPdxTypeRegistry();
+ auto serializationRegistry = cacheImpl->getSerializationRegistry();
+
+ PdxTypePtr pType = pdxTypeRegistry->getPdxType(typeId);
if (pType != nullptr) { // this may happen with PdxInstanceFactory {
- pdxLocalType = PdxTypeRegistry::getLocalPdxType(
+ pdxLocalType = pdxTypeRegistry->getLocalPdxType(
pType->getPdxClassName()); // this should be fine for IPdxTypeMapper
}
if (pType != nullptr && pdxLocalType != nullptr) // type found
@@ -176,25 +172,27 @@ PdxSerializablePtr PdxHelper::deserializePdx(DataInput& dataInput,
LOGDEBUG("deserializePdx ClassName = %s, isLocal = %d ",
pType->getPdxClassName(), pType->isLocal());
- pdxObjectptr = SerializationRegistry::getPdxType(pdxClassname);
+ pdxObjectptr = serializationRegistry->getPdxType(pdxClassname);
if (pType->isLocal()) // local type no need to read Unread data
{
- PdxLocalReaderPtr plr =
- std::make_shared<PdxLocalReader>(dataInput, pType, length);
+ PdxLocalReaderPtr plr = std::make_shared<PdxLocalReader>(
+ dataInput, pType, length, pdxTypeRegistry);
pdxObjectptr->fromData(std::dynamic_pointer_cast<PdxReader>(plr));
plr->MoveStream();
} else {
- PdxRemoteReaderPtr prr =
- std::make_shared<PdxRemoteReader>(dataInput, pType, length);
+ PdxRemoteReaderPtr prr = std::make_shared<PdxRemoteReader>(
+ dataInput, pType, length, pdxTypeRegistry);
pdxObjectptr->fromData(std::dynamic_pointer_cast<PdxReader>(prr));
PdxTypePtr mergedVersion =
- PdxTypeRegistry::getMergedType(pType->getTypeId());
+ pdxTypeRegistry->getMergedType(pType->getTypeId());
PdxRemotePreservedDataPtr preserveData =
prr->getPreservedData(mergedVersion, pdxObjectptr);
if (preserveData != nullptr) {
- PdxTypeRegistry::setPreserveData(
- pdxObjectptr, preserveData); // it will set data in weakhashmap
+ pdxTypeRegistry->setPreserveData(
+ pdxObjectptr, preserveData,
+ cacheImpl
+ ->getExpiryTaskManager()); // it will set data in weakhashmap
}
prr->MoveStream();
}
@@ -202,9 +200,11 @@ PdxSerializablePtr PdxHelper::deserializePdx(DataInput& dataInput,
// type not found; need to get from server
if (pType == nullptr) {
pType = std::static_pointer_cast<PdxType>(
- SerializationRegistry::GetPDXTypeById(dataInput.getPoolName(),
- typeId));
- pdxLocalType = PdxTypeRegistry::getLocalPdxType(pType->getPdxClassName());
+ serializationRegistry->GetPDXTypeById(
+ cacheImpl->getCache()->getPoolManager().find(
+ dataInput.getPoolName()),
+ typeId));
+ pdxLocalType = pdxTypeRegistry->getLocalPdxType(pType->getPdxClassName());
}
/* adongre - Coverity II
* CID 29298: Unused pointer value (UNUSED_VALUE)
@@ -213,13 +213,13 @@ PdxSerializablePtr PdxHelper::deserializePdx(DataInput& dataInput,
* Fix : Commented the line
*/
// pdxClassname = pType->getPdxClassName();
- pdxObjectptr = SerializationRegistry::getPdxType(pType->getPdxClassName());
+ pdxObjectptr = serializationRegistry->getPdxType(pType->getPdxClassName());
PdxSerializablePtr pdxRealObject = pdxObjectptr;
if (pdxLocalType == nullptr) // need to know local type
{
PdxReaderWithTypeCollectorPtr prtc =
- std::make_shared<PdxReaderWithTypeCollector>(dataInput, pType,
- length);
+ std::make_shared<PdxReaderWithTypeCollector>(dataInput, pType, length,
+ pdxTypeRegistry);
pdxObjectptr->fromData(std::dynamic_pointer_cast<PdxReader>(prtc));
// Check for the PdxWrapper
@@ -227,44 +227,45 @@ PdxSerializablePtr PdxHelper::deserializePdx(DataInput& dataInput,
pdxLocalType = prtc->getLocalType();
if (pType->Equals(pdxLocalType)) {
- PdxTypeRegistry::addLocalPdxType(pdxRealObject->getClassName(), pType);
- PdxTypeRegistry::addPdxType(pType->getTypeId(), pType);
+ pdxTypeRegistry->addLocalPdxType(pdxRealObject->getClassName(), pType);
+ pdxTypeRegistry->addPdxType(pType->getTypeId(), pType);
pType->setLocal(true);
} else {
// Need to know local type and then merge type
pdxLocalType->InitializeType();
- pdxLocalType->setTypeId(PdxTypeRegistry::getPDXIdForType(
+ pdxLocalType->setTypeId(pdxTypeRegistry->getPDXIdForType(
pdxObjectptr->getClassName(), dataInput.getPoolName(), pdxLocalType,
true));
pdxLocalType->setLocal(true);
- PdxTypeRegistry::addLocalPdxType(pdxRealObject->getClassName(),
+ pdxTypeRegistry->addLocalPdxType(pdxRealObject->getClassName(),
pdxLocalType); // added local type
- PdxTypeRegistry::addPdxType(pdxLocalType->getTypeId(), pdxLocalType);
+ pdxTypeRegistry->addPdxType(pdxLocalType->getTypeId(), pdxLocalType);
pType->InitializeType();
- PdxTypeRegistry::addPdxType(pType->getTypeId(),
+ pdxTypeRegistry->addPdxType(pType->getTypeId(),
pType); // adding remote type
// create merge type
createMergedType(pdxLocalType, pType, dataInput);
PdxTypePtr mergedVersion =
- PdxTypeRegistry::getMergedType(pType->getTypeId());
+ pdxTypeRegistry->getMergedType(pType->getTypeId());
PdxRemotePreservedDataPtr preserveData =
prtc->getPreservedData(mergedVersion, pdxObjectptr);
if (preserveData != nullptr) {
- PdxTypeRegistry::setPreserveData(pdxObjectptr, preserveData);
+ pdxTypeRegistry->setPreserveData(pdxObjectptr, preserveData,
+ cacheImpl->getExpiryTaskManager());
}
}
prtc->MoveStream();
} else { // remote reader will come here as local type is there
pType->InitializeType();
LOGDEBUG("Adding type %d ", pType->getTypeId());
- PdxTypeRegistry::addPdxType(pType->getTypeId(),
+ pdxTypeRegistry->addPdxType(pType->getTypeId(),
pType); // adding remote type
- PdxRemoteReaderPtr prr =
- std::make_shared<PdxRemoteReader>(dataInput, pType, length);
+ PdxRemoteReaderPtr prr = std::make_shared<PdxRemoteReader>(
+ dataInput, pType, length, pdxTypeRegistry);
pdxObjectptr->fromData(std::dynamic_pointer_cast<PdxReader>(prr));
// Check for PdxWrapper to getObject.
@@ -272,12 +273,13 @@ PdxSerializablePtr PdxHelper::deserializePdx(DataInput& dataInput,
createMergedType(pdxLocalType, pType, dataInput);
PdxTypePtr mergedVersion =
- PdxTypeRegistry::getMergedType(pType->getTypeId());
+ pdxTypeRegistry->getMergedType(pType->getTypeId());
PdxRemotePreservedDataPtr preserveData =
prr->getPreservedData(mergedVersion, pdxObjectptr);
if (preserveData != nullptr) {
- PdxTypeRegistry::setPreserveData(pdxObjectptr, preserveData);
+ pdxTypeRegistry->setPreserveData(pdxObjectptr, preserveData,
+ cacheImpl->getExpiryTaskManager());
}
prr->MoveStream();
}
@@ -287,7 +289,11 @@ PdxSerializablePtr PdxHelper::deserializePdx(DataInput& dataInput,
PdxSerializablePtr PdxHelper::deserializePdx(DataInput& dataInput,
bool forceDeserialize) {
- if (PdxTypeRegistry::getPdxReadSerialized() == false || forceDeserialize) {
+ auto cacheImpl = CacheRegionHelper::getCacheImpl(dataInput.getCache());
+ auto pdxTypeRegistry = cacheImpl->getPdxTypeRegistry();
+ auto serializationRegistry = cacheImpl->getSerializationRegistry();
+ auto& cachePerfStats = cacheImpl->getCachePerfStats();
+ if (pdxTypeRegistry->getPdxReadSerialized() == false || forceDeserialize) {
// Read Length
int32_t len;
dataInput.readInt(&len);
@@ -296,11 +302,8 @@ PdxSerializablePtr PdxHelper::deserializePdx(DataInput& dataInput,
// read typeId
dataInput.readInt(&typeId);
- auto cacheImpl = PdxHelper::getCacheImpl();
- if (cacheImpl != nullptr) {
- cacheImpl->m_cacheStats->incPdxDeSerialization(len +
- 9); // pdxLen + 1 + 2*4
- }
+ cachePerfStats.incPdxDeSerialization(len + 9); // pdxLen + 1 + 2*4
+
return PdxHelper::deserializePdx(dataInput, forceDeserialize,
(int32_t)typeId, (int32_t)len);
@@ -313,26 +316,31 @@ PdxSerializablePtr PdxHelper::deserializePdx(DataInput& dataInput,
// read typeId
dataInput.readInt(&typeId);
- auto pType = PdxTypeRegistry::getPdxType(typeId);
+ auto pType = pdxTypeRegistry->getPdxType(typeId);
if (pType == nullptr) {
+ // TODO shared_ptr why redef?
auto pType = std::static_pointer_cast<PdxType>(
- SerializationRegistry::GetPDXTypeById(dataInput.getPoolName(),
- typeId));
- PdxTypeRegistry::addLocalPdxType(pType->getPdxClassName(), pType);
- PdxTypeRegistry::addPdxType(pType->getTypeId(), pType);
+ serializationRegistry->GetPDXTypeById(
+ cacheImpl->getCache()->getPoolManager().find(
+ dataInput.getPoolName()),
+ typeId));
+ pdxTypeRegistry->addLocalPdxType(pType->getPdxClassName(), pType);
+ pdxTypeRegistry->addPdxType(pType->getTypeId(), pType);
}
+ cachePerfStats.incPdxInstanceCreations();
+
// TODO::Enable it once the PdxInstanceImple is CheckedIn.
auto pdxObject = std::make_shared<PdxInstanceImpl>(
- const_cast<uint8_t*>(dataInput.currentBufferPosition()), len, typeId);
+ const_cast<uint8_t*>(dataInput.currentBufferPosition()), len, typeId,
+ &cachePerfStats, pdxTypeRegistry, dataInput.getCache(),
+ cacheImpl->getDistributedSystem()
+ .getSystemProperties()
+ .getEnableTimeStatistics());
dataInput.advanceCursor(len);
- auto cacheImpl = PdxHelper::getCacheImpl();
- if (cacheImpl != nullptr) {
- cacheImpl->m_cacheStats->incPdxInstanceCreations();
- }
return pdxObject;
}
}
@@ -340,22 +348,26 @@ PdxSerializablePtr PdxHelper::deserializePdx(DataInput& dataInput,
void PdxHelper::createMergedType(PdxTypePtr localType, PdxTypePtr remoteType,
DataInput& dataInput) {
PdxTypePtr mergedVersion = localType->mergeVersion(remoteType);
+ auto cacheImpl = CacheRegionHelper::getCacheImpl(dataInput.getCache());
+ auto pdxTypeRegistry = cacheImpl->getPdxTypeRegistry();
+ auto serializaionRegistry = cacheImpl->getSerializationRegistry();
if (mergedVersion->Equals(localType)) {
- PdxTypeRegistry::setMergedType(remoteType->getTypeId(), localType);
+ pdxTypeRegistry->setMergedType(remoteType->getTypeId(), localType);
} else if (mergedVersion->Equals(remoteType)) {
- PdxTypeRegistry::setMergedType(remoteType->getTypeId(), remoteType);
+ pdxTypeRegistry->setMergedType(remoteType->getTypeId(), remoteType);
} else { // need to create new version
mergedVersion->InitializeType();
if (mergedVersion->getTypeId() == 0) {
- mergedVersion->setTypeId(SerializationRegistry::GetPDXIdForType(
- dataInput.getPoolName(), mergedVersion));
+ mergedVersion->setTypeId(serializaionRegistry->GetPDXIdForType(
+ dataInput.getCache()->getPoolManager().find(dataInput.getPoolName()),
+ mergedVersion));
}
// PdxTypeRegistry::AddPdxType(remoteType->TypeId, mergedVersion);
- PdxTypeRegistry::addPdxType(mergedVersion->getTypeId(), mergedVersion);
- PdxTypeRegistry::setMergedType(remoteType->getTypeId(), mergedVersion);
- PdxTypeRegistry::setMergedType(mergedVersion->getTypeId(), mergedVersion);
+ pdxTypeRegistry->addPdxType(mergedVersion->getTypeId(), mergedVersion);
+ pdxTypeRegistry->setMergedType(remoteType->getTypeId(), mergedVersion);
+ pdxTypeRegistry->setMergedType(mergedVersion->getTypeId(), mergedVersion);
}
}
@@ -414,13 +426,15 @@ int32_t PdxHelper::readInt(uint8_t* offsetPosition, int size) {
}
int32_t PdxHelper::getEnumValue(const char* enumClassName, const char* enumName,
- int hashcode) {
- auto ei = std::make_shared<EnumInfo>(enumClassName, enumName, hashcode);
- return PdxTypeRegistry::getEnumValue(ei);
+ int hashcode,
+ PdxTypeRegistryPtr pdxTypeRegistry) {
+ const auto& ei =
+ std::make_shared<EnumInfo>(enumClassName, enumName, hashcode);
+ return pdxTypeRegistry->getEnumValue(ei);
}
-EnumInfoPtr PdxHelper::getEnum(int enumId) {
- EnumInfoPtr ei = PdxTypeRegistry::getEnum(enumId);
+EnumInfoPtr PdxHelper::getEnum(int enumId, PdxTypeRegistryPtr pdxTypeRegistry) {
+ const auto& ei = pdxTypeRegistry->getEnum(enumId);
return ei;
}
} // namespace client
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PdxHelper.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PdxHelper.hpp b/src/cppcache/src/PdxHelper.hpp
index 546278e..d83d6b1 100644
--- a/src/cppcache/src/PdxHelper.hpp
+++ b/src/cppcache/src/PdxHelper.hpp
@@ -77,9 +77,9 @@ class PdxHelper {
static int32_t readInt(uint8_t* offsetPosition, int size);
static int32_t getEnumValue(const char* enumClassName, const char* enumName,
- int hashcode);
+ int hashcode, PdxTypeRegistryPtr pdxTypeRegistry);
- static EnumInfoPtr getEnum(int enumId);
+ static EnumInfoPtr getEnum(int enumId, PdxTypeRegistryPtr pdxTypeRegistry);
static CacheImpl* getCacheImpl();
};
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PdxInstanceFactoryImpl.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PdxInstanceFactoryImpl.cpp b/src/cppcache/src/PdxInstanceFactoryImpl.cpp
index 166f742..b75c9fe 100644
--- a/src/cppcache/src/PdxInstanceFactoryImpl.cpp
+++ b/src/cppcache/src/PdxInstanceFactoryImpl.cpp
@@ -26,13 +26,20 @@ namespace client {
PdxInstanceFactoryImpl::~PdxInstanceFactoryImpl() {}
-PdxInstanceFactoryImpl::PdxInstanceFactoryImpl(const char* className) {
+PdxInstanceFactoryImpl::PdxInstanceFactoryImpl(
+ const char* className, CachePerfStats* cachePerfStats,
+ PdxTypeRegistryPtr pdxTypeRegistry, const Cache* cache,
+ bool enableTimeStatistics)
+ : m_pdxType(std::make_shared<PdxType>(pdxTypeRegistry, className, false)),
+ m_created(false),
+ m_cachePerfStats(cachePerfStats),
+ m_pdxTypeRegistry(pdxTypeRegistry),
+ m_cache(cache),
+ m_enableTimeStatistics(enableTimeStatistics) {
if (className == nullptr ||
*className == '\0') { // COVERITY ---> 30289 Same on both sides
throw IllegalStateException("className should not be null.");
}
- m_pdxType = std::make_shared<PdxType>(className, false);
- m_created = false;
}
std::unique_ptr<PdxInstance> PdxInstanceFactoryImpl::create() {
@@ -41,7 +48,8 @@ std::unique_ptr<PdxInstance> PdxInstanceFactoryImpl::create() {
"The PdxInstanceFactory.Create() method can only be called once.");
}
auto pi = std::unique_ptr<PdxInstance>(
- new PdxInstanceImpl(m_FieldVsValues, m_pdxType));
+ new PdxInstanceImpl(m_FieldVsValues, m_pdxType, m_cachePerfStats,
+ m_pdxTypeRegistry, m_cache, m_enableTimeStatistics));
m_created = true;
return pi;
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PdxInstanceFactoryImpl.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PdxInstanceFactoryImpl.hpp b/src/cppcache/src/PdxInstanceFactoryImpl.hpp
index 05a6b85..03eccd4 100644
--- a/src/cppcache/src/PdxInstanceFactoryImpl.hpp
+++ b/src/cppcache/src/PdxInstanceFactoryImpl.hpp
@@ -24,6 +24,8 @@
#include <geode/CacheableBuiltins.hpp>
#include <map>
#include "PdxType.hpp"
+#include "PdxTypeRegistry.hpp"
+#include "CachePerfStats.hpp"
namespace apache {
namespace geode {
@@ -446,13 +448,18 @@ class CPPCACHE_EXPORT PdxInstanceFactoryImpl
*/
virtual PdxInstanceFactoryPtr markIdentityField(const char* fieldName);
- PdxInstanceFactoryImpl(const char* className);
+ PdxInstanceFactoryImpl(const char* className, CachePerfStats* cachePerfStats,
+ PdxTypeRegistryPtr m_pdxTypeRegistry,
+ const Cache* cache, bool enableTimeStatistics);
private:
bool m_created;
PdxTypePtr m_pdxType;
FieldVsValues m_FieldVsValues;
-
+ CachePerfStats* m_cachePerfStats;
+ PdxTypeRegistryPtr m_pdxTypeRegistry;
+ const Cache* m_cache;
+ bool m_enableTimeStatistics;
void isFieldAdded(const char* fieldName);
};
} // namespace client
[13/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CqQueryImpl.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CqQueryImpl.cpp b/src/cppcache/src/CqQueryImpl.cpp
index b221f95..ffb603e 100644
--- a/src/cppcache/src/CqQueryImpl.cpp
+++ b/src/cppcache/src/CqQueryImpl.cpp
@@ -31,7 +31,7 @@ CqQueryImpl::CqQueryImpl(const CqServicePtr& cqService,
const std::string& cqName,
const std::string& queryString,
const CqAttributesPtr& cqAttributes,
- const bool isDurable,
+ StatisticsFactory* factory, const bool isDurable,
const UserAttributesPtr& userAttributesPtr)
: m_cqName(cqName),
m_queryString(queryString),
@@ -39,11 +39,8 @@ CqQueryImpl::CqQueryImpl(const CqServicePtr& cqService,
m_serverCqName(
cqName), // On Client Side serverCqName and cqName will be same.
m_isDurable(isDurable),
- m_stats(new CqQueryVsdStats(m_cqName.c_str())),
+ m_stats(std::make_shared<CqQueryVsdStats>(factory, m_cqName)),
m_cqState(CqState::STOPPED), // Initial state is stopped
- /* adongre
- * CID 28930: Uninitialized scalar field (UNINIT_CTOR)
- */
m_cqOperation(CqOperation::OP_TYPE_INVALID),
m_tccdm(m_cqService->getDM()) {
CqAttributesFactory cqAf(cqAttributes);
@@ -259,7 +256,12 @@ GfErrType CqQueryImpl::execute(TcrEndpoint* endpoint) {
LOGFINE("Executing CQ [%s]", m_cqName.c_str());
- TcrMessageExecuteCq request(m_cqName, m_queryString, CqState::RUNNING,
+ TcrMessageExecuteCq request(m_cqService->getDM()
+ ->getConnectionManager()
+ .getCacheImpl()
+ ->getCache()
+ ->createDataOutput(),
+ m_cqName, m_queryString, CqState::RUNNING,
isDurable(), m_tccdm);
TcrMessageReply reply(true, m_tccdm);
@@ -324,7 +326,12 @@ bool CqQueryImpl::executeCq(TcrMessage::MsgType requestType) {
}
LOGDEBUG("CqQueryImpl::executeCq");
- TcrMessageExecuteCq msg(m_cqName, m_queryString, CqState::RUNNING,
+ TcrMessageExecuteCq msg(m_cqService->getDM()
+ ->getConnectionManager()
+ .getCacheImpl()
+ ->getCache()
+ ->createDataOutput(),
+ m_cqName, m_queryString, CqState::RUNNING,
isDurable(), m_tccdm);
TcrMessageReply reply(true, m_tccdm);
@@ -368,7 +375,12 @@ CqResultsPtr CqQueryImpl::executeWithInitialResults(uint32_t timeout) {
"CqQuery::executeWithInitialResults: cq is already running");
}
// QueryResult values;
- TcrMessageExecuteCqWithIr msg(m_cqName, m_queryString, CqState::RUNNING,
+ TcrMessageExecuteCqWithIr msg(m_cqService->getDM()
+ ->getConnectionManager()
+ .getCacheImpl()
+ ->getCache()
+ ->createDataOutput(),
+ m_cqName, m_queryString, CqState::RUNNING,
isDurable(), m_tccdm);
TcrMessageReply reply(true, m_tccdm);
auto resultCollector = (new ChunkedQueryResponse(reply));
@@ -458,10 +470,20 @@ void CqQueryImpl::sendStopOrClose(TcrMessage::MsgType requestType) {
TcrMessageReply reply(true, m_tccdm);
if (requestType == TcrMessage::STOPCQ_MSG_TYPE) {
- TcrMessageStopCQ msg(m_cqName, -1, m_tccdm);
+ TcrMessageStopCQ msg(m_cqService->getDM()
+ ->getConnectionManager()
+ .getCacheImpl()
+ ->getCache()
+ ->createDataOutput(),
+ m_cqName, -1, m_tccdm);
err = m_tccdm->sendSyncRequest(msg, reply);
} else if (requestType == TcrMessage::CLOSECQ_MSG_TYPE) {
- TcrMessageCloseCQ msg(m_cqName, -1, m_tccdm);
+ TcrMessageCloseCQ msg(m_cqService->getDM()
+ ->getConnectionManager()
+ .getCacheImpl()
+ ->getCache()
+ ->createDataOutput(),
+ m_cqName, -1, m_tccdm);
err = m_tccdm->sendSyncRequest(msg, reply);
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CqQueryImpl.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CqQueryImpl.hpp b/src/cppcache/src/CqQueryImpl.hpp
index a4fcd04..8a7920a 100644
--- a/src/cppcache/src/CqQueryImpl.hpp
+++ b/src/cppcache/src/CqQueryImpl.hpp
@@ -94,7 +94,8 @@ class CqQueryImpl : public CqQuery,
public:
CqQueryImpl(const CqServicePtr& cqService, const std::string& cqName,
const std::string& queryString,
- const CqAttributesPtr& cqAttributes, const bool isDurable = false,
+ const CqAttributesPtr& cqAttributes, statistics::StatisticsFactory* factory,
+ const bool isDurable = false,
const UserAttributesPtr& userAttributesPtr = nullptr);
~CqQueryImpl();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CqQueryVsdStats.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CqQueryVsdStats.cpp b/src/cppcache/src/CqQueryVsdStats.cpp
index ceb40a6..473165c 100644
--- a/src/cppcache/src/CqQueryVsdStats.cpp
+++ b/src/cppcache/src/CqQueryVsdStats.cpp
@@ -15,12 +15,6 @@
* limitations under the License.
*/
-#include <geode/geode_globals.hpp>
-
-#include "CqQueryVsdStats.hpp"
-//#include "StatisticsFactory.hpp"
-
-#include <ace/Singleton.h>
#include <mutex>
@@ -28,8 +22,12 @@
const char* cqStatsName = "CqQueryStatistics";
const char* cqStatsDesc = "Statistics for this cq query";
+#include <ace/Thread_Mutex.h>
+#include <ace/Singleton.h>
-////////////////////////////////////////////////////////////////////////////////
+#include <geode/geode_globals.hpp>
+
+#include "CqQueryVsdStats.hpp"
namespace apache {
namespace geode {
@@ -39,80 +37,38 @@ using statistics::StatisticsFactory;
using util::concurrent::spinlock_mutex;
using std::lock_guard;
-////////////////////////////////////////////////////////////////////////////////
-
-spinlock_mutex CqQueryStatType::m_statTypeLock;
+constexpr const char* CqQueryVsdStats::STATS_NAME;
+constexpr const char* CqQueryVsdStats::STATS_DESC;
-StatisticsType* CqQueryStatType::getStatType() {
- const bool largerIsBetter = true;
- lock_guard<spinlock_mutex> guard(m_statTypeLock);
- StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
- GF_D_ASSERT(!!factory);
-
- StatisticsType* statsType = factory->findType("CqQueryStatistics");
-
- if (statsType == nullptr) {
- m_stats[0] = factory->createIntCounter(
+CqQueryVsdStats::CqQueryVsdStats(StatisticsFactory* factory,
+ const std::string& cqqueryName) {
+ auto statsType = factory->findType(STATS_NAME);
+ if (!statsType) {
+ const bool largerIsBetter = true;
+ auto stats = new StatisticDescriptor*[4];
+ stats[0] = factory->createIntCounter(
"inserts", "The total number of inserts this cq qurey", "entries",
largerIsBetter);
- m_stats[1] = factory->createIntCounter(
+ stats[1] = factory->createIntCounter(
"updates", "The total number of updates for this cq query", "entries",
largerIsBetter);
- m_stats[2] = factory->createIntCounter(
+ stats[2] = factory->createIntCounter(
"deletes", "The total number of deletes for this cq query", "entries",
largerIsBetter);
- m_stats[3] = factory->createIntCounter(
+ stats[3] = factory->createIntCounter(
"events", "The total number of events for this cq query", "entries",
largerIsBetter);
- statsType = factory->createType(cqStatsName, cqStatsDesc, m_stats, 4);
-
- m_numInsertsId = statsType->nameToId("inserts");
- m_numUpdatesId = statsType->nameToId("updates");
- m_numDeletesId = statsType->nameToId("deletes");
- m_numEventsId = statsType->nameToId("events");
+ statsType = factory->createType(STATS_NAME, STATS_DESC, stats, 4);
}
- return statsType;
-}
-
-CqQueryStatType& CqQueryStatType::getInstance() {
- // C++11 initializes statics threads safe
- static CqQueryStatType instance;
- return instance;
-}
-
-CqQueryStatType::CqQueryStatType()
- : m_numInsertsId(0),
- m_numUpdatesId(0),
- m_numDeletesId(0),
- m_numEventsId(0) {
- memset(m_stats, 0, sizeof(m_stats));
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-// typedef ACE_Singleton<CqQueryVsdStatsInit, ACE_Thread_Mutex>
-// TheCqQueryVsdStatsInit;
-
-////////////////////////////////////////////////////////////////////////////////
-
-CqQueryVsdStats::CqQueryVsdStats(const char* cqqueryName) {
- auto& regStatType = CqQueryStatType::getInstance();
-
- StatisticsType* statsType = regStatType.getStatType();
-
- GF_D_ASSERT(statsType != nullptr);
-
- StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
-
- m_cqQueryVsdStats = factory->createAtomicStatistics(
- statsType, const_cast<char*>(cqqueryName));
+ m_cqQueryVsdStats =
+ factory->createAtomicStatistics(statsType, cqqueryName.c_str());
- m_numInsertsId = regStatType.getNumInsertsId();
- m_numUpdatesId = regStatType.getNumUpdatesId();
- m_numDeletesId = regStatType.getNumDeletesId();
- m_numEventsId = regStatType.getNumEventsId();
+ m_numInsertsId = statsType->nameToId("inserts");
+ m_numUpdatesId = statsType->nameToId("updates");
+ m_numDeletesId = statsType->nameToId("deletes");
+ m_numEventsId = statsType->nameToId("events");
m_cqQueryVsdStats->setInt(m_numInsertsId, 0);
m_cqQueryVsdStats->setInt(m_numUpdatesId, 0);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CqQueryVsdStats.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CqQueryVsdStats.hpp b/src/cppcache/src/CqQueryVsdStats.hpp
index 3cc5672..33beb02 100644
--- a/src/cppcache/src/CqQueryVsdStats.hpp
+++ b/src/cppcache/src/CqQueryVsdStats.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_CQQUERYVSDSTATS_H_
-#define GEODE_CQQUERYVSDSTATS_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,6 +15,13 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_CQQUERYVSDSTATS_H_
+#define GEODE_CQQUERYVSDSTATS_H_
+
+#include <string>
+
#include <geode/geode_globals.hpp>
#include <geode/statistics/Statistics.hpp>
#include <geode/statistics/StatisticsFactory.hpp>
@@ -39,7 +41,7 @@ using util::concurrent::spinlock_mutex;
class CPPCACHE_EXPORT CqQueryVsdStats : public CqStatistics {
public:
/** hold statistics for a cq. */
- CqQueryVsdStats(const char* cqName);
+ CqQueryVsdStats(statistics::StatisticsFactory* factory, const std::string& cqqueryName);
/** disable stat collection for this item. */
virtual ~CqQueryVsdStats();
@@ -74,39 +76,11 @@ class CPPCACHE_EXPORT CqQueryVsdStats : public CqStatistics {
int32_t m_numUpdatesId;
int32_t m_numDeletesId;
int32_t m_numEventsId;
-};
-
-class CqQueryStatType {
- private:
- static spinlock_mutex m_statTypeLock;
-
- public:
- static CqQueryStatType& getInstance();
-
- StatisticsType* getStatType();
-
- private:
- CqQueryStatType();
- ~CqQueryStatType() = default;
- CqQueryStatType(const CqQueryStatType&) = delete;
- CqQueryStatType& operator=(const CqQueryStatType&) = delete;
-
- StatisticDescriptor* m_stats[4];
-
- int32_t m_numInsertsId;
- int32_t m_numUpdatesId;
- int32_t m_numDeletesId;
- int32_t m_numEventsId;
-
- public:
- inline int32_t getNumInsertsId() { return m_numInsertsId; }
- inline int32_t getNumUpdatesId() { return m_numUpdatesId; }
-
- inline int32_t getNumDeletesId() { return m_numDeletesId; }
-
- inline int32_t getNumEventsId() { return m_numEventsId; }
+ static constexpr const char* STATS_NAME = "CqQueryStatistics";
+ static constexpr const char* STATS_DESC = "Statistics for this cq query";
};
+
} // namespace client
} // namespace geode
} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CqService.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CqService.cpp b/src/cppcache/src/CqService.cpp
index d2d5e7f..e5cbeb9 100644
--- a/src/cppcache/src/CqService.cpp
+++ b/src/cppcache/src/CqService.cpp
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#include "CqService.hpp"
#include "ReadWriteLock.hpp"
#include <geode/DistributedSystem.hpp>
@@ -26,10 +27,12 @@
#include <geode/CqStatusListener.hpp>
using namespace apache::geode::client;
-CqService::CqService(ThinClientBaseDM* tccdm)
+CqService::CqService(ThinClientBaseDM* tccdm,
+ StatisticsFactory* statisticsFactory)
: m_tccdm(tccdm),
+ m_statisticsFactory(statisticsFactory),
m_notificationSema(1),
- m_stats(std::make_shared<CqServiceVsdStats>()) {
+ m_stats(std::make_shared<CqServiceVsdStats>(m_statisticsFactory)) {
m_cqQueryMap = new MapOfCqQueryWithLock();
m_running = true;
LOGDEBUG("CqService Started");
@@ -100,9 +103,11 @@ CqQueryPtr CqService::newCq(const std::string& cqName,
// check for durable client
if (isDurable) {
- auto sysProps = DistributedSystem::getSystemProperties();
- const auto durableID =
- (sysProps != nullptr) ? sysProps->durableClientId() : nullptr;
+ const auto durableID = m_tccdm->getConnectionManager()
+ .getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties()
+ .durableClientId();
if (durableID == nullptr || strlen(durableID) == 0) {
LOGERROR("Cannot create durable CQ because client is not durable.");
throw IllegalStateException(
@@ -123,7 +128,8 @@ CqQueryPtr CqService::newCq(const std::string& cqName,
}
auto cQuery = std::make_shared<CqQueryImpl>(
- shared_from_this(), cqName, queryString, cqAttributes, isDurable, ua);
+ shared_from_this(), cqName, queryString, cqAttributes,
+ m_statisticsFactory, isDurable, ua);
cQuery->initCq();
return cQuery;
}
@@ -570,7 +576,11 @@ CqOperation::CqOperationType CqService::getOperation(int eventType) {
* cqs.
*/
CacheableArrayListPtr CqService::getAllDurableCqsFromServer() {
- TcrMessageGetDurableCqs msg(m_tccdm);
+ TcrMessageGetDurableCqs msg(m_tccdm->getConnectionManager()
+ .getCacheImpl()
+ ->getCache()
+ ->createDataOutput(),
+ m_tccdm);
TcrMessageReply reply(true, m_tccdm);
// intialize the chunked response hadler for durable cqs list
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CqService.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CqService.hpp b/src/cppcache/src/CqService.hpp
index 554abc7..88ff1a8 100644
--- a/src/cppcache/src/CqService.hpp
+++ b/src/cppcache/src/CqService.hpp
@@ -65,6 +65,7 @@ class CPPCACHE_EXPORT CqService
public std::enable_shared_from_this<CqService> {
private:
ThinClientBaseDM* m_tccdm;
+ statistics::StatisticsFactory* m_statisticsFactory;
ACE_Recursive_Thread_Mutex m_mutex;
std::string m_queryString;
ACE_Semaphore m_notificationSema;
@@ -85,7 +86,7 @@ class CPPCACHE_EXPORT CqService
/**
* Constructor.
*/
- CqService(ThinClientBaseDM* tccdm);
+ CqService(ThinClientBaseDM* tccdm, statistics::StatisticsFactory* statisticsFactory);
ThinClientBaseDM* getDM() { return m_tccdm; }
void receiveNotification(TcrMessage* msg);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CqServiceVsdStats.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CqServiceVsdStats.cpp b/src/cppcache/src/CqServiceVsdStats.cpp
index 08f331b..c4d5999 100644
--- a/src/cppcache/src/CqServiceVsdStats.cpp
+++ b/src/cppcache/src/CqServiceVsdStats.cpp
@@ -15,21 +15,13 @@
* limitations under the License.
*/
-#include <geode/geode_globals.hpp>
-
-#include "CqServiceVsdStats.hpp"
-//#include "StatisticsFactory.hpp"
-
+#include <ace/Thread_Mutex.h>
#include <ace/Singleton.h>
-
#include <mutex>
+#include <geode/geode_globals.hpp>
+#include <geode/statistics/StatisticsFactory.hpp>
-#include "util/concurrent/spinlock_mutex.hpp"
-
-const char* cqServiceStatsName = "CqServiceStatistics";
-const char* cqServiceStatsDesc = "Statistics for this cq Service";
-
-////////////////////////////////////////////////////////////////////////////////
+#include "CqServiceVsdStats.hpp"
namespace apache {
namespace geode {
@@ -39,90 +31,47 @@ using statistics::StatisticsFactory;
using util::concurrent::spinlock_mutex;
using std::lock_guard;
-////////////////////////////////////////////////////////////////////////////////
-
-spinlock_mutex CqServiceStatType::m_statTypeLock;
+constexpr const char* CqServiceVsdStats::STATS_NAME;
+constexpr const char* CqServiceVsdStats::STATS_DESC;
-StatisticsType* CqServiceStatType::getStatType() {
- const bool largerIsBetter = true;
- lock_guard<spinlock_mutex> guard(m_statTypeLock);
- StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
- GF_D_ASSERT(!!factory);
-
- StatisticsType* statsType = factory->findType("CqServiceStatistics");
-
- if (statsType == nullptr) {
- m_stats[0] = factory->createIntCounter(
+CqServiceVsdStats::CqServiceVsdStats(StatisticsFactory* factory,
+ const std::string& cqServiceName) {
+ auto statsType = factory->findType(STATS_NAME);
+ if (!statsType) {
+ const bool largerIsBetter = true;
+ auto stats = new StatisticDescriptor*[5];
+ stats[0] = factory->createIntCounter(
"CqsActive", "The total number of CqsActive this cq qurey", "entries",
largerIsBetter);
- m_stats[1] = factory->createIntCounter(
+ stats[1] = factory->createIntCounter(
"CqsCreated", "The total number of CqsCreated for this cq Service",
"entries", largerIsBetter);
- m_stats[2] = factory->createIntCounter(
+ stats[2] = factory->createIntCounter(
"CqsClosed", "The total number of CqsClosed for this cq Service",
"entries", largerIsBetter);
- m_stats[3] = factory->createIntCounter(
+ stats[3] = factory->createIntCounter(
"CqsStopped", "The total number of CqsStopped for this cq Service",
"entries", largerIsBetter);
- m_stats[4] = factory->createIntCounter(
+ stats[4] = factory->createIntCounter(
"CqsOnClient",
"The total number of Cqs on the client for this cq Service", "entries",
largerIsBetter);
- statsType =
- factory->createType(cqServiceStatsName, cqServiceStatsDesc, m_stats, 5);
-
- m_numCqsActiveId = statsType->nameToId("CqsActive");
- m_numCqsCreatedId = statsType->nameToId("CqsCreated");
- m_numCqsOnClientId = statsType->nameToId("CqsOnClient");
- m_numCqsClosedId = statsType->nameToId("CqsClosed");
- m_numCqsStoppedId = statsType->nameToId("CqsStopped");
+ statsType = factory->createType(STATS_NAME, STATS_DESC, stats, 5);
}
- return statsType;
-}
-
-CqServiceStatType& CqServiceStatType::getInstance() {
- static CqServiceStatType instance;
- return instance;
-}
-
-CqServiceStatType::CqServiceStatType()
- : m_numCqsActiveId(0),
- m_numCqsCreatedId(0),
- m_numCqsOnClientId(0),
- m_numCqsClosedId(0),
- m_numCqsStoppedId(0) {
- memset(m_stats, 0, sizeof(m_stats));
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-// typedef ACE_Singleton<CqServiceVsdStatsInit, ACE_Thread_Mutex>
-// TheCqServiceVsdStatsInit;
-
-////////////////////////////////////////////////////////////////////////////////
-
-CqServiceVsdStats::CqServiceVsdStats(const char* cqServiceName) {
- auto& regStatType = CqServiceStatType::getInstance();
-
- StatisticsType* statsType = regStatType.getStatType();
-
- GF_D_ASSERT(statsType != nullptr);
-
- StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
-
- m_cqServiceVsdStats = factory->createAtomicStatistics(
- statsType, const_cast<char*>(cqServiceName));
+ m_cqServiceVsdStats =
+ factory->createAtomicStatistics(statsType, cqServiceName.c_str());
- m_numCqsActiveId = regStatType.getNumCqsActiveId();
- m_numCqsCreatedId = regStatType.getNumCqsCreatedId();
- m_numCqsOnClientId = regStatType.getNumCqsOnClientId();
- m_numCqsClosedId = regStatType.getNumCqsClosedId();
- m_numCqsStoppedId = regStatType.getNumCqsStoppedId();
+ m_numCqsActiveId = statsType->nameToId("CqsActive");
+ m_numCqsCreatedId = statsType->nameToId("CqsCreated");
+ m_numCqsOnClientId = statsType->nameToId("CqsOnClient");
+ m_numCqsClosedId = statsType->nameToId("CqsClosed");
+ m_numCqsStoppedId = statsType->nameToId("CqsStopped");
m_cqServiceVsdStats->setInt(m_numCqsActiveId, 0);
m_cqServiceVsdStats->setInt(m_numCqsCreatedId, 0);
+ m_cqServiceVsdStats->setInt(m_numCqsOnClientId, 0);
m_cqServiceVsdStats->setInt(m_numCqsClosedId, 0);
m_cqServiceVsdStats->setInt(m_numCqsStoppedId, 0);
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CqServiceVsdStats.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CqServiceVsdStats.hpp b/src/cppcache/src/CqServiceVsdStats.hpp
index 710dfdb..2d48056 100644
--- a/src/cppcache/src/CqServiceVsdStats.hpp
+++ b/src/cppcache/src/CqServiceVsdStats.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_CQSERVICEVSDSTATS_H_
-#define GEODE_CQSERVICEVSDSTATS_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,6 +15,13 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_CQSERVICEVSDSTATS_H_
+#define GEODE_CQSERVICEVSDSTATS_H_
+
+#include <string>
+
#include <geode/geode_globals.hpp>
#include <geode/statistics/Statistics.hpp>
#include <geode/statistics/StatisticsFactory.hpp>
@@ -39,7 +41,8 @@ using util::concurrent::spinlock_mutex;
class CPPCACHE_EXPORT CqServiceVsdStats : public CqServiceStatistics {
public:
/** hold statistics for a cq. */
- CqServiceVsdStats(const char* cqName = "CqServiceVsdStats");
+ CqServiceVsdStats(statistics::StatisticsFactory* factory,
+ const std::string& cqName = "CqServiceVsdStats");
/** disable stat collection for this item. */
virtual ~CqServiceVsdStats();
@@ -108,42 +111,11 @@ class CPPCACHE_EXPORT CqServiceVsdStats : public CqServiceStatistics {
int32_t m_numCqsOnClientId;
int32_t m_numCqsClosedId;
int32_t m_numCqsStoppedId;
-};
-
-class CqServiceStatType {
- private:
- static spinlock_mutex m_statTypeLock;
-
- public:
- static CqServiceStatType& getInstance();
-
- StatisticsType* getStatType();
-
- private:
- CqServiceStatType();
- ~CqServiceStatType() = default;
- CqServiceStatType(const CqServiceStatType&) = delete;
- CqServiceStatType& operator=(const CqServiceStatType&) = delete;
-
- StatisticDescriptor* m_stats[5];
-
- int32_t m_numCqsActiveId;
- int32_t m_numCqsCreatedId;
- int32_t m_numCqsOnClientId;
- int32_t m_numCqsClosedId;
- int32_t m_numCqsStoppedId;
-
- public:
- inline int32_t getNumCqsActiveId() { return m_numCqsActiveId; }
- inline int32_t getNumCqsCreatedId() { return m_numCqsCreatedId; }
-
- inline int32_t getNumCqsOnClientId() { return m_numCqsOnClientId; }
-
- inline int32_t getNumCqsClosedId() { return m_numCqsClosedId; }
-
- inline int32_t getNumCqsStoppedId() { return m_numCqsStoppedId; }
+ static constexpr const char* STATS_NAME = "CqServiceStatistics";
+ static constexpr const char* STATS_DESC = "Statistics for this cq Service";
};
+
} // namespace client
} // namespace geode
} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/DataInput.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/DataInput.cpp b/src/cppcache/src/DataInput.cpp
index 402a07a..1de3ae3 100644
--- a/src/cppcache/src/DataInput.cpp
+++ b/src/cppcache/src/DataInput.cpp
@@ -17,15 +17,23 @@
#include <geode/DataInput.hpp>
+#include "CacheRegionHelper.hpp"
#include <SerializationRegistry.hpp>
+#include "CacheImpl.hpp"
namespace apache {
namespace geode {
namespace client {
void DataInput::readObjectInternal(SerializablePtr& ptr, int8_t typeId) {
- ptr = SerializationRegistry::deserialize(*this, typeId);
+ ptr = getSerializationRegistry().deserialize(*this, typeId);
}
+
+const SerializationRegistry& DataInput::getSerializationRegistry() const {
+ return *CacheRegionHelper::getCacheImpl(m_cache)->getSerializationRegistry();
+}
+
+const Cache* DataInput::getCache() { return m_cache; }
} // namespace client
} // namespace geode
} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/DataInputInternal.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/DataInputInternal.hpp b/src/cppcache/src/DataInputInternal.hpp
new file mode 100644
index 0000000..c566d82
--- /dev/null
+++ b/src/cppcache/src/DataInputInternal.hpp
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#ifndef GEODE_DATAINPUTINTERNAL_H_
+#define GEODE_DATAINPUTINTERNAL_H_
+
+#include <geode/DataInput.hpp>
+
+namespace apache {
+namespace geode {
+namespace client {
+
+class DataInputInternal : public DataInput {
+ public:
+ DataInputInternal(const uint8_t* m_buffer, int32_t len, const Cache* cache)
+ : DataInput(m_buffer, len, cache) {}
+
+ virtual const Cache* getCache() override {
+ throw FatalInternalException("DataInputInternal does not have a Cache");
+ }
+};
+
+} // namespace client
+} // namespace geode
+} // namespace apache
+
+#endif // GEODE_DATAINPUTINTERNAL_H_
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/DataOutput.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/DataOutput.cpp b/src/cppcache/src/DataOutput.cpp
index f718d12..061f822 100644
--- a/src/cppcache/src/DataOutput.cpp
+++ b/src/cppcache/src/DataOutput.cpp
@@ -22,6 +22,8 @@
#include <ace/Recursive_Thread_Mutex.h>
#include <vector>
+#include "CacheImpl.hpp"
+#include "CacheRegionHelper.hpp"
namespace apache {
namespace geode {
@@ -105,8 +107,8 @@ TSSDataOutput::~TSSDataOutput() {
ACE_TSS<TSSDataOutput> TSSDataOutput::s_tssDataOutput;
-DataOutput::DataOutput()
- : m_poolName(nullptr), m_size(0), m_haveBigBuffer(false) {
+DataOutput::DataOutput(const Cache* cache)
+ : m_cache(cache), m_poolName(nullptr), m_size(0), m_haveBigBuffer(false) {
m_buf = m_bytes = DataOutput::checkoutBuffer(&m_size);
}
@@ -119,12 +121,18 @@ void DataOutput::checkinBuffer(uint8_t* buffer, uint32_t size) {
}
void DataOutput::writeObjectInternal(const Serializable* ptr, bool isDelta) {
- SerializationRegistry::serialize(ptr, *this, isDelta);
+ getSerializationRegistry().serialize(ptr, *this, isDelta);
}
void DataOutput::acquireLock() { g_bigBufferLock.acquire(); }
void DataOutput::releaseLock() { g_bigBufferLock.release(); }
+
+const SerializationRegistry& DataOutput::getSerializationRegistry() const {
+ return *CacheRegionHelper::getCacheImpl(m_cache)->getSerializationRegistry();
+}
+
+const Cache* DataOutput::getCache() { return m_cache; }
} // namespace client
} // namespace geode
} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/DataOutputInternal.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/DataOutputInternal.hpp b/src/cppcache/src/DataOutputInternal.hpp
new file mode 100644
index 0000000..fd0412e
--- /dev/null
+++ b/src/cppcache/src/DataOutputInternal.hpp
@@ -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.
+ */
+
+#pragma once
+
+#ifndef GEODE_DATAOUTPUTINTERNAL_H_
+#define GEODE_DATAOUTPUTINTERNAL_H_
+
+#include <geode/DataOutput.hpp>
+
+namespace apache {
+namespace geode {
+namespace client {
+
+class DataOutputInternal : public DataOutput {
+ public:
+ DataOutputInternal() : DataOutput() {}
+
+ DataOutputInternal(Cache* cache) : DataOutput(cache) {}
+
+ virtual const Cache* getCache() override {
+ throw FatalInternalException("DataOutputInternal does not have a Cache");
+ }
+};
+
+} // namespace client
+} // namespace geode
+} // namespace apache
+
+#endif // GEODE_DATAOUTPUTINTERNAL_H_
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/Delta.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/Delta.cpp b/src/cppcache/src/Delta.cpp
index 5cae7cd..98f28e0 100644
--- a/src/cppcache/src/Delta.cpp
+++ b/src/cppcache/src/Delta.cpp
@@ -22,15 +22,18 @@
*/
#include <geode/Delta.hpp>
+#include <geode/Cache.hpp>
using namespace apache::geode::client;
+Delta::Delta(Cache* cache) : m_cache(cache) {}
+
DeltaPtr Delta::clone() {
- DataOutput out;
- Cacheable* ptr = dynamic_cast<Cacheable*>(this);
- out.writeObject(ptr);
- DataInput in(out.getBuffer(), out.getBufferLength());
+ auto out = m_cache->createDataOutput();
+ auto ptr = dynamic_cast<Cacheable*>(this);
+ out->writeObject(ptr);
+ auto in = m_cache->createDataInput(out->getBuffer(), out->getBufferLength());
CacheablePtr theClonePtr;
- in.readObject(theClonePtr);
+ in->readObject(theClonePtr);
return std::dynamic_pointer_cast<Delta>(theClonePtr);
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/DiffieHellman.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/DiffieHellman.cpp b/src/cppcache/src/DiffieHellman.cpp
index 6f07d71..80748bd 100644
--- a/src/cppcache/src/DiffieHellman.cpp
+++ b/src/cppcache/src/DiffieHellman.cpp
@@ -25,8 +25,6 @@ namespace geode {
namespace client {
ACE_DLL DiffieHellman::m_dll;
-bool DiffieHellman::m_inited = false;
-ACE_Recursive_Thread_Mutex DiffieHellman::s_mutex;
#define INIT_DH_FUNC_PTR(OrigName) \
DiffieHellman::OrigName##_Type DiffieHellman::OrigName##_Ptr = nullptr;
@@ -53,7 +51,9 @@ void* DiffieHellman::getOpenSSLFuncPtr(const char* function_name) {
}
void DiffieHellman::initOpenSSLFuncPtrs() {
- if (DiffieHellman::m_inited) {
+ static bool inited = false;
+
+ if (inited) {
return;
}
@@ -78,15 +78,14 @@ void DiffieHellman::initOpenSSLFuncPtrs() {
ASSIGN_DH_FUNC_PTR(gf_decryptDH)
ASSIGN_DH_FUNC_PTR(gf_verifyDH)
- DiffieHellman::m_inited = true;
+ inited = true;
}
void DiffieHellman::initDhKeys(const PropertiesPtr& props) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(DiffieHellman::s_mutex);
m_dhCtx = nullptr;
- CacheableStringPtr dhAlgo = props->find(SecurityClientDhAlgo);
- CacheableStringPtr ksPath = props->find(SecurityClientKsPath);
+ const auto& dhAlgo = props->find(SecurityClientDhAlgo);
+ const auto& ksPath = props->find(SecurityClientKsPath);
// Null check only for DH Algo
if (dhAlgo == nullptr) {
@@ -123,20 +122,6 @@ void DiffieHellman::clearDhKeys(void) {
m_dhCtx = nullptr;
- /*
- //reset all pointers
-#define CLEAR_DH_FUNC_PTR(OrigName) \
- OrigName##_Ptr = nullptr;
-
- CLEAR_DH_FUNC_PTR(gf_initDhKeys)
- CLEAR_DH_FUNC_PTR(gf_clearDhKeys)
- CLEAR_DH_FUNC_PTR(gf_getPublicKey)
- CLEAR_DH_FUNC_PTR(gf_setPublicKeyOther)
- CLEAR_DH_FUNC_PTR(gf_computeSharedSecret)
- CLEAR_DH_FUNC_PTR(gf_encryptDH)
- CLEAR_DH_FUNC_PTR(gf_verifyDH)
- */
-
return;
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/DiffieHellman.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/DiffieHellman.hpp b/src/cppcache/src/DiffieHellman.hpp
index bab6630..a97c0fe 100644
--- a/src/cppcache/src/DiffieHellman.hpp
+++ b/src/cppcache/src/DiffieHellman.hpp
@@ -41,8 +41,6 @@ namespace geode {
namespace client {
class DiffieHellman {
- static ACE_Recursive_Thread_Mutex s_mutex;
-
public:
void initDhKeys(const PropertiesPtr& props);
void clearDhKeys(void);
@@ -59,15 +57,10 @@ class DiffieHellman {
static void initOpenSSLFuncPtrs();
- DiffieHellman()
- : /* adongre
- * CID 28933: Uninitialized pointer field (UNINIT_CTOR)
- */
- m_dhCtx((void*)0) {}
+ DiffieHellman() : m_dhCtx(nullptr) {}
private:
void* m_dhCtx;
- static bool m_inited;
static void* getOpenSSLFuncPtr(const char* function_name);
// OpenSSL Func Ptrs: Declare Func Ptr type and a static variable of FuncPtr
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/DiskVersionTag.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/DiskVersionTag.hpp b/src/cppcache/src/DiskVersionTag.hpp
index 1a34360..850a7c1 100644
--- a/src/cppcache/src/DiskVersionTag.hpp
+++ b/src/cppcache/src/DiskVersionTag.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_DISKVERSIONTAG_H_
-#define GEODE_DISKVERSIONTAG_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,6 +15,11 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_DISKVERSIONTAG_H_
+#define GEODE_DISKVERSIONTAG_H_
+
#include "VersionTag.hpp"
#include "GeodeTypeIdsImpl.hpp"
#include "DiskStoreId.hpp"
@@ -35,30 +35,26 @@ _GF_PTR_DEF_(VersionTag, VersionTagPtr);
class DiskVersionTag : public VersionTag {
protected:
virtual void readMembers(uint16_t flags, DataInput& input) {
- DSMemberForVersionStampPtr previousMemId, internalMemId;
- MemberListForVersionStampPtr memberList =
- CacheImpl::getMemberListForVersionStamp();
if ((flags & HAS_MEMBER_ID) != 0) {
- DiskStoreId* temp = new DiskStoreId();
- temp->fromData(input);
- internalMemId = DSMemberForVersionStampPtr(temp);
- m_internalMemId = memberList->add(internalMemId);
+ auto internalMemId = std::make_shared<DiskStoreId>();
+ internalMemId->fromData(input);
+ m_internalMemId = m_memberListForVersionStamp.add(internalMemId);
}
if ((flags & HAS_PREVIOUS_MEMBER_ID) != 0) {
if ((flags & DUPLICATE_MEMBER_IDS) != 0) {
m_previousMemId = m_internalMemId;
} else {
- DiskStoreId* temp = new DiskStoreId();
- temp->fromData(input);
- previousMemId = DSMemberForVersionStampPtr(temp);
- m_previousMemId = memberList->add(previousMemId);
+ auto previousMemId = std::make_shared<DiskStoreId>();
+ previousMemId->fromData(input);
+ m_previousMemId = m_memberListForVersionStamp.add(previousMemId);
}
}
}
public:
- DiskVersionTag() : VersionTag() {}
+ DiskVersionTag(MemberListForVersionStamp& memberListForVersionStamp)
+ : VersionTag(memberListForVersionStamp) {}
virtual int32_t classId() const { return 0; }
@@ -66,16 +62,20 @@ class DiskVersionTag : public VersionTag {
return static_cast<int8_t>(GeodeTypeIdsImpl::DiskVersionTag);
}
- static Serializable* createDeserializable() { return new DiskVersionTag(); }
+ static Serializable* createDeserializable(
+ MemberListForVersionStamp& memberListForVersionStamp) {
+ return new DiskVersionTag(memberListForVersionStamp);
+ }
/**
* for internal testing
*/
DiskVersionTag(int32_t entryVersion, int16_t regionVersionHighBytes,
int32_t regionVersionLowBytes, uint16_t internalMemId,
- uint16_t previousMemId)
+ uint16_t previousMemId,
+ MemberListForVersionStamp& memberListForVersionStamp)
: VersionTag(entryVersion, regionVersionHighBytes, regionVersionLowBytes,
- internalMemId, previousMemId) {}
+ internalMemId, previousMemId, memberListForVersionStamp) {}
};
} // namespace client
} // namespace geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/DistributedSystem.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/DistributedSystem.cpp b/src/cppcache/src/DistributedSystem.cpp
index 72ae401..9c4faf3 100644
--- a/src/cppcache/src/DistributedSystem.cpp
+++ b/src/cppcache/src/DistributedSystem.cpp
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+#include "config.h"
#include <geode/geode_globals.hpp>
#include <geode/DistributedSystem.hpp>
@@ -44,109 +44,84 @@
using namespace apache::geode::client;
using namespace apache::geode::statistics;
-DistributedSystemPtr* DistributedSystem::m_instance_ptr = nullptr;
-bool DistributedSystem::m_connected = false;
-DistributedSystemImpl* DistributedSystem::m_impl = nullptr;
-
ACE_Recursive_Thread_Mutex* g_disconnectLock = new ACE_Recursive_Thread_Mutex();
-namespace {
-
-StatisticsManager* g_statMngr = nullptr;
-
-SystemProperties* g_sysProps = nullptr;
-} // namespace
+namespace {} // namespace
-DistributedSystem::DistributedSystem(const char* name) : m_name(nullptr) {
- LOGDEBUG("DistributedSystem::DistributedSystem");
- if (name != nullptr) {
- size_t len = strlen(name) + 1;
- m_name = new char[len];
- ACE_OS::strncpy(m_name, name, len);
+namespace apache {
+namespace geode {
+namespace client {
+void setLFH() {
+#ifdef _WIN32
+ static HINSTANCE kernelMod = nullptr;
+ if (kernelMod == nullptr) {
+ kernelMod = GetModuleHandle("kernel32");
+ if (kernelMod != nullptr) {
+ typedef BOOL(WINAPI * PHSI)(
+ HANDLE HeapHandle, HEAP_INFORMATION_CLASS HeapInformationClass,
+ PVOID HeapInformation, SIZE_T HeapInformationLength);
+ typedef HANDLE(WINAPI * PGPH)();
+ PHSI pHSI = nullptr;
+ PGPH pGPH = nullptr;
+ if ((pHSI = (PHSI)GetProcAddress(kernelMod, "HeapSetInformation")) !=
+ nullptr) {
+ // The LFH API is available
+ /* Only set LFH for process heap; causes problems in C++ framework if
+ set for all heaps
+ HANDLE hProcessHeapHandles[1024];
+ DWORD dwRet;
+ ULONG heapFragValue = 2;
+
+ dwRet= GetProcessHeaps( 1024, hProcessHeapHandles );
+ for (DWORD i = 0; i < dwRet; i++)
+ {
+ HeapSetInformation( hProcessHeapHandles[i],
+ HeapCompatibilityInformation, &heapFragValue, sizeof(heapFragValue)
+ );
+ }
+ */
+ HANDLE hProcessHeapHandle;
+ ULONG heapFragValue = 2;
+ if ((pGPH = (PGPH)GetProcAddress(kernelMod, "GetProcessHeap")) !=
+ nullptr) {
+ hProcessHeapHandle = pGPH();
+ LOGCONFIG(
+ "Setting Microsoft Windows' low-fragmentation heap for use as "
+ "the main process heap.");
+ pHSI(hProcessHeapHandle, HeapCompatibilityInformation, &heapFragValue,
+ sizeof(heapFragValue));
+ }
+ }
+ }
}
- if (strlen(g_sysProps->securityClientDhAlgo()) > 0) {
+#endif
+}
+} // namespace client
+} // namespace geode
+} // namespace apache
+
+DistributedSystem::DistributedSystem(
+ const std::string& name, std::unique_ptr<StatisticsManager> statMngr,
+ std::unique_ptr<SystemProperties> sysProps)
+ : m_name(name),
+ m_statisticsManager(std::move(statMngr)),
+ m_sysProps(std::move(sysProps)),
+ m_connected(false) {
+ LOGDEBUG("DistributedSystem::DistributedSystem");
+ if (strlen(m_sysProps->securityClientDhAlgo()) > 0) {
DiffieHellman::initOpenSSLFuncPtrs();
}
}
-DistributedSystem::~DistributedSystem() { GF_SAFE_DELETE_ARRAY(m_name); }
-
-DistributedSystemPtr DistributedSystem::connect(
- const char* name, const PropertiesPtr& configPtr) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> disconnectGuard(*g_disconnectLock);
- if (m_connected == true) {
- throw AlreadyConnectedException(
- "DistributedSystem::connect: already connected, call getInstance to "
- "get it");
- }
-
- // make sure statics are initialized.
- if (m_instance_ptr == nullptr) {
- m_instance_ptr = new DistributedSystemPtr();
- }
- if (g_sysProps == nullptr) {
- g_sysProps = new SystemProperties(configPtr, nullptr);
- }
- Exception::setStackTraces(g_sysProps->debugStackTraceEnabled());
-
- if (name == nullptr) {
- delete g_sysProps;
- g_sysProps = nullptr;
- throw IllegalArgumentException(
- "DistributedSystem::connect: "
- "name cannot be nullptr");
- }
- if (name[0] == '\0') {
- name = "NativeDS";
- }
-
- // Fix for Ticket#866 on NC OR SR#13306117704
- // Set client name via native client API
- const char* propName = g_sysProps->name();
- if (propName != nullptr && strlen(propName) > 0) {
- name = propName;
- }
+DistributedSystem::~DistributedSystem() {}
- // Trigger other library initialization.
- CppCacheLibrary::initLib();
-
- if (!TcrMessage::init()) {
- TcrMessage::cleanup();
- throw IllegalArgumentException(
- "DistributedSystem::connect: preallocate message buffer failed!");
- }
+void DistributedSystem::logSystemInformation() {
+ std::string gfcpp = CppCacheLibrary::getProductDir();
+ LOGCONFIG("Using Geode Native Client Product Directory: %s", gfcpp.c_str());
- const char* logFilename = g_sysProps->logFilename();
- if (logFilename != nullptr) {
- try {
- Log::close();
- Log::init(g_sysProps->logLevel(), logFilename,
- g_sysProps->logFileSizeLimit(),
- g_sysProps->logDiskSpaceLimit());
- } catch (const GeodeIOException&) {
- Log::close();
- TcrMessage::cleanup();
- CppCacheLibrary::closeLib();
- delete g_sysProps;
- g_sysProps = nullptr;
- *m_instance_ptr = nullptr;
- // delete g_disconnectLock;
- throw;
- }
- } else {
- Log::setLogLevel(g_sysProps->logLevel());
- }
-
- try {
- std::string gfcpp = CppCacheLibrary::getProductDir();
- LOGCONFIG("Using Geode Native Client Product Directory: %s", gfcpp.c_str());
- } catch (const Exception&) {
- LOGERROR(
- "Unable to determine Product Directory. Please set the "
- "GFCPP environment variable.");
- throw;
- }
// Add version information, source revision, current directory etc.
- LOGCONFIG("Product version: %s", CacheFactory::getProductDescription());
+ LOGCONFIG("Product version: %s",
+ PRODUCT_VENDOR " " PRODUCT_NAME " " PRODUCT_VERSION
+ " (" PRODUCT_BITS ") " PRODUCT_BUILDDATE);
LOGCONFIG("Source revision: %s", PRODUCT_SOURCE_REVISION);
LOGCONFIG("Source repository: %s", PRODUCT_SOURCE_REPOSITORY);
@@ -171,44 +146,90 @@ DistributedSystemPtr DistributedSystem::connect(
ld_libpath == nullptr ? "nullptr" : ld_libpath);
#endif
// Log the Geode system properties
- g_sysProps->logSettings();
+ m_sysProps->logSettings();
+}
+
+std::unique_ptr<DistributedSystem> DistributedSystem::create(
+ const std::string& _name, Cache* cache, const PropertiesPtr& configPtr) {
+ // TODO global - Refactory out the static initialization
+ // Trigger other library initialization.
+ CppCacheLibrary::initLib();
+
+ auto sysProps = std::unique_ptr<SystemProperties>(
+ new SystemProperties(configPtr, nullptr));
+
+ // TODO global - Refactor this to some process helper
+ Exception::setStackTraces(sysProps->debugStackTraceEnabled());
+
+ auto name = _name;
+ if (name.empty()) {
+ name = "NativeDS";
+ }
+
+ // Set client name via native client API
+ const char* propName = sysProps->name();
+ if (propName != nullptr && strlen(propName) > 0) {
+ name = propName;
+ }
- /* if (strlen(g_sysProps->securityClientDhAlgo())>0) {
- DiffieHellman::initDhKeys(g_sysProps->getSecurityProperties());
- }*/
+ // TODO global - keep global but setup once.
+ const char* logFilename = sysProps->logFilename();
+ if (logFilename) {
+ try {
+ Log::close();
+ Log::init(sysProps->logLevel(), logFilename, sysProps->logFileSizeLimit(),
+ sysProps->logDiskSpaceLimit());
+ } catch (const GeodeIOException&) {
+ Log::close();
+ sysProps = nullptr;
+ throw;
+ }
+ } else {
+ Log::setLogLevel(sysProps->logLevel());
+ }
+
+ try {
+ std::string gfcpp = CppCacheLibrary::getProductDir();
+ } catch (const Exception&) {
+ LOGERROR(
+ "Unable to determine Product Directory. Please set the "
+ "GFCPP environment variable.");
+ throw;
+ }
- DistributedSystemPtr dptr;
+ std::unique_ptr<StatisticsManager> statMngr;
try {
- g_statMngr = StatisticsManager::initInstance(
- g_sysProps->statisticsArchiveFile(),
- g_sysProps->statisticsSampleInterval(), g_sysProps->statisticsEnabled(),
- g_sysProps->statsFileSizeLimit(), g_sysProps->statsDiskSpaceLimit());
+ statMngr = std::unique_ptr<StatisticsManager>(new StatisticsManager(
+ sysProps->statisticsArchiveFile(), sysProps->statisticsSampleInterval(),
+ sysProps->statisticsEnabled(), cache, sysProps->durableClientId(),
+ sysProps->durableTimeout(), sysProps->statsFileSizeLimit(),
+ sysProps->statsDiskSpaceLimit()));
} catch (const NullPointerException&) {
- // close all open handles, delete whatever was newed.
- g_statMngr = nullptr;
- //:Merge issue
- /*if (strlen(g_sysProps->securityClientDhAlgo())>0) {
- DiffieHellman::clearDhKeys();
- }*/
Log::close();
- TcrMessage::cleanup();
- CppCacheLibrary::closeLib();
- delete g_sysProps;
- g_sysProps = nullptr;
- *m_instance_ptr = nullptr;
- // delete g_disconnectLock;
throw;
}
- GF_D_ASSERT(g_statMngr != nullptr);
-
- CacheImpl::expiryTaskManager = new ExpiryTaskManager();
- CacheImpl::expiryTaskManager->begin();
+ GF_D_ASSERT(m_statisticsManager != nullptr);
- DistributedSystem* dp = new DistributedSystem(name);
- if (!dp) {
+ auto distributedSystem = std::unique_ptr<DistributedSystem>(
+ new DistributedSystem(name, std::move(statMngr), std::move(sysProps)));
+ if (!distributedSystem) {
throw NullPointerException("DistributedSystem::connect: new failed");
}
- m_impl = new DistributedSystemImpl(name, dp);
+ distributedSystem->m_impl =
+ new DistributedSystemImpl(name.c_str(), distributedSystem.get());
+
+ distributedSystem->logSystemInformation();
+ LOGCONFIG("Starting the Geode Native Client");
+ return distributedSystem;
+}
+
+void DistributedSystem::connect() {
+ ACE_Guard<ACE_Recursive_Thread_Mutex> disconnectGuard(*g_disconnectLock);
+ if (m_connected == true) {
+ throw AlreadyConnectedException(
+ "DistributedSystem::connect: already connected, call getInstance to "
+ "get it");
+ }
try {
m_impl->connect();
@@ -230,16 +251,8 @@ DistributedSystemPtr DistributedSystem::connect(
}
m_connected = true;
- dptr.reset(dp);
- *m_instance_ptr = dptr;
- LOGCONFIG("Starting the Geode Native Client");
-
- return dptr;
}
-/**
- *@brief disconnect from the distributed system
- */
void DistributedSystem::disconnect() {
ACE_Guard<ACE_Recursive_Thread_Mutex> disconnectGuard(*g_disconnectLock);
@@ -249,19 +262,6 @@ void DistributedSystem::disconnect() {
"not called");
}
- try {
- CachePtr cache = CacheFactory::getAnyInstance();
- if (cache != nullptr && !cache->isClosed()) {
- cache->close();
- }
- } catch (const apache::geode::client::Exception& e) {
- LOGWARN("Exception while closing: %s: %s", e.getName(), e.getMessage());
- }
-
- if (CacheImpl::expiryTaskManager != nullptr) {
- CacheImpl::expiryTaskManager->stopExpiryTaskManager();
- }
-
if (m_impl) {
m_impl->disconnect();
delete m_impl;
@@ -270,73 +270,16 @@ void DistributedSystem::disconnect() {
LOGFINEST("Deleted DistributedSystemImpl");
- if (strlen(g_sysProps->securityClientDhAlgo()) > 0) {
- // DistributedSystem::getInstance()->m_dh->clearDhKeys();
- }
-
- // Clear DH Keys
- /* if (strlen(g_sysProps->securityClientDhAlgo())>0) {
- DiffieHellman::clearDhKeys();
- }*/
-
- GF_D_ASSERT(!!g_sysProps);
- delete g_sysProps;
- g_sysProps = nullptr;
-
- LOGFINEST("Deleted SystemProperties");
-
- if (CacheImpl::expiryTaskManager != nullptr) {
- delete CacheImpl::expiryTaskManager;
- CacheImpl::expiryTaskManager = nullptr;
- }
-
- LOGFINEST("Deleted ExpiryTaskManager");
-
- TcrMessage::cleanup();
-
- LOGFINEST("Cleaned TcrMessage");
-
- GF_D_ASSERT(!!g_statMngr);
- g_statMngr->clean();
- g_statMngr = nullptr;
-
- LOGFINEST("Cleaned StatisticsManager");
-
- RegionStatType::clean();
-
- LOGFINEST("Cleaned RegionStatType");
-
- PoolStatType::clean();
-
- LOGFINEST("Cleaned PoolStatType");
-
- *m_instance_ptr = nullptr;
-
- // Free up library resources
- CppCacheLibrary::closeLib();
-
LOGCONFIG("Stopped the Geode Native Client");
+ // TODO global - log stays global so lets move this
Log::close();
m_connected = false;
}
-SystemProperties* DistributedSystem::getSystemProperties() {
- return g_sysProps;
+SystemProperties& DistributedSystem::getSystemProperties() const {
+ return *m_sysProps;
}
-const char* DistributedSystem::getName() const { return m_name; }
-
-bool DistributedSystem::isConnected() {
- CppCacheLibrary::initLib();
- return m_connected;
-}
-
-DistributedSystemPtr DistributedSystem::getInstance() {
- CppCacheLibrary::initLib();
- if (m_instance_ptr == nullptr) {
- return nullptr;
- }
- return *m_instance_ptr;
-}
+const std::string& DistributedSystem::getName() const { return m_name; }
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/DistributedSystemImpl.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/DistributedSystemImpl.cpp b/src/cppcache/src/DistributedSystemImpl.cpp
index 6b5b08d..b562629 100644
--- a/src/cppcache/src/DistributedSystemImpl.cpp
+++ b/src/cppcache/src/DistributedSystemImpl.cpp
@@ -33,13 +33,13 @@ DistributedSystemImpl::DistributedSystemImpl(const char* name,
DistributedSystem* implementee)
: m_name(name == 0 ? "" : name), m_implementee(implementee) {
g_numInstances = 0;
- if (m_implementee->getSystemProperties()->isDhOn()) {
+ if (m_implementee->getSystemProperties().isDhOn()) {
// m_dh.initDhKeys(m_implementee->getSystemProperties()->getSecurityProperties());
}
}
DistributedSystemImpl::~DistributedSystemImpl() {
- if (m_implementee->getSystemProperties()->isDhOn()) {
+ if (m_implementee->getSystemProperties().isDhOn()) {
// m_dh.clearDhKeys();
}
g_numInstances = 0;
@@ -48,7 +48,7 @@ DistributedSystemImpl::~DistributedSystemImpl() {
AuthInitializePtr DistributedSystemImpl::getAuthLoader() {
ACE_Guard<ACE_Recursive_Thread_Mutex> authGuard(m_authLock);
- return DistributedSystem::getSystemProperties()->getAuthLoader();
+ return m_implementee->getSystemProperties().getAuthLoader();
}
void DistributedSystemImpl::connect() {}
@@ -68,46 +68,28 @@ void DistributedSystemImpl::releaseDisconnectLock() {
int DistributedSystemImpl::currentInstances() {
ACE_Guard<ACE_Recursive_Thread_Mutex> disconnectGuard(*g_disconnectLock);
- if (DistributedSystem::getInstance() != nullptr &&
- DistributedSystem::getInstance()->getSystemProperties() != nullptr &&
- !DistributedSystem::getInstance()
- ->getSystemProperties()
- ->isAppDomainEnabled()) {
- return 0;
- }
-
return g_numInstances;
}
void DistributedSystemImpl::connectInstance() {
ACE_Guard<ACE_Recursive_Thread_Mutex> disconnectGuard(*g_disconnectLock);
- if (DistributedSystem::getInstance()->getSystemProperties() != nullptr &&
- DistributedSystem::getInstance()
- ->getSystemProperties()
- ->isAppDomainEnabled()) {
- g_numInstances++;
- }
+ g_numInstances++;
}
void DistributedSystemImpl::disconnectInstance() {
ACE_Guard<ACE_Recursive_Thread_Mutex> disconnectGuard(*g_disconnectLock);
- if (DistributedSystem::getInstance()->getSystemProperties() != nullptr &&
- DistributedSystem::getInstance()
- ->getSystemProperties()
- ->isAppDomainEnabled()) {
- g_numInstances--;
- }
+ g_numInstances--;
}
-void DistributedSystemImpl::CallCliCallBack() {
+void DistributedSystemImpl::CallCliCallBack(Cache& cache) {
ACE_Guard<ACE_Recursive_Thread_Mutex> disconnectGuard(m_cliCallbackLock);
if (m_isCliCallbackSet == true) {
for (std::map<int, CliCallbackMethod>::iterator iter =
m_cliCallbackMap.begin();
iter != m_cliCallbackMap.end(); ++iter) {
- (*iter).second();
+ (*iter).second(cache);
}
}
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/DistributedSystemImpl.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/DistributedSystemImpl.hpp b/src/cppcache/src/DistributedSystemImpl.hpp
index 404c151..5352263 100644
--- a/src/cppcache/src/DistributedSystemImpl.hpp
+++ b/src/cppcache/src/DistributedSystemImpl.hpp
@@ -126,7 +126,7 @@ class CPPCACHE_EXPORT DistributedSystemImpl {
static void unregisterCliCallback(int appdomainId);
- static void CallCliCallBack();
+ static void CallCliCallBack(Cache& cache);
private:
/**
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/EntriesMap.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/EntriesMap.hpp b/src/cppcache/src/EntriesMap.hpp
index a6cea61..c057aa5 100644
--- a/src/cppcache/src/EntriesMap.hpp
+++ b/src/cppcache/src/EntriesMap.hpp
@@ -22,6 +22,8 @@
// This needs to be ace free so that the region can include it.
+#include <memory>
+
#include <geode/geode_globals.hpp>
#include "MapEntry.hpp"
#include <geode/CacheableKey.hpp>
@@ -40,7 +42,7 @@ namespace client {
*/
class CPPCACHE_EXPORT EntriesMap {
public:
- EntriesMap(EntryFactory* entryFactory) : m_entryFactory(entryFactory) {}
+ EntriesMap(std::unique_ptr<EntryFactory> entryFactory) : m_entryFactory(std::move(entryFactory)) {}
virtual ~EntriesMap() {}
/**
@@ -168,10 +170,10 @@ class CPPCACHE_EXPORT EntriesMap {
static bool boolVal;
protected:
- EntryFactory* m_entryFactory;
+ const std::unique_ptr<EntryFactory> m_entryFactory;
/** @brief return the instance of EntryFactory for the segments to use. */
- inline const EntryFactory* getEntryFactory() const { return m_entryFactory; }
+ inline const EntryFactory* getEntryFactory() const { return m_entryFactory.get(); }
}; // class EntriesMap
} // namespace client
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/EntriesMapFactory.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/EntriesMapFactory.cpp b/src/cppcache/src/EntriesMapFactory.cpp
index 99213dd..b8e3254 100644
--- a/src/cppcache/src/EntriesMapFactory.cpp
+++ b/src/cppcache/src/EntriesMapFactory.cpp
@@ -44,45 +44,51 @@ EntriesMap* EntriesMapFactory::createMap(RegionInternal* region,
bool concurrencyChecksEnabled = attrs->getConcurrencyChecksEnabled();
bool heapLRUEnabled = false;
- SystemProperties* prop = DistributedSystem::getSystemProperties();
- if ((lruLimit != 0) ||
- (prop && prop->heapLRULimitEnabled())) { // create LRU map...
+ auto cache = region->getCacheImpl();
+ auto& prop = cache->getDistributedSystem().getSystemProperties();
+ auto& expiryTaskmanager = cache->getExpiryTaskManager();
+
+ if ((lruLimit != 0) || (prop.heapLRULimitEnabled())) { // create LRU map...
LRUAction::Action lruEvictionAction;
DiskPolicyType::PolicyType dpType = attrs->getDiskPolicy();
if (dpType == DiskPolicyType::OVERFLOWS) {
lruEvictionAction = LRUAction::OVERFLOW_TO_DISK;
} else if ((dpType == DiskPolicyType::NONE) ||
- (prop && prop->heapLRULimitEnabled())) {
+ (prop.heapLRULimitEnabled())) {
lruEvictionAction = LRUAction::LOCAL_DESTROY;
- if (prop && prop->heapLRULimitEnabled()) heapLRUEnabled = true;
+ if (prop.heapLRULimitEnabled()) heapLRUEnabled = true;
} else {
return nullptr;
}
if (ttl != 0 || idle != 0) {
- EntryFactory* entryFactory = LRUExpEntryFactory::singleton;
- entryFactory->setConcurrencyChecksEnabled(concurrencyChecksEnabled);
- result = new LRUEntriesMap(entryFactory, region, lruEvictionAction,
- lruLimit, concurrencyChecksEnabled,
- concurrency, heapLRUEnabled);
+ result = new LRUEntriesMap(
+ &expiryTaskmanager,
+ std::unique_ptr<LRUExpEntryFactory>(
+ new LRUExpEntryFactory(concurrencyChecksEnabled)),
+ region, lruEvictionAction, lruLimit, concurrencyChecksEnabled,
+ concurrency, heapLRUEnabled);
} else {
- EntryFactory* entryFactory = LRUEntryFactory::singleton;
- entryFactory->setConcurrencyChecksEnabled(concurrencyChecksEnabled);
- result = new LRUEntriesMap(entryFactory, region, lruEvictionAction,
- lruLimit, concurrencyChecksEnabled,
- concurrency, heapLRUEnabled);
+ result = new LRUEntriesMap(
+ &expiryTaskmanager,
+ std::unique_ptr<LRUEntryFactory>(
+ new LRUEntryFactory(concurrencyChecksEnabled)),
+ region, lruEvictionAction, lruLimit, concurrencyChecksEnabled,
+ concurrency, heapLRUEnabled);
}
} else if (ttl != 0 || idle != 0) {
// create entries with a ExpEntryFactory.
- EntryFactory* entryFactory = ExpEntryFactory::singleton;
- entryFactory->setConcurrencyChecksEnabled(concurrencyChecksEnabled);
- result = new ConcurrentEntriesMap(entryFactory, concurrencyChecksEnabled,
- region, concurrency);
+ result = new ConcurrentEntriesMap(
+ &expiryTaskmanager,
+ std::unique_ptr<ExpEntryFactory>(
+ new ExpEntryFactory(concurrencyChecksEnabled)),
+ concurrencyChecksEnabled, region, concurrency);
} else {
// create plain concurrent map.
- EntryFactory* entryFactory = EntryFactory::singleton;
- entryFactory->setConcurrencyChecksEnabled(concurrencyChecksEnabled);
- result = new ConcurrentEntriesMap(entryFactory, concurrencyChecksEnabled,
- region, concurrency);
+ result = new ConcurrentEntriesMap(
+ &expiryTaskmanager,
+ std::unique_ptr<EntryFactory>(
+ new EntryFactory(concurrencyChecksEnabled)),
+ concurrencyChecksEnabled, region, concurrency);
}
result->open(initialCapacity);
return result;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/EntryExpiryHandler.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/EntryExpiryHandler.cpp b/src/cppcache/src/EntryExpiryHandler.cpp
index 31ef91c..fec863d 100644
--- a/src/cppcache/src/EntryExpiryHandler.cpp
+++ b/src/cppcache/src/EntryExpiryHandler.cpp
@@ -68,7 +68,8 @@ int EntryExpiryHandler::handle_timeout(const ACE_Time_Value& current_time,
"[%s]",
-sec, Utils::getCacheableKeyString(key)->asChar(),
m_regionPtr->getFullPath());
- CacheImpl::expiryTaskManager->resetTask(expProps.getExpiryTaskId(), -sec);
+ m_regionPtr->getCacheImpl()->getExpiryTaskManager().resetTask(
+ expProps.getExpiryTaskId(), -sec);
return 0;
}
} catch (...) {
@@ -77,7 +78,8 @@ int EntryExpiryHandler::handle_timeout(const ACE_Time_Value& current_time,
LOGDEBUG("Removing expiry task for key [%s] of region [%s]",
Utils::getCacheableKeyString(key)->asChar(),
m_regionPtr->getFullPath());
- CacheImpl::expiryTaskManager->resetTask(expProps.getExpiryTaskId(), 0);
+ m_regionPtr->getCacheImpl()->getExpiryTaskManager().resetTask(
+ expProps.getExpiryTaskId(), 0);
// we now delete the handler in GF_Timer_Heap_ImmediateReset_T
// and always return success.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ExecutionImpl.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ExecutionImpl.cpp b/src/cppcache/src/ExecutionImpl.cpp
index 3a9e1b1..cfe45cd 100644
--- a/src/cppcache/src/ExecutionImpl.cpp
+++ b/src/cppcache/src/ExecutionImpl.cpp
@@ -371,7 +371,11 @@ GfErrType ExecutionImpl::getFuncAttributes(const char* func,
// do TCR GET_FUNCTION_ATTRIBUTES
LOGDEBUG("Tcrmessage request GET_FUNCTION_ATTRIBUTES ");
std::string funcName(func);
- TcrMessageGetFunctionAttributes request(funcName, tcrdm);
+ TcrMessageGetFunctionAttributes request(tcrdm->getConnectionManager()
+ .getCacheImpl()
+ ->getCache()
+ ->createDataOutput(),
+ funcName, tcrdm);
TcrMessageReply reply(true, tcrdm);
err = tcrdm->sendSyncRequest(request, reply);
if (err != GF_NOERR) {
@@ -483,7 +487,11 @@ CacheableVectorPtr ExecutionImpl::executeOnPool(std::string& func,
while (attempt <= retryAttempts) {
std::string funcName(func);
- TcrMessageExecuteFunction msg(funcName, m_args, getResult, tcrdm, timeout);
+ TcrMessageExecuteFunction msg(tcrdm->getConnectionManager()
+ .getCacheImpl()
+ ->getCache()
+ ->createDataOutput(),
+ funcName, m_args, getResult, tcrdm, timeout);
TcrMessageReply reply(true, tcrdm);
ChunkedFunctionExecutionResponse* resultCollector(
new ChunkedFunctionExecutionResponse(reply, (getResult & 2), m_rc));
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ExpMapEntry.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ExpMapEntry.cpp b/src/cppcache/src/ExpMapEntry.cpp
index 22ef261..f3db017 100644
--- a/src/cppcache/src/ExpMapEntry.cpp
+++ b/src/cppcache/src/ExpMapEntry.cpp
@@ -14,23 +14,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#include "ExpMapEntry.hpp"
#include "MapEntryT.hpp"
-using namespace apache::geode::client;
-
-ExpEntryFactory* ExpEntryFactory::singleton = nullptr;
+namespace apache {
+namespace geode {
+namespace client {
-/**
- * @brief called when library is initialized... see CppCacheLibrary.
- */
-void ExpEntryFactory::init() { singleton = new ExpEntryFactory(); }
-
-void ExpEntryFactory::newMapEntry(const CacheableKeyPtr& key,
+void ExpEntryFactory::newMapEntry(ExpiryTaskManager* expiryTaskManager,
+ const CacheableKeyPtr& key,
MapEntryImplPtr& result) const {
if (m_concurrencyChecksEnabled) {
- result = MapEntryT<VersionedExpMapEntry, 0, 0>::create(key);
+ result =
+ MapEntryT<VersionedExpMapEntry, 0, 0>::create(expiryTaskManager, key);
} else {
- result = MapEntryT<ExpMapEntry, 0, 0>::create(key);
+ result = MapEntryT<ExpMapEntry, 0, 0>::create(expiryTaskManager, key);
}
}
+
+} // namespace client
+} // namespace geode
+} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ExpMapEntry.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ExpMapEntry.hpp b/src/cppcache/src/ExpMapEntry.hpp
index 823ee39..a307222 100644
--- a/src/cppcache/src/ExpMapEntry.hpp
+++ b/src/cppcache/src/ExpMapEntry.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_EXPMAPENTRY_H_
-#define GEODE_EXPMAPENTRY_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,6 +15,11 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_EXPMAPENTRY_H_
+#define GEODE_EXPMAPENTRY_H_
+
#include <geode/geode_globals.hpp>
#include "MapEntry.hpp"
#include "VersionStamp.hpp"
@@ -49,7 +49,9 @@ class CPPCACHE_EXPORT ExpMapEntry : public MapEntryImpl,
inline explicit ExpMapEntry(bool noInit)
: MapEntryImpl(true), ExpEntryProperties(true) {}
- inline ExpMapEntry(const CacheableKeyPtr& key) : MapEntryImpl(key) {}
+ inline ExpMapEntry(ExpiryTaskManager* expiryTaskManager,
+ const CacheableKeyPtr& key)
+ : MapEntryImpl(key), ExpEntryProperties(expiryTaskManager) {}
private:
// disabled
@@ -69,7 +71,9 @@ class CPPCACHE_EXPORT VersionedExpMapEntry : public ExpMapEntry,
protected:
inline explicit VersionedExpMapEntry(bool noInit) : ExpMapEntry(true) {}
- inline VersionedExpMapEntry(const CacheableKeyPtr& key) : ExpMapEntry(key) {}
+ inline VersionedExpMapEntry(ExpiryTaskManager* expiryTaskManager,
+ const CacheableKeyPtr& key)
+ : ExpMapEntry(expiryTaskManager, key) {}
private:
// disabled
@@ -81,14 +85,12 @@ typedef std::shared_ptr<VersionedExpMapEntry> VersionedExpMapEntryPtr;
class CPPCACHE_EXPORT ExpEntryFactory : public EntryFactory {
public:
- static ExpEntryFactory* singleton;
- static void init();
-
- ExpEntryFactory() {}
+ using EntryFactory::EntryFactory;
virtual ~ExpEntryFactory() {}
- virtual void newMapEntry(const CacheableKeyPtr& key,
+ virtual void newMapEntry(ExpiryTaskManager* expiryTaskManager,
+ const CacheableKeyPtr& key,
MapEntryImplPtr& result) const;
};
} // namespace client
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/FarSideEntryOp.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/FarSideEntryOp.cpp b/src/cppcache/src/FarSideEntryOp.cpp
index 6ed18f9..e17c677 100644
--- a/src/cppcache/src/FarSideEntryOp.cpp
+++ b/src/cppcache/src/FarSideEntryOp.cpp
@@ -30,7 +30,8 @@ namespace apache {
namespace geode {
namespace client {
-FarSideEntryOp::FarSideEntryOp(RegionCommit* region)
+FarSideEntryOp::FarSideEntryOp(
+ RegionCommit* region, MemberListForVersionStamp& memberListForVersionStamp)
: // UNUSED m_region(region),
/* adongre
*
@@ -38,7 +39,8 @@ FarSideEntryOp::FarSideEntryOp(RegionCommit* region)
m_op(0),
m_modSerialNum(0),
m_eventOffset(0),
- m_didDestroy(false)
+ m_didDestroy(false),
+ m_memberListForVersionStamp(memberListForVersionStamp)
{}
@@ -73,7 +75,8 @@ void FarSideEntryOp::fromData(DataInput& input, bool largeModCount,
}
skipFilterRoutingInfo(input);
- m_versionTag = TcrMessage::readVersionTagPart(input, memId);
+ m_versionTag =
+ TcrMessage::readVersionTagPart(input, memId, m_memberListForVersionStamp);
// SerializablePtr sPtr;
// input.readObject(sPtr);
input.readInt(&m_eventOffset);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/FarSideEntryOp.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/FarSideEntryOp.hpp b/src/cppcache/src/FarSideEntryOp.hpp
index 043e905..ab4063a 100644
--- a/src/cppcache/src/FarSideEntryOp.hpp
+++ b/src/cppcache/src/FarSideEntryOp.hpp
@@ -94,7 +94,8 @@ _GF_PTR_DEF_(FarSideEntryOp, FarSideEntryOpPtr);
class FarSideEntryOp {
public:
- FarSideEntryOp(RegionCommit* region);
+ FarSideEntryOp(RegionCommit* region,
+ MemberListForVersionStamp& memberListForVersionStamp);
virtual ~FarSideEntryOp();
void fromData(DataInput& input, bool largeModCount, uint16_t memId);
@@ -115,6 +116,7 @@ class FarSideEntryOp {
bool m_didDestroy;
UserDataPtr m_callbackArg;
VersionTagPtr m_versionTag;
+ MemberListForVersionStamp& m_memberListForVersionStamp;
// FilterRoutingInfo filterRoutingInfo;
bool isDestroy(int8_t op);
bool isInvalidate(int8_t op);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/FunctionService.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/FunctionService.cpp b/src/cppcache/src/FunctionService.cpp
index c785836..a392586 100644
--- a/src/cppcache/src/FunctionService.cpp
+++ b/src/cppcache/src/FunctionService.cpp
@@ -16,12 +16,14 @@
*/
#include <geode/FunctionService.hpp>
#include <geode/ExceptionTypes.hpp>
-#include <ExecutionImpl.hpp>
-#include <ProxyRegion.hpp>
-#include <UserAttributes.hpp>
-#include <ProxyCache.hpp>
#include <geode/PoolManager.hpp>
-#include <CacheRegionHelper.hpp>
+
+#include "CacheRegionHelper.hpp"
+#include "ExecutionImpl.hpp"
+#include "ProxyRegion.hpp"
+#include "UserAttributes.hpp"
+#include "ProxyCache.hpp"
+#include "CacheImpl.hpp"
using namespace apache::geode::client;
@@ -45,7 +47,8 @@ ExecutionPtr FunctionService::onRegion(RegionPtr region) {
// it is in multiuser mode
proxyCache = pr->m_proxyCache;
PoolPtr userAttachedPool = proxyCache->m_userAttributes->getPool();
- PoolPtr pool = PoolManager::find(userAttachedPool->getName());
+ PoolPtr pool = region->getCache()->getPoolManager().find(
+ userAttachedPool->getName());
if (!(pool != nullptr && pool.get() == userAttachedPool.get() &&
!pool->isDestroyed())) {
throw IllegalStateException(
@@ -54,9 +57,9 @@ ExecutionPtr FunctionService::onRegion(RegionPtr region) {
RegionPtr tmpRegion;
tmpRegion = nullptr;
// getting real region to execute function on region
- if (!CacheFactory::getAnyInstance()->isClosed()) {
- CacheRegionHelper::getCacheImpl(CacheFactory::getAnyInstance().get())
- ->getRegion(region->getName(), tmpRegion);
+ if (!region->getCache()->isClosed()) {
+ region->getCache()->m_cacheImpl->getRegion(region->getName(),
+ tmpRegion);
} else {
throw IllegalStateException("Cache has been closed");
}
@@ -109,7 +112,8 @@ ExecutionPtr FunctionService::onServerWithCache(const RegionServicePtr& cache) {
LOGDEBUG("FunctionService::onServer:");
if (pc != nullptr) {
PoolPtr userAttachedPool = pc->m_userAttributes->getPool();
- PoolPtr pool = PoolManager::find(userAttachedPool->getName());
+ PoolPtr pool =
+ pc->m_cacheImpl->getPoolManager().find(userAttachedPool->getName());
if (pool != nullptr && pool.get() == userAttachedPool.get() &&
!pool->isDestroyed()) {
return std::make_shared<ExecutionImpl>(pool, false, pc);
@@ -118,7 +122,8 @@ ExecutionPtr FunctionService::onServerWithCache(const RegionServicePtr& cache) {
"Pool has been close to execute function on server");
} else {
CachePtr realcache = std::static_pointer_cast<Cache>(cache);
- return FunctionService::onServer(realcache->m_cacheImpl->getDefaultPool());
+ return FunctionService::onServer(
+ realcache->m_cacheImpl->getPoolManager().getDefaultPool());
}
}
@@ -133,7 +138,8 @@ ExecutionPtr FunctionService::onServersWithCache(
LOGDEBUG("FunctionService::onServers:");
if (pc != nullptr && !cache->isClosed()) {
auto userAttachedPool = pc->m_userAttributes->getPool();
- auto pool = PoolManager::find(userAttachedPool->getName());
+ auto pool = pc->m_cacheImpl->getCache()->getPoolManager().find(
+ userAttachedPool->getName());
if (pool != nullptr && pool.get() == userAttachedPool.get() &&
!pool->isDestroyed()) {
return std::make_shared<ExecutionImpl>(pool, true, pc);
@@ -142,6 +148,7 @@ ExecutionPtr FunctionService::onServersWithCache(
"Pool has been close to execute function on server");
} else {
auto realcache = std::static_pointer_cast<Cache>(cache);
- return FunctionService::onServers(realcache->m_cacheImpl->getDefaultPool());
+ return FunctionService::onServers(
+ realcache->m_cacheImpl->getPoolManager().getDefaultPool());
}
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/InternalCacheTransactionManager2PCImpl.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/InternalCacheTransactionManager2PCImpl.cpp b/src/cppcache/src/InternalCacheTransactionManager2PCImpl.cpp
index 5a01dff..b24c898 100644
--- a/src/cppcache/src/InternalCacheTransactionManager2PCImpl.cpp
+++ b/src/cppcache/src/InternalCacheTransactionManager2PCImpl.cpp
@@ -66,6 +66,10 @@ void InternalCacheTransactionManager2PCImpl::prepare() {
}
TcrMessageTxSynchronization requestCommitBefore(
+ tcr_dm->getConnectionManager()
+ .getCacheImpl()
+ ->getCache()
+ ->createDataOutput(),
BEFORE_COMMIT, txState->getTransactionId()->getId(), STATUS_COMMITTED);
TcrMessageReply replyCommitBefore(true, nullptr);
@@ -161,6 +165,10 @@ void InternalCacheTransactionManager2PCImpl::afterCompletion(int32_t status) {
TXCleaner txCleaner(this);
TcrMessageTxSynchronization requestCommitAfter(
+ tcr_dm->getConnectionManager()
+ .getCacheImpl()
+ ->getCache()
+ ->createDataOutput(),
AFTER_COMMIT, txState->getTransactionId()->getId(), status);
TcrMessageReply replyCommitAfter(true, nullptr);
@@ -172,9 +180,8 @@ void InternalCacheTransactionManager2PCImpl::afterCompletion(int32_t status) {
} else {
switch (replyCommitAfter.getMessageType()) {
case TcrMessage::RESPONSE: {
- TXCommitMessagePtr commit =
- std::static_pointer_cast<TXCommitMessage>(
- replyCommitAfter.getValue());
+ TXCommitMessagePtr commit = std::static_pointer_cast<TXCommitMessage>(
+ replyCommitAfter.getValue());
if (commit.get() !=
nullptr) // e.g. when afterCompletion(STATUS_ROLLEDBACK) called
{
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/LRUAction.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/LRUAction.cpp b/src/cppcache/src/LRUAction.cpp
index 6abb9ee..8c3e74d 100644
--- a/src/cppcache/src/LRUAction.cpp
+++ b/src/cppcache/src/LRUAction.cpp
@@ -87,7 +87,7 @@ bool LRUOverFlowToDiskAction::evict(const MapEntryImplPtr& mePtr) {
lruProps.setPersistenceInfo(persistenceInfo);
}
(m_regionPtr->getRegionStats())->incOverflows();
- (m_regionPtr->getCacheImpl())->m_cacheStats->incOverflows();
+ (m_regionPtr->getCacheImpl())->getCachePerfStats().incOverflows();
// set value after write on disk to indicate that it is on disk.
mePtr->setValueI(CacheableToken::overflowed());
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/LRUEntriesMap.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/LRUEntriesMap.cpp b/src/cppcache/src/LRUEntriesMap.cpp
index 5ecefec..34348db 100644
--- a/src/cppcache/src/LRUEntriesMap.cpp
+++ b/src/cppcache/src/LRUEntriesMap.cpp
@@ -52,13 +52,15 @@ class CPPCACHE_EXPORT TestMapAction : public virtual LRUAction {
friend class LRUAction;
};
-LRUEntriesMap::LRUEntriesMap(EntryFactory* entryFactory, RegionInternal* region,
+LRUEntriesMap::LRUEntriesMap(ExpiryTaskManager* expiryTaskManager,
+ std::unique_ptr<EntryFactory> entryFactory,
+ RegionInternal* region,
const LRUAction::Action& lruAction,
const uint32_t limit,
bool concurrencyChecksEnabled,
const uint8_t concurrency, bool heapLRUEnabled)
- : ConcurrentEntriesMap(entryFactory, concurrencyChecksEnabled, region,
- concurrency),
+ : ConcurrentEntriesMap(expiryTaskManager, std::move(entryFactory),
+ concurrencyChecksEnabled, region, concurrency),
m_lruList(),
m_limit(limit),
m_pmPtr(nullptr),
@@ -396,7 +398,7 @@ bool LRUEntriesMap::get(const CacheableKeyPtr& key, CacheablePtr& returnPtr,
return false;
}
m_region->getRegionStats()->incRetrieves();
- m_region->getCacheImpl()->m_cacheStats->incRetrieves();
+ m_region->getCacheImpl()->getCachePerfStats().incRetrieves();
returnPtr = tmpObj;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/LRUEntriesMap.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/LRUEntriesMap.hpp b/src/cppcache/src/LRUEntriesMap.hpp
index 498bd90..0c86abe 100644
--- a/src/cppcache/src/LRUEntriesMap.hpp
+++ b/src/cppcache/src/LRUEntriesMap.hpp
@@ -73,10 +73,11 @@ class CPPCACHE_EXPORT LRUEntriesMap : public ConcurrentEntriesMap,
bool m_heapLRUEnabled;
public:
- LRUEntriesMap(EntryFactory* entryFactory, RegionInternal* region,
- const LRUAction::Action& lruAction, const uint32_t limit,
- bool concurrencyChecksEnabled, const uint8_t concurrency = 16,
- bool heapLRUEnabled = false);
+ LRUEntriesMap(ExpiryTaskManager* expiryTaskManager,
+ std::unique_ptr<EntryFactory> entryFactory,
+ RegionInternal* region, const LRUAction::Action& lruAction,
+ const uint32_t limit, bool concurrencyChecksEnabled,
+ const uint8_t concurrency = 16, bool heapLRUEnabled = false);
virtual ~LRUEntriesMap();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/LRUExpMapEntry.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/LRUExpMapEntry.cpp b/src/cppcache/src/LRUExpMapEntry.cpp
index e3213cc..66aface 100644
--- a/src/cppcache/src/LRUExpMapEntry.cpp
+++ b/src/cppcache/src/LRUExpMapEntry.cpp
@@ -14,23 +14,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#include "LRUExpMapEntry.hpp"
#include "MapEntryT.hpp"
-using namespace apache::geode::client;
-
-LRUExpEntryFactory* LRUExpEntryFactory::singleton = nullptr;
+namespace apache {
+namespace geode {
+namespace client {
-/**
- * @brief called when library is initialized... see CppCacheLibrary.
- */
-void LRUExpEntryFactory::init() { singleton = new LRUExpEntryFactory(); }
-
-void LRUExpEntryFactory::newMapEntry(const CacheableKeyPtr& key,
+void LRUExpEntryFactory::newMapEntry(ExpiryTaskManager* expiryTaskManager,
+ const CacheableKeyPtr& key,
MapEntryImplPtr& result) const {
if (m_concurrencyChecksEnabled) {
- result = MapEntryT<VersionedLRUExpMapEntry, 0, 0>::create(key);
+ result = MapEntryT<VersionedLRUExpMapEntry, 0, 0>::create(expiryTaskManager,
+ key);
} else {
- result = MapEntryT<LRUExpMapEntry, 0, 0>::create(key);
+ result = MapEntryT<LRUExpMapEntry, 0, 0>::create(expiryTaskManager, key);
}
}
+
+} // namespace client
+} // namespace geode
+} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/LRUExpMapEntry.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/LRUExpMapEntry.hpp b/src/cppcache/src/LRUExpMapEntry.hpp
index 98271e2..3617909 100644
--- a/src/cppcache/src/LRUExpMapEntry.hpp
+++ b/src/cppcache/src/LRUExpMapEntry.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_LRUEXPMAPENTRY_H_
-#define GEODE_LRUEXPMAPENTRY_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,6 +15,11 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_LRUEXPMAPENTRY_H_
+#define GEODE_LRUEXPMAPENTRY_H_
+
#include <geode/geode_globals.hpp>
#include "MapEntry.hpp"
#include "LRUList.hpp"
@@ -53,7 +53,9 @@ class CPPCACHE_EXPORT LRUExpMapEntry : public MapEntryImpl,
LRUEntryProperties(true),
ExpEntryProperties(true) {}
- inline LRUExpMapEntry(const CacheableKeyPtr& key) : MapEntryImpl(key) {}
+ inline LRUExpMapEntry(ExpiryTaskManager* expiryTaskManager,
+ const CacheableKeyPtr& key)
+ : MapEntryImpl(key), ExpEntryProperties(expiryTaskManager) {}
private:
// disabled
@@ -73,8 +75,9 @@ class CPPCACHE_EXPORT VersionedLRUExpMapEntry : public LRUExpMapEntry,
protected:
inline explicit VersionedLRUExpMapEntry(bool noInit) : LRUExpMapEntry(true) {}
- inline VersionedLRUExpMapEntry(const CacheableKeyPtr& key)
- : LRUExpMapEntry(key) {}
+ inline VersionedLRUExpMapEntry(ExpiryTaskManager* expiryTaskManager,
+ const CacheableKeyPtr& key)
+ : LRUExpMapEntry(expiryTaskManager, key) {}
private:
// disabled
@@ -86,14 +89,12 @@ typedef std::shared_ptr<VersionedLRUExpMapEntry> VersionedLRUExpMapEntryPtr;
class CPPCACHE_EXPORT LRUExpEntryFactory : public EntryFactory {
public:
- static LRUExpEntryFactory* singleton;
- static void init();
-
- LRUExpEntryFactory() {}
+ using EntryFactory::EntryFactory;
virtual ~LRUExpEntryFactory() {}
- virtual void newMapEntry(const CacheableKeyPtr& key,
+ virtual void newMapEntry(ExpiryTaskManager* expiryTaskManager,
+ const CacheableKeyPtr& key,
MapEntryImplPtr& result) const;
};
} // namespace client
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/LRUMapEntry.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/LRUMapEntry.cpp b/src/cppcache/src/LRUMapEntry.cpp
index 8cae083..ed060e3 100644
--- a/src/cppcache/src/LRUMapEntry.cpp
+++ b/src/cppcache/src/LRUMapEntry.cpp
@@ -14,19 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#include "LRUMapEntry.hpp"
#include "MapEntryT.hpp"
-using namespace apache::geode::client;
-
-LRUEntryFactory* LRUEntryFactory::singleton = nullptr;
+namespace apache {
+namespace geode {
+namespace client {
-/**
- * @brief called when library is initialized... see CppCacheLibrary.
- */
-void LRUEntryFactory::init() { singleton = new LRUEntryFactory(); }
-
-void LRUEntryFactory::newMapEntry(const CacheableKeyPtr& key,
+void LRUEntryFactory::newMapEntry(ExpiryTaskManager* expiryTaskManager,
+ const CacheableKeyPtr& key,
MapEntryImplPtr& result) const {
if (m_concurrencyChecksEnabled) {
result = MapEntryT<VersionedLRUMapEntry, 0, 0>::create(key);
@@ -34,3 +31,7 @@ void LRUEntryFactory::newMapEntry(const CacheableKeyPtr& key,
result = MapEntryT<LRUMapEntry, 0, 0>::create(key);
}
}
+
+} // namespace client
+} // namespace geode
+} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/LRUMapEntry.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/LRUMapEntry.hpp b/src/cppcache/src/LRUMapEntry.hpp
index 2ab14d5..3520a4a 100644
--- a/src/cppcache/src/LRUMapEntry.hpp
+++ b/src/cppcache/src/LRUMapEntry.hpp
@@ -110,14 +110,12 @@ typedef std::shared_ptr<VersionedLRUMapEntry> VersionedLRUMapEntryPtr;
class CPPCACHE_EXPORT LRUEntryFactory : public EntryFactory {
public:
- static LRUEntryFactory* singleton;
- static void init();
-
- LRUEntryFactory() {}
+ using EntryFactory::EntryFactory;
virtual ~LRUEntryFactory() {}
- virtual void newMapEntry(const CacheableKeyPtr& key,
+ virtual void newMapEntry(ExpiryTaskManager* expiryTaskManager,
+ const CacheableKeyPtr& key,
MapEntryImplPtr& result) const;
};
} // namespace client
[04/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/test/DataOutputTest.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/test/DataOutputTest.cpp b/src/cppcache/test/DataOutputTest.cpp
index a3af420..48a8936 100644
--- a/src/cppcache/test/DataOutputTest.cpp
+++ b/src/cppcache/test/DataOutputTest.cpp
@@ -22,13 +22,19 @@
#include <gtest/gtest.h>
#include <geode/DataOutput.hpp>
+#include <geode/CacheFactory.hpp>
#include "ByteArrayFixture.hpp"
+#include "DataOutputInternal.hpp"
+#include "SerializationRegistry.hpp"
+
+namespace {
using namespace apache::geode::client;
-class TestDataOutput : public DataOutput {
+class TestDataOutput : public DataOutputInternal {
public:
- TestDataOutput() : m_byteArray(nullptr) {
+ TestDataOutput(Cache* cache)
+ : DataOutputInternal(cache), m_byteArray(nullptr), m_serializationRegistry() {
// NOP
}
@@ -44,8 +50,15 @@ class TestDataOutput : public DataOutput {
return *m_byteArray;
}
+ protected:
+ virtual const SerializationRegistry& getSerializationRegistry()
+ const override {
+ return m_serializationRegistry;
+ }
+
private:
mutable ByteArray* m_byteArray;
+ SerializationRegistry m_serializationRegistry;
};
class DataOutputTest : public ::testing::Test, public ByteArrayFixture {
@@ -77,21 +90,21 @@ class DataOutputTest : public ::testing::Test, public ByteArrayFixture {
};
TEST_F(DataOutputTest, TestWriteUint8) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
dataOutput.write(static_cast<uint8_t>(55U));
dataOutput.write(static_cast<uint8_t>(66U));
EXPECT_BYTEARRAY_EQ("3742", dataOutput.getByteArray());
}
TEST_F(DataOutputTest, TestWriteInt8) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
dataOutput.write(static_cast<int8_t>(66));
dataOutput.write(static_cast<int8_t>(55));
EXPECT_BYTEARRAY_EQ("4237", dataOutput.getByteArray());
}
TEST_F(DataOutputTest, TestWriteSequenceNumber) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
dataOutput.writeInt((int32_t)55);
dataOutput.writeInt((int32_t)17);
dataOutput.writeInt((int32_t)0);
@@ -102,7 +115,7 @@ TEST_F(DataOutputTest, TestWriteSequenceNumber) {
}
TEST_F(DataOutputTest, TestWriteBoolean) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
dataOutput.writeBoolean(true);
dataOutput.writeBoolean(false);
EXPECT_BYTEARRAY_EQ("0100", dataOutput.getByteArray());
@@ -111,7 +124,7 @@ TEST_F(DataOutputTest, TestWriteBoolean) {
TEST_F(DataOutputTest, TestWriteBytesSigned) {
int8_t bytes[] = {0, 1, 2, 3, 4, 5, -4, -3, -2, -1, 0};
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
dataOutput.writeBytes(bytes, 11);
EXPECT_BYTEARRAY_EQ("0B000102030405FCFDFEFF00", dataOutput.getByteArray());
}
@@ -119,7 +132,7 @@ TEST_F(DataOutputTest, TestWriteBytesSigned) {
TEST_F(DataOutputTest, TestWriteBytesOnlyUnsigned) {
uint8_t bytes[] = {0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0};
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
dataOutput.writeBytesOnly(bytes, 11);
EXPECT_BYTEARRAY_EQ("0001020304050403020100", dataOutput.getByteArray());
}
@@ -127,13 +140,13 @@ TEST_F(DataOutputTest, TestWriteBytesOnlyUnsigned) {
TEST_F(DataOutputTest, TestWriteBytesOnlySigned) {
int8_t bytes[] = {0, 1, 2, 3, 4, 5, -4, -3, -2, -1, 0};
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
dataOutput.writeBytesOnly(bytes, 11);
EXPECT_BYTEARRAY_EQ("000102030405FCFDFEFF00", dataOutput.getByteArray());
}
TEST_F(DataOutputTest, TestWriteIntUInt16) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
dataOutput.writeInt(static_cast<uint16_t>(66));
dataOutput.writeInt(static_cast<uint16_t>(55));
dataOutput.writeInt(static_cast<uint16_t>(3333));
@@ -141,7 +154,7 @@ TEST_F(DataOutputTest, TestWriteIntUInt16) {
}
TEST_F(DataOutputTest, TestWriteCharUInt16) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
dataOutput.writeChar(static_cast<uint16_t>(66));
dataOutput.writeChar(static_cast<uint16_t>(55));
dataOutput.writeChar(static_cast<uint16_t>(3333));
@@ -149,20 +162,20 @@ TEST_F(DataOutputTest, TestWriteCharUInt16) {
}
TEST_F(DataOutputTest, TestWriteIntUInt32) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
dataOutput.writeInt(static_cast<uint32_t>(3435973836));
EXPECT_BYTEARRAY_EQ("CCCCCCCC", dataOutput.getByteArray());
}
TEST_F(DataOutputTest, TestWriteIntUInt64) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
uint64_t big = 13455272147882261178U;
dataOutput.writeInt(big);
EXPECT_BYTEARRAY_EQ("BABABABABABABABA", dataOutput.getByteArray());
}
TEST_F(DataOutputTest, TestWriteIntInt16) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
dataOutput.writeInt(static_cast<int16_t>(66));
dataOutput.writeInt(static_cast<int16_t>(55));
dataOutput.writeInt(static_cast<int16_t>(3333));
@@ -170,40 +183,40 @@ TEST_F(DataOutputTest, TestWriteIntInt16) {
}
TEST_F(DataOutputTest, TestWriteIntInt32) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
dataOutput.writeInt(static_cast<int32_t>(3435973836));
EXPECT_BYTEARRAY_EQ("CCCCCCCC", dataOutput.getByteArray());
}
TEST_F(DataOutputTest, TestWriteIntInt64) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
int64_t big = 773738426788457421;
dataOutput.writeInt(big);
EXPECT_BYTEARRAY_EQ("0ABCDEFFEDCBABCD", dataOutput.getByteArray());
}
TEST_F(DataOutputTest, TestWriteArrayLength) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
dataOutput.writeArrayLen(static_cast<int32_t>(3435973836));
EXPECT_BYTEARRAY_EQ("CC", dataOutput.getByteArray());
}
TEST_F(DataOutputTest, TestWriteFloat) {
- TestDataOutput dataOutput;
- float pi = 3.14;
+ TestDataOutput dataOutput(nullptr);
+ float pi = 3.14f;
dataOutput.writeFloat(pi);
EXPECT_BYTEARRAY_EQ("4048F5C3", dataOutput.getByteArray());
}
TEST_F(DataOutputTest, TestWriteDouble) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
double pi = 3.14159265359;
dataOutput.writeDouble(pi);
EXPECT_BYTEARRAY_EQ("400921FB54442EEA", dataOutput.getByteArray());
}
TEST_F(DataOutputTest, TestWriteASCII) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
dataOutput.writeASCII("You had me at meat tornado.");
EXPECT_BYTEARRAY_EQ(
"001B596F7520686164206D65206174206D65617420746F726E61646F2E",
@@ -211,7 +224,7 @@ TEST_F(DataOutputTest, TestWriteASCII) {
}
TEST_F(DataOutputTest, TestWriteNativeString) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
dataOutput.writeNativeString("You had me at meat tornado.");
EXPECT_BYTEARRAY_EQ(
"57001B596F7520686164206D65206174206D65617420746F726E61646F2E",
@@ -219,7 +232,7 @@ TEST_F(DataOutputTest, TestWriteNativeString) {
}
TEST_F(DataOutputTest, TestWriteASCIIHuge) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
dataOutput.writeASCIIHuge("You had me at meat tornado.");
EXPECT_BYTEARRAY_EQ(
"0000001B596F7520686164206D65206174206D65617420746F726E61646F2E",
@@ -227,7 +240,7 @@ TEST_F(DataOutputTest, TestWriteASCIIHuge) {
}
TEST_F(DataOutputTest, TestWriteFullUTF) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
dataOutput.writeFullUTF("You had me at meat tornado.");
EXPECT_BYTEARRAY_EQ(
"0000001B00596F7520686164206D65206174206D65617420746F726E61646F2E",
@@ -235,7 +248,7 @@ TEST_F(DataOutputTest, TestWriteFullUTF) {
}
TEST_F(DataOutputTest, TestWriteUTF) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
dataOutput.writeUTF("You had me at meat tornado.");
EXPECT_BYTEARRAY_EQ(
"001B596F7520686164206D65206174206D65617420746F726E61646F2E",
@@ -243,7 +256,7 @@ TEST_F(DataOutputTest, TestWriteUTF) {
}
TEST_F(DataOutputTest, TestWriteUTFHuge) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
dataOutput.writeUTFHuge("You had me at meat tornado.");
EXPECT_BYTEARRAY_EQ(
"0000001B0059006F007500200068006100640020006D00650020006100740020006D0065"
@@ -252,7 +265,7 @@ TEST_F(DataOutputTest, TestWriteUTFHuge) {
}
TEST_F(DataOutputTest, TestWriteUTFWide) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
dataOutput.writeUTF(L"You had me at meat tornado!");
EXPECT_BYTEARRAY_EQ(
"001B596F7520686164206D65206174206D65617420746F726E61646F21",
@@ -260,7 +273,7 @@ TEST_F(DataOutputTest, TestWriteUTFWide) {
}
TEST_F(DataOutputTest, TestWriteUTFHugeWide) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
dataOutput.writeUTFHuge(L"You had me at meat tornado.");
EXPECT_BYTEARRAY_EQ(
"0000001B0059006F007500200068006100640020006D00650020006100740020006D0065"
@@ -269,17 +282,17 @@ TEST_F(DataOutputTest, TestWriteUTFHugeWide) {
}
TEST_F(DataOutputTest, TestEncodedLength) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
EXPECT_EQ(27, dataOutput.getEncodedLength("You had me at meat tornado!"));
}
TEST_F(DataOutputTest, TestEncodedLengthWide) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
EXPECT_EQ(27, dataOutput.getEncodedLength(L"You had me at meat tornado."));
}
TEST_F(DataOutputTest, TestWriteObjectSharedPtr) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
std::shared_ptr<CacheableString> objptr =
CacheableString::create("You had me at meat tornado.");
dataOutput.writeObject(objptr);
@@ -289,7 +302,7 @@ TEST_F(DataOutputTest, TestWriteObjectSharedPtr) {
}
TEST_F(DataOutputTest, TestWriteObjectCacheableString) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
CacheableStringPtr objptr =
CacheableString::create("You had me at meat tornado.");
dataOutput.writeObject(objptr);
@@ -299,7 +312,7 @@ TEST_F(DataOutputTest, TestWriteObjectCacheableString) {
}
TEST_F(DataOutputTest, TestCursorAdvance) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
dataOutput.writeUTF("You had me at meat tornado.");
EXPECT_BYTEARRAY_EQ(
"001B596F7520686164206D65206174206D65617420746F726E61646F2E",
@@ -312,7 +325,7 @@ TEST_F(DataOutputTest, TestCursorAdvance) {
}
TEST_F(DataOutputTest, TestCursorNegativeAdvance) {
- TestDataOutput dataOutput;
+ TestDataOutput dataOutput(nullptr);
dataOutput.writeUTF("You had me at meat tornado.");
EXPECT_BYTEARRAY_EQ(
"001B596F7520686164206D65206174206D65617420746F726E61646F2E",
@@ -323,3 +336,5 @@ TEST_F(DataOutputTest, TestCursorNegativeAdvance) {
EXPECT_EQ((originalLength - 2), dataOutput.getBufferLength())
<< "Correct length after negative advance";
}
+
+} // namespace
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/test/PdxLocalReaderTest.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/test/PdxLocalReaderTest.cpp b/src/cppcache/test/PdxLocalReaderTest.cpp
index a424000..5852562 100644
--- a/src/cppcache/test/PdxLocalReaderTest.cpp
+++ b/src/cppcache/test/PdxLocalReaderTest.cpp
@@ -17,10 +17,14 @@
#include <gtest/gtest.h>
+#include <geode/CacheFactory.hpp>
#include <PdxType.hpp>
#include <PdxLocalReader.hpp>
#include <PdxLocalWriter.hpp>
#include <PdxTypeRegistry.hpp>
+#include "CacheRegionHelper.hpp"
+#include "DataInputInternal.hpp"
+#include "DataOutputInternal.hpp"
using namespace apache::geode::client;
@@ -59,31 +63,47 @@ const char *MyPdxClass::getClassName() const { return "MyPdxClass"; }
PdxSerializable *MyPdxClass::CreateDeserializable() { return new MyPdxClass(); }
-TEST(PdxLocalReaderTest, x) {
+class DISABLED_PdxLocalReaderTest : public ::testing::Test {
+ public:
+ void SetUp() {
+ auto factory = CacheFactory::createCacheFactory();
+ cache = factory->create();
+ }
+
+ protected:
+ CachePtr cache;
+};
+
+TEST_F(DISABLED_PdxLocalReaderTest, testSerializationOfPdxType) {
MyPdxClass expected, actual;
- DataOutput stream;
+ DataOutputInternal stream(cache.get());
int length = 0;
expected.setAString("the_expected_string");
+ // TODO: Refactor static singleton patterns in PdxTypeRegistry so that
+ // tests will not interfere with each other.
+
+ auto pdxTypeRegistry =
+ CacheRegionHelper::getCacheImpl(cache.get())->getPdxTypeRegistry();
+
// C++ Client does not require pdxDomainClassName as it is only needed
// for reflection purposes, which we do not support in C++. We pass in
// getClassName() for consistency reasons only.
- auto pdx_type_ptr = std::make_shared<PdxType>(expected.getClassName(), false);
-
- // TODO: Refactor static singleton patterns in PdxTypeRegistry so that
- // tests will not interfere with each other.
- PdxTypeRegistry::init();
+ auto pdx_type_ptr = std::make_shared<PdxType>(pdxTypeRegistry,
+ expected.getClassName(), false);
// Here we construct a serialized stream of bytes representing MyPdxClass.
// The stream is later deserialization and validated for consistency.
- auto writer = std::make_shared<PdxLocalWriter>(stream, pdx_type_ptr);
+ auto writer =
+ std::make_shared<PdxLocalWriter>(stream, pdx_type_ptr, pdxTypeRegistry);
expected.toData(writer);
writer->endObjectWriting();
uint8_t *raw_stream = writer->getPdxStream(length);
- DataInput input(raw_stream, length);
- auto reader = std::make_shared<PdxLocalReader>(input, pdx_type_ptr, length);
+ DataInputInternal input(raw_stream, length, cache.get());
+ auto reader = std::make_shared<PdxLocalReader>(input, pdx_type_ptr, length,
+ pdxTypeRegistry);
actual.fromData(reader);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/test/TcrMessage_unittest.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/test/TcrMessage_unittest.cpp b/src/cppcache/test/TcrMessage_unittest.cpp
index d58a6af..87f6c17 100644
--- a/src/cppcache/test/TcrMessage_unittest.cpp
+++ b/src/cppcache/test/TcrMessage_unittest.cpp
@@ -20,11 +20,28 @@
#include "gtest/gtest.h"
#include <geode/CqState.hpp>
+#include <geode/CacheFactory.hpp>
#include <TcrMessage.hpp>
#include "ByteArrayFixture.hpp"
+namespace {
+
using namespace apache::geode::client;
+class DataOutputUnderTest : public DataOutput {
+ public:
+ using DataOutput::DataOutput;
+
+ protected:
+ virtual const SerializationRegistry &getSerializationRegistry()
+ const override {
+ return m_serializationRegistry;
+ }
+
+ private:
+ SerializationRegistry m_serializationRegistry;
+};
+
#define EXPECT_MESSAGE_EQ(e, a) EXPECT_PRED_FORMAT2(assertMessageEqual, e, a)
class TcrMessageTest : public ::testing::Test, protected ByteArrayFixture {
@@ -52,8 +69,9 @@ TEST_F(TcrMessageTest, testConstructor1MessageDataContentWithDESTROY_REGION) {
int messageResponseTimeout = 1000;
ThinClientBaseDM *connectionDM = nullptr;
- TcrMessageDestroyRegion message(region, aCallbackArgument,
- messageResponseTimeout, connectionDM);
+ TcrMessageDestroyRegion message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()), region,
+ aCallbackArgument, messageResponseTimeout, connectionDM);
EXPECT_EQ(TcrMessage::DESTROY_REGION, message.getMessageType());
@@ -70,8 +88,9 @@ TEST_F(TcrMessageTest, testConstructor1MessageDataContentWithCLEAR_REGION) {
int messageResponseTimeout = 1000;
ThinClientBaseDM *connectionDM = nullptr;
- TcrMessageClearRegion message(region, aCallbackArgument,
- messageResponseTimeout, connectionDM);
+ TcrMessageClearRegion message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()), region,
+ aCallbackArgument, messageResponseTimeout, connectionDM);
EXPECT_MESSAGE_EQ(
"000000240000003800000003\\h{8}"
@@ -84,8 +103,9 @@ TEST_F(TcrMessageTest, testQueryConstructorMessageDataCotent) {
int messageResponseTimeout = 1000;
ThinClientBaseDM *connectionDM = nullptr;
- TcrMessageCloseCQ message("myRegionName", messageResponseTimeout,
- connectionDM);
+ TcrMessageCloseCQ message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
+ "myRegionName", messageResponseTimeout, connectionDM);
EXPECT_EQ(TcrMessage::CLOSECQ_MSG_TYPE, message.getMessageType());
@@ -99,7 +119,9 @@ TEST_F(TcrMessageTest, testQueryConstructorWithQUERY) {
int messageResponseTimeout = 1000;
ThinClientBaseDM *connectionDM = nullptr;
- TcrMessageQuery message("aRegionName", messageResponseTimeout, connectionDM);
+ TcrMessageQuery message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
+ "aRegionName", messageResponseTimeout, connectionDM);
EXPECT_EQ(TcrMessage::QUERY, message.getMessageType());
@@ -113,7 +135,9 @@ TEST_F(TcrMessageTest, testQueryConstructorWithSTOPCQ_MSG_TYPE) {
int messageResponseTimeout = 1000;
ThinClientBaseDM *connectionDM = nullptr;
- TcrMessageStopCQ message("aRegionName", messageResponseTimeout, connectionDM);
+ TcrMessageStopCQ message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
+ "aRegionName", messageResponseTimeout, connectionDM);
EXPECT_EQ(TcrMessage::STOPCQ_MSG_TYPE, message.getMessageType());
@@ -127,8 +151,9 @@ TEST_F(TcrMessageTest, testQueryConstructorWithCLOSECQ_MSG_TYPE) {
int messageResponseTimeout = 1000;
ThinClientBaseDM *connectionDM = nullptr;
- TcrMessageCloseCQ message("aRegionName", messageResponseTimeout,
- connectionDM);
+ TcrMessageCloseCQ message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
+ "aRegionName", messageResponseTimeout, connectionDM);
EXPECT_EQ(TcrMessage::CLOSECQ_MSG_TYPE, message.getMessageType());
@@ -145,9 +170,10 @@ TEST_F(TcrMessageTest,
const UserDataPtr aCallbackArgument = nullptr;
CacheableVectorPtr paramList = CacheableVector::create();
- TcrMessageQueryWithParameters message("aRegionName", aCallbackArgument,
- paramList, messageResponseTimeout,
- connectionDM);
+ TcrMessageQueryWithParameters message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
+ "aRegionName", aCallbackArgument, paramList, messageResponseTimeout,
+ connectionDM);
EXPECT_EQ(TcrMessage::QUERY_WITH_PARAMETERS, message.getMessageType());
@@ -159,6 +185,7 @@ TEST_F(TcrMessageTest,
TEST_F(TcrMessageTest, testConstructorWithCONTAINS_KEY) {
TcrMessageContainsKey message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
static_cast<const Region *>(nullptr),
CacheableString::create(
"mykey"), // static_cast<const CacheableKeyPtr>(nullptr),
@@ -174,7 +201,9 @@ TEST_F(TcrMessageTest, testConstructorWithCONTAINS_KEY) {
}
TEST_F(TcrMessageTest, testConstructorWithGETDURABLECQS_MSG_TYPE) {
- TcrMessageGetDurableCqs message(static_cast<ThinClientBaseDM *>(nullptr));
+ TcrMessageGetDurableCqs message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
+ static_cast<ThinClientBaseDM *>(nullptr));
EXPECT_EQ(TcrMessage::GETDURABLECQS_MSG_TYPE, message.getMessageType());
@@ -183,6 +212,7 @@ TEST_F(TcrMessageTest, testConstructorWithGETDURABLECQS_MSG_TYPE) {
TEST_F(TcrMessageTest, testConstructor2WithREQUEST) {
TcrMessageRequest message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
static_cast<const Region *>(nullptr),
CacheableString::create(
"mykey"), // static_cast<const CacheableKeyPtr>(nullptr),
@@ -198,11 +228,12 @@ TEST_F(TcrMessageTest, testConstructor2WithREQUEST) {
}
TEST_F(TcrMessageTest, testConstructor2WithDESTROY) {
- TcrMessageDestroy message(static_cast<const Region *>(nullptr),
- CacheableString::create("mykey"),
- static_cast<const CacheableKeyPtr>(nullptr),
- static_cast<const UserDataPtr>(nullptr),
- static_cast<ThinClientBaseDM *>(nullptr));
+ TcrMessageDestroy message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
+ static_cast<const Region *>(nullptr), CacheableString::create("mykey"),
+ static_cast<const CacheableKeyPtr>(nullptr),
+ static_cast<const UserDataPtr>(nullptr),
+ static_cast<ThinClientBaseDM *>(nullptr));
EXPECT_EQ(TcrMessage::DESTROY, message.getMessageType());
@@ -215,6 +246,7 @@ TEST_F(TcrMessageTest, testConstructor2WithDESTROY) {
TEST_F(TcrMessageTest, testConstructor2WithINVALIDATE) {
TcrMessageInvalidate message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
static_cast<const Region *>(nullptr),
CacheableString::create(
"mykey"), // static_cast<const CacheableKeyPtr>(nullptr),
@@ -231,15 +263,16 @@ TEST_F(TcrMessageTest, testConstructor2WithINVALIDATE) {
}
TEST_F(TcrMessageTest, testConstructor3WithPUT) {
- TcrMessagePut message(static_cast<const Region *>(nullptr),
- CacheableString::create("mykey"),
- CacheableString::create("myvalue"),
- static_cast<const UserDataPtr>(nullptr),
- false, // isDelta
- static_cast<ThinClientBaseDM *>(nullptr),
- false, // isMetaRegion
- false, // fullValueAfterDeltaFail
- "myRegionName");
+ TcrMessagePut message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
+ static_cast<const Region *>(nullptr), CacheableString::create("mykey"),
+ CacheableString::create("myvalue"),
+ static_cast<const UserDataPtr>(nullptr),
+ false, // isDelta
+ static_cast<ThinClientBaseDM *>(nullptr),
+ false, // isMetaRegion
+ false, // fullValueAfterDeltaFail
+ "myRegionName");
EXPECT_EQ(TcrMessage::PUT, message.getMessageType());
@@ -261,7 +294,9 @@ TEST_F(TcrMessageTest, testConstructor4) {
TEST_F(TcrMessageTest, testConstructor5WithREGISTER_INTERST_LIST) {
VectorOfCacheableKey keys;
keys.push_back(CacheableString::create("mykey"));
+
TcrMessageRegisterInterestList message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
static_cast<const Region *>(nullptr), keys,
false, // isDurable
false, // isCacheingEnabled
@@ -280,7 +315,9 @@ TEST_F(TcrMessageTest, testConstructor5WithREGISTER_INTERST_LIST) {
TEST_F(TcrMessageTest, testConstructor5WithUNREGISTER_INTERST_LIST) {
VectorOfCacheableKey keys;
keys.push_back(CacheableString::create("mykey"));
+
TcrMessageUnregisterInterestList message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
static_cast<const Region *>(nullptr), keys,
false, // isDurable
false, // isCacheingEnabled
@@ -298,6 +335,7 @@ TEST_F(TcrMessageTest, testConstructor5WithUNREGISTER_INTERST_LIST) {
TEST_F(TcrMessageTest, testConstructorGET_FUNCTION_ATTRIBUTES) {
TcrMessageGetFunctionAttributes message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
std::string("myFunction"), static_cast<ThinClientBaseDM *>(nullptr));
EXPECT_EQ(TcrMessage::GET_FUNCTION_ATTRIBUTES, message.getMessageType());
@@ -308,8 +346,10 @@ TEST_F(TcrMessageTest, testConstructorGET_FUNCTION_ATTRIBUTES) {
}
TEST_F(TcrMessageTest, testConstructorKEY_SET) {
- TcrMessageKeySet message(std::string("myFunctionKeySet"),
- static_cast<ThinClientBaseDM *>(nullptr));
+ TcrMessageKeySet message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
+ std::string("myFunctionKeySet"),
+ static_cast<ThinClientBaseDM *>(nullptr));
EXPECT_EQ(TcrMessage::KEY_SET, message.getMessageType());
@@ -320,13 +360,15 @@ TEST_F(TcrMessageTest, testConstructorKEY_SET) {
}
TEST_F(TcrMessageTest, testConstructor6WithCREATE_REGION) {
- TcrMessageCreateRegion message("str1", // TODO: what does this parameter do?!
- "str2", // TODO: what does this parameter do?!
- InterestResultPolicy::NONE,
- false, // isDurable
- false, // isCacheingEnabled
- false, // receiveValues
- static_cast<ThinClientBaseDM *>(nullptr));
+ TcrMessageCreateRegion message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
+ "str1", // TODO: what does this parameter do?!
+ "str2", // TODO: what does this parameter do?!
+ InterestResultPolicy::NONE,
+ false, // isDurable
+ false, // isCacheingEnabled
+ false, // receiveValues
+ static_cast<ThinClientBaseDM *>(nullptr));
EXPECT_EQ(TcrMessage::CREATE_REGION, message.getMessageType());
@@ -337,6 +379,7 @@ TEST_F(TcrMessageTest, testConstructor6WithCREATE_REGION) {
TEST_F(TcrMessageTest, testConstructor6WithREGISTER_INTEREST) {
TcrMessageRegisterInterest message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
"str1", // TODO: what does this parameter do?!
"str2", // TODO: what does this parameter do?!
InterestResultPolicy::NONE,
@@ -355,6 +398,7 @@ TEST_F(TcrMessageTest, testConstructor6WithREGISTER_INTEREST) {
TEST_F(TcrMessageTest, testConstructor6WithUNREGISTER_INTEREST) {
TcrMessageUnregisterInterest message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
"str1", // TODO: what does this parameter do?!
"str2", // TODO: what does this parameter do?!
InterestResultPolicy::NONE,
@@ -372,8 +416,9 @@ TEST_F(TcrMessageTest, testConstructor6WithUNREGISTER_INTEREST) {
}
TEST_F(TcrMessageTest, testConstructorGET_PDX_TYPE_BY_ID) {
- TcrMessageGetPdxTypeById message(42,
- static_cast<ThinClientBaseDM *>(nullptr));
+ TcrMessageGetPdxTypeById message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()), 42,
+ static_cast<ThinClientBaseDM *>(nullptr));
EXPECT_EQ(TcrMessage::GET_PDX_TYPE_BY_ID, message.getMessageType());
@@ -382,8 +427,9 @@ TEST_F(TcrMessageTest, testConstructorGET_PDX_TYPE_BY_ID) {
}
TEST_F(TcrMessageTest, testConstructorGET_PDX_ENUM_BY_ID) {
- TcrMessageGetPdxEnumById message(42,
- static_cast<ThinClientBaseDM *>(nullptr));
+ TcrMessageGetPdxEnumById message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()), 42,
+ static_cast<ThinClientBaseDM *>(nullptr));
EXPECT_EQ(TcrMessage::GET_PDX_ENUM_BY_ID, message.getMessageType());
@@ -394,7 +440,8 @@ TEST_F(TcrMessageTest, testConstructorGET_PDX_ENUM_BY_ID) {
TEST_F(TcrMessageTest, testConstructorGET_PDX_ID_FOR_TYPE) {
CacheablePtr myPtr(CacheableString::createDeserializable());
TcrMessageGetPdxIdForType message(
- myPtr, static_cast<ThinClientBaseDM *>(nullptr), 42);
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()), myPtr,
+ static_cast<ThinClientBaseDM *>(nullptr), 42);
EXPECT_EQ(TcrMessage::GET_PDX_ID_FOR_TYPE, message.getMessageType());
@@ -404,8 +451,9 @@ TEST_F(TcrMessageTest, testConstructorGET_PDX_ID_FOR_TYPE) {
TEST_F(TcrMessageTest, testConstructorADD_PDX_TYPE) {
CacheablePtr myPtr(CacheableString::createDeserializable());
- TcrMessageAddPdxType message(myPtr, static_cast<ThinClientBaseDM *>(nullptr),
- 42);
+ TcrMessageAddPdxType message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()), myPtr,
+ static_cast<ThinClientBaseDM *>(nullptr), 42);
EXPECT_EQ(TcrMessage::ADD_PDX_TYPE, message.getMessageType());
@@ -415,9 +463,10 @@ TEST_F(TcrMessageTest, testConstructorADD_PDX_TYPE) {
}
TEST_F(TcrMessageTest, testConstructorGET_PDX_ID_FOR_ENUM) {
- TcrMessageGetPdxIdForEnum message(static_cast<CacheablePtr>(nullptr),
- static_cast<ThinClientBaseDM *>(nullptr),
- 42);
+ TcrMessageGetPdxIdForEnum message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
+ static_cast<CacheablePtr>(nullptr),
+ static_cast<ThinClientBaseDM *>(nullptr), 42);
EXPECT_EQ(TcrMessage::GET_PDX_ID_FOR_ENUM, message.getMessageType());
@@ -426,8 +475,11 @@ TEST_F(TcrMessageTest, testConstructorGET_PDX_ID_FOR_ENUM) {
TEST_F(TcrMessageTest, testConstructorADD_PDX_ENUM) {
CacheablePtr myPtr(CacheableString::createDeserializable());
- TcrMessageAddPdxEnum message(static_cast<CacheablePtr>(nullptr),
- static_cast<ThinClientBaseDM *>(nullptr), 42);
+
+ TcrMessageAddPdxEnum message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
+ static_cast<CacheablePtr>(nullptr),
+ static_cast<ThinClientBaseDM *>(nullptr), 42);
EXPECT_EQ(TcrMessage::ADD_PDX_ENUM, message.getMessageType());
@@ -437,7 +489,9 @@ TEST_F(TcrMessageTest, testConstructorADD_PDX_ENUM) {
}
TEST_F(TcrMessageTest, testConstructorEventId) {
- TcrMessageRequestEventValue message(static_cast<EventIdPtr>(nullptr));
+ TcrMessageRequestEventValue message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
+ static_cast<EventIdPtr>(nullptr));
EXPECT_EQ(TcrMessage::REQUEST_EVENT_VALUE, message.getMessageType());
@@ -445,15 +499,17 @@ TEST_F(TcrMessageTest, testConstructorEventId) {
}
TEST_F(TcrMessageTest, testConstructorREMOVE_USER_AUTH) {
- TcrMessageRemoveUserAuth message(true,
- static_cast<ThinClientBaseDM *>(nullptr));
+ TcrMessageRemoveUserAuth message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()), true,
+ static_cast<ThinClientBaseDM *>(nullptr));
EXPECT_EQ(TcrMessage::REMOVE_USER_AUTH, message.getMessageType());
EXPECT_MESSAGE_EQ("0000004E0000000600000001FFFFFFFF00000000010001", message);
- TcrMessageRemoveUserAuth message2(false,
- static_cast<ThinClientBaseDM *>(nullptr));
+ TcrMessageRemoveUserAuth message2(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()), false,
+ static_cast<ThinClientBaseDM *>(nullptr));
EXPECT_EQ(TcrMessage::REMOVE_USER_AUTH, message2.getMessageType());
@@ -461,8 +517,10 @@ TEST_F(TcrMessageTest, testConstructorREMOVE_USER_AUTH) {
}
TEST_F(TcrMessageTest, testConstructorUSER_CREDENTIAL_MESSAGE) {
- TcrMessageUserCredential message(static_cast<PropertiesPtr>(nullptr),
- static_cast<ThinClientBaseDM *>(nullptr));
+ TcrMessageUserCredential message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
+ static_cast<PropertiesPtr>(nullptr),
+ static_cast<ThinClientBaseDM *>(nullptr));
EXPECT_EQ(TcrMessage::USER_CREDENTIAL_MESSAGE, message.getMessageType());
// this message is currently blank so this should change it if the impl
@@ -471,7 +529,9 @@ TEST_F(TcrMessageTest, testConstructorUSER_CREDENTIAL_MESSAGE) {
}
TEST_F(TcrMessageTest, testConstructorGET_CLIENT_PARTITION_ATTRIBUTES) {
- TcrMessageGetClientPartitionAttributes message("testClientRegion");
+ TcrMessageGetClientPartitionAttributes message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
+ "testClientRegion");
EXPECT_EQ(TcrMessage::GET_CLIENT_PARTITION_ATTRIBUTES,
message.getMessageType());
@@ -483,7 +543,9 @@ TEST_F(TcrMessageTest, testConstructorGET_CLIENT_PARTITION_ATTRIBUTES) {
}
TEST_F(TcrMessageTest, testConstructorGET_CLIENT_PR_METADATA) {
- TcrMessageGetClientPrMetadata message("testClientRegionPRMETA");
+ TcrMessageGetClientPrMetadata message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
+ "testClientRegionPRMETA");
EXPECT_EQ(TcrMessage::GET_CLIENT_PR_METADATA, message.getMessageType());
@@ -493,7 +555,9 @@ TEST_F(TcrMessageTest, testConstructorGET_CLIENT_PR_METADATA) {
message);
}
TEST_F(TcrMessageTest, testConstructorSIZE) {
- TcrMessageSize message("testClientRegionSIZE");
+ TcrMessageSize message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
+ "testClientRegionSIZE");
EXPECT_EQ(TcrMessage::SIZE, message.getMessageType());
@@ -509,7 +573,9 @@ TEST_F(TcrMessageTest, testConstructorEXECUTE_REGION_FUNCTION_SINGLE_HOP) {
CacheableHashSetPtr myHashCachePtr = CacheableHashSet::create();
CacheablePtr myPtr(CacheableString::createDeserializable());
+
TcrMessageExecuteRegionFunctionSingleHop message(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
"myFuncName", region, myPtr, myHashCachePtr, 2, myHashCachePtr,
false, // allBuckets
1, static_cast<ThinClientBaseDM *>(nullptr));
@@ -518,7 +584,7 @@ TEST_F(TcrMessageTest, testConstructorEXECUTE_REGION_FUNCTION_SINGLE_HOP) {
message.getMessageType());
EXPECT_MESSAGE_EQ(
- "0000004F0000005E00000009FFFFFFFF00000000050002000003E80000001300494E5641"
+ "0000004F0000005E00000009FFFFFFFF00000000050002000000010000001300494E5641"
"4C49445F524547494F4E5F4E414D450000000A006D7946756E634E616D65000000030157"
"000000000001012900000001000000000004000000000000000004000000000000000002"
"014200",
@@ -535,6 +601,7 @@ TEST_F(TcrMessageTest, testConstructorEXECUTE_REGION_FUNCTION) {
CacheableVectorPtr myVectPtr = CacheableVector::create();
TcrMessageExecuteRegionFunction testMessage(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
"ExecuteRegion", region, myCacheablePtr, myVectPtr, 2, myHashCachePtr, 10,
static_cast<ThinClientBaseDM *>(nullptr), 10);
@@ -543,7 +610,7 @@ TEST_F(TcrMessageTest, testConstructorEXECUTE_REGION_FUNCTION) {
// changes
EXPECT_MESSAGE_EQ(
- "0000003B0000006100000009FFFFFFFF00000000050002000027100000001300494E5641"
+ "0000003B0000006100000009FFFFFFFF000000000500020000000A0000001300494E5641"
"4C49445F524547494F4E5F4E414D450000000D0045786563757465526567696F6E000000"
"030157000000000001012900000001000A00000004000000000000000004000000000000"
"000002014200",
@@ -552,10 +619,11 @@ TEST_F(TcrMessageTest, testConstructorEXECUTE_REGION_FUNCTION) {
EXPECT_TRUE(testMessage.hasResult());
}
-TEST_F(TcrMessageTest, testConstructorEXECUTE_FUNCTION) {
+TEST_F(TcrMessageTest, DISABLED_testConstructorEXECUTE_FUNCTION) {
CacheablePtr myCacheablePtr(CacheableString::createDeserializable());
TcrMessageExecuteFunction testMessage(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
"ExecuteFunction", myCacheablePtr, 1,
static_cast<ThinClientBaseDM *>(nullptr), 10);
@@ -564,7 +632,7 @@ TEST_F(TcrMessageTest, testConstructorEXECUTE_FUNCTION) {
EXPECT_TRUE(testMessage.hasResult());
EXPECT_MESSAGE_EQ(
- "0000003E0000002600000003FFFFFFFF00000000050001000027100000000F0045786563"
+ "0000003E0000002600000003FFFFFFFF000000000500010000000A0000000F0045786563"
"75746546756E6374696F6E0000000301570000",
testMessage);
}
@@ -572,9 +640,10 @@ TEST_F(TcrMessageTest, testConstructorEXECUTE_FUNCTION) {
TEST_F(TcrMessageTest, testConstructorEXECUTECQ_MSG_TYPE) {
CacheablePtr myCacheablePtr(CacheableString::createDeserializable());
- TcrMessageExecuteCq testMessage("ExecuteCQ", "select * from /somewhere",
- CqState::RUNNING, false,
- static_cast<ThinClientBaseDM *>(nullptr));
+ TcrMessageExecuteCq testMessage(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
+ "ExecuteCQ", "select * from /somewhere", CqState::RUNNING, false,
+ static_cast<ThinClientBaseDM *>(nullptr));
EXPECT_EQ(TcrMessage::EXECUTECQ_MSG_TYPE, testMessage.getMessageType());
@@ -603,9 +672,11 @@ TEST_F(TcrMessageTest, testConstructorWithGinormousQueryEXECUTECQ_MSG_TYPE) {
oss << '\'';
}
oss << ") and s.type in SET('AAA','BBB','CCC','DDD') limit 60000";
- TcrMessageExecuteCq testMessage("ExecuteCQ", oss.str(), CqState::RUNNING,
- false,
- static_cast<ThinClientBaseDM *>(nullptr));
+
+ TcrMessageExecuteCq testMessage(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
+ "ExecuteCQ", oss.str(), CqState::RUNNING, false,
+ static_cast<ThinClientBaseDM *>(nullptr));
EXPECT_EQ(TcrMessage::EXECUTECQ_MSG_TYPE, testMessage.getMessageType());
@@ -619,6 +690,7 @@ TEST_F(TcrMessageTest, testConstructorEXECUTECQ_WITH_IR_MSG_TYPE) {
CacheablePtr myCacheablePtr(CacheableString::createDeserializable());
TcrMessageExecuteCqWithIr testMessage(
+ std::unique_ptr<DataOutputUnderTest>(new DataOutputUnderTest()),
"ExecuteCQWithIr", "select * from /somewhere", CqState::RUNNING, false,
static_cast<ThinClientBaseDM *>(nullptr));
@@ -631,3 +703,5 @@ TEST_F(TcrMessageTest, testConstructorEXECUTECQ_WITH_IR_MSG_TYPE) {
"000001000000010000000000010001",
testMessage);
}
+
+} // namespace
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/quickstart/cpp/CqQuery.cpp
----------------------------------------------------------------------
diff --git a/src/quickstart/cpp/CqQuery.cpp b/src/quickstart/cpp/CqQuery.cpp
index 07d85f8..13c51cf 100644
--- a/src/quickstart/cpp/CqQuery.cpp
+++ b/src/quickstart/cpp/CqQuery.cpp
@@ -95,8 +95,8 @@ int main(int argc, char** argv) {
// Register our Serializable/Cacheable Query objects, viz. Portfolio and
// Position.
- Serializable::registerType(Portfolio::createDeserializable);
- Serializable::registerType(Position::createDeserializable);
+ serializationRegistry->addType(Portfolio::createDeserializable);
+ serializationRegistry->addType(Position::createDeserializable);
LOGINFO("Registered Serializable Query Objects");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/quickstart/cpp/Delta.cpp
----------------------------------------------------------------------
diff --git a/src/quickstart/cpp/Delta.cpp b/src/quickstart/cpp/Delta.cpp
index dba53a0..00e2c03 100644
--- a/src/quickstart/cpp/Delta.cpp
+++ b/src/quickstart/cpp/Delta.cpp
@@ -61,7 +61,7 @@ int main(int argc, char** argv) {
LOGINFO("Obtained the Region from the Cache");
// Register our Serializable/Cacheable Delta objects, DeltaExample.
- Serializable::registerType(DeltaExample::create);
+ serializationRegistry->addType(DeltaExample::create);
// Creating Delta Object.
DeltaExample* ptr = new DeltaExample(10, 15, 20);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/quickstart/cpp/DistributedSystem.cpp
----------------------------------------------------------------------
diff --git a/src/quickstart/cpp/DistributedSystem.cpp b/src/quickstart/cpp/DistributedSystem.cpp
index b399743..090802d 100644
--- a/src/quickstart/cpp/DistributedSystem.cpp
+++ b/src/quickstart/cpp/DistributedSystem.cpp
@@ -44,7 +44,7 @@ using namespace apache::geode::client;
void distributedsystem(CachePtr cachePtr, char *hostname, int port,
char *poolName, char *regionName) {
// create pool factory to create the pool.
- PoolFactoryPtr poolFacPtr = PoolManager::createFactory();
+ PoolFactoryPtr poolFacPtr = cachePtr->getPoolManager().createFactory();
// adding host(endpoint) in pool
poolFacPtr->addServer(hostname, port);
@@ -53,7 +53,7 @@ void distributedsystem(CachePtr cachePtr, char *hostname, int port,
poolFacPtr->setSubscriptionEnabled(true);
// creating pool with name "examplePool"
- poolFacPtr->create(poolName);
+ poolFacPtr->create(poolName, *cachePtr.get());
RegionFactoryPtr regionFactory = cachePtr->createRegionFactory(CACHING_PROXY);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/quickstart/cpp/PdxRemoteQuery.cpp
----------------------------------------------------------------------
diff --git a/src/quickstart/cpp/PdxRemoteQuery.cpp b/src/quickstart/cpp/PdxRemoteQuery.cpp
index 40e34b2..be3fb9f 100644
--- a/src/quickstart/cpp/PdxRemoteQuery.cpp
+++ b/src/quickstart/cpp/PdxRemoteQuery.cpp
@@ -67,8 +67,8 @@ int main(int argc, char** argv) {
// Register our Serializable/Cacheable Query objects, viz. PortfolioPdx and
// PositionPdx.
- Serializable::registerPdxType(PortfolioPdx::createDeserializable);
- Serializable::registerPdxType(PositionPdx::createDeserializable);
+ serializationRegistry->addPdxType(PortfolioPdx::createDeserializable);
+ serializationRegistry->addPdxType(PositionPdx::createDeserializable);
LOGINFO("Registered PDX Type Query Objects");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/quickstart/cpp/PdxSerializer.cpp
----------------------------------------------------------------------
diff --git a/src/quickstart/cpp/PdxSerializer.cpp b/src/quickstart/cpp/PdxSerializer.cpp
index c0d41a1..90250eb 100644
--- a/src/quickstart/cpp/PdxSerializer.cpp
+++ b/src/quickstart/cpp/PdxSerializer.cpp
@@ -16,22 +16,22 @@
*/
/*
-* The PdxSerializer QuickStart Example.
-* This example takes the following steps:
-*
-* This example shows PdxSerializer usage.
-*
-* 1. Create a Geode Cache.
-* 2. Get the Person from the Cache.
-* 3. Populate some query Person objects on the Region.
-* 4. Get the pool, get the Query Service from Pool. Pool is define in
-* clientPdxSerializer.xml.
-* 5. Execute a query that returns a Result Set.
-* 6. Execute a query that returns a Struct Set.
-* 7. Execute the region shortcut/convenience query methods.
-* 8. Close the Cache.
-*
-*/
+ * The PdxSerializer QuickStart Example.
+ * This example takes the following steps:
+ *
+ * This example shows PdxSerializer usage.
+ *
+ * 1. Create a Geode Cache.
+ * 2. Get the Person from the Cache.
+ * 3. Populate some query Person objects on the Region.
+ * 4. Get the pool, get the Query Service from Pool. Pool is define in
+ * clientPdxSerializer.xml.
+ * 5. Execute a query that returns a Result Set.
+ * 6. Execute a query that returns a Struct Set.
+ * 7. Execute the region shortcut/convenience query methods.
+ * 8. Close the Cache.
+ *
+ */
// Include the Geode library.
#include <geode/GeodeCppCache.hpp>
@@ -165,22 +165,22 @@ int main(int argc, char** argv) {
LOGINFO("Registered Person Query Objects");
// Populate the Region with some Person objects.
- Person* p1 = new Person((char *)"John", 1 /*ID*/, 23 /*age*/);
+ Person* p1 = new Person((char*)"John", 1 /*ID*/, 23 /*age*/);
PdxWrapperPtr pdxobj1(new PdxWrapper(p1, CLASSNAME));
regionPtr->put("Key1", pdxobj1);
- Person* p2 = new Person((char *)"Jack", 2 /*ID*/, 20 /*age*/);
+ Person* p2 = new Person((char*)"Jack", 2 /*ID*/, 20 /*age*/);
PdxWrapperPtr pdxobj2(new PdxWrapper(p2, CLASSNAME));
regionPtr->put("Key2", pdxobj2);
- Person* p3 = new Person((char *)"Tony", 3 /*ID*/, 35 /*age*/);
+ Person* p3 = new Person((char*)"Tony", 3 /*ID*/, 35 /*age*/);
PdxWrapperPtr pdxobj3(new PdxWrapper(p3, CLASSNAME));
regionPtr->put("Key3", pdxobj3);
LOGINFO("Populated some Person Objects through PdxWrapper");
// find the pool
- PoolPtr poolPtr = PoolManager::find("examplePool");
+ PoolPtr poolPtr = cachePtr->getPoolManager().find("examplePool");
// Get the QueryService from the Pool.
QueryServicePtr qrySvcPtr = poolPtr->getQueryService();
@@ -218,7 +218,9 @@ int main(int argc, char** argv) {
LOGINFO("Region Query returned %d rows", resultsPtr->size());
// Execute the Region selectValue() API.
- PdxWrapperPtr pdxWrapperPtr = std::dynamic_pointer_cast<apache::geode::client::PdxWrapper>(regionPtr->selectValue("m_id = 3"));
+ PdxWrapperPtr pdxWrapperPtr =
+ std::dynamic_pointer_cast<apache::geode::client::PdxWrapper>(
+ regionPtr->selectValue("m_id = 3"));
Person* per = reinterpret_cast<Person*>(pdxWrapperPtr->getObject());
LOGINFO(
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/quickstart/cpp/PoolCqQuery.cpp
----------------------------------------------------------------------
diff --git a/src/quickstart/cpp/PoolCqQuery.cpp b/src/quickstart/cpp/PoolCqQuery.cpp
index cd91fcf..fc69953 100644
--- a/src/quickstart/cpp/PoolCqQuery.cpp
+++ b/src/quickstart/cpp/PoolCqQuery.cpp
@@ -102,8 +102,8 @@ int main(int argc, char** argv) {
// Register our Serializable/Cacheable Query objects, viz. Portfolio and
// Position.
- Serializable::registerType(Portfolio::createDeserializable);
- Serializable::registerType(Position::createDeserializable);
+ serializationRegistry->addType(Portfolio::createDeserializable);
+ serializationRegistry->addType(Position::createDeserializable);
LOGINFO("Registered Serializable Query Objects");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/quickstart/cpp/PoolRemoteQuery.cpp
----------------------------------------------------------------------
diff --git a/src/quickstart/cpp/PoolRemoteQuery.cpp b/src/quickstart/cpp/PoolRemoteQuery.cpp
index 4e98dbd..9172959 100644
--- a/src/quickstart/cpp/PoolRemoteQuery.cpp
+++ b/src/quickstart/cpp/PoolRemoteQuery.cpp
@@ -67,8 +67,8 @@ int main(int argc, char** argv) {
// Register our Serializable/Cacheable Query objects, viz. Portfolio and
// Position.
- Serializable::registerType(Portfolio::createDeserializable);
- Serializable::registerType(Position::createDeserializable);
+ serializationRegistry->addType(Portfolio::createDeserializable);
+ serializationRegistry->addType(Position::createDeserializable);
LOGINFO("Registered Serializable Query Objects");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/quickstart/cpp/PoolWithEndpoints.cpp
----------------------------------------------------------------------
diff --git a/src/quickstart/cpp/PoolWithEndpoints.cpp b/src/quickstart/cpp/PoolWithEndpoints.cpp
index c1a5cee..4c5fa59 100644
--- a/src/quickstart/cpp/PoolWithEndpoints.cpp
+++ b/src/quickstart/cpp/PoolWithEndpoints.cpp
@@ -54,7 +54,7 @@ int main(int argc, char** argv) {
LOGINFO("Created the Geode Cache");
// Create Poolfactory with endpoint and then create pool using poolfactory.
- PoolFactoryPtr pfact = PoolManager::createFactory();
+ PoolFactoryPtr pfact = cachePtr->getPoolManager().createFactory();
pfact->addServer("localhost", 40404);
PoolPtr pptr = pfact->create("examplePool");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/quickstart/cpp/RemoteQuery.cpp
----------------------------------------------------------------------
diff --git a/src/quickstart/cpp/RemoteQuery.cpp b/src/quickstart/cpp/RemoteQuery.cpp
index 9bfcf47..7694ba8 100644
--- a/src/quickstart/cpp/RemoteQuery.cpp
+++ b/src/quickstart/cpp/RemoteQuery.cpp
@@ -64,8 +64,8 @@ int main(int argc, char** argv) {
// Register our Serializable/Cacheable Query objects, viz. Portfolio and
// Position.
- Serializable::registerType(Portfolio::createDeserializable);
- Serializable::registerType(Position::createDeserializable);
+ serializationRegistry->addType(Portfolio::createDeserializable);
+ serializationRegistry->addType(Position::createDeserializable);
LOGINFO("Registered Serializable Query Objects");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/quickstart/csharp/CqQuery.cs
----------------------------------------------------------------------
diff --git a/src/quickstart/csharp/CqQuery.cs b/src/quickstart/csharp/CqQuery.cs
index b4c9b9a..f05323e 100644
--- a/src/quickstart/csharp/CqQuery.cs
+++ b/src/quickstart/csharp/CqQuery.cs
@@ -87,8 +87,8 @@ namespace Apache.Geode.Client.QuickStart
Console.WriteLine("Created the Region Programmatically.");
// Register our Serializable/Cacheable Query objects, viz. Portfolio and Position.
- Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable);
- Serializable.RegisterTypeGeneric(Position.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable, CacheHelper.DCache);
+ Serializable.RegisterTypeGeneric(Position.CreateDeserializable, CacheHelper.DCache);
Console.WriteLine("Registered Serializable Query Objects");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/quickstart/csharp/Delta.cs
----------------------------------------------------------------------
diff --git a/src/quickstart/csharp/Delta.cs b/src/quickstart/csharp/Delta.cs
index 21c4cf6..9f9d08c 100644
--- a/src/quickstart/csharp/Delta.cs
+++ b/src/quickstart/csharp/Delta.cs
@@ -60,7 +60,7 @@ namespace Apache.Geode.Client.QuickStart
Console.WriteLine("Obtained the Region from the Cache");
- Serializable.RegisterTypeGeneric(DeltaExample.create);
+ Serializable.RegisterTypeGeneric(DeltaExample.create, CacheHelper.DCache);
//Creating Delta Object.
DeltaExample ptr = new DeltaExample(10, 15, 20);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/quickstart/csharp/PoolCqQuery.cs
----------------------------------------------------------------------
diff --git a/src/quickstart/csharp/PoolCqQuery.cs b/src/quickstart/csharp/PoolCqQuery.cs
index 30751e3..b792f09 100755
--- a/src/quickstart/csharp/PoolCqQuery.cs
+++ b/src/quickstart/csharp/PoolCqQuery.cs
@@ -92,8 +92,8 @@ namespace Apache.Geode.Client.QuickStart
Console.WriteLine("Obtained the Region from the Cache");
// Register our Serializable/Cacheable Query objects, viz. Portfolio and Position.
- Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable);
- Serializable.RegisterTypeGeneric(Position.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable, CacheHelper.DCache);
+ Serializable.RegisterTypeGeneric(Position.CreateDeserializable, CacheHelper.DCache);
Console.WriteLine("Registered Serializable Query Objects");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/quickstart/csharp/PoolRemoteQuery.cs
----------------------------------------------------------------------
diff --git a/src/quickstart/csharp/PoolRemoteQuery.cs b/src/quickstart/csharp/PoolRemoteQuery.cs
index 1978e6a..3f9aada 100755
--- a/src/quickstart/csharp/PoolRemoteQuery.cs
+++ b/src/quickstart/csharp/PoolRemoteQuery.cs
@@ -64,8 +64,8 @@ namespace Apache.Geode.Client.QuickStart
Console.WriteLine("Obtained the Region from the Cache");
// Register our Serializable/Cacheable Query objects, viz. Portfolio and Position.
- Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable);
- Serializable.RegisterTypeGeneric(Position.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable, CacheHelper.DCache);
+ Serializable.RegisterTypeGeneric(Position.CreateDeserializable, CacheHelper.DCache);
Console.WriteLine("Registered Serializable Query Objects");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/quickstart/csharp/RemoteQuery.cs
----------------------------------------------------------------------
diff --git a/src/quickstart/csharp/RemoteQuery.cs b/src/quickstart/csharp/RemoteQuery.cs
index b33aae8..9f4f278 100644
--- a/src/quickstart/csharp/RemoteQuery.cs
+++ b/src/quickstart/csharp/RemoteQuery.cs
@@ -62,8 +62,8 @@ namespace Apache.Geode.Client.QuickStart
Console.WriteLine("Created the Region Programmatically.");
// Register our Serializable/Cacheable Query objects, viz. Portfolio and Position.
- Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable);
- Serializable.RegisterTypeGeneric(Position.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable, CacheHelper.DCache);
+ Serializable.RegisterTypeGeneric(Position.CreateDeserializable, CacheHelper.DCache);
Console.WriteLine("Registered Serializable Query Objects");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/sqliteimpl/SqLiteImpl.cpp
----------------------------------------------------------------------
diff --git a/src/sqliteimpl/SqLiteImpl.cpp b/src/sqliteimpl/SqLiteImpl.cpp
index 24052c9..c1a6a00 100644
--- a/src/sqliteimpl/SqLiteImpl.cpp
+++ b/src/sqliteimpl/SqLiteImpl.cpp
@@ -14,6 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <geode/Region.hpp>
+#include <geode/Cache.hpp>
#include "SqLiteImpl.hpp"
#ifdef _WIN32
@@ -31,6 +33,7 @@ void SqLiteImpl::init(const RegionPtr& region, PropertiesPtr& diskProperties) {
int maxPageCount = 0;
int pageSize = 0;
+ m_regionPtr = region;
m_persistanceDir = g_default_persistence_directory;
std::string regionName = region->getName();
if (diskProperties != nullptr) {
@@ -108,14 +111,16 @@ void SqLiteImpl::init(const RegionPtr& region, PropertiesPtr& diskProperties) {
void SqLiteImpl::write(const CacheableKeyPtr& key, const CacheablePtr& value,
void*& dbHandle) {
// Serialize key and value.
- DataOutput keyDataBuffer, valueDataBuffer;
+ auto* cache = m_regionPtr->getCache().get();
+ auto keyDataBuffer = cache->createDataOutput();
+ auto valueDataBuffer = cache->createDataOutput();
uint32_t keyBufferSize, valueBufferSize;
- keyDataBuffer.writeObject(key);
- valueDataBuffer.writeObject(value);
- void* keyData = const_cast<uint8_t*>(keyDataBuffer.getBuffer(&keyBufferSize));
+ keyDataBuffer->writeObject(key);
+ valueDataBuffer->writeObject(value);
+ void* keyData = const_cast<uint8_t*>(keyDataBuffer->getBuffer(&keyBufferSize));
void* valueData =
- const_cast<uint8_t*>(valueDataBuffer.getBuffer(&valueBufferSize));
+ const_cast<uint8_t*>(valueDataBuffer->getBuffer(&valueBufferSize));
if (m_sqliteHelper->insertKeyValue(keyData, keyBufferSize, valueData,
valueBufferSize) != 0) {
@@ -127,10 +132,10 @@ bool SqLiteImpl::writeAll() { return true; }
CacheablePtr SqLiteImpl::read(const CacheableKeyPtr& key, void*& dbHandle) {
// Serialize key.
- DataOutput keyDataBuffer;
+ auto keyDataBuffer = m_regionPtr->getCache()->createDataOutput();
uint32_t keyBufferSize;
- keyDataBuffer.writeObject(key);
- void* keyData = const_cast<uint8_t*>(keyDataBuffer.getBuffer(&keyBufferSize));
+ keyDataBuffer->writeObject(key);
+ void* keyData = const_cast<uint8_t*>(keyDataBuffer->getBuffer(&keyBufferSize));
void* valueData;
uint32_t valueBufferSize;
@@ -140,10 +145,10 @@ CacheablePtr SqLiteImpl::read(const CacheableKeyPtr& key, void*& dbHandle) {
}
// Deserialize object and return value.
- DataInput valueDataBuffer(reinterpret_cast<uint8_t*>(valueData),
+ auto valueDataBuffer = m_regionPtr->getCache()->createDataInput(reinterpret_cast<uint8_t*>(valueData),
valueBufferSize);
CacheablePtr retValue;
- valueDataBuffer.readObject(retValue);
+ valueDataBuffer->readObject(retValue);
// Free memory for serialized form of Cacheable object.
free(valueData);
@@ -170,10 +175,10 @@ void SqLiteImpl::destroyRegion() {
void SqLiteImpl::destroy(const CacheableKeyPtr& key, void*& dbHandle) {
// Serialize key and value.
- DataOutput keyDataBuffer;
+ auto keyDataBuffer = m_regionPtr->getCache()->createDataOutput();
uint32_t keyBufferSize;
- keyDataBuffer.writeObject(key);
- void* keyData = const_cast<uint8_t*>(keyDataBuffer.getBuffer(&keyBufferSize));
+ keyDataBuffer->writeObject(key);
+ void* keyData = const_cast<uint8_t*>(keyDataBuffer->getBuffer(&keyBufferSize));
if (m_sqliteHelper->removeKey(keyData, keyBufferSize) != 0) {
throw IllegalStateException("Failed to destroy the key from SQLITE.");
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/templates/security/PkcsAuthInit.cpp
----------------------------------------------------------------------
diff --git a/src/templates/security/PkcsAuthInit.cpp b/src/templates/security/PkcsAuthInit.cpp
index a545990..ebae246 100644
--- a/src/templates/security/PkcsAuthInit.cpp
+++ b/src/templates/security/PkcsAuthInit.cpp
@@ -14,12 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+#include "SerializationRegistry.hpp"
#include "PkcsAuthInit.hpp"
#include "geode/Properties.hpp"
#include "geode/CacheableBuiltins.hpp"
#include "geode/ExceptionTypes.hpp"
#include <cstdio>
+#include <string>
namespace apache {
namespace geode {
@@ -90,7 +91,7 @@ static bool s_initDone = openSSLInit();
}
// end of extern "C"
-PropertiesPtr PKCSAuthInit::getCredentials(PropertiesPtr& securityprops,
+PropertiesPtr PKCSAuthInit::getCredentials(const PropertiesPtr& securityprops,
const char* server) {
if (!s_initDone) {
throw AuthenticationFailedException(
@@ -132,7 +133,6 @@ PropertiesPtr PKCSAuthInit::getCredentials(PropertiesPtr& securityprops,
"PKCSAuthInit::getCredentials: "
"key-store password property KEYSTORE_PASSWORD not set.");
}
- DataOutput additionalMsg;
FILE* keyStoreFP = fopen(keyStorePath, "r");
if (keyStoreFP == NULL) {
@@ -158,16 +158,10 @@ PropertiesPtr PKCSAuthInit::getCredentials(PropertiesPtr& securityprops,
fclose(keyStoreFP);
- additionalMsg.writeUTF(alias);
-
- uint32_t dataLen;
- char* data = (char*)additionalMsg.getBuffer(&dataLen);
unsigned int lengthEncryptedData = 0;
- // Skip first two bytes of the java UTF-8 encoded string
- // containing the length of the string.
uint8_t* signatureData = createSignature(
- privateKey, cert, reinterpret_cast<unsigned char*>(data + 2), dataLen - 2,
+ privateKey, cert, reinterpret_cast<const unsigned char*>(alias), strlen(alias),
&lengthEncryptedData);
EVP_PKEY_free(privateKey);
X509_free(cert);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/templates/security/PkcsAuthInit.hpp
----------------------------------------------------------------------
diff --git a/src/templates/security/PkcsAuthInit.hpp b/src/templates/security/PkcsAuthInit.hpp
index 8b7a385..9e2f1cb 100644
--- a/src/templates/security/PkcsAuthInit.hpp
+++ b/src/templates/security/PkcsAuthInit.hpp
@@ -85,7 +85,7 @@ class PKCSAuthInit : public AuthInitialize {
* The format expected is "host:port".
* @returns the credentials to be used for the given <code>server</code>
*/
- PropertiesPtr getCredentials(PropertiesPtr& securityprops,
+ PropertiesPtr getCredentials(const PropertiesPtr& securityprops,
const char* server);
/**
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/templates/security/UserPasswordAuthInit.cpp
----------------------------------------------------------------------
diff --git a/src/templates/security/UserPasswordAuthInit.cpp b/src/templates/security/UserPasswordAuthInit.cpp
index 8d4f4e9..4714aba 100644
--- a/src/templates/security/UserPasswordAuthInit.cpp
+++ b/src/templates/security/UserPasswordAuthInit.cpp
@@ -33,8 +33,8 @@ LIBEXP AuthInitialize* createUserPasswordAuthInitInstance() {
}
}
-PropertiesPtr UserPasswordAuthInit::getCredentials(PropertiesPtr& securityprops,
- const char* server) {
+PropertiesPtr UserPasswordAuthInit::getCredentials(
+ const PropertiesPtr& securityprops, const char* server) {
// LOGDEBUG("UserPasswordAuthInit: inside userPassword::getCredentials");
CacheablePtr userName;
if (securityprops == nullptr ||
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/templates/security/UserPasswordAuthInit.hpp
----------------------------------------------------------------------
diff --git a/src/templates/security/UserPasswordAuthInit.hpp b/src/templates/security/UserPasswordAuthInit.hpp
index fec9ecf..e3d7ed6 100644
--- a/src/templates/security/UserPasswordAuthInit.hpp
+++ b/src/templates/security/UserPasswordAuthInit.hpp
@@ -65,7 +65,7 @@ class UserPasswordAuthInit : public AuthInitialize {
* @remarks This method can modify the given set of properties. For
* example it may invoke external agents or even interact with the user.
*/
- PropertiesPtr getCredentials(PropertiesPtr& securityprops,
+ PropertiesPtr getCredentials(const PropertiesPtr& securityprops,
const char* server);
/**
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cli/FwkUtil/FwkData.cs
----------------------------------------------------------------------
diff --git a/src/tests/cli/FwkUtil/FwkData.cs b/src/tests/cli/FwkUtil/FwkData.cs
index f7c3771..c5f6c40 100644
--- a/src/tests/cli/FwkUtil/FwkData.cs
+++ b/src/tests/cli/FwkUtil/FwkData.cs
@@ -21,6 +21,7 @@ using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Xml;
+
#pragma warning disable 618
namespace Apache.Geode.Client.FwkLib
@@ -189,172 +190,8 @@ namespace Apache.Geode.Client.FwkLib
public static Dictionary<string, FwkData> ReadDataNodes(XmlNode node)
{
- XmlNodeList xmlNodes = node.SelectNodes("data");
- // Console.WriteLine("Total number of data nodes found = " + xmlNodes.Count);
- if (xmlNodes != null)
- {
- Dictionary<string, FwkData> dataNodes = new Dictionary<string, FwkData>();
- foreach (XmlNode xmlNode in xmlNodes)
- {
- XmlAttribute tmpattr = xmlNode.Attributes["name"];
- string name;
- if (tmpattr != null)
- {
- name = tmpattr.Value;
- }
- else
- {
- throw new IllegalArgException("The xml file passed has an unknown format");
- }
+ throw new Exception();
- //Console.WriteLine("xmlNode.FirstChild.Name = " + xmlNode.FirstChild.Name);
- if (xmlNode.FirstChild == null || xmlNode.FirstChild.NodeType == XmlNodeType.Text)
- {
- object data = xmlNode.InnerText;
- // Console.WriteLine("Going to construct FwkData with data = " + data.ToString() +
- // " data2 = null " + " datakind = " + DataKind.String.ToString());
- FwkData td = new FwkData(data, null, DataKind.String);
- dataNodes[name] = td;
- }
- else if (xmlNode.FirstChild.Name == "snippet")
- {
- string regionName;
- if (xmlNode.FirstChild.FirstChild.Name == "region")
- {
- XmlAttribute nameattr = xmlNode.FirstChild.FirstChild.Attributes["name"];
- regionName = nameattr.Value;
-
- // Now collect the region atributes
- XmlNode attrnode = xmlNode.FirstChild.FirstChild.FirstChild;
- Apache.Geode.Client.Properties<string, string> rattr = Apache.Geode.Client.Properties<string, string>.Create<string, string>();
- //AttributesFactory af = new AttributesFactory();
- if (attrnode.Name == "region-attributes")
- {
- XmlAttributeCollection attrcoll = attrnode.Attributes;
- if (attrcoll != null)
- {
- foreach (XmlAttribute eachattr in attrcoll)
- {
- rattr.Insert(eachattr.Name, eachattr.Value);
- //SetThisAttribute(eachattr.Name, eachattr, af);
- }
- }
- if (attrnode.ChildNodes != null)
- {
- foreach (XmlNode tmpnode in attrnode.ChildNodes)
- {
- rattr.Insert(tmpnode.Name, tmpnode.Value);
- //SetThisAttribute(tmpnode.Name, tmpnode, af);
- }
- }
- Apache.Geode.Client.DataOutput dout = new Apache.Geode.Client.DataOutput();
- //RegionAttributes rattr = af.CreateRegionAttributes();
- rattr.ToData(dout);
- // Console.WriteLine("Going to construct FwkData with region = " + regionName +
- // " data2 = region attributes" + " datakind = " + DataKind.Region.ToString());
- FwkData td = new FwkData(regionName, dout.GetBuffer(), DataKind.Region);
- dataNodes[name] = td;
- }
- else
- {
- throw new IllegalArgException("The xml file passed has an unknown format");
- }
- }
- else if (xmlNode.FirstChild.FirstChild.Name == "pool")
- {
- XmlAttribute nameattr = xmlNode.FirstChild.FirstChild.Attributes["name"];
- String poolName = nameattr.Value;
- // Now collect the pool atributes
- Apache.Geode.Client.Properties<string, string> prop = Apache.Geode.Client.Properties<string, string>.Create<string, string>();
- XmlAttributeCollection attrcoll = xmlNode.FirstChild.FirstChild.Attributes;
- if (attrcoll != null)
- {
- foreach (XmlAttribute eachattr in attrcoll)
- {
- prop.Insert(eachattr.Name, eachattr.Value);
- }
- Apache.Geode.Client.DataOutput dout = new Apache.Geode.Client.DataOutput();
- prop.ToData(dout);
- FwkData td = new FwkData(poolName, dout.GetBuffer(), DataKind.Pool);
- dataNodes[name] = td;
- }
- else
- {
- throw new IllegalArgException("The xml file passed has an unknown format");
- }
- }
- else
- {
- throw new IllegalArgException("The xml file passed has an unknown format");
- }
- }
- else if (xmlNode.FirstChild.Name == "list")
- {
- List<string> tmplist = new List<string>();
- XmlNode listNode = xmlNode.FirstChild;
- if (listNode.FirstChild != null)
- {
- bool isOneOf = false;
- if (listNode.FirstChild.Name == "oneOf")
- {
- isOneOf = true;
- listNode = listNode.FirstChild;
- }
- XmlNodeList tmpListNodes = listNode.ChildNodes;
- foreach (XmlNode itemnode in tmpListNodes)
- {
- if (itemnode.Name == "item")
- {
- tmplist.Add(itemnode.InnerText);
- //Console.WriteLine("Adding the value " + itemnode.InnerText + " to the list");
- }
- else
- {
- throw new IllegalArgException("The xml file passed has an unknown node " +
- itemnode.Name + " in data-list");
- }
- }
- //Console.WriteLine("Going to construct FwkData list data: oneof = " + isOneOf.ToString() + " datakind = " + DataKind.List.ToString());
- FwkData td = new FwkData(tmplist, isOneOf, DataKind.List);
- dataNodes[name] = td;
- }
- }
- else if ( xmlNode.FirstChild.Name == "range" )
- {
- XmlAttributeCollection rangeAttr = xmlNode.FirstChild.Attributes;
- string lowmarkstr = rangeAttr["low"].Value;
- string highmarkstr = rangeAttr["high"].Value;
- int lowmark = int.Parse(lowmarkstr);
- int highmark = int.Parse(highmarkstr);
- //Console.WriteLine("Going to construct FwkData Range datakind = " + DataKind.Range.ToString() + " high = " + highmark + " low = " + lowmark);
- FwkData td = new FwkData(lowmark, highmark, DataKind.Range);
- dataNodes[name] = td;
- }
- else if (xmlNode.FirstChild.Name == "oneof")
- {
- XmlNodeList itemlist = xmlNode.FirstChild.ChildNodes;
- List<string> opItemList = new List<string>();
- foreach (XmlNode tmpitem in itemlist)
- {
- if (tmpitem.Name == "item")
- {
- opItemList.Add(tmpitem.InnerText);
- }
- }
- FwkData td = new FwkData(opItemList, true, DataKind.List);
- dataNodes[name] = td;
- }
- else
- {
- throw new IllegalArgException("The xml file passed has an unknown child: " +
- xmlNode.FirstChild.Name + " ; number of childnodes: " +
- (xmlNode.ChildNodes == null ? XmlNodeType.None :
- xmlNode.FirstChild.NodeType));
- }
- }
- return dataNodes;
- }
- return null;
}
public static void SetThisAttribute(string name, XmlNode node, Apache.Geode.Client.AttributesFactory<string, string> af)
@@ -887,45 +724,6 @@ namespace Apache.Geode.Client.FwkLib
return null;
}
- /// <summary>
- /// Read the region attributes for the given key.
- /// </summary>
- /// <param name="key">The key of the region to read.</param>
- /// <returns>The attributes of the region.</returns>
- public Apache.Geode.Client.RegionAttributes<string, string> GetRegionAttributes(string key)
- {
- FwkData data = ReadData(key);
- if (data != null && data.Kind == DataKind.Region)
- {
- Apache.Geode.Client.AttributesFactory<string, string> af = new Apache.Geode.Client.AttributesFactory<string, string>();
- Apache.Geode.Client.RegionAttributes<string, string> attrs = af.CreateRegionAttributes();
- byte[] attrsArr = data.Data2 as byte[];
- if (attrsArr != null && attrsArr.Length > 0)
- {
- Apache.Geode.Client.DataInput dinp = new Apache.Geode.Client.DataInput(attrsArr);
- attrs.FromData(dinp);
- }
- return attrs;
- }
- return null;
- }
- public Apache.Geode.Client.Properties<string, string> GetPoolAttributes(string key)
- {
- FwkData data = ReadData(key);
- if (data != null && data.Kind == DataKind.Pool)
- {
- Apache.Geode.Client.Properties<string, string> prop = Apache.Geode.Client.Properties<string, string>.Create<string, string>();
- //RegionAttributes attrs = af.CreateRegionAttributes();
- byte[] attrsArr = data.Data2 as byte[];
- if (attrsArr != null && attrsArr.Length > 0)
- {
- Apache.Geode.Client.DataInput dinp = new Apache.Geode.Client.DataInput(attrsArr);
- prop.FromData(dinp);
- }
- return prop;
- }
- return null;
- }
/// <summary>
/// Reset a key to the start.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cli/NewFwkLib/CacheHelper.cs
----------------------------------------------------------------------
diff --git a/src/tests/cli/NewFwkLib/CacheHelper.cs b/src/tests/cli/NewFwkLib/CacheHelper.cs
index 217cb81..f3c4753 100644
--- a/src/tests/cli/NewFwkLib/CacheHelper.cs
+++ b/src/tests/cli/NewFwkLib/CacheHelper.cs
@@ -265,7 +265,7 @@ namespace Apache.Geode.Client.FwkLib
}
catch (CacheExistsException)
{
- m_cache = CacheFactory.GetAnyInstance();
+ m_cache = CacheFactory.CreateCacheFactory(config).Create();
}
}
@@ -302,14 +302,7 @@ namespace Apache.Geode.Client.FwkLib
public static void Close()
{
- if (DistributedSystem.IsConnected)
- {
- CloseCache();
- if (m_doDisconnect)
- {
- DistributedSystem.Disconnect();
- }
- }
+ CloseCache();
m_dsys = null;
}
@@ -324,14 +317,7 @@ namespace Apache.Geode.Client.FwkLib
public static void CloseKeepAlive()
{
- if (DistributedSystem.IsConnected)
- {
- CloseCacheKeepAlive();
- if (m_doDisconnect)
- {
- DistributedSystem.Disconnect();
- }
- }
+ CloseCacheKeepAlive();
m_dsys = null;
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cli/NewFwkLib/CacheServer.cs
----------------------------------------------------------------------
diff --git a/src/tests/cli/NewFwkLib/CacheServer.cs b/src/tests/cli/NewFwkLib/CacheServer.cs
index 6f9b138..1128aa9 100644
--- a/src/tests/cli/NewFwkLib/CacheServer.cs
+++ b/src/tests/cli/NewFwkLib/CacheServer.cs
@@ -37,8 +37,7 @@ namespace Apache.Geode.Client.FwkLib
long currentTimeInMillies()
{
- DateTime startTime = DateTime.Now;
- long curruntMillis = SmokePerf<TKey, TVal>.GetDateTimeMillis(startTime);
+ long curruntMillis = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
return curruntMillis;
}
public override void AfterCreate(EntryEvent<TKey, TVal> ev)
@@ -966,7 +965,7 @@ namespace Apache.Geode.Client.FwkLib
{
ResetKey(ObjectType);
string objectType = GetStringValue(ObjectType);
- QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper();
+ QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper(CacheHelper<TKey, TVal>.DCache);
int numSet = 0;
int setSize = 0;
if (objectType != null && (objectType == "Portfolio" || objectType == "PortfolioPdx"))
@@ -991,7 +990,7 @@ namespace Apache.Geode.Client.FwkLib
int numOfKeys = GetUIntValue(EntryCount);
ResetKey(ValueSizes);
int objSize = GetUIntValue(ValueSizes);
- QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper();
+ QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper(CacheHelper<TKey, TVal>.DCache);
int numSet = 0;
int setSize = 0;
if (objType != null && objType == "Portfolio")
@@ -1122,7 +1121,7 @@ namespace Apache.Geode.Client.FwkLib
{
ResetKey(EntryCount);
int numOfKeys = GetUIntValue(EntryCount);
- QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper();
+ QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper(CacheHelper<TKey, TVal>.DCache);
int setSize = qh.PortfolioSetSize;
if (numOfKeys < setSize)
{
@@ -1219,7 +1218,7 @@ namespace Apache.Geode.Client.FwkLib
{
Int32 numSet = 0;
Int32 setSize = 0;
- QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper();
+ QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper(CacheHelper<TKey, TVal>.DCache);
TVal port;
setSize = qh.PortfolioSetSize;
numSet = 200 / setSize;
@@ -1339,7 +1338,7 @@ namespace Apache.Geode.Client.FwkLib
FwkInfo("Sleeping for " + sleepTime + " millis");
Thread.Sleep(sleepTime);
region.GetSubscriptionService().RegisterAllKeys(isDurable, keys, isGetInitialValues, isReceiveValues);
- String durableClientId = DistributedSystem.SystemProperties.DurableClientId;
+ String durableClientId = CacheHelper<TKey, TVal>.DCache.DistributedSystem.SystemProperties.DurableClientId;
if (durableClientId.Length > 0)
{
CacheHelper<TKey, TVal>.DCache.ReadyForEvents();
@@ -2963,7 +2962,7 @@ namespace Apache.Geode.Client.FwkLib
FwkInfo("Sleeping for " + sleepTime + " millis");
Thread.Sleep(sleepTime);
region.GetSubscriptionService().RegisterKeys(m_KeysA, isDurable, isGetInitialValues, isReceiveValues);
- String durableClientId = DistributedSystem.SystemProperties.DurableClientId;
+ String durableClientId = CacheHelper<TKey, TVal>.DCache.DistributedSystem.SystemProperties.DurableClientId;
if (durableClientId.Length > 0)
{
CacheHelper<TKey, TVal>.DCache.ReadyForEvents();
@@ -3019,7 +3018,7 @@ namespace Apache.Geode.Client.FwkLib
verifyEntry(m_KeysA[i], expected);
templist.Clear();
}
- String durableClientId = DistributedSystem.SystemProperties.DurableClientId;
+ String durableClientId = CacheHelper<TKey, TVal>.DCache.DistributedSystem.SystemProperties.DurableClientId;
if (durableClientId.Length > 0)
{
CacheHelper<TKey, TVal>.DCache.ReadyForEvents();
@@ -4086,9 +4085,8 @@ private void checkUpdatedValue(TKey key, TVal value)
int sleepMS = 2000;
FwkInfo("Waiting for a period of silence for " + desiredSilenceSec + " seconds...");
long desiredSilenceMS = desiredSilenceSec * 1000;
- DateTime startTime = DateTime.Now;
- long silenceStartTime = SmokePerf<TKey, TVal>.GetDateTimeMillis(startTime);
- long currentTime = SmokePerf<TKey, TVal>.GetDateTimeMillis(startTime);
+ long silenceStartTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
+ long currentTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
long lastEventTime = (long)Util.BBGet("ListenerBB", "lastEventTime");
while (currentTime - silenceStartTime < desiredSilenceMS)
@@ -4107,8 +4105,7 @@ private void checkUpdatedValue(TKey key, TVal value)
// restart the wait
silenceStartTime = lastEventTime;
}
- startTime = DateTime.Now;
- currentTime = SmokePerf<TKey, TVal>.GetDateTimeMillis(startTime);
+ currentTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
}
long duration = currentTime - silenceStartTime;
FwkInfo("Done waiting, clients have been silent for " + duration + " ms");
@@ -4263,7 +4260,7 @@ private void checkUpdatedValue(TKey key, TVal value)
if (poolName != null)
{
- Pool pool = PoolManager.Find(poolName);
+ Pool pool = CacheHelper<TKey, TVal>.DCache.GetPoolManager().Find(poolName);
if (pool.MultiuserAuthentication)
{
FwkInfo("pool is in multiuser mode and entering CreateMultiUserCacheAndRegion");
@@ -4372,7 +4369,7 @@ private void checkUpdatedValue(TKey key, TVal value)
userProp.Insert(KeyStoreAliasProp, userName);
userProp.Insert(KeyStorePasswordProp, "geode");
//mu_cache = pool.CreateSecureUserCache(userProp);
- //IRegionService mu_cache = CacheHelper.DCache.CreateAuthenticatedView(userProp, pool.Name);
+ //IRegionService mu_cache = CacheHelper<TKey, TVal>.DCache.CreateAuthenticatedView(userProp, pool.Name);
IRegionService mu_cache = CacheHelper<TKey, TVal>.DCache.CreateAuthenticatedView(
CacheHelper<TKey, TVal>.GetPkcsCredentialsForMU(
pkcs.GetCredentials(userProp, "0:0")), pool.Name);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cli/NewFwkLib/DeltaTest/DeltaTest.cs
----------------------------------------------------------------------
diff --git a/src/tests/cli/NewFwkLib/DeltaTest/DeltaTest.cs b/src/tests/cli/NewFwkLib/DeltaTest/DeltaTest.cs
index 8f3a046..be37c81 100644
--- a/src/tests/cli/NewFwkLib/DeltaTest/DeltaTest.cs
+++ b/src/tests/cli/NewFwkLib/DeltaTest/DeltaTest.cs
@@ -520,8 +520,8 @@ namespace Apache.Geode.Client.FwkLib
{
if (!isObjectRegistered)
{
- Serializable.RegisterTypeGeneric(DeltaTestImpl.CreateDeserializable);
- Serializable.RegisterTypeGeneric(TestObject1.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(DeltaTestImpl.CreateDeserializable, CacheHelper<TKey, TVal>.DCache);
+ Serializable.RegisterTypeGeneric(TestObject1.CreateDeserializable, CacheHelper<TKey, TVal>.DCache);
isObjectRegistered = true;
}
IRegion<TKey, TVal> region = CreateRootRegion();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cli/NewFwkLib/EventTest/EventTests.cs
----------------------------------------------------------------------
diff --git a/src/tests/cli/NewFwkLib/EventTest/EventTests.cs b/src/tests/cli/NewFwkLib/EventTest/EventTests.cs
index 5f9c4d4..6f3f8f1 100644
--- a/src/tests/cli/NewFwkLib/EventTest/EventTests.cs
+++ b/src/tests/cli/NewFwkLib/EventTest/EventTests.cs
@@ -519,7 +519,7 @@ namespace Apache.Geode.Client.FwkLib
Region rootRegion;
RegionAttributes attr;
- rootRegionArray = CacheHelper.DCache.RootRegions();
+ rootRegionArray = CacheHelper<TKey, TVal>.DCache.RootRegions();
int ulRegionCount = rootRegionArray.Length;
@@ -562,7 +562,7 @@ namespace Apache.Geode.Client.FwkLib
{
FwkException("Data not provided for 'regionName', failing.");
}
- Region region = CacheHelper.DCache.GetRegion(testRegionName);
+ Region region = CacheHelper<TKey, TVal>.DCache.GetRegion(testRegionName);
int usePid = GetUIntValue("usePID");
int pid = Util.PID;
@@ -631,7 +631,7 @@ namespace Apache.Geode.Client.FwkLib
{
FwkException("Data not provided for 'regionName', failing.");
}
- Region region = CacheHelper.DCache.GetRegion(testRegionName);
+ Region region = CacheHelper<TKey, TVal>.DCache.GetRegion(testRegionName);
int usePid = GetUIntValue("usePID");
int pid = Util.PID;
@@ -692,8 +692,8 @@ namespace Apache.Geode.Client.FwkLib
FwkInfo("validateCacheContent()");
string testRegionName = GetStringValue("testRegion");
string validateRegionName = GetStringValue("validateRegion");
- Region testRegion = CacheHelper.DCache.GetRegion(testRegionName);
- Region validateRegion = CacheHelper.DCache.GetRegion(validateRegionName);
+ Region testRegion = CacheHelper<TKey, TVal>.DCache.GetRegion(testRegionName);
+ Region validateRegion = CacheHelper<TKey, TVal>.DCache.GetRegion(validateRegionName);
ICacheableKey[] keyVector;
keyVector = testRegion.GetKeys();
@@ -740,8 +740,8 @@ namespace Apache.Geode.Client.FwkLib
string testRegionName = GetStringValue("testRegion");
string validateRegionName = GetStringValue("validateRegion");
string regionName = GetStringValue("regionName");
- Region testRegion = CacheHelper.DCache.GetRegion(testRegionName);
- Region validateRegion = CacheHelper.DCache.GetRegion(validateRegionName);
+ Region testRegion = CacheHelper<TKey, TVal>.DCache.GetRegion(testRegionName);
+ Region validateRegion = CacheHelper<TKey, TVal>.DCache.GetRegion(validateRegionName);
FwkInfo("localDestroyRegion region name is " + testRegion.Name);
// destroy the region
@@ -750,7 +750,7 @@ namespace Apache.Geode.Client.FwkLib
testRegion.LocalDestroyRegion();
CreateRootRegion();
- Region region = CacheHelper.DCache.GetRegion(regionName);
+ Region region = CacheHelper<TKey, TVal>.DCache.GetRegion(regionName);
FwkInfo(" Recreated Region name is " + region.Name);
@@ -807,8 +807,8 @@ namespace Apache.Geode.Client.FwkLib
FwkInfo("doIterateOnEntry()");
string testRegionName = GetStringValue("testRegion");
string validateRegionName = GetStringValue("validateRegion");
- Region testRegion = CacheHelper.DCache.GetRegion(testRegionName);
- Region validateRegion = CacheHelper.DCache.GetRegion(validateRegionName);
+ Region testRegion = CacheHelper<TKey, TVal>.DCache.GetRegion(testRegionName);
+ Region validateRegion = CacheHelper<TKey, TVal>.DCache.GetRegion(validateRegionName);
ICacheableKey[] keyVector = null;
int keysInRegion = 1;
@@ -849,7 +849,7 @@ namespace Apache.Geode.Client.FwkLib
{
FwkException("Data not provided for 'regionName', failing.");
}
- Region region = CacheHelper.DCache.GetRegion(testRegionName);
+ Region region = CacheHelper<TKey, TVal>.DCache.GetRegion(testRegionName);
int opsSecond = GetUIntValue("opsSecond");
if (opsSecond < 0)
@@ -1150,7 +1150,7 @@ namespace Apache.Geode.Client.FwkLib
// TODO: For lock
// SpinLockGuard guard( m_lck );
// TODO: setTask(taskId)
- if (CacheHelper.DCache == null)
+ if (CacheHelper<TKey, TVal>.DCache == null)
{
Properties pp = new Properties();
//TODO: Initialize? cacheInitialize( pp );
@@ -1448,7 +1448,7 @@ namespace Apache.Geode.Client.FwkLib
public Region GetRandomRegion(bool bAllowRootRegion)
{
FwkInfo("Inside GetRandomRegion ... Check 1");
- Region[] rootRegionVector = CacheHelper.DCache.RootRegions();
+ Region[] rootRegionVector = CacheHelper<TKey, TVal>.DCache.RootRegions();
int irootSize = rootRegionVector.Length;
Region[] subRegionVector;
@@ -1666,12 +1666,12 @@ namespace Apache.Geode.Client.FwkLib
public int getAllRegionCount()
{
- if (CacheHelper.DCache == null)
+ if (CacheHelper<TKey, TVal>.DCache == null)
{
FwkSevere("Null cache pointer, no connection established.");
return 0;
}
- Region[] rootRegions = CacheHelper.DCache.RootRegions();
+ Region[] rootRegions = CacheHelper<TKey, TVal>.DCache.RootRegions();
int iRootSize = rootRegions.Length;
int iTotalRegions = iRootSize;
@@ -1747,7 +1747,7 @@ namespace Apache.Geode.Client.FwkLib
public Int32 getRegionCount()
{
FwkInfo("Check 1.1 Inside getRegionCount");
- Region[] roots = CacheHelper.DCache.RootRegions();
+ Region[] roots = CacheHelper<TKey, TVal>.DCache.RootRegions();
FwkInfo("Check 1.1 root region count = {0}", roots.Length);
return roots.Length;
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cli/NewFwkLib/FunctionExecution/FunctionExecution.cs
----------------------------------------------------------------------
diff --git a/src/tests/cli/NewFwkLib/FunctionExecution/FunctionExecution.cs b/src/tests/cli/NewFwkLib/FunctionExecution/FunctionExecution.cs
index 9f7fabd..9195aa6 100644
--- a/src/tests/cli/NewFwkLib/FunctionExecution/FunctionExecution.cs
+++ b/src/tests/cli/NewFwkLib/FunctionExecution/FunctionExecution.cs
@@ -736,7 +736,7 @@ namespace Apache.Geode.Client.FwkLib
string poolname = GetStringValue( "poolName" );
string funcName = null;
if(executionMode == "onServers" || executionMode == "onServer"){
- pptr = PoolManager/*<TKey, TVal>*/.Find(poolname);
+ pptr = CacheHelper<TKey, TVal>.DCache.GetPoolManager().Find(poolname);
if(getresult)
funcName = "ServerOperationsFunction";
else
@@ -1137,7 +1137,7 @@ namespace Apache.Geode.Client.FwkLib
Apache.Geode.Client.Execution<object> exc = null;
try
{
- Pool/*<TKey, TVal>*/ pptr = PoolManager/*<TKey, TVal>*/.Find(poolname);
+ Pool/*<TKey, TVal>*/ pptr = CacheHelper<TKey, TVal>.DCache.GetPoolManager().Find(poolname);
MyResultCollector<object> myRC = new MyResultCollector<object>();
exc = Client.FunctionService<object>.OnServers(pptr).WithCollector(myRC);
// execute function
[20/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/include/geode/RegionFactory.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/RegionFactory.hpp b/src/cppcache/include/geode/RegionFactory.hpp
index 4894bdf..52aba8a 100644
--- a/src/cppcache/include/geode/RegionFactory.hpp
+++ b/src/cppcache/include/geode/RegionFactory.hpp
@@ -153,11 +153,11 @@ class CPPCACHE_EXPORT RegionFactory
const PropertiesPtr& config = nullptr);
/** Sets the PersistenceManager for the next <code>RegionAttributes</code>
- * created.
- * @param persistenceManager a user defined PersistenceManager, nullptr if no
- * persistenceManager
- * @return a reference to <code>this</code>
- */
+ * created.
+ * @param persistenceManager a user defined PersistenceManager, nullptr if no
+ * persistenceManager
+ * @return a reference to <code>this</code>
+ */
RegionFactoryPtr setPersistenceManager(
const PersistenceManagerPtr& persistenceManager,
const PropertiesPtr& config = nullptr);
@@ -237,31 +237,32 @@ class CPPCACHE_EXPORT RegionFactory
RegionFactoryPtr setCloningEnabled(bool isClonable);
/**
- * Enables or disables concurrent modification checks
- * @since 7.0
- * @param concurrencyChecksEnabled whether to perform concurrency checks on
- * operations
- * @return a reference to <code>this</code>
- */
+ * Enables or disables concurrent modification checks
+ * @since 7.0
+ * @param concurrencyChecksEnabled whether to perform concurrency checks on
+ * operations
+ * @return a reference to <code>this</code>
+ */
RegionFactoryPtr setConcurrencyChecksEnabled(bool enable);
/**
- * Sets time out for tombstones
- * @since 7.0
- * @param tombstoneTimeoutInMSec tombstone timeout in milli second
- * @return a reference to <code>this</code>
- */
+ * Sets time out for tombstones
+ * @since 7.0
+ * @param tombstoneTimeoutInMSec tombstone timeout in milli second
+ * @return a reference to <code>this</code>
+ */
RegionFactoryPtr setTombstoneTimeout(uint32_t tombstoneTimeoutInMSec);
private:
- RegionFactory(apache::geode::client::RegionShortcut preDefinedRegion);
+ RegionFactory(apache::geode::client::RegionShortcut preDefinedRegion,
+ CacheImpl* cacheImpl);
RegionShortcut m_preDefinedRegion;
AttributesFactoryPtr m_attributeFactory;
void setRegionShortcut();
-
+ CacheImpl* m_cacheImpl;
~RegionFactory();
friend class CacheImpl;
FRIEND_STD_SHARED_PTR(RegionFactory)
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/include/geode/Serializable.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/Serializable.hpp b/src/cppcache/include/geode/Serializable.hpp
index 06d571a..6e21260 100644
--- a/src/cppcache/include/geode/Serializable.hpp
+++ b/src/cppcache/include/geode/Serializable.hpp
@@ -26,6 +26,7 @@
#include "geode_globals.hpp"
#include "geode_types.hpp"
+#include <functional>
namespace apache {
namespace geode {
@@ -34,14 +35,14 @@ namespace client {
class DataOutput;
class DataInput;
-typedef void (*CliCallbackMethod)();
+typedef void (*CliCallbackMethod)(Cache& cache);
/** @brief signature of functions passed to registerType. Such functions
* should return an empty instance of the type they represent. The instance
* will typically be initialized immediately after creation by a call to
* fromData().
*/
-typedef Serializable* (*TypeFactoryMethod)();
+using TypeFactoryMethod = std::function<Serializable*()>;
typedef PdxSerializable* (*TypeFactoryMethodPdx)();
/**
@@ -105,31 +106,6 @@ class CPPCACHE_EXPORT Serializable
virtual uint32_t objectSize() const;
/**
- * @brief register an instance factory method for a given type.
- * During registration the factory will be invoked to extract the typeId
- * to associate with this function.
- * @throws IllegalStateException if the typeId has already been registered,
- * or there is an error in registering the type; check errno for
- * more information in the latter case.
- */
- static void registerType(TypeFactoryMethod creationFunction);
-
- /**
- * @brief register an Pdx instance factory method for a given type.
- * @throws IllegalStateException if the typeName has already been registered,
- * or there is an error in registering the type; check errno for
- * more information in the latter case.
- */
- static void registerPdxType(TypeFactoryMethodPdx creationFunction);
-
- /**
- * Register the PDX serializer which can handle serialization for instances of
- * user domain classes.
- * @see PdxSerializer
- */
- static void registerPdxSerializer(PdxSerializerPtr pdxSerializer);
-
- /**
* Display this object as 'string', which depends on the implementation in
* the subclasses.
* The default implementation renders the classname.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/include/geode/SystemProperties.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/SystemProperties.hpp b/src/cppcache/include/geode/SystemProperties.hpp
index 0e8ded2..d2a2128 100644
--- a/src/cppcache/include/geode/SystemProperties.hpp
+++ b/src/cppcache/include/geode/SystemProperties.hpp
@@ -211,7 +211,7 @@ class CPPCACHE_EXPORT SystemProperties {
/**
* Returns client Queueconflation option
*/
- char* conflateEvents() { return m_conflateEvents; }
+ char* conflateEvents() const { return m_conflateEvents; }
/**
* Returns true if the stack trace is enabled ,false otherwise
@@ -312,14 +312,14 @@ class CPPCACHE_EXPORT SystemProperties {
}
/** Return the security diffie hellman secret key algo */
- const char* securityClientDhAlgo() {
+ const char* securityClientDhAlgo() const {
return (m_securityClientDhAlgo == nullptr
? ""
: m_securityClientDhAlgo->asChar());
}
/** Return the keystore (.pem file ) path */
- const char* securityClientKsPath() {
+ const char* securityClientKsPath() const {
return (m_securityClientKsPath == nullptr
? ""
: m_securityClientKsPath->asChar());
@@ -351,7 +351,7 @@ class CPPCACHE_EXPORT SystemProperties {
* Check whether Diffie-Hellman based credentials encryption is on.
* @return bool flag to indicate whether DH for credentials is on.
*/
- bool isDhOn() {
+ bool isDhOn() const {
return isSecurityOn() && m_securityClientDhAlgo != nullptr &&
m_securityClientDhAlgo->length() > 0;
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/include/geode/TypeRegistry.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/TypeRegistry.hpp b/src/cppcache/include/geode/TypeRegistry.hpp
new file mode 100644
index 0000000..87f6a87
--- /dev/null
+++ b/src/cppcache/include/geode/TypeRegistry.hpp
@@ -0,0 +1,69 @@
+
+#pragma once
+
+#ifndef GEODE_TYPEREGISTRY_H_
+#define GEODE_TYPEREGISTRY_H_
+
+/*
+ * 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.
+ */
+
+#include "geode_globals.hpp"
+#include "geode_types.hpp"
+#include "Serializable.hpp"
+namespace apache {
+namespace geode {
+namespace client {
+
+class TypeRegistry {
+ public:
+ TypeRegistry(Cache& cache);
+
+ /**
+ * @brief register an instance factory method for a given type.
+ * During registration the factory will be invoked to extract the typeId
+ * to associate with this function.
+ * @throws IllegalStateException if the typeId has already been
+ * registered, or there is an error in registering the type; check errno
+ * for more information in the latter case.
+ */
+ void registerType(TypeFactoryMethod creationFunction);
+
+ /**
+ * @brief register an Pdx instance factory method for a given type.
+ * @throws IllegalStateException if the typeName has already been registered,
+ * or there is an error in registering the type; check errno for
+ * more information in the latter case.
+ */
+ void registerPdxType(TypeFactoryMethodPdx creationFunction);
+
+ /**
+ * Register the PDX serializer which can handle serialization for instances of
+ * user domain classes.
+ * @see PdxSerializer
+ */
+ void registerPdxSerializer(PdxSerializerPtr pdxSerializer);
+
+ protected:
+ private:
+ Cache& m_cache;
+};
+} // namespace client
+} // namespace geode
+} // namespace apache
+
+#endif //GEODE_TYPEREGISTRY_H_
+
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/include/geode/geode_types.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/geode_types.hpp b/src/cppcache/include/geode/geode_types.hpp
index 25ce7e3..882893a 100644
--- a/src/cppcache/include/geode/geode_types.hpp
+++ b/src/cppcache/include/geode/geode_types.hpp
@@ -38,7 +38,6 @@ class CacheFactory;
class CPPCACHE_EXPORT a; \
typedef std::shared_ptr<a> b;
-_GF_PTR_DEF_(DistributedSystem, DistributedSystemPtr);
_GF_PTR_DEF_(CacheFactory, CacheFactoryPtr);
_GF_PTR_DEF_(RegionService, RegionServicePtr);
_GF_PTR_DEF_(GeodeCache, GeodeCachePtr);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/include/geode/statistics/StatisticsFactory.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/statistics/StatisticsFactory.hpp b/src/cppcache/include/geode/statistics/StatisticsFactory.hpp
index f14041a..5c395b1 100644
--- a/src/cppcache/include/geode/statistics/StatisticsFactory.hpp
+++ b/src/cppcache/include/geode/statistics/StatisticsFactory.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_STATISTICS_STATISTICSFACTORY_H_
-#define GEODE_STATISTICS_STATISTICSFACTORY_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -19,6 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_STATISTICS_STATISTICSFACTORY_H_
+#define GEODE_STATISTICS_STATISTICSFACTORY_H_
+
#include <geode/geode_globals.hpp>
#include <geode/statistics/StatisticDescriptor.hpp>
#include <geode/statistics/StatisticsType.hpp>
@@ -54,15 +54,9 @@ namespace statistics {
class CPPCACHE_EXPORT StatisticsFactory {
protected:
StatisticsFactory() {}
- StatisticsFactory(const StatisticsFactory&) {}
+ StatisticsFactory(const StatisticsFactory&) = delete;
public:
- /**
- * Return a pre-existing statistics factory. Typically configured through
- * creation of a distributed system.
- */
- static StatisticsFactory* getExistingInstance();
-
virtual ~StatisticsFactory() {}
/**
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/BuiltinCacheableWrappers.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/BuiltinCacheableWrappers.hpp b/src/cppcache/integration-test/BuiltinCacheableWrappers.hpp
index 6b4a669..5cef85b 100644
--- a/src/cppcache/integration-test/BuiltinCacheableWrappers.hpp
+++ b/src/cppcache/integration-test/BuiltinCacheableWrappers.hpp
@@ -20,13 +20,15 @@
* limitations under the License.
*/
-#include "CacheableWrapper.hpp"
#include <limits.h>
#include <cstdlib>
#include <wchar.h>
#include <ace/Date_Time.h>
-
+#include "CacheHelper.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheableWrapper.hpp"
+#include "CacheImpl.hpp"
using namespace apache::geode::client;
namespace CacheableHelper {
@@ -148,18 +150,18 @@ inline uint32_t crc32(const uint8_t* buffer, uint32_t bufLen) {
template <typename TPRIM>
inline uint32_t crc32(TPRIM value) {
- DataOutput output;
- apache::geode::client::serializer::writeObject(output, value);
- return crc32(output.getBuffer(), output.getBufferLength());
+ auto output = CacheHelper::getHelper().getCache()->createDataOutput();
+ apache::geode::client::serializer::writeObject(*output, value);
+ return crc32(output->getBuffer(), output->getBufferLength());
}
template <typename TPRIM>
inline uint32_t crc32Array(const TPRIM* arr, uint32_t len) {
- DataOutput output;
+ auto output = CacheHelper::getHelper().getCache()->createDataOutput();
for (uint32_t index = 0; index < len; index++) {
- apache::geode::client::serializer::writeObject(output, arr[index]);
+ apache::geode::client::serializer::writeObject(*output, arr[index]);
}
- return crc32(output.getBuffer(), output.getBufferLength());
+ return crc32(output->getBuffer(), output->getBufferLength());
}
inline bool isContainerTypeId(int8_t typeId) {
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/CMakeLists.txt b/src/cppcache/integration-test/CMakeLists.txt
index 6a6f3e7..0df3bcb 100644
--- a/src/cppcache/integration-test/CMakeLists.txt
+++ b/src/cppcache/integration-test/CMakeLists.txt
@@ -117,7 +117,6 @@ set_property(TEST testFWHelper PROPERTY LABELS STABLE QUICK)
set_property(TEST testLRUList PROPERTY LABELS STABLE QUICK)
set_property(TEST testSystemProperties PROPERTY LABELS STABLE QUICK)
set_property(TEST testLogger PROPERTY LABELS STABLE QUICK)
-set_property(TEST testEntriesMap PROPERTY LABELS STABLE QUICK)
set_property(TEST testCache PROPERTY LABELS STABLE QUICK)
set_property(TEST testLinkage PROPERTY LABELS STABLE QUICK)
set_property(TEST testRegionTemplateArgs PROPERTY LABELS STABLE QUICK)
@@ -129,7 +128,6 @@ set_property(TEST testConnect PROPERTY LABELS STABLE QUICK)
set_property(TEST testThinClientRemoveAllLocal PROPERTY LABELS STABLE QUICK)
set_property(TEST testDunit PROPERTY LABELS STABLE QUICK)
set_property(TEST testAttributesMutator PROPERTY LABELS STABLE QUICK)
-set_property(TEST testEntriesMapForVersioning PROPERTY LABELS STABLE QUICK)
set_property(TEST testSpinLock PROPERTY LABELS STABLE QUICK)
set_property(TEST testThinClientSSLAuthFail PROPERTY LABELS STABLE QUICK)
set_property(TEST testThinClientSSLAuthCorrupt PROPERTY LABELS STABLE QUICK)
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/CacheHelper.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/CacheHelper.cpp b/src/cppcache/integration-test/CacheHelper.cpp
index bba3dcd..df345b2 100644
--- a/src/cppcache/integration-test/CacheHelper.cpp
+++ b/src/cppcache/integration-test/CacheHelper.cpp
@@ -29,6 +29,7 @@
#include "DistributedSystemImpl.hpp"
#include "TimeBomb.hpp"
#include "Utils.hpp"
+#include "CacheImpl.hpp"
#include "CacheHelper.hpp"
#define __DUNIT_NO_MAIN__
@@ -125,6 +126,9 @@ CacheHelper::CacheHelper(const PropertiesPtr& configPtr,
cachePtr = CacheFactory::createCacheFactory(pp)->create();
+ auto poolFactory = cachePtr->getPoolManager().createFactory();
+ poolFactory->create("__CACHE_HELPER_POOL__");
+
m_doDisconnect = false;
if (noRootRegion) return;
@@ -196,32 +200,37 @@ CacheHelper::CacheHelper(const bool isthinClient, const char* poolName,
try {
CacheFactoryPtr cacheFac = CacheFactory::createCacheFactory(pp);
- cacheFac->setPRSingleHopEnabled(prSingleHop);
- cacheFac->setThreadLocalConnections(threadLocal);
+ cachePtr = cacheFac->create();
+
+ auto poolFactory = cachePtr->getPoolManager().createFactory();
+
+ poolFactory->setPRSingleHopEnabled(prSingleHop);
+ poolFactory->setThreadLocalConnections(threadLocal);
printf(" Setting pr-single-hop to prSingleHop = %d ", prSingleHop);
printf("Setting threadLocal to %d ", threadLocal);
if (locators) {
- addServerLocatorEPs(locators, cacheFac);
+ addServerLocatorEPs(locators, poolFactory);
if (serverGroup) {
- cacheFac->setServerGroup(serverGroup);
+ poolFactory->setServerGroup(serverGroup);
}
}
- cacheFac->setSubscriptionRedundancy(redundancy);
- cacheFac->setSubscriptionEnabled(clientNotification);
- cacheFac->setMultiuserAuthentication(isMultiuserMode);
+ poolFactory->setSubscriptionRedundancy(redundancy);
+ poolFactory->setSubscriptionEnabled(clientNotification);
+ poolFactory->setMultiuserAuthentication(isMultiuserMode);
if (loadConditioningInterval > 0) {
- cacheFac->setLoadConditioningInterval(loadConditioningInterval);
+ poolFactory->setLoadConditioningInterval(loadConditioningInterval);
}
printf("Setting connections to %d ", connections);
if (connections >= 0) {
- cacheFac->setMinConnections(connections);
- cacheFac->setMaxConnections(connections);
+ poolFactory->setMinConnections(connections);
+ poolFactory->setMaxConnections(connections);
}
if (subscriptionAckInterval != -1) {
- cacheFac->setSubscriptionAckInterval(subscriptionAckInterval);
+ poolFactory->setSubscriptionAckInterval(subscriptionAckInterval);
}
- cachePtr = cacheFac->create();
+ poolFactory->create(poolName);
+
} catch (const Exception& excp) {
LOG("Geode exception while creating cache, logged in following line");
LOG(excp.getMessage());
@@ -248,7 +257,7 @@ CacheHelper::~CacheHelper() {
}
void CacheHelper::closePool(const char* poolName, bool keepAlive) {
- PoolPtr pool = PoolManager::find(poolName);
+ PoolPtr pool = getCache()->getPoolManager().find(poolName);
pool->destroy(keepAlive);
}
@@ -259,11 +268,6 @@ void CacheHelper::disconnect(bool keepalive) {
LOG("Beginning cleanup after CacheHelper.");
- DistributedSystemPtr systemPtr;
- if (m_doDisconnect) {
- systemPtr = cachePtr->getDistributedSystem();
- }
-
// rootRegionPtr->localDestroyRegion();
rootRegionPtr = nullptr;
LOG("Destroyed root region.");
@@ -280,17 +284,17 @@ void CacheHelper::disconnect(bool keepalive) {
LOG("exception throw while closing cache");
}
- cachePtr = nullptr;
LOG("Closed cache.");
try {
if (m_doDisconnect) {
LOG("Disconnecting...");
- systemPtr->disconnect();
+ cachePtr->getDistributedSystem().disconnect();
LOG("Finished disconnect.");
}
} catch (...) {
LOG("Throwing exception while disconnecting....");
}
+ cachePtr = nullptr;
singleton = nullptr;
LOG("Finished cleanup after CacheHelper.");
}
@@ -409,7 +413,7 @@ PoolPtr CacheHelper::createPool(const char* poolName, const char* locators,
int loadConditioningInterval,
bool isMultiuserMode) {
// printf(" in createPool isMultiuserMode = %d \n", isMultiuserMode);
- PoolFactoryPtr poolFacPtr = PoolManager::createFactory();
+ PoolFactoryPtr poolFacPtr = getCache()->getPoolManager().createFactory();
addServerLocatorEPs(locators, poolFacPtr);
if (serverGroup) {
@@ -440,7 +444,7 @@ PoolPtr CacheHelper::createPool2(const char* poolName, const char* locators,
const char* serverGroup, const char* servers,
int redundancy, bool clientNotification,
int subscriptionAckInterval, int connections) {
- PoolFactoryPtr poolFacPtr = PoolManager::createFactory();
+ PoolFactoryPtr poolFacPtr = getCache()->getPoolManager().createFactory();
if (servers != 0) // with explicit server list
{
@@ -577,33 +581,34 @@ void CacheHelper::addServerLocatorEPs(const char* epList, PoolFactoryPtr pfPtr,
}
}
-void CacheHelper::addServerLocatorEPs(const char* epList,
- CacheFactoryPtr cacheFac,
- bool poolLocators) {
- std::unordered_set<std::string> endpointNames;
- Utils::parseEndpointNamesString(epList, endpointNames);
- for (std::unordered_set<std::string>::iterator iter = endpointNames.begin();
- iter != endpointNames.end(); ++iter) {
- size_t position = (*iter).find_first_of(":");
- if (position != std::string::npos) {
- std::string hostname = (*iter).substr(0, position);
- int portnumber = atoi(((*iter).substr(position + 1)).c_str());
- if (poolLocators) {
- cacheFac->addLocator(hostname.c_str(), portnumber);
- } else {
- printf("ankur Server: %d", portnumber);
- cacheFac->addServer(hostname.c_str(), portnumber);
- }
- }
- }
-}
+// void CacheHelper::addServerLocatorEPs(const char* epList,
+// CacheFactoryPtr cacheFac,
+// bool poolLocators) {
+// std::unordered_set<std::string> endpointNames;
+// Utils::parseEndpointNamesString(epList, endpointNames);
+// for (std::unordered_set<std::string>::iterator iter = endpointNames.begin();
+// iter != endpointNames.end(); ++iter) {
+// size_t position = (*iter).find_first_of(":");
+// if (position != std::string::npos) {
+// std::string hostname = (*iter).substr(0, position);
+// int portnumber = atoi(((*iter).substr(position + 1)).c_str());
+// if (poolLocators) {
+// getCache()->getPoolFactory()->addLocator(hostname.c_str(),
+// portnumber);
+// } else {
+// printf("ankur Server: %d", portnumber);
+// getCache()->getPoolFactory()->addServer(hostname.c_str(), portnumber);
+// }
+// }
+// }
+//}
RegionPtr CacheHelper::createPooledRegion(
const char* name, bool ack, const char* locators, const char* poolName,
bool caching, bool clientNotificationEnabled, int ettl, int eit, int rttl,
int rit, int lel, const CacheListenerPtr& cacheListener,
ExpirationAction::Action action) {
- PoolFactoryPtr poolFacPtr = PoolManager::createFactory();
+ PoolFactoryPtr poolFacPtr = getCache()->getPoolManager().createFactory();
poolFacPtr->setSubscriptionEnabled(clientNotificationEnabled);
if (locators) {
@@ -611,7 +616,7 @@ RegionPtr CacheHelper::createPooledRegion(
addServerLocatorEPs(locators, poolFacPtr);
}
- if ((PoolManager::find(poolName)) ==
+ if ((getCache()->getPoolManager().find(poolName)) ==
nullptr) { // Pool does not exist with the same name.
PoolPtr pptr = poolFacPtr->create(poolName);
}
@@ -641,13 +646,13 @@ RegionPtr CacheHelper::createPooledRegionConcurrencyCheckDisabled(
bool caching, bool clientNotificationEnabled, bool concurrencyCheckEnabled,
int ettl, int eit, int rttl, int rit, int lel,
const CacheListenerPtr& cacheListener, ExpirationAction::Action action) {
- PoolFactoryPtr poolFacPtr = PoolManager::createFactory();
+ PoolFactoryPtr poolFacPtr = getCache()->getPoolManager().createFactory();
poolFacPtr->setSubscriptionEnabled(clientNotificationEnabled);
LOG("adding pool locators");
addServerLocatorEPs(locators, poolFacPtr);
- if ((PoolManager::find(poolName)) ==
+ if ((getCache()->getPoolManager().find(poolName)) ==
nullptr) { // Pool does not exist with the same name.
PoolPtr pptr = poolFacPtr->create(poolName);
}
@@ -708,7 +713,7 @@ RegionPtr CacheHelper::createPooledRegionDiscOverFlow(
bool caching, bool clientNotificationEnabled, int ettl, int eit, int rttl,
int rit, int lel, const CacheListenerPtr& cacheListener,
ExpirationAction::Action action) {
- PoolFactoryPtr poolFacPtr = PoolManager::createFactory();
+ PoolFactoryPtr poolFacPtr = getCache()->getPoolManager().createFactory();
poolFacPtr->setSubscriptionEnabled(clientNotificationEnabled);
if (locators) // with locator
@@ -716,7 +721,7 @@ RegionPtr CacheHelper::createPooledRegionDiscOverFlow(
LOG("adding pool locators");
addServerLocatorEPs(locators, poolFacPtr);
}
- if ((PoolManager::find(poolName)) ==
+ if ((getCache()->getPoolManager().find(poolName)) ==
nullptr) { // Pool does not exist with the same name.
PoolPtr pptr = poolFacPtr->create(poolName);
}
@@ -763,7 +768,7 @@ RegionPtr CacheHelper::createPooledRegionSticky(
bool caching, bool clientNotificationEnabled, int ettl, int eit, int rttl,
int rit, int lel, const CacheListenerPtr& cacheListener,
ExpirationAction::Action action) {
- PoolFactoryPtr poolFacPtr = PoolManager::createFactory();
+ PoolFactoryPtr poolFacPtr = getCache()->getPoolManager().createFactory();
poolFacPtr->setSubscriptionEnabled(clientNotificationEnabled);
poolFacPtr->setThreadLocalConnections(true);
poolFacPtr->setPRSingleHopEnabled(false);
@@ -771,7 +776,7 @@ RegionPtr CacheHelper::createPooledRegionSticky(
LOG("adding pool locators");
addServerLocatorEPs(locators, poolFacPtr);
- if ((PoolManager::find(poolName)) ==
+ if ((getCache()->getPoolManager().find(poolName)) ==
nullptr) { // Pool does not exist with the same name.
PoolPtr pptr = poolFacPtr->create(poolName);
LOG("createPooledRegionSticky logPoolAttributes");
@@ -804,14 +809,14 @@ RegionPtr CacheHelper::createPooledRegionStickySingleHop(
int rit, int lel, const CacheListenerPtr& cacheListener,
ExpirationAction::Action action) {
LOG("createPooledRegionStickySingleHop");
- PoolFactoryPtr poolFacPtr = PoolManager::createFactory();
+ PoolFactoryPtr poolFacPtr = getCache()->getPoolManager().createFactory();
poolFacPtr->setSubscriptionEnabled(clientNotificationEnabled);
poolFacPtr->setThreadLocalConnections(true);
poolFacPtr->setPRSingleHopEnabled(true);
LOG("adding pool locators");
addServerLocatorEPs(locators, poolFacPtr);
- if ((PoolManager::find(poolName)) ==
+ if ((getCache()->getPoolManager().find(poolName)) ==
nullptr) { // Pool does not exist with the same name.
PoolPtr pptr = poolFacPtr->create(poolName);
LOG("createPooledRegionStickySingleHop logPoolAttributes");
@@ -1735,13 +1740,20 @@ void CacheHelper::initLocator(int instance, bool ssl, bool multiDS, int dsId,
}
void CacheHelper::clearSecProp() {
- PropertiesPtr tmpSecProp =
- DistributedSystem::getSystemProperties()->getSecurityProperties();
+ PropertiesPtr tmpSecProp = CacheHelper::getHelper()
+ .getCache()
+ ->getDistributedSystem()
+ .getSystemProperties()
+ .getSecurityProperties();
tmpSecProp->remove("security-username");
tmpSecProp->remove("security-password");
}
void CacheHelper::setJavaConnectionPoolSize(long size) {
- DistributedSystem::getSystemProperties()->setjavaConnectionPoolSize(size);
+ CacheHelper::getHelper()
+ .getCache()
+ ->getDistributedSystem()
+ .getSystemProperties()
+ .setjavaConnectionPoolSize(size);
}
bool CacheHelper::setSeed() {
@@ -1800,10 +1812,6 @@ int CacheHelper::getRandomAvailablePort() {
}
}
-PoolPtr CacheHelper::getPoolPtr(const char* poolName) {
- return PoolManager::find(poolName);
-}
-
std::string CacheHelper::unitTestOutputFile() {
char currWDPath[512];
char* wdPath ATTR_UNUSED = ACE_OS::getcwd(currWDPath, 512);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/CacheHelper.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/CacheHelper.hpp b/src/cppcache/integration-test/CacheHelper.hpp
index d63a67f..910a0b3 100644
--- a/src/cppcache/integration-test/CacheHelper.hpp
+++ b/src/cppcache/integration-test/CacheHelper.hpp
@@ -55,7 +55,6 @@ class CacheHelper {
static CacheHelper& getHelper();
- static PoolPtr getPoolPtr(const char* poolName);
static std::string unitTestOutputFile();
static int getNumLocatorListUpdates(const char* s);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/DeltaEx.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/DeltaEx.hpp b/src/cppcache/integration-test/DeltaEx.hpp
index a502b31..263f652 100644
--- a/src/cppcache/integration-test/DeltaEx.hpp
+++ b/src/cppcache/integration-test/DeltaEx.hpp
@@ -40,14 +40,8 @@ class DeltaEx : public Cacheable, public Delta {
static int fromDeltaCount;
static int fromDataCount;
static int cloneCount;
- DeltaEx() {
- counter = 1;
- isDelta = false;
- }
- DeltaEx(int count) {
- counter = 0;
- isDelta = false;
- }
+ DeltaEx() : Delta(nullptr), counter(1), isDelta(false) {}
+ DeltaEx(int count) : Delta(nullptr), counter(0), isDelta(false) {}
virtual bool hasDelta() { return isDelta; }
virtual void toDelta(DataOutput& out) const {
out.writeInt(counter);
@@ -103,14 +97,8 @@ class PdxDeltaEx : public PdxSerializable, public Delta {
static int m_fromDeltaCount;
static int m_fromDataCount;
static int m_cloneCount;
- PdxDeltaEx() {
- m_counter = 1;
- m_isDelta = false;
- }
- PdxDeltaEx(int count) {
- m_counter = 0;
- m_isDelta = false;
- }
+ PdxDeltaEx() : Delta(nullptr), m_counter(1), m_isDelta(false) {}
+ PdxDeltaEx(int count) : Delta(nullptr), m_counter(0), m_isDelta(false) {}
virtual bool hasDelta() { return m_isDelta; }
virtual void toDelta(DataOutput& out) const {
out.writeInt(m_counter);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/QueryHelper.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/QueryHelper.hpp b/src/cppcache/integration-test/QueryHelper.hpp
index 90d5daf..df220c6 100644
--- a/src/cppcache/integration-test/QueryHelper.hpp
+++ b/src/cppcache/integration-test/QueryHelper.hpp
@@ -34,6 +34,8 @@
#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
@@ -247,7 +249,9 @@ void QueryHelper::populatePositionPdxData(RegionPtr& rptr, int setSize,
void QueryHelper::populatePDXObject(RegionPtr& rptr) {
// Register PdxType Object
- Serializable::registerPdxType(PdxTests::PdxType::createDeserializable);
+
+ CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(rptr->getCache().get());
+ cacheImpl->getSerializationRegistry()->addPdxType(PdxTests::PdxType::createDeserializable);
LOG("PdxObject Registered Successfully....");
// Creating object of type PdxObject
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/ThinClientDistOps.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientDistOps.hpp b/src/cppcache/integration-test/ThinClientDistOps.hpp
index 20364cc..2bc4fa8 100644
--- a/src/cppcache/integration-test/ThinClientDistOps.hpp
+++ b/src/cppcache/integration-test/ThinClientDistOps.hpp
@@ -282,7 +282,7 @@ void createAndVerifyEntry(const char* name) {
auto longRetValue =
std::dynamic_pointer_cast<CacheableInt64>(regPtr->get(int64Key));
FAIL("Expected EntryExistException here");
- } catch (EntryExistsException& ) {
+ } catch (EntryExistsException&) {
LOG(" Expected EntryExistsException exception thrown by localCreate");
}
@@ -316,7 +316,7 @@ void createAndVerifyEntry(const char* name) {
/*5.create new with entry userobject cantain all cacheable type ( like
* cacheableInt,CacheableDouble, CacheableString,CacheableHashMap etc) key and
* null value*/
- // Serializable::registerPdxType(PdxTests::PdxType::createDeserializable);
+ // serializationRegistry->addPdxType(PdxTests::PdxType::createDeserializable);
auto keyObject1 = std::make_shared<PdxTests::PdxType>();
regPtr->create(keyObject1, x);
CacheablePtr retVal = regPtr->get(keyObject1);
@@ -339,7 +339,7 @@ void createAndVerifyEntry(const char* name) {
regPtr->create(keyObject2, in64Value);
FAIL("Expected EntryExistException here");
}
- } catch (EntryExistsException& ) {
+ } catch (EntryExistsException&) {
LOG(" Expected EntryExistsException exception thrown by localCreate");
}
@@ -594,7 +594,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, VerifyUpdateLocatorListThread)
int sleepSeconds = 60;
dunit::sleep(sleepSeconds * 1000);
- PoolPtr pptr = CacheHelper::getPoolPtr("__TESTPOOL1_");
+ PoolPtr pptr =
+ getHelper()->getCache()->getPoolManager().find("__TESTPOOL1_");
int updateIntervalSeconds = pptr->getUpdateLocatorListInterval() / 1000;
int numLocatorListUpdates =
@@ -784,7 +785,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepEight_Pool_Sticky)
RegionPtr reg1 = getHelper()->getRegion(regionNames[1]);
reg0->localInvalidate(createKey(keys[1]));
reg1->localInvalidate(createKey(keys[3]));
- PoolPtr pool = PoolManager::find("__TESTPOOL1_");
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find("__TESTPOOL1_");
ASSERT(pool != nullptr, "Pool Should have been found");
doNetsearch(regionNames[0], keys[1], nvals[1]);
doNetsearch(regionNames[1], keys[3], nvals[3]);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/ThinClientDistOps2.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientDistOps2.hpp b/src/cppcache/integration-test/ThinClientDistOps2.hpp
index 7b3a9f1..b645e11 100644
--- a/src/cppcache/integration-test/ThinClientDistOps2.hpp
+++ b/src/cppcache/integration-test/ThinClientDistOps2.hpp
@@ -93,8 +93,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, CreateClient1Regions_Pooled_Locator)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ true);
createPooledRegion(_regionNames[0], USE_ACK, locatorsG, poolName);
createPooledRegion(_regionNames[1], NO_ACK, locatorsG, poolName);
LOG("CreateClient1Regions complete.");
@@ -103,8 +103,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, CreateClient2Regions_Pooled_Locator)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ true);
createPooledRegion(_regionNames[0], USE_ACK, locatorsG, poolName);
createPooledRegion(_regionNames[1], NO_ACK, locatorsG, poolName);
LOG("CreateClient1Regions complete.");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/ThinClientDurable.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientDurable.hpp b/src/cppcache/integration-test/ThinClientDurable.hpp
index 5faad78..07c0d01 100644
--- a/src/cppcache/integration-test/ThinClientDurable.hpp
+++ b/src/cppcache/integration-test/ThinClientDurable.hpp
@@ -222,8 +222,8 @@ void feederUpdate(int value, int ignoreR2 = false) {
DUNIT_TASK_DEFINITION(FEEDER, FeederInit)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ true);
getHelper()->createPooledRegion(regionNames[0], USE_ACK, locatorsG,
"__TEST_POOL1__", true, true);
getHelper()->createPooledRegion(regionNames[1], USE_ACK, locatorsG,
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/ThinClientDurableFailover.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientDurableFailover.hpp b/src/cppcache/integration-test/ThinClientDurableFailover.hpp
index 07fc425..01cf5b9 100644
--- a/src/cppcache/integration-test/ThinClientDurableFailover.hpp
+++ b/src/cppcache/integration-test/ThinClientDurableFailover.hpp
@@ -229,8 +229,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(FEEDER, FeederInit)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ true);
getHelper()->createPooledRegion(regionNames[0], USE_ACK, locatorsG,
"__TEST_POOL1__", true, true);
LOG("FeederInit complete.");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/ThinClientDurableInterest.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientDurableInterest.hpp b/src/cppcache/integration-test/ThinClientDurableInterest.hpp
index 29507e0..bf8d0c7 100644
--- a/src/cppcache/integration-test/ThinClientDurableInterest.hpp
+++ b/src/cppcache/integration-test/ThinClientDurableInterest.hpp
@@ -203,8 +203,8 @@ void feederUpdate1(int value) {
DUNIT_TASK_DEFINITION(FEEDER, FeederInit)
{
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ true);
getHelper()->createPooledRegion(regionNames[0], USE_ACK, locatorsG,
"__TEST_POOL1__", true, true);
getHelper()->createPooledRegion(regionNames[1], NO_ACK, locatorsG,
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/ThinClientFailoverInterestAllWithCache.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientFailoverInterestAllWithCache.hpp b/src/cppcache/integration-test/ThinClientFailoverInterestAllWithCache.hpp
index c5998d5..7ea1372 100644
--- a/src/cppcache/integration-test/ThinClientFailoverInterestAllWithCache.hpp
+++ b/src/cppcache/integration-test/ThinClientFailoverInterestAllWithCache.hpp
@@ -51,8 +51,8 @@ const char* locatorsG =
#include "ThinClientTasks_C2S2.hpp"
void initClient(const bool isthinClient) {
if (cacheHelper == nullptr) {
- cacheHelper = new CacheHelper(isthinClient, "__TEST_POOL1__", nullptr,
- "ServerGroup1", nullptr, 0, true);
+ cacheHelper = new CacheHelper(isthinClient, "__TEST_POOL1__", locatorsG,
+ nullptr, nullptr, 0, true);
}
ASSERT(cacheHelper, "Failed to create a CacheHelper client instance.");
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/ThinClientHelper.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientHelper.hpp b/src/cppcache/integration-test/ThinClientHelper.hpp
index 8d1a173..34f2452 100644
--- a/src/cppcache/integration-test/ThinClientHelper.hpp
+++ b/src/cppcache/integration-test/ThinClientHelper.hpp
@@ -430,7 +430,7 @@ RegionPtr createPooledRegion(const char* name, bool ackMode,
PoolPtr findPool(const char* poolName) {
LOG("findPool() entered.");
- PoolPtr poolPtr = PoolManager::find(poolName);
+ PoolPtr poolPtr = getHelper()->getCache()->getPoolManager().find(poolName);
ASSERT(poolPtr != nullptr, "Failed to find pool.");
return poolPtr;
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/ThinClientLocalCacheLoader.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientLocalCacheLoader.hpp b/src/cppcache/integration-test/ThinClientLocalCacheLoader.hpp
index 2a90a08..6b9a3c7 100644
--- a/src/cppcache/integration-test/ThinClientLocalCacheLoader.hpp
+++ b/src/cppcache/integration-test/ThinClientLocalCacheLoader.hpp
@@ -33,7 +33,6 @@ using namespace test;
TallyLoaderPtr reg1Loader1;
int numLoads = 0;
-DistributedSystemPtr dSysPtr;
CachePtr cachePtr;
RegionPtr regionPtr;
@@ -123,7 +122,6 @@ DUNIT_TASK_DEFINITION(CLIENT1, InitClientEvents)
{
numLoads = 0;
regionPtr = nullptr;
- dSysPtr = nullptr;
cachePtr = nullptr;
}
END_TASK_DEFINITION
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/ThinClientMultipleCaches.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientMultipleCaches.hpp b/src/cppcache/integration-test/ThinClientMultipleCaches.hpp
new file mode 100644
index 0000000..9b33e45
--- /dev/null
+++ b/src/cppcache/integration-test/ThinClientMultipleCaches.hpp
@@ -0,0 +1,104 @@
+#pragma once
+
+#ifndef GEODE_INTEGRATION_TEST_THINCLIENTMULTIPLECACHES_H_
+#define GEODE_INTEGRATION_TEST_THINCLIENTMULTIPLECACHES_H_
+
+/*
+ * 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.
+ */
+
+#include <string>
+
+#include "fw_dunit.hpp"
+#include <geode/GeodeCppCache.hpp>
+#include <geode/CacheFactory.hpp>
+
+#include "CacheHelper.hpp"
+
+using namespace apache::geode::client;
+using namespace test;
+
+#define CLIENT1 s1p1
+#define SERVER1 s2p1
+
+static bool isLocalServer = false;
+static bool isLocator = false;
+
+const char* locatorsG =
+ CacheHelper::getLocatorHostPort(isLocator, isLocalServer);
+
+#include "LocatorHelper.hpp"
+
+DUNIT_TASK_DEFINITION(SERVER1, CreateServer1)
+ {
+ CacheHelper::initServer(1, "cacheserver_notify_subscription.xml");
+ LOG("SERVER1 started");
+ }
+END_TASK_DEFINITION
+
+RegionPtr createRegionFromCache(std::shared_ptr<Cache> cache) {
+ auto poolFactory = cache->getPoolManager().createFactory();
+ CacheHelper::getHelper().addServerLocatorEPs(locatorsG, poolFactory, true);
+ poolFactory->create("DistRegionAck");
+ return cache->createRegionFactory(PROXY)->create("DistRegionAck");
+}
+
+DUNIT_TASK_DEFINITION(CLIENT1, SetupAndTestMutlipleCaches)
+ {
+ auto factory = CacheFactory::createCacheFactory();
+ auto cache1 = factory->create();
+ auto region1 = createRegionFromCache(cache1);
+
+ auto cache2 = factory->create();
+ auto region2 = createRegionFromCache(cache2);
+
+ region1->put("a", "key");
+
+ LOG("Closing first cache.");
+ cache1->close();
+
+ ASSERT(cache1->isClosed(), "Cache 1 is not closed.");
+ ASSERT(!cache2->isClosed(), "Cache 2 is closed.");
+
+ LOG("Doing get() on second cache.");
+ auto value = region2->get("a")->toString();
+
+ ASSERT(std::strcmp(value->asChar(), "key") == 0,
+ std::string("Expected value 'key' didn't equal actual value '")
+ .append(value->asChar())
+ .append("'")
+ .c_str());
+ }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(SERVER1, CloseServer)
+ {
+ CacheHelper::closeServer(1);
+ LOG("SERVER1 stopped");
+ }
+END_TASK_DEFINITION
+
+void run() {
+ CALL_TASK(CreateLocator1);
+ CALL_TASK(CreateServer1_With_Locator_XML);
+
+ CALL_TASK(SetupAndTestMutlipleCaches);
+
+ CALL_TASK(CloseServer);
+ CALL_TASK(CloseLocator1);
+}
+
+#endif // GEODE_INTEGRATION_TEST_THINCLIENTMULTIPLECACHES_H_
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/ThinClientNotification.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientNotification.hpp b/src/cppcache/integration-test/ThinClientNotification.hpp
index 4e0b195..3552b99 100644
--- a/src/cppcache/integration-test/ThinClientNotification.hpp
+++ b/src/cppcache/integration-test/ThinClientNotification.hpp
@@ -45,7 +45,7 @@ CacheHelper* cacheHelper = nullptr;
void initClient(const bool isthinClient) {
if (cacheHelper == nullptr) {
cacheHelper = new CacheHelper(isthinClient, "__TEST_POOL1__", locatorsG,
- "ServerGroup1", nullptr, 0, true);
+ nullptr, nullptr, 0, true);
}
ASSERT(cacheHelper, "Failed to create a CacheHelper client instance.");
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/ThinClientPdxSerializer.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientPdxSerializer.hpp b/src/cppcache/integration-test/ThinClientPdxSerializer.hpp
index 571cff7..7e80b6b 100644
--- a/src/cppcache/integration-test/ThinClientPdxSerializer.hpp
+++ b/src/cppcache/integration-test/ThinClientPdxSerializer.hpp
@@ -38,7 +38,7 @@
#include "testobject/PdxClassV2.hpp"
#include "testobject/NonPdxType.hpp"
#include "ThinClientPdxSerializers.hpp"
-
+#include "CacheRegionHelper.hpp"
using namespace apache::geode::client;
using namespace test;
using namespace PdxTests;
@@ -164,14 +164,21 @@ void checkPdxInstanceToStringAtServer(RegionPtr regionPtr) {
DUNIT_TASK_DEFINITION(CLIENT1, JavaPutGet)
{
- Serializable::registerPdxSerializer(std::make_shared<TestPdxSerializer>());
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->setPdxSerializer(std::make_shared<TestPdxSerializer>());
auto regPtr0 = getHelper()->getRegion("DistRegionAck");
-
auto keyport = CacheableKey::create(1);
- auto npt1 = new PdxTests::NonPdxType;
- auto pdxobj = std::make_shared<PdxWrapper>(npt1, CLASSNAME1);
+ auto npt1 = new PdxTests::NonPdxType(
+ CacheRegionHelper::getCacheImpl(getHelper()->getCache().get())
+ ->getSerializationRegistry()
+ ->getPdxSerializer());
+ auto pdxobj = std::make_shared<PdxWrapper>(
+ npt1, CLASSNAME1,
+ CacheRegionHelper::getCacheImpl(getHelper()->getCache().get())
+ ->getSerializationRegistry()
+ ->getPdxSerializer());
regPtr0->put(keyport, pdxobj);
auto obj2 = std::dynamic_pointer_cast<PdxWrapper>(regPtr0->get(keyport));
@@ -189,7 +196,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, JavaGet)
{
- Serializable::registerPdxSerializer(std::make_shared<TestPdxSerializer>());
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->setPdxSerializer(std::make_shared<TestPdxSerializer>());
LOGDEBUG("JavaGet-1 Line_309");
auto regPtr0 = getHelper()->getRegion("DistRegionAck");
@@ -214,15 +222,16 @@ DUNIT_TASK_DEFINITION(CLIENT1, putFromVersion1_PS)
auto regPtr0 = getHelper()->getRegion("DistRegionAck");
auto key = CacheableKey::create(1);
- // purpose?
- // PdxTests::TestDiffTypePdxSV2* npt1 =
- // new PdxTests::TestDiffTypePdxSV2(false);
- Serializable::registerPdxSerializer(
- std::make_shared<TestPdxSerializerForV1>());
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->setPdxSerializer(std::make_shared<TestPdxSerializerForV1>());
// Create New object and wrap it in PdxWrapper (owner)
auto npt1 = new PdxTests::TestDiffTypePdxSV1(true);
- auto pdxobj = std::make_shared<PdxWrapper>(npt1, V1CLASSNAME2);
+ auto pdxobj = std::make_shared<PdxWrapper>(
+ npt1, V1CLASSNAME2,
+ CacheRegionHelper::getCacheImpl(getHelper()->getCache().get())
+ ->getSerializationRegistry()
+ ->getPdxSerializer());
// PUT
regPtr0->put(key, pdxobj);
@@ -246,15 +255,17 @@ DUNIT_TASK_DEFINITION(CLIENT2, putFromVersion2_PS)
auto regPtr0 = getHelper()->getRegion("DistRegionAck");
auto key = CacheableKey::create(1);
- // purpose?
- // PdxTests::TestDiffTypePdxSV2* npt1 =
- // new PdxTests::TestDiffTypePdxSV2(false);
- Serializable::registerPdxSerializer(
- PdxSerializerPtr(new TestPdxSerializerForV2));
+
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->setPdxSerializer(PdxSerializerPtr(new TestPdxSerializerForV2));
// Create New object and wrap it in PdxWrapper (owner)
auto npt1 = new PdxTests::TestDiffTypePdxSV2(true);
- auto pdxobj = std::make_shared<PdxWrapper>(npt1, V2CLASSNAME4);
+ auto pdxobj = std::make_shared<PdxWrapper>(
+ npt1, V2CLASSNAME4,
+ CacheRegionHelper::getCacheImpl(getHelper()->getCache().get())
+ ->getSerializationRegistry()
+ ->getPdxSerializer());
// PUT
regPtr0->put(key, pdxobj);
@@ -308,7 +319,11 @@ DUNIT_TASK_DEFINITION(CLIENT1, getputFromVersion1_PS)
"should be equal");
// Get then Put.. this should Not merge data back
- auto pdxobj = std::make_shared<PdxWrapper>(npt1, V1CLASSNAME2);
+ auto pdxobj = std::make_shared<PdxWrapper>(
+ npt1, V1CLASSNAME2,
+ CacheRegionHelper::getCacheImpl(getHelper()->getCache().get())
+ ->getSerializationRegistry()
+ ->getPdxSerializer());
regPtr0->put(key2, pdxobj);
}
END_TASK_DEFINITION
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/ThinClientPdxSerializers.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientPdxSerializers.hpp b/src/cppcache/integration-test/ThinClientPdxSerializers.hpp
index b29a6df..e166213 100644
--- a/src/cppcache/integration-test/ThinClientPdxSerializers.hpp
+++ b/src/cppcache/integration-test/ThinClientPdxSerializers.hpp
@@ -84,7 +84,10 @@ class TestPdxSerializer : public PdxSerializer {
return fromDataForAddress(pr);
}
- PdxTests::NonPdxType *npt = new PdxTests::NonPdxType;
+ PdxTests::NonPdxType *npt =
+ new PdxTests::NonPdxType(CacheRegionHelper::getCacheImpl(getHelper()->getCache().get())
+ ->getSerializationRegistry()
+ ->getPdxSerializer());
try {
int32_t *Lengtharr;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/ThinClientPutAll.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientPutAll.hpp b/src/cppcache/integration-test/ThinClientPutAll.hpp
index 35a98aa..bb21ca4 100644
--- a/src/cppcache/integration-test/ThinClientPutAll.hpp
+++ b/src/cppcache/integration-test/ThinClientPutAll.hpp
@@ -27,7 +27,9 @@
#include "testobject/PdxType.hpp"
#include "testobject/VariousPdxTypes.hpp"
#include <string>
-
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
#define ROOT_NAME "ThinClientPutAll"
#define ROOT_SCOPE DISTRIBUTED_ACK
#include "CacheHelper.hpp"
@@ -396,11 +398,12 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, StepThree)
{
try {
- Serializable::registerPdxType(PdxTests::PdxType::createDeserializable);
- Serializable::registerPdxType(PdxTests::PdxTypes1::createDeserializable);
- Serializable::registerPdxType(PdxTests::PdxTypes2::createDeserializable);
- Serializable::registerPdxType(PdxTests::Address::createDeserializable);
- Serializable::registerPdxType(PdxTests::PdxTypes3::createDeserializable);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->addPdxType(PdxTests::PdxType::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxTypes1::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxTypes2::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::Address::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxTypes3::createDeserializable);
} catch (Exception e) {
LOG("Got expected Exception for Serialization, already registered");
}
@@ -433,11 +436,12 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, StepFour)
{
try {
- Serializable::registerPdxType(PdxTests::PdxType::createDeserializable);
- Serializable::registerPdxType(PdxTests::PdxTypes1::createDeserializable);
- Serializable::registerPdxType(PdxTests::PdxTypes2::createDeserializable);
- Serializable::registerPdxType(PdxTests::Address::createDeserializable);
- Serializable::registerPdxType(PdxTests::PdxTypes3::createDeserializable);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->addPdxType(PdxTests::PdxType::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxTypes1::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxTypes2::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::Address::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxTypes3::createDeserializable);
} catch (Exception e) {
LOG("Got expected Exception for Serialization, already registered");
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp b/src/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp
index f24fc20..8d987b4 100644
--- a/src/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp
+++ b/src/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp
@@ -31,7 +31,9 @@
#define ROOT_NAME "ThinClientPutAllWithCallBack"
#define ROOT_SCOPE DISTRIBUTED_ACK
#include "CacheHelper.hpp"
-
+#include "CacheRegionHelper.hpp"
+#include "SerializationRegistry.hpp"
+#include "CacheImpl.hpp"
using namespace apache::geode::client;
using namespace test;
@@ -396,12 +398,15 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, RegisterClient1Keys)
{
+
try {
- Serializable::registerPdxType(PdxTests::PdxType::createDeserializable);
- Serializable::registerPdxType(PdxTests::PdxTypes1::createDeserializable);
- Serializable::registerPdxType(PdxTests::PdxTypes2::createDeserializable);
- Serializable::registerPdxType(PdxTests::Address::createDeserializable);
- Serializable::registerPdxType(PdxTests::PdxTypes3::createDeserializable);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+
+ serializationRegistry->addPdxType(PdxTests::PdxType::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxTypes1::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxTypes2::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::Address::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxTypes3::createDeserializable);
} catch (Exception e) {
LOG("Got expected Exception for Serialization, already registered");
}
@@ -434,11 +439,12 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, RegisterClient2Keys)
{
try {
- Serializable::registerPdxType(PdxTests::PdxType::createDeserializable);
- Serializable::registerPdxType(PdxTests::PdxTypes1::createDeserializable);
- Serializable::registerPdxType(PdxTests::PdxTypes2::createDeserializable);
- Serializable::registerPdxType(PdxTests::Address::createDeserializable);
- Serializable::registerPdxType(PdxTests::PdxTypes3::createDeserializable);
+ SerializationRegistryPtr serializationRegistry = CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())->getSerializationRegistry();
+ serializationRegistry->addPdxType(PdxTests::PdxType::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxTypes1::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxTypes2::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::Address::createDeserializable);
+ serializationRegistry->addPdxType(PdxTests::PdxTypes3::createDeserializable);
} catch (Exception e) {
LOG("Got expected Exception for Serialization, already registered");
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/ThinClientPutGetAll.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientPutGetAll.hpp b/src/cppcache/integration-test/ThinClientPutGetAll.hpp
index 4576cf2..7353e4f 100644
--- a/src/cppcache/integration-test/ThinClientPutGetAll.hpp
+++ b/src/cppcache/integration-test/ThinClientPutGetAll.hpp
@@ -49,7 +49,7 @@ static int numberOfLocators = 0;
const char* locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
-const char* poolName = "__TESTPOOL1_";
+const char* poolName = "__TEST_POOL1__";
const char* _keys[] = {"Key-1", "Key-2", "Key-3", "Key-4"};
const char* _vals[] = {"Value-1", "Value-2", "Value-3", "Value-4"};
@@ -118,22 +118,12 @@ void createPooledRegion(const char* name, bool ackMode, const char* locators,
LOG("Pooled Region created.");
}
-DUNIT_TASK_DEFINITION(SERVER1, CreateServer1)
- {
- // start one server
- if (isLocalServer) {
- CacheHelper::initServer(1, "cacheserver_notify_subscription.xml");
- LOG("SERVER1 started");
- }
- }
-END_TASK_DEFINITION
-
DUNIT_TASK_DEFINITION(CLIENT1, StepOne_Pooled_Locator)
{
// waitForDebugger();
// start 1st client with caching enable true and client notification true
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ true);
createPooledRegion(_regionNames[0], USE_ACK, locatorsG, poolName, true,
true);
LOG("StepOne_Pooled_Locator complete.");
@@ -143,8 +133,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, StepTwo_Pooled_Locator)
{
// start 1st client with caching enable true and client notification true
- initClientWithPool(true, "__TEST_POOL1__", locatorsG, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locatorsG, nullptr, nullptr, 0,
+ true);
createPooledRegion(_regionNames[0], USE_ACK, locatorsG, poolName, true,
true);
LOG("StepTwo_Pooled_Locator complete.");
@@ -236,60 +226,62 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, putallAndGetallPdxWithCallBackArg)
{
LOG("putallAndGetallPdxWithCallBackArg started.");
-
+ SerializationRegistryPtr serializationRegistry =
+ CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
+ ->getSerializationRegistry();
try {
- Serializable::registerPdxType(PdxTypes1::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes1::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes2::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes2::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes3::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes3::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes4::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes4::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes5::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes5::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes6::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes6::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes7::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes7::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes8::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes8::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes9::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes9::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes10::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes10::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
@@ -413,60 +405,62 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, putallAndGetallPdx)
{
LOG("putallAndGetallPdx started.");
-
+ SerializationRegistryPtr serializationRegistry =
+ CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
+ ->getSerializationRegistry();
try {
- Serializable::registerPdxType(PdxTypes1::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes1::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes2::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes2::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes3::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes3::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes4::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes4::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes5::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes5::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes6::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes6::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes7::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes7::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes8::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes8::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes9::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes9::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
try {
- Serializable::registerPdxType(PdxTypes10::createDeserializable);
+ serializationRegistry->addPdxType(PdxTypes10::createDeserializable);
} catch (const IllegalStateException&) {
// ignore exception
}
@@ -497,6 +491,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, putallAndGetallPdx)
map0.emplace(CacheableInt32::create(29), p9);
map0.emplace(CacheableInt32::create(30), p10);
RegionPtr regPtr0 = getHelper()->getRegion(_regionNames[0]);
+ regPtr0->put(CacheableInt32::create(30), p10);
regPtr0->putAll(map0);
LOG("putAll on Pdx objects completed.");
@@ -608,12 +603,12 @@ void runPutGetAll() {
CALL_TASK(StepOne_Pooled_Locator);
CALL_TASK(StepTwo_Pooled_Locator);
- CALL_TASK(PutAllInitialValuesFromClientOne);
- CALL_TASK(GetAllInitialValuesFromClientTwo);
- CALL_TASK(PutAllUpdatedValuesFromClientOne);
- CALL_TASK(GetAllUpdatedValuesFromClientTwo);
+ // CALL_TASK(PutAllInitialValuesFromClientOne);
+ // CALL_TASK(GetAllInitialValuesFromClientTwo);
+ // CALL_TASK(PutAllUpdatedValuesFromClientOne);
+ // CALL_TASK(GetAllUpdatedValuesFromClientTwo);
- CALL_TASK(GetAllAfterLocalDestroyRegionOnClientTwo_Pool);
+ // CALL_TASK(GetAllAfterLocalDestroyRegionOnClientTwo_Pool);
CALL_TASK(putallAndGetallPdx);
// TODO: Does this task add value? Is it same code path as
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/ThinClientSecurity.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientSecurity.hpp b/src/cppcache/integration-test/ThinClientSecurity.hpp
index 14c069e..63a7cc5 100644
--- a/src/cppcache/integration-test/ThinClientSecurity.hpp
+++ b/src/cppcache/integration-test/ThinClientSecurity.hpp
@@ -57,7 +57,7 @@ void createRegionForSecurity(const char* name, bool ackMode,
char buff[128] = {'\0'};
const char* poolName = name;
- if (PoolManager::find(name) != nullptr) {
+ if (getHelper()->getCache()->getPoolManager().find(name) != nullptr) {
static unsigned int index = 0;
sprintf(buff, "%s_%d", poolName, index++);
poolName = buff;
@@ -70,11 +70,12 @@ void createRegionForSecurity(const char* name, bool ackMode,
setCacheListener(name, listener);
}
-PoolPtr getPool(const char* name) { return PoolManager::find(name); }
+PoolPtr getPool(const char* name) {
+ return getHelper()->getCache()->getPoolManager().find(name);
+}
RegionServicePtr getVirtualCache(PropertiesPtr creds, PoolPtr pool) {
CachePtr cachePtr = getHelper()->getCache();
- // return pool->createSecureUserCache(creds);
return cachePtr->createAuthenticatedView(creds, pool->getName());
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/ThinClientTransactions.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientTransactions.hpp b/src/cppcache/integration-test/ThinClientTransactions.hpp
index d0a8227..a41df4c 100644
--- a/src/cppcache/integration-test/ThinClientTransactions.hpp
+++ b/src/cppcache/integration-test/ThinClientTransactions.hpp
@@ -425,7 +425,11 @@ class SuspendTransactionThread : public ACE_Task_Base {
sprintf(buf, " Out SuspendTransactionThread");
LOG(buf);
- PoolManager::find("__TESTPOOL1_")->releaseThreadLocalConnection();
+ getHelper()
+ ->getCache()
+ ->getPoolManager()
+ .find("__TESTPOOL1_")
+ ->releaseThreadLocalConnection();
return 0;
}
@@ -567,7 +571,11 @@ class ResumeTransactionThread : public ACE_Task_Base {
LOG("Got expected EntryNotFoundException for keyPtr4");
}
}
- PoolManager::find("__TESTPOOL1_")->releaseThreadLocalConnection();
+ getHelper()
+ ->getCache()
+ ->getPoolManager()
+ .find("__TESTPOOL1_")
+ ->releaseThreadLocalConnection();
sprintf(buf, " Out ResumeTransactionThread");
LOG(buf);
return 0;
@@ -1065,7 +1073,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, CreateClient1KeyThriceWithSticky)
RegionPtr reg1 = getHelper()->getRegion(regionNames[1]);
reg0->localInvalidate(createKey(keys[1]));
reg1->localInvalidate(createKey(keys[3]));
- PoolPtr pool = PoolManager::find("__TESTPOOL1_");
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find("__TESTPOOL1_");
ASSERT(pool != nullptr, "Pool Should have been found");
doNetsearch(regionNames[0], keys[1], nvals[1]);
doNetsearch(regionNames[1], keys[3], nvals[3]);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/ThinClientTransactionsXA.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientTransactionsXA.hpp b/src/cppcache/integration-test/ThinClientTransactionsXA.hpp
index 6dc3580..331d701 100644
--- a/src/cppcache/integration-test/ThinClientTransactionsXA.hpp
+++ b/src/cppcache/integration-test/ThinClientTransactionsXA.hpp
@@ -425,7 +425,11 @@ class SuspendTransactionThread : public ACE_Task_Base {
sprintf(buf, " Out SuspendTransactionThread");
LOG(buf);
- PoolManager::find("__TESTPOOL1_")->releaseThreadLocalConnection();
+ getHelper()
+ ->getCache()
+ ->getPoolManager()
+ .find("__TESTPOOL1_")
+ ->releaseThreadLocalConnection();
return 0;
}
@@ -570,7 +574,11 @@ class ResumeTransactionThread : public ACE_Task_Base {
LOG("Got expected EntryNotFoundException for keyPtr4");
}
}
- PoolManager::find("__TESTPOOL1_")->releaseThreadLocalConnection();
+ getHelper()
+ ->getCache()
+ ->getPoolManager()
+ .find("__TESTPOOL1_")
+ ->releaseThreadLocalConnection();
sprintf(buf, " Out ResumeTransactionThread");
LOG(buf);
return 0;
@@ -1080,7 +1088,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepEight_Pool_Sticky)
RegionPtr reg1 = getHelper()->getRegion(regionNames[1]);
reg0->localInvalidate(createKey(keys[1]));
reg1->localInvalidate(createKey(keys[3]));
- PoolPtr pool = PoolManager::find("__TESTPOOL1_");
+ PoolPtr pool =
+ getHelper()->getCache()->getPoolManager().find("__TESTPOOL1_");
ASSERT(pool != nullptr, "Pool Should have been found");
doNetsearch(regionNames[0], keys[1], nvals[1]);
doNetsearch(regionNames[1], keys[3], nvals[3]);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/fw_dunit.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/fw_dunit.cpp b/src/cppcache/integration-test/fw_dunit.cpp
index 06851d0..1613a39 100644
--- a/src/cppcache/integration-test/fw_dunit.cpp
+++ b/src/cppcache/integration-test/fw_dunit.cpp
@@ -1034,8 +1034,6 @@ void PerfSuite::addRecord(std::string testName, const long ops,
const TimeStamp& start, const TimeStamp& stop) {
Record tmp(testName, ops, start, stop);
m_records[testName] = tmp;
- int64_t elapsed ATTR_UNUSED = stop.msec() - start.msec();
- int64_t opspersec ATTR_UNUSED = (1000 * ops) / elapsed;
fprintf(stdout, "[PerfSuite] %s\n", tmp.asString().c_str());
fflush(stdout);
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testAttributesMutator.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testAttributesMutator.cpp b/src/cppcache/integration-test/testAttributesMutator.cpp
index 16f8dbe..208fd80 100644
--- a/src/cppcache/integration-test/testAttributesMutator.cpp
+++ b/src/cppcache/integration-test/testAttributesMutator.cpp
@@ -19,7 +19,8 @@
#include "fw_dunit.hpp"
#include <geode/GeodeCppCache.hpp>
-#include <CacheRegionHelper.hpp>
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
// this is a test.
@@ -58,7 +59,8 @@ DUNIT_TASK(A, CreateAndVerifyExpiry)
// countdown begins... it is ttl so access should not play into it..
SLEEP(3000); // sleep for a second, expect value to still be there.
- auto res = std::dynamic_pointer_cast<CacheableInt32>(Test.m_region->get("one"));
+ auto res =
+ std::dynamic_pointer_cast<CacheableInt32>(Test.m_region->get("one"));
ASSERT(res->value() == 1, "Expected to find value 1.");
fflush(stdout);
SLEEP(5000); // sleep for 5 more seconds, expect value to be invalid.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testCache.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testCache.cpp b/src/cppcache/integration-test/testCache.cpp
index df74e76..af65ebf 100644
--- a/src/cppcache/integration-test/testCache.cpp
+++ b/src/cppcache/integration-test/testCache.cpp
@@ -21,7 +21,8 @@
#include <iostream>
#include <geode/GeodeCppCache.hpp>
-#include <CacheRegionHelper.hpp>
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
#include "fw_helper.hpp"
using namespace apache::geode::client;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testCacheless.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testCacheless.cpp b/src/cppcache/integration-test/testCacheless.cpp
index 7bd1964..9c44854 100644
--- a/src/cppcache/integration-test/testCacheless.cpp
+++ b/src/cppcache/integration-test/testCacheless.cpp
@@ -61,7 +61,8 @@ class RegionWrapper {
int tries = 0;
int val = 0;
do {
- valPtr = std::dynamic_pointer_cast<CacheableString>(m_regionPtr->get(keyPtr));
+ valPtr =
+ std::dynamic_pointer_cast<CacheableString>(m_regionPtr->get(keyPtr));
ASSERT(valPtr != nullptr, "value should not be null.");
val = atoi(valPtr->asChar());
SLEEP(100);
@@ -121,8 +122,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(s1p1, CreateRegionNoCache)
{
- initClientWithPool(true, "__TEST_POOL1__", locHostPort, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locHostPort, nullptr, nullptr, 0,
+ true);
LOG("Creating region in s1p1-pusher, no-ack, no-cache, no-listener");
getHelper()->createPooledRegion(REGIONNAME, false, locHostPort,
"__TEST_POOL1__", true, true);
@@ -132,8 +133,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(s1p2, CreateNoCacheWListener)
{
LOG("Creating region in s1p2-listener, no-ack, no-cache, with-listener");
- initClientWithPool(true, "__TEST_POOL1__", locHostPort, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locHostPort, nullptr, nullptr, 0,
+ true);
listener = std::make_shared<TallyListener>();
getHelper()->createPooledRegion(REGIONNAME, false, locHostPort,
"__TEST_POOL1__", true, true, 0, 0, 0, 0, 0,
@@ -145,8 +146,8 @@ DUNIT_TASK_DEFINITION(s2p1, CreateRegionCacheMirror)
{
LOG("Creating region in s2p1-storage, no-ack, cache, no-interestlist, "
"no-listener");
- initClientWithPool(true, "__TEST_POOL1__", locHostPort, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locHostPort, nullptr, nullptr, 0,
+ true);
getHelper()->createPooledRegion(REGIONNAME, false, locHostPort,
"__TEST_POOL1__", true, true);
}
@@ -156,8 +157,8 @@ DUNIT_TASK_DEFINITION(s2p2, CreateRegionCache)
{
LOG("Creating region in s2p2-subset, no-ack, no-mirror, cache, "
"no-interestlist, with-listener");
- initClientWithPool(true, "__TEST_POOL1__", locHostPort, "ServerGroup1",
- nullptr, 0, true);
+ initClientWithPool(true, "__TEST_POOL1__", locHostPort, nullptr, nullptr, 0,
+ true);
listener = std::make_shared<TallyListener>();
getHelper()->createPooledRegion(REGIONNAME, false, locHostPort,
"__TEST_POOL1__", true, true, 0, 0, 0, 0, 0,
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testConnect.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testConnect.cpp b/src/cppcache/integration-test/testConnect.cpp
index 850a215..7cf284c 100644
--- a/src/cppcache/integration-test/testConnect.cpp
+++ b/src/cppcache/integration-test/testConnect.cpp
@@ -25,19 +25,25 @@ using namespace apache::geode::client;
const char* host_name = "Suds";
DUNIT_TASK(s1p1, CreateRegionOne)
{
+ CacheFactoryPtr factory = CacheFactory::createCacheFactory();
+ CachePtr cache = factory->create();
try {
- DistributedSystem::disconnect();
+ cache->getDistributedSystem().connect();
FAIL("Expected an exception.");
- } catch (const NotConnectedException& ex) {
+ } catch (const AlreadyConnectedException& ex) {
LOG("Got expected exception.");
LOG(ex.getMessage());
}
+
+ cache->getDistributedSystem().disconnect();
+
try {
- DistributedSystemPtr dsys = DistributedSystem::connect(host_name);
- if (!dsys->isConnected()) FAIL("Distributed system is not connected");
- } catch (const Exception& ex) {
+ // doing second disconnect to force the exception
+ cache->getDistributedSystem().disconnect();
+ FAIL("Expected an exception.");
+ } catch (const NotConnectedException& ex) {
+ LOG("Got expected exception.");
LOG(ex.getMessage());
- ASSERT(false, "connect failed.");
}
}
ENDTASK
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testDataOutput.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testDataOutput.cpp b/src/cppcache/integration-test/testDataOutput.cpp
index cf9801a..f0755f9 100644
--- a/src/cppcache/integration-test/testDataOutput.cpp
+++ b/src/cppcache/integration-test/testDataOutput.cpp
@@ -22,6 +22,9 @@
#include <geode/DataOutput.hpp>
#include <geode/DataInput.hpp>
+#include "SerializationRegistry.hpp"
+#include "DataInputInternal.hpp"
+#include "DataOutputInternal.hpp"
#include "fw_helper.hpp"
@@ -49,7 +52,7 @@ void dumpnwords(const uint32_t* buf, uint32_t length) {
BEGIN_TEST(Byte)
{
- DataOutput dataOutput;
+ DataOutputInternal dataOutput;
dataOutput.write(static_cast<uint8_t>(0x11));
const uint8_t* buffer = dataOutput.getBuffer();
@@ -57,7 +60,8 @@ BEGIN_TEST(Byte)
ASSERT(buffer[0] == (uint8_t)0x11, "expected 0x11.");
int8_t result;
- DataInput dataInput(buffer, dataOutput.getBufferLength());
+
+ DataInputInternal dataInput(buffer, dataOutput.getBufferLength(), nullptr);
dataInput.read(&result);
ASSERT(result == (uint8_t)0x11, "expected 0x11");
}
@@ -65,7 +69,7 @@ END_TEST(Byte)
BEGIN_TEST(Boolean)
{
- DataOutput dataOutput;
+ DataOutputInternal dataOutput(nullptr);
dataOutput.writeBoolean(true);
dataOutput.writeBoolean(false);
@@ -75,7 +79,8 @@ BEGIN_TEST(Boolean)
ASSERT(buffer[1] == (uint8_t)0x0, "expected 0x0.");
bool result;
- DataInput dataInput(buffer, dataOutput.getBufferLength());
+
+ DataInputInternal dataInput(buffer, dataOutput.getBufferLength(), nullptr);
dataInput.readBoolean(&result);
ASSERT(result, "expected true");
dataInput.readBoolean(&result);
@@ -85,7 +90,7 @@ END_TEST(Boolean)
BEGIN_TEST(Short)
{
- DataOutput dataOutput;
+ DataOutputInternal dataOutput;
dataOutput.writeInt(static_cast<int16_t>(0x1122));
const uint8_t* buffer = dataOutput.getBuffer();
@@ -93,7 +98,8 @@ BEGIN_TEST(Short)
ASSERT(buffer[1] == (uint8_t)0x22, "expected 0x11.");
int16_t result;
- DataInput dataInput(buffer, dataOutput.getBufferLength());
+
+ DataInputInternal dataInput(buffer, dataOutput.getBufferLength(), nullptr);
dataInput.readInt(&result);
ASSERT(result == 0x1122, "expected 0x1122");
}
@@ -101,7 +107,7 @@ END_TEST(Short)
BEGIN_TEST(int_t)
{
- DataOutput dataOutput;
+ DataOutputInternal dataOutput;
dataOutput.writeInt((int32_t)0x11223344);
const uint8_t* buffer = dataOutput.getBuffer();
@@ -111,7 +117,7 @@ BEGIN_TEST(int_t)
ASSERT(buffer[2] == (uint8_t)0x33, "expected 0x33.");
ASSERT(buffer[3] == (uint8_t)0x44, "expected 0x44.");
- DataInput dataInput(buffer, dataOutput.getBufferLength());
+ DataInputInternal dataInput(buffer, dataOutput.getBufferLength(), nullptr);
int32_t result;
dataInput.readInt(&result);
ASSERT(result == 0x11223344, "expected 0x11223344");
@@ -120,7 +126,7 @@ END_TEST(int_t)
BEGIN_TEST(Long)
{
- DataOutput dataOutput;
+ DataOutputInternal dataOutput;
int64_t value = ((static_cast<int64_t>(0x11223344)) << 32) | 0x55667788;
dataOutput.writeInt(value);
@@ -134,7 +140,7 @@ BEGIN_TEST(Long)
ASSERT(buffer[6] == (uint8_t)0x77, "expected 0x77.");
ASSERT(buffer[7] == (uint8_t)0x88, "expected 0x88.");
- DataInput dataInput(buffer, dataOutput.getBufferLength());
+ DataInputInternal dataInput(buffer, dataOutput.getBufferLength(), nullptr);
int64_t result;
dataInput.readInt(&result);
ASSERT(result == value, "expected 0x1122334455667788");
@@ -143,7 +149,7 @@ END_TEST(Long)
BEGIN_TEST(Float)
{
- DataOutput dataOutput;
+ DataOutputInternal dataOutput;
dataOutput.writeFloat(1.2f);
const uint8_t* buffer = dataOutput.getBuffer();
@@ -152,7 +158,7 @@ BEGIN_TEST(Float)
ASSERT(buffer[2] == (uint8_t)0x99, "expected 0x99.");
ASSERT(buffer[3] == (uint8_t)0x9a, "expected 0x9a.");
- DataInput dataInput(buffer, dataOutput.getBufferLength());
+ DataInputInternal dataInput(buffer, dataOutput.getBufferLength(), nullptr);
float result;
dataInput.readFloat(&result);
ASSERT(result == 1.2f, "expected 1.2f");
@@ -161,7 +167,7 @@ END_TEST(Float)
BEGIN_TEST(Double)
{
- DataOutput dataOutput;
+ DataOutputInternal dataOutput;
dataOutput.writeDouble(1.2);
const uint8_t* buffer = dataOutput.getBuffer();
@@ -174,7 +180,7 @@ BEGIN_TEST(Double)
ASSERT(buffer[6] == (uint8_t)0x33, "expected 0x33.");
ASSERT(buffer[7] == (uint8_t)0x33, "expected 0x33.");
- DataInput dataInput(buffer, dataOutput.getBufferLength());
+ DataInputInternal dataInput(buffer, dataOutput.getBufferLength(), nullptr);
double result;
dataInput.readDouble(&result);
ASSERT(result == 1.2, "expected 1.2");
@@ -184,7 +190,7 @@ END_TEST(Double)
// Test data output numbers.
BEGIN_TEST(Numbers)
{
- DataOutput dataOutput;
+ DataOutputInternal dataOutput;
dataOutput.write(static_cast<uint8_t>(0x11));
dataOutput.write(static_cast<uint8_t>(0xAA));
@@ -206,7 +212,7 @@ END_TEST(Numbers)
BEGIN_TEST(NarrowStrings)
{
- DataOutput dataOutput;
+ DataOutputInternal dataOutput;
const char* strOrig = "This is fun.";
dataOutput.writeASCII(strOrig);
@@ -230,7 +236,7 @@ BEGIN_TEST(NarrowStrings)
ASSERT(buffer[12] == 'n', "wrong utf encoding.");
ASSERT(buffer[13] == '.', "wrong utf encoding.");
- DataInput dataInput(buffer, dataOutput.getBufferLength());
+ DataInputInternal dataInput(buffer, dataOutput.getBufferLength(), nullptr);
char* str = nullptr;
uint16_t res_length;
dataInput.readASCII(&str, &res_length);
@@ -246,7 +252,7 @@ END_TEST(NarrowStrings)
BEGIN_TEST(WideStrings)
{
- DataOutput dataOutput;
+ DataOutputInternal dataOutput;
wchar_t* strOrig = new wchar_t[40];
strOrig[0] = 0;
@@ -275,7 +281,7 @@ BEGIN_TEST(WideStrings)
ASSERT(buffer[10] == 0xbf, "wrong utf encoding.");
ASSERT(buffer[11] == 0xbf, "wrong utf encoding.");
std::cout << "sizeof wchar_t " << sizeof(wchar_t) << std::endl;
- DataInput dataInput(buffer, dataOutput.getBufferLength());
+ DataInputInternal dataInput(buffer, dataOutput.getBufferLength(), nullptr);
wchar_t* str = nullptr;
uint16_t res_length;
dataInput.readUTF(&str, &res_length);
[03/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cli/NewFwkLib/FwkTest.cs
----------------------------------------------------------------------
diff --git a/src/tests/cli/NewFwkLib/FwkTest.cs b/src/tests/cli/NewFwkLib/FwkTest.cs
index 904e3c3..da7e5a8 100644
--- a/src/tests/cli/NewFwkLib/FwkTest.cs
+++ b/src/tests/cli/NewFwkLib/FwkTest.cs
@@ -608,16 +608,16 @@ namespace Apache.Geode.Client.FwkLib
public virtual void CreatePool()
{
CreateCache();
- PoolFactory pf = PoolManager.CreateFactory();
+ PoolFactory pf = CacheHelper<TKey, TVal>.DCache.GetPoolFactory();
ResetKey("poolSpec");
string poolRegionData = GetStringValue("poolSpec");
FwkInfo("PoolSpec is :{0}", poolRegionData);
string poolName = null;
SetPoolAttributes(pf, poolRegionData, ref poolName);
- if (PoolManager.Find(poolName) == null)
+ if (CacheHelper<TKey, TVal>.DCache.GetPoolManager().Find(poolName) == null)
{
- Pool pool = pf.Create(poolName);
+ Pool pool = pf.Create(poolName, CacheHelper<TKey, TVal>.DCache);
FwkInfo("Pool attributes are {0}:", PoolAttributesToString(pool));
}
}
@@ -964,9 +964,6 @@ namespace Apache.Geode.Client.FwkLib
String createCacheLoader = myType.Namespace + '.' +
loaderlibrary + "<" + typeof(TKey) + "," + typeof(TVal) + ">." + "createCacheLoader";
- if (String.Compare(loaderfunction, createCacheLoader, true) == 0) {
- loader = new PerfCacheLoader<TKey, TVal>();
- }
Util.Log(Util.LogLevel.Info, "Instantiated Loader = {0} ", loaderfunction);
af.SetCacheLoader(loader);
}
@@ -1054,12 +1051,6 @@ namespace Apache.Geode.Client.FwkLib
else if (String.Compare(listenerfunction, createDurablePerfListener, true) == 0) {
listener = new DurablePerfListener<TKey, TVal>();
}
- else if (String.Compare(listenerfunction, CreateDurableCacheListenerSP, true) == 0) {
- listener = new DurableCacheListener<TKey, TVal>();
- }
- else if (String.Compare(listenerfunction, createLatencyListener, true) == 0) {
- listener = new LatencyListeners<TKey, TVal>(InitPerfStat.perfstat[0]);
- }
else if (String.Compare(listenerfunction, createSilenceListener, true) == 0)
{
listener = new SilenceListener<TKey, TVal>();
@@ -1303,7 +1294,7 @@ namespace Apache.Geode.Client.FwkLib
//Properties rootAttrs = GetNewRegionAttributes(rootRegionData);
// Check if this is a thin-client region; if so set the endpoints
RegionFactory rootAttrs = null;
- //RegionFactory rootAttrs = CacheHelper.DCache.CreateRegionFactory(RegionShortcut.PROXY);
+ //RegionFactory rootAttrs = CacheHelper<TKey, TVal>.DCache.CreateRegionFactory(RegionShortcut.PROXY);
string m_isPool = null;
//SetRegionAttributes(rootAttrs, rootRegionData, ref m_isPool);
int redundancyLevel = 0;
@@ -1358,7 +1349,7 @@ namespace Apache.Geode.Client.FwkLib
private void ParseEndPoints(string ep, bool isServer, int redundancyLevel)
{
string poolName = "_Test_Pool";
- PoolFactory pf = PoolManager.CreateFactory();
+ PoolFactory pf = CacheHelper<TKey, TVal>.DCache.GetPoolFactory();
string[] eps = ep.Split(',');
foreach (string endpoint in eps)
{
@@ -1397,9 +1388,9 @@ namespace Apache.Geode.Client.FwkLib
if (redundancyLevel > 0)
pf.SetSubscriptionRedundancy(redundancyLevel);
- if (PoolManager.Find(poolName) == null)
+ if (CacheHelper<TKey, TVal>.DCache.GetPoolManager().Find(poolName) == null)
{
- Pool pool = pf.Create(poolName);
+ Pool pool = pf.Create(poolName, CacheHelper<TKey, TVal>.DCache);
FwkInfo("Pool attributes are {0}:", PoolAttributesToString(pool));
}
FwkInfo("Create Pool complete with poolName= {0}", poolName);
@@ -1515,7 +1506,7 @@ namespace Apache.Geode.Client.FwkLib
public QueryService<TKey, object> CheckQueryService()
{
string mode = Util.GetEnvironmentVariable("POOLOPT");
- Pool/*<TKey, TVal>*/ pool = PoolManager/*<TKey, TVal>*/.Find("_Test_Pool");
+ Pool/*<TKey, TVal>*/ pool = CacheHelper<TKey, TVal>.DCache.GetPoolManager().Find("_Test_Pool");
return pool.GetQueryService<TKey, object>();
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cli/NewFwkLib/NewFwkLib.csproj.in
----------------------------------------------------------------------
diff --git a/src/tests/cli/NewFwkLib/NewFwkLib.csproj.in b/src/tests/cli/NewFwkLib/NewFwkLib.csproj.in
index ebcf743..f58de91 100644
--- a/src/tests/cli/NewFwkLib/NewFwkLib.csproj.in
+++ b/src/tests/cli/NewFwkLib/NewFwkLib.csproj.in
@@ -230,48 +230,13 @@
<Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\NewFwkLib\ResumableTx\TxInfo.cs">
<Link>ResumableTx\TxInfo.cs</Link>
</Compile>
- <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\NewFwkLib\SmokePerf\ObjectHelper.cs">
- <Link>SmokePerf\ObjectHelper.cs</Link>
- </Compile>
- <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\NewFwkLib\SmokePerf\PerfStat.cs">
- <Link>SmokePerf\PerfStat.cs</Link>
- </Compile>
- <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\NewFwkLib\SmokePerf\SmokePerf.cs">
- <Link>SmokePerf\SmokePerf.cs</Link>
- </Compile>
- <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\NewFwkLib\SmokePerf\SmokeTasks.cs">
- <Link>SmokePerf\SmokeTasks.cs</Link>
- </Compile>
<Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\NewFwkLib\Utils.cs">
<Link>Utils.cs</Link>
</Compile>
- <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\NewTestObject\ArrayOfByte.cs">
- <Link>SmokePerf\ArrayOfByte.cs</Link>
- </Compile>
- <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\NewTestObject\BatchObject.cs">
- <Link>SmokePerf\BatchObject.cs</Link>
- </Compile>
- <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\NewTestObject\DeltaFastAssetAccount.cs">
- <Link>SmokePerf\DeltaFastAssetAccount.cs</Link>
- </Compile>
- <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\NewTestObject\DeltaPSTObject.cs">
- <Link>SmokePerf\DeltaPSTObject.cs</Link>
- </Compile>
<Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\NewTestObject\DeltaTestImpl.cs">
<Link>DeltaTest\DeltaTestImpl.cs</Link>
</Compile>
- <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\NewTestObject\EqStruct.cs">
- <Link>SmokePerf\EqStruct.cs</Link>
- </Compile>
- <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\NewTestObject\FastAsset.cs">
- <Link>SmokePerf\FastAsset.cs</Link>
- </Compile>
- <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\NewTestObject\FastAssetAccount.cs">
- <Link>SmokePerf\FastAssetAccount.cs</Link>
- </Compile>
- <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\NewTestObject\NoopAuthInit.cs">
- <Link>SmokePerf\NoopAuthInit.cs</Link>
- </Compile>
+
<Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\NewTestObject\PdxAutoSerializerObj.cs">
<Link>PdxTest\PdxAutoSerializerObj.cs</Link>
</Compile>
@@ -287,16 +252,10 @@
<Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\NewTestObject\PositionPdx.cs">
<Link>QueryTest\PositionPdx.cs</Link>
</Compile>
- <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\NewTestObject\PSTObject.cs">
- <Link>SmokePerf\PSTObject.cs</Link>
- </Compile>
<Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\NewTestObject\TestObject1.cs">
<Link>DeltaTest\TestObject1.cs</Link>
</Compile>
- <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\NewTestObject\TimeStampdObject.cs">
- <Link>SmokePerf\TimeStampdObject.cs</Link>
- </Compile>
- <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\QueryHelper\QueryHelperN.cs">
+ <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\QueryHelper\QueryHelperN.cs">
<Link>QueryTest\QueryHelperN.cs</Link>
</Compile>
</ItemGroup>
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cli/NewFwkLib/PdxTest/PdxTests.cs
----------------------------------------------------------------------
diff --git a/src/tests/cli/NewFwkLib/PdxTest/PdxTests.cs b/src/tests/cli/NewFwkLib/PdxTest/PdxTests.cs
index 12d6186..5962fe4 100644
--- a/src/tests/cli/NewFwkLib/PdxTest/PdxTests.cs
+++ b/src/tests/cli/NewFwkLib/PdxTest/PdxTests.cs
@@ -39,8 +39,7 @@ namespace Apache.Geode.Client.FwkLib
{
long currentTimeInMillies()
{
- DateTime startTime = DateTime.Now;
- long curruntMillis = SmokePerf<TKey, TVal>.GetDateTimeMillis(startTime);
+ long curruntMillis = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
return curruntMillis;
}
public override void AfterCreate(EntryEvent<TKey, TVal> ev)
@@ -1028,7 +1027,7 @@ namespace Apache.Geode.Client.FwkLib
{
FwkTest<TKey, TVal>.CurrentTest.ResetKey(ObjectType);
string objectType = GetStringValue(ObjectType);
- QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper();
+ QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper(CacheHelper<TKey, TVal>.DCache);
int numSet = 0;
int setSize = 0;
if (objectType != null && objectType == "Portfolio")
@@ -1053,7 +1052,7 @@ namespace Apache.Geode.Client.FwkLib
int numOfKeys = GetUIntValue(EntryCount);
FwkTest<TKey, TVal>.CurrentTest.ResetKey(ValueSizes);
int objSize = GetUIntValue(ValueSizes);
- QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper();
+ QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper(CacheHelper<TKey, TVal>.DCache);
int numSet = 0;
int setSize = 0;
if (objType != null && objType == "Portfolio")
@@ -1171,7 +1170,7 @@ namespace Apache.Geode.Client.FwkLib
{
FwkTest<TKey, TVal>.CurrentTest.ResetKey(EntryCount);
int numOfKeys = GetUIntValue(EntryCount);
- QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper();
+ QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper(CacheHelper<TKey, TVal>.DCache);
int setSize = qh.PortfolioSetSize;
if (numOfKeys < setSize)
{
@@ -1251,7 +1250,7 @@ namespace Apache.Geode.Client.FwkLib
{
Int32 numSet = 0;
Int32 setSize = 0;
- QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper();
+ QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper(CacheHelper<TKey, TVal>.DCache);
TVal port;
setSize = qh.PortfolioSetSize;
numSet = 200 / setSize;
@@ -2177,9 +2176,8 @@ namespace Apache.Geode.Client.FwkLib
int sleepMS = 2000;
FwkInfo("Waiting for a period of silence for " + desiredSilenceSec + " seconds...");
long desiredSilenceMS = desiredSilenceSec * 1000;
- DateTime startTime = DateTime.Now;
- long silenceStartTime = SmokePerf<TKey, TVal>.GetDateTimeMillis(startTime);
- long currentTime = SmokePerf<TKey, TVal>.GetDateTimeMillis(startTime);
+ long silenceStartTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
+ long currentTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
long lastEventTime = (long)Util.BBGet("ListenerBB", "lastEventTime");
while (currentTime - silenceStartTime < desiredSilenceMS)
@@ -2198,8 +2196,7 @@ namespace Apache.Geode.Client.FwkLib
// restart the wait
silenceStartTime = lastEventTime;
}
- startTime = DateTime.Now;
- currentTime = SmokePerf<TKey, TVal>.GetDateTimeMillis(startTime);
+ currentTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
}
long duration = currentTime - silenceStartTime;
FwkInfo("Done waiting, clients have been silent for " + duration + " ms");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cli/NewFwkLib/PerfTest/PerfTests.cs
----------------------------------------------------------------------
diff --git a/src/tests/cli/NewFwkLib/PerfTest/PerfTests.cs b/src/tests/cli/NewFwkLib/PerfTest/PerfTests.cs
index 1e98555..3081f67 100644
--- a/src/tests/cli/NewFwkLib/PerfTest/PerfTests.cs
+++ b/src/tests/cli/NewFwkLib/PerfTest/PerfTests.cs
@@ -1119,7 +1119,7 @@ namespace Apache.Geode.Client.FwkLib
isReceiveValues = GetBoolValue("receiveValue");
}
region.GetSubscriptionService().RegisterKeys(registerKeyList, isDurable, isGetInitialValues, isReceiveValues);
- String durableClientId = DistributedSystem.SystemProperties.DurableClientId;
+ String durableClientId = CacheHelper<TKey, TVal>.DCache.DistributedSystem.SystemProperties.DurableClientId;
if (durableClientId.Length > 0)
{
CacheHelper<TKey, TVal>.DCache.ReadyForEvents();
@@ -1150,7 +1150,7 @@ namespace Apache.Geode.Client.FwkLib
isReceiveValues = GetBoolValue("receiveValue");
}
region.GetSubscriptionService().RegisterAllKeys(isDurable, null, isGetInitialValues,isReceiveValues);
- String durableClientId = DistributedSystem.SystemProperties.DurableClientId;
+ String durableClientId = CacheHelper<TKey, TVal>.DCache.DistributedSystem.SystemProperties.DurableClientId;
if (durableClientId.Length > 0)
{
CacheHelper<TKey, TVal>.DCache.ReadyForEvents();
@@ -1244,7 +1244,7 @@ namespace Apache.Geode.Client.FwkLib
isReceiveValues = GetBoolValue("receiveValue");
}
region.GetSubscriptionService().RegisterRegex(regex, isDurable, null, isGetInitialValues, isReceiveValues);
- String durableClientId = DistributedSystem.SystemProperties.DurableClientId;
+ String durableClientId = CacheHelper<TKey, TVal>.DCache.DistributedSystem.SystemProperties.DurableClientId;
if (durableClientId.Length > 0)
{
CacheHelper<TKey, TVal>.DCache.ReadyForEvents();
@@ -1359,8 +1359,8 @@ namespace Apache.Geode.Client.FwkLib
Int32 eventAfterUpdate = (Int32)Util.BBGet("ConflationCacheListener", "AFTER_UPDATE_COUNT_" + Util.ClientId + "_" + region.Name);
FwkInfo("DoValidateQConflation() -- eventAfterCreate {0} and eventAfterUpdate {1}", eventAfterCreate, eventAfterUpdate);
- String conflateEvent = DistributedSystem.SystemProperties.ConflateEvents;
- String durableClientId = DistributedSystem.SystemProperties.DurableClientId;
+ String conflateEvent = CacheHelper<TKey, TVal>.DCache.DistributedSystem.SystemProperties.ConflateEvents;
+ String durableClientId = CacheHelper<TKey, TVal>.DCache.DistributedSystem.SystemProperties.DurableClientId;
Int32 totalCount = 3500;
if(durableClientId.Length > 0) {
FwkInfo("DoValidateQConflation() Validation for Durable client .");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cli/NewFwkLib/QueryTest/QueryTests.cs
----------------------------------------------------------------------
diff --git a/src/tests/cli/NewFwkLib/QueryTest/QueryTests.cs b/src/tests/cli/NewFwkLib/QueryTest/QueryTests.cs
index ef11454..e6f5dd6 100644
--- a/src/tests/cli/NewFwkLib/QueryTest/QueryTests.cs
+++ b/src/tests/cli/NewFwkLib/QueryTest/QueryTests.cs
@@ -223,7 +223,7 @@ namespace Apache.Geode.Client.FwkLib
ResetKey(DistinctKeys);
numOfKeys = GetUIntValue(DistinctKeys);
}
- QueryHelper<TKey,TVal> qh = QueryHelper<TKey,TVal>.GetHelper();
+ QueryHelper<TKey,TVal> qh = QueryHelper<TKey,TVal>.GetHelper(CacheHelper<TKey, TVal>.DCache);
int setSize = qh.PortfolioSetSize;
FwkInfo("QueryTests.VerifyResultSet: numOfKeys [{0}], setSize [{1}].",
numOfKeys, setSize);
@@ -404,7 +404,7 @@ namespace Apache.Geode.Client.FwkLib
ResetKey(DistinctKeys);
numOfKeys = GetUIntValue(DistinctKeys);
}
- QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper();
+ QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper(CacheHelper<TKey, TVal>.DCache);
int setSize = qh.PortfolioSetSize;
FwkInfo("QueryTests.VerifyStructSet: numOfKeys [{0}], setSize [{1}].",
numOfKeys, setSize);
@@ -629,7 +629,6 @@ namespace Apache.Geode.Client.FwkLib
bool isDC = GetBoolValue("isDurable");
RegionFactory rootAttrs = null;
string m_isPool = null;
- //RegionAttributes rootAttrs = GetRegionAttributes(rootRegionData);
// Check if this is a thin-client region; if so set the endpoints
int redundancyLevel = 0;
if (endpoints != null && endpoints.Length > 0)
@@ -691,11 +690,11 @@ namespace Apache.Geode.Client.FwkLib
if (!isObjectRegistered)
{
{
- Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable, CacheHelper<TKey, TVal>.DCache);
FwkInfo("Completed Portfolio registeration");
}
{
- Serializable.RegisterTypeGeneric(Position.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(Position.CreateDeserializable, CacheHelper<TKey, TVal>.DCache);
Serializable.RegisterPdxType(PortfolioPdx.CreateDeserializable);
Serializable.RegisterPdxType(PositionPdx.CreateDeserializable);
FwkInfo("Completed other object registeration");
@@ -1396,8 +1395,8 @@ namespace Apache.Geode.Client.FwkLib
if (isTypeRegistered != "registered")
{
FwkInfo("Getting inside for registeration");
- Serializable.RegisterTypeGeneric(Position.CreateDeserializable);
- Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(Position.CreateDeserializable, CacheHelper<TKey, TVal>.DCache);
+ Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable, CacheHelper<TKey, TVal>.DCache);
Serializable.RegisterPdxType(Apache.Geode.Client.Tests.PortfolioPdx.CreateDeserializable);
Serializable.RegisterPdxType(Apache.Geode.Client.Tests.PositionPdx.CreateDeserializable);
@@ -1461,7 +1460,7 @@ namespace Apache.Geode.Client.FwkLib
//string label = CacheHelper<TKey, TVal>.RegionTag(region.Attributes);
ResetKey(DistinctKeys);
int numOfKeys = GetUIntValue(DistinctKeys);
- QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper();
+ QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper(CacheHelper<TKey, TVal>.DCache);
string objectType = GetStringValue(ObjectType);
int setSize = qh.PortfolioSetSize;
int destroyKeys = GetUIntValue(DestroyKeys);
@@ -1504,7 +1503,7 @@ namespace Apache.Geode.Client.FwkLib
//string label = CacheHelper<TKey, TVal>.RegionTag(region.Attributes);
ResetKey(DistinctKeys);
int numOfKeys = GetUIntValue(DistinctKeys);
- QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper();
+ QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper(CacheHelper<TKey, TVal>.DCache);
string objectType = GetStringValue(ObjectType);
int setSize = qh.PortfolioSetSize;
int invalidateKeys = GetUIntValue(InvalidateKeys);
@@ -1548,7 +1547,7 @@ namespace Apache.Geode.Client.FwkLib
//string label = CacheHelper<TKey, TVal>.RegionTag(region.Attributes);
ResetKey(DistinctKeys);
int numOfKeys = GetUIntValue(DistinctKeys); // number of keys should be multiple of 20
- QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper();
+ QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper(CacheHelper<TKey, TVal>.DCache);
int numSet = 0;
int setSize = 0;
// Loop over value sizes
@@ -1633,7 +1632,7 @@ namespace Apache.Geode.Client.FwkLib
int numOfKeys = GetUIntValue(DistinctKeys);
string objectType = GetStringValue(ObjectType);
- QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper();
+ QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper(CacheHelper<TKey, TVal>.DCache);
int setSize = qh.PortfolioSetSize;
if (numOfKeys < setSize)
{
@@ -1730,7 +1729,7 @@ namespace Apache.Geode.Client.FwkLib
{
try
{
- QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper();
+ QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper(CacheHelper<TKey, TVal>.DCache);
int numSet = 0;
int setSize = 0;
//populating data
@@ -1828,7 +1827,7 @@ namespace Apache.Geode.Client.FwkLib
int rangeStart = GetUIntValue("range-start");
int rangeEnd = GetUIntValue("range-end");
- QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper();
+ QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper(CacheHelper<TKey, TVal>.DCache);
if (m_istransaction)
{
txManager = CacheHelper<TKey, TVal>.DCache.CacheTransactionManager;
@@ -1857,7 +1856,7 @@ namespace Apache.Geode.Client.FwkLib
int rangeStart = GetUIntValue("range-start");
int rangeEnd = GetUIntValue("range-end");
- QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper();
+ QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper(CacheHelper<TKey, TVal>.DCache);
for (int i = rangeStart; i <= rangeEnd; i++)
{
@@ -1894,7 +1893,7 @@ namespace Apache.Geode.Client.FwkLib
endTime = endTime.AddSeconds(secondsToRun);
IRegion<TKey, TVal> region = GetRegion();
- QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper();
+ QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper(CacheHelper<TKey, TVal>.DCache);
while (nowTime < endTime)
{
@@ -1917,7 +1916,7 @@ namespace Apache.Geode.Client.FwkLib
{
int maxRange = GetUIntValue("range-max");
IRegion<TKey, TVal> region = GetRegion();
- QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper();
+ QueryHelper<TKey, TVal> qh = QueryHelper<TKey, TVal>.GetHelper(CacheHelper<TKey, TVal>.DCache);
for (int i = 1; i <= maxRange; i++)
{
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cli/NewFwkLib/SecurityTest/Security.cs
----------------------------------------------------------------------
diff --git a/src/tests/cli/NewFwkLib/SecurityTest/Security.cs b/src/tests/cli/NewFwkLib/SecurityTest/Security.cs
index 10555c0..05124e4 100644
--- a/src/tests/cli/NewFwkLib/SecurityTest/Security.cs
+++ b/src/tests/cli/NewFwkLib/SecurityTest/Security.cs
@@ -135,7 +135,7 @@ namespace Apache.Geode.Client.FwkLib
DateTime startTime;
DateTime endTime;
TimeSpan elapsedTime;
- QueryService qs = CacheHelper.DCache.GetQueryService();
+ QueryService qs = CacheHelper<TKey, TVal>.DCache.GetQueryService();
ResetKey(LargeSetQuery);
ResetKey(UnsupportedPRQuery);
bool isLargeSetQuery = GetBoolValue(LargeSetQuery);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cli/NewFwkLib/SmokePerf/ObjectHelper.cs
----------------------------------------------------------------------
diff --git a/src/tests/cli/NewFwkLib/SmokePerf/ObjectHelper.cs b/src/tests/cli/NewFwkLib/SmokePerf/ObjectHelper.cs
deleted file mode 100644
index c0f395d..0000000
--- a/src/tests/cli/NewFwkLib/SmokePerf/ObjectHelper.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Threading;
-using Apache.Geode.Client.Tests;
-namespace Apache.Geode.Client.FwkLib
-{
- using Apache.Geode.DUnitFramework;
- using Apache.Geode.Client;
- public class ObjectHelper<TKey, TVal>
- {
- public static TVal CreateObject(string objectname, Int32 size, bool encodeKey, bool encodeTimestamp,
- Int32 assetSize,Int32 maxVal ,Int32 idx) {
-
- if (objectname.Equals("ArrayOfByte"))
- {
- return (TVal)(object)ArrayOfByte.Init(size,encodeKey,encodeTimestamp);
- }
- else if(objectname.Equals("BatchObject"))
- {
- return (TVal)(object) new BatchObject(idx, assetSize, size);
- }
-
- else if (objectname.Equals("PSTObject"))
- {
- return (TVal)(object) new PSTObject(size, encodeKey, encodeTimestamp);
- }
- else if(objectname.Equals("FastAssetAccount"))
- {
- return (TVal)(object) new FastAssetAccount(idx, encodeTimestamp, maxVal, assetSize);
- }
- else if (objectname.Equals("DeltaFastAssetAccount"))
- {
- return (TVal)(object) new DeltaFastAssetAccount(idx, encodeTimestamp, maxVal, assetSize, encodeKey);
- }
- else if (objectname == "EqStruct")
- {
- return (TVal)(object) new EqStruct(idx);
- }
- else if (objectname.Equals("DeltaPSTObject"))
- {
- return (TVal)(object)new DeltaPSTObject(size, encodeKey, encodeTimestamp);
- }
- else {
- Int32 bufSize = size;
- byte[] buf = new byte[bufSize];
- for (int i = 0; i < bufSize; i++)
- {
- buf[i] = 123;
- }
- Int32 rsiz = (bufSize <= 10) ? bufSize : 10;
- return (TVal)(object)buf;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cli/NewFwkLib/SmokePerf/PerfStat.cs
----------------------------------------------------------------------
diff --git a/src/tests/cli/NewFwkLib/SmokePerf/PerfStat.cs b/src/tests/cli/NewFwkLib/SmokePerf/PerfStat.cs
deleted file mode 100644
index 7b6f15b..0000000
--- a/src/tests/cli/NewFwkLib/SmokePerf/PerfStat.cs
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * 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.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Threading;
-using Apache.Geode.Client.Tests;
-using Apache.Geode.DUnitFramework;
-namespace Apache.Geode.Client.FwkLib
-{
- using Apache.Geode.Client;
- public static class PerfOps {
- public const string PERF_CREATES = "creates";
- public const string PERF_CREATE_TIME = "createTime";
- public const string PERF_PUTS="puts";
- public const string PERF_PUT_TIME="putTime";
- public const string PERF_UPDATE_EVENTS="updateEvents";
- public const string PERF_UPDATE_LATENCY="updateLatency";
- public const string PERF_LATENCY_SPIKES = "latencySpikes";
- public const string PERF_NEGATIVE_LATENCIES = "negativeLatencies";
- public const string PERF_OPS = "operations";
- public const string PERF_OP_TIME = "operationTime";
- public const string PERF_CONNECTS = "connects";
- public const string PERF_CONNECT_TIME = "connectTime";
- public const string PERF_DISCONNECTS = "disconnects";
- public const string PERF_DISCONNECT_TIME = "disconnectTime";
- public const string PERF_GETS = "gets";
- public const string PERF_GET_TIME = "getTime";
- public const string PERF_QUERIES = "queries";
- public const string PERF_QUERY_TIME = "queryTime";
- public const string PERF_UPDATES = "updates";
- public const string PERF_UPDATES_TIME = "updateTime";
- }
- public class PerfStat
- {
- private Statistics testStat;
- private StatisticsType statsType;
- private long ReturnTime()
- {
- DateTime startTime = DateTime.Now;
- //Stopwatch System.Diagnostics.Stopwatch;
-
- return startTime.Ticks * (1000000 / TimeSpan.TicksPerMillisecond);
- }
- public PerfStat(int threadID)
- {
- PerfStatType regStatType = PerfStatType.GetInstance();
- statsType = regStatType.GetStatType();
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
- string buf = String.Format("ThreadId-{0}", threadID);
- testStat = factory.CreateStatistics(statsType, buf);
- }
- public long StartCreate()
- {
- return ReturnTime();
- }
- public void EndCreate(long start, bool isMainWorkload)
- {
- EndCreate(start, 1, isMainWorkload);
- }
- public void EndCreate(long start, int amount, bool isMainWorkload)
- {
- long elapsed = ReturnTime() - start;
- if (isMainWorkload)
- {
- testStat.IncInt(statsType.NameToId(PerfOps.PERF_OPS), amount);
- testStat.IncLong(statsType.NameToId(PerfOps.PERF_OP_TIME), elapsed);
- }
- testStat.IncInt(statsType.NameToId(PerfOps.PERF_CREATES), amount);
- testStat.IncLong(statsType.NameToId(PerfOps.PERF_CREATE_TIME), elapsed);
- }
- public long StartPut()
- {
- return ReturnTime();
- }
- public void EndPut(long start, bool isMainWorkload)
- {
- EndPut(start, 1, isMainWorkload);
- }
- public void EndPut(long start, int amount, bool isMainWorkload)
- {
- long elapsed = ReturnTime() - start;
- if(isMainWorkload){
- testStat.IncInt(statsType.NameToId(PerfOps.PERF_OPS), amount);
- testStat.IncLong(statsType.NameToId(PerfOps.PERF_OP_TIME), elapsed);
- }
- testStat.IncInt(statsType.NameToId(PerfOps.PERF_PUTS), amount);
- testStat.IncLong(statsType.NameToId(PerfOps.PERF_PUT_TIME), elapsed);
- }
- public long StartGet()
- {
- return ReturnTime();
- }
- public void EndGet(long start, bool isMainWorkload)
- {
- EndGet(start,1,isMainWorkload);
- }
- public void EndGet(long start, int amount, bool isMainWorkload)
- {
- long elapsed = ReturnTime() - start;
- if(isMainWorkload){
- testStat.IncInt(statsType.NameToId(PerfOps.PERF_OPS), amount);
- testStat.IncLong(statsType.NameToId(PerfOps.PERF_OP_TIME), elapsed);
- }
- testStat.IncInt(statsType.NameToId(PerfOps.PERF_GETS), amount);
- testStat.IncLong(statsType.NameToId(PerfOps.PERF_GET_TIME), elapsed);
- }
- public void Close(){
- testStat.Close();
- }
- public void IncUpdateLatency(long amount)
- {
- long nonZeroAmount = amount;
- if (nonZeroAmount == 0) { // make non-zero to ensure non-flatline
- nonZeroAmount = 1; // nanosecond
- }
- testStat.IncInt(statsType.NameToId(PerfOps.PERF_UPDATE_EVENTS), 1);
- testStat.IncLong(statsType.NameToId(PerfOps.PERF_UPDATE_LATENCY), nonZeroAmount);
- }
-
- public void IncLatencySpikes(int amount)
- {
- testStat.IncInt(statsType.NameToId(PerfOps.PERF_LATENCY_SPIKES), amount);
- }
-
- public void IncNegativeLatencies(int amount)
- {
- testStat.IncInt(statsType.NameToId(PerfOps.PERF_NEGATIVE_LATENCIES), amount);
- }
- public void SetOps(int amount)
- {
- testStat.SetInt(statsType.NameToId(PerfOps.PERF_OPS), amount);
- }
- public void SetOpTime(long amount)
- {
- testStat.SetLong(statsType.NameToId(PerfOps.PERF_OP_TIME), amount);
- }
- public long StartConnect()
- {
- return ReturnTime();
- }
- public void EndConnect(long start, bool isMainWorkload)
- {
- long elapsed = ReturnTime() - start;
- if(isMainWorkload){
- testStat.IncInt(statsType.NameToId(PerfOps.PERF_OPS), 1);
- testStat.IncLong(statsType.NameToId(PerfOps.PERF_OP_TIME), elapsed);
- }
- testStat.IncInt(statsType.NameToId(PerfOps.PERF_CONNECTS), 1);
- testStat.IncLong(statsType.NameToId(PerfOps.PERF_CONNECT_TIME), elapsed);
- }
- public Int64 GetConnectTime()
- {
- return testStat.GetLong(PerfOps.PERF_CONNECT_TIME);
- }
- public long StartQuery()
- {
- return ReturnTime();
- }
- public void EndQuery(long start, bool isMainWorkload)
- {
- EndQuery(start,1,isMainWorkload);
- }
- public void EndQuery(long start, int amount, bool isMainWorkload)
- {
- long elapsed = ReturnTime() - start;
- if(isMainWorkload){
- testStat.IncInt(statsType.NameToId(PerfOps.PERF_OPS), amount);
- testStat.IncLong(statsType.NameToId(PerfOps.PERF_OP_TIME), elapsed);
- }
- testStat.IncInt(statsType.NameToId(PerfOps.PERF_QUERIES), amount);
- testStat.IncLong(statsType.NameToId(PerfOps.PERF_QUERY_TIME), elapsed);
- }
- public void IncUpdateEvents(int amount)
- {
- testStat.IncInt(statsType.NameToId(PerfOps.PERF_UPDATE_EVENTS), amount);
- }
- public int GetOps()
- {
- return testStat.GetInt(PerfOps.PERF_OPS);
- }
- /**
- * @return the timestamp that marks the start of the update
- */
- public long StartUpdate()
- {
- return ReturnTime();
- }
- public void EndUpdate(long start, bool isMainWorkload)
- {
- EndUpdate(start, 1, isMainWorkload);
- }
- public void EndUpdate(long start, int amount, bool isMainWorkload)
- {
- long elapsed = ReturnTime() - start;
- if (isMainWorkload) {
- testStat.IncInt(statsType.NameToId(PerfOps.PERF_OPS), amount);
- testStat.IncLong(statsType.NameToId(PerfOps.PERF_OP_TIME), elapsed);
- }
- testStat.IncInt(statsType.NameToId(PerfOps.PERF_UPDATES), amount);
- testStat.IncLong(statsType.NameToId(PerfOps.PERF_UPDATES_TIME), elapsed);
- }
- }
- public class PerfStatType
- {
- private static PerfStatType single = null;
- private StatisticDescriptor[] statDes = new StatisticDescriptor[20];
- private PerfStatType()
- {
- }
- public static PerfStatType GetInstance()
- {
- if(single == null)
- {
- single = new PerfStatType();
- }
- return single;
- }
- public StatisticsType GetStatType()
- {
- StatisticsFactory m_factory = StatisticsFactory.GetExistingInstance();
- StatisticsType statsType = m_factory.FindType("cacheperf.CachePerfStats");
- if (statsType == null)
- {
- statDes[0] = m_factory.CreateIntCounter(PerfOps.PERF_PUTS, "Number of puts completed.", "operations", 1);
- statDes[1] = m_factory.CreateLongCounter(PerfOps.PERF_PUT_TIME,
- "Total time spent doing puts.", "nanoseconds", 0);
- statDes[2] = m_factory.CreateIntCounter(PerfOps.PERF_UPDATE_EVENTS,
- "Number of update events.", "events", 1);
- statDes[3] = m_factory.CreateLongCounter(PerfOps.PERF_UPDATE_LATENCY,
- "Latency of update operations.", "nanoseconds", 0);
- statDes[4] = m_factory.CreateIntCounter(PerfOps.PERF_CREATES,
- "Number of creates completed.", "operations", 1);
- statDes[5] = m_factory.CreateLongCounter(PerfOps.PERF_CREATE_TIME,
- "Total time spent doing creates.", "nanoseconds", 0);
- statDes[6] = m_factory.CreateIntCounter(PerfOps.PERF_LATENCY_SPIKES,
- "Number of latency spikes.", "spikes", 0);
- statDes[7]
- = m_factory.CreateIntCounter(
- PerfOps.PERF_NEGATIVE_LATENCIES,
- "Number of negative latencies (caused by insufficient clock skew correction).",
- "negatives", 0);
- statDes[8] = m_factory.CreateIntCounter(PerfOps.PERF_OPS,
- "Number of operations completed.", "operations", 1);
- statDes[9] = m_factory.CreateLongCounter(PerfOps.PERF_OP_TIME,
- "Total time spent doing operations.", "nanoseconds", 0);
- statDes[10] = m_factory.CreateIntCounter(PerfOps.PERF_CONNECTS,
- "Number of connects completed.", "operations", 1);
- statDes[11] = m_factory.CreateLongCounter(PerfOps.PERF_CONNECT_TIME,
- "Total time spent doing connects.", "nanoseconds", 0);
- statDes[12] = m_factory.CreateIntCounter(PerfOps.PERF_DISCONNECTS,
- "Number of disconnects completed.", "operations", 1);
- statDes[13] = m_factory.CreateLongCounter(PerfOps.PERF_DISCONNECT_TIME,
- "Total time spent doing disconnects.", "nanoseconds", 0);
- statDes[14] = m_factory.CreateIntCounter(PerfOps.PERF_GETS,
- "Number of gets completed.", "operations", 1);
- statDes[15] = m_factory.CreateLongCounter(PerfOps.PERF_GET_TIME,
- "Total time spent doing gets.", "nanoseconds", 0);
- statDes[16] = m_factory.CreateIntCounter(PerfOps.PERF_QUERIES,
- "Number of queries completed.", "operations", 1);
- statDes[17] = m_factory.CreateLongCounter(PerfOps.PERF_QUERY_TIME,
- "Total time spent doing queries.", "nanoseconds", 0);
- statDes[18] = m_factory.CreateIntCounter(PerfOps.PERF_UPDATES,
- "Number of updates completed.", "operations", 1);
- statDes[19] = m_factory.CreateLongCounter(PerfOps.PERF_UPDATES_TIME,
- "Total time spent doing updates.", "nanoseconds", 0);
- statsType = m_factory.CreateType("cacheperf.CachePerfStats", "Application statistics.", statDes, 20);
- }
- return statsType;
- }
- public static void Clean()
- {
- if (single != null)
- {
- single = null;
- }
- }
-
- }
-}
[21/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/include/geode/Region.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/Region.hpp b/src/cppcache/include/geode/Region.hpp
index b7fc10a..15e2da1 100644
--- a/src/cppcache/include/geode/Region.hpp
+++ b/src/cppcache/include/geode/Region.hpp
@@ -33,8 +33,8 @@
#include "CacheableBuiltins.hpp"
/**
-* @file
-*/
+ * @file
+ */
#include "RegionEntry.hpp"
#include "CacheListener.hpp"
@@ -86,30 +86,30 @@ namespace client {
*/
class CPPCACHE_EXPORT Region : public std::enable_shared_from_this<Region> {
/** @brief Public Methods
- */
+ */
public:
/** return single name of region. The storage is backed by the region. */
virtual const char* getName() const = 0;
// virtual uint64_t getUpdateReceived() const { return 0; };
/** return the full path of the region as can be used to lookup the
- * region from Cache::getRegion. The storage is backed by the region.
- */
+ * region from Cache::getRegion. The storage is backed by the region.
+ */
virtual const char* getFullPath() const = 0;
/** Returns the parent region, or nullptr if a root region.
- * @throws RegionDestroyedException
- */
+ * @throws RegionDestroyedException
+ */
virtual RegionPtr getParentRegion() const = 0;
/** Return the RegionAttributes for this region.
- */
+ */
virtual RegionAttributesPtr getAttributes() const = 0;
/** Return the a mutator object for changing a subset of the region
- * attributes.
- * @throws RegionDestroyedException.
- */
+ * attributes.
+ * @throws RegionDestroyedException.
+ */
virtual AttributesMutatorPtr getAttributesMutator() const = 0;
// virtual void updateAccessOrModifiedTime() = 0;
@@ -117,22 +117,21 @@ class CPPCACHE_EXPORT Region : public std::enable_shared_from_this<Region> {
virtual CacheStatisticsPtr getStatistics() const = 0;
/** Invalidates this region. The invalidation will cascade to
- * all the subregions and cached entries. After
- * the <code>invalidateRegion</code> , the region and the entries in it still
- * exist. In order to remove all the entries and the region,
- * <code>destroyRegion</code> should be used.
- *
- * @param aCallbackArgument a user-defined parameter to pass to callback events
- * triggered by this method.
- * Can be nullptr. If it is sent on the wire, it has to be Serializable.
- * @throws CacheListenerException if CacheListener throws an exception; if this
- * occurs some subregions may have already been successfully
- * invalidated
- * @throws RegionDestroyedException if the region is no longer valid
- * @see destroyRegion
- * @see CacheListener::afterRegionInvalidate
- * This operation is not distributed.
- */
+ * all the subregions and cached entries. After
+ * the <code>invalidateRegion</code> , the region and the entries in it still
+ * exist. In order to remove all the entries and the region,
+ * <code>destroyRegion</code> should be used.
+ *
+ * @param aCallbackArgument a user-defined parameter to pass to callback
+ * events triggered by this method. Can be nullptr. If it is sent on the wire,
+ * it has to be Serializable.
+ * @throws CacheListenerException if CacheListener throws an exception; if
+ * this occurs some subregions may have already been successfully invalidated
+ * @throws RegionDestroyedException if the region is no longer valid
+ * @see destroyRegion
+ * @see CacheListener::afterRegionInvalidate
+ * This operation is not distributed.
+ */
virtual void invalidateRegion(
const UserDataPtr& aCallbackArgument = nullptr) = 0;
@@ -159,42 +158,41 @@ class CPPCACHE_EXPORT Region : public std::enable_shared_from_this<Region> {
const UserDataPtr& aCallbackArgument = nullptr) = 0;
/** Destroys the whole region and provides a user-defined parameter
- * object to any <code>CacheWriter</code> invoked in the process.
- * Destroy cascades to all entries
- * and subregions. After the destroy, this region object cannot be used
- * any more. Any attempt to use this region object will get a
- * <code>RegionDestroyedException</code> exception.
- *
- * The region destroy not only destroys the local region but also destroys the
- * server region. However, if server region destroy fails throwing back
- * <code>CacheServerException</code> or security exception,
- * the local region is still destroyed.
- *
- * @param aCallbackArgument a user-defined parameter to pass to callback events
- * triggered by this call.
- * Can be nullptr. If it is sent on the wire, it has to be Serializable.
- * @throws CacheWriterException if CacheWriter aborts the operation; if this
- * occurs some subregions may have already been successfully destroyed.
- * @throws CacheListenerException if CacheListener throws an exception; if this
- * occurs some subregions may have already been successfully
- * invalidated
- * @throws CacheServerException If an exception is received from the Java cache
- * server.
- * Only for Native Client regions.
- * @throws NotConnectedException if not connected to the geode system because
- * the client
- * cannot establish usable connections to any of the servers given to
- * it.
- * For pools configured with locators, if no locators are available,
- * the cause
- * of NotConnectedException is set to NoAvailableLocatorsException.
- * @throws MessageExcepton If the message received from server could not be
- * handled. This will be the case when an unregistered typeId is
- * received in the reply or reply is not well formed.
- * More information can be found in the log.
- * @throws TimeoutException if operation timed out
- * @see invalidateRegion
- */
+ * object to any <code>CacheWriter</code> invoked in the process.
+ * Destroy cascades to all entries
+ * and subregions. After the destroy, this region object cannot be used
+ * any more. Any attempt to use this region object will get a
+ * <code>RegionDestroyedException</code> exception.
+ *
+ * The region destroy not only destroys the local region but also destroys the
+ * server region. However, if server region destroy fails throwing back
+ * <code>CacheServerException</code> or security exception,
+ * the local region is still destroyed.
+ *
+ * @param aCallbackArgument a user-defined parameter to pass to callback
+ * events triggered by this call. Can be nullptr. If it is sent on the wire,
+ * it has to be Serializable.
+ * @throws CacheWriterException if CacheWriter aborts the operation; if this
+ * occurs some subregions may have already been successfully
+ * destroyed.
+ * @throws CacheListenerException if CacheListener throws an exception; if
+ * this occurs some subregions may have already been successfully invalidated
+ * @throws CacheServerException If an exception is received from the Java
+ * cache server. Only for Native Client regions.
+ * @throws NotConnectedException if not connected to the geode system because
+ * the client
+ * cannot establish usable connections to any of the servers given to
+ * it.
+ * For pools configured with locators, if no locators are available,
+ * the cause
+ * of NotConnectedException is set to NoAvailableLocatorsException.
+ * @throws MessageExcepton If the message received from server could not be
+ * handled. This will be the case when an unregistered typeId is
+ * received in the reply or reply is not well formed.
+ * More information can be found in the log.
+ * @throws TimeoutException if operation timed out
+ * @see invalidateRegion
+ */
virtual void destroyRegion(
const UserDataPtr& aCallbackArgument = nullptr) = 0;
/**
@@ -215,24 +213,24 @@ class CPPCACHE_EXPORT Region : public std::enable_shared_from_this<Region> {
virtual void localClear(const UserDataPtr& aCallbackArgument = nullptr) = 0;
/** Destroys the whole region and provides a user-defined parameter
- * object to any <code>CacheWriter</code> invoked in the process.
- * Destroy cascades to all entries
- * and subregions. After the destroy, this region object cannot be used
- * any more. Any attempt to use this region object will get a
- * <code>RegionDestroyedException</code> exception. The region destroy is not
- * distributed to other caches.
- *
- * @param aCallbackArgument a user-defined parameter to pass to callback events
- * triggered by this call.
- * Can be nullptr. If it is sent on the wire, it has to be Serializable.
- * @throws CacheWriterException if CacheWriter aborts the operation; if this
- * occurs some subregions may have already been successfully destroyed.
- * @throws CacheListenerException if CacheListener throws an exception; if this
- * occurs some subregions may have already been successfully
- * invalidated
- *
- * @see localInvalidateRegion
- */
+ * object to any <code>CacheWriter</code> invoked in the process.
+ * Destroy cascades to all entries
+ * and subregions. After the destroy, this region object cannot be used
+ * any more. Any attempt to use this region object will get a
+ * <code>RegionDestroyedException</code> exception. The region destroy is not
+ * distributed to other caches.
+ *
+ * @param aCallbackArgument a user-defined parameter to pass to callback
+ * events triggered by this call. Can be nullptr. If it is sent on the wire,
+ * it has to be Serializable.
+ * @throws CacheWriterException if CacheWriter aborts the operation; if this
+ * occurs some subregions may have already been successfully
+ * destroyed.
+ * @throws CacheListenerException if CacheListener throws an exception; if
+ * this occurs some subregions may have already been successfully invalidated
+ *
+ * @see localInvalidateRegion
+ */
virtual void localDestroyRegion(
const UserDataPtr& aCallbackArgument = nullptr) = 0;
@@ -246,17 +244,17 @@ class CPPCACHE_EXPORT Region : public std::enable_shared_from_this<Region> {
const RegionAttributesPtr& aRegionAttributes) = 0;
/** Populates the passed in VectorOfRegion with subregions of the current
- * region
- * @param recursive determines whether the method recursively fills in
- * subregions
- * @param[out] sr subregions
- * @throws RegionDestroyedException
- */
+ * region
+ * @param recursive determines whether the method recursively fills in
+ * subregions
+ * @param[out] sr subregions
+ * @throws RegionDestroyedException
+ */
virtual void subregions(const bool recursive, VectorOfRegion& sr) = 0;
/** Return the meta-object RegionEntry for key.
- * @throws IllegalArgumentException, RegionDestroyedException.
- */
+ * @throws IllegalArgumentException, RegionDestroyedException.
+ */
virtual RegionEntryPtr getEntry(const CacheableKeyPtr& key) = 0;
/** Convenience method allowing key to be a const char* */
@@ -266,46 +264,46 @@ class CPPCACHE_EXPORT Region : public std::enable_shared_from_this<Region> {
}
/** Returns the value associated with the specified key, passing the callback
- * argument to any cache loaders that are invoked in the
- * operation.
- * If the value is not present locally then it is requested from the java
- *server.
- * If even that is unsuccessful then a local CacheLoader will be invoked if
- *there is one.
- * The value returned by get is not copied, so multi-threaded applications
- * should not modify the value directly, but should use the update methods.
- *<p>
- * Updates the {@link CacheStatistics::getLastAccessedTime},
- * {@link CacheStatistics::getHitCount}, {@link CacheStatistics::getMissCount},
- * and {@link CacheStatistics::getLastModifiedTime} (if a new value is loaded)
- * for this region and the entry.
- *
- * @param key whose associated value is to be returned. The key Object must
- * implement the equals and hashCode methods.
- * @param aCallbackArgument an argument passed into the CacheLoader if
- * loader is used. If it is sent on the wire, it has to be Serializable.
- *
- * @throws IllegalArgumentException if key is nullptr or aCallbackArgument is
- * not serializable and a remote CacheLoader needs to be invoked
- * @throws CacheLoaderException if CacheLoader throws an exception
- * @throws CacheServerException If an exception is received from the Java cache
- *server.
- * Only for Native Client regions.
- * @throws NotConnectedException if it is not connected to the cache because
- *the client
- * cannot establish usable connections to any of the servers given to
- *it.
- * For pools configured with locators, if no locators are available,
- *the cause
- * of NotConnectedException is set to NoAvailableLocatorsException.
- * @throws MessageExcepton If the message received from server could not be
- * handled. This will be the case when an unregistered typeId is
- * received in the reply or reply is not well formed.
- * More information can be found in the log.
- * @throws TimeoutException if operation timed out
- * @throws RegionDestroyedException if the method is called on a destroyed
- *region
- **/
+ * argument to any cache loaders that are invoked in the
+ * operation.
+ * If the value is not present locally then it is requested from the java
+ *server.
+ * If even that is unsuccessful then a local CacheLoader will be invoked if
+ *there is one.
+ * The value returned by get is not copied, so multi-threaded applications
+ * should not modify the value directly, but should use the update methods.
+ *<p>
+ * Updates the {@link CacheStatistics::getLastAccessedTime},
+ * {@link CacheStatistics::getHitCount}, {@link
+ *CacheStatistics::getMissCount}, and {@link
+ *CacheStatistics::getLastModifiedTime} (if a new value is loaded) for this
+ *region and the entry.
+ *
+ * @param key whose associated value is to be returned. The key Object must
+ * implement the equals and hashCode methods.
+ * @param aCallbackArgument an argument passed into the CacheLoader if
+ * loader is used. If it is sent on the wire, it has to be Serializable.
+ *
+ * @throws IllegalArgumentException if key is nullptr or aCallbackArgument is
+ * not serializable and a remote CacheLoader needs to be invoked
+ * @throws CacheLoaderException if CacheLoader throws an exception
+ * @throws CacheServerException If an exception is received from the Java
+ *cache server. Only for Native Client regions.
+ * @throws NotConnectedException if it is not connected to the cache because
+ *the client
+ * cannot establish usable connections to any of the servers given to
+ *it.
+ * For pools configured with locators, if no locators are available,
+ *the cause
+ * of NotConnectedException is set to NoAvailableLocatorsException.
+ * @throws MessageExcepton If the message received from server could not be
+ * handled. This will be the case when an unregistered typeId is
+ * received in the reply or reply is not well formed.
+ * More information can be found in the log.
+ * @throws TimeoutException if operation timed out
+ * @throws RegionDestroyedException if the method is called on a destroyed
+ *region
+ **/
virtual CacheablePtr get(const CacheableKeyPtr& key,
const UserDataPtr& aCallbackArgument = nullptr) = 0;
@@ -317,48 +315,50 @@ class CPPCACHE_EXPORT Region : public std::enable_shared_from_this<Region> {
}
/** Places a new value into an entry in this region with the specified key,
- * providing a user-defined parameter
- * object to any <code>CacheWriter</code> invoked in the process.
- * The same parameter is also passed to the <code>CacheListener</code>,
- * if one is defined for this <code>Region</code>, invoked in the process.
- * If there is already an entry associated with the specified key in this
- * region,
- * the entry's previous value is overwritten.
- * The new put value is propogated to the java server to which it is connected
- * with.
- * <p>Updates the {@link CacheStatistics::getLastAccessedTime} and
- * {@link CacheStatistics::getLastModifiedTime} for this region and the entry.
- *
- * If remote server put fails throwing back a <code>CacheServerException</code>
- * or security exception, then local put is tried to rollback. However, if the
- * entry has overflowed/evicted/expired then the rollback is aborted since it
- * may be due to a more recent notification or update by another thread.
- *
- * @param key a key smart pointer associated with the value to be put into this
- * region.
- * @param value the value to be put into the cache
- * @param aCallbackArgument an argument that is passed to the callback function
- *
- * @throws IllegalArgumentException if key or value is nullptr
- * @throws CacheWriterException if CacheWriter aborts the operation
- * @throws CacheListenerException if CacheListener throws an exception
- * @throws RegionDestroyedException if region no longer valid
- * @throws CacheServerException If an exception is received from the Java cache
- * server.
- * @throws NotConnectedException if it is not connected to the cache because
- * the client
- * cannot establish usable connections to any of the servers given to
- * it
- * For pools configured with locators, if no locators are available,
- * the cause
- * of NotConnectedException is set to NoAvailableLocatorsException.
- * @throws MessageExcepton If the message received from server could not be
- * handled. This will be the case when an unregistered typeId is
- * received in the reply or reply is not well formed.
- * More information can be found in the log.
- * @throws TimeoutException if operation timed out
- * @throws OutOfMemoryException if not enoough memory for the value
- */
+ * providing a user-defined parameter
+ * object to any <code>CacheWriter</code> invoked in the process.
+ * The same parameter is also passed to the <code>CacheListener</code>,
+ * if one is defined for this <code>Region</code>, invoked in the process.
+ * If there is already an entry associated with the specified key in this
+ * region,
+ * the entry's previous value is overwritten.
+ * The new put value is propogated to the java server to which it is connected
+ * with.
+ * <p>Updates the {@link CacheStatistics::getLastAccessedTime} and
+ * {@link CacheStatistics::getLastModifiedTime} for this region and the entry.
+ *
+ * If remote server put fails throwing back a
+ * <code>CacheServerException</code> or security exception, then local put is
+ * tried to rollback. However, if the entry has overflowed/evicted/expired
+ * then the rollback is aborted since it may be due to a more recent
+ * notification or update by another thread.
+ *
+ * @param key a key smart pointer associated with the value to be put into
+ * this region.
+ * @param value the value to be put into the cache
+ * @param aCallbackArgument an argument that is passed to the callback
+ * function
+ *
+ * @throws IllegalArgumentException if key or value is nullptr
+ * @throws CacheWriterException if CacheWriter aborts the operation
+ * @throws CacheListenerException if CacheListener throws an exception
+ * @throws RegionDestroyedException if region no longer valid
+ * @throws CacheServerException If an exception is received from the Java
+ * cache server.
+ * @throws NotConnectedException if it is not connected to the cache because
+ * the client
+ * cannot establish usable connections to any of the servers given to
+ * it
+ * For pools configured with locators, if no locators are available,
+ * the cause
+ * of NotConnectedException is set to NoAvailableLocatorsException.
+ * @throws MessageExcepton If the message received from server could not be
+ * handled. This will be the case when an unregistered typeId is
+ * received in the reply or reply is not well formed.
+ * More information can be found in the log.
+ * @throws TimeoutException if operation timed out
+ * @throws OutOfMemoryException if not enoough memory for the value
+ */
virtual void put(const CacheableKeyPtr& key, const CacheablePtr& value,
const UserDataPtr& aCallbackArgument = nullptr) = 0;
@@ -457,51 +457,51 @@ class CPPCACHE_EXPORT Region : public std::enable_shared_from_this<Region> {
}
/** Creates a new entry in this region with the specified key and value,
- * providing a user-defined parameter
- * object to any <code>CacheWriter</code> invoked in the process.
- * The same parameter is also passed to the <code>CacheListener</code>,
- * if one is defined for this <code>Region</code>, invoked in the process.
- * The new entry is propogated to the java server also to which it is connected
- * with.
- * <p>Updates the {@link CacheStatistics::getLastAccessedTime} and
- * {@link CacheStatistics::getLastModifiedTime} for this region and the entry.
- * <p>
- *
- * If remote server put fails throwing back a <code>CacheServerException</code>
- * or security exception, then local put is tried to rollback. However, if the
- * entry has overflowed/evicted/expired then the rollback is aborted since it
- * may be due to a more recent notification or update by another thread.
- *
- * @param key the key smart pointer for which to create the entry in this
- * region.
- * @param value the value for the new entry, which may be nullptr meaning
- * the new entry starts as if it had been locally invalidated.
- * @param aCallbackArgument a user-defined parameter to pass to callback events
- * triggered by this method. Can be nullptr. Should be serializable if
- * passed to remote callback events
- * @throws IllegalArgumentException if key is nullptr or if the key, value, or
- * aCallbackArgument do not meet serializability requirements
- * @throws CacheWriterException if CacheWriter aborts the operation
- * @throws CacheListenerException if CacheListener throws an exception
- * @throws RegionDestroyedException if region is no longer valid
- * @throws CacheServerException If an exception is received from the Java cache
- * server.
- * Only for Native Client regions.
- * @throws NotConnectedException if it is not connected to the cache because
- * the client
- * cannot establish usable connections to any of the servers given to
- * it
- * For pools configured with locators, if no locators are available,
- * the cause
- * of NotConnectedException is set to NoAvailableLocatorsException.
- * @throws MessageExcepton If the message received from server could not be
- * handled. This will be the case when an unregistered typeId is
- * received in the reply or reply is not well formed.
- * More information can be found in the log.
- * @throws TimeoutException if the operation timed out
- * @throws OutOfMemoryException if no memory for new entry
- * @throws EntryExistsException if an entry with this key already exists
- */
+ * providing a user-defined parameter
+ * object to any <code>CacheWriter</code> invoked in the process.
+ * The same parameter is also passed to the <code>CacheListener</code>,
+ * if one is defined for this <code>Region</code>, invoked in the process.
+ * The new entry is propogated to the java server also to which it is
+ * connected with. <p>Updates the {@link CacheStatistics::getLastAccessedTime}
+ * and
+ * {@link CacheStatistics::getLastModifiedTime} for this region and the entry.
+ * <p>
+ *
+ * If remote server put fails throwing back a
+ * <code>CacheServerException</code> or security exception, then local put is
+ * tried to rollback. However, if the entry has overflowed/evicted/expired
+ * then the rollback is aborted since it may be due to a more recent
+ * notification or update by another thread.
+ *
+ * @param key the key smart pointer for which to create the entry in this
+ * region.
+ * @param value the value for the new entry, which may be nullptr meaning
+ * the new entry starts as if it had been locally invalidated.
+ * @param aCallbackArgument a user-defined parameter to pass to callback
+ * events triggered by this method. Can be nullptr. Should be serializable if
+ * passed to remote callback events
+ * @throws IllegalArgumentException if key is nullptr or if the key, value, or
+ * aCallbackArgument do not meet serializability requirements
+ * @throws CacheWriterException if CacheWriter aborts the operation
+ * @throws CacheListenerException if CacheListener throws an exception
+ * @throws RegionDestroyedException if region is no longer valid
+ * @throws CacheServerException If an exception is received from the Java
+ * cache server. Only for Native Client regions.
+ * @throws NotConnectedException if it is not connected to the cache because
+ * the client
+ * cannot establish usable connections to any of the servers given to
+ * it
+ * For pools configured with locators, if no locators are available,
+ * the cause
+ * of NotConnectedException is set to NoAvailableLocatorsException.
+ * @throws MessageExcepton If the message received from server could not be
+ * handled. This will be the case when an unregistered typeId is
+ * received in the reply or reply is not well formed.
+ * More information can be found in the log.
+ * @throws TimeoutException if the operation timed out
+ * @throws OutOfMemoryException if no memory for new entry
+ * @throws EntryExistsException if an entry with this key already exists
+ */
virtual void create(const CacheableKeyPtr& key, const CacheablePtr& value,
const UserDataPtr& aCallbackArgument = nullptr) = 0;
@@ -577,27 +577,27 @@ class CPPCACHE_EXPORT Region : public std::enable_shared_from_this<Region> {
}
/** Invalidates the entry with the specified key,
- * and provides a user-defined argument to the <code>CacheListener</code>.
- * Invalidate only removes the value from the entry, the key is kept intact.
- * To completely remove the entry, destroy should be used.
- * The invalidate is not propogated to the Geode cache server to which it is
- * connected with.
- * <p>Updates the {@link CacheStatistics::getLastAccessedTime} and
- * {@link CacheStatistics::getLastModifiedTime} for this region and the entry.
- * <p>
- *
- * @param key the key of the value to be invalidated
- * @param aCallbackArgument a user-defined parameter to pass to callback events
- * triggered by this method. Can be nullptr. Should be serializable if
- * passed to remote callback events
- * @throws IllegalArgumentException if key is nullptr
- * @throws CacheListenerException if CacheListener throws an exception
- * @throws EntryNotFoundException if this entry does not exist in this region
- * locally
- * @throws RegionDestroyedException if the region is destroyed
- * @see destroy
- * @see CacheListener::afterInvalidate
- */
+ * and provides a user-defined argument to the <code>CacheListener</code>.
+ * Invalidate only removes the value from the entry, the key is kept intact.
+ * To completely remove the entry, destroy should be used.
+ * The invalidate is not propogated to the Geode cache server to which it is
+ * connected with.
+ * <p>Updates the {@link CacheStatistics::getLastAccessedTime} and
+ * {@link CacheStatistics::getLastModifiedTime} for this region and the entry.
+ * <p>
+ *
+ * @param key the key of the value to be invalidated
+ * @param aCallbackArgument a user-defined parameter to pass to callback
+ * events triggered by this method. Can be nullptr. Should be serializable if
+ * passed to remote callback events
+ * @throws IllegalArgumentException if key is nullptr
+ * @throws CacheListenerException if CacheListener throws an exception
+ * @throws EntryNotFoundException if this entry does not exist in this region
+ * locally
+ * @throws RegionDestroyedException if the region is destroyed
+ * @see destroy
+ * @see CacheListener::afterInvalidate
+ */
virtual void invalidate(const CacheableKeyPtr& key,
const UserDataPtr& aCallbackArgument = nullptr) = 0;
@@ -608,25 +608,25 @@ class CPPCACHE_EXPORT Region : public std::enable_shared_from_this<Region> {
}
/** Invalidates the entry with the specified key in the local cache only,
- * and provides a user-defined argument to the <code>CacheListener</code>.
- * Invalidate only removes the value from the entry, the key is kept intact.
- * To completely remove the entry, destroy should be used.
- * <p>Updates the {@link CacheStatistics::getLastAccessedTime} and
- * {@link CacheStatistics::getLastModifiedTime} for this region and the entry.
- * <p>
- *
- * @param key the key of the value to be invalidated
- * @param aCallbackArgument a user-defined parameter to pass to callback events
- * triggered by this method. Can be nullptr. Should be serializable if
- * passed to remote callback events
- * @throws IllegalArgumentException if key is nullptr
- * @throws CacheListenerException if CacheListener throws an exception
- * @throws EntryNotFoundException if this entry does not exist in this region
- * locally
- * @throws RegionDestroyedException if the region is destroyed
- * @see destroy
- * @see CacheListener::afterInvalidate
- */
+ * and provides a user-defined argument to the <code>CacheListener</code>.
+ * Invalidate only removes the value from the entry, the key is kept intact.
+ * To completely remove the entry, destroy should be used.
+ * <p>Updates the {@link CacheStatistics::getLastAccessedTime} and
+ * {@link CacheStatistics::getLastModifiedTime} for this region and the entry.
+ * <p>
+ *
+ * @param key the key of the value to be invalidated
+ * @param aCallbackArgument a user-defined parameter to pass to callback
+ * events triggered by this method. Can be nullptr. Should be serializable if
+ * passed to remote callback events
+ * @throws IllegalArgumentException if key is nullptr
+ * @throws CacheListenerException if CacheListener throws an exception
+ * @throws EntryNotFoundException if this entry does not exist in this region
+ * locally
+ * @throws RegionDestroyedException if the region is destroyed
+ * @see destroy
+ * @see CacheListener::afterInvalidate
+ */
virtual void localInvalidate(
const CacheableKeyPtr& key,
const UserDataPtr& aCallbackArgument = nullptr) = 0;
@@ -639,49 +639,49 @@ class CPPCACHE_EXPORT Region : public std::enable_shared_from_this<Region> {
}
/** Destroys the entry with the specified key, and provides a user-defined
- * parameter object to any <code>CacheWriter</code> invoked in the process.
- * The same parameter is also passed to the <code>CacheListener</code>,
- * if one is defined for this <code>Region</code>, invoked in the process.
- * Destroy removes
- * not only the value, but also the key and entry from this region.
- *
- * The destroy is propogated to the Geode cache server to which it is
- * connected with. If the destroy fails due to an exception on server
- * throwing back <code>CacheServerException</code> or security exception,
- * then the local entry is still destroyed.
- *
- * <p>Updates the {@link CacheStatistics::getLastAccessedTime} and
- * {@link CacheStatistics::getLastModifiedTime} for this region and the entry.
- * <p>
- *
- * @param key the key of the entry to destroy
- * @param aCallbackArgument a user-defined parameter to pass to callback events
- * triggered by this method.
- * Can be nullptr. If it is sent on the wire, it has to be Serializable.
- * @throws IllegalArgumentException if key is nullptr
- * @throws CacheWriterException if CacheWriter aborts the operation
- * @throws CacheListenerException if CacheListener throws an exception
- * @throws CacheServerException If an exception is received from the Geode
- * cache server.
- * Only for Native Client regions.
- * @throws NotConnectedException if it is not connected to the cache because
- * the client
- * cannot establish usable connections to any of the servers given to
- * it
- * For pools configured with locators, if no locators are available,
- * the cause
- * of NotConnectedException is set to NoAvailableLocatorsException.
- * @throws MessageExcepton If the message received from server could not be
- * handled. This will be the case when an unregistered typeId is
- * received in the reply or reply is not well formed.
- * More information can be found in the log.
- * @throws TimeoutException if the operation timed out
- * @throws RegionDestroyedException if the region is destroyed.
- * @throws EntryNotFoundException if the entry does not exist in this region.
- * @see invalidate
- * @see CacheListener::afterDestroy
- * @see CacheWriter::beforeDestroy
- */
+ * parameter object to any <code>CacheWriter</code> invoked in the process.
+ * The same parameter is also passed to the <code>CacheListener</code>,
+ * if one is defined for this <code>Region</code>, invoked in the process.
+ * Destroy removes
+ * not only the value, but also the key and entry from this region.
+ *
+ * The destroy is propogated to the Geode cache server to which it is
+ * connected with. If the destroy fails due to an exception on server
+ * throwing back <code>CacheServerException</code> or security exception,
+ * then the local entry is still destroyed.
+ *
+ * <p>Updates the {@link CacheStatistics::getLastAccessedTime} and
+ * {@link CacheStatistics::getLastModifiedTime} for this region and the entry.
+ * <p>
+ *
+ * @param key the key of the entry to destroy
+ * @param aCallbackArgument a user-defined parameter to pass to callback
+ * events triggered by this method. Can be nullptr. If it is sent on the wire,
+ * it has to be Serializable.
+ * @throws IllegalArgumentException if key is nullptr
+ * @throws CacheWriterException if CacheWriter aborts the operation
+ * @throws CacheListenerException if CacheListener throws an exception
+ * @throws CacheServerException If an exception is received from the Geode
+ * cache server.
+ * Only for Native Client regions.
+ * @throws NotConnectedException if it is not connected to the cache because
+ * the client
+ * cannot establish usable connections to any of the servers given to
+ * it
+ * For pools configured with locators, if no locators are available,
+ * the cause
+ * of NotConnectedException is set to NoAvailableLocatorsException.
+ * @throws MessageExcepton If the message received from server could not be
+ * handled. This will be the case when an unregistered typeId is
+ * received in the reply or reply is not well formed.
+ * More information can be found in the log.
+ * @throws TimeoutException if the operation timed out
+ * @throws RegionDestroyedException if the region is destroyed.
+ * @throws EntryNotFoundException if the entry does not exist in this region.
+ * @see invalidate
+ * @see CacheListener::afterDestroy
+ * @see CacheWriter::beforeDestroy
+ */
virtual void destroy(const CacheableKeyPtr& key,
const UserDataPtr& aCallbackArgument = nullptr) = 0;
@@ -726,53 +726,53 @@ class CPPCACHE_EXPORT Region : public std::enable_shared_from_this<Region> {
}
/** Removes the entry with the specified key, value and provides a
- * user-defined
- * parameter object to any <code>CacheWriter</code> invoked in the process.
- * The same parameter is also passed to the <code>CacheListener</code> and
- * <code>CacheWriter</code>,
- * if one is defined for this <code>Region</code>, invoked in the process.
- * remove removes
- * not only the value, but also the key and entry from this region.
- *
- * The remove is propogated to the Geode cache server to which it is
- * connected with. If the destroy fails due to an exception on server
- * throwing back <code>CacheServerException</code> or security exception,
- * then the local entry is still removed.
- *
- * <p>Updates the {@link CacheStatistics::getLastAccessedTime} and
- * {@link CacheStatistics::getLastModifiedTime} for this region and the entry.
- * <p>
- *
- * @param key the key of the entry to remove
- * @param value the value of the key to remove, it can be nullptr.
- * @param aCallbackArgument a user-defined parameter to pass to callback events
- * triggered by this method.
- * Can be nullptr. If it is sent on the wire, it has to be Serializable.
- * @throws IllegalArgumentException if key is nullptr
- * @throws CacheWriterException if CacheWriter aborts the operation
- * @throws CacheListenerException if CacheListener throws an exception
- * @throws CacheServerException If an exception is received from the Geode
- * cache server.
- * Only for Native Client regions.
- * @throws NotConnectedException if it is not connected to the cache because
- * the client
- * cannot establish usable connections to any of the servers given to
- * it
- * For pools configured with locators, if no locators are available,
- * the cause
- * of NotConnectedException is set to NoAvailableLocatorsException.
- * @throws MessageExcepton If the message received from server could not be
- * handled. This will be the case when an unregistered typeId is
- * received in the reply or reply is not well formed.
- * More information can be found in the log.
- * @throws TimeoutException if the operation timed out
- * @throws RegionDestroyedException if the region is destroyed.
- * @return the boolean true if an entry(key, value)has been removed or
- * false if an entry(key, value) has not been removed.
- * @see destroy
- * @see CacheListener::afterDestroy
- * @see CacheWriter::beforeDestroy
- */
+ * user-defined
+ * parameter object to any <code>CacheWriter</code> invoked in the process.
+ * The same parameter is also passed to the <code>CacheListener</code> and
+ * <code>CacheWriter</code>,
+ * if one is defined for this <code>Region</code>, invoked in the process.
+ * remove removes
+ * not only the value, but also the key and entry from this region.
+ *
+ * The remove is propogated to the Geode cache server to which it is
+ * connected with. If the destroy fails due to an exception on server
+ * throwing back <code>CacheServerException</code> or security exception,
+ * then the local entry is still removed.
+ *
+ * <p>Updates the {@link CacheStatistics::getLastAccessedTime} and
+ * {@link CacheStatistics::getLastModifiedTime} for this region and the entry.
+ * <p>
+ *
+ * @param key the key of the entry to remove
+ * @param value the value of the key to remove, it can be nullptr.
+ * @param aCallbackArgument a user-defined parameter to pass to callback
+ * events triggered by this method. Can be nullptr. If it is sent on the wire,
+ * it has to be Serializable.
+ * @throws IllegalArgumentException if key is nullptr
+ * @throws CacheWriterException if CacheWriter aborts the operation
+ * @throws CacheListenerException if CacheListener throws an exception
+ * @throws CacheServerException If an exception is received from the Geode
+ * cache server.
+ * Only for Native Client regions.
+ * @throws NotConnectedException if it is not connected to the cache because
+ * the client
+ * cannot establish usable connections to any of the servers given to
+ * it
+ * For pools configured with locators, if no locators are available,
+ * the cause
+ * of NotConnectedException is set to NoAvailableLocatorsException.
+ * @throws MessageExcepton If the message received from server could not be
+ * handled. This will be the case when an unregistered typeId is
+ * received in the reply or reply is not well formed.
+ * More information can be found in the log.
+ * @throws TimeoutException if the operation timed out
+ * @throws RegionDestroyedException if the region is destroyed.
+ * @return the boolean true if an entry(key, value)has been removed or
+ * false if an entry(key, value) has not been removed.
+ * @see destroy
+ * @see CacheListener::afterDestroy
+ * @see CacheWriter::beforeDestroy
+ */
virtual bool remove(const CacheableKeyPtr& key, const CacheablePtr& value,
const UserDataPtr& aCallbackArgument = nullptr) = 0;
@@ -806,51 +806,51 @@ class CPPCACHE_EXPORT Region : public std::enable_shared_from_this<Region> {
}
/** Removes the entry with the specified key and provides a user-defined
- * parameter object to any <code>CacheWriter</code> invoked in the process.
- * The same parameter is also passed to the <code>CacheListener</code> and
- * <code>CacheWriter</code>,
- * if one is defined for this <code>Region</code>, invoked in the process.
- * remove removes
- * not only the value, but also the key and entry from this region.
- *
- * The remove is propogated to the Geode cache server to which it is
- * connected with. If the destroy fails due to an exception on server
- * throwing back <code>CacheServerException</code> or security exception,
- * then the local entry is still removed.
- *
- * <p>Updates the {@link CacheStatistics::getLastAccessedTime} and
- * {@link CacheStatistics::getLastModifiedTime} for this region and the entry.
- * <p>
- *
- * @param key the key of the entry to remove
- * @param aCallbackArgument a user-defined parameter to pass to callback events
- * triggered by this method.
- * Can be nullptr. If it is sent on the wire, it has to be Serializable.
- * @throws IllegalArgumentException if key is nullptr
- * @throws CacheWriterException if CacheWriter aborts the operation
- * @throws CacheListenerException if CacheListener throws an exception
- * @throws CacheServerException If an exception is received from the Geode
- * cache server.
- * Only for Native Client regions.
- * @throws NotConnectedException if it is not connected to the cache because
- * the client
- * cannot establish usable connections to any of the servers given to
- * it
- * For pools configured with locators, if no locators are available,
- * the cause
- * of NotConnectedException is set to NoAvailableLocatorsException.
- * @throws MessageExcepton If the message received from server could not be
- * handled. This will be the case when an unregistered typeId is
- * received in the reply or reply is not well formed.
- * More information can be found in the log.
- * @throws TimeoutException if the operation timed out
- * @throws RegionDestroyedException if the region is destroyed.
- * @return the boolean true if an entry(key, value)has been removed or
- * false if an entry(key, value) has not been removed.
- * @see destroy
- * @see CacheListener::afterDestroy
- * @see CacheWriter::beforeDestroy
- */
+ * parameter object to any <code>CacheWriter</code> invoked in the process.
+ * The same parameter is also passed to the <code>CacheListener</code> and
+ * <code>CacheWriter</code>,
+ * if one is defined for this <code>Region</code>, invoked in the process.
+ * remove removes
+ * not only the value, but also the key and entry from this region.
+ *
+ * The remove is propogated to the Geode cache server to which it is
+ * connected with. If the destroy fails due to an exception on server
+ * throwing back <code>CacheServerException</code> or security exception,
+ * then the local entry is still removed.
+ *
+ * <p>Updates the {@link CacheStatistics::getLastAccessedTime} and
+ * {@link CacheStatistics::getLastModifiedTime} for this region and the entry.
+ * <p>
+ *
+ * @param key the key of the entry to remove
+ * @param aCallbackArgument a user-defined parameter to pass to callback
+ * events triggered by this method. Can be nullptr. If it is sent on the wire,
+ * it has to be Serializable.
+ * @throws IllegalArgumentException if key is nullptr
+ * @throws CacheWriterException if CacheWriter aborts the operation
+ * @throws CacheListenerException if CacheListener throws an exception
+ * @throws CacheServerException If an exception is received from the Geode
+ * cache server.
+ * Only for Native Client regions.
+ * @throws NotConnectedException if it is not connected to the cache because
+ * the client
+ * cannot establish usable connections to any of the servers given to
+ * it
+ * For pools configured with locators, if no locators are available,
+ * the cause
+ * of NotConnectedException is set to NoAvailableLocatorsException.
+ * @throws MessageExcepton If the message received from server could not be
+ * handled. This will be the case when an unregistered typeId is
+ * received in the reply or reply is not well formed.
+ * More information can be found in the log.
+ * @throws TimeoutException if the operation timed out
+ * @throws RegionDestroyedException if the region is destroyed.
+ * @return the boolean true if an entry(key, value)has been removed or
+ * false if an entry(key, value) has not been removed.
+ * @see destroy
+ * @see CacheListener::afterDestroy
+ * @see CacheWriter::beforeDestroy
+ */
virtual bool removeEx(const CacheableKeyPtr& key,
const UserDataPtr& aCallbackArgument = nullptr) = 0;
@@ -861,32 +861,32 @@ class CPPCACHE_EXPORT Region : public std::enable_shared_from_this<Region> {
}
/** Removes the entry with the specified key and value in the local cache
- * only,
- * and provides a user-defined parameter object to any
- * <code>CacheWriter</code> invoked in the process.
- * The same parameter is also passed to the <code>CacheListener</code> and
- * <code>CacheWriter</code>,
- * if one is defined for this <code>Region</code>, invoked in the process.
- * Remove removes
- * not only the value but also the key and entry from this region.
- * <p>
- * <p>Updates the {@link CacheStatistics::getLastAccessedTime} and
- * {@link CacheStatistics::getLastModifiedTime} for this region and the entry.
- * <p>
- *
- * @param key the key of the entry to remove.
- * @param value the value of the entry to remove.
- * @param aCallbackArgument the callback for user to pass in, default is
- * nullptr.
- * @throws IllegalArgumentException if key is nullptr
- * @throws CacheWriterException if CacheWriter aborts the operation
- * @throws CacheListenerException if CacheListener throws an exception
- * @return the boolean true if an entry(key, value)has been removed or
- * false if an entry(key, value) has not been removed.
- * @see destroy
- * @see CacheListener::afterDestroy
- * @see CacheWriter::beforeDestroy
- */
+ * only,
+ * and provides a user-defined parameter object to any
+ * <code>CacheWriter</code> invoked in the process.
+ * The same parameter is also passed to the <code>CacheListener</code> and
+ * <code>CacheWriter</code>,
+ * if one is defined for this <code>Region</code>, invoked in the process.
+ * Remove removes
+ * not only the value but also the key and entry from this region.
+ * <p>
+ * <p>Updates the {@link CacheStatistics::getLastAccessedTime} and
+ * {@link CacheStatistics::getLastModifiedTime} for this region and the entry.
+ * <p>
+ *
+ * @param key the key of the entry to remove.
+ * @param value the value of the entry to remove.
+ * @param aCallbackArgument the callback for user to pass in, default is
+ * nullptr.
+ * @throws IllegalArgumentException if key is nullptr
+ * @throws CacheWriterException if CacheWriter aborts the operation
+ * @throws CacheListenerException if CacheListener throws an exception
+ * @return the boolean true if an entry(key, value)has been removed or
+ * false if an entry(key, value) has not been removed.
+ * @see destroy
+ * @see CacheListener::afterDestroy
+ * @see CacheWriter::beforeDestroy
+ */
virtual bool localRemove(const CacheableKeyPtr& key,
const CacheablePtr& value,
const UserDataPtr& aCallbackArgument = nullptr) = 0;
@@ -913,30 +913,30 @@ class CPPCACHE_EXPORT Region : public std::enable_shared_from_this<Region> {
}
/** Removes the entry with the specified key in the local cache only,
- * and provides a user-defined parameter object to any
- * <code>CacheWriter</code> invoked in the process.
- * The same parameter is also passed to the <code>CacheListener</code> and
- * <code>CacheWriter</code>,
- * if one is defined for this <code>Region</code>, invoked in the process.
- * Remove removes
- * not only the value but also the key and entry from this region.
- * <p>
- * <p>Updates the {@link CacheStatistics::getLastAccessedTime} and
- * {@link CacheStatistics::getLastModifiedTime} for this region and the entry.
- * <p>
- *
- * @param key the key of the entry to remove.
- * @param aCallbackArgument the callback for user to pass in, default is
- * nullptr.
- * @throws IllegalArgumentException if key is nullptr
- * @throws CacheWriterException if CacheWriter aborts the operation
- * @throws CacheListenerException if CacheListener throws an exception
- * @return the boolean true if an entry(key, value)has been removed or
- * false if an entry(key, value) has not been removed.
- * @see destroy
- * @see CacheListener::afterDestroy
- * @see CacheWriter::beforeDestroy
- */
+ * and provides a user-defined parameter object to any
+ * <code>CacheWriter</code> invoked in the process.
+ * The same parameter is also passed to the <code>CacheListener</code> and
+ * <code>CacheWriter</code>,
+ * if one is defined for this <code>Region</code>, invoked in the process.
+ * Remove removes
+ * not only the value but also the key and entry from this region.
+ * <p>
+ * <p>Updates the {@link CacheStatistics::getLastAccessedTime} and
+ * {@link CacheStatistics::getLastModifiedTime} for this region and the entry.
+ * <p>
+ *
+ * @param key the key of the entry to remove.
+ * @param aCallbackArgument the callback for user to pass in, default is
+ * nullptr.
+ * @throws IllegalArgumentException if key is nullptr
+ * @throws CacheWriterException if CacheWriter aborts the operation
+ * @throws CacheListenerException if CacheListener throws an exception
+ * @return the boolean true if an entry(key, value)has been removed or
+ * false if an entry(key, value) has not been removed.
+ * @see destroy
+ * @see CacheListener::afterDestroy
+ * @see CacheWriter::beforeDestroy
+ */
virtual bool localRemoveEx(
const CacheableKeyPtr& key,
@@ -950,42 +950,42 @@ class CPPCACHE_EXPORT Region : public std::enable_shared_from_this<Region> {
}
/**
- * Return all the keys in the local process for this region. This includes
- * keys for which the entry is invalid.
- */
+ * Return all the keys in the local process for this region. This includes
+ * keys for which the entry is invalid.
+ */
virtual void keys(VectorOfCacheableKey& v) = 0;
/**
- * Return the set of keys defined in the server process associated to this
- * client and region. If a server has the region defined as a mirror, then
- * this will be the entire keyset for the region across all PEER in the
- * distributed system.
- * The vector v will contain only the server keys. Any prior contents in the
- * vector will be removed.
- * @throws CacheServerException If an exception is received from the Geode
- * cache server.
- * Only for Native Client regions.
- * @throws NotConnectedException if it is not connected to the cache because
- * the client
- * cannot establish usable connections to any of the servers given to
- * it
- * For pools configured with locators, if no locators are available,
- * the cause
- * of NotConnectedException is set to NoAvailableLocatorsException.
- * @throws MessageExcepton If the message received from server could not be
- * handled. This will be the case when an unregistered typeId is
- * received in the reply or reply is not well formed.
- * More information can be found in the log.
- * @throws TimeoutException if there is a timeout getting the keys
- * @throws UnsupportedOperationException if the member type is not CLIENT
- * or region is not a native client one.
- */
+ * Return the set of keys defined in the server process associated to this
+ * client and region. If a server has the region defined as a mirror, then
+ * this will be the entire keyset for the region across all PEER in the
+ * distributed system.
+ * The vector v will contain only the server keys. Any prior contents in the
+ * vector will be removed.
+ * @throws CacheServerException If an exception is received from the Geode
+ * cache server.
+ * Only for Native Client regions.
+ * @throws NotConnectedException if it is not connected to the cache because
+ * the client
+ * cannot establish usable connections to any of the servers given to
+ * it
+ * For pools configured with locators, if no locators are available,
+ * the cause
+ * of NotConnectedException is set to NoAvailableLocatorsException.
+ * @throws MessageExcepton If the message received from server could not be
+ * handled. This will be the case when an unregistered typeId is
+ * received in the reply or reply is not well formed.
+ * More information can be found in the log.
+ * @throws TimeoutException if there is a timeout getting the keys
+ * @throws UnsupportedOperationException if the member type is not CLIENT
+ * or region is not a native client one.
+ */
virtual void serverKeys(VectorOfCacheableKey& v) = 0;
/**
- * Return all values in the local process for this region. No value is included
- * for entries that are invalidated.
- */
+ * Return all values in the local process for this region. No value is
+ * included for entries that are invalidated.
+ */
virtual void values(VectorOfCacheable& vc) = 0;
virtual void entries(VectorOfRegionEntry& me, bool recursive) = 0;
@@ -999,313 +999,313 @@ class CPPCACHE_EXPORT Region : public std::enable_shared_from_this<Region> {
virtual bool isDestroyed() const = 0;
/**
- * This operations checks for the value in the local cache .
- * It is not propagated to the Geode cache server
- * to which it is connected.
- */
+ * This operations checks for the value in the local cache .
+ * It is not propagated to the Geode cache server
+ * to which it is connected.
+ */
virtual bool containsValueForKey(const CacheableKeyPtr& keyPtr) const = 0;
/**
- * Convenience method allowing key to be a const char*
- * This operations checks for the value in the local cache .
- * It is not propagated to the Geode cache server
- * to which it is connected.
- */
+ * Convenience method allowing key to be a const char*
+ * This operations checks for the value in the local cache .
+ * It is not propagated to the Geode cache server
+ * to which it is connected.
+ */
template <class KEYTYPE>
inline bool containsValueForKey(const KEYTYPE& key) const {
return containsValueForKey(createKey(key));
}
/**
- * Only the client's cache is searched for the key. It does not go to the java
- * server
- * to which it is connected with.
- */
+ * Only the client's cache is searched for the key. It does not go to the java
+ * server
+ * to which it is connected with.
+ */
virtual bool containsKey(const CacheableKeyPtr& keyPtr) const = 0;
/**
- * The cache of the server, to which it is connected with, is searched
- * for the key to see if the key is present.
- * @throws UnsupportedOperationException if the region's scope is
- * ScopeType::LOCAL.
- */
+ * The cache of the server, to which it is connected with, is searched
+ * for the key to see if the key is present.
+ * @throws UnsupportedOperationException if the region's scope is
+ * ScopeType::LOCAL.
+ */
virtual bool containsKeyOnServer(const CacheableKeyPtr& keyPtr) const = 0;
/**
- * Returns the list of keys on which this client is interested and will be
- * notified of changes.
- * @throws UnsupportedOperationException if the region's scope is
- * ScopeType::LOCAL.
- */
+ * Returns the list of keys on which this client is interested and will be
+ * notified of changes.
+ * @throws UnsupportedOperationException if the region's scope is
+ * ScopeType::LOCAL.
+ */
virtual void getInterestList(VectorOfCacheableKey& vlist) const = 0;
/**
- * Returns the list of regular expresssions on which this client is
- * interested and will be notified of changes.
- * @throws UnsupportedOperationException if the region's scope is
- * ScopeType::LOCAL.
- */
+ * Returns the list of regular expresssions on which this client is
+ * interested and will be notified of changes.
+ * @throws UnsupportedOperationException if the region's scope is
+ * ScopeType::LOCAL.
+ */
virtual void getInterestListRegex(VectorOfCacheableString& vregex) const = 0;
/**
- * Convenience method allowing key to be a const char*
- * This operations checks for the key in the local cache .
- * It is not propagated to the Geode cache server
- * to which it is connected.
- */
+ * Convenience method allowing key to be a const char*
+ * This operations checks for the key in the local cache .
+ * It is not propagated to the Geode cache server
+ * to which it is connected.
+ */
template <class KEYTYPE>
inline bool containsKey(const KEYTYPE& key) const {
return containsKey(createKey(key));
}
/**
- * Registers an array of keys for getting updates from the server.
- * Valid only for a Native Client region when client notification
- * ( {@link AttributesFactory::setClientNotification} ) is true.
- *
- * @param keys the array of keys
- * @param isDurable flag to indicate whether this is a durable registration
- * @param getInitialValues true to populate the cache with values of the keys
- * that were registered on the server
- * @param receiveValues whether to act like notify-by-subscription is set
- *
- * @throws IllegalArgumentException If the array of keys is empty.
- * @throws IllegalStateException If already registered interest for all keys.
- * @throws EntryNotFoundException If an exception occurs while obtaining
- * values from server after register interest is complete. The actual cause
- * of the exception can be obtained using <code>Exception::getCause</code>.
- * If an application wants to undo the registration on server, or take
- * some other steps for the incomplete cache population then this is
- * the exception that should be caught.
- * @throws UnsupportedOperationException If the region is not a Native Client
- * region or
- * {@link AttributesFactory::setClientNotification} is false.
- * @throws CacheServerException If an exception is received from the Java cache
- * server.
- * @throws NotConnectedException if it is not connected to the cache because
- * the client
- * cannot establish usable connections to any of the servers given to
- * it
- * For pools configured with locators, if no locators are available,
- * the cause
- * of NotConnectedException is set to NoAvailableLocatorsException.
- * @throws RegionDestroyedException If region destroy is pending.
- * @throws UnknownException For other exceptions.
- * @throws TimeoutException if operation timed out
- */
+ * Registers an array of keys for getting updates from the server.
+ * Valid only for a Native Client region when client notification
+ * ( {@link AttributesFactory::setClientNotification} ) is true.
+ *
+ * @param keys the array of keys
+ * @param isDurable flag to indicate whether this is a durable registration
+ * @param getInitialValues true to populate the cache with values of the keys
+ * that were registered on the server
+ * @param receiveValues whether to act like notify-by-subscription is set
+ *
+ * @throws IllegalArgumentException If the array of keys is empty.
+ * @throws IllegalStateException If already registered interest for all keys.
+ * @throws EntryNotFoundException If an exception occurs while obtaining
+ * values from server after register interest is complete. The actual cause
+ * of the exception can be obtained using <code>Exception::getCause</code>.
+ * If an application wants to undo the registration on server, or take
+ * some other steps for the incomplete cache population then this is
+ * the exception that should be caught.
+ * @throws UnsupportedOperationException If the region is not a Native Client
+ * region or
+ * {@link AttributesFactory::setClientNotification} is false.
+ * @throws CacheServerException If an exception is received from the Java
+ * cache server.
+ * @throws NotConnectedException if it is not connected to the cache because
+ * the client
+ * cannot establish usable connections to any of the servers given to
+ * it
+ * For pools configured with locators, if no locators are available,
+ * the cause
+ * of NotConnectedException is set to NoAvailableLocatorsException.
+ * @throws RegionDestroyedException If region destroy is pending.
+ * @throws UnknownException For other exceptions.
+ * @throws TimeoutException if operation timed out
+ */
virtual void registerKeys(const VectorOfCacheableKey& keys,
bool isDurable = false,
bool getInitialValues = false,
bool receiveValues = true) = 0;
/**
- * Unregisters an array of keys to stop getting updates for them.
- * Valid only for a Native Client region when client notification
- * ( {@link AttributesFactory::setClientNotification} ) is true.
- *
- * @param keys the array of keys
- *
- * @throws IllegalArgumentException If the array of keys is empty.
- * @throws IllegalStateException If no keys were previously registered.
- * @throws UnsupportedOperationException If the region is not a Native Client
- * region or
- * {@link AttributesFactory::setClientNotification} is false.
- * @throws CacheServerException If an exception is received from the Java cache
- * server.
- * @throws NotConnectedException if it is not connected to the cache because
- * the client
- * cannot establish usable connections to any of the servers given to
- * it
- * For pools configured with locators, if no locators are available,
- * the cause
- * of NotConnectedException is set to NoAvailableLocatorsException.
- * @throws RegionDestroyedException If region destroy is pending.
- * @throws UnknownException For other exceptions.
- * @throws TimeoutException if operation timed out
- */
+ * Unregisters an array of keys to stop getting updates for them.
+ * Valid only for a Native Client region when client notification
+ * ( {@link AttributesFactory::setClientNotification} ) is true.
+ *
+ * @param keys the array of keys
+ *
+ * @throws IllegalArgumentException If the array of keys is empty.
+ * @throws IllegalStateException If no keys were previously registered.
+ * @throws UnsupportedOperationException If the region is not a Native Client
+ * region or
+ * {@link AttributesFactory::setClientNotification} is false.
+ * @throws CacheServerException If an exception is received from the Java
+ * cache server.
+ * @throws NotConnectedException if it is not connected to the cache because
+ * the client
+ * cannot establish usable connections to any of the servers given to
+ * it
+ * For pools configured with locators, if no locators are available,
+ * the cause
+ * of NotConnectedException is set to NoAvailableLocatorsException.
+ * @throws RegionDestroyedException If region destroy is pending.
+ * @throws UnknownException For other exceptions.
+ * @throws TimeoutException if operation timed out
+ */
virtual void unregisterKeys(const VectorOfCacheableKey& keys) = 0;
/**
- * Registers to get updates for all keys from the server.
- * Valid only for a Native Client region when client notification
- * ( {@link AttributesFactory::setClientNotification} ) is true.
- *
- * @param isDurable flag to indicate whether this is a durable registration
- * @param resultKeys If non-nullptr then all the keys on the server that got
- * registered are returned. The vector is cleared at the start to discard
- * any existing keys in the vector.
- * @param getInitialValues true to populate the cache with values of all keys
- * from the server
- * @param receiveValues whether to act like notify-by-subscription is set
- *
- * @throws EntryNotFoundException If an exception occurs while obtaining
- * values from server after register interest is complete. The actual cause
- * of the exception can be obtained using <code>Exception::getCause</code>.
- * If an application wants to undo the registration on server, or take
- * some other steps for the incomplete cache population then this is
- * the exception that should be caught.
- * @throws UnsupportedOperationException If the region is not a Native Client
- * region or
- * {@link AttributesFactory::setClientNotification} is false.
- * @throws CacheServerException If an exception is received from the Java cache
- * server.
- * @throws NotConnectedException if it is not connected to the cache because
- * the client
- * cannot establish usable connections to any of the servers given to
- * it
- * For pools configured with locators, if no locators are available,
- * the cause
- * of NotConnectedException is set to NoAvailableLocatorsException.
- * @throws RegionDestroyedException If region destroy is pending.
- * @throws UnknownException For other exceptions.
- * @throws TimeoutException if operation timed out
- */
+ * Registers to get updates for all keys from the server.
+ * Valid only for a Native Client region when client notification
+ * ( {@link AttributesFactory::setClientNotification} ) is true.
+ *
+ * @param isDurable flag to indicate whether this is a durable registration
+ * @param resultKeys If non-nullptr then all the keys on the server that got
+ * registered are returned. The vector is cleared at the start to discard
+ * any existing keys in the vector.
+ * @param getInitialValues true to populate the cache with values of all keys
+ * from the server
+ * @param receiveValues whether to act like notify-by-subscription is set
+ *
+ * @throws EntryNotFoundException If an exception occurs while obtaining
+ * values from server after register interest is complete. The actual cause
+ * of the exception can be obtained using <code>Exception::getCause</code>.
+ * If an application wants to undo the registration on server, or take
+ * some other steps for the incomplete cache population then this is
+ * the exception that should be caught.
+ * @throws UnsupportedOperationException If the region is not a Native Client
+ * region or
+ * {@link AttributesFactory::setClientNotification} is false.
+ * @throws CacheServerException If an exception is received from the Java
+ * cache server.
+ * @throws NotConnectedException if it is not connected to the cache because
+ * the client
+ * cannot establish usable connections to any of the servers given to
+ * it
+ * For pools configured with locators, if no locators are available,
+ * the cause
+ * of NotConnectedException is set to NoAvailableLocatorsException.
+ * @throws RegionDestroyedException If region destroy is pending.
+ * @throws UnknownException For other exceptions.
+ * @throws TimeoutException if operation timed out
+ */
virtual void registerAllKeys(bool isDurable = false,
VectorOfCacheableKeyPtr resultKeys = nullptr,
bool getInitialValues = false,
bool receiveValues = true) = 0;
/**
- * Registers to get updates for all keys from the server.
- * Valid only for a Native Client region when client notification
- * ( {@link AttributesFactory::setClientNotification} ) is true.
- *
- * @throws IllegalStateException If not previously registered all keys.
- * @throws UnsupportedOperationException If the region is not a Native Client
- * region or
- * {@link AttributesFactory::setClientNotification} is false.
- * @throws CacheServerException If an exception is received from the Java cache
- * server.
- * @throws NotConnectedException if it is not connected to the cache because
- * the client
- * cannot establish usable connections to any of the servers given to
- * it
- * For pools configured with locators, if no locators are available,
- * the cause
- * of NotConnectedException is set to NoAvailableLocatorsException.
- * @throws RegionDestroyedException If region destroy is pending.
- * @throws UnknownException For other exceptions.
- * @throws TimeoutException if operation timed out
- */
+ * Registers to get updates for all keys from the server.
+ * Valid only for a Native Client region when client notification
+ * ( {@link AttributesFactory::setClientNotification} ) is true.
+ *
+ * @throws IllegalStateException If not previously registered all keys.
+ * @throws UnsupportedOperationException If the region is not a Native Client
+ * region or
+ * {@link AttributesFactory::setClientNotification} is false.
+ * @throws CacheServerException If an exception is received from the Java
+ * cache server.
+ * @throws NotConnectedException if it is not connected to the cache because
+ * the client
+ * cannot establish usable connections to any of the servers given to
+ * it
+ * For pools configured with locators, if no locators are available,
+ * the cause
+ * of NotConnectedException is set to NoAvailableLocatorsException.
+ * @throws RegionDestroyedException If region destroy is pending.
+ * @throws UnknownException For other exceptions.
+ * @throws TimeoutException if operation timed out
+ */
virtual void unregisterAllKeys() = 0;
/**
- * Registers a regular expression to match with keys to get updates from the
- * server.
- * Valid only for a Native Client region when client notification
- * ( {@link AttributesFactory::setClientNotification} ) is true.
- *
- * @param regex The regular expression string.
- * @param isDurable flag to indicate whether this is a durable registration
- * @param resultKeys If non-nullptr then the keys that match the regular
- * expression on the server are returned. The vector is cleared at the
- * start to discard any existing keys in the vector.
- * @param getInitialValues true to populate the cache with values of the keys
- * that were registered on the server
- * @param receiveValues whether to act like notify-by-subscription is set
- *
- * @throws IllegalArgumentException If regex is empty.
- * @throws IllegalStateException If already registered interest for all keys.
- * @throws EntryNotFoundException If an exception occurs while obtaining
- * values from server after register interest is complete. The actual cause
- * of the exception can be obtained using <code>Exception::getCause</code>.
- * If an application wants to undo the registration on server, or take
- * some other steps for the incomplete cache population then this is
- * the exception that should be caught.
- * @throws UnsupportedOperationException If the region is not a Native Client
- * region or
- * {@link AttributesFactory::setClientNotification} is false.
- * @throws CacheServerException If an exception is received from the Java cache
- * server.
- * @throws NotConnectedException if it is not connected to the cache because
- * the client
- * cannot establish usable connections to any of the servers given to
- * it
- * For pools configured with locators, if no locators are available,
- * the cause
- * of NotConnectedException is set to NoAvailableLocatorsException.
- * @throws MessageExcepton If the message received from server could not be
- * handled. This will be the case when an unregistered typeId is
- * received in the reply or reply is not well formed.
- * More information can be found in the log.
- * @throws RegionDestroyedException If region destroy is pending.
- * @throws UnknownException For other exceptions.
- * @throws TimeoutException if operation timed out
- */
+ * Registers a regular expression to match with keys to get updates from the
+ * server.
+ * Valid only for a Native Client region when client notification
+ * ( {@link AttributesFactory::setClientNotification} ) is true.
+ *
+ * @param regex The regular expression string.
+ * @param isDurable flag to indicate whether this is a durable registration
+ * @param resultKeys If non-nullptr then the keys that match the regular
+ * expression on the server are returned. The vector is cleared at the
+ * start to discard any existing keys in the vector.
+ * @param getInitialValues true to populate the cache with values of the keys
+ * that were registered on the server
+ * @param receiveValues whether to act like notify-by-subscription is set
+ *
+ * @throws IllegalArgumentException If regex is empty.
+ * @throws IllegalStateException If already registered interest for all keys.
+ * @throws EntryNotFoundException If an exception occurs while obtaining
+ * values from server after register interest is complete. The actual cause
+ * of the exception can be obtained using <code>Exception::getCause</code>.
+ * If an application wants to undo the registration on server, or take
+ * some other steps for the incomplete cache population then this is
+ * the exception that should be caught.
+ * @throws UnsupportedOperationException If the region is not a Native Client
+ * region or
+ * {@link AttributesFactory::setClientNotification} is false.
+ * @throws CacheServerException If an exception is received from the Java
+ * cache server.
+ * @throws NotConnectedException if it is not connected to the cache because
+ * the client
+ * cannot establish usable connections to any of the servers given to
+ * it
+ * For pools configured with locators, if no locators are available,
+ * the cause
+ * of NotConnectedException is set to NoAvailableLocatorsException.
+ * @throws MessageExcepton If the message received from server could not be
+ * handled. This will be the case when an unregistered typeId is
+ * received in the reply or reply is not well formed.
+ * More information can be found in the log.
+ * @throws RegionDestroyedException If region destroy is pending.
+ * @throws UnknownException For other exceptions.
+ * @throws TimeoutException if operation timed out
+ */
virtual void registerRegex(const char* regex, bool isDurable = false,
VectorOfCacheableKeyPtr resultKeys = nullptr,
bool getInitialValues = false,
bool receiveValues = true) = 0;
/**
- * Unregisters a regular expression to stop getting updates for keys from the
- * server.
- * Valid only for a Native Client region when client notification
- * ( {@link AttributesFactory::setClientNotification} ) is true.
- *
- * @param regex The regular expression string.
- *
- * @throws IllegalArgumentException If regex is empty.
- * @throws IllegalStateException If not previously registered this regular
- * expression string.
- * @throws UnsupportedOperationException If the region is not a Native Client
- * region or
- * {@link AttributesFactory::setClientNotification} is false.
- * @throws CacheServerException If an exception is received from the Java cache
- * server.
- * @throws NotConnectedException if it is not connected to the cache because
- * the client
- * cannot establish usable connections to any of the servers given to
- * it
- * For pools configured with locators, if no locators are available,
- * the cause
- * of NotConnectedException is set to NoAvailableLocatorsException.
- * @throws RegionDestroyedException If region destroy is pending.
- * @throws UnknownException For other exceptions.
- * @throws TimeoutException if operation timed out
- */
+ * Unregisters a regular expression to stop getting updates for keys from the
+ * server.
+ * Valid only for a Native Client region when client notification
+ * ( {@link AttributesFactory::setClientNotification} ) is true.
+ *
+ * @param regex The regular expression string.
+ *
+ * @throws IllegalArgumentException If regex is empty.
+ * @throws IllegalStateException If not previously registered this regular
+ * expression string.
+ * @throws UnsupportedOperationException If the region is not a Native Client
+ * region or
+ * {@link AttributesFactory::setClientNotification} is false.
+ * @throws CacheServerException If an exception is received from the Java
+ * cache server.
+ * @throws NotConnectedException if it is not connected to the cache because
+ * the client
+ * cannot establish usable connections to any of the servers given to
+ * it
+ * For pools configured with locators, if no locators are available,
+ * the cause
+ * of NotConnectedException is set to NoAvailableLocatorsException.
+ * @throws RegionDestroyedException If region destroy is pending.
+ * @throws UnknownException For other exceptions.
+ * @throws TimeoutException if operation timed out
+ */
virtual void unregisterRegex(const char* regex) = 0;
/**
- * Gets values for an array of keys from the local cache or server.
- * If value for a key is not present locally then it is requested from the
- * java server. The value returned is not copied, so multi-threaded
- * applications should not modify the value directly,
- * but should use the update methods.
- *<p>
- * Updates the {@link CacheStatistics::getLastAccessedTime},
- * {@link CacheStatistics::getHitCount} and {@link
- *CacheStatistics::getMissCount}
- * for this region and the entry.
- *
- * @param keys the array of keys
- * @param values Output parameter that provides the map of keys to
- * respective values. It is ignored if nullptr, and when nullptr then at
- *least
- * the <code>addToLocalCache</code> parameter should be true and caching
- * should be enabled for the region to get values into the region
- * otherwise an <code>IllegalArgumentException</code> is thrown.
- * @param exceptions Output parameter that provides the map of keys
- * to any exceptions while obtaining the key. It is ignored if nullptr.
- * @param addToLocalCache true if the obtained values have also to be added
- * to the local cache
- * @since 8.1
- * @param aCallbackArgument an argument that is passed to the callback
- *functions.
- * It may be nullptr. Must be serializable if this operation is distributed.
- * @throws IllegalArgumentException If the array of keys is empty. Other
- * invalid case is when the <code>values</code> parameter is nullptr, and
- * either <code>addToLocalCache</code> is false or caching is disabled
- * for this region.
- * @throws CacheServerException If an exception is received from the Java
- * cache server while processing the request.
- * @throws NotConnectedException if it is not connected to the cache because
- * the client cannot establish usable connections to any of the given servers
- * For pools configured with locators, if no locators are available, the
- *cause
- * of NotConnectedException is set to NoAvailableLocatorsException.
- * @throws RegionDestroyedException If region destroy is pending.
- * @throws TimeoutException if operation timed out.
- * @throws UnknownException For other exceptions.
- *
- * @see get
- */
+ * Gets values for an array of keys from the local cache or server.
+ * If value for a key is not present locally then it is requested from the
+ * java server. The value returned is not copied, so multi-threaded
+ * applications should not modify the value directly,
+ * but should use the update methods.
+ *<p>
+ * Updates the {@link CacheStatistics::getLastAccessedTime},
+ * {@link CacheStatistics::getHitCount} and {@link
+ *CacheStatistics::getMissCount}
+ * for this region and the entry.
+ *
+ * @param keys the array of keys
+ * @param values Output parameter that provides the map of keys to
+ * respective values. It is ignored if nullptr, and when nullptr then at
+ *least
+ * the <code>addToLocalCache</code> parameter should be true and caching
+ * should be enabled for the region to get values into the region
+ * otherwise an <code>IllegalArgumentException</code> is thrown.
+ * @param exceptions Output parameter that provides the map of keys
+ * to any exceptions while obtaining the key. It is ignored if nullptr.
+ * @param addToLocalCache true if the obtained values have also to be added
+ * to the local cache
+ * @since 8.1
+ * @param aCallbackArgument an argument that is passed to the callback
+ *functions.
+ * It may be nullptr. Must be serializable if this operation is distributed.
+ * @throws IllegalArgumentException If the array of keys is empty. Other
+ * invalid case is when the <code>values</code> parameter is nullptr, and
+ * either <code>addToLocalCache</code> is false or caching is disabled
+ * for this region.
+ * @throws CacheServerException If an exception is received from the Java
+ * cache server while processing the request.
+ * @throws NotConnectedException if it is not connected to the cache because
+ * the client cannot establish usable connections to any of the given
+ *servers For pools configured with locators, if no locators are available,
+ *the cause of NotConnectedException is set to
+ *NoAvailableLocatorsException.
+ * @throws RegionDestroyedException If region destroy is pending.
+ * @throws TimeoutException if operation timed out.
+ * @throws UnknownException For other exceptions.
+ *
+ * @see get
+ */
virtual void getAll(const VectorOfCacheableKey& keys,
HashMapOfCacheablePtr values,
HashMapOfExceptionPtr exceptions,
@@ -1313,121 +1313,119 @@ class CPPCACHE_EXPORT Region : public std::enable_shared_from_this<Region> {
const UserDataPtr& aCallbackArgument = nullptr) = 0;
/**
- * Executes the query on the server based on the predicate.
- * Valid only for a Native Client region.
- *
- * @param predicate The query predicate (just the WHERE clause) or the entire
- * query to execute.
- * @param timeout The time (in seconds) to wait for the query response,
- * optional.
- * This should be less than or equal to 2^31/1000 i.e. 2147483.
- *
- * @throws IllegalArgumentException If predicate is empty or timeout
- * parameter is greater than 2^31/1000.
- * @throws QueryException if some query error occurred at the server.
- * @throws CacheServerException If an exception is received from the Java cache
- * server.
- * @throws NotConnectedException if a server connection error occurs.
- * For pools configured with locators, if no locators are available,
- * the cause
- * of NotConnectedException is set to NoAvailableLocatorsException.
- * @throws MessageExcepton If the message received from server could not be
- * handled. This will be the case when an unregistered typeId is
- * received in the reply or reply is not well formed.
- * More information can be found in the log.
- * @throws TimeoutException if operation timed out
- * @throws CacheClosedException if the cache has been closed
- *
- * @returns A smart pointer to the SelectResults which can either be a
- * ResultSet or a StructSet.
- */
+ * Executes the query on the server based on the predicate.
+ * Valid only for a Native Client region.
+ *
+ * @param predicate The query predicate (just the WHERE clause) or the entire
+ * query to execute.
+ * @param timeout The time (in seconds) to wait for the query response,
+ * optional.
+ * This should be less than or equal to 2^31/1000 i.e. 2147483.
+ *
+ * @throws IllegalArgumentException If predicate is empty or timeout
+ * parameter is greater than 2^31/1000.
+ * @throws QueryException if some query error occurred at the server.
+ * @throws CacheServerException If an exception is received from the Java
+ * cache server.
+ * @throws NotConnectedException if a server connection error occurs.
+ * For pools configured with locators, if no locators are available,
+ * the cause
+ * of NotConnectedException is set to NoAvailableLocatorsException.
+ * @throws MessageExcepton If the message received from server could not be
+ * handled. This will be the case when an unregistered typeId is
+ * received in the reply or reply is not well formed.
+ * More information can be found in the log.
+ * @throws TimeoutException if operation timed out
+ * @throws CacheClosedException if the cache has been closed
+ *
+ * @returns A smart pointer to the SelectResults which can either be a
+ * ResultSet or a StructSet.
+ */
virtual SelectResultsPtr query(
const char* predicate,
uint32_t timeout = DEFAULT_QUERY_RESPONSE_TIMEOUT) = 0;
/**
- * Executes the query on the server based on the predicate and returns whether
- * any result exists.
- * Valid only for a Native Client region.
- * @param predicate The query predicate (just the WHERE clause) or the entire
- * query to execute.
- * @param timeout The time (in seconds) to wait for the response, optional.
- * This should be less than or equal to 2^31/1000 i.e. 2147483.
- * @throws IllegalArgumentException If predicate is empty or timeout
- * parameter is greater than 2^31/1000.
- * @throws QueryException if some query error occurred at the server.
- * @throws NotConnectedException if a server connection error occurs.
- * For pools configured with locators, if no locators are available,
- * the cause
- * of NotConnectedException is set to NoAvailableLocatorsException.
- * @throws MessageExcepton If the message received from server could not be
- * handled. This will be the case when the reply is not well formed.
- * More information can be found in the log.
- * @throws TimeoutException if operation timed out
- * @throws CacheClosedException if the cache has been closed
- * @returns true if the result size is non-zero, false otherwise.
- */
+ * Executes the query on the server based on the predicate and returns whether
+ * any result exists.
+ * Valid only for a Native Client region.
+ * @param predicate The query predicate (just the WHERE clause) or the entire
+ * query to execute.
+ * @param timeout The time (in seconds) to wait for the response, optional.
+ * This should be less than or equal to 2^31/1000 i.e. 2147483.
+ * @throws IllegalArgumentException If predicate is empty or timeout
+ * parameter is greater than 2^31/1000.
+ * @throws QueryException if some query error occurred at the server.
+ * @throws NotConnectedException if a server connection error occurs.
+ * For pools configured with locators, if no locators are available,
+ * the cause
+ * of NotConnectedException is set to NoAvailableLocatorsException.
+ * @throws MessageExcepton If the message received from server could not be
+ * handled. This will be the case when the reply is not well forme
<TRUNCATED>
[10/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PoolManager.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PoolManager.cpp b/src/cppcache/src/PoolManager.cpp
index 49a6425..7ad036b 100644
--- a/src/cppcache/src/PoolManager.cpp
+++ b/src/cppcache/src/PoolManager.cpp
@@ -14,84 +14,116 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <mutex>
+
#include <geode/PoolManager.hpp>
-#include <ace/Recursive_Thread_Mutex.h>
-#include <ace/Guard_T.h>
using namespace apache::geode::client;
-// TODO: make this a member of TcrConnectionManager.
-HashMapOfPools* connectionPools = nullptr; /*new HashMapOfPools( )*/
-ACE_Recursive_Thread_Mutex connectionPoolsLock;
+class PoolManager::Impl {
+ public:
+ Impl(const Cache& cache) : m_cache(cache) {}
+ void removePool(const char* name);
-void removePool(const char* name) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(connectionPoolsLock);
- connectionPools->erase(name);
-}
+ PoolFactoryPtr createFactory();
-PoolFactoryPtr PoolManager::createFactory() {
- if (connectionPools == nullptr) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(connectionPoolsLock);
- if (connectionPools == nullptr) {
- connectionPools = new HashMapOfPools();
- }
- }
- return PoolFactoryPtr(new PoolFactory());
+ void close(bool keepAlive);
+
+ PoolPtr find(const char* name);
+
+ PoolPtr find(RegionPtr region);
+
+ const HashMapOfPools& getAll();
+
+ void addPool(const char* name, const PoolPtr& pool);
+
+ PoolPtr getDefaultPool();
+
+ private:
+ HashMapOfPools m_connectionPools;
+ std::recursive_mutex m_connectionPoolsLock;
+ PoolPtr m_defaultPool;
+ const Cache& m_cache;
+};
+
+void PoolManager::Impl::removePool(const char* name) {
+ std::lock_guard<std::recursive_mutex> guard(m_connectionPoolsLock);
+ m_connectionPools.erase(name);
}
-void PoolManager::close(bool keepAlive) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(connectionPoolsLock);
+PoolFactoryPtr PoolManager::Impl::createFactory() {
+ return std::shared_ptr<PoolFactory>(new PoolFactory(m_cache));
+}
- if (connectionPools == nullptr) {
- return;
- }
+void PoolManager::Impl::close(bool keepAlive) {
+ std::lock_guard<std::recursive_mutex> guard(m_connectionPoolsLock);
std::vector<PoolPtr> poolsList;
- for (const auto& c : *connectionPools) {
+ for (const auto& c : m_connectionPools) {
poolsList.push_back(c.second);
}
for (const auto& iter : poolsList) {
iter->destroy(keepAlive);
}
-
- GF_SAFE_DELETE(connectionPools);
}
-PoolPtr PoolManager::find(const char* name) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(connectionPoolsLock);
-
- if (connectionPools == nullptr) {
- connectionPools = new HashMapOfPools();
- }
+PoolPtr PoolManager::Impl::find(const char* name) {
+ std::lock_guard<std::recursive_mutex> guard(m_connectionPoolsLock);
if (name) {
- const auto& iter = connectionPools->find(name);
+ const auto& iter = m_connectionPools.find(name);
PoolPtr poolPtr = nullptr;
- if (iter != connectionPools->end()) {
+ if (iter != m_connectionPools.end()) {
poolPtr = iter->second;
GF_DEV_ASSERT(poolPtr != nullptr);
}
return poolPtr;
} else {
- return nullptr;
+ return m_connectionPools.empty() ? nullptr
+ : m_connectionPools.begin()->second;
}
}
-PoolPtr PoolManager::find(RegionPtr region) {
+PoolPtr PoolManager::Impl::find(RegionPtr region) {
return find(region->getAttributes()->getPoolName());
}
-const HashMapOfPools& PoolManager::getAll() {
- if (connectionPools == nullptr) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> guard(connectionPoolsLock);
- if (connectionPools == nullptr) {
- connectionPools = new HashMapOfPools();
- }
+const HashMapOfPools& PoolManager::Impl::getAll() { return m_connectionPools; }
+
+void PoolManager::Impl::addPool(const char* name, const PoolPtr& pool) {
+ std::lock_guard<std::recursive_mutex> guard(m_connectionPoolsLock);
+
+ if (!m_defaultPool) {
+ m_defaultPool = pool;
}
- return *connectionPools;
+
+ m_connectionPools.emplace(name, pool);
}
+
+PoolPtr PoolManager::Impl::getDefaultPool() { return m_defaultPool; }
+
+PoolManager::PoolManager(const Cache& cache)
+ : m_pimpl(new Impl(cache), [](Impl* impl) { delete impl; }) {}
+
+void PoolManager::removePool(const char* name) { m_pimpl->removePool(name); }
+
+PoolFactoryPtr PoolManager::createFactory() { return m_pimpl->createFactory(); }
+
+void PoolManager::close(bool keepAlive) { m_pimpl->close(keepAlive); }
+
+PoolPtr PoolManager::find(const char* name) { return m_pimpl->find(name); }
+
+PoolPtr PoolManager::find(RegionPtr region) { return m_pimpl->find(region); }
+
+const HashMapOfPools& PoolManager::getAll() { return m_pimpl->getAll(); }
+
+void PoolManager::addPool(const char* name, const PoolPtr& pool) {
+ m_pimpl->addPool(name, pool);
+}
+
+PoolPtr PoolManager::getDefaultPool() { return m_pimpl->getDefaultPool(); }
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PoolStatistics.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PoolStatistics.cpp b/src/cppcache/src/PoolStatistics.cpp
index 9aa477a..e5f5188 100644
--- a/src/cppcache/src/PoolStatistics.cpp
+++ b/src/cppcache/src/PoolStatistics.cpp
@@ -36,233 +36,136 @@ using statistics::StatisticsFactory;
using statistics::StatisticsManager;
using util::concurrent::spinlock_mutex;
-////////////////////////////////////////////////////////////////////////////////
-
-PoolStatType* PoolStatType::single = nullptr;
-spinlock_mutex PoolStatType::m_singletonLock;
-spinlock_mutex PoolStatType::m_statTypeLock;
-
-void PoolStatType::clean() {
- std::lock_guard<spinlock_mutex> guard(m_singletonLock);
- if (single) {
- delete single;
- single = nullptr;
- }
-}
-
-StatisticsType* PoolStatType::getStatType() {
- std::lock_guard<spinlock_mutex> guard(m_statTypeLock);
- StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
- GF_D_ASSERT(!!factory);
+constexpr const char* PoolStats::STATS_NAME;
+constexpr const char* PoolStats::STATS_DESC;
- StatisticsType* statsType = factory->findType("PoolStatistics");
+PoolStats::PoolStats(StatisticsFactory* factory, const std::string& poolName) {
+ auto statsType = factory->findType(STATS_NAME);
if (statsType == nullptr) {
- m_stats[0] = factory->createIntGauge(
+ auto stats = new StatisticDescriptor*[27];
+
+ stats[0] = factory->createIntGauge(
"locators", "Current number of locators discovered", "locators");
- m_stats[1] = factory->createIntGauge(
+ stats[1] = factory->createIntGauge(
"servers", "Current number of servers discovered", "servers");
- m_stats[2] = factory->createIntGauge(
+ stats[2] = factory->createIntGauge(
"subscriptionServers",
"Number of servers hosting this clients subscriptions", "servers");
- m_stats[3] = factory->createLongCounter(
+ stats[3] = factory->createLongCounter(
"locatorRequests",
"Number of requests from this connection pool to a locator",
"requests");
- m_stats[4] = factory->createLongCounter(
+ stats[4] = factory->createLongCounter(
"locatorResponses",
"Number of responses from the locator to this connection pool",
"responses");
- m_stats[5] = factory->createIntGauge(
+ stats[5] = factory->createIntGauge(
"poolConnections", "Current number of pool connections", "connections");
- m_stats[6] = factory->createIntCounter(
+ stats[6] = factory->createIntCounter(
"connects", "Total number of times a connection has been created.",
"connects");
- m_stats[7] = factory->createIntCounter(
+ stats[7] = factory->createIntCounter(
"disconnects", "Total number of times a connection has been destroyed.",
"disconnects");
- m_stats[8] = factory->createIntCounter(
+ stats[8] = factory->createIntCounter(
"minPoolSizeConnects",
"Total number of connects done to maintain minimum pool size.",
"connects");
- m_stats[9] = factory->createIntCounter(
+ stats[9] = factory->createIntCounter(
"loadConditioningConnects",
"Total number of connects done due to load conditioning.", "connects");
- m_stats[10] = factory->createIntCounter(
+ stats[10] = factory->createIntCounter(
"idleDisconnects",
"Total number of disconnects done due to idle expiration.",
"disconnects");
- m_stats[11] = factory->createIntCounter(
+ stats[11] = factory->createIntCounter(
"loadConditioningDisconnects",
"Total number of disconnects done due to load conditioning expiration.",
"disconnects");
- m_stats[12] = factory->createIntGauge(
+ stats[12] = factory->createIntGauge(
"connectionWaitsInProgress",
"Current number of threads waiting for a connection", "threads");
- m_stats[13] = factory->createIntCounter(
+ stats[13] = factory->createIntCounter(
"connectionWaits",
"Total number of times a thread completed waiting for a connection (by "
"timing out or by getting a connection).",
"waits");
- m_stats[14] = factory->createLongCounter(
+ stats[14] = factory->createLongCounter(
"connectionWaitTime",
"Total time (nanoseconds) spent waiting for a connection.",
"nanoseconds");
- m_stats[15] = factory->createIntGauge(
+ stats[15] = factory->createIntGauge(
"clientOpsInProgress", "Current number of clientOps being executed",
"clientOps");
- m_stats[16] = factory->createIntCounter(
+ stats[16] = factory->createIntCounter(
"clientOps", "Total number of clientOps completed successfully",
"clientOps");
- m_stats[17] = factory->createLongCounter(
+ stats[17] = factory->createLongCounter(
"clientOpTime",
"Total amount of time, in nanoseconds spent doing clientOps",
"nanoseconds");
- m_stats[18] = factory->createIntCounter(
+ stats[18] = factory->createIntCounter(
"clientOpFailures",
"Total number of clientOp attempts that have failed", "clientOps");
- m_stats[19] = factory->createIntCounter(
+ stats[19] = factory->createIntCounter(
"clientOpTimeouts",
"Total number of clientOp attempts that have timed out", "clientOps");
- m_stats[20] = factory->createLongCounter(
+ stats[20] = factory->createLongCounter(
"receivedBytes", "Total number of bytes received from the server.",
"bytes");
- m_stats[21] = factory->createLongCounter(
+ stats[21] = factory->createLongCounter(
"messagesBeingReceived",
"Total number of message being received off the network.", "messages");
- m_stats[22] = factory->createLongCounter(
+ stats[22] = factory->createLongCounter(
"processedDeltaMessages",
"Total number of delta message processed successfully", "messages");
- m_stats[23] = factory->createLongCounter(
+ stats[23] = factory->createLongCounter(
"deltaMessageFailures", "Total number of failures in processing delta",
"messages");
- m_stats[24] = factory->createLongCounter(
+ stats[24] = factory->createLongCounter(
"processedDeltaMessagesTime", "Total time spent while processing Delta",
"nanoseconds");
- m_stats[25] = factory->createIntCounter("queryExecutions",
- "Total number of queryExecutions",
- "queryExecutions");
- m_stats[26] = factory->createLongCounter(
+ stats[25] = factory->createIntCounter("queryExecutions",
+ "Total number of queryExecutions",
+ "queryExecutions");
+ stats[26] = factory->createLongCounter(
"queryExecutionTime",
"Total time spent while processing queryExecution", "nanoseconds");
- statsType = factory->createType("PoolStatistics",
- "Statistics for this pool", m_stats, 27);
-
- m_locatorsId = statsType->nameToId("locators");
- m_serversId = statsType->nameToId("servers");
- m_subsServsId = statsType->nameToId("subscriptionServers");
- m_locReqsId = statsType->nameToId("locatorRequests");
- m_locRespsId = statsType->nameToId("locatorResponses");
- m_poolConnsId = statsType->nameToId("poolConnections");
- m_connectsId = statsType->nameToId("connects");
- m_disconnectsId = statsType->nameToId("disconnects");
- m_minPoolConnectsId = statsType->nameToId("minPoolSizeConnects");
- m_loadCondConnectsId = statsType->nameToId("loadConditioningConnects");
- m_idleDisconnectsId = statsType->nameToId("idleDisconnects");
- m_loadCondDisconnectsId =
- statsType->nameToId("loadConditioningDisconnects");
- m_waitingConnectionsId = statsType->nameToId("connectionWaitsInProgress");
- m_totalWaitingConnsId = statsType->nameToId("connectionWaits");
- m_totalWaitingConnTimeId = statsType->nameToId("connectionWaitTime");
- m_curClientOpsId = statsType->nameToId("clientOpsInProgress");
- m_clientOpsSuccessId = statsType->nameToId("clientOps");
- m_clientOpsSuccessTimeId = statsType->nameToId("clientOpTime");
- m_clientOpsFailedId = statsType->nameToId("clientOpFailures");
- m_clientOpsTimeoutId = statsType->nameToId("clientOpTimeouts");
- m_receivedBytesId = statsType->nameToId("receivedBytes");
- m_messagesBeingReceivedId = statsType->nameToId("messagesBeingReceived");
- m_processedDeltaMessagesId = statsType->nameToId("processedDeltaMessages");
- m_deltaMessageFailuresId = statsType->nameToId("deltaMessageFailures");
- m_processedDeltaMessagesTimeId =
- statsType->nameToId("processedDeltaMessagesTime");
- m_queryExecutionsId = statsType->nameToId("queryExecutions");
- m_queryExecutionTimeId = statsType->nameToId("queryExecutionTime");
- }
-
- return statsType;
-}
-
-PoolStatType* PoolStatType::getInstance() {
- std::lock_guard<spinlock_mutex> guard(m_singletonLock);
- if (!single) {
- single = new PoolStatType();
+ statsType = factory->createType(STATS_NAME, STATS_DESC, stats, 27);
}
- return single;
-}
-
-PoolStatType::PoolStatType()
- : m_locatorsId(0),
- m_serversId(0),
- m_subsServsId(0),
- m_locReqsId(0),
- m_locRespsId(0),
- m_poolConnsId(0),
- m_connectsId(0),
- m_disconnectsId(0),
- m_minPoolConnectsId(0),
- m_loadCondConnectsId(0),
- m_idleDisconnectsId(0),
- m_loadCondDisconnectsId(0),
- m_waitingConnectionsId(0),
- m_totalWaitingConnsId(0),
- m_totalWaitingConnTimeId(0),
- m_curClientOpsId(0),
- m_clientOpsSuccessId(0),
- m_clientOpsSuccessTimeId(0),
- m_clientOpsFailedId(0),
- m_clientOpsTimeoutId(0),
- m_receivedBytesId(0),
- m_messagesBeingReceivedId(0),
- m_processedDeltaMessagesId(0),
- m_deltaMessageFailuresId(0),
- m_processedDeltaMessagesTimeId(0),
- m_queryExecutionsId(0),
- m_queryExecutionTimeId(0) {
- memset(m_stats, 0, sizeof(m_stats));
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-PoolStats::PoolStats(const char* poolName) {
- PoolStatType* poolStatType = PoolStatType::getInstance();
-
- StatisticsType* statsType = poolStatType->getStatType();
-
- GF_D_ASSERT(statsType != nullptr);
-
- StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
+ m_locatorsId = statsType->nameToId("locators");
+ m_serversId = statsType->nameToId("servers");
+ m_subsServsId = statsType->nameToId("subscriptionServers");
+ m_locReqsId = statsType->nameToId("locatorRequests");
+ m_locRespsId = statsType->nameToId("locatorResponses");
+ m_poolConnsId = statsType->nameToId("poolConnections");
+ m_connectsId = statsType->nameToId("connects");
+ m_disconnectsId = statsType->nameToId("disconnects");
+ m_minPoolConnectsId = statsType->nameToId("minPoolSizeConnects");
+ m_loadCondConnectsId = statsType->nameToId("loadConditioningConnects");
+ m_idleDisconnectsId = statsType->nameToId("idleDisconnects");
+ m_loadCondDisconnectsId = statsType->nameToId("loadConditioningDisconnects");
+ m_waitingConnectionsId = statsType->nameToId("connectionWaitsInProgress");
+ m_totalWaitingConnsId = statsType->nameToId("connectionWaits");
+ m_totalWaitingConnTimeId = statsType->nameToId("connectionWaitTime");
+ m_curClientOpsId = statsType->nameToId("clientOpsInProgress");
+ m_clientOpsSuccessId = statsType->nameToId("clientOps");
+ m_clientOpsSuccessTimeId = statsType->nameToId("clientOpTime");
+ m_clientOpsFailedId = statsType->nameToId("clientOpFailures");
+ m_clientOpsTimeoutId = statsType->nameToId("clientOpTimeouts");
+ m_receivedBytesId = statsType->nameToId("receivedBytes");
+ m_messagesBeingReceivedId = statsType->nameToId("messagesBeingReceived");
+ m_processedDeltaMessagesId = statsType->nameToId("processedDeltaMessages");
+ m_deltaMessageFailuresId = statsType->nameToId("deltaMessageFailures");
+ m_processedDeltaMessagesTimeId =
+ statsType->nameToId("processedDeltaMessagesTime");
+ m_queryExecutionsId = statsType->nameToId("queryExecutions");
+ m_queryExecutionTimeId = statsType->nameToId("queryExecutionTime");
- m_poolStats = factory->createAtomicStatistics(statsType, poolName);
+ m_poolStats = factory->createAtomicStatistics(statsType, poolName.c_str());
- m_locatorsId = poolStatType->getLocatorsId();
- m_serversId = poolStatType->getServersId();
- m_subsServsId = poolStatType->getSubscriptionServersId();
- m_locReqsId = poolStatType->getLocatorRequestsId();
- m_locRespsId = poolStatType->getLocatorResposesId();
- m_poolConnsId = poolStatType->getPoolConnectionsId();
- m_connectsId = poolStatType->getConnectsId();
- m_disconnectsId = poolStatType->getDisconnectsId();
- m_minPoolConnectsId = poolStatType->getMinPoolSizeConnectsId();
- m_loadCondConnectsId = poolStatType->getLoadCondConnectsId();
- m_idleDisconnectsId = poolStatType->getIdleDisconnectsId();
- m_loadCondDisconnectsId = poolStatType->getLoadCondDisconnectsId();
- m_waitingConnectionsId = poolStatType->getWaitingConnectionsId();
- m_totalWaitingConnsId = poolStatType->getTotalWaitingConnsId();
- m_totalWaitingConnTimeId = poolStatType->getTotalWaitingConnTimeId();
- m_curClientOpsId = poolStatType->getCurClientOpsId();
- m_clientOpsSuccessId = poolStatType->getClientOpsSucceededId();
- m_clientOpsSuccessTimeId = poolStatType->getClientOpsSucceededTimeId();
- m_clientOpsFailedId = poolStatType->getClientOpsFailedId();
- m_clientOpsTimeoutId = poolStatType->getClientOpsTimeoutId();
- m_receivedBytesId = poolStatType->getReceivedBytesId();
- m_messagesBeingReceivedId = poolStatType->getMessagesBeingReceivedId();
- m_processedDeltaMessagesId = poolStatType->getProcessedDeltaMessagesId();
- m_deltaMessageFailuresId = poolStatType->getDeltaMessageFailuresId();
- m_processedDeltaMessagesTimeId =
- poolStatType->getProcessedDeltaMessagesTimeId();
- m_queryExecutionsId = poolStatType->getQueryExecutionId();
- m_queryExecutionTimeId = poolStatType->getQueryExecutionTimeId();
getStats()->setInt(m_locatorsId, 0);
getStats()->setInt(m_serversId, 0);
getStats()->setInt(m_subsServsId, 0);
@@ -290,8 +193,6 @@ PoolStats::PoolStats(const char* poolName) {
getStats()->setInt(m_processedDeltaMessagesTimeId, 0);
getStats()->setInt(m_queryExecutionsId, 0);
getStats()->setLong(m_queryExecutionTimeId, 0);
-
- StatisticsManager::getExistingInstance()->forceSample();
}
PoolStats::~PoolStats() {
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PoolStatistics.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PoolStatistics.hpp b/src/cppcache/src/PoolStatistics.hpp
index c882cfc..ae16a9d 100644
--- a/src/cppcache/src/PoolStatistics.hpp
+++ b/src/cppcache/src/PoolStatistics.hpp
@@ -1,5 +1,4 @@
/*
- * 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
@@ -20,27 +19,13 @@
#ifndef GEODE_POOLSTATISTICS_H_
#define GEODE_POOLSTATISTICS_H_
-/*
- * 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.
- */
+#include <string>
#include <geode/geode_globals.hpp>
#include <geode/statistics/Statistics.hpp>
#include <geode/statistics/StatisticsFactory.hpp>
-#include <statistics/StatisticsManager.hpp>
-#include "util/concurrent/spinlock_mutex.hpp"
+
+#include "statistics/StatisticsManager.hpp"
namespace apache {
namespace geode {
@@ -54,15 +39,12 @@ using util::concurrent::spinlock_mutex;
class PoolStats {
public:
/** hold statistics for a pool.. */
- PoolStats(const char* poolName);
+ PoolStats(statistics::StatisticsFactory* factory, const std::string& poolName);
/** disable stat collection for this item. */
virtual ~PoolStats();
- void close() {
- getStats()->close();
- statistics::StatisticsManager::getExistingInstance()->forceSample();
- }
+ void close() { getStats()->close(); }
void setLocators(int32_t curVal) { getStats()->setInt(m_locatorsId, curVal); }
@@ -147,6 +129,11 @@ class PoolStats {
inline apache::geode::statistics::Statistics* getStats() {
return m_poolStats;
}
+ inline int32_t getTotalWaitingConnTimeId() {
+ return m_totalWaitingConnTimeId;
+ }
+
+ inline int32_t getQueryExecutionTimeId() { return m_queryExecutionTimeId; }
private:
// volatile apache::geode::statistics::Statistics* m_poolStats;
@@ -179,92 +166,9 @@ class PoolStats {
int32_t m_processedDeltaMessagesTimeId;
int32_t m_queryExecutionsId;
int32_t m_queryExecutionTimeId;
-};
-
-class PoolStatType {
- private:
- static PoolStatType* single;
- static spinlock_mutex m_singletonLock;
- static spinlock_mutex m_statTypeLock;
-
- public:
- static PoolStatType* getInstance();
-
- statistics::StatisticsType* getStatType();
-
- static void clean();
- private:
- PoolStatType();
- statistics::StatisticDescriptor* m_stats[27];
-
- int32_t m_locatorsId;
- int32_t m_serversId;
- int32_t m_subsServsId;
- int32_t m_locReqsId;
- int32_t m_locRespsId;
- int32_t m_poolConnsId;
- int32_t m_connectsId;
- int32_t m_disconnectsId;
- int32_t m_minPoolConnectsId;
- int32_t m_loadCondConnectsId;
- int32_t m_idleDisconnectsId;
- int32_t m_loadCondDisconnectsId;
- int32_t m_waitingConnectionsId;
- int32_t m_totalWaitingConnsId;
- int32_t m_totalWaitingConnTimeId;
- int32_t m_curClientOpsId;
- int32_t m_clientOpsSuccessId;
- int32_t m_clientOpsSuccessTimeId;
- int32_t m_clientOpsFailedId;
- int32_t m_clientOpsTimeoutId;
- int32_t m_receivedBytesId;
- int32_t m_messagesBeingReceivedId;
- int32_t m_processedDeltaMessagesId;
- int32_t m_deltaMessageFailuresId;
- int32_t m_processedDeltaMessagesTimeId;
- int32_t m_queryExecutionsId;
- int32_t m_queryExecutionTimeId;
-
- public:
- int32_t getLocatorsId() { return m_locatorsId; }
-
- int32_t getServersId() { return m_serversId; }
-
- int32_t getSubscriptionServersId() { return m_subsServsId; }
-
- int32_t getLocatorRequestsId() { return m_locReqsId; }
-
- int32_t getLocatorResposesId() { return m_locRespsId; }
-
- int32_t getPoolConnectionsId() { return m_poolConnsId; }
-
- int32_t getConnectsId() { return m_connectsId; }
-
- int32_t getDisconnectsId() { return m_disconnectsId; }
-
- int32_t getMinPoolSizeConnectsId() { return m_minPoolConnectsId; }
-
- int32_t getLoadCondConnectsId() { return m_loadCondConnectsId; }
- int32_t getIdleDisconnectsId() { return m_idleDisconnectsId; }
- int32_t getLoadCondDisconnectsId() { return m_loadCondDisconnectsId; }
- int32_t getWaitingConnectionsId() { return m_waitingConnectionsId; }
- int32_t getTotalWaitingConnsId() { return m_totalWaitingConnsId; }
- int32_t getTotalWaitingConnTimeId() { return m_totalWaitingConnTimeId; }
- int32_t getCurClientOpsId() { return m_curClientOpsId; }
- int32_t getClientOpsSucceededId() { return m_clientOpsSuccessId; }
- int32_t getClientOpsSucceededTimeId() { return m_clientOpsSuccessTimeId; }
- int32_t getClientOpsFailedId() { return m_clientOpsFailedId; }
- int32_t getClientOpsTimeoutId() { return m_clientOpsTimeoutId; }
- int32_t getReceivedBytesId() { return m_receivedBytesId; }
- int32_t getMessagesBeingReceivedId() { return m_messagesBeingReceivedId; }
- int32_t getProcessedDeltaMessagesId() { return m_processedDeltaMessagesId; }
- int32_t getDeltaMessageFailuresId() { return m_deltaMessageFailuresId; }
- int32_t getProcessedDeltaMessagesTimeId() {
- return m_processedDeltaMessagesTimeId;
- }
- int32_t getQueryExecutionId() { return m_queryExecutionsId; }
- int32_t getQueryExecutionTimeId() { return m_queryExecutionTimeId; }
+ static constexpr const char* STATS_NAME = "PoolStatistics";
+ static constexpr const char* STATS_DESC = "Statistics for this pool";
};
} // namespace client
} // namespace geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PoolXmlCreation.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PoolXmlCreation.cpp b/src/cppcache/src/PoolXmlCreation.cpp
index ecb42d6..45216c0 100644
--- a/src/cppcache/src/PoolXmlCreation.cpp
+++ b/src/cppcache/src/PoolXmlCreation.cpp
@@ -15,6 +15,9 @@
* limitations under the License.
*/
+#include <geode/Cache.hpp>
+#include <geode/PoolManager.hpp>
+
#include "PoolXmlCreation.hpp"
using namespace apache::geode::client;
@@ -33,7 +36,7 @@ void PoolXmlCreation::addServer(const char * host, const char * port)
}
*/
-PoolPtr PoolXmlCreation::create() {
+PoolPtr PoolXmlCreation::create(Cache& cache) {
return poolFactory->create(poolName.c_str());
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PoolXmlCreation.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PoolXmlCreation.hpp b/src/cppcache/src/PoolXmlCreation.hpp
index c6a3446..d3cb455 100644
--- a/src/cppcache/src/PoolXmlCreation.hpp
+++ b/src/cppcache/src/PoolXmlCreation.hpp
@@ -82,7 +82,7 @@ class CPPCACHE_EXPORT PoolXmlCreation {
* @throws UnknownException otherwise
*
*/
- PoolPtr create();
+ PoolPtr create(Cache &cache);
};
} // namespace client
} // namespace geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PreservedDataExpiryHandler.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PreservedDataExpiryHandler.cpp b/src/cppcache/src/PreservedDataExpiryHandler.cpp
index 550edf6..5126020 100644
--- a/src/cppcache/src/PreservedDataExpiryHandler.cpp
+++ b/src/cppcache/src/PreservedDataExpiryHandler.cpp
@@ -33,14 +33,16 @@
using namespace apache::geode::client;
PreservedDataExpiryHandler::PreservedDataExpiryHandler(
- PdxSerializablePtr pdxObjectPtr, uint32_t duration)
+ const std::shared_ptr<PdxTypeRegistry>& pdxTypeRegistry,
+ const PdxSerializablePtr& pdxObjectPtr, uint32_t duration)
: // UNUSED m_duration(duration),
- m_pdxObjectPtr(pdxObjectPtr) {}
+ m_pdxObjectPtr(pdxObjectPtr),
+ m_pdxTypeRegistry(pdxTypeRegistry) {}
int PreservedDataExpiryHandler::handle_timeout(
const ACE_Time_Value& current_time, const void* arg) {
- WriteGuard guard(PdxTypeRegistry::getPreservedDataLock());
- auto map = PdxTypeRegistry::getPreserveDataMap();
+ WriteGuard guard(m_pdxTypeRegistry->getPreservedDataLock());
+ auto map = m_pdxTypeRegistry->getPreserveDataMap();
LOGDEBUG(
"Entered PreservedDataExpiryHandler "
"PdxTypeRegistry::getPreserveDataMap().size() = %d",
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/PreservedDataExpiryHandler.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PreservedDataExpiryHandler.hpp b/src/cppcache/src/PreservedDataExpiryHandler.hpp
index ce85a87..e8aafc9 100644
--- a/src/cppcache/src/PreservedDataExpiryHandler.hpp
+++ b/src/cppcache/src/PreservedDataExpiryHandler.hpp
@@ -53,7 +53,8 @@ class CPPCACHE_EXPORT PreservedDataExpiryHandler : public ACE_Event_Handler {
/**
* Constructor
*/
- PreservedDataExpiryHandler(PdxSerializablePtr pdxObjectPtr,
+ PreservedDataExpiryHandler(const std::shared_ptr<PdxTypeRegistry>& pdxTypeRegistry,
+ const PdxSerializablePtr& pdxObjectPtr,
uint32_t duration);
/** This task object will be registered with the Timer Queue.
@@ -69,6 +70,7 @@ class CPPCACHE_EXPORT PreservedDataExpiryHandler : public ACE_Event_Handler {
// Duration after which the task should be reset in case of
// modification.
// UNUSED uint32_t m_duration;
+ std::shared_ptr<PdxTypeRegistry> m_pdxTypeRegistry;
PdxSerializablePtr m_pdxObjectPtr;
};
} // namespace client
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ProxyCache.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ProxyCache.cpp b/src/cppcache/src/ProxyCache.cpp
index 978919c..2d03a8b 100644
--- a/src/cppcache/src/ProxyCache.cpp
+++ b/src/cppcache/src/ProxyCache.cpp
@@ -69,7 +69,8 @@ void ProxyCache::close() {
m_userAttributes->unSetCredentials();
// send message to server
PoolPtr userAttachedPool = m_userAttributes->getPool();
- PoolPtr pool = PoolManager::find(userAttachedPool->getName());
+ PoolPtr pool = m_cacheImpl->getCache()->getPoolManager().find(
+ userAttachedPool->getName());
if (pool != nullptr && pool.get() == userAttachedPool.get()) {
auto poolDM = std::static_pointer_cast<ThinClientPoolDM>(pool);
if (!poolDM->isDestroyed()) {
@@ -86,15 +87,15 @@ RegionPtr ProxyCache::getRegion(const char* path) {
if (!m_isProxyCacheClosed) {
RegionPtr result;
- CachePtr realCache = CacheFactory::getAnyInstance();
- if (realCache != nullptr && !realCache->isClosed()) {
- CacheRegionHelper::getCacheImpl(realCache.get())->getRegion(path, result);
+ if (m_cacheImpl != nullptr && !m_cacheImpl->isClosed()) {
+ m_cacheImpl->getRegion(path, result);
}
if (result != nullptr) {
PoolPtr userAttachedPool = m_userAttributes->getPool();
- PoolPtr pool = PoolManager::find(result->getAttributes()->getPoolName());
+ PoolPtr pool = m_cacheImpl->getCache()->getPoolManager().find(
+ result->getAttributes()->getPoolName());
if (pool != nullptr && pool.get() == userAttachedPool.get() &&
!pool->isDestroyed()) {
return std::make_shared<ProxyRegion>(shared_from_this(), result);
@@ -134,13 +135,12 @@ void ProxyCache::rootRegions(VectorOfRegion& regions) {
if (!m_isProxyCacheClosed) {
RegionPtr result;
- CachePtr realCache = CacheFactory::getAnyInstance();
- if (realCache != nullptr && !realCache->isClosed()) {
+ if (m_cacheImpl != nullptr && !m_cacheImpl->isClosed()) {
VectorOfRegion tmp;
// this can cause issue when pool attached with region in multiuserSecure
// mode
- realCache->rootRegions(tmp);
+ m_cacheImpl->rootRegions(tmp);
if (tmp.size() > 0) {
for (int32_t i = 0; i < tmp.size(); i++) {
@@ -157,15 +157,22 @@ void ProxyCache::rootRegions(VectorOfRegion& regions) {
}
}
-ProxyCache::ProxyCache(PropertiesPtr credentials, PoolPtr pool) {
- m_remoteQueryService = nullptr;
- m_isProxyCacheClosed = false;
- m_userAttributes = std::make_shared<UserAttributes>(credentials, pool, this);
-}
+ProxyCache::ProxyCache(PropertiesPtr credentials, PoolPtr pool,
+ CacheImpl* cacheImpl)
+ : m_remoteQueryService(nullptr),
+ m_isProxyCacheClosed(false),
+ m_userAttributes(
+ std::make_shared<UserAttributes>(credentials, pool, this)),
+ m_cacheImpl(cacheImpl) {}
ProxyCache::~ProxyCache() {}
PdxInstanceFactoryPtr ProxyCache::createPdxInstanceFactory(
const char* className) {
- return std::make_shared<PdxInstanceFactoryImpl>(className);
+ return std::make_shared<PdxInstanceFactoryImpl>(
+ className, &(m_cacheImpl->getCachePerfStats()),
+ m_cacheImpl->getPdxTypeRegistry(), m_cacheImpl->getCache(),
+ m_cacheImpl->getDistributedSystem()
+ .getSystemProperties()
+ .getEnableTimeStatistics());
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ProxyCache.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ProxyCache.hpp b/src/cppcache/src/ProxyCache.hpp
index 23d085c..acbc295 100644
--- a/src/cppcache/src/ProxyCache.hpp
+++ b/src/cppcache/src/ProxyCache.hpp
@@ -86,28 +86,28 @@ class CPPCACHE_EXPORT ProxyCache
virtual RegionPtr getRegion(const char* path);
/**
- * Gets the QueryService from which a new Query can be obtained.
- *
- * @returns A smart pointer to the QueryService.
- */
+ * Gets the QueryService from which a new Query can be obtained.
+ *
+ * @returns A smart pointer to the QueryService.
+ */
virtual QueryServicePtr getQueryService();
/**
- * Returns a set of root regions in the cache. This set is a snapshot and
- * is not backed by the Cache. The vector passed in is cleared and the
- * regions are added to it.
- *
- * @param regions the returned set of
- * regions
- */
+ * Returns a set of root regions in the cache. This set is a snapshot and
+ * is not backed by the Cache. The vector passed in is cleared and the
+ * regions are added to it.
+ *
+ * @param regions the returned set of
+ * regions
+ */
virtual void rootRegions(VectorOfRegion& regions);
/**
- * @brief destructor
- */
+ * @brief destructor
+ */
virtual ~ProxyCache();
- ProxyCache(PropertiesPtr credentials, PoolPtr pool);
+ ProxyCache(PropertiesPtr credentials, PoolPtr pool, CacheImpl* cacheImpl);
/**
* Returns a factory that can create a {@link PdxInstance}.
@@ -126,6 +126,7 @@ class CPPCACHE_EXPORT ProxyCache
UserAttributesPtr m_userAttributes;
bool m_isProxyCacheClosed;
QueryServicePtr m_remoteQueryService;
+ CacheImpl* m_cacheImpl;
friend class Pool;
friend class ProxyRegion;
friend class ProxyRemoteQueryService;
@@ -134,6 +135,7 @@ class CPPCACHE_EXPORT ProxyCache
friend class FunctionServiceImpl;
friend class FunctionService;
friend class GuardUserAttribures;
+ friend class CacheRegionHelper;
};
} // namespace client
} // namespace geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ProxyRegion.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ProxyRegion.hpp b/src/cppcache/src/ProxyRegion.hpp
index d0b77bc..d4d5940 100644
--- a/src/cppcache/src/ProxyRegion.hpp
+++ b/src/cppcache/src/ProxyRegion.hpp
@@ -1495,21 +1495,22 @@ class CPPCACHE_EXPORT ProxyRegion : public Region {
virtual const PoolPtr& getPool() { return m_realRegion->getPool(); }
- ProxyRegion(const ProxyCachePtr& proxyCache, const RegionPtr& realRegion) {
+ ProxyRegion(const ProxyCachePtr& proxyCache, const RegionPtr& realRegion)
+ : Region(realRegion->getCache()) {
m_proxyCache = proxyCache;
m_realRegion = realRegion;
}
virtual ~ProxyRegion() {}
+ ProxyRegion(const ProxyRegion&) = delete;
+ ProxyRegion& operator=(const ProxyRegion&) = delete;
+
private:
void unSupportedOperation(const char* operationName) const;
ProxyCachePtr m_proxyCache;
RegionPtr m_realRegion;
- // Disallow copy constructor and assignment operator.
- ProxyRegion(const ProxyRegion&);
- ProxyRegion& operator=(const ProxyRegion&);
friend class FunctionService;
FRIEND_STD_SHARED_PTR(ProxyRegion)
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ProxyRemoteQueryService.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ProxyRemoteQueryService.cpp b/src/cppcache/src/ProxyRemoteQueryService.cpp
index da66e0b..25aec8a 100644
--- a/src/cppcache/src/ProxyRemoteQueryService.cpp
+++ b/src/cppcache/src/ProxyRemoteQueryService.cpp
@@ -25,7 +25,8 @@ ProxyRemoteQueryService::ProxyRemoteQueryService(ProxyCachePtr cptr)
QueryPtr ProxyRemoteQueryService::newQuery(const char* querystring) {
if (!m_proxyCache->isClosed()) {
auto userAttachedPool = m_proxyCache->m_userAttributes->getPool();
- auto pool = PoolManager::find(userAttachedPool->getName());
+ auto pool = m_proxyCache->m_cacheImpl->getCache()->getPoolManager().find(
+ userAttachedPool->getName());
if (pool != nullptr && pool.get() == userAttachedPool.get() &&
!pool->isDestroyed()) {
GuardUserAttribures gua(m_proxyCache);
@@ -53,7 +54,8 @@ CqQueryPtr ProxyRemoteQueryService::newCq(const char* querystr,
bool isDurable) {
if (!m_proxyCache->isClosed()) {
auto userAttachedPool = m_proxyCache->m_userAttributes->getPool();
- auto pool = PoolManager::find(userAttachedPool->getName());
+ auto pool = m_proxyCache->m_cacheImpl->getCache()->getPoolManager().find(
+ userAttachedPool->getName());
if (pool != nullptr && pool.get() == userAttachedPool.get() &&
!pool->isDestroyed()) {
GuardUserAttribures gua(m_proxyCache);
@@ -81,7 +83,8 @@ CqQueryPtr ProxyRemoteQueryService::newCq(const char* name,
bool isDurable) {
if (!m_proxyCache->isClosed()) {
auto userAttachedPool = m_proxyCache->m_userAttributes->getPool();
- auto pool = PoolManager::find(userAttachedPool->getName());
+ auto pool = m_proxyCache->m_cacheImpl->getCache()->getPoolManager().find(
+ userAttachedPool->getName());
if (pool != nullptr && pool.get() == userAttachedPool.get() &&
!pool->isDestroyed()) {
GuardUserAttribures gua(m_proxyCache);
@@ -114,12 +117,12 @@ void ProxyRemoteQueryService::closeCqs(bool keepAlive) {
cqImpl->close(false);
}
} catch (QueryException& qe) {
- Log::fine(("Failed to close the CQ, CqName : " + cqName + " Error : " +
- qe.getMessage())
+ Log::fine(("Failed to close the CQ, CqName : " + cqName +
+ " Error : " + qe.getMessage())
.c_str());
} catch (CqClosedException& cce) {
- Log::fine(("Failed to close the CQ, CqName : " + cqName + " Error : " +
- cce.getMessage())
+ Log::fine(("Failed to close the CQ, CqName : " + cqName +
+ " Error : " + cce.getMessage())
.c_str());
}
}
@@ -133,7 +136,8 @@ void ProxyRemoteQueryService::getCqs(query_container_type& vec) {
CqQueryPtr ProxyRemoteQueryService::getCq(const char* name) {
if (!m_proxyCache->isClosed()) {
auto userAttachedPool = m_proxyCache->m_userAttributes->getPool();
- auto pool = PoolManager::find(userAttachedPool->getName());
+ auto pool = m_proxyCache->m_cacheImpl->getCache()->getPoolManager().find(
+ userAttachedPool->getName());
if (pool != nullptr && pool.get() == userAttachedPool.get() &&
!pool->isDestroyed()) {
GuardUserAttribures gua(m_proxyCache);
@@ -155,12 +159,12 @@ void ProxyRemoteQueryService::executeCqs() {
try {
q->execute();
} catch (QueryException& qe) {
- Log::fine(("Failed to excecue the CQ, CqName : " + cqName + " Error : " +
- qe.getMessage())
+ Log::fine(("Failed to excecue the CQ, CqName : " + cqName +
+ " Error : " + qe.getMessage())
.c_str());
} catch (CqClosedException& cce) {
- Log::fine(("Failed to excecue the CQ, CqName : " + cqName + " Error : " +
- cce.getMessage())
+ Log::fine(("Failed to excecue the CQ, CqName : " + cqName +
+ " Error : " + cce.getMessage())
.c_str());
}
}
@@ -174,12 +178,12 @@ void ProxyRemoteQueryService::stopCqs() {
try {
q->stop();
} catch (QueryException& qe) {
- Log::fine(("Failed to stop the CQ, CqName : " + cqName + " Error : " +
- qe.getMessage())
+ Log::fine(("Failed to stop the CQ, CqName : " + cqName +
+ " Error : " + qe.getMessage())
.c_str());
} catch (CqClosedException& cce) {
- Log::fine(("Failed to stop the CQ, CqName : " + cqName + " Error : " +
- cce.getMessage())
+ Log::fine(("Failed to stop the CQ, CqName : " + cqName +
+ " Error : " + cce.getMessage())
.c_str());
}
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/Region.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/Region.cpp b/src/cppcache/src/Region.cpp
index eab6760..fa1ce3e 100644
--- a/src/cppcache/src/Region.cpp
+++ b/src/cppcache/src/Region.cpp
@@ -20,7 +20,7 @@
namespace apache {
namespace geode {
namespace client {
-Region::Region() {}
+Region::Region(const CachePtr& cache) : m_cache(cache) {}
Region::~Region() {}
} // namespace client
} // namespace geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RegionCommit.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RegionCommit.cpp b/src/cppcache/src/RegionCommit.cpp
index 62e26c8..3bef90c 100644
--- a/src/cppcache/src/RegionCommit.cpp
+++ b/src/cppcache/src/RegionCommit.cpp
@@ -38,9 +38,11 @@ void RegionCommit::fromData(DataInput& input) {
input.readBoolean(&largeModCount);
DSMemberForVersionStampPtr dsMember;
input.readObject(dsMember);
- uint16_t memId = CacheImpl::getMemberListForVersionStamp()->add(dsMember);
+
+ auto memId = m_memberListForVersionStamp.add(dsMember);
for (int i = 0; i < size; i++) {
- auto entryOp = std::make_shared<FarSideEntryOp>(this);
+ auto entryOp =
+ std::make_shared<FarSideEntryOp>(this, m_memberListForVersionStamp);
entryOp->fromData(input, largeModCount, memId);
m_farSideEntryOps.push_back(entryOp);
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RegionCommit.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RegionCommit.hpp b/src/cppcache/src/RegionCommit.hpp
index 9458bee..0d24dfb 100644
--- a/src/cppcache/src/RegionCommit.hpp
+++ b/src/cppcache/src/RegionCommit.hpp
@@ -38,10 +38,12 @@ namespace geode {
namespace client {
_GF_PTR_DEF_(RegionCommit, RegionCommitPtr);
+_GF_PTR_DEF_(FarSideEntryOp, FarSideEntryOpPtr);
class RegionCommit {
public:
- RegionCommit(){};
+ RegionCommit(MemberListForVersionStamp& memberListForVersionStamp): m_memberListForVersionStamp(memberListForVersionStamp)
+ {};
virtual ~RegionCommit(){};
void fromData(DataInput& input);
@@ -55,6 +57,7 @@ class RegionCommit {
CacheableStringPtr m_regionPath;
CacheableStringPtr m_parentRegionPath;
std::vector< std::shared_ptr<FarSideEntryOp> > m_farSideEntryOps;
+ MemberListForVersionStamp& m_memberListForVersionStamp;
};
} // namespace client
} // namespace geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RegionExpiryHandler.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RegionExpiryHandler.cpp b/src/cppcache/src/RegionExpiryHandler.cpp
index 66e74c5..ba97f16 100644
--- a/src/cppcache/src/RegionExpiryHandler.cpp
+++ b/src/cppcache/src/RegionExpiryHandler.cpp
@@ -62,14 +62,17 @@ int RegionExpiryHandler::handle_timeout(const ACE_Time_Value& current_time,
// (lastAccessTime + entryExpiryDuration - curr_time) in seconds
LOGDEBUG("Resetting expiry task for region [%s] after %d sec",
m_regionPtr->getFullPath(), -sec);
- CacheImpl::expiryTaskManager->resetTask(m_expiryTaskId, -sec);
+ m_regionPtr->getCacheImpl()->getExpiryTaskManager().resetTask(
+ m_expiryTaskId, -sec);
return 0;
}
+ LOGDEBUG("Removing expiry task for region [%s]",
+ m_regionPtr->getFullPath());
+ m_regionPtr->getCacheImpl()->getExpiryTaskManager().resetTask(
+ m_expiryTaskId, 0);
} catch (...) {
// Ignore whatever exception comes
}
- LOGDEBUG("Removing expiry task for region [%s]", m_regionPtr->getFullPath());
- CacheImpl::expiryTaskManager->resetTask(m_expiryTaskId, 0);
// we now delete the handler in GF_Timer_Heap_ImmediateReset_T
// and always return success.
return 0;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RegionFactory.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RegionFactory.cpp b/src/cppcache/src/RegionFactory.cpp
index a25b7e3..6d2b41a 100644
--- a/src/cppcache/src/RegionFactory.cpp
+++ b/src/cppcache/src/RegionFactory.cpp
@@ -35,10 +35,11 @@ namespace apache {
namespace geode {
namespace client {
-RegionFactory::RegionFactory(RegionShortcut preDefinedRegion) {
- m_preDefinedRegion = preDefinedRegion;
- m_attributeFactory = std::make_shared<AttributesFactory>();
- ;
+RegionFactory::RegionFactory(RegionShortcut preDefinedRegion,
+ CacheImpl* cacheImpl)
+ : m_preDefinedRegion(preDefinedRegion),
+ m_attributeFactory(std::make_shared<AttributesFactory>()),
+ m_cacheImpl(cacheImpl) {
setRegionShortcut();
}
@@ -47,36 +48,38 @@ RegionFactory::~RegionFactory() {}
RegionPtr RegionFactory::create(const char* name) {
RegionPtr retRegionPtr = nullptr;
RegionAttributesPtr regAttr = m_attributeFactory->createRegionAttributes();
-
- // assuming pool name is not DEFAULT_POOL_NAME
- if (regAttr->getPoolName() != nullptr && strlen(regAttr->getPoolName()) > 0) {
- // poolname is set
- CachePtr cache = CacheFactory::getAnyInstance();
- CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(cache.get());
- cacheImpl->createRegion(name, regAttr, retRegionPtr);
- } else {
- // need to look default Pool
- ACE_Guard<ACE_Recursive_Thread_Mutex> connectGuard(*g_disconnectLock);
- // if local region no need to create default pool
- if (m_preDefinedRegion != LOCAL) {
- PoolPtr pool = CacheFactory::createOrGetDefaultPool();
- if (pool == nullptr) {
- throw IllegalStateException("Pool is not defined create region.");
- }
- m_attributeFactory->setPoolName(pool->getName());
+ if (m_preDefinedRegion != LOCAL && (regAttr->getPoolName() == nullptr ||
+ strlen(regAttr->getPoolName()) == 0)) {
+ auto pool = m_cacheImpl->getPoolManager().getDefaultPool();
+ if (!pool) {
+ throw IllegalStateException("No pool for non-local region.");
}
-
+ m_attributeFactory->setPoolName(pool->getName());
regAttr = m_attributeFactory->createRegionAttributes();
- CachePtr cache = CacheFactory::getAnyInstance();
- CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(cache.get());
- cacheImpl->createRegion(name, regAttr, retRegionPtr);
}
+ m_cacheImpl->createRegion(name, regAttr, retRegionPtr);
return retRegionPtr;
}
void RegionFactory::setRegionShortcut() {
- CacheImpl::setRegionShortcut(m_attributeFactory, m_preDefinedRegion);
+ switch (m_preDefinedRegion) {
+ case PROXY: {
+ m_attributeFactory->setCachingEnabled(false);
+ } break;
+ case CACHING_PROXY: {
+ m_attributeFactory->setCachingEnabled(true);
+ } break;
+ case CACHING_PROXY_ENTRY_LRU: {
+ m_attributeFactory->setCachingEnabled(true);
+ m_attributeFactory->setLruEntriesLimit(DEFAULT_LRU_MAXIMUM_ENTRIES);
+ } break;
+ case LOCAL: {
+ } break;
+ case LOCAL_ENTRY_LRU: {
+ m_attributeFactory->setLruEntriesLimit(DEFAULT_LRU_MAXIMUM_ENTRIES);
+ } break;
+ }
}
RegionFactoryPtr RegionFactory::setCacheLoader(
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RegionInternal.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RegionInternal.cpp b/src/cppcache/src/RegionInternal.cpp
index 0dc47cb..860acfe 100644
--- a/src/cppcache/src/RegionInternal.cpp
+++ b/src/cppcache/src/RegionInternal.cpp
@@ -37,8 +37,9 @@ const CacheEventFlags CacheEventFlags::CACHE_CLOSE(
const CacheEventFlags CacheEventFlags::NOCACHEWRITER(
CacheEventFlags::GF_NOCACHEWRITER);
-RegionInternal::RegionInternal(const RegionAttributesPtr& attributes)
- : m_regionAttributes(attributes) {}
+RegionInternal::RegionInternal(const CachePtr& cache,
+ const RegionAttributesPtr& attributes)
+ : Region(cache), m_regionAttributes(attributes) {}
RegionInternal::~RegionInternal() {}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RegionInternal.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RegionInternal.hpp b/src/cppcache/src/RegionInternal.hpp
index 1b8c639..4b30bca 100644
--- a/src/cppcache/src/RegionInternal.hpp
+++ b/src/cppcache/src/RegionInternal.hpp
@@ -82,26 +82,40 @@ class CacheEventFlags {
return (m_flags == flags.m_flags);
}
- inline bool isNormal() const { return (m_flags & GF_NORMAL); }
+ inline bool isNormal() const {
+ return (m_flags & GF_NORMAL) > 0 ? true : false;
+ }
- inline bool isLocal() const { return (m_flags & GF_LOCAL); }
+ inline bool isLocal() const {
+ return (m_flags & GF_LOCAL) > 0 ? true : false;
+ }
- inline bool isNotification() const { return (m_flags & GF_NOTIFICATION); }
+ inline bool isNotification() const {
+ return (m_flags & GF_NOTIFICATION) > 0 ? true : false;
+ }
inline bool isNotificationUpdate() const {
- return (m_flags & GF_NOTIFICATION_UPDATE);
+ return (m_flags & GF_NOTIFICATION_UPDATE) > 0 ? true : false;
}
- inline bool isEviction() const { return (m_flags & GF_EVICTION); }
+ inline bool isEviction() const {
+ return (m_flags & GF_EVICTION) > 0 ? true : false;
+ }
- inline bool isExpiration() const { return (m_flags & GF_EXPIRATION); }
+ inline bool isExpiration() const {
+ return (m_flags & GF_EXPIRATION) > 0 ? true : false;
+ }
- inline bool isCacheClose() const { return (m_flags & GF_CACHE_CLOSE); }
+ inline bool isCacheClose() const {
+ return (m_flags & GF_CACHE_CLOSE) > 0 ? true : false;
+ }
- inline bool isNoCacheWriter() const { return (m_flags & GF_NOCACHEWRITER); }
+ inline bool isNoCacheWriter() const {
+ return (m_flags & GF_NOCACHEWRITER) > 0 ? true : false;
+ }
inline bool isEvictOrExpire() const {
- return (m_flags & (GF_EVICTION | GF_EXPIRATION));
+ return (m_flags & (GF_EVICTION | GF_EXPIRATION)) > 0 ? true : false;
}
// special optimized method for CacheWriter invocation condition
@@ -254,7 +268,7 @@ class RegionInternal : public Region {
/**
* @brief constructor
*/
- RegionInternal(const RegionAttributesPtr& attributes);
+ RegionInternal(const CachePtr& cache, const RegionAttributesPtr& attributes);
void setLruEntriesLimit(uint32_t limit);
void setRegionTimeToLiveExpirationAction(ExpirationAction::Action action);
@@ -286,10 +300,8 @@ class RegionInternal : public Region {
return m_regionAttributes->getRegionExpiryEnabled();
}
- private:
- // Disallow copy constructor and assignment operator.
- RegionInternal(const RegionInternal&);
- RegionInternal& operator=(const RegionInternal&);
+ RegionInternal(const RegionInternal&) = delete;
+ RegionInternal& operator=(const RegionInternal&) = delete;
};
typedef std::shared_ptr<RegionInternal> RegionInternalPtr;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RegionStats.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RegionStats.cpp b/src/cppcache/src/RegionStats.cpp
index e8f8004..3c6192c 100644
--- a/src/cppcache/src/RegionStats.cpp
+++ b/src/cppcache/src/RegionStats.cpp
@@ -15,22 +15,13 @@
* limitations under the License.
*/
-#include <geode/geode_globals.hpp>
-
-#include "RegionStats.hpp"
-//#include "StatisticsFactory.hpp"
-
#include <ace/Thread_Mutex.h>
#include <ace/Singleton.h>
-#include <mutex>
-
-#include "util/concurrent/spinlock_mutex.hpp"
-
-const char* statsName = "RegionStatistics";
-const char* statsDesc = "Statistics for this region";
+#include <geode/geode_globals.hpp>
+#include <util/concurrent/spinlock_mutex.hpp>
-////////////////////////////////////////////////////////////////////////////////
+#include "RegionStats.hpp"
namespace apache {
namespace geode {
@@ -39,124 +30,111 @@ namespace client {
using statistics::StatisticsFactory;
using util::concurrent::spinlock_mutex;
-////////////////////////////////////////////////////////////////////////////////
-
-RegionStatType* RegionStatType::single = nullptr;
-spinlock_mutex RegionStatType::m_singletonLock;
-spinlock_mutex RegionStatType::m_statTypeLock;
+constexpr const char* RegionStats::STATS_NAME;
+constexpr const char* RegionStats::STATS_DESC;
-void RegionStatType::clean() {
- std::lock_guard<spinlock_mutex> guard(m_singletonLock);
- if (single) {
- delete single;
- single = nullptr;
- }
-}
+RegionStats::RegionStats(StatisticsFactory* factory,
+ const std::string& regionName) {
+ auto statsType = factory->findType(STATS_NAME);
-StatisticsType* RegionStatType::getStatType() {
- const bool largerIsBetter = true;
- std::lock_guard<spinlock_mutex> guard(m_statTypeLock);
- StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
- GF_D_ASSERT(!!factory);
-
- StatisticsType* statsType = factory->findType("RegionStatistics");
-
- if (statsType == nullptr) {
- m_stats[0] = factory->createIntCounter(
+ if (!statsType) {
+ const bool largerIsBetter = true;
+ auto stats = new StatisticDescriptor*[25];
+ stats[0] = factory->createIntCounter(
"creates", "The total number of cache creates for this region",
"entries", largerIsBetter);
- m_stats[1] = factory->createIntCounter(
+ stats[1] = factory->createIntCounter(
"puts", "The total number of cache puts for this region", "entries",
largerIsBetter);
- m_stats[2] = factory->createIntCounter(
+ stats[2] = factory->createIntCounter(
"gets", "The total number of cache gets for this region", "entries",
largerIsBetter);
- m_stats[3] = factory->createIntCounter(
+ stats[3] = factory->createIntCounter(
"hits", "The total number of cache hits for this region", "entries",
largerIsBetter);
- m_stats[4] = factory->createIntCounter(
+ stats[4] = factory->createIntCounter(
"misses", "The total number of cache misses for this region", "entries",
!largerIsBetter);
- m_stats[5] = factory->createIntGauge(
+ stats[5] = factory->createIntGauge(
"entries", "The current number of cache entries for this region",
"entries", largerIsBetter);
- m_stats[6] = factory->createIntCounter(
+ stats[6] = factory->createIntCounter(
"destroys", "The total number of cache destroys for this region",
"entries", largerIsBetter);
- m_stats[7] =
+ stats[7] =
factory->createIntCounter("overflows",
"The total number of cache overflows for "
"this region to persistence backup",
"entries", largerIsBetter);
- m_stats[8] =
+ stats[8] =
factory->createIntCounter("retrieves",
"The total number of cache entries fetched "
"from persistence backup into the cache",
"entries", largerIsBetter);
- m_stats[9] =
+ stats[9] =
factory->createIntCounter("metaDataRefreshCount",
"The total number of times matadata is "
"refreshed due to hoping observed",
"entries", !largerIsBetter);
- m_stats[10] = factory->createIntCounter(
+ stats[10] = factory->createIntCounter(
"getAll", "The total number of cache getAll for this region", "entries",
largerIsBetter);
- m_stats[11] = factory->createIntCounter(
+ stats[11] = factory->createIntCounter(
"putAll", "The total number of cache putAll for this region", "entries",
largerIsBetter);
- m_stats[12] = factory->createLongCounter(
+ stats[12] = factory->createLongCounter(
"getTime", "Total time spent doing get operations for this region",
"Nanoseconds", !largerIsBetter);
- m_stats[13] = factory->createLongCounter(
+ stats[13] = factory->createLongCounter(
"putTime", "Total time spent doing puts operations for this region",
"Nanoseconds", !largerIsBetter);
- m_stats[14] = factory->createLongCounter(
+ stats[14] = factory->createLongCounter(
"putAllTime",
"Total time spent doing putAlls operations for this region",
"Nanoseconds", !largerIsBetter);
- m_stats[15] = factory->createLongCounter(
+ stats[15] = factory->createLongCounter(
"getAllTime",
"Total time spent doing the getAlls operations for this region",
"Nanoseconds", !largerIsBetter);
- m_stats[16] = factory->createIntCounter(
+ stats[16] = factory->createIntCounter(
"cacheLoaderCallsCompleted",
"Total number of times a load has completed for this region", "entries",
largerIsBetter);
- m_stats[17] = factory->createLongCounter(
+ stats[17] = factory->createLongCounter(
"cacheLoaderCallTIme",
"Total time spent invoking the loaders for this region", "Nanoseconds",
!largerIsBetter);
- m_stats[18] =
+ stats[18] =
factory->createIntCounter("cacheWriterCallsCompleted",
"Total number of times a cache writer call "
"has completed for this region",
"entries", largerIsBetter);
- m_stats[19] = factory->createLongCounter(
+ stats[19] = factory->createLongCounter(
"cacheWriterCallTime", "Total time spent doing cache writer calls",
"Nanoseconds", !largerIsBetter);
- m_stats[20] =
+ stats[20] =
factory->createIntCounter("cacheListenerCallsCompleted",
"Total number of times a cache listener call "
"has completed for this region",
"entries", largerIsBetter);
- m_stats[21] = factory->createLongCounter(
+ stats[21] = factory->createLongCounter(
"cacheListenerCallTime",
"Total time spent doing cache listener calls for this region",
"Nanoseconds", !largerIsBetter);
- m_stats[22] =
+ stats[22] =
factory->createIntCounter("clears",
"The total number of times a clear has been "
"done on this cache for this region",
"entries", !largerIsBetter);
- m_stats[23] = factory->createIntCounter(
+ stats[23] = factory->createIntCounter(
"removeAll", "The total number of cache removeAll for this region",
"entries", largerIsBetter);
- m_stats[24] = factory->createLongCounter(
+ stats[24] = factory->createLongCounter(
"removeAllTime",
"Total time spent doing removeAlls operations for this region",
"Nanoseconds", !largerIsBetter);
- statsType = factory->createType(statsName, statsDesc, m_stats, 25);
+ statsType = factory->createType(STATS_NAME, STATS_DESC, stats, 25);
}
m_destroysId = statsType->nameToId("destroys");
@@ -186,87 +164,8 @@ StatisticsType* RegionStatType::getStatType() {
m_ListenerCallTimeId = statsType->nameToId("cacheListenerCallTime");
m_clearsId = statsType->nameToId("clears");
- return statsType;
-}
-
-RegionStatType* RegionStatType::getInstance() {
- std::lock_guard<spinlock_mutex> guard(m_singletonLock);
- if (!single) {
- single = new RegionStatType();
- }
- return single;
-}
-
-RegionStatType::RegionStatType()
- : m_destroysId(0),
- m_createsId(0),
- m_putsId(0),
- m_putTimeId(0),
- m_putAllId(0),
- m_putAllTimeId(0),
- m_removeAllId(0),
- m_removeAllTimeId(0),
- m_getsId(0),
- m_getTimeId(0),
- m_getAllId(0),
- m_getAllTimeId(0),
- m_hitsId(0),
- m_missesId(0),
- m_entriesId(0),
- m_overflowsId(0),
- m_retrievesId(0),
- m_metaDataRefreshId(0),
- m_LoaderCallsCompletedId(0),
- m_LoaderCallTimeId(0),
- m_WriterCallsCompletedId(0),
- m_WriterCallTimeId(0),
- m_ListenerCallsCompletedId(0),
- m_ListenerCallTimeId(0),
- m_clearsId(0) {}
-
-////////////////////////////////////////////////////////////////////////////////
-
-// typedef ACE_Singleton<RegionStatsInit, ACE_Thread_Mutex> TheRegionStatsInit;
-
-////////////////////////////////////////////////////////////////////////////////
-
-RegionStats::RegionStats(const char* regionName) {
- RegionStatType* regStatType = RegionStatType::getInstance();
-
- StatisticsType* statsType = regStatType->getStatType();
-
- GF_D_ASSERT(statsType != nullptr);
-
- StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
-
- m_regionStats =
- factory->createAtomicStatistics(statsType, const_cast<char*>(regionName));
-
- m_destroysId = regStatType->getDestroysId();
- m_createsId = regStatType->getCreatesId();
- m_putsId = regStatType->getPutsId();
- m_putTimeId = regStatType->getPutTimeId();
- m_getsId = regStatType->getGetsId();
- m_getTimeId = regStatType->getGetTimeId();
- m_getAllId = regStatType->getGetAllId();
- m_getAllTimeId = regStatType->getGetAllTimeId();
- m_putAllId = regStatType->getPutAllId();
- m_putAllTimeId = regStatType->getPutAllTimeId();
- m_removeAllId = regStatType->getRemoveAllId();
- m_removeAllTimeId = regStatType->getRemoveAllTimeId();
- m_hitsId = regStatType->getHitsId();
- m_missesId = regStatType->getMissesId();
- m_entriesId = regStatType->getEntriesId();
- m_overflowsId = regStatType->getOverflowsId();
- m_retrievesId = regStatType->getRetrievesId();
- m_metaDataRefreshId = regStatType->getMetaDataRefreshCount();
- m_LoaderCallsCompletedId = regStatType->getLoaderCallsCompletedId();
- m_LoaderCallTimeId = regStatType->getLoaderCallTimeId();
- m_WriterCallsCompletedId = regStatType->getWriterCallsCompletedId();
- m_WriterCallTimeId = regStatType->getWriterCallTimeId();
- m_ListenerCallsCompletedId = regStatType->getListenerCallsCompletedId();
- m_ListenerCallTimeId = regStatType->getListenerCallTimeId();
- m_clearsId = regStatType->getClearsId();
+ m_regionStats = factory->createAtomicStatistics(
+ statsType, const_cast<char*>(regionName.c_str()));
m_regionStats->setInt(m_destroysId, 0);
m_regionStats->setInt(m_createsId, 0);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RegionStats.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RegionStats.hpp b/src/cppcache/src/RegionStats.hpp
index f37ca1b..0bedfde 100644
--- a/src/cppcache/src/RegionStats.hpp
+++ b/src/cppcache/src/RegionStats.hpp
@@ -20,10 +20,11 @@
#ifndef GEODE_REGIONSTATS_H_
#define GEODE_REGIONSTATS_H_
+#include <string>
+
#include <geode/geode_globals.hpp>
#include <geode/statistics/Statistics.hpp>
#include <geode/statistics/StatisticsFactory.hpp>
-#include "util/concurrent/spinlock_mutex.hpp"
namespace apache {
namespace geode {
@@ -32,12 +33,11 @@ namespace client {
using statistics::StatisticDescriptor;
using statistics::StatisticsType;
using statistics::Statistics;
-using util::concurrent::spinlock_mutex;
class CPPCACHE_EXPORT RegionStats {
public:
/** hold statistics for a region.. */
- RegionStats(const char* regionName);
+ RegionStats(statistics::StatisticsFactory* factory, const std::string& regionName);
/** disable stat collection for this item. */
virtual ~RegionStats();
@@ -88,56 +88,32 @@ class CPPCACHE_EXPORT RegionStats {
inline void incClears() { m_regionStats->incInt(m_clearsId, 1); }
+ inline void updateGetTime() { m_regionStats->incInt(m_clearsId, 1); }
+
inline apache::geode::statistics::Statistics* getStat() {
return m_regionStats;
}
- private:
- apache::geode::statistics::Statistics* m_regionStats;
+ inline int32_t getGetTimeId() { return m_getTimeId; }
- int32_t m_destroysId;
- int32_t m_createsId;
- int32_t m_putsId;
- int32_t m_putTimeId;
- int32_t m_putAllId;
- int32_t m_putAllTimeId;
- int32_t m_removeAllId;
- int32_t m_removeAllTimeId;
- int32_t m_getsId;
- int32_t m_getTimeId;
- int32_t m_getAllId;
- int32_t m_getAllTimeId;
- int32_t m_hitsId;
- int32_t m_missesId;
- int32_t m_entriesId;
- int32_t m_overflowsId;
- int32_t m_retrievesId;
- int32_t m_metaDataRefreshId;
- int32_t m_LoaderCallsCompletedId;
- int32_t m_LoaderCallTimeId;
- int32_t m_WriterCallsCompletedId;
- int32_t m_WriterCallTimeId;
- int32_t m_ListenerCallsCompletedId;
- int32_t m_ListenerCallTimeId;
- int32_t m_clearsId;
-};
+ inline int32_t getPutTimeId() { return m_putTimeId; }
-class RegionStatType {
- private:
- static RegionStatType* single;
- static spinlock_mutex m_singletonLock;
- static spinlock_mutex m_statTypeLock;
+ inline int32_t getGetAllTimeId() { return m_getAllTimeId; }
- public:
- static RegionStatType* getInstance();
+ inline int32_t getPutAllTimeId() { return m_putAllTimeId; }
+
+ inline int32_t getRemoveAllTimeId() { return m_removeAllTimeId; }
- statistics::StatisticsType* getStatType();
+ inline int32_t getLoaderCallTimeId() { return m_LoaderCallTimeId; }
- static void clean();
+ inline int32_t getWriterCallTimeId() { return m_WriterCallTimeId; }
+
+ inline int32_t getListenerCallTimeId() { return m_ListenerCallTimeId; }
+
+ inline int32_t getClearsId() { return m_clearsId; }
private:
- RegionStatType();
- statistics::StatisticDescriptor* m_stats[25];
+ apache::geode::statistics::Statistics* m_regionStats;
int32_t m_destroysId;
int32_t m_createsId;
@@ -165,63 +141,10 @@ class RegionStatType {
int32_t m_ListenerCallTimeId;
int32_t m_clearsId;
- public:
- inline int32_t getDestroysId() { return m_destroysId; }
-
- inline int32_t getCreatesId() { return m_createsId; }
-
- inline int32_t getPutsId() { return m_putsId; }
-
- inline int32_t getPutTimeId() { return m_putTimeId; }
-
- inline int32_t getPutAllId() { return m_putAllId; }
-
- inline int32_t getPutAllTimeId() { return m_putAllTimeId; }
-
- inline int32_t getRemoveAllId() { return m_removeAllId; }
-
- inline int32_t getRemoveAllTimeId() { return m_removeAllTimeId; }
-
- inline int32_t getGetsId() { return m_getsId; }
-
- inline int32_t getGetTimeId() { return m_getTimeId; }
-
- inline int32_t getGetAllId() { return m_getAllId; }
-
- inline int32_t getGetAllTimeId() { return m_getAllTimeId; }
-
- inline int32_t getHitsId() { return m_hitsId; }
-
- inline int32_t getMissesId() { return m_missesId; }
-
- inline int32_t getEntriesId() { return m_entriesId; }
-
- inline int32_t getOverflowsId() { return m_overflowsId; }
-
- inline int32_t getRetrievesId() { return m_retrievesId; }
-
- inline int32_t getMetaDataRefreshCount() { return m_metaDataRefreshId; }
-
- inline int32_t getLoaderCallsCompletedId() {
- return m_LoaderCallsCompletedId;
- }
-
- inline int32_t getLoaderCallTimeId() { return m_LoaderCallTimeId; }
-
- inline int32_t getWriterCallsCompletedId() {
- return m_WriterCallsCompletedId;
- }
-
- inline int32_t getWriterCallTimeId() { return m_WriterCallTimeId; }
-
- inline int32_t getListenerCallsCompletedId() {
- return m_ListenerCallsCompletedId;
- }
-
- inline int32_t getListenerCallTimeId() { return m_ListenerCallTimeId; }
-
- inline int32_t getClearsId() { return m_clearsId; }
+ static constexpr const char* STATS_NAME = "RegionStatistics";
+ static constexpr const char* STATS_DESC = "Statistics for this region";
};
+
} // namespace client
} // namespace geode
} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RegionXmlCreation.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RegionXmlCreation.cpp b/src/cppcache/src/RegionXmlCreation.cpp
index 37de2e0..8b234d0 100644
--- a/src/cppcache/src/RegionXmlCreation.cpp
+++ b/src/cppcache/src/RegionXmlCreation.cpp
@@ -20,9 +20,9 @@
#include "RegionXmlCreation.hpp"
#include "CacheImpl.hpp"
using namespace apache::geode::client;
-extern bool Cache_CreatedFromCacheFactory;
-void RegionXmlCreation::addSubregion(RegionXmlCreation* regionPtr) {
+void RegionXmlCreation::addSubregion(
+ std::shared_ptr<RegionXmlCreation> regionPtr) {
subRegions.push_back(regionPtr);
}
@@ -33,11 +33,8 @@ void RegionXmlCreation::setAttributes(RegionAttributesPtr attrsPtr) {
RegionAttributesPtr RegionXmlCreation::getAttributes() { return regAttrs; }
void RegionXmlCreation::fillIn(RegionPtr regionPtr) {
- std::vector<RegionXmlCreation*>::iterator start = subRegions.begin();
- while (start != subRegions.end()) {
- RegionXmlCreation* regXmlCreation = *start;
+ for (const auto& regXmlCreation : subRegions) {
regXmlCreation->create(regionPtr);
- start++;
}
}
@@ -45,23 +42,6 @@ void RegionXmlCreation::createRoot(Cache* cache) {
GF_D_ASSERT(this->isRoot);
RegionPtr rootRegPtr = nullptr;
- if (Cache_CreatedFromCacheFactory) {
- // if(cache->m_cacheImpl->getDefaultPool() == nullptr)
- {
- // we may need to initialize default pool
- if (regAttrs->getEndpoints() == nullptr) {
- if (regAttrs->getPoolName() == nullptr) {
- PoolPtr pool = CacheFactory::createOrGetDefaultPool();
-
- if (pool == nullptr) {
- throw IllegalStateException("Pool is not defined create region.");
- }
- regAttrs->setPoolName(pool->getName());
- }
- }
- }
- }
-
CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(cache);
cacheImpl->createRegion(regionName.c_str(), regAttrs, rootRegPtr);
fillIn(rootRegPtr);
@@ -83,15 +63,6 @@ RegionXmlCreation::RegionXmlCreation(char* name, bool isRootRegion)
attrId = "";
}
-RegionXmlCreation::~RegionXmlCreation() {
- std::vector<RegionXmlCreation*>::iterator start = subRegions.begin();
- while (start != subRegions.end()) {
- delete *start;
- *start = nullptr;
- ++start;
- }
-}
-
std::string RegionXmlCreation::getAttrId() const { return attrId; }
void RegionXmlCreation::setAttrId(const std::string& pattrId) {
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RegionXmlCreation.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RegionXmlCreation.hpp b/src/cppcache/src/RegionXmlCreation.hpp
index 0c31425..a0bd853 100644
--- a/src/cppcache/src/RegionXmlCreation.hpp
+++ b/src/cppcache/src/RegionXmlCreation.hpp
@@ -57,7 +57,7 @@ class CPPCACHE_EXPORT RegionXmlCreation {
RegionAttributesPtr regAttrs;
/** This region's subregions */
- std::vector<RegionXmlCreation*> subRegions;
+ std::vector<std::shared_ptr<RegionXmlCreation>> subRegions;
public:
/**
@@ -69,7 +69,7 @@ class CPPCACHE_EXPORT RegionXmlCreation {
void fillIn(RegionPtr region);
public:
- ~RegionXmlCreation();
+ ~RegionXmlCreation() = default;
/**
* Creates a new <code>RegionCreation</code> with the given name.
*/
@@ -78,7 +78,7 @@ class CPPCACHE_EXPORT RegionXmlCreation {
/**
* Adds a subregion with the given name to this region
*/
- void addSubregion(RegionXmlCreation* regionPtr);
+ void addSubregion(std::shared_ptr<RegionXmlCreation> regionPtr);
/**
* Sets the attributes of this region
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RemoteQuery.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RemoteQuery.cpp b/src/cppcache/src/RemoteQuery.cpp
index 2c37595..b8450f5 100644
--- a/src/cppcache/src/RemoteQuery.cpp
+++ b/src/cppcache/src/RemoteQuery.cpp
@@ -70,7 +70,13 @@ SelectResultsPtr RemoteQuery::execute(uint32_t timeout, const char* func,
pool->getStats().incQueryExecutionId();
}
/*get the start time for QueryExecutionTime stat*/
- int64_t sampleStartNanos = Utils::startStatOpTime();
+ bool enableTimeStatistics = pool->getConnectionManager()
+ .getCacheImpl()
+ ->getDistributedSystem()
+ .getSystemProperties()
+ .getEnableTimeStatistics();
+ int64_t sampleStartNanos =
+ enableTimeStatistics ? Utils::startStatOpTime() : 0;
TcrMessageReply reply(true, tcdm);
ChunkedQueryResponse* resultCollector = (new ChunkedQueryResponse(reply));
reply.setChunkedResultHandler(
@@ -105,11 +111,10 @@ SelectResultsPtr RemoteQuery::execute(uint32_t timeout, const char* func,
}
/*update QueryExecutionTime stat */
- if (pool != nullptr) {
- Utils::updateStatOpTime(
- pool->getStats().getStats(),
- PoolStatType::getInstance()->getQueryExecutionTimeId(),
- sampleStartNanos);
+ if (pool != nullptr && enableTimeStatistics) {
+ Utils::updateStatOpTime(pool->getStats().getStats(),
+ pool->getStats().getQueryExecutionTimeId(),
+ sampleStartNanos);
}
delete resultCollector;
return sr;
@@ -130,6 +135,10 @@ GfErrType RemoteQuery::executeNoThrow(uint32_t timeout, TcrMessageReply& reply,
if (paramList != nullptr) {
// QUERY_WITH_PARAMETERS
TcrMessageQueryWithParameters msg(
+ m_tccdm->getConnectionManager()
+ .getCacheImpl()
+ ->getCache()
+ ->createDataOutput(),
m_queryString, nullptr, paramList,
static_cast<int>(timeout * 1000) /* in milli second */, tcdm);
msg.setTimeout(timeout);
@@ -152,7 +161,11 @@ GfErrType RemoteQuery::executeNoThrow(uint32_t timeout, TcrMessageReply& reply,
}
return err;
} else {
- TcrMessageQuery msg(m_queryString,
+ TcrMessageQuery msg(m_tccdm->getConnectionManager()
+ .getCacheImpl()
+ ->getCache()
+ ->createDataOutput(),
+ m_queryString,
static_cast<int>(timeout * 1000) /* in milli second */,
tcdm);
msg.setTimeout(timeout);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RemoteQueryService.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RemoteQueryService.cpp b/src/cppcache/src/RemoteQueryService.cpp
index 095c7e7..d46e1b3 100644
--- a/src/cppcache/src/RemoteQueryService.cpp
+++ b/src/cppcache/src/RemoteQueryService.cpp
@@ -21,20 +21,23 @@
#include "CqServiceVsdStats.hpp"
#include "ThinClientPoolDM.hpp"
#include "UserAttributes.hpp"
+#include "statistics/StatisticsManager.hpp"
using namespace apache::geode::client;
-RemoteQueryService::RemoteQueryService(CacheImpl* cptr,
+RemoteQueryService::RemoteQueryService(CacheImpl* cache,
ThinClientPoolDM* poolDM)
- : m_invalid(true), m_cqService(nullptr) {
+ : m_invalid(true),
+ m_cqService(nullptr),
+ m_statisticsFactory(cache->getDistributedSystem()
+ .getStatisticsManager()
+ ->getStatisticsFactory()) {
if (poolDM) {
m_tccdm = poolDM;
} else {
m_tccdm =
- new ThinClientCacheDistributionManager(cptr->tcrConnectionManager());
+ new ThinClientCacheDistributionManager(cache->tcrConnectionManager());
}
- // m_cqService = new CqService(m_tccdm);
- // m_tccdm->init();
LOGFINEST("Initialized m_tccdm");
}
@@ -242,10 +245,10 @@ CqServiceStatisticsPtr RemoteQueryService::getCqServiceStatistics() {
"QueryService::getCqServiceStatistics: Cache has been closed.");
}
// If cqService has not started, then no cq exists
- if (m_cqService != nullptr) {
+ if (m_cqService) {
return m_cqService->getCqServiceStatistics();
}
- return std::make_shared<CqServiceVsdStats>();
+ return nullptr;
}
void RemoteQueryService::receiveNotification(TcrMessage* msg) {
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/RemoteQueryService.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RemoteQueryService.hpp b/src/cppcache/src/RemoteQueryService.hpp
index ec9567d..feca89c 100644
--- a/src/cppcache/src/RemoteQueryService.hpp
+++ b/src/cppcache/src/RemoteQueryService.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_REMOTEQUERYSERVICE_H_
-#define GEODE_REMOTEQUERYSERVICE_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -19,14 +14,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+#pragma once
+
+#ifndef GEODE_REMOTEQUERYSERVICE_H_
+#define GEODE_REMOTEQUERYSERVICE_H_
+
+#include <ace/Recursive_Thread_Mutex.h>
#include <geode/geode_globals.hpp>
#include <memory>
-#include "CqService.hpp"
-
#include <geode/QueryService.hpp>
-#include "ThinClientCacheDistributionManager.hpp"
-#include <ace/Recursive_Thread_Mutex.h>
+#include "CqService.hpp"
+#include "ThinClientCacheDistributionManager.hpp"
+#include "statistics/StatisticsManager.hpp"
namespace apache {
namespace geode {
@@ -73,7 +74,7 @@ class CPPCACHE_EXPORT RemoteQueryService
inline void initCqService() {
if (m_cqService == nullptr) {
LOGFINE("RemoteQueryService: starting cq service");
- m_cqService = std::make_shared<CqService>(m_tccdm);
+ m_cqService = std::make_shared<CqService>(m_tccdm, m_statisticsFactory);
LOGFINE("RemoteQueryService: started cq service");
}
}
@@ -85,6 +86,7 @@ class CPPCACHE_EXPORT RemoteQueryService
ThinClientBaseDM* m_tccdm;
CqServicePtr m_cqService;
CqPoolsConnected m_CqPoolsConnected;
+ statistics::StatisticsFactory* m_statisticsFactory;
};
typedef std::shared_ptr<RemoteQueryService> RemoteQueryServicePtr;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/Serializable.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/Serializable.cpp b/src/cppcache/src/Serializable.cpp
index db2d17a..143385d 100644
--- a/src/cppcache/src/Serializable.cpp
+++ b/src/cppcache/src/Serializable.cpp
@@ -20,6 +20,7 @@
#include <SerializationRegistry.hpp>
#include <Utils.hpp>
#include <geode/CacheableString.hpp>
+#include "CacheImpl.hpp"
namespace apache {
namespace geode {
@@ -42,18 +43,6 @@ int8_t Serializable::DSFID() const {
uint32_t Serializable::objectSize() const { return 0; }
-void Serializable::registerType(TypeFactoryMethod creationFunction) {
- SerializationRegistry::addType(creationFunction);
-}
-
-void Serializable::registerPdxType(TypeFactoryMethodPdx creationFunction) {
- SerializationRegistry::addPdxType(creationFunction);
-}
-
-void Serializable::registerPdxSerializer(PdxSerializerPtr pdxSerializer) {
- SerializationRegistry::setPdxSerializer(pdxSerializer);
-}
-
CacheableStringPtr Serializable::toString() const {
return Utils::demangleTypeName(typeid(*this).name());
}
[02/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cli/NewFwkLib/SmokePerf/SmokePerf.cs
----------------------------------------------------------------------
diff --git a/src/tests/cli/NewFwkLib/SmokePerf/SmokePerf.cs b/src/tests/cli/NewFwkLib/SmokePerf/SmokePerf.cs
deleted file mode 100644
index 6e96cf9..0000000
--- a/src/tests/cli/NewFwkLib/SmokePerf/SmokePerf.cs
+++ /dev/null
@@ -1,1580 +0,0 @@
-/*
- * 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.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.IO;
-using System.Text.RegularExpressions;
-using System.Threading;
-using Apache.Geode.Client.Tests;
-namespace Apache.Geode.Client.FwkLib
-{
- using Apache.Geode.DUnitFramework;
- using Apache.Geode.Client;
- //using Region = Apache.Geode.Client.IRegion<Object, Object>;
- public class PerfCacheListener<TKey, TVal> : CacheListenerAdapter<TKey, TVal>, IDisposable
- {
- public static Int64 LAT_MARK = 0x55667788;
- public static Int64 LATENCY_SPIKE_THRESHOLD = 10000000;
- protected PerfStat statistics = null;
- public PerfCacheListener(PerfStat perfstat)
- {
- statistics = perfstat;
- }
-
- public void RecordLatency(object objValue)
- {
- DateTime startTime = DateTime.Now;
- long now = startTime.Ticks * (1000000 / TimeSpan.TicksPerMillisecond);
- long then;
- if (objValue is byte[])
- {
- then = ArrayOfByte.GetTimestamp(objValue as byte[]);
- }
- else
- {
- then = ((TimeStampdObject)objValue).GetTimestamp();
- }
- long latency = now - then;
- if (latency > LATENCY_SPIKE_THRESHOLD)
- {
- statistics.IncLatencySpikes(1);
- }
- if (latency < 0)
- {
- statistics.IncNegativeLatencies(1);
- }
- else
- {
- statistics.IncUpdateLatency(latency);
- }
- }
- protected virtual void Dispose(bool disposing)
- {
- }
- #region IDisposable Members
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- #endregion
-
- ~PerfCacheListener()
- {
- Dispose(false);
- }
- }
-
- public class LatencyListeners<TKey, TVal> : PerfCacheListener<TKey, TVal>
- {
-
- public LatencyListeners(PerfStat perfstat)
- : base(perfstat)
- {
- Util.Log("LatencyListeners constructor");
- }
-
- public override void AfterUpdate(EntryEvent<TKey, TVal> ev)
- {
-
- FwkTest<TKey, TVal>.CurrentTest.FwkInfo("rjk LatencyListeners AfterUpdate invoked ");
- TKey key = ev.Key;
- TVal value = ev.NewValue;
- Util.Log("rjk: LatencyListeners AfterUpdate - 11");
- RecordLatency(value);
- Util.Log("rjk: LatencyListeners AfterUpdate - 12");
-
- }
- }
-
- public class CQLatencyListener<TKey, TVal> : PerfCacheListener<TKey, TVal>, ICqListener<TKey, object>
- {
- public CQLatencyListener(PerfStat perfstat)
- : base(perfstat)
- {
- }
- public void OnEvent(CqEvent<TKey, object> ev)
- {
- /*TVal*/ object value = ev.getNewValue();
- RecordLatency(value);
- }
- public void OnError(CqEvent<TKey, object> ev)
- {
- }
- public void Close()
- {
- }
- }
-
- public class PerfCacheLoader<TKey, TVal> : ICacheLoader<TKey, TVal>
- {
- private Int32 m_loads = 0;
- public PerfCacheLoader()
- : base()
- {
- }
- #region Public accessors
- public Int32 Loads
- {
- get
- {
- return m_loads;
- }
- }
- #endregion
- public TVal Load(IRegion<TKey, TVal> region, TKey key, object helper)
- {
- m_loads++;
- return default(TVal);
- }
- public virtual void Close(IRegion<TKey, TVal> region) { }
-
- // VJR: added dummy load/close placeholders.
- /*
- public IGeodeSerializable Load( Apache.Geode.Client.Region region, ICacheableKey key, IGeodeSerializable helper)
- {
- return new CacheableInt32(m_loads++);
- }
- public virtual void Close( Apache.Geode.Client.Region region) { }
- */
- }
-
- public class DurableCacheListener<TKey, TVal> : CacheListenerAdapter<TKey, TVal>, IDisposable
- {
- private Int32 m_ops = 0;
- private string m_clntName;
-
- private void check(EntryEvent<TKey, TVal> ev)
- {
- TKey key = ev.Key;
- TVal value = ev.NewValue;
- m_ops++;
- }
-
- public DurableCacheListener()
- {
- m_ops = 0;
- m_clntName = String.Format("ClientName_{0}", Util.ClientNum);
- Util.BBSet("DURABLEBB", m_clntName, 0);
- }
-
- ~DurableCacheListener()
- {
- Dispose(false);
- }
-
- void dumpToBB()
- {
- FwkTest<TKey, TVal> currTest = FwkTest<TKey, TVal>.CurrentTest;
- string bbkey = m_clntName;
- int current = 0;
- try
- {
- current = (int)Util.BBGet("DURABLEBB", bbkey);
- }
- catch (Apache.Geode.DUnitFramework.KeyNotFoundException)
- {
- currTest.FwkInfo("Key not found for DURABLEBB {0}", bbkey);
- }
- current += m_ops;
- Util.BBSet("DURABLEBB", bbkey, current);
- currTest.FwkInfo("Current count for " + bbkey + " is " + current);
- }
-
- public override void AfterCreate(EntryEvent<TKey, TVal> ev)
- {
- check(ev);
- }
-
- public override void AfterUpdate(EntryEvent<TKey, TVal> ev)
- {
- check(ev);
- }
-
- public override void AfterRegionDestroy(RegionEvent<TKey, TVal> ev)
- {
- dumpToBB();
- }
-
- protected virtual void Dispose(bool disposing)
- {
- }
-
- #region IDisposable Members
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- #endregion
- }
-
- public class SmokePerf<TKey, TVal> : FwkTest<TKey, TVal>
- {
- //private string bb = "Trim_BB";
- private static readonly DateTime EpochTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
- private static readonly DateTime EpochTimeLocal = EpochTime.ToLocalTime();
- protected TKey[] m_keysA;
- protected int m_maxKeys;
- protected int m_keyIndexBegin;
-
- protected TVal[] m_cValues;
- protected int m_maxValues;
- protected char m_keyType = 'i';
- protected bool m_isObjectRegistered = false;
- protected static List<IDictionary<TKey,TVal>> maps = new List<IDictionary<TKey,TVal>>();
-
- protected const string ClientCount = "clientCount";
- protected const string TimedInterval = "timedInterval";
- protected const string DistinctKeys = "distinctKeys";
- protected const string NumThreads = "numThreads";
- protected const string ValueSizes = "valueSizes";
- protected const string OpsSecond = "opsSecond";
- protected const string KeyType = "keyType";
- protected const string KeySize = "keySize";
- protected const string KeyIndexBegin = "keyIndexBegin";
- protected const string RegisterKeys = "registerKeys";
- protected const string RegisterRegex = "registerRegex";
- protected const string UnregisterRegex = "unregisterRegex";
- protected const string ExpectedCount = "expectedCount";
- protected const string InterestPercent = "interestPercent";
- protected const string KeyStart = "keyStart";
- protected const string KeyEnd = "keyEnd";
-
- #region Protected methods
-
- protected void ClearKeys()
- {
- if (m_keysA != null)
- {
- for (int i = 0; i < m_keysA.Length; i++)
- {
- if (m_keysA[i] != null)
- {
- //m_keysA[i].Dispose();
- m_keysA[i] = default(TKey);
- }
- }
- m_keysA = null;
- m_maxKeys = 0;
- }
- }
- protected int InitKeys(bool useDefault, bool useAllClientID)
- {
- string typ = GetStringValue(KeyType); // int is only value to use
- char newType = (typ == null || typ.Length == 0) ? 's' : typ[0];
-
- int low = GetUIntValue(KeyIndexBegin);
- low = (low > 0) ? low : 0;
- //ResetKey(DistinctKeys);
- int numKeys = GetUIntValue(DistinctKeys); // check distinct keys first
- if (numKeys <= 0)
- {
- if (useDefault)
- {
- numKeys = 5000;
- }
- else
- {
- //FwkSevere("Failed to initialize keys with numKeys: {0}", numKeys);
- return numKeys;
- }
- }
- ResetKey("clientCount");
- int numClients = GetUIntValue("clientCount");
- //Int32 id = 0;
- string id = null;
- if (numClients > 0)
- {
- id = Util.ClientId;
- //if (id < 0)
- // id = -id;
- numKeys = numKeys / numClients;
- }
- if (numKeys < 1)
- FwkException("SmokePerf::InitKeys:Key is less than 0 for each client. Provide max number of distinctKeys");
-
- int high = numKeys + low;
- FwkInfo("InitKeys:: numKeys: {0}; low: {1}", numKeys, low);
- if ((newType == m_keyType) && (numKeys == m_maxKeys) &&
- (m_keyIndexBegin == low))
- {
- return numKeys;
- }
-
- ClearKeys();
- m_maxKeys = numKeys;
- m_keyIndexBegin = low;
- m_keyType = newType;
- if (m_keyType == 'i')
- {
- InitIntKeys(low, high);
- }
- else
- {
- int keySize = GetUIntValue(KeySize);
- keySize = (keySize > 0) ? keySize : 10;
- string keyBase = new string('A', keySize);
- InitStrKeys(low, high, keyBase, id, useAllClientID);
- }
- for (int j = 0; j < numKeys; j++)
- {
- int randIndx = Util.Rand(numKeys);
- if (randIndx != j)
- {
- TKey tmp = m_keysA[j];
- m_keysA[j] = m_keysA[randIndx];
- m_keysA[randIndx] = tmp;
- }
- }
- return m_maxKeys;
- }
-
- protected int InitKeys()
- {
- return InitKeys(true, false);
- }
-
- protected void InitStrKeys(int low, int high, string keyBase, string clientId, bool useAllClientID)
- {
- m_keysA = (TKey[])(object) new String[m_maxKeys];
- ResetKey("clientCount");
- int numClients = GetUIntValue("clientCount");
- if (numClients < 0)
- numClients = 0;
- string id = clientId.Substring(clientId.LastIndexOf('.') + 1);
- FwkInfo("m_maxKeys: {0}; low: {1}; high: {2} Client id {3} numClient {4}",
- m_maxKeys, low, high, id, numClients);
- //string id = clientId.Substring(0, clientId.LastIndexOf("."));
- //int epCount = (int)Util.BBGet(FwkTest.JavaServerBB, FwkTest.JavaServerEPCountKey);
- for (int i = low; i < high; i++)
- {
- if (useAllClientID)
- {
- id = Convert.ToString(Util.Rand(1, (numClients + 1)));
- }
- m_keysA[i - low] = (TKey)(object)(keyBase.ToString() +id + i.ToString("D10"));
- //FwkInfo("rjk: generating key {0}", m_keysA[i - low]);
- }
- }
-
- protected void InitIntKeys(int low, int high)
- {
- m_keysA = (TKey[])(object)new Int32[m_maxKeys];
- FwkInfo("m_maxKeys: {0}; low: {1}; high: {2}",
- m_maxKeys, low, high);
- for (int i = low; i < high; i++)
- {
- m_keysA[i - low] = (TKey)(object)i;
- }
- }
- protected int InitBatchKeys(bool useDefault)
- {
- int low = 0;
- //ResetKey(DistinctKeys);
- int numKeys = GetUIntValue(DistinctKeys); // check distinct keys first
- if (numKeys <= 0)
- {
- if (useDefault)
- {
- numKeys = 5000;
- }
- else
- {
- //FwkSevere("Failed to initialize keys with numKeys: {0}", numKeys);
- return numKeys;
- }
- }
- int batchSize = GetUIntValue("BatchSize");
- batchSize = (batchSize <= 0) ? 500 : batchSize;
- int high = 0;
- ClearKeys();
- m_maxKeys = numKeys;
- int batches = numKeys / batchSize;
- m_keysA = (TKey[])(object) new String[m_maxKeys];
- high = batchSize;
- FwkInfo("m_MaxKeys: {0} low: {1} high: {2}", m_maxKeys, low, high);
- for (int i = 0; i < batches; i++)
- {
- for (int j = low; j < high; j++)
- {
- string buf = String.Format("_{0}_{1}", i, j);
- m_keysA[j] = (TKey)(object)buf;
- }
- low += batchSize;
- high += batchSize;
- FwkInfo("low: {0} high: {1}", low, high);
- }
- for (int j = 0; j < numKeys; j++)
- {
- int randIndx = Util.Rand(numKeys);
- if (randIndx != j)
- {
- TKey tmp = m_keysA[j];
- m_keysA[j] = m_keysA[randIndx];
- m_keysA[randIndx] = tmp;
- }
- }
-
- return m_maxKeys;
- }
-
- protected int InitValues(int numKeys)
- {
- return InitValues(numKeys, 0, true);
- }
-
- protected int InitValues(int numKeys, int size, bool useDefault)
- {
- if (size == 0)
- {
- size = GetUIntValue(ValueSizes);
- }
- if (size <= 0)
- {
- if (useDefault)
- {
- size = 55;
- }
- else
- {
- return size;
- }
- }
- return size;
- }
- protected IRegion<TKey, TVal> GetRegion()
- {
- return (IRegion<TKey, TVal>)GetRegion(null);
-
- }
- protected IRegion<TKey, TVal> GetRegion(string regionName)
- {
- IRegion<TKey, TVal> region;
- if (regionName == null)
- {
- regionName = GetStringValue("regionName");
- }
- if (regionName == null)
- {
- region = (IRegion<TKey, TVal>)GetRootRegion();
- if (region == null)
- {
- IRegion<TKey, TVal>[] rootRegions = CacheHelper<TKey, TVal>.DCache.RootRegions<TKey, TVal>();
- if (rootRegions != null && rootRegions.Length > 0)
- {
- region = rootRegions[Util.Rand(rootRegions.Length)];
- }
- }
- }
- else
- {
- region = CacheHelper<TKey, TVal>.GetRegion(regionName);
- }
- return region;
- }
- #endregion
-
- #region private utility methods
-
- public static long GetDateTimeMillis(DateTime dt)
- {
- long numTicks;
- long numMillis, residualTicks;
-
- if (dt.Kind != DateTimeKind.Utc)
- {
- numTicks = dt.Ticks - EpochTimeLocal.Ticks;
- }
- else
- {
- numTicks = dt.Ticks - EpochTime.Ticks;
- }
- numMillis = numTicks / TimeSpan.TicksPerMillisecond;
- residualTicks = numTicks % TimeSpan.TicksPerMillisecond;
- // round-off to nearest millisecond in case of residual ticks
- if ((residualTicks * 2) >= TimeSpan.TicksPerMillisecond)
- {
- ++numMillis;
- }
- return numMillis;
- }
-
- private object SafeBBGet(string bb, string key)
- {
- try
- {
- return Util.BBGet(bb, key);
- }
- catch (Apache.Geode.DUnitFramework.KeyNotFoundException)
- {
- return null;
- }
- }
- private void checkTrimForOps(string msg,StreamWriter sw)
- {
- String st = "";
-
- if (File.Exists("trim.spec"))
- {
- StreamReader sr = File.OpenText("trim.spec");
- st = sr.ReadToEnd();
- sr.Close();
- }
- string regMatch = "trimspec operations start=";
- if (!(Regex.IsMatch(st, regMatch)))
- {
- sw.WriteLine(msg);
- }
- }
-
- private void SetTrimTime(string op)
- {
- SetTrimTime(op, false);
- }
- private void SetTrimTime(string op, bool endTime)
- {
- DateTime startTime;
- string trTime = null;
- string TemptrTime = null;
- TimeSpan diff = new TimeSpan(0, 0, 30);
- if (endTime)
- {
- startTime = DateTime.Now.Subtract(diff);
- //startTime = DateTime.Now;
- trTime = op + "_" + "EndTime";
- TemptrTime = op + "_" + "TempEndTime";
- }
- else
- {
- startTime = DateTime.Now.Add(diff);
- trTime = op + "_" + "StartTime";
- TemptrTime = op + "_" + "TempStartTime";
- }
- //long tnanoSec = startTime.Ticks * (1000000 / TimeSpan.TicksPerMillisecond);
- //long tnanoSec = startTime.ToFileTimeUtc();
- long curruntMillis = GetDateTimeMillis(startTime);
- long trim_Time = 0;
- try
- {
- trim_Time = (long)Util.BBGet("Trim_BB", TemptrTime);
- }
- catch (Apache.Geode.DUnitFramework.KeyNotFoundException)
- {
- FwkInfo("Key not found for Trim_BB {0}", TemptrTime);
- }
- string timeZone = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? TimeZone.CurrentTimeZone.DaylightName : TimeZone.CurrentTimeZone.StandardName;
- string shortTZ = " ";
- for (Int32 i = 0; i < timeZone.Length; i++)
- {
- if (Char.IsUpper(timeZone[i]))
- shortTZ += timeZone[i];
- }
- string timeFormat = startTime.ToString("yyyy/MM/dd HH:mm:ss.FFF") +
- shortTZ + " (" + curruntMillis.ToString() + ")";
- if (trim_Time > 0)
- {
- //if (((tnanoSec > Convert.ToInt64(trim_Time)) && !endTime) || ((tnanoSec < Convert.ToInt64(trim_Time)) && endTime))
- if (((curruntMillis > trim_Time) && !endTime) || ((curruntMillis < trim_Time) && endTime))
- {
- Util.BBSet("Trim_BB", trTime, timeFormat);
- Util.BBSet("Trim_BB", TemptrTime, curruntMillis);
- }
- }
- else
- {
- Util.BBSet("Trim_BB", trTime, timeFormat);
- Util.BBSet("Trim_BB", TemptrTime, curruntMillis);
- }
- }
- private string GetQuery(int i)
- {
- IRegion<TKey,TVal> region = GetRegion();
- int strBatchSize = GetUIntValue("BatchSize");
- int maxkeys = GetUIntValue("distinctKeys");
- if ((maxkeys % strBatchSize) != 0)
- FwkException("Keys does not evenly divide");
- int batches = maxkeys / strBatchSize;
- int batchNum = (i + 1) % batches;
- string query = "SELECT * FROM " + region.FullPath + " obj WHERE obj.batch = " + Convert.ToString(batchNum);
- return query;
- }
- #endregion
-
- #region Public methods
- public static ICacheLoader<TKey,TVal> createCacheLoader()
- {
- return new PerfCacheLoader<TKey, TVal>();
- }
- public static ICacheListener<TKey, TVal> CreateDurableCacheListenerSP()
- {
- return new DurableCacheListener<TKey, TVal>();
- }
- public static ICacheListener<TKey, TVal> CreateLatencyListener()
- {
- return new LatencyListeners<TKey, TVal>(InitPerfStat.perfstat[0]);
- }
-
- public virtual void DoCreateRegion()
- {
- FwkInfo("In DoCreateRegion()");
- try
- {
- if (!m_isObjectRegistered)
- {
- Serializable.RegisterTypeGeneric(PSTObject.CreateDeserializable);
- Serializable.RegisterTypeGeneric(FastAssetAccount.CreateDeserializable);
- Serializable.RegisterTypeGeneric(FastAsset.CreateDeserializable);
- Serializable.RegisterTypeGeneric(BatchObject.CreateDeserializable);
- Serializable.RegisterTypeGeneric(DeltaFastAssetAccount.CreateDeserializable);
- Serializable.RegisterTypeGeneric(DeltaPSTObject.CreateDeserializable);
- m_isObjectRegistered = true;
- }
- IRegion<TKey, TVal> region = CreateRootRegion();
- if (region == null)
- {
- FwkException("DoCreateRegion() could not create region.");
- }
- FwkInfo("DoCreateRegion() Created region '{0}'", region.Name);
- }
- catch (Exception ex)
- {
- FwkException("DoCreateRegion() Caught Exception: {0}", ex);
- }
- FwkInfo("DoCreateRegion() complete.");
- }
-
- public void DoCloseCache()
- {
- FwkInfo("DoCloseCache() Closing cache and disconnecting from" +
- " distributed system.");
- CacheHelper<TKey, TVal>.Close();
- }
-
- public void DoGenerateTrimSpec()
- {
- FwkInfo("In DoGenerateTrimSpec()");
-
- try
- {
- StreamWriter sw = new StreamWriter("trim.spec");
- if (SafeBBGet("Trim_BB", "creates_EndTime") != null)
- {
- string msg = "trimspec creates end=" + (string)SafeBBGet("Trim_BB", "creates_EndTime") + "\n;";
- sw.WriteLine(msg);
- }
- if (SafeBBGet("Trim_BB", "reg_EndTime") != null)
- {
- string msg = "trimspec registerInterests end=" + (string)SafeBBGet("Trim_BB", "reg_EndTime") + "\n;";
- sw.WriteLine(msg);
- }
- if ((SafeBBGet("Trim_BB", "put_StartTime") != null) && (SafeBBGet(
- "Trim_BB", "put_EndTime") != null))
- {
- string msg = "trimspec puts start=" + (string)SafeBBGet("Trim_BB",
- "put_StartTime") + " end=" + (string)SafeBBGet("Trim_BB",
- "put_EndTime") + "\n;";
- sw.WriteLine(msg);
- string msg1 = "trimspec operations start="
- + (string)SafeBBGet("Trim_BB", "put_StartTime") + " end="
- + (string)SafeBBGet("Trim_BB", "put_EndTime") + "\n;";
- sw.WriteLine(msg1);
- //checkTrimForOps(msg1,sw);
- }
- if ((SafeBBGet("Trim_BB", "connects_StartTime") != null) && (SafeBBGet(
- "Trim_BB", "connects_EndTime") != null))
- {
- string msg = "trimspec connects start=" + (string)SafeBBGet("Trim_BB",
- "connects_StartTime") + " end=" + (string)SafeBBGet("Trim_BB",
- "connects_EndTime") + "\n;";
- sw.WriteLine(msg);
- string msg1 = "trimspec operations start=" + SafeBBGet("Trim_BB",
- "connects_StartTime") + " end=" + SafeBBGet("Trim_BB", "connects_EndTime") + "\n;";
- sw.WriteLine(msg1);
- }
- if ((SafeBBGet("Trim_BB", "get_StartTime") != null) && (SafeBBGet(
- "Trim_BB", "get_EndTime") != null))
- {
- string msg = "trimspec gets start=" + (string)SafeBBGet("Trim_BB",
- "get_StartTime") + " end=" + (string)SafeBBGet("Trim_BB",
- "get_EndTime") + "\n;";
- sw.WriteLine(msg);
- string msg1 = "trimspec operations start="
- + (string)SafeBBGet("Trim_BB", "get_StartTime") + " end="
- + (string)SafeBBGet("Trim_BB", "get_EndTime") + "\n;";
- sw.WriteLine(msg1);
- }
- if ((SafeBBGet("Trim_BB", "putgets_StartTime") != null) && (SafeBBGet(
- "Trim_BB", "putgets_EndTime") != null))
- {
- string msg = "trimspec putgets start=" + (string)SafeBBGet("Trim_BB",
- "putgets_StartTime") + " end=" + (string)SafeBBGet("Trim_BB",
- "putgets_EndTime") + "\n;";
- sw.WriteLine(msg);
- string msg1 = "trimspec operations start=" + (string)SafeBBGet("Trim_BB",
- "putgets_StartTime") + " end=" + (string)SafeBBGet("Trim_BB",
- "putgets_EndTime") + "\n;";
- sw.WriteLine(msg1);
- }
- if ((SafeBBGet("Trim_BB", "queries_StartTime") != null) && (SafeBBGet(
- "Trim_BB", "queries_EndTime") != null))
- {
- string msg = "trimspec queries start=" + (string)SafeBBGet("Trim_BB",
- "queries_StartTime") + " end=" + (string)SafeBBGet("Trim_BB",
- "queries_EndTime") + "\n;";
- sw.WriteLine(msg);
- string msg1 = "trimspec operations start="
- + (string)SafeBBGet("Trim_BB", "queries_StartTime") + " end="
- + (string)SafeBBGet("Trim_BB", "queries_EndTime") + "\n;";
- sw.WriteLine(msg1);
- }
- if ((SafeBBGet("Trim_BB", "updates_StartTime") != null) && (SafeBBGet(
- "Trim_BB", "updates_EndTime") != null))
- {
- string msg = "trimspec updates start=" + (string)SafeBBGet("Trim_BB",
- "updates_StartTime") + " end=" + (string)SafeBBGet("Trim_BB",
- "updates_EndTime") + "\n;";
- sw.WriteLine(msg);
- string msg1 = "trimspec operations start="
- + (string)SafeBBGet("Trim_BB", "updates_StartTime") + " end="
- + (string)SafeBBGet("Trim_BB", "updates_EndTime") + "\n;";
- sw.WriteLine(msg1);
- }
- sw.Close();
- }
- catch (Exception ex)
- {
- FwkException("DoGenerateTrimSpec() Caught Exception: {0}", ex);
- }
-
- }
- public void DoOpenStatistic()
- {
- FwkInfo("In DoOpenStatistic()");
- try
- {
- CreateCacheConnect();
- ResetKey(NumThreads);
- int numThreads = GetUIntValue(NumThreads);
- numThreads = (numThreads < 0) ? 1 : numThreads;
- InitPerfStat initStat = new InitPerfStat();
- RunTask(initStat, numThreads, 0, -1, -1, null);
- Thread.Sleep(3000);
- }
- catch (Exception ex)
- {
- FwkException("DoOpenStatistic() Caught Exception: {0}", ex);
- }
- }
- public void DoCloseStatistic()
- {
- FwkInfo("In DoCloseStatistic()");
- try
- {
- for (int i = 0; i < InitPerfStat.perfstat.Length; i++)
- {
- InitPerfStat.perfstat[i] = null;
- }
- FwkInfo("Closed statistics");
- }
- catch (Exception ex)
- {
- FwkException("DoCloseStatistic() Caught Exception: {0}", ex);
- }
- }
- public virtual void DoCreatePool()
- {
- FwkInfo("In DoCreatePool()");
- try
- {
- CreatePool();
- }
- catch (Exception ex)
- {
- FwkException("DoCreatePool() Caught Exception: {0}", ex);
- }
- FwkInfo("DoCreatePool() complete.");
- }
-
- public void DoRegisterAllKeys()
- {
- FwkInfo("In DoRegisterAllKeys()");
- try
- {
- IRegion<TKey, TVal> region = GetRegion();
- FwkInfo("DoRegisterAllKeys() region name is {0}", region.Name);
- ResetKey("getInitialValues");
- bool isGetInitialValues = GetBoolValue("getInitialValues");
- bool checkReceiveVal = GetBoolValue("checkReceiveVal");
- bool isReceiveValues = true;
- if (checkReceiveVal)
- {
- ResetKey("receiveValue");
- isReceiveValues = GetBoolValue("receiveValue");
- }
- region.GetSubscriptionService().RegisterAllKeys(false, null, isGetInitialValues, isReceiveValues);
- SetTrimTime("reg", true);
- }
- catch (Exception ex)
- {
- FwkException("DoRegisterAllKeys() Caught Exception: {0}", ex);
- }
- FwkInfo("DoRegisterAllKeys() complete.");
- }
-
- public void DoPopulateRegion()
- {
- FwkInfo("In DoPopulateRegion()");
- try
- {
- IRegion<TKey, TVal> region = GetRegion();
- ResetKey(DistinctKeys);
- ResetKey(ValueSizes);
- int numKeys = InitKeys();
- int size = GetUIntValue(ValueSizes);
- ResetKey("ObjectType");
- string objectname = GetStringValue("ObjectType");
- ResetKey("encodeKey");
- ResetKey("encodeTimestamp");
- ResetKey(NumThreads);
- ResetKey("AssetAccountSize");
- ResetKey("AssetMaxVal");
- ResetKey("isMainWorkLoad");
- bool encodeKey = GetBoolValue("encodeKey");
- bool encodeTimestamp = GetBoolValue("encodeTimestamp");
- bool mainworkLoad = GetBoolValue("isMainWorkLoad");
- int assetAccountSize = GetUIntValue("AssetAccountSize");
- if (assetAccountSize < 0)
- assetAccountSize = 0;
- int assetMaxVal = GetUIntValue("AssetMaxVal");
- if (assetMaxVal < 0)
- assetMaxVal = 0;
- CreateTasks<TKey, TVal> creates = new CreateTasks<TKey, TVal>(region, m_keysA, size, objectname, encodeKey,
- encodeTimestamp, mainworkLoad, assetAccountSize, assetMaxVal);
- FwkInfo("Populating region.");
- RunTask(creates, 1, m_maxKeys, -1, -1, null);
- FwkInfo("Populated region.");
- SetTrimTime("creates", true);
- }
- catch (Exception ex)
- {
- FwkException("DoPopulateRegion() Caught Exception: {0}", ex);
- }
- FwkInfo("DoPopulateRegion() complete.");
- }
-
- public void DoPuts()
- {
- FwkInfo("In DoPuts()");
- try
- {
- IRegion<TKey, TVal> region = GetRegion();
- int numClients = GetUIntValue(ClientCount);
- int timedInterval = GetTimeValue(TimedInterval) * 1000;
- if (timedInterval <= 0)
- {
- timedInterval = 5000;
- }
- int maxTime = 10 * timedInterval;
-
- // Loop over key set sizes
- ResetKey("encodeKey");
- ResetKey("encodeTimestamp");
- ResetKey("ObjectType");
- bool encodeKey = GetBoolValue("encodeKey");
- bool encodeTimestamp = GetBoolValue("encodeTimestamp");
- string objectname = GetStringValue("ObjectType");
- ResetKey("isMainWorkLoad");
- bool mainworkLoad = GetBoolValue("isMainWorkLoad");
- ResetKey("distinctKeys");
- ResetKey("BatchSize");
- ResetKey("opsSecond");
- int opsSec = GetUIntValue("opsSecond");
- opsSec = (opsSec < 1) ? 0 : opsSec;
- int numKeys;
- ClientTask puts = null;
- while ((numKeys = InitKeys(false, true)) > 0)
- { // keys loop
- // Loop over value sizes
- ResetKey(ValueSizes);
- int valSize;
- while ((valSize = InitValues(numKeys, 0, false)) > 0)
- { // value loop
- // Loop over threads
- ResetKey(NumThreads);
- int numThreads;
- while ((numThreads = GetUIntValue(NumThreads)) > 0)
- {
- if (opsSec > 0)
- {
- puts = new MeteredPutTask<TKey, TVal>(region, m_keysA, valSize,
- objectname, encodeKey, encodeTimestamp, mainworkLoad, opsSec);
- }
- else
- {
- puts = new PutTasks<TKey, TVal>(region, m_keysA, valSize,
- objectname, encodeKey, encodeTimestamp, mainworkLoad);
- }
- try
- {
- SetTrimTime("put");
- RunTask(puts, numThreads, -1, timedInterval, maxTime, null);
- SetTrimTime("put", true);
- }
- catch (ClientTimeoutException)
- {
- FwkException("In DoPuts() Timed run timed out.");
- }
-
- // real work complete for this pass thru the loop
-
- Thread.Sleep(3000); // Put a marker of inactivity in the stats
- }
- Thread.Sleep(3000); // Put a marker of inactivity in the stats
- } // value loop
- Thread.Sleep(3000); // Put a marker of inactivity in the stats
- } // keys loop
- }
- catch (Exception ex)
- {
- FwkException("DoPuts() Caught Exception: {0}", ex);
- }
- Thread.Sleep(3000); // Put a marker of inactivity in the stats
- FwkInfo("DoPuts() complete.");
- }
-
- public void DoGets()
- {
- FwkInfo("In DoGets()");
- try
- {
- IRegion<TKey, TVal> region = GetRegion();
- int numClients = GetUIntValue(ClientCount);
- int timedInterval = GetTimeValue(TimedInterval) * 1000;
- if (timedInterval <= 0)
- {
- timedInterval = 5000;
- }
- int maxTime = 10 * timedInterval;
-
- ResetKey(DistinctKeys);
- InitKeys(false, true);
-
- int valSize = GetUIntValue(ValueSizes);
-
- // Loop over threads
- ResetKey(NumThreads);
- int numThreads;
- ResetKey("isMainWorkLoad");
- bool mainworkLoad = GetBoolValue("isMainWorkLoad");
-
- while ((numThreads = GetUIntValue(NumThreads)) > 0)
- { // thread loop
-
- // And we do the real work now
- GetTask<TKey, TVal> gets = new GetTask<TKey, TVal>(region, m_keysA, mainworkLoad);
- try
- {
- SetTrimTime("get");
- RunTask(gets, numThreads, -1, timedInterval, maxTime, null);
- SetTrimTime("get", true);
- }
- catch (ClientTimeoutException)
- {
- FwkException("In DoGets() Timed run timed out.");
- }
-
- Thread.Sleep(3000);
- } // thread loop
- }
- catch (Exception ex)
- {
- FwkException("DoGets() Caught Exception: {0}", ex);
- }
- Thread.Sleep(3000);
- FwkInfo("DoGets() complete.");
- }
-
- public void DoCyclePoolTask()
- {
-
- FwkInfo("In Smokeperf::DoCyclePoolTask");
- try
- {
- int timedInterval = GetUIntValue("timedInterval");
- if (timedInterval <= 0)
- {
- timedInterval = 5;
- }
- ResetKey("isMainWorkLoad");
- bool mainworkLoad = GetBoolValue("isMainWorkLoad");
- int sleepMs = GetTimeValue("sleepMs");
- DateTime now = DateTime.Now;
- DateTime end = now.AddSeconds(timedInterval);
- //PoolFactory pf = CreatePoolFactoryAndSetAttribute();
- ResetKey("poolSpec");
- string poolRegionData = GetStringValue("poolSpec");
- //poolRegionData = poolRegionData + "New";
- //Properties prop = GetNewPoolAttributes(poolRegionData);
- string poolName = null;
- PoolFactory pf = PoolManager.CreateFactory();
- SetPoolAttributes(pf, poolRegionData, ref poolName);
- long startTime;
- SetTrimTime("connects");
- while (now < end)
- {
- startTime = InitPerfStat.perfstat[0].StartConnect();
- Pool pool = pf.Create(poolName);
- //FwkInfo("rjk: durable client id is {0}", DistributedSystem.SystemProperties.DurableClientId);
- if (pool != null)
- {
- pool.Destroy();
- }
- InitPerfStat.perfstat[0].EndConnect(startTime, mainworkLoad);
- Thread.Sleep(sleepMs);
- now = DateTime.Now;
- }
- SetTrimTime("connects", true);
- }
- catch (Exception ex)
- {
- FwkException("Smokeperf::DoCyclePoolTask FAILED -- caught exception: {0}", ex);
- }
- FwkInfo("DoCyclePoolTask() complete.");
- }
- // BridgeConnection ( old endpoint) related task is depricated in the product. so no use of this Method
- // Used in perf073,075,100.
- public void DoCycleBridgeConnectionTask()
- {
- FwkInfo("In Smokeperf::DoCycleBridgeConnectionTask");
- string name = GetStringValue("regionName");
- if (name.Length <= 0)
- {
- FwkException("Region name not specified in test.");
- }
- ResetKey("isMainWorkLoad");
- bool mainworkLoad = GetBoolValue("isMainWorkLoad");
- try
- {
- int timedInterval = GetUIntValue("timedInterval");
- if (timedInterval <= 0)
- {
- timedInterval = 5;
- }
- int sleepMs = GetTimeValue("sleepMs");
- DateTime now = DateTime.Now;
- DateTime end = now.AddSeconds(timedInterval);
- long startTime;
- SetTrimTime("connects");
- while (now < end)
- {
- startTime = InitPerfStat.perfstat[0].StartConnect();
- IRegion<TKey, TVal> region = CreateRootRegion();
- region.GetLocalView().DestroyRegion();
- InitPerfStat.perfstat[0].EndConnect(startTime, mainworkLoad);
- Thread.Sleep(sleepMs);
- now = DateTime.Now;
- }
- SetTrimTime("connects", true);
- }
- catch (Exception ex)
- {
- FwkException("Smokeperf::DoCycleBridgeConnectionTask FAILED -- caught exception: {0}", ex);
- }
- FwkInfo("DoCycleBridgeConnectionTask() complete.");
- }
-
- public void DoMixPutGetDataTask()
- {
- FwkInfo("In DoMixPutGetDataTask()");
- try
- {
- IRegion<TKey, TVal> region = GetRegion();
- int numClients = GetUIntValue(ClientCount);
- int timedInterval = GetTimeValue(TimedInterval) * 1000;
- if (timedInterval <= 0)
- {
- timedInterval = 5000;
- }
- int maxTime = 10 * timedInterval;
-
- // Loop over key set sizes
- ResetKey("encodeKey");
- ResetKey("encodeTimestamp");
- ResetKey("ObjectType");
- bool encodeKey = GetBoolValue("encodeKey");
- bool encodeTimestamp = GetBoolValue("encodeTimestamp");
- string objectname = GetStringValue("ObjectType");
- ResetKey("putPercentage");
- int putPercentage = GetUIntValue("putPercentage");
- ResetKey("isMainWorkLoad");
- bool mainworkLoad = GetBoolValue("isMainWorkLoad");
- ResetKey("distinctKeys");
- int numKeys;
- while ((numKeys = InitKeys(false, true)) > 0)
- { // keys loop
- // Loop over value sizes
- ResetKey(ValueSizes);
- int valSize;
- while ((valSize = InitValues(numKeys, 0, false)) > 0)
- { // value loop
- // Loop over threads
- ResetKey(NumThreads);
- int numThreads;
- while ((numThreads = GetUIntValue(NumThreads)) > 0)
- {
- PutGetMixTask<TKey, TVal> putGet = new PutGetMixTask<TKey, TVal>(region, m_keysA, valSize, objectname, encodeKey,
- encodeTimestamp, mainworkLoad, putPercentage);
-
- try
- {
- SetTrimTime("putgets");
- RunTask(putGet, numThreads, -1, timedInterval, maxTime, null);
- SetTrimTime("putgets", true);
- }
- catch (ClientTimeoutException)
- {
- FwkException("In DoMixPutGetDataTask() Timed run timed out.");
- }
-
- // real work complete for this pass thru the loop
-
- Thread.Sleep(3000); // Put a marker of inactivity in the stats
- }
- Thread.Sleep(3000); // Put a marker of inactivity in the stats
- } // value loop
- Thread.Sleep(3000); // Put a marker of inactivity in the stats
- } // keys loop
- }
- catch (Exception ex)
- {
- FwkException("DoMixPutGetDataTask() Caught Exception: {0}", ex);
- }
- Thread.Sleep(3000); // Put a marker of inactivity in the stats
- FwkInfo("DoMixPutGetDataTask() complete.");
- }
-
- public void DoQueryRegionDataTask()
- {
- FwkInfo("In Smokeperf::DoQueryRegionDataTask()");
-
- try
- {
- IRegion<TKey, TVal> region = GetRegion();
- int numClients = GetUIntValue(ClientCount);
- int timedInterval = GetTimeValue(TimedInterval) * 1000;
- if (timedInterval <= 0)
- {
- timedInterval = 5000;
- }
- int maxTime = 10 * timedInterval;
-
-
- // Loop over key set sizes
- ResetKey("query");
- string queryStr = GetStringValue("query"); // set the query string in xml
- if (queryStr.Length <= 0)
- queryStr = "select distinct * from " + region.FullPath;
- ResetKey(NumThreads);
- int numThreads;
- while ((numThreads = GetUIntValue(NumThreads)) > 0)
- { // thread loop
- RegionQueryTask<TKey, TVal> query = new RegionQueryTask<TKey, TVal>(region, queryStr);
- SetTrimTime("queries");
- RunTask(query, numThreads, -1, timedInterval, maxTime, null);
- SetTrimTime("queries", true);
- Thread.Sleep(3000);
- } // thread loop
- }
- catch (Exception ex)
- {
- FwkException("Smokeperf::DoQueryRegionDataTask() Caught Exception: {0}", ex);
- }
- FwkInfo("Smokeperf::DoQueryRegionDataTask() complete.");
- }
-
- public void DoRegisterCQs()
- {
- FwkInfo("In Smokeperf::DoRegisterCQs()");
-
- try
- {
- IRegion<TKey, TVal> region = GetRegion();
- int numCQ = GetUIntValue("numCQs");
- numCQ = (numCQ <= 0) ? 1 : numCQ;
- for (int i = 0; i < numCQ; i++)
- {
- string cqname = String.Format("cq{0}", i);
- string query = GetQuery(i);
- Pool pool = PoolManager.Find("_Test_Pool1");
- QueryService<TKey, object> qs = null;// pool.GetQueryService<TKey, object>(); //rjk to do fixed
- CqAttributesFactory<TKey, object> cqFac = new CqAttributesFactory<TKey, object>();
- ICqListener<TKey, object> cqLstner = new CQLatencyListener<TKey, TVal>(InitPerfStat.perfstat[0]);
- cqFac.AddCqListener(cqLstner);
- CqAttributes<TKey, object> cqAttr = cqFac.Create();
- FwkInfo("Registering CQ named {0} with query: {1}", cqname, query);
- CqQuery<TKey, object> qry = qs.NewCq(cqname, query, cqAttr, false);
- ISelectResults<object> results = qry.ExecuteWithInitialResults(300);
-
- FwkInfo("Successfully executed CQ named {0}", cqname);
- }
-
- }
- catch (Exception ex)
- {
- FwkException("Smokeperf::DoRegisterCQs() Caught Exception: {0}", ex);
- }
- FwkInfo("Smokeperf::DoRegisterCQs() complete.");
- }
-
- public void DoPutBatchObj()
- {
- FwkInfo("In DoPutBatchObj()");
- try
- {
- IRegion<TKey, TVal> region = GetRegion();
- int numClients = GetUIntValue(ClientCount);
- int timedInterval = GetTimeValue(TimedInterval) * 1000;
- if (timedInterval <= 0)
- {
- timedInterval = 5000;
- }
- int maxTime = 10 * timedInterval;
-
- // Loop over key set sizes
- ResetKey("encodeKey");
- ResetKey("encodeTimestamp");
- ResetKey("ObjectType");
- bool encodeKey = GetBoolValue("encodeKey");
- bool encodeTimestamp = GetBoolValue("encodeTimestamp");
- string objectname = GetStringValue("ObjectType");
- int putPercentage = GetUIntValue("putPercentage");
- ResetKey("isMainWorkLoad");
- bool mainworkLoad = GetBoolValue("isMainWorkLoad");
- ResetKey("distinctKeys");
- ResetKey("BatchSize");
- int batchsize = GetUIntValue("BatchSize");
- int numKeys = 0;
- if (batchsize > 0)
- numKeys = InitBatchKeys(false);
- else
- numKeys = InitKeys(false, true);
- while (numKeys > 0)
- { // keys loop
- // Loop over value sizes
- ResetKey(ValueSizes);
- int valSize;
- while ((valSize = InitValues(numKeys, 0, false)) > 0)
- { // value loop
- // Loop over threads
- ResetKey(NumThreads);
- int numThreads;
- while ((numThreads = GetUIntValue(NumThreads)) > 0)
- {
- PutBatchObjectTask<TKey, TVal> puts = new PutBatchObjectTask<TKey, TVal>(region, m_keysA, valSize, objectname,
- encodeKey, encodeTimestamp, mainworkLoad, batchsize, valSize);
-
- try
- {
- bool isCreate = GetBoolValue("isCreate");
- if (isCreate)
- {
- FwkInfo("Creating entries.");
- RunTask(puts, 1, m_maxKeys, -1, -1, null);
- }
- else
- {
- SetTrimTime("put");
- RunTask(puts, numThreads, -1, timedInterval, maxTime, null);
- SetTrimTime("put", true);
- }
- }
- catch (ClientTimeoutException)
- {
- FwkException("In DoPutBatchObj() Timed run timed out.");
- }
-
- // real work complete for this pass thru the loop
-
- }
-
- } // value loop
- batchsize = GetUIntValue("BatchSize");
- if (batchsize > 0)
- numKeys = InitBatchKeys(false);
- else
- numKeys = InitKeys(false, true);
- if (numKeys > 0)
- {
- Thread.Sleep(3000); // Put a marker of inactivity in the stats
- }
- } // keys loop
-
- }
- catch (Exception ex)
- {
- FwkException("DoPutBatchObj() Caught Exception: {0}", ex);
- }
- Thread.Sleep(3000); // Put a marker of inactivity in the stats
- FwkInfo("DoPutBatchObj() complete.");
- }
-
- public void DoCycleDurableClientTask()
- {
- FwkInfo("In Smokeperf::DoCycleDurableClientTask()");
- //resetValue("isMainWorkLoad");
- //bool mainworkLoad = getBoolValue("isMainWorkLoad");
- try
- {
- int timedInterval = GetTimeValue("timedInterval");
- if (timedInterval <= 0)
- {
- timedInterval = 5;
- }
- ResetKey("isDurableReg");
- //ResetKey("poolName");
- bool isDurable = GetBoolValue("isDurableReg");
- //string poolName = GetStringValue("poolName");
- //if (poolName.Length <= 0)
- // poolName = "_Test_Pool1";
- DateTime now = DateTime.Now;
- DateTime end = now.AddSeconds(timedInterval);
- long startTime;
- SetTrimTime("connects");
- while (now < end)
- {
- startTime = InitPerfStat.perfstat[0].StartConnect();
- DoCreatePool();
- ResetKey("regionSpec");
- DoCreateRegion();
- IRegion<TKey, TVal> region = GetRegion();
- region.GetSubscriptionService().RegisterRegex(".*", isDurable);
- CacheHelper<TKey, TVal>.DCache.ReadyForEvents();
- InitPerfStat.perfstat[0].EndConnect(startTime, false);
- string oper_cnt_key = string.Format("ClientName_{0}", Util.ClientNum);
- int cur_cnt = (int)Util.BBGet("DURABLEBB", oper_cnt_key);
- InitPerfStat.perfstat[0].IncUpdateEvents(cur_cnt);
- InitPerfStat.perfstat[0].SetOpTime(InitPerfStat.perfstat[0].GetConnectTime());
- InitPerfStat.perfstat[0].SetOps(cur_cnt + InitPerfStat.perfstat[0].GetOps());
- CacheHelper<TKey, TVal>.DCache.Close(true);
- //pool->destroy();
- region = null;
- CacheHelper<TKey, TVal>.DCache = null;
- //CacheHelper.SetDCacheNull();
- Thread.Sleep(10000);
- now = DateTime.Now;
- }
- SetTrimTime("connects", true);
- }
- catch (Exception ex)
- {
- FwkException("Smokeperf::DoCycleDurableClientTask FAILED -- caught exception: {0}", ex);
- }
- }
- public void DoCreateEntryMapTask()
- {
-
- FwkInfo("In Smokeperf::DoCreateEntryMapTask()");
-
- try
- {
- IRegion<TKey, TVal> region = GetRegion();
- int timedInterval = GetTimeValue("timedInterval");
- if (timedInterval <= 0)
- {
- timedInterval = 5;
- }
- // Loop over key set sizes
- ResetKey("encodeKey");
- ResetKey("encodeTimestamp");
- ResetKey("ObjectType");
- bool encodeKey = GetBoolValue("encodeKey");
- bool encodeTimestamp = GetBoolValue("encodeTimestamp");
- string objectname = GetStringValue("ObjectType");
- ResetKey("isMainWorkLoad");
- bool mainworkLoad = GetBoolValue("isMainWorkLoad");
- ResetKey("distinctKeys");
- int numKeys = InitKeys(false, true);
- ResetKey("valueSizes");
- int valSize = InitValues(numKeys, 0, false);
- ResetKey("numThreads");
- int numThreads = GetUIntValue("numThreads");
- CreatePutAllMap<TKey, TVal> createMap = new CreatePutAllMap<TKey, TVal>(region, m_keysA,
- valSize, objectname, maps, encodeKey, encodeTimestamp,
- mainworkLoad);
-
- FwkInfo("Running timed task.");
- RunTask(createMap, numThreads, m_maxKeys, -1, -1, null);
-
- }
- catch (Exception ex)
- {
- FwkException("Smokeperf::DoCreateEntryMapTask() Caught Exception: {0}", ex);
- }
- ClearKeys();
- Thread.Sleep(3); // Put a marker of inactivity in the stats
- FwkInfo("Smokeperf::createEntryMapTask() complete.");
- }
-
- public void DoPutAllEntryMapTask()
- {
- FwkInfo("In DoPutAllEntryMapTask()");
- try
- {
- IRegion<TKey, TVal> region = GetRegion();
- int numClients = GetUIntValue(ClientCount);
- int timedInterval = GetTimeValue(TimedInterval) * 1000;
- if (timedInterval <= 0)
- {
- timedInterval = 5000;
- }
- int maxTime = 10 * timedInterval;
-
- // Loop over key set sizes
- ResetKey("encodeKey");
- ResetKey("encodeTimestamp");
- ResetKey("ObjectType");
- bool encodeKey = GetBoolValue("encodeKey");
- bool encodeTimestamp = GetBoolValue("encodeTimestamp");
- string objectname = GetStringValue("ObjectType");
- ResetKey("isMainWorkLoad");
- bool mainworkLoad = GetBoolValue("isMainWorkLoad");
- ResetKey("distinctKeys");
- ResetKey("BatchSize");
- ResetKey("opsSecond");
- int opsSec = GetUIntValue("opsSecond");
- opsSec = (opsSec < 1) ? 0 : opsSec;
- int numKeys = InitKeys(false, true);
- ResetKey(ValueSizes);
- int valSize = InitValues(numKeys, 0, false);
-
- ResetKey(NumThreads);
- int numThreads = GetUIntValue(NumThreads);
- CreatePutAllMap<TKey, TVal> createMap = new CreatePutAllMap<TKey, TVal>(region, m_keysA,
- valSize, objectname, maps, encodeKey, encodeTimestamp,
- mainworkLoad);
-
- FwkInfo("Running timed task.");
- RunTask(createMap, numThreads, m_maxKeys, -1, -1, null);
-
- PutAllMap<TKey, TVal> putall = new PutAllMap<TKey, TVal>(region, m_keysA, valSize, objectname, maps, encodeKey,
- encodeTimestamp, mainworkLoad);
-
-
- try
- {
- SetTrimTime("put");
- RunTask(putall, numThreads, -1, timedInterval, maxTime, null);
- SetTrimTime("put", true);
- }
- catch (ClientTimeoutException)
- {
- FwkException("In DoPutAllEntryMapTask() Timed run timed out.");
- }
-
- }
- catch (Exception ex)
- {
- FwkException("DoPutAllEntryMapTask() Caught Exception: {0}", ex);
- }
- Thread.Sleep(3000); // Put a marker of inactivity in the stats
- FwkInfo("DoPutAllEntryMapTask() complete.");
- }
- public void DoUpdateDeltaData()
- {
- FwkInfo("In DoUpdateDeltaData()");
- try
- {
- IRegion<TKey, TVal> region = GetRegion();
- int numClients = GetUIntValue(ClientCount);
- int timedInterval = GetTimeValue(TimedInterval) * 1000;
- if (timedInterval <= 0)
- {
- timedInterval = 5000;
- }
- int maxTime = 10 * timedInterval;
-
- // Loop over key set sizes
- ResetKey("encodeKey");
- ResetKey("encodeTimestamp");
- ResetKey("ObjectType");
- bool encodeKey = GetBoolValue("encodeKey");
- bool encodeTimestamp = GetBoolValue("encodeTimestamp");
- string objectname = GetStringValue("ObjectType");
- ResetKey("isMainWorkLoad");
- bool mainworkLoad = GetBoolValue("isMainWorkLoad");
- ResetKey("distinctKeys");
- ResetKey("BatchSize");
- ResetKey("opsSecond");
- ResetKey("AssetAccountSize");
- ResetKey("AssetMaxVal");
- int assetAccountSize = GetUIntValue("AssetAccountSize");
- if (assetAccountSize < 0)
- assetAccountSize = 0;
- int assetMaxVal = GetUIntValue("AssetMaxVal");
- if (assetMaxVal < 0)
- assetMaxVal = 0;
- int numKeys;
- while ((numKeys = InitKeys(false, true)) > 0)
- { // keys loop
- // Loop over value sizes
- ResetKey(ValueSizes);
- int valSize;
- while ((valSize = InitValues(numKeys, 0, false)) > 0)
- { // value loop
- // Loop over threads
- ResetKey(NumThreads);
- int numThreads;
- while ((numThreads = GetUIntValue(NumThreads)) > 0)
- {
- UpdateDeltaTask<TKey, TVal> puts = new UpdateDeltaTask<TKey, TVal>(region, m_keysA, valSize, objectname, encodeKey,
- encodeTimestamp, mainworkLoad, assetAccountSize, assetMaxVal);
- try
- {
- SetTrimTime("updates");
- RunTask(puts, numThreads, -1, timedInterval, maxTime, null);
- SetTrimTime("updates", true);
- }
- catch (ClientTimeoutException)
- {
- FwkException("In DoUpdateDeltaData() Timed run timed out.");
- }
-
- // real work complete for this pass thru the loop
-
- Thread.Sleep(3000); // Put a marker of inactivity in the stats
- }
- Thread.Sleep(3000); // Put a marker of inactivity in the stats
- } // value loop
- Thread.Sleep(3000); // Put a marker of inactivity in the stats
- } // keys loop
- }
- catch (Exception ex)
- {
- FwkException("DoUpdateDeltaData() Caught Exception: {0}", ex);
- }
- Thread.Sleep(3000); // Put a marker of inactivity in the stats
- FwkInfo("DoUpdateDeltaData() complete.");
- }
- #endregion
- }
-}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cli/NewFwkLib/SmokePerf/SmokeTasks.cs
----------------------------------------------------------------------
diff --git a/src/tests/cli/NewFwkLib/SmokePerf/SmokeTasks.cs b/src/tests/cli/NewFwkLib/SmokePerf/SmokeTasks.cs
deleted file mode 100644
index 0935e0f..0000000
--- a/src/tests/cli/NewFwkLib/SmokePerf/SmokeTasks.cs
+++ /dev/null
@@ -1,829 +0,0 @@
-/*
- * 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.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Threading;
-using Apache.Geode.Client.Tests;
-using Apache.Geode.DUnitFramework;
-
-namespace Apache.Geode.Client.FwkLib
-{
- using Apache.Geode.Client;
- //using Region = Apache.Geode.Client.IRegion<Object, Object>;
- public class InitPerfStat : ClientTask
- {
- public Int32 m_cnt;
- public static PerfStat[] perfstat = new PerfStat[10];
- public InitPerfStat()
- : base()
- {
- m_cnt = 0;
- }
-
- public override void DoTask(int iters, object data)
- {
- Int32 localcnt = m_cnt;
- Interlocked.Increment(ref m_cnt);
- perfstat[localcnt] = new PerfStat(Thread.CurrentThread.ManagedThreadId);
- }
- }
-
-
- public class PutAllTask<TKey, TVal> : ClientTask
- {
- #region Private members
-
- private IRegion<TKey, TVal> m_region;
- private TKey[] m_keys;
- private TVal[] m_values;
-
- #endregion
-
- #region Public accessors
-
- public TVal[] Values
- {
- get
- {
- return m_values;
- }
- set
- {
- m_values = value;
- }
- }
-
- #endregion
-
- public PutAllTask(IRegion<TKey, TVal> region, TKey[] keys,
- TVal[] values)
- : base()
- {
- m_region = region as IRegion<TKey, TVal>;
- m_keys = keys as TKey[];
- m_values = values as TVal[];
- }
-
- public override void DoTask(int iters, object data)
- {
- if (m_keys != null && m_keys.Length > 0)
- {
- int numKeys = m_keys.Length;
- int offset = Util.Rand(numKeys);
- int count = offset;
- IDictionary<TKey, TVal> map = new Dictionary<TKey, TVal>();
- //CacheableHashMap map = new CacheableHashMap();
- map.Clear();
- Util.Log("PutAllTask::DoTask: starting {0} iterations.", iters);
- while (Running && (iters-- != 0))
- {
- int idx = count % numKeys;
- try
- {
- map.Add(m_keys[idx], m_values[idx]);
- }
- catch (Exception ex)
- {
- Util.Log(Util.LogLevel.Error,
- "Exception while putting key[{0}] for region {1} in iteration " +
- "{2}: {3}", idx, m_region.Name, (count - offset), ex);
- throw;
- }
- count++;
- }
- DateTime startTime = DateTime.Now;
- m_region.PutAll(map, 60);
- DateTime endTime = DateTime.Now;
- TimeSpan elapsedTime = endTime - startTime;
- FwkTest<TKey, TVal>.CurrentTest.FwkInfo("Time Taken to execute putAll for {0}" +
- " is {1}ms", numKeys, elapsedTime.TotalMilliseconds);
- Interlocked.Add(ref m_iters, count - offset);
- }
- }
- }
- public class GetTask<TKey, TVal> : ClientTask
- {
- #region Private members
-
- private IRegion<TKey, TVal> m_region;
- private TKey[] m_keys;
- bool m_isMainWorkLoad;
- public Int32 m_cnt;
-
- #endregion
-
- public GetTask(IRegion<TKey, TVal> region, TKey[] keys, bool isMainWorkLoad)
- : base()
- {
- m_region = region as IRegion<TKey, TVal>;
- m_keys = keys as TKey[];
- m_isMainWorkLoad = isMainWorkLoad;
- m_cnt = 0;
- }
-
- public override void DoTask(int iters, object data)
- {
- if (m_keys != null && m_keys.Length > 0)
- {
- Int32 localcnt = m_cnt;
- Interlocked.Increment(ref m_cnt);
- int numKeys = m_keys.Length;
- int offset = Util.Rand(numKeys);
- int count = offset;
- long startTime;
- while (Running && (iters-- != 0))
- {
- object val = null;
- int idx = count % numKeys;
- try
- {
- startTime = InitPerfStat.perfstat[localcnt].StartGet();
- val = m_region[m_keys[idx]];
- //val = m_region.Get(m_keys[idx],null);
- InitPerfStat.perfstat[localcnt].EndGet(startTime, m_isMainWorkLoad);
- }
- catch (Exception ex)
- {
- Util.Log(Util.LogLevel.Error,
- "Exception while getting key[{0}] for region {1} in iteration " +
- "{2}: {3}", idx, m_region.Name, (count - offset), ex);
- throw;
- }
- if (val == null)
- {
- string exStr = string.Format("Key[{0}] not found in region {1}",
- m_keys[idx], m_region.Name);
- Util.Log(Util.LogLevel.Error, exStr);
- throw new EntryNotFoundException(exStr);
- }
- count++;
- }
- Interlocked.Add(ref m_iters, count - offset);
- }
- }
- }
-
- public class CreateTasks<TKey, TVal> : ClientTask
- {
- #region Private members
-
- private IRegion<TKey, TVal> m_region;
- private TKey[] m_keys;
- private TVal[] m_values;
- private Int32 m_cnt;
- private Int32 m_size;
- private string m_objectType;
- private bool m_encodeKey;
- private bool m_encodeTimestamp;
- private bool m_isMainWorkLoad;
- private Int32 m_assetAcSize;
- private Int32 m_assetmaxVal;
-
- #endregion
-
- #region Public accessors
-
- public TVal[] Values
- {
- get
- {
- return m_values;
- }
- set
- {
- m_values = value;
- }
- }
-
- #endregion
-
- public CreateTasks(IRegion<TKey, TVal> region, TKey[] keys, Int32 size, string objectType,
- bool encodeKey, bool encodeTimestamp, bool isMainWorkLoad, Int32 assetACsize, Int32 assetMaxVal)
- : base()
- {
- m_region = region as IRegion<TKey, TVal>;
- m_keys = keys as TKey[];
- m_values = null;
- m_cnt = 0;
- m_size = size;
- m_objectType = objectType;
- m_encodeKey = encodeKey;
- m_encodeTimestamp = encodeTimestamp;
- m_isMainWorkLoad = isMainWorkLoad;
- m_assetAcSize = assetACsize;
- m_assetmaxVal = assetMaxVal;
- }
-
- public override void DoTask(int iters, object data)
- {
- if (m_keys != null && m_keys.Length > 0)
- {
- Int32 localcnt = m_cnt;
- Interlocked.Increment(ref m_cnt);
- int numKeys = m_keys.Length;
- int offset = Util.Rand(numKeys);
- int count = offset;
- long startTime;
- Util.Log("CreateTasks::DoTask: starting {0} iterations.", iters);
- while (Running && (iters-- != 0))
- {
- int idx = count % numKeys;
- try
- {
- TVal obj = ObjectHelper<TKey, TVal>.CreateObject(m_objectType, m_size, m_encodeKey,
- m_encodeTimestamp, m_assetAcSize, m_assetmaxVal, idx);
- startTime = InitPerfStat.perfstat[localcnt].StartCreate();
- //Util.Log("Create Keys is {0} object is {1}", m_keys[idx],obj.ToString());
- m_region.Add(m_keys[idx], obj);
- InitPerfStat.perfstat[localcnt].EndCreate(startTime, m_isMainWorkLoad);
- }
- catch (Exception ex)
- {
- Util.Log(Util.LogLevel.Error,
- "Exception while putting key[{0}] for region {1} in iteration " +
- "{2}: {3}", idx, m_region.Name, (count - offset), ex);
- throw;
- }
- count++;
- }
- Interlocked.Add(ref m_iters, count - offset);
- }
- }
- }
-
- public class PutTasks<TKey, TVal> : ClientTask
- {
- #region Private members
-
- private IRegion<TKey, TVal> m_region;
- private TKey[] m_keys;
- private Int32 m_cnt;
- private Int32 m_size;
- private string m_objectType;
- private bool m_encodeKey;
- private bool m_encodeTimestamp;
- private bool m_isMainWorkLoad;
-
- #endregion
-
- public PutTasks(IRegion<TKey, TVal> region, TKey[] keys, Int32 size, string objectType,
- bool encodeKey, bool encodeTimestamp, bool isMainWorkLoad)
- : base()
- {
- m_region = region as IRegion<TKey, TVal>;
- m_keys = keys as TKey[];
- m_cnt = 0;
- m_size = size;
- m_objectType = objectType;
- m_encodeKey = encodeKey;
- m_encodeTimestamp = encodeTimestamp;
- m_isMainWorkLoad = isMainWorkLoad;
- }
-
- public override void DoTask(int iters, object data)
- {
- if (m_keys != null && m_keys.Length > 0)
- {
- Int32 localcnt = m_cnt;
- Interlocked.Increment(ref m_cnt);
- int numKeys = m_keys.Length;
- int offset = Util.Rand(numKeys);
- int count = offset;
- long startTime;
- Util.Log("PutTasks::DoTask: starting {0} iterations.", iters);
- while (Running && (iters-- != 0))
- {
- int idx = count % numKeys;
- try
- {
- TVal obj = ObjectHelper<TKey, TVal>.CreateObject(m_objectType, m_size, m_encodeKey,
- m_encodeTimestamp, 0, 0, 0);
- startTime = InitPerfStat.perfstat[localcnt].StartPut();
- m_region[m_keys[idx]] = obj;//.Put(m_keys[idx], obj);
- InitPerfStat.perfstat[localcnt].EndPut(startTime, m_isMainWorkLoad);
- }
- catch (Exception ex)
- {
- Util.Log(Util.LogLevel.Error,
- "Exception while putting key[{0}] for region {1} in iteration " +
- "{2}: {3}", idx, m_region.Name, (count - offset), ex);
- throw;
- }
- count++;
-
- }
- Interlocked.Add(ref m_iters, count - offset);
- }
- }
- }
-
- public class MeteredPutTask<TKey, TVal> : ClientTask
- {
- #region Private members
-
- private IRegion<TKey, TVal> m_region;
- private TKey[] m_keys;
- private int m_opsSec;
- private Int32 m_cnt;
- private Int32 m_size;
- private string m_objectType;
- private bool m_encodeKey;
- private bool m_encodeTimestamp;
- private bool m_isMainWorkLoad;
-
- #endregion
-
-
- public MeteredPutTask(IRegion<TKey, TVal> region, TKey[] keys, Int32 size, string objectType,
- bool encodeKey, bool encodeTimestamp, bool isMainWorkLoad, int opsSec)
- : base()
- {
- m_region = region as IRegion<TKey, TVal>;
- m_keys = keys as TKey[];
- m_opsSec = opsSec;
- m_cnt = 0;
- m_size = size;
- m_objectType = objectType;
- m_encodeKey = encodeKey;
- m_encodeTimestamp = encodeTimestamp;
- m_isMainWorkLoad = isMainWorkLoad;
- }
-
- public override void DoTask(int iters, object data)
- {
- if (m_keys != null && m_keys.Length > 0)
- {
- Int32 localcnt = m_cnt;
- Interlocked.Increment(ref m_cnt);
- int numKeys = m_keys.Length;
- int offset = Util.Rand(numKeys);
- int count = offset;
- long startTime;
- int idx;
- PaceMeter pm = new PaceMeter(m_opsSec);
- while (Running && (iters-- != 0))
- {
- idx = count % numKeys;
- try
- {
- TVal obj = ObjectHelper<TKey, TVal>.CreateObject(m_objectType, m_size, m_encodeKey,
- m_encodeTimestamp, 0, 0, 0);
- startTime = InitPerfStat.perfstat[localcnt].StartPut();
- m_region[m_keys[idx]] = obj;//.Put(m_keys[idx], obj);
- InitPerfStat.perfstat[localcnt].EndPut(startTime, m_isMainWorkLoad);
- pm.CheckPace();
- }
- catch (Exception ex)
- {
- Util.Log(Util.LogLevel.Error,
- "Exception while putting key[{0}] for region {1} in iteration " +
- "{2}: {3}", idx, m_region.Name, (count - offset), ex);
- throw;
- }
- count++;
- }
- Interlocked.Add(ref m_iters, count - offset);
- }
- }
- }
-
- public class PutGetMixTask<TKey, TVal> : ClientTask
- {
- #region Private members
-
- private IRegion<TKey, TVal> m_region;
- private TKey[] m_keys;
- private Int32 m_cnt;
- private Int32 m_size;
- private string m_objectType;
- private bool m_encodeKey;
- private bool m_encodeTimestamp;
- private bool m_isMainWorkLoad;
- private Int32 m_putPercentage;
-
- #endregion
-
- public PutGetMixTask(IRegion<TKey, TVal> region, TKey[] keys, Int32 size, string objectType,
- bool encodeKey, bool encodeTimestamp, bool isMainWorkLoad,Int32 putpercentage)
- : base()
- {
- m_region = region as IRegion<TKey, TVal>;
- m_keys = keys as TKey[];
- m_cnt = 0;
- m_size = size;
- m_objectType = objectType;
- m_encodeKey = encodeKey;
- m_encodeTimestamp = encodeTimestamp;
- m_isMainWorkLoad = isMainWorkLoad;
- m_putPercentage = putpercentage;
- }
-
- public override void DoTask(int iters, object data)
- {
- if (m_keys != null && m_keys.Length > 0)
- {
- Int32 localcnt = m_cnt;
- Interlocked.Increment(ref m_cnt);
- int numKeys = m_keys.Length;
- int offset = Util.Rand(numKeys);
- int count = offset;
- long startTime;
- Util.Log("PutGetMixTask::DoTask: starting {0} iterations.", iters);
- while (Running && (iters-- != 0))
- {
- int n = Util.Rand(1, 100);
- int idx = count % numKeys;
-
- if (n < m_putPercentage)
- {
- TVal obj = ObjectHelper<TKey, TVal>.CreateObject(m_objectType, m_size, m_encodeKey,
- m_encodeTimestamp, 0, 0, 0);
- startTime = InitPerfStat.perfstat[localcnt].StartPut();
- m_region[m_keys[idx]] = obj;//.Put(m_keys[idx], obj);
- InitPerfStat.perfstat[localcnt].EndPut(startTime, m_isMainWorkLoad);
- }
- else
- {
- TVal val = default(TVal);
- startTime = InitPerfStat.perfstat[localcnt].StartGet();
- val = m_region[m_keys[idx]];
- InitPerfStat.perfstat[localcnt].EndGet(startTime, m_isMainWorkLoad);
-
- if (val == null)
- {
- string exStr = string.Format("Key[{0}] not found in region {1}",
- m_keys[idx], m_region.Name);
- Util.Log(Util.LogLevel.Error, exStr);
- throw new EntryNotFoundException(exStr);
- }
- }
- count++;
- }
- Interlocked.Add(ref m_iters, count - offset);
- }
- }
- }
-
- public class RegionQueryTask<TKey, TVal> : ClientTask
- {
- private IRegion<TKey, TVal> m_region;
- private Int32 m_cnt;
- private string m_queryString;
- public RegionQueryTask(IRegion<TKey, TVal> region, string queryString)
- : base()
- {
- m_region = region as IRegion<TKey, TVal>;
- m_cnt = 0;
- m_queryString = queryString;
- }
-
- public override void DoTask(int iters, object data)
- {
- Int32 localcnt = m_cnt;
- Interlocked.Increment(ref m_cnt);
- int offset = Util.Rand(100);
- int count = offset;
- long startTime;
- while (Running && (iters-- != 0))
- {
- startTime = InitPerfStat.perfstat[localcnt].StartQuery();
- ISelectResults<object> sptr = m_region.Query<object>(m_queryString, 600);
- InitPerfStat.perfstat[localcnt].EndQuery(startTime, false);
- count++;
- }
- Interlocked.Add(ref m_iters, count - offset);
- }
- }
-
- public class PutBatchObjectTask<TKey, TVal> : ClientTask
- {
- #region Private members
-
- private IRegion<TKey, TVal> m_region;
- private TKey[] m_keys;
- private Int32 m_cnt;
- private Int32 m_size;
- private string m_objectType;
- private bool m_encodeKey;
- private bool m_encodeTimestamp;
- private bool m_isMainWorkLoad;
- private Int32 m_batchSize;
- private Int32 m_batchObjSize;
-
- #endregion
-
- public PutBatchObjectTask(IRegion<TKey, TVal> region, TKey[] keys, Int32 size, string objectType,
- bool encodeKey, bool encodeTimestamp, bool isMainWorkLoad,Int32 batchSize, Int32 objsize)
- : base()
- {
- m_region = region as IRegion<TKey, TVal>;
- m_keys = keys as TKey[];
- m_cnt = 0;
- m_size = size;
- m_objectType = objectType;
- m_encodeKey = encodeKey;
- m_encodeTimestamp = encodeTimestamp;
- m_isMainWorkLoad = isMainWorkLoad;
- m_batchSize = batchSize;
- m_batchObjSize = objsize;
- }
-
- public override void DoTask(int iters, object data)
- {
- if (m_keys != null && m_keys.Length > 0)
- {
- Int32 localcnt = m_cnt;
- Interlocked.Increment(ref m_cnt);
- int numKeys = m_keys.Length;
- int offset = Util.Rand(numKeys);
- int count = offset;
- long startTime;
- Util.Log("PutBatchObjectTask::DoTask: starting {0} iterations.", iters);
- while (Running && (iters-- != 0))
- {
- int idx = count % numKeys;
- try
- {
- TVal obj = ObjectHelper<TKey, TVal>.CreateObject(m_objectType, m_size, m_encodeKey, m_encodeTimestamp,
- m_batchSize, m_batchObjSize, idx);
- startTime = InitPerfStat.perfstat[localcnt].StartPut();
- m_region[m_keys[idx]] = obj;
- InitPerfStat.perfstat[localcnt].EndPut(startTime, m_isMainWorkLoad);
- }
- catch (Exception ex)
- {
- Util.Log(Util.LogLevel.Error,
- "Exception while putting key[{0}] for region {1} in iteration " +
- "{2}: {3}", idx, m_region.Name, (count - offset), ex);
- throw;
- }
- count++;
- }
- Interlocked.Add(ref m_iters, count - offset);
- }
- }
- }
-
- public class CreatePutAllMap<TKey, TVal> : ClientTask
- {
- #region Private members
-
- private IRegion<TKey, TVal> m_region;
- private TKey[] m_keys;
- private Int32 m_cnt;
- private Int32 m_size;
- private string m_objectType;
- private List<IDictionary<TKey, TVal>> m_maps;
- private bool m_encodeKey;
- private bool m_encodeTimestamp;
- private bool m_isMainWorkLoad;
-
- #endregion
-
- public CreatePutAllMap(IRegion<TKey, TVal> region, TKey[] keys, Int32 size, string objectType,
- List<IDictionary<TKey, TVal>> maps, bool encodeKey, bool encodeTimestamp, bool isMainWorkLoad)
- : base()
- {
- m_region = region as IRegion<TKey, TVal>;
- m_keys = keys as TKey[];
- m_cnt = 0;
- m_size = size;
- m_objectType = objectType;
- m_maps = maps;
- m_encodeKey = encodeKey;
- m_encodeTimestamp = encodeTimestamp;
- m_isMainWorkLoad = isMainWorkLoad;
- }
-
- public override void DoTask(int iters, object data)
- {
- if (m_keys != null && m_keys.Length > 0)
- {
- Int32 localcnt = m_cnt;
- Interlocked.Increment(ref m_cnt);
- int numKeys = m_keys.Length;
- int offset = Util.Rand(numKeys);
- int count = offset;
- IDictionary<TKey,TVal> hmoc = new Dictionary<TKey,TVal>();
- lock (m_maps)
- {
- m_maps.Add(hmoc);
- }
- Util.Log("CreatePutAllMap::DoTask: starting {0} iterations. size of map list {1}", iters,m_maps.Count);
- while (Running && (iters-- != 0))
- {
- int idx = count % numKeys;
- try
- {
- TVal obj = ObjectHelper<TKey, TVal>.CreateObject(m_objectType, m_size, m_encodeKey, m_encodeTimestamp, 0, 0, 0);
- //Util.Log("rjk CreatePutAllMap key[{0}] is {1}", idx, m_keys[idx]);
- ((IDictionary<object,object>)(m_maps[localcnt])).Add(m_keys[idx], obj);
- }
- catch (Exception ex)
- {
- Util.Log(Util.LogLevel.Error,
- "Exception while putting key[{0}] for region {1} in iteration " +
- "{2}: {3}", idx, m_region.Name, (count - offset), ex);
- throw;
- }
- count++;
- }
- Interlocked.Add(ref m_iters, count - offset);
- }
- }
- }
-
- public class PutAllMap<TKey, TVal> : ClientTask
- {
- #region Private members
-
- private IRegion<TKey, TVal> m_region;
- private TKey[] m_keys;
- private Int32 m_cnt;
- private Int32 m_size;
- private string m_objectType;
- private List<IDictionary<TKey, TVal>> m_maps;
- private bool m_encodeKey;
- private bool m_encodeTimestamp;
- private bool m_isMainWorkLoad;
-
-
- #endregion
-
- public PutAllMap(IRegion<TKey, TVal> region, TKey[] keys, Int32 size, string objectType,
- List<IDictionary<TKey, TVal>> maps, bool encodeKey, bool encodeTimestamp, bool isMainWorkLoad)
- : base()
- {
- m_region = region as IRegion<TKey, TVal>;
- m_keys = keys as TKey[];
- m_cnt = 0;
- m_size = size;
- m_objectType = objectType;
- m_maps = maps as List<IDictionary<TKey, TVal>>;
- m_encodeKey = encodeKey;
- m_encodeTimestamp = encodeTimestamp;
- m_isMainWorkLoad = isMainWorkLoad;
- }
-
- public override void DoTask(int iters, object data)
- {
- if (m_keys != null && m_keys.Length > 0)
- {
- Int32 localcnt = m_cnt;
- Interlocked.Increment(ref m_cnt);
- int numKeys = m_keys.Length;
- int offset = Util.Rand(numKeys);
- int count = offset;
- long startTime;
- Util.Log("PutAllMap::DoTask: starting {0} iterations. size of map list {1}", iters,m_maps.Count);
- while (Running && (iters-- != 0))
- {
- try
- {
- startTime = InitPerfStat.perfstat[localcnt].StartPut();
- /*
- foreach (CacheableHashMap map in m_maps)
- {
- Util.Log("PutAllMap:: mape keys = {0} size ={1}", map.Keys,map.Count);
- }
- CacheableHashMap putAllmap;
- lock (m_maps)
- {
- putAllmap = m_maps[localcnt];
- }
- foreach (ICacheableKey key in putAllmap.Keys)
- {
- Util.Log("PutAllMap:: key = {0} ", key);
- }
- foreach (IGeodeSerializable val in putAllmap.Values)
- {
- Util.Log("PutAllMap:: value = {0} ", val);
- }
-
- foreach (KeyValuePair<ICacheableKey, IGeodeSerializable> item in putAllmap)
- {
- Util.Log("PutAllMap:: key = {0} value = {1} localcont = {2}", item.Key, item.Value, localcnt);
- }
- */
- m_region.PutAll(m_maps[localcnt], 60);
- InitPerfStat.perfstat[localcnt].EndPut(startTime, m_isMainWorkLoad);
-
- }
- catch (Exception ex)
- {
- Util.Log(Util.LogLevel.Error,
- "Exception while putAll map[{0}] for region {1} in iteration " +
- "{2}: {3}", localcnt, m_region.Name, (count - offset), ex);
- throw;
- }
- count++;
- }
- Interlocked.Add(ref m_iters, count - offset);
- }
- }
- }
-
- public class UpdateDeltaTask<TKey, TVal> : ClientTask
- {
- #region Private members
-
- private IRegion<TKey, TVal> m_region;
- private TKey[] m_keys;
- private Int32 m_cnt;
- private Int32 m_size;
- private string m_objectType;
- private bool m_encodeKey;
- private bool m_encodeTimestamp;
- private bool m_isMainWorkLoad;
- private Int32 m_assetAcSize;
- private Int32 m_assetmaxVal;
-
- #endregion
-
- public UpdateDeltaTask(IRegion<TKey, TVal> region, TKey[] keys, Int32 size, string objectType,
- bool encodeKey, bool encodeTimestamp, bool isMainWorkLoad, Int32 assetACsize, Int32 assetMaxVal)
- : base()
- {
- m_region = region as IRegion<TKey, TVal>;
- m_keys = keys as TKey[];
- m_cnt = 0;
- m_size = size;
- m_objectType = objectType;
- m_encodeKey = encodeKey;
- m_encodeTimestamp = encodeTimestamp;
- m_isMainWorkLoad = isMainWorkLoad;
- m_assetAcSize = assetACsize;
- m_assetmaxVal = assetMaxVal;
- }
-
- public override void DoTask(int iters, object data)
- {
- if (m_keys != null && m_keys.Length > 0)
- {
- Int32 localcnt = m_cnt;
- Interlocked.Increment(ref m_cnt);
- int numKeys = m_keys.Length;
- int offset = Util.Rand(numKeys);
- int count = offset;
- long startTime;
- TVal obj = default(TVal);
- Util.Log("UpdateDeltaTask::DoTask: starting {0} iterations.", iters);
- while (Running && (iters-- != 0))
- {
- int idx = count % numKeys;
- startTime = InitPerfStat.perfstat[localcnt].StartUpdate();
- if (m_encodeKey)
- {
- obj = m_region[m_keys[idx]];
- if (obj == null)
- {
- string exStr = string.Format("Key[{0}] has not been created in region {1}",
- m_keys[idx], m_region.Name);
- Util.Log(Util.LogLevel.Error, exStr);
- throw new EntryNotFoundException(exStr);
- }
- }
- else {
- obj = ObjectHelper<TKey, TVal>.CreateObject(m_objectType, m_size, m_encodeKey, m_encodeTimestamp, m_assetAcSize, m_assetmaxVal, idx);
- }
- DeltaFastAssetAccount obj1 = obj as DeltaFastAssetAccount;
- if(obj1 == null)
- {
- DeltaPSTObject obj2 = obj as DeltaPSTObject;
- if (obj2 == null)
- {
- m_region[m_keys[idx]] = obj;
- }
- else{
- obj2.Update();
- }
- }
- else
- {
- obj1.Update();
- }
- InitPerfStat.perfstat[localcnt].EndUpdate(startTime, m_isMainWorkLoad);
- count++;
- }
- Interlocked.Add(ref m_iters, count - offset);
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cli/PkcsWrapper/PkcsAuthInitMN.hpp
----------------------------------------------------------------------
diff --git a/src/tests/cli/PkcsWrapper/PkcsAuthInitMN.hpp b/src/tests/cli/PkcsWrapper/PkcsAuthInitMN.hpp
index 249863a..bf8d665 100644
--- a/src/tests/cli/PkcsWrapper/PkcsAuthInitMN.hpp
+++ b/src/tests/cli/PkcsWrapper/PkcsAuthInitMN.hpp
@@ -20,6 +20,7 @@
#include <memory>
#include "native_shared_ptr.hpp"
#include "PkcsAuthInit.hpp"
+//#include "IAuthInitialize.hpp"
using namespace System;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cli/QueryHelper/QueryHelperN.cs
----------------------------------------------------------------------
diff --git a/src/tests/cli/QueryHelper/QueryHelperN.cs b/src/tests/cli/QueryHelper/QueryHelperN.cs
index d1198a0..3f71876 100644
--- a/src/tests/cli/QueryHelper/QueryHelperN.cs
+++ b/src/tests/cli/QueryHelper/QueryHelperN.cs
@@ -36,7 +36,7 @@ namespace Apache.Geode.Client.Tests
private int m_portfolioNumSets;
private int m_positionSetSize;
private int m_positionNumSets;
-
+ private Cache m_cache;
private static QueryHelper<TKey, TVal> m_instance = null;
#endregion
@@ -77,19 +77,20 @@ namespace Apache.Geode.Client.Tests
#endregion
- private QueryHelper()
+ private QueryHelper(Cache cache)
{
m_portfolioSetSize = 20;
m_portfolioNumSets = 1;
m_positionSetSize = 20;
m_positionNumSets = 1;
+ m_cache = cache;
}
- public static QueryHelper<TKey, TVal> GetHelper()
+ public static QueryHelper<TKey, TVal> GetHelper(Cache cache)
{
if (m_instance == null)
{
- m_instance = new QueryHelper<TKey,TVal>();
+ m_instance = new QueryHelper<TKey,TVal>(cache);
}
return m_instance;
}
@@ -459,8 +460,8 @@ namespace Apache.Geode.Client.Tests
return false;
}
- DataOutput o1 = new DataOutput();
- DataOutput o2 = new DataOutput();
+ DataOutput o1 = m_cache.CreateDataOutput();
+ DataOutput o2 = m_cache.CreateDataOutput();
p1.ToData(o1);
p2.ToData(o2);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cli/QueryHelper/QueryStringsM.cpp
----------------------------------------------------------------------
diff --git a/src/tests/cli/QueryHelper/QueryStringsM.cpp b/src/tests/cli/QueryHelper/QueryStringsM.cpp
index aab1745..f00ac81 100644
--- a/src/tests/cli/QueryHelper/QueryStringsM.cpp
+++ b/src/tests/cli/QueryHelper/QueryStringsM.cpp
@@ -15,10 +15,6 @@
* limitations under the License.
*/
-#include "begin_native.hpp"
-#include <memory>
-#include "end_native.hpp"
-
#include "QueryStringsM.hpp"
#include "impl/ManagedString.hpp"
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cpp/fwklib/FrameworkTest.cpp
----------------------------------------------------------------------
diff --git a/src/tests/cpp/fwklib/FrameworkTest.cpp b/src/tests/cpp/fwklib/FrameworkTest.cpp
index d2af77f..1a1994d 100644
--- a/src/tests/cpp/fwklib/FrameworkTest.cpp
+++ b/src/tests/cpp/fwklib/FrameworkTest.cpp
@@ -338,7 +338,7 @@ void FrameworkTest::localDestroyRegion(RegionPtr& region) {
void FrameworkTest::parseEndPoints(int32_t ep, std::string label,
bool isServer) {
std::string poolName = "_Test_Pool";
- PoolFactoryPtr pfPtr = PoolManager::createFactory();
+ PoolFactoryPtr pfPtr = m_cache->getPoolManager().createFactory();
std::string tag = getStringValue("TAG");
std::string bb("GFE_BB");
@@ -402,14 +402,14 @@ void FrameworkTest::parseEndPoints(int32_t ep, std::string label,
if (!tag.empty()) {
poolName.append(tag);
// check if pool already exists
- pptr = PoolManager::find(poolName.c_str());
+ pptr = m_cache->getPoolManager().find(poolName.c_str());
if (pptr == nullptr) {
pptr = pfPtr->create(poolName.c_str());
}
}
// create default pool
else {
- pptr = PoolManager::find(poolName.c_str());
+ pptr = m_cache->getPoolManager().find(poolName.c_str());
if (pptr == nullptr) {
pptr = pfPtr->create(poolName.c_str());
}
@@ -444,12 +444,12 @@ void FrameworkTest::createPool() {
}
QueryServicePtr FrameworkTest::checkQueryService() {
- PoolFactoryPtr pfPtr = PoolManager::createFactory();
+ PoolFactoryPtr pfPtr = m_cache->getPoolManager().createFactory();
std::string bb("GFE_BB");
std::string keys("testScheme");
std::string mode = bbGetString(bb, keys);
if (mode == "poolwithendpoints" || mode == "poolwithlocator") {
- PoolPtr pool = PoolManager::find("_Test_Pool");
+ PoolPtr pool = m_cache->getPoolManager().find("_Test_Pool");
return pool->getQueryService();
} else {
return m_cache->getQueryService();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/tests/cpp/fwklib/FwkObjects.cpp
----------------------------------------------------------------------
diff --git a/src/tests/cpp/fwklib/FwkObjects.cpp b/src/tests/cpp/fwklib/FwkObjects.cpp
index 374f296..adbb754 100644
--- a/src/tests/cpp/fwklib/FwkObjects.cpp
+++ b/src/tests/cpp/fwklib/FwkObjects.cpp
@@ -576,7 +576,10 @@ Attributes::Attributes(const DOMNode* node)
FwkPool::FwkPool(const DOMNode* node) : m_locators(false), m_servers(false) {
// Init Factory
- m_poolFactory = PoolManager::createFactory();
+ auto cacheFactory = CacheFactory::createCacheFactory();
+ m_cache = cacheFactory->create();
+ m_poolManager = new PoolManager(*m_cache);
+ m_poolFactory = m_poolManager->createFactory();
// Set Attrs to Pool
setAttributesToFactory(node);
[19/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testEntriesMap.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testEntriesMap.cpp b/src/cppcache/integration-test/testEntriesMap.cpp
deleted file mode 100644
index 9b169b1..0000000
--- a/src/cppcache/integration-test/testEntriesMap.cpp
+++ /dev/null
@@ -1,777 +0,0 @@
-/*
- * 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.
- */
-
-#define ROOT_NAME "testEntriesMap"
-
-#include <iostream>
-
-#include "fw_helper.hpp"
-
-#ifdef WIN32
-
-BEGIN_TEST(NotOnWindows)
- { LOG("Too many non-external symbols used too fix right now on windows."); }
-END_TEST(NotOnWindows)
-
-#else
-
-//#define BUILD_CPPCACHE 1
-#include <geode/GeodeCppCache.hpp>
-#include <LRUEntriesMap.hpp>
-#include <LRUMapEntry.hpp>
-#include <VersionTag.hpp>
-#include <cstdlib>
-#include <LocalRegion.hpp>
-
-using namespace apache::geode::client;
-
-typedef std::vector<MapEntryImplPtr> VectorOfMapEntry;
-
-CacheableStringPtr createCacheable(const char* value) {
- CacheableStringPtr result = CacheableString::create(value);
- ASSERT(result != nullptr, "expected result non-nullptr");
- return result;
-}
-
-namespace {
-class FakeRegion : public RegionInternal {
- public:
- FakeRegion() : RegionInternal(nullptr) {}
- virtual void registerKeys(const VectorOfCacheableKey& keys,
- bool isDurable = false,
- bool getInitialValues = false,
- bool receiveValues = true) override {}
- virtual void unregisterKeys(const VectorOfCacheableKey& keys) override {}
- virtual void registerAllKeys(bool isDurable = false,
- VectorOfCacheableKeyPtr resultKeys = nullptr,
- bool getInitialValues = false,
- bool receiveValues = true) override {}
- virtual void unregisterAllKeys() override {}
-
- virtual void registerRegex(const char* regex, bool isDurable = false,
- VectorOfCacheableKeyPtr resultKeys = nullptr,
- bool getInitialValues = false,
- bool receiveValues = true) override {}
- virtual void unregisterRegex(const char* regex) override {}
-
- virtual SelectResultsPtr query(
- const char* predicate,
- uint32_t timeout = DEFAULT_QUERY_RESPONSE_TIMEOUT) override {
- return nullptr;
- }
- virtual bool existsValue(
- const char* predicate,
- uint32_t timeout = DEFAULT_QUERY_RESPONSE_TIMEOUT) override {
- return false;
- }
- virtual SerializablePtr selectValue(
- const char* predicate,
- uint32_t timeout = DEFAULT_QUERY_RESPONSE_TIMEOUT) override {
- return nullptr;
- }
- virtual PersistenceManagerPtr getPersistenceManager() override {
- return nullptr;
- }
- virtual void setPersistenceManager(PersistenceManagerPtr& pmPtr) override{};
-
- virtual GfErrType getNoThrow(const CacheableKeyPtr& key, CacheablePtr& value,
- const UserDataPtr& aCallbackArgument) override {
- return GF_NOERR;
- }
- virtual GfErrType getAllNoThrow(
- const VectorOfCacheableKey& keys, const HashMapOfCacheablePtr& values,
- const HashMapOfExceptionPtr& exceptions, bool addToLocalCache,
- const UserDataPtr& aCallbackArgument) override {
- return GF_NOERR;
- }
- virtual GfErrType putNoThrow(const CacheableKeyPtr& key,
- const CacheablePtr& value,
- const UserDataPtr& aCallbackArgument,
- CacheablePtr& oldValue, int updateCount,
- const CacheEventFlags eventFlags,
- VersionTagPtr versionTag,
- DataInput* delta = nullptr,
- EventIdPtr eventId = nullptr) override {
- return GF_NOERR;
- }
- virtual GfErrType createNoThrow(const CacheableKeyPtr& key,
- const CacheablePtr& value,
- const UserDataPtr& aCallbackArgument,
- int updateCount,
- const CacheEventFlags eventFlags,
- VersionTagPtr versionTag) override {
- return GF_NOERR;
- }
- virtual GfErrType destroyNoThrow(const CacheableKeyPtr& key,
- const UserDataPtr& aCallbackArgument,
- int updateCount,
- const CacheEventFlags eventFlags,
- VersionTagPtr versionTag) override {
- return GF_NOERR;
- }
- virtual GfErrType removeNoThrow(const CacheableKeyPtr& key,
- const CacheablePtr& value,
- const UserDataPtr& aCallbackArgument,
- int updateCount,
- const CacheEventFlags eventFlags,
- VersionTagPtr versionTag) override {
- return GF_NOERR;
- }
- virtual GfErrType invalidateNoThrow(const CacheableKeyPtr& keyPtr,
- const UserDataPtr& aCallbackArgument,
- int updateCount,
- const CacheEventFlags eventFlags,
- VersionTagPtr versionTag) override {
- return GF_NOERR;
- }
- virtual GfErrType invalidateRegionNoThrow(
- const UserDataPtr& aCallbackArgument,
- const CacheEventFlags eventFlags) override {
- return GF_NOERR;
- }
- virtual GfErrType destroyRegionNoThrow(
- const UserDataPtr& aCallbackArgument, bool removeFromParent,
- const CacheEventFlags eventFlags) override {
- return GF_NOERR;
- }
-
- virtual void setRegionExpiryTask() override {}
- virtual void acquireReadLock() override {}
- virtual void releaseReadLock() override {}
- // behaviors for attributes mutator
- virtual uint32_t adjustLruEntriesLimit(uint32_t limit) override { return 0; }
- virtual ExpirationAction::Action adjustRegionExpiryAction(
- ExpirationAction::Action action) override {
- return action;
- }
- virtual ExpirationAction::Action adjustEntryExpiryAction(
- ExpirationAction::Action action) override {
- return action;
- }
- virtual int32_t adjustRegionExpiryDuration(int32_t duration) override {
- return 0;
- }
- virtual int32_t adjustEntryExpiryDuration(int32_t duration) override {
- return 0;
- }
- virtual void adjustCacheListener(const CacheListenerPtr& aListener) override {
- }
- virtual void adjustCacheListener(const char* libpath,
- const char* factoryFuncName) override {}
- virtual void adjustCacheLoader(const CacheLoaderPtr& aLoader) override {}
- virtual void adjustCacheLoader(const char* libpath,
- const char* factoryFuncName) override {}
- virtual void adjustCacheWriter(const CacheWriterPtr& aWriter) override {}
- virtual void adjustCacheWriter(const char* libpath,
- const char* factoryFuncName) override {}
- virtual RegionStats* getRegionStats() override { return nullptr; }
- virtual bool cacheEnabled() override { return 0; }
- virtual bool isDestroyed() const override { return 0; }
- virtual void evict(int32_t percentage) override {}
- virtual CacheImpl* getCacheImpl() const override { return nullptr; }
- virtual TombstoneListPtr getTombstoneList() override { return nullptr; }
-
- virtual void updateAccessAndModifiedTime(bool modified) override {}
- virtual void updateAccessAndModifiedTimeForEntry(MapEntryImplPtr& ptr,
- bool modified) override {}
- virtual void addDisMessToQueue() override {}
-
- virtual void txDestroy(const CacheableKeyPtr& key,
- const UserDataPtr& callBack,
- VersionTagPtr versionTag) override {}
- virtual void txInvalidate(const CacheableKeyPtr& key,
- const UserDataPtr& callBack,
- VersionTagPtr versionTag) override {}
- virtual void txPut(const CacheableKeyPtr& key, const CacheablePtr& value,
- const UserDataPtr& callBack,
- VersionTagPtr versionTag) override {}
- virtual const PoolPtr& getPool() override { throw "not implemented"; }
-
- virtual void destroyRegion(
- const UserDataPtr& aCallbackArgument = nullptr) override {}
- virtual void clear(const UserDataPtr& aCallbackArgument = nullptr) override {}
- virtual void localClear(
- const UserDataPtr& aCallbackArgument = nullptr) override {}
- virtual void localDestroyRegion(
- const UserDataPtr& aCallbackArgument = nullptr) override {}
- virtual RegionPtr getSubregion(const char* path) override { return nullptr; }
- virtual RegionPtr createSubregion(
- const char* subregionName,
- const RegionAttributesPtr& aRegionAttributes) override {
- return nullptr;
- }
- virtual void subregions(const bool recursive, VectorOfRegion& sr) override {}
- virtual RegionEntryPtr getEntry(const CacheableKeyPtr& key) override {
- return nullptr;
- }
-
- virtual CacheablePtr get(
- const CacheableKeyPtr& key,
- const UserDataPtr& aCallbackArgument = nullptr) override {
- return nullptr;
- }
-
- virtual void put(const CacheableKeyPtr& key, const CacheablePtr& value,
- const UserDataPtr& aCallbackArgument = nullptr) override {}
-
- virtual void putAll(const HashMapOfCacheable& map,
- uint32_t timeout = DEFAULT_RESPONSE_TIMEOUT,
- const UserDataPtr& aCallbackArgument = nullptr) override {
- }
- virtual void localPut(
- const CacheableKeyPtr& key, const CacheablePtr& value,
- const UserDataPtr& aCallbackArgument = nullptr) override {}
-
- virtual void localCreate(
- const CacheableKeyPtr& key, const CacheablePtr& value,
- const UserDataPtr& aCallbackArgument = nullptr) override {}
- virtual void invalidate(
- const CacheableKeyPtr& key,
- const UserDataPtr& aCallbackArgument = nullptr) override {}
-
- virtual void localInvalidate(
- const CacheableKeyPtr& key,
- const UserDataPtr& aCallbackArgument = nullptr) override {}
- virtual void destroy(
- const CacheableKeyPtr& key,
- const UserDataPtr& aCallbackArgument = nullptr) override {}
-
- virtual void localDestroy(
- const CacheableKeyPtr& key,
- const UserDataPtr& aCallbackArgument = nullptr) override {}
-
- virtual bool remove(const CacheableKeyPtr& key, const CacheablePtr& value,
- const UserDataPtr& aCallbackArgument = nullptr) override {
- return false;
- }
-
- virtual bool removeEx(
- const CacheableKeyPtr& key,
- const UserDataPtr& aCallbackArgument = nullptr) override {
- return false;
- }
-
- virtual bool localRemove(
- const CacheableKeyPtr& key, const CacheablePtr& value,
- const UserDataPtr& aCallbackArgument = nullptr) override {
- return false;
- }
-
- virtual bool localRemoveEx(
- const CacheableKeyPtr& key,
- const UserDataPtr& aCallbackArgument = nullptr) override {
- return false;
- }
- virtual void keys(VectorOfCacheableKey& v) override {}
- virtual void serverKeys(VectorOfCacheableKey& v) override {}
- virtual void values(VectorOfCacheable& vc) override {}
- virtual void entries(VectorOfRegionEntry& me, bool recursive) override {}
- virtual void getAll(const VectorOfCacheableKey& keys,
- HashMapOfCacheablePtr values,
- HashMapOfExceptionPtr exceptions,
- bool addToLocalCache = false,
- const UserDataPtr& aCallbackArgument = nullptr) override {
- }
- virtual void removeAll(
- const VectorOfCacheableKey& keys,
- const UserDataPtr& aCallbackArgument = nullptr) override {}
- virtual uint32_t size() override { return 0; }
- virtual const char* getName() const override { return nullptr; }
- virtual const char* getFullPath() const override { return nullptr; }
- virtual RegionPtr getParentRegion() const override { return nullptr; }
- virtual RegionAttributesPtr getAttributes() const override { return nullptr; }
- virtual AttributesMutatorPtr getAttributesMutator() const override {
- return nullptr;
- }
- virtual CacheStatisticsPtr getStatistics() const override { return nullptr; }
- virtual void invalidateRegion(
- const UserDataPtr& aCallbackArgument = nullptr) override {}
- virtual void localInvalidateRegion(
- const UserDataPtr& aCallbackArgument = nullptr) override {}
- virtual void create(const CacheableKeyPtr& key, const CacheablePtr& value,
- const UserDataPtr& aCallbackArgument = nullptr) override {
- }
- virtual RegionServicePtr getRegionService() const override { return nullptr; }
- virtual bool containsValueForKey(
- const CacheableKeyPtr& keyPtr) const override {
- return false;
- }
- virtual bool containsKey(const CacheableKeyPtr& keyPtr) const override {
- return false;
- }
- virtual bool containsKeyOnServer(
- const CacheableKeyPtr& keyPtr) const override {
- return false;
- }
- virtual void getInterestList(VectorOfCacheableKey& vlist) const override {}
- virtual void getInterestListRegex(
- VectorOfCacheableString& vregex) const override {}
-};
-} // namespace
-
-BEGIN_TEST(PutAndGet)
- {
- CacheableStringPtr ccstr = createCacheable("100");
- CacheablePtr ct = ccstr;
- EntryFactory* entryFactory = EntryFactory::singleton;
- AttributesFactory af;
- auto region = std::make_shared<FakeRegion>();
- EntriesMap* entries =
- new ConcurrentEntriesMap(entryFactory, false, region.get());
- entries->open();
- CacheableKeyPtr keyPtr = CacheableKey::create((char*)"foobar");
- ASSERT(keyPtr != nullptr, "expected keyPtr non-nullptr");
- MapEntryImplPtr me;
- VersionTagPtr versionTag;
- CacheablePtr oldValue;
- entries->put(keyPtr, ct, me, oldValue, -1, 0, versionTag);
- CacheablePtr myValuePtr;
- entries->get(keyPtr, myValuePtr, me);
- ASSERT(myValuePtr != nullptr, "expected non-nullptr");
- auto strValue = std::dynamic_pointer_cast<CacheableString>(myValuePtr);
- ASSERT(ccstr->operator==(*strValue), "expected 100");
- delete entries;
- }
-END_TEST(PutAndGet)
-
-BEGIN_TEST(CheckMapEntryImplPtr)
- {
- char error[1000] ATTR_UNUSED;
- MapEntryImplPtr mePtr;
- ASSERT(mePtr == nullptr, "expected mePtr to be nullptr");
- CacheableKeyPtr keyPtr = CacheableKey::create(fwtest_Name);
- ASSERT(keyPtr != nullptr, "expected keyPtr non-nullptr");
- EntryFactory::singleton->newMapEntry(keyPtr, mePtr);
- ASSERT(mePtr != nullptr, "expected to not be null.");
- }
-END_TEST(CheckMapEntryImplPtr)
-
-BEGIN_TEST(RemoveTest)
- {
- CacheableStringPtr cst = createCacheable("200");
- CacheablePtr ct = cst;
- EntryFactory* entryFactory = EntryFactory::singleton;
- auto region = std::make_shared<FakeRegion>();
- EntriesMap* entries =
- new ConcurrentEntriesMap(entryFactory, false, region.get());
- entries->open();
- CacheableKeyPtr keyPtr = CacheableKey::create(fwtest_Name);
- MapEntryImplPtr me;
- ASSERT(keyPtr != nullptr, "expected keyPtr non-nullptr");
- CacheablePtr oldValue;
- VersionTagPtr versionTag;
- entries->put(keyPtr, ct, me, oldValue, -1, 0, versionTag);
- CacheablePtr myValuePtr;
- (void)entries->remove(keyPtr, myValuePtr, me, -1, versionTag, false);
- auto resPtr = std::dynamic_pointer_cast<CacheableString>(myValuePtr);
- ASSERT(myValuePtr != nullptr, "expected to not be null.");
- ASSERT(resPtr->operator==(*createCacheable("200")),
- "CustomerType with m_foobar 200.");
- (void)entries->remove(keyPtr, myValuePtr, me, -1, versionTag, false);
- ASSERT(myValuePtr == nullptr,
- "expected already removed, and null result should clear ptr.");
- }
-END_TEST(RemoveTest)
-
-BEGIN_TEST(GetEntryTest)
- {
- CacheableStringPtr cst = createCacheable("200");
- CacheablePtr ct = cst;
- EntryFactory* entryFactory = EntryFactory::singleton;
- auto region = std::make_shared<FakeRegion>();
- EntriesMap* entries =
- new ConcurrentEntriesMap(entryFactory, false, region.get());
- entries->open();
- CacheableKeyPtr keyPtr;
- MapEntryImplPtr me;
- keyPtr = CacheableKey::create(fwtest_Name);
- ASSERT(keyPtr != nullptr, "expected keyPtr non-nullptr");
- CacheablePtr oldValue;
- VersionTagPtr versionTag;
- entries->put(keyPtr, ct, me, oldValue, -1, 0, versionTag);
- MapEntryImplPtr mePtr;
- CacheablePtr ctPtr;
- entries->getEntry(keyPtr, mePtr, ctPtr);
- ASSERT(mePtr != nullptr, "should not be null.");
- auto valPtr = std::dynamic_pointer_cast<CacheableString>(ctPtr);
- ASSERT(valPtr->operator==(*cst),
- "Entry should have a CustomerType Value of 200");
- CacheableKeyPtr keyPtr1;
- mePtr->getKey(keyPtr1);
- ASSERT(keyPtr1->operator==(*keyPtr), "should have same key.");
- }
-END_TEST(GetEntryTest)
-
-BEGIN_TEST(MapEntryImplPtrRCTest)
- {
- // Test Reference Counting and destruction for MapEntry.
- CacheableKeyPtr keyPtr = CacheableKey::create("foobar");
- ASSERT(keyPtr != nullptr, "expected keyPtr non-nullptr");
- MapEntryImplPtr mePtr;
- EntryFactory ef;
- ef.newMapEntry(keyPtr, mePtr);
- CacheablePtr ct = createCacheable("someval");
- mePtr->setValue(ct);
- }
-END_TEST(MapEntryImplPtrRCTest)
-
-BEGIN_TEST(VectorOfMapEntryTestA)
- {
- VectorOfMapEntry* meVec = new VectorOfMapEntry();
- delete meVec;
- }
-END_TEST(VectorOfMapEntryTestA)
-
-BEGIN_TEST(VectorOfMapEntryTestB)
- {
- VectorOfMapEntry* meVec = new VectorOfMapEntry();
- meVec->resize(100);
- meVec->clear();
- meVec->resize(10);
- MapEntryImplPtr mePtr;
- for (int i = 0; i < 10; i++) {
- meVec->push_back(mePtr);
- }
- for (int j = 0; j < 10; j++) {
- meVec->pop_back();
- }
- delete meVec;
- }
-END_TEST(VectorOfMapEntryTestB)
-
-BEGIN_TEST(EntriesTest)
- {
- EntryFactory* entryFactory = EntryFactory::singleton;
- auto region = std::make_shared<FakeRegion>();
- EntriesMap* entries =
- new ConcurrentEntriesMap(entryFactory, false, region.get());
- entries->open();
- char keyBuf[100];
- char valBuf[100];
- VersionTagPtr versionTag;
- MapEntryImplPtr me;
- for (int i = 0; i < 10; i++) {
- sprintf(keyBuf, "key_%d", i);
- sprintf(valBuf, "%d", i);
- CacheableKeyPtr keyPtr = CacheableKey::create(keyBuf);
- ASSERT(keyPtr != nullptr, "expected keyPtr non-nullptr");
- CacheablePtr v = createCacheable(valBuf);
- CacheablePtr oldValue;
- entries->put(keyPtr, v, me, oldValue, -1, 0, versionTag);
- }
- VectorOfRegionEntry* entriesVec = new VectorOfRegionEntry();
- entriesVec->resize(1);
- entries->entries(*entriesVec);
- // should be 10, but they are hashed so, we don't know what order they will
- // come in...
- int total = 0;
- int expectedTotal = 0;
- for (int k = 0; k < 10; k++) {
- expectedTotal += k;
- RegionEntryPtr rePtr = entriesVec->back();
- CacheableStringPtr ctPtr;
- CacheablePtr ccPtr;
- ccPtr = rePtr->getValue();
- ctPtr = std::dynamic_pointer_cast<CacheableString>(ccPtr);
- std::cout << "value is " << ctPtr->asChar() << std::endl;
- int val = atoi(ctPtr->asChar());
- std::cout << "atoi returned " << val << std::endl;
- total += val;
- entriesVec->pop_back();
- }
- entriesVec->clear();
- entriesVec->resize(0);
- delete entriesVec;
- sprintf(keyBuf, "total = %d, expected = %d", total, expectedTotal);
- ASSERT(total == expectedTotal, keyBuf);
- delete entries;
- }
-END_TEST(EntriesTest)
-
-BEGIN_TEST(ValuesTest)
- {
- EntryFactory* entryFactory = EntryFactory::singleton;
- auto region = std::make_shared<FakeRegion>();
- EntriesMap* entries =
- new ConcurrentEntriesMap(entryFactory, false, region.get());
- entries->open();
- char keyBuf[100];
- char valBuf[100];
- VersionTagPtr versionTag;
- MapEntryImplPtr me;
- for (int i = 0; i < 10; i++) {
- sprintf(keyBuf, "key_%d", i);
- sprintf(valBuf, "%d", i);
- CacheableKeyPtr keyPtr = CacheableKey::create(keyBuf);
- ASSERT(keyPtr != nullptr, "expected keyPtr non-nullptr");
- CacheablePtr v = createCacheable(valBuf);
- CacheablePtr oldValue;
- entries->put(keyPtr, v, me, oldValue, -1, 0, versionTag);
- }
- VectorOfCacheable* valuesVec = new VectorOfCacheable();
- valuesVec->resize(1);
- entries->values(*valuesVec);
- // should be 10, but they are hashed so, we don't know what order they will
- // come in...
- int total = 0;
- int expectedTotal = 0;
- for (int k = 0; k < 10; k++) {
- expectedTotal += k;
- auto valuePtr =
- std::dynamic_pointer_cast<CacheableString>(valuesVec->back());
- total += atoi(valuePtr->asChar());
- valuesVec->pop_back();
- }
- delete valuesVec;
- sprintf(keyBuf, "total = %d, expected = %d", total, expectedTotal);
- ASSERT(total == expectedTotal, keyBuf);
- delete entries;
- }
-END_TEST(ValuesTest)
-
-BEGIN_TEST(KeysTest)
- {
- EntryFactory* entryFactory = EntryFactory::singleton;
- auto region = std::make_shared<FakeRegion>();
- EntriesMap* entries =
- new ConcurrentEntriesMap(entryFactory, false, region.get());
- entries->open();
- char keyBuf[100];
- char valBuf[100];
- VersionTagPtr versionTag;
- MapEntryImplPtr me;
- for (int i = 0; i < 10; i++) {
- sprintf(keyBuf, "key_%d", i);
- sprintf(valBuf, "%d", i);
- CacheableKeyPtr keyPtr = CacheableKey::create(keyBuf);
- ASSERT(keyPtr != nullptr, "expected keyPtr non-nullptr");
- CacheablePtr v = createCacheable(valBuf);
- CacheablePtr oldValue;
- entries->put(keyPtr, v, me, oldValue, -1, 0, versionTag);
- }
- VectorOfCacheableKey keysVec;
- // keysVec.resize( 1 );
- entries->keys(keysVec);
- // should be 10, but they are hashed so, we don't know what order they will
- // come in...
- int total = 0;
- int expectedTotal = 0;
- for (int k = 0; k < 10; k++) {
- expectedTotal += k;
- CacheableKeyPtr keyPtr = keysVec.back();
- CacheablePtr cvPtr;
- entries->get(keyPtr, cvPtr, me);
- auto valuePtr = std::dynamic_pointer_cast<CacheableString>(cvPtr);
- total += atoi(valuePtr->asChar());
- keysVec.pop_back();
- }
- sprintf(keyBuf, "total = %d, expected = %d", total, expectedTotal);
- ASSERT(total == expectedTotal, keyBuf);
- delete entries;
- }
-END_TEST(KeysTest)
-
-BEGIN_TEST(TestRehash)
- {
- EntryFactory* entryFactory = EntryFactory::singleton;
- ConcurrentEntriesMap* entries =
- new ConcurrentEntriesMap(entryFactory, false, nullptr, 1);
- entries->open(10);
- ASSERT(entries->totalSegmentRehashes() == 0,
- "should not have rehashed yet.");
- char keyBuf[100];
- char valBuf[100];
- MapEntryImplPtr me;
-
- for (uint32_t i = 0; i < 10000; i++) {
- sprintf(keyBuf, "key_%d", i);
- sprintf(valBuf, "%d", i);
- CacheableKeyPtr keyPtr = CacheableKey::create(keyBuf);
- ASSERT(keyPtr != nullptr, "expected keyPtr non-nullptr");
- CacheablePtr v = createCacheable(valBuf);
- CacheablePtr oldValue;
- VersionTagPtr versionTag;
- entries->put(keyPtr, v, me, oldValue, -1, 0, versionTag);
- }
- // check rehash count...
- ASSERT(entries->totalSegmentRehashes() > 0,
- "should have rehashed several times.");
- // VectorOfMapEntry result ;
- // entries->entries( result );
- // printf("entries->size()=%d\n", entries->size());
- ASSERT(entries->size() == 10000, "should be 10k items");
- for (uint32_t j = 0; j < 10000; j++) {
- sprintf(keyBuf, "key_%d", j);
- CacheableStringPtr valuePtr;
- CacheableKeyPtr keyPtr = CacheableKey::create(keyBuf);
- ASSERT(keyPtr != nullptr, "expected keyPtr non-nullptr");
- CacheablePtr cvPtr;
- entries->get(keyPtr, cvPtr, me);
- valuePtr = std::dynamic_pointer_cast<CacheableString>(cvPtr);
- if (valuePtr == nullptr) {
- std::cout << "error finding key: " << keyBuf << std::endl;
- FAIL("should have found value for all keys after rehash.");
- }
- }
- }
-END_TEST(TestRehash)
-
-//---- LRU variants
-
-BEGIN_TEST(LRUPutAndGet)
- {
- CacheableStringPtr cst = createCacheable("100");
- CacheablePtr ct = cst;
- MapEntryImplPtr me;
- EntryFactory* entryFactory = LRUEntryFactory::singleton;
- EntriesMap* entries = new LRUEntriesMap(
- entryFactory, nullptr, LRUAction::LOCAL_DESTROY, 20, false);
- entries->open();
- ASSERT(entries->size() == 0, "expected size 0.");
- CacheableKeyPtr keyPtr = CacheableKey::create("foobar");
- CacheablePtr oldValue;
- VersionTagPtr versionTag;
- entries->put(keyPtr, ct, me, oldValue, -1, 0, versionTag);
- ASSERT(entries->size() == 1, "expected size 1.");
- CacheableStringPtr myValuePtr;
- CacheablePtr cvPtr;
- ASSERT(keyPtr != nullptr, "expected keyPtr non-nullptr");
- entries->get(keyPtr, cvPtr, me);
- myValuePtr = std::dynamic_pointer_cast<CacheableString>(cvPtr);
- ASSERT(myValuePtr != nullptr, "expected non-nullptr");
- ASSERT(cst->operator==(*myValuePtr), "expected 100");
- delete entries;
- }
-END_TEST(LRUPutAndGet)
-
-BEGIN_TEST(CheckLRUMapEntryImplPtr)
- {
- char error[1000] ATTR_UNUSED;
- MapEntryImplPtr mePtr;
- ASSERT(mePtr == nullptr, "expected mePtr to be nullptr");
- CacheableKeyPtr keyPtr = CacheableKey::create(fwtest_Name);
- ASSERT(keyPtr != nullptr, "expected keyPtr non-nullptr");
- LRUEntryFactory::singleton->newMapEntry(keyPtr, mePtr);
- ASSERT(mePtr != nullptr, "expected to not be null.");
- auto lmePtr = std::dynamic_pointer_cast<LRUMapEntry>(mePtr);
- ASSERT(lmePtr != nullptr, "expected to cast successfully to LRUMapEntry.");
- }
-END_TEST(LRUCheckMapEntryImplPtr)
-
-BEGIN_TEST(LRURemoveTest)
- {
- CacheableStringPtr cst = createCacheable("200");
- CacheablePtr ct = cst;
- EntryFactory* entryFactory = LRUEntryFactory::singleton;
- EntriesMap* entries = new LRUEntriesMap(
- entryFactory, nullptr, LRUAction::LOCAL_DESTROY, 20, false);
- entries->open();
- ASSERT(entries->size() == 0, "expected size 0.");
- CacheableKeyPtr keyPtr;
- MapEntryImplPtr me;
- keyPtr = CacheableKey::create(fwtest_Name);
- CacheablePtr oldValue;
- VersionTagPtr versionTag;
- entries->put(keyPtr, ct, me, oldValue, -1, 0, versionTag);
- ASSERT(entries->size() == 1, "expected size 1.");
- CacheableStringPtr myValuePtr;
- CacheablePtr cvPtr;
- (void)entries->remove(keyPtr, cvPtr, me, -1, versionTag, false);
- myValuePtr = std::dynamic_pointer_cast<CacheableString>(cvPtr);
- ASSERT(entries->size() == 0, "expected size 0.");
- ASSERT(cvPtr != nullptr, "expected to not be null.");
- ASSERT(myValuePtr->operator==(*createCacheable("200")),
- "CustomerType with m_foobar 200.");
-
- (void)entries->remove(keyPtr, cvPtr, me, -1, versionTag, false);
- ASSERT(cvPtr == nullptr,
- "expected already removed, and null result should clear ptr.");
- }
-END_TEST(LRURemoveTest)
-
-BEGIN_TEST(LRUGetEntryTest)
- {
- CacheableStringPtr cst = createCacheable("200");
- CacheablePtr ct = cst;
- EntryFactory* entryFactory = LRUEntryFactory::singleton;
- EntriesMap* entries = new LRUEntriesMap(
- entryFactory, nullptr, LRUAction::LOCAL_DESTROY, 20, false);
- entries->open();
- CacheableKeyPtr keyPtr;
- MapEntryImplPtr me;
- keyPtr = CacheableKey::create(fwtest_Name);
- ASSERT(keyPtr != nullptr, "expected keyPtr non-nullptr");
- CacheablePtr oldValue;
- VersionTagPtr versionTag;
- entries->put(keyPtr, ct, me, oldValue, -1, 0, versionTag);
- ASSERT(entries->size() == 1, "expected size 1.");
- MapEntryImplPtr mePtr;
- CacheablePtr cvPtr;
- entries->getEntry(keyPtr, mePtr, cvPtr);
- ASSERT(mePtr != nullptr, "should not be null.");
- CacheableStringPtr ctPtr;
- ctPtr = std::dynamic_pointer_cast<CacheableString>(cvPtr);
- ASSERT(ctPtr->operator==(*cst),
- "Entry should have a CustomerType Value of 200");
- CacheableKeyPtr keyPtr1;
- mePtr->getKey(keyPtr1);
- ASSERT(keyPtr1->operator==(*keyPtr), "should have same key.");
- }
-END_TEST(LRUGetEntryTest)
-
-BEGIN_TEST(LRULimitEvictTest)
- {
- EntryFactory* entryFactory = LRUEntryFactory::singleton;
- EntriesMap* entries = new LRUEntriesMap(entryFactory, nullptr,
- LRUAction::LOCAL_DESTROY, 5, false);
- entries->open();
- MapEntryImplPtr me;
- CacheablePtr ct = createCacheable("somevalue");
- CacheablePtr oldValue;
- CacheableKeyPtr keyPtr = CacheableKey::create("1");
- ASSERT(keyPtr != nullptr, "expected keyPtr non-nullptr");
- VersionTagPtr versionTag;
- entries->put(keyPtr, ct, me, oldValue, -1, 0, versionTag);
- ASSERT(entries->size() == 1, "expected size 1.");
- keyPtr = CacheableKey::create("2");
- ASSERT(keyPtr != nullptr, "expected keyPtr non-nullptr");
- entries->put(keyPtr, ct, me, oldValue, -1, 0, versionTag);
- ASSERT(entries->size() == 2, "expected size 2.");
- keyPtr = CacheableKey::create("3");
- ASSERT(keyPtr != nullptr, "expected keyPtr non-nullptr");
- entries->put(keyPtr, ct, me, oldValue, -1, 0, versionTag);
- ASSERT(entries->size() == 3, "expected size 3.");
- keyPtr = CacheableKey::create("4");
- ASSERT(keyPtr != nullptr, "expected keyPtr non-nullptr");
- entries->put(keyPtr, ct, me, oldValue, -1, 0, versionTag);
- ASSERT(entries->size() == 4, "expected size 4.");
- keyPtr = CacheableKey::create("5");
- ASSERT(keyPtr != nullptr, "expected keyPtr non-nullptr");
- entries->put(keyPtr, ct, me, oldValue, -1, 0, versionTag);
- ASSERT(entries->size() == 5, "expected size 5.");
- LOG("Map is now at the limit.");
- keyPtr = CacheableKey::create("6");
- ASSERT(keyPtr != nullptr, "expected keyPtr non-nullptr");
- LOG("About to spill over.");
- entries->put(keyPtr, ct, me, oldValue, -1, 0, versionTag);
- LOG("Spilled over.");
- ASSERT(entries->size() == 5, "expected size 5.");
- LOG("Limit was preserved.");
- }
-END_TEST(LRULimitEvictTest)
-
-#endif
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/integration-test/testEntriesMapForVersioning.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testEntriesMapForVersioning.cpp b/src/cppcache/integration-test/testEntriesMapForVersioning.cpp
deleted file mode 100644
index d93ae4c..0000000
--- a/src/cppcache/integration-test/testEntriesMapForVersioning.cpp
+++ /dev/null
@@ -1,1297 +0,0 @@
-/*
- * 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.
- */
-
-#include <geode/geode_base.hpp>
-
-#include "fw_dunit.hpp"
-
-#ifdef WIN32
-
-#define CLIENT1 s1p1
-DUNIT_TASK_DEFINITION(CLIENT1, CREATECLIENT)
- { LOG("This test doesn't run on windows. Too many classes to export."); }
-END_TASK_DEFINITION
-void runTask() { CALL_TASK(CREATECLIENT); }
-DUNIT_MAIN
- { runTask(); }
-END_MAIN
-
-#else
-
-//#define BUILD_CPPCACHE 1
-#include <geode/GeodeCppCache.hpp>
-#include <LRUEntriesMap.hpp>
-#include <LRUMapEntry.hpp>
-#include <LRUExpMapEntry.hpp>
-#include <VersionTag.hpp>
-#include <cstdlib>
-#include <ClientProxyMembershipID.hpp>
-#include <ace/OS.h>
-#include <string>
-#include <vector>
-#include <LocalRegion.hpp>
-#include <geode/DataInput.hpp>
-#include "DeltaEx.hpp"
-#include "CacheableToken.hpp"
-#include "DiskStoreId.hpp"
-#include "DiskVersionTag.hpp"
-#include "DSMemberForVersionStamp.hpp"
-#include "CachePerfStats.hpp"
-#define ROOT_SCOPE LOCAL
-
-#include "CacheHelper.hpp"
-
-#define CLIENT1 s1p1
-
-using namespace apache::geode::client;
-using namespace test;
-
-CacheHelper* cacheHelper = nullptr;
-RegionPtr regPtr;
-
-const char* endpoints = nullptr;
-
-void initClient() {
- if (cacheHelper == nullptr) {
- PropertiesPtr configPtr = Properties::create();
- configPtr->insert("tombstone-timeout", 5000);
- cacheHelper = new CacheHelper(true, configPtr);
- }
- ASSERT(cacheHelper, "Failed to create a CacheHelper client instance.");
-}
-void cleanProc() {
- if (cacheHelper != nullptr) {
- delete cacheHelper;
- cacheHelper = nullptr;
- }
-}
-
-CacheHelper* getHelper() {
- ASSERT(cacheHelper != nullptr, "No cacheHelper initialized.");
- return cacheHelper;
-}
-
-void createRegion(const char* name, bool ackMode,
- bool clientNotificationEnabled = false, bool caching = true) {
- LOG("createRegion() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
- fflush(stdout);
- // ack, caching
- regPtr =
- getHelper()->createRegion(name, ackMode, caching, nullptr,
- clientNotificationEnabled, true, true, 5000);
- ASSERT(regPtr != nullptr, "Failed to create region.");
- LOG("Region created.");
-}
-
-typedef std::vector<MapEntryImplPtr> VectorOfMapEntry;
-
-CacheableStringPtr createCacheable(const char* value) {
- CacheableStringPtr result = CacheableString::create(value);
- ASSERT(result != nullptr, "expected result non-nullptr");
- return result;
-}
-
-uint8_t addr1[6] = {0xff, 0xff, 0xff, 0xaa, 0xff, 0xff};
-uint8_t addr2[6] = {0xff, 0xff, 0xff, 0xaa, 0xff, 0xbb};
-uint8_t addr3[6] = {0xff, 0xff, 0xaa, 0xaa, 0xff, 0xff};
-uint8_t addr4[6] = {0xff, 0xff, 0xff, 0xff, 0xaa, 0xff};
-
-auto member_host1 = std::make_shared<ClientProxyMembershipID>(addr1, 6, 80, "",
- "myuniquetag", 0);
-auto member_host12 = std::make_shared<ClientProxyMembershipID>(
- addr1, 6, 80, "", "myuniquetah", 0);
-auto member_host13 = std::make_shared<ClientProxyMembershipID>(
- addr1, 6, 81, "", "myuniquetag", 0);
-auto member_host14 = std::make_shared<ClientProxyMembershipID>(
- addr1, 6, 88, "", "myuniquetag", 0);
-auto member_host15 = std::make_shared<ClientProxyMembershipID>(
- addr2, 6, 88, "", "myuniquetag", 0);
-auto member_host16 = std::make_shared<ClientProxyMembershipID>(
- addr3, 6, 88, "", "myuniquetag", 0);
-auto member_host17 = std::make_shared<ClientProxyMembershipID>(
- addr4, 6, 88, "", "myuniquetag", 0);
-auto diskStore17 = new DiskStoreId(1, 7);
-auto diskStore18 = new DiskStoreId(1, 8);
-auto diskStore27 = new DiskStoreId(2, 7);
-auto member_host_vmview5 =
- std::make_shared<ClientProxyMembershipID>(addr4, 6, 88, "", "", 5);
-auto member_host_vmview6 =
- std::make_shared<ClientProxyMembershipID>(addr4, 6, 88, "", "", 6);
-auto member_host_vmview7 =
- std::make_shared<ClientProxyMembershipID>(addr4, 6, 88, "", "", 7);
-
-uint16_t host1;
-uint16_t host12;
-uint16_t host13;
-uint16_t host14;
-uint16_t host15;
-uint16_t host16;
-uint16_t host17;
-uint16_t disk17;
-uint16_t disk18;
-uint16_t disk27;
-uint16_t hostVmview5;
-uint16_t hostVmview6;
-uint16_t hostVmview7;
-
-int DeltaEx::toDeltaCount = 0;
-int DeltaEx::toDataCount = 0;
-int DeltaEx::fromDeltaCount = 0;
-int DeltaEx::fromDataCount = 0;
-int DeltaEx::cloneCount = 0;
-
-//#undef DUNIT_TASK_DEFINITION
-//#define DUNIT_TASK_DEFINITION(_X, _Y) void _Y()
-//#undef END_TASK_DEFINITION
-//#define END_TASK_DEFINITION
-//#undef CALL_TASK
-//#define CALL_TASK(_Y) _Y()
-
-DUNIT_TASK_DEFINITION(CLIENT1, CREATECLIENT)
- {
- initClient();
- createRegion("myregion", true, false);
- LOG("StepOne complete.");
- }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(CLIENT1, CloseCache1)
- { cleanProc(); }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(CLIENT1, StepOne_AddHosts)
- {
- auto lregPtr = std::dynamic_pointer_cast<LocalRegion>(regPtr);
- host1 = lregPtr->getCacheImpl()->getMemberListForVersionStamp()->add(
- member_host1);
- host12 = lregPtr->getCacheImpl()->getMemberListForVersionStamp()->add(
- member_host12);
- host13 = lregPtr->getCacheImpl()->getMemberListForVersionStamp()->add(
- member_host13);
- host14 = lregPtr->getCacheImpl()->getMemberListForVersionStamp()->add(
- member_host14);
- host15 = lregPtr->getCacheImpl()->getMemberListForVersionStamp()->add(
- member_host15);
- host16 = lregPtr->getCacheImpl()->getMemberListForVersionStamp()->add(
- member_host16);
- host17 = lregPtr->getCacheImpl()->getMemberListForVersionStamp()->add(
- member_host17);
- disk17 = lregPtr->getCacheImpl()->getMemberListForVersionStamp()->add(
- DSMemberForVersionStampPtr(diskStore17));
- disk18 = lregPtr->getCacheImpl()->getMemberListForVersionStamp()->add(
- DSMemberForVersionStampPtr(diskStore18));
- disk27 = lregPtr->getCacheImpl()->getMemberListForVersionStamp()->add(
- DSMemberForVersionStampPtr(diskStore27));
- hostVmview5 = lregPtr->getCacheImpl()->getMemberListForVersionStamp()->add(
- member_host_vmview5);
- hostVmview6 = lregPtr->getCacheImpl()->getMemberListForVersionStamp()->add(
- member_host_vmview6);
- hostVmview7 = lregPtr->getCacheImpl()->getMemberListForVersionStamp()->add(
- member_host_vmview7);
- }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(CLIENT1, StepTwo_TestPut)
- {
- auto lregPtr = std::dynamic_pointer_cast<LocalRegion>(regPtr);
- auto ccstr = createCacheable("100");
- auto ccstr1 = createCacheable("500");
- auto entryFactory = EntryFactory::singleton;
- entryFactory->setConcurrencyChecksEnabled(true);
- EntriesMap* entries =
- new ConcurrentEntriesMap(entryFactory, true, lregPtr.get());
- entries->open();
- auto keyPtr = CacheableKey::create("key1");
- ASSERT(keyPtr != nullptr, "expected keyPtr non-nullptr");
- MapEntryImplPtr me;
- auto versionTag1 = std::make_shared<VersionTag>(5, 6, 7, host1, 0);
-
- auto versionTag12 = std::make_shared<VersionTag>(5, 6, 7, host12, 0);
-
- auto versionTag13 = std::make_shared<VersionTag>(5, 6, 7, host13, 0);
- auto versionTag14 = std::make_shared<VersionTag>(5, 6, 7, host14, 0);
- auto versionTag15 = std::make_shared<VersionTag>(5, 6, 7, host15, 0);
- auto versionTag16 = std::make_shared<VersionTag>(5, 6, 7, host16, 0);
- auto versionTag17 = std::make_shared<VersionTag>(5, 6, 7, host17, 0);
-
- CacheablePtr oldValue;
- entries->put(keyPtr, ccstr, me, oldValue, -1, 0, versionTag1);
- char log[256];
-
- auto err = entries->put(keyPtr, ccstr1, me, oldValue, -1, 0, versionTag12);
- ASSERT(err != GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
-
- err = entries->put(keyPtr, ccstr, me, oldValue, -1, 0, versionTag1);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
-
- err = entries->put(keyPtr, ccstr1, me, oldValue, -1, 0, versionTag13);
- ASSERT(err != GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
-
- err = entries->put(keyPtr, ccstr, me, oldValue, -1, 0, versionTag1);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
-
- uint32_t conflatedEvents =
- lregPtr->getCacheImpl()->m_cacheStats->getConflatedEvents();
- ASSERT(conflatedEvents == 2, "conflated events should be 2");
-
- err = entries->put(keyPtr, ccstr1, me, oldValue, -1, 0, versionTag14);
- ASSERT(err != GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
-
- err = entries->put(keyPtr, ccstr, me, oldValue, -1, 0, versionTag1);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
-
- err = entries->put(keyPtr, ccstr1, me, oldValue, -1, 0, versionTag15);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
-
- err = entries->put(keyPtr, ccstr, me, oldValue, -1, 0, versionTag1);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
-
- err = entries->put(keyPtr, ccstr1, me, oldValue, -1, 0, versionTag16);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
-
- err = entries->put(keyPtr, ccstr1, me, oldValue, -1, 0, versionTag17);
- ASSERT(err != GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
- MapEntryImplPtr result;
- CacheablePtr value;
- entries->getEntry(keyPtr, result, value);
- ASSERT(atoi(value->toString()->asChar()) == 500, "an exception");
- ASSERT(me->getVersionStamp().getMemberId() == 7, "an exception");
-
- auto versionTag18 = std::make_shared<VersionTag>(0xffffaa, 6, 7, host1, 0);
-
- // version rollover, this will not be applied
- err = entries->put(keyPtr, ccstr, me, oldValue, -1, 0, versionTag18);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
- entries->getEntry(keyPtr, result, value);
- ASSERT(atoi(value->toString()->asChar()) == 500, "an exception");
- ASSERT(me->getVersionStamp().getMemberId() == 7, "an exception");
-
- auto keyPtr2 = CacheableKey::create("Key2");
- err = entries->put(keyPtr2, ccstr, me, oldValue, -1, 0, versionTag18);
- ASSERT(err != GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
- entries->getEntry(keyPtr2, result, value);
- ASSERT(atoi(value->toString()->asChar()) == 100, "an exception");
- ASSERT(me->getVersionStamp().getMemberId() == 1, "an exception");
-
- // version rollover, this will be applied
- err = entries->put(keyPtr2, ccstr1, me, oldValue, -1, 0, versionTag12);
- ASSERT(err != GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
- entries->getEntry(keyPtr2, result, value);
- ASSERT(atoi(value->toString()->asChar()) == 500, "an exception");
- ASSERT(me->getVersionStamp().getMemberId() == 2, "an exception");
-
- // Null version tag, this will be applied
- VersionTagPtr versionTag19;
- err = entries->put(keyPtr2, ccstr, me, oldValue, -1, 0, versionTag19);
- ASSERT(err != GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
- entries->getEntry(keyPtr2, result, value);
- ASSERT(atoi(value->toString()->asChar()) == 100, "an exception");
- ASSERT(result->getVersionStamp().getMemberId() == 2, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 5, "an exception");
-
- // inserts a null tag
- auto keyPtr3 = CacheableKey::create("Key3");
- err = entries->put(keyPtr3, ccstr1, me, oldValue, -1, 0, versionTag19);
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keyPtr3, result, value);
- ASSERT(atoi(value->toString()->asChar()) == 500, "an exception");
- ASSERT(result->getVersionStamp().getMemberId() == 0, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 0, "an exception");
-
- // inserts an entry with version stamp, the previous entry is without
- // version
- // stamp,
- // should be allowed.
- err = entries->put(keyPtr3, ccstr1, me, oldValue, -1, 0, versionTag12);
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keyPtr3, result, value);
- ASSERT(atoi(value->toString()->asChar()) == 500, "an exception");
- ASSERT(me->getVersionStamp().getMemberId() == 2, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 5, "an exception");
-
- try {
- Serializable::registerType(DeltaEx::create);
- } catch (IllegalStateException&) {
- // ignore exception caused by type reregistration.
- }
- DeltaEx::toDeltaCount = 0;
- DeltaEx::toDataCount = 0;
- sprintf(log, "Some delta tests...");
- LOG(log);
-
- auto keyPtr4 = CacheableKey::create("Key4");
- auto valPtr = std::make_shared<DeltaEx>();
- err = entries->put(keyPtr4, valPtr, me, oldValue, -1, 0, versionTag12);
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keyPtr4, result, value);
- ASSERT(result->getVersionStamp().getMemberId() == 2, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 5, "an exception");
- ASSERT(DeltaEx::fromDeltaCount == 0, " Delta count should have been 0 ");
-
- auto valPtr1 = std::make_shared<DeltaEx>();
- valPtr1->setDelta(true);
- DataOutput doutput;
- doutput.writeInt(1);
- const auto buffer = doutput.getBuffer();
-
- DataInput datainput(buffer, doutput.getBufferLength());
-
- bool isUpdate;
- auto versionTag12plus =
- std::make_shared<VersionTag>(6, 6, 7, host13, host12);
- err = entries->put(keyPtr4, valPtr1, me, oldValue, -1, 0, versionTag12plus,
- isUpdate, &datainput);
-
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keyPtr4, result, value);
- ASSERT(result->getVersionStamp().getMemberId() == 3, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 6, "an exception");
- ASSERT(DeltaEx::fromDeltaCount == 1, " Delta count should have been 1 ");
-
- // Delta update, Not allowed as same tag and stamp versions
- err = entries->put(keyPtr4, valPtr1, me, oldValue, -1, 0, versionTag12plus,
- isUpdate, &datainput);
- ASSERT(err == GF_INVALID_DELTA, "an exception");
- entries->getEntry(keyPtr4, result, value);
- ASSERT(result->getVersionStamp().getMemberId() == 3, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 6, "an exception");
- ASSERT(DeltaEx::fromDeltaCount == 1, " Delta count should have been 1 ");
-
- // Delta update, Not allowed as delta based on a different host version
- // different
- auto versionTag12pp = std::make_shared<VersionTag>(7, 6, 7, host13, host12);
- err = entries->put(keyPtr4, valPtr1, me, oldValue, -1, 0, versionTag12plus,
- isUpdate, &datainput);
- ASSERT(err == GF_INVALID_DELTA, "an exception");
- entries->getEntry(keyPtr4, result, value);
- ASSERT(result->getVersionStamp().getMemberId() == 3, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 6, "an exception");
- ASSERT(DeltaEx::fromDeltaCount == 1, " Delta count should have been 1 ");
-
- auto valPtr2 = std::make_shared<DeltaEx>();
- valPtr2->setDelta(true);
- DataOutput doutput1;
- doutput1.writeInt(1);
- const auto buffer1 = doutput1.getBuffer();
- DataInput datainput1(buffer1, doutput1.getBufferLength());
- DeltaEx::fromDeltaCount = 0;
- // Delta update, allowed as delta based on correct host version different
- auto versionTag12pp1 =
- std::make_shared<VersionTag>(7, 6, 7, host14, host13);
- err = entries->put(keyPtr4, valPtr2, me, oldValue, -1, 0, versionTag12pp1,
- isUpdate, &datainput1);
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keyPtr4, result, value);
- ASSERT(result->getVersionStamp().getMemberId() == 4, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 7, "an exception");
- ASSERT(DeltaEx::fromDeltaCount == 1, " Delta count should have been 1 ");
-
- /******* Test disk version tags*****************/
- auto versiondiskTag17 =
- std::make_shared<DiskVersionTag>(5, 6, 7, disk17, 0);
- auto versiondiskTag18 =
- std::make_shared<DiskVersionTag>(5, 6, 7, disk18, 0);
- auto versiondiskTag27 =
- std::make_shared<DiskVersionTag>(5, 6, 7, disk27, 0);
- auto keydiskPtr = CacheableKey::create("keydisk1");
- err =
- entries->put(keydiskPtr, ccstr, me, oldValue, -1, 0, versiondiskTag17);
- err =
- entries->put(keydiskPtr, ccstr1, me, oldValue, -1, 0, versiondiskTag27);
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keydiskPtr, result, value);
- ASSERT(atoi(value->toString()->asChar()) == 500, "an exception");
- ASSERT(result->getVersionStamp().getMemberId() == disk27, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 5, "an exception");
-
- err =
- entries->put(keydiskPtr, ccstr, me, oldValue, -1, 0, versiondiskTag18);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
- entries->getEntry(keydiskPtr, result, value);
- ASSERT(atoi(value->toString()->asChar()) == 500, "an exception");
- ASSERT(result->getVersionStamp().getMemberId() == disk27, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 5, "an exception");
-
- /********* Test with vm view ids ****************/
- auto versionvmviewTag5 =
- std::make_shared<VersionTag>(5, 6, 7, hostVmview5, 0);
- auto versionvmviewTag6 =
- std::make_shared<VersionTag>(5, 6, 7, hostVmview6, 0);
- auto versionvmviewTag7 =
- std::make_shared<VersionTag>(5, 6, 7, hostVmview7, 0);
- auto keyvmviewPtr = CacheableKey::create("keyvm1");
- err = entries->put(keyvmviewPtr, ccstr, me, oldValue, -1, 0,
- versionvmviewTag5);
-
- err = entries->put(keyvmviewPtr, ccstr1, me, oldValue, -1, 0,
- versionvmviewTag7);
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keyvmviewPtr, result, value);
- ASSERT(atoi(value->toString()->asChar()) == 500, "an exception");
- ASSERT(result->getVersionStamp().getMemberId() == hostVmview7,
- "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 5, "an exception");
-
- err = entries->put(keyvmviewPtr, ccstr, me, oldValue, -1, 0,
- versionvmviewTag6);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
- entries->getEntry(keyvmviewPtr, result, value);
- ASSERT(atoi(value->toString()->asChar()) == 500, "an exception");
- ASSERT(result->getVersionStamp().getMemberId() == hostVmview7,
- "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 5, "an exception");
-
- sprintf(log, "Put test complete. %d", err);
- LOG(log);
-
- delete entries;
- }
-END_TASK_DEFINITION
-DUNIT_TASK_DEFINITION(CLIENT1, StepThree_TestCreate)
- {
- auto lregPtr = std::dynamic_pointer_cast<LocalRegion>(regPtr);
- auto ccstr = createCacheable("100");
- auto ccstr1 = createCacheable("500");
- auto entryFactory = EntryFactory::singleton;
- entryFactory->setConcurrencyChecksEnabled(true);
- EntriesMap* entries =
- new ConcurrentEntriesMap(entryFactory, true, lregPtr.get());
- entries->open();
- auto keyPtr4 = CacheableKey::create("key4");
- ASSERT(keyPtr4 != nullptr, "expected keyPtr non-nullptr");
- MapEntryImplPtr me;
- MapEntryImplPtr result;
- CacheablePtr value;
-
- /*new VersionTag(int32_t entryVersion,
- int16_t regionVersionHighBytes, int32_t regionVersionLowBytes,
- uint16_t internalMemId, uint16_t previousMemId) */
- auto versionTag1 = std::make_shared<VersionTag>(5, 6, 7, host1, 0);
-
- auto versionTag12 = std::make_shared<VersionTag>(5, 6, 7, host12, 0);
-
- auto versionTag13 = std::make_shared<VersionTag>(5, 6, 7, host13, 0);
- auto versionTag14 = std::make_shared<VersionTag>(5, 6, 7, host14, 0);
- auto versionTag15 = std::make_shared<VersionTag>(5, 6, 7, host15, 0);
- auto versionTag16 = std::make_shared<VersionTag>(5, 6, 7, host16, 0);
- auto versionTag17 = std::make_shared<VersionTag>(5, 6, 7, host17, 0);
-
- CacheablePtr oldValue;
- entries->create(keyPtr4, ccstr, me, oldValue, -1, 0, versionTag1);
- entries->getEntry(keyPtr4, result, value);
- ASSERT(me->getVersionStamp().getEntryVersion() == 5, "an exception");
- ASSERT(me->getVersionStamp().getMemberId() == 1, "an exception");
-
- char log[256];
-
- auto keyPtr = CacheableKey::create("Key");
- auto err =
- entries->create(keyPtr, nullptr, me, oldValue, -1, 0, versionTag12);
- ASSERT(err == GF_NOERR, "an exception");
-
- err = entries->create(keyPtr, nullptr, me, oldValue, -1, 0, versionTag1);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
-
- err = entries->create(keyPtr, nullptr, me, oldValue, -1, 0, versionTag13);
- ASSERT(err == GF_NOERR, "an exception");
-
- err = entries->create(keyPtr, nullptr, me, oldValue, -1, 0, versionTag1);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
-
- err = entries->create(keyPtr, nullptr, me, oldValue, -1, 0, versionTag14);
- ASSERT(err == GF_NOERR, "an exception");
-
- err = entries->create(keyPtr, nullptr, me, oldValue, -1, 0, versionTag1);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
-
- err = entries->create(keyPtr, nullptr, me, oldValue, -1, 0, versionTag15);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
-
- err = entries->create(keyPtr, nullptr, me, oldValue, -1, 0, versionTag1);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
-
- err = entries->create(keyPtr, nullptr, me, oldValue, -1, 0, versionTag16);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
-
- err = entries->create(keyPtr, ccstr1, me, oldValue, -1, 0, versionTag17);
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keyPtr, result, value);
- ASSERT(result->getVersionStamp().getMemberId() == 7, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 5, "an exception");
-
- auto versionTag18 = std::make_shared<VersionTag>(0xffffaa, 6, 7, host1, 0);
-
- auto keyPtr2 = CacheableKey::create("Key2");
- err = entries->create(keyPtr2, nullptr, me, oldValue, -1, 0, versionTag18);
- ASSERT(err == GF_NOERR, "an exception");
-
- // version rollover, this will be applied
- err = entries->create(keyPtr2, nullptr, me, oldValue, -1, 0, versionTag12);
- ASSERT(err == GF_NOERR, "an exception");
-
- // Null version tag, this will be applied
- VersionTagPtr versionTag19;
- err = entries->create(keyPtr2, ccstr, me, oldValue, -1, 0, versionTag19);
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keyPtr2, result, value);
- ASSERT(result->getVersionStamp().getMemberId() == 2, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 5, "an exception");
-
- // inserts a null tag
- auto keyPtr3 = CacheableKey::create("Key3");
- err = entries->create(keyPtr3, nullptr, me, oldValue, -1, 0, versionTag19);
- ASSERT(err == GF_NOERR, "an exception");
-
- // inserts an entry with version stamp, the previous entry is without
- // version
- // stamp,
- // should be allowed.
- err = entries->create(keyPtr3, ccstr1, me, oldValue, -1, 0, versionTag12);
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keyPtr3, result, value);
- ASSERT(result->getVersionStamp().getMemberId() == 2, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 5, "an exception");
-
- sprintf(log, "Create test complete. %d", err);
- LOG(log);
-
- delete entries;
- }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(CLIENT1, StepEight_TestLRUEntries)
- {
- auto lregPtr = std::dynamic_pointer_cast<LocalRegion>(regPtr);
- auto ccstr = createCacheable("100");
- auto ccstr1 = createCacheable("500");
- auto entryFactory = LRUExpEntryFactory::singleton;
- entryFactory->setConcurrencyChecksEnabled(true);
- EntriesMap* entries = new LRUEntriesMap(entryFactory, lregPtr.get(),
- LRUAction::DESTROY, 50000, true);
- entries->open();
- auto keyPtr4 = CacheableKey::create("key4");
- auto keyPtr5 = CacheableKey::create("key5");
- auto keyPtr6 = CacheableKey::create("key6");
- MapEntryImplPtr me;
- MapEntryImplPtr result;
- CacheablePtr value;
- char log[256];
-
- auto versionTag1 = std::make_shared<VersionTag>(5, 6, 7, host1, 0);
-
- auto versionTag12 = std::make_shared<VersionTag>(5, 6, 7, host12, 0);
-
- entries->put(keyPtr4, ccstr, me, value, -1, 0, versionTag1);
-
- auto err = entries->remove(keyPtr4, value, me, -1, versionTag12, false);
- ASSERT(err == GF_NOERR, "an exception");
- bool isTombstone;
- err = entries->isTombstone(keyPtr4, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
-
- entries->put(keyPtr5, ccstr, me, value, -1, 0, versionTag1);
-
- err = entries->invalidate(keyPtr5, me, value, versionTag12);
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keyPtr5, result, value);
- ASSERT(CacheableToken::isInvalid(value) == true, "an exception");
-
- entries->put(keyPtr6, ccstr, me, value, -1, 0, versionTag1);
-
- ASSERT(entries->get(keyPtr4, value, result) == false, "an exception");
- ASSERT(entries->get(keyPtr6, value, result) == true, "an exception");
-
- sprintf(log, "LRUentriesMap test complete. %d", err);
- LOG(log);
-
- delete entries;
- }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(CLIENT1, StepFive_TestTombstoneExpiry)
- {
- auto lregPtr = std::dynamic_pointer_cast<LocalRegion>(regPtr);
- auto ccstr = createCacheable("100");
- auto ccstr1 = createCacheable("500");
- auto entryFactory = EntryFactory::singleton;
- entryFactory->setConcurrencyChecksEnabled(true);
- EntriesMap* entries =
- new ConcurrentEntriesMap(entryFactory, true, lregPtr.get());
- entries->open();
- auto keyPtr4 = CacheableKey::create("key4");
- auto keyPtr5 = CacheableKey::create("key5");
- auto keyPtr6 = CacheableKey::create("key6");
- MapEntryImplPtr me;
- MapEntryImplPtr result;
- CacheablePtr value;
- char log[256];
-
- auto versionTag1 = std::make_shared<VersionTag>(5, 6, 7, host1, 0);
-
- auto versionTag12 = std::make_shared<VersionTag>(5, 6, 7, host12, 0);
-
- entries->put(keyPtr4, ccstr, me, value, -1, 0, versionTag1);
-
- auto err = entries->remove(keyPtr4, value, me, -1, versionTag12, false);
- ASSERT(err == GF_NOERR, "an exception");
- bool isTombstone;
- err = entries->isTombstone(keyPtr4, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
-
- entries->put(keyPtr5, ccstr, me, value, -1, 0, versionTag1);
-
- err = entries->remove(keyPtr5, value, me, -1, versionTag12, false);
- ASSERT(err == GF_NOERR, "an exception");
- err = entries->isTombstone(keyPtr5, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
-
- entries->put(keyPtr6, ccstr, me, value, -1, 0, versionTag1);
- auto tombstone_count =
- lregPtr->getCacheImpl()->m_cacheStats->getTombstoneCount();
- auto tombstone_size =
- lregPtr->getCacheImpl()->m_cacheStats->getTombstoneSize();
-
- sprintf(log,
- "Before expiry, Tombstone size: %" PRId64 " Tombstone count: %d",
- tombstone_size, tombstone_count);
- LOG(log);
- ASSERT(tombstone_count > 0, "Tombstone count should be equal to 2");
- ASSERT(tombstone_size > 160,
- "Tombstone size should be greater than 160 bytes. 160 is a approx "
- "figure for tombstone overhead");
-
- ACE_OS::sleep(8);
-
- err = entries->isTombstone(keyPtr5, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == false, "an exception");
- ASSERT(entries->get(keyPtr5, value, result) == false, "an exception");
- err = entries->isTombstone(keyPtr4, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == false, "an exception");
- ASSERT(entries->get(keyPtr4, value, result) == false, "an exception");
-
- auto tombstone_count_after =
- lregPtr->getCacheImpl()->m_cacheStats->getTombstoneCount();
- auto tombstone_size_after =
- lregPtr->getCacheImpl()->m_cacheStats->getTombstoneSize();
-
- sprintf(log,
- "After expiry, Tombstone size: %" PRId64 " Tombstone count: %d",
- tombstone_size_after, tombstone_count_after);
- LOG(log);
-
- ASSERT((tombstone_count - 2) == tombstone_count_after,
- "Tombstone count does not match");
- ASSERT((tombstone_size - 160) > tombstone_size_after,
- "Tombstone size does not match");
-
- sprintf(log, "Tombstone expiry test complete. %d", err);
- LOG(log);
-
- delete entries;
- }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(CLIENT1, StepSix_TestInvalidate)
- {
- auto lregPtr = std::dynamic_pointer_cast<LocalRegion>(regPtr);
- auto ccstr = createCacheable("100");
- auto ccstr1 = createCacheable("500");
- auto entryFactory = EntryFactory::singleton;
- entryFactory->setConcurrencyChecksEnabled(true);
- EntriesMap* entries =
- new ConcurrentEntriesMap(entryFactory, true, lregPtr.get());
- entries->open();
- CacheableKeyPtr keyPtr = CacheableKey::create("key1");
- ASSERT(keyPtr != nullptr, "expected keyPtr non-nullptr");
- MapEntryImplPtr me;
- MapEntryImplPtr result;
- CacheablePtr value;
-
- auto versionTag1 = std::make_shared<VersionTag>(5, 6, 7, host1, 0);
-
- auto versionTag12 = std::make_shared<VersionTag>(5, 6, 7, host12, 0);
-
- auto versionTag13 = std::make_shared<VersionTag>(5, 6, 7, host13, 0);
- auto versionTag14 = std::make_shared<VersionTag>(5, 6, 7, host14, 0);
- auto versionTag15 = std::make_shared<VersionTag>(5, 6, 7, host15, 0);
- auto versionTag16 = std::make_shared<VersionTag>(5, 6, 7, host16, 0);
- auto versionTag17 = std::make_shared<VersionTag>(5, 6, 7, host17, 0);
- auto versionTag22 = std::make_shared<VersionTag>(9, 10, 10, host12, 0);
-
- CacheablePtr oldValue;
- entries->put(keyPtr, ccstr, me, oldValue, -1, 0, versionTag1);
- char log[256];
-
- auto err = entries->invalidate(keyPtr, me, oldValue, versionTag12);
-
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keyPtr, result, value);
- ASSERT(CacheableToken::isInvalid(value) == true, "an exception");
-
- err = entries->put(keyPtr, ccstr, me, oldValue, -1, 0, versionTag1);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
- entries->getEntry(keyPtr, result, value);
- ASSERT(CacheableToken::isInvalid(value) == true, "an exception");
-
- err = entries->put(keyPtr, ccstr1, me, oldValue, -1, 0, versionTag13);
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keyPtr, result, value);
- ASSERT(CacheableToken::isInvalid(value) != true, "an exception");
-
- err = entries->invalidate(keyPtr, me, oldValue, versionTag1);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
- entries->getEntry(keyPtr, result, value);
- ASSERT(CacheableToken::isInvalid(value) != true, "an exception");
-
- err = entries->invalidate(keyPtr, me, oldValue, versionTag14);
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keyPtr, result, value);
- ASSERT(CacheableToken::isInvalid(value) == true, "an exception");
-
- err = entries->invalidate(keyPtr, me, oldValue, versionTag17);
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keyPtr, result, value);
- ASSERT(CacheableToken::isInvalid(value) == true, "an exception");
- ASSERT(result->getVersionStamp().getMemberId() == 7, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 5, "an exception");
-
- err = entries->invalidate(keyPtr, me, oldValue, versionTag22);
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keyPtr, result, value);
- ASSERT(CacheableToken::isInvalid(value) == true, "an exception");
- ASSERT(result->getVersionStamp().getMemberId() == 2, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 9, "an exception");
-
- auto versionTag18 = std::make_shared<VersionTag>(0xffffaa, 6, 7, host1, 0);
-
- // version rollover, this will not be applied
- err = entries->put(keyPtr, ccstr, me, oldValue, -1, 0, versionTag18);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
- entries->getEntry(keyPtr, result, value);
- ASSERT(CacheableToken::isInvalid(value) == true, "an exception");
- ASSERT(result->getVersionStamp().getMemberId() == 2, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 9, "an exception");
-
- auto keyPtr2 = CacheableKey::create("Key2");
- err = entries->put(keyPtr2, ccstr, me, oldValue, -1, 0, versionTag18);
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keyPtr2, result, value);
- ASSERT(atoi(value->toString()->asChar()) == 100, "an exception");
- ASSERT(me->getVersionStamp().getMemberId() == 1, "an exception");
-
- // version rollover, this will be applied
- err = entries->invalidate(keyPtr2, me, oldValue, versionTag22);
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keyPtr2, result, value);
- ASSERT(CacheableToken::isInvalid(value) == true, "an exception");
- ASSERT(result->getVersionStamp().getMemberId() == 2, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 9, "an exception");
-
- // Null version tag, this will be applied
- VersionTagPtr versionTag19;
- err = entries->put(keyPtr2, ccstr, me, oldValue, -1, 0, versionTag19);
- entries->getEntry(keyPtr2, result, value);
- ASSERT(CacheableToken::isInvalid(value) != true, "an exception");
- ASSERT(atoi(value->toString()->asChar()) == 100, "an exception");
- ASSERT(result->getVersionStamp().getMemberId() == 2, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 9, "an exception");
-
- // inserts a null tag
- auto keyPtr3 = CacheableKey::create("Key3");
- err = entries->put(keyPtr3, ccstr1, me, oldValue, -1, 0, versionTag19);
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keyPtr3, result, value);
- ASSERT(atoi(value->toString()->asChar()) == 500, "an exception");
- ASSERT(result->getVersionStamp().getMemberId() == 0, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 0, "an exception");
-
- // removes an entry with version tag, the previous entry is without version
- // stamp,
- // should be allowed.
- err = entries->invalidate(keyPtr3, me, oldValue, versionTag12);
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keyPtr3, result, value);
- ASSERT(CacheableToken::isInvalid(value) == true, "an exception");
- ASSERT(result->getVersionStamp().getMemberId() == 2, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 5, "an exception");
- delete entries;
- sprintf(log, "Invalidate test complete. %d", err);
- LOG(log);
- }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(CLIENT1, StepSeven_TestGetsAfterRemove)
- {
- auto lregPtr = std::dynamic_pointer_cast<LocalRegion>(regPtr);
- auto ccstr = createCacheable("100");
- auto ccstr1 = createCacheable("500");
- auto entryFactory = EntryFactory::singleton;
- entryFactory->setConcurrencyChecksEnabled(true);
- EntriesMap* entries =
- new ConcurrentEntriesMap(entryFactory, true, lregPtr.get());
- entries->open();
- auto keyPtr4 = CacheableKey::create("key4");
- auto keyPtr5 = CacheableKey::create("key5");
- auto keyPtr6 = CacheableKey::create("key6");
- MapEntryImplPtr me;
- MapEntryImplPtr result;
- CacheablePtr value;
- char log[256];
-
- auto versionTag1 = std::make_shared<VersionTag>(5, 6, 7, host1, 0);
-
- auto versionTag12 = std::make_shared<VersionTag>(5, 6, 7, host12, 0);
-
- auto versionTag22 = std::make_shared<VersionTag>(6, 6, 7, host12, 0);
-
- entries->put(keyPtr4, ccstr, me, value, -1, 0, versionTag1);
-
- auto err = entries->remove(keyPtr4, value, me, -1, versionTag12, false);
- ASSERT(err == GF_NOERR, "an exception");
- bool isTombstone;
- err = entries->isTombstone(keyPtr4, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
-
- entries->put(keyPtr5, ccstr, me, value, -1, 0, versionTag1);
-
- err = entries->remove(keyPtr5, value, me, -1, versionTag12, false);
- ASSERT(err == GF_NOERR, "an exception");
- err = entries->isTombstone(keyPtr5, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
-
- entries->put(keyPtr6, ccstr, me, value, -1, 0, versionTag1);
-
- ASSERT(entries->containsKey(keyPtr6) == true, "an exception");
- ASSERT(entries->containsKey(keyPtr5) == false, "an exception");
- ASSERT(entries->containsKey(keyPtr4) == false, "an exception");
- ASSERT(entries->get(keyPtr4, value, result) == false, "an exception");
- ASSERT(entries->get(keyPtr5, value, result) == false, "an exception");
- ASSERT(entries->get(keyPtr6, value, result) == true, "an exception");
-
- VectorOfCacheable values;
- entries->values(values);
- ASSERT(values.size() == 1, "an exception");
-
- VectorOfCacheableKey keys;
- entries->keys(keys);
- ASSERT(keys.size() == 1, "an exception");
-
- VectorOfRegionEntry regionEntries;
- entries->entries(regionEntries);
- ASSERT(regionEntries.size() == 1, "an exception");
-
- entries->put(keyPtr5, ccstr, me, value, -1, 0, versionTag22);
-
- ASSERT(entries->containsKey(keyPtr6) == true, "an exception");
- ASSERT(entries->containsKey(keyPtr5) == true, "an exception");
- ASSERT(entries->containsKey(keyPtr4) == false, "an exception");
- ASSERT(entries->get(keyPtr4, value, result) == false, "an exception");
- ASSERT(entries->get(keyPtr5, value, result) == true, "an exception");
- ASSERT(entries->get(keyPtr6, value, result) == true, "an exception");
-
- entries->values(values);
- ASSERT(values.size() == 2, "an exception");
-
- entries->keys(keys);
- ASSERT(keys.size() == 2, "an exception");
-
- entries->entries(regionEntries);
- ASSERT(regionEntries.size() == 2, "an exception");
-
- sprintf(log, "TestGetsAfterRemove test complete. %d", err);
- LOG(log);
-
- delete entries;
- }
-END_TASK_DEFINITION
-DUNIT_TASK_DEFINITION(CLIENT1, StepFour_TestRemove)
- {
- auto lregPtr = std::dynamic_pointer_cast<LocalRegion>(regPtr);
- auto ccstr = createCacheable("100");
- auto ccstr1 = createCacheable("500");
- auto entryFactory = EntryFactory::singleton;
- entryFactory->setConcurrencyChecksEnabled(true);
- EntriesMap* entries =
- new ConcurrentEntriesMap(entryFactory, true, lregPtr.get());
- entries->open();
- auto keyPtr = CacheableKey::create("key1");
- ASSERT(keyPtr != nullptr, "expected keyPtr non-nullptr");
- MapEntryImplPtr me;
- MapEntryImplPtr result;
- CacheablePtr value;
-
- auto versionTag1 = std::make_shared<VersionTag>(5, 6, 7, host1, 0);
-
- auto versionTag12 = std::make_shared<VersionTag>(5, 6, 7, host12, 0);
-
- auto versionTag13 = std::make_shared<VersionTag>(5, 6, 7, host13, 0);
- auto versionTag14 = std::make_shared<VersionTag>(5, 6, 7, host14, 0);
- auto versionTag15 = std::make_shared<VersionTag>(5, 6, 7, host15, 0);
- auto versionTag16 = std::make_shared<VersionTag>(5, 6, 7, host16, 0);
- auto versionTag17 = std::make_shared<VersionTag>(5, 6, 7, host17, 0);
- auto versionTag22 = std::make_shared<VersionTag>(9, 10, 10, host12, 0);
-
- CacheablePtr oldValue;
- entries->put(keyPtr, ccstr, me, oldValue, -1, 0, versionTag1);
- char log[256];
-
- auto err = entries->remove(keyPtr, oldValue, me, -1, versionTag12, false);
-
- ASSERT(err == GF_NOERR, "an exception");
- bool isTombstone;
- err = entries->isTombstone(keyPtr, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keyPtr, result, value);
- ASSERT(isTombstone == true, "an exception");
-
- err = entries->put(keyPtr, ccstr, me, oldValue, -1, 0, versionTag1);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
- err = entries->isTombstone(keyPtr, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
-
- auto tombstone_count =
- lregPtr->getCacheImpl()->m_cacheStats->getTombstoneCount();
- auto tombstone_size =
- lregPtr->getCacheImpl()->m_cacheStats->getTombstoneSize();
-
- sprintf(log,
- "After tombstone creation, Tombstone size: %" PRId64
- " Tombstone count: %d",
- tombstone_size, tombstone_count);
- LOG(log);
- ASSERT(tombstone_count == 1, "Tombstone count should be equal to 1");
- ASSERT(tombstone_size > 70,
- "Tombstone size should be greater than 70 bytes. 70 is an approx "
- "figure for tombstone overhead");
-
- err = entries->put(keyPtr, ccstr1, me, oldValue, -1, 0, versionTag13);
- ASSERT(err == GF_NOERR, "an exception");
- err = entries->isTombstone(keyPtr, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == false, "an exception");
-
- tombstone_count =
- lregPtr->getCacheImpl()->m_cacheStats->getTombstoneCount();
- tombstone_size = lregPtr->getCacheImpl()->m_cacheStats->getTombstoneSize();
-
- sprintf(log,
- "After converting tombstone into an entry, Tombstone size: %" PRId64
- " Tombstone count: %d",
- tombstone_size, tombstone_count);
- LOG(log);
- ASSERT(tombstone_count == 0, "Tombstone count should be equal to 0");
- ASSERT(tombstone_size == 0, "Tombstone size should be 0");
-
- err = entries->remove(keyPtr, oldValue, me, -1, versionTag1, false);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
- err = entries->isTombstone(keyPtr, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == false, "an exception");
- ASSERT(entries->get(keyPtr, value, result) == true, "an exception");
-
- err = entries->remove(keyPtr, oldValue, me, -1, versionTag14, false);
- ASSERT(err == GF_NOERR, "an exception");
- err = entries->isTombstone(keyPtr, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
- ASSERT(result->getVersionStamp().getMemberId() == 4, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 5, "an exception");
- ASSERT(entries->get(keyPtr, value, result) == false, "an exception");
-
- err = entries->put(keyPtr, ccstr, me, oldValue, -1, 0, versionTag1);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
-
- err = entries->put(keyPtr, ccstr1, me, oldValue, -1, 0, versionTag15);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
-
- err = entries->put(keyPtr, ccstr, me, oldValue, -1, 0, versionTag1);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
-
- err = entries->remove(keyPtr, oldValue, me, -1, versionTag16, false);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
-
- err = entries->remove(keyPtr, oldValue, me, -1, versionTag17, false);
- ASSERT(err == GF_CACHE_ENTRY_NOT_FOUND, "an exception");
- err = entries->isTombstone(keyPtr, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
- ASSERT(result->getVersionStamp().getMemberId() == 7, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 5, "an exception");
- ASSERT(entries->get(keyPtr, value, result) == false, "an exception");
-
- err = entries->remove(keyPtr, oldValue, me, -1, versionTag22, false);
- ASSERT(err == GF_CACHE_ENTRY_NOT_FOUND, "an exception");
- err = entries->isTombstone(keyPtr, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
- ASSERT(result->getVersionStamp().getMemberId() == 2, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 9, "an exception");
- ASSERT(entries->get(keyPtr, value, result) == false, "an exception");
-
- auto versionTag18 = std::make_shared<VersionTag>(0xffffaa, 6, 7, host1, 0);
-
- // version rollover, this will not be applied
- err = entries->put(keyPtr, ccstr, me, oldValue, -1, 0, versionTag18);
- ASSERT(err == GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION, "an exception");
- err = entries->isTombstone(keyPtr, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
- ASSERT(result->getVersionStamp().getMemberId() == 2, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 9, "an exception");
- ASSERT(entries->get(keyPtr, value, result) == false, "an exception");
-
- auto keyPtr2 = CacheableKey::create("Key2");
- err = entries->put(keyPtr2, ccstr, me, oldValue, -1, 0, versionTag18);
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keyPtr2, result, value);
- ASSERT(atoi(value->toString()->asChar()) == 100, "an exception");
- ASSERT(me->getVersionStamp().getMemberId() == 1, "an exception");
-
- // version rollover, this will be applied
- err = entries->remove(keyPtr2, oldValue, me, -1, versionTag22, false);
- ASSERT(err == GF_NOERR, "an exception");
- err = entries->isTombstone(keyPtr2, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
- ASSERT(result->getVersionStamp().getMemberId() == 2, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 9, "an exception");
- ASSERT(entries->get(keyPtr2, value, result) == false, "an exception");
-
- // Null version tag, this will be applied
- VersionTagPtr versionTag19;
- err = entries->put(keyPtr2, ccstr, me, oldValue, -1, 0, versionTag19);
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keyPtr2, result, value);
- ASSERT(atoi(value->toString()->asChar()) == 100, "an exception");
- ASSERT(result->getVersionStamp().getMemberId() == 2, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 9, "an exception");
-
- // inserts a null tag
- auto keyPtr3 = CacheableKey::create("Key3");
- err = entries->put(keyPtr3, ccstr1, me, oldValue, -1, 0, versionTag19);
- ASSERT(err == GF_NOERR, "an exception");
- entries->getEntry(keyPtr3, result, value);
- ASSERT(atoi(value->toString()->asChar()) == 500, "an exception");
- ASSERT(result->getVersionStamp().getMemberId() == 0, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 0, "an exception");
-
- // removes an entry with version tag, the previous entry is without version
- // stamp,
- // should be allowed.
- err = entries->remove(keyPtr3, oldValue, me, 0, versionTag12, false);
- ASSERT(err == GF_NOERR, "an exception");
- err = entries->isTombstone(keyPtr3, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
- ASSERT(result->getVersionStamp().getMemberId() == 2, "an exception");
- ASSERT(result->getVersionStamp().getEntryVersion() == 5, "an exception");
- ASSERT(entries->get(keyPtr3, value, result) == false, "an exception");
-
- auto keyPtrR2 = CacheableKey::create("keyPtrR2");
- auto keyPtrR3 = CacheableKey::create("keyPtrR3");
- auto keyPtrR4 = CacheableKey::create("keyPtrR4");
- auto keyPtrR5 = CacheableKey::create("keyPtrR5");
- auto keyPtrR6 = CacheableKey::create("keyPtrR6");
-
- auto keyPtrR21 = CacheableKey::create("keyPtrR21");
- auto keyPtrR31 = CacheableKey::create("keyPtrR31");
- auto keyPtrR41 = CacheableKey::create("keyPtrR41");
- auto keyPtrR51 = CacheableKey::create("keyPtrR51");
- auto keyPtrR61 = CacheableKey::create("keyPtrR61");
-
- auto versionTag23 = std::make_shared<VersionTag>(9, 10, 10, host13, 0);
- auto versionTag24 = std::make_shared<VersionTag>(9, 10, 10, host14, 0);
- auto versionTag25 = std::make_shared<VersionTag>(9, 10, 10, host15, 0);
- auto versionTag26 = std::make_shared<VersionTag>(9, 10, 10, host16, 0);
-
- sprintf(log, "Test reaping of tombstones");
- LOG(log);
-
- // add few entries with null version tags
- err = entries->put(keyPtrR2, ccstr1, me, oldValue, -1, 0, versionTag19);
- err = entries->put(keyPtrR3, ccstr1, me, oldValue, -1, 0, versionTag19);
- err = entries->put(keyPtrR4, ccstr1, me, oldValue, -1, 0, versionTag19);
- err = entries->put(keyPtrR5, ccstr1, me, oldValue, -1, 0, versionTag19);
- err = entries->put(keyPtrR21, ccstr1, me, oldValue, -1, 0, versionTag19);
- err = entries->put(keyPtrR31, ccstr1, me, oldValue, -1, 0, versionTag19);
- err = entries->put(keyPtrR41, ccstr1, me, oldValue, -1, 0, versionTag19);
- err = entries->put(keyPtrR51, ccstr1, me, oldValue, -1, 0, versionTag19);
- err = entries->put(keyPtrR61, ccstr1, me, oldValue, -1, 0, versionTag19);
-
- // remove those entries using non null version tags
- err = entries->remove(keyPtrR2, oldValue, me, -1, versionTag12, false);
- err = entries->remove(keyPtrR3, oldValue, me, -1, versionTag13, false);
- err = entries->remove(keyPtrR4, oldValue, me, -1, versionTag14, false);
- err = entries->remove(keyPtrR5, oldValue, me, -1, versionTag15, false);
- err = entries->remove(keyPtrR21, oldValue, me, -1, versionTag22, false);
- err = entries->remove(keyPtrR31, oldValue, me, -1, versionTag23, false);
- err = entries->remove(keyPtrR41, oldValue, me, -1, versionTag24, false);
- err = entries->remove(keyPtrR51, oldValue, me, -1, versionTag25, false);
- err = entries->remove(keyPtrR61, oldValue, me, -1, versionTag26, false);
-
- // test if all of them have been converted into tombstones.
- err = entries->isTombstone(keyPtrR2, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
- err = entries->isTombstone(keyPtrR3, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
- err = entries->isTombstone(keyPtrR4, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
- err = entries->isTombstone(keyPtrR5, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
- err = entries->isTombstone(keyPtrR21, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
- err = entries->isTombstone(keyPtrR31, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
- err = entries->isTombstone(keyPtrR41, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
- err = entries->isTombstone(keyPtrR51, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
-
- // generate dummy gc versions
- std::map<uint16_t, int64_t> gcVersions;
- int64_t temp = 3;
- temp = temp << 32;
- gcVersions[1] = temp;
- gcVersions[2] = temp;
- temp = 11;
- temp = temp << 32;
- gcVersions[3] = temp;
- temp = 9;
- temp = temp << 32;
- gcVersions[4] = temp;
- temp = 10;
- temp = temp << 32;
- gcVersions[5] = temp;
-
- // reap entries based on gc versions
- entries->reapTombstones(gcVersions);
-
- // make sure entries are reaped
- err = entries->isTombstone(keyPtrR2, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
- ASSERT(entries->get(keyPtrR2, value, result) == false, "an exception");
- err = entries->isTombstone(keyPtrR3, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == false, "an exception");
- ASSERT(entries->get(keyPtrR3, value, result) == false, "an exception");
- err = entries->isTombstone(keyPtrR4, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == false, "an exception");
- ASSERT(entries->get(keyPtrR4, value, result) == false, "an exception");
-
- err = entries->isTombstone(keyPtrR5, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == false, "an exception");
- ASSERT(entries->get(keyPtrR5, value, result) == false, "an exception");
-
- err = entries->isTombstone(keyPtrR21, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
- ASSERT(entries->get(keyPtrR21, value, result) == false, "an exception");
-
- err = entries->isTombstone(keyPtrR31, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == false, "an exception");
- ASSERT(entries->get(keyPtrR31, value, result) == false, "an exception");
-
- err = entries->isTombstone(keyPtrR41, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
- ASSERT(entries->get(keyPtrR41, value, result) == false, "an exception");
-
- err = entries->isTombstone(keyPtrR51, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
- ASSERT(entries->get(keyPtrR51, value, result) == false, "an exception");
-
- sprintf(log, "Remove test complete. %d", err);
- LOG(log);
- // reap using removedKeys API
- auto keyPtrR71 = CacheableKey::create("keyPtrR71");
- auto removedKeys = CacheableHashSet::create();
- removedKeys->insert(keyPtrR3);
- removedKeys->insert(keyPtrR71);
- removedKeys->insert(keyPtrR2);
- removedKeys->insert(keyPtrR41);
-
- // reap entries based keys
- entries->reapTombstones(removedKeys);
-
- // make sure entries are reaped
- err = entries->isTombstone(keyPtrR2, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == false, "an exception");
- err = entries->isTombstone(keyPtrR3, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == false, "an exception");
- err = entries->isTombstone(keyPtrR4, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == false, "an exception");
- err = entries->isTombstone(keyPtrR5, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == false, "an exception");
- err = entries->isTombstone(keyPtrR21, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
- err = entries->isTombstone(keyPtrR31, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == false, "an exception");
- err = entries->isTombstone(keyPtrR41, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == false, "an exception");
- err = entries->isTombstone(keyPtrR51, result, isTombstone);
- ASSERT(err == GF_NOERR, "an exception");
- ASSERT(isTombstone == true, "an exception");
- delete entries;
- }
-END_TASK_DEFINITION
-void runTask() {
- CALL_TASK(CREATECLIENT);
- CALL_TASK(StepOne_AddHosts);
- CALL_TASK(StepTwo_TestPut);
- CALL_TASK(StepThree_TestCreate);
- CALL_TASK(StepFour_TestRemove);
- CALL_TASK(StepFive_TestTombstoneExpiry);
- CALL_TASK(StepSix_TestInvalidate);
- CALL_TASK(StepSeven_TestGetsAfterRemove);
- CALL_TASK(StepEight_TestLRUEntries);
- CALL_TASK(CloseCache1);
-}
-
-DUNIT_MAIN
- { runTask(); }
-END_MAIN
-
-#endif
[23/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/CliCallbackDelgate.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/CliCallbackDelgate.cpp b/src/clicache/src/impl/CliCallbackDelgate.cpp
new file mode 100644
index 0000000..acb0c6c
--- /dev/null
+++ b/src/clicache/src/impl/CliCallbackDelgate.cpp
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+#include "CliCallbackDelgate.hpp"
+
+#include "begin_native.hpp"
+#include "CacheRegionHelper.hpp"
+#include "end_native.hpp"
+
+#include "../Cache.hpp"
+using namespace System;
+
+namespace Apache
+{
+ namespace Geode
+ {
+ namespace Client
+ {
+ void CliCallbackDelegate::Callback(apache::geode::client::Cache& cache)
+ {
+ Apache::Geode::Client::Log::Fine("CliCallbackDelgate::Callback( ) ");
+ CacheRegionHelper::getCacheImpl(&cache)->getPdxTypeRegistry()->clear();
+ }
+ } // namespace Client
+ } // namespace Geode
+} // namespace Apache
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/CliCallbackDelgate.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/CliCallbackDelgate.hpp b/src/clicache/src/impl/CliCallbackDelgate.hpp
index 2bb688a..4029652 100755
--- a/src/clicache/src/impl/CliCallbackDelgate.hpp
+++ b/src/clicache/src/impl/CliCallbackDelgate.hpp
@@ -24,6 +24,7 @@
#include "../Log.hpp"
#include "PdxTypeRegistry.hpp"
+
using namespace System;
namespace Apache
@@ -32,7 +33,7 @@ namespace Apache
{
namespace Client
{
-
+ ref class Cache;
/// <summary>
/// to get the callback from c++ layer
/// </summary>
@@ -40,17 +41,12 @@ namespace Apache
{
public:
- inline CliCallbackDelegate( )
- {
- }
-
- void Callback( )
- {
- Apache::Geode::Client::Log::Fine("CliCallbackDelgate::Callback( ) ");
- Apache::Geode::Client::Internal::PdxTypeRegistry::clear();
- }
-
+ CliCallbackDelegate()
+ {}
+ void Callback(apache::geode::client::Cache& cache);
+
+ CliCallbackDelegate(const CliCallbackDelegate^ other){}
private:
};
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/DelegateWrapper.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/DelegateWrapper.hpp b/src/clicache/src/impl/DelegateWrapper.hpp
index 45a1550..68da9f9 100644
--- a/src/clicache/src/impl/DelegateWrapper.hpp
+++ b/src/clicache/src/impl/DelegateWrapper.hpp
@@ -17,6 +17,12 @@
#pragma once
+#include "begin_native.hpp"
+#include "CacheImpl.hpp"
+#include "CacheRegionHelper.hpp"
+#include "end_native.hpp"
+
+#include "Cache.hpp"
#include "../geode_defs.hpp"
#include "../Serializable.hpp"
#include "ManagedCacheableKey.hpp"
@@ -31,7 +37,7 @@ namespace Apache
{
namespace Client
{
-
+ namespace native = apache::geode::client;
/// <summary>
/// Template class to wrap a managed <see cref="TypeFactoryMethod" />
/// delegate that returns an <see cref="IGeodeSerializable" /> object. It contains
@@ -63,8 +69,8 @@ namespace Apache
/// <summary>
/// Constructor to wrap the given managed delegate.
/// </summary>
- inline DelegateWrapperGeneric( TypeFactoryMethodGeneric^ typeDelegate )
- : m_delegate( typeDelegate ) { }
+ inline DelegateWrapperGeneric( TypeFactoryMethodGeneric^ typeDelegate, Cache^ cache )
+ : m_delegate( typeDelegate ), m_cache(cache) { }
/// <summary>
/// Returns the native <c>apache::geode::client::Serializable</c> object by invoking the
@@ -87,7 +93,7 @@ namespace Apache
return new apache::geode::client::ManagedCacheableDeltaBytesGeneric( tempDelta, false );
}
else if(!SafeConvertClassGeneric::isAppDomainEnabled)
- return new apache::geode::client::ManagedCacheableKeyGeneric( tempObj);
+ return new apache::geode::client::ManagedCacheableKeyGeneric( tempObj, CacheRegionHelper::getCacheImpl(m_cache->GetNative().get())->getSerializationRegistry().get());
else
return new apache::geode::client::ManagedCacheableKeyBytesGeneric( tempObj, false);
}
@@ -96,6 +102,8 @@ namespace Apache
private:
TypeFactoryMethodGeneric^ m_delegate;
+
+ Cache^ m_cache;
};
} // namespace Client
} // namespace Geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/FixedPartitionResolver.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/FixedPartitionResolver.hpp b/src/clicache/src/impl/FixedPartitionResolver.hpp
index 03f57c9..38a3fa3 100644
--- a/src/clicache/src/impl/FixedPartitionResolver.hpp
+++ b/src/clicache/src/impl/FixedPartitionResolver.hpp
@@ -60,7 +60,7 @@ namespace Apache
{
EntryEvent<TKey, TValue> gevent(&ev);
Object^ groutingobject = m_resolver->GetRoutingObject(%gevent);
- return Serializable::GetUnmanagedValueGeneric<Object^>(groutingobject);
+ return Serializable::GetUnmanagedValueGeneric<Object^>(groutingobject, nullptr);
}
virtual const char * getName()
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/ManagedAuthInitialize.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/ManagedAuthInitialize.cpp b/src/clicache/src/impl/ManagedAuthInitialize.cpp
index 4ad28bb..61e0683 100644
--- a/src/clicache/src/impl/ManagedAuthInitialize.cpp
+++ b/src/clicache/src/impl/ManagedAuthInitialize.cpp
@@ -170,7 +170,7 @@ namespace apache
return NULL;
}
- PropertiesPtr ManagedAuthInitializeGeneric::getCredentials(PropertiesPtr&
+ PropertiesPtr ManagedAuthInitializeGeneric::getCredentials(const PropertiesPtr&
securityprops, const char* server)
{
try {
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/ManagedAuthInitialize.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/ManagedAuthInitialize.hpp b/src/clicache/src/impl/ManagedAuthInitialize.hpp
index 482a9e7..83f7961 100644
--- a/src/clicache/src/impl/ManagedAuthInitialize.hpp
+++ b/src/clicache/src/impl/ManagedAuthInitialize.hpp
@@ -101,7 +101,7 @@ namespace apache
/// </param>
/// <param name="server">It is the ID of the endpoint
/// </param>
- virtual PropertiesPtr getCredentials(PropertiesPtr& securityprops, const char* server);
+ virtual PropertiesPtr getCredentials(const PropertiesPtr& securityprops, const char* server);
virtual ~ManagedAuthInitializeGeneric() { }
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/ManagedCacheableDelta.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/ManagedCacheableDelta.cpp b/src/clicache/src/impl/ManagedCacheableDelta.cpp
index 75fc5cf..8c0c0d1 100644
--- a/src/clicache/src/impl/ManagedCacheableDelta.cpp
+++ b/src/clicache/src/impl/ManagedCacheableDelta.cpp
@@ -59,7 +59,7 @@ namespace apache
{
try {
int pos = input.getBytesRead();
- Apache::Geode::Client::DataInput mg_input(&input, true);
+ Apache::Geode::Client::DataInput mg_input(&input, true, input.getCache());
m_managedSerializableptr->FromData(%mg_input);
//this will move the cursor in c++ layer
@@ -178,7 +178,7 @@ namespace apache
void ManagedCacheableDeltaGeneric::fromDelta(DataInput& input)
{
try {
- Apache::Geode::Client::DataInput mg_input(&input, true);
+ Apache::Geode::Client::DataInput mg_input(&input, true, input.getCache());
m_managedptr->FromDelta(%mg_input);
//this will move the cursor in c++ layer
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/ManagedCacheableDelta.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/ManagedCacheableDelta.hpp b/src/clicache/src/impl/ManagedCacheableDelta.hpp
index a531178..9211a8d 100644
--- a/src/clicache/src/impl/ManagedCacheableDelta.hpp
+++ b/src/clicache/src/impl/ManagedCacheableDelta.hpp
@@ -72,7 +72,7 @@ namespace apache
/// </param>
inline ManagedCacheableDeltaGeneric(
Apache::Geode::Client::IGeodeDelta^ managedptr)
- : m_managedptr(managedptr)
+ : Delta(nullptr), m_managedptr(managedptr)
{
m_managedSerializableptr = dynamic_cast <Apache::Geode::Client::IGeodeSerializable^> (managedptr);
m_classId = m_managedSerializableptr->ClassId;
@@ -81,7 +81,7 @@ namespace apache
inline ManagedCacheableDeltaGeneric(
Apache::Geode::Client::IGeodeDelta^ managedptr, int hashcode, int classId)
- : m_managedptr(managedptr) {
+ :Delta(nullptr), m_managedptr(managedptr) {
m_hashcode = hashcode;
m_classId = classId;
m_managedSerializableptr = dynamic_cast <Apache::Geode::Client::IGeodeSerializable^> (managedptr);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/ManagedCacheableDeltaBytes.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/ManagedCacheableDeltaBytes.cpp b/src/clicache/src/impl/ManagedCacheableDeltaBytes.cpp
index e7f590c..18472c4 100644
--- a/src/clicache/src/impl/ManagedCacheableDeltaBytes.cpp
+++ b/src/clicache/src/impl/ManagedCacheableDeltaBytes.cpp
@@ -54,7 +54,7 @@ namespace apache
{
try {
Apache::Geode::Client::Log::Debug("ManagedCacheableDeltaBytes::fromData: classid " + m_classId);
- Apache::Geode::Client::DataInput mg_input(&input, true);
+ Apache::Geode::Client::DataInput mg_input(&input, true, input.getCache());
const System::Byte* objStartPos = input.currentBufferPosition();
Apache::Geode::Client::IGeodeSerializable^ obj =
@@ -179,7 +179,7 @@ namespace apache
try {
Apache::Geode::Client::Log::Debug("ManagedCacheableDeltaBytes::fromDelta:");
Apache::Geode::Client::IGeodeDelta^ deltaObj = this->getManagedObject();
- Apache::Geode::Client::DataInput mg_input(&input, true);
+ Apache::Geode::Client::DataInput mg_input(&input, true, input.getCache());
deltaObj->FromDelta(%mg_input);
Apache::Geode::Client::IGeodeSerializable^ managedptr =
@@ -188,8 +188,8 @@ namespace apache
{
Apache::Geode::Client::Log::Debug("ManagedCacheableDeltaBytes::fromDelta: current domain ID: " + System::Threading::Thread::GetDomainID() + " for object: " + System::Convert::ToString((uint64_t) this) + " with its domain ID: " + m_domainId);
Apache::Geode::Client::Log::Debug("ManagedCacheableDeltaBytes::fromDelta: classid " + managedptr->ClassId + " : " + managedptr->ToString());
- apache::geode::client::DataOutput dataOut;
- Apache::Geode::Client::DataOutput mg_output(&dataOut, true);
+ auto dataOut = input.getCache()->createDataOutput();
+ Apache::Geode::Client::DataOutput mg_output(dataOut.get(), true);
managedptr->ToData(%mg_output);
//move cursor
@@ -197,8 +197,8 @@ namespace apache
mg_output.WriteBytesToUMDataOutput();
GF_SAFE_DELETE(m_bytes);
- m_bytes = dataOut.getBufferCopy();
- m_size = dataOut.getBufferLength();
+ m_bytes = dataOut->getBufferCopy();
+ m_size = dataOut->getBufferLength();
Apache::Geode::Client::Log::Debug("ManagedCacheableDeltaBytes::fromDelta objectSize = " + m_size + " m_hashCode = " + m_hashCode);
m_hashCode = managedptr->GetHashCode();
}
@@ -241,8 +241,8 @@ namespace apache
Apache::Geode::Client::Log::Debug("ManagedCacheableDeltaBytes::getManagedObject");
- apache::geode::client::DataInput dinp(m_bytes, m_size);
- Apache::Geode::Client::DataInput mg_dinp(&dinp, true);
+ auto dinp = m_cache->createDataInput(m_bytes, m_size);
+ Apache::Geode::Client::DataInput mg_dinp(dinp.get(), true, m_cache);
Apache::Geode::Client::TypeFactoryMethodGeneric^ creationMethod =
Apache::Geode::Client::Serializable::GetTypeFactoryMethodGeneric(m_classId);
Apache::Geode::Client::IGeodeSerializable^ newObj = creationMethod();
@@ -261,8 +261,8 @@ namespace apache
const ManagedCacheableDeltaBytesGeneric* p_other =
dynamic_cast<const ManagedCacheableDeltaBytesGeneric*>(&other);
if (p_other != NULL) {
- apache::geode::client::DataInput di(m_bytes, m_size);
- Apache::Geode::Client::DataInput mg_input(&di, true);
+ auto di = m_cache->createDataInput(m_bytes, m_size);
+ Apache::Geode::Client::DataInput mg_input(di.get(), true, m_cache);
Apache::Geode::Client::IGeodeSerializable^ obj =
Apache::Geode::Client::Serializable::GetTypeFactoryMethodGeneric(m_classId)();
obj->FromData(%mg_input);
@@ -285,8 +285,8 @@ namespace apache
{
try {
Apache::Geode::Client::Log::Debug("ManagedCacheableDeltaBytesGeneric::equal. ");
- apache::geode::client::DataInput di(m_bytes, m_size);
- Apache::Geode::Client::DataInput mg_input(&di, true);
+ auto di = m_cache->createDataInput(m_bytes, m_size);
+ Apache::Geode::Client::DataInput mg_input(di.get(), true, m_cache);
Apache::Geode::Client::IGeodeSerializable^ obj =
Apache::Geode::Client::Serializable::GetTypeFactoryMethodGeneric(m_classId)();
obj->FromData(%mg_input);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/ManagedCacheableDeltaBytes.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/ManagedCacheableDeltaBytes.hpp b/src/clicache/src/impl/ManagedCacheableDeltaBytes.hpp
index 905d08a..c5fcbb2 100644
--- a/src/clicache/src/impl/ManagedCacheableDeltaBytes.hpp
+++ b/src/clicache/src/impl/ManagedCacheableDeltaBytes.hpp
@@ -20,7 +20,10 @@
#include "../geode_defs.hpp"
#include <vcclr.h>
#include "begin_native.hpp"
+#include "SerializationRegistry.hpp"
+#include <geode/Cache.hpp>
#include <geode/Delta.hpp>
+#include <geode/DataOutput.hpp>
#include "end_native.hpp"
#include "../Log.hpp"
@@ -67,7 +70,7 @@ namespace apache
/// </param>
inline ManagedCacheableDeltaBytesGeneric(
Apache::Geode::Client::IGeodeDelta^ managedDeltaptr, bool storeBytes)
- : m_domainId(System::Threading::Thread::GetDomainID()),
+ :Delta(nullptr), m_domainId(System::Threading::Thread::GetDomainID()),
m_classId(0),
m_bytes(NULL),
m_size(0),
@@ -85,48 +88,22 @@ namespace apache
Apache::Geode::Client::Log::Finer("ManagedCacheableDeltaBytes::Constructor: class ID " + managedptr->ClassId + " : " + managedptr->ToString() + " storeBytes:" + storeBytes);
if (storeBytes)
{
- apache::geode::client::DataOutput dataOut;
- Apache::Geode::Client::DataOutput mg_output(&dataOut, true);
+ auto dataOut = m_cache->createDataOutput();
+ Apache::Geode::Client::DataOutput mg_output(dataOut.get(), true);
managedptr->ToData(%mg_output);
//move cursor
//dataOut.advanceCursor(mg_output.BufferLength);
mg_output.WriteBytesToUMDataOutput();
- m_bytes = dataOut.getBufferCopy();
- m_size = dataOut.getBufferLength();
+ m_bytes = dataOut->getBufferCopy();
+ m_size = dataOut->getBufferLength();
m_hashCode = managedptr->GetHashCode();
Apache::Geode::Client::Log::Finer("ManagedCacheableDeltaBytes::Constructor objectSize = " + m_size + " m_hashCode = " + m_hashCode);
}
}
}
- /*
- inline ManagedCacheableDeltaBytes(
- Apache::Geode::Client::IGeodeDelta^ managedDeltaptr, bool storeBytes)
- : m_domainId(System::Threading::Thread::GetDomainID()),
- m_classId(0),
- m_bytes(NULL),
- m_size(0),
- m_hashCode(0)
- {
- Apache::Geode::Client::Log::Fine("ManagedCacheableDeltaBytes::Constructor: not storing bytes ");
- Apache::Geode::Client::IGeodeSerializable^ managedptr = dynamic_cast <Apache::Geode::Client::IGeodeSerializable^> ( managedDeltaptr );
- if(managedptr != nullptr)
- {
- m_classId = managedptr->ClassId;
- Apache::Geode::Client::Log::Fine("ManagedCacheableDeltaBytes::Constructor: current AppDomain ID: " + System::Threading::Thread::GetDomainID() + " for object: " + System::Convert::ToString((uint64_t) this) + " with its AppDomain ID: " + m_domainId);
- Apache::Geode::Client::Log::Fine("ManagedCacheableDeltaBytes::Constructor: class ID " + managedptr->ClassId + " : " + managedptr->ToString());
- apache::geode::client::DataOutput dataOut;
- Apache::Geode::Client::DataOutput mg_output( &dataOut);
- managedptr->ToData( %mg_output );
- m_bytes = dataOut.getBufferCopy();
- m_size = dataOut.getBufferLength();
- Apache::Geode::Client::Log::Fine("ManagedCacheableDeltaBytes::Constructor objectSize = " + m_size + " m_hashCode = " + m_hashCode);
- m_hashCode = managedptr->GetHashCode();
- }
- }*/
-
-
+
/// <summary>
/// serialize this object
/// </summary>
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/ManagedCacheableKey.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/ManagedCacheableKey.cpp b/src/clicache/src/impl/ManagedCacheableKey.cpp
index d30d41e..8cefef9 100644
--- a/src/clicache/src/impl/ManagedCacheableKey.cpp
+++ b/src/clicache/src/impl/ManagedCacheableKey.cpp
@@ -62,7 +62,7 @@ namespace apache
try {
int pos = input.getBytesRead();
//Apache::Geode::Client::Log::Debug("ManagedCacheableKeyGeneric::fromData");
- Apache::Geode::Client::DataInput mg_input(&input, true);
+ Apache::Geode::Client::DataInput mg_input(&input, true, input.getCache());
m_managedptr = m_managedptr->FromData(%mg_input);
//this will move the cursor in c++ layer
@@ -102,28 +102,15 @@ namespace apache
System::Int32 ManagedCacheableKeyGeneric::classId() const
{
- //Apache::Geode::Client::Log::Debug("ManagedCacheableKeyGeneric::classid " + m_classId);
- /*System::UInt32 classId;
- try {
- classId = m_managedptr->ClassId;
- }
- catch (GeodeException^ ex) {
- ex->ThrowNative();
- }
- catch (System::Exception^ ex) {
- GeodeException::ThrowNative(ex);
- }*/
return (m_classId >= 0x80000000 ? 0 : m_classId);
}
int8_t ManagedCacheableKeyGeneric::typeId() const
{
- //Apache::Geode::Client::Log::Debug("ManagedCacheableKeyGeneric::typeId " + m_classId);
if (m_classId >= 0x80000000) {
return (int8_t)((m_classId - 0x80000000) % 0x20000000);
}
else if (m_classId <= 0x7F) {
- //Apache::Geode::Client::Log::Debug("ManagedCacheableKeyGeneric::typeId inin");
return (int8_t)GeodeTypeIdsImpl::CacheableUserData;
}
else if (m_classId <= 0x7FFF) {
@@ -136,12 +123,6 @@ namespace apache
int8_t ManagedCacheableKeyGeneric::DSFID() const
{
- // convention that [0x8000000, 0xa0000000) is for FixedIDDefault,
- // [0xa000000, 0xc0000000) is for FixedIDByte,
- // [0xc0000000, 0xe0000000) is for FixedIDShort
- // and [0xe0000000, 0xffffffff] is for FixedIDInt
- // Note: depends on fact that FixedIDByte is 1, FixedIDShort is 2
- // and FixedIDInt is 3; if this changes then correct this accordingly
if (m_classId >= 0x80000000) {
return (int8_t)((m_classId - 0x80000000) / 0x20000000);
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/ManagedCacheableKey.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/ManagedCacheableKey.hpp b/src/clicache/src/impl/ManagedCacheableKey.hpp
index 27fa215..1f3c27f 100644
--- a/src/clicache/src/impl/ManagedCacheableKey.hpp
+++ b/src/clicache/src/impl/ManagedCacheableKey.hpp
@@ -22,6 +22,7 @@
#include "begin_native.hpp"
#include <geode/CacheableKey.hpp>
#include <GeodeTypeIdsImpl.hpp>
+#include "SerializationRegistry.hpp"
#include "end_native.hpp"
#include "../IGeodeSerializable.hpp"
@@ -34,6 +35,7 @@ namespace apache
{
namespace client
{
+ namespace native = apache::geode::client;
/// <summary>
/// Wraps the managed <see cref="Apache.Geode.Client.IGeodeSerializable" />
@@ -45,14 +47,16 @@ namespace apache
private:
int m_hashcode;
int m_classId;
+ native::SerializationRegistry* m_serializationRegistry;
int m_objectSize;
public:
inline ManagedCacheableKeyGeneric(
- Apache::Geode::Client::IGeodeSerializable^ managedptr, int hashcode, int classId)
+ Apache::Geode::Client::IGeodeSerializable^ managedptr, int hashcode, int classId, native::SerializationRegistry * serializationRegistry)
: m_managedptr(managedptr) {
m_hashcode = hashcode;
m_classId = classId;
+ m_serializationRegistry = serializationRegistry;
m_objectSize = 0;
}
/// <summary>
@@ -61,11 +65,12 @@ namespace apache
/// <param name="managedptr">
/// The managed object.
/// </param>
- inline ManagedCacheableKeyGeneric(Apache::Geode::Client::IGeodeSerializable^ managedptr)
+ inline ManagedCacheableKeyGeneric(Apache::Geode::Client::IGeodeSerializable^ managedptr, native::SerializationRegistry * serializationRegistry)
: m_managedptr(managedptr) {
// m_hashcode = managedptr->GetHashCode();
m_hashcode = 0;
m_classId = managedptr->ClassId;
+ m_serializationRegistry = serializationRegistry;
m_objectSize = 0;
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/ManagedCacheableKeyBytes.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/ManagedCacheableKeyBytes.cpp b/src/clicache/src/impl/ManagedCacheableKeyBytes.cpp
index 5d39280..93e01bc 100644
--- a/src/clicache/src/impl/ManagedCacheableKeyBytes.cpp
+++ b/src/clicache/src/impl/ManagedCacheableKeyBytes.cpp
@@ -16,7 +16,9 @@
*/
#include "begin_native.hpp"
+#include <geode/Cache.hpp>
#include <GeodeTypeIdsImpl.hpp>
+#include "DataInputInternal.hpp"
#include "end_native.hpp"
#include "ManagedCacheableKeyBytes.hpp"
@@ -56,7 +58,7 @@ namespace apache
try {
Apache::Geode::Client::Log::Debug("ManagedCacheableKeyBytesGeneric::fromData: classid " + m_classId + "aid = " + +System::Threading::Thread::GetDomainID());
- Apache::Geode::Client::DataInput mg_input(&input, true);
+ Apache::Geode::Client::DataInput mg_input(&input, true, input.getCache());
const System::Byte* objStartPos = input.currentBufferPosition();
Apache::Geode::Client::IGeodeSerializable^ obj = Apache::Geode::Client::Serializable::GetTypeFactoryMethodGeneric(m_classId)();
@@ -187,8 +189,8 @@ namespace apache
const ManagedCacheableKeyBytesGeneric* p_other =
dynamic_cast<const ManagedCacheableKeyBytesGeneric*>(&other);
if (p_other != NULL) {
- apache::geode::client::DataInput di(m_bytes, m_size);
- Apache::Geode::Client::DataInput mg_input(&di, true);
+ DataInputInternal di(m_bytes, m_size, nullptr);
+ Apache::Geode::Client::DataInput mg_input(&di, true, nullptr);
Apache::Geode::Client::IGeodeSerializable^ obj =
Apache::Geode::Client::Serializable::GetTypeFactoryMethodGeneric(m_classId)();
obj->FromData(%mg_input);
@@ -211,8 +213,8 @@ namespace apache
{
try {
Apache::Geode::Client::Log::Debug("ManagedCacheableKeyBytesGeneric::equal. ");
- apache::geode::client::DataInput di(m_bytes, m_size);
- Apache::Geode::Client::DataInput mg_input(&di, true);
+ DataInputInternal di(m_bytes, m_size, nullptr);
+ Apache::Geode::Client::DataInput mg_input(&di, true, nullptr);
Apache::Geode::Client::IGeodeSerializable^ obj =
Apache::Geode::Client::Serializable::GetTypeFactoryMethodGeneric(m_classId)();
obj->FromData(%mg_input);
@@ -274,8 +276,8 @@ namespace apache
//}
// Apache::Geode::Client::Log::Debug("ManagedCacheableKeyBytesGeneric::getManagedObject " + sb);
- apache::geode::client::DataInput dinp(m_bytes, m_size);
- Apache::Geode::Client::DataInput mg_dinp(&dinp, true);
+ DataInputInternal dinp(m_bytes, m_size, nullptr);
+ Apache::Geode::Client::DataInput mg_dinp(&dinp, true, nullptr);
Apache::Geode::Client::TypeFactoryMethodGeneric^ creationMethod =
Apache::Geode::Client::Serializable::GetTypeFactoryMethodGeneric(m_classId);
Apache::Geode::Client::IGeodeSerializable^ newObj = creationMethod();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/ManagedCacheableKeyBytes.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/ManagedCacheableKeyBytes.hpp b/src/clicache/src/impl/ManagedCacheableKeyBytes.hpp
index e0b4ecf..10f0466 100644
--- a/src/clicache/src/impl/ManagedCacheableKeyBytes.hpp
+++ b/src/clicache/src/impl/ManagedCacheableKeyBytes.hpp
@@ -21,6 +21,7 @@
#include <vcclr.h>
#include "begin_native.hpp"
#include <geode/CacheableKey.hpp>
+#include "DataOutputInternal.hpp"
#include "end_native.hpp"
#include "../Log.hpp"
@@ -76,7 +77,7 @@ namespace apache
{
if (storeBytes)//if value is from app
{
- apache::geode::client::DataOutput dataOut;
+ DataOutputInternal dataOut;
Apache::Geode::Client::DataOutput mg_output(&dataOut, true);
managedptr->ToData(%mg_output);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/ManagedString.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/ManagedString.hpp b/src/clicache/src/impl/ManagedString.hpp
index d869ad9..ed67695 100644
--- a/src/clicache/src/impl/ManagedString.hpp
+++ b/src/clicache/src/impl/ManagedString.hpp
@@ -22,7 +22,8 @@
#include "../geode_defs.hpp"
#ifdef _WIN32
-#define snprintf _snprintf
+// FIXME: Why is this needed?
+//#define snprintf _snprintf
#endif
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PartitionResolver.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/PartitionResolver.hpp b/src/clicache/src/impl/PartitionResolver.hpp
index 543ea07..8223e19 100644
--- a/src/clicache/src/impl/PartitionResolver.hpp
+++ b/src/clicache/src/impl/PartitionResolver.hpp
@@ -59,7 +59,7 @@ namespace Apache
{
EntryEvent<TKey, TValue> gevent(&ev);
Object^ groutingobject = m_resolver->GetRoutingObject(%gevent);
- return Serializable::GetUnmanagedValueGeneric<Object^>(groutingobject);
+ return Serializable::GetUnmanagedValueGeneric<Object^>(groutingobject, nullptr);
}
virtual const char * getName()
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxHelper.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/PdxHelper.cpp b/src/clicache/src/impl/PdxHelper.cpp
index 1d35467..f611146 100644
--- a/src/clicache/src/impl/PdxHelper.cpp
+++ b/src/clicache/src/impl/PdxHelper.cpp
@@ -45,20 +45,6 @@ namespace Apache
namespace Internal
{
-
- CacheImpl* getCacheImpl()
- {
- CachePtr cache = CacheFactory::getAnyInstance();
- if (cache == nullptr)
- {
- throw gcnew IllegalStateException("cache has not been created yet.");;
- }
- if (cache->isClosed())
- {
- throw gcnew IllegalStateException("cache has been closed. ");
- }
- return CacheRegionHelper::getCacheImpl(cache.get());
- }
void PdxHelper::SerializePdx(DataOutput^ dataOutput, IPdxSerializable^ pdxObject)
{
@@ -84,7 +70,7 @@ namespace Apache
PdxType^ piPt = pdxII->getPdxType();
if(piPt != nullptr && piPt->TypeId == 0)//from pdxInstance factory need to get typeid from server
{
- int typeId = PdxTypeRegistry::GetPDXIdForType(piPt, dataOutput->GetPoolName());
+ int typeId = PdxTypeRegistry::GetPDXIdForType(piPt, dataOutput->GetPoolName(), dataOutput->GetNative()->getCache());
pdxII->setPdxId(typeId);
}
PdxLocalWriter^ plw = gcnew PdxLocalWriter(dataOutput, piPt);
@@ -117,20 +103,20 @@ namespace Apache
//get type id from server and then set it
int nTypeId = PdxTypeRegistry::GetPDXIdForType(pdxType,
- dataOutput->GetPoolName(), nType, true);
+ dataOutput->GetPoolName(), nType, true, dataOutput->GetNative()->getCache());
nType->TypeId = nTypeId;
ptc->EndObjectWriting();//now write typeid
PdxTypeRegistry::AddLocalPdxType(pdxClassname, nType);//add classname VS pdxType
PdxTypeRegistry::AddPdxType(nTypeId, nType);//add typeid vs pdxtype
- //This is for pdx Statistics
- CacheImpl* cacheImpl = getCacheImpl();
- if (cacheImpl != NULL) {
- System::Byte* stPos = dataOutput->GetStartBufferPosition() + ptc->getStartPositionOffset();
- int pdxLen = PdxHelper::ReadInt32(stPos);
- cacheImpl->m_cacheStats->incPdxSerialization(pdxLen + 1 + 2*4); //pdxLen + 93 DSID + len + typeID
- }
+
+ //This is for pdx Statistics
+ System::Byte* stPos = dataOutput->GetStartBufferPosition() + ptc->getStartPositionOffset();
+ int pdxLen = PdxHelper::ReadInt32(stPos);
+ // TODO global - Figure out why dataInput cache is nullptr
+ // CacheRegionHelper::getCacheImpl(dataOutput->GetNative()->getCache())->getCachePerfStats().incPdxSerialization(pdxLen + 1 + 2*4); //pdxLen + 93 DSID + len + typeID
+ // GC::KeepAlive(dataOutput);
}
else//we know locasl type, need to see preerved data
{
@@ -154,18 +140,18 @@ namespace Apache
pdxObject->ToData(prw);
prw->EndObjectWriting();
- //This is for pdx Statistics
- CacheImpl* cacheImpl = getCacheImpl();
- if (cacheImpl != NULL) {
- System::Byte* stPos = dataOutput->GetStartBufferPosition() + prw->getStartPositionOffset();
- int pdxLen = PdxHelper::ReadInt32(stPos);
- cacheImpl->m_cacheStats->incPdxSerialization(pdxLen + 1 + 2*4); //pdxLen + 93 DSID + len + typeID
- }
+
+ //This is for pdx Statistics
+ System::Byte* stPos = dataOutput->GetStartBufferPosition() + prw->getStartPositionOffset();
+ int pdxLen = PdxHelper::ReadInt32(stPos);
+ // TODO global - Figure out why dataInput cache is nullptr
+ // CacheRegionHelper::getCacheImpl(dataOutput->GetNative()->getCache())->getCachePerfStats().incPdxSerialization(pdxLen + 1 + 2*4); //pdxLen + 93 DSID + len + typeID
+ // GC::KeepAlive(dataOutput);
}
}
- IPdxSerializable^ PdxHelper::DeserializePdx(DataInput^ dataInput, bool forceDeserialize, int typeId, int len )
+ IPdxSerializable^ PdxHelper::DeserializePdx(DataInput^ dataInput, bool forceDeserialize, int typeId, int len, const native::SerializationRegistry* serializationRegistry)
{
dataInput->setPdxdeserialization(true);
String^ pdxClassname = nullptr;
@@ -208,7 +194,7 @@ namespace Apache
{
if(pType == nullptr)
{
- pType = (PdxType^)(Serializable::GetPDXTypeById(dataInput->GetPoolName(), typeId));
+ pType = (PdxType^)(Serializable::GetPDXTypeById(dataInput->GetPoolName(), typeId, dataInput->GetNative()->getCache()));
pdxLocalType = PdxTypeRegistry::GetLocalPdxType(pType->PdxClassName);//this should be fine for IPdxTypeMappers
}
@@ -254,7 +240,7 @@ namespace Apache
pdxLocalType->InitializeType();
pdxLocalType->TypeId = PdxTypeRegistry::GetPDXIdForType(pdxObject->GetType(),
dataInput->GetPoolName(),
- pdxLocalType, true);
+ pdxLocalType, true, dataInput->GetNative()->getCache());
pdxLocalType->IsLocal = true;
PdxTypeRegistry::AddLocalPdxType(pdxClassname, pdxLocalType);//added local type
PdxTypeRegistry::AddPdxType(pdxLocalType->TypeId, pdxLocalType);
@@ -265,7 +251,7 @@ namespace Apache
//pdxLocalType->AddOtherVersion(pdxLocalType);//no need to add local type
//need to create merge type
- CreateMergedType(pdxLocalType, pType, dataInput);
+ CreateMergedType(pdxLocalType, pType, dataInput, serializationRegistry);
PdxType^ mergedVersion = PdxTypeRegistry::GetMergedType(pType->TypeId);
PdxRemotePreservedData^ preserveData = prtc->GetPreservedData(mergedVersion, pdxObject);
@@ -289,7 +275,7 @@ namespace Apache
pdxRealObject = pdxWrapper->GetObject();
//need to create merge type
- CreateMergedType(pdxLocalType, pType, dataInput);
+ CreateMergedType(pdxLocalType, pType, dataInput, serializationRegistry);
PdxType^ mergedVersion = PdxTypeRegistry::GetMergedType(pType->TypeId);
PdxRemotePreservedData^ preserveData = prr->GetPreservedData(mergedVersion, pdxObject);
@@ -301,7 +287,7 @@ namespace Apache
return pdxObject;
}
- IPdxSerializable^ PdxHelper::DeserializePdx(DataInput^ dataInput, bool forceDeserialize )
+ IPdxSerializable^ PdxHelper::DeserializePdx(DataInput^ dataInput, bool forceDeserialize, const native::SerializationRegistry* serializationRegistry)
{
try
{
@@ -313,13 +299,10 @@ namespace Apache
int len = dataInput->ReadInt32();
int typeId= dataInput->ReadInt32();
- //This is for pdx Statistics
- CacheImpl* cacheImpl = getCacheImpl();
- if (cacheImpl != NULL) {
- cacheImpl->m_cacheStats->incPdxDeSerialization(len + 9);//pdxLen + 1 + 2*4
- }
+ //This is for pdx Statistics
+ CacheRegionHelper::getCacheImpl(dataInput->GetNative()->getCache())->getCachePerfStats().incPdxDeSerialization(len + 9);//pdxLen + 1 + 2*4
- return DeserializePdx(dataInput, forceDeserialize, typeId, len);
+ return DeserializePdx(dataInput, forceDeserialize, typeId, len, serializationRegistry);
}//create PdxInstance
else
{
@@ -334,7 +317,7 @@ namespace Apache
if(pType == nullptr)
{
- PdxType^ pType = (PdxType^)(Serializable::GetPDXTypeById(dataInput->GetPoolName(), typeId));
+ PdxType^ pType = (PdxType^)(Serializable::GetPDXTypeById(dataInput->GetPoolName(), typeId, dataInput->GetNative()->getCache()));
//this should be fine for IPdxTypeMapper
PdxTypeRegistry::AddLocalPdxType(pType->PdxClassName, pType);
PdxTypeRegistry::AddPdxType(pType->TypeId, pType);
@@ -342,7 +325,7 @@ namespace Apache
}
// pdxObject = gcnew PdxInstanceImpl(gcnew DataInput(dataInput->GetBytes(dataInput->GetCursor(), len + 8 ), len + 8));
- pdxObject = gcnew PdxInstanceImpl(dataInput->GetBytes(dataInput->GetCursor(), len ), len, typeId, true );
+ pdxObject = gcnew PdxInstanceImpl(dataInput->GetBytes(dataInput->GetCursor(), len ), len, typeId, true, dataInput->GetNative()->getCache());
dataInput->AdvanceCursorPdx(len );
@@ -351,10 +334,7 @@ namespace Apache
dataInput->SetBuffer();
//This is for pdxinstance Statistics
- CacheImpl* cacheImpl = getCacheImpl();
- if (cacheImpl != NULL) {
- cacheImpl->m_cacheStats->incPdxInstanceCreations();
- }
+ CacheRegionHelper::getCacheImpl(dataInput->GetNative()->getCache())->getCachePerfStats().incPdxInstanceCreations();
return pdxObject;
}
}finally
@@ -363,21 +343,21 @@ namespace Apache
}
}
- Int32 PdxHelper::GetEnumValue(String^ enumClassName, String^ enumName, int hashcode)
+ Int32 PdxHelper::GetEnumValue(String^ enumClassName, String^ enumName, int hashcode, const native::Cache* cache)
{
//in case app want different name
enumClassName = Serializable::GetPdxTypeName(enumClassName);
EnumInfo^ ei = gcnew EnumInfo(enumClassName, enumName, hashcode);
- return PdxTypeRegistry::GetEnumValue(ei);
+ return PdxTypeRegistry::GetEnumValue(ei, cache);
}
- Object^ PdxHelper::GetEnum(int enumId)
+ Object^ PdxHelper::GetEnum(int enumId, const native::Cache* cache)
{
- EnumInfo^ ei = PdxTypeRegistry::GetEnum(enumId);
+ EnumInfo^ ei = PdxTypeRegistry::GetEnum(enumId, cache);
return ei->GetEnum();
}
- void PdxHelper::CreateMergedType(PdxType^ localType, PdxType^ remoteType, DataInput^ dataInput)
+ void PdxHelper::CreateMergedType(PdxType^ localType, PdxType^ remoteType, DataInput^ dataInput, const native::SerializationRegistry* serializationRegistry)
{
PdxType^ mergedVersion = localType->MergeVersion(remoteType);
@@ -393,7 +373,7 @@ namespace Apache
{//need to create new version
mergedVersion->InitializeType();
if(mergedVersion->TypeId == 0)
- mergedVersion->TypeId = Serializable::GetPDXIdForType(dataInput->GetPoolName(), mergedVersion);
+ mergedVersion->TypeId = Serializable::GetPDXIdForType(dataInput->GetPoolName(), mergedVersion, dataInput->GetNative()->getCache());
// PdxTypeRegistry::AddPdxType(remoteType->TypeId, mergedVersion);
PdxTypeRegistry::AddPdxType(mergedVersion->TypeId, mergedVersion);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxHelper.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/PdxHelper.hpp b/src/clicache/src/impl/PdxHelper.hpp
index 80b2b80..7cc9c82 100644
--- a/src/clicache/src/impl/PdxHelper.hpp
+++ b/src/clicache/src/impl/PdxHelper.hpp
@@ -19,6 +19,7 @@
//#include "../DataOutput.hpp"
#include "begin_native.hpp"
#include <geode/DataOutput.hpp>
+#include "SerializationRegistry.hpp"
#include "end_native.hpp"
#include "../IPdxSerializable.hpp"
@@ -30,7 +31,7 @@ namespace Apache
{
namespace Client
{
-
+ namespace native = apache::geode::client;
ref class DataOutput;
ref class DataInput;
namespace Internal
@@ -42,9 +43,9 @@ namespace Apache
static void SerializePdx(DataOutput^ dataOutput, IPdxSerializable^ pdxObject);
- static IPdxSerializable^ DeserializePdx(DataInput^ dataOutput, bool forceDeserialize);
+ static IPdxSerializable^ DeserializePdx(DataInput^ dataOutput, bool forceDeserialize, const native::SerializationRegistry* serializationRegistry);
- static IPdxSerializable^ PdxHelper::DeserializePdx(DataInput^ dataInput, bool forceDeserialize, int typeId, int length );
+ static IPdxSerializable^ PdxHelper::DeserializePdx(DataInput^ dataInput, bool forceDeserialize, int typeId, int length, const native::SerializationRegistry* serializationRegistry);
literal Byte PdxHeader = 8;
@@ -64,12 +65,12 @@ namespace Apache
static Int32 ReadInt(System::Byte* offsetPosition, int size);
- static Int32 GetEnumValue(String^ enumClassName, String^ enumName, int hashcode);
+ static Int32 GetEnumValue(String^ enumClassName, String^ enumName, int hashcode, const native::Cache* cache);
- static Object^ GetEnum(int enumId);
+ static Object^ GetEnum(int enumId, const native::Cache* cache);
private:
- static void CreateMergedType(PdxType^ localType, PdxType^ remoteType, DataInput^ dataInput);
+ static void CreateMergedType(PdxType^ localType, PdxType^ remoteType, DataInput^ dataInput, const native::SerializationRegistry* serializationRegistry);
};
} // namespace Client
} // namespace Geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxInstanceFactoryImpl.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/PdxInstanceFactoryImpl.cpp b/src/clicache/src/impl/PdxInstanceFactoryImpl.cpp
index 885dab6..230972a 100644
--- a/src/clicache/src/impl/PdxInstanceFactoryImpl.cpp
+++ b/src/clicache/src/impl/PdxInstanceFactoryImpl.cpp
@@ -16,6 +16,10 @@
*/
#pragma once
+#include "begin_native.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
+#include "end_native.hpp"
#include "PdxInstanceFactoryImpl.hpp"
#include "PdxInstanceImpl.hpp"
#include "DotNetTypes.hpp"
@@ -30,7 +34,7 @@ namespace Apache
namespace Internal
{
- PdxInstanceFactoryImpl::PdxInstanceFactoryImpl(String^ className)
+ PdxInstanceFactoryImpl::PdxInstanceFactoryImpl(String^ className, native::Cache* cache)
{
if (className == nullptr)
throw gcnew IllegalStateException(
@@ -38,6 +42,7 @@ namespace Apache
m_pdxType = gcnew PdxType(className, false);
m_FieldVsValues = gcnew Dictionary<String^, Object^>();
m_created = false;
+ m_cache = cache;
}
IPdxInstance^ PdxInstanceFactoryImpl::Create()
@@ -48,7 +53,7 @@ namespace Apache
"The IPdxInstanceFactory.Create() method can only be called once.");
}
//need to get typeid;
- IPdxInstance^ pi = gcnew PdxInstanceImpl(m_FieldVsValues, m_pdxType);
+ IPdxInstance^ pi = gcnew PdxInstanceImpl(m_FieldVsValues, m_pdxType, &CacheRegionHelper::getCacheImpl(m_cache)->getCachePerfStats(), m_cache);
m_created = true;
return pi;
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxInstanceFactoryImpl.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/PdxInstanceFactoryImpl.hpp b/src/clicache/src/impl/PdxInstanceFactoryImpl.hpp
index 91b38d1..cce22e4 100644
--- a/src/clicache/src/impl/PdxInstanceFactoryImpl.hpp
+++ b/src/clicache/src/impl/PdxInstanceFactoryImpl.hpp
@@ -16,6 +16,9 @@
*/
#pragma once
+#include "begin_native.hpp"
+#include <geode/Cache.hpp>
+#include "end_native.hpp"
#include "../IPdxInstanceFactory.hpp"
#include "../IPdxSerializable.hpp"
@@ -31,17 +34,23 @@ namespace Apache
namespace Internal
{
+
+ namespace native = apache::geode::client;
+
ref class PdxInstanceFactoryImpl : IPdxInstanceFactory
{
private:
bool m_created;
PdxType^ m_pdxType;
Dictionary<String^, Object^>^ m_FieldVsValues;
+ native::Cache* m_cache;
internal:
- PdxInstanceFactoryImpl(String^ className);
+ PdxInstanceFactoryImpl(String^ className, native::Cache* cache);
void isFieldAdded(String^ fieldName);
+
+
public:
- /// <summary>
+ /// <summary>
/// Create a {@link PdxInstance}. The instance
/// will contain any data written to this factory
/// using the write methods.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxInstanceImpl.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/PdxInstanceImpl.cpp b/src/clicache/src/impl/PdxInstanceImpl.cpp
index b4092f9..785d997 100755
--- a/src/clicache/src/impl/PdxInstanceImpl.cpp
+++ b/src/clicache/src/impl/PdxInstanceImpl.cpp
@@ -45,7 +45,7 @@ namespace Apache
namespace Internal
{
//this is for PdxInstanceFactory
- PdxInstanceImpl::PdxInstanceImpl(Dictionary<String^, Object^>^ fieldVsValue, PdxType^ pdxType)
+ PdxInstanceImpl::PdxInstanceImpl(Dictionary<String^, Object^>^ fieldVsValue, PdxType^ pdxType, CachePerfStats* cachePerfStats, const native::Cache* cache)
{
m_updatedFields = fieldVsValue;
m_typeId = 0;
@@ -53,21 +53,15 @@ namespace Apache
m_buffer = NULL;
m_bufferLength = 0;
m_pdxType = pdxType;
-
+ m_cache = cache;
+ m_cachePerfStats = cachePerfStats;
m_pdxType->InitializeType();//to generate static position map
//need to initiailize stream. this will call todata and in toData we will have stream
- apache::geode::client::DataOutput* output = apache::geode::client::DataOutput::getDataOutput();
+ auto output = m_cache->createDataOutput();
- try
- {
- Apache::Geode::Client::DataOutput mg_output(&(*output), true);
- Apache::Geode::Client::Internal::PdxHelper::SerializePdx(%mg_output, this);
- }
- finally
- {
- apache::geode::client::DataOutput::releaseDataOutput(output);
- }
+ Apache::Geode::Client::DataOutput mg_output(output.get(), true);
+ Apache::Geode::Client::Internal::PdxHelper::SerializePdx(%mg_output, this);
}
String^ PdxInstanceImpl::GetClassName()
@@ -84,27 +78,18 @@ namespace Apache
}
Object^ PdxInstanceImpl::GetObject()
{
- DataInput^ dataInput = gcnew DataInput(m_buffer, m_bufferLength);
+ DataInput^ dataInput = gcnew DataInput(m_buffer, m_bufferLength, m_cache);
dataInput->setRootObjectPdx(true);
System::Int64 sampleStartNanos = Utils::startStatOpTime();
- Object^ ret = Internal::PdxHelper::DeserializePdx(dataInput, true, m_typeId, m_bufferLength);
+ Object^ ret = Internal::PdxHelper::DeserializePdx(dataInput, true, m_typeId, m_bufferLength, CacheRegionHelper::getCacheImpl(m_cache)->getSerializationRegistry().get());
//dataInput->ResetPdx(0);
- CachePtr cache = CacheFactory::getAnyInstance();
- if (cache == nullptr)
- {
- throw gcnew IllegalStateException("cache has not been created yet.");;
- }
- if (cache->isClosed())
+ if(m_cachePerfStats)
{
- throw gcnew IllegalStateException("cache has been closed. ");
- }
- CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(cache.get());
- if (cacheImpl != NULL) {
- Utils::updateStatOpTime(cacheImpl->m_cacheStats->getStat(),
- cacheImpl->m_cacheStats->getPdxInstanceDeserializationTimeId(),
+ Utils::updateStatOpTime(m_cachePerfStats->getStat(),
+ m_cachePerfStats->getPdxInstanceDeserializationTimeId(),
sampleStartNanos);
- cacheImpl->m_cacheStats->incPdxInstanceDeserializations();
+ m_cachePerfStats->incPdxInstanceDeserializations();
}
return ret;
}
@@ -152,7 +137,7 @@ namespace Apache
}
{
- DataInput^ dataInput = gcnew DataInput(m_buffer, m_bufferLength);
+ DataInput^ dataInput = gcnew DataInput(m_buffer, m_bufferLength, m_cache);
dataInput->setPdxdeserialization(true);
int pos = getOffset(dataInput, pt, pft->SequenceId);
@@ -246,9 +231,9 @@ namespace Apache
equatePdxFields(myPdxIdentityFieldList, otherPdxIdentityFieldList);
equatePdxFields(otherPdxIdentityFieldList, myPdxIdentityFieldList);
- DataInput^ myDataInput = gcnew DataInput(m_buffer, m_bufferLength);
+ DataInput^ myDataInput = gcnew DataInput(m_buffer, m_bufferLength, m_cache);
myDataInput->setPdxdeserialization(true);
- DataInput^ otherDataInput = gcnew DataInput(otherPdx->m_buffer, otherPdx->m_bufferLength);
+ DataInput^ otherDataInput = gcnew DataInput(otherPdx->m_buffer, otherPdx->m_bufferLength, m_cache);
otherDataInput->setPdxdeserialization(true);
bool isEqual = false;
@@ -578,7 +563,7 @@ namespace Apache
IList<PdxFieldType^>^ pdxIdentityFieldList = getIdentityPdxFields(pt);
- DataInput^ dataInput = gcnew DataInput(m_buffer, m_bufferLength);
+ DataInput^ dataInput = gcnew DataInput(m_buffer, m_bufferLength, m_cache);
dataInput->setPdxdeserialization(true);
for (int i = 0; i < pdxIdentityFieldList->Count; i++)
@@ -964,7 +949,7 @@ namespace Apache
IWritablePdxInstance^ PdxInstanceImpl::CreateWriter()
{
//dataInput->ResetPdx(0);
- return gcnew PdxInstanceImpl(m_buffer, m_bufferLength, m_typeId, false);//need to create duplicate byte stream
+ return gcnew PdxInstanceImpl(m_buffer, m_bufferLength, m_typeId, false, m_cache);//need to create duplicate byte stream
}
void PdxInstanceImpl::SetField(String^ fieldName, Object^ value)
@@ -1001,7 +986,7 @@ namespace Apache
if (!m_own)
copy = apache::geode::client::DataInput::getBufferCopy(m_buffer, m_bufferLength);
- DataInput^ dataInput = gcnew DataInput(copy, m_bufferLength);//this will delete buffer
+ DataInput^ dataInput = gcnew DataInput(copy, m_bufferLength, m_cache);//this will delete buffer
dataInput->setPdxdeserialization(true);
//but new stream is set for this from pdxHelper::serialize function
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxInstanceImpl.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/PdxInstanceImpl.hpp b/src/clicache/src/impl/PdxInstanceImpl.hpp
index ebab9a5..4e44022 100755
--- a/src/clicache/src/impl/PdxInstanceImpl.hpp
+++ b/src/clicache/src/impl/PdxInstanceImpl.hpp
@@ -16,6 +16,10 @@
*/
#pragma once
+#include "begin_native.hpp"
+#include "CachePerfStats.hpp"
+#include "SerializationRegistry.hpp"
+#include "end_native.hpp"
#include "../IPdxInstance.hpp"
#include "../IPdxSerializable.hpp"
@@ -64,11 +68,13 @@ namespace Apache
//DataInput^ m_dataInput;
+ CachePerfStats* m_cachePerfStats;
System::Byte* m_buffer;
int m_bufferLength;
int m_typeId;
bool m_own;
PdxType^ m_pdxType;
+ const native::Cache* m_cache;
internal:
Dictionary<String^, Object^>^ m_updatedFields;
@@ -119,7 +125,7 @@ namespace Apache
void updatePdxStream(System::Byte* newPdxStream, int len);
public:
- PdxInstanceImpl(System::Byte* buffer, int length, int typeId, bool own)
+ PdxInstanceImpl(System::Byte* buffer, int length, int typeId, bool own, const native::Cache* cache)
{
//m_dataInput = dataInput;
m_buffer = buffer;
@@ -128,10 +134,11 @@ namespace Apache
m_updatedFields = nullptr;
m_own = own;
m_pdxType = nullptr;
+ m_cache = cache;
}
//for pdxInstance factory
- PdxInstanceImpl(Dictionary<String^, Object^>^ fieldVsValue, PdxType^ pdxType);
+ PdxInstanceImpl(Dictionary<String^, Object^>^ fieldVsValue, PdxType^ pdxType, CachePerfStats* cachePerfStats, const native::Cache* cache);
~PdxInstanceImpl()
{
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxManagedCacheableKey.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/PdxManagedCacheableKey.cpp b/src/clicache/src/impl/PdxManagedCacheableKey.cpp
index 81fa5d2..2764b36 100644
--- a/src/clicache/src/impl/PdxManagedCacheableKey.cpp
+++ b/src/clicache/src/impl/PdxManagedCacheableKey.cpp
@@ -20,6 +20,7 @@
#include "begin_native.hpp"
#include <GeodeTypeIdsImpl.hpp>
+#include "CacheRegionHelper.hpp"
#include "end_native.hpp"
#include "PdxManagedCacheableKey.hpp"
@@ -62,9 +63,9 @@ namespace apache
{
try {
int pos = input.getBytesRead();
- Apache::Geode::Client::DataInput mg_input(&input, true);
+ Apache::Geode::Client::DataInput mg_input(&input, true, input.getCache());
//m_managedptr = m_managedptr->FromData( %mg_input );
- Apache::Geode::Client::IPdxSerializable^ tmp = Apache::Geode::Client::Internal::PdxHelper::DeserializePdx(%mg_input, false);
+ Apache::Geode::Client::IPdxSerializable^ tmp = Apache::Geode::Client::Internal::PdxHelper::DeserializePdx(%mg_input, false, CacheRegionHelper::getCacheImpl(input.getCache())->getSerializationRegistry().get());
m_managedptr = tmp;
m_managedDeltaptr = dynamic_cast<Apache::Geode::Client::IGeodeDelta^>(tmp);
@@ -259,10 +260,10 @@ namespace apache
}
}
- void PdxManagedCacheableKey::fromDelta(DataInput& input)
+ void PdxManagedCacheableKey::fromDelta(native::DataInput& input)
{
try {
- Apache::Geode::Client::DataInput mg_input(&input, true);
+ Apache::Geode::Client::DataInput mg_input(&input, true, input.getCache());
m_managedDeltaptr->FromDelta(%mg_input);
//this will move the cursor in c++ layer
@@ -287,7 +288,7 @@ namespace apache
Apache::Geode::Client::IPdxSerializable^ Mclone =
dynamic_cast<Apache::Geode::Client::IPdxSerializable^>(cloneable->Clone());
return DeltaPtr(static_cast<PdxManagedCacheableKey*>(
- SafeGenericM2UMConvert(Mclone)));
+ SafeGenericM2UMConvert(Mclone, m_cache)));
}
else {
return Delta::clone();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxManagedCacheableKey.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/PdxManagedCacheableKey.hpp b/src/clicache/src/impl/PdxManagedCacheableKey.hpp
index 859319b..02bea8c 100644
--- a/src/clicache/src/impl/PdxManagedCacheableKey.hpp
+++ b/src/clicache/src/impl/PdxManagedCacheableKey.hpp
@@ -63,14 +63,14 @@ namespace apache
public:
inline PdxManagedCacheableKey()
- : m_managedptr(nullptr), m_hashcode(0), m_objectSize(0), m_managedDeltaptr(nullptr)
+ : Delta(nullptr), m_managedptr(nullptr), m_hashcode(0), m_objectSize(0), m_managedDeltaptr(nullptr)
{
}
inline PdxManagedCacheableKey(
Apache::Geode::Client::IPdxSerializable^ managedptr, int hashcode)
- : m_managedptr(managedptr), m_objectSize(0) {
+ :Delta(nullptr), m_managedptr(managedptr), m_objectSize(0) {
m_hashcode = hashcode;
m_managedDeltaptr = dynamic_cast<Apache::Geode::Client::IGeodeDelta^>(managedptr);
}
@@ -82,7 +82,7 @@ namespace apache
/// </param>
inline PdxManagedCacheableKey(
Apache::Geode::Client::IPdxSerializable^ managedptr)
- : m_managedptr(managedptr), m_objectSize(0) {
+ : Delta(nullptr), m_managedptr(managedptr), m_objectSize(0) {
m_hashcode = 0;//it can be zero while initializing the object
m_managedDeltaptr = dynamic_cast<Apache::Geode::Client::IGeodeDelta^>(managedptr);
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxManagedCacheableKeyBytes.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/PdxManagedCacheableKeyBytes.cpp b/src/clicache/src/impl/PdxManagedCacheableKeyBytes.cpp
index cabe7d9..f811449 100644
--- a/src/clicache/src/impl/PdxManagedCacheableKeyBytes.cpp
+++ b/src/clicache/src/impl/PdxManagedCacheableKeyBytes.cpp
@@ -55,24 +55,17 @@ namespace apache
{
try {
- //Apache::Geode::Client::Log::Debug("PdxManagedCacheableKeyBytes::fromData: classid " + m_classId);
- Apache::Geode::Client::DataInput mg_input(&input, true);
+ Apache::Geode::Client::DataInput mg_input(&input, true, input.getCache());
const System::Byte* objStartPos = input.currentBufferPosition();
- Apache::Geode::Client::IPdxSerializable^ obj = Apache::Geode::Client::Internal::PdxHelper::DeserializePdx(%mg_input, false);
-
- //Apache::Geode::Client::IGeodeSerializable^ obj = Apache::Geode::Client::Serializable::GetTypeFactoryMethodGeneric(m_classId)();
- //obj->FromData(%mg_input);
-
+ Apache::Geode::Client::IPdxSerializable^ obj = Apache::Geode::Client::Internal::PdxHelper::DeserializePdx(%mg_input, false, CacheRegionHelper::getCacheImpl(input.getCache())->getSerializationRegistry().get());
input.advanceCursor(mg_input.BytesReadInternally);
m_hashCode = obj->GetHashCode();
const System::Byte* objEndPos = input.currentBufferPosition();
- //m_size = mg_input.BytesRead;
m_size = (System::UInt32)(objEndPos - objStartPos);
- // Apache::Geode::Client::Log::Debug("PdxManagedCacheableKeyBytes::fromData: objectSize = " + m_size + " m_hashCode = " + m_hashCode);
m_bytes = input.getBufferCopyFrom(objStartPos, m_size);
}
@@ -88,7 +81,6 @@ namespace apache
System::UInt32 PdxManagedCacheableKeyBytes::objectSize() const
{
try {
- //return m_managedptr->ObjectSize;
return m_size;
}
catch (Apache::Geode::Client::GeodeException^ ex) {
@@ -102,62 +94,18 @@ namespace apache
System::Int32 PdxManagedCacheableKeyBytes::classId() const
{
- //System::UInt32 classId;
- //try {
- // //classId = m_managedptr->ClassId;
- // classId = m_classId;
- //}
- //catch (Apache::Geode::Client::GeodeException^ ex) {
- // ex->ThrowNative();
- //}
- //catch (System::Exception^ ex) {
- // Apache::Geode::Client::GeodeException::ThrowNative(ex);
- //}
- //return (classId >= 0x80000000 ? 0 : classId);
return 0;
}
int8_t PdxManagedCacheableKeyBytes::typeId() const
{
- //try {
- // //System::UInt32 classId = m_managedptr->ClassId;
- // System::UInt32 classId = m_classId;
- // if (classId >= 0x80000000) {
- // return (int8_t)((classId - 0x80000000) % 0x20000000);
- // }
- // else if (classId <= 0x7F) {
- // return (int8_t)apache::geode::client::GeodeTypeIdsImpl::CacheableUserData;
- // }
- // else if (classId <= 0x7FFF) {
- // return (int8_t)apache::geode::client::GeodeTypeIdsImpl::CacheableUserData2;
- // }
- // else {
- // return (int8_t)apache::geode::client::GeodeTypeIdsImpl::CacheableUserData4;
- // }
- //}
- //catch (Apache::Geode::Client::GeodeException^ ex) {
- // ex->ThrowNative();
- //}
- //catch (System::Exception^ ex) {
- // Apache::Geode::Client::GeodeException::ThrowNative(ex);
- //}
+
return (int8_t)GeodeTypeIdsImpl::PDX;
}
int8_t PdxManagedCacheableKeyBytes::DSFID() const
{
- // convention that [0x8000000, 0xa0000000) is for FixedIDDefault,
- // [0xa000000, 0xc0000000) is for FixedIDByte,
- // [0xc0000000, 0xe0000000) is for FixedIDShort
- // and [0xe0000000, 0xffffffff] is for FixedIDInt
- // Note: depends on fact that FixedIDByte is 1, FixedIDShort is 2
- // and FixedIDInt is 3; if this changes then correct this accordingly
- //System::UInt32 classId = m_managedptr->ClassId;
- /* System::UInt32 classId = m_classId;
- if (classId >= 0x80000000) {
- return (int8_t)((classId - 0x80000000) / 0x20000000);
- }*/
- return 0;
+ return 0;
}
apache::geode::client::CacheableStringPtr PdxManagedCacheableKeyBytes::toString() const
@@ -190,14 +138,8 @@ namespace apache
const PdxManagedCacheableKeyBytes* p_other =
dynamic_cast<const PdxManagedCacheableKeyBytes*>(&other);
if (p_other != NULL) {
- apache::geode::client::DataInput di(m_bytes, m_size);
- Apache::Geode::Client::DataInput mg_input(&di, true);
- /* Apache::Geode::Client::IGeodeSerializable^ obj =
- Apache::Geode::Client::Serializable::GetTypeFactoryMethodGeneric(m_classId)();
- obj->FromData(%mg_input);*/
Apache::Geode::Client::IPdxSerializable^ obj = getManagedObject();
bool ret = obj->Equals(p_other->ptr());
- // Apache::Geode::Client::Log::Debug("PdxManagedCacheableKeyBytes::equal return VAL = " + ret);
return ret;
}
}
@@ -215,16 +157,9 @@ namespace apache
{
try {
//Apache::Geode::Client::Log::Debug("PdxManagedCacheableKeyBytes::equal. ");
- apache::geode::client::DataInput di(m_bytes, m_size);
- Apache::Geode::Client::DataInput mg_input(&di, true);
- /*Apache::Geode::Client::IGeodeSerializable^ obj =
- Apache::Geode::Client::Serializable::GetTypeFactoryMethodGeneric(m_classId)();
- obj->FromData(%mg_input);*/
Apache::Geode::Client::IPdxSerializable^ obj = getManagedObject();
bool ret = obj->Equals(other.ptr());
- // Apache::Geode::Client::Log::Debug("PdxManagedCacheableKeyBytes::equal return VAL = " + ret);
return ret;
- //return obj->Equals(other.get());
}
catch (Apache::Geode::Client::GeodeException^ ex) {
ex->ThrowNative();
@@ -267,25 +202,14 @@ namespace apache
Apache::Geode::Client::IPdxSerializable^
PdxManagedCacheableKeyBytes::getManagedObject() const
{
-
- // Apache::Geode::Client::Log::Debug("PdxManagedCacheableKeyBytes::getManagedObject " + m_size);
-
- apache::geode::client::DataInput dinp(m_bytes, m_size);
- Apache::Geode::Client::DataInput mg_dinp(&dinp, true);
- /*TypeFactoryMethodGeneric^ creationMethod =
- Apache::Geode::Client::Serializable::GetTypeFactoryMethodGeneric(m_classId);
- Apache::Geode::Client::IGeodeSerializable^ newObj = creationMethod();
- return newObj->FromData(%mg_dinp);*/
- return Apache::Geode::Client::Internal::PdxHelper::DeserializePdx(%mg_dinp, false);
+ auto dinp = m_cache->createDataInput(m_bytes, m_size);
+ Apache::Geode::Client::DataInput mg_dinp(dinp.get(), true, m_cache);
+ return Apache::Geode::Client::Internal::PdxHelper::DeserializePdx(%mg_dinp, false, CacheRegionHelper::getCacheImpl(m_cache)->getSerializationRegistry().get());
}
bool PdxManagedCacheableKeyBytes::hasDelta()
{
- /* Apache::Geode::Client::IGeodeDelta^ deltaObj = dynamic_cast<Apache::Geode::Client::IGeodeDelta^>(this->getManagedObject());
-
- if(deltaObj)
- return deltaObj->HasDelta();*/
- return m_hasDelta;
+ return m_hasDelta;
}
void PdxManagedCacheableKeyBytes::toDelta(DataOutput& output) const
@@ -310,29 +234,21 @@ namespace apache
try {
Apache::Geode::Client::Log::Debug("PdxManagedCacheableKeyBytes::fromDelta:");
Apache::Geode::Client::IGeodeDelta^ deltaObj = dynamic_cast<Apache::Geode::Client::IGeodeDelta^>(this->getManagedObject());
- Apache::Geode::Client::DataInput mg_input(&input, true);
+ Apache::Geode::Client::DataInput mg_input(&input, true, input.getCache());
deltaObj->FromDelta(%mg_input);
Apache::Geode::Client::IPdxSerializable^ managedptr =
dynamic_cast <Apache::Geode::Client::IPdxSerializable^> (deltaObj);
- // if(managedptr != nullptr)
{
Apache::Geode::Client::Log::Debug("PdxManagedCacheableKeyBytes::fromDelta: current domain ID: " + System::Threading::Thread::GetDomainID() + " for object: " + System::Convert::ToString((uint64_t) this) + " with its domain ID: " + m_domainId);
- //Apache::Geode::Client::Log::Debug("PdxManagedCacheableKeyBytes::fromDelta: classid " + managedptr->ClassId + " : " + managedptr->ToString());
- apache::geode::client::DataOutput dataOut;
- Apache::Geode::Client::DataOutput mg_output(&dataOut, true);
- //managedptr->ToData( %mg_output );
+ auto dataOut = m_cache->createDataOutput();
+ Apache::Geode::Client::DataOutput mg_output(dataOut.get(), true);
Apache::Geode::Client::Internal::PdxHelper::SerializePdx(%mg_output, managedptr);
- //m_managedptr->ToData( %mg_output );
- //this will move the cursor in c++ layer
mg_output.WriteBytesToUMDataOutput();
- //move cursor
- // dataOut.advanceCursor(mg_output.BufferLength);
-
- GF_SAFE_DELETE(m_bytes);
- m_bytes = dataOut.getBufferCopy();
- m_size = dataOut.getBufferLength();
+ GF_SAFE_DELETE(m_bytes);
+ m_bytes = dataOut->getBufferCopy();
+ m_size = dataOut->getBufferLength();
Apache::Geode::Client::Log::Debug("PdxManagedCacheableKeyBytes::fromDelta objectSize = " + m_size + " m_hashCode = " + m_hashCode);
m_hashCode = managedptr->GetHashCode();
}
@@ -354,7 +270,7 @@ namespace apache
Apache::Geode::Client::IPdxSerializable^ Mclone =
dynamic_cast<Apache::Geode::Client::IPdxSerializable^>(cloneable->Clone());
return DeltaPtr(static_cast<PdxManagedCacheableKeyBytes*>(
- SafeGenericM2UMConvert(Mclone)));
+ SafeGenericM2UMConvert(Mclone, m_cache)));
}
else {
return Delta::clone();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxManagedCacheableKeyBytes.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/PdxManagedCacheableKeyBytes.hpp b/src/clicache/src/impl/PdxManagedCacheableKeyBytes.hpp
index d388200..4480268 100644
--- a/src/clicache/src/impl/PdxManagedCacheableKeyBytes.hpp
+++ b/src/clicache/src/impl/PdxManagedCacheableKeyBytes.hpp
@@ -22,6 +22,8 @@
#include "begin_native.hpp"
#include <geode/CacheableKey.hpp>
#include <geode/Delta.hpp>
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
#include "end_native.hpp"
#include "../Log.hpp"
@@ -67,10 +69,11 @@ namespace apache
/// The managed object.
/// </param>
inline PdxManagedCacheableKeyBytes(
- Apache::Geode::Client::IPdxSerializable^ managedptr, bool storeBytes )
- : m_domainId(System::Threading::Thread::GetDomainID()),
+ Apache::Geode::Client::IPdxSerializable^ managedptr, bool storeBytes, Cache* cache)
+ : Delta(cache), m_domainId(System::Threading::Thread::GetDomainID()),
m_bytes(NULL),
m_size(0),
+ m_cache(cache),
m_hashCode(0)
{
m_hasDelta = false;
@@ -85,17 +88,19 @@ namespace apache
{
if(storeBytes)//if value is from app
{
- apache::geode::client::DataOutput dataOut;
- Apache::Geode::Client::DataOutput mg_output( &dataOut, true);
- Apache::Geode::Client::Internal::PdxHelper::SerializePdx(%mg_output, managedptr);
+ auto dataOut = m_cache->createDataOutput();
+ Apache::Geode::Client::DataOutput mg_output(dataOut.get(), true);
+ SerializationRegistry defaultSerializationRegistry;
+
+ Apache::Geode::Client::Internal::PdxHelper::SerializePdx(%mg_output, managedptr);
// managedptr->ToData( %mg_output );
//move cursor
//dataOut.advanceCursor(mg_output.BufferLength);
mg_output.WriteBytesToUMDataOutput();
- m_bytes = dataOut.getBufferCopy();
- m_size = dataOut.getBufferLength();
+ m_bytes = dataOut->getBufferCopy();
+ m_size = dataOut->getBufferLength();
m_hashCode = managedptr->GetHashCode();
Apache::Geode::Client::Log::Fine(
@@ -104,10 +109,11 @@ namespace apache
}
}
- inline PdxManagedCacheableKeyBytes( )
- : m_domainId(System::Threading::Thread::GetDomainID()),
+ inline PdxManagedCacheableKeyBytes(Cache* cache)
+ : Delta(cache), m_domainId(System::Threading::Thread::GetDomainID()),
m_bytes(NULL),
m_size(0),
+ m_cache(cache),
m_hashCode(0)
{
m_hasDelta = false;
@@ -198,9 +204,9 @@ namespace apache
return getManagedObject();
}
- static Serializable* CreateDeserializable()
+ static Serializable* CreateDeserializable(Cache* cache)
{
- return new PdxManagedCacheableKeyBytes();
+ return new PdxManagedCacheableKeyBytes(cache);
}
inline ~PdxManagedCacheableKeyBytes()
@@ -227,6 +233,7 @@ namespace apache
UInt32 m_classId;
System::Byte * m_bytes;
System::UInt32 m_size;
+ Cache* m_cache;
bool m_hasDelta;
System::Int32 m_hashCode;
// Disable the copy and assignment constructors
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxTypeRegistry.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/PdxTypeRegistry.cpp b/src/clicache/src/impl/PdxTypeRegistry.cpp
index dae9c5f..de739a0 100644
--- a/src/clicache/src/impl/PdxTypeRegistry.cpp
+++ b/src/clicache/src/impl/PdxTypeRegistry.cpp
@@ -40,7 +40,7 @@ namespace Apache
return preserveData->Count;
}
- Int32 PdxTypeRegistry::GetPDXIdForType(Type^ pdxType, const char* poolname, PdxType^ nType, bool checkIfThere)
+ Int32 PdxTypeRegistry::GetPDXIdForType(Type^ pdxType, const char* poolname, PdxType^ nType, bool checkIfThere, const native::Cache* cache)
{
if(checkIfThere)
{
@@ -62,7 +62,7 @@ namespace Apache
return lpdx->TypeId;
}
}
- return Serializable::GetPDXIdForType(poolname, nType);
+ return Serializable::GetPDXIdForType(poolname, nType, cache);
}
finally
{
@@ -71,7 +71,7 @@ namespace Apache
}
- Int32 PdxTypeRegistry::GetPDXIdForType(PdxType^ pType, const char* poolname)
+ Int32 PdxTypeRegistry::GetPDXIdForType(PdxType^ pType, const char* poolname, const native::Cache* cache)
{
IDictionary<PdxType^, Int32>^ tmp = pdxTypeToTypeId;
Int32 typeId = 0;
@@ -92,7 +92,7 @@ namespace Apache
return typeId;
}
- typeId = Serializable::GetPDXIdForType(poolname, pType);
+ typeId = Serializable::GetPDXIdForType(poolname, pType, cache);
pType->TypeId = typeId;
IDictionary<PdxType^, Int32>^ newDict = gcnew Dictionary<PdxType^, Int32>(pdxTypeToTypeId);
@@ -255,7 +255,7 @@ namespace Apache
return nullptr;
}
- Int32 PdxTypeRegistry::GetEnumValue(EnumInfo^ ei)
+ Int32 PdxTypeRegistry::GetEnumValue(EnumInfo^ ei, const native::Cache* cache)
{
IDictionary<EnumInfo^, Int32>^ tmp = enumToInt;
if(tmp->ContainsKey(ei))
@@ -267,7 +267,7 @@ namespace Apache
if(tmp->ContainsKey(ei))
return tmp[ei];
- int val = Serializable::GetEnumValue(ei);
+ int val = Serializable::GetEnumValue(ei, cache);
tmp = gcnew Dictionary<EnumInfo^, Int32>(enumToInt);
tmp[ei] = val;
enumToInt = tmp;
@@ -280,7 +280,7 @@ namespace Apache
return 0;
}
- EnumInfo^ PdxTypeRegistry::GetEnum(Int32 enumVal)
+ EnumInfo^ PdxTypeRegistry::GetEnum(Int32 enumVal, const native::Cache* cache)
{
IDictionary<Int32, EnumInfo^>^ tmp = intToEnum;
EnumInfo^ ret = nullptr;
@@ -298,7 +298,7 @@ namespace Apache
if(ret != nullptr)
return ret;
- ret = Serializable::GetEnum(enumVal);
+ ret = Serializable::GetEnum(enumVal, cache);
tmp = gcnew Dictionary<Int32, EnumInfo^>(intToEnum);
tmp[enumVal] = ret;
intToEnum = tmp;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxTypeRegistry.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/PdxTypeRegistry.hpp b/src/clicache/src/impl/PdxTypeRegistry.hpp
index e45d7a5..a35fd81 100644
--- a/src/clicache/src/impl/PdxTypeRegistry.hpp
+++ b/src/clicache/src/impl/PdxTypeRegistry.hpp
@@ -16,6 +16,9 @@
*/
#pragma once
+#include "begin_native.hpp"
+#include "SerializationRegistry.hpp"
+#include "end_native.hpp"
#include "PdxType.hpp"
#include "PdxRemotePreservedData.hpp"
#include "../IPdxSerializable.hpp"
@@ -37,33 +40,35 @@ namespace Apache
public ref class PdxTypeRegistry
{
public:
+
+ PdxTypeRegistry(Cache^ cache) :m_cache(cache) {}
//test hook;
- static int testGetNumberOfPdxIds();
+ static int testGetNumberOfPdxIds();
//test hook
- static int testNumberOfPreservedData();
+ static int testNumberOfPreservedData();
- static void AddPdxType(Int32 typeId, PdxType^ pdxType);
+ static void AddPdxType(Int32 typeId, PdxType^ pdxType);
- static PdxType^ GetPdxType(Int32 typeId);
+ static PdxType^ GetPdxType(Int32 typeId);
- static void AddLocalPdxType(String^ localType, PdxType^ pdxType);
+ static void AddLocalPdxType(String^ localType, PdxType^ pdxType);
- static PdxType^ GetLocalPdxType(String^ localType);
+ static PdxType^ GetLocalPdxType(String^ localType);
- static void SetMergedType(Int32 remoteTypeId, PdxType^ mergedType);
+ static void SetMergedType(Int32 remoteTypeId, PdxType^ mergedType);
- static PdxType^ GetMergedType(Int32 remoteTypeId);
+ static PdxType^ GetMergedType(Int32 remoteTypeId);
- static void SetPreserveData(IPdxSerializable^ obj, PdxRemotePreservedData^ preserveData);
+ static void SetPreserveData(IPdxSerializable^ obj, PdxRemotePreservedData^ preserveData);
- static PdxRemotePreservedData^ GetPreserveData(IPdxSerializable^ obj);
+ static PdxRemotePreservedData^ GetPreserveData(IPdxSerializable^ obj);
- static void clear();
+ void clear();
- static Int32 GetPDXIdForType(Type^ type, const char* poolname, PdxType^ nType, bool checkIfThere);
+ static Int32 GetPDXIdForType(Type^ type, const char* poolname, PdxType^ nType, bool checkIfThere, const native::Cache* cache);
- static Int32 GetPDXIdForType(PdxType^ type, const char* poolname);
+ static Int32 GetPDXIdForType(PdxType^ type, const char* poolname, const native::Cache* cache);
static property bool PdxIgnoreUnreadFields
{
@@ -71,25 +76,26 @@ namespace Apache
void set(bool value){pdxIgnoreUnreadFields = value;}
}
- static property bool PdxReadSerialized
+ static property bool PdxReadSerialized
{
bool get() {return pdxReadSerialized;}
void set(bool value){pdxReadSerialized= value;}
}
- static Int32 GetEnumValue(EnumInfo^ ei);
+ static Int32 GetEnumValue(EnumInfo^ ei, const native::Cache* cache);
- static EnumInfo^ GetEnum(Int32 enumVal);
+ static EnumInfo^ GetEnum(Int32 enumVal, const native::Cache* cache);
private:
+ Cache^ m_cache;
- static IDictionary<Int32, PdxType^>^ typeIdToPdxType = gcnew Dictionary<Int32, PdxType^>();
+ static IDictionary<Int32, PdxType^>^ typeIdToPdxType = gcnew Dictionary<Int32, PdxType^>();
- static IDictionary<PdxType^, Int32>^ pdxTypeToTypeId = gcnew Dictionary<PdxType^, Int32>();
+ static IDictionary<PdxType^, Int32>^ pdxTypeToTypeId = gcnew Dictionary<PdxType^, Int32>();
- static IDictionary<Int32, PdxType^>^ remoteTypeIdToMergedPdxType = gcnew Dictionary<Int32, PdxType^>();
+ static IDictionary<Int32, PdxType^>^ remoteTypeIdToMergedPdxType = gcnew Dictionary<Int32, PdxType^>();
- static IDictionary<String^, PdxType^>^ localTypeToPdxType = gcnew Dictionary<String^, PdxType^>();
+ static IDictionary<String^, PdxType^>^ localTypeToPdxType = gcnew Dictionary<String^, PdxType^>();
static IDictionary<EnumInfo^, Int32>^ enumToInt = gcnew Dictionary<EnumInfo^, Int32>();
@@ -97,7 +103,7 @@ namespace Apache
//TODO: this will be weak hashmap
//static IDictionary<IPdxSerializable^ , PdxRemotePreservedData^>^ preserveData = gcnew Dictionary<IPdxSerializable^ , PdxRemotePreservedData^>();
- static WeakHashMap^ preserveData = gcnew WeakHashMap();
+ static WeakHashMap^ preserveData = gcnew WeakHashMap();
static ReaderWriterLock^ g_readerWriterLock = gcnew ReaderWriterLock();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PersistenceManagerProxy.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/PersistenceManagerProxy.hpp b/src/clicache/src/impl/PersistenceManagerProxy.hpp
index a88d0bd..6b519f6 100644
--- a/src/clicache/src/impl/PersistenceManagerProxy.hpp
+++ b/src/clicache/src/impl/PersistenceManagerProxy.hpp
@@ -72,7 +72,7 @@ namespace Apache
virtual CacheablePtr read(const CacheableKeyPtr& key/*, void *& PersistenceInfo*/)
{
TKey gKey = Serializable::GetManagedValueGeneric<TKey>(key);
- return Serializable::GetUnmanagedValueGeneric<TValue>(m_persistenceManager->Read(gKey));
+ return Serializable::GetUnmanagedValueGeneric<TValue>(m_persistenceManager->Read(gKey), nullptr);
}
virtual bool readAll()
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/SafeConvert.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/impl/SafeConvert.hpp b/src/clicache/src/impl/SafeConvert.hpp
index 69fe885..200c5d0 100644
--- a/src/clicache/src/impl/SafeConvert.hpp
+++ b/src/clicache/src/impl/SafeConvert.hpp
@@ -19,6 +19,10 @@
#include "../geode_defs.hpp"
+#include "begin_native.hpp"
+#include "CacheImpl.hpp"
+#include "end_native.hpp"
+
#include "ManagedCacheableKey.hpp"
#include "ManagedCacheableDelta.hpp"
#include "ManagedCacheableKeyBytes.hpp"
@@ -155,9 +159,9 @@ namespace Apache
}
else{
if(!SafeConvertClassGeneric::isAppDomainEnabled)
- return new ManagedWrapper(mg_obj, mg_obj->GetHashCode(), mg_obj->ClassId);
+ return new ManagedWrapper(mg_obj, mg_obj->GetHashCode(), mg_obj->ClassId, nullptr);
else
- return new native::ManagedCacheableKeyBytesGeneric( mg_obj, true);
+ return new native::ManagedCacheableKeyBytesGeneric(mg_obj, true);
}
}
//if (mg_obj == nullptr) return NULL;
@@ -230,7 +234,7 @@ namespace Apache
}
generic<class TValue>
- inline static native::Cacheable* SafeGenericM2UMConvert( TValue mg_val )
+ inline static native::Cacheable* SafeGenericM2UMConvert( TValue mg_val, native::Cache* cache )
{
if (mg_val == nullptr) return NULL;
@@ -254,7 +258,7 @@ namespace Apache
if(!SafeConvertClassGeneric::isAppDomainEnabled)
return new native::PdxManagedCacheableKey(pdxType);
else
- return new native::PdxManagedCacheableKeyBytes(pdxType, true);
+ return new native::PdxManagedCacheableKeyBytes(pdxType, true, cache);
}
Apache::Geode::Client::IGeodeDelta^ sDelta =
@@ -274,7 +278,7 @@ namespace Apache
{
if(!SafeConvertClassGeneric::isAppDomainEnabled)
{
- return new native::ManagedCacheableKeyGeneric( tmpIGFS );
+ return new native::ManagedCacheableKeyGeneric( tmpIGFS, nullptr);
}
else
{
@@ -288,16 +292,16 @@ namespace Apache
if(!SafeConvertClassGeneric::isAppDomainEnabled)
return new native::PdxManagedCacheableKey(gcnew PdxWrapper(mg_obj));
else
- return new native::PdxManagedCacheableKeyBytes(gcnew PdxWrapper(mg_obj), true);
+ return new native::PdxManagedCacheableKeyBytes(gcnew PdxWrapper(mg_obj), true, nullptr);
}
throw gcnew Apache::Geode::Client::IllegalStateException(String::Format("Unable to map object type {0}. Possible Object type may not be registered or PdxSerializer is not registered. ", mg_obj->GetType()));
}
}
generic<class TValue>
- inline static native::Cacheable* SafeGenericMSerializableConvert( TValue mg_obj )
+ inline static native::Cacheable* SafeGenericMSerializableConvert( TValue mg_obj, native::Cache* cache )
{
- return SafeGenericM2UMConvert<TValue>( mg_obj );
+ return SafeGenericM2UMConvert<TValue>( mg_obj, cache );
}
inline static IPdxSerializable^ SafeUMSerializablePDXConvert( native::SerializablePtr obj )
@@ -345,7 +349,7 @@ namespace Apache
inline static native::CacheableKey* SafeGenericMKeyConvert( TKey mg_obj )
{
if (mg_obj == nullptr) return NULL;
- auto obj = Apache::Geode::Client::Serializable::GetUnmanagedValueGeneric<TKey>( mg_obj );
+ auto obj = Apache::Geode::Client::Serializable::GetUnmanagedValueGeneric<TKey>( mg_obj, nullptr );
if (obj.get() != nullptr)
{
return obj.get();
@@ -353,9 +357,9 @@ namespace Apache
else
{
if(!SafeConvertClassGeneric::isAppDomainEnabled)
- return new native::ManagedCacheableKeyGeneric( SafeUMSerializableConvertGeneric(obj) );
+ return new native::ManagedCacheableKeyGeneric(SafeUMSerializableConvertGeneric(obj), nullptr);
else
- return new native::ManagedCacheableKeyBytesGeneric( SafeUMSerializableConvertGeneric(obj), true );
+ return new native::ManagedCacheableKeyBytesGeneric(SafeUMSerializableConvertGeneric(obj), true);
}
}
@@ -369,7 +373,7 @@ namespace Apache
if(!SafeConvertClassGeneric::isAppDomainEnabled)
return new native::ManagedCacheableKeyGeneric( mg_obj, mg_obj->GetHashCode(), mg_obj->ClassId );
else
- return new native::ManagedCacheableKeyBytesGeneric( mg_obj, true );
+ return new native::ManagedCacheableKeyBytesGeneric( mg_obj, true, nullptr);
}
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/include/geode/AuthInitialize.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/AuthInitialize.hpp b/src/cppcache/include/geode/AuthInitialize.hpp
index 569af59..0978b22 100644
--- a/src/cppcache/include/geode/AuthInitialize.hpp
+++ b/src/cppcache/include/geode/AuthInitialize.hpp
@@ -54,7 +54,7 @@ class CPPCACHE_EXPORT AuthInitialize {
* @remarks This method can modify the given set of properties. For
* example it may invoke external agents or even interact with the user.
*/
- virtual PropertiesPtr getCredentials(PropertiesPtr& securityprops,
+ virtual PropertiesPtr getCredentials(const PropertiesPtr& securityprops,
const char* server) = 0;
/**@brief Invoked before the cache goes down. */
[05/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/VersionedCacheableObjectPartList.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/VersionedCacheableObjectPartList.cpp b/src/cppcache/src/VersionedCacheableObjectPartList.cpp
index 94ec919..ecfc350 100644
--- a/src/cppcache/src/VersionedCacheableObjectPartList.cpp
+++ b/src/cppcache/src/VersionedCacheableObjectPartList.cpp
@@ -203,6 +203,8 @@ Serializable* VersionedCacheableObjectPartList::fromData(DataInput& input) {
len = versionTaglen;
m_versionTags.resize(versionTaglen);
std::vector<uint16_t> ids;
+ MemberListForVersionStamp& memberListForVersionStamp =
+ *(m_region->getCacheImpl()->getMemberListForVersionStamp());
for (int32_t index = 0; index < versionTaglen; index++) {
uint8_t entryType = 0;
input.read(&entryType);
@@ -213,9 +215,11 @@ Serializable* VersionedCacheableObjectPartList::fromData(DataInput& input) {
}
case FLAG_FULL_TAG: {
if (persistent) {
- versionTag = VersionTagPtr(new DiskVersionTag());
+ versionTag =
+ VersionTagPtr(new DiskVersionTag(memberListForVersionStamp));
} else {
- versionTag = VersionTagPtr(new VersionTag());
+ versionTag =
+ VersionTagPtr(new VersionTag(memberListForVersionStamp));
}
versionTag->fromData(input);
versionTag->replaceNullMemberId(getEndpointMemId());
@@ -224,9 +228,11 @@ Serializable* VersionedCacheableObjectPartList::fromData(DataInput& input) {
case FLAG_TAG_WITH_NEW_ID: {
if (persistent) {
- versionTag = VersionTagPtr(new DiskVersionTag());
+ versionTag =
+ VersionTagPtr(new DiskVersionTag(memberListForVersionStamp));
} else {
- versionTag = VersionTagPtr(new VersionTag());
+ versionTag =
+ VersionTagPtr(new VersionTag(memberListForVersionStamp));
}
versionTag->fromData(input);
ids.push_back(versionTag->getInternalMemID());
@@ -235,9 +241,11 @@ Serializable* VersionedCacheableObjectPartList::fromData(DataInput& input) {
case FLAG_TAG_WITH_NUMBER_ID: {
if (persistent) {
- versionTag = VersionTagPtr(new DiskVersionTag());
+ versionTag =
+ VersionTagPtr(new DiskVersionTag(memberListForVersionStamp));
} else {
- versionTag = VersionTagPtr(new VersionTag());
+ versionTag =
+ VersionTagPtr(new VersionTag(memberListForVersionStamp));
}
versionTag->fromData(input);
int32_t idNumber;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/VersionedCacheableObjectPartList.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/VersionedCacheableObjectPartList.hpp b/src/cppcache/src/VersionedCacheableObjectPartList.hpp
index 91b7f3c..9ebd6f4 100644
--- a/src/cppcache/src/VersionedCacheableObjectPartList.hpp
+++ b/src/cppcache/src/VersionedCacheableObjectPartList.hpp
@@ -126,6 +126,18 @@ class VersionedCacheableObjectPartList : public CacheableObjectPartList {
;
}
+ VersionedCacheableObjectPartList(ThinClientRegion* region, uint16_t dsmemId,
+ ACE_Recursive_Thread_Mutex& responseLock)
+ : CacheableObjectPartList(region),
+ m_responseLock(responseLock),
+ m_endpointMemId(dsmemId) {
+ m_regionIsVersioned = false;
+ m_serializeValues = false;
+ m_hasTags = false;
+ this->m_hasKeys = false;
+ ;
+ }
+
VersionedCacheableObjectPartList(VectorOfCacheableKey* keys,
ACE_Recursive_Thread_Mutex& responseLock)
: m_tempKeys(keys), m_responseLock(responseLock) {
@@ -136,8 +148,12 @@ class VersionedCacheableObjectPartList : public CacheableObjectPartList {
this->m_hasKeys = false;
}
- VersionedCacheableObjectPartList(ACE_Recursive_Thread_Mutex& responseLock)
- : m_responseLock(responseLock) {
+ VersionedCacheableObjectPartList(ThinClientRegion* region,
+ VectorOfCacheableKey* keys,
+ ACE_Recursive_Thread_Mutex& responseLock)
+ : CacheableObjectPartList(region),
+ m_tempKeys(keys),
+ m_responseLock(responseLock) {
m_regionIsVersioned = false;
m_serializeValues = false;
m_hasTags = false;
@@ -145,12 +161,15 @@ class VersionedCacheableObjectPartList : public CacheableObjectPartList {
this->m_hasKeys = false;
}
- /*inline VersionedCacheableObjectPartList(bool serializeValues)
- {
- m_serializeValues = serializeValues;
- GF_NEW(m_tempKeys, VectorOfCacheableKey);
-
- }*/
+ VersionedCacheableObjectPartList(ThinClientRegion* region,
+ ACE_Recursive_Thread_Mutex& responseLock)
+ : m_responseLock(responseLock), CacheableObjectPartList(region) {
+ m_regionIsVersioned = false;
+ m_serializeValues = false;
+ m_hasTags = false;
+ m_endpointMemId = 0;
+ this->m_hasKeys = false;
+ }
inline uint16_t getEndpointMemId() { return m_endpointMemId; }
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/statistics/GeodeStatisticsFactory.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/statistics/GeodeStatisticsFactory.cpp b/src/cppcache/src/statistics/GeodeStatisticsFactory.cpp
index ae5ec92..b3423e7 100644
--- a/src/cppcache/src/statistics/GeodeStatisticsFactory.cpp
+++ b/src/cppcache/src/statistics/GeodeStatisticsFactory.cpp
@@ -33,11 +33,6 @@
using namespace apache::geode::client;
using namespace apache::geode::statistics;
-/**
- * static member initialization
- */
-GeodeStatisticsFactory* GeodeStatisticsFactory::s_singleton = nullptr;
-
GeodeStatisticsFactory::GeodeStatisticsFactory(StatisticsManager* statMngr) {
m_name = "GeodeStatisticsFactory";
m_id = ACE_OS::getpid();
@@ -46,31 +41,6 @@ GeodeStatisticsFactory::GeodeStatisticsFactory(StatisticsManager* statMngr) {
m_statMngr = statMngr;
}
-GeodeStatisticsFactory* GeodeStatisticsFactory::initInstance(
- StatisticsManager* statMngr) {
- if (!s_singleton) {
- s_singleton = new GeodeStatisticsFactory(statMngr);
- }
-
- return s_singleton;
-}
-
-GeodeStatisticsFactory* GeodeStatisticsFactory::getExistingInstance() {
- GF_D_ASSERT(!!s_singleton);
-
- s_singleton->getId(); // should fault if !s_singleton
-
- return s_singleton;
-}
-
-/**************************Dtor*******************************************/
-void GeodeStatisticsFactory::clean() {
- if (s_singleton != nullptr) {
- delete s_singleton;
- s_singleton = nullptr;
- }
-}
-
GeodeStatisticsFactory::~GeodeStatisticsFactory() {
try {
m_statMngr = nullptr;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/statistics/GeodeStatisticsFactory.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/statistics/GeodeStatisticsFactory.hpp b/src/cppcache/src/statistics/GeodeStatisticsFactory.hpp
index ba9157c..33c3a32 100644
--- a/src/cppcache/src/statistics/GeodeStatisticsFactory.hpp
+++ b/src/cppcache/src/statistics/GeodeStatisticsFactory.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_STATISTICS_GEODESTATISTICSFACTORY_H_
-#define GEODE_STATISTICS_GEODESTATISTICSFACTORY_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,19 +15,22 @@
* limitations under the License.
*/
-#include <geode/geode_globals.hpp>
+#pragma once
+
+#ifndef GEODE_STATISTICS_GEODESTATISTICSFACTORY_H_
+#define GEODE_STATISTICS_GEODESTATISTICSFACTORY_H_
-#include <sys/types.h>
-#ifndef WIN32
-#include <unistd.h>
-#endif
#include <vector>
+
#include <ace/Recursive_Thread_Mutex.h>
#include <ace/Map_Manager.h>
-#include "StatisticsTypeImpl.hpp"
+
+#include <geode/geode_globals.hpp>
+#include <geode/ExceptionTypes.hpp>
#include <geode/statistics/StatisticsFactory.hpp>
+
+#include "StatisticsTypeImpl.hpp"
#include "StatisticsManager.hpp"
-#include <geode/ExceptionTypes.hpp>
using namespace apache::geode::client;
@@ -51,20 +49,12 @@ class StatisticsManager;
*/
class GeodeStatisticsFactory : public StatisticsFactory {
private:
- //--------------------Properties-------------------------------------------------
-
const char* m_name;
int64_t m_id;
StatisticsManager* m_statMngr;
- static GeodeStatisticsFactory* s_singleton;
-
- //------------------ methods ------------------------------
-
- GeodeStatisticsFactory(StatisticsManager* statMngr);
-
int64_t m_statsListUniqueId; // Creates a unique id for each stats object in
// the list
@@ -76,23 +66,14 @@ class GeodeStatisticsFactory : public StatisticsFactory {
StatisticsTypeImpl* addType(StatisticsTypeImpl* t);
- //////////////////////////public member functions///////////////////////////
-
public:
+ GeodeStatisticsFactory(StatisticsManager* statMngr);
~GeodeStatisticsFactory();
- static void clean();
-
const char* getName();
int64_t getId();
- static GeodeStatisticsFactory* initInstance(StatisticsManager* statMngr);
-
- static GeodeStatisticsFactory* getExistingInstance();
-
- //------------ StatisticsFactory methods: Statistics
- //------------------------------
Statistics* createStatistics(StatisticsType* type);
Statistics* createStatistics(StatisticsType* type, const char* textId);
@@ -110,15 +91,11 @@ class GeodeStatisticsFactory : public StatisticsFactory {
Statistics* createAtomicStatistics(StatisticsType* type, const char* textId,
int64_t numericId);
- //------------ StatisticsFactory methods: Statistics Type
- //------------------------------
StatisticsType* createType(const char* name, const char* description,
StatisticDescriptor** stats, int32_t statsLength);
StatisticsType* findType(const char* name);
- //------------ StatisticsFactory methods: Statistics Descriptor
- //---------------------
StatisticDescriptor* createIntCounter(const char* name,
const char* description,
const char* units, bool largerBetter);
@@ -145,8 +122,7 @@ class GeodeStatisticsFactory : public StatisticsFactory {
/** Return the first instance that matches the type, or nullptr */
Statistics* findFirstStatisticsByType(StatisticsType* type);
-
-}; // class
+};
} // namespace statistics
} // namespace geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/statistics/HostStatHelper.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/statistics/HostStatHelper.cpp b/src/cppcache/src/statistics/HostStatHelper.cpp
index d2a330f..040930d 100644
--- a/src/cppcache/src/statistics/HostStatHelper.cpp
+++ b/src/cppcache/src/statistics/HostStatHelper.cpp
@@ -83,20 +83,21 @@ void HostStatHelper::refresh() {
* Creates and returns a {@link Statistics} with
* the given pid and name.
*/
-void HostStatHelper::newProcessStats(int64_t pid, const char* name) {
+void HostStatHelper::newProcessStats(GeodeStatisticsFactory* statisticsFactory,
+ int64_t pid, const char* name) {
// Init OsCode
initOSCode();
// Create processStats , Internally they will create own stats
switch (osCode) {
case GFS_OSTYPE_SOLARIS:
- processStats = new SolarisProcessStats(pid, name);
+ processStats = new SolarisProcessStats(statisticsFactory, pid, name);
break;
case GFS_OSTYPE_LINUX:
- processStats = new LinuxProcessStats(pid, name);
+ processStats = new LinuxProcessStats(statisticsFactory, pid, name);
break;
case GFS_OSTYPE_WINDOWS:
- processStats = new WindowsProcessStats(pid, name);
+ processStats = new WindowsProcessStats(statisticsFactory, pid, name);
break;
case GFS_OSTYPE_MACOSX:
processStats = new NullProcessStats(pid, name);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/statistics/HostStatHelper.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/statistics/HostStatHelper.hpp b/src/cppcache/src/statistics/HostStatHelper.hpp
index eb63531..be26bb2 100644
--- a/src/cppcache/src/statistics/HostStatHelper.hpp
+++ b/src/cppcache/src/statistics/HostStatHelper.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_STATISTICS_HOSTSTATHELPER_H_
-#define GEODE_STATISTICS_HOSTSTATHELPER_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,6 +15,11 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_STATISTICS_HOSTSTATHELPER_H_
+#define GEODE_STATISTICS_HOSTSTATHELPER_H_
+
#include <geode/geode_globals.hpp>
#include <string>
#include "StatisticDescriptorImpl.hpp"
@@ -42,7 +42,7 @@
// TODO refactor - conditionally include os specific impl headers.
/** @file
-*/
+ */
namespace apache {
namespace geode {
@@ -72,13 +72,14 @@ class CPPCACHE_EXPORT HostStatHelper {
static void refresh();
- static void newProcessStats(int64_t pid, const char* name);
+ static void newProcessStats(GeodeStatisticsFactory* statisticsFactory,
+ int64_t pid, const char* name);
static void close();
static void cleanup();
};
-} // namespace client
+} // namespace statistics
} // namespace geode
} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/statistics/HostStatSampler.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/statistics/HostStatSampler.cpp b/src/cppcache/src/statistics/HostStatSampler.cpp
index 7f8788f..777fed3 100644
--- a/src/cppcache/src/statistics/HostStatSampler.cpp
+++ b/src/cppcache/src/statistics/HostStatSampler.cpp
@@ -39,6 +39,9 @@
#include "GeodeStatisticsFactory.hpp"
#include <ClientHealthStats.hpp>
#include <ClientProxyMembershipID.hpp>
+#include "CacheImpl.hpp"
+using namespace apache::geode::statistics;
+using namespace apache::geode::client;
namespace apache {
namespace geode {
@@ -58,7 +61,9 @@ typedef std::vector<std::pair<std::string, int64_t> > g_fileInfo;
} // namespace geode
} // namespace apache
-extern "C" {
+using namespace apache::geode::statistics::globals;
+
+// extern "C" {
int selector(const dirent* d) {
std::string inputname(d->d_name);
@@ -110,7 +115,7 @@ int comparator(const dirent** d1, const dirent** d2) {
return 0;
}
}
-}
+//}
namespace apache {
namespace geode {
@@ -124,26 +129,27 @@ using std::chrono::nanoseconds;
const char* HostStatSampler::NC_HSS_Thread = "NC HSS Thread";
HostStatSampler::HostStatSampler(const char* filePath, int64_t sampleIntervalMs,
- StatisticsManager* statMngr,
+ StatisticsManager* statMngr, Cache* cache,
+ const char* durableClientId,
+ const uint32_t durableTimeout,
int64_t statFileLimit,
- int64_t statDiskSpaceLimit) {
+ int64_t statDiskSpaceLimit)
+ : m_cache(cache) {
m_isStatDiskSpaceEnabled = false;
m_adminError = false;
m_running = false;
m_stopRequested = false;
m_archiver = nullptr;
- m_samplerStats = new StatSamplerStats();
-
+ m_samplerStats = new StatSamplerStats(statMngr->getStatisticsFactory());
m_startTime = system_clock::now();
-
m_pid = ACE_OS::getpid();
m_statMngr = statMngr;
m_archiveFileName = filePath;
- globals::g_statFile = filePath;
+ g_statFile = filePath;
m_sampleRate = sampleIntervalMs;
rollIndex = 0;
m_archiveDiskSpaceLimit = statDiskSpaceLimit;
- globals::g_spaceUsed = 0;
+ g_spaceUsed = 0;
if (statDiskSpaceLimit != 0) {
m_isStatDiskSpaceEnabled = true;
@@ -365,7 +371,7 @@ void HostStatSampler::changeArchive(std::string filename) {
}
filename = chkForGFSExt(filename);
if (m_archiver != nullptr) {
- globals::g_previoussamplesize = m_archiver->getSampleSize();
+ g_previoussamplesize = m_archiver->getSampleSize();
m_archiver->closeFile();
}
// create new file only when tis file has some data; otherwise reuse it
@@ -385,7 +391,7 @@ void HostStatSampler::changeArchive(std::string filename) {
m_archiver = nullptr;
}
- m_archiver = new StatArchiveWriter(filename, this);
+ m_archiver = new StatArchiveWriter(filename, this, m_cache);
}
std::string HostStatSampler::chkForGFSExt(std::string filename) {
@@ -500,7 +506,8 @@ int32_t HostStatSampler::rollArchive(std::string filename) {
void HostStatSampler::initSpecialStats() {
// After Special categories are decided initialize them here
- HostStatHelper::newProcessStats(m_pid, "ProcessStats");
+ HostStatHelper::newProcessStats(m_statMngr->getStatisticsFactory(), m_pid,
+ "ProcessStats");
}
void HostStatSampler::sampleSpecialStats() { HostStatHelper::refresh(); }
@@ -537,10 +544,13 @@ void HostStatSampler::putStatsInAdminRegion() {
static std::string clientId = "";
AdminRegionPtr adminRgn = m_statMngr->getAdminRegion();
if (adminRgn == nullptr) return;
+ auto conn_man = adminRgn->getConnectionManager();
+ if (conn_man->isNetDown()) {
+ return;
+ }
TryReadGuard _guard(adminRgn->getRWLock(), adminRgn->isDestroyed());
if (!adminRgn->isDestroyed()) {
- TcrConnectionManager* m_conn_man = adminRgn->getConnectionManager();
- if (m_conn_man->getNumEndPoints() > 0) {
+ if (conn_man->getNumEndPoints() > 0) {
if (!initDone) {
adminRgn->init();
initDone = true;
@@ -548,8 +558,7 @@ void HostStatSampler::putStatsInAdminRegion() {
int puts = 0, gets = 0, misses = 0, numListeners = 0, numThreads = 0,
creates = 0;
int64_t cpuTime = 0;
- GeodeStatisticsFactory* gf =
- GeodeStatisticsFactory::getExistingInstance();
+ auto gf = m_statMngr->getStatisticsFactory();
if (gf) {
StatisticsType* cacheStatType = gf->findType("CachePerfStats");
if (cacheStatType) {
@@ -577,15 +586,12 @@ void HostStatSampler::putStatsInAdminRegion() {
ACE_INET_Addr driver("", hostName, "tcp");
uint32_t hostAddr = driver.get_ip_address();
uint16_t hostPort = 0;
- SystemProperties* sysProp = DistributedSystem::getSystemProperties();
- const char* durableId =
- (sysProp != nullptr) ? sysProp->durableClientId() : nullptr;
- const uint32_t durableTimeOut =
- (sysProp != nullptr) ? sysProp->durableTimeout() : 0;
-
- ClientProxyMembershipID memId(hostName, hostAddr, hostPort, durableId,
- durableTimeOut);
- clientId = memId.getDSMemberIdForThinClientUse();
+
+ auto memId = conn_man->getCacheImpl()
+ ->getClientProxyMembershipIDFactory()
+ .create(hostName, hostAddr, hostPort,
+ m_durableClientId, m_durableTimeout);
+ clientId = memId->getDSMemberIdForThinClientUse();
}
CacheableKeyPtr keyPtr = CacheableString::create(clientId.c_str());
@@ -619,39 +625,40 @@ void HostStatSampler::doSample(std::string& archivefilename) {
checkListeners();
// Populate Admin Region for GFMon
- if (isSamplingEnabled() && !m_adminError &&
- !TcrConnectionManager::isNetDown) {
+ if (isSamplingEnabled() && !m_adminError) {
putStatsInAdminRegion();
}
- m_archiver->sample();
+ if (m_archiver) {
+ m_archiver->sample();
- if (m_archiveFileSizeLimit != 0) {
- int64_t size = m_archiver->getSampleSize();
- int64_t bytesWritten =
- m_archiver->bytesWritten(); // + globals::g_previoussamplesize;
- if (bytesWritten > (m_archiveFileSizeLimit - size)) {
- // roll the archive
- changeArchive(archivefilename);
+ if (m_archiveFileSizeLimit != 0) {
+ int64_t size = m_archiver->getSampleSize();
+ int64_t bytesWritten =
+ m_archiver->bytesWritten(); // + g_previoussamplesize;
+ if (bytesWritten > (m_archiveFileSizeLimit - size)) {
+ // roll the archive
+ changeArchive(archivefilename);
+ }
+ }
+ g_spaceUsed += m_archiver->bytesWritten();
+ // delete older stat files if disk limit is about to be exceeded.
+ if ((m_archiveDiskSpaceLimit != 0) &&
+ (g_spaceUsed >=
+ (m_archiveDiskSpaceLimit - m_archiver->getSampleSize()))) {
+ checkDiskLimit();
}
- }
- globals::g_spaceUsed += m_archiver->bytesWritten();
- // delete older stat files if disk limit is about to be exceeded.
- if ((m_archiveDiskSpaceLimit != 0) &&
- (globals::g_spaceUsed >=
- (m_archiveDiskSpaceLimit - m_archiver->getSampleSize()))) {
- checkDiskLimit();
- }
- // It will flush the contents to the archive file, in every
- // sample run.
+ // It will flush the contents to the archive file, in every
+ // sample run.
- m_archiver->flush();
+ m_archiver->flush();
+ }
}
void HostStatSampler::checkDiskLimit() {
- globals::g_fileInfo fileInfo;
- globals::g_spaceUsed = 0;
+ g_fileInfo fileInfo;
+ g_spaceUsed = 0;
char fullpath[512] = {0};
std::string dirname = ACE::dirname(globals::g_statFile.c_str());
// struct dirent **resultArray;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/statistics/HostStatSampler.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/statistics/HostStatSampler.hpp b/src/cppcache/src/statistics/HostStatSampler.hpp
index 7723799..67d2238 100644
--- a/src/cppcache/src/statistics/HostStatSampler.hpp
+++ b/src/cppcache/src/statistics/HostStatSampler.hpp
@@ -39,7 +39,7 @@
using namespace apache::geode::client;
/** @file
-*/
+ */
#ifndef GEMFIRE_MAX_STATS_FILE_LIMIT
#define GEMFIRE_MAX_STATS_FILE_LIMIT (1024 * 1024 * 1024)
#endif
@@ -82,8 +82,9 @@ class CPPCACHE_EXPORT HostStatSampler : public ACE_Task_Base,
* Constructor:
*/
HostStatSampler(const char* filePath, int64_t sampleIntervalMs,
- StatisticsManager* statMngr, int64_t statFileLimit = 0,
- int64_t statDiskSpaceLimit = 0);
+ StatisticsManager* statMngr, Cache* cache,
+ const char* durableClientId, const uint32_t durableTimeout,
+ int64_t statFileLimit = 0, int64_t statDiskSpaceLimit = 0);
/**
* Adds the pid to the archive file passed to it.
@@ -192,8 +193,8 @@ class CPPCACHE_EXPORT HostStatSampler : public ACE_Task_Base,
int32_t svc(void);
/**
- * Method to know whether the sampling thread is running or not.
- */
+ * Method to know whether the sampling thread is running or not.
+ */
bool isRunning();
~HostStatSampler();
@@ -207,12 +208,15 @@ class CPPCACHE_EXPORT HostStatSampler : public ACE_Task_Base,
volatile bool m_isStatDiskSpaceEnabled;
StatArchiveWriter* m_archiver;
StatSamplerStats* m_samplerStats;
+ const char* m_durableClientId;
+ uint32_t m_durableTimeout;
std::string m_archiveFileName;
int64_t m_archiveFileSizeLimit;
int64_t m_archiveDiskSpaceLimit;
int64_t m_sampleRate;
StatisticsManager* m_statMngr;
+ Cache* m_cache;
int64_t m_pid;
system_clock::time_point m_startTime;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/statistics/LinuxProcessStats.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/statistics/LinuxProcessStats.cpp b/src/cppcache/src/statistics/LinuxProcessStats.cpp
index ca77bba..f1e0a2b 100644
--- a/src/cppcache/src/statistics/LinuxProcessStats.cpp
+++ b/src/cppcache/src/statistics/LinuxProcessStats.cpp
@@ -18,8 +18,8 @@
#include <ace/Thread_Mutex.h>
#include <ace/Singleton.h>
#include "LinuxProcessStats.hpp"
-#include "GeodeStatisticsFactory.hpp"
#include "HostStatHelperLinux.hpp"
+
using namespace apache::geode::statistics;
/**
@@ -28,10 +28,8 @@ using namespace apache::geode::statistics;
*
*/
-LinuxProcessStats::LinuxProcessStats(int64_t pid, const char* name) {
- GeodeStatisticsFactory* statFactory =
- GeodeStatisticsFactory::getExistingInstance();
-
+LinuxProcessStats::LinuxProcessStats(GeodeStatisticsFactory* statFactory,
+ int64_t pid, const char* name) {
// Create Statistics Type
createType(statFactory);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/statistics/LinuxProcessStats.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/statistics/LinuxProcessStats.hpp b/src/cppcache/src/statistics/LinuxProcessStats.hpp
index 86eb745..19321ce 100644
--- a/src/cppcache/src/statistics/LinuxProcessStats.hpp
+++ b/src/cppcache/src/statistics/LinuxProcessStats.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_STATISTICS_LINUXPROCESSSTATS_H_
-#define GEODE_STATISTICS_LINUXPROCESSSTATS_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,17 +15,24 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_STATISTICS_LINUXPROCESSSTATS_H_
+#define GEODE_STATISTICS_LINUXPROCESSSTATS_H_
+
#include <geode/geode_globals.hpp>
#include <geode/statistics/Statistics.hpp>
#include <geode/statistics/StatisticsType.hpp>
#include <geode/statistics/StatisticDescriptor.hpp>
+
#include "ProcessStats.hpp"
#include "HostStatHelper.hpp"
+#include "GeodeStatisticsFactory.hpp"
using namespace apache::geode::client;
/** @file
-*/
+ */
namespace apache {
namespace geode {
@@ -60,7 +62,8 @@ class CPPCACHE_EXPORT LinuxProcessStats : public ProcessStats {
void createType(StatisticsFactory* statFactory);
public:
- LinuxProcessStats(int64_t pid, const char* name);
+ LinuxProcessStats(GeodeStatisticsFactory* statFactory, int64_t pid,
+ const char* name);
~LinuxProcessStats();
int64_t getProcessSize();
@@ -79,7 +82,7 @@ class CPPCACHE_EXPORT LinuxProcessStats : public ProcessStats {
}; // Class LinuxProcessStats
-} // namespace client
+} // namespace statistics
} // namespace geode
} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/statistics/PoolStatsSampler.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/statistics/PoolStatsSampler.cpp b/src/cppcache/src/statistics/PoolStatsSampler.cpp
index 96e5d78..094b59f 100644
--- a/src/cppcache/src/statistics/PoolStatsSampler.cpp
+++ b/src/cppcache/src/statistics/PoolStatsSampler.cpp
@@ -38,7 +38,11 @@ const char* PoolStatsSampler::NC_PSS_Thread = "NC PSS Thread";
PoolStatsSampler::PoolStatsSampler(int64_t sampleRate, CacheImpl* cache,
ThinClientPoolDM* distMan)
- : m_sampleRate(sampleRate), m_distMan(distMan) {
+ : m_sampleRate(sampleRate),
+ m_distMan(distMan),
+ m_statisticsFactory(cache->getDistributedSystem()
+ .getStatisticsManager()
+ ->getStatisticsFactory()) {
m_running = false;
m_stopRequested = false;
m_adminRegion = AdminRegion::create(cache, distMan);
@@ -91,13 +95,12 @@ void PoolStatsSampler::putStatsInAdminRegion() {
int puts = 0, gets = 0, misses = 0, numListeners = 0, numThreads = 0,
creates = 0;
int64_t cpuTime = 0;
- GeodeStatisticsFactory* gf =
- GeodeStatisticsFactory::getExistingInstance();
- if (gf) {
- StatisticsType* cacheStatType = gf->findType("CachePerfStats");
+ if (m_statisticsFactory) {
+ StatisticsType* cacheStatType =
+ m_statisticsFactory->findType("CachePerfStats");
if (cacheStatType) {
Statistics* cachePerfStats =
- gf->findFirstStatisticsByType(cacheStatType);
+ m_statisticsFactory->findFirstStatisticsByType(cacheStatType);
if (cachePerfStats) {
puts = cachePerfStats->getInt((char*)"puts");
gets = cachePerfStats->getInt((char*)"gets");
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/statistics/PoolStatsSampler.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/statistics/PoolStatsSampler.hpp b/src/cppcache/src/statistics/PoolStatsSampler.hpp
index 2ccf809..d600312 100644
--- a/src/cppcache/src/statistics/PoolStatsSampler.hpp
+++ b/src/cppcache/src/statistics/PoolStatsSampler.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_STATISTICS_POOLSTATSSAMPLER_H_
-#define GEODE_STATISTICS_POOLSTATSSAMPLER_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -19,8 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+#pragma once
+
+#ifndef GEODE_STATISTICS_POOLSTATSSAMPLER_H_
+#define GEODE_STATISTICS_POOLSTATSSAMPLER_H_
+
#include <ace/Task.h>
#include <geode/geode_globals.hpp>
+
+#include "statistics/GeodeStatisticsFactory.hpp"
+
namespace apache {
namespace geode {
namespace client {
@@ -60,6 +64,7 @@ class CPPCACHE_EXPORT PoolStatsSampler : public ACE_Task_Base {
ThinClientPoolDM* m_distMan;
ACE_Recursive_Thread_Mutex m_lock;
static const char* NC_PSS_Thread;
+ GeodeStatisticsFactory* m_statisticsFactory;
};
} // namespace statistics
} // namespace geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/statistics/SolarisProcessStats.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/statistics/SolarisProcessStats.cpp b/src/cppcache/src/statistics/SolarisProcessStats.cpp
index 27275b1..7aa3327 100644
--- a/src/cppcache/src/statistics/SolarisProcessStats.cpp
+++ b/src/cppcache/src/statistics/SolarisProcessStats.cpp
@@ -18,8 +18,8 @@
#include <ace/Thread_Mutex.h>
#include <ace/Singleton.h>
#include "SolarisProcessStats.hpp"
-#include "GeodeStatisticsFactory.hpp"
#include "HostStatHelperSolaris.hpp"
+
using namespace apache::geode::statistics;
/**
@@ -28,10 +28,8 @@ using namespace apache::geode::statistics;
*
*/
-SolarisProcessStats::SolarisProcessStats(int64_t pid, const char* name) {
- GeodeStatisticsFactory* statFactory =
- GeodeStatisticsFactory::getExistingInstance();
-
+SolarisProcessStats::SolarisProcessStats(GeodeStatisticsFactory* statFactory,
+ int64_t pid, const char* name) {
// Create Statistics Type
createType(statFactory);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/statistics/SolarisProcessStats.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/statistics/SolarisProcessStats.hpp b/src/cppcache/src/statistics/SolarisProcessStats.hpp
index 3233b13..5defe55 100644
--- a/src/cppcache/src/statistics/SolarisProcessStats.hpp
+++ b/src/cppcache/src/statistics/SolarisProcessStats.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_STATISTICS_SOLARISPROCESSSTATS_H_
-#define GEODE_STATISTICS_SOLARISPROCESSSTATS_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -19,17 +14,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_STATISTICS_SOLARISPROCESSSTATS_H_
+#define GEODE_STATISTICS_SOLARISPROCESSSTATS_H_
+
#include <geode/geode_globals.hpp>
#include <geode/statistics/Statistics.hpp>
#include <geode/statistics/StatisticsType.hpp>
#include <geode/statistics/StatisticDescriptor.hpp>
#include "ProcessStats.hpp"
#include "HostStatHelper.hpp"
+#include "GeodeStatisticsFactory.hpp"
using namespace apache::geode::client;
/** @file
-*/
+ */
namespace apache {
namespace geode {
@@ -60,7 +61,8 @@ class CPPCACHE_EXPORT SolarisProcessStats : public ProcessStats {
void createType(StatisticsFactory* statFactory);
public:
- SolarisProcessStats(int64_t pid, const char* name);
+ SolarisProcessStats(GeodeStatisticsFactory* statisticsFactory, int64_t pid,
+ const char* name);
~SolarisProcessStats();
int64_t getProcessSize();
@@ -80,7 +82,7 @@ class CPPCACHE_EXPORT SolarisProcessStats : public ProcessStats {
}; // Class SolarisProcessStats
-} // namespace client
+} // namespace statistics
} // namespace geode
} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/statistics/StatArchiveWriter.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/statistics/StatArchiveWriter.cpp b/src/cppcache/src/statistics/StatArchiveWriter.cpp
index 90e79f2..47f03ec 100644
--- a/src/cppcache/src/statistics/StatArchiveWriter.cpp
+++ b/src/cppcache/src/statistics/StatArchiveWriter.cpp
@@ -39,11 +39,14 @@ using std::chrono::nanoseconds;
// Constructor and Member functions of StatDataOutput class
-StatDataOutput::StatDataOutput(std::string filename) {
+StatDataOutput::StatDataOutput(std::string filename, Cache *cache) {
if (filename.length() == 0) {
std::string s("undefined archive file name");
throw IllegalArgumentException(s.c_str());
}
+
+ SerializationRegistry serializationRegistry;
+ dataBuffer = cache->createDataOutput();
outFile = filename;
closed = false;
bytesWritten = 0;
@@ -63,12 +66,12 @@ StatDataOutput::~StatDataOutput() {
int64_t StatDataOutput::getBytesWritten() { return this->bytesWritten; }
void StatDataOutput::flush() {
- const uint8_t *buffBegin = dataBuffer.getBuffer();
+ const uint8_t *buffBegin = dataBuffer->getBuffer();
if (buffBegin == nullptr) {
std::string s("undefined stat data buffer beginning");
throw NullPointerException(s.c_str());
}
- const uint8_t *buffEnd = dataBuffer.getCursor();
+ const uint8_t *buffEnd = dataBuffer->getCursor();
if (buffEnd == nullptr) {
std::string s("undefined stat data buffer end");
throw NullPointerException(s.c_str());
@@ -90,41 +93,41 @@ void StatDataOutput::flush() {
}
void StatDataOutput::resetBuffer() {
- dataBuffer.reset();
+ dataBuffer->reset();
bytesWritten = 0;
}
void StatDataOutput::writeByte(int8_t v) {
- dataBuffer.write((int8_t)v);
+ dataBuffer->write((int8_t)v);
bytesWritten += 1;
}
void StatDataOutput::writeBoolean(int8_t v) { writeByte(v); }
void StatDataOutput::writeShort(int16_t v) {
- dataBuffer.writeInt(v);
+ dataBuffer->writeInt(v);
bytesWritten += 2;
}
void StatDataOutput::writeInt(int32_t v) {
- dataBuffer.writeInt(v);
+ dataBuffer->writeInt(v);
bytesWritten += 4;
}
void StatDataOutput::writeLong(int64_t v) {
- dataBuffer.writeInt(v);
+ dataBuffer->writeInt(v);
bytesWritten += 8;
}
void StatDataOutput::writeString(std::string s) {
size_t len = s.length();
- dataBuffer.writeASCII(s.data(), static_cast<uint32_t>(len));
+ dataBuffer->writeASCII(s.data(), static_cast<uint32_t>(len));
bytesWritten += len;
}
void StatDataOutput::writeUTF(std::wstring s) {
size_t len = s.length();
- dataBuffer.writeUTF(s.data(), static_cast<uint32_t>(len));
+ dataBuffer->writeUTF(s.data(), static_cast<uint32_t>(len));
bytesWritten += len;
}
@@ -311,7 +314,8 @@ void ResourceInst::writeResourceInst(StatDataOutput *dataOutArg,
// Constructor and Member functions of StatArchiveWriter class
StatArchiveWriter::StatArchiveWriter(std::string outfile,
- HostStatSampler *samplerArg) {
+ HostStatSampler *samplerArg, Cache *cache)
+ : cache(cache) {
resourceTypeId = 0;
resourceInstId = 0;
statResourcesModCount = 0;
@@ -323,7 +327,7 @@ StatArchiveWriter::StatArchiveWriter(std::string outfile,
*/
m_samplesize = 0;
- dataBuffer = new StatDataOutput(archiveFile);
+ dataBuffer = new StatDataOutput(archiveFile, cache);
this->sampler = samplerArg;
// write the time, system property etc.
@@ -426,14 +430,14 @@ void StatArchiveWriter::closeFile() { this->dataBuffer->close(); }
void StatArchiveWriter::openFile(std::string filename) {
// this->dataBuffer->openFile(filename, m_samplesize);
- StatDataOutput *p_dataBuffer = new StatDataOutput(filename);
+ StatDataOutput *p_dataBuffer = new StatDataOutput(filename, cache);
- const uint8_t *buffBegin = dataBuffer->dataBuffer.getBuffer();
+ const uint8_t *buffBegin = dataBuffer->dataBuffer->getBuffer();
if (buffBegin == nullptr) {
std::string s("undefined stat data buffer beginning");
throw NullPointerException(s.c_str());
}
- const uint8_t *buffEnd = dataBuffer->dataBuffer.getCursor();
+ const uint8_t *buffEnd = dataBuffer->dataBuffer->getCursor();
if (buffEnd == nullptr) {
std::string s("undefined stat data buffer end");
throw NullPointerException(s.c_str());
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/statistics/StatArchiveWriter.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/statistics/StatArchiveWriter.hpp b/src/cppcache/src/statistics/StatArchiveWriter.hpp
index 55f30cb..d908ca9 100644
--- a/src/cppcache/src/statistics/StatArchiveWriter.hpp
+++ b/src/cppcache/src/statistics/StatArchiveWriter.hpp
@@ -24,6 +24,7 @@
#include <list>
#include <geode/geode_globals.hpp>
#include <geode/ExceptionTypes.hpp>
+#include <geode/Cache.hpp>
#include "StatsDef.hpp"
#include <geode/statistics/Statistics.hpp>
#include <geode/statistics/StatisticDescriptor.hpp>
@@ -34,9 +35,9 @@
#include <geode/DataOutput.hpp>
#include <NonCopyable.hpp>
#include <chrono>
+#include "SerializationRegistry.hpp"
using namespace apache::geode::client;
-
/**
* some constants to be used while archiving
*/
@@ -78,8 +79,10 @@ using std::chrono::steady_clock;
class CPPCACHE_EXPORT StatDataOutput {
public:
- StatDataOutput() : bytesWritten(0), m_fp(nullptr), closed(false) {}
- StatDataOutput(std::string);
+ StatDataOutput(Cache *cache) : bytesWritten(0), m_fp(nullptr), closed(false) {
+ dataBuffer = cache->createDataOutput();
+ }
+ StatDataOutput(std::string, Cache *cache);
~StatDataOutput();
/**
* Returns the number of bytes written into the buffer so far.
@@ -126,14 +129,14 @@ class CPPCACHE_EXPORT StatDataOutput {
/**
* This method is for the unit tests only for this class.
*/
- const uint8_t *getBuffer() { return dataBuffer.getBuffer(); }
+ const uint8_t *getBuffer() { return dataBuffer->getBuffer(); }
void close();
void openFile(std::string, int64_t);
private:
int64_t bytesWritten;
- DataOutput dataBuffer;
+ std::unique_ptr<DataOutput> dataBuffer;
std::string outFile;
FILE *m_fp;
bool closed;
@@ -204,6 +207,7 @@ class CPPCACHE_EXPORT StatArchiveWriter {
private:
HostStatSampler *sampler;
StatDataOutput *dataBuffer;
+ Cache *cache;
steady_clock::time_point previousTimeStamp;
int32_t resourceTypeId;
int32_t resourceInstId;
@@ -225,7 +229,8 @@ class CPPCACHE_EXPORT StatArchiveWriter {
bool resourceInstMapHas(Statistics *sp);
public:
- StatArchiveWriter(std::string archiveName, HostStatSampler *sampler);
+ StatArchiveWriter(std::string archiveName, HostStatSampler *sampler,
+ Cache *cache);
~StatArchiveWriter();
/**
* Returns the number of bytes written so far to this archive.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/statistics/StatSamplerStats.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/statistics/StatSamplerStats.cpp b/src/cppcache/src/statistics/StatSamplerStats.cpp
index 10ea6b4..41240c3 100644
--- a/src/cppcache/src/statistics/StatSamplerStats.cpp
+++ b/src/cppcache/src/statistics/StatSamplerStats.cpp
@@ -16,14 +16,14 @@
*/
#include "StatSamplerStats.hpp"
+#include "statistics/StatisticsManager.hpp"
using namespace apache::geode::statistics;
/**
* Statistics related to the statistic sampler.
*/
-StatSamplerStats::StatSamplerStats() {
- StatisticsFactory* statFactory = StatisticsFactory::getExistingInstance();
+StatSamplerStats::StatSamplerStats(StatisticsFactory* statFactory) {
statDescriptorArr = new StatisticDescriptor*[2];
statDescriptorArr[0] = statFactory->createIntCounter(
"sampleCount", "Total number of samples taken by this sampler.",
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/statistics/StatSamplerStats.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/statistics/StatSamplerStats.hpp b/src/cppcache/src/statistics/StatSamplerStats.hpp
index 41c352f..aafc8ab 100644
--- a/src/cppcache/src/statistics/StatSamplerStats.hpp
+++ b/src/cppcache/src/statistics/StatSamplerStats.hpp
@@ -29,7 +29,7 @@
using namespace apache::geode::client;
/** @file
-*/
+ */
namespace apache {
namespace geode {
@@ -48,7 +48,7 @@ class CPPCACHE_EXPORT StatSamplerStats {
StatisticDescriptor** statDescriptorArr;
public:
- StatSamplerStats();
+ StatSamplerStats(StatisticsFactory* statFactory);
void tookSample(int64_t nanosSpentWorking);
void close();
void setInitialValues();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/statistics/StatisticDescriptorImpl.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/statistics/StatisticDescriptorImpl.hpp b/src/cppcache/src/statistics/StatisticDescriptorImpl.hpp
index 25b8154..9e8f0cb 100644
--- a/src/cppcache/src/statistics/StatisticDescriptorImpl.hpp
+++ b/src/cppcache/src/statistics/StatisticDescriptorImpl.hpp
@@ -25,7 +25,7 @@
#include <geode/statistics/StatisticDescriptor.hpp>
/** @file
-*/
+ */
namespace apache {
namespace geode {
@@ -127,7 +127,8 @@ class StatisticDescriptorImpl : public StatisticDescriptor {
* @throws IllegalArgumentException
* <code>code</code> is an unknown type
*/
- static int32_t getTypeCodeBits(FieldType code) throw(IllegalArgumentException);
+ static int32_t getTypeCodeBits(FieldType code) throw(
+ IllegalArgumentException);
///////////////////////////Create methods ////////////////////////////////////
@@ -138,7 +139,7 @@ class StatisticDescriptorImpl : public StatisticDescriptor {
*/
static StatisticDescriptor* createIntCounter(
const char* name, const char* description, const char* units,
- bool isLargerBetter) throw(OutOfMemoryException);
+ bool isLargerBetter) throw(apache::geode::client::OutOfMemoryException);
/**
* Creates a descriptor of Long type
* whose value behaves like a counter
@@ -147,7 +148,7 @@ class StatisticDescriptorImpl : public StatisticDescriptor {
static StatisticDescriptor* createLongCounter(
const char* name, const char* description, const char* units,
- bool isLargerBetter) throw(OutOfMemoryException);
+ bool isLargerBetter) throw(apache::geode::client::OutOfMemoryException);
/**
* Creates a descriptor of Double type
@@ -156,7 +157,7 @@ class StatisticDescriptorImpl : public StatisticDescriptor {
*/
static StatisticDescriptor* createDoubleCounter(
const char* name, const char* description, const char* units,
- bool isLargerBetter) throw(OutOfMemoryException);
+ bool isLargerBetter) throw(apache::geode::client::OutOfMemoryException);
/**
* Creates a descriptor of Integer type
@@ -165,7 +166,7 @@ class StatisticDescriptorImpl : public StatisticDescriptor {
*/
static StatisticDescriptor* createIntGauge(
const char* name, const char* description, const char* units,
- bool isLargerBetter) throw(OutOfMemoryException);
+ bool isLargerBetter) throw(apache::geode::client::OutOfMemoryException);
/**
* Creates a descriptor of Long type
@@ -174,7 +175,7 @@ class StatisticDescriptorImpl : public StatisticDescriptor {
*/
static StatisticDescriptor* createLongGauge(
const char* name, const char* description, const char* units,
- bool isLargerBetter) throw(OutOfMemoryException);
+ bool isLargerBetter) throw(apache::geode::client::OutOfMemoryException);
/**
* Creates a descriptor of Double type
@@ -183,7 +184,7 @@ class StatisticDescriptorImpl : public StatisticDescriptor {
*/
static StatisticDescriptor* createDoubleGauge(
const char* name, const char* description, const char* units,
- bool isLargerBetter) throw(OutOfMemoryException);
+ bool isLargerBetter) throw(apache::geode::client::OutOfMemoryException);
///////////////// StatisticDescriptor(Base class) Methods
///////////////////////
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/statistics/StatisticsFactory.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/statistics/StatisticsFactory.cpp b/src/cppcache/src/statistics/StatisticsFactory.cpp
deleted file mode 100644
index 0ca4502..0000000
--- a/src/cppcache/src/statistics/StatisticsFactory.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.
- */
-
-#include "GeodeStatisticsFactory.hpp"
-
-namespace apache {
-namespace geode {
-namespace statistics {
-
-StatisticsFactory* StatisticsFactory::getExistingInstance() {
- return GeodeStatisticsFactory::getExistingInstance();
-}
-} // namespace client
-} // namespace geode
-} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/statistics/StatisticsManager.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/statistics/StatisticsManager.cpp b/src/cppcache/src/statistics/StatisticsManager.cpp
index bc81a33..a4a4df0 100644
--- a/src/cppcache/src/statistics/StatisticsManager.cpp
+++ b/src/cppcache/src/statistics/StatisticsManager.cpp
@@ -36,21 +36,24 @@ using namespace apache::geode::statistics;
/**
* static member initialization
*/
-StatisticsManager* StatisticsManager::s_singleton = nullptr;
StatisticsManager::StatisticsManager(const char* filePath,
int64_t sampleInterval, bool enabled,
+ Cache* cache, const char* durableClientId,
+ const uint32_t durableTimeout,
int64_t statFileLimit,
int64_t statDiskSpaceLimit)
: m_sampler(nullptr), m_adminRegion(nullptr) {
m_sampleIntervalMs =
static_cast<int32_t>(sampleInterval) * 1000; /* convert to millis */
m_newlyAddedStatsList.reserve(16); // Allocate initial sizes
- GeodeStatisticsFactory::initInstance(this);
+ m_statisticsFactory =
+ std::unique_ptr<GeodeStatisticsFactory>(new GeodeStatisticsFactory(this));
try {
if (m_sampler == nullptr && enabled) {
- m_sampler = new HostStatSampler(filePath, m_sampleIntervalMs, this,
+ m_sampler = new HostStatSampler(filePath, m_sampleIntervalMs, this, cache,
+ durableClientId, durableTimeout,
statFileLimit, statDiskSpaceLimit);
m_sampler->start();
}
@@ -60,25 +63,6 @@ StatisticsManager::StatisticsManager(const char* filePath,
}
}
-StatisticsManager* StatisticsManager::initInstance(
- const char* filePath, int64_t sampleIntervalMs, bool enabled,
- int64_t statsFileLimit, int64_t statsDiskSpaceLimit) {
- if (!s_singleton) {
- s_singleton = new StatisticsManager(filePath, sampleIntervalMs, enabled,
- statsFileLimit, statsDiskSpaceLimit);
- }
-
- return s_singleton;
-}
-
-StatisticsManager* StatisticsManager::getExistingInstance() {
- if (s_singleton) {
- return s_singleton;
- }
-
- return nullptr;
-}
-
void StatisticsManager::forceSample() {
if (m_sampler) m_sampler->forceSample();
}
@@ -115,10 +99,6 @@ StatisticsManager::~StatisticsManager() {
}
m_statsList.erase(m_statsList.begin(), m_statsList.end());
}
-
- // Clean Factory: clean Type map etc.
- GeodeStatisticsFactory::clean();
-
} catch (const Exception& ex) {
Log::warningCatch("~StatisticsManager swallowing Geode exception", ex);
@@ -132,15 +112,6 @@ StatisticsManager::~StatisticsManager() {
}
}
-void StatisticsManager::clean() {
- if (s_singleton != nullptr) {
- delete s_singleton;
- s_singleton = nullptr;
- }
-}
-
-////////////////////// Mutex methods ///////////////////////////
-
ACE_Recursive_Thread_Mutex& StatisticsManager::getListMutex() {
return m_statsListLock;
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/statistics/StatisticsManager.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/statistics/StatisticsManager.hpp b/src/cppcache/src/statistics/StatisticsManager.hpp
index 0fa9ed2..0d48d0c 100644
--- a/src/cppcache/src/statistics/StatisticsManager.hpp
+++ b/src/cppcache/src/statistics/StatisticsManager.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_STATISTICS_STATISTICSMANAGER_H_
-#define GEODE_STATISTICS_STATISTICSMANAGER_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,72 +15,61 @@
* limitations under the License.
*/
-#include <geode/geode_globals.hpp>
+#pragma once
-#include <sys/types.h>
-#ifndef WIN32
-#include <unistd.h>
-#endif
+#ifndef GEODE_STATISTICS_STATISTICSMANAGER_H_
+#define GEODE_STATISTICS_STATISTICSMANAGER_H_
+
+#include <memory>
#include <vector>
-#include "HostStatSampler.hpp"
-#include <geode/ExceptionTypes.hpp>
-#include "StatisticsTypeImpl.hpp"
+
+#include <geode/geode_globals.hpp>
#include <geode/statistics/Statistics.hpp>
-#include <AdminRegion.hpp>
+#include <geode/ExceptionTypes.hpp>
-/** @file
- */
+#include "HostStatSampler.hpp"
+#include "StatisticsTypeImpl.hpp"
+#include "AdminRegion.hpp"
+#include "GeodeStatisticsFactory.hpp"
namespace apache {
namespace geode {
namespace statistics {
+class GeodeStatisticsFactory;
+
/**
* Head Application Manager for Statistics Module.
*
*/
class StatisticsManager {
private:
- //--------------------Properties-------------------------------------------------
-
// interval at which the sampler will take a sample of Stats
int32_t m_sampleIntervalMs;
- //----------------Sampler and Stat Lists-----------------------------------
-
- HostStatSampler* m_sampler; // Statistics sampler
+ // Statistics sampler
+ HostStatSampler* m_sampler;
- std::vector<Statistics*>
- m_statsList; // Vector containing all the Stats objects
+ // Vector containing all the Stats objects
+ std::vector<Statistics*> m_statsList;
// Vector containing stats pointers which are not yet sampled.
std::vector<Statistics*> m_newlyAddedStatsList;
- ACE_Recursive_Thread_Mutex m_statsListLock; // Mutex to lock the list of
- // Stats
+ // Mutex to lock the list of Stats
+ ACE_Recursive_Thread_Mutex m_statsListLock;
- //----------------Admin Region -----------------------------------
AdminRegionPtr m_adminRegion;
- //////////////////////////private member functions///////////////////////////
-
- static StatisticsManager* s_singleton;
-
- StatisticsManager(const char* filePath, int64_t sampleIntervalMs,
- bool enabled, int64_t statFileLimit = 0,
- int64_t statDiskSpaceLimit = 0);
+ std::unique_ptr<GeodeStatisticsFactory> m_statisticsFactory;
void closeSampler();
- //////////////////////////public member functions///////////////////////////
-
public:
- static StatisticsManager* initInstance(const char* filePath,
- int64_t sampleIntervalMs, bool enabled,
- int64_t statFileLimit = 0,
- int64_t statDiskSpaceLimit = 0);
-
- static StatisticsManager* getExistingInstance();
+ StatisticsManager(const char* filePath, int64_t sampleIntervalMs,
+ bool enabled, Cache* cache, const char* durableClientId,
+ const uint32_t durableTimeout, int64_t statFileLimit = 0,
+ int64_t statDiskSpaceLimit = 0);
void RegisterAdminRegion(AdminRegionPtr adminRegPtr) {
m_adminRegion = adminRegPtr;
@@ -101,18 +85,12 @@ class StatisticsManager {
void addStatisticsToList(Statistics* stat);
- static void clean();
-
- //--------------------Stat List
- // functions--------------------------------------
std::vector<Statistics*>& getStatsList();
std::vector<Statistics*>& getNewlyAddedStatsList();
ACE_Recursive_Thread_Mutex& getListMutex();
- //------------ Find Statistics ---------------------
-
/** Return the first instance that matches the type, or nullptr */
Statistics* findFirstStatisticsByType(StatisticsType* type);
@@ -126,6 +104,10 @@ class StatisticsManager {
static void deleteStatistics(Statistics*& stat);
+ GeodeStatisticsFactory* getStatisticsFactory() const {
+ return m_statisticsFactory.get();
+ }
+
}; // class
} // namespace statistics
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/statistics/WindowsProcessStats.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/statistics/WindowsProcessStats.cpp b/src/cppcache/src/statistics/WindowsProcessStats.cpp
index f9213ec..c9cc88e 100644
--- a/src/cppcache/src/statistics/WindowsProcessStats.cpp
+++ b/src/cppcache/src/statistics/WindowsProcessStats.cpp
@@ -19,20 +19,17 @@
#include <ace/Singleton.h>
#include "WindowsProcessStats.hpp"
#include "HostStatHelperWin.hpp"
-#include "GeodeStatisticsFactory.hpp"
#include "HostStatHelper.hpp"
using namespace apache::geode::statistics;
-WindowsProcessStats::WindowsProcessStats(int64_t pid, const char* name) {
- GeodeStatisticsFactory* statFactory =
- GeodeStatisticsFactory::getExistingInstance();
-
+WindowsProcessStats::WindowsProcessStats(
+ GeodeStatisticsFactory* statisticsFactory, int64_t pid, const char* name) {
// Create for Statistics Type
- createType(statFactory);
+ createType(statisticsFactory);
// Create Statistics
- this->stats = statFactory->createOsStatistics(m_statsType, name, pid);
+ this->stats = statisticsFactory->createOsStatistics(m_statsType, name, pid);
GF_D_ASSERT(this->stats != nullptr);
// Refresh Stats Values
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/statistics/WindowsProcessStats.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/statistics/WindowsProcessStats.hpp b/src/cppcache/src/statistics/WindowsProcessStats.hpp
index 8dae107..1f3ca48 100644
--- a/src/cppcache/src/statistics/WindowsProcessStats.hpp
+++ b/src/cppcache/src/statistics/WindowsProcessStats.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_STATISTICS_WINDOWSPROCESSSTATS_H_
-#define GEODE_STATISTICS_WINDOWSPROCESSSTATS_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -19,18 +14,26 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+#pragma once
+
+#ifndef GEODE_STATISTICS_WINDOWSPROCESSSTATS_H_
+#define GEODE_STATISTICS_WINDOWSPROCESSSTATS_H_
+
#include <geode/geode_globals.hpp>
#include <geode/statistics/Statistics.hpp>
#include <geode/statistics/StatisticsType.hpp>
#include <geode/statistics/StatisticDescriptor.hpp>
#include <geode/statistics/StatisticsFactory.hpp>
-#include "ProcessStats.hpp"
#include <geode/ExceptionTypes.hpp>
+#include "ProcessStats.hpp"
+#include "GeodeStatisticsFactory.hpp"
+
using namespace apache::geode::client;
/** @file
-*/
+ */
namespace apache {
namespace geode {
@@ -68,7 +71,8 @@ class CPPCACHE_EXPORT WindowsProcessStats : public ProcessStats {
void createType(StatisticsFactory* statFactory);
public:
- WindowsProcessStats(int64_t pid, const char* name);
+ WindowsProcessStats(GeodeStatisticsFactory* statisticsFactory, int64_t pid,
+ const char* name);
~WindowsProcessStats();
int64_t getProcessSize();
@@ -83,7 +87,7 @@ class CPPCACHE_EXPORT WindowsProcessStats : public ProcessStats {
friend class HostStatHelperWin;
};
-} // namespace client
+} // namespace statistics
} // namespace geode
} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/test/CacheXmlParserTest.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/test/CacheXmlParserTest.cpp b/src/cppcache/test/CacheXmlParserTest.cpp
index 6b5d9c8..b0d4404 100644
--- a/src/cppcache/test/CacheXmlParserTest.cpp
+++ b/src/cppcache/test/CacheXmlParserTest.cpp
@@ -105,13 +105,13 @@ std::string dtd_prefix = R"(<?xml version="1.0" encoding="UTF-8"?>
<client-cache>)";
TEST(CacheXmlParser, CanParseRegionConfigFromAValidXsdCacheConfig) {
- CacheXmlParser parser;
+ CacheXmlParser parser(nullptr);
std::string xml = xsd_prefix + valid_cache_config_body;
parser.parseMemory(xml.c_str(), static_cast<int>(xml.length()));
}
TEST(CacheXmlParser, CanParseRegionConfigFromAValidDtdCacheConfig) {
- CacheXmlParser parser;
+ CacheXmlParser parser(nullptr);
std::string xml = dtd_prefix + valid_cache_config_body;
parser.parseMemory(xml.c_str(), static_cast<int>(xml.length()));
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/test/ClientProxyMembershipIDFactoryTest.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/test/ClientProxyMembershipIDFactoryTest.cpp b/src/cppcache/test/ClientProxyMembershipIDFactoryTest.cpp
new file mode 100644
index 0000000..b9fec88
--- /dev/null
+++ b/src/cppcache/test/ClientProxyMembershipIDFactoryTest.cpp
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+#include <regex>
+
+#include <gtest/gtest.h>
+
+#include <ClientProxyMembershipIDFactory.hpp>
+
+using namespace apache::geode::client;
+
+TEST(ClientProxyMembershipIDFactoryTest, testCreate) {
+ ClientProxyMembershipIDFactory factory("myDs");
+
+ auto id = factory.create("myHost", 1, 2, "myClientID", 3);
+ ASSERT_NE(nullptr, id);
+
+ EXPECT_EQ("myDs", id->getDSName());
+ EXPECT_EQ(1, static_cast<uint32_t>(*id->getHostAddr()));
+ EXPECT_EQ(4, id->getHostAddrLen());
+ EXPECT_EQ(2, id->getHostPort());
+
+ auto uniqueTag = id->getUniqueTag();
+ ASSERT_NE("", uniqueTag);
+ EXPECT_EQ(std::string(":1:0:0:0:2:myDs:").append(uniqueTag),
+ id->getHashKey());
+ EXPECT_TRUE(std::regex_search(
+ id->getDSMemberIdForThinClientUse(),
+ std::regex(
+ std::string("myHost(.*):2:").append(uniqueTag).append(":myDs"))));
+}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/test/DataInputTest.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/test/DataInputTest.cpp b/src/cppcache/test/DataInputTest.cpp
index 90727fa..804e709 100644
--- a/src/cppcache/test/DataInputTest.cpp
+++ b/src/cppcache/test/DataInputTest.cpp
@@ -23,24 +23,42 @@
#include <gtest/gtest.h>
+#include <geode/CacheFactory.hpp>
#include <geode/DataInput.hpp>
-#include <geode/DataOutput.hpp>
#include <memory>
#include "ByteArrayFixture.hpp"
+#include "DataInputInternal.hpp"
+#include "DataOutputInternal.hpp"
+#include "SerializationRegistry.hpp"
+
+namespace {
using namespace apache::geode::client;
+class DataInputUnderTest : public DataInputInternal {
+ public:
+ using DataInputInternal::DataInputInternal;
+
+ virtual const SerializationRegistry &getSerializationRegistry()
+ const override {
+ return m_serializationRegistry;
+ }
+
+ private:
+ SerializationRegistry m_serializationRegistry;
+};
+
class TestDataInput {
public:
- explicit TestDataInput(const char *str)
+ explicit TestDataInput(const char *str, Cache *cache)
: m_byteArray(ByteArray::fromString(str)),
- m_dataInput(m_byteArray.get(), m_byteArray.size()) {
+ m_dataInput(m_byteArray.get(), m_byteArray.size(), cache) {
// NOP
}
- explicit TestDataInput(const wchar_t *str)
+ explicit TestDataInput(const wchar_t *str, Cache *cache)
: m_byteArray(ByteArray::fromString(str)),
- m_dataInput(m_byteArray.get(), m_byteArray.size()) {
+ m_dataInput(m_byteArray.get(), m_byteArray.size(), cache) {
// NOP
}
@@ -183,7 +201,7 @@ class TestDataInput {
private:
ByteArray m_byteArray;
- DataInput m_dataInput;
+ DataInputUnderTest m_dataInput;
};
class DataInputTest : public ::testing::Test, protected ByteArrayFixture {
@@ -194,7 +212,7 @@ class DataInputTest : public ::testing::Test, protected ByteArrayFixture {
};
TEST_F(DataInputTest, ThrowsWhenReadingInputWithSizeZero) {
- TestDataInput dataInput("");
+ TestDataInput dataInput("", nullptr);
uint8_t aByte = 0U;
ASSERT_THROW(dataInput.read(&aByte),
@@ -202,7 +220,7 @@ TEST_F(DataInputTest, ThrowsWhenReadingInputWithSizeZero) {
}
TEST_F(DataInputTest, ThrowsWhenReadingMoreBytesThanSizePassedToConstructor) {
- TestDataInput dataInput("01");
+ TestDataInput dataInput("01", nullptr);
uint8_t aByte = 0U;
dataInput.read(&aByte);
@@ -214,7 +232,7 @@ TEST_F(DataInputTest, ThrowsWhenReadingMoreBytesThanSizePassedToConstructor) {
}
TEST_F(DataInputTest, CanReadUnsignedBytesFromInput) {
- TestDataInput dataInput("FF00");
+ TestDataInput dataInput("FF00", nullptr);
uint8_t aByte = 0U;
dataInput.read(&aByte);
@@ -226,7 +244,7 @@ TEST_F(DataInputTest, CanReadUnsignedBytesFromInput) {
}
TEST_F(DataInputTest, CanReadSignedBytesFromInput) {
- TestDataInput dataInput("807F");
+ TestDataInput dataInput("807F", nullptr);
int8_t aByte = 0U;
dataInput.read(&aByte);
@@ -239,7 +257,7 @@ TEST_F(DataInputTest, CanReadSignedBytesFromInput) {
TEST_F(DataInputTest, CanReadABooleanFromInput) {
bool boolArray[2] = {true, false};
- DataInput dataInput(reinterpret_cast<uint8_t *>(boolArray), 2);
+ DataInputUnderTest dataInput(reinterpret_cast<uint8_t *>(boolArray), 2, nullptr);
bool aBool = false;
dataInput.readBoolean(&aBool);
@@ -251,7 +269,7 @@ TEST_F(DataInputTest, CanReadABooleanFromInput) {
}
TEST_F(DataInputTest, CanReadAnArrayOfBytesFromInput) {
- TestDataInput dataInput("010203");
+ TestDataInput dataInput("010203", nullptr);
uint8_t byteArrayCopy[4];
dataInput.readBytesOnly(byteArrayCopy, 3);
@@ -262,7 +280,7 @@ TEST_F(DataInputTest, CanReadAnArrayOfBytesFromInput) {
TEST_F(DataInputTest,
ThrowsWhenReadingMoreContinuousBytesThanSizePassedToConstructor) {
- TestDataInput dataInput("010203");
+ TestDataInput dataInput("010203", nullptr);
// fails to read 4 bytes from 3 byte buffer
uint8_t byteArrayCopy[4];
@@ -272,7 +290,8 @@ TEST_F(DataInputTest,
TEST_F(DataInputTest, CanReadIntWithAMaxSizeUnsigned64BitIntInput) {
uint64_t intArray[1] = {std::numeric_limits<uint64_t>::max()};
- DataInput dataInput(reinterpret_cast<uint8_t *>(intArray), sizeof(intArray));
+ DataInputUnderTest dataInput(reinterpret_cast<uint8_t *>(intArray), sizeof(intArray),
+ nullptr);
uint64_t aInt = 0UL;
dataInput.readInt(&aInt);
@@ -282,10 +301,12 @@ TEST_F(DataInputTest, CanReadIntWithAMaxSizeUnsigned64BitIntInput) {
TEST_F(DataInputTest, CanReadASCIIWithAnASCIIStringInput) {
char *actualString;
const char *expectedString = "foobar";
- DataOutput stream;
+ DataOutputInternal stream;
+
stream.writeASCII(expectedString);
- DataInput dataInput(stream.getBufferCopy(), stream.getBufferLength());
+ DataInputUnderTest dataInput(stream.getBufferCopy(), stream.getBufferLength(),
+ nullptr);
dataInput.readASCII(&actualString);
EXPECT_TRUE(std::string(expectedString) == std::string(actualString));
@@ -294,10 +315,11 @@ TEST_F(DataInputTest, CanReadASCIIWithAnASCIIStringInput) {
TEST_F(DataInputTest, ThrowsWhenCallingReadStringWithAnASCIIStringInput) {
char *actualString;
const char *expectedString = "foobar";
- DataOutput stream;
+ DataOutputInternal stream;
stream.writeASCII(expectedString);
- DataInput dataInput(stream.getBufferCopy(), stream.getBufferLength());
+ DataInputUnderTest dataInput(stream.getBufferCopy(), stream.getBufferLength(),
+ nullptr);
// ASCII and non-ASCII: consider matching exception string
ASSERT_THROW(dataInput.readString(&actualString),
@@ -307,10 +329,11 @@ TEST_F(DataInputTest, ThrowsWhenCallingReadStringWithAnASCIIStringInput) {
TEST_F(DataInputTest, CanReadASCIIWithAnUTFStringInput) {
char *actualString;
const char *expectedString = "foobar";
- DataOutput stream;
+ DataOutputInternal stream;
stream.writeUTF(expectedString);
- DataInput dataInput(stream.getBufferCopy(), stream.getBufferLength());
+ DataInputUnderTest dataInput(stream.getBufferCopy(), stream.getBufferLength(),
+ nullptr);
dataInput.readASCII(&actualString);
EXPECT_TRUE(std::string(expectedString) == std::string(actualString));
@@ -319,10 +342,11 @@ TEST_F(DataInputTest, CanReadASCIIWithAnUTFStringInput) {
TEST_F(DataInputTest, ThrowsWhenCallingReadStringWithAnUTFStringInput) {
char *actualString;
const char *expectedString = "foobar";
- DataOutput stream;
+ DataOutputInternal stream;
stream.writeUTF(expectedString);
- DataInput dataInput(stream.getBufferCopy(), stream.getBufferLength());
+ DataInputUnderTest dataInput(stream.getBufferCopy(), stream.getBufferLength(),
+ nullptr);
// UTF and non-UTF: consider matching exception string
ASSERT_THROW(dataInput.readString(&actualString),
@@ -332,10 +356,11 @@ TEST_F(DataInputTest, ThrowsWhenCallingReadStringWithAnUTFStringInput) {
TEST_F(DataInputTest, CanReadUTFWithAnUTFStringInput) {
char *actualString;
const char *expectedString = "foobar";
- DataOutput stream;
+ DataOutputInternal stream;
stream.writeUTF(expectedString);
- DataInput dataInput(stream.getBufferCopy(), stream.getBufferLength());
+ DataInputUnderTest dataInput(stream.getBufferCopy(), stream.getBufferLength(),
+ nullptr);
dataInput.readUTF(&actualString);
EXPECT_TRUE(std::string(expectedString) == std::string(actualString));
@@ -344,17 +369,18 @@ TEST_F(DataInputTest, CanReadUTFWithAnUTFStringInput) {
TEST_F(DataInputTest, CanReadUTFWithAnASCIIStringInput) {
char *actualString;
const char *expectedString = "foobar";
- DataOutput stream;
+ DataOutputInternal stream;
stream.writeASCII(expectedString);
- DataInput dataInput(stream.getBufferCopy(), stream.getBufferLength());
+ DataInputUnderTest dataInput(stream.getBufferCopy(), stream.getBufferLength(),
+ nullptr);
dataInput.readUTF(&actualString);
EXPECT_TRUE(std::string(expectedString) == std::string(actualString));
}
TEST_F(DataInputTest, InputResetCausesPristineRead) {
- TestDataInput dataInput("010203");
+ TestDataInput dataInput("010203", nullptr);
// 1) read byte off buffer
// 2) then reset buffer back
@@ -369,7 +395,7 @@ TEST_F(DataInputTest, InputResetCausesPristineRead) {
}
TEST_F(DataInputTest, InputRewindCausesReplayedRead) {
- TestDataInput dataInput("010203");
+ TestDataInput dataInput("010203", nullptr);
uint8_t aByte = 0U;
dataInput.read(&aByte);
@@ -383,28 +409,28 @@ TEST_F(DataInputTest, InputRewindCausesReplayedRead) {
}
TEST_F(DataInputTest, TestReadUint8) {
- TestDataInput dataInput("37");
+ TestDataInput dataInput("37", nullptr);
uint8_t value = 0U;
dataInput.read(&value);
EXPECT_EQ((uint8_t)55U, value) << "Correct uint8_t";
}
TEST_F(DataInputTest, TestReadInt8) {
- TestDataInput dataInput("37");
+ TestDataInput dataInput("37", nullptr);
int8_t value = 0;
dataInput.read(&value);
EXPECT_EQ((int8_t)55, value) << "Correct int8_t";
}
TEST_F(DataInputTest, TestReadBoolean) {
- TestDataInput dataInput("01");
+ TestDataInput dataInput("01", nullptr);
bool value = false;
dataInput.readBoolean(&value);
EXPECT_EQ(true, value) << "Correct bool";
}
TEST_F(DataInputTest, TestReadUint8_tBytesOnly) {
- TestDataInput dataInput("BABEFACE");
+ TestDataInput dataInput("BABEFACE", nullptr);
uint8_t buffer[4];
::memset(buffer, 0U, 4 * sizeof(uint8_t));
dataInput.readBytesOnly(buffer, 4);
@@ -415,7 +441,7 @@ TEST_F(DataInputTest, TestReadUint8_tBytesOnly) {
}
TEST_F(DataInputTest, TestReadInt8_tBytesOnly) {
- TestDataInput dataInput("DEADBEEF");
+ TestDataInput dataInput("DEADBEEF", nullptr);
int8_t buffer[4];
::memset(buffer, 0, 4 * sizeof(int8_t));
dataInput.readBytesOnly(buffer, 4);
@@ -426,7 +452,7 @@ TEST_F(DataInputTest, TestReadInt8_tBytesOnly) {
}
TEST_F(DataInputTest, TestReadUint8_tBytes) {
- TestDataInput dataInput("04BABEFACE");
+ TestDataInput dataInput("04BABEFACE", nullptr);
uint8_t *buffer = nullptr;
int32_t len = 0;
dataInput.readBytes(&buffer, &len);
@@ -440,7 +466,7 @@ TEST_F(DataInputTest, TestReadUint8_tBytes) {
}
TEST_F(DataInputTest, TestReadInt8_tBytes) {
- TestDataInput dataInput("04DEADBEEF");
+ TestDataInput dataInput("04DEADBEEF", nullptr);
int8_t *buffer = nullptr;
int32_t len = 0;
dataInput.readBytes(&buffer, &len);
@@ -454,42 +480,42 @@ TEST_F(DataInputTest, TestReadInt8_tBytes) {
}
TEST_F(DataInputTest, TestReadIntUint16) {
- TestDataInput dataInput("123456789ABCDEF0");
+ TestDataInput dataInput("123456789ABCDEF0", nullptr);
uint16_t value = 0U;
dataInput.readInt(&value);
EXPECT_EQ((uint16_t)4660U, value) << "Correct uint16_t";
}
TEST_F(DataInputTest, TestReadIntInt16) {
- TestDataInput dataInput("123456789ABCDEF0");
+ TestDataInput dataInput("123456789ABCDEF0", nullptr);
int16_t value = 0;
dataInput.readInt(&value);
EXPECT_EQ((int16_t)4660, value) << "Correct int16_t";
}
TEST_F(DataInputTest, TestReadIntUint32) {
- TestDataInput dataInput("123456789ABCDEF0");
+ TestDataInput dataInput("123456789ABCDEF0", nullptr);
uint32_t value = 0U;
dataInput.readInt(&value);
EXPECT_EQ((uint32_t)305419896U, value) << "Correct uint32_t";
}
TEST_F(DataInputTest, TestReadIntInt32) {
- TestDataInput dataInput("123456789ABCDEF0");
+ TestDataInput dataInput("123456789ABCDEF0", nullptr);
int32_t value = 0;
dataInput.readInt(&value);
EXPECT_EQ((int32_t)305419896, value) << "Correct int32_t";
}
TEST_F(DataInputTest, TestReadIntUint64) {
- TestDataInput dataInput("123456789ABCDEF0");
+ TestDataInput dataInput("123456789ABCDEF0", nullptr);
uint64_t value = 0U;
dataInput.readInt(&value);
EXPECT_EQ((uint64_t)1311768467463790320U, value) << "Correct uint64_t";
}
TEST_F(DataInputTest, TestReadIntInt64) {
- TestDataInput dataInput("123456789ABCDEF0");
+ TestDataInput dataInput("123456789ABCDEF0", nullptr);
int64_t value = 0;
dataInput.readInt(&value);
EXPECT_EQ((int64_t)1311768467463790320, value) << "Correct int64_t";
@@ -498,19 +524,19 @@ TEST_F(DataInputTest, TestReadIntInt64) {
TEST_F(DataInputTest, TestReadArrayLen) {
int32_t len = 0;
- TestDataInput dataInput0("FF12345678");
+ TestDataInput dataInput0("FF12345678", nullptr);
dataInput0.readArrayLen(&len);
EXPECT_EQ(-1, len) << "Correct length for 0xFF";
- TestDataInput dataInput1("FE12345678");
+ TestDataInput dataInput1("FE12345678", nullptr);
dataInput1.readArrayLen(&len);
EXPECT_EQ(4660, len) << "Correct length for 0xFE";
- TestDataInput dataInput2("FD12345678");
+ TestDataInput dataInput2("FD12345678", nullptr);
dataInput2.readArrayLen(&len);
EXPECT_EQ(305419896, len) << "Correct length for 0xFD";
- TestDataInput dataInput3("FC12345678");
+ TestDataInput dataInput3("FC12345678", nullptr);
dataInput3.readArrayLen(&len);
EXPECT_EQ(252, len) << "Correct length for 0xFC";
}
@@ -528,21 +554,22 @@ TEST_F(DataInputTest, TestReadUnsignedVL) {
// 1110000
// 00 12 1A 15 4F 09 55 73 3D 70
// 00 92 9A 95 CF 89 D5 F3 BD F0
- TestDataInput dataInput("F0BDF3D589CF959A9200");
+
+ TestDataInput dataInput("F0BDF3D589CF959A9200", nullptr);
int64_t value = 0;
dataInput.readUnsignedVL(&value);
EXPECT_EQ((int64_t)1311768467463790320, value) << "Correct int64_t";
}
TEST_F(DataInputTest, TestReadFloat) {
- TestDataInput dataInput("123456789ABCDEF0");
+ TestDataInput dataInput("123456789ABCDEF0", nullptr);
float value = 0.F;
dataInput.readFloat(&value);
EXPECT_FLOAT_EQ(5.6904566e-28F, value) << "Correct float";
}
TEST_F(DataInputTest, TestReadDouble) {
- TestDataInput dataInput("123456789ABCDEF0");
+ TestDataInput dataInput("123456789ABCDEF0", nullptr);
double value = 0.;
dataInput.readDouble(&value);
EXPECT_DOUBLE_EQ(5.626349274901198e-221, value) << "Correct double";
@@ -550,7 +577,7 @@ TEST_F(DataInputTest, TestReadDouble) {
TEST_F(DataInputTest, TestReadASCII) {
TestDataInput dataInput(
- "001B596F7520686164206D65206174206D65617420746F726E61646F2E");
+ "001B596F7520686164206D65206174206D65617420746F726E61646F2E", nullptr);
char *value = nullptr;
uint16_t len = 0U;
dataInput.readASCII(&value, &len);
@@ -561,7 +588,8 @@ TEST_F(DataInputTest, TestReadASCII) {
TEST_F(DataInputTest, TestReadASCIIHuge) {
TestDataInput dataInput(
- "0000001B596F7520686164206D65206174206D65617420746F726E61646F2E");
+ "0000001B596F7520686164206D65206174206D65617420746F726E61646F2E",
+ nullptr);
char *value = nullptr;
uint32_t len = 0U;
dataInput.readASCIIHuge(&value, &len);
@@ -572,7 +600,7 @@ TEST_F(DataInputTest, TestReadASCIIHuge) {
TEST_F(DataInputTest, TestReadUTFNarrow) {
TestDataInput dataInput(
- "001B596F7520686164206D65206174206D65617420746F726E61646F2E");
+ "001B596F7520686164206D65206174206D65617420746F726E61646F2E", nullptr);
char *value = nullptr;
uint16_t len = 0U;
dataInput.readUTF(&value, &len);
@@ -584,7 +612,8 @@ TEST_F(DataInputTest, TestReadUTFNarrow) {
TEST_F(DataInputTest, TestReadUTFHugeNarrow) {
TestDataInput dataInput(
"0000001B0059006F007500200068006100640020006D00650020006100740020006D0065"
- "0061007400200074006F0072006E00610064006F002E");
+ "0061007400200074006F0072006E00610064006F002E",
+ nullptr);
char *value = nullptr;
uint32_t len = 0U;
dataInput.readUTFHuge(&value, &len);
@@ -595,7 +624,7 @@ TEST_F(DataInputTest, TestReadUTFHugeNarrow) {
TEST_F(DataInputTest, TestReadUTFNoLen) {
TestDataInput dataInput(
- "596F7520686164206D65206174206D65617420746F726E61646F2E");
+ "596F7520686164206D65206174206D65617420746F726E61646F2E", nullptr);
wchar_t *value = nullptr;
dataInput.readUTFNoLen(&value, static_cast<uint16_t>(27U));
EXPECT_STREQ(L"You had me at meat tornado.", value) << "Correct wchar_t *";
@@ -604,7 +633,7 @@ TEST_F(DataInputTest, TestReadUTFNoLen) {
TEST_F(DataInputTest, TestReadUTFWide) {
TestDataInput dataInput(
- "001B596F7520686164206D65206174206D65617420746F726E61646F2E");
+ "001B596F7520686164206D65206174206D65617420746F726E61646F2E", nullptr);
wchar_t *value = nullptr;
uint16_t len = 0U;
dataInput.readUTF(&value, &len);
@@ -616,7 +645,8 @@ TEST_F(DataInputTest, TestReadUTFWide) {
TEST_F(DataInputTest, TestReadUTFHugeWide) {
TestDataInput dataInput(
"0000001B0059006F007500200068006100640020006D00650020006100740020006D0065"
- "0061007400200074006F0072006E00610064006F002E");
+ "0061007400200074006F0072006E00610064006F002E",
+ nullptr);
wchar_t *value = nullptr;
uint32_t len = 0U;
dataInput.readUTFHuge(&value, &len);
@@ -627,7 +657,7 @@ TEST_F(DataInputTest, TestReadUTFHugeWide) {
TEST_F(DataInputTest, TestReadObjectSharedPtr) {
TestDataInput dataInput(
- "57001B596F7520686164206D65206174206D65617420746F726E61646F2E");
+ "57001B596F7520686164206D65206174206D65617420746F726E61646F2E", nullptr);
CacheableStringPtr objptr;
dataInput.readObject(objptr);
EXPECT_STREQ((const char *)"You had me at meat tornado.",
@@ -636,20 +666,20 @@ TEST_F(DataInputTest, TestReadObjectSharedPtr) {
}
TEST_F(DataInputTest, TestReadNativeBool) {
- TestDataInput dataInput("0001");
+ TestDataInput dataInput("0001", nullptr);
const bool value = dataInput.readNativeBool();
EXPECT_EQ(true, value) << "Correct bool";
}
TEST_F(DataInputTest, TestReadNativeInt32) {
- TestDataInput dataInput("0012345678");
+ TestDataInput dataInput("0012345678", nullptr);
const int32_t value = dataInput.readNativeInt32();
EXPECT_EQ((int32_t)305419896, value) << "Correct int32_t";
}
TEST_F(DataInputTest, TestReadNativeString) {
TestDataInput dataInput(
- "57001B596F7520686164206D65206174206D65617420746F726E61646F2E");
+ "57001B596F7520686164206D65206174206D65617420746F726E61646F2E", nullptr);
CacheableStringPtr objptr;
ASSERT_EQ(true, dataInput.readNativeString(objptr)) << "Successful read";
EXPECT_STREQ((const char *)"You had me at meat tornado.",
@@ -659,7 +689,7 @@ TEST_F(DataInputTest, TestReadNativeString) {
TEST_F(DataInputTest, TestReadDirectObject) {
TestDataInput dataInput(
- "57001B596F7520686164206D65206174206D65617420746F726E61646F2E");
+ "57001B596F7520686164206D65206174206D65617420746F726E61646F2E", nullptr);
SerializablePtr objptr;
dataInput.readDirectObject(objptr);
EXPECT_STREQ(
@@ -671,7 +701,7 @@ TEST_F(DataInputTest, TestReadDirectObject) {
TEST_F(DataInputTest, TestReadObjectSerializablePtr) {
TestDataInput dataInput(
- "57001B596F7520686164206D65206174206D65617420746F726E61646F2E");
+ "57001B596F7520686164206D65206174206D65617420746F726E61646F2E", nullptr);
SerializablePtr objptr;
dataInput.readObject(objptr);
EXPECT_STREQ(
@@ -684,7 +714,8 @@ TEST_F(DataInputTest, TestReadObjectSerializablePtr) {
TEST_F(DataInputTest, TestReadCharArray) {
TestDataInput dataInput(
"1C0059006F007500200068006100640020006D00650020006100740020006D0065006100"
- "7400200074006F0072006E00610064006F002E0000");
+ "7400200074006F0072006E00610064006F002E0000",
+ nullptr);
char *value = nullptr;
int32_t length = 0;
dataInput.readCharArray(&value, length);
@@ -695,7 +726,7 @@ TEST_F(DataInputTest, TestReadCharArray) {
TEST_F(DataInputTest, TestReadString) {
TestDataInput dataInput(
- "57001B596F7520686164206D65206174206D65617420746F726E61646F2E");
+ "57001B596F7520686164206D65206174206D65617420746F726E61646F2E", nullptr);
char *value = nullptr;
dataInput.readString(&value);
EXPECT_STREQ("You had me at meat tornado.", value) << "Correct char *";
@@ -704,7 +735,7 @@ TEST_F(DataInputTest, TestReadString) {
TEST_F(DataInputTest, TestReadWideString) {
TestDataInput dataInput(
- "57001B596F7520686164206D65206174206D65617420746F726E61646F2E");
+ "57001B596F7520686164206D65206174206D65617420746F726E61646F2E", nullptr);
wchar_t *value = nullptr;
dataInput.readWideString(&value);
EXPECT_STREQ(L"You had me at meat tornado.", value) << "Correct wchar_t *";
@@ -713,7 +744,8 @@ TEST_F(DataInputTest, TestReadWideString) {
TEST_F(DataInputTest, TestReadStringArray) {
TestDataInput dataInput(
- "0157001B596F7520686164206D65206174206D65617420746F726E61646F2E");
+ "0157001B596F7520686164206D65206174206D65617420746F726E61646F2E",
+ nullptr);
char **value = nullptr;
int32_t length = 0;
dataInput.readStringArray(&value, length);
@@ -725,7 +757,8 @@ TEST_F(DataInputTest, TestReadStringArray) {
TEST_F(DataInputTest, TestReadWideStringArray) {
TestDataInput dataInput(
- "0157001B596F7520686164206D65206174206D65617420746F726E61646F2E");
+ "0157001B596F7520686164206D65206174206D65617420746F726E61646F2E",
+ nullptr);
wchar_t **value = nullptr;
int32_t length = 0;
dataInput.readWideStringArray(&value, length);
@@ -736,7 +769,7 @@ TEST_F(DataInputTest, TestReadWideStringArray) {
}
TEST_F(DataInputTest, TestReadArrayOfByteArrays) {
- TestDataInput dataInput("0104DEADBEEF");
+ TestDataInput dataInput("0104DEADBEEF", nullptr);
int8_t **arrayOfByteArrays = nullptr;
int32_t arrayLength = 0;
int32_t *elementLength = nullptr;
@@ -757,7 +790,7 @@ TEST_F(DataInputTest, TestReadArrayOfByteArrays) {
}
TEST_F(DataInputTest, TestGetBytesRead) {
- TestDataInput dataInput("123456789ABCDEF0");
+ TestDataInput dataInput("123456789ABCDEF0", nullptr);
EXPECT_EQ((int32_t)0, dataInput.getBytesRead())
<< "Correct bytes read before any reads";
uint8_t value = 0U;
@@ -776,7 +809,7 @@ TEST_F(DataInputTest, TestGetBytesRead) {
}
TEST_F(DataInputTest, TestGetBytesRemaining) {
- TestDataInput dataInput("123456789ABCDEF0");
+ TestDataInput dataInput("123456789ABCDEF0", nullptr);
EXPECT_EQ((int32_t)8, dataInput.getBytesRemaining())
<< "Correct bytes remaining before any reads";
uint8_t value = 0U;
@@ -795,7 +828,7 @@ TEST_F(DataInputTest, TestGetBytesRemaining) {
}
TEST_F(DataInputTest, TestAdvanceCursor) {
- TestDataInput dataInput("123456789ABCDEF0");
+ TestDataInput dataInput("123456789ABCDEF0", nullptr);
EXPECT_EQ((int32_t)0, dataInput.getBytesRead())
<< "Correct bytes read before any advancement";
EXPECT_EQ((int32_t)8, dataInput.getBytesRemaining())
@@ -813,7 +846,7 @@ TEST_F(DataInputTest, TestAdvanceCursor) {
}
TEST_F(DataInputTest, TestRewindCursor) {
- TestDataInput dataInput("123456789ABCDEF0");
+ TestDataInput dataInput("123456789ABCDEF0", nullptr);
EXPECT_EQ((int32_t)0, dataInput.getBytesRead())
<< "Correct bytes read before any rewinding";
EXPECT_EQ((int32_t)8, dataInput.getBytesRemaining())
@@ -831,7 +864,7 @@ TEST_F(DataInputTest, TestRewindCursor) {
}
TEST_F(DataInputTest, TestReset) {
- TestDataInput dataInput("123456789ABCDEF0");
+ TestDataInput dataInput("123456789ABCDEF0", nullptr);
EXPECT_EQ((int32_t)0, dataInput.getBytesRead())
<< "Correct bytes read before any reads";
EXPECT_EQ((int32_t)8, dataInput.getBytesRemaining())
@@ -853,7 +886,7 @@ TEST_F(DataInputTest, TestReset) {
}
TEST_F(DataInputTest, TestSetBuffer) {
- TestDataInput dataInput("123456789ABCDEF0");
+ TestDataInput dataInput("123456789ABCDEF0", nullptr);
EXPECT_EQ((int32_t)0, dataInput.getBytesRead())
<< "Correct bytes read before any reads";
EXPECT_EQ((int32_t)8, dataInput.getBytesRemaining())
@@ -876,7 +909,8 @@ TEST_F(DataInputTest, TestSetBuffer) {
TEST_F(DataInputTest, TestSetPoolName) {
static const char *poolName = "Das Schwimmbad";
- TestDataInput dataInput("123456789ABCDEF0");
+
+ TestDataInput dataInput("123456789ABCDEF0", nullptr);
EXPECT_EQ((const char *)nullptr, dataInput.getPoolName())
<< "Null pool name before setting";
dataInput.setPoolName(poolName);
@@ -885,3 +919,5 @@ TEST_F(DataInputTest, TestSetPoolName) {
EXPECT_STREQ(poolName, dataInput.getPoolName())
<< "Correct pool name after setting";
}
+
+} // namespace
[25/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/ThinClientStatisticTestsN.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/ThinClientStatisticTestsN.cs b/src/clicache/integration-test/ThinClientStatisticTestsN.cs
index 730ea6c..69bc5e9 100644
--- a/src/clicache/integration-test/ThinClientStatisticTestsN.cs
+++ b/src/clicache/integration-test/ThinClientStatisticTestsN.cs
@@ -247,33 +247,7 @@ namespace Apache.Geode.Client.UnitTests
void statisticsTest()
{
- /* Create Statistics in right and wrong manner */
- StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
-
- /* Register a type */
- TestStatisticsType testType = new TestStatisticsType();
- createType(factory, testType);
- Util.Log("Statistics Type TestStats Registered");
-
- /* Create a statistics */
- Statistics testStat1 = factory.CreateStatistics(testType.testStatsType,"TestStatistics");
- Assert.IsNotNull(testStat1, "Test Statistics Creation Failed");
-
- /* Tests Find Type , Find Statistics */
- Statistics temp = factory.FindFirstStatisticsByType(testType.testStatsType);
- Assert.IsNotNull(temp , "findFirstStatisticsByType Failed");
- Util.Log("Statistics testStat1 Created Successfully.");
-
- /* Test Set Functions */
- testGetSetIncFunctions( testStat1, testType );
- Util.Log("Get / Set / Inc Functions Tested ");
-
- /* Close Statistics */
- testStat1.Close();
- Statistics temp2 = factory.FindFirstStatisticsByType(testType.testStatsType);
- Assert.IsNull(temp2, "Statistics close() Failed");
-
- Util.Log("StatisticsTest Completed");
+
}
#endregion
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/ThinClientStringArrayTestsN.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/ThinClientStringArrayTestsN.cs b/src/clicache/integration-test/ThinClientStringArrayTestsN.cs
index 1050b6b..6294bb0 100644
--- a/src/clicache/integration-test/ThinClientStringArrayTestsN.cs
+++ b/src/clicache/integration-test/ThinClientStringArrayTestsN.cs
@@ -72,8 +72,8 @@ namespace Apache.Geode.Client.UnitTests
CacheHelper.Init();
try
{
- Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable);
- Serializable.RegisterTypeGeneric(Position.CreateDeserializable);
+ Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable, CacheHelper.DCache);
+ Serializable.RegisterTypeGeneric(Position.CreateDeserializable, CacheHelper.DCache);
}
catch (IllegalStateException)
{
@@ -104,7 +104,7 @@ namespace Apache.Geode.Client.UnitTests
IRegion<object, object> region2 = CacheHelper.GetRegion<object, object>(QueryRegionNames[2]);
IRegion<object, object> region3 = CacheHelper.GetRegion<object, object>(QueryRegionNames[3]);
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
Util.Log("SetSize {0}, NumSets {1}.", qh.PortfolioSetSize,
qh.PortfolioNumSets);
@@ -127,7 +127,7 @@ namespace Apache.Geode.Client.UnitTests
IRegion<object, object> region0 = CacheHelper.GetRegion<object, object>(QueryRegionNames[0]);
IRegion<object, object> subRegion0 = region0.GetSubRegion(QueryRegionNames[1]);
- QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+ QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
string[] /*sta*/ cnm = { "C#aaa", "C#bbb", "C#ccc", "C#ddd" };
//CacheableStringArray cnm = CacheableStringArray.Create(sta);
qh.PopulatePortfolioData(region0, 4, 2, 2, cnm);
@@ -152,7 +152,7 @@ namespace Apache.Geode.Client.UnitTests
region["4"] = p4;
QueryService<object, object> qs = null;
- qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+ qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
Query<object> qry = qs.NewQuery("select * from /" + QERegionName + " p where p.ID!=3");
ISelectResults<object> results = qry.Execute();
Util.Log("Results size {0}.", results.Size);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/Cache.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/Cache.cpp b/src/clicache/src/Cache.cpp
index e900f76..7438e84 100644
--- a/src/clicache/src/Cache.cpp
+++ b/src/clicache/src/Cache.cpp
@@ -15,15 +15,18 @@
* limitations under the License.
*/
-//#include "geode_includes.hpp"
+#include "begin_native.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
+#include "end_native.hpp"
+
#include "Cache.hpp"
#include "ExceptionTypes.hpp"
#include "DistributedSystem.hpp"
+#include "PoolFactory.hpp"
#include "Region.hpp"
#include "RegionAttributes.hpp"
#include "QueryService.hpp"
-//#include "FunctionService.hpp"
-//#include "Execution.hpp"
#include "CacheFactory.hpp"
#include "impl/AuthenticatedCache.hpp"
#include "impl/ManagedString.hpp"
@@ -47,7 +50,7 @@ namespace Apache
{
try
{
- return ManagedString::Get( m_nativeptr->get()->getName( ) );
+ return ManagedString::Get( m_nativeptr->get()->getName( ).c_str() );
}
finally
{
@@ -71,7 +74,7 @@ namespace Apache
{
try
{
- return Client::DistributedSystem::Create(m_nativeptr->get()->getDistributedSystem());
+ return Client::DistributedSystem::Create(&(m_nativeptr->get()->getDistributedSystem()));
}
finally
{
@@ -120,13 +123,13 @@ namespace Apache
// If DS automatically disconnected due to the new bootstrap API, then cleanup the C++/CLI side
//if (!apache::geode::client::DistributedSystem::isConnected())
{
- Apache::Geode::Client::DistributedSystem::UnregisterBuiltinManagedTypes();
+ Apache::Geode::Client::DistributedSystem::UnregisterBuiltinManagedTypes(this);
}
_GF_MG_EXCEPTION_CATCH_ALL2
finally
{
- Apache::Geode::Client::Internal::PdxTypeRegistry::clear();
+ CacheRegionHelper::getCacheImpl(m_nativeptr->get())->getPdxTypeRegistry()->clear();
Serializable::Clear();
Apache::Geode::Client::DistributedSystem::releaseDisconnectLock();
Apache::Geode::Client::DistributedSystem::unregisterCliCallback();
@@ -343,8 +346,36 @@ namespace Apache
IPdxInstanceFactory^ Cache::CreatePdxInstanceFactory(String^ className)
{
- return gcnew Internal::PdxInstanceFactoryImpl(className);
+
+ return gcnew Internal::PdxInstanceFactoryImpl(className, (m_nativeptr->get()));
+
+ }
+
+ DataInput^ Cache::CreateDataInput(array<Byte>^ buffer, System::Int32 len)
+ {
+ return gcnew DataInput(buffer, len, m_nativeptr->get());
}
+
+
+ DataInput^ Cache::CreateDataInput(array<Byte>^ buffer)
+ {
+ return gcnew DataInput(buffer, m_nativeptr->get());
+ }
+
+ DataOutput^ Cache::CreateDataOutput()
+ {
+ return gcnew DataOutput( m_nativeptr->get());
+ }
+
+ PoolFactory^ Cache::GetPoolFactory()
+ {
+ return PoolFactory::Create(m_nativeptr->get_shared_ptr()->getPoolManager().createFactory());
+ }
+
+ PoolManager^ Cache::GetPoolManager()
+ {
+ return gcnew PoolManager(m_nativeptr->get_shared_ptr()->getPoolManager());
+ }
} // namespace Client
} // namespace Geode
} // namespace Apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/Cache.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/Cache.hpp b/src/clicache/src/Cache.hpp
index 889faaf..666e562 100644
--- a/src/clicache/src/Cache.hpp
+++ b/src/clicache/src/Cache.hpp
@@ -22,6 +22,7 @@
#include "IGeodeCache.hpp"
#include "IRegion.hpp"
#include "RegionAttributes.hpp"
+#include "PoolManager.hpp"
using namespace System;
@@ -252,6 +253,15 @@ namespace Apache
/// </summary>
virtual IPdxInstanceFactory^ CreatePdxInstanceFactory(String^ className);
+ virtual DataInput^ CreateDataInput(array<Byte>^ buffer, System::Int32 len);
+ virtual DataInput^ CreateDataInput(array<Byte>^ buffer);
+
+ virtual DataOutput^ Cache::CreateDataOutput();
+
+ virtual PoolFactory^ GetPoolFactory();
+
+ virtual PoolManager^ GetPoolManager();
+
internal:
/// <summary>
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/CacheFactory.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheFactory.cpp b/src/clicache/src/CacheFactory.cpp
index 6bdda46..2071b20 100644
--- a/src/clicache/src/CacheFactory.cpp
+++ b/src/clicache/src/CacheFactory.cpp
@@ -64,20 +64,25 @@ namespace Apache
bool pdxIgnoreUnreadFields = false;
bool pdxReadSerialized = false;
bool appDomainEnable = false;
+ native::CachePtr nativeCache = nullptr;
_GF_MG_EXCEPTION_TRY2
//msclr::lock lockInstance(m_singletonSync);
DistributedSystem::acquireDisconnectLock();
+ nativeCache = m_nativeptr->get()->create( );
+
+ auto cache = Cache::Create( nativeCache );
+ // TODO global create SerializerRegistry
if(!m_connected)
{
- DistributedSystem::AppDomainInstanceInitialization(m_dsProps->GetNative());
+ DistributedSystem::AppDomainInstanceInitialization(cache);
}
- auto nativeCache = m_nativeptr->get()->create( );
+
pdxIgnoreUnreadFields = nativeCache->getPdxIgnoreUnreadFields();
pdxReadSerialized = nativeCache->getPdxReadSerialized();
- appDomainEnable = DistributedSystem::SystemProperties->AppDomainEnabled;
+ appDomainEnable = cache->DistributedSystem->SystemProperties->AppDomainEnabled;
Log::SetLogLevel(static_cast<LogLevel>(native::Log::logLevel( )));
//TODO::split
SafeConvertClassGeneric::SetAppDomainEnabled(appDomainEnable);
@@ -91,56 +96,33 @@ namespace Apache
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::PdxType,
gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::Internal::PdxType::CreateDeserializable),
- nullptr);
+ nullptr, cache);
if(!m_connected)
{
//it registers types in unmanage layer, so should be once only
- DistributedSystem::ManagedPostConnect();
+ DistributedSystem::ManagedPostConnect(cache);
DistributedSystem::AppDomainInstancePostInitialization();
DistributedSystem::connectInstance();
}
m_connected = true;
- return Cache::Create( nativeCache );
+
+
+ DistributedSystem::registerCliCallback();
+ Serializable::RegisterPDXManagedCacheableKey(appDomainEnable, cache);
+
+ return cache;
_GF_MG_EXCEPTION_CATCH_ALL2
finally {
GC::KeepAlive(m_nativeptr);
- DistributedSystem::registerCliCallback();
- Serializable::RegisterPDXManagedCacheableKey(appDomainEnable);
Apache::Geode::Client::Internal::PdxTypeRegistry::PdxIgnoreUnreadFields = pdxIgnoreUnreadFields;
Apache::Geode::Client::Internal::PdxTypeRegistry::PdxReadSerialized = pdxReadSerialized;
DistributedSystem::releaseDisconnectLock();
}
}
-
- Cache^ CacheFactory::GetInstance( DistributedSystem^ system )
- {
- _GF_MG_EXCEPTION_TRY2
-
- return Cache::Create( native::CacheFactory::getInstance( system->GetNative() ) );
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
-
- Cache^ CacheFactory::GetInstanceCloseOk( DistributedSystem^ system )
- {
- _GF_MG_EXCEPTION_TRY2
-
- return Cache::Create( native::CacheFactory::getInstanceCloseOk( system->GetNative() ) );
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
-
- Cache^ CacheFactory::GetAnyInstance( )
- {
- _GF_MG_EXCEPTION_TRY2
-
- return Cache::Create( native::CacheFactory::getAnyInstance( ) );
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
+
String^ CacheFactory::Version::get( )
{
@@ -154,368 +136,6 @@ namespace Apache
}
- CacheFactory^ CacheFactory::SetFreeConnectionTimeout( Int32 connectionTimeout )
- {
- _GF_MG_EXCEPTION_TRY2
-
- try
- {
- m_nativeptr->get()->setFreeConnectionTimeout( connectionTimeout );
- }
- finally
- {
- GC::KeepAlive(m_nativeptr);
- }
-
- return this;
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
-
- CacheFactory^ CacheFactory::SetLoadConditioningInterval( Int32 loadConditioningInterval )
- {
- _GF_MG_EXCEPTION_TRY2
-
- try
- {
- m_nativeptr->get()->setLoadConditioningInterval( loadConditioningInterval );
- }
- finally
- {
- GC::KeepAlive(m_nativeptr);
- }
- return this;
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
-
- CacheFactory^ CacheFactory::SetSocketBufferSize( Int32 bufferSize )
- {
- _GF_MG_EXCEPTION_TRY2
-
- try
- {
- m_nativeptr->get()->setSocketBufferSize( bufferSize );
- }
- finally
- {
- GC::KeepAlive(m_nativeptr);
- }
- return this;
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
-
- CacheFactory^ CacheFactory::SetReadTimeout( Int32 timeout )
- {
- _GF_MG_EXCEPTION_TRY2
-
- try
- {
- m_nativeptr->get()->setReadTimeout( timeout );
- }
- finally
- {
- GC::KeepAlive(m_nativeptr);
- }
- return this;
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
-
- CacheFactory^ CacheFactory::SetMinConnections( Int32 minConnections )
- {
- _GF_MG_EXCEPTION_TRY2
-
- try
- {
- m_nativeptr->get()->setMinConnections( minConnections );
- }
- finally
- {
- GC::KeepAlive(m_nativeptr);
- }
- return this;
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
-
- CacheFactory^ CacheFactory::SetMaxConnections( Int32 maxConnections )
- {
- _GF_MG_EXCEPTION_TRY2
-
- try
- {
- m_nativeptr->get()->setMaxConnections( maxConnections );
- }
- finally
- {
- GC::KeepAlive(m_nativeptr);
- }
- return this;
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
-
- CacheFactory^ CacheFactory::SetIdleTimeout( Int32 idleTimeout )
- {
- _GF_MG_EXCEPTION_TRY2
-
- try
- {
- m_nativeptr->get()->setIdleTimeout( idleTimeout );
- }
- finally
- {
- GC::KeepAlive(m_nativeptr);
- }
- return this;
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
-
- CacheFactory^ CacheFactory::SetRetryAttempts( Int32 retryAttempts )
- {
- _GF_MG_EXCEPTION_TRY2
-
- try
- {
- m_nativeptr->get()->setRetryAttempts( retryAttempts );
- }
- finally
- {
- GC::KeepAlive(m_nativeptr);
- }
- return this;
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
-
- CacheFactory^ CacheFactory::SetPingInterval( Int32 pingInterval )
- {
- _GF_MG_EXCEPTION_TRY2
-
- try
- {
- m_nativeptr->get()->setPingInterval( pingInterval );
- }
- finally
- {
- GC::KeepAlive(m_nativeptr);
- }
- return this;
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
-
- CacheFactory^ CacheFactory::SetUpdateLocatorListInterval( Int32 updateLocatorListInterval )
- {
- _GF_MG_EXCEPTION_TRY2
-
- try
- {
- m_nativeptr->get()->setUpdateLocatorListInterval( updateLocatorListInterval );
- }
- finally
- {
- GC::KeepAlive(m_nativeptr);
- }
- return this;
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
-
- CacheFactory^ CacheFactory::SetStatisticInterval( Int32 statisticInterval )
- {
- _GF_MG_EXCEPTION_TRY2
-
- try
- {
- m_nativeptr->get()->setStatisticInterval( statisticInterval );
- }
- finally
- {
- GC::KeepAlive(m_nativeptr);
- }
- return this;
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
-
- CacheFactory^ CacheFactory::SetServerGroup( String^ group )
- {
- _GF_MG_EXCEPTION_TRY2
-
- ManagedString mg_servergroup( group );
- try
- {
- m_nativeptr->get()->setServerGroup( mg_servergroup.CharPtr );
- }
- finally
- {
- GC::KeepAlive(m_nativeptr);
- }
- return this;
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
-
- CacheFactory^ CacheFactory::AddLocator( String^ host, Int32 port )
- {
- _GF_MG_EXCEPTION_TRY2
-
- ManagedString mg_host( host );
- try
- {
- m_nativeptr->get()->addLocator( mg_host.CharPtr, port );
- }
- finally
- {
- GC::KeepAlive(m_nativeptr);
- }
- return this;
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
-
- CacheFactory^ CacheFactory::AddServer( String^ host, Int32 port )
- {
- _GF_MG_EXCEPTION_TRY2
-
- ManagedString mg_host( host );
- try
- {
- m_nativeptr->get()->addServer( mg_host.CharPtr, port );
- }
- finally
- {
- GC::KeepAlive(m_nativeptr);
- }
- return this;
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
-
- CacheFactory^ CacheFactory::SetSubscriptionEnabled( Boolean enabled )
- {
- _GF_MG_EXCEPTION_TRY2
-
- try
- {
- m_nativeptr->get()->setSubscriptionEnabled( enabled );
- }
- finally
- {
- GC::KeepAlive(m_nativeptr);
- }
- return this;
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
-
- CacheFactory^ CacheFactory::SetPRSingleHopEnabled( Boolean enabled )
- {
- _GF_MG_EXCEPTION_TRY2
-
- try
- {
- m_nativeptr->get()->setPRSingleHopEnabled(enabled);
- }
- finally
- {
- GC::KeepAlive(m_nativeptr);
- }
- return this;
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
-
- CacheFactory^ CacheFactory::SetSubscriptionRedundancy( Int32 redundancy )
- {
- _GF_MG_EXCEPTION_TRY2
-
- try
- {
- m_nativeptr->get()->setSubscriptionRedundancy( redundancy );
- }
- finally
- {
- GC::KeepAlive(m_nativeptr);
- }
- return this;
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
-
- CacheFactory^ CacheFactory::SetSubscriptionMessageTrackingTimeout( Int32 messageTrackingTimeout )
- {
- _GF_MG_EXCEPTION_TRY2
-
- try
- {
- m_nativeptr->get()->setSubscriptionMessageTrackingTimeout( messageTrackingTimeout );
- }
- finally
- {
- GC::KeepAlive(m_nativeptr);
- }
- return this;
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
-
- CacheFactory^ CacheFactory::SetSubscriptionAckInterval( Int32 ackInterval )
- {
- _GF_MG_EXCEPTION_TRY2
-
- try
- {
- m_nativeptr->get()->setSubscriptionAckInterval( ackInterval );
- }
- finally
- {
- GC::KeepAlive(m_nativeptr);
- }
- return this;
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
-
- CacheFactory^ CacheFactory::SetThreadLocalConnections( bool enabled )
- {
- _GF_MG_EXCEPTION_TRY2
-
- try
- {
- m_nativeptr->get()->setThreadLocalConnections( enabled );
- }
- finally
- {
- GC::KeepAlive(m_nativeptr);
- }
-
- _GF_MG_EXCEPTION_CATCH_ALL2
-
- return this;
- }
-
- CacheFactory^ CacheFactory::SetMultiuserAuthentication( bool multiuserAuthentication )
- {
- _GF_MG_EXCEPTION_TRY2
-
- try
- {
- m_nativeptr->get()->setMultiuserAuthentication( multiuserAuthentication );
- }
- finally
- {
- GC::KeepAlive(m_nativeptr);
- }
- return this;
-
- _GF_MG_EXCEPTION_CATCH_ALL2
- }
-
CacheFactory^ CacheFactory::SetPdxIgnoreUnreadFields(bool ignore)
{
_GF_MG_EXCEPTION_TRY2
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/CacheFactory.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheFactory.hpp b/src/clicache/src/CacheFactory.hpp
index ca7f07b..fb9f8ba 100644
--- a/src/clicache/src/CacheFactory.hpp
+++ b/src/clicache/src/CacheFactory.hpp
@@ -72,59 +72,13 @@ namespace Apache
Cache^ Create();
/// <summary>
- /// Gets the instance of <see cref="Cache" /> produced by an
- /// earlier call to <see cref="CacheFactory.Create" />.
+ /// Set allocators for non default Microsoft CRT versions.
/// </summary>
- /// <param name="system">
- /// the <see cref="DistributedSystem" /> the cache was created with.
- /// </param>
- /// <returns>the <see cref="Cache" /> associated with the specified system.</returns>
- /// <exception cref="IllegalArgumentException">
- /// if the distributed system argument is null
- /// </exception>
- /// <exception cref="CacheClosedException">
- /// if a cache has not been created or the created one is closed
- /// ( <see cref="Cache.IsClosed" /> )
- /// </exception>
- /// <exception cref="EntryNotFoundException">
- /// if a cache with specified system not found
- /// </exception>
- static Cache^ GetInstance(DistributedSystem^ system);
-
- /// <summary>
- /// Gets the instance of <see cref="Cache" /> produced by an
- /// earlier call to <see cref="CacheFactory.Create" />, even if it has been closed.
- /// </summary>
- /// <param name="system">
- /// the <see cref="DistributedSystem" /> the cache was created with.
- /// </param>
- /// <returns>
- /// the <c>Cache</c> associated with the specified system.
- /// </returns>
- /// <exception cref="IllegalArgumentException">
- /// if the distributed system argument is null
- /// </exception>
- /// <exception cref="CacheClosedException">
- /// if a cache has not been created.
- /// </exception>
- /// <exception cref="EntryNotFoundException">
- /// if a cache with specified system not found
- /// </exception>
- static Cache^ GetInstanceCloseOk(DistributedSystem^ system);
-
- /// <summary>
- /// Gets an arbitrary open instance of <see cref="Cache" /> produced by an
- /// earlier call to <see cref="CacheFactory.Create" />.
- /// </summary>
- /// <exception cref="CacheClosedException">
- /// if a cache has not been created or the only created one is
- /// closed ( <see cref="Cache.IsClosed" /> )
- /// </exception>
- /// <exception cref="EntryNotFoundException">
- /// if a cache with specified system not found
- /// </exception>
- static Cache^ GetAnyInstance();
-
+ /* static void SetNewAndDelete()
+ {
+ native::setNewAndDelete(&operator new, &operator delete);
+ }
+*/
/// <summary>
/// Returns the version of the cache implementation.
/// For the 1.0 release of Geode, the string returned is <c>1.0</c>.
@@ -143,390 +97,6 @@ namespace Apache
static String^ get();
}
- /// <summary>
- /// Sets the free connection timeout for this pool.
- /// </summary>
- /// <remarks>
- /// If the pool has a max connections setting, operations will block
- /// if all of the connections are in use. The free connection timeout
- /// specifies how long those operations will block waiting for
- /// a free connection before receiving an AllConnectionsInUseException.
- /// If max connections is not set this setting has no effect.
- /// </remarks>
- /// <param>
- /// connectionTimeout the connection timeout in milliseconds
- /// </param>
- /// <exception>
- /// IllegalArgumentException if connectionTimeout
- /// is less than or equal to 0.
- /// </exception>
- CacheFactory^ SetFreeConnectionTimeout(Int32 connectionTimeout);
-
- /// <summary>
- /// Sets the load conditioning interval for this pool.
- /// </summary>
- /// <remarks>
- /// This interval controls how frequently the pool will check to see if
- /// a connection to a given server should be moved to a different
- /// server to improve the load balance.
- /// </remarks>
- /// <param>
- /// loadConditioningInterval the connection lifetime in milliseconds
- /// A value of -1 disables load conditioning.
- /// </param>
- /// <exception>
- /// throws IllegalArgumentException if connectionLifetime
- /// is less than -1.
- /// </exception>
- /// <returns>
- /// a instance of <c>CacheFactory</c>
- /// </returns>
- CacheFactory^ SetLoadConditioningInterval(Int32 loadConditioningInterval);
-
- /// <summary>
- /// Sets the socket buffer size for each connection made in this pool.
- /// </summary>
- /// <remarks>
- /// Large messages can be received and sent faster when this buffer is larger.
- /// Larger buffers also optimize the rate at which servers can send events
- /// for client subscriptions.
- /// </remarks>
- /// <param>
- /// bufferSize the size of the socket buffers used for reading and
- /// writing on each connection in this pool.
- /// </param>
- /// <exception>
- /// throws IllegalArgumentException if bufferSize
- /// is less than or equal to 0.
- /// </exception>
- /// <returns>
- /// a instance of <c>CacheFactory</c>
- /// </returns>
- CacheFactory^ SetSocketBufferSize(Int32 bufferSize);
-
- /// <summary>
- /// Sets the number of milliseconds to wait for a response from a server before
- /// timing out the operation and trying another server (if any are available).
- /// </summary>
- /// <param>
- /// timeout number of milliseconds to wait for a response from a server
- /// </param>
- /// <exception>
- /// throws IllegalArgumentException if timeout
- /// is less than or equal to 0.
- /// </exception>
- /// <returns>
- /// a instance of <c>CacheFactory</c>
- /// </returns>
- CacheFactory^ SetReadTimeout(Int32 timeout);
-
- /// <summary>
- /// Set the minimum number of connections to keep available at all times.
- /// </summary>
- /// <remarks>
- /// When the pool is created, it will create this many connections.
- /// If 0 then connections will not be made until an actual operation
- /// is done that requires client-to-server communication.
- /// </remarks>
- /// <param>
- /// minConnections the initial number of connections this pool will create.
- /// </param>
- /// <exception>
- /// throws IllegalArgumentException if minConnections is less than 0.
- /// </exception>
- /// <returns>
- /// a instance of <c>CacheFactory</c>
- /// </returns>
- CacheFactory^ SetMinConnections(Int32 minConnections);
-
- /// <summary>
- /// Set the max number of client to server connections that the pool will create.
- /// </summary>
- /// <remarks>
- /// If all of the connections are in use, an operation requiring a client to
- /// server connection will block until a connection is available.
- /// see setFreeConnectionTimeout(int)
- /// </remarks>
- /// <param>
- /// maxConnections the maximum number of connections in the pool.
- /// -1 indicates that there is no maximum number of connections.
- /// </param>
- /// <exception>
- /// throws IllegalArgumentException if maxConnections is less than minConnections.
- /// </exception>
- /// <returns>
- /// a instance of <c>CacheFactory</c>
- /// </returns>
- CacheFactory^ SetMaxConnections(Int32 maxConnections);
-
- /// <summary>
- /// Set the amount of time a connection can be idle before expiring the connection.
- /// </summary>
- /// <remarks>
- /// If the pool size is greater than the minimum specified, connections which have
- /// been idle for longer than the idleTimeout will be closed.
- /// </remarks>
- /// <param>
- /// idleTimeout The amount of time in milliseconds that an idle connection
- /// should live before expiring. -1 indicates that connections should never expire.
- /// </param>
- /// <exception>
- /// throws IllegalArgumentException if idleTimout is less than 0.
- /// </exception>
- /// <returns>
- /// a instance of <c>CacheFactory</c>
- /// </returns>
- CacheFactory^ SetIdleTimeout(Int32 idleTimeout);
-
- /// <summary>
- /// Set the number of times to retry a request after timeout/exception.
- /// </summary>
- /// <param>
- /// retryAttempts The number of times to retry a request
- /// after timeout/exception. -1 indicates that a request should be
- /// tried against every available server before failing.
- /// </param>
- /// <exception>
- /// throws IllegalArgumentException if idleTimout is less than 0.
- /// </exception>
- /// <returns>
- /// a instance of <c>CacheFactory</c>
- /// </returns>
- CacheFactory^ SetRetryAttempts(Int32 retryAttempts);
-
- /// <summary>
- /// Set how often to ping servers to verify that they are still alive.
- /// </summary>
- /// <remarks>
- /// Each server will be sent a ping every pingInterval if there has not
- /// been any other communication with the server.
- /// These pings are used by the server to monitor the health of
- /// the client. Make sure that the pingInterval is less than the
- /// maximum time between pings allowed by the bridge server.
- /// see in CacheServer: setMaximumTimeBetweenPings(int)
- /// </remarks>
- /// <param>
- /// pingInterval The amount of time in milliseconds between pings.
- /// </param>
- /// <exception>
- /// throws IllegalArgumentException if pingInterval is less than 0.
- /// </exception>
- /// <returns>
- /// a instance of <c>CacheFactory</c>
- /// </returns>
- CacheFactory^ SetPingInterval(Int32 pingInterval);
-
- /// <summary>
- /// Set how often to update locator list from locator
- /// </summary>
- /// <param>
- /// updateLocatorListInterval The amount of time in milliseconds between
- /// updating locator list. If its set to 0 then client will not update
- /// the locator list.
- /// </param>
- /// <returns>
- /// a instance of <c>CacheFactory</c>
- /// </returns>
- CacheFactory^ SetUpdateLocatorListInterval(Int32 updateLocatorListInterval);
-
-
- /// <summary>
- /// Set how often to send client statistics to the server.
- /// </summary>
- /// <remarks>
- /// Doing this allows gfmon to monitor clients.
- /// A value of -1 disables the sending of client statistics
- /// to the server.
- /// </remarks>
- /// <param>
- /// statisticInterval The amount of time in milliseconds between
- /// sends of client statistics to the server.
- /// </param>
- /// <exception>
- /// throws IllegalArgumentException if statisticInterval
- /// is less than -1.
- /// </exception>
- /// <returns>
- /// a instance of <c>CacheFactory</c>
- /// </returns>
- CacheFactory^ SetStatisticInterval(Int32 statisticInterval);
-
- /// <summary>
- /// Configures the group that all servers this pool connects to must belong to.
- /// </summary>
- /// <param>
- /// group the server group that this pool will connect to.
- /// If null or "" then all servers will be connected to.
- /// </param>
- /// <returns>
- /// a instance of <c>CacheFactory</c>
- /// </returns>
- CacheFactory^ SetServerGroup(String^ group);
-
- /// <summary>
- /// Add a locator, given its host and port, to this factory.
- /// </summary>
- /// <remarks>
- /// The locator must be a server locator and will be used to discover other running
- /// bridge servers and locators.
- /// </remarks>
- /// <param>
- /// host the host name or ip address that the locator is listening on.
- /// </param>
- /// <param>
- /// port the port that the locator is listening on
- /// </param>
- /// <exception>
- /// throws IllegalArgumentException if host is an unknown host
- /// or if port is outside the valid range of [1..65535] inclusive.
- /// </exception>
- /// <exception>
- /// throws IllegalStateException if a locator has already been added to this factory.
- /// </exception>
- /// <returns>
- /// a instance of <c>CacheFactory</c>
- /// </returns>
- CacheFactory^ AddLocator(String^ host, Int32 port);
-
- /// <summary>
- /// Add a server, given its host and port, to this factory.
- /// </summary>
- /// <remarks>
- /// The server must be a bridge server and this client will
- /// directly connect to without consulting a server locator.
- /// </remarks>
- /// <param>
- /// host the host name or ip address that the server is listening on.
- /// </param>
- /// <param>
- /// port the port that the server is listening on
- /// </param>
- /// <exception>
- /// throws IllegalArgumentException if host is an unknown host
- /// or if port is outside the valid range of [1..65535] inclusive.
- /// </exception>
- /// <exception>
- /// throws IllegalStateException if a server has already been added to this factory.
- /// </exception>
- /// <returns>
- /// a instance of <c>CacheFactory</c>
- /// </returns>
- CacheFactory^ AddServer(String^ host, Int32 port);
-
- /// <summary>
- /// Enable subscriptions.
- /// </summary>
- /// <remarks>
- /// If set to true then the created pool will have server-to-client
- /// subscriptions enabled. If set to false then all Subscription*
- /// attributes are ignored at create time.
- /// </remarks>
- /// <returns>
- /// a instance of <c>CacheFactory</c>
- /// </returns>
- CacheFactory^ SetSubscriptionEnabled(Boolean enabled);
-
- /// <summary>
- /// By default SetPRSingleHopEnabled is true.
- /// </summary>
- /// <remarks>
- /// The client is aware of location of partitions on servers hosting
- /// Using this information, the client routes the client cache operations
- /// directly to the server which is hosting the required partition for the
- /// cache operation.
- /// If SetPRSingleHopEnabled is false the client can do an extra hop on servers
- /// to go to the required partition for that cache operation.
- /// The SetPRSingleHopEnabled avoids extra hops only for following cache operations :
- /// put, get & destroy operations.
- /// </remarks>
- /// <returns>
- /// a instance of <c>CacheFactory</c>
- /// </returns>
- CacheFactory^ SetPRSingleHopEnabled(Boolean enabled);
-
- /// <summary>
- /// Sets the redundancy level for this pools server-to-client subscriptions.
- /// </summary>
- /// <remarks>
- /// If 0 then no redundant copies will be kept on the servers.
- /// Otherwise an effort will be made to maintain the requested number of
- /// copies of the server-to-client subscriptions. At most one copy per server will
- /// be made up to the requested level.
- /// </remarks>
- /// <param>
- /// redundancy the number of redundant servers for this client's subscriptions.
- /// </param>
- /// <exception>
- /// throws IllegalArgumentException if redundancyLevel is less than -1.
- /// </exception>
- /// <returns>
- /// a instance of <c>CacheFactory</c>
- /// </returns>
- CacheFactory^ SetSubscriptionRedundancy(Int32 redundancy);
-
- /// <summary>
- /// Sets the messageTrackingTimeout attribute which is the time-to-live period,
- /// in milliseconds, for subscription events the client has received from the server.
- /// </summary>
- /// <remarks>
- /// It's used to minimize duplicate events. Entries that have not been modified
- /// for this amount of time are expired from the list.
- /// </remarks>
- /// <param>
- /// messageTrackingTimeout number of milliseconds to set the timeout to.
- /// </param>
- /// <exception>
- /// throws IllegalArgumentException if messageTrackingTimeout is less than or equal to 0.
- /// </exception>
- /// <returns>
- /// a instance of <c>CacheFactory</c>
- /// </returns>
- CacheFactory^ SetSubscriptionMessageTrackingTimeout(Int32 messageTrackingTimeout);
-
- /// <summary>
- /// Sets the is the interval in milliseconds to wait before sending
- /// acknowledgements to the bridge server for events received from the server subscriptions.
- /// </summary>
- /// <param>
- /// ackInterval number of milliseconds to wait before sending event acknowledgements.
- /// </param>
- /// <exception>
- /// throws IllegalArgumentException if ackInterval is less than or equal to 0.
- /// </exception>
- /// <returns>
- /// a instance of <c>CacheFactory</c>
- /// </returns>
- CacheFactory^ SetSubscriptionAckInterval(Int32 ackInterval);
-
- /// <summary>
- /// Enable thread local connections.
- /// </summary>
- /// <remarks>
- /// Sets the thread local connections policy for the default connection pool.
- /// If true then any time a thread goes to use a connection
- /// from this pool it will check a thread local cache and see if it already
- /// has a connection in it. If so it will use it. If not it will get one from
- /// this pool and cache it in the thread local. This gets rid of thread contention
- /// for the connections but increases the number of connections the servers see.
- /// If false then connections are returned to the pool as soon
- /// as the operation being done with the connection completes. This allows
- /// connections to be shared amonst multiple threads keeping the number of
- /// connections down.
- /// </remarks>
- CacheFactory^ SetThreadLocalConnections(bool enabled);
-
- /// <summary>
- /// Sets whether pool is in multiuser mode
- /// </summary>
- /// <param>
- /// multiuserAuthentication should be true/false. Default value is false;
- /// </param>
- /// <returns>
- /// a instance of <c>CacheFactory</c>
- /// </returns>
- CacheFactory^ SetMultiuserAuthentication(bool multiuserAuthentication);
-
-
///<summary>
/// Control whether pdx ignores fields that were unread during deserialization.
/// The default is to preserve unread fields be including their data during serialization.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/CacheableHashSet.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableHashSet.hpp b/src/clicache/src/CacheableHashSet.hpp
index 9330d4a..581d4a8 100644
--- a/src/clicache/src/CacheableHashSet.hpp
+++ b/src/clicache/src/CacheableHashSet.hpp
@@ -380,7 +380,7 @@ namespace Apache
try
{
- static_cast<HSTYPE*>(m_nativeptr->get())->insert(Serializable::GetUnmanagedValueGeneric(item));
+ static_cast<HSTYPE*>(m_nativeptr->get())->insert(Serializable::GetUnmanagedValueGeneric(item, nullptr));
}
finally
{
@@ -420,7 +420,7 @@ namespace Apache
{
try
{
- return static_cast<HSTYPE*>(m_nativeptr->get())->find(Serializable::GetUnmanagedValueGeneric(item)) != static_cast<HSTYPE*>(m_nativeptr->get())->end();
+ return static_cast<HSTYPE*>(m_nativeptr->get())->find(Serializable::GetUnmanagedValueGeneric(item, nullptr)) != static_cast<HSTYPE*>(m_nativeptr->get())->end();
}
finally
{
@@ -510,7 +510,7 @@ namespace Apache
{
try
{
- return (static_cast<HSTYPE*>(m_nativeptr->get())->erase(Serializable::GetUnmanagedValueGeneric(item)) > 0);
+ return (static_cast<HSTYPE*>(m_nativeptr->get())->erase(Serializable::GetUnmanagedValueGeneric(item, nullptr)) > 0);
}
finally
{
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/DataInput.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/DataInput.cpp b/src/clicache/src/DataInput.cpp
index e6d7ac1..a3ca689 100644
--- a/src/clicache/src/DataInput.cpp
+++ b/src/clicache/src/DataInput.cpp
@@ -18,6 +18,8 @@
#include "begin_native.hpp"
#include <geode/Cache.hpp>
#include <GeodeTypeIdsImpl.hpp>
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
#include "end_native.hpp"
#include <vcclr.h>
@@ -47,14 +49,15 @@ namespace Apache
{
namespace native = apache::geode::client;
- DataInput::DataInput(System::Byte* buffer, int size)
+ DataInput::DataInput(System::Byte* buffer, int size, const native::Cache* cache)
{
m_ispdxDesrialization = false;
m_isRootObjectPdx = false;
+ m_cache = cache;
if (buffer != nullptr && size > 0) {
_GF_MG_EXCEPTION_TRY2
- m_nativeptr = gcnew native_conditional_unique_ptr<native::DataInput>(std::make_unique<native::DataInput>(buffer, size));
+ m_nativeptr = gcnew native_conditional_unique_ptr<native::DataInput>(cache->createDataInput(buffer, size));
m_cursor = 0;
m_isManagedObject = false;
m_forStringDecode = gcnew array<Char>(100);
@@ -77,10 +80,11 @@ namespace Apache
}
}
- DataInput::DataInput(array<Byte>^ buffer)
+ DataInput::DataInput(array<Byte>^ buffer, const native::Cache * cache)
{
m_ispdxDesrialization = false;
m_isRootObjectPdx = false;
+ m_cache = cache;
if (buffer != nullptr && buffer->Length > 0) {
_GF_MG_EXCEPTION_TRY2
@@ -88,7 +92,7 @@ namespace Apache
GF_NEW(m_buffer, System::Byte[len]);
pin_ptr<const Byte> pin_buffer = &buffer[0];
memcpy(m_buffer, (void*)pin_buffer, len);
- m_nativeptr = gcnew native_conditional_unique_ptr<native::DataInput>(std::unique_ptr<native::DataInput>(new native::DataInput(m_buffer, len)));
+ m_nativeptr = gcnew native_conditional_unique_ptr<native::DataInput>(m_cache->createDataInput(m_buffer, len));
m_cursor = 0;
m_isManagedObject = false;
@@ -112,10 +116,11 @@ namespace Apache
}
}
- DataInput::DataInput(array<Byte>^ buffer, System::Int32 len)
+ DataInput::DataInput(array<Byte>^ buffer, System::Int32 len, const native::Cache* cache)
{
m_ispdxDesrialization = false;
m_isRootObjectPdx = false;
+ m_cache = cache;
if (buffer != nullptr) {
if (len == 0 || (System::Int32)len > buffer->Length) {
throw gcnew IllegalArgumentException(String::Format(
@@ -129,7 +134,7 @@ namespace Apache
GF_NEW(m_buffer, System::Byte[len]);
pin_ptr<const Byte> pin_buffer = &buffer[0];
memcpy(m_buffer, (void*)pin_buffer, len);
- m_nativeptr = gcnew native_conditional_unique_ptr<native::DataInput>(std::unique_ptr<native::DataInput>(new native::DataInput(m_buffer, len)));
+ m_nativeptr = gcnew native_conditional_unique_ptr<native::DataInput>(m_cache->createDataInput(m_buffer, len));
try
{
@@ -160,7 +165,7 @@ namespace Apache
DataInput^ DataInput::GetClone()
{
- return gcnew DataInput(m_buffer, m_bufferLength);
+ return gcnew DataInput(m_buffer, m_bufferLength, m_cache);
}
Byte DataInput::ReadByte()
@@ -658,7 +663,7 @@ namespace Apache
int cacheCursor = m_cursor;
System::Byte* cacheBuffer = m_buffer;
unsigned int cacheBufferLength = m_bufferLength;
- Object^ ret = Internal::PdxHelper::DeserializePdx(this, false);
+ Object^ ret = Internal::PdxHelper::DeserializePdx(this, false, CacheRegionHelper::getCacheImpl(m_cache)->getSerializationRegistry().get());
int tmp = m_nativeptr->get()->getBytesRemaining();
m_cursor = cacheBufferLength - tmp;
m_buffer = cacheBuffer;
@@ -682,7 +687,7 @@ namespace Apache
int tmp = ReadArrayLen();
int enumId = (dsId << 24) | (tmp & 0xFFFFFF);
- Object^ enumVal = Internal::PdxHelper::GetEnum(enumId);
+ Object^ enumVal = Internal::PdxHelper::GetEnum(enumId, m_cache);
return enumVal;
}
else if (compId == GeodeTypeIds::CacheableNullString) {
@@ -809,7 +814,7 @@ namespace Apache
}
else if (compId == GeodeClassIds::PDX)
{
- return Internal::PdxHelper::DeserializePdx(this, false);
+ return Internal::PdxHelper::DeserializePdx(this, false, CacheRegionHelper::getCacheImpl(m_cache)->getSerializationRegistry().get());
}
else if (compId == GeodeTypeIds::CacheableNullString) {
//return SerializablePtr(CacheableString::createDeserializable());
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/DataInput.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/DataInput.hpp b/src/clicache/src/DataInput.hpp
index 8797381..80ed2b0 100644
--- a/src/clicache/src/DataInput.hpp
+++ b/src/clicache/src/DataInput.hpp
@@ -52,12 +52,12 @@ namespace Apache
/// Construct <c>DataInput</c> using an given array of bytes.
/// </summary>
/// <param name="buffer">
- /// The buffer to use for reading data values.
+ /// The buffer to use for reading data values
/// </param>
/// <exception cref="IllegalArgumentException">
/// if the buffer is null
/// </exception>
- DataInput( array<Byte>^ buffer );
+ DataInput( array<Byte>^ buffer, const native::Cache* cache );
/// <summary>
/// Construct <c>DataInput</c> using a given length of an array of
@@ -72,7 +72,7 @@ namespace Apache
/// <exception cref="IllegalArgumentException">
/// if the buffer is null
/// </exception>
- DataInput( array<Byte>^ buffer, System::Int32 len );
+ DataInput( array<Byte>^ buffer, System::Int32 len, const native::Cache* cache );
/// <summary>
/// Dispose: frees the internal buffer.
@@ -656,11 +656,12 @@ namespace Apache
/// Internal constructor to wrap a native object pointer
/// </summary>
/// <param name="nativeptr">The native object pointer</param>
- inline DataInput( apache::geode::client::DataInput* nativeptr, bool managedObject )
+ inline DataInput( apache::geode::client::DataInput* nativeptr, bool managedObject, const native::Cache* cache )
{
m_nativeptr = gcnew native_conditional_unique_ptr<native::DataInput>(nativeptr);
m_ispdxDesrialization = false;
m_isRootObjectPdx = false;
+ m_cache = cache;
m_cursor = 0;
m_isManagedObject = managedObject;
m_forStringDecode = gcnew array<Char>(100);
@@ -673,7 +674,7 @@ namespace Apache
}
}
- DataInput( System::Byte* buffer, int size );
+ DataInput( System::Byte* buffer, int size, const native::Cache* cache );
bool IsManagedObject()
{
@@ -693,6 +694,7 @@ namespace Apache
/// </summary>
bool m_ispdxDesrialization;
bool m_isRootObjectPdx;
+ const native::Cache* m_cache;
System::Byte* m_buffer;
unsigned int m_bufferLength;
int m_cursor;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/DataOutput.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/DataOutput.cpp b/src/clicache/src/DataOutput.cpp
index 8ced074..8b1d1cc 100644
--- a/src/clicache/src/DataOutput.cpp
+++ b/src/clicache/src/DataOutput.cpp
@@ -17,6 +17,8 @@
#include "begin_native.hpp"
#include <GeodeTypeIdsImpl.hpp>
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
#include "end_native.hpp"
#include <vcclr.h>
@@ -454,7 +456,7 @@ namespace Apache
if (m_ispdxSerialization && obj->GetType()->IsEnum)
{
//need to set
- int enumVal = Internal::PdxHelper::GetEnumValue(obj->GetType()->FullName, Enum::GetName(obj->GetType(), obj), obj->GetHashCode());
+ int enumVal = Internal::PdxHelper::GetEnumValue(obj->GetType()->FullName, Enum::GetName(obj->GetType(), obj), obj->GetHashCode(), m_nativeptr->get()->getCache());
WriteByte(GeodeClassIds::PDX_ENUM);
WriteByte(enumVal >> 24);
WriteArrayLen(enumVal & 0xFFFFFF);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/DataOutput.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/DataOutput.hpp b/src/clicache/src/DataOutput.hpp
index 81e610d..c98245c 100644
--- a/src/clicache/src/DataOutput.hpp
+++ b/src/clicache/src/DataOutput.hpp
@@ -20,6 +20,7 @@
#include "geode_defs.hpp"
#include "begin_native.hpp"
#include <geode/DataOutput.hpp>
+#include <geode/Cache.hpp>
#include "end_native.hpp"
#include "native_conditional_unique_ptr.hpp"
@@ -66,9 +67,9 @@ namespace Apache
/// <summary>
/// Default constructor.
/// </summary>
- inline DataOutput( )
+ inline DataOutput(native::Cache* cache)
{
- m_nativeptr = gcnew native_conditional_unique_ptr<native::DataOutput>(std::make_unique<native::DataOutput>());
+ m_nativeptr = gcnew native_conditional_unique_ptr<native::DataOutput>(cache->createDataOutput());
m_isManagedObject = true;
m_cursor = 0;
try
@@ -530,10 +531,6 @@ namespace Apache
void WriteObject(UInt32% obj);
void WriteObject(UInt64% obj);
-
- // void WriteObject(array<UInt16>^ objArray);
- //void WriteObject(array<UInt32>^ objArray);
- //void WriteObject(array<UInt64>^ objArray);
template <typename mType>
@@ -556,7 +553,6 @@ namespace Apache
bool IsManagedObject()
{
- //TODO::
return m_isManagedObject;
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/DistributedSystem.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/DistributedSystem.cpp b/src/clicache/src/DistributedSystem.cpp
index 239d7e2..7431933 100644
--- a/src/clicache/src/DistributedSystem.cpp
+++ b/src/clicache/src/DistributedSystem.cpp
@@ -22,12 +22,14 @@
#include <geode/FixedPartitionResolver.hpp>
#include <geode/CacheWriter.hpp>
#include <geode/GeodeTypeIds.hpp>
+#include <geode/Cache.hpp>
#include <CacheImpl.hpp>
#include <CacheXmlParser.hpp>
#include <DistributedSystemImpl.hpp>
#include <ace/Process.h> // Added to get rid of unresolved token warning
#include "end_native.hpp"
+#include "Cache.hpp"
#include "Serializable.hpp"
#include "DistributedSystem.hpp"
#include "SystemProperties.hpp"
@@ -128,31 +130,31 @@ namespace Apache
namespace Client
{
+
namespace native = apache::geode::client;
- DistributedSystem^ DistributedSystem::Connect(String^ name)
+ DistributedSystem^ DistributedSystem::Connect(String^ name, Cache^ cache)
{
- return DistributedSystem::Connect(name, nullptr);
+ return DistributedSystem::Connect(name, nullptr, cache);
}
- DistributedSystem^ DistributedSystem::Connect(String^ name, Properties<String^, String^>^ config)
+ DistributedSystem^ DistributedSystem::Connect(String^ name, Properties<String^, String^>^ config, Cache ^ cache)
{
native::DistributedSystemImpl::acquireDisconnectLock();
_GF_MG_EXCEPTION_TRY2
- ManagedString mg_name(name);
-
- DistributedSystem::AppDomainInstanceInitialization(config->GetNative());
+ ManagedString mg_name(name);
// this we are calling after all .NET initialization required in
// each AppDomain
- auto nativeptr = native::DistributedSystem::connect(mg_name.CharPtr,
+ auto nativeptr = native::DistributedSystem::create(mg_name.CharPtr, cache->GetNative().get(),
config->GetNative());
+ nativeptr->connect();
- ManagedPostConnect();
+ ManagedPostConnect(cache);
- return Create(nativeptr);
+ return gcnew DistributedSystem(std::move(nativeptr));
_GF_MG_EXCEPTION_CATCH_ALL2
@@ -161,19 +163,17 @@ namespace Apache
}
}
- void DistributedSystem::Disconnect()
+ void DistributedSystem::Disconnect(Cache^ cache)
{
native::DistributedSystemImpl::acquireDisconnectLock();
_GF_MG_EXCEPTION_TRY2
- if (native::DistributedSystem::isConnected()) {
- // native::CacheImpl::expiryTaskManager->cancelTask(
- // s_memoryPressureTaskID);
- Serializable::UnregisterNativesGeneric();
- DistributedSystem::UnregisterBuiltinManagedTypes();
- }
- native::DistributedSystem::disconnect();
+
+ Serializable::UnregisterNativesGeneric();
+ DistributedSystem::UnregisterBuiltinManagedTypes(cache);
+ m_nativeptr->get()->disconnect();
+ GC::KeepAlive(m_nativeptr);
_GF_MG_EXCEPTION_CATCH_ALL2
@@ -182,154 +182,16 @@ namespace Apache
}
}
- void DistributedSystem::AppDomainInstanceInitialization(
- const native::PropertiesPtr& nativepropsptr)
+ void DistributedSystem::AppDomainInstanceInitialization(Cache^ cache)
{
_GF_MG_EXCEPTION_TRY2
// Register wrapper types for built-in types, this are still cpp wrapper
- /*
- Serializable::RegisterWrapperGeneric(
- gcnew WrapperDelegateGeneric(Apache::Geode::Client::CacheableHashSet::Create),
- native::GeodeTypeIds::CacheableHashSet);
-
- Serializable::RegisterWrapperGeneric(
- gcnew WrapperDelegateGeneric(Apache::Geode::Client::CacheableLinkedHashSet::Create),
- native::GeodeTypeIds::CacheableLinkedHashSet);
-
- Serializable::RegisterWrapperGeneric(
- gcnew WrapperDelegateGeneric(Apache::Geode::Client::Struct::Create),
- native::GeodeTypeIds::Struct);
-
- Serializable::RegisterWrapperGeneric(
- gcnew WrapperDelegateGeneric(Apache::Geode::Client::Properties::CreateDeserializable),
- native::GeodeTypeIds::Properties);
-
- // End register wrapper types for built-in types
-
- // Register with cpp using unmanaged Cacheablekey wrapper
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableByte,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableByte::CreateDeserializable));
-
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableBoolean,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableBoolean::CreateDeserializable));
-
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableBytes,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableBytes::CreateDeserializable));
-
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::BooleanArray,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::BooleanArray::CreateDeserializable));
-
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableWideChar,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableCharacter::CreateDeserializable));
-
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CharArray,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CharArray::CreateDeserializable));
-
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableDouble,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableDouble::CreateDeserializable));
-
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableDoubleArray,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableDoubleArray::CreateDeserializable));
-
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableFloat,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableFloat::CreateDeserializable));
-
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableFloatArray,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableFloatArray::CreateDeserializable));
-
-
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableHashSet,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableHashSet::CreateDeserializable));
-
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableLinkedHashSet,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableLinkedHashSet::CreateDeserializable));
-
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableInt16,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableInt16::CreateDeserializable));
-
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableInt16Array,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableInt16Array::CreateDeserializable));
-
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableInt32,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableInt32::CreateDeserializable));
-
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableInt32Array,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableInt32Array::CreateDeserializable));
-
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableInt64,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableInt64::CreateDeserializable));
-
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableInt64Array,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableInt64Array::CreateDeserializable));
- */
-
- /*Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableASCIIString,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableString::CreateDeserializable));
-
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableASCIIStringHuge,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableString::createDeserializableHuge));
-
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableString,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableString::createUTFDeserializable));
-
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableStringHuge,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableString::createUTFDeserializableHuge));*/
-
- /*
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableNullString,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableString::CreateDeserializable));
-
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableStringArray,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableStringArray::CreateDeserializable));
-
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::Struct,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::Struct::CreateDeserializable));
-
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::Properties,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::Properties::CreateDeserializable));
- */
-
- // End register other built-in types
-
- //primitive types are still C++, as these are used as keys mostly
- // Register generic wrapper types for built-in types
- //byte
-
- /* Serializable::RegisterWrapperGeneric(
- gcnew WrapperDelegateGeneric(CacheableByte::Create),
- native::GeodeTypeIds::CacheableByte, Byte::typeid);*/
-
- Serializable::RegisterWrapperGeneric(
- gcnew WrapperDelegateGeneric(CacheableByte::Create),
- native::GeodeTypeIds::CacheableByte, SByte::typeid);
+ //byte
+ Serializable::RegisterWrapperGeneric(
+ gcnew WrapperDelegateGeneric(CacheableByte::Create),
+ native::GeodeTypeIds::CacheableByte, SByte::typeid);
//boolean
Serializable::RegisterWrapperGeneric(
@@ -348,21 +210,6 @@ namespace Apache
gcnew WrapperDelegateGeneric(CacheableString::Create),
native::GeodeTypeIds::CacheableASCIIString, String::typeid);
- //TODO:
- ////ascii string huge
- //Serializable::RegisterWrapperGeneric(
- // gcnew WrapperDelegateGeneric(CacheableString::Create),
- // native::GeodeTypeIds::CacheableASCIIStringHuge, String::typeid);
- ////string
- //Serializable::RegisterWrapperGeneric(
- // gcnew WrapperDelegateGeneric(CacheableString::Create),
- // native::GeodeTypeIds::CacheableString, String::typeid);
- ////string huge
- //Serializable::RegisterWrapperGeneric(
- // gcnew WrapperDelegateGeneric(CacheableString::Create),
- // native::GeodeTypeIds::CacheableStringHuge, String::typeid);
- //float
-
Serializable::RegisterWrapperGeneric(
gcnew WrapperDelegateGeneric(CacheableFloat::Create),
native::GeodeTypeIds::CacheableFloat, float::typeid);
@@ -379,136 +226,83 @@ namespace Apache
gcnew WrapperDelegateGeneric(CacheableInt64::Create),
native::GeodeTypeIds::CacheableInt64, Int64::typeid);
- ////uint16
- //Serializable::RegisterWrapperGeneric(
- // gcnew WrapperDelegateGeneric(CacheableInt16::Create),
- // native::GeodeTypeIds::CacheableInt16, UInt16::typeid);
- ////uint32
- //Serializable::RegisterWrapperGeneric(
- // gcnew WrapperDelegateGeneric(CacheableInt32::Create),
- // native::GeodeTypeIds::CacheableInt32, UInt32::typeid);
- ////uint64
- //Serializable::RegisterWrapperGeneric(
- // gcnew WrapperDelegateGeneric(CacheableInt64::Create),
- // native::GeodeTypeIds::CacheableInt64, UInt64::typeid);
- //=======================================================================
-
//Now onwards all will be wrap in managed cacheable key..
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::CacheableBytes,
gcnew TypeFactoryMethodGeneric(CacheableBytes::CreateDeserializable),
- Type::GetType("System.Byte[]"));
-
- /* Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableBytes,
- gcnew TypeFactoryMethodGeneric(CacheableBytes::CreateDeserializable),
- Type::GetType("System.SByte[]"));*/
+ Type::GetType("System.Byte[]"), cache);
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::CacheableDoubleArray,
gcnew TypeFactoryMethodGeneric(CacheableDoubleArray::CreateDeserializable),
- Type::GetType("System.Double[]"));
+ Type::GetType("System.Double[]"), cache);
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::CacheableFloatArray,
gcnew TypeFactoryMethodGeneric(CacheableFloatArray::CreateDeserializable),
- Type::GetType("System.Single[]"));
+ Type::GetType("System.Single[]"), cache);
//TODO:
//as it is
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::CacheableHashSet,
gcnew TypeFactoryMethodGeneric(CacheableHashSet::CreateDeserializable),
- nullptr);
+ nullptr, cache);
//as it is
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::CacheableLinkedHashSet,
gcnew TypeFactoryMethodGeneric(CacheableLinkedHashSet::CreateDeserializable),
- nullptr);
+ nullptr, cache);
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::CacheableInt16Array,
gcnew TypeFactoryMethodGeneric(CacheableInt16Array::CreateDeserializable),
- Type::GetType("System.Int16[]"));
-
- /* Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableInt16Array,
- gcnew TypeFactoryMethodGeneric(CacheableInt16Array::CreateDeserializable),
- Type::GetType("System.UInt16[]"));*/
-
+ Type::GetType("System.Int16[]"), cache);
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::CacheableInt32Array,
gcnew TypeFactoryMethodGeneric(CacheableInt32Array::CreateDeserializable),
- Type::GetType("System.Int32[]"));
-
- /* Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableInt32Array,
- gcnew TypeFactoryMethodGeneric(CacheableInt32Array::CreateDeserializable),
- Type::GetType("System.UInt32[]"));*/
+ Type::GetType("System.Int32[]"), cache);
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::CacheableInt64Array,
gcnew TypeFactoryMethodGeneric(CacheableInt64Array::CreateDeserializable),
- Type::GetType("System.Int64[]"));
-
- /* Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableInt64Array,
- gcnew TypeFactoryMethodGeneric(CacheableInt64Array::CreateDeserializable),
- Type::GetType("System.UInt64[]"));*/
- //TODO:;split
+ Type::GetType("System.Int64[]"), cache);
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::BooleanArray,
gcnew TypeFactoryMethodGeneric(BooleanArray::CreateDeserializable),
- Type::GetType("System.Boolean[]"));
+ Type::GetType("System.Boolean[]"), cache);
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::CharArray,
gcnew TypeFactoryMethodGeneric(CharArray::CreateDeserializable),
- Type::GetType("System.Char[]"));
-
- //TODO::
-
- //Serializable::RegisterTypeGeneric(
- // native::GeodeTypeIds::CacheableNullString,
- // gcnew TypeFactoryMethodNew(Apache::Geode::Client::CacheableString::CreateDeserializable));
+ Type::GetType("System.Char[]"), cache);
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::CacheableStringArray,
gcnew TypeFactoryMethodGeneric(CacheableStringArray::CreateDeserializable),
- Type::GetType("System.String[]"));
+ Type::GetType("System.String[]"), cache);
//as it is
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::Struct,
gcnew TypeFactoryMethodGeneric(Struct::CreateDeserializable),
- nullptr);
-
- //as it is
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::Properties,
- gcnew TypeFactoryMethodGeneric(Properties<String^, String^>::CreateDeserializable),
- nullptr);
-
- /* Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::PdxType,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::Internal::PdxType::CreateDeserializable),
- nullptr);*/
+ nullptr, cache);
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::EnumInfo,
gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::Internal::EnumInfo::CreateDeserializable),
- nullptr);
+ nullptr, cache);
// End register generic wrapper types for built-in types
- if (!native::DistributedSystem::isConnected())
- {
+ //if (!native::DistributedSystem::isConnected())
+ //{
// Set the Generic ManagedAuthInitialize factory function
native::SystemProperties::managedAuthInitializeFn =
native::ManagedAuthInitializeGeneric::create;
@@ -528,57 +322,18 @@ namespace Apache
// Set the Generic ManagedPersistanceManager factory function
native::CacheXmlParser::managedPersistenceManagerFn =
native::ManagedPersistenceManagerGeneric::create;
- }
+ //}
_GF_MG_EXCEPTION_CATCH_ALL2
}
- void DistributedSystem::ManagedPostConnect()
+ void DistributedSystem::ManagedPostConnect(Cache^ cache)
{
// The registration into the native map should be after
// native connect since it can be invoked only once
// Register other built-in types
- /*
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableDate,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableDate::CreateDeserializable));
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableFileName,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableFileName::CreateDeserializable));
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableHashMap,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableHashMap::CreateDeserializable));
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableHashTable,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableHashTable::CreateDeserializable));
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableIdentityHashMap,
- gcnew TypeFactoryMethodGeneric(
- Apache::Geode::Client::CacheableIdentityHashMap::CreateDeserializable));
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableUndefined,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableUndefined::CreateDeserializable));
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableVector,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableVector::CreateDeserializable));
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableObjectArray,
- gcnew TypeFactoryMethodGeneric(
- Apache::Geode::Client::CacheableObjectArray::CreateDeserializable));
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableArrayList,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableArrayList::CreateDeserializable));
- Serializable::RegisterTypeGeneric(
- native::GeodeTypeIds::CacheableStack,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableStack::CreateDeserializable));
- Serializable::RegisterTypeGeneric(
- GeodeClassIds::CacheableManagedObject - 0x80000000,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableObject::CreateDeserializable));
- Serializable::RegisterTypeGeneric(
- GeodeClassIds::CacheableManagedObjectXml - 0x80000000,
- gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableObjectXml::CreateDeserializable));
- */
+
// End register other built-in types
// Register other built-in types for generics
@@ -587,75 +342,75 @@ namespace Apache
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::CacheableDate,
gcnew TypeFactoryMethodGeneric(CacheableDate::CreateDeserializable),
- Type::GetType("System.DateTime"));
+ Type::GetType("System.DateTime"), cache);
//as it is
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::CacheableFileName,
gcnew TypeFactoryMethodGeneric(CacheableFileName::CreateDeserializable),
- nullptr);
+ nullptr, cache);
//for generic dictionary define its type in static constructor of Serializable.hpp
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::CacheableHashMap,
gcnew TypeFactoryMethodGeneric(CacheableHashMap::CreateDeserializable),
- nullptr);
+ nullptr, cache);
//c# hashtable
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::CacheableHashTable,
gcnew TypeFactoryMethodGeneric(CacheableHashTable::CreateDeserializable),
- Type::GetType("System.Collections.Hashtable"));
+ Type::GetType("System.Collections.Hashtable"), cache);
//Need to keep public as no counterpart in c#
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::CacheableIdentityHashMap,
gcnew TypeFactoryMethodGeneric(
CacheableIdentityHashMap::CreateDeserializable),
- nullptr);
+ nullptr, cache);
//keep as it is
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::CacheableUndefined,
gcnew TypeFactoryMethodGeneric(CacheableUndefined::CreateDeserializable),
- nullptr);
+ nullptr, cache);
//c# arraylist
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::CacheableVector,
gcnew TypeFactoryMethodGeneric(CacheableVector::CreateDeserializable),
- nullptr);
+ nullptr, cache);
//as it is
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::CacheableObjectArray,
gcnew TypeFactoryMethodGeneric(
CacheableObjectArray::CreateDeserializable),
- nullptr);
+ nullptr, cache);
//Generic::List
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::CacheableArrayList,
gcnew TypeFactoryMethodGeneric(CacheableArrayList::CreateDeserializable),
- nullptr);
+ nullptr, cache);
//c# generic stack
Serializable::RegisterTypeGeneric(
native::GeodeTypeIds::CacheableStack,
gcnew TypeFactoryMethodGeneric(CacheableStack::CreateDeserializable),
- nullptr);
+ nullptr, cache);
//as it is
Serializable::RegisterTypeGeneric(
GeodeClassIds::CacheableManagedObject - 0x80000000,
gcnew TypeFactoryMethodGeneric(CacheableObject::CreateDeserializable),
- nullptr);
+ nullptr, cache);
//as it is
Serializable::RegisterTypeGeneric(
GeodeClassIds::CacheableManagedObjectXml - 0x80000000,
gcnew TypeFactoryMethodGeneric(CacheableObjectXml::CreateDeserializable),
- nullptr);
+ nullptr, cache);
// End register other built-in types
@@ -675,11 +430,12 @@ namespace Apache
void DistributedSystem::AppDomainInstancePostInitialization()
{
+ // TODO global - Is this necessary?
//to create .net memory pressure handler
- Create(native::DistributedSystem::getInstance());
+ //Create(native::DistributedSystem::getInstance());
}
- void DistributedSystem::UnregisterBuiltinManagedTypes()
+ void DistributedSystem::UnregisterBuiltinManagedTypes(Cache^ cache)
{
_GF_MG_EXCEPTION_TRY2
@@ -694,27 +450,27 @@ namespace Apache
Serializable::UnregisterTypeGeneric(
- native::GeodeTypeIds::CacheableDate);
+ native::GeodeTypeIds::CacheableDate, cache);
Serializable::UnregisterTypeGeneric(
- native::GeodeTypeIds::CacheableFileName);
+ native::GeodeTypeIds::CacheableFileName, cache);
Serializable::UnregisterTypeGeneric(
- native::GeodeTypeIds::CacheableHashMap);
+ native::GeodeTypeIds::CacheableHashMap, cache);
Serializable::UnregisterTypeGeneric(
- native::GeodeTypeIds::CacheableHashTable);
+ native::GeodeTypeIds::CacheableHashTable, cache);
Serializable::UnregisterTypeGeneric(
- native::GeodeTypeIds::CacheableIdentityHashMap);
+ native::GeodeTypeIds::CacheableIdentityHashMap, cache);
Serializable::UnregisterTypeGeneric(
- native::GeodeTypeIds::CacheableVector);
+ native::GeodeTypeIds::CacheableVector, cache);
Serializable::UnregisterTypeGeneric(
- native::GeodeTypeIds::CacheableObjectArray);
+ native::GeodeTypeIds::CacheableObjectArray, cache);
Serializable::UnregisterTypeGeneric(
- native::GeodeTypeIds::CacheableArrayList);
+ native::GeodeTypeIds::CacheableArrayList, cache);
Serializable::UnregisterTypeGeneric(
- native::GeodeTypeIds::CacheableStack);
+ native::GeodeTypeIds::CacheableStack, cache);
Serializable::UnregisterTypeGeneric(
- GeodeClassIds::CacheableManagedObject - 0x80000000);
+ GeodeClassIds::CacheableManagedObject - 0x80000000, cache);
Serializable::UnregisterTypeGeneric(
- GeodeClassIds::CacheableManagedObjectXml - 0x80000000);
+ GeodeClassIds::CacheableManagedObjectXml - 0x80000000, cache);
}
@@ -730,7 +486,7 @@ namespace Apache
_GF_MG_EXCEPTION_TRY2
return Apache::Geode::Client::SystemProperties::Create(
- native::DistributedSystem::getSystemProperties());
+ &(m_nativeptr->get()->getSystemProperties()));
_GF_MG_EXCEPTION_CATCH_ALL2
}
@@ -739,50 +495,36 @@ namespace Apache
{
try
{
- return ManagedString::Get(m_nativeptr->get()->getName());
+ return ManagedString::Get(m_nativeptr->get()->getName().c_str());
}
finally
{
GC::KeepAlive(m_nativeptr);
}
}
-
- bool DistributedSystem::IsConnected::get()
- {
- return native::DistributedSystem::isConnected();
- }
-
- DistributedSystem^ DistributedSystem::GetInstance()
- {
- return Create(native::DistributedSystem::getInstance());
- }
-
+
void DistributedSystem::HandleMemoryPressure(System::Object^ state)
{
+ // TODO global - Need single memory pressue event running?
ACE_Time_Value dummy(1);
MemoryPressureHandler handler;
handler.handle_timeout(dummy, nullptr);
}
- DistributedSystem^ DistributedSystem::Create(native::DistributedSystemPtr nativeptr)
+ DistributedSystem^ DistributedSystem::Create(native::DistributedSystem* nativeptr)
{
- if (m_instance == nullptr) {
- msclr::lock lockInstance(m_singletonSync);
- if (m_instance == nullptr) {
- m_instance = __nullptr == nativeptr ? nullptr :
- gcnew DistributedSystem(nativeptr);
- }
- }
- auto instance = (DistributedSystem^)m_instance;
+ auto instance = gcnew DistributedSystem(nativeptr);
return instance;
}
+
+ DistributedSystem::DistributedSystem(std::unique_ptr<native::DistributedSystem> nativeptr)
+ {
+ m_nativeptr = gcnew native_conditional_unique_ptr<native::DistributedSystem>(std::move(nativeptr));
+ }
- DistributedSystem::DistributedSystem(native::DistributedSystemPtr nativeptr)
+ DistributedSystem::DistributedSystem(native::DistributedSystem* nativeptr)
{
- m_nativeptr = gcnew native_shared_ptr<native::DistributedSystem>(nativeptr);
- auto timerCallback = gcnew System::Threading::TimerCallback(&DistributedSystem::HandleMemoryPressure);
- m_memoryPressureHandler = gcnew System::Threading::Timer(
- timerCallback, "MemoryPressureHandler", 3 * 60000, 3 * 60000);
+ m_nativeptr = gcnew native_conditional_unique_ptr<native::DistributedSystem>(nativeptr);
}
DistributedSystem::~DistributedSystem()
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/DistributedSystem.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/DistributedSystem.hpp b/src/clicache/src/DistributedSystem.hpp
index 65e8be8..48c2723 100644
--- a/src/clicache/src/DistributedSystem.hpp
+++ b/src/clicache/src/DistributedSystem.hpp
@@ -22,7 +22,7 @@
#include <geode/DistributedSystem.hpp>
#include "end_native.hpp"
-#include "native_shared_ptr.hpp"
+#include "native_conditional_unique_ptr.hpp"
#include "SystemProperties.hpp"
#include "Properties.hpp"
#include "impl/CliCallbackDelgate.hpp"
@@ -64,7 +64,7 @@ namespace Apache
/// An application can have one only one connection to a DistributedSystem.
/// </exception>
/// <exception cref="UnknownException">otherwise</exception>
- static DistributedSystem^ Connect(String^ name);
+ DistributedSystem^ Connect(String^ name, Cache^ cache);
/// <summary>
/// Initializes the Native Client system to be able to connect to the
@@ -81,22 +81,22 @@ namespace Apache
/// An application can have one only one connection to a DistributedSystem.
/// </exception>
/// <exception cref="UnknownException">otherwise</exception>
- static DistributedSystem^ Connect(String^ name, Properties<String^, String^>^ config);
+ static DistributedSystem^ Connect(String^ name, Properties<String^, String^>^ config, Cache^ cache);
/// <summary>
/// Disconnect from the distributed system.
/// </summary>
/// <exception cref="IllegalStateException">if not connected</exception>
- static void Disconnect();
+ void Disconnect(Cache^ cache);
/// <summary>
/// Returns the SystemProperties used to create this instance of a
/// <c>DistributedSystem</c>.
/// </summary>
/// <returns>the SystemProperties</returns>
- static property Apache::Geode::Client::SystemProperties^ SystemProperties
+ property Apache::Geode::Client::SystemProperties^ SystemProperties
{
- static Apache::Geode::Client::SystemProperties^ get();
+ Apache::Geode::Client::SystemProperties^ get();
}
/// <summary>
@@ -108,21 +108,6 @@ namespace Apache
String^ get();
}
- /// <summary>
- /// The current connection status of this client to the <c>DistributedSystem</c>.
- /// </summary>
- /// <returns>true if connected, false otherwise</returns>
- static property bool IsConnected
- {
- static bool get();
- }
-
- /// <summary>
- /// Returns a reference to this DistributedSystem instance.
- /// </summary>
- /// <returns>the DistributedSystem instance</returns>
- static DistributedSystem^ GetInstance();
-
internal:
@@ -134,7 +119,9 @@ namespace Apache
/// <returns>
/// The managed wrapper object; null if the native pointer is null.
/// </returns>
- static DistributedSystem^ Create(native::DistributedSystemPtr nativeptr);
+ static DistributedSystem^ Create(native::DistributedSystem* nativeptr);
+
+ DistributedSystem(std::unique_ptr<native::DistributedSystem> nativeptr);
static void acquireDisconnectLock();
@@ -144,7 +131,7 @@ namespace Apache
static void connectInstance();
- delegate void cliCallback();
+ delegate void cliCallback(apache::geode::client::Cache& cache);
static void registerCliCallback();
@@ -152,14 +139,13 @@ namespace Apache
/// <summary>
/// Stuff that needs to be done for Connect in each AppDomain.
/// </summary>
- static void AppDomainInstanceInitialization(
- const native::PropertiesPtr& nativepropsptr);
+ static void AppDomainInstanceInitialization(Cache^ cache);
/// <summary>
/// Managed registrations and other stuff to be done for the manage
/// layer after the first connect.
/// </summary>
- static void ManagedPostConnect();
+ static void ManagedPostConnect(Cache^ cache);
/// <summary>
/// Stuff that needs to be done for Connect in each AppDomain but
@@ -170,11 +156,11 @@ namespace Apache
/// <summary>
/// Unregister the builtin managed types like CacheableObject.
/// </summary>
- static void UnregisterBuiltinManagedTypes();
+ static void UnregisterBuiltinManagedTypes(Cache^ cache);
- std::shared_ptr<native::DistributedSystem> GetNative()
+ native::DistributedSystem& GetNative()
{
- return m_nativeptr->get_shared_ptr();
+ return *(m_nativeptr->get());
}
private:
@@ -189,14 +175,14 @@ namespace Apache
/// Private constructor to wrap a native object pointer
/// </summary>
/// <param name="nativeptr">The native object pointer</param>
- DistributedSystem(native::DistributedSystemPtr nativeptr);
+ DistributedSystem(native::DistributedSystem* nativeptr);
/// <summary>
/// Finalizer for the singleton instance of this class.
/// </summary>
~DistributedSystem();
- native_shared_ptr<native::DistributedSystem>^ m_nativeptr;
+ native_conditional_unique_ptr<native::DistributedSystem>^ m_nativeptr;
/// <summary>
[14/27] geode-native git commit: GEODE-2729: Remove global variables
Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheImpl.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheImpl.cpp b/src/cppcache/src/CacheImpl.cpp
index 4995d60..a7c5157 100644
--- a/src/cppcache/src/CacheImpl.cpp
+++ b/src/cppcache/src/CacheImpl.cpp
@@ -14,56 +14,48 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-#include "CacheImpl.hpp"
#include <string>
+#include <string>
+
+#include <ace/OS.h>
#include <geode/CacheStatistics.hpp>
+#include <geode/PoolManager.hpp>
+#include <geode/SystemProperties.hpp>
+#include <geode/PoolManager.hpp>
+#include <geode/RegionAttributes.hpp>
+#include <geode/PersistenceManager.hpp>
+
+#include "CacheImpl.hpp"
#include "Utils.hpp"
#include "LocalRegion.hpp"
#include "ExpiryTaskManager.hpp"
-#include <geode/PersistenceManager.hpp>
#include "RegionExpiryHandler.hpp"
#include "TcrMessage.hpp"
#include "ThinClientRegion.hpp"
#include "ThinClientHARegion.hpp"
#include "ThinClientPoolRegion.hpp"
#include "ThinClientPoolDM.hpp"
-#include <geode/PoolManager.hpp>
-#include <geode/SystemProperties.hpp>
#include "Version.hpp"
#include "ClientProxyMembershipID.hpp"
#include "AutoDelete.hpp"
-#include <string>
-#include "ace/OS.h"
-#include <geode/PoolManager.hpp>
-#include <geode/RegionAttributes.hpp>
#include "ThinClientPoolHADM.hpp"
#include "InternalCacheTransactionManager2PCImpl.hpp"
#include "PdxTypeRegistry.hpp"
+#include "SerializationRegistry.hpp"
+#include "ThreadPool.hpp"
using namespace apache::geode::client;
-ExpiryTaskManager* CacheImpl::expiryTaskManager = nullptr;
-CacheImpl* CacheImpl::s_instance = nullptr;
-volatile bool CacheImpl::s_networkhop = false;
-volatile int CacheImpl::s_blacklistBucketTimeout = 0;
-ACE_Recursive_Thread_Mutex CacheImpl::s_nwHopLock;
-volatile int8_t CacheImpl::s_serverGroupFlag = 0;
-
-#define DEFAULT_LRU_MAXIMUM_ENTRIES 100000
-
-ExpiryTaskManager* getCacheImplExpiryTaskManager() {
- return CacheImpl::expiryTaskManager;
-}
-
-CacheImpl::CacheImpl(Cache* c, const char* name, DistributedSystemPtr sys,
- const char* id_data, bool iPUF, bool readPdxSerialized)
- : m_defaultPool(nullptr),
+CacheImpl::CacheImpl(Cache* c, const std::string& name,
+ std::unique_ptr<DistributedSystem> sys, bool iPUF,
+ bool readPdxSerialized)
+ : m_name(name),
+ m_defaultPool(nullptr),
m_ignorePdxUnreadFields(iPUF),
m_readPdxSerialized(readPdxSerialized),
m_closed(false),
m_initialized(false),
- m_distributedSystem(sys),
+ m_distributedSystem(std::move(sys)),
m_implementee(c),
m_cond(m_mutex),
m_attributes(nullptr),
@@ -72,88 +64,42 @@ CacheImpl::CacheImpl(Cache* c, const char* name, DistributedSystemPtr sys,
m_remoteQueryServicePtr(nullptr),
m_destroyPending(false),
m_initDone(false),
- m_adminRegion(nullptr) {
+ m_adminRegion(nullptr),
+ m_memberListForVersionStamp(
+ *(std::make_shared<MemberListForVersionStamp>())),
+ m_serializationRegistry(std::make_shared<SerializationRegistry>()),
+ m_pdxTypeRegistry(std::make_shared<PdxTypeRegistry>(c)),
+ m_expiryTaskManager(
+ std::unique_ptr<ExpiryTaskManager>(new ExpiryTaskManager())),
+ m_clientProxyMembershipIDFactory(m_distributedSystem->getName()),
+ m_threadPool(new ThreadPool(
+ m_distributedSystem->getSystemProperties().threadPoolSize())) {
m_cacheTXManager = InternalCacheTransactionManager2PCPtr(
new InternalCacheTransactionManager2PCImpl(c));
- m_name = Utils::copyString(name);
-
- if (!DistributedSystem::isConnected()) {
- throw IllegalArgumentException("DistributedSystem is not up");
- }
m_regions = new MapOfRegionWithLock();
- SystemProperties* prop = DistributedSystem::getSystemProperties();
- if (prop && prop->heapLRULimitEnabled()) {
- m_evictionControllerPtr = new EvictionController(
- prop->heapLRULimit(), prop->heapLRUDelta(), this);
+ auto& prop = m_distributedSystem->getSystemProperties();
+ if (prop.heapLRULimitEnabled()) {
+ m_evictionControllerPtr =
+ new EvictionController(prop.heapLRULimit(), prop.heapLRUDelta(), this);
m_evictionControllerPtr->start();
LOGINFO("Heap LRU eviction controller thread started");
}
- /*
- else {
- LOGFINE("Eviction controller is nullptr");
- }
- */
- ClientProxyMembershipID::init(sys->getName());
+ m_cacheStats = new CachePerfStats(m_distributedSystem.get()
+ ->getStatisticsManager()
+ ->getStatisticsFactory());
+ m_expiryTaskManager->begin();
- m_cacheStats = new CachePerfStats;
-
- s_instance = this;
m_initialized = true;
-}
-CacheImpl::CacheImpl(Cache* c, const char* name, DistributedSystemPtr sys,
- bool iPUF, bool readPdxSerialized)
- : m_defaultPool(nullptr),
- m_ignorePdxUnreadFields(iPUF),
- m_readPdxSerialized(readPdxSerialized),
- m_closed(false),
- m_initialized(false),
- m_distributedSystem(sys),
- m_implementee(c),
- m_cond(m_mutex),
- m_attributes(nullptr),
- m_evictionControllerPtr(nullptr),
- m_tcrConnectionManager(nullptr),
- m_remoteQueryServicePtr(nullptr),
- m_destroyPending(false),
- m_initDone(false),
- m_adminRegion(nullptr) {
- m_cacheTXManager = InternalCacheTransactionManager2PCPtr(
- new InternalCacheTransactionManager2PCImpl(c));
-
- m_name = Utils::copyString(name);
- if (!DistributedSystem::isConnected()) {
- throw IllegalArgumentException("DistributedSystem is not connected");
- }
- m_regions = new MapOfRegionWithLock();
- SystemProperties* prop = DistributedSystem::getSystemProperties();
- if (prop && prop->heapLRULimitEnabled()) {
- m_evictionControllerPtr = new EvictionController(
- prop->heapLRULimit(), prop->heapLRUDelta(), this);
- m_evictionControllerPtr->start();
- LOGINFO("Heap LRU eviction controller thread started");
- }
- /*
- else {
- LOGFINE("Eviction controller is nullptr");
- }
- */
-
- ClientProxyMembershipID::init(sys->getName());
-
- m_cacheStats = new CachePerfStats;
-
- s_instance = this;
- m_initialized = true;
+ m_poolManager = std::unique_ptr<PoolManager>(new PoolManager(*m_implementee));
}
void CacheImpl::initServices() {
m_tcrConnectionManager = new TcrConnectionManager(this);
- PdxTypeRegistry::init();
if (!m_initDone && m_attributes != nullptr && m_attributes->getEndpoints()) {
- if (PoolManager::getAll().size() > 0 && getCacheMode()) {
+ if (getCache()->getPoolManager().getAll().size() > 0 && getCacheMode()) {
LOGWARN(
"At least one pool has been created so ignoring cache level "
"redundancy setting");
@@ -161,37 +107,18 @@ void CacheImpl::initServices() {
m_tcrConnectionManager->init();
m_remoteQueryServicePtr = std::make_shared<RemoteQueryService>(this);
// StartAdminRegion
- SystemProperties* prop = DistributedSystem::getSystemProperties();
- if (prop && prop->statisticsEnabled()) {
+ auto& prop = m_distributedSystem->getSystemProperties();
+ if (prop.statisticsEnabled()) {
m_adminRegion = AdminRegion::create(this);
}
m_initDone = true;
}
}
-int CacheImpl::blackListBucketTimeouts() { return s_blacklistBucketTimeout; }
-
-void CacheImpl::setBlackListBucketTimeouts() { s_blacklistBucketTimeout += 1; }
-
-bool CacheImpl::getAndResetNetworkHopFlag() {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _lock(s_nwHopLock);
- bool networkhop = CacheImpl::s_networkhop;
- CacheImpl::s_networkhop = false;
- // This log should only appear in tests
- LOGDEBUG("networkhop flag = %d", networkhop);
- return networkhop;
-}
-
-int8_t CacheImpl::getAndResetServerGroupFlag() {
- int8_t serverGroupFlag = CacheImpl::s_serverGroupFlag;
- CacheImpl::s_serverGroupFlag = 0;
- return serverGroupFlag;
-}
-
void CacheImpl::netDown() {
m_tcrConnectionManager->netDown();
- for (const auto& itr : PoolManager::getAll()) {
+ for (const auto& itr : getCache()->getPoolManager().getAll()) {
auto currPool = itr.second;
if (auto poolHADM =
std::dynamic_pointer_cast<ThinClientPoolHADM>(currPool)) {
@@ -223,7 +150,7 @@ CacheImpl::RegionKind CacheImpl::getRegionKind(
regionKind = THINCLIENT_REGION;
}
} else if (rattrs->getPoolName()) {
- PoolPtr pPtr = PoolManager::find(rattrs->getPoolName());
+ PoolPtr pPtr = getCache()->getPoolManager().find(rattrs->getPoolName());
if ((pPtr != nullptr && (pPtr->getSubscriptionRedundancy() > 0 ||
pPtr->getSubscriptionEnabled())) ||
m_tcrConnectionManager->isDurable()) {
@@ -269,7 +196,7 @@ QueryServicePtr CacheImpl::getQueryService(const char* poolName) {
if (poolName == nullptr || strlen(poolName) == 0) {
throw IllegalArgumentException("PoolName is nullptr or not defined..");
}
- PoolPtr pool = PoolManager::find(poolName);
+ PoolPtr pool = getCache()->getPoolManager().find(poolName);
if (pool != nullptr) {
if (pool->isDestroyed()) {
@@ -289,13 +216,9 @@ CacheImpl::~CacheImpl() {
if (m_regions != nullptr) {
delete m_regions;
}
-
- if (m_name != nullptr) {
- delete[] m_name;
- }
}
-const char* CacheImpl::getName() const {
+const std::string& CacheImpl::getName() const {
if (m_closed || m_destroyPending) {
throw CacheClosedException("Cache::getName: cache closed");
}
@@ -310,15 +233,12 @@ void CacheImpl::setAttributes(const CacheAttributesPtr& attrs) {
}
}
-void CacheImpl::getDistributedSystem(DistributedSystemPtr& dptr) const {
- if (m_closed || m_destroyPending) {
- throw CacheClosedException("Cache::getDistributedSystem: cache closed");
- }
- dptr = m_distributedSystem;
+DistributedSystem& CacheImpl::getDistributedSystem() const {
+ return *m_distributedSystem;
}
void CacheImpl::sendNotificationCloseMsgs() {
- for (const auto& iter : PoolManager::getAll()) {
+ for (const auto& iter : getPoolManager().getAll()) {
if (const auto& pool =
std::dynamic_pointer_cast<ThinClientPoolHADM>(iter.second)) {
pool->sendNotificationCloseMsgs();
@@ -387,11 +307,10 @@ void CacheImpl::close(bool keepalive) {
m_cacheStats->close();
}
- PoolManager::close(keepalive);
+ m_poolManager->close(keepalive);
LOGFINE("Closed pool manager with keepalive %s",
keepalive ? "true" : "false");
- PdxTypeRegistry::cleanup();
// Close CachePef Stats
if (m_cacheStats) {
@@ -403,6 +322,9 @@ void CacheImpl::close(bool keepalive) {
GF_SAFE_DELETE(m_tcrConnectionManager);
m_cacheTXManager = nullptr;
+
+ m_expiryTaskManager->stopExpiryTaskManager();
+
m_closed = true;
LOGFINE("Cache closed.");
@@ -410,10 +332,6 @@ void CacheImpl::close(bool keepalive) {
bool CacheImpl::isCacheDestroyPending() const { return m_destroyPending; }
-void CacheImpl::setDefaultPool(PoolPtr pool) { m_defaultPool = pool; }
-
-PoolPtr CacheImpl::getDefaultPool() { return m_defaultPool; }
-
void CacheImpl::validateRegionAttributes(
const char* name, const RegionAttributesPtr& attrs) const {
RegionKind kind = getRegionKind(attrs);
@@ -440,8 +358,8 @@ void CacheImpl::createRegion(const char* name,
if (!(aRegionAttributes->getPoolName())) {
m_tcrConnectionManager->init();
m_remoteQueryServicePtr = std::make_shared<RemoteQueryService>(this);
- SystemProperties* prop = DistributedSystem::getSystemProperties();
- if (prop && prop->statisticsEnabled()) {
+ auto& prop = m_distributedSystem->getSystemProperties();
+ if (prop.statisticsEnabled()) {
m_adminRegion = AdminRegion::create(this);
}
}
@@ -535,11 +453,11 @@ void CacheImpl::createRegion(const char* name,
// When region is created, added that region name in client meta data
// service to fetch its
// metadata for single hop.
- SystemProperties* props = DistributedSystem::getSystemProperties();
- if (!props->isGridClient()) {
+ auto& props = m_distributedSystem->getSystemProperties();
+ if (!props.isGridClient()) {
const char* poolName = aRegionAttributes->getPoolName();
if (poolName != nullptr) {
- PoolPtr pool = PoolManager::find(poolName);
+ PoolPtr pool = getCache()->getPoolManager().find(poolName);
if (pool != nullptr && !pool->isDestroyed() &&
pool->getPRSingleHopEnabled()) {
ThinClientPoolDM* poolDM =
@@ -644,7 +562,7 @@ std::shared_ptr<RegionInternal> CacheImpl::createRegion_internal(
}*/
if (poolName != nullptr) {
- PoolPtr pool = PoolManager::find(poolName);
+ PoolPtr pool = getCache()->getPoolManager().find(poolName);
if (pool != nullptr && !pool->isDestroyed()) {
bool isMultiUserSecureMode = pool->getMultiuserAuthentication();
if (isMultiUserSecureMode && (attrs->getCachingEnabled())) {
@@ -718,7 +636,7 @@ EvictionController* CacheImpl::getEvictionController() {
void CacheImpl::readyForEvents() {
bool autoReadyForEvents =
- DistributedSystem::getSystemProperties()->autoReadyForEvents();
+ m_distributedSystem->getSystemProperties().autoReadyForEvents();
bool isDurable = m_tcrConnectionManager->isDurable();
if (!isDurable && autoReadyForEvents) {
@@ -738,7 +656,7 @@ void CacheImpl::readyForEvents() {
return;
}
- const auto& pools = PoolManager::getAll();
+ const auto& pools = getCache()->getPoolManager().getAll();
if (pools.empty()) throw IllegalStateException("No pools found.");
for (const auto& itr : pools) {
const auto& currPool = itr.second;
@@ -756,7 +674,7 @@ void CacheImpl::readyForEvents() {
}
bool CacheImpl::getEndpointStatus(const std::string& endpoint) {
- const auto& pools = PoolManager::getAll();
+ const auto& pools = getCache()->getPoolManager().getAll();
std::string fullName = endpoint;
if (pools.empty()) {
@@ -792,7 +710,8 @@ void CacheImpl::processMarker() {
if (!q.int_id_->isDestroyed()) {
if (const auto tcrHARegion =
std::dynamic_pointer_cast<ThinClientHARegion>(q.int_id_)) {
- auto regionMsg = new TcrMessageClientMarker(true);
+ auto regionMsg = new TcrMessageClientMarker(
+ this->getCache()->createDataOutput(), true);
tcrHARegion->receiveNotification(regionMsg);
VectorOfRegion subregions;
tcrHARegion->subregions(true, subregions);
@@ -800,7 +719,8 @@ void CacheImpl::processMarker() {
if (!iter->isDestroyed()) {
if (const auto subregion =
std::dynamic_pointer_cast<ThinClientHARegion>(iter)) {
- regionMsg = new TcrMessageClientMarker(true);
+ regionMsg = new TcrMessageClientMarker(
+ this->getCache()->createDataOutput(), true);
subregion->receiveNotification(regionMsg);
}
}
@@ -811,7 +731,7 @@ void CacheImpl::processMarker() {
}
int CacheImpl::getPoolSize(const char* poolName) {
- if (const auto pool = PoolManager::find(poolName)) {
+ if (const auto pool = getCache()->getPoolManager().find(poolName)) {
if (const auto dm = std::dynamic_pointer_cast<ThinClientPoolDM>(pool)) {
return dm->m_poolSize;
}
@@ -821,28 +741,7 @@ int CacheImpl::getPoolSize(const char* poolName) {
RegionFactoryPtr CacheImpl::createRegionFactory(
RegionShortcut preDefinedRegion) {
- return std::make_shared<RegionFactory>(preDefinedRegion);
-}
-
-void CacheImpl::setRegionShortcut(AttributesFactoryPtr attrFact,
- RegionShortcut preDefinedRegionAttr) {
- switch (preDefinedRegionAttr) {
- case PROXY: {
- attrFact->setCachingEnabled(false);
- } break;
- case CACHING_PROXY: {
- attrFact->setCachingEnabled(true);
- } break;
- case CACHING_PROXY_ENTRY_LRU: {
- attrFact->setCachingEnabled(true);
- attrFact->setLruEntriesLimit(DEFAULT_LRU_MAXIMUM_ENTRIES);
- } break;
- case LOCAL: {
- } break;
- case LOCAL_ENTRY_LRU: {
- attrFact->setLruEntriesLimit(DEFAULT_LRU_MAXIMUM_ENTRIES);
- } break;
- }
+ return std::make_shared<RegionFactory>(preDefinedRegion, this);
}
std::map<std::string, RegionAttributesPtr> CacheImpl::getRegionShortcut() {
@@ -886,6 +785,16 @@ std::map<std::string, RegionAttributesPtr> CacheImpl::getRegionShortcut() {
return preDefined;
}
+PdxTypeRegistryPtr CacheImpl::getPdxTypeRegistry() const {
+ return m_pdxTypeRegistry;
+}
+
+SerializationRegistryPtr CacheImpl::getSerializationRegistry() const {
+ return m_serializationRegistry;
+}
+
+ThreadPool* CacheImpl::getThreadPool() { return m_threadPool; }
+
CacheTransactionManagerPtr CacheImpl::getCacheTransactionManager() {
return m_cacheTXManager;
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheImpl.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheImpl.hpp b/src/cppcache/src/CacheImpl.hpp
index 6de340e..e6da435 100644
--- a/src/cppcache/src/CacheImpl.hpp
+++ b/src/cppcache/src/CacheImpl.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_CACHEIMPL_H_
-#define GEODE_CACHEIMPL_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,6 +15,13 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_CACHEIMPL_H_
+#define GEODE_CACHEIMPL_H_
+
+#include <atomic>
+
#include <geode/geode_globals.hpp>
#include <memory>
@@ -28,7 +30,6 @@
#include <geode/DistributedSystem.hpp>
#include "MapWithLock.hpp"
#include <ace/ACE.h>
-#include <ace/Condition_Recursive_Thread_Mutex.h>
#include <ace/Time_Value.h>
#include <ace/Guard_T.h>
#include <ace/Recursive_Thread_Mutex.h>
@@ -40,13 +41,14 @@
#include "CachePerfStats.hpp"
#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... */
@@ -58,14 +60,18 @@ namespace apache {
namespace geode {
namespace client {
+class ThreadPool;
class CacheFactory;
class ExpiryTaskManager;
+class PdxTypeRegistry;
+class SerializationRegistry;
+typedef std::shared_ptr<SerializationRegistry> SerializationRegistryPtr;
/**
* @class Cache Cache.hpp
* Geode's implementation of a distributed C++ Cache.
*
- * Caches are obtained from static methods on the {@link CacheFactory} class.
+ * Caches are obtained from methods on the {@link CacheFactory} class.
* <p>
* When a cache is created a {@link DistributedSystem} must be specified.
* This system tells the cache where to find other caches on the network
@@ -92,26 +98,28 @@ class CPPCACHE_EXPORT CacheImpl : private NonCopyable, private NonAssignable {
void setClientCrashTEST() { m_tcrConnectionManager->setClientCrashTEST(); }
// For PrSingleHop C++unit testing.
- static ACE_Recursive_Thread_Mutex s_nwHopLock;
- static void setNetworkHopFlag(bool networkhopflag) {
- ACE_Guard<ACE_Recursive_Thread_Mutex> _lock(s_nwHopLock);
- CacheImpl::s_networkhop = networkhopflag;
- }
- static bool getAndResetNetworkHopFlag();
+ void setNetworkHopFlag(bool networkhopflag) {
+ m_networkhop = networkhopflag;
+ };
+
+ bool getAndResetNetworkHopFlag() { return m_networkhop.exchange(false); }
+
+ int getBlackListBucketTimeouts() { return m_blacklistBucketTimeout; }
+
+ void incBlackListBucketTimeouts() { ++m_blacklistBucketTimeout; }
- static int blackListBucketTimeouts();
- static void setBlackListBucketTimeouts();
+ int8_t getAndResetServerGroupFlag() { return m_serverGroupFlag.exchange(0); }
- static void setServerGroupFlag(int8_t serverGroupFlag) {
- CacheImpl::s_serverGroupFlag = serverGroupFlag;
+ void setServerGroupFlag(int8_t serverGroupFlag) {
+ m_serverGroupFlag = serverGroupFlag;
}
- static int8_t getAndResetServerGroupFlag();
- static MemberListForVersionStampPtr getMemberListForVersionStamp();
+
+ MemberListForVersionStampPtr getMemberListForVersionStamp();
/** Returns the name of this cache.
* @return the string name of this cache
*/
- const char* getName() const;
+ const std::string& getName() const;
/**
* Indicates if this cache has been closed.
@@ -133,7 +141,7 @@ class CPPCACHE_EXPORT CacheImpl : private NonCopyable, private NonAssignable {
* Returns the distributed system that this cache was
* {@link CacheFactory::create created} with.
*/
- void getDistributedSystem(DistributedSystemPtr& dptr) const;
+ DistributedSystem& getDistributedSystem() const;
/**
* Terminates this object cache and releases all the local resources.
@@ -206,15 +214,19 @@ class CPPCACHE_EXPORT CacheImpl : private NonCopyable, private NonAssignable {
/**
* @brief constructors
*/
- CacheImpl(Cache* c, const char* name, DistributedSystemPtr sys,
- bool ignorePdxUnreadFields, bool readPdxSerialized);
- CacheImpl(Cache* c, const char* name, DistributedSystemPtr sys,
- const char* id_data, bool ignorePdxUnreadFields,
+ CacheImpl(Cache* c, const std::string& name,
+ std::unique_ptr<DistributedSystem> sys, bool ignorePdxUnreadFields,
bool readPdxSerialized);
+
void initServices();
EvictionController* getEvictionController();
- static ExpiryTaskManager* expiryTaskManager;
+ ExpiryTaskManager& getExpiryTaskManager() { return *m_expiryTaskManager; }
+
+ ClientProxyMembershipIDFactory& getClientProxyMembershipIDFactory() {
+ return m_clientProxyMembershipIDFactory;
+ }
+
Cache* getCache() const { return m_implementee; }
TcrConnectionManager& tcrConnectionManager() {
return *m_tcrConnectionManager;
@@ -243,12 +255,7 @@ class CPPCACHE_EXPORT CacheImpl : private NonCopyable, private NonAssignable {
void processMarker();
// Pool helpers for unit tests
- static int getPoolSize(const char* poolName);
-
- // CachePerfStats
- CachePerfStats* m_cacheStats;
-
- static inline CacheImpl* getInstance() { return s_instance; };
+ int getPoolSize(const char* poolName);
bool getCacheMode() {
return m_attributes == nullptr ? false : m_attributes->m_cacheMode;
@@ -264,22 +271,30 @@ class CPPCACHE_EXPORT CacheImpl : private NonCopyable, private NonAssignable {
bool getPdxReadSerialized() { return m_readPdxSerialized; }
bool isCacheDestroyPending() const;
- void setDefaultPool(PoolPtr pool);
+ static std::map<std::string, RegionAttributesPtr> getRegionShortcut();
- PoolPtr getDefaultPool();
+ PdxTypeRegistryPtr getPdxTypeRegistry() const;
- static void setRegionShortcut(AttributesFactoryPtr attrFact,
- RegionShortcut preDefinedRegionAttr);
+ SerializationRegistryPtr getSerializationRegistry() const;
+ inline CachePerfStats& getCachePerfStats() { return *m_cacheStats; };
- static std::map<std::string, RegionAttributesPtr> getRegionShortcut();
+ PoolManager& getPoolManager() { return *m_poolManager; }
+
+ ThreadPool* getThreadPool();
private:
- static volatile bool s_networkhop;
- static volatile int s_blacklistBucketTimeout;
- static volatile int8_t s_serverGroupFlag;
+ std::atomic<bool> m_networkhop;
+ std::atomic<int> m_blacklistBucketTimeout;
+ std::atomic<int8_t> m_serverGroupFlag;
PoolPtr m_defaultPool;
bool m_ignorePdxUnreadFields;
bool m_readPdxSerialized;
+ std::unique_ptr<ExpiryTaskManager> m_expiryTaskManager;
+
+ // CachePerfStats
+ CachePerfStats* m_cacheStats;
+
+ std::unique_ptr<PoolManager> m_poolManager;
enum RegionKind {
CPP_REGION,
@@ -303,11 +318,12 @@ class CPPCACHE_EXPORT CacheImpl : private NonCopyable, private NonAssignable {
srm.bind((*p).ext_id_, (*p).int_id_);
}
}
- char* m_name;
+ std::string m_name;
bool m_closed;
bool m_initialized;
- DistributedSystemPtr m_distributedSystem;
+ std::unique_ptr<DistributedSystem> m_distributedSystem;
+ ClientProxyMembershipIDFactory m_clientProxyMembershipIDFactory;
MapOfRegionWithLock* m_regions;
Cache* m_implementee;
ACE_Recursive_Thread_Mutex m_mutex;
@@ -319,11 +335,15 @@ class CPPCACHE_EXPORT CacheImpl : private NonCopyable, private NonAssignable {
ACE_RW_Thread_Mutex m_destroyCacheMutex;
volatile bool m_destroyPending;
volatile bool m_initDone;
- static CacheImpl* s_instance;
ACE_Thread_Mutex m_initDoneLock;
AdminRegionPtr m_adminRegion;
CacheTransactionManagerPtr m_cacheTXManager;
+ MemberListForVersionStamp& m_memberListForVersionStamp;
+ SerializationRegistryPtr m_serializationRegistry;
+ PdxTypeRegistryPtr m_pdxTypeRegistry;
+ ThreadPool* m_threadPool;
+
friend class CacheFactory;
friend class Cache;
};
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CachePerfStats.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CachePerfStats.hpp b/src/cppcache/src/CachePerfStats.hpp
index adfda8b..e22d5cd 100644
--- a/src/cppcache/src/CachePerfStats.hpp
+++ b/src/cppcache/src/CachePerfStats.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_CACHEPERFSTATS_H_
-#define GEODE_CACHEPERFSTATS_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,10 +15,17 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_CACHEPERFSTATS_H_
+#define GEODE_CACHEPERFSTATS_H_
+
#include <geode/geode_globals.hpp>
#include <geode/statistics/Statistics.hpp>
#include <geode/statistics/StatisticsFactory.hpp>
+#include "statistics/StatisticsManager.hpp"
+
namespace apache {
namespace geode {
namespace client {
@@ -33,11 +35,8 @@ using namespace apache::geode::statistics;
/** hold statistics for cache.. */
class CPPCACHE_EXPORT CachePerfStats {
public:
- CachePerfStats() {
- StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
- GF_D_ASSERT(!!factory);
-
- StatisticsType* statsType = factory->findType("CachePerfStats");
+ CachePerfStats(StatisticsFactory* factory) {
+ auto statsType = factory->findType("CachePerfStats");
if (statsType == nullptr) {
const bool largerIsBetter = true;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheRegionHelper.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheRegionHelper.cpp b/src/cppcache/src/CacheRegionHelper.cpp
new file mode 100644
index 0000000..a685d11
--- /dev/null
+++ b/src/cppcache/src/CacheRegionHelper.cpp
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
+#include "ProxyCache.hpp"
+
+namespace apache {
+namespace geode {
+namespace client {
+
+CacheImpl* CacheRegionHelper::getCacheImpl(const Cache* cache) {
+ return cache->m_cacheImpl.get();
+}
+
+CacheImpl* CacheRegionHelper::getCacheImpl(const ProxyCache* proxyCache) {
+ return proxyCache->m_cacheImpl;
+}
+
+CacheImpl* CacheRegionHelper::getCacheImpl(const RegionService* regionService) {
+ if (const auto proxyCache = dynamic_cast<const ProxyCache*>(regionService)) {
+ return getCacheImpl(proxyCache);
+ }
+
+ if (const auto cache = dynamic_cast<const Cache*>(regionService)) {
+ return getCacheImpl(cache);
+ }
+
+ return nullptr;
+}
+
+} // namespace client
+} // namespace geode
+} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheRegionHelper.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheRegionHelper.hpp b/src/cppcache/src/CacheRegionHelper.hpp
index 7e26e1a..a101060 100644
--- a/src/cppcache/src/CacheRegionHelper.hpp
+++ b/src/cppcache/src/CacheRegionHelper.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_CACHEREGIONHELPER_H_
-#define GEODE_CACHEREGIONHELPER_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,32 +15,30 @@
* limitations under the License.
*/
-/**
- * @file
- */
+#pragma once
+
+#ifndef GEODE_CACHEREGIONHELPER_H_
+#define GEODE_CACHEREGIONHELPER_H_
+
#include <geode/geode_globals.hpp>
-#include <geode/Region.hpp>
#include <geode/Cache.hpp>
-#include "CacheImpl.hpp"
-#include <geode/DistributedSystem.hpp>
namespace apache {
namespace geode {
namespace client {
-class CacheRegionHelper {
+class CacheImpl;
+class ProxyCache;
+
+class CPPCACHE_EXPORT CacheRegionHelper {
/**
* CacheHelper
*
*/
public:
- inline static CacheImpl* getCacheImpl(const Cache* cache) {
- return cache->m_cacheImpl.get();
- }
-
- inline static DistributedSystemImpl* getDistributedSystemImpl() {
- return DistributedSystem::m_impl;
- }
+ static CacheImpl* getCacheImpl(const Cache* cache);
+ static CacheImpl* getCacheImpl(const ProxyCache* cache);
+ static CacheImpl* getCacheImpl(const RegionService* cache);
};
} // namespace client
} // namespace geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheTransactionManagerImpl.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheTransactionManagerImpl.cpp b/src/cppcache/src/CacheTransactionManagerImpl.cpp
index b5c633d..4a795e6 100644
--- a/src/cppcache/src/CacheTransactionManagerImpl.cpp
+++ b/src/cppcache/src/CacheTransactionManagerImpl.cpp
@@ -25,13 +25,15 @@
#include "CacheTransactionManagerImpl.hpp"
#include <geode/TransactionId.hpp>
#include <geode/ExceptionTypes.hpp>
+#include <geode/PoolManager.hpp>
+
#include "TSSTXStateWrapper.hpp"
#include "TcrMessage.hpp"
#include "ThinClientBaseDM.hpp"
#include "ThinClientPoolDM.hpp"
#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
#include "TssConnectionWrapper.hpp"
-#include <geode/PoolManager.hpp>
#include "TXCleaner.hpp"
namespace apache {
@@ -63,7 +65,7 @@ void CacheTransactionManagerImpl::commit() {
GF_CACHE_ILLEGAL_STATE_EXCEPTION);
}
- TcrMessageCommit request;
+ TcrMessageCommit request(m_cache->createDataOutput());
TcrMessageReply reply(true, nullptr);
ThinClientPoolDM* tcr_dm = getDM();
@@ -112,8 +114,7 @@ void CacheTransactionManagerImpl::commit() {
}
TXCommitMessagePtr commit =
- std::static_pointer_cast<TXCommitMessage>(
- reply.getValue());
+ std::static_pointer_cast<TXCommitMessage>(reply.getValue());
txCleaner.clean();
commit->apply(m_cache);
@@ -277,7 +278,7 @@ void CacheTransactionManagerImpl::rollback() {
GfErrType CacheTransactionManagerImpl::rollback(TXState* txState,
bool callListener) {
- TcrMessageRollback request;
+ TcrMessageRollback request(m_cache->createDataOutput());
TcrMessageReply reply(true, nullptr);
GfErrType err = GF_NOERR;
ThinClientPoolDM* tcr_dm = getDM();
@@ -360,11 +361,13 @@ TransactionIdPtr CacheTransactionManagerImpl::suspend() {
txState->releaseStickyConnection();
// set the expiry handler for the suspended transaction
- SystemProperties* sysProp = DistributedSystem::getSystemProperties();
+ auto& sysProp = m_cache->getDistributedSystem().getSystemProperties();
SuspendedTxExpiryHandler* handler = new SuspendedTxExpiryHandler(
- this, txState->getTransactionId(), sysProp->suspendedTxTimeout());
- long id = CacheImpl::expiryTaskManager->scheduleExpiryTask(
- handler, sysProp->suspendedTxTimeout() * 60, 0, false);
+ this, txState->getTransactionId(), sysProp.suspendedTxTimeout());
+ long id = CacheRegionHelper::getCacheImpl(m_cache)
+ ->getExpiryTaskManager()
+ .scheduleExpiryTask(handler, sysProp.suspendedTxTimeout() * 60,
+ 0, false);
txState->setSuspendedExpiryTaskId(id);
// add the transaction state to the list of suspended transactions
@@ -451,11 +454,11 @@ void CacheTransactionManagerImpl::resumeTxUsingTxState(TXState* txState,
if (cancelExpiryTask) {
// cancel the expiry task for the transaction
- CacheImpl::expiryTaskManager->cancelTask(
+ CacheRegionHelper::getCacheImpl(m_cache)->getExpiryTaskManager().cancelTask(
txState->getSuspendedExpiryTaskId());
} else {
- CacheImpl::expiryTaskManager->resetTask(txState->getSuspendedExpiryTaskId(),
- 0);
+ CacheRegionHelper::getCacheImpl(m_cache)->getExpiryTaskManager().resetTask(
+ txState->getSuspendedExpiryTaskId(), 0);
}
// set the current state as the state of the suspended transaction
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheTransactionManagerImpl.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheTransactionManagerImpl.hpp b/src/cppcache/src/CacheTransactionManagerImpl.hpp
index a3b220c..e0b8cb4 100644
--- a/src/cppcache/src/CacheTransactionManagerImpl.hpp
+++ b/src/cppcache/src/CacheTransactionManagerImpl.hpp
@@ -60,14 +60,6 @@ class CacheTransactionManagerImpl
virtual TransactionIdPtr getTransactionId();
-
-// inline static int32_t hasher(const SharedBasePtr& p) {
-// return static_cast<int32_t>(reinterpret_cast<intptr_t>(p.get()));
-// }
-//
-// inline static bool equal_to(const SharedBasePtr& x, const SharedBasePtr& y) {
-// return x.get() == y.get();
-// }
TXState* getSuspendedTx(int32_t txId);
protected:
@@ -86,6 +78,7 @@ class CacheTransactionManagerImpl
void addTx(int32_t txId);
bool removeTx(int32_t txId);
bool findTx(int32_t txId);
+
std::map<int32_t, TXState*> m_suspendedTXs;
ACE_Recursive_Thread_Mutex m_suspendedTxLock;
std::vector<int32_t> m_TXs;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheXmlCreation.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheXmlCreation.cpp b/src/cppcache/src/CacheXmlCreation.cpp
index c140d24..541bcf8 100644
--- a/src/cppcache/src/CacheXmlCreation.cpp
+++ b/src/cppcache/src/CacheXmlCreation.cpp
@@ -22,11 +22,13 @@
using namespace apache::geode::client;
-void CacheXmlCreation::addRootRegion(RegionXmlCreation* root) {
+void CacheXmlCreation::addRootRegion(std::shared_ptr<RegionXmlCreation> root) {
rootRegions.push_back(root);
}
-void CacheXmlCreation::addPool(PoolXmlCreation* pool) { pools.push_back(pool); }
+void CacheXmlCreation::addPool(std::shared_ptr<PoolXmlCreation> pool) {
+ pools.push_back(pool);
+}
void CacheXmlCreation::create(Cache* cache) {
m_cache = cache;
@@ -34,16 +36,12 @@ void CacheXmlCreation::create(Cache* cache) {
m_cache->m_cacheImpl->setPdxReadSerialized(m_readPdxSerialized);
// Create any pools before creating any regions.
- std::vector<PoolXmlCreation*>::iterator pool = pools.begin();
- while (pool != pools.end()) {
- (*pool)->create();
- ++pool;
+ for (const auto& pool : pools) {
+ pool->create(*m_cache);
}
- std::vector<RegionXmlCreation*>::iterator start = rootRegions.begin();
- while (start != rootRegions.end()) {
- (*start)->createRoot(cache);
- ++start;
+ for (const auto& rootRegion : rootRegions) {
+ rootRegion->createRoot(cache);
}
}
@@ -63,18 +61,3 @@ CacheXmlCreation::CacheXmlCreation()
m_pdxIgnoreUnreadFields = false;
m_readPdxSerialized = false;
}
-
-CacheXmlCreation::~CacheXmlCreation() {
- std::vector<RegionXmlCreation*>::iterator start = rootRegions.begin();
- while (start != rootRegions.end()) {
- delete *start;
- *start = nullptr;
- ++start;
- }
- std::vector<PoolXmlCreation*>::iterator pool = pools.begin();
- while (pool != pools.end()) {
- delete *pool;
- *pool = nullptr;
- ++pool;
- }
-}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheXmlCreation.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheXmlCreation.hpp b/src/cppcache/src/CacheXmlCreation.hpp
index ed1813a..754674c 100644
--- a/src/cppcache/src/CacheXmlCreation.hpp
+++ b/src/cppcache/src/CacheXmlCreation.hpp
@@ -47,10 +47,10 @@ class CPPCACHE_EXPORT CacheXmlCreation {
/**
* Adds a root region to the cache
*/
- void addRootRegion(RegionXmlCreation* root);
+ void addRootRegion(std::shared_ptr<RegionXmlCreation> root);
/** Adds a pool to the cache */
- void addPool(PoolXmlCreation* pool);
+ void addPool(std::shared_ptr<PoolXmlCreation> pool);
/**
* Fills in the contents of a {@link Cache} based on this creation
@@ -79,14 +79,14 @@ class CPPCACHE_EXPORT CacheXmlCreation {
bool getPdxReadSerialized(bool val) { return m_readPdxSerialized; }
- ~CacheXmlCreation();
+ ~CacheXmlCreation() = default;
private:
/** This cache's roots */
- std::vector<RegionXmlCreation*> rootRegions;
+ std::vector<std::shared_ptr<RegionXmlCreation>> rootRegions;
/** This cache's pools */
- std::vector<PoolXmlCreation*> pools;
+ std::vector<std::shared_ptr<PoolXmlCreation>> pools;
Cache* m_cache;
bool m_pdxIgnoreUnreadFields;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheXmlParser.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheXmlParser.cpp b/src/cppcache/src/CacheXmlParser.cpp
index 552a0e1..52ee603 100644
--- a/src/cppcache/src/CacheXmlParser.cpp
+++ b/src/cppcache/src/CacheXmlParser.cpp
@@ -266,7 +266,7 @@ LibraryPersistenceManagerFn CacheXmlParser::managedPersistenceManagerFn =
//////////////////////////////////////////////////////////////////
-CacheXmlParser::CacheXmlParser()
+CacheXmlParser::CacheXmlParser(Cache* cache)
: m_cacheCreation(nullptr),
m_nestedRegions(0),
m_config(nullptr),
@@ -275,7 +275,8 @@ CacheXmlParser::CacheXmlParser()
m_flagIllegalStateException(false),
m_flagAnyOtherException(false),
m_flagExpirationAttribute(false),
- m_poolFactory(nullptr) {
+ m_poolFactory(nullptr),
+ m_cache(cache) {
static xmlSAXHandler saxHandler = {
nullptr, /* internalSubset */
nullptr, /* isStandalone */
@@ -388,9 +389,9 @@ void CacheXmlParser::handleParserErrors(int res) {
* If xml file is well-flrmed but not valid
* @throws UnknownException otherwise
*/
-CacheXmlParser* CacheXmlParser::parse(const char* cacheXml) {
+CacheXmlParser* CacheXmlParser::parse(const char* cacheXml, Cache* cache) {
CacheXmlParser* handler;
- GF_NEW(handler, CacheXmlParser());
+ GF_NEW(handler, CacheXmlParser(cache));
// use RAII to delete the handler object in case of exceptions
DeleteObject<CacheXmlParser> delHandler(handler);
@@ -517,14 +518,13 @@ void CacheXmlParser::endPdx() {}
void CacheXmlParser::startLocator(const xmlChar** atts) {
int attrsCount = 0;
if (!atts) {
-
std::string s =
"XML:No attributes provided for <locator>. "
"A locator requires a host and port";
throw CacheXmlException(s.c_str());
}
+ m_poolFactory = std::static_pointer_cast<PoolFactory>(_stack.top());
- m_poolFactory = reinterpret_cast<PoolFactory*>(_stack.top());
const char* host = nullptr;
const char* port = nullptr;
@@ -554,14 +554,13 @@ void CacheXmlParser::startLocator(const xmlChar** atts) {
void CacheXmlParser::startServer(const xmlChar** atts) {
int attrsCount = 0;
if (!atts) {
-
std::string s =
"XML:No attributes provided for <server>. A server requires a host and "
"port";
throw CacheXmlException(s.c_str());
}
+ auto factory = std::static_pointer_cast<PoolFactory>(_stack.top());
- PoolFactory* factory = reinterpret_cast<PoolFactory*>(_stack.top());
const char* host = nullptr;
const char* port = nullptr;
@@ -596,8 +595,8 @@ void CacheXmlParser::startPool(const xmlChar** atts) {
"A pool cannot be created without a name";
throw CacheXmlException(s.c_str());
}
+ PoolFactoryPtr factory = m_cache->getPoolManager().createFactory();
- PoolFactoryPtr factory = PoolManager::createFactory();
const char* poolName = nullptr;
while (atts[attrsCount] != nullptr) {
@@ -619,15 +618,15 @@ void CacheXmlParser::startPool(const xmlChar** atts) {
throw CacheXmlException(s.c_str());
}
- PoolXmlCreation* poolxml = new PoolXmlCreation(poolName, factory);
+ auto poolxml = std::make_shared<PoolXmlCreation>(poolName, factory);
_stack.push(poolxml);
- _stack.push(factory.get());
+ _stack.push(factory);
}
void CacheXmlParser::endPool() {
_stack.pop(); // remove factory
- PoolXmlCreation* poolxml = reinterpret_cast<PoolXmlCreation*>(_stack.top());
+ auto poolxml = std::static_pointer_cast<PoolXmlCreation>(_stack.top());
_stack.pop(); // remove pool
m_cacheCreation->addPool(poolxml);
}
@@ -747,7 +746,7 @@ void CacheXmlParser::startRegion(const xmlChar** atts, bool isRoot) {
throw CacheXmlException(s.c_str());
}
- RegionXmlCreation* region = new RegionXmlCreation(regionName, isRoot);
+ auto region = std::make_shared<RegionXmlCreation>(regionName, isRoot);
if (!region) {
throw UnknownException("CacheXmlParser::startRegion:Out of memeory");
}
@@ -784,7 +783,7 @@ void CacheXmlParser::startRootRegion(const xmlChar** atts) {
void CacheXmlParser::startRegionAttributes(const xmlChar** atts) {
bool isDistributed = false;
bool isTCR = false;
- AttributesFactory* attrsFactory = nullptr;
+ std::shared_ptr<AttributesFactory> attrsFactory = nullptr;
if (atts) {
int attrsCount = 0;
while (atts[attrsCount] != nullptr) ++attrsCount;
@@ -813,8 +812,8 @@ void CacheXmlParser::startRegionAttributes(const xmlChar** atts) {
}
if (strcmp((char*)atts[i - 1], ID) == 0) {
- RegionXmlCreation* region =
- reinterpret_cast<RegionXmlCreation*>(_stack.top());
+ auto region =
+ std::static_pointer_cast<RegionXmlCreation>(_stack.top());
region->setAttrId(std::string((char*)atts[i]));
} else if (strcmp((char*)atts[i - 1], REFID) == 0) {
refid = (char*)atts[i];
@@ -823,14 +822,15 @@ void CacheXmlParser::startRegionAttributes(const xmlChar** atts) {
}
if (refid == nullptr) {
- RegionXmlCreation* region =
- reinterpret_cast<RegionXmlCreation*>(_stack.top());
- attrsFactory = new AttributesFactory(region->getAttributes());
+ auto region = std::static_pointer_cast<RegionXmlCreation>(_stack.top());
+ attrsFactory =
+ std::make_shared<AttributesFactory>(region->getAttributes());
} else {
std::string refidStr(refid);
if (namedRegions.find(refidStr) != namedRegions.end()) {
- attrsFactory = new AttributesFactory(namedRegions[refidStr]);
+ attrsFactory =
+ std::make_shared<AttributesFactory>(namedRegions[refidStr]);
} else {
std::string s =
"XML:referenced named attribute '" + refidStr + "' does not exist.";
@@ -990,9 +990,8 @@ void CacheXmlParser::startRegionAttributes(const xmlChar** atts) {
} // for loop
} // atts is nullptr
else {
- RegionXmlCreation* region =
- reinterpret_cast<RegionXmlCreation*>(_stack.top());
- attrsFactory = new AttributesFactory(region->getAttributes());
+ auto region = std::static_pointer_cast<RegionXmlCreation>(_stack.top());
+ attrsFactory = std::make_shared<AttributesFactory>(region->getAttributes());
_stack.push(attrsFactory);
}
@@ -1004,8 +1003,7 @@ void CacheXmlParser::startRegionAttributes(const xmlChar** atts) {
}
void CacheXmlParser::endRegionAttributes() {
- AttributesFactory* attrsFactory =
- reinterpret_cast<AttributesFactory*>(_stack.top());
+ auto attrsFactory = std::static_pointer_cast<AttributesFactory>(_stack.top());
_stack.pop();
if (!attrsFactory) {
throw UnknownException(
@@ -1015,8 +1013,7 @@ void CacheXmlParser::endRegionAttributes() {
RegionAttributesPtr regionAttributesPtr =
attrsFactory->createRegionAttributes();
- RegionXmlCreation* regionPtr =
- reinterpret_cast<RegionXmlCreation*>(_stack.top());
+ auto regionPtr = std::static_pointer_cast<RegionXmlCreation>(_stack.top());
if (!regionPtr) {
throw UnknownException("CacheXmlParser::endRegion:Region is null");
}
@@ -1070,7 +1067,8 @@ void CacheXmlParser::startExpirationAttributes(const xmlChar** atts) {
std::string s =
"XML:The attribute <action> of <expiration-attributes> cannot be "
"set to empty string. It should either have a value or the "
- "attribute should be removed. In the latter case the default value "
+ "attribute should be removed. In the latter case the default "
+ "value "
"will be set";
throw CacheXmlException(s.c_str());
} else if (strcmp(INVALIDATE, action) == 0) {
@@ -1100,12 +1098,12 @@ void CacheXmlParser::startExpirationAttributes(const xmlChar** atts) {
}
if (timeOut == nullptr || strcmp(timeOut, "") == 0) {
std::string s =
- "XML:The attribute <timeout> not specified in <expiration-attributes>.";
+ "XML:The attribute <timeout> not specified in "
+ "<expiration-attributes>.";
throw CacheXmlException(s.c_str());
}
- ExpirationAttributes* expireAttr =
- new ExpirationAttributes(timeOutInt, expire);
+ auto expireAttr = std::make_shared<ExpirationAttributes>(timeOutInt, expire);
if (!expireAttr) {
throw UnknownException(
"CacheXmlParser::startExpirationAttributes:Out of memeory");
@@ -1123,7 +1121,8 @@ void CacheXmlParser::startPersistenceManager(const xmlChar** atts) {
while (atts[attrsCount] != nullptr) ++attrsCount;
if (attrsCount > 4) {
std::string s =
- "XML:Incorrect number of attributes provided for <persistence-manager>";
+ "XML:Incorrect number of attributes provided for "
+ "<persistence-manager>";
throw CacheXmlException(s.c_str());
}
char* libraryName = nullptr;
@@ -1142,9 +1141,11 @@ void CacheXmlParser::startPersistenceManager(const xmlChar** atts) {
if (libraryName == nullptr) {
std::string s =
- "XML:The attribute <library-name> of <persistence-manager> cannot "
+ "XML:The attribute <library-name> of <persistence-manager> "
+ "cannot "
"be set to an empty string. It should either have a value or the "
- "attribute should be removed. In the latter case the default value "
+ "attribute should be removed. In the latter case the default "
+ "value "
"will be set";
throw CacheXmlException(s.c_str());
}
@@ -1169,14 +1170,16 @@ void CacheXmlParser::startPersistenceManager(const xmlChar** atts) {
char* name = (char*)atts[i];
std::string temp(name);
std::string s =
- "XML:Incorrect attribute name specified in <persistence-manager>: " +
+ "XML:Incorrect attribute name specified in "
+ "<persistence-manager>: " +
temp;
throw CacheXmlException(s.c_str());
}
}
if (libraryFunctionName == nullptr) {
std::string s =
- "XML:Library function name not specified in the <persistence-manager>";
+ "XML:Library function name not specified in the "
+ "<persistence-manager>";
throw CacheXmlException(s.c_str());
}
@@ -1192,8 +1195,8 @@ void CacheXmlParser::startPersistenceManager(const xmlChar** atts) {
throw CacheXmlException(ex.getMessage());
}
- _stack.push(libraryName);
- _stack.push(libraryFunctionName);
+ _stack.push(std::make_shared<std::string>(std::string(libraryName)));
+ _stack.push(std::make_shared<std::string>(std::string(libraryFunctionName)));
}
void CacheXmlParser::startPersistenceProperties(const xmlChar** atts) {
@@ -1275,9 +1278,11 @@ void CacheXmlParser::startCacheLoader(const xmlChar** atts) {
libraryName = (char*)atts[i];
if (libraryName == nullptr || strcmp(libraryName, "") == 0) {
std::string s =
- "XML:The attribute <library-name> of <cache-loader> cannot be set "
+ "XML:The attribute <library-name> of <cache-loader> cannot be "
+ "set "
"to an empty string. It should either have a value or the "
- "attribute should be removed. In the latter case the default value "
+ "attribute should be removed. In the latter case the default "
+ "value "
"will be set";
throw CacheXmlException(s.c_str());
}
@@ -1316,8 +1321,7 @@ void CacheXmlParser::startCacheLoader(const xmlChar** atts) {
throw CacheXmlException(ex.getMessage());
}
- AttributesFactory* attrsFactory =
- reinterpret_cast<AttributesFactory*>(_stack.top());
+ auto attrsFactory = std::static_pointer_cast<AttributesFactory>(_stack.top());
attrsFactory->setCacheLoader(libraryName, libraryFunctionName);
}
@@ -1384,8 +1388,7 @@ void CacheXmlParser::startCacheListener(const xmlChar** atts) {
throw CacheXmlException(ex.getMessage());
}
- AttributesFactory* attrsFactory =
- reinterpret_cast<AttributesFactory*>(_stack.top());
+ auto attrsFactory = std::static_pointer_cast<AttributesFactory>(_stack.top());
attrsFactory->setCacheListener(libraryName, libraryFunctionName);
}
@@ -1400,7 +1403,8 @@ void CacheXmlParser::startPartitionResolver(const xmlChar** atts) {
while (atts[attrsCount] != nullptr) ++attrsCount;
if (attrsCount > 4) {
std::string s =
- "XML:Incorrect number of attributes provided for <partition-resolver>";
+ "XML:Incorrect number of attributes provided for "
+ "<partition-resolver>";
throw CacheXmlException(s.c_str());
}
@@ -1410,7 +1414,8 @@ void CacheXmlParser::startPartitionResolver(const xmlChar** atts) {
libraryName = (char*)atts[i];
if (libraryName == nullptr || strcmp(libraryName, "") == 0) {
std::string s =
- "XML:The attribute <library-name> of the <partition-resolver> tag "
+ "XML:The attribute <library-name> of the <partition-resolver> "
+ "tag "
"cannot be set to an empty string. It should either have a value "
"or the attribute should be removed. In the latter case the "
"default value will be set";
@@ -1429,7 +1434,8 @@ void CacheXmlParser::startPartitionResolver(const xmlChar** atts) {
char* name = (char*)atts[i];
std::string temp(name);
std::string s =
- "XML:Incorrect attribute name specified in <partition-resolver> : " +
+ "XML:Incorrect attribute name specified in <partition-resolver> "
+ ": " +
temp;
throw CacheXmlException(s.c_str());
}
@@ -1452,8 +1458,7 @@ void CacheXmlParser::startPartitionResolver(const xmlChar** atts) {
throw CacheXmlException(ex.getMessage());
}
- AttributesFactory* attrsFactory =
- reinterpret_cast<AttributesFactory*>(_stack.top());
+ auto attrsFactory = std::static_pointer_cast<AttributesFactory>(_stack.top());
attrsFactory->setPartitionResolver(libraryName, libraryFunctionName);
}
@@ -1478,9 +1483,11 @@ void CacheXmlParser::startCacheWriter(const xmlChar** atts) {
libraryName = (char*)atts[i];
if (libraryName == nullptr || strcmp(libraryName, "") == 0) {
std::string s =
- "XML:The attribute <library-name> of <cache-writer> cannot be set "
+ "XML:The attribute <library-name> of <cache-writer> cannot be "
+ "set "
"to an empty string. It should either have a value or the "
- "attribute should be removed. In the latter case the default value "
+ "attribute should be removed. In the latter case the default "
+ "value "
"will be set";
throw CacheXmlException(s.c_str());
}
@@ -1519,8 +1526,7 @@ void CacheXmlParser::startCacheWriter(const xmlChar** atts) {
throw CacheXmlException(ex.getMessage());
}
- AttributesFactory* attrsFactory =
- reinterpret_cast<AttributesFactory*>(_stack.top());
+ auto attrsFactory = std::static_pointer_cast<AttributesFactory>(_stack.top());
attrsFactory->setCacheWriter(libraryName, libraryFunctionName);
}
@@ -1530,8 +1536,7 @@ void CacheXmlParser::startCacheWriter(const xmlChar** atts) {
* <code>RegionXmlCreation</code>, then it is the parent region.
*/
void CacheXmlParser::endRegion(bool isRoot) {
- RegionXmlCreation* regionPtr =
- reinterpret_cast<RegionXmlCreation*>(_stack.top());
+ auto regionPtr = std::static_pointer_cast<RegionXmlCreation>(_stack.top());
_stack.pop();
if (isRoot) {
if (!_stack.empty()) {
@@ -1549,8 +1554,7 @@ void CacheXmlParser::endRegion(bool isRoot) {
std::string s = "Xml file has incorrectly nested region tags";
throw CacheXmlException(s.c_str());
}
- RegionXmlCreation* parent =
- reinterpret_cast<RegionXmlCreation*>(_stack.top());
+ auto parent = std::static_pointer_cast<RegionXmlCreation>(_stack.top());
parent->addSubregion(regionPtr);
}
}
@@ -1578,12 +1582,11 @@ void CacheXmlParser::endRegionTimeToLive() {
throw CacheXmlException(s.c_str());
}
- ExpirationAttributes* expireAttr =
- reinterpret_cast<ExpirationAttributes*>(_stack.top());
+ auto expireAttr =
+ std::static_pointer_cast<ExpirationAttributes>(_stack.top());
_stack.pop();
- AttributesFactory* attrsFactory =
- reinterpret_cast<AttributesFactory*>(_stack.top());
+ auto attrsFactory = std::static_pointer_cast<AttributesFactory>(_stack.top());
attrsFactory->setRegionTimeToLive(expireAttr->getAction(),
expireAttr->getTimeout());
m_flagExpirationAttribute = false;
@@ -1601,11 +1604,10 @@ void CacheXmlParser::endRegionIdleTime() {
"XML: <region-idle-time> cannot be without <expiration-attributes>";
throw CacheXmlException(s.c_str());
}
- ExpirationAttributes* expireAttr =
- reinterpret_cast<ExpirationAttributes*>(_stack.top());
+ auto expireAttr =
+ std::static_pointer_cast<ExpirationAttributes>(_stack.top());
_stack.pop();
- AttributesFactory* attrsFactory =
- reinterpret_cast<AttributesFactory*>(_stack.top());
+ auto attrsFactory = std::static_pointer_cast<AttributesFactory>(_stack.top());
attrsFactory->setRegionIdleTimeout(expireAttr->getAction(),
expireAttr->getTimeout());
@@ -1625,11 +1627,10 @@ void CacheXmlParser::endEntryTimeToLive() {
"<expiration-attributes>";
throw CacheXmlException(s.c_str());
}
- ExpirationAttributes* expireAttr =
- reinterpret_cast<ExpirationAttributes*>(_stack.top());
+ auto expireAttr =
+ std::static_pointer_cast<ExpirationAttributes>(_stack.top());
_stack.pop();
- AttributesFactory* attrsFactory =
- reinterpret_cast<AttributesFactory*>(_stack.top());
+ auto attrsFactory = std::static_pointer_cast<AttributesFactory>(_stack.top());
attrsFactory->setEntryTimeToLive(expireAttr->getAction(),
expireAttr->getTimeout());
@@ -1648,11 +1649,10 @@ void CacheXmlParser::endEntryIdleTime() {
"XML: <entry-idle-time> cannot be without <expiration-attributes>";
throw CacheXmlException(s.c_str());
}
- ExpirationAttributes* expireAttr =
- reinterpret_cast<ExpirationAttributes*>(_stack.top());
+ auto expireAttr =
+ std::static_pointer_cast<ExpirationAttributes>(_stack.top());
_stack.pop();
- AttributesFactory* attrsFactory =
- reinterpret_cast<AttributesFactory*>(_stack.top());
+ auto attrsFactory = std::static_pointer_cast<AttributesFactory>(_stack.top());
attrsFactory->setEntryIdleTimeout(expireAttr->getAction(),
expireAttr->getTimeout());
m_flagExpirationAttribute = false;
@@ -1663,23 +1663,21 @@ void CacheXmlParser::endEntryIdleTime() {
* factory.
*/
void CacheXmlParser::endPersistenceManager() {
- char* libraryFunctionName = reinterpret_cast<char*>(_stack.top());
+ std::shared_ptr<std::string> libraryFunctionName =
+ std::static_pointer_cast<std::string>(_stack.top());
_stack.pop();
- char* libraryName = reinterpret_cast<char*>(_stack.top());
+ std::shared_ptr<std::string> libraryName =
+ std::static_pointer_cast<std::string>(_stack.top());
_stack.pop();
- AttributesFactory* attrsFactory =
- reinterpret_cast<AttributesFactory*>(_stack.top());
+ auto attrsFactory = std::static_pointer_cast<AttributesFactory>(_stack.top());
if (m_config != nullptr) {
- attrsFactory->setPersistenceManager(libraryName, libraryFunctionName,
- m_config);
+ attrsFactory->setPersistenceManager(libraryName->c_str(),
+ libraryFunctionName->c_str(), m_config);
m_config = nullptr;
} else {
- attrsFactory->setPersistenceManager(libraryName, libraryFunctionName);
+ attrsFactory->setPersistenceManager(libraryName->c_str(),
+ libraryFunctionName->c_str());
}
- // Free memory allocated in startPersistenceManager, already checked for
- // nullptr
- free(libraryName);
- free(libraryFunctionName);
}
CacheXmlParser::~CacheXmlParser() { GF_SAFE_DELETE(m_cacheCreation); }
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheXmlParser.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheXmlParser.hpp b/src/cppcache/src/CacheXmlParser.hpp
index b86c479..025c83a 100644
--- a/src/cppcache/src/CacheXmlParser.hpp
+++ b/src/cppcache/src/CacheXmlParser.hpp
@@ -55,7 +55,7 @@ typedef PersistenceManager* (*LibraryPersistenceManagerFn)(
class CPPCACHE_EXPORT CacheXmlParser : public CacheXml {
private:
- std::stack<void*> _stack;
+ std::stack<std::shared_ptr<void>> _stack;
xmlSAXHandler m_saxHandler;
CacheXmlCreation* m_cacheCreation;
std::string m_error;
@@ -67,8 +67,9 @@ class CPPCACHE_EXPORT CacheXmlParser : public CacheXml {
bool m_flagAnyOtherException;
bool m_flagExpirationAttribute;
std::map<std::string, RegionAttributesPtr> namedRegions;
- PoolFactory* m_poolFactory;
+ std::shared_ptr<PoolFactory> m_poolFactory;
+ Cache* m_cache;
/** Pool helper */
void setPoolInfo(PoolFactory* poolFactory, const char* name,
const char* value);
@@ -76,9 +77,9 @@ class CPPCACHE_EXPORT CacheXmlParser : public CacheXml {
void handleParserErrors(int res);
public:
- CacheXmlParser();
+ CacheXmlParser(Cache* cache);
~CacheXmlParser();
- static CacheXmlParser* parse(const char* cachexml);
+ static CacheXmlParser* parse(const char* cachexml, Cache* cache);
void parseFile(const char* filename);
void parseMemory(const char* buffer, int size);
void setAttributes(Cache* cache);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheableEnum.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheableEnum.cpp b/src/cppcache/src/CacheableEnum.cpp
index 7795de5..5e76483 100644
--- a/src/cppcache/src/CacheableEnum.cpp
+++ b/src/cppcache/src/CacheableEnum.cpp
@@ -19,6 +19,7 @@
#include <PdxHelper.hpp>
#include <GeodeTypeIdsImpl.hpp>
#include <EnumInfo.hpp>
+#include "CacheRegionHelper.hpp"
namespace apache {
namespace geode {
@@ -40,8 +41,9 @@ CacheableEnum::CacheableEnum(const char* enumClassName, const char* enumName,
}
void CacheableEnum::toData(apache::geode::client::DataOutput& output) const {
- int enumVal = PdxHelper::getEnumValue(m_enumClassName->asChar(),
- m_enumName->asChar(), m_ordinal);
+ int enumVal = PdxHelper::getEnumValue(
+ m_enumClassName->asChar(), m_enumName->asChar(), m_ordinal,
+ CacheRegionHelper::getCacheImpl(output.getCache())->getPdxTypeRegistry());
output.write(static_cast<int8_t>(GeodeTypeIds::CacheableEnum));
output.write(int8_t(enumVal >> 24));
output.writeArrayLen(enumVal & 0xFFFFFF);
@@ -53,7 +55,9 @@ Serializable* CacheableEnum::fromData(apache::geode::client::DataInput& input) {
int32_t arrLen;
input.readArrayLen(&arrLen);
int enumId = (dsId << 24) | (arrLen & 0xFFFFFF);
- EnumInfoPtr enumVal = PdxHelper::getEnum(enumId);
+ EnumInfoPtr enumVal = PdxHelper::getEnum(
+ enumId,
+ CacheRegionHelper::getCacheImpl(input.getCache())->getPdxTypeRegistry());
m_enumClassName = enumVal->getEnumClassName();
m_enumName = enumVal->getEnumName();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheableObjectPartList.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheableObjectPartList.hpp b/src/cppcache/src/CacheableObjectPartList.hpp
index cbc241b..35e9d39 100644
--- a/src/cppcache/src/CacheableObjectPartList.hpp
+++ b/src/cppcache/src/CacheableObjectPartList.hpp
@@ -72,6 +72,17 @@ class CacheableObjectPartList : public Cacheable {
m_destroyTracker(0),
m_addToLocalCache(false) {}
+ inline CacheableObjectPartList(ThinClientRegion* region)
+ : m_keys(nullptr),
+ m_keysOffset(nullptr),
+ m_values(nullptr),
+ m_exceptions(nullptr),
+ m_resultKeys(nullptr),
+ m_region(region),
+ m_updateCountMap(nullptr),
+ m_destroyTracker(0),
+ m_addToLocalCache(false) {}
+
// never implemented.
CacheableObjectPartList& operator=(const CacheableObjectPartList& other);
CacheableObjectPartList(const CacheableObjectPartList& other);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CacheableString.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheableString.cpp b/src/cppcache/src/CacheableString.cpp
index 85fac8d..eddba1c 100644
--- a/src/cppcache/src/CacheableString.cpp
+++ b/src/cppcache/src/CacheableString.cpp
@@ -25,6 +25,8 @@
#include <cstdlib>
#include <ace/ACE.h>
#include <ace/OS.h>
+#include "DataOutputInternal.hpp"
+#include "SerializationRegistry.hpp"
using namespace apache::geode::client;
@@ -196,7 +198,7 @@ char* CacheableString::getASCIIString(const wchar_t* value, int32_t& len,
}
len -= clen;
} else {
- DataOutput out;
+ DataOutputInternal out;
const wchar_t* pvalue = value;
while ((currentChar = *pvalue) != 0) {
c = getASCIIChar(currentChar, isASCII, encodedLen);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ClientMetadata.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ClientMetadata.hpp b/src/cppcache/src/ClientMetadata.hpp
index 37a025e..b6ab281 100644
--- a/src/cppcache/src/ClientMetadata.hpp
+++ b/src/cppcache/src/ClientMetadata.hpp
@@ -20,6 +20,7 @@
* limitations under the License.
*/
+#include <geode/Log.hpp>
#include <geode/PartitionResolver.hpp>
#include "ServerLocation.hpp"
#include "BucketServerLocation.hpp"
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ClientMetadataService.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ClientMetadataService.cpp b/src/cppcache/src/ClientMetadataService.cpp
index 1939f16..20b611f 100644
--- a/src/cppcache/src/ClientMetadataService.cpp
+++ b/src/cppcache/src/ClientMetadataService.cpp
@@ -54,8 +54,12 @@ ClientMetadataService::ClientMetadataService(Pool* pool)
{
m_regionQueue = new Queue<std::string>(false);
m_pool = pool;
- m_bucketWaitTimeout =
- DistributedSystem::getSystemProperties()->bucketWaitTimeout();
+
+ ThinClientPoolDM* tcrdm = dynamic_cast<ThinClientPoolDM*>(m_pool);
+ CacheImpl* cacheImpl = tcrdm->getConnectionManager().getCacheImpl();
+ m_bucketWaitTimeout = cacheImpl->getDistributedSystem()
+ .getSystemProperties()
+ .bucketWaitTimeout();
}
int ClientMetadataService::svc() {
@@ -128,7 +132,11 @@ void ClientMetadataService::getClientPRMetadata(const char* regionFullPath) {
ClientMetadataPtr newCptr = nullptr;
if (cptr == nullptr) {
- TcrMessageGetClientPartitionAttributes request(regionFullPath);
+ TcrMessageGetClientPartitionAttributes request(tcrdm->getConnectionManager()
+ .getCacheImpl()
+ ->getCache()
+ ->createDataOutput(),
+ regionFullPath);
GfErrType err = tcrdm->sendSyncRequest(request, reply);
if (err == GF_NOERR &&
reply.getMessageType() ==
@@ -182,7 +190,11 @@ ClientMetadataPtr ClientMetadataService::SendClientPRMetadata(
throw IllegalArgumentException(
"ClientMetaData: pool cast to ThinClientPoolDM failed");
}
- TcrMessageGetClientPrMetadata request(regionPath);
+ TcrMessageGetClientPrMetadata request(tcrdm->getConnectionManager()
+ .getCacheImpl()
+ ->getCache()
+ ->createDataOutput(),
+ regionPath);
TcrMessageReply reply(true, nullptr);
// send this message to server and get metadata from server.
LOGFINE("Now sending GET_CLIENT_PR_METADATA for getting from server: %s",
@@ -251,10 +263,9 @@ void ClientMetadataService::getBucketServerLocation(
"The RoutingObject returned by PartitionResolver is null.");
}
}
- FixedPartitionResolverPtr fpResolver(
- dynamic_cast<FixedPartitionResolver*>(resolver.get()));
- if (fpResolver != nullptr) {
- const char* partition = fpResolver->getPartitionName(event);
+ if (const auto fpResolver =
+ std::dynamic_pointer_cast<FixedPartitionResolver>(resolver)) {
+ const auto partition = fpResolver->getPartitionName(event);
if (partition == nullptr) {
throw IllegalStateException(
"partition name returned by Partition resolver is null.");
@@ -313,13 +324,13 @@ void ClientMetadataService::enqueueForMetadataRefresh(
"ClientMetaData: pool cast to ThinClientPoolDM failed");
}
RegionPtr region;
- tcrdm->getConnectionManager().getCacheImpl()->getRegion(regionFullPath,
- region);
- LocalRegion* lregion = dynamic_cast<LocalRegion*>(region.get());
+
+ auto cache = tcrdm->getConnectionManager().getCacheImpl();
+ cache->getRegion(regionFullPath, region);
std::string serverGroup = tcrdm->getServerGroup();
if (serverGroup.length() != 0) {
- CacheImpl::setServerGroupFlag(serverGroupFlag);
+ cache->setServerGroupFlag(serverGroupFlag);
if (serverGroupFlag == 2) {
LOGFINER(
"Network hop but, from within same server-group, so no metadata "
@@ -337,7 +348,7 @@ void ClientMetadataService::enqueueForMetadataRefresh(
return;
}
LOGFINE("Network hop so fetching single hop metadata from the server");
- CacheImpl::setNetworkHopFlag(true);
+ cache->setNetworkHopFlag(true);
tcrRegion->setMetaDataRefreshed(true);
std::string* tempRegionPath = new std::string(regionFullPath);
m_regionQueue->put(tempRegionPath);
@@ -855,15 +866,13 @@ bool ClientMetadataService::isBucketMarkedForTimeout(const char* regionFullPath,
ReadGuard guard(m_PRbucketStatusLock);
- std::map<std::string, PRbuckets*>::iterator bs =
- m_bucketStatus.find(regionFullPath);
-
+ const auto& bs = m_bucketStatus.find(regionFullPath);
if (bs != m_bucketStatus.end()) {
bool m = bs->second->isBucketTimedOut(bucketid, m_bucketWaitTimeout);
- if (m == true) {
+ if (m) {
ThinClientPoolDM* tcrdm = dynamic_cast<ThinClientPoolDM*>(m_pool);
CacheImpl* cache = tcrdm->getConnectionManager().getCacheImpl();
- cache->setBlackListBucketTimeouts();
+ cache->incBlackListBucketTimeouts();
}
LOGFINE("isBucketMarkedForTimeout:: for bucket %d returning = %d", bucketid,
m);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ClientProxyMembershipID.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ClientProxyMembershipID.cpp b/src/cppcache/src/ClientProxyMembershipID.cpp
index 41f0f6e..cbf7d6b 100644
--- a/src/cppcache/src/ClientProxyMembershipID.cpp
+++ b/src/cppcache/src/ClientProxyMembershipID.cpp
@@ -22,8 +22,10 @@
#include <geode/GeodeTypeIds.hpp>
#include "GeodeTypeIdsImpl.hpp"
#include <geode/CacheableBuiltins.hpp>
+#include "DataOutputInternal.hpp"
#include "Version.hpp"
#include <string>
+#include <memory>
#define ADDRSIZE 4
#define DCPORT 12334
@@ -50,73 +52,9 @@ static class RandomInitializer {
} oneTimeRandomInitializer;
} // namespace
-std::string ClientProxyMembershipID::g_dsName("DSName");
-std::string ClientProxyMembershipID::g_randString("GFNative");
-#define RAND_STRING_LEN 10
const int ClientProxyMembershipID::VERSION_MASK = 0x8;
const int8_t ClientProxyMembershipID::TOKEN_ORDINAL = -1;
-// initialize random string data and DistributedSystem name
-void ClientProxyMembershipID::init(const std::string& dsName) {
- if (dsName.size() > 0) {
- const char selectChars[] =
- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
- const uint32_t numChars = (sizeof(selectChars) / sizeof(char)) - 1;
-
- g_dsName = dsName;
- bool randDone = false;
- char randString[RAND_STRING_LEN + 1];
- int pid = ACE_OS::getpid();
- // try /dev/urandom first
- FILE* urandom = ACE_OS::fopen("/dev/urandom", "rb");
- if (urandom) {
- LOGFINE("Opened /dev/urandom for ClientProxyMembershipID random data");
- uint8_t readBytes[RAND_STRING_LEN];
- size_t readLen = ACE_OS::fread(readBytes, RAND_STRING_LEN, 1, urandom);
- if (readLen == 1) {
- for (uint32_t index = 0; index < RAND_STRING_LEN; ++index) {
- randString[index] = selectChars[readBytes[index] % numChars];
- }
- randString[RAND_STRING_LEN] = '\0';
- randDone = true;
- }
- ACE_OS::fclose(urandom);
- }
- if (!randDone) {
- for (uint32_t index = 0; index < RAND_STRING_LEN; ++index) {
- randString[index] = selectChars[ACE_OS::rand() % numChars];
- }
- randString[RAND_STRING_LEN] = '\0';
- }
- char ps[15] = {0};
- ACE_OS::snprintf(ps, 15, "%d", pid);
- g_randString = "GFNative_";
- g_randString.append(randString).append(ps);
- LOGINFO("Using %s as random data for ClientProxyMembershipID",
- g_randString.c_str());
- }
-}
-const std::string& ClientProxyMembershipID::getRandStringId() {
- return g_randString;
-}
-/*
-// Commenting this function as this is not getting used anywhere.
-ClientProxyMembershipID::ClientProxyMembershipID(const char *durableClientId,
- const uint32_t
-durableClntTimeOut)
-{
- if( durableClientId != nullptr && durableClntTimeOut != 0 ) {
- DataOutput m_memID;
- m_memID.write((int8_t)GeodeTypeIds::CacheableASCIIString);
- m_memID.writeASCII(durableClientId);
- CacheableInt32Ptr int32ptr = CacheableInt32::create(durableClntTimeOut);
- int32ptr->toData(m_memID);
- uint32_t len;
- char* buf = (char*)m_memID.getBuffer(&len);
- m_memIDStr.append(buf, len);
- }
-}
-*/
ClientProxyMembershipID::ClientProxyMembershipID()
: m_hostPort(0),
m_hostAddr(nullptr)
@@ -133,13 +71,14 @@ ClientProxyMembershipID::~ClientProxyMembershipID() {
}
ClientProxyMembershipID::ClientProxyMembershipID(
- const char* hostname, uint32_t hostAddr, uint32_t hostPort,
- const char* durableClientId, const uint32_t durableClntTimeOut) {
+ std::string dsName, std::string randString, const char* hostname,
+ uint32_t hostAddr, uint32_t hostPort, const char* durableClientId,
+ const uint32_t durableClntTimeOut)
+ : m_hostAddrAsUInt32(hostAddr) {
int32_t vmPID = ACE_OS::getpid();
-
- initObjectVars(hostname, reinterpret_cast<uint8_t*>(&hostAddr), 4, false,
- hostPort, durableClientId, durableClntTimeOut, DCPORT, vmPID,
- VMKIND, 0, g_dsName.c_str(), g_randString.c_str(), 0);
+ initObjectVars(hostname, reinterpret_cast<uint8_t*>(&m_hostAddrAsUInt32), 4,
+ false, hostPort, durableClientId, durableClntTimeOut, DCPORT,
+ vmPID, VMKIND, 0, dsName.c_str(), randString.c_str(), 0);
}
// This is only for unit tests and should not be used for any other purpose. See
@@ -157,7 +96,7 @@ void ClientProxyMembershipID::initObjectVars(
const uint32_t durableClntTimeOut, int32_t dcPort, int32_t vPID,
int8_t vmkind, int8_t splitBrainFlag, const char* dsname,
const char* uniqueTag, uint32_t vmViewId) {
- DataOutput m_memID;
+ DataOutputInternal m_memID;
if (dsname == nullptr) {
m_dsname = std::string("");
} else {
@@ -212,9 +151,7 @@ void ClientProxyMembershipID::initObjectVars(
char PID[15] = {0};
char Synch_Counter[15] = {0};
- // ACE_OS::snprintf(PID, 15, "%d",vPID);
ACE_OS::itoa(vPID, PID, 10);
- // ACE_OS::snprintf(Synch_Counter, 15, "%d",synch_counter);
ACE_OS::itoa(synch_counter, Synch_Counter, 10);
clientID.append(hostname);
clientID.append("(");
@@ -273,74 +210,6 @@ const std::string& ClientProxyMembershipID::getDSMemberIdForThinClientUse() {
std::string ClientProxyMembershipID::getHashKey() { return m_hashKey; }
-void ClientProxyMembershipID::getClientProxyMembershipID() {
- // Implement LonerDistributionManager::generateMemberId() and store result in
- // dsMemberId,dsMemberIdLength
- const char* hex = "0123456789ABCDEF";
- std::string DSMemberId = "";
- ACE_TCHAR host[MAXHOSTNAMELEN];
- std::string hostName = " ";
- char buf[50];
- char dsName[50];
- DistributedSystemPtr dsPtr;
- dsPtr = DistributedSystem::getInstance();
-
- ACE_OS::hostname(host, sizeof(host) - 1);
- hostName = host;
- pid_t pid;
- pid = ACE_OS::getpid();
-
- /* adongre
- * CID 28814: Resource leak (RESOURCE_LEAK)
- * Following allocation is not used anywhere
- * commenting the same.
- */
-
- /*int* random = new int[8];
- for (int i = 0; i < 8; i++) {
- random[i]=ACE_OS::rand()%16;
- } */
- char* hname = host;
-
- // ACE_OS::sprintf(hname,"%s",hostName);
- uint32_t len = static_cast<uint32_t>(hostName.length());
- DataOutput m_dsmemID;
- m_dsmemID.writeBytesOnly(reinterpret_cast<int8_t*>(hname), len);
- // DSMemberId = DSMemberId.append(host);
- // DSMemberId= DSMemberId.append("(");
- m_dsmemID.write(static_cast<int8_t>('('));
- int lenPid = ACE_OS::snprintf(buf, 50, "%d", pid);
- // DSMemberId.append(buf);
- // m_dsmemID.writeInt((int32_t)pid);
- m_dsmemID.writeBytesOnly(reinterpret_cast<int8_t*>(buf), lenPid);
- // DSMemberId.append("):");
- m_dsmemID.write(static_cast<int8_t>(')'));
- m_dsmemID.write(static_cast<int8_t>(':'));
-
- char hexBuf[20];
- for (int j = 0; j < 8; j++) {
- // Hardcoding random number for Thin Client
- // hexBuf[j] = hex[random[j]%16];
- hexBuf[j] = hex[1];
- }
- // DSMemberId = DSMemberId.append(hexBuf);
- m_dsmemID.writeBytesOnly(reinterpret_cast<int8_t*>(hexBuf), 8);
- m_dsmemID.write(static_cast<int8_t>(':'));
- // DSMemberId = DSMemberId.append(":");
- ACE_OS::snprintf(dsName, 50, "%s", dsPtr->getName());
- // DSMemberId.append(dsName);
- uint32_t dsLen = static_cast<uint32_t>(strlen(dsName));
- m_dsmemID.writeBytesOnly(reinterpret_cast<int8_t*>(dsName), dsLen);
- m_dsmemIDStr += (char*)m_dsmemID.getBuffer();
- uint32_t strLen;
- char* strBuf = (char*)m_dsmemID.getBuffer(&strLen);
- m_dsmemIDStr.append(strBuf, strLen);
- // dsMemberIdLength = DSMemberId.length();
- // dsMemberId= (char*)ACE_OS::malloc(dsMemberIdLength+1);
- // ACE_OS::strcpy(dsMemberId,DSMemberId.c_str());
- // return m_dsmemID;
-}
-
void ClientProxyMembershipID::toData(DataOutput& output) const {
throw IllegalStateException("Member ID toData() not implemented.");
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ClientProxyMembershipID.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ClientProxyMembershipID.hpp b/src/cppcache/src/ClientProxyMembershipID.hpp
index d7a29c9..4e86423 100644
--- a/src/cppcache/src/ClientProxyMembershipID.hpp
+++ b/src/cppcache/src/ClientProxyMembershipID.hpp
@@ -37,7 +37,9 @@ class ClientProxyMembershipID : public DSMemberForVersionStamp {
public:
const char* getDSMemberId(uint32_t& mesgLength) const;
const char* getDSMemberIdForCS43(uint32_t& mesgLength) const;
- ClientProxyMembershipID(const char* hostname, uint32_t hostAddr,
+
+ ClientProxyMembershipID(std::string dsName, std::string randString,
+ const char* hostname, uint32_t hostAddr,
uint32_t hostPort,
const char* durableClientId = nullptr,
const uint32_t durableClntTimeOut = 0);
@@ -51,11 +53,6 @@ class ClientProxyMembershipID : public DSMemberForVersionStamp {
// uint32_t durableClntTimeOut = 0);
ClientProxyMembershipID();
~ClientProxyMembershipID();
- void getClientProxyMembershipID();
- // Initialize for random data and set the DS name.
- // This method is not thread-safe.
- static void init(const std::string& dsName);
- static const std::string& getRandStringId();
static void increaseSynchCounter();
static Serializable* createDeserializable() {
return new ClientProxyMembershipID();
@@ -111,15 +108,13 @@ class ClientProxyMembershipID : public DSMemberForVersionStamp {
private:
std::string m_memIDStr;
std::string m_dsmemIDStr;
- // static data
- static std::string g_dsName;
- static std::string g_randString;
std::string clientID;
std::string m_dsname;
uint32_t m_hostPort;
uint8_t* m_hostAddr;
uint32_t m_hostAddrLen;
+ uint32_t m_hostAddrAsUInt32;
std::string m_uniqueTag;
std::string m_hashKey;
bool m_hostAddrLocalMem;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ClientProxyMembershipIDFactory.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ClientProxyMembershipIDFactory.cpp b/src/cppcache/src/ClientProxyMembershipIDFactory.cpp
new file mode 100644
index 0000000..f9bf982
--- /dev/null
+++ b/src/cppcache/src/ClientProxyMembershipIDFactory.cpp
@@ -0,0 +1,44 @@
+#include <algorithm>
+#include <iterator>
+#include <random>
+
+#include "ClientProxyMembershipIDFactory.hpp"
+
+namespace apache {
+namespace geode {
+namespace client {
+
+ClientProxyMembershipIDFactory::ClientProxyMembershipIDFactory(
+ std::string dsName)
+ : dsName(dsName) {
+ static const auto alphabet =
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
+ static const auto numChars = (sizeof(alphabet) / sizeof(char)) - 2;
+
+ std::random_device rd;
+ std::default_random_engine rng(rd());
+ std::uniform_int_distribution<> dist(0, numChars);
+
+ randString.reserve(7 + 10 + 15);
+ randString.append("Native_");
+ std::generate_n(std::back_inserter(randString), 10,
+ [&]() { return alphabet[dist(rng)]; });
+
+ auto pid = ACE_OS::getpid();
+ randString.append(std::to_string(pid));
+
+ LOGINFO("Using %s as random data for ClientProxyMembershipID",
+ randString.c_str());
+}
+
+std::unique_ptr<ClientProxyMembershipID> ClientProxyMembershipIDFactory::create(
+ const char* hostname, uint32_t hostAddr, uint32_t hostPort,
+ const char* durableClientId, const uint32_t durableClntTimeOut) {
+ return std::unique_ptr<ClientProxyMembershipID>(new ClientProxyMembershipID(
+ dsName, randString, hostname, hostAddr, hostPort, durableClientId,
+ durableClntTimeOut));
+}
+
+} // namespace client
+} // namespace geode
+} // namespace apache
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ClientProxyMembershipIDFactory.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ClientProxyMembershipIDFactory.hpp b/src/cppcache/src/ClientProxyMembershipIDFactory.hpp
new file mode 100644
index 0000000..a24abbf
--- /dev/null
+++ b/src/cppcache/src/ClientProxyMembershipIDFactory.hpp
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#ifndef GEODE_CLIENTPROXYMEMBERSHIPIDFACTORY_H_
+#define GEODE_CLIENTPROXYMEMBERSHIPIDFACTORY_H_
+
+#include <string>
+
+#include "ClientProxyMembershipID.hpp"
+
+namespace apache {
+namespace geode {
+namespace client {
+
+class ClientProxyMembershipIDFactory {
+ public:
+ ClientProxyMembershipIDFactory(std::string dsName);
+
+ std::unique_ptr<ClientProxyMembershipID> create(
+ const char* hostname, uint32_t hostAddr, uint32_t hostPort,
+ const char* durableClientId = nullptr,
+ const uint32_t durableClntTimeOut = 0);
+
+ private:
+ std::string dsName;
+ std::string randString;
+};
+
+} // namespace client
+} // namespace geode
+} // namespace apache
+
+#endif // GEODE_CLIENTPROXYMEMBERSHIPID_H_
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ConcurrentEntriesMap.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ConcurrentEntriesMap.cpp b/src/cppcache/src/ConcurrentEntriesMap.cpp
index c79d4c2..c8338be 100644
--- a/src/cppcache/src/ConcurrentEntriesMap.cpp
+++ b/src/cppcache/src/ConcurrentEntriesMap.cpp
@@ -24,19 +24,17 @@ using namespace apache::geode::client;
bool EntriesMap::boolVal = false;
-ConcurrentEntriesMap::ConcurrentEntriesMap(EntryFactory* entryFactory,
- bool concurrencyChecksEnabled,
- RegionInternal* region,
- uint8_t concurrency)
- : EntriesMap(entryFactory),
+ConcurrentEntriesMap::ConcurrentEntriesMap(
+ ExpiryTaskManager* expiryTaskManager,
+ std::unique_ptr<EntryFactory> entryFactory, bool concurrencyChecksEnabled,
+ RegionInternal* region, uint8_t concurrency)
+ : EntriesMap(std::move(entryFactory)),
+ m_expiryTaskManager(expiryTaskManager),
m_concurrency(0),
m_segments((MapSegment*)0),
m_size(0),
m_region(region),
m_numDestroyTrackers(0),
- /* adongre
- * CID 28929: Uninitialized pointer field (UNINIT_CTOR)
- */
m_concurrencyChecksEnabled(concurrencyChecksEnabled) {
GF_DEV_ASSERT(entryFactory != nullptr);
@@ -52,8 +50,9 @@ void ConcurrentEntriesMap::open(uint32_t initialCapacity) {
uint32_t segSize = 1 + (initialCapacity - 1) / m_concurrency;
m_segments = new MapSegment[m_concurrency];
for (int index = 0; index < m_concurrency; ++index) {
- m_segments[index].open(m_region, this->getEntryFactory(), segSize,
- &m_numDestroyTrackers, m_concurrencyChecksEnabled);
+ m_segments[index].open(m_region, getEntryFactory(), m_expiryTaskManager,
+ segSize, &m_numDestroyTrackers,
+ m_concurrencyChecksEnabled);
}
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/ConcurrentEntriesMap.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ConcurrentEntriesMap.hpp b/src/cppcache/src/ConcurrentEntriesMap.hpp
index 94e6a34..0a67fbb 100644
--- a/src/cppcache/src/ConcurrentEntriesMap.hpp
+++ b/src/cppcache/src/ConcurrentEntriesMap.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_CONCURRENTENTRIESMAP_H_
-#define GEODE_CONCURRENTENTRIESMAP_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,7 +15,12 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_CONCURRENTENTRIESMAP_H_
+#define GEODE_CONCURRENTENTRIESMAP_H_
#include <atomic>
+
#include <geode/geode_globals.hpp>
#include "EntriesMap.hpp"
#include "MapSegment.hpp"
@@ -38,6 +38,7 @@ class RegionInternal;
*/
class CPPCACHE_EXPORT ConcurrentEntriesMap : public EntriesMap {
protected:
+ ExpiryTaskManager* m_expiryTaskManager;
uint8_t m_concurrency;
MapSegment* m_segments;
std::atomic<uint32_t> m_size;
@@ -70,7 +71,8 @@ class CPPCACHE_EXPORT ConcurrentEntriesMap : public EntriesMap {
/**
* @brief constructor, must call open before using map.
*/
- ConcurrentEntriesMap(EntryFactory* entryFactory,
+ ConcurrentEntriesMap(ExpiryTaskManager* expiryTaskManager,
+ std::unique_ptr<EntryFactory> entryFactory,
bool concurrencyChecksEnabled, RegionInternal* region,
uint8_t concurrency = 16);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CppCacheLibrary.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CppCacheLibrary.cpp b/src/cppcache/src/CppCacheLibrary.cpp
index ea77dbb..c9c1fd9 100644
--- a/src/cppcache/src/CppCacheLibrary.cpp
+++ b/src/cppcache/src/CppCacheLibrary.cpp
@@ -33,7 +33,6 @@
#include <geode/DataOutput.hpp>
#include "TcrMessage.hpp"
#include "Utils.hpp"
-#include "PdxTypeRegistry.hpp"
#include <string>
@@ -57,12 +56,6 @@ CppCacheLibrary::CppCacheLibrary() {
// Put initialization code for statics and other such things here.
try {
gf_log_libinit();
- EntryFactory::init();
- LRUEntryFactory::init();
- ExpEntryFactory::init();
- LRUExpEntryFactory::init();
- CacheFactory::init();
- SerializationRegistry::init();
// PdxTypeRegistry::init();
// log( "Finished initializing CppCacheLibrary." );
} catch (apache::geode::client::Exception& ge) {
@@ -73,7 +66,6 @@ CppCacheLibrary::CppCacheLibrary() {
CppCacheLibrary::~CppCacheLibrary() {
// Put any global clean up code here.
- CacheFactory::cleanup();
// PdxTypeRegistry::cleanup();
ACE::fini();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/src/CqEventImpl.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CqEventImpl.cpp b/src/cppcache/src/CqEventImpl.cpp
index 8d15bd0..050c9cd 100644
--- a/src/cppcache/src/CqEventImpl.cpp
+++ b/src/cppcache/src/CqEventImpl.cpp
@@ -68,7 +68,11 @@ CacheablePtr CqEventImpl::getNewValue() const {
return m_newValue;
} else {
// Get full object for delta
- TcrMessageRequestEventValue fullObjectMsg(m_eventId);
+ TcrMessageRequestEventValue fullObjectMsg(m_tcrdm->getConnectionManager()
+ .getCacheImpl()
+ ->getCache()
+ ->createDataOutput(),
+ m_eventId);
TcrMessageReply reply(true, nullptr);
ThinClientPoolHADM* poolHADM = dynamic_cast<ThinClientPoolHADM*>(m_tcrdm);
GfErrType err = GF_NOTCON;