-
Notifications
You must be signed in to change notification settings - Fork 111
/
PersistentEntityStoreConfig.java
956 lines (793 loc) · 41.8 KB
/
PersistentEntityStoreConfig.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
/*
* Copyright ${inceptionYear} - ${year} ${owner}
*
* Licensed 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
*
* https://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 jetbrains.exodus.entitystore;
import jetbrains.exodus.AbstractConfig;
import jetbrains.exodus.ConfigSettingChangeListener;
import jetbrains.exodus.ConfigurationStrategy;
import jetbrains.exodus.ExodusException;
import jetbrains.exodus.core.dataStructures.Pair;
import jetbrains.exodus.entitystore.replication.PersistentEntityStoreReplicator;
import jetbrains.exodus.env.Environment;
import jetbrains.exodus.system.JVMConstants;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
/**
* Specifies settings of {@linkplain PersistentEntityStore}. Default settings are specified by {@linkplain #DEFAULT} which
* is immutable. Any newly created {@code PersistentEntityStoreConfig} has the same settings as {@linkplain #DEFAULT}.
*
* <p>As a rule, the {@code PersistentEntityStoreConfig} instance is created along with the
* {@linkplain PersistentEntityStore} one. E.g., for given {@linkplain Environment environment} creation of
* {@linkplain PersistentEntityStore} with some tuned caching settings can look as follows:
* <pre>
* final PersistentEntityStoreConfig config = new PersistentEntityStoreConfig().setBlobStringsCacheSize(4000).setCachingDisabled(true);
* final PersistentEntityStore store = PersistentEntityStores.newInstance(config, environment, "storeName");
* </pre>
* <p>
* Some setting are mutable at runtime and some are immutable. Immutable at runtime settings can be changed, but they
* won't take effect on the {@linkplain PersistentEntityStore} instance. Those settings are applicable only during
* {@linkplain PersistentEntityStore} instance creation.
*
* <p>Most of the {@code PersistentEntityStoreConfig} settings allow to change behaviour of different caching processes.
* The rest of the settings are mostly not intended for public use, but for debugging and troubleshooting purposes.
*
* <p>You can define custom processing of changed settings values by
* {@linkplain #addChangedSettingsListener(ConfigSettingChangeListener)}. Override
* {@linkplain ConfigSettingChangeListener#beforeSettingChanged(String, Object, Map)} to pre-process mutations of
* settings and {@linkplain ConfigSettingChangeListener#afterSettingChanged(String, Object, Map)} to post-process them.
*
* @see PersistentEntityStore
* @see PersistentEntityStore#getConfig()
*/
@SuppressWarnings({"UnusedDeclaration", "WeakerAccess", "UnusedReturnValue"})
public class PersistentEntityStoreConfig extends AbstractConfig {
public static final PersistentEntityStoreConfig DEFAULT = new PersistentEntityStoreConfig(ConfigurationStrategy.IGNORE) {
@Override
public PersistentEntityStoreConfig setMutable(boolean isMutable) {
if (!this.isMutable() && isMutable) {
throw new ExodusException("Can't make PersistentEntityStoreConfig.DEFAULT mutable");
}
return super.setMutable(isMutable);
}
}.setMutable(false);
/**
* If is set to {@code true} then new {@linkplain PersistentEntityStore} will skip all refactorings on its creation.
* Default value is {@code false}.
* <p>Mutable at runtime: no
*/
public static final String REFACTORING_SKIP_ALL = "exodus.entityStore.refactoring.skipAll";
/**
* If is set to {@code true} then new {@linkplain PersistentEntityStore} will force all refactorings on its creation.
* Default value is {@code false}.
* <p>Mutable at runtime: no
*/
public static final String REFACTORING_FORCE_ALL = "exodus.entityStore.refactoring.forceAll";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code false}.
* <p>Mutable at runtime: no
*/
public static final String REFACTORING_NULL_INDICES = "exodus.entityStore.refactoring.nullIndices";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code false}.
* <p>Mutable at runtime: no
*/
public static final String REFACTORING_BLOB_NULL_INDICES = "exodus.entityStore.refactoring.blobNullIndices";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code false}.
* <p>Mutable at runtime: no
*/
public static final String REFACTORING_HEAVY_LINKS = "exodus.entityStore.refactoring.heavyLinks";
public static final String REFACTORING_MISSED_LINKS = "exodus.entityStore.refactoring.missedLinks";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code false}.
* <p>Mutable at runtime: no
*/
public static final String REFACTORING_HEAVY_PROPS = "exodus.entityStore.refactoring.heavyProps";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code false}.
* <p>Mutable at runtime: no
*/
public static final String REFACTORING_DELETE_REDUNDANT_BLOBS = "exodus.entityStore.refactoring.deleteRedundantBlobs";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code false}.
* <p>Mutable at runtime: no
*/
public static final String REFACTORING_CLEAR_BROKEN_BLOBS = "exodus.entityStore.refactoring.clearBrokenBlobs";
public static final String REFACTORING_CLEAR_NOT_REGISTERED_BLOBS = "exodus.entityStore.refactoring.clearNotRegisteredBlobs";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code 30}.
* <p>Mutable at runtime: no
*/
public static final String REFACTORING_DEDUPLICATE_BLOBS_EVERY = "exodus.entityStore.refactoring.deduplicateBlobsEvery";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code 10}.
* <p>Mutable at runtime: no
*/
public static final String REFACTORING_DEDUPLICATE_BLOBS_MIN_SIZE = "exodus.entityStore.refactoring.deduplicateBlobsMinSize";
/**
* Defines the maximum size in bytes of an "in-place" blob. In-place blob saves its content in
* {@linkplain Environment} (in .xd files), not in {@linkplain BlobVault}. "In-place" blobs are normally small
* blobs, saving them in {@code Environment} allows to reduce the nu,ber of files in {@code BlobVault}.
* Default value is {@code 10000}.
* <p>Mutable at runtime: yes
*/
public static final String MAX_IN_PLACE_BLOB_SIZE = "exodus.entityStore.maxInPlaceBlobSize";
/**
* If is set to {@code true} then {@linkplain BlobVault} uses shared (static) blob strings cache.
* Otherwise, {@linkplain BlobVault} creates its own cache. Default value is {@code true}.
* <p>Mutable at runtime: no
*
* @since 1.0.5
*/
public static final String BLOB_STRINGS_CACHE_SHARED = "exodus.entityStore.blobStringsCacheShared";
/**
* Defines the maximum size in bytes of a blob string that can be cached in blob strings cache.
* Default value is {@code 100000}.
* <p>Mutable at runtime: yes
*
* @since 1.0.5
*/
public static final String BLOB_STRINGS_CACHE_MAX_VALUE_SIZE = "exodus.entityStore.blobStringsCacheMaxValueSize";
/**
* As of 1.0.5, is deprecated and has no effect. Though system property with the name
* {@code "exodus.entityStore.blobStringsCacheSize"} is used to configure size of blob strings cache.
* <p>Mutable at runtime: no
*/
@Deprecated
public static final String BLOB_STRINGS_CACHE_SIZE = "exodus.entityStore.blobStringsCacheSize";
/**
* In case of usage of file system for storing of blobs writing of blob's content is performed
* after the commit of metadata in Xodus environment. That implies delay between transaction acknowledge
* and real write of data which can cause situation when blob content can be incorrectly read in
* another thread. To avoid such situation blob content is checked before returning to the user.
* If content is incomplete thread will wait specified amount of time in seconds till blob content
* will be completely written by the transaction, otherwise exception will be thrown.
* <p>
* Default value: {@code 300}
*
* <p>Mutable at runtime: yes
*
* @since 3.0
*/
public static final String BLOB_MAX_READ_WAITING_INTERVAL = "exodus.entityStore.maxReadWaitingInterval";
/**
* If is set to {@code true} then EntityIterableCache is not operable.
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code false}.
* <p>Mutable at runtime: yes
*/
public static final String CACHING_DISABLED = "exodus.entityStore.cachingDisabled";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code false}.
* <p>Mutable at runtime: yes
*/
public static final String REORDERING_DISABLED = "exodus.entityStore.reorderingDisabled";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code false}.
* <p>Mutable at runtime: no
*/
public static final String EXPLAIN_ON = "exodus.entityStore.explainOn";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code false}.
* <p>Mutable at runtime: no
*/
public static final String DEBUG_LINK_DATA_GETTER = "exodus.entityStore.debug.linkDataGetter";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code false}.
* <p>Mutable at runtime: no
*/
public static final String DEBUG_SEARCH_FOR_INCOMING_LINKS_ON_DELETE = "exodus.entityStore.debug.searchForIncomingLinksOnDelete";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code false}.
* <p>Mutable at runtime: yes
*/
public static final String DEBUG_TEST_LINKED_ENTITIES = "exodus.entityStore.debug.testLinkedEntities";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code true}.
* <p>Mutable at runtime: yes
*/
public static final String DEBUG_ALLOW_IN_MEMORY_SORT = "exodus.entityStore.debug.allowInMemorySort";
/**
* Defines the size of EntityIterableCache. EntityIterableCache is operable only if {@linkplain #CACHING_DISABLED}
* is {@code false}. Default value depends on the JVM memory settings.
* <p><b>It's generally recommended to use weighted cache instead. See {@linkplain #ENTITY_ITERABLE_CACHE_MEMORY_PERCENTAGE}.</b>
* <p>Mutable at runtime: yes
*
* @see #CACHING_DISABLED
*/
public static final String ENTITY_ITERABLE_CACHE_SIZE = "exodus.entityStore.entityIterableCache.size";
/**
* Specifies the percentage (from 0 to 100) of heap memory used for entity iterable cache.
* This value is used to calculate max cache weight.
* The final formula for maxCacheWeight is: maxMemory * memoryPercentage / 100 / entityWeight.
*
* <p>Use in conjunction with {@linkplain #ENTITY_ITERABLE_CACHE_DEFERRED_SIZE}.
* <p>Mutable at runtime: no
*
* @see #ENTITY_ITERABLE_CACHE_ENTITY_WEIGHT
*/
public static final String ENTITY_ITERABLE_CACHE_MEMORY_PERCENTAGE = "exodus.entityStore.entityIterableCache.memoryPercentage";
/**
* Specifies the size of a single entity key stored in cached in bytes.
* <p>Mutable at runtime: no
*
* @see #ENTITY_ITERABLE_CACHE_MEMORY_PERCENTAGE
*/
public static final String ENTITY_ITERABLE_CACHE_ENTITY_WEIGHT = "exodus.entityStore.entityIterableCache.weightCoefficient";
/**
* Defines the size of the counts cache of EntityIterableCache. EntityIterableCache is operable only if
* {@linkplain #CACHING_DISABLED} is {@code false}. Default value is {@code 65536}.
*
* <p>Mutable at runtime: no
*
* @see #CACHING_DISABLED
* @see EntityIterable#getRoughCount()
* @see EntityIterable#getRoughSize()
*/
public static final String ENTITY_ITERABLE_CACHE_COUNTS_CACHE_SIZE = "exodus.entityStore.entityIterableCache.countsCacheSize";
/**
* Defines minimum lifetime in milliseconds of a single cache count. Is applicable only if
* {@linkplain #CACHING_DISABLED} is {@code false}. Default value is {@code 30000L}.
*
* <p>Mutable at runtime: no
*
* @see #CACHING_DISABLED
*/
public static final String ENTITY_ITERABLE_CACHE_COUNTS_LIFETIME = "exodus.entityStore.entityIterableCache.countsLifeTime";
/**
* Defines the number of thread which EntityIterableCache uses for its background caching activity.
* EntityIterableCache is operable only if {@linkplain #CACHING_DISABLED} is {@code false}.
* If {@linkplain #ENTITY_ITERABLE_CACHE_COUNTS_THREAD_COUNT} is not set, thread count will be split between entity and counts caching.
* <p>Mutable at runtime: no
*
* @see #CACHING_DISABLED
* @see PersistentEntityStore#getAsyncProcessor()
*/
public static final String ENTITY_ITERABLE_CACHE_THREAD_COUNT = "exodus.entityStore.entityIterableCache.threadCount";
/**
* Defines the number of thread which EntityIterableCache uses for its background counts caching activity.
* EntityIterableCache is operable only if {@linkplain #CACHING_DISABLED} is {@code false}.
* <p>Mutable at runtime: no
*
* @see #CACHING_DISABLED
* @see PersistentEntityStore#getCountsAsyncProcessor()
*/
public static final String ENTITY_ITERABLE_CACHE_COUNTS_THREAD_COUNT = "exodus.entityStore.entityIterableCache.countsThreadCount";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code 10000L}.
* <p>Mutable at runtime: yes
*/
public static final String ENTITY_ITERABLE_CACHE_CACHING_TIMEOUT = "exodus.entityStore.entityIterableCache.cachingTimeout";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code 100000L}.
* <p>Mutable at runtime: yes
*/
public static final String ENTITY_ITERABLE_CACHE_COUNTS_CACHING_TIMEOUT = "exodus.entityStore.entityIterableCache.countsCachingTimeout";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code 7000L}.
* <p>Mutable at runtime: yes
*/
public static final String ENTITY_ITERABLE_CACHE_START_CACHING_TIMEOUT = "exodus.entityStore.entityIterableCache.startCachingTimeout";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code true}.
* <p>Mutable at runtime: yes
*/
public static final String ENTITY_ITERABLE_CACHE_DEFERRED_ENABLED = "exodus.entityStore.entityIterableCache.deferredEnabled";
/**
* Defines the size of deferred cache of EntityIterableCache.
* Deferred cache is used to identify and cache only repeatable queries in oder to avoid unnecessary caching.
* Query is repeatable if it was executed not later than {@linkplain #ENTITY_ITERABLE_CACHE_DEFERRED_DELAY} milliseconds since the previous request.
* <p>Mutable at runtime: no
*/
public static final String ENTITY_ITERABLE_CACHE_DEFERRED_SIZE = "exodus.entityStore.entityIterableCache.deferredSize";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code 2000}.
* <p>Mutable at runtime: yes
*/
public static final String ENTITY_ITERABLE_CACHE_DEFERRED_DELAY = "exodus.entityStore.entityIterableCache.deferredDelay";
/**
* Specifies that each entry should be automatically removed from the cache
* once a fixed duration has elapsed after the entry's creation,
* the most recent replacement of its value, or its last access.
* <p>Disabled by default.
* <p>Mutable at runtime: no
*/
public static final String ENTITY_ITERABLE_CACHE_EXPIRE_AFTER_ACCESS_SECONDS = "exodus.entityStore.entityIterableCache.expireAfterAccessSeconds";
/**
* Specifies that each value (not key) stored in the cache should be wrapped in a SoftReference (by default, strong references are used).
* Softly-referenced objects will be garbage-collected in a globally least-recently-used manner, in response to memory demand.
*/
public static final String ENTITY_ITERABLE_CACHE_SOFT_VALUES = "exodus.entityStore.entityIterableCache.softValues";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code false}.
* <p>Mutable at runtime: yes
*/
public static final String ENTITY_ITERABLE_CACHE_USE_HUMAN_READABLE = "exodus.entityStore.entityIterableCache.useHumanReadable";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code -1} (disabled).
* <p>Mutable at runtime: true
*/
public static final String ENTITY_ITERABLE_CACHE_OBSOLETE_MAX_RETRIES = "exodus.entityStore.entityIterableCache.obsoleteMaxRetries";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code 2048}.
* <p>Mutable at runtime: true
*/
public static final String ENTITY_ITERABLE_CACHE_HEAVY_ENABLED = "exodus.entityStore.entityIterableCache.heavyEnabled";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code 2048}.
* <p>Mutable at runtime: no
*/
public static final String ENTITY_ITERABLE_CACHE_HEAVY_QUERIES_CACHE_SIZE = "exodus.entityStore.entityIterableCache.heavyQueriesCacheSize";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code 60000}.
* <p>Mutable at runtime: yes
*/
public static final String ENTITY_ITERABLE_CACHE_HEAVY_ITERABLES_LIFE_SPAN = "exodus.entityStore.entityIterableCache.heavyQueriesLifeSpan";
/**
* Defines the size of "property values" cache held by each {@linkplain StoreTransaction} instance. This cache
* reduces load created by de-serialization of property values. Default value is {@code 1024}.
* <p>Mutable at runtime: yes
*/
public static final String TRANSACTION_PROPS_CACHE_SIZE = "exodus.entityStore.transaction.propsCacheSize";
/**
* Defines the size of "links" cache held by each {@linkplain StoreTransaction} instance. This cache reduces load
* created by de-serialization of links between {@linkplain Entity entities}. Default value is {@code 1024}.
* <p>Mutable at runtime: yes
*/
public static final String TRANSACTION_LINKS_CACHE_SIZE = "exodus.entityStore.transaction.linksCacheSize";
/**
* Defines the size of "blob strings" cache held by each {@linkplain StoreTransaction} instance. This cache
* reduces load created by de-serialization of blob string. This cache is different from the one held by
* {@linkplain BlobVault}. Default value is {@code 256}.
* <p>Mutable at runtime: yes
*/
public static final String TRANSACTION_BLOB_STRINGS_CACHE_SIZE = "exodus.entityStore.transaction.blobStringsCacheSize";
/**
* If is set to {@code true} then {@linkplain PersistentEntityStore} gathers statistics and exposes it via
* JMX managed bean provided {@linkplain #MANAGEMENT_ENABLED} is also {@code true}.
* <p>Mutable at runtime: no
*
* @see #MANAGEMENT_ENABLED
* @see PersistentEntityStore#getStatistics()
*/
public static final String GATHER_STATISTICS = "exodus.entityStore.gatherStatistics";
/**
* If is set to {@code true} then the {@linkplain PersistentEntityStore} exposes two JMX managed beans. One for
* {@linkplain PersistentEntityStore#getStatistics() statistics} and second for controlling the
* {@code PersistentEntityStoreConfig} settings. Default value is {@code true}.
* <p>Mutable at runtime: no
*
* @see PersistentEntityStore#getStatistics()
* @see PersistentEntityStore#getConfig()
*/
public static final String MANAGEMENT_ENABLED = "exodus.entityStore.managementEnabled";
/**
* If set to some value different from {@code null}, delegate replication to corresponding external service of provided value.
* <p>Mutable at runtime: no
*
* @see PersistentEntityStoreReplicator
*/
public static final String REPLICATOR = "exodus.entityStore.replicator";
/**
* Location of directory on the file system where all blobs will be stored.
* Applicable only if disk based blob directory is used.
* If relative path is provided, path will be created relatively location of main database.
* If value is not provided then default value "blobs" is used.
* Default value {@code null}.
*
* <p>Mutable at runtime: no
*/
public static final String BLOBS_DIRECTORY_LOCATION = "exodus.entityStore.blobsDirectoryLocation";
/**
* Not for public use, for debugging and troubleshooting purposes. Default value is {@code false}.
* <p>Mutable at runtime: no
*/
public static final String USE_INT_FOR_LOCAL_ID = "exodus.entityStore.useIntForLocalId";
private static final int MAX_DEFAULT_ENTITY_ITERABLE_CACHE_DEFERRED_SIZE = 4096;
public PersistentEntityStoreConfig() {
this(ConfigurationStrategy.SYSTEM_PROPERTY);
}
@SuppressWarnings({"rawtypes", "unchecked"})
public PersistentEntityStoreConfig(@NotNull final ConfigurationStrategy strategy) {
super(new Pair[]{
new Pair(REFACTORING_SKIP_ALL, false),
new Pair(USE_INT_FOR_LOCAL_ID, false),
new Pair(REFACTORING_FORCE_ALL, false),
new Pair(REFACTORING_NULL_INDICES, false),
new Pair(REFACTORING_BLOB_NULL_INDICES, false),
new Pair(REFACTORING_HEAVY_LINKS, false),
new Pair(REFACTORING_MISSED_LINKS, false),
new Pair(REFACTORING_HEAVY_PROPS, false),
new Pair(REFACTORING_DELETE_REDUNDANT_BLOBS, false),
new Pair(REFACTORING_CLEAR_BROKEN_BLOBS, false),
new Pair(REFACTORING_CLEAR_NOT_REGISTERED_BLOBS, false),
new Pair(REFACTORING_DEDUPLICATE_BLOBS_EVERY, 30),
new Pair(REFACTORING_DEDUPLICATE_BLOBS_MIN_SIZE, 10),
new Pair(MAX_IN_PLACE_BLOB_SIZE, 10000),
new Pair(BLOB_STRINGS_CACHE_SHARED, true),
new Pair(BLOB_STRINGS_CACHE_MAX_VALUE_SIZE, 100000L),
new Pair(CACHING_DISABLED, false),
new Pair(REORDERING_DISABLED, false),
new Pair(EXPLAIN_ON, false),
new Pair(DEBUG_LINK_DATA_GETTER, false),
new Pair(DEBUG_SEARCH_FOR_INCOMING_LINKS_ON_DELETE, false),
new Pair(DEBUG_TEST_LINKED_ENTITIES, true),
new Pair(DEBUG_ALLOW_IN_MEMORY_SORT, true),
new Pair(ENTITY_ITERABLE_CACHE_SIZE, -1), // weight-based cache used instead by default
new Pair(ENTITY_ITERABLE_CACHE_MEMORY_PERCENTAGE, 5), // 5% of max available memory
new Pair(ENTITY_ITERABLE_CACHE_ENTITY_WEIGHT, 12), // 12 bytes per entityId stored in cache
new Pair(ENTITY_ITERABLE_CACHE_THREAD_COUNT, defaultEntityIterableCacheThreadCount()),
new Pair(ENTITY_ITERABLE_CACHE_CACHING_TIMEOUT, 10000L),
new Pair(ENTITY_ITERABLE_CACHE_COUNTS_THREAD_COUNT, -1), // not set by default
new Pair(ENTITY_ITERABLE_CACHE_COUNTS_CACHE_SIZE, 65536),
new Pair(ENTITY_ITERABLE_CACHE_COUNTS_LIFETIME, 30000L),
new Pair(ENTITY_ITERABLE_CACHE_COUNTS_CACHING_TIMEOUT, 100000L),
new Pair(ENTITY_ITERABLE_CACHE_START_CACHING_TIMEOUT, 7000L),
new Pair(ENTITY_ITERABLE_CACHE_DEFERRED_ENABLED, true),
new Pair(ENTITY_ITERABLE_CACHE_DEFERRED_SIZE, -1), // unset by default
new Pair(ENTITY_ITERABLE_CACHE_DEFERRED_DELAY, 2000),
new Pair(ENTITY_ITERABLE_CACHE_EXPIRE_AFTER_ACCESS_SECONDS, -1), // disabled by default
new Pair(ENTITY_ITERABLE_CACHE_SOFT_VALUES, true),
new Pair(ENTITY_ITERABLE_CACHE_USE_HUMAN_READABLE, false),
new Pair(ENTITY_ITERABLE_CACHE_OBSOLETE_MAX_RETRIES, -1), // disabled by default
new Pair(ENTITY_ITERABLE_CACHE_HEAVY_ENABLED, true),
new Pair(ENTITY_ITERABLE_CACHE_HEAVY_QUERIES_CACHE_SIZE, 2048),
new Pair(ENTITY_ITERABLE_CACHE_HEAVY_ITERABLES_LIFE_SPAN, 60000L),
new Pair(TRANSACTION_PROPS_CACHE_SIZE, 1024),
new Pair(TRANSACTION_LINKS_CACHE_SIZE, 1024),
new Pair(TRANSACTION_BLOB_STRINGS_CACHE_SIZE, 256),
new Pair(GATHER_STATISTICS, true),
new Pair(MANAGEMENT_ENABLED, !JVMConstants.getIS_ANDROID()),
new Pair(REPLICATOR, null),
new Pair(BLOB_MAX_READ_WAITING_INTERVAL, 300),
new Pair(BLOBS_DIRECTORY_LOCATION, null)
}, strategy);
}
@Override
public PersistentEntityStoreConfig setSetting(@NotNull String key, @NotNull Object value) {
return (PersistentEntityStoreConfig) super.setSetting(key, value);
}
@Override
public PersistentEntityStoreConfig setMutable(boolean isMutable) {
return (PersistentEntityStoreConfig) super.setMutable(isMutable);
}
public boolean getRefactoringSkipAll() {
return (Boolean) getSetting(REFACTORING_SKIP_ALL);
}
public PersistentEntityStoreConfig setRefactoringSkipAll(final boolean skipAll) {
return setSetting(REFACTORING_SKIP_ALL, skipAll);
}
public boolean getRefactoringForceAll() {
return (Boolean) getSetting(REFACTORING_FORCE_ALL);
}
public PersistentEntityStoreConfig setRefactoringForceAll(final boolean forceAll) {
return setSetting(REFACTORING_FORCE_ALL, forceAll);
}
public boolean getRefactoringNullIndices() {
return getRefactoringForceAll() || (Boolean) getSetting(REFACTORING_NULL_INDICES);
}
public PersistentEntityStoreConfig setRefactoringNullIndices(final boolean nullIndices) {
return setSetting(REFACTORING_NULL_INDICES, nullIndices);
}
public boolean getRefactoringBlobNullIndices() {
return getRefactoringForceAll() || (Boolean) getSetting(REFACTORING_BLOB_NULL_INDICES);
}
public PersistentEntityStoreConfig setRefactoringBlobNullIndices(final boolean nullIndices) {
return setSetting(REFACTORING_BLOB_NULL_INDICES, nullIndices);
}
public boolean getRefactoringHeavyLinks() {
return getRefactoringForceAll() || (Boolean) getSetting(REFACTORING_HEAVY_LINKS);
}
public boolean getRefactorMissedLinks() {
return (Boolean) getSetting(REFACTORING_MISSED_LINKS);
}
public PersistentEntityStoreConfig setRefactoringHeavyLinks(final boolean heavyLinks) {
return setSetting(REFACTORING_HEAVY_LINKS, heavyLinks);
}
public boolean getRefactoringHeavyProps() {
return getRefactoringForceAll() || (Boolean) getSetting(REFACTORING_HEAVY_PROPS);
}
public PersistentEntityStoreConfig setRefactoringHeavyProps(final boolean heavyProps) {
return setSetting(REFACTORING_HEAVY_PROPS, heavyProps);
}
public boolean getRefactoringDeleteRedundantBlobs() {
return getRefactoringForceAll() || (Boolean) getSetting(REFACTORING_DELETE_REDUNDANT_BLOBS);
}
public PersistentEntityStoreConfig setRefactoringDeleteRedundantBlobs(final boolean fixRedundantBlobs) {
return setSetting(REFACTORING_DELETE_REDUNDANT_BLOBS, fixRedundantBlobs);
}
public PersistentEntityStoreConfig setRefactoringClearBrokenBlobs(final boolean clearBrokenBlobs) {
return setSetting(REFACTORING_CLEAR_BROKEN_BLOBS, clearBrokenBlobs);
}
public boolean getRefactoringClearBrokenBlobs() {
return getRefactoringForceAll() || (Boolean) (getSetting(REFACTORING_CLEAR_BROKEN_BLOBS));
}
public PersistentEntityStoreConfig setRefactoringClearNotRegisteredBlobs(final boolean clearBrokenBlobs) {
return setSetting(REFACTORING_CLEAR_NOT_REGISTERED_BLOBS, clearBrokenBlobs);
}
public boolean getRefactoringClearNotRegisteredBlobs() {
return getRefactoringForceAll() || (Boolean) (getSetting(REFACTORING_CLEAR_NOT_REGISTERED_BLOBS));
}
public int getRefactoringDeduplicateBlobsEvery() {
return getRefactoringForceAll() ? 0 : (Integer) getSetting(REFACTORING_DEDUPLICATE_BLOBS_EVERY);
}
public PersistentEntityStoreConfig setRefactoringDeduplicateBlobsEvery(final int days) {
return setSetting(REFACTORING_DEDUPLICATE_BLOBS_EVERY, days);
}
public int getRefactoringDeduplicateBlobsMinSize() {
return getRefactoringForceAll() ? 0 : (Integer) getSetting(REFACTORING_DEDUPLICATE_BLOBS_MIN_SIZE);
}
public PersistentEntityStoreConfig setRefactoringDeduplicateBlobsMinSize(final int size) {
return setSetting(REFACTORING_DEDUPLICATE_BLOBS_MIN_SIZE, size);
}
public int getMaxInPlaceBlobSize() {
return (Integer) getSetting(MAX_IN_PLACE_BLOB_SIZE);
}
public PersistentEntityStoreConfig setMaxInPlaceBlobSize(final int blobSize) {
return setSetting(MAX_IN_PLACE_BLOB_SIZE, blobSize);
}
public boolean isBlobStringsCacheShared() {
return (Boolean) getSetting(BLOB_STRINGS_CACHE_SHARED);
}
public PersistentEntityStoreConfig setBlobStringsCacheShared(final boolean shared) {
return setSetting(BLOB_STRINGS_CACHE_SHARED, shared);
}
public long getBlobStringsCacheMaxValueSize() {
return (Long) getSetting(BLOB_STRINGS_CACHE_MAX_VALUE_SIZE);
}
public PersistentEntityStoreConfig setBlobStringsCacheMaxValueSize(final long maxValueSize) {
return setSetting(BLOB_STRINGS_CACHE_MAX_VALUE_SIZE, maxValueSize);
}
@Deprecated
public int getBlobStringsCacheSize() {
return (Integer) getSetting(BLOB_STRINGS_CACHE_SIZE);
}
public PersistentEntityStoreConfig setBlobMaxReadWaitingInterval(final int maxReadWaitingInterval) {
return setSetting(BLOB_MAX_READ_WAITING_INTERVAL, maxReadWaitingInterval);
}
public int getBlobMaxReadWaitingInterval() {
return ((Integer) getSetting(BLOB_MAX_READ_WAITING_INTERVAL)).intValue();
}
@Deprecated
public PersistentEntityStoreConfig setBlobStringsCacheSize(final int blobStringsCacheSize) {
return setSetting(BLOB_STRINGS_CACHE_SIZE, blobStringsCacheSize);
}
public boolean getUseIntForLocalId() {
return (Boolean) getSetting(USE_INT_FOR_LOCAL_ID);
}
public PersistentEntityStoreConfig setUseIntForLocalId(final boolean useUseIntForLocalId) {
return setSetting(USE_INT_FOR_LOCAL_ID, useUseIntForLocalId);
}
public boolean isCachingDisabled() {
return (Boolean) getSetting(CACHING_DISABLED);
}
public PersistentEntityStoreConfig setCachingDisabled(final boolean disabled) {
return setSetting(CACHING_DISABLED, disabled);
}
public boolean isReorderingDisabled() {
return (Boolean) getSetting(REORDERING_DISABLED);
}
public PersistentEntityStoreConfig setReorderingDisabled(final boolean disabled) {
return setSetting(REORDERING_DISABLED, disabled);
}
public boolean isExplainOn() {
return (Boolean) getSetting(EXPLAIN_ON);
}
public PersistentEntityStoreConfig setExplainOn(final boolean explainOn) {
return setSetting(EXPLAIN_ON, explainOn);
}
public boolean isDebugLinkDataGetter() {
return (Boolean) getSetting(DEBUG_LINK_DATA_GETTER);
}
public PersistentEntityStoreConfig setDebugLinkDataGetter(final boolean debug) {
return setSetting(DEBUG_LINK_DATA_GETTER, debug);
}
public boolean isDebugSearchForIncomingLinksOnDelete() {
return (Boolean) getSetting(DEBUG_SEARCH_FOR_INCOMING_LINKS_ON_DELETE);
}
public PersistentEntityStoreConfig setDebugSearchForIncomingLinksOnDelete(final boolean debug) {
return setSetting(DEBUG_SEARCH_FOR_INCOMING_LINKS_ON_DELETE, debug);
}
public boolean isDebugTestLinkedEntities() {
return (Boolean) getSetting(DEBUG_TEST_LINKED_ENTITIES);
}
public PersistentEntityStoreConfig setDebugTestLinkedEntities(final boolean debug) {
return setSetting(DEBUG_TEST_LINKED_ENTITIES, debug);
}
public boolean isDebugAllowInMemorySort() {
return (Boolean) getSetting(DEBUG_ALLOW_IN_MEMORY_SORT);
}
public PersistentEntityStoreConfig setDebugAllowInMemorySort(final boolean debug) {
return setSetting(DEBUG_ALLOW_IN_MEMORY_SORT, debug);
}
public int getEntityIterableCacheSize() {
return (Integer) getSetting(ENTITY_ITERABLE_CACHE_SIZE);
}
public PersistentEntityStoreConfig setEntityIterableCacheSize(final int size) {
return setSetting(ENTITY_ITERABLE_CACHE_SIZE, size);
}
public int getEntityIterableCacheMemoryPercentage() {
return (Integer) getSetting(ENTITY_ITERABLE_CACHE_MEMORY_PERCENTAGE);
}
public int getEntityIterableCacheEntityWeight() {
return (Integer) getSetting(ENTITY_ITERABLE_CACHE_ENTITY_WEIGHT);
}
public long getEntityIterableCacheWeight() {
long maxMemory = Runtime.getRuntime().maxMemory();
long percentage = getEntityIterableCacheMemoryPercentage();
long entityWeight = getEntityIterableCacheEntityWeight();
return (maxMemory * percentage) / (100 * entityWeight);
}
public int getEntityIterableCacheCountsCacheSize() {
return (Integer) getSetting(ENTITY_ITERABLE_CACHE_COUNTS_CACHE_SIZE);
}
public PersistentEntityStoreConfig setEntityIterableCacheCountsCacheSize(final int size) {
return setSetting(ENTITY_ITERABLE_CACHE_COUNTS_CACHE_SIZE, size);
}
public long getEntityIterableCacheCountsLifeTime() {
return (Long) getSetting(ENTITY_ITERABLE_CACHE_COUNTS_LIFETIME);
}
public PersistentEntityStoreConfig setEntityIterableCacheCountsLifeTime(final long lifeTime) {
return setSetting(ENTITY_ITERABLE_CACHE_COUNTS_LIFETIME, lifeTime);
}
public int getEntityIterableCacheThreadCount() {
int threads = (Integer) getSetting(ENTITY_ITERABLE_CACHE_THREAD_COUNT);
int countsThreads = (Integer) getSetting(ENTITY_ITERABLE_CACHE_COUNTS_THREAD_COUNT);
if (countsThreads < 0) {
// When counts threads count is not set, fallback for backward compatibility
return threads / 2 + threads % 2;
} else {
return threads;
}
}
public int getEntityIterableCacheCountsThreadCount() {
int threads = (Integer) getSetting(ENTITY_ITERABLE_CACHE_THREAD_COUNT);
int countsThreads = (Integer) getSetting(ENTITY_ITERABLE_CACHE_COUNTS_THREAD_COUNT);
if (countsThreads < 0) {
// When counts threads count is not set, fallback for backward compatibility
return threads / 2;
} else {
return countsThreads;
}
}
public PersistentEntityStoreConfig setEntityIterableCacheThreadCount(final int threadCount) {
return setSetting(ENTITY_ITERABLE_CACHE_THREAD_COUNT, threadCount);
}
public long getEntityIterableCacheCachingTimeout() {
return (Long) getSetting(ENTITY_ITERABLE_CACHE_CACHING_TIMEOUT);
}
public PersistentEntityStoreConfig setEntityIterableCacheCachingTimeout(final long cachingTimeout) {
return setSetting(ENTITY_ITERABLE_CACHE_CACHING_TIMEOUT, cachingTimeout);
}
public long getEntityIterableCacheCountsCachingTimeout() {
return (Long) getSetting(ENTITY_ITERABLE_CACHE_COUNTS_CACHING_TIMEOUT);
}
public PersistentEntityStoreConfig setEntityIterableCacheCountsCachingTimeout(final long cachingTimeout) {
return setSetting(ENTITY_ITERABLE_CACHE_COUNTS_CACHING_TIMEOUT, cachingTimeout);
}
public long getEntityIterableCacheStartCachingTimeout() {
return (Long) getSetting(ENTITY_ITERABLE_CACHE_START_CACHING_TIMEOUT);
}
public PersistentEntityStoreConfig setEntityIterableCacheStartCachingTimeout(final long cachingTimeout) {
return setSetting(ENTITY_ITERABLE_CACHE_START_CACHING_TIMEOUT, cachingTimeout);
}
public int getEntityIterableCacheDeferredSize() {
int deferredCacheSize = (Integer) getSetting(ENTITY_ITERABLE_CACHE_DEFERRED_SIZE);
if (deferredCacheSize > 0) {
// If set explicitly, use the value
return deferredCacheSize;
} else if (getEntityIterableCacheSize() > 0) {
// If sized cache is used, deferred cache size is the same value
return getEntityIterableCacheSize();
} else {
return defaultEntityIterableDeferredCacheSize();
}
}
public boolean getEntityIterableCacheDeferredEnabled() {
return (Boolean) getSetting(ENTITY_ITERABLE_CACHE_DEFERRED_ENABLED);
}
public PersistentEntityStoreConfig setEntityIterableCacheDeferredEnabled(final boolean deferredEnabled) {
return setSetting(ENTITY_ITERABLE_CACHE_DEFERRED_ENABLED, deferredEnabled);
}
public int getEntityIterableCacheDeferredDelay() {
return (Integer) getSetting(ENTITY_ITERABLE_CACHE_DEFERRED_DELAY);
}
public PersistentEntityStoreConfig setEntityIterableCacheDeferredDelay(final int deferredDelay) {
return setSetting(ENTITY_ITERABLE_CACHE_DEFERRED_DELAY, deferredDelay);
}
public int getEntityIterableCacheExpireAfterAccess() {
return (Integer) getSetting(ENTITY_ITERABLE_CACHE_EXPIRE_AFTER_ACCESS_SECONDS);
}
public boolean getEntityIterableCacheSoftValues() {
return (Boolean) getSetting(ENTITY_ITERABLE_CACHE_SOFT_VALUES);
}
public boolean getEntityIterableCacheUseHumanReadable() {
return (Boolean) getSetting(ENTITY_ITERABLE_CACHE_USE_HUMAN_READABLE);
}
public PersistentEntityStoreConfig setEntityIterableCacheUseHumanReadable(final boolean useHumanReadable) {
return setSetting(ENTITY_ITERABLE_CACHE_USE_HUMAN_READABLE, useHumanReadable);
}
public int getEntityIterableCacheObsoleteMaxRetries() {
return (Integer) getSetting(ENTITY_ITERABLE_CACHE_OBSOLETE_MAX_RETRIES);
}
public PersistentEntityStoreConfig setEntityIterableCacheObsoleteMaxRetries(int maxRetries) {
return setSetting(ENTITY_ITERABLE_CACHE_OBSOLETE_MAX_RETRIES, maxRetries);
}
public boolean getEntityIterableCacheHeavyEnabled() {
return (Boolean) getSetting(ENTITY_ITERABLE_CACHE_HEAVY_ENABLED);
}
public PersistentEntityStoreConfig setEntityIterableCacheHeavyEnabled(final boolean heavyEnabled) {
return setSetting(ENTITY_ITERABLE_CACHE_HEAVY_ENABLED, heavyEnabled);
}
public int getEntityIterableCacheHeavyIterablesCacheSize() {
return (Integer) getSetting(ENTITY_ITERABLE_CACHE_HEAVY_QUERIES_CACHE_SIZE);
}
public PersistentEntityStoreConfig setEntityIterableCacheHeavyIterablesCacheSize(int cacheSize) {
return setSetting(ENTITY_ITERABLE_CACHE_HEAVY_QUERIES_CACHE_SIZE, cacheSize);
}
public long getEntityIterableCacheHeavyIterablesLifeSpan() {
return (Long) getSetting(ENTITY_ITERABLE_CACHE_HEAVY_ITERABLES_LIFE_SPAN);
}
public PersistentEntityStoreConfig setEntityIterableCacheHeavyIterablesLifeSpan(long lifeSpan) {
return setSetting(ENTITY_ITERABLE_CACHE_HEAVY_ITERABLES_LIFE_SPAN, lifeSpan);
}
public int getTransactionPropsCacheSize() {
return (Integer) getSetting(TRANSACTION_PROPS_CACHE_SIZE);
}
public PersistentEntityStoreConfig setTransactionPropsCacheSize(final int transactionPropsCacheSize) {
return setSetting(TRANSACTION_PROPS_CACHE_SIZE, transactionPropsCacheSize);
}
public int getTransactionLinksCacheSize() {
return (Integer) getSetting(TRANSACTION_LINKS_CACHE_SIZE);
}
public PersistentEntityStoreConfig setTransactionLinksCacheSize(final int transactionLinksCacheSize) {
return setSetting(TRANSACTION_LINKS_CACHE_SIZE, transactionLinksCacheSize);
}
public int getTransactionBlobStringsCacheSize() {
return (Integer) getSetting(TRANSACTION_BLOB_STRINGS_CACHE_SIZE);
}
public PersistentEntityStoreConfig setTransactionBlobStringsCacheSize(final int transactionBlobStringsCacheSize) {
return setSetting(TRANSACTION_BLOB_STRINGS_CACHE_SIZE, transactionBlobStringsCacheSize);
}
public boolean getGatherStatistics() {
return (Boolean) getSetting(GATHER_STATISTICS);
}
public PersistentEntityStoreConfig setGatherStatistics(final boolean gatherStatistics) {
return setSetting(GATHER_STATISTICS, gatherStatistics);
}
public boolean isManagementEnabled() {
return (Boolean) getSetting(MANAGEMENT_ENABLED);
}
public PersistentEntityStoreConfig setManagementEnabled(final boolean managementEnabled) {
return setSetting(MANAGEMENT_ENABLED, managementEnabled && !JVMConstants.getIS_ANDROID());
}
public PersistentEntityStoreConfig setStoreReplicator(final PersistentEntityStoreReplicator replicator) {
return setSetting(REPLICATOR, replicator);
}
public PersistentEntityStoreReplicator getStoreReplicator() {
return (PersistentEntityStoreReplicator) getSetting(REPLICATOR);
}
public PersistentEntityStoreConfig setBlobsDirectoryLocation(final String value) {
return setSetting(BLOBS_DIRECTORY_LOCATION, value);
}
public String getBlobsDirectoryLocation() {
return (String) getSetting(BLOBS_DIRECTORY_LOCATION);
}
private static int defaultEntityIterableDeferredCacheSize() {
return Math.max((int) (Runtime.getRuntime().maxMemory() >> 20), MAX_DEFAULT_ENTITY_ITERABLE_CACHE_DEFERRED_SIZE);
}
private static int defaultEntityIterableCacheThreadCount() {
return Runtime.getRuntime().availableProcessors() > 8 ? 4 : 2;
}
}