Skip to content

Commit f91263b

Browse files
committed
Add javadocs for FullFileCachedIndexInput
Signed-off-by: Shreyansh Ray <rayshrey@amazon.com>
1 parent 9107f09 commit f91263b

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

server/src/internalClusterTest/java/org/opensearch/remotestore/WritableWarmIT.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.opensearch.node.Node;
3232
import org.opensearch.test.InternalTestCluster;
3333
import org.opensearch.test.OpenSearchIntegTestCase;
34-
import org.opensearch.test.junit.annotations.TestLogging;
3534

3635
import java.util.Arrays;
3736
import java.util.HashSet;
@@ -44,7 +43,7 @@
4443
@ThreadLeakFilters(filters = CleanerDaemonThreadLeakFilter.class)
4544
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0, supportsDedicatedMasters = false)
4645
// Uncomment the below line to enable trace level logs for this test for better debugging
47-
@TestLogging(reason = "Getting trace logs from composite directory package", value = "org.opensearch.index.store:TRACE")
46+
// @TestLogging(reason = "Getting trace logs from composite directory package", value = "org.opensearch.index.store:TRACE")
4847
public class WritableWarmIT extends RemoteStoreBaseIntegTestCase {
4948

5049
protected static final String INDEX_NAME = "test-idx-1";
@@ -69,8 +68,8 @@ protected Settings featureFlagSettings() {
6968
public void testWritableWarmFeatureFlagDisabled() {
7069
Settings clusterSettings = Settings.builder().put(super.nodeSettings(0)).put(FeatureFlags.TIERED_REMOTE_INDEX, false).build();
7170
InternalTestCluster internalTestCluster = internalCluster();
72-
internalTestCluster.startClusterManagerOnlyNodes(3, clusterSettings);
73-
internalTestCluster.startDataOnlyNodes(1, clusterSettings);
71+
internalTestCluster.startClusterManagerOnlyNode(clusterSettings);
72+
internalTestCluster.startDataOnlyNode(clusterSettings);
7473

7574
Settings indexSettings = Settings.builder()
7675
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)

server/src/main/java/org/opensearch/index/store/remote/filecache/CachedFullFileIndexInput.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import java.util.concurrent.atomic.AtomicBoolean;
1717

1818
/**
19-
* Implementation of the CachedIndexInput for NON_BLOCK files which takes in an IndexInput as parameter
19+
* Implementation of the CachedIndexInput for full files which takes in an IndexInput as parameter
2020
*
2121
* @opensearch.experimental
2222
*/

server/src/main/java/org/opensearch/index/store/remote/filecache/FullFileCachedIndexInput.java

+21
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,21 @@
1212
import org.apache.logging.log4j.Logger;
1313
import org.apache.lucene.store.AlreadyClosedException;
1414
import org.apache.lucene.store.IndexInput;
15+
import org.opensearch.common.annotation.ExperimentalApi;
1516

1617
import java.io.IOException;
1718
import java.nio.file.Path;
1819
import java.util.HashSet;
1920
import java.util.Set;
2021

22+
/**
23+
* Extension of {@link FileCachedIndexInput} for full files for handling clones and slices
24+
* 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
25+
* Closing of clones explicitly is needed as Lucene does not guarantee that it will close the clones
26+
* https://github.com/apache/lucene/blob/8340b01c3cc229f33584ce2178b07b8984daa6a9/lucene/core/src/java/org/apache/lucene/store/IndexInput.java#L32-L33
27+
* @opensearch.experimental
28+
*/
29+
@ExperimentalApi
2130
public class FullFileCachedIndexInput extends FileCachedIndexInput {
2231
private static final Logger logger = LogManager.getLogger(FullFileCachedIndexInput.class);
2332
private final Set<FullFileCachedIndexInput> clones;
@@ -31,6 +40,10 @@ public FullFileCachedIndexInput(FileCache cache, Path filePath, IndexInput under
3140
clones = new HashSet<>();
3241
}
3342

43+
/**
44+
* Clones the index input and returns the clone
45+
* Increase the ref count whenever the index input is cloned and add it to the clone map as well
46+
*/
3447
@Override
3548
public FullFileCachedIndexInput clone() {
3649
FullFileCachedIndexInput clonedIndexInput = new FullFileCachedIndexInput(cache, filePath, luceneIndexInput.clone(), true);
@@ -39,6 +52,10 @@ public FullFileCachedIndexInput clone() {
3952
return clonedIndexInput;
4053
}
4154

55+
/**
56+
* Clones the index input and returns the slice
57+
* Increase the ref count whenever the index input is sliced and add it to the clone map as well
58+
*/
4259
@Override
4360
public IndexInput slice(String sliceDescription, long offset, long length) throws IOException {
4461
if (offset < 0 || length < 0 || offset + length > this.length()) {
@@ -62,6 +79,10 @@ public IndexInput slice(String sliceDescription, long offset, long length) throw
6279
return slicedIndexInput;
6380
}
6481

82+
/**
83+
* Closes the index input and it's clones as well
84+
* @throws IOException
85+
*/
6586
@Override
6687
public void close() throws IOException {
6788
if (!closed) {

0 commit comments

Comments
 (0)