~ubuntu-branches/ubuntu/trusty/ehcache/trusty

« back to all changes in this revision

Viewing changes to src/main/java/net/sf/ehcache/management/sampled/CacheSamplerImpl.java

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg
  • Date: 2013-05-06 14:53:07 UTC
  • mfrom: (1.1.7) (2.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20130506145307-v5bhw5yu70re00l3
Tags: 2.6.7-1
* Team upload.
* New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 *  Copyright Terracotta, Inc.
 
3
 *
 
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
 
7
 *
 
8
 *      http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
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.
 
15
 */
 
16
 
 
17
package net.sf.ehcache.management.sampled;
 
18
 
 
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;
 
28
 
 
29
/**
 
30
 * An implementation of {@link CacheSampler}
 
31
 *
 
32
 * @author <a href="mailto:asanoujam@terracottatech.com">Abhishek Sanoujam</a>
 
33
 * @author <a href="mailto:byoukste@terracottatech.com">byoukste</a>
 
34
 */
 
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;
 
39
 
 
40
    private static final Logger LOG = LoggerFactory.getLogger(CacheSamplerImpl.class);
 
41
 
 
42
    private final Ehcache cache;
 
43
 
 
44
    /**
 
45
     * Constructor accepting the backing {@link Ehcache}
 
46
     *
 
47
     * @param cache the cache object to use in initializing this sampled representation
 
48
     */
 
49
    public CacheSamplerImpl(Ehcache cache) {
 
50
        this.cache = cache;
 
51
        cache.getCacheConfiguration().addConfigurationListener(this);
 
52
    }
 
53
 
 
54
    /**
 
55
     * {@inheritDoc}
 
56
     */
 
57
    public boolean isEnabled() {
 
58
        return !cache.isDisabled();
 
59
    }
 
60
 
 
61
    /**
 
62
     * {@inheritDoc}
 
63
     */
 
64
    public void setEnabled(boolean enabled) {
 
65
        try {
 
66
            cache.setDisabled(!enabled);
 
67
        } catch (RuntimeException e) {
 
68
            throw Utils.newPlainException(e);
 
69
        }
 
70
    }
 
71
 
 
72
    /**
 
73
     * {@inheritDoc}
 
74
     */
 
75
    public boolean isClusterBulkLoadEnabled() {
 
76
        try {
 
77
            return cache.isClusterBulkLoadEnabled();
 
78
        } catch (RuntimeException e) {
 
79
            throw Utils.newPlainException(e);
 
80
        }
 
81
    }
 
82
 
 
83
    /**
 
84
     * {@inheritDoc}
 
85
     */
 
86
    public boolean isNodeBulkLoadEnabled() {
 
87
        return cache.isNodeBulkLoadEnabled();
 
88
    }
 
89
 
 
90
    /**
 
91
     * {@inheritDoc}
 
92
     */
 
93
    public void setNodeBulkLoadEnabled(boolean bulkLoadEnabled) {
 
94
        if (bulkLoadEnabled && getTransactional()) {
 
95
            LOG.warn("a transactional cache cannot be put into bulk-load mode");
 
96
            return;
 
97
        }
 
98
        cache.setNodeBulkLoadEnabled(!bulkLoadEnabled);
 
99
    }
 
100
 
 
101
    /**
 
102
     * {@inheritDoc}
 
103
     */
 
104
    public void flush() {
 
105
        try {
 
106
            cache.flush();
 
107
        } catch (RuntimeException e) {
 
108
            throw Utils.newPlainException(e);
 
109
        }
 
110
    }
 
111
 
 
112
    /**
 
113
     * {@inheritDoc}
 
114
     */
 
115
    public String getCacheName() {
 
116
        return cache.getName();
 
117
    }
 
118
 
 
119
    /**
 
120
     * {@inheritDoc}
 
121
     */
 
122
    public String getStatus() {
 
123
        return cache.getStatus().toString();
 
124
    }
 
125
 
 
126
    /**
 
127
     * {@inheritDoc}
 
128
     */
 
129
    public void removeAll() {
 
130
        CacheTransactionHelper.beginTransactionIfNeeded(cache);
 
131
        try {
 
132
            cache.removeAll();
 
133
        } catch (RuntimeException e) {
 
134
            throw Utils.newPlainException(e);
 
135
        } finally {
 
136
            try {
 
137
                CacheTransactionHelper.commitTransactionIfNeeded(cache);
 
138
            } catch (RuntimeException e2) {
 
139
                throw Utils.newPlainException(e2);
 
140
            }
 
141
        }
 
142
    }
 
143
 
 
144
    /**
 
145
     * {@inheritDoc}
 
146
     */
 
147
    public long getAverageGetTimeMostRecentSample() {
 
148
        return cache.getSampledCacheStatistics().getAverageGetTimeMostRecentSample();
 
149
    }
 
150
 
 
151
    /**
 
152
     * {@inheritDoc}
 
153
     */
 
154
    public long getAverageGetTimeNanosMostRecentSample() {
 
155
        return cache.getSampledCacheStatistics().getAverageGetTimeNanosMostRecentSample();
 
156
    }
 
157
 
 
158
    /**
 
159
     * {@inheritDoc}
 
160
     */
 
161
    public long getCacheEvictionRate() {
 
162
        return getCacheElementEvictedMostRecentSample();
 
163
    }
 
164
 
 
165
    /**
 
166
     * {@inheritDoc}
 
167
     */
 
168
    public long getCacheElementEvictedMostRecentSample() {
 
169
        return cache.getSampledCacheStatistics().getCacheElementEvictedMostRecentSample();
 
170
    }
 
171
 
 
172
    /**
 
173
     * {@inheritDoc}
 
174
     */
 
175
    public long getCacheExpirationRate() {
 
176
        return getCacheElementExpiredMostRecentSample();
 
177
    }
 
178
 
 
179
    /**
 
180
     * {@inheritDoc}
 
181
     */
 
182
    public long getCacheElementExpiredMostRecentSample() {
 
183
        return cache.getSampledCacheStatistics().getCacheElementExpiredMostRecentSample();
 
184
    }
 
185
 
 
186
    /**
 
187
     * {@inheritDoc}
 
188
     */
 
189
    public long getCachePutRate() {
 
190
        return getCacheElementPutMostRecentSample();
 
191
    }
 
192
 
 
193
    /**
 
194
     * {@inheritDoc}
 
195
     */
 
196
    public long getCacheElementPutMostRecentSample() {
 
197
        return cache.getSampledCacheStatistics().getCacheElementPutMostRecentSample();
 
198
    }
 
199
 
 
200
    /**
 
201
     * {@inheritDoc}
 
202
     */
 
203
    public long getCacheRemoveRate() {
 
204
        return getCacheElementRemovedMostRecentSample();
 
205
    }
 
206
 
 
207
    /**
 
208
     * {@inheritDoc}
 
209
     */
 
210
    public long getCacheElementRemovedMostRecentSample() {
 
211
        return cache.getSampledCacheStatistics().getCacheElementRemovedMostRecentSample();
 
212
    }
 
213
 
 
214
    /**
 
215
     * {@inheritDoc}
 
216
     */
 
217
    public long getCacheUpdateRate() {
 
218
        return getCacheElementUpdatedMostRecentSample();
 
219
    }
 
220
 
 
221
    /**
 
222
     * {@inheritDoc}
 
223
     */
 
224
    public long getCacheElementUpdatedMostRecentSample() {
 
225
        return cache.getSampledCacheStatistics().getCacheElementUpdatedMostRecentSample();
 
226
    }
 
227
 
 
228
    /**
 
229
     * {@inheritDoc}
 
230
     */
 
231
    public long getCacheInMemoryHitRate() {
 
232
        return getCacheHitInMemoryMostRecentSample();
 
233
    }
 
234
 
 
235
    /**
 
236
     * {@inheritDoc}
 
237
     */
 
238
    public long getCacheHitInMemoryMostRecentSample() {
 
239
        return cache.getSampledCacheStatistics().getCacheHitInMemoryMostRecentSample();
 
240
    }
 
241
 
 
242
    /**
 
243
     * {@inheritDoc}
 
244
     */
 
245
    public long getCacheOffHeapHitRate() {
 
246
        return getCacheHitOffHeapMostRecentSample();
 
247
    }
 
248
 
 
249
    /**
 
250
     * {@inheritDoc}
 
251
     */
 
252
    public long getCacheHitOffHeapMostRecentSample() {
 
253
        return cache.getSampledCacheStatistics().getCacheHitOffHeapMostRecentSample();
 
254
    }
 
255
 
 
256
    /**
 
257
     * {@inheritDoc}
 
258
     */
 
259
    public long getCacheHitRate() {
 
260
        return getCacheHitMostRecentSample();
 
261
    }
 
262
 
 
263
    /**
 
264
     * {@inheritDoc}
 
265
     */
 
266
    public long getCacheHitMostRecentSample() {
 
267
        return cache.getSampledCacheStatistics().getCacheHitMostRecentSample();
 
268
    }
 
269
 
 
270
    /**
 
271
     * {@inheritDoc}
 
272
     */
 
273
    public long getCacheOnDiskHitRate() {
 
274
        return getCacheHitOnDiskMostRecentSample();
 
275
    }
 
276
 
 
277
    /**
 
278
     * {@inheritDoc}
 
279
     */
 
280
    public long getCacheHitOnDiskMostRecentSample() {
 
281
        return cache.getSampledCacheStatistics().getCacheHitOnDiskMostRecentSample();
 
282
    }
 
283
 
 
284
    /**
 
285
     * {@inheritDoc}
 
286
     */
 
287
    public long getCacheMissExpiredMostRecentSample() {
 
288
        return cache.getSampledCacheStatistics().getCacheMissExpiredMostRecentSample();
 
289
    }
 
290
 
 
291
    /**
 
292
     * {@inheritDoc}
 
293
     */
 
294
    public long getCacheMissRate() {
 
295
        return getCacheMissMostRecentSample();
 
296
    }
 
297
 
 
298
    /**
 
299
     * {@inheritDoc}
 
300
     */
 
301
    public long getCacheMissMostRecentSample() {
 
302
        return cache.getSampledCacheStatistics().getCacheMissMostRecentSample();
 
303
    }
 
304
 
 
305
    /**
 
306
     * {@inheritDoc}
 
307
     */
 
308
    public long getCacheInMemoryMissRate() {
 
309
        return getCacheMissInMemoryMostRecentSample();
 
310
    }
 
311
 
 
312
    /**
 
313
     * {@inheritDoc}
 
314
     */
 
315
    public long getCacheMissInMemoryMostRecentSample() {
 
316
        return cache.getSampledCacheStatistics().getCacheMissInMemoryMostRecentSample();
 
317
    }
 
318
 
 
319
    /**
 
320
     * {@inheritDoc}
 
321
     */
 
322
    public long getCacheOffHeapMissRate() {
 
323
        return getCacheMissOffHeapMostRecentSample();
 
324
    }
 
325
 
 
326
    /**
 
327
     * {@inheritDoc}
 
328
     */
 
329
    public long getCacheMissOffHeapMostRecentSample() {
 
330
        return cache.getSampledCacheStatistics().getCacheMissOffHeapMostRecentSample();
 
331
    }
 
332
 
 
333
    /**
 
334
     * {@inheritDoc}
 
335
     */
 
336
    public long getCacheOnDiskMissRate() {
 
337
        return getCacheMissOnDiskMostRecentSample();
 
338
    }
 
339
 
 
340
    /**
 
341
     * {@inheritDoc}
 
342
     */
 
343
    public long getCacheMissOnDiskMostRecentSample() {
 
344
        return cache.getSampledCacheStatistics().getCacheMissOnDiskMostRecentSample();
 
345
    }
 
346
 
 
347
    /**
 
348
     * {@inheritDoc}
 
349
     */
 
350
    public long getCacheMissNotFoundMostRecentSample() {
 
351
        return cache.getSampledCacheStatistics().getCacheMissNotFoundMostRecentSample();
 
352
    }
 
353
 
 
354
    /**
 
355
     * {@inheritDoc}
 
356
     */
 
357
    public int getStatisticsAccuracy() {
 
358
        return cache.getSampledCacheStatistics().getStatisticsAccuracy();
 
359
    }
 
360
 
 
361
    /**
 
362
     * {@inheritDoc}
 
363
     */
 
364
    public String getStatisticsAccuracyDescription() {
 
365
        return cache.getSampledCacheStatistics().getStatisticsAccuracyDescription();
 
366
    }
 
367
 
 
368
    /**
 
369
     * {@inheritDoc}
 
370
     */
 
371
    public void clearStatistics() {
 
372
        try {
 
373
            cache.clearStatistics();
 
374
        } catch (RuntimeException e) {
 
375
            throw Utils.newPlainException(e);
 
376
        }
 
377
    }
 
378
 
 
379
    /**
 
380
     * {@inheritDoc}
 
381
     */
 
382
    public boolean isStatisticsEnabled() {
 
383
        return cache.isStatisticsEnabled();
 
384
    }
 
385
 
 
386
    /**
 
387
     * {@inheritDoc}
 
388
     */
 
389
    public boolean isSampledStatisticsEnabled() {
 
390
        return cache.getSampledCacheStatistics().isSampledStatisticsEnabled();
 
391
    }
 
392
 
 
393
    /**
 
394
     * {@inheritDoc}
 
395
     */
 
396
    public void dispose() {
 
397
        cache.getCacheConfiguration().removeConfigurationListener(this);
 
398
    }
 
399
 
 
400
    /**
 
401
     * {@inheritDoc}
 
402
     */
 
403
    public boolean isTerracottaClustered() {
 
404
        return this.cache.getCacheConfiguration().isTerracottaClustered();
 
405
    }
 
406
 
 
407
    /**
 
408
     * {@inheritDoc}
 
409
     */
 
410
    public String getTerracottaConsistency() {
 
411
        Consistency consistency = this.cache.getCacheConfiguration().getTerracottaConsistency();
 
412
        return consistency != null ? consistency.name() : "na";
 
413
    }
 
414
 
 
415
    /**
 
416
     * {@inheritDoc}
 
417
     */
 
418
    public void enableStatistics() {
 
419
        if (!cache.isStatisticsEnabled()) {
 
420
            try {
 
421
                cache.setSampledStatisticsEnabled(true);
 
422
                cache.setStatisticsEnabled(true);
 
423
            } catch (RuntimeException e) {
 
424
                throw Utils.newPlainException(e);
 
425
            }
 
426
        }
 
427
    }
 
428
 
 
429
    /**
 
430
     * {@inheritDoc}
 
431
     */
 
432
    public void disableStatistics() {
 
433
        if (cache.isStatisticsEnabled()) {
 
434
            try {
 
435
                cache.setSampledStatisticsEnabled(false);
 
436
                cache.setStatisticsEnabled(false);
 
437
            } catch (RuntimeException e) {
 
438
                throw Utils.newPlainException(e);
 
439
            }
 
440
        }
 
441
    }
 
442
 
 
443
    /**
 
444
     * {@inheritDoc}
 
445
     */
 
446
    public void setStatisticsEnabled(boolean statsEnabled) {
 
447
        boolean oldValue = isStatisticsEnabled();
 
448
        if (oldValue != statsEnabled) {
 
449
            if (statsEnabled) {
 
450
                enableStatistics();
 
451
            } else {
 
452
                disableStatistics();
 
453
            }
 
454
        }
 
455
    }
 
456
 
 
457
    /**
 
458
     * {@inheritDoc}
 
459
     */
 
460
    public void enableSampledStatistics() {
 
461
        if (!cache.isSampledStatisticsEnabled()) {
 
462
            try {
 
463
                cache.setSampledStatisticsEnabled(true);
 
464
            } catch (RuntimeException e) {
 
465
                throw Utils.newPlainException(e);
 
466
            }
 
467
        }
 
468
    }
 
469
 
 
470
    /**
 
471
     * {@inheritDoc}
 
472
     */
 
473
    public void disableSampledStatistics() {
 
474
        if (cache.isSampledStatisticsEnabled()) {
 
475
            try {
 
476
                cache.setSampledStatisticsEnabled(false);
 
477
            } catch (RuntimeException e) {
 
478
                throw Utils.newPlainException(e);
 
479
            }
 
480
        }
 
481
    }
 
482
 
 
483
    /**
 
484
     * {@inheritDoc}
 
485
     */
 
486
    public long getCacheAverageGetTime() {
 
487
        return getAverageGetTimeNanos();
 
488
    }
 
489
 
 
490
    /**
 
491
     * {@inheritDoc}
 
492
     */
 
493
    public float getAverageGetTimeMillis() {
 
494
        try {
 
495
            return getAverageGetTimeNanos() / (float) NANOS_PER_MILLI;
 
496
        } catch (RuntimeException e) {
 
497
            throw Utils.newPlainException(e);
 
498
        }
 
499
    }
 
500
 
 
501
    /**
 
502
     * {@inheritDoc}
 
503
     */
 
504
    public long getAverageGetTimeNanos() {
 
505
        try {
 
506
            return getAverageGetTimeNanosMostRecentSample();
 
507
        } catch (RuntimeException e) {
 
508
            throw Utils.newPlainException(e);
 
509
        }
 
510
    }
 
511
 
 
512
    /**
 
513
     * {@inheritDoc}
 
514
     */
 
515
    public long getMaxGetTimeMillis() {
 
516
        try {
 
517
            return cache.getLiveCacheStatistics().getMaxGetTimeMillis();
 
518
        } catch (RuntimeException e) {
 
519
            throw Utils.newPlainException(e);
 
520
        }
 
521
    }
 
522
 
 
523
    /**
 
524
     * {@inheritDoc}
 
525
     */
 
526
    public long getMinGetTimeMillis() {
 
527
        try {
 
528
            return cache.getLiveCacheStatistics().getMinGetTimeMillis();
 
529
        } catch (RuntimeException e) {
 
530
            throw Utils.newPlainException(e);
 
531
        }
 
532
    }
 
533
 
 
534
    /**
 
535
     * {@inheritDoc}
 
536
     */
 
537
    public long getMaxGetTimeNanos() {
 
538
        try {
 
539
            return cache.getLiveCacheStatistics().getMaxGetTimeNanos();
 
540
        } catch (RuntimeException e) {
 
541
            throw Utils.newPlainException(e);
 
542
        }
 
543
    }
 
544
 
 
545
    /**
 
546
     * {@inheritDoc}
 
547
     */
 
548
    public long getMinGetTimeNanos() {
 
549
        try {
 
550
            return cache.getLiveCacheStatistics().getMinGetTimeNanos();
 
551
        } catch (RuntimeException e) {
 
552
            throw Utils.newPlainException(e);
 
553
        }
 
554
    }
 
555
 
 
556
    /**
 
557
     * {@inheritDoc}
 
558
     */
 
559
    public long getXaCommitCount() {
 
560
        try {
 
561
            return cache.getLiveCacheStatistics().getXaCommitCount();
 
562
        } catch (RuntimeException e) {
 
563
            throw Utils.newPlainException(e);
 
564
        }
 
565
    }
 
566
 
 
567
    /**
 
568
     * {@inheritDoc}
 
569
     */
 
570
    public long getXaRollbackCount() {
 
571
        try {
 
572
            return cache.getLiveCacheStatistics().getXaRollbackCount();
 
573
        } catch (RuntimeException e) {
 
574
            throw Utils.newPlainException(e);
 
575
        }
 
576
    }
 
577
 
 
578
    /**
 
579
     * {@inheritDoc}
 
580
     */
 
581
    public long getXaRecoveredCount() {
 
582
        try {
 
583
            return cache.getLiveCacheStatistics().getXaRecoveredCount();
 
584
        } catch (RuntimeException e) {
 
585
            throw Utils.newPlainException(e);
 
586
        }
 
587
    }
 
588
 
 
589
    /**
 
590
     * {@inheritDoc}
 
591
     */
 
592
    public boolean getHasWriteBehindWriter() {
 
593
        return cache.getWriterManager() instanceof WriteBehindManager &&
 
594
               cache.getRegisteredCacheWriter() != null;
 
595
    }
 
596
 
 
597
    /**
 
598
     * {@inheritDoc}
 
599
     */
 
600
    public long getWriterQueueLength() {
 
601
        try {
 
602
            return cache.getLiveCacheStatistics().getWriterQueueLength();
 
603
        } catch (RuntimeException e) {
 
604
            throw Utils.newPlainException(e);
 
605
        }
 
606
    }
 
607
 
 
608
    /**
 
609
     * {@inheritDoc}
 
610
     */
 
611
    public int getWriterMaxQueueSize() {
 
612
        return cache.getCacheConfiguration().getCacheWriterConfiguration().getWriteBehindMaxQueueSize();
 
613
    }
 
614
 
 
615
    /**
 
616
     * {@inheritDoc}
 
617
     */
 
618
    public int getWriterConcurrency() {
 
619
        return cache.getCacheConfiguration().getCacheWriterConfiguration().getWriteBehindConcurrency();
 
620
    }
 
621
    /**
 
622
     * {@inheritDoc}
 
623
     */
 
624
    public long getCacheHitCount() {
 
625
        try {
 
626
            return cache.getLiveCacheStatistics().getCacheHitCount();
 
627
        } catch (RuntimeException e) {
 
628
            throw Utils.newPlainException(e);
 
629
        }
 
630
    }
 
631
 
 
632
    /**
 
633
     * {@inheritDoc}
 
634
     */
 
635
    public long getCacheMissCount() {
 
636
        try {
 
637
            return cache.getLiveCacheStatistics().getCacheMissCount();
 
638
        } catch (RuntimeException e) {
 
639
            throw Utils.newPlainException(e);
 
640
        }
 
641
    }
 
642
 
 
643
    /**
 
644
     * {@inheritDoc}
 
645
     */
 
646
    public long getInMemoryMissCount() {
 
647
        try {
 
648
            return cache.getLiveCacheStatistics().getInMemoryMissCount();
 
649
        } catch (RuntimeException e) {
 
650
            throw Utils.newPlainException(e);
 
651
        }
 
652
    }
 
653
 
 
654
    /**
 
655
     * {@inheritDoc}
 
656
     */
 
657
    public long getOffHeapMissCount() {
 
658
        try {
 
659
            return cache.getLiveCacheStatistics().getOffHeapMissCount();
 
660
        } catch (RuntimeException e) {
 
661
            throw Utils.newPlainException(e);
 
662
        }
 
663
    }
 
664
 
 
665
    /**
 
666
     * {@inheritDoc}
 
667
     */
 
668
    public long getOnDiskMissCount() {
 
669
        try {
 
670
            return cache.getLiveCacheStatistics().getOnDiskMissCount();
 
671
        } catch (RuntimeException e) {
 
672
            throw Utils.newPlainException(e);
 
673
        }
 
674
    }
 
675
 
 
676
    /**
 
677
     * {@inheritDoc}
 
678
     */
 
679
    public long getCacheMissCountExpired() {
 
680
        try {
 
681
            return cache.getLiveCacheStatistics().getCacheMissCountExpired();
 
682
        } catch (RuntimeException e) {
 
683
            throw Utils.newPlainException(e);
 
684
        }
 
685
    }
 
686
 
 
687
    /**
 
688
     * {@inheritDoc}
 
689
     */
 
690
    public long getDiskExpiryThreadIntervalSeconds() {
 
691
        return cache.getCacheConfiguration().getDiskExpiryThreadIntervalSeconds();
 
692
    }
 
693
 
 
694
    /**
 
695
     * {@inheritDoc}
 
696
     */
 
697
    public void setDiskExpiryThreadIntervalSeconds(long seconds) {
 
698
        if (getDiskExpiryThreadIntervalSeconds() != seconds) {
 
699
            try {
 
700
                cache.getCacheConfiguration().setDiskExpiryThreadIntervalSeconds(seconds);
 
701
            } catch (RuntimeException e) {
 
702
                throw Utils.newPlainException(e);
 
703
            }
 
704
        }
 
705
    }
 
706
 
 
707
    /**
 
708
     * {@inheritDoc}
 
709
     */
 
710
    public long getMaxEntriesLocalHeap() {
 
711
        return cache.getCacheConfiguration().getMaxEntriesLocalHeap();
 
712
    }
 
713
 
 
714
    /**
 
715
     * {@inheritDoc}
 
716
     */
 
717
    public void setMaxEntriesLocalHeap(long maxEntries) {
 
718
        if (getMaxEntriesLocalHeap() != maxEntries) {
 
719
            try {
 
720
                cache.getCacheConfiguration().setMaxEntriesLocalHeap(maxEntries);
 
721
            } catch (RuntimeException e) {
 
722
                throw Utils.newPlainException(e);
 
723
            }
 
724
        }
 
725
    }
 
726
 
 
727
    /**
 
728
     * {@inheritDoc}
 
729
     */
 
730
    public long getMaxBytesLocalHeap() {
 
731
        return cache.getCacheConfiguration().getMaxBytesLocalHeap();
 
732
    }
 
733
 
 
734
    /**
 
735
     * {@inheritDoc}
 
736
     */
 
737
    public void setMaxBytesLocalHeap(long maxBytes) {
 
738
        try {
 
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 + ")");
 
745
                }
 
746
            }
 
747
            cache.getCacheConfiguration().setMaxBytesLocalHeap(maxBytes);
 
748
        } catch (RuntimeException e) {
 
749
            throw Utils.newPlainException(e);
 
750
        }
 
751
    }
 
752
 
 
753
    /**
 
754
     * {@inheritDoc}
 
755
     */
 
756
    public void setMaxBytesLocalHeapAsString(String maxBytes) {
 
757
        try {
 
758
            cache.getCacheConfiguration().setMaxBytesLocalHeap(maxBytes);
 
759
        } catch (RuntimeException e) {
 
760
            throw Utils.newPlainException(e);
 
761
        }
 
762
 
 
763
        if (cache.getCacheConfiguration().isMaxBytesLocalHeapPercentageSet()) {
 
764
            long cacheAssignedMem = cache.getCacheManager().getConfiguration().getMaxBytesLocalHeap() *
 
765
                                    cache.getCacheConfiguration().getMaxBytesLocalHeapPercentage() / PERCENTAGE_DIVISOR;
 
766
            setMaxBytesLocalHeap(cacheAssignedMem);
 
767
        }
 
768
 
 
769
    }
 
770
 
 
771
    /**
 
772
     * {@inheritDoc}
 
773
     */
 
774
    public String getMaxBytesLocalHeapAsString() {
 
775
        return cache.getCacheConfiguration().getMaxBytesLocalHeapAsString();
 
776
    }
 
777
 
 
778
    /**
 
779
     * {@inheritDoc}
 
780
     */
 
781
    public long getMaxEntriesLocalDisk() {
 
782
        return cache.getCacheConfiguration().getMaxEntriesLocalDisk();
 
783
    }
 
784
 
 
785
    /**
 
786
     * {@inheritDoc}
 
787
     */
 
788
    public void setMaxEntriesLocalDisk(long maxEntries) {
 
789
        if (getMaxEntriesLocalDisk() != maxEntries) {
 
790
            try {
 
791
                cache.getCacheConfiguration().setMaxEntriesLocalDisk(maxEntries);
 
792
            } catch (RuntimeException e) {
 
793
                throw Utils.newPlainException(e);
 
794
            }
 
795
        }
 
796
    }
 
797
 
 
798
    /**
 
799
     * {@inheritDoc}
 
800
     */
 
801
    public void setMaxBytesLocalDisk(long maxBytes) {
 
802
        try {
 
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 + ")");
 
809
                }
 
810
            }
 
811
            cache.getCacheConfiguration().setMaxBytesLocalDisk(maxBytes);
 
812
        } catch (RuntimeException e) {
 
813
            throw Utils.newPlainException(e);
 
814
        }
 
815
    }
 
816
 
 
817
    /**
 
818
     * {@inheritDoc}
 
819
     */
 
820
    public void setMaxBytesLocalDiskAsString(String maxBytes) {
 
821
        try {
 
822
            cache.getCacheConfiguration().setMaxBytesLocalDisk(maxBytes);
 
823
        } catch (RuntimeException e) {
 
824
            throw Utils.newPlainException(e);
 
825
        }
 
826
 
 
827
        if (cache.getCacheConfiguration().isMaxBytesLocalDiskPercentageSet()) {
 
828
            long cacheAssignedMem = cache.getCacheManager().getConfiguration().getMaxBytesLocalDisk() *
 
829
                                    cache.getCacheConfiguration().getMaxBytesLocalDiskPercentage() / PERCENTAGE_DIVISOR;
 
830
            setMaxBytesLocalDisk(cacheAssignedMem);
 
831
        }
 
832
    }
 
833
 
 
834
    /**
 
835
     * {@inheritDoc}
 
836
     */
 
837
    public String getMaxBytesLocalDiskAsString() {
 
838
        return cache.getCacheConfiguration().getMaxBytesLocalDiskAsString();
 
839
    }
 
840
 
 
841
    /**
 
842
     * {@inheritDoc}
 
843
     */
 
844
    public int getMaxElementsOnDisk() {
 
845
        return cache.getCacheConfiguration().getMaxElementsOnDisk();
 
846
    }
 
847
 
 
848
    /**
 
849
     * {@inheritDoc}
 
850
     */
 
851
    public void setMaxElementsOnDisk(int maxElements) {
 
852
        if (getMaxElementsOnDisk() != maxElements) {
 
853
            try {
 
854
                cache.getCacheConfiguration().setMaxElementsOnDisk(maxElements);
 
855
            } catch (RuntimeException e) {
 
856
                throw Utils.newPlainException(e);
 
857
            }
 
858
        }
 
859
    }
 
860
 
 
861
    /**
 
862
     * {@inheritDoc}
 
863
     */
 
864
    public long getMaxBytesLocalDisk() {
 
865
        return cache.getCacheConfiguration().getMaxBytesLocalDisk();
 
866
    }
 
867
 
 
868
    /**
 
869
     * {@inheritDoc}
 
870
     */
 
871
    public long getMaxBytesLocalOffHeap() {
 
872
        return cache.getCacheConfiguration().getMaxBytesLocalOffHeap();
 
873
    }
 
874
 
 
875
    /**
 
876
     * {@inheritDoc}
 
877
     */
 
878
    public String getMaxBytesLocalOffHeapAsString() {
 
879
        return cache.getCacheConfiguration().getMaxBytesLocalOffHeapAsString();
 
880
    }
 
881
 
 
882
    /**
 
883
     * {@inheritDoc}
 
884
     */
 
885
    public String getMemoryStoreEvictionPolicy() {
 
886
        return cache.getCacheConfiguration().getMemoryStoreEvictionPolicy().toString();
 
887
    }
 
888
 
 
889
    /**
 
890
     * {@inheritDoc}
 
891
     */
 
892
    public void setMemoryStoreEvictionPolicy(String evictionPolicy) {
 
893
        if (!getMemoryStoreEvictionPolicy().equals(evictionPolicy)) {
 
894
            try {
 
895
                cache.getCacheConfiguration().setMemoryStoreEvictionPolicy(evictionPolicy);
 
896
            } catch (RuntimeException e) {
 
897
                throw Utils.newPlainException(e);
 
898
            }
 
899
        }
 
900
    }
 
901
 
 
902
    /**
 
903
     * {@inheritDoc}
 
904
     */
 
905
    public long getTimeToIdleSeconds() {
 
906
        return cache.getCacheConfiguration().getTimeToIdleSeconds();
 
907
    }
 
908
 
 
909
    /**
 
910
     * {@inheritDoc}
 
911
     */
 
912
    public void setTimeToIdleSeconds(long tti) {
 
913
        if (getTimeToIdleSeconds() != tti) {
 
914
            try {
 
915
                cache.getCacheConfiguration().setTimeToIdleSeconds(tti);
 
916
            } catch (RuntimeException e) {
 
917
                throw Utils.newPlainException(e);
 
918
            }
 
919
        }
 
920
    }
 
921
 
 
922
    /**
 
923
     * {@inheritDoc}
 
924
     */
 
925
    public long getTimeToLiveSeconds() {
 
926
        return cache.getCacheConfiguration().getTimeToLiveSeconds();
 
927
    }
 
928
 
 
929
    /**
 
930
     * {@inheritDoc}
 
931
     */
 
932
    public void setTimeToLiveSeconds(long ttl) {
 
933
        if (getTimeToLiveSeconds() != ttl) {
 
934
            try {
 
935
                cache.getCacheConfiguration().setTimeToLiveSeconds(ttl);
 
936
            } catch (RuntimeException e) {
 
937
                throw Utils.newPlainException(e);
 
938
            }
 
939
        }
 
940
    }
 
941
 
 
942
    /**
 
943
     * {@inheritDoc}
 
944
     */
 
945
    public boolean isDiskPersistent() {
 
946
        return cache.getCacheConfiguration().isDiskPersistent();
 
947
    }
 
948
 
 
949
    /**
 
950
     * {@inheritDoc}
 
951
     */
 
952
    public void setDiskPersistent(boolean diskPersistent) {
 
953
        if (isDiskPersistent() != diskPersistent) {
 
954
            try {
 
955
                cache.getCacheConfiguration().setDiskPersistent(diskPersistent);
 
956
            } catch (RuntimeException e) {
 
957
                throw Utils.newPlainException(e);
 
958
            }
 
959
        }
 
960
    }
 
961
 
 
962
    /**
 
963
     * {@inheritDoc}
 
964
     */
 
965
    public boolean isEternal() {
 
966
        return cache.getCacheConfiguration().isEternal();
 
967
    }
 
968
 
 
969
    /**
 
970
     * {@inheritDoc}
 
971
     */
 
972
    public void setEternal(boolean eternal) {
 
973
        if (isEternal() != eternal) {
 
974
            try {
 
975
                cache.getCacheConfiguration().setEternal(eternal);
 
976
            } catch (RuntimeException e) {
 
977
                throw Utils.newPlainException(e);
 
978
            }
 
979
        }
 
980
    }
 
981
 
 
982
    /**
 
983
     * {@inheritDoc}
 
984
     */
 
985
    public boolean isOverflowToDisk() {
 
986
        return cache.getCacheConfiguration().isOverflowToDisk();
 
987
    }
 
988
 
 
989
    /**
 
990
     * {@inheritDoc}
 
991
     */
 
992
    public void setOverflowToDisk(boolean overflowToDisk) {
 
993
        if (isOverflowToDisk() != overflowToDisk) {
 
994
            try {
 
995
                cache.getCacheConfiguration().setOverflowToDisk(overflowToDisk);
 
996
            } catch (RuntimeException e) {
 
997
                throw Utils.newPlainException(e);
 
998
            }
 
999
        }
 
1000
    }
 
1001
 
 
1002
    /**
 
1003
     * {@inheritDoc}
 
1004
     */
 
1005
    public boolean isLoggingEnabled() {
 
1006
        return cache.getCacheConfiguration().getLogging();
 
1007
    }
 
1008
 
 
1009
    /**
 
1010
     * {@inheritDoc}
 
1011
     */
 
1012
    public void setLoggingEnabled(boolean enabled) {
 
1013
        if (isLoggingEnabled() != enabled) {
 
1014
            try {
 
1015
                cache.getCacheConfiguration().setLogging(enabled);
 
1016
            } catch (RuntimeException e) {
 
1017
                throw Utils.newPlainException(e);
 
1018
            }
 
1019
        }
 
1020
    }
 
1021
 
 
1022
    /**
 
1023
     * {@inheritDoc}
 
1024
     */
 
1025
    public boolean isPinned() {
 
1026
        return cache.getCacheConfiguration().getPinningConfiguration() != null;
 
1027
    }
 
1028
 
 
1029
    /**
 
1030
     * {@inheritDoc}
 
1031
     */
 
1032
    public String getPinnedToStore() {
 
1033
        PinningConfiguration pinningConfig = cache.getCacheConfiguration().getPinningConfiguration();
 
1034
        return pinningConfig != null ? pinningConfig.getStore().name() : "na";
 
1035
    }
 
1036
 
 
1037
    /**
 
1038
     * {@inheritDoc}
 
1039
     */
 
1040
    public long getEvictedCount() {
 
1041
        try {
 
1042
            return cache.getLiveCacheStatistics().getEvictedCount();
 
1043
        } catch (RuntimeException e) {
 
1044
            throw Utils.newPlainException(e);
 
1045
        }
 
1046
    }
 
1047
 
 
1048
    /**
 
1049
     * {@inheritDoc}
 
1050
     */
 
1051
    public long getExpiredCount() {
 
1052
        try {
 
1053
            return cache.getLiveCacheStatistics().getExpiredCount();
 
1054
        } catch (RuntimeException e) {
 
1055
            throw Utils.newPlainException(e);
 
1056
        }
 
1057
    }
 
1058
 
 
1059
    /**
 
1060
     * {@inheritDoc}
 
1061
     */
 
1062
    public long getInMemoryHitCount() {
 
1063
        try {
 
1064
            return cache.getLiveCacheStatistics().getInMemoryHitCount();
 
1065
        } catch (RuntimeException e) {
 
1066
            throw Utils.newPlainException(e);
 
1067
        }
 
1068
    }
 
1069
 
 
1070
    /**
 
1071
     * {@inheritDoc}
 
1072
     */
 
1073
    public long getOffHeapHitCount() {
 
1074
        try {
 
1075
            return cache.getLiveCacheStatistics().getOffHeapHitCount();
 
1076
        } catch (RuntimeException e) {
 
1077
            throw Utils.newPlainException(e);
 
1078
        }
 
1079
    }
 
1080
 
 
1081
    /**
 
1082
     * {@inheritDoc}
 
1083
     *
 
1084
     * @deprecated use {@link #getLocalOffHeapSize()}
 
1085
     */
 
1086
    @Deprecated
 
1087
    public long getOffHeapSize() {
 
1088
        return getLocalOffHeapSize();
 
1089
    }
 
1090
 
 
1091
    /**
 
1092
     * {@inheritDoc}
 
1093
     */
 
1094
    public long getOnDiskHitCount() {
 
1095
        try {
 
1096
            return cache.getLiveCacheStatistics().getOnDiskHitCount();
 
1097
        } catch (RuntimeException e) {
 
1098
            throw Utils.newPlainException(e);
 
1099
        }
 
1100
    }
 
1101
 
 
1102
    /**
 
1103
     * {@inheritDoc}
 
1104
     *
 
1105
     * @deprecated use {@link #getLocalDiskSize()}
 
1106
     */
 
1107
    @Deprecated
 
1108
    public long getOnDiskSize() {
 
1109
        return getLocalDiskSize();
 
1110
    }
 
1111
 
 
1112
    /**
 
1113
     * {@inheritDoc}
 
1114
     */
 
1115
    public long getLocalDiskSize() {
 
1116
        try {
 
1117
            return cache.getLiveCacheStatistics().getLocalDiskSize();
 
1118
        } catch (RuntimeException e) {
 
1119
            throw Utils.newPlainException(e);
 
1120
        }
 
1121
    }
 
1122
 
 
1123
    /**
 
1124
     * {@inheritDoc}
 
1125
     */
 
1126
    public long getLocalHeapSize() {
 
1127
        try {
 
1128
            return cache.getLiveCacheStatistics().getLocalHeapSize();
 
1129
        } catch (RuntimeException e) {
 
1130
            throw Utils.newPlainException(e);
 
1131
        }
 
1132
    }
 
1133
 
 
1134
    /**
 
1135
     * {@inheritDoc}
 
1136
     */
 
1137
    public long getLocalOffHeapSize() {
 
1138
        try {
 
1139
            return cache.getLiveCacheStatistics().getLocalOffHeapSize();
 
1140
        } catch (RuntimeException e) {
 
1141
            throw Utils.newPlainException(e);
 
1142
        }
 
1143
    }
 
1144
 
 
1145
    /**
 
1146
     * {@inheritDoc}
 
1147
     */
 
1148
    public long getLocalDiskSizeInBytes() {
 
1149
        try {
 
1150
            return cache.getLiveCacheStatistics().getLocalDiskSizeInBytes();
 
1151
        } catch (RuntimeException e) {
 
1152
            throw Utils.newPlainException(e);
 
1153
        }
 
1154
    }
 
1155
 
 
1156
    /**
 
1157
     * {@inheritDoc}
 
1158
     */
 
1159
    public long getLocalHeapSizeInBytes() {
 
1160
        try {
 
1161
            return cache.getLiveCacheStatistics().getLocalHeapSizeInBytes();
 
1162
        } catch (RuntimeException e) {
 
1163
            throw Utils.newPlainException(e);
 
1164
        }
 
1165
    }
 
1166
 
 
1167
    /**
 
1168
     * {@inheritDoc}
 
1169
     */
 
1170
    public long getLocalOffHeapSizeInBytes() {
 
1171
        try {
 
1172
            return cache.getLiveCacheStatistics().getLocalOffHeapSizeInBytes();
 
1173
        } catch (RuntimeException e) {
 
1174
            throw Utils.newPlainException(e);
 
1175
        }
 
1176
    }
 
1177
 
 
1178
    /**
 
1179
     * {@inheritDoc}
 
1180
     */
 
1181
    public long getPutCount() {
 
1182
        try {
 
1183
            return cache.getLiveCacheStatistics().getPutCount();
 
1184
        } catch (RuntimeException e) {
 
1185
            throw Utils.newPlainException(e);
 
1186
        }
 
1187
    }
 
1188
 
 
1189
    /**
 
1190
     * {@inheritDoc}
 
1191
     */
 
1192
    public long getRemovedCount() {
 
1193
        try {
 
1194
            return cache.getLiveCacheStatistics().getRemovedCount();
 
1195
        } catch (RuntimeException e) {
 
1196
            throw Utils.newPlainException(e);
 
1197
        }
 
1198
    }
 
1199
 
 
1200
    /**
 
1201
     * {@inheritDoc}
 
1202
     */
 
1203
    public long getSize() {
 
1204
        try {
 
1205
            return cache.getLiveCacheStatistics().getSize();
 
1206
        } catch (RuntimeException e) {
 
1207
            throw Utils.newPlainException(e);
 
1208
        }
 
1209
    }
 
1210
 
 
1211
    /**
 
1212
     * {@inheritDoc}
 
1213
     */
 
1214
    public long getInMemorySize() {
 
1215
        return getLocalHeapSize();
 
1216
    }
 
1217
 
 
1218
    /**
 
1219
     * {@inheritDoc}
 
1220
     */
 
1221
    public long getUpdateCount() {
 
1222
        try {
 
1223
            return cache.getLiveCacheStatistics().getUpdateCount();
 
1224
        } catch (RuntimeException e) {
 
1225
            throw Utils.newPlainException(e);
 
1226
        }
 
1227
    }
 
1228
 
 
1229
    /**
 
1230
     * {@inheritDoc}
 
1231
     */
 
1232
    public void deregistered(CacheConfiguration config) {
 
1233
        /**/
 
1234
    }
 
1235
 
 
1236
    /**
 
1237
     * {@inheritDoc}
 
1238
     */
 
1239
    public void maxBytesLocalHeapChanged(final long oldValue, final long newValue) {
 
1240
        if (oldValue != newValue) {
 
1241
            setMaxBytesLocalHeap(newValue);
 
1242
        }
 
1243
    }
 
1244
 
 
1245
    /**
 
1246
     * {@inheritDoc}
 
1247
     */
 
1248
    public void maxBytesLocalDiskChanged(final long oldValue, final long newValue) {
 
1249
        if (oldValue != newValue) {
 
1250
            setMaxBytesLocalDisk(newValue);
 
1251
        }
 
1252
    }
 
1253
 
 
1254
    /**
 
1255
     * {@inheritDoc}
 
1256
     */
 
1257
    public void diskCapacityChanged(int oldCapacity, int newCapacity) {
 
1258
        if (oldCapacity != newCapacity) {
 
1259
            setMaxElementsOnDisk(newCapacity);
 
1260
        }
 
1261
    }
 
1262
 
 
1263
    /**
 
1264
     * {@inheritDoc}
 
1265
     */
 
1266
    public void loggingChanged(boolean oldValue, boolean newValue) {
 
1267
        if (oldValue != newValue) {
 
1268
            setLoggingEnabled(newValue);
 
1269
        }
 
1270
    }
 
1271
 
 
1272
    /**
 
1273
     * {@inheritDoc}
 
1274
     */
 
1275
    public void memoryCapacityChanged(int oldCapacity, int newCapacity) {
 
1276
        if (oldCapacity != newCapacity) {
 
1277
            setMaxEntriesLocalHeap(newCapacity);
 
1278
        }
 
1279
    }
 
1280
 
 
1281
    /**
 
1282
     * {@inheritDoc}
 
1283
     */
 
1284
    public void registered(CacheConfiguration config) {
 
1285
        /**/
 
1286
    }
 
1287
 
 
1288
    /**
 
1289
     * {@inheritDoc}
 
1290
     */
 
1291
    public void timeToIdleChanged(long oldTimeToIdle, long newTimeToIdle) {
 
1292
        if (oldTimeToIdle != newTimeToIdle) {
 
1293
            setTimeToIdleSeconds(newTimeToIdle);
 
1294
        }
 
1295
    }
 
1296
 
 
1297
    /**
 
1298
     * {@inheritDoc}
 
1299
     */
 
1300
    public void timeToLiveChanged(long oldTimeToLive, long newTimeToLive) {
 
1301
        if (oldTimeToLive != newTimeToLive) {
 
1302
            setTimeToLiveSeconds(newTimeToLive);
 
1303
        }
 
1304
    }
 
1305
 
 
1306
    /**
 
1307
     * {@inheritDoc}
 
1308
     */
 
1309
    public long getAverageSearchTime() {
 
1310
        return cache.getAverageSearchTime();
 
1311
    }
 
1312
 
 
1313
    /**
 
1314
     * {@inheritDoc}
 
1315
     */
 
1316
    public long getSearchesPerSecond() {
 
1317
        return cache.getSearchesPerSecond();
 
1318
    }
 
1319
 
 
1320
    /**
 
1321
     * {@inheritDoc}
 
1322
     */
 
1323
    public boolean getTransactional() {
 
1324
        return cache.getCacheConfiguration().getTransactionalMode().isTransactional();
 
1325
    }
 
1326
 
 
1327
    /**
 
1328
     * {@inheritDoc}
 
1329
     */
 
1330
    public boolean getSearchable() {
 
1331
        return cache.getCacheConfiguration().getSearchable() != null;
 
1332
    }
 
1333
 
 
1334
    /**
 
1335
     * {@inheritDoc}
 
1336
     */
 
1337
    public long getCacheSearchRate() {
 
1338
        return cache.getSampledCacheStatistics().getSearchesPerSecond();
 
1339
    }
 
1340
 
 
1341
    /**
 
1342
     * {@inheritDoc}
 
1343
     */
 
1344
    public long getCacheAverageSearchTime() {
 
1345
        return cache.getSampledCacheStatistics().getAverageSearchTime();
 
1346
    }
 
1347
 
 
1348
    /**
 
1349
     * {@inheritDoc}
 
1350
     */
 
1351
    public long getTransactionCommitRate() {
 
1352
        return getCacheXaCommitsMostRecentSample();
 
1353
    }
 
1354
 
 
1355
    /**
 
1356
     * {@inheritDoc}
 
1357
     */
 
1358
    public long getCacheXaCommitsMostRecentSample() {
 
1359
        return cache.getSampledCacheStatistics().getCacheXaCommitsMostRecentSample();
 
1360
    }
 
1361
 
 
1362
    /**
 
1363
     * {@inheritDoc}
 
1364
     */
 
1365
    public long getTransactionRollbackRate() {
 
1366
        return getCacheXaRollbacksMostRecentSample();
 
1367
    }
 
1368
 
 
1369
    /**
 
1370
     * {@inheritDoc}
 
1371
     */
 
1372
    public long getCacheXaRollbacksMostRecentSample() {
 
1373
        return cache.getSampledCacheStatistics().getCacheXaRollbacksMostRecentSample();
 
1374
    }
 
1375
 
 
1376
    /**
 
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.
 
1381
     *
 
1382
     * @return the underlying {@code Ehcache} object
 
1383
     */
 
1384
    Ehcache getCache() {
 
1385
        return cache;
 
1386
    }
 
1387
 
 
1388
    /**
 
1389
     * {@inheritDoc}
 
1390
     */
 
1391
    public int getCacheHitRatio() {
 
1392
        return getCacheHitRatioMostRecentSample();
 
1393
    }
 
1394
 
 
1395
    /**
 
1396
     * {@inheritDoc}
 
1397
     */
 
1398
    public int getCacheHitRatioMostRecentSample() {
 
1399
        return cache.getSampledCacheStatistics().getCacheHitRatioMostRecentSample();
 
1400
    }
 
1401
}
 
1402
 
 
1403