浏览代码

[CORE] Remove IndexEngine

IndexEngine was an abstraction where we had index-level engines (instead
of shard-level) that could store meta information about the index. It
was never actually used by Elasticsearch, and only there for plugins.

This removes it, because it is a confusing abstraction and not needed,
no plugins should be implementing their own IndexEngines.
Lee Hinman 11 年之前
父节点
当前提交
a8fa650ee6

+ 4 - 13
src/main/java/org/elasticsearch/index/IndexService.java

@@ -32,7 +32,6 @@ import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.util.concurrent.CountDown;
 import org.elasticsearch.env.NodeEnvironment;
 import org.elasticsearch.env.ShardLock;
-import org.elasticsearch.index.*;
 import org.elasticsearch.index.aliases.IndexAliasesService;
 import org.elasticsearch.index.analysis.AnalysisService;
 import org.elasticsearch.index.cache.IndexCache;
@@ -43,7 +42,6 @@ import org.elasticsearch.index.cache.query.ShardQueryCacheModule;
 import org.elasticsearch.index.deletionpolicy.DeletionPolicyModule;
 import org.elasticsearch.index.engine.Engine;
 import org.elasticsearch.index.engine.EngineModule;
-import org.elasticsearch.index.engine.IndexEngine;
 import org.elasticsearch.index.fielddata.IndexFieldDataService;
 import org.elasticsearch.index.fielddata.ShardFieldDataModule;
 import org.elasticsearch.index.gateway.IndexGateway;
@@ -62,10 +60,10 @@ import org.elasticsearch.index.query.IndexQueryParserService;
 import org.elasticsearch.index.search.stats.ShardSearchModule;
 import org.elasticsearch.index.settings.IndexSettings;
 import org.elasticsearch.index.settings.IndexSettingsService;
+import org.elasticsearch.index.shard.IndexShard;
 import org.elasticsearch.index.shard.IndexShardCreationException;
 import org.elasticsearch.index.shard.IndexShardModule;
 import org.elasticsearch.index.shard.ShardId;
-import org.elasticsearch.index.shard.IndexShard;
 import org.elasticsearch.index.similarity.SimilarityService;
 import org.elasticsearch.index.snapshots.IndexShardSnapshotModule;
 import org.elasticsearch.index.store.IndexStore;
@@ -123,8 +121,6 @@ public class IndexService extends AbstractIndexComponent implements IndexCompone
 
     private final BitsetFilterCache bitsetFilterCache;
 
-    private final IndexEngine indexEngine;
-
     private final IndexGateway indexGateway;
 
     private final IndexStore indexStore;
@@ -142,9 +138,9 @@ public class IndexService extends AbstractIndexComponent implements IndexCompone
     @Inject
     public IndexService(Injector injector, Index index, @IndexSettings Settings indexSettings, NodeEnvironment nodeEnv,
                         AnalysisService analysisService, MapperService mapperService, IndexQueryParserService queryParserService,
-                        SimilarityService similarityService, IndexAliasesService aliasesService, IndexCache indexCache, IndexEngine indexEngine,
-                        IndexGateway indexGateway, IndexStore indexStore, IndexSettingsService settingsService, IndexFieldDataService indexFieldData,
-                        BitsetFilterCache bitSetFilterCache) {
+                        SimilarityService similarityService, IndexAliasesService aliasesService, IndexCache indexCache,
+                        IndexGateway indexGateway, IndexStore indexStore, IndexSettingsService settingsService,
+                        IndexFieldDataService indexFieldData, BitsetFilterCache bitSetFilterCache) {
         super(index, indexSettings);
         this.injector = injector;
         this.indexSettings = indexSettings;
@@ -155,7 +151,6 @@ public class IndexService extends AbstractIndexComponent implements IndexCompone
         this.aliasesService = aliasesService;
         this.indexCache = indexCache;
         this.indexFieldData = indexFieldData;
-        this.indexEngine = indexEngine;
         this.indexGateway = indexGateway;
         this.indexStore = indexStore;
         this.settingsService = settingsService;
@@ -254,10 +249,6 @@ public class IndexService extends AbstractIndexComponent implements IndexCompone
         return aliasesService;
     }
 
-    public IndexEngine engine() {
-        return indexEngine;
-    }
-
     public synchronized void close(final String reason, final IndicesService.IndexCloseListener listener) {
         if (closed.compareAndSet(false, true)) {
             final Set<Integer> shardIds = shardIds();

+ 6 - 1
src/main/java/org/elasticsearch/index/engine/EngineModule.java

@@ -25,12 +25,16 @@ import org.elasticsearch.common.inject.Module;
 import org.elasticsearch.common.inject.Modules;
 import org.elasticsearch.common.inject.SpawnModules;
 import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.index.engine.internal.InternalEngineModule;
 
 /**
  *
  */
 public class EngineModule extends AbstractModule implements SpawnModules {
 
+    public static final String ENGINE_TYPE = "index.engine.type";
+    public static final Class<? extends Module> DEFAULT_ENGINE = InternalEngineModule.class;
+
     private final Settings settings;
 
     public EngineModule(Settings settings) {
@@ -39,7 +43,8 @@ public class EngineModule extends AbstractModule implements SpawnModules {
 
     @Override
     public Iterable<? extends Module> spawnModules() {
-        return ImmutableList.of(Modules.createModule(settings.getAsClass(IndexEngineModule.EngineSettings.ENGINE_TYPE, IndexEngineModule.EngineSettings.DEFAULT_ENGINE, "org.elasticsearch.index.engine.", "EngineModule"), settings));
+        return ImmutableList.of(Modules.createModule(settings.getAsClass(ENGINE_TYPE, DEFAULT_ENGINE,
+                "org.elasticsearch.index.engine.", "EngineModule"), settings));
     }
 
     @Override

+ 0 - 33
src/main/java/org/elasticsearch/index/engine/IndexEngine.java

@@ -1,33 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.elasticsearch.index.engine;
-
-import org.elasticsearch.index.IndexComponent;
-
-/**
- * An "index" scoped engine that provides some meta engine for the engine, and can be used to store
- * index level data structures that an engine requires.
- *
- *
- */
-public interface IndexEngine extends IndexComponent {
-
-    void close();
-}

+ 0 - 58
src/main/java/org/elasticsearch/index/engine/IndexEngineModule.java

@@ -1,58 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.elasticsearch.index.engine;
-
-import com.google.common.collect.ImmutableList;
-import org.elasticsearch.common.inject.AbstractModule;
-import org.elasticsearch.common.inject.Module;
-import org.elasticsearch.common.inject.SpawnModules;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.index.engine.internal.InternalEngineModule;
-import org.elasticsearch.index.engine.internal.InternalIndexEngineModule;
-
-import static org.elasticsearch.common.inject.Modules.createModule;
-
-/**
- *
- */
-public class IndexEngineModule extends AbstractModule implements SpawnModules {
-
-    public static final class EngineSettings {
-        public static final String ENGINE_TYPE = "index.engine.type";
-        public static final String INDEX_ENGINE_TYPE = "index.index_engine.type";
-        public static final Class<? extends Module> DEFAULT_INDEX_ENGINE = InternalIndexEngineModule.class;
-        public static final Class<? extends Module> DEFAULT_ENGINE = InternalEngineModule.class;
-    }
-
-    private final Settings settings;
-
-    public IndexEngineModule(Settings settings) {
-        this.settings = settings;
-    }
-
-    @Override
-    public Iterable<? extends Module> spawnModules() {
-        return ImmutableList.of(createModule(settings.getAsClass(EngineSettings.INDEX_ENGINE_TYPE, EngineSettings.DEFAULT_INDEX_ENGINE, "org.elasticsearch.index.engine.", "IndexEngineModule"), settings));
-    }
-
-    @Override
-    protected void configure() {
-    }
-}

+ 0 - 48
src/main/java/org/elasticsearch/index/engine/internal/InternalIndexEngine.java

@@ -1,48 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.elasticsearch.index.engine.internal;
-
-import org.elasticsearch.common.inject.Inject;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.index.AbstractIndexComponent;
-import org.elasticsearch.index.Index;
-import org.elasticsearch.index.engine.IndexEngine;
-import org.elasticsearch.index.settings.IndexSettings;
-
-import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_SETTINGS;
-
-/**
- *
- */
-public class InternalIndexEngine extends AbstractIndexComponent implements IndexEngine {
-
-    public InternalIndexEngine(Index index) {
-        this(index, EMPTY_SETTINGS);
-    }
-
-    @Inject
-    public InternalIndexEngine(Index index, @IndexSettings Settings indexSettings) {
-        super(index, indexSettings);
-    }
-
-    @Override
-    public void close() {
-    }
-}

+ 0 - 34
src/main/java/org/elasticsearch/index/engine/internal/InternalIndexEngineModule.java

@@ -1,34 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.elasticsearch.index.engine.internal;
-
-import org.elasticsearch.common.inject.AbstractModule;
-import org.elasticsearch.index.engine.IndexEngine;
-
-/**
- *
- */
-public class InternalIndexEngineModule extends AbstractModule {
-
-    @Override
-    protected void configure() {
-        bind(IndexEngine.class).to(InternalIndexEngine.class).asEagerSingleton();
-    }
-}

+ 1 - 5
src/main/java/org/elasticsearch/index/query/IndexQueryParserService.java

@@ -39,7 +39,6 @@ import org.elasticsearch.index.Index;
 import org.elasticsearch.index.analysis.AnalysisService;
 import org.elasticsearch.index.cache.IndexCache;
 import org.elasticsearch.index.cache.bitset.BitsetFilterCache;
-import org.elasticsearch.index.engine.IndexEngine;
 import org.elasticsearch.index.fielddata.IndexFieldDataService;
 import org.elasticsearch.index.mapper.MapperService;
 import org.elasticsearch.index.mapper.internal.AllFieldMapper;
@@ -93,8 +92,6 @@ public class IndexQueryParserService extends AbstractIndexComponent {
 
     final BitsetFilterCache bitsetFilterCache;
 
-    final IndexEngine indexEngine;
-
     private final Map<String, QueryParser> queryParsers;
 
     private final Map<String, FilterParser> filterParsers;
@@ -109,7 +106,7 @@ public class IndexQueryParserService extends AbstractIndexComponent {
                                    IndicesQueriesRegistry indicesQueriesRegistry,
                                    ScriptService scriptService, AnalysisService analysisService,
                                    MapperService mapperService, IndexCache indexCache, IndexFieldDataService fieldDataService,
-                                   IndexEngine indexEngine, BitsetFilterCache bitsetFilterCache,
+                                   BitsetFilterCache bitsetFilterCache,
                                    @Nullable SimilarityService similarityService,
                                    @Nullable Map<String, QueryParserFactory> namedQueryParsers,
                                    @Nullable Map<String, FilterParserFactory> namedFilterParsers) {
@@ -120,7 +117,6 @@ public class IndexQueryParserService extends AbstractIndexComponent {
         this.similarityService = similarityService;
         this.indexCache = indexCache;
         this.fieldDataService = fieldDataService;
-        this.indexEngine = indexEngine;
         this.bitsetFilterCache = bitsetFilterCache;
 
         this.defaultField = indexSettings.get(DEFAULT_FIELD, AllFieldMapper.NAME);

+ 0 - 5
src/main/java/org/elasticsearch/index/query/QueryParseContext.java

@@ -42,7 +42,6 @@ import org.elasticsearch.index.Index;
 import org.elasticsearch.index.analysis.AnalysisService;
 import org.elasticsearch.index.cache.filter.support.CacheKeyFilter;
 import org.elasticsearch.index.cache.query.parser.QueryParserCache;
-import org.elasticsearch.index.engine.IndexEngine;
 import org.elasticsearch.index.fielddata.IndexFieldData;
 import org.elasticsearch.index.mapper.FieldMapper;
 import org.elasticsearch.index.mapper.FieldMappers;
@@ -158,10 +157,6 @@ public class QueryParseContext {
         return indexQueryParser.mapperService;
     }
 
-    public IndexEngine indexEngine() {
-        return indexQueryParser.indexEngine;
-    }
-
     @Nullable
     public SimilarityService similarityService() {
         return indexQueryParser.similarityService;

+ 1 - 8
src/main/java/org/elasticsearch/indices/IndicesService.java

@@ -43,8 +43,6 @@ import org.elasticsearch.index.analysis.AnalysisService;
 import org.elasticsearch.index.cache.IndexCache;
 import org.elasticsearch.index.cache.IndexCacheModule;
 import org.elasticsearch.index.codec.CodecModule;
-import org.elasticsearch.index.engine.IndexEngine;
-import org.elasticsearch.index.engine.IndexEngineModule;
 import org.elasticsearch.index.fielddata.IndexFieldDataModule;
 import org.elasticsearch.index.fielddata.IndexFieldDataService;
 import org.elasticsearch.index.flush.FlushStats;
@@ -59,17 +57,15 @@ import org.elasticsearch.index.query.IndexQueryParserModule;
 import org.elasticsearch.index.query.IndexQueryParserService;
 import org.elasticsearch.index.refresh.RefreshStats;
 import org.elasticsearch.index.search.stats.SearchStats;
-import org.elasticsearch.index.IndexService;
 import org.elasticsearch.index.settings.IndexSettingsModule;
 import org.elasticsearch.index.shard.IllegalIndexShardStateException;
-import org.elasticsearch.index.shard.ShardId;
 import org.elasticsearch.index.shard.IndexShard;
+import org.elasticsearch.index.shard.ShardId;
 import org.elasticsearch.index.similarity.SimilarityModule;
 import org.elasticsearch.index.store.IndexStore;
 import org.elasticsearch.index.store.IndexStoreModule;
 import org.elasticsearch.indices.analysis.IndicesAnalysisService;
 import org.elasticsearch.indices.recovery.RecoverySettings;
-import org.elasticsearch.indices.store.IndicesStore;
 import org.elasticsearch.plugins.IndexPluginsModule;
 import org.elasticsearch.plugins.PluginsService;
 
@@ -313,7 +309,6 @@ public class IndicesService extends AbstractLifecycleComponent<IndicesService> i
         modules.add(new IndexSettingsModule(index, indexSettings));
         modules.add(new IndexPluginsModule(indexSettings, pluginsService));
         modules.add(new IndexStoreModule(indexSettings));
-        modules.add(new IndexEngineModule(indexSettings));
         modules.add(new AnalysisModule(indexSettings, indicesAnalysisService));
         modules.add(new SimilarityModule(indexSettings));
         modules.add(new IndexCacheModule(indexSettings));
@@ -434,8 +429,6 @@ public class IndicesService extends AbstractLifecycleComponent<IndicesService> i
             indexInjector.getInstance(IndexFieldDataService.class).clear();
             logger.debug("[{}] closing analysis service (reason [{}])", index, reason);
             indexInjector.getInstance(AnalysisService.class).close();
-            logger.debug("[{}] closing index engine (reason [{}])", index, reason);
-            indexInjector.getInstance(IndexEngine.class).close();
 
             logger.debug("[{}] closing index gateway (reason [{}])", index, reason);
             indexInjector.getInstance(IndexGateway.class).close();

+ 0 - 2
src/test/java/org/elasticsearch/index/query/TemplateQueryParserTest.java

@@ -39,7 +39,6 @@ import org.elasticsearch.index.IndexNameModule;
 import org.elasticsearch.index.analysis.AnalysisModule;
 import org.elasticsearch.index.cache.IndexCacheModule;
 import org.elasticsearch.index.codec.CodecModule;
-import org.elasticsearch.index.engine.IndexEngineModule;
 import org.elasticsearch.index.query.functionscore.FunctionScoreModule;
 import org.elasticsearch.index.settings.IndexSettingsModule;
 import org.elasticsearch.index.similarity.SimilarityModule;
@@ -84,7 +83,6 @@ public class TemplateQueryParserTest extends ElasticsearchTestCase {
                 new IndexSettingsModule(index, settings),
                 new IndexCacheModule(settings),
                 new AnalysisModule(settings),
-                new IndexEngineModule(settings),
                 new SimilarityModule(settings),
                 new IndexNameModule(index),
                 new IndexQueryParserModule(settings),

+ 0 - 2
src/test/java/org/elasticsearch/index/query/plugin/IndexQueryParserPlugin2Tests.java

@@ -34,7 +34,6 @@ import org.elasticsearch.index.IndexNameModule;
 import org.elasticsearch.index.analysis.AnalysisModule;
 import org.elasticsearch.index.cache.IndexCacheModule;
 import org.elasticsearch.index.codec.CodecModule;
-import org.elasticsearch.index.engine.IndexEngineModule;
 import org.elasticsearch.index.query.IndexQueryParserModule;
 import org.elasticsearch.index.query.IndexQueryParserService;
 import org.elasticsearch.index.query.functionscore.FunctionScoreModule;
@@ -74,7 +73,6 @@ public class IndexQueryParserPlugin2Tests extends ElasticsearchTestCase {
                 new IndexSettingsModule(index, settings),
                 new IndexCacheModule(settings),
                 new AnalysisModule(settings),
-                new IndexEngineModule(settings),
                 new SimilarityModule(settings),
                 queryParserModule,
                 new IndexNameModule(index),

+ 0 - 2
src/test/java/org/elasticsearch/index/query/plugin/IndexQueryParserPluginTests.java

@@ -34,7 +34,6 @@ import org.elasticsearch.index.IndexNameModule;
 import org.elasticsearch.index.analysis.AnalysisModule;
 import org.elasticsearch.index.cache.IndexCacheModule;
 import org.elasticsearch.index.codec.CodecModule;
-import org.elasticsearch.index.engine.IndexEngineModule;
 import org.elasticsearch.index.query.IndexQueryParserModule;
 import org.elasticsearch.index.query.IndexQueryParserService;
 import org.elasticsearch.index.query.functionscore.FunctionScoreModule;
@@ -82,7 +81,6 @@ public class IndexQueryParserPluginTests extends ElasticsearchTestCase {
                 new IndexSettingsModule(index, settings),
                 new IndexCacheModule(settings),
                 new AnalysisModule(settings),
-                new IndexEngineModule(settings),
                 new SimilarityModule(settings),
                 queryParserModule,
                 new IndexNameModule(index),

+ 0 - 3
src/test/java/org/elasticsearch/test/InternalTestCluster.java

@@ -73,7 +73,6 @@ import org.elasticsearch.index.IndexService;
 import org.elasticsearch.index.cache.filter.FilterCacheModule;
 import org.elasticsearch.index.cache.filter.none.NoneFilterCache;
 import org.elasticsearch.index.cache.filter.weighted.WeightedFilterCache;
-import org.elasticsearch.index.engine.IndexEngineModule;
 import org.elasticsearch.index.shard.ShardId;
 import org.elasticsearch.indices.IndicesService;
 import org.elasticsearch.indices.breaker.CircuitBreakerService;
@@ -88,7 +87,6 @@ import org.elasticsearch.search.SearchService;
 import org.elasticsearch.test.cache.recycler.MockBigArraysModule;
 import org.elasticsearch.test.cache.recycler.MockPageCacheRecyclerModule;
 import org.elasticsearch.test.disruption.ServiceDisruptionScheme;
-import org.elasticsearch.test.engine.MockEngineModule;
 import org.elasticsearch.test.store.MockFSIndexStoreModule;
 import org.elasticsearch.test.transport.AssertingLocalTransport;
 import org.elasticsearch.test.transport.MockTransportService;
@@ -366,7 +364,6 @@ public final class InternalTestCluster extends TestCluster {
                 .put(SETTING_CLUSTER_NODE_SEED, seed);
         if (ENABLE_MOCK_MODULES && usually(random)) {
             builder.put("index.store.type", MockFSIndexStoreModule.class.getName()); // no RAM dir for now!
-            builder.put(IndexEngineModule.EngineSettings.ENGINE_TYPE, MockEngineModule.class.getName());
             builder.put(PageCacheRecyclerModule.CACHE_IMPL, MockPageCacheRecyclerModule.class.getName());
             builder.put(BigArraysModule.IMPL, MockBigArraysModule.class.getName());
             builder.put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, MockTransportService.class.getName());