diff --git a/server/src/internalClusterTest/java/org/opensearch/remotestore/WritableWarmIT.java b/server/src/internalClusterTest/java/org/opensearch/remotestore/WritableWarmIT.java index d6b18ce2297df..a51bd6b20fff0 100644 --- a/server/src/internalClusterTest/java/org/opensearch/remotestore/WritableWarmIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/remotestore/WritableWarmIT.java @@ -31,7 +31,6 @@ import org.opensearch.node.Node; import org.opensearch.test.InternalTestCluster; import org.opensearch.test.OpenSearchIntegTestCase; -import org.opensearch.test.junit.annotations.TestLogging; import java.util.Arrays; import java.util.HashSet; @@ -44,7 +43,7 @@ @ThreadLeakFilters(filters = CleanerDaemonThreadLeakFilter.class) @OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0, supportsDedicatedMasters = false) // Uncomment the below line to enable trace level logs for this test for better debugging -@TestLogging(reason = "Getting trace logs from composite directory package", value = "org.opensearch.index.store:TRACE") +// @TestLogging(reason = "Getting trace logs from composite directory package", value = "org.opensearch.index.store:TRACE") public class WritableWarmIT extends RemoteStoreBaseIntegTestCase { protected static final String INDEX_NAME = "test-idx-1"; @@ -69,8 +68,8 @@ protected Settings featureFlagSettings() { public void testWritableWarmFeatureFlagDisabled() { Settings clusterSettings = Settings.builder().put(super.nodeSettings(0)).put(FeatureFlags.TIERED_REMOTE_INDEX, false).build(); InternalTestCluster internalTestCluster = internalCluster(); - internalTestCluster.startClusterManagerOnlyNodes(3, clusterSettings); - internalTestCluster.startDataOnlyNodes(1, clusterSettings); + internalTestCluster.startClusterManagerOnlyNode(clusterSettings); + internalTestCluster.startDataOnlyNode(clusterSettings); Settings indexSettings = Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) diff --git a/server/src/main/java/org/opensearch/index/store/remote/filecache/CachedFullFileIndexInput.java b/server/src/main/java/org/opensearch/index/store/remote/filecache/CachedFullFileIndexInput.java index c159e3ac61465..286739cb6cd90 100644 --- a/server/src/main/java/org/opensearch/index/store/remote/filecache/CachedFullFileIndexInput.java +++ b/server/src/main/java/org/opensearch/index/store/remote/filecache/CachedFullFileIndexInput.java @@ -16,7 +16,7 @@ import java.util.concurrent.atomic.AtomicBoolean; /** - * Implementation of the CachedIndexInput for NON_BLOCK files which takes in an IndexInput as parameter + * Implementation of the CachedIndexInput for full files which takes in an IndexInput as parameter * * @opensearch.experimental */ diff --git a/server/src/main/java/org/opensearch/index/store/remote/filecache/FullFileCachedIndexInput.java b/server/src/main/java/org/opensearch/index/store/remote/filecache/FullFileCachedIndexInput.java index 7411c14d59ef4..269a3f0579455 100644 --- a/server/src/main/java/org/opensearch/index/store/remote/filecache/FullFileCachedIndexInput.java +++ b/server/src/main/java/org/opensearch/index/store/remote/filecache/FullFileCachedIndexInput.java @@ -12,12 +12,21 @@ import org.apache.logging.log4j.Logger; import org.apache.lucene.store.AlreadyClosedException; import org.apache.lucene.store.IndexInput; +import org.opensearch.common.annotation.ExperimentalApi; import java.io.IOException; import java.nio.file.Path; import java.util.HashSet; import java.util.Set; +/** + * Extension of {@link FileCachedIndexInput} for full files for handling clones and slices + * We maintain a clone map so that we can close them when the parent IndexInput is closed so that ref count is properly maintained in file cache + * Closing of clones explicitly is needed as Lucene does not guarantee that it will close the clones + * https://github.com/apache/lucene/blob/8340b01c3cc229f33584ce2178b07b8984daa6a9/lucene/core/src/java/org/apache/lucene/store/IndexInput.java#L32-L33 + * @opensearch.experimental + */ +@ExperimentalApi public class FullFileCachedIndexInput extends FileCachedIndexInput { private static final Logger logger = LogManager.getLogger(FullFileCachedIndexInput.class); private final Set clones; @@ -31,6 +40,10 @@ public FullFileCachedIndexInput(FileCache cache, Path filePath, IndexInput under clones = new HashSet<>(); } + /** + * Clones the index input and returns the clone + * Increase the ref count whenever the index input is cloned and add it to the clone map as well + */ @Override public FullFileCachedIndexInput clone() { FullFileCachedIndexInput clonedIndexInput = new FullFileCachedIndexInput(cache, filePath, luceneIndexInput.clone(), true); @@ -39,6 +52,10 @@ public FullFileCachedIndexInput clone() { return clonedIndexInput; } + /** + * Clones the index input and returns the slice + * Increase the ref count whenever the index input is sliced and add it to the clone map as well + */ @Override public IndexInput slice(String sliceDescription, long offset, long length) throws IOException { if (offset < 0 || length < 0 || offset + length > this.length()) { @@ -62,6 +79,10 @@ public IndexInput slice(String sliceDescription, long offset, long length) throw return slicedIndexInput; } + /** + * Closes the index input and it's clones as well + * @throws IOException + */ @Override public void close() throws IOException { if (!closed) {