Remove allocation id from engine (#62680)

We no longer need the allocation id in Engine.
This commit is contained in:
Howard 2020-10-01 01:20:44 +08:00 committed by Nhat Nguyen
parent f69d268500
commit 8c6e197f51
10 changed files with 10 additions and 27 deletions

View File

@ -64,7 +64,7 @@ public class IndexingMemoryControllerIT extends ESSingleNodeTestCase {
Settings settings = Settings.builder().put(config.getIndexSettings().getSettings()) Settings settings = Settings.builder().put(config.getIndexSettings().getSettings())
.put("indices.memory.index_buffer_size", "10mb").build(); .put("indices.memory.index_buffer_size", "10mb").build();
IndexSettings indexSettings = new IndexSettings(config.getIndexSettings().getIndexMetadata(), settings); IndexSettings indexSettings = new IndexSettings(config.getIndexSettings().getIndexMetadata(), settings);
return new EngineConfig(config.getShardId(), config.getAllocationId(), config.getThreadPool(), return new EngineConfig(config.getShardId(), config.getThreadPool(),
indexSettings, config.getWarmer(), config.getStore(), config.getMergePolicy(), config.getAnalyzer(), indexSettings, config.getWarmer(), config.getStore(), config.getMergePolicy(), config.getAnalyzer(),
config.getSimilarity(), new CodecService(null, LogManager.getLogger(IndexingMemoryControllerIT.class)), config.getSimilarity(), new CodecService(null, LogManager.getLogger(IndexingMemoryControllerIT.class)),
config.getEventListener(), config.getQueryCache(), config.getEventListener(), config.getQueryCache(),

View File

@ -117,7 +117,6 @@ public abstract class Engine implements Closeable {
public static final String CAN_MATCH_SEARCH_SOURCE = "can_match"; public static final String CAN_MATCH_SEARCH_SOURCE = "can_match";
protected final ShardId shardId; protected final ShardId shardId;
protected final String allocationId;
protected final Logger logger; protected final Logger logger;
protected final EngineConfig engineConfig; protected final EngineConfig engineConfig;
protected final Store store; protected final Store store;
@ -147,7 +146,6 @@ public abstract class Engine implements Closeable {
this.engineConfig = engineConfig; this.engineConfig = engineConfig;
this.shardId = engineConfig.getShardId(); this.shardId = engineConfig.getShardId();
this.allocationId = engineConfig.getAllocationId();
this.store = engineConfig.getStore(); this.store = engineConfig.getStore();
// we use the engine class directly here to make sure all subclasses have the same logger name // we use the engine class directly here to make sure all subclasses have the same logger name
this.logger = Loggers.getLogger(Engine.class, this.logger = Loggers.getLogger(Engine.class,

View File

@ -55,7 +55,6 @@ import java.util.function.Supplier;
*/ */
public final class EngineConfig { public final class EngineConfig {
private final ShardId shardId; private final ShardId shardId;
private final String allocationId;
private final IndexSettings indexSettings; private final IndexSettings indexSettings;
private final ByteSizeValue indexingBufferSize; private final ByteSizeValue indexingBufferSize;
private volatile boolean enableGcDeletes = true; private volatile boolean enableGcDeletes = true;
@ -131,7 +130,7 @@ public final class EngineConfig {
/** /**
* Creates a new {@link org.elasticsearch.index.engine.EngineConfig} * Creates a new {@link org.elasticsearch.index.engine.EngineConfig}
*/ */
public EngineConfig(ShardId shardId, String allocationId, ThreadPool threadPool, public EngineConfig(ShardId shardId, ThreadPool threadPool,
IndexSettings indexSettings, Engine.Warmer warmer, Store store, IndexSettings indexSettings, Engine.Warmer warmer, Store store,
MergePolicy mergePolicy, Analyzer analyzer, MergePolicy mergePolicy, Analyzer analyzer,
Similarity similarity, CodecService codecService, Engine.EventListener eventListener, Similarity similarity, CodecService codecService, Engine.EventListener eventListener,
@ -144,7 +143,6 @@ public final class EngineConfig {
LongSupplier primaryTermSupplier, LongSupplier primaryTermSupplier,
TombstoneDocSupplier tombstoneDocSupplier) { TombstoneDocSupplier tombstoneDocSupplier) {
this.shardId = shardId; this.shardId = shardId;
this.allocationId = allocationId;
this.indexSettings = indexSettings; this.indexSettings = indexSettings;
this.threadPool = threadPool; this.threadPool = threadPool;
this.warmer = warmer == null ? (a) -> {} : warmer; this.warmer = warmer == null ? (a) -> {} : warmer;
@ -286,15 +284,6 @@ public final class EngineConfig {
*/ */
public ShardId getShardId() { return shardId; } public ShardId getShardId() { return shardId; }
/**
* Returns the allocation ID for the shard.
*
* @return the allocation ID
*/
public String getAllocationId() {
return allocationId;
}
/** /**
* Returns the analyzer as the default analyzer in the engines {@link org.apache.lucene.index.IndexWriter} * Returns the analyzer as the default analyzer in the engines {@link org.apache.lucene.index.IndexWriter}
*/ */

View File

@ -2780,7 +2780,7 @@ public class IndexShard extends AbstractIndexShardComponent implements IndicesCl
this.warmer.warm(reader); this.warmer.warm(reader);
} }
}; };
return new EngineConfig(shardId, shardRouting.allocationId().getId(), return new EngineConfig(shardId,
threadPool, indexSettings, warmer, store, indexSettings.getMergePolicy(), threadPool, indexSettings, warmer, store, indexSettings.getMergePolicy(),
mapperService != null ? mapperService.indexAnalyzer() : null, mapperService != null ? mapperService.indexAnalyzer() : null,
similarityService.similarity(mapperService), codecService, shardEventListener, similarityService.similarity(mapperService), codecService, shardEventListener,

View File

@ -3193,7 +3193,6 @@ public class InternalEngineTests extends EngineTestCase {
EngineConfig brokenConfig = new EngineConfig( EngineConfig brokenConfig = new EngineConfig(
shardId, shardId,
allocationId.getId(),
threadPool, threadPool,
config.getIndexSettings(), config.getIndexSettings(),
null, null,
@ -6257,7 +6256,7 @@ public class InternalEngineTests extends EngineTestCase {
EngineConfig config = engine.config(); EngineConfig config = engine.config();
final TranslogConfig translogConfig = new TranslogConfig(config.getTranslogConfig().getShardId(), final TranslogConfig translogConfig = new TranslogConfig(config.getTranslogConfig().getShardId(),
createTempDir(), config.getTranslogConfig().getIndexSettings(), config.getTranslogConfig().getBigArrays()); createTempDir(), config.getTranslogConfig().getIndexSettings(), config.getTranslogConfig().getBigArrays());
EngineConfig configWithWarmer = new EngineConfig(config.getShardId(), config.getAllocationId(), config.getThreadPool(), EngineConfig configWithWarmer = new EngineConfig(config.getShardId(), config.getThreadPool(),
config.getIndexSettings(), warmer, store, config.getMergePolicy(), config.getAnalyzer(), config.getIndexSettings(), warmer, store, config.getMergePolicy(), config.getAnalyzer(),
config.getSimilarity(), new CodecService(null, logger), config.getEventListener(), config.getQueryCache(), config.getSimilarity(), new CodecService(null, logger), config.getEventListener(), config.getQueryCache(),
config.getQueryCachingPolicy(), translogConfig, config.getFlushMergesAfter(), config.getQueryCachingPolicy(), translogConfig, config.getFlushMergesAfter(),

View File

@ -4175,7 +4175,7 @@ public class IndexShardTests extends IndexShardTestCase {
throw new AssertionError(e); throw new AssertionError(e);
} }
}; };
EngineConfig configWithWarmer = new EngineConfig(config.getShardId(), config.getAllocationId(), config.getThreadPool(), EngineConfig configWithWarmer = new EngineConfig(config.getShardId(), config.getThreadPool(),
config.getIndexSettings(), warmer, config.getStore(), config.getMergePolicy(), config.getAnalyzer(), config.getIndexSettings(), warmer, config.getStore(), config.getMergePolicy(), config.getAnalyzer(),
config.getSimilarity(), new CodecService(null, logger), config.getEventListener(), config.getQueryCache(), config.getSimilarity(), new CodecService(null, logger), config.getEventListener(), config.getQueryCache(),
config.getQueryCachingPolicy(), config.getTranslogConfig(), config.getFlushMergesAfter(), config.getQueryCachingPolicy(), config.getTranslogConfig(), config.getFlushMergesAfter(),

View File

@ -128,7 +128,6 @@ public class RefreshListenersTests extends ESTestCase {
store.associateIndexWithNewTranslog(translogUUID); store.associateIndexWithNewTranslog(translogUUID);
EngineConfig config = new EngineConfig( EngineConfig config = new EngineConfig(
shardId, shardId,
allocationId,
threadPool, threadPool,
indexSettings, indexSettings,
null, null,

View File

@ -376,7 +376,7 @@ public class IndexingMemoryControllerTests extends IndexShardTestCase {
EngineConfig configWithRefreshListener(EngineConfig config, ReferenceManager.RefreshListener listener) { EngineConfig configWithRefreshListener(EngineConfig config, ReferenceManager.RefreshListener listener) {
final List<ReferenceManager.RefreshListener> internalRefreshListener = new ArrayList<>(config.getInternalRefreshListener());; final List<ReferenceManager.RefreshListener> internalRefreshListener = new ArrayList<>(config.getInternalRefreshListener());;
internalRefreshListener.add(listener); internalRefreshListener.add(listener);
return new EngineConfig(config.getShardId(), config.getAllocationId(), config.getThreadPool(), return new EngineConfig(config.getShardId(), config.getThreadPool(),
config.getIndexSettings(), config.getWarmer(), config.getStore(), config.getMergePolicy(), config.getAnalyzer(), config.getIndexSettings(), config.getWarmer(), config.getStore(), config.getMergePolicy(), config.getAnalyzer(),
config.getSimilarity(), new CodecService(null, logger), config.getEventListener(), config.getQueryCache(), config.getSimilarity(), new CodecService(null, logger), config.getEventListener(), config.getQueryCache(),
config.getQueryCachingPolicy(), config.getTranslogConfig(), config.getFlushMergesAfter(), config.getQueryCachingPolicy(), config.getTranslogConfig(), config.getFlushMergesAfter(),

View File

@ -233,7 +233,7 @@ public abstract class EngineTestCase extends ESTestCase {
} }
public EngineConfig copy(EngineConfig config, LongSupplier globalCheckpointSupplier) { public EngineConfig copy(EngineConfig config, LongSupplier globalCheckpointSupplier) {
return new EngineConfig(config.getShardId(), config.getAllocationId(), config.getThreadPool(), config.getIndexSettings(), return new EngineConfig(config.getShardId(), config.getThreadPool(), config.getIndexSettings(),
config.getWarmer(), config.getStore(), config.getMergePolicy(), config.getAnalyzer(), config.getSimilarity(), config.getWarmer(), config.getStore(), config.getMergePolicy(), config.getAnalyzer(), config.getSimilarity(),
new CodecService(null, logger), config.getEventListener(), config.getQueryCache(), config.getQueryCachingPolicy(), new CodecService(null, logger), config.getEventListener(), config.getQueryCache(), config.getQueryCachingPolicy(),
config.getTranslogConfig(), config.getFlushMergesAfter(), config.getTranslogConfig(), config.getFlushMergesAfter(),
@ -243,7 +243,7 @@ public abstract class EngineTestCase extends ESTestCase {
} }
public EngineConfig copy(EngineConfig config, Analyzer analyzer) { public EngineConfig copy(EngineConfig config, Analyzer analyzer) {
return new EngineConfig(config.getShardId(), config.getAllocationId(), config.getThreadPool(), config.getIndexSettings(), return new EngineConfig(config.getShardId(), config.getThreadPool(), config.getIndexSettings(),
config.getWarmer(), config.getStore(), config.getMergePolicy(), analyzer, config.getSimilarity(), config.getWarmer(), config.getStore(), config.getMergePolicy(), analyzer, config.getSimilarity(),
new CodecService(null, logger), config.getEventListener(), config.getQueryCache(), config.getQueryCachingPolicy(), new CodecService(null, logger), config.getEventListener(), config.getQueryCache(), config.getQueryCachingPolicy(),
config.getTranslogConfig(), config.getFlushMergesAfter(), config.getTranslogConfig(), config.getFlushMergesAfter(),
@ -253,7 +253,7 @@ public abstract class EngineTestCase extends ESTestCase {
} }
public EngineConfig copy(EngineConfig config, MergePolicy mergePolicy) { public EngineConfig copy(EngineConfig config, MergePolicy mergePolicy) {
return new EngineConfig(config.getShardId(), config.getAllocationId(), config.getThreadPool(), config.getIndexSettings(), return new EngineConfig(config.getShardId(), config.getThreadPool(), config.getIndexSettings(),
config.getWarmer(), config.getStore(), mergePolicy, config.getAnalyzer(), config.getSimilarity(), config.getWarmer(), config.getStore(), mergePolicy, config.getAnalyzer(), config.getSimilarity(),
new CodecService(null, logger), config.getEventListener(), config.getQueryCache(), config.getQueryCachingPolicy(), new CodecService(null, logger), config.getEventListener(), config.getQueryCache(), config.getQueryCachingPolicy(),
config.getTranslogConfig(), config.getFlushMergesAfter(), config.getTranslogConfig(), config.getFlushMergesAfter(),
@ -686,7 +686,6 @@ public abstract class EngineTestCase extends ESTestCase {
} }
return new EngineConfig( return new EngineConfig(
shardId, shardId,
allocationId.getId(),
threadPool, threadPool,
indexSettings, indexSettings,
null, null,
@ -716,7 +715,7 @@ public abstract class EngineTestCase extends ESTestCase {
Settings.builder().put(config.getIndexSettings().getSettings()) Settings.builder().put(config.getIndexSettings().getSettings())
.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true).build()); .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true).build());
TranslogConfig translogConfig = new TranslogConfig(shardId, translogPath, indexSettings, BigArrays.NON_RECYCLING_INSTANCE); TranslogConfig translogConfig = new TranslogConfig(shardId, translogPath, indexSettings, BigArrays.NON_RECYCLING_INSTANCE);
return new EngineConfig(config.getShardId(), config.getAllocationId(), config.getThreadPool(), return new EngineConfig(config.getShardId(), config.getThreadPool(),
indexSettings, config.getWarmer(), store, config.getMergePolicy(), config.getAnalyzer(), config.getSimilarity(), indexSettings, config.getWarmer(), store, config.getMergePolicy(), config.getAnalyzer(), config.getSimilarity(),
new CodecService(null, logger), config.getEventListener(), config.getQueryCache(), config.getQueryCachingPolicy(), new CodecService(null, logger), config.getEventListener(), config.getQueryCache(), config.getQueryCachingPolicy(),
translogConfig, config.getFlushMergesAfter(), config.getExternalRefreshListener(), translogConfig, config.getFlushMergesAfter(), config.getExternalRefreshListener(),

View File

@ -246,7 +246,6 @@ public class FollowingEngineTests extends ESTestCase {
final TranslogConfig translogConfig = new TranslogConfig(shardId, translogPath, indexSettings, BigArrays.NON_RECYCLING_INSTANCE); final TranslogConfig translogConfig = new TranslogConfig(shardId, translogPath, indexSettings, BigArrays.NON_RECYCLING_INSTANCE);
return new EngineConfig( return new EngineConfig(
shardId, shardId,
"allocation-id",
threadPool, threadPool,
indexSettings, indexSettings,
null, null,