2
* Copyright Terracotta, Inc.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
package net.sf.ehcache.management.sampled;
19
import net.sf.ehcache.Ehcache;
20
import net.sf.ehcache.config.CacheConfiguration;
21
import net.sf.ehcache.config.CacheConfigurationListener;
22
import net.sf.ehcache.config.PinningConfiguration;
23
import net.sf.ehcache.config.TerracottaConfiguration.Consistency;
24
import net.sf.ehcache.util.CacheTransactionHelper;
25
import net.sf.ehcache.writer.writebehind.WriteBehindManager;
26
import org.slf4j.Logger;
27
import org.slf4j.LoggerFactory;
30
* An implementation of {@link CacheSampler}
32
* @author <a href="mailto:asanoujam@terracottatech.com">Abhishek Sanoujam</a>
33
* @author <a href="mailto:byoukste@terracottatech.com">byoukste</a>
35
public class CacheSamplerImpl implements CacheSampler, CacheConfigurationListener {
36
private static final int PERCENTAGE_DIVISOR = 100;
37
private static final int MILLIS_PER_SECOND = 1000;
38
private static final int NANOS_PER_MILLI = MILLIS_PER_SECOND * MILLIS_PER_SECOND;
40
private static final Logger LOG = LoggerFactory.getLogger(CacheSamplerImpl.class);
42
private final Ehcache cache;
45
* Constructor accepting the backing {@link Ehcache}
47
* @param cache the cache object to use in initializing this sampled representation
49
public CacheSamplerImpl(Ehcache cache) {
51
cache.getCacheConfiguration().addConfigurationListener(this);
57
public boolean isEnabled() {
58
return !cache.isDisabled();
64
public void setEnabled(boolean enabled) {
66
cache.setDisabled(!enabled);
67
} catch (RuntimeException e) {
68
throw Utils.newPlainException(e);
75
public boolean isClusterBulkLoadEnabled() {
77
return cache.isClusterBulkLoadEnabled();
78
} catch (RuntimeException e) {
79
throw Utils.newPlainException(e);
86
public boolean isNodeBulkLoadEnabled() {
87
return cache.isNodeBulkLoadEnabled();
93
public void setNodeBulkLoadEnabled(boolean bulkLoadEnabled) {
94
if (bulkLoadEnabled && getTransactional()) {
95
LOG.warn("a transactional cache cannot be put into bulk-load mode");
98
cache.setNodeBulkLoadEnabled(!bulkLoadEnabled);
104
public void flush() {
107
} catch (RuntimeException e) {
108
throw Utils.newPlainException(e);
115
public String getCacheName() {
116
return cache.getName();
122
public String getStatus() {
123
return cache.getStatus().toString();
129
public void removeAll() {
130
CacheTransactionHelper.beginTransactionIfNeeded(cache);
133
} catch (RuntimeException e) {
134
throw Utils.newPlainException(e);
137
CacheTransactionHelper.commitTransactionIfNeeded(cache);
138
} catch (RuntimeException e2) {
139
throw Utils.newPlainException(e2);
147
public long getAverageGetTimeMostRecentSample() {
148
return cache.getSampledCacheStatistics().getAverageGetTimeMostRecentSample();
154
public long getAverageGetTimeNanosMostRecentSample() {
155
return cache.getSampledCacheStatistics().getAverageGetTimeNanosMostRecentSample();
161
public long getCacheEvictionRate() {
162
return getCacheElementEvictedMostRecentSample();
168
public long getCacheElementEvictedMostRecentSample() {
169
return cache.getSampledCacheStatistics().getCacheElementEvictedMostRecentSample();
175
public long getCacheExpirationRate() {
176
return getCacheElementExpiredMostRecentSample();
182
public long getCacheElementExpiredMostRecentSample() {
183
return cache.getSampledCacheStatistics().getCacheElementExpiredMostRecentSample();
189
public long getCachePutRate() {
190
return getCacheElementPutMostRecentSample();
196
public long getCacheElementPutMostRecentSample() {
197
return cache.getSampledCacheStatistics().getCacheElementPutMostRecentSample();
203
public long getCacheRemoveRate() {
204
return getCacheElementRemovedMostRecentSample();
210
public long getCacheElementRemovedMostRecentSample() {
211
return cache.getSampledCacheStatistics().getCacheElementRemovedMostRecentSample();
217
public long getCacheUpdateRate() {
218
return getCacheElementUpdatedMostRecentSample();
224
public long getCacheElementUpdatedMostRecentSample() {
225
return cache.getSampledCacheStatistics().getCacheElementUpdatedMostRecentSample();
231
public long getCacheInMemoryHitRate() {
232
return getCacheHitInMemoryMostRecentSample();
238
public long getCacheHitInMemoryMostRecentSample() {
239
return cache.getSampledCacheStatistics().getCacheHitInMemoryMostRecentSample();
245
public long getCacheOffHeapHitRate() {
246
return getCacheHitOffHeapMostRecentSample();
252
public long getCacheHitOffHeapMostRecentSample() {
253
return cache.getSampledCacheStatistics().getCacheHitOffHeapMostRecentSample();
259
public long getCacheHitRate() {
260
return getCacheHitMostRecentSample();
266
public long getCacheHitMostRecentSample() {
267
return cache.getSampledCacheStatistics().getCacheHitMostRecentSample();
273
public long getCacheOnDiskHitRate() {
274
return getCacheHitOnDiskMostRecentSample();
280
public long getCacheHitOnDiskMostRecentSample() {
281
return cache.getSampledCacheStatistics().getCacheHitOnDiskMostRecentSample();
287
public long getCacheMissExpiredMostRecentSample() {
288
return cache.getSampledCacheStatistics().getCacheMissExpiredMostRecentSample();
294
public long getCacheMissRate() {
295
return getCacheMissMostRecentSample();
301
public long getCacheMissMostRecentSample() {
302
return cache.getSampledCacheStatistics().getCacheMissMostRecentSample();
308
public long getCacheInMemoryMissRate() {
309
return getCacheMissInMemoryMostRecentSample();
315
public long getCacheMissInMemoryMostRecentSample() {
316
return cache.getSampledCacheStatistics().getCacheMissInMemoryMostRecentSample();
322
public long getCacheOffHeapMissRate() {
323
return getCacheMissOffHeapMostRecentSample();
329
public long getCacheMissOffHeapMostRecentSample() {
330
return cache.getSampledCacheStatistics().getCacheMissOffHeapMostRecentSample();
336
public long getCacheOnDiskMissRate() {
337
return getCacheMissOnDiskMostRecentSample();
343
public long getCacheMissOnDiskMostRecentSample() {
344
return cache.getSampledCacheStatistics().getCacheMissOnDiskMostRecentSample();
350
public long getCacheMissNotFoundMostRecentSample() {
351
return cache.getSampledCacheStatistics().getCacheMissNotFoundMostRecentSample();
357
public int getStatisticsAccuracy() {
358
return cache.getSampledCacheStatistics().getStatisticsAccuracy();
364
public String getStatisticsAccuracyDescription() {
365
return cache.getSampledCacheStatistics().getStatisticsAccuracyDescription();
371
public void clearStatistics() {
373
cache.clearStatistics();
374
} catch (RuntimeException e) {
375
throw Utils.newPlainException(e);
382
public boolean isStatisticsEnabled() {
383
return cache.isStatisticsEnabled();
389
public boolean isSampledStatisticsEnabled() {
390
return cache.getSampledCacheStatistics().isSampledStatisticsEnabled();
396
public void dispose() {
397
cache.getCacheConfiguration().removeConfigurationListener(this);
403
public boolean isTerracottaClustered() {
404
return this.cache.getCacheConfiguration().isTerracottaClustered();
410
public String getTerracottaConsistency() {
411
Consistency consistency = this.cache.getCacheConfiguration().getTerracottaConsistency();
412
return consistency != null ? consistency.name() : "na";
418
public void enableStatistics() {
419
if (!cache.isStatisticsEnabled()) {
421
cache.setSampledStatisticsEnabled(true);
422
cache.setStatisticsEnabled(true);
423
} catch (RuntimeException e) {
424
throw Utils.newPlainException(e);
432
public void disableStatistics() {
433
if (cache.isStatisticsEnabled()) {
435
cache.setSampledStatisticsEnabled(false);
436
cache.setStatisticsEnabled(false);
437
} catch (RuntimeException e) {
438
throw Utils.newPlainException(e);
446
public void setStatisticsEnabled(boolean statsEnabled) {
447
boolean oldValue = isStatisticsEnabled();
448
if (oldValue != statsEnabled) {
460
public void enableSampledStatistics() {
461
if (!cache.isSampledStatisticsEnabled()) {
463
cache.setSampledStatisticsEnabled(true);
464
} catch (RuntimeException e) {
465
throw Utils.newPlainException(e);
473
public void disableSampledStatistics() {
474
if (cache.isSampledStatisticsEnabled()) {
476
cache.setSampledStatisticsEnabled(false);
477
} catch (RuntimeException e) {
478
throw Utils.newPlainException(e);
486
public long getCacheAverageGetTime() {
487
return getAverageGetTimeNanos();
493
public float getAverageGetTimeMillis() {
495
return getAverageGetTimeNanos() / (float) NANOS_PER_MILLI;
496
} catch (RuntimeException e) {
497
throw Utils.newPlainException(e);
504
public long getAverageGetTimeNanos() {
506
return getAverageGetTimeNanosMostRecentSample();
507
} catch (RuntimeException e) {
508
throw Utils.newPlainException(e);
515
public long getMaxGetTimeMillis() {
517
return cache.getLiveCacheStatistics().getMaxGetTimeMillis();
518
} catch (RuntimeException e) {
519
throw Utils.newPlainException(e);
526
public long getMinGetTimeMillis() {
528
return cache.getLiveCacheStatistics().getMinGetTimeMillis();
529
} catch (RuntimeException e) {
530
throw Utils.newPlainException(e);
537
public long getMaxGetTimeNanos() {
539
return cache.getLiveCacheStatistics().getMaxGetTimeNanos();
540
} catch (RuntimeException e) {
541
throw Utils.newPlainException(e);
548
public long getMinGetTimeNanos() {
550
return cache.getLiveCacheStatistics().getMinGetTimeNanos();
551
} catch (RuntimeException e) {
552
throw Utils.newPlainException(e);
559
public long getXaCommitCount() {
561
return cache.getLiveCacheStatistics().getXaCommitCount();
562
} catch (RuntimeException e) {
563
throw Utils.newPlainException(e);
570
public long getXaRollbackCount() {
572
return cache.getLiveCacheStatistics().getXaRollbackCount();
573
} catch (RuntimeException e) {
574
throw Utils.newPlainException(e);
581
public long getXaRecoveredCount() {
583
return cache.getLiveCacheStatistics().getXaRecoveredCount();
584
} catch (RuntimeException e) {
585
throw Utils.newPlainException(e);
592
public boolean getHasWriteBehindWriter() {
593
return cache.getWriterManager() instanceof WriteBehindManager &&
594
cache.getRegisteredCacheWriter() != null;
600
public long getWriterQueueLength() {
602
return cache.getLiveCacheStatistics().getWriterQueueLength();
603
} catch (RuntimeException e) {
604
throw Utils.newPlainException(e);
611
public int getWriterMaxQueueSize() {
612
return cache.getCacheConfiguration().getCacheWriterConfiguration().getWriteBehindMaxQueueSize();
618
public int getWriterConcurrency() {
619
return cache.getCacheConfiguration().getCacheWriterConfiguration().getWriteBehindConcurrency();
624
public long getCacheHitCount() {
626
return cache.getLiveCacheStatistics().getCacheHitCount();
627
} catch (RuntimeException e) {
628
throw Utils.newPlainException(e);
635
public long getCacheMissCount() {
637
return cache.getLiveCacheStatistics().getCacheMissCount();
638
} catch (RuntimeException e) {
639
throw Utils.newPlainException(e);
646
public long getInMemoryMissCount() {
648
return cache.getLiveCacheStatistics().getInMemoryMissCount();
649
} catch (RuntimeException e) {
650
throw Utils.newPlainException(e);
657
public long getOffHeapMissCount() {
659
return cache.getLiveCacheStatistics().getOffHeapMissCount();
660
} catch (RuntimeException e) {
661
throw Utils.newPlainException(e);
668
public long getOnDiskMissCount() {
670
return cache.getLiveCacheStatistics().getOnDiskMissCount();
671
} catch (RuntimeException e) {
672
throw Utils.newPlainException(e);
679
public long getCacheMissCountExpired() {
681
return cache.getLiveCacheStatistics().getCacheMissCountExpired();
682
} catch (RuntimeException e) {
683
throw Utils.newPlainException(e);
690
public long getDiskExpiryThreadIntervalSeconds() {
691
return cache.getCacheConfiguration().getDiskExpiryThreadIntervalSeconds();
697
public void setDiskExpiryThreadIntervalSeconds(long seconds) {
698
if (getDiskExpiryThreadIntervalSeconds() != seconds) {
700
cache.getCacheConfiguration().setDiskExpiryThreadIntervalSeconds(seconds);
701
} catch (RuntimeException e) {
702
throw Utils.newPlainException(e);
710
public long getMaxEntriesLocalHeap() {
711
return cache.getCacheConfiguration().getMaxEntriesLocalHeap();
717
public void setMaxEntriesLocalHeap(long maxEntries) {
718
if (getMaxEntriesLocalHeap() != maxEntries) {
720
cache.getCacheConfiguration().setMaxEntriesLocalHeap(maxEntries);
721
} catch (RuntimeException e) {
722
throw Utils.newPlainException(e);
730
public long getMaxBytesLocalHeap() {
731
return cache.getCacheConfiguration().getMaxBytesLocalHeap();
737
public void setMaxBytesLocalHeap(long maxBytes) {
739
if (cache.getCacheManager().getConfiguration().isMaxBytesLocalHeapSet()) {
740
long heapPoolSize = cache.getCacheManager().getConfiguration().getMaxBytesLocalHeap();
741
if (maxBytes > heapPoolSize) {
742
throw new IllegalArgumentException("Requested maxBytesLocalHeap ("
743
+ maxBytes + ") greater than available CacheManager heap pool size ("
744
+ heapPoolSize + ")");
747
cache.getCacheConfiguration().setMaxBytesLocalHeap(maxBytes);
748
} catch (RuntimeException e) {
749
throw Utils.newPlainException(e);
756
public void setMaxBytesLocalHeapAsString(String maxBytes) {
758
cache.getCacheConfiguration().setMaxBytesLocalHeap(maxBytes);
759
} catch (RuntimeException e) {
760
throw Utils.newPlainException(e);
763
if (cache.getCacheConfiguration().isMaxBytesLocalHeapPercentageSet()) {
764
long cacheAssignedMem = cache.getCacheManager().getConfiguration().getMaxBytesLocalHeap() *
765
cache.getCacheConfiguration().getMaxBytesLocalHeapPercentage() / PERCENTAGE_DIVISOR;
766
setMaxBytesLocalHeap(cacheAssignedMem);
774
public String getMaxBytesLocalHeapAsString() {
775
return cache.getCacheConfiguration().getMaxBytesLocalHeapAsString();
781
public long getMaxEntriesLocalDisk() {
782
return cache.getCacheConfiguration().getMaxEntriesLocalDisk();
788
public void setMaxEntriesLocalDisk(long maxEntries) {
789
if (getMaxEntriesLocalDisk() != maxEntries) {
791
cache.getCacheConfiguration().setMaxEntriesLocalDisk(maxEntries);
792
} catch (RuntimeException e) {
793
throw Utils.newPlainException(e);
801
public void setMaxBytesLocalDisk(long maxBytes) {
803
if (cache.getCacheManager().getConfiguration().isMaxBytesLocalDiskSet()) {
804
long diskPoolSize = cache.getCacheManager().getConfiguration().getMaxBytesLocalDisk();
805
if (maxBytes > diskPoolSize) {
806
throw new IllegalArgumentException("Requested maxBytesLocalDisk ("
807
+ maxBytes + ") greater than available CacheManager disk pool size ("
808
+ diskPoolSize + ")");
811
cache.getCacheConfiguration().setMaxBytesLocalDisk(maxBytes);
812
} catch (RuntimeException e) {
813
throw Utils.newPlainException(e);
820
public void setMaxBytesLocalDiskAsString(String maxBytes) {
822
cache.getCacheConfiguration().setMaxBytesLocalDisk(maxBytes);
823
} catch (RuntimeException e) {
824
throw Utils.newPlainException(e);
827
if (cache.getCacheConfiguration().isMaxBytesLocalDiskPercentageSet()) {
828
long cacheAssignedMem = cache.getCacheManager().getConfiguration().getMaxBytesLocalDisk() *
829
cache.getCacheConfiguration().getMaxBytesLocalDiskPercentage() / PERCENTAGE_DIVISOR;
830
setMaxBytesLocalDisk(cacheAssignedMem);
837
public String getMaxBytesLocalDiskAsString() {
838
return cache.getCacheConfiguration().getMaxBytesLocalDiskAsString();
844
public int getMaxElementsOnDisk() {
845
return cache.getCacheConfiguration().getMaxElementsOnDisk();
851
public void setMaxElementsOnDisk(int maxElements) {
852
if (getMaxElementsOnDisk() != maxElements) {
854
cache.getCacheConfiguration().setMaxElementsOnDisk(maxElements);
855
} catch (RuntimeException e) {
856
throw Utils.newPlainException(e);
864
public long getMaxBytesLocalDisk() {
865
return cache.getCacheConfiguration().getMaxBytesLocalDisk();
871
public long getMaxBytesLocalOffHeap() {
872
return cache.getCacheConfiguration().getMaxBytesLocalOffHeap();
878
public String getMaxBytesLocalOffHeapAsString() {
879
return cache.getCacheConfiguration().getMaxBytesLocalOffHeapAsString();
885
public String getMemoryStoreEvictionPolicy() {
886
return cache.getCacheConfiguration().getMemoryStoreEvictionPolicy().toString();
892
public void setMemoryStoreEvictionPolicy(String evictionPolicy) {
893
if (!getMemoryStoreEvictionPolicy().equals(evictionPolicy)) {
895
cache.getCacheConfiguration().setMemoryStoreEvictionPolicy(evictionPolicy);
896
} catch (RuntimeException e) {
897
throw Utils.newPlainException(e);
905
public long getTimeToIdleSeconds() {
906
return cache.getCacheConfiguration().getTimeToIdleSeconds();
912
public void setTimeToIdleSeconds(long tti) {
913
if (getTimeToIdleSeconds() != tti) {
915
cache.getCacheConfiguration().setTimeToIdleSeconds(tti);
916
} catch (RuntimeException e) {
917
throw Utils.newPlainException(e);
925
public long getTimeToLiveSeconds() {
926
return cache.getCacheConfiguration().getTimeToLiveSeconds();
932
public void setTimeToLiveSeconds(long ttl) {
933
if (getTimeToLiveSeconds() != ttl) {
935
cache.getCacheConfiguration().setTimeToLiveSeconds(ttl);
936
} catch (RuntimeException e) {
937
throw Utils.newPlainException(e);
945
public boolean isDiskPersistent() {
946
return cache.getCacheConfiguration().isDiskPersistent();
952
public void setDiskPersistent(boolean diskPersistent) {
953
if (isDiskPersistent() != diskPersistent) {
955
cache.getCacheConfiguration().setDiskPersistent(diskPersistent);
956
} catch (RuntimeException e) {
957
throw Utils.newPlainException(e);
965
public boolean isEternal() {
966
return cache.getCacheConfiguration().isEternal();
972
public void setEternal(boolean eternal) {
973
if (isEternal() != eternal) {
975
cache.getCacheConfiguration().setEternal(eternal);
976
} catch (RuntimeException e) {
977
throw Utils.newPlainException(e);
985
public boolean isOverflowToDisk() {
986
return cache.getCacheConfiguration().isOverflowToDisk();
992
public void setOverflowToDisk(boolean overflowToDisk) {
993
if (isOverflowToDisk() != overflowToDisk) {
995
cache.getCacheConfiguration().setOverflowToDisk(overflowToDisk);
996
} catch (RuntimeException e) {
997
throw Utils.newPlainException(e);
1005
public boolean isLoggingEnabled() {
1006
return cache.getCacheConfiguration().getLogging();
1012
public void setLoggingEnabled(boolean enabled) {
1013
if (isLoggingEnabled() != enabled) {
1015
cache.getCacheConfiguration().setLogging(enabled);
1016
} catch (RuntimeException e) {
1017
throw Utils.newPlainException(e);
1025
public boolean isPinned() {
1026
return cache.getCacheConfiguration().getPinningConfiguration() != null;
1032
public String getPinnedToStore() {
1033
PinningConfiguration pinningConfig = cache.getCacheConfiguration().getPinningConfiguration();
1034
return pinningConfig != null ? pinningConfig.getStore().name() : "na";
1040
public long getEvictedCount() {
1042
return cache.getLiveCacheStatistics().getEvictedCount();
1043
} catch (RuntimeException e) {
1044
throw Utils.newPlainException(e);
1051
public long getExpiredCount() {
1053
return cache.getLiveCacheStatistics().getExpiredCount();
1054
} catch (RuntimeException e) {
1055
throw Utils.newPlainException(e);
1062
public long getInMemoryHitCount() {
1064
return cache.getLiveCacheStatistics().getInMemoryHitCount();
1065
} catch (RuntimeException e) {
1066
throw Utils.newPlainException(e);
1073
public long getOffHeapHitCount() {
1075
return cache.getLiveCacheStatistics().getOffHeapHitCount();
1076
} catch (RuntimeException e) {
1077
throw Utils.newPlainException(e);
1084
* @deprecated use {@link #getLocalOffHeapSize()}
1087
public long getOffHeapSize() {
1088
return getLocalOffHeapSize();
1094
public long getOnDiskHitCount() {
1096
return cache.getLiveCacheStatistics().getOnDiskHitCount();
1097
} catch (RuntimeException e) {
1098
throw Utils.newPlainException(e);
1105
* @deprecated use {@link #getLocalDiskSize()}
1108
public long getOnDiskSize() {
1109
return getLocalDiskSize();
1115
public long getLocalDiskSize() {
1117
return cache.getLiveCacheStatistics().getLocalDiskSize();
1118
} catch (RuntimeException e) {
1119
throw Utils.newPlainException(e);
1126
public long getLocalHeapSize() {
1128
return cache.getLiveCacheStatistics().getLocalHeapSize();
1129
} catch (RuntimeException e) {
1130
throw Utils.newPlainException(e);
1137
public long getLocalOffHeapSize() {
1139
return cache.getLiveCacheStatistics().getLocalOffHeapSize();
1140
} catch (RuntimeException e) {
1141
throw Utils.newPlainException(e);
1148
public long getLocalDiskSizeInBytes() {
1150
return cache.getLiveCacheStatistics().getLocalDiskSizeInBytes();
1151
} catch (RuntimeException e) {
1152
throw Utils.newPlainException(e);
1159
public long getLocalHeapSizeInBytes() {
1161
return cache.getLiveCacheStatistics().getLocalHeapSizeInBytes();
1162
} catch (RuntimeException e) {
1163
throw Utils.newPlainException(e);
1170
public long getLocalOffHeapSizeInBytes() {
1172
return cache.getLiveCacheStatistics().getLocalOffHeapSizeInBytes();
1173
} catch (RuntimeException e) {
1174
throw Utils.newPlainException(e);
1181
public long getPutCount() {
1183
return cache.getLiveCacheStatistics().getPutCount();
1184
} catch (RuntimeException e) {
1185
throw Utils.newPlainException(e);
1192
public long getRemovedCount() {
1194
return cache.getLiveCacheStatistics().getRemovedCount();
1195
} catch (RuntimeException e) {
1196
throw Utils.newPlainException(e);
1203
public long getSize() {
1205
return cache.getLiveCacheStatistics().getSize();
1206
} catch (RuntimeException e) {
1207
throw Utils.newPlainException(e);
1214
public long getInMemorySize() {
1215
return getLocalHeapSize();
1221
public long getUpdateCount() {
1223
return cache.getLiveCacheStatistics().getUpdateCount();
1224
} catch (RuntimeException e) {
1225
throw Utils.newPlainException(e);
1232
public void deregistered(CacheConfiguration config) {
1239
public void maxBytesLocalHeapChanged(final long oldValue, final long newValue) {
1240
if (oldValue != newValue) {
1241
setMaxBytesLocalHeap(newValue);
1248
public void maxBytesLocalDiskChanged(final long oldValue, final long newValue) {
1249
if (oldValue != newValue) {
1250
setMaxBytesLocalDisk(newValue);
1257
public void diskCapacityChanged(int oldCapacity, int newCapacity) {
1258
if (oldCapacity != newCapacity) {
1259
setMaxElementsOnDisk(newCapacity);
1266
public void loggingChanged(boolean oldValue, boolean newValue) {
1267
if (oldValue != newValue) {
1268
setLoggingEnabled(newValue);
1275
public void memoryCapacityChanged(int oldCapacity, int newCapacity) {
1276
if (oldCapacity != newCapacity) {
1277
setMaxEntriesLocalHeap(newCapacity);
1284
public void registered(CacheConfiguration config) {
1291
public void timeToIdleChanged(long oldTimeToIdle, long newTimeToIdle) {
1292
if (oldTimeToIdle != newTimeToIdle) {
1293
setTimeToIdleSeconds(newTimeToIdle);
1300
public void timeToLiveChanged(long oldTimeToLive, long newTimeToLive) {
1301
if (oldTimeToLive != newTimeToLive) {
1302
setTimeToLiveSeconds(newTimeToLive);
1309
public long getAverageSearchTime() {
1310
return cache.getAverageSearchTime();
1316
public long getSearchesPerSecond() {
1317
return cache.getSearchesPerSecond();
1323
public boolean getTransactional() {
1324
return cache.getCacheConfiguration().getTransactionalMode().isTransactional();
1330
public boolean getSearchable() {
1331
return cache.getCacheConfiguration().getSearchable() != null;
1337
public long getCacheSearchRate() {
1338
return cache.getSampledCacheStatistics().getSearchesPerSecond();
1344
public long getCacheAverageSearchTime() {
1345
return cache.getSampledCacheStatistics().getAverageSearchTime();
1351
public long getTransactionCommitRate() {
1352
return getCacheXaCommitsMostRecentSample();
1358
public long getCacheXaCommitsMostRecentSample() {
1359
return cache.getSampledCacheStatistics().getCacheXaCommitsMostRecentSample();
1365
public long getTransactionRollbackRate() {
1366
return getCacheXaRollbacksMostRecentSample();
1372
public long getCacheXaRollbacksMostRecentSample() {
1373
return cache.getSampledCacheStatistics().getCacheXaRollbacksMostRecentSample();
1377
* A package friendly method to allow dependants access to the underlying {@link Ehcache} object. This is available
1378
* in order to allow {@link SampledCache} objects to continue to provide deprecated methods on the {@link SampledCacheMBean}
1379
* interface, rather than burdening {@link CacheSampler} with these now irrelevant methods. This helper method
1380
* should be removed if we are ever able to discontinue support for the deprecated methods on dependant interfaces.
1382
* @return the underlying {@code Ehcache} object
1384
Ehcache getCache() {
1391
public int getCacheHitRatio() {
1392
return getCacheHitRatioMostRecentSample();
1398
public int getCacheHitRatioMostRecentSample() {
1399
return cache.getSampledCacheStatistics().getCacheHitRatioMostRecentSample();