16 #ifndef HAZELCAST_CLIENT_CONFIG_EVICTIONCONFIG_H_
17 #define HAZELCAST_CLIENT_CONFIG_EVICTIONCONFIG_H_
21 #include <boost/shared_ptr.hpp>
24 #include "hazelcast/client/internal/eviction/EvictionPolicyComparator.h"
25 #include "hazelcast/util/Preconditions.h"
26 #include "hazelcast/util/HazelcastDll.h"
27 #include "hazelcast/client/internal/eviction/EvictionConfiguration.h"
28 #include "hazelcast/client/config/EvictionPolicy.h"
30 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
32 #pragma warning(disable: 4251) //for dll export
42 template<
typename K,
typename V>
92 EvictionConfig() : size(DEFAULT_MAX_ENTRY_COUNT), maxSizePolicy(DEFAULT_MAX_SIZE_POLICY),
93 evictionPolicy(DEFAULT_EVICTION_POLICY) {
99 this->size = util::Preconditions::checkPositive(size,
"Size must be positive number!");
100 this->maxSizePolicy = maxSizePolicy;
101 this->comparator = util::Preconditions::checkNotNull<internal::eviction::EvictionPolicyComparator>(
102 comparator,
"Comparator cannot be null!");
105 int32_t getSize()
const {
109 EvictionConfig &setSize(int32_t size) {
110 this->size = util::Preconditions::checkPositive(size,
"Size must be positive number!");
115 return maxSizePolicy;
118 EvictionConfig &setMaximumSizePolicy(
const MaxSizePolicy &maxSizePolicy) {
119 this->maxSizePolicy = maxSizePolicy;
123 EvictionPolicy getEvictionPolicy()
const {
124 return evictionPolicy;
127 EvictionConfig<K, V> &setEvictionPolicy(EvictionPolicy policy) {
128 this->evictionPolicy = policy;
132 const boost::shared_ptr<internal::eviction::EvictionPolicyComparator<K, V> >
getComparator()
const {
138 this->comparator = comparator;
148 if (evictionPolicy == LFU) {
149 return internal::eviction::LFU;
150 }
else if (evictionPolicy == LRU) {
151 return internal::eviction::LRU;
152 }
else if (evictionPolicy == RANDOM) {
153 return internal::eviction::RANDOM;
154 }
else if (evictionPolicy == NONE) {
155 return internal::eviction::NONE;
159 return internal::eviction::NONE;
165 EvictionPolicy evictionPolicy;
166 boost::shared_ptr<internal::eviction::EvictionPolicyComparator<K, V> > comparator;
169 template <
typename K,
typename V>
170 std::ostream &operator<<(std::ostream &out, const EvictionConfig<K, V> &config) {
171 out <<
"EvictionConfig{"
172 <<
"size=" << config.getSize()
173 <<
", maxSizePolicy=" << config.getMaximumSizePolicy()
174 <<
", evictionPolicy=" << config.getEvictionPolicy()
175 <<
", comparator=" << config.getComparator()
184 template <
typename K,
typename V>
185 const int EvictionConfig<K, V>::DEFAULT_MAX_ENTRY_COUNT = INT32_MAX;
190 template <
typename K,
typename V>
191 const typename EvictionConfig<K, V>::MaxSizePolicy EvictionConfig<K, V>::DEFAULT_MAX_SIZE_POLICY = ENTRY_COUNT;
196 template <
typename K,
typename V>
197 const EvictionPolicy EvictionConfig<K, V>::DEFAULT_EVICTION_POLICY = LRU;
202 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
Configuration for eviction.
Definition: EvictionConfig.h:43
internal::eviction::EvictionPolicyType getEvictionPolicyType() const
Gets the type of eviction policy.
Definition: EvictionConfig.h:147
static const int32_t DEFAULT_MAX_ENTRY_COUNT
Default maximum entry count.
Definition: EvictionConfig.h:80
internal::eviction::EvictionStrategyType::Type getEvictionStrategyType() const
Gets the type of eviction strategy.
Definition: EvictionConfig.h:142
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:132
static const EvictionPolicy DEFAULT_EVICTION_POLICY
Default Eviction Policy.
Definition: EvictionConfig.h:90
static const MaxSizePolicy DEFAULT_MAX_SIZE_POLICY
Default Max-Size Policy.
Definition: EvictionConfig.h:85
MaxSizePolicy
Maximum Size Policy.
Definition: EvictionConfig.h:51
Definition: MapEntryView.h:32
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:55
Interface for configuration information about eviction.
Definition: EvictionConfiguration.h:38