diff --git a/server/src/main/java/org/opensearch/common/metrics/CounterMetric.java b/server/src/main/java/org/opensearch/common/metrics/CounterMetric.java index cb181840406a5..33fc5e32e9c60 100644 --- a/server/src/main/java/org/opensearch/common/metrics/CounterMetric.java +++ b/server/src/main/java/org/opensearch/common/metrics/CounterMetric.java @@ -32,6 +32,7 @@ package org.opensearch.common.metrics; +import java.io.Serializable; import java.util.concurrent.atomic.LongAdder; /** diff --git a/server/src/main/java/org/opensearch/index/cache/request/ShardRequestCache.java b/server/src/main/java/org/opensearch/index/cache/request/ShardRequestCache.java index f09d2504680c7..3194aee757fc4 100644 --- a/server/src/main/java/org/opensearch/index/cache/request/ShardRequestCache.java +++ b/server/src/main/java/org/opensearch/index/cache/request/ShardRequestCache.java @@ -37,6 +37,7 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.indices.TierType; +import java.io.Serializable; import java.util.EnumMap; /** @@ -113,7 +114,7 @@ public void onRemoval(Accountable key, BytesReference value, boolean evicted, Ti statsHolder.get(tierType).totalMetric.dec(dec); } - static class StatsHolder { + static class StatsHolder implements Serializable { final CounterMetric evictionsMetric = new CounterMetric(); final CounterMetric totalMetric = new CounterMetric(); diff --git a/server/src/test/java/org/opensearch/indices/IndicesRequestCacheTests.java b/server/src/test/java/org/opensearch/indices/IndicesRequestCacheTests.java index 14cca8ef60681..5636268d78eb1 100644 --- a/server/src/test/java/org/opensearch/indices/IndicesRequestCacheTests.java +++ b/server/src/test/java/org/opensearch/indices/IndicesRequestCacheTests.java @@ -67,6 +67,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.util.io.IOUtils; import org.opensearch.core.common.bytes.AbstractBytesReference; +import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.core.index.shard.ShardId; @@ -164,7 +165,8 @@ public void testAddDirectToEhcache() throws Exception { BytesReference termBytes = XContentHelper.toXContent(termQuery, MediaTypeRegistry.JSON, false); IndicesRequestCache.Key key = new IndicesRequestCache.Key(entity, reader.getReaderCacheHelper().getKey(), termBytes); - TestBytesReference value = new TestBytesReference(124); + //TestBytesReference value = new TestBytesReference(124); + BytesReference value = new BytesArray(new byte[]{0}); cache.tieredCacheHandler.getDiskCachingTier().put(key, value); System.out.println("Size: " + cache.tieredCacheHandler.getDiskCachingTier().count()); @@ -707,7 +709,7 @@ public boolean isFragment() { } } - private class TestEntity extends AbstractIndexShardCacheEntity { + private class TestEntity extends AbstractIndexShardCacheEntity implements Serializable { private final AtomicBoolean standInForIndexShard; private final ShardRequestCache shardRequestCache;