16 #ifndef HAZELCAST_CLIENT_CONFIG_EVICTIONCONFIG_H_
17 #define HAZELCAST_CLIENT_CONFIG_EVICTIONCONFIG_H_
21 #include <boost/shared_ptr.hpp>
23 #include "hazelcast/client/internal/eviction/EvictionPolicyComparator.h"
24 #include "hazelcast/util/Preconditions.h"
25 #include "hazelcast/util/HazelcastDll.h"
26 #include "hazelcast/client/internal/eviction/EvictionConfiguration.h"
27 #include "hazelcast/client/config/EvictionPolicy.h"
29 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
31 #pragma warning(disable: 4251) //for dll export
41 template<
typename K,
typename V>
98 this->size = util::Preconditions::checkPositive(size,
"Size must be positive number!");
99 this->maxSizePolicy = maxSizePolicy;
100 this->comparator = util::Preconditions::checkNotNull<internal::eviction::EvictionPolicyComparator>(
101 comparator,
"Comparator cannot be null!");
104 int32_t getSize()
const {
108 EvictionConfig &setSize(int32_t size) {
109 this->size = util::Preconditions::checkPositive(size,
"Size must be positive number!");
114 return maxSizePolicy;
117 EvictionConfig &setMaximumSizePolicy(
const MaxSizePolicy &maxSizePolicy) {
118 this->maxSizePolicy = maxSizePolicy;
122 EvictionPolicy getEvictionPolicy()
const {
123 return evictionPolicy;
126 EvictionConfig<K, V> &setEvictionPolicy(EvictionPolicy policy) {
127 this->evictionPolicy = policy;
131 const boost::shared_ptr<internal::eviction::EvictionPolicyComparator<K, V> >
getComparator()
const {
137 this->comparator = comparator;
147 if (evictionPolicy == LFU) {
148 return internal::eviction::LFU;
149 }
else if (evictionPolicy == LRU) {
150 return internal::eviction::LRU;
151 }
else if (evictionPolicy == RANDOM) {
152 return internal::eviction::RANDOM;
153 }
else if (evictionPolicy == NONE) {
154 return internal::eviction::NONE;
158 return internal::eviction::NONE;
161 std::ostream &operator<<(std::ostream &out) {
162 out <<
"EvictionConfig{"
163 <<
"size=" << getSize()
164 <<
", maxSizePolicy=" << getMaximumSizePolicy()
165 <<
", evictionPolicy=" << getEvictionPolicy()
174 EvictionPolicy evictionPolicy;
175 boost::shared_ptr<internal::eviction::EvictionPolicyComparator<K, V> > comparator;
181 template <
typename K,
typename V>
182 const int EvictionConfig<K, V>::DEFAULT_MAX_ENTRY_COUNT = INT32_MAX;
187 template <
typename K,
typename V>
188 const typename EvictionConfig<K, V>::MaxSizePolicy EvictionConfig<K, V>::DEFAULT_MAX_SIZE_POLICY = ENTRY_COUNT;
193 template <
typename K,
typename V>
194 const EvictionPolicy EvictionConfig<K, V>::DEFAULT_EVICTION_POLICY = LRU;
199 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
Configuration for eviction.
Definition: EvictionConfig.h:42
internal::eviction::EvictionPolicyType getEvictionPolicyType() const
Gets the type of eviction policy.
Definition: EvictionConfig.h:146
static const int32_t DEFAULT_MAX_ENTRY_COUNT
Default maximum entry count.
Definition: EvictionConfig.h:79
internal::eviction::EvictionStrategyType::Type getEvictionStrategyType() const
Gets the type of eviction strategy.
Definition: EvictionConfig.h:141
Type
Definition: EvictionStrategyType.h:35
A kind of java.util.Comparator to be used while comparing entries to be evicted.
Definition: EvictionPolicyComparator.h:38
const boost::shared_ptr< internal::eviction::EvictionPolicyComparator< K, V > > getComparator() const
Gets the class name of the configured EvictionPolicyComparator implementation.
Definition: EvictionConfig.h:131
static const EvictionPolicy DEFAULT_EVICTION_POLICY
Default Eviction Policy.
Definition: EvictionConfig.h:89
static const MaxSizePolicy DEFAULT_MAX_SIZE_POLICY
Default Max-Size Policy.
Definition: EvictionConfig.h:84
MaxSizePolicy
Maximum Size Policy.
Definition: EvictionConfig.h:50
static const Type DEFAULT_EVICTION_STRATEGY
Default value of com.hazelcast.internal.eviction.EvictionStrategyType.
Definition: EvictionStrategyType.h:44
Policy based on maximum number of entries stored per data structure (map, cache etc) ...
Definition: EvictionConfig.h:54
Interface for configuration information about eviction.
Definition: EvictionConfiguration.h:38