Skip to content

Commit f60339f

Browse files
peteralfonsiPeter Alfonsi
andcommitted
[Tiered Caching] Bump versions for serialization in new cache stats API (opensearch-project#13460)
--------- Signed-off-by: Peter Alfonsi <[email protected]> Co-authored-by: Peter Alfonsi <[email protected]>
1 parent 88718a2 commit f60339f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

server/src/main/java/org/opensearch/index/cache/request/ShardRequestCache.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
package org.opensearch.index.cache.request;
3434

35+
import org.apache.lucene.util.Accountable;
3536
import org.opensearch.common.metrics.CounterMetric;
3637
import org.opensearch.core.common.bytes.BytesReference;
3738

@@ -59,6 +60,7 @@ public void onMiss() {
5960
missCount.inc();
6061
}
6162

63+
// Functions used to increment size by passing in the size directly, Used now, as we use ICacheKey<Key> in the IndicesRequestCache..
6264
public void onCached(long keyRamBytesUsed, BytesReference value) {
6365
totalMetric.inc(keyRamBytesUsed + value.ramBytesUsed());
6466
}
@@ -73,4 +75,22 @@ public void onRemoval(long keyRamBytesUsed, BytesReference value, boolean evicte
7375
}
7476
totalMetric.dec(dec);
7577
}
78+
79+
// Old functions which increment size by passing in an Accountable. Functional but no longer used.
80+
public void onCached(Accountable key, BytesReference value) {
81+
totalMetric.inc(key.ramBytesUsed() + value.ramBytesUsed());
82+
}
83+
84+
public void onRemoval(Accountable key, BytesReference value, boolean evicted) {
85+
if (evicted) {
86+
evictionsMetric.inc();
87+
}
88+
long dec = 0;
89+
if (key != null) {
90+
dec += key.ramBytesUsed();
91+
}
92+
if (value != null) {
93+
dec += value.ramBytesUsed();
94+
}
95+
}
7696
}

0 commit comments

Comments
 (0)