/
CacheConfiguration.java
1620 lines (1414 loc) · 57.7 KB
/
CacheConfiguration.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.ignite.configuration;
import org.apache.ignite.*;
import org.apache.ignite.cache.*;
import org.apache.ignite.cache.affinity.*;
import org.apache.ignite.cache.eviction.*;
import org.apache.ignite.cache.store.*;
import org.apache.ignite.internal.processors.cache.*;
import org.apache.ignite.internal.util.typedef.internal.*;
import org.apache.ignite.spi.indexing.*;
import org.jetbrains.annotations.*;
import javax.cache.configuration.*;
import java.util.*;
/**
* This class defines grid cache configuration. This configuration is passed to
* grid via {@link IgniteConfiguration#getCacheConfiguration()} method. It defines all configuration
* parameters required to start a cache within grid instance. You can have multiple caches
* configured with different names within one grid.
* <p>
* Cache configuration is set on {@link
* IgniteConfiguration#setCacheConfiguration(CacheConfiguration...)} method. This adapter is a simple bean and
* can be configured from Spring XML files (or other DI frameworks). <p> Note that absolutely all configuration
* properties are optional, so users should only change what they need.
*/
@SuppressWarnings("RedundantFieldInitialization")
public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
/** Default size of preload thread pool. */
public static final int DFLT_PRELOAD_THREAD_POOL_SIZE = 2;
/** Default preload timeout (ms).*/
public static final long DFLT_PRELOAD_TIMEOUT = 10000;
/** Time in milliseconds to wait between preload messages to avoid overloading CPU. */
public static final long DFLT_PRELOAD_THROTTLE = 0;
/**
* Default time to live. The value is <tt>0</tt> which means that
* cached objects never expire based on time.
*/
public static final long DFLT_TIME_TO_LIVE = 0;
/** Default number of backups. */
public static final int DFLT_BACKUPS = 0;
/** Default caching mode. */
public static final CacheMode DFLT_CACHE_MODE = CacheMode.REPLICATED;
/** Default atomicity mode. */
public static final CacheAtomicityMode DFLT_CACHE_ATOMICITY_MODE = CacheAtomicityMode.ATOMIC;
/** Default value for cache distribution mode. */
public static final CacheDistributionMode DFLT_DISTRIBUTION_MODE = CacheDistributionMode.PARTITIONED_ONLY;
/** Default query timeout. */
public static final long DFLT_QUERY_TIMEOUT = 0;
/** Default lock timeout. */
public static final long DFLT_LOCK_TIMEOUT = 0;
/** Initial default cache size. */
public static final int DFLT_START_SIZE = 1500000;
/** Default cache size to use with eviction policy. */
public static final int DFLT_CACHE_SIZE = 100000;
/** Initial default near cache size. */
public static final int DFLT_NEAR_START_SIZE = DFLT_START_SIZE / 4;
/** Default value for 'invalidate' flag that indicates if this is invalidation-based cache. */
public static final boolean DFLT_INVALIDATE = false;
/** Default preload mode for distributed cache. */
public static final CachePreloadMode DFLT_PRELOAD_MODE = CachePreloadMode.ASYNC;
/** Default preload batch size in bytes. */
public static final int DFLT_PRELOAD_BATCH_SIZE = 512 * 1024; // 512K
/** Default maximum eviction queue ratio. */
public static final float DFLT_MAX_EVICTION_OVERFLOW_RATIO = 10;
/** Default eviction synchronized flag. */
public static final boolean DFLT_EVICT_SYNCHRONIZED = false;
/** Default near nodes eviction synchronized flag. */
public static final boolean DFLT_EVICT_NEAR_SYNCHRONIZED = true;
/** Default eviction key buffer size for batching synchronized evicts. */
public static final int DFLT_EVICT_KEY_BUFFER_SIZE = 1024;
/** Default synchronous eviction timeout in milliseconds. */
public static final long DFLT_EVICT_SYNCHRONIZED_TIMEOUT = 10000;
/** Default synchronous eviction concurrency level. */
public static final int DFLT_EVICT_SYNCHRONIZED_CONCURRENCY_LEVEL = 4;
/** Default value for eager ttl flag. */
public static final boolean DFLT_EAGER_TTL = true;
/** Default off-heap storage size is {@code -1} which means that off-heap storage is disabled. */
public static final long DFLT_OFFHEAP_MEMORY = -1;
/** Default value for 'swapEnabled' flag. */
public static final boolean DFLT_SWAP_ENABLED = false;
/** Default value for 'maxConcurrentAsyncOps'. */
public static final int DFLT_MAX_CONCURRENT_ASYNC_OPS = 500;
/** Default value for 'queryIndexEnabled' flag. */
public static final boolean DFLT_QUERY_INDEX_ENABLED = false;
/** Default value for 'writeBehindEnabled' flag. */
public static final boolean DFLT_WRITE_BEHIND_ENABLED = false;
/** Default flush size for write-behind cache store. */
public static final int DFLT_WRITE_BEHIND_FLUSH_SIZE = 10240; // 10K
/** Default critical size used when flush size is not specified. */
public static final int DFLT_WRITE_BEHIND_CRITICAL_SIZE = 16384; // 16K
/** Default flush frequency for write-behind cache store in milliseconds. */
public static final long DFLT_WRITE_BEHIND_FLUSH_FREQUENCY = 5000;
/** Default count of flush threads for write-behind cache store. */
public static final int DFLT_WRITE_FROM_BEHIND_FLUSH_THREAD_CNT = 1;
/** Default batch size for write-behind cache store. */
public static final int DFLT_WRITE_BEHIND_BATCH_SIZE = 512;
/** Default maximum number of query iterators that can be stored. */
public static final int DFLT_MAX_QUERY_ITERATOR_CNT = 1024;
/** Default value for load previous value flag. */
public static final boolean DFLT_LOAD_PREV_VAL = false;
/** Default memory mode. */
public static final CacheMemoryMode DFLT_MEMORY_MODE = CacheMemoryMode.ONHEAP_TIERED;
/** Default value for 'readFromBackup' flag. */
public static final boolean DFLT_READ_FROM_BACKUP = true;
/** Cache name. */
private String name;
/** Preload thread pool size. */
private int preloadPoolSize = DFLT_PRELOAD_THREAD_POOL_SIZE;
/** Preload timeout. */
private long preloadTimeout = DFLT_PRELOAD_TIMEOUT;
/** Default time to live for cache entries. */
private long ttl = DFLT_TIME_TO_LIVE;
/** Cache expiration policy. */
private CacheEvictionPolicy evictPlc;
/** Near cache eviction policy. */
private CacheEvictionPolicy nearEvictPlc;
/** Flag indicating whether eviction is synchronized. */
private boolean evictSync = DFLT_EVICT_SYNCHRONIZED;
/** Flag indicating whether eviction is synchronized with near nodes. */
private boolean evictNearSync = DFLT_EVICT_NEAR_SYNCHRONIZED;
/** Eviction key buffer size. */
private int evictKeyBufSize = DFLT_EVICT_KEY_BUFFER_SIZE;
/** Synchronous eviction timeout. */
private int evictSyncConcurrencyLvl = DFLT_EVICT_SYNCHRONIZED_CONCURRENCY_LEVEL;
/** Synchronous eviction timeout. */
private long evictSyncTimeout = DFLT_EVICT_SYNCHRONIZED_TIMEOUT;
/** Eviction filter. */
private CacheEvictionFilter<?, ?> evictFilter;
/** Maximum eviction overflow ratio. */
private float evictMaxOverflowRatio = DFLT_MAX_EVICTION_OVERFLOW_RATIO;
/** Eager ttl flag. */
private boolean eagerTtl = DFLT_EAGER_TTL;
/** Default lock timeout. */
private long dfltLockTimeout = DFLT_LOCK_TIMEOUT;
/** Default query timeout. */
private long dfltQryTimeout = DFLT_QUERY_TIMEOUT;
/** Default cache start size. */
private int startSize = DFLT_START_SIZE;
/** Default near cache start size. */
private int nearStartSize = DFLT_NEAR_START_SIZE;
/** Cache distribution mode. */
private CacheDistributionMode distro = DFLT_DISTRIBUTION_MODE;
/** Default value for 'copyOnGet' flag. */
public static final boolean DFLT_COPY_ON_GET = true;
/** Write synchronization mode. */
private CacheWriteSynchronizationMode writeSync;
/** */
private Factory storeFactory;
/** */
private boolean loadPrevVal = DFLT_LOAD_PREV_VAL;
/** Node group resolver. */
private CacheAffinityFunction aff;
/** Cache mode. */
private CacheMode cacheMode = DFLT_CACHE_MODE;
/** Cache atomicity mode. */
private CacheAtomicityMode atomicityMode;
/** Write ordering mode. */
private CacheAtomicWriteOrderMode atomicWriteOrderMode;
/** Number of backups for cache. */
private int backups = DFLT_BACKUPS;
/** Flag indicating whether this is invalidation-based cache. */
private boolean invalidate = DFLT_INVALIDATE;
/** Name of class implementing GridCacheTmLookup. */
private String tmLookupClsName;
/** Distributed cache preload mode. */
private CachePreloadMode preloadMode = DFLT_PRELOAD_MODE;
/** Cache preload order. */
private int preloadOrder;
/** Preload batch size. */
private int preloadBatchSize = DFLT_PRELOAD_BATCH_SIZE;
/** Off-heap memory size. */
private long offHeapMaxMem = DFLT_OFFHEAP_MEMORY;
/** */
private boolean swapEnabled = DFLT_SWAP_ENABLED;
/** Maximum number of concurrent asynchronous operations. */
private int maxConcurrentAsyncOps = DFLT_MAX_CONCURRENT_ASYNC_OPS;
/** */
private boolean qryIdxEnabled = DFLT_QUERY_INDEX_ENABLED;
/** Write-behind feature. */
private boolean writeBehindEnabled = DFLT_WRITE_BEHIND_ENABLED;
/** Maximum size of write-behind cache. */
private int writeBehindFlushSize = DFLT_WRITE_BEHIND_FLUSH_SIZE;
/** Write-behind flush frequency in milliseconds. */
private long writeBehindFlushFreq = DFLT_WRITE_BEHIND_FLUSH_FREQUENCY;
/** Flush thread count for write-behind cache store. */
private int writeBehindFlushThreadCnt = DFLT_WRITE_FROM_BEHIND_FLUSH_THREAD_CNT;
/** Maximum batch size for write-behind cache store. */
private int writeBehindBatchSize = DFLT_WRITE_BEHIND_BATCH_SIZE;
/** Maximum number of query iterators that can be stored. */
private int maxQryIterCnt = DFLT_MAX_QUERY_ITERATOR_CNT;
/** Memory mode. */
private CacheMemoryMode memMode = DFLT_MEMORY_MODE;
/** */
private CacheAffinityKeyMapper affMapper;
/** */
private String indexingSpiName;
/** */
private long preloadDelay;
/** */
private long preloadThrottle = DFLT_PRELOAD_THROTTLE;
/** */
private CacheInterceptor<?, ?> interceptor;
/** Query configuration. */
private CacheQueryConfiguration qryCfg;
/**
* Flag indicating whether data can be read from backup.
* If {@code false} always get data from primary node (never from backup).
*/
private boolean readFromBackup = DFLT_READ_FROM_BACKUP;
/** Collection of type metadata. */
private Collection<CacheTypeMetadata> typeMeta;
/** Copy on get flag. */
private boolean cpOnGet = DFLT_COPY_ON_GET;
/** Empty constructor (all values are initialized to their defaults). */
public CacheConfiguration() {
/* No-op. */
}
/**
* Copy constructor.
*
* @param cfg Configuration to copy.
*/
public CacheConfiguration(CompleteConfiguration cfg) {
super(cfg);
if (!(cfg instanceof CacheConfiguration))
return;
CacheConfiguration cc = (CacheConfiguration)cfg;
/*
* NOTE: MAKE SURE TO PRESERVE ALPHABETIC ORDER!
* ==============================================
*/
aff = cc.getAffinity();
affMapper = cc.getAffinityMapper();
atomicityMode = cc.getAtomicityMode();
atomicWriteOrderMode = cc.getAtomicWriteOrderMode();
backups = cc.getBackups();
cacheLoaderFactory = cc.getCacheLoaderFactory();
cacheMode = cc.getCacheMode();
cacheWriterFactory = cc.getCacheWriterFactory();
cpOnGet = cc.isCopyOnGet();
dfltLockTimeout = cc.getDefaultLockTimeout();
dfltQryTimeout = cc.getDefaultQueryTimeout();
distro = cc.getDistributionMode();
eagerTtl = cc.isEagerTtl();
evictFilter = cc.getEvictionFilter();
evictKeyBufSize = cc.getEvictSynchronizedKeyBufferSize();
evictMaxOverflowRatio = cc.getEvictMaxOverflowRatio();
evictNearSync = cc.isEvictNearSynchronized();
evictPlc = cc.getEvictionPolicy();
evictSync = cc.isEvictSynchronized();
evictSyncConcurrencyLvl = cc.getEvictSynchronizedConcurrencyLevel();
evictSyncTimeout = cc.getEvictSynchronizedTimeout();
expiryPolicyFactory = cc.getExpiryPolicyFactory();
indexingSpiName = cc.getIndexingSpiName();
interceptor = cc.getInterceptor();
invalidate = cc.isInvalidate();
isReadThrough = cc.isReadThrough();
isWriteThrough = cc.isWriteThrough();
listenerConfigurations = cc.listenerConfigurations;
loadPrevVal = cc.isLoadPreviousValue();
offHeapMaxMem = cc.getOffHeapMaxMemory();
maxConcurrentAsyncOps = cc.getMaxConcurrentAsyncOperations();
maxQryIterCnt = cc.getMaximumQueryIteratorCount();
memMode = cc.getMemoryMode();
name = cc.getName();
nearStartSize = cc.getNearStartSize();
nearEvictPlc = cc.getNearEvictionPolicy();
preloadMode = cc.getPreloadMode();
preloadBatchSize = cc.getPreloadBatchSize();
preloadDelay = cc.getPreloadPartitionedDelay();
preloadOrder = cc.getPreloadOrder();
preloadPoolSize = cc.getPreloadThreadPoolSize();
preloadTimeout = cc.getPreloadTimeout();
preloadThrottle = cc.getPreloadThrottle();
qryCfg = cc.getQueryConfiguration();
qryIdxEnabled = cc.isQueryIndexEnabled();
readFromBackup = cc.isReadFromBackup();
startSize = cc.getStartSize();
storeFactory = cc.getCacheStoreFactory();
swapEnabled = cc.isSwapEnabled();
tmLookupClsName = cc.getTransactionManagerLookupClassName();
ttl = cc.getDefaultTimeToLive();
writeBehindBatchSize = cc.getWriteBehindBatchSize();
writeBehindEnabled = cc.isWriteBehindEnabled();
writeBehindFlushFreq = cc.getWriteBehindFlushFrequency();
writeBehindFlushSize = cc.getWriteBehindFlushSize();
writeBehindFlushThreadCnt = cc.getWriteBehindFlushThreadCount();
writeSync = cc.getWriteSynchronizationMode();
typeMeta = cc.getTypeMetadata();
}
/**
* Cache name. If not provided or {@code null}, then this will be considered a default
* cache which can be accessed via {@link Ignite#jcache(String)} method. Otherwise, if name
* is provided, the cache will be accessed via {@link Ignite#jcache(String)} method.
*
* @return Cache name.
*/
public String getName() {
return name;
}
/**
* Sets cache name.
*
* @param name Cache name. May be <tt>null</tt>, but may not be empty string.
*/
public void setName(String name) {
A.ensure(name == null || !name.isEmpty(), "Name cannot be null or empty.");
this.name = name;
}
/**
* Gets time to live for all objects in cache. This value can be overridden for individual objects.
* If not set, then value is {@code 0} which means that objects never expire.
*
* @return Time to live for all objects in cache.
*/
public long getDefaultTimeToLive() {
return ttl;
}
/**
* Sets time to live for all objects in cache. This value can be override for individual objects.
*
* @param ttl Time to live for all objects in cache.
*/
public void setDefaultTimeToLive(long ttl) {
this.ttl = ttl;
}
/**
* Gets cache eviction policy. By default, returns {@code null}
* which means that evictions are disabled for cache.
*
* @return Cache eviction policy or {@code null} if evictions should be disabled.
*/
@SuppressWarnings({"unchecked"})
@Nullable public CacheEvictionPolicy<K, V> getEvictionPolicy() {
return evictPlc;
}
/**
* Sets cache eviction policy.
*
* @param evictPlc Cache expiration policy.
*/
public void setEvictionPolicy(@Nullable CacheEvictionPolicy evictPlc) {
this.evictPlc = evictPlc;
}
/**
* Gets cache distribution mode. This parameter is taken into account only if
* {@link #getCacheMode()} is set to {@link CacheMode#PARTITIONED} or {@link CacheMode#REPLICATED} mode.
* <p>
* If not set, default value is {@link #DFLT_DISTRIBUTION_MODE}.
*
* @return Cache distribution mode.
*/
public CacheDistributionMode getDistributionMode() {
return distro;
}
/**
* Sets cache distribution mode.
*
* @param distro Distribution mode.
*/
public void setDistributionMode(CacheDistributionMode distro) {
this.distro = distro;
}
/**
* Gets write synchronization mode. This mode controls whether the main
* caller should wait for update on other nodes to complete or not.
*
* @return Write synchronization mode.
*/
public CacheWriteSynchronizationMode getWriteSynchronizationMode() {
return writeSync;
}
/**
* Sets write synchronization mode.
*
* @param writeSync Write synchronization mode.
*/
public void setWriteSynchronizationMode(CacheWriteSynchronizationMode writeSync) {
this.writeSync = writeSync;
}
/**
* Gets eviction policy for {@code near} cache which is different from the one used for
* {@code partitioned} cache. By default, returns {@code null}
* which means that evictions are disabled for near cache.
*
* @return Cache eviction policy or {@code null} if evictions should be disabled.
*/
@SuppressWarnings({"unchecked"})
@Nullable public CacheEvictionPolicy<K, V> getNearEvictionPolicy() {
return nearEvictPlc;
}
/**
* Sets eviction policy for near cache. This property is only used for {@link CacheMode#PARTITIONED} caching
* mode.
*
* @param nearEvictPlc Eviction policy for near cache.
*/
public void setNearEvictionPolicy(@Nullable CacheEvictionPolicy nearEvictPlc) {
this.nearEvictPlc = nearEvictPlc;
}
/**
* Gets flag indicating whether eviction is synchronized between primary and
* backup nodes on partitioned cache. If this parameter is {@code true} and
* swap is disabled then {@link CacheProjection#evict(Object)}
* and all its variations will involve all nodes where an entry is kept -
* this is a group of nodes responsible for partition to which
* corresponding key belongs. If this property is set to {@code false} then
* eviction is done independently on cache nodes.
* <p>
* Default value is defined by {@link #DFLT_EVICT_SYNCHRONIZED}.
* <p>
* Note that it's not recommended to set this value to {@code true} if cache
* store is configured since it will allow to significantly improve cache
* performance.
*
* @return {@code true} If eviction is synchronized with backup nodes (or the
* rest of the nodes in case of replicated cache), {@code false} if not.
*/
public boolean isEvictSynchronized() {
return evictSync;
}
/**
* Sets flag indicating whether eviction is synchronized with backup nodes (or the rest of the nodes for replicated
* cache).
*
* @param evictSync {@code true} if synchronized, {@code false} if not.
*/
public void setEvictSynchronized(boolean evictSync) {
this.evictSync = evictSync;
}
/**
* Sets flag indicating whether eviction is synchronized with near nodes.
*
* @param evictNearSync {@code true} if synchronized, {@code false} if not.
*/
public void setEvictNearSynchronized(boolean evictNearSync) {
this.evictNearSync = evictNearSync;
}
/**
* Gets flag indicating whether eviction on primary node is synchronized with
* near nodes where entry is kept. Default value is {@code true} and
* is defined by {@link #DFLT_EVICT_NEAR_SYNCHRONIZED}.
* <p>
* Note that in most cases this property should be set to {@code true} to keep
* cache consistency. But there may be the cases when user may use some
* special near eviction policy to have desired control over near cache
* entry set.
*
* @return {@code true} If eviction is synchronized with near nodes in
* partitioned cache, {@code false} if not.
*/
public boolean isEvictNearSynchronized() {
return evictNearSync;
}
/**
* Gets size of the key buffer for synchronized evictions.
* <p>
* Default value is defined by {@link #DFLT_EVICT_KEY_BUFFER_SIZE}.
*
* @return Eviction key buffer size.
*/
public int getEvictSynchronizedKeyBufferSize() {
return evictKeyBufSize;
}
/**
* Sets eviction key buffer size.
*
* @param evictKeyBufSize Eviction key buffer size.
*/
public void setEvictSynchronizedKeyBufferSize(int evictKeyBufSize) {
this.evictKeyBufSize = evictKeyBufSize;
}
/**
* Gets concurrency level for synchronized evictions. This flag only makes sense
* with {@link #isEvictNearSynchronized()} or {@link #isEvictSynchronized()} set
* to {@code true}. When synchronized evictions are enabled, it is possible that
* local eviction policy will try to evict entries faster than evictions can be
* synchronized with backup or near nodes. This value specifies how many concurrent
* synchronous eviction sessions should be allowed before the system is forced to
* wait and let synchronous evictions catch up with the eviction policy.
* <p>
* Note that if synchronous evictions start lagging, it is possible that you have either
* too big or too small eviction key buffer size or small eviction timeout. In that case
* you will need to adjust {@link #getEvictSynchronizedKeyBufferSize} or
* {@link #getEvictSynchronizedTimeout()} values as well.
* <p>
* Default value is defined by {@link #DFLT_EVICT_SYNCHRONIZED_CONCURRENCY_LEVEL}.
*
* @return Synchronous eviction concurrency level.
*/
public int getEvictSynchronizedConcurrencyLevel() {
return evictSyncConcurrencyLvl;
}
/**
* Sets concurrency level for synchronized evictions.
*
* @param evictSyncConcurrencyLvl Concurrency level for synchronized evictions.
*/
public void setEvictSynchronizedConcurrencyLevel(int evictSyncConcurrencyLvl) {
this.evictSyncConcurrencyLvl = evictSyncConcurrencyLvl;
}
/**
* Gets timeout for synchronized evictions.
* <p>
* Node that initiates eviction waits for responses
* from remote nodes within this timeout.
* <p>
* Default value is defined by {@link #DFLT_EVICT_SYNCHRONIZED_TIMEOUT}.
*
* @return Synchronous eviction timeout.
*/
public long getEvictSynchronizedTimeout() {
return evictSyncTimeout;
}
/**
* Sets timeout for synchronized evictions.
*
* @param evictSyncTimeout Timeout for synchronized evictions.
*/
public void setEvictSynchronizedTimeout(long evictSyncTimeout) {
this.evictSyncTimeout = evictSyncTimeout;
}
/**
* This value denotes the maximum size of eviction queue in percents of cache
* size in case of distributed cache (replicated and partitioned) and using
* synchronized eviction (that is if {@link #isEvictSynchronized()} returns
* {@code true}).
* <p>
* That queue is used internally as a buffer to decrease network costs for
* synchronized eviction. Once queue size reaches specified value all required
* requests for all entries in the queue are sent to remote nodes and the queue
* is cleared.
* <p>
* Default value is defined by {@link #DFLT_MAX_EVICTION_OVERFLOW_RATIO} and
* equals to {@code 10%}.
*
* @return Maximum size of eviction queue in percents of cache size.
*/
public float getEvictMaxOverflowRatio() {
return evictMaxOverflowRatio;
}
/**
* Sets maximum eviction overflow ratio.
*
* @param evictMaxOverflowRatio Maximum eviction overflow ratio.
*/
public void setEvictMaxOverflowRatio(float evictMaxOverflowRatio) {
this.evictMaxOverflowRatio = evictMaxOverflowRatio;
}
/**
* Gets eviction filter to specify which entries should not be evicted
* (except explicit evict by calling {@link IgniteCache#localEvict(Collection)}).
* If {@link org.apache.ignite.cache.eviction.CacheEvictionFilter#evictAllowed(javax.cache.Cache.Entry)} method
* returns {@code false} then eviction policy will not be notified and entry will
* never be evicted.
* <p>
* If not provided, any entry may be evicted depending on
* {@link #getEvictionPolicy() eviction policy} configuration.
*
* @return Eviction filter or {@code null}.
*/
@SuppressWarnings("unchecked")
public CacheEvictionFilter<K, V> getEvictionFilter() {
return (CacheEvictionFilter<K, V>)evictFilter;
}
/**
* Sets eviction filter.
*
* @param evictFilter Eviction filter.
*/
public void setEvictionFilter(CacheEvictionFilter<K, V> evictFilter) {
this.evictFilter = evictFilter;
}
/**
* Gets flag indicating whether expired cache entries will be eagerly removed from cache. When
* set to {@code false}, expired entries will be removed on next entry access.
* <p>
* When not set, default value is {@link #DFLT_EAGER_TTL}.
* <p>
* <b>Note</b> that this flag only matters for entries expiring based on
* {@link javax.cache.expiry.ExpiryPolicy} and should not be confused with entry
* evictions based on configured {@link org.apache.ignite.cache.eviction.CacheEvictionPolicy}.
*
* @return Flag indicating whether Ignite will eagerly remove expired entries.
*/
public boolean isEagerTtl() {
return eagerTtl;
}
/**
* Sets eager ttl flag.
*
* @param eagerTtl {@code True} if Ignite should eagerly remove expired cache entries.
* @see #isEagerTtl()
*/
public void setEagerTtl(boolean eagerTtl) {
this.eagerTtl = eagerTtl;
}
/**
* Gets initial cache size which will be used to pre-create internal
* hash table after start. Default value is defined by {@link #DFLT_START_SIZE}.
*
* @return Initial cache size.
*/
public int getStartSize() {
return startSize;
}
/**
* Initial size for internal hash map.
*
* @param startSize Cache start size.
*/
public void setStartSize(int startSize) {
this.startSize = startSize;
}
/**
* Gets initial cache size for near cache which will be used to pre-create internal
* hash table after start. Default value is defined by {@link #DFLT_NEAR_START_SIZE}.
*
* @return Initial near cache size.
*/
public int getNearStartSize() {
return nearStartSize;
}
/**
* Start size for near cache. This property is only used for {@link CacheMode#PARTITIONED} caching mode.
*
* @param nearStartSize Start size for near cache.
*/
public void setNearStartSize(int nearStartSize) {
this.nearStartSize = nearStartSize;
}
/**
* Gets flag indicating whether value should be loaded from store if it is not in the cache
* for following cache operations:
* <ul>
* <li>{@link IgniteCache#putIfAbsent(Object, Object)}</li>
* <li>{@link IgniteCache#replace(Object, Object)}</li>
* <li>{@link IgniteCache#replace(Object, Object, Object)}</li>
* <li>{@link IgniteCache#remove(Object, Object)}</li>
* <li>{@link IgniteCache#getAndPut(Object, Object)}</li>
* <li>{@link IgniteCache#getAndRemove(Object)}</li>
* <li>{@link IgniteCache#getAndReplace(Object, Object)}</li>
* <li>{@link IgniteCache#getAndPutIfAbsent(Object, Object)}</li>
*</ul>
*
* @return Load previous value flag.
*/
public boolean isLoadPreviousValue() {
return loadPrevVal;
}
/**
* Sets flag indicating whether value should be loaded from store if it is not in the cache
* for following cache operations:
* <ul>
* <li>{@link IgniteCache#putIfAbsent(Object, Object)}</li>
* <li>{@link IgniteCache#replace(Object, Object)}</li>
* <li>{@link IgniteCache#replace(Object, Object, Object)}</li>
* <li>{@link IgniteCache#remove(Object, Object)}</li>
* <li>{@link IgniteCache#getAndPut(Object, Object)}</li>
* <li>{@link IgniteCache#getAndRemove(Object)}</li>
* <li>{@link IgniteCache#getAndReplace(Object, Object)}</li>
* <li>{@link IgniteCache#getAndPutIfAbsent(Object, Object)}</li>
*</ul>
* When not set, default value is {@link #DFLT_LOAD_PREV_VAL}.
*
* @param loadPrevVal Load previous value flag.
*/
public void setLoadPreviousValue(boolean loadPrevVal) {
this.loadPrevVal = loadPrevVal;
}
/**
* Gets factory for underlying persistent storage for read-through and write-through operations.
*
* @return Cache store factory.
*/
@SuppressWarnings("unchecked")
public Factory<CacheStore<? super K, ? super V>> getCacheStoreFactory() {
return (Factory<CacheStore<? super K, ? super V>>)storeFactory;
}
/**
* Sets factory fpr persistent storage for cache data.
* @param storeFactory Cache store factory.
*/
@SuppressWarnings("unchecked")
public void setCacheStoreFactory(Factory<? extends CacheStore<? super K, ? super V>> storeFactory) {
this.storeFactory = storeFactory;
}
/**
* Gets key topology resolver to provide mapping from keys to nodes.
*
* @return Key topology resolver to provide mapping from keys to nodes.
*/
public CacheAffinityFunction getAffinity() {
return aff;
}
/**
* Sets affinity for cache keys.
*
* @param aff Cache key affinity.
*/
public void setAffinity(CacheAffinityFunction aff) {
this.aff = aff;
}
/**
* Gets caching mode to use. You can configure cache either to be local-only,
* fully replicated, partitioned, or near. If not provided, {@link CacheMode#REPLICATED}
* mode will be used by default (defined by {@link #DFLT_CACHE_MODE} constant).
*
* @return {@code True} if cache is local.
*/
public CacheMode getCacheMode() {
return cacheMode;
}
/**
* Sets caching mode.
*
* @param cacheMode Caching mode.
*/
public void setCacheMode(CacheMode cacheMode) {
this.cacheMode = cacheMode;
}
/**
* Gets cache atomicity mode.
* <p>
* Default value is defined by {@link #DFLT_CACHE_ATOMICITY_MODE}.
*
* @return Cache atomicity mode.
*/
public CacheAtomicityMode getAtomicityMode() {
return atomicityMode;
}
/**
* Sets cache atomicity mode.
*
* @param atomicityMode Cache atomicity mode.
*/
public void setAtomicityMode(CacheAtomicityMode atomicityMode) {
this.atomicityMode = atomicityMode;
}
/**
* Gets cache write ordering mode. This property can be enabled only for {@link CacheAtomicityMode#ATOMIC}
* cache (for other atomicity modes it will be ignored).
*
* @return Cache write ordering mode.
*/
public CacheAtomicWriteOrderMode getAtomicWriteOrderMode() {
return atomicWriteOrderMode;
}
/**
* Sets cache write ordering mode. This property can be enabled only for {@link CacheAtomicityMode#ATOMIC}
* cache (for other atomicity modes it will be ignored).
*
* @param atomicWriteOrderMode Cache write ordering mode.
*/
public void setAtomicWriteOrderMode(CacheAtomicWriteOrderMode atomicWriteOrderMode) {
this.atomicWriteOrderMode = atomicWriteOrderMode;
}
/**
* Gets number of nodes used to back up single partition for {@link CacheMode#PARTITIONED} cache.
* <p>
* If not set, default value is {@link #DFLT_BACKUPS}.
*
* @return Number of backup nodes for one partition.
*/
public int getBackups() {
return backups;
}
/**
* Sets number of nodes used to back up single partition for {@link CacheMode#PARTITIONED} cache.
* <p>
* If not set, default value is {@link #DFLT_BACKUPS}.
*
* @param backups Number of backup nodes for one partition.
*/
public void setBackups(int backups) {
this.backups = backups;
}
/**
* Gets default lock acquisition timeout. Default value is defined by {@link #DFLT_LOCK_TIMEOUT}
* which is {@code 0} and means that lock acquisition will never timeout.
*
* @return Default lock timeout.
*/
public long getDefaultLockTimeout() {
return dfltLockTimeout;
}
/**
* Sets default lock timeout in milliseconds. By default this value is defined by {@link #DFLT_LOCK_TIMEOUT}.
*
* @param dfltLockTimeout Default lock timeout.
*/
public void setDefaultLockTimeout(long dfltLockTimeout) {
this.dfltLockTimeout = dfltLockTimeout;
}
/**
* Gets default query timeout. Default value is defined by {@link #DFLT_QUERY_TIMEOUT}. {@code 0} (zero)
* means that the query will never timeout and will wait for completion.
*
* @return Default query timeout, {@code 0} for never.
*/
public long getDefaultQueryTimeout() {
return dfltQryTimeout;
}
/**
* Sets default query timeout, {@code 0} for never. For more information see {@link #getDefaultQueryTimeout()}.
*
* @param dfltQryTimeout Default query timeout.
*/
public void setDefaultQueryTimeout(long dfltQryTimeout) {
this.dfltQryTimeout = dfltQryTimeout;
}
/**
* Invalidation flag. If {@code true}, values will be invalidated (nullified) upon commit in near cache.
*
* @return Invalidation flag.
*/
public boolean isInvalidate() {
return invalidate;
}
/**
* Sets invalidation flag for near cache entries in this transaction. Default is {@code false}.
*
* @param invalidate Flag to set this cache into invalidation-based mode. Default value is {@code false}.
*/
public void setInvalidate(boolean invalidate) {
this.invalidate = invalidate;
}
/**
* Gets class name of transaction manager finder for integration for JEE app servers.
*
* @return Transaction manager finder.
*/
public String getTransactionManagerLookupClassName() {