Skip to content

Commit

Permalink
Addressed Sorabh's comments
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Alfonsi <[email protected]>
  • Loading branch information
Peter Alfonsi committed Jun 3, 2024
1 parent 060d00c commit 60934a4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

package org.opensearch.cache.common.tier;

import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;

import org.opensearch.action.admin.cluster.node.stats.NodesStatsRequest;
import org.opensearch.action.admin.cluster.node.stats.NodesStatsResponse;
import org.opensearch.action.admin.indices.stats.CommonStatsFlags;
Expand All @@ -22,13 +20,11 @@
import org.opensearch.common.cache.stats.ImmutableCacheStatsHolder;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.common.util.FeatureFlags;
import org.opensearch.index.cache.request.RequestCacheStats;
import org.opensearch.index.query.QueryBuilders;
import org.opensearch.indices.IndicesRequestCache;
import org.opensearch.plugins.Plugin;
import org.opensearch.test.OpenSearchIntegTestCase;
import org.opensearch.test.ParameterizedStaticSettingsOpenSearchIntegTestCase;
import org.opensearch.test.hamcrest.OpenSearchAssertions;

import java.io.IOException;
Expand All @@ -47,26 +43,17 @@

// Use a single data node to simplify accessing cache stats across different shards.
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0)
public class TieredSpilloverCacheStatsIT extends ParameterizedStaticSettingsOpenSearchIntegTestCase {
public class TieredSpilloverCacheStatsIT extends OpenSearchIntegTestCase {
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Arrays.asList(TieredSpilloverCachePlugin.class, TieredSpilloverCacheIT.MockDiskCachePlugin.class);
}

public TieredSpilloverCacheStatsIT(Settings settings) {
super(settings);
}

private final String HEAP_CACHE_SIZE_STRING = "10000B";
private final int HEAP_CACHE_SIZE = 10_000;
private final String index1Name = "index1";
private final String index2Name = "index2";

@ParametersFactory
public static Collection<Object[]> parameters() {
return Arrays.<Object[]>asList(new Object[] { Settings.builder().put(FeatureFlags.PLUGGABLE_CACHE, "true").build() });
}

/**
* Test aggregating by indices
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ public void incrementMisses(List<String> dimensionValues) {
internalIncrement(dimensionValues, missIncrementer, true);
}

/**
* This method shouldn't be used in this class. Instead, use incrementEvictions(dimensionValues, includeInTotal)
* which specifies whether the eviction should be included in the cache's total evictions, or if it should
* just count towards that tier's evictions.
* @param dimensionValues The dimension values
*/
@Override
public void incrementEvictions(List<String> dimensionValues) {
throw new UnsupportedOperationException(

Check warning on line 116 in modules/cache-common/src/main/java/org/opensearch/cache/common/tier/TieredSpilloverCacheStatsHolder.java

View check run for this annotation

Codecov / codecov/patch

modules/cache-common/src/main/java/org/opensearch/cache/common/tier/TieredSpilloverCacheStatsHolder.java#L116

Added line #L116 was not covered by tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@ private synchronized void cleanCache(double stalenessThreshold) {
if (cacheEntity == null) {
// If cache entity is null, it means that index or shard got deleted/closed meanwhile.
// So we will delete this key.
dimensionListsToDrop.add(key.dimensions);
iterator.remove();
} else {
CleanupKey cleanupKey = new CleanupKey(cacheEntity, delegatingKey.readerCacheKeyId);
Expand Down

0 comments on commit 60934a4

Please sign in to comment.