VMware GemFire Native C++ Reference  9.1
RegionAttributes.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #ifndef GEODE_REGIONATTRIBUTES_H_
4 #define GEODE_REGIONATTRIBUTES_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 
27 #include "geode_globals.hpp"
28 #include "geode_types.hpp"
29 #include "CacheLoader.hpp"
30 #include "ExpirationAttributes.hpp"
31 #include "CacheWriter.hpp"
32 #include "CacheListener.hpp"
33 #include "PartitionResolver.hpp"
34 #include "Properties.hpp"
35 #include "Serializable.hpp"
36 #include "DiskPolicyType.hpp"
37 #include "PersistenceManager.hpp"
38 
39 namespace apache {
40 namespace geode {
41 namespace client {
42 class CacheImpl;
43 
67 class AttributesFactory;
68 class AttributesMutator;
69 class Cache;
70 class Region;
71 
76  public:
82  CacheLoaderPtr getCacheLoader();
83 
89  CacheWriterPtr getCacheWriter();
90 
96  CacheListenerPtr getCacheListener();
97 
104  PartitionResolverPtr getPartitionResolver();
105 
110  int getRegionTimeToLive();
111  ExpirationAction::Action getRegionTimeToLiveAction();
112 
117  int getRegionIdleTimeout();
118  ExpirationAction::Action getRegionIdleTimeoutAction();
119 
124  int getEntryTimeToLive();
125  ExpirationAction::Action getEntryTimeToLiveAction();
126 
131  int getEntryIdleTimeout();
132  ExpirationAction::Action getEntryIdleTimeoutAction();
133 
138  inline bool getCachingEnabled() const { return m_caching; }
139 
140  // MAP ATTRIBUTES
141 
145  int getInitialCapacity() const;
146 
150  float getLoadFactor() const;
151 
156  uint8_t getConcurrencyLevel() const;
157 
162  uint32_t getLruEntriesLimit() const;
163 
169  DiskPolicyType::PolicyType getDiskPolicy() const;
170 
175  const ExpirationAction::Action getLruEvictionAction() const;
176 
180  const char* getPoolName() const;
181 
182  /*destructor
183  *
184  */
185  virtual ~RegionAttributes();
186 
188  virtual void toData(DataOutput& out) const;
189 
191  virtual Serializable* fromData(DataInput& in);
192 
194  static Serializable* createDeserializable();
195 
197  virtual int32_t classId() const;
198 
200  virtual int8_t typeId() const;
201 
202  // return zero deliberately
203  virtual uint32_t objectSize() const { return 0; }
204 
209  const char* getCacheLoaderLibrary();
210 
215  const char* getCacheLoaderFactory();
216 
221  const char* getCacheListenerLibrary();
222 
227  const char* getCacheListenerFactory();
228 
233  const char* getCacheWriterLibrary();
234 
239  const char* getCacheWriterFactory();
240 
245  const char* getPartitionResolverLibrary();
246 
251  const char* getPartitionResolverFactory();
252 
254  bool operator==(const RegionAttributes& other) const;
255 
257  bool operator!=(const RegionAttributes& other) const;
258 
264  void validateSerializableAttributes();
265 
269  const char* getEndpoints();
270 
274  bool getClientNotificationEnabled() const;
275 
280  const char* getPersistenceLibrary();
281 
286  const char* getPersistenceFactory();
287 
291  PropertiesPtr getPersistenceProperties();
292 
299  PersistenceManagerPtr getPersistenceManager();
300 
306  const char* getPoolName() { return m_poolName; }
307  bool getCloningEnabled() { return m_isClonable; }
308 
314  bool getConcurrencyChecksEnabled() { return m_isConcurrencyChecksEnabled; }
315 
316  private:
317  // Helper function that safely compares two attribute string
318  // taking into consideration the fact the one or the other
319  // might be NULL
320  static int32_t compareStringAttribute(char* attributeA, char* attributeB);
321 
322  // Helper function that safely copies one string attribute to
323  // another.
324  static void copyStringAttribute(char*& lhs, const char* rhs);
325 
326  void setCacheListener(const char* libpath, const char* factoryFuncName);
327  void setCacheLoader(const char* libpath, const char* factoryFuncName);
328  void setCacheWriter(const char* libpath, const char* factoryFuncName);
329  void setPartitionResolver(const char* libpath, const char* factoryFuncName);
330  void setPersistenceManager(const char* lib, const char* func,
331  const PropertiesPtr& config);
332  void setEndpoints(const char* endpoints);
333  void setPoolName(const char* poolName);
334  void setCloningEnabled(bool isClonable);
335  void setCachingEnabled(bool enable);
336  void setLruEntriesLimit(int limit);
337  void setDiskPolicy(DiskPolicyType::PolicyType diskPolicy);
338  void setConcurrencyChecksEnabled(bool enable);
339  inline bool getEntryExpiryEnabled() const {
340  return (m_entryTimeToLive != 0 || m_entryIdleTimeout != 0);
341  }
342 
343  inline bool getRegionExpiryEnabled() const {
344  return (m_regionTimeToLive != 0 || m_regionIdleTimeout != 0);
345  }
346 
347  // will be created by the factory
350 
351  ExpirationAction::Action m_regionTimeToLiveExpirationAction;
352  ExpirationAction::Action m_regionIdleTimeoutExpirationAction;
353  ExpirationAction::Action m_entryTimeToLiveExpirationAction;
354  ExpirationAction::Action m_entryIdleTimeoutExpirationAction;
355  ExpirationAction::Action m_lruEvictionAction;
356  CacheWriterPtr m_cacheWriter;
357  CacheLoaderPtr m_cacheLoader;
358  CacheListenerPtr m_cacheListener;
359  PartitionResolverPtr m_partitionResolver;
360  uint32_t m_lruEntriesLimit;
361  bool m_caching;
362  uint32_t m_maxValueDistLimit;
363  uint32_t m_entryIdleTimeout;
364  uint32_t m_entryTimeToLive;
365  uint32_t m_regionIdleTimeout;
366  uint32_t m_regionTimeToLive;
367  uint32_t m_initialCapacity;
368  float m_loadFactor;
369  uint8_t m_concurrencyLevel;
370  char* m_cacheLoaderLibrary;
371  char* m_cacheWriterLibrary;
372  char* m_cacheListenerLibrary;
373  char* m_partitionResolverLibrary;
374  char* m_cacheLoaderFactory;
375  char* m_cacheWriterFactory;
376  char* m_cacheListenerFactory;
377  char* m_partitionResolverFactory;
378  DiskPolicyType::PolicyType m_diskPolicy;
379  char* m_endpoints;
380  bool m_clientNotificationEnabled;
381  char* m_persistenceLibrary;
382  char* m_persistenceFactory;
383  PropertiesPtr m_persistenceProperties;
384  PersistenceManagerPtr m_persistenceManager;
385  char* m_poolName;
386  bool m_isClonable;
387  bool m_isConcurrencyChecksEnabled;
388  friend class AttributesFactory;
389  friend class AttributesMutator;
390  friend class Cache;
391  friend class CacheImpl;
392  friend class Region;
393  friend class RegionInternal;
394  friend class RegionXmlCreation;
395 
396  private:
397  const RegionAttributes& operator=(const RegionAttributes&);
398 };
399 } // namespace client
400 } // namespace geode
401 } // namespace apache
402 
403 #endif // GEODE_REGIONATTRIBUTES_H_
bool getCachingEnabled() const
If true, this region will store data in the current process.
Definition: RegionAttributes.hpp:138
PolicyType
Values for setting PolicyType.
Definition: DiskPolicyType.hpp:43
Creates instances of RegionAttributes.
Definition: AttributesFactory.hpp:152
Each enum represents a predefined RegionAttributes in a Cache.
Definition: Assert.hpp:31
Defines attributes for configuring a region.
Definition: RegionAttributes.hpp:72
const char * getPoolName()
TODO Returns the name of the Pool that this region will use to communicate with servers, if any.
Definition: RegionAttributes.hpp:306
#define CPPCACHE_EXPORT
Defines a Geode CPPCACHE export.
Definition: geode_base.hpp:58
Provide operations for writing primitive data values, byte arrays, strings, Serializable objects to a...
Definition: DataOutput.hpp:74
virtual uint32_t objectSize() const
return the size in bytes of the instance being serialized.
Definition: RegionAttributes.hpp:203
bool getConcurrencyChecksEnabled()
Returns true if concurrent update checks are turned on for this region.
Definition: RegionAttributes.hpp:314
This abstract base class is the superclass of all user objects in the cache that can be serialized...
Definition: Serializable.hpp:53
Action
Definition: ExpirationAction.hpp:43
Provide operations for reading primitive data values, byte arrays, strings, Serializable objects from...
Definition: DataInput.hpp:56
Supports modification of certain region attributes after the region has been created.
Definition: AttributesMutator.hpp:55
This class manages subregions and cached data.
Definition: Region.hpp:87
This namespace contains all the Geode C++ API classes, enumerations and globals.
Cache are obtained from create method on the CacheFactory#create class.
Definition: Cache.hpp:59

Pivotal GemFire C++ Cache API Documentation