VMware Tanzu GemFire Native C++ Reference 10.3.0
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"
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
41namespace apache {
42namespace geode {
43namespace client {
44
45class CacheImpl;
46class RegionAttributesFactory;
47class AttributesMutator;
48class Cache;
49class Region;
50class PersistenceManager;
51
76class 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
139 std::chrono::seconds getEntryIdleTimeout() const;
140
141 ExpirationAction getEntryIdleTimeoutAction() const;
142
147 inline bool getCachingEnabled() const { return m_caching; }
148
149 // MAP ATTRIBUTES
150
155
159 float getLoadFactor() const;
160
165 uint8_t getConcurrencyLevel() const;
166
171 uint32_t getLruEntriesLimit() const;
172
179
185
189 const std::string& getPoolName() const { return m_poolName; }
190
191 // will be created by the factory
193 RegionAttributes(const RegionAttributes& rhs) = default;
194
195 /*destructor
196 *
197 */
198 ~RegionAttributes() noexcept override;
199
201 static std::shared_ptr<Serializable> createDeserializable();
202
203 void toData(DataOutput& out) const override;
204
205 void fromData(DataInput& in) override;
206
211 const std::string& getCacheLoaderLibrary() const;
212
217 const std::string& getCacheLoaderFactory() const;
218
223 const std::string& getCacheListenerLibrary() const;
224
229 const std::string& getCacheListenerFactory() const;
230
235 const std::string& getCacheWriterLibrary() const;
236
241 const std::string& getCacheWriterFactory() const;
242
247 const std::string& getPartitionResolverLibrary() const;
248
253 const std::string& getPartitionResolverFactory() const;
254
256 bool operator==(const RegionAttributes& other) const;
257
259 bool operator!=(const RegionAttributes& other) const;
260
266 void validateSerializableAttributes();
267
271 const std::string& getEndpoints() const;
272
276 bool getClientNotificationEnabled() const;
277
282 const std::string& getPersistenceLibrary() const;
283
288 const std::string& getPersistenceFactory() const;
289
293 std::shared_ptr<Properties> getPersistenceProperties() const;
294
301 std::shared_ptr<PersistenceManager> getPersistenceManager() const;
302
303 bool getCloningEnabled() const { return m_isClonable; }
304
311 return m_isConcurrencyChecksEnabled;
312 }
313 RegionAttributes& operator=(const RegionAttributes&) = default;
314
315 private:
316 void setCacheListener(const std::string& libpath,
317 const std::string& factoryFuncName);
318 void setCacheLoader(const std::string& libpath,
319 const std::string& factoryFuncName);
320 void setCacheWriter(const std::string& libpath,
321 const std::string& factoryFuncName);
322 void setPartitionResolver(const std::string& libpath,
323 const std::string& factoryFuncName);
324 void setPersistenceManager(const std::string& lib, const std::string& func,
325 const std::shared_ptr<Properties>& config);
326 void setEndpoints(const std::string& endpoints);
327 void setPoolName(const std::string& poolName);
328 void setCloningEnabled(bool isClonable);
329 void setCachingEnabled(bool enable);
330 void setLruEntriesLimit(int limit);
331 void setDiskPolicy(DiskPolicyType diskPolicy);
332 void setConcurrencyChecksEnabled(bool enable);
333
334 inline bool getEntryExpiryEnabled() const {
335 return (m_entryTimeToLive > std::chrono::seconds::zero() ||
336 m_entryIdleTimeout > std::chrono::seconds::zero());
337 }
338
339 inline bool getRegionExpiryEnabled() const {
340 return (m_regionTimeToLive > std::chrono::seconds::zero() ||
341 m_regionIdleTimeout > std::chrono::seconds::zero());
342 }
343
344 ExpirationAction m_regionTimeToLiveExpirationAction;
345 ExpirationAction m_regionIdleTimeoutExpirationAction;
346 ExpirationAction m_entryTimeToLiveExpirationAction;
347 ExpirationAction m_entryIdleTimeoutExpirationAction;
348 ExpirationAction m_lruEvictionAction;
349 mutable std::shared_ptr<CacheWriter> m_cacheWriter;
350 mutable std::shared_ptr<CacheLoader> m_cacheLoader;
351 mutable std::shared_ptr<CacheListener> m_cacheListener;
352 mutable std::shared_ptr<PartitionResolver> m_partitionResolver;
353 uint32_t m_lruEntriesLimit;
354 bool m_caching;
355 uint32_t m_maxValueDistLimit;
356 std::chrono::seconds m_entryIdleTimeout;
357 std::chrono::seconds m_entryTimeToLive;
358 std::chrono::seconds m_regionIdleTimeout;
359 std::chrono::seconds m_regionTimeToLive;
360 uint32_t m_initialCapacity;
361 float m_loadFactor;
362 uint8_t m_concurrencyLevel;
363 std::string m_cacheLoaderLibrary;
364 std::string m_cacheWriterLibrary;
365 std::string m_cacheListenerLibrary;
366 std::string m_partitionResolverLibrary;
367 std::string m_cacheLoaderFactory;
368 std::string m_cacheWriterFactory;
369 std::string m_cacheListenerFactory;
370 std::string m_partitionResolverFactory;
371 DiskPolicyType m_diskPolicy;
372 std::string m_endpoints;
373 bool m_clientNotificationEnabled;
374 std::string m_persistenceLibrary;
375 std::string m_persistenceFactory;
376 std::shared_ptr<Properties> m_persistenceProperties;
377 mutable std::shared_ptr<PersistenceManager> m_persistenceManager;
378 std::string m_poolName;
379 bool m_isClonable;
380 bool m_isConcurrencyChecksEnabled;
381 friend class RegionAttributesFactory;
382 friend class AttributesMutator;
383 friend class Cache;
384 friend class CacheImpl;
385 friend class Region;
386 friend class RegionInternal;
387 friend class RegionXmlCreation;
388
389 private:
390};
391
392} // namespace client
393} // namespace geode
394} // namespace apache
395
396#endif // GEODE_REGIONATTRIBUTES_H_
DiskPolicyType
DiskPolicyType.hpp Enumerated type for disk policy.
Definition: DiskPolicyType.hpp:42
ExpirationAction
ExpirationAction.hpp Enumerated type for expiration actions.
Definition: ExpirationAction.hpp:42
Provide operations for reading primitive data values, byte arrays, strings, Serializable objects from...
Definition: DataInput.hpp:59
Provide operations for writing primitive data values, byte arrays, strings, Serializable objects to a...
Definition: DataOutput.hpp:48
PersistenceManager API for persistence and overflow.
Definition: PersistenceManager.hpp:52
Contains a set of (key, value) pair properties with key being the name of the property; value,...
Definition: Properties.hpp:52
Defines attributes for configuring a region.
Definition: RegionAttributes.hpp:77
int getInitialCapacity() const
Returns the initial capacity of the entry's local cache.
std::shared_ptr< CacheWriter > getCacheWriter() const
Gets the cache writer for the region.
std::chrono::seconds getRegionTimeToLive() const
Gets the timeToLive expiration attributes for the region as a whole.
std::chrono::seconds getRegionIdleTimeout() const
Gets the idleTimeout expiration attributes for the region as a whole.
std::shared_ptr< CacheListener > getCacheListener() const
Gets the cache listener for the region.
uint8_t getConcurrencyLevel() const
Returns the concurrencyLevel of the entry's local cache.
const std::string & getPoolName() const
Returns the name of the pool attached to the region.
Definition: RegionAttributes.hpp:189
bool getCachingEnabled() const
If true, this region will store data in the current process.
Definition: RegionAttributes.hpp:147
std::shared_ptr< CacheLoader > getCacheLoader() const
public static methods
std::shared_ptr< PartitionResolver > getPartitionResolver() const
Gets the partition resolver for the partition region.
uint32_t getLruEntriesLimit() const
Returns the maximum number of entries this cache will hold before using LRU eviction.
std::chrono::seconds getEntryTimeToLive() const
Gets the timeToLive expiration attributes for entries in this region.
DiskPolicyType getDiskPolicy() const
Returns the disk policy type of the region.
bool getConcurrencyChecksEnabled() const
Returns true if concurrent update checks are turned on for this region.
Definition: RegionAttributes.hpp:310
std::chrono::seconds getEntryIdleTimeout() const
Gets the idleTimeout expiration attributes for entries in this region.
float getLoadFactor() const
Returns the load factor of the entry's local cache.
ExpirationAction getLruEvictionAction() const
Returns the ExpirationAction used for LRU Eviction, default is LOCAL_DESTROY.
This base class is the superclass of all user objects in the cache that can be serialized.
Definition: Serializable.hpp:53

Apache Geode C++ Cache API Documentation