add an index level engine instance, allowing to provide and share data across different shard level engines

This commit is contained in:
kimchy 2010-05-19 04:24:39 +03:00
parent 40fdcc43b7
commit 1882460645
6 changed files with 161 additions and 6 deletions

View File

@ -19,7 +19,6 @@
package org.elasticsearch.index.engine;
import org.elasticsearch.index.engine.robin.RobinEngineModule;
import org.elasticsearch.util.guice.ModulesFactory;
import org.elasticsearch.util.inject.AbstractModule;
import org.elasticsearch.util.settings.Settings;
@ -29,10 +28,6 @@ import org.elasticsearch.util.settings.Settings;
*/
public class EngineModule extends AbstractModule {
public static final class EngineSettings {
public static final String ENGINE_TYPE = "index.engine.type";
}
private final Settings settings;
public EngineModule(Settings settings) {
@ -40,6 +35,6 @@ public class EngineModule extends AbstractModule {
}
@Override protected void configure() {
ModulesFactory.createModule(settings.getAsClass(EngineSettings.ENGINE_TYPE, RobinEngineModule.class, "org.elasticsearch.index.engine.", "EngineModule"), settings).configure(binder());
ModulesFactory.createModule(settings.getAsClass(IndexEngineModule.EngineSettings.ENGINE_TYPE, IndexEngineModule.EngineSettings.DEFAULT_ENGINE, "org.elasticsearch.index.engine.", "EngineModule"), settings).configure(binder());
}
}

View File

@ -0,0 +1,33 @@
/*
* Licensed to Elastic Search and Shay Banon under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Elastic Search 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.
*
* @author kimchy (shay.banon)
*/
public interface IndexEngine extends IndexComponent {
void close();
}

View File

@ -0,0 +1,50 @@
/*
* Licensed to Elastic Search and Shay Banon under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Elastic Search 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.engine.robin.RobinEngineModule;
import org.elasticsearch.index.engine.robin.RobinIndexEngineModule;
import org.elasticsearch.util.inject.AbstractModule;
import org.elasticsearch.util.inject.Module;
import org.elasticsearch.util.settings.Settings;
import static org.elasticsearch.util.guice.ModulesFactory.*;
/**
* @author kimchy (shay.banon)
*/
public class IndexEngineModule extends AbstractModule {
public static final class EngineSettings {
public static final String ENGINE_TYPE = "index.engine.type";
public static final Class<? extends Module> DEFAULT_INDEX_ENGINE = RobinIndexEngineModule.class;
public static final Class<? extends Module> DEFAULT_ENGINE = RobinEngineModule.class;
}
private final Settings settings;
public IndexEngineModule(Settings settings) {
this.settings = settings;
}
@Override protected void configure() {
createModule(settings.getAsClass(EngineSettings.ENGINE_TYPE, EngineSettings.DEFAULT_INDEX_ENGINE, "org.elasticsearch.index.engine.", "IndexEngineModule"), settings).configure(binder());
}
}

View File

@ -0,0 +1,40 @@
/*
* Licensed to Elastic Search and Shay Banon under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Elastic Search 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.robin;
import org.elasticsearch.index.AbstractIndexComponent;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.engine.IndexEngine;
import org.elasticsearch.index.settings.IndexSettings;
import org.elasticsearch.util.inject.Inject;
import org.elasticsearch.util.settings.Settings;
/**
* @author kimchy (shay.banon)
*/
public class RobinIndexEngine extends AbstractIndexComponent implements IndexEngine {
@Inject public RobinIndexEngine(Index index, @IndexSettings Settings indexSettings) {
super(index, indexSettings);
}
@Override public void close() {
}
}

View File

@ -0,0 +1,33 @@
/*
* Licensed to Elastic Search and Shay Banon under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Elastic Search 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.robin;
import org.elasticsearch.index.engine.IndexEngine;
import org.elasticsearch.util.inject.AbstractModule;
/**
* @author kimchy (shay.banon)
*/
public class RobinIndexEngineModule extends AbstractModule {
@Override protected void configure() {
bind(IndexEngine.class).to(RobinIndexEngine.class).asEagerSingleton();
}
}

View File

@ -28,6 +28,8 @@ import org.elasticsearch.index.analysis.AnalysisModule;
import org.elasticsearch.index.analysis.AnalysisService;
import org.elasticsearch.index.cache.IndexCacheModule;
import org.elasticsearch.index.cache.filter.FilterCache;
import org.elasticsearch.index.engine.IndexEngine;
import org.elasticsearch.index.engine.IndexEngineModule;
import org.elasticsearch.index.gateway.IndexGateway;
import org.elasticsearch.index.gateway.IndexGatewayModule;
import org.elasticsearch.index.mapper.MapperServiceModule;
@ -174,6 +176,7 @@ public class InternalIndicesService extends AbstractLifecycleComponent<IndicesSe
modules.add(new LocalNodeIdModule(localNodeId));
modules.add(new IndexSettingsModule(indexSettings));
modules.add(new IndicesPluginsModule(indexSettings, pluginsService));
modules.add(new IndexEngineModule(indexSettings));
modules.add(new AnalysisModule(indexSettings));
modules.add(new SimilarityModule(indexSettings));
modules.add(new IndexCacheModule(indexSettings));
@ -228,6 +231,7 @@ public class InternalIndicesService extends AbstractLifecycleComponent<IndicesSe
indexInjector.getInstance(FilterCache.class).close();
indexInjector.getInstance(AnalysisService.class).close();
indexInjector.getInstance(IndexEngine.class).close();
indexInjector.getInstance(IndexServiceManagement.class).close();
indexInjector.getInstance(IndexGateway.class).close(delete);