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:30 UTC
[22/27] geode-native git commit: GEODE-2729: Remove global variables
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