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);