[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 <nknize@amazon.com>
This commit is contained in:
parent
ce7864efdc
commit
84d953b1c6
|
@ -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<OpenSearchDirectoryReader> {
|
||||
private final BiConsumer<OpenSearchDirectoryReader, OpenSearchDirectoryReader> refreshListener;
|
||||
private final ElasticsearchReaderManager internalReaderManager;
|
||||
private final OpenSearchReaderManager internalReaderManager;
|
||||
private boolean isWarmedUp; //guarded by refreshLock
|
||||
|
||||
ExternalReaderManager(ElasticsearchReaderManager internalReaderManager,
|
||||
ExternalReaderManager(OpenSearchReaderManager internalReaderManager,
|
||||
BiConsumer<OpenSearchDirectoryReader, OpenSearchDirectoryReader> 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);
|
||||
|
|
|
@ -38,19 +38,19 @@ import org.elasticsearch.common.lucene.index.OpenSearchDirectoryReader;
|
|||
*
|
||||
*/
|
||||
@SuppressForbidden(reason = "reference counting is required here")
|
||||
class ElasticsearchReaderManager extends ReferenceManager<OpenSearchDirectoryReader> {
|
||||
class OpenSearchReaderManager extends ReferenceManager<OpenSearchDirectoryReader> {
|
||||
private final BiConsumer<OpenSearchDirectoryReader, OpenSearchDirectoryReader> 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<OpenSearchDirectoryReader, OpenSearchDirectoryReader> refreshListener) {
|
||||
OpenSearchReaderManager(OpenSearchDirectoryReader reader,
|
||||
BiConsumer<OpenSearchDirectoryReader, OpenSearchDirectoryReader> refreshListener) {
|
||||
this.current = reader;
|
||||
this.refreshListener = refreshListener;
|
||||
refreshListener.accept(current, null);
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue