VMware GemFire Native C++ Reference  9.1
CacheFactory.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #ifndef GEODE_CACHEFACTORY_H_
4 #define GEODE_CACHEFACTORY_H_
5 
6 /*
7  * Licensed to the Apache Software Foundation (ASF) under one or more
8  * contributor license agreements. See the NOTICE file distributed with
9  * this work for additional information regarding copyright ownership.
10  * The ASF licenses this file to You under the Apache License, Version 2.0
11  * (the "License"); you may not use this file except in compliance with
12  * the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  */
22 
23 #include "geode_globals.hpp"
24 #include "geode_types.hpp"
25 #include "DistributedSystem.hpp"
26 #include "Cache.hpp"
27 #include "CacheAttributes.hpp"
28 #include "PoolFactory.hpp"
33 #define DEFAULT_POOL_NAME "default_geodeClientPool"
34 
35 namespace apache {
36 namespace geode {
37 namespace client {
38 
39 class CppCacheLibrary;
49  public:
55  static CacheFactoryPtr createCacheFactory(
56  const PropertiesPtr& dsProps = NULLPTR);
57 
61  CachePtr create();
62 
73  static CachePtr getInstance(const DistributedSystemPtr& system);
74 
85  static CachePtr getInstanceCloseOk(const DistributedSystemPtr& system);
86 
93  static CachePtr getAnyInstance();
94 
99  static const char* getVersion();
100 
103  static const char* getProductDescription();
104 
119  CacheFactoryPtr setFreeConnectionTimeout(int connectionTimeout);
131  CacheFactoryPtr setLoadConditioningInterval(int loadConditioningInterval);
143  CacheFactoryPtr setSocketBufferSize(int bufferSize);
144 
162  CacheFactoryPtr setThreadLocalConnections(bool threadLocalConnections);
163 
173  CacheFactoryPtr setReadTimeout(int timeout);
174 
187  CacheFactoryPtr setMinConnections(int minConnections);
188 
202  CacheFactoryPtr setMaxConnections(int maxConnections);
203 
219  CacheFactoryPtr setIdleTimeout(long idleTimeout);
220 
230  CacheFactoryPtr setRetryAttempts(int retryAttempts);
231 
248  CacheFactoryPtr setPingInterval(long pingInterval);
249 
258  CacheFactoryPtr setUpdateLocatorListInterval(long updateLocatorListInterval);
259 
272  CacheFactoryPtr setStatisticInterval(int statisticInterval);
273 
282  CacheFactoryPtr setServerGroup(const char* group);
283 
301  CacheFactoryPtr addLocator(const char* host, int port);
302 
318  CacheFactoryPtr addServer(const char* host, int port);
319 
328  CacheFactoryPtr setSubscriptionEnabled(bool enabled);
342  CacheFactoryPtr setSubscriptionRedundancy(int redundancy);
357  CacheFactoryPtr setSubscriptionMessageTrackingTimeout(
358  int messageTrackingTimeout);
359 
372  CacheFactoryPtr setSubscriptionAckInterval(int ackInterval);
373 
383  CacheFactoryPtr setMultiuserAuthentication(bool multiuserAuthentication);
384 
406  CacheFactoryPtr setPRSingleHopEnabled(bool enabled);
407 
430  CacheFactoryPtr setPdxIgnoreUnreadFields(bool ignore);
431 
450  CacheFactoryPtr setPdxReadSerialized(bool pdxReadSerialized);
451 
459  CacheFactoryPtr set(const char* name, const char* value);
460 
461  private:
462  PoolFactoryPtr pf;
463  PropertiesPtr dsProp;
464  bool ignorePdxUnreadFields;
465  bool pdxReadSerialized;
466 
467  PoolFactoryPtr getPoolFactory();
468 
469  CachePtr create(const char* name, DistributedSystemPtr system = NULLPTR,
470  const char* cacheXml = 0,
471  const CacheAttributesPtr& attrs = NULLPTR);
472 
473  static void create_(const char* name, DistributedSystemPtr& system,
474  const char* id_data, CachePtr& cptr,
475  bool ignorePdxUnreadFields, bool readPdxSerialized);
476 
477  // no instances allowed
478  CacheFactory();
479  CacheFactory(const PropertiesPtr dsProps);
480  ~CacheFactory();
481 
482  PoolPtr determineDefaultPool(CachePtr cachePtr);
483 
484  static CachePtr getAnyInstance(bool throwException);
485  static GfErrType basicGetInstance(const DistributedSystemPtr& system,
486  bool closeOk, CachePtr& cptr);
487 
488  // Set very first time some creates cache
489  static CacheFactoryPtr default_CacheFactory;
490  static PoolPtr createOrGetDefaultPool();
491  static void* m_cacheMap;
492  static void init();
493  static void cleanup();
494  static void handleXML(CachePtr& cachePtr, const char* cachexml,
495  DistributedSystemPtr& system);
496  friend class CppCacheLibrary;
497  friend class RegionFactory;
498  friend class RegionXmlCreation;
499  friend class CacheXmlCreation;
500 };
501 } // namespace client
502 } // namespace geode
503 } // namespace apache
504 
505 #endif // GEODE_CACHEFACTORY_H_
Each enum represents a predefined RegionAttributes in a Cache.
Definition: Assert.hpp:31
#define CPPCACHE_EXPORT
Defines a Geode CPPCACHE export.
Definition: geode_base.hpp:58
GfErrType
Error codes returned by Geode C++ interface functions.
Definition: geode_base.hpp:182
Top level class for configuring and using Geode on a client.This should be called once to create Cach...
Definition: CacheFactory.hpp:48
Defines a reference counted shared pointer.
Definition: SharedPtr.hpp:52
This abstract base class is the base class of all user objects that have the shared capability of ref...
Definition: SharedBase.hpp:40
This namespace contains all the Geode C++ API classes, enumerations and globals.

Pivotal GemFire C++ Cache API Documentation