1919package org .apache .polaris .persistence .cache ;
2020
2121import static java .util .concurrent .CompletableFuture .delayedExecutor ;
22+ import static org .apache .polaris .persistence .cache .CaffeineCacheBackend .METER_CACHE_ADMIT_CAPACITY ;
23+ import static org .apache .polaris .persistence .cache .CaffeineCacheBackend .METER_CACHE_CAPACITY ;
2224import static org .apache .polaris .persistence .cache .CaffeineCacheBackend .METER_CACHE_REJECTED_WEIGHT ;
23- import static org .apache .polaris .persistence .cache .CaffeineCacheBackend .METER_CACHE_REJECTIONS ;
2425import static org .apache .polaris .persistence .cache .CaffeineCacheBackend .METER_CACHE_WEIGHT ;
2526
2627import com .google .common .base .Strings ;
@@ -76,9 +77,10 @@ private void testCacheOvershoot(Executor evictionExecutor) throws Exception {
7677 meterRegistry .getMeters ().stream ()
7778 .collect (Collectors .toMap (m -> m .getId ().getName (), Function .identity (), (a , b ) -> a ));
7879 soft .assertThat (metersByName )
79- .containsKeys (METER_CACHE_WEIGHT , METER_CACHE_REJECTIONS , METER_CACHE_REJECTED_WEIGHT );
80+ .containsKeys (METER_CACHE_WEIGHT , METER_CACHE_ADMIT_CAPACITY , METER_CACHE_REJECTED_WEIGHT );
8081 var meterWeightReported = (Gauge ) metersByName .get (METER_CACHE_WEIGHT );
81- var meterRejections = (Gauge ) metersByName .get (METER_CACHE_REJECTIONS );
82+ var meterAdmittedCapacity = (Gauge ) metersByName .get (METER_CACHE_ADMIT_CAPACITY );
83+ var meterCapacity = (Gauge ) metersByName .get (METER_CACHE_CAPACITY );
8284 var meterRejectedWeight = (DistributionSummary ) metersByName .get (METER_CACHE_REJECTED_WEIGHT );
8385
8486 var maxWeight = cache .capacityBytes ();
@@ -97,7 +99,9 @@ private void testCacheOvershoot(Executor evictionExecutor) throws Exception {
9799 soft .assertThat (cache .currentWeightReported ()).isLessThanOrEqualTo (maxWeight );
98100 soft .assertThat (cache .rejections ()).isEqualTo (0L );
99101 soft .assertThat (meterWeightReported .value ()).isGreaterThan (0d );
100- soft .assertThat (meterRejections .value ()).isEqualTo ((double ) cache .rejections ());
102+ soft .assertThat (meterAdmittedCapacity .value ()).isEqualTo ((double ) admitWeight );
103+ soft .assertThat (meterCapacity .value ())
104+ .isEqualTo ((double ) config .sizing ().orElseThrow ().fixedSize ().orElseThrow ().asLong ());
101105
102106 var seenOvershoot = false ;
103107 var stop = new AtomicBoolean ();
@@ -126,7 +130,6 @@ private void testCacheOvershoot(Executor evictionExecutor) throws Exception {
126130
127131 soft .assertThat (cache .currentWeightReported ()).isLessThanOrEqualTo (admitWeight );
128132 soft .assertThat (cache .rejections ()).isEqualTo (0L );
129- soft .assertThat (meterRejections .value ()).isEqualTo (0d );
130133 soft .assertThat (meterRejectedWeight .totalAmount ()).isEqualTo (0d );
131134 soft .assertThat (seenOvershoot ).isFalse ();
132135 }
0 commit comments