@@ -119,6 +119,11 @@ public void testComputeIfAbsentWithFactoryBasedCacheCreation() throws Exception
119
119
.getKey (),
120
120
onHeapCacheSize * keyValueSize + "b"
121
121
)
122
+ .put (
123
+ CacheSettings .getConcreteStoreNameSettingForCacheType (CacheType .INDICES_REQUEST_CACHE ).getKey (),
124
+ TieredSpilloverCache .TieredSpilloverCacheFactory .TIERED_SPILLOVER_CACHE_NAME
125
+ )
126
+ .put (FeatureFlags .PLUGGABLE_CACHE , "true" )
122
127
.build ();
123
128
124
129
ICache <String , String > tieredSpilloverICache = new TieredSpilloverCache .TieredSpilloverCacheFactory ().create (
@@ -127,12 +132,8 @@ public void testComputeIfAbsentWithFactoryBasedCacheCreation() throws Exception
127
132
.setWeigher ((k , v ) -> keyValueSize )
128
133
.setRemovalListener (removalListener )
129
134
.setSettings (settings )
130
- .setCachedResultParser (new Function <String , CachedQueryResult .PolicyValues >() {
131
- @ Override
132
- public CachedQueryResult .PolicyValues apply (String s ) {
133
- return new CachedQueryResult .PolicyValues (20_000_000L );
134
- }
135
- }) // Values will always appear to have taken 20_000_000 ns = 20 ms to compute
135
+ .setCachedResultParser (s -> new CachedQueryResult .PolicyValues (20_000_000L )) // Values will always appear to have taken
136
+ // 20_000_000 ns = 20 ms to compute
136
137
.build (),
137
138
CacheType .INDICES_REQUEST_CACHE ,
138
139
Map .of (
@@ -145,20 +146,16 @@ public CachedQueryResult.PolicyValues apply(String s) {
145
146
146
147
TieredSpilloverCache <String , String > tieredSpilloverCache = (TieredSpilloverCache <String , String >) tieredSpilloverICache ;
147
148
148
- // Put values in cache more than it's size and cause evictions from onHeap.
149
149
int numOfItems1 = randomIntBetween (onHeapCacheSize + 1 , totalSize );
150
- List <String > onHeapKeys = new ArrayList <>();
151
- List <String > diskTierKeys = new ArrayList <>();
152
150
for (int iter = 0 ; iter < numOfItems1 ; iter ++) {
153
151
String key = UUID .randomUUID ().toString ();
154
152
LoadAwareCacheLoader <String , String > tieredCacheLoader = getLoadAwareCacheLoader ();
155
153
tieredSpilloverCache .computeIfAbsent (key , tieredCacheLoader );
156
154
}
157
- tieredSpilloverCache .getOnHeapCache ().keys ().forEach (onHeapKeys ::add );
158
- tieredSpilloverCache .getDiskCache ().keys ().forEach (diskTierKeys ::add );
159
-
160
- assertEquals (tieredSpilloverCache .getOnHeapCache ().count (), onHeapKeys .size ());
161
- assertEquals (tieredSpilloverCache .getDiskCache ().count (), diskTierKeys .size ());
155
+ // Verify on heap cache size.
156
+ assertEquals (onHeapCacheSize , tieredSpilloverCache .getOnHeapCache ().count ());
157
+ // Verify disk cache size.
158
+ assertEquals (numOfItems1 - onHeapCacheSize , tieredSpilloverCache .getDiskCache ().count ());
162
159
}
163
160
164
161
public void testWithFactoryCreationWithOnHeapCacheNotPresent () {
@@ -180,6 +177,11 @@ public void testWithFactoryCreationWithOnHeapCacheNotPresent() {
180
177
.getKey (),
181
178
onHeapCacheSize * keyValueSize + "b"
182
179
)
180
+ .put (
181
+ CacheSettings .getConcreteStoreNameSettingForCacheType (CacheType .INDICES_REQUEST_CACHE ).getKey (),
182
+ TieredSpilloverCache .TieredSpilloverCacheFactory .TIERED_SPILLOVER_CACHE_NAME
183
+ )
184
+ .put (FeatureFlags .PLUGGABLE_CACHE , "true" )
183
185
.build ();
184
186
185
187
IllegalArgumentException ex = assertThrows (
0 commit comments