[
https://issues.apache.org/jira/browse/GEODE-3998?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16316735#comment-16316735
]
ASF GitHub Bot commented on GEODE-3998:
---------------------------------------
pivotal-jbarrett closed pull request #178: GEODE-3998: Links Cache::Name to
DistributeSystem::Name
URL: https://github.com/apache/geode-native/pull/178
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/cppcache/include/geode/Cache.hpp b/cppcache/include/geode/Cache.hpp
index e654441f..dc93c675 100644
--- a/cppcache/include/geode/Cache.hpp
+++ b/cppcache/include/geode/Cache.hpp
@@ -250,8 +250,8 @@ class CPPCACHE_EXPORT Cache : public GeodeCache,
/**
* @brief constructors
*/
- Cache(const std::string& name, std::shared_ptr<Properties> dsProp,
- bool ignorePdxUnreadFields, bool readPdxSerialized,
+ Cache(std::shared_ptr<Properties> dsProp, bool ignorePdxUnreadFields,
+ bool readPdxSerialized,
const std::shared_ptr<AuthInitialize>& authInitialize);
std::unique_ptr<CacheImpl> m_cacheImpl;
diff --git a/cppcache/include/geode/CacheFactory.hpp
b/cppcache/include/geode/CacheFactory.hpp
index 6be40049..ce3c9215 100644
--- a/cppcache/include/geode/CacheFactory.hpp
+++ b/cppcache/include/geode/CacheFactory.hpp
@@ -145,9 +145,7 @@ class CPPCACHE_EXPORT CacheFactory {
bool pdxReadSerialized;
std::shared_ptr<AuthInitialize> authInitialize;
- Cache create(
- const std::string name,
- const std::shared_ptr<CacheAttributes>& attrs = nullptr) const;
+ Cache create(const std::shared_ptr<CacheAttributes>& attrs) const;
friend class CppCacheLibrary;
friend class RegionFactory;
diff --git a/cppcache/src/Cache.cpp b/cppcache/src/Cache.cpp
index 1ed20db3..1e515a5b 100644
--- a/cppcache/src/Cache.cpp
+++ b/cppcache/src/Cache.cpp
@@ -134,12 +134,12 @@ std::shared_ptr<CacheTransactionManager>
Cache::getCacheTransactionManager()
TypeRegistry& Cache::getTypeRegistry() { return *(m_typeRegistry.get()); }
-Cache::Cache(const std::string& name, std::shared_ptr<Properties> dsProp,
- bool ignorePdxUnreadFields, bool readPdxSerialized,
+Cache::Cache(std::shared_ptr<Properties> dsProp, bool ignorePdxUnreadFields,
+ bool readPdxSerialized,
const std::shared_ptr<AuthInitialize>& authInitialize) {
- m_cacheImpl = std::unique_ptr<CacheImpl>(new CacheImpl(
- this, name, DistributedSystem::create(DEFAULT_DS_NAME, dsProp),
- ignorePdxUnreadFields, readPdxSerialized, authInitialize));
+ m_cacheImpl = std::unique_ptr<CacheImpl>(
+ new CacheImpl(this, DistributedSystem::create(DEFAULT_DS_NAME, dsProp),
+ ignorePdxUnreadFields, readPdxSerialized, authInitialize));
m_cacheImpl->getDistributedSystem().connect(this);
m_typeRegistry =
std::unique_ptr<TypeRegistry>(new TypeRegistry(m_cacheImpl.get()));
diff --git a/cppcache/src/CacheFactory.cpp b/cppcache/src/CacheFactory.cpp
index 8b603227..162caaab 100644
--- a/cppcache/src/CacheFactory.cpp
+++ b/cppcache/src/CacheFactory.cpp
@@ -70,8 +70,31 @@ CacheFactory::CacheFactory(
dsProp(properties) {}
Cache CacheFactory::create() const {
- LOGFINE("CacheFactory called DistributedSystem::connect");
- auto cache = create(DEFAULT_CACHE_NAME, nullptr);
+ auto cache =
+ Cache(dsProp, ignorePdxUnreadFields, pdxReadSerialized, authInitialize);
+
+ try {
+ auto&& cacheXml =
+ cache.getDistributedSystem().getSystemProperties().cacheXMLFile();
+ if (!cacheXml.empty()) {
+ cache.initializeDeclarativeCache(cacheXml);
+ } else {
+ cache.m_cacheImpl->initServices();
+ }
+ } catch (const apache::geode::client::RegionExistsException&) {
+ LOGWARN("Attempt to create existing regions declaratively");
+ } catch (const apache::geode::client::Exception&) {
+ if (!cache.isClosed()) {
+ cache.close();
+ }
+ throw;
+ } catch (...) {
+ if (!cache.isClosed()) {
+ cache.close();
+ }
+ throw apache::geode::client::UnknownException(
+ "Exception thrown in CacheFactory::create");
+ }
auto& cacheImpl = cache.m_cacheImpl;
const auto& serializationRegistry = cacheImpl->getSerializationRegistry();
@@ -105,9 +128,8 @@ Cache CacheFactory::create() const {
}
Cache CacheFactory::create(
- std::string name,
- const std::shared_ptr<CacheAttributes>& attrs /*= nullptr*/) const {
- auto cache = Cache(name, dsProp, ignorePdxUnreadFields, pdxReadSerialized,
+ const std::shared_ptr<CacheAttributes>& attrs) const {
+ auto cache = Cache(dsProp, ignorePdxUnreadFields, pdxReadSerialized,
authInitialize);
cache.m_cacheImpl->setAttributes(attrs);
diff --git a/cppcache/src/CacheImpl.cpp b/cppcache/src/CacheImpl.cpp
index 6990c8ab..fb2c1f15 100644
--- a/cppcache/src/CacheImpl.cpp
+++ b/cppcache/src/CacheImpl.cpp
@@ -46,12 +46,10 @@
using namespace apache::geode::client;
-CacheImpl::CacheImpl(Cache* c, const std::string& name,
- std::unique_ptr<DistributedSystem> sys, bool iPUF,
- bool readPdxSerialized,
+CacheImpl::CacheImpl(Cache* c, std::unique_ptr<DistributedSystem> sys,
+ bool iPUF, bool readPdxSerialized,
const std::shared_ptr<AuthInitialize>& authInitialize)
- : m_name(name),
- m_defaultPool(nullptr),
+ : m_defaultPool(nullptr),
m_ignorePdxUnreadFields(iPUF),
m_readPdxSerialized(readPdxSerialized),
m_closed(false),
@@ -217,10 +215,7 @@ CacheImpl::~CacheImpl() {
}
const std::string& CacheImpl::getName() const {
- if (m_closed || m_destroyPending) {
- throw CacheClosedException("Cache::getName: cache closed");
- }
- return m_name;
+ return m_distributedSystem->getName();
}
bool CacheImpl::isClosed() const { return m_closed; }
diff --git a/cppcache/src/CacheImpl.hpp b/cppcache/src/CacheImpl.hpp
index 65fa0d40..cdc362fa 100644
--- a/cppcache/src/CacheImpl.hpp
+++ b/cppcache/src/CacheImpl.hpp
@@ -213,9 +213,9 @@ class CPPCACHE_EXPORT CacheImpl : private NonCopyable,
private NonAssignable {
/**
* @brief constructors
*/
- CacheImpl(Cache* c, const std::string& name,
- std::unique_ptr<DistributedSystem> sys, bool ignorePdxUnreadFields,
- bool readPdxSerialized, const std::shared_ptr<AuthInitialize>&
authInitialize);
+ CacheImpl(Cache* c, std::unique_ptr<DistributedSystem> sys,
+ bool ignorePdxUnreadFields, bool readPdxSerialized,
+ const std::shared_ptr<AuthInitialize>& authInitialize);
void initServices();
EvictionController* getEvictionController();
@@ -334,7 +334,6 @@ class CPPCACHE_EXPORT CacheImpl : private NonCopyable,
private NonAssignable {
void setCache(Cache* cache);
- std::string m_name;
bool m_closed;
bool m_initialized;
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Cache::Name should be tied to DistributedSystem::Name
> ------------------------------------------------------
>
> Key: GEODE-3998
> URL: https://issues.apache.org/jira/browse/GEODE-3998
> Project: Geode
> Issue Type: Improvement
> Components: native client
> Reporter: Jacob S. Barrett
> Assignee: Jacob S. Barrett
>
> After the removal of globals the CacheFactory::create() method does't take a
> name and creates all Cache's with DEFAULT_CACHE_NAME. The Java client uses
> the distributed system name. The native clients should use the distribute
> system name as configured by the default ds name or system property to be
> consistent with the Java client.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)