Skip to content

Commit

Permalink
Add drainRefreshes as part of tearDown in RemoteStoreRefreshListenerT…
Browse files Browse the repository at this point in the history
…ests (opensearch-project#12157)

Signed-off-by: Sachin Kale <[email protected]>
Co-authored-by: Sachin Kale <[email protected]>
  • Loading branch information
sachinpkale and Sachin Kale authored Feb 5, 2024
1 parent 4d055b8 commit 6b2c2f2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import org.apache.lucene.index.IndexFileNames;
import org.apache.lucene.index.SegmentInfos;
import org.apache.lucene.search.ReferenceManager;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FilterDirectory;
import org.apache.lucene.tests.store.BaseDirectoryWrapper;
Expand Down Expand Up @@ -102,6 +103,16 @@ private void indexDocs(int startDocId, int numberOfDocs) throws IOException {
public void tearDown() throws Exception {
Directory storeDirectory = ((FilterDirectory) ((FilterDirectory) indexShard.store().directory()).getDelegate()).getDelegate();
((BaseDirectoryWrapper) storeDirectory).setCheckIndexOnClose(false);

for (ReferenceManager.RefreshListener refreshListener : indexShard.getEngine().config().getInternalRefreshListener()) {
if (refreshListener instanceof ReleasableRetryableRefreshListener) {
((ReleasableRetryableRefreshListener) refreshListener).drainRefreshes();
}
}
if (remoteStoreRefreshListener != null) {
remoteStoreRefreshListener.drainRefreshes();
}

closeShards(indexShard);
super.tearDown();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -785,10 +785,10 @@ protected Store createRemoteStore(Path path, ShardRouting shardRouting, IndexMet
protected RemoteSegmentStoreDirectory createRemoteSegmentStoreDirectory(ShardId shardId, Path path) throws IOException {
NodeEnvironment.NodePath remoteNodePath = new NodeEnvironment.NodePath(path);
ShardPath remoteShardPath = new ShardPath(false, remoteNodePath.resolve(shardId), remoteNodePath.resolve(shardId), shardId);
RemoteDirectory dataDirectory = newRemoteDirectory(remoteShardPath.resolveIndex());
RemoteDirectory metadataDirectory = newRemoteDirectory(remoteShardPath.resolveIndex());
RemoteDirectory dataDirectory = newRemoteDirectory(remoteShardPath.resolveIndex().resolve("data"));
RemoteDirectory metadataDirectory = newRemoteDirectory(remoteShardPath.resolveIndex().resolve("metadata"));
RemoteStoreLockManager remoteStoreLockManager = new RemoteStoreMetadataLockManager(
new RemoteBufferedOutputDirectory(getBlobContainer(remoteShardPath.resolveIndex()))
new RemoteBufferedOutputDirectory(getBlobContainer(remoteShardPath.resolveIndex().resolve("lock_files")))
);
return new RemoteSegmentStoreDirectory(dataDirectory, metadataDirectory, remoteStoreLockManager, threadPool, shardId);
}
Expand Down

0 comments on commit 6b2c2f2

Please sign in to comment.