VMware Tanzu GemFire Native C++ Reference  10.1.5
RegionAttributes.hpp
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #pragma once
19 
20 #ifndef GEODE_REGIONATTRIBUTES_H_
21 #define GEODE_REGIONATTRIBUTES_H_
22 
27 #include <chrono>
28 
29 #include "CacheListener.hpp"
30 #include "CacheLoader.hpp"
31 #include "CacheWriter.hpp"
32 #include "DiskPolicyType.hpp"
33 #include "ExpirationAttributes.hpp"
34 #include "PartitionResolver.hpp"
35 #include "Properties.hpp"
36 #include "Serializable.hpp"
37 #include "internal/DataSerializableInternal.hpp"
38 #include "internal/chrono/duration.hpp"
39 #include "internal/geode_globals.hpp"
40 
41 namespace apache {
42 namespace geode {
43 namespace client {
44 
45 class CacheImpl;
46 class RegionAttributesFactory;
47 class AttributesMutator;
48 class Cache;
49 class Region;
50 class PersistenceManager;
51 
76 class APACHE_GEODE_EXPORT RegionAttributes
77  : public internal::DataSerializableInternal {
81  public:
87  std::shared_ptr<CacheLoader> getCacheLoader() const;
88 
94  std::shared_ptr<CacheWriter> getCacheWriter() const;
95 
101  std::shared_ptr<CacheListener> getCacheListener() const;
102 
109  std::shared_ptr<PartitionResolver> getPartitionResolver() const;
110 
115  std::chrono::seconds getRegionTimeToLive() const;
116 
117  ExpirationAction getRegionTimeToLiveAction() const;
118 
123  std::chrono::seconds getRegionIdleTimeout() const;
124 
125  ExpirationAction getRegionIdleTimeoutAction() const;
126 
131  std::chrono::seconds getEntryTimeToLive() const;
132 
133  ExpirationAction getEntryTimeToLiveAction() const;
134 
140  std::chrono::seconds getEntryIdleTimeout() const;
141 
142  ExpirationAction getEntryIdleTimeoutAction() const;
143 
148  inline bool getCachingEnabled() const { return m_caching; }
149 
150  // MAP ATTRIBUTES
151 
155  int getInitialCapacity() const;
156 
160  float getLoadFactor() const;
161 
166  uint8_t getConcurrencyLevel() const;
167 
172  uint32_t getLruEntriesLimit() const;
173 
180 
186 
190  const std::string& getPoolName() const { return m_poolName; }
191 
192  // will be created by the factory
194  RegionAttributes(const RegionAttributes& rhs) = default;
195 
196  /*destructor
197  *
198  */
199  ~RegionAttributes() noexcept override;
200 
202  static std::shared_ptr<Serializable> createDeserializable();
203 
204  void toData(DataOutput& out) const override;
205 
206  void fromData(DataInput& in) override;
207 
212  const std::string& getCacheLoaderLibrary() const;
213 
218  const std::string& getCacheLoaderFactory() const;
219 
224  const std::string& getCacheListenerLibrary() const;
225 
230  const std::string& getCacheListenerFactory() const;
231 
236  const std::string& getCacheWriterLibrary() const;
237 
242  const std::string& getCacheWriterFactory() const;
243 
248  const std::string& getPartitionResolverLibrary() const;
249 
254  const std::string& getPartitionResolverFactory() const;
255 
257  bool operator==(const RegionAttributes& other) const;
258 
260  bool operator!=(const RegionAttributes& other) const;
261 
267  void validateSerializableAttributes();
268 
272  const std::string& getEndpoints() const;
273 
277  bool getClientNotificationEnabled() const;
278 
283  const std::string& getPersistenceLibrary() const;
284 
289  const std::string& getPersistenceFactory() const;
290 
294  std::shared_ptr<Properties> getPersistenceProperties() const;
295 
302  std::shared_ptr<PersistenceManager> getPersistenceManager() const;
303 
304  bool getCloningEnabled() const { return m_isClonable; }
305 
312  return m_isConcurrencyChecksEnabled;
313  }
314  RegionAttributes& operator=(const RegionAttributes&) = default;
315 
316  private:
317  void setCacheListener(const std::string& libpath,
318  const std::string& factoryFuncName);
319  void setCacheLoader(const std::string& libpath,
320  const std::string& factoryFuncName);
321  void setCacheWriter(const std::string& libpath,
322  const std::string& factoryFuncName);
323  void setPartitionResolver(const std::string& libpath,
324  const std::string& factoryFuncName);
325  void setPersistenceManager(const std::string& lib, const std::string& func,
326  const std::shared_ptr<Properties>& config);
327  void setEndpoints(const std::string& endpoints);
328  void setPoolName(const std::string& poolName);
329  void setCloningEnabled(bool isClonable);
330  void setCachingEnabled(bool enable);
331  void setLruEntriesLimit(int limit);
332  void setDiskPolicy(DiskPolicyType diskPolicy);
333  void setConcurrencyChecksEnabled(bool enable);
334 
335  inline bool getEntryExpiryEnabled() const {
336  return (m_entryTimeToLive > std::chrono::seconds::zero() ||
337  m_entryIdleTimeout > std::chrono::seconds::zero());
338  }
339 
340  inline bool getRegionExpiryEnabled() const {
341  return (m_regionTimeToLive > std::chrono::seconds::zero() ||
342  m_regionIdleTimeout > std::chrono::seconds::zero());
343  }
344 
345  ExpirationAction m_regionTimeToLiveExpirationAction;
346  ExpirationAction m_regionIdleTimeoutExpirationAction;
347  ExpirationAction m_entryTimeToLiveExpirationAction;
348  ExpirationAction m_entryIdleTimeoutExpirationAction;
349  ExpirationAction m_lruEvictionAction;
350  mutable std::shared_ptr<CacheWriter> m_cacheWriter;
351  mutable std::shared_ptr<CacheLoader> m_cacheLoader;
352  mutable std::shared_ptr<CacheListener> m_cacheListener;
353  mutable std::shared_ptr<PartitionResolver> m_partitionResolver;
354  uint32_t m_lruEntriesLimit;
355  bool m_caching;
356  uint32_t m_maxValueDistLimit;
357  std::chrono::seconds m_entryIdleTimeout;
358  std::chrono::seconds m_entryTimeToLive;
359  std::chrono::seconds m_regionIdleTimeout;
360  std::chrono::seconds m_regionTimeToLive;
361  uint32_t m_initialCapacity;
362  float m_loadFactor;
363  uint8_t m_concurrencyLevel;
364  std::string m_cacheLoaderLibrary;
365  std::string m_cacheWriterLibrary;
366  std::string m_cacheListenerLibrary;
367  std::string m_partitionResolverLibrary;
368  std::string m_cacheLoaderFactory;
369  std::string m_cacheWriterFactory;
370  std::string m_cacheListenerFactory;
371  std::string m_partitionResolverFactory;
372  DiskPolicyType m_diskPolicy;
373  std::string m_endpoints;
374  bool m_clientNotificationEnabled;
375  std::string m_persistenceLibrary;
376  std::string m_persistenceFactory;
377  std::shared_ptr<Properties> m_persistenceProperties;
378  mutable std::shared_ptr<PersistenceManager> m_persistenceManager;
379  std::string m_poolName;
380  bool m_isClonable;
381  bool m_isConcurrencyChecksEnabled;
382  friend class RegionAttributesFactory;
383  friend class AttributesMutator;
384  friend class Cache;
385  friend class CacheImpl;
386  friend class Region;
387  friend class RegionInternal;
388  friend class RegionXmlCreation;
389 
390  private:
391 };
392 
393 } // namespace client
394 } // namespace geode
395 } // namespace apache
396 
397 #endif // GEODE_REGIONATTRIBUTES_H_
apache::geode::client::RegionAttributes::getRegionIdleTimeout
std::chrono::seconds getRegionIdleTimeout() const
Gets the idleTimeout expiration attributes for the region as a whole.
apache::geode::client::Properties
Contains a set of (key, value) pair properties with key being the name of the property; value,...
Definition: Properties.hpp:52
apache::geode::client::RegionAttributes::getConcurrencyChecksEnabled
bool getConcurrencyChecksEnabled() const
Returns true if concurrent update checks are turned on for this region.
Definition: RegionAttributes.hpp:311
apache::geode::client::RegionAttributes::getEntryIdleTimeout
std::chrono::seconds getEntryIdleTimeout() const
Gets the idleTimeout expiration attributes for entries in this region.
ExpirationAttributes.hpp
apache::geode::client::RegionAttributes::getPartitionResolver
std::shared_ptr< PartitionResolver > getPartitionResolver() const
Gets the partition resolver for the partition region.
ExpirationAction
Enumerated type for expiration actions.
apache::geode::client::RegionAttributes::getRegionTimeToLive
std::chrono::seconds getRegionTimeToLive() const
Gets the timeToLive expiration attributes for the region as a whole.
apache::geode::client::RegionAttributes::getConcurrencyLevel
uint8_t getConcurrencyLevel() const
Returns the concurrencyLevel of the entry's local cache.
apache::geode::client::RegionAttributes::getLruEvictionAction
ExpirationAction getLruEvictionAction() const
Returns the ExpirationAction used for LRU Eviction, default is LOCAL_DESTROY.
apache::geode::client::Serializable
This base class is the superclass of all user objects in the cache that can be serialized.
Definition: Serializable.hpp:53
apache::geode::client::PersistenceManager
PersistenceManager API for persistence and overflow.
Definition: PersistenceManager.hpp:52
apache::geode::client::RegionAttributes::getEntryTimeToLive
std::chrono::seconds getEntryTimeToLive() const
Gets the timeToLive expiration attributes for entries in this region.
apache::geode::client::RegionAttributes::getCacheLoader
std::shared_ptr< CacheLoader > getCacheLoader() const
public static methods
apache::geode::client::RegionAttributes::getPoolName
const std::string & getPoolName() const
Returns the name of the pool attached to the region.
Definition: RegionAttributes.hpp:190
apache::geode::client::DataOutput
Provide operations for writing primitive data values, byte arrays, strings, Serializable objects to a...
Definition: DataOutput.hpp:48
CacheLoader.hpp
apache::geode::client::RegionAttributes::getCachingEnabled
bool getCachingEnabled() const
If true, this region will store data in the current process.
Definition: RegionAttributes.hpp:148
DiskPolicyType.hpp
apache::geode::client::RegionAttributes
Defines attributes for configuring a region.
Definition: RegionAttributes.hpp:77
apache::geode::client::DataInput
Provide operations for reading primitive data values, byte arrays, strings, Serializable objects from...
Definition: DataInput.hpp:59
apache::geode::client::RegionAttributes::getCacheWriter
std::shared_ptr< CacheWriter > getCacheWriter() const
Gets the cache writer for the region.
DiskPolicyType
Enumerated type for disk policy.
apache::geode::client::RegionAttributes::getCacheListener
std::shared_ptr< CacheListener > getCacheListener() const
Gets the cache listener for the region.
apache::geode::client::RegionAttributes::getLruEntriesLimit
uint32_t getLruEntriesLimit() const
Returns the maximum number of entries this cache will hold before using LRU eviction.
apache::geode::client::RegionAttributes::getLoadFactor
float getLoadFactor() const
Returns the load factor of the entry's local cache.
apache::geode::client::RegionAttributes::getDiskPolicy
DiskPolicyType getDiskPolicy() const
Returns the disk policy type of the region.
CacheListener.hpp
apache::geode::client::RegionAttributes::getInitialCapacity
int getInitialCapacity() const
Returns the initial capacity of the entry's local cache.
Properties.hpp

Apache Geode C++ Cache API Documentation