Skip to content

Commit

Permalink
[Tiered Caching] Bump versions for serialization in new cache stats A…
Browse files Browse the repository at this point in the history
…PI (opensearch-project#13460)

---------

Signed-off-by: Peter Alfonsi <petealft@amazon.com>
Co-authored-by: Peter Alfonsi <petealft@amazon.com>
  • Loading branch information
peteralfonsi and Peter Alfonsi committed Sep 3, 2024
1 parent 88718a2 commit f60339f
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

package org.opensearch.index.cache.request;

import org.apache.lucene.util.Accountable;
import org.opensearch.common.metrics.CounterMetric;
import org.opensearch.core.common.bytes.BytesReference;

Expand Down Expand Up @@ -59,6 +60,7 @@ public void onMiss() {
missCount.inc();
}

// Functions used to increment size by passing in the size directly, Used now, as we use ICacheKey<Key> in the IndicesRequestCache..
public void onCached(long keyRamBytesUsed, BytesReference value) {
totalMetric.inc(keyRamBytesUsed + value.ramBytesUsed());
}
Expand All @@ -73,4 +75,22 @@ public void onRemoval(long keyRamBytesUsed, BytesReference value, boolean evicte
}
totalMetric.dec(dec);
}

// Old functions which increment size by passing in an Accountable. Functional but no longer used.
public void onCached(Accountable key, BytesReference value) {
totalMetric.inc(key.ramBytesUsed() + value.ramBytesUsed());
}

public void onRemoval(Accountable key, BytesReference value, boolean evicted) {
if (evicted) {
evictionsMetric.inc();
}
long dec = 0;
if (key != null) {
dec += key.ramBytesUsed();
}
if (value != null) {
dec += value.ramBytesUsed();
}
}
}

0 comments on commit f60339f

Please sign in to comment.