From 84d953b1c64e980825a1d8f798debdaa12cc519a Mon Sep 17 00:00:00 2001 From: Nick Knize Date: Wed, 3 Mar 2021 20:29:34 -0600 Subject: [PATCH] [Rename] ElasticsearchReaderManager class in server module (#180) This commit refactors ElasticsearchReaderManager class in the server module to OpenSearchReaderManager. References and usages throughout the rest of the codebase are fully refactored. Signed-off-by: Nicholas Knize --- .../elasticsearch/index/engine/InternalEngine.java | 12 ++++++------ ...aderManager.java => OpenSearchReaderManager.java} | 8 ++++---- .../elasticsearch/index/engine/ReadOnlyEngine.java | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) rename server/src/main/java/org/elasticsearch/index/engine/{ElasticsearchReaderManager.java => OpenSearchReaderManager.java} (89%) diff --git a/server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java b/server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java index 99e34e726d8..3eab81abdf2 100644 --- a/server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java +++ b/server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java @@ -135,7 +135,7 @@ public class InternalEngine extends Engine { private final IndexWriter indexWriter; private final ExternalReaderManager externalReaderManager; - private final ElasticsearchReaderManager internalReaderManager; + private final OpenSearchReaderManager internalReaderManager; private final Lock flushLock = new ReentrantLock(); private final ReentrantLock optimizeLock = new ReentrantLock(); @@ -220,7 +220,7 @@ public class InternalEngine extends Engine { IndexWriter writer = null; Translog translog = null; ExternalReaderManager externalReaderManager = null; - ElasticsearchReaderManager internalReaderManager = null; + OpenSearchReaderManager internalReaderManager = null; EngineMergeScheduler scheduler = null; boolean success = false; try { @@ -348,10 +348,10 @@ public class InternalEngine extends Engine { @SuppressForbidden(reason = "reference counting is required here") private static final class ExternalReaderManager extends ReferenceManager { private final BiConsumer refreshListener; - private final ElasticsearchReaderManager internalReaderManager; + private final OpenSearchReaderManager internalReaderManager; private boolean isWarmedUp; //guarded by refreshLock - ExternalReaderManager(ElasticsearchReaderManager internalReaderManager, + ExternalReaderManager(OpenSearchReaderManager internalReaderManager, BiConsumer refreshListener) throws IOException { this.refreshListener = refreshListener; this.internalReaderManager = internalReaderManager; @@ -635,12 +635,12 @@ public class InternalEngine extends Engine { private ExternalReaderManager createReaderManager(RefreshWarmerListener externalRefreshListener) throws EngineException { boolean success = false; - ElasticsearchReaderManager internalReaderManager = null; + OpenSearchReaderManager internalReaderManager = null; try { try { final OpenSearchDirectoryReader directoryReader = OpenSearchDirectoryReader.wrap(DirectoryReader.open(indexWriter), shardId); - internalReaderManager = new ElasticsearchReaderManager(directoryReader, + internalReaderManager = new OpenSearchReaderManager(directoryReader, new RamAccountingRefreshListener(engineConfig.getCircuitBreakerService())); lastCommittedSegmentInfos = store.readLastCommittedSegmentsInfo(); ExternalReaderManager externalReaderManager = new ExternalReaderManager(internalReaderManager, externalRefreshListener); diff --git a/server/src/main/java/org/elasticsearch/index/engine/ElasticsearchReaderManager.java b/server/src/main/java/org/elasticsearch/index/engine/OpenSearchReaderManager.java similarity index 89% rename from server/src/main/java/org/elasticsearch/index/engine/ElasticsearchReaderManager.java rename to server/src/main/java/org/elasticsearch/index/engine/OpenSearchReaderManager.java index e02d18dc781..2902cc24987 100644 --- a/server/src/main/java/org/elasticsearch/index/engine/ElasticsearchReaderManager.java +++ b/server/src/main/java/org/elasticsearch/index/engine/OpenSearchReaderManager.java @@ -38,19 +38,19 @@ import org.elasticsearch.common.lucene.index.OpenSearchDirectoryReader; * */ @SuppressForbidden(reason = "reference counting is required here") -class ElasticsearchReaderManager extends ReferenceManager { +class OpenSearchReaderManager extends ReferenceManager { private final BiConsumer refreshListener; /** - * Creates and returns a new ElasticsearchReaderManager from the given + * Creates and returns a new OpenSearchReaderManager from the given * already-opened {@link OpenSearchDirectoryReader}, stealing * the incoming reference. * * @param reader the directoryReader to use for future reopens * @param refreshListener A consumer that is called every time a new reader is opened */ - ElasticsearchReaderManager(OpenSearchDirectoryReader reader, - BiConsumer refreshListener) { + OpenSearchReaderManager(OpenSearchDirectoryReader reader, + BiConsumer refreshListener) { this.current = reader; this.refreshListener = refreshListener; refreshListener.accept(current, null); diff --git a/server/src/main/java/org/elasticsearch/index/engine/ReadOnlyEngine.java b/server/src/main/java/org/elasticsearch/index/engine/ReadOnlyEngine.java index e17ab9ef70b..174100be83d 100644 --- a/server/src/main/java/org/elasticsearch/index/engine/ReadOnlyEngine.java +++ b/server/src/main/java/org/elasticsearch/index/engine/ReadOnlyEngine.java @@ -67,7 +67,7 @@ public class ReadOnlyEngine extends Engine { */ private final SegmentInfos lastCommittedSegmentInfos; private final SeqNoStats seqNoStats; - private final ElasticsearchReaderManager readerManager; + private final OpenSearchReaderManager readerManager; private final IndexCommit indexCommit; private final Lock indexWriterLock; private final RamAccountingRefreshListener refreshListener; @@ -114,7 +114,7 @@ public class ReadOnlyEngine extends Engine { this.seqNoStats = seqNoStats; this.indexCommit = Lucene.getIndexCommit(lastCommittedSegmentInfos, directory); reader = wrapReader(open(indexCommit), readerWrapperFunction); - readerManager = new ElasticsearchReaderManager(reader, refreshListener); + readerManager = new OpenSearchReaderManager(reader, refreshListener); assert translogStats != null || obtainLock : "mutiple translogs instances should not be opened at the same time"; this.translogStats = translogStats != null ? translogStats : translogStats(config, lastCommittedSegmentInfos); this.indexWriterLock = indexWriterLock;