Plugins: Simplify Plugin API for constructing modules
The Plugin interface currently contains 6 different methods for adding modules. Elasticsearch has 3 different levels of injectors, and for each of those, there are two methods. The first takes no arguments and returns a collection of class objects to construct. The second takes a Settings object and returns a collection of module objects already constructed. The settings argument is unecessary because the plugin can already get the settings from its constructor. Removing that, the only difference between the two versions is returning an already constructed Module, or a module Class, and there is no reason the plugin can't construct all their modules themselves. This change reduces the plugin api down to just 3 methods for adding modules. Each returns a Collection<Module>. It also removes the processModule method, which was unnecessary since onModule implementations fullfill the same requirement. And finally, it renames the modules() method to nodeModules() so it is clear these are created once for each node.
This commit is contained in:
parent
75ced057ed
commit
2bf84593e0
|
@ -260,7 +260,7 @@ public class TransportClient extends AbstractClient {
|
|||
// ignore, might not be bounded
|
||||
}
|
||||
|
||||
for (Class<? extends LifecycleComponent> plugin : injector.getInstance(PluginsService.class).services()) {
|
||||
for (Class<? extends LifecycleComponent> plugin : injector.getInstance(PluginsService.class).nodeServices()) {
|
||||
injector.getInstance(plugin).close();
|
||||
}
|
||||
try {
|
||||
|
|
|
@ -230,7 +230,7 @@ public class Node implements Releasable {
|
|||
// hack around dependency injection problem (for now...)
|
||||
injector.getInstance(Discovery.class).setRoutingService(injector.getInstance(RoutingService.class));
|
||||
|
||||
for (Class<? extends LifecycleComponent> plugin : pluginsService.services()) {
|
||||
for (Class<? extends LifecycleComponent> plugin : pluginsService.nodeServices()) {
|
||||
injector.getInstance(plugin).start();
|
||||
}
|
||||
|
||||
|
@ -297,7 +297,7 @@ public class Node implements Releasable {
|
|||
injector.getInstance(RestController.class).stop();
|
||||
injector.getInstance(TransportService.class).stop();
|
||||
|
||||
for (Class<? extends LifecycleComponent> plugin : pluginsService.services()) {
|
||||
for (Class<? extends LifecycleComponent> plugin : pluginsService.nodeServices()) {
|
||||
injector.getInstance(plugin).stop();
|
||||
}
|
||||
// we should stop this last since it waits for resources to get released
|
||||
|
@ -364,7 +364,7 @@ public class Node implements Releasable {
|
|||
stopWatch.stop().start("percolator_service");
|
||||
injector.getInstance(PercolatorService.class).close();
|
||||
|
||||
for (Class<? extends LifecycleComponent> plugin : pluginsService.services()) {
|
||||
for (Class<? extends LifecycleComponent> plugin : pluginsService.nodeServices()) {
|
||||
stopWatch.stop().start("plugin(" + plugin.getName() + ")");
|
||||
injector.getInstance(plugin).close();
|
||||
}
|
||||
|
|
|
@ -19,20 +19,16 @@
|
|||
|
||||
package org.elasticsearch.plugins;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.elasticsearch.common.component.LifecycleComponent;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* A base class for a plugin.
|
||||
* <p/>
|
||||
* A plugin can be dynamically injected with {@link Module} by implementing <tt>onModule(AnyModule)</tt> method
|
||||
* removing the need to override {@link #processModule(org.elasticsearch.common.inject.Module)} and check using
|
||||
* instanceof.
|
||||
* A base class for a plugin which returns no services or modules.
|
||||
*/
|
||||
public abstract class AbstractPlugin implements Plugin {
|
||||
|
||||
|
@ -40,40 +36,24 @@ public abstract class AbstractPlugin implements Plugin {
|
|||
* Defaults to return an empty list.
|
||||
*/
|
||||
@Override
|
||||
public Collection<Class<? extends Module>> modules() {
|
||||
return ImmutableList.of();
|
||||
public Collection<Module> nodeModules() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Defaults to return an empty list.
|
||||
*/
|
||||
@Override
|
||||
public Collection<Module> modules(Settings settings) {
|
||||
return ImmutableList.of();
|
||||
public Collection<Class<? extends LifecycleComponent>> nodeServices() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Defaults to return an empty list.
|
||||
*/
|
||||
@Override
|
||||
public Collection<Class<? extends LifecycleComponent>> services() {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
/**
|
||||
* Defaults to return an empty list.
|
||||
*/
|
||||
@Override
|
||||
public Collection<Class<? extends Module>> indexModules() {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
/**
|
||||
* Defaults to return an empty list.
|
||||
*/
|
||||
@Override
|
||||
public Collection<Module> indexModules(Settings settings) {
|
||||
return ImmutableList.of();
|
||||
public Collection<Module> indexModules() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,23 +61,15 @@ public abstract class AbstractPlugin implements Plugin {
|
|||
*/
|
||||
@Override
|
||||
public Collection<Class<? extends Closeable>> indexServices() {
|
||||
return ImmutableList.of();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Defaults to return an empty list.
|
||||
*/
|
||||
@Override
|
||||
public Collection<Class<? extends Module>> shardModules() {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
/**
|
||||
* Defaults to return an empty list.
|
||||
*/
|
||||
@Override
|
||||
public Collection<Module> shardModules(Settings settings) {
|
||||
return ImmutableList.of();
|
||||
public Collection<Module> shardModules() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,12 +77,7 @@ public abstract class AbstractPlugin implements Plugin {
|
|||
*/
|
||||
@Override
|
||||
public Collection<Class<? extends Closeable>> shardServices() {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processModule(Module module) {
|
||||
// nothing to do here
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,18 +19,12 @@
|
|||
|
||||
package org.elasticsearch.plugins;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.inject.PreProcessModule;
|
||||
import org.elasticsearch.common.inject.SpawnModules;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static org.elasticsearch.common.inject.Modules.createModule;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -47,13 +41,7 @@ public class IndexPluginsModule extends AbstractModule implements SpawnModules,
|
|||
|
||||
@Override
|
||||
public Iterable<? extends Module> spawnModules() {
|
||||
List<Module> modules = Lists.newArrayList();
|
||||
Collection<Class<? extends Module>> modulesClasses = pluginsService.indexModules();
|
||||
for (Class<? extends Module> moduleClass : modulesClasses) {
|
||||
modules.add(createModule(moduleClass, settings));
|
||||
}
|
||||
modules.addAll(pluginsService.indexModules(settings));
|
||||
return modules;
|
||||
return pluginsService.indexModules();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -29,9 +29,8 @@ import java.util.Collection;
|
|||
/**
|
||||
* An extension point allowing to plug in custom functionality.
|
||||
* <p/>
|
||||
* A plugin can be dynamically injected with {@link Module} by implementing <tt>onModule(AnyModule)</tt> method
|
||||
* removing the need to override {@link #processModule(org.elasticsearch.common.inject.Module)} and check using
|
||||
* instanceof.
|
||||
* A plugin can be register custom extensions to builtin behavior by implementing <tt>onModule(AnyModule)</tt>,
|
||||
* and registering the extension with the given module.
|
||||
*/
|
||||
public interface Plugin {
|
||||
|
||||
|
@ -46,31 +45,19 @@ public interface Plugin {
|
|||
String description();
|
||||
|
||||
/**
|
||||
* Node level modules (classes, will automatically be created).
|
||||
* Node level modules.
|
||||
*/
|
||||
Collection<Class<? extends Module>> modules();
|
||||
|
||||
/**
|
||||
* Node level modules (instances)
|
||||
*
|
||||
* @param settings The node level settings.
|
||||
*/
|
||||
Collection<? extends Module> modules(Settings settings);
|
||||
Collection<Module> nodeModules();
|
||||
|
||||
/**
|
||||
* Node level services that will be automatically started/stopped/closed.
|
||||
*/
|
||||
Collection<Class<? extends LifecycleComponent>> services();
|
||||
Collection<Class<? extends LifecycleComponent>> nodeServices();
|
||||
|
||||
/**
|
||||
* Per index modules.
|
||||
*/
|
||||
Collection<Class<? extends Module>> indexModules();
|
||||
|
||||
/**
|
||||
* Per index modules.
|
||||
*/
|
||||
Collection<? extends Module> indexModules(Settings settings);
|
||||
Collection<Module> indexModules();
|
||||
|
||||
/**
|
||||
* Per index services that will be automatically closed.
|
||||
|
@ -80,24 +67,13 @@ public interface Plugin {
|
|||
/**
|
||||
* Per index shard module.
|
||||
*/
|
||||
Collection<Class<? extends Module>> shardModules();
|
||||
|
||||
/**
|
||||
* Per index shard module.
|
||||
*/
|
||||
Collection<? extends Module> shardModules(Settings settings);
|
||||
Collection<Module> shardModules();
|
||||
|
||||
/**
|
||||
* Per index shard service that will be automatically closed.
|
||||
*/
|
||||
Collection<Class<? extends Closeable>> shardServices();
|
||||
|
||||
/**
|
||||
* Process a specific module. Note, its simpler to implement a custom <tt>onModule(AnyModule module)</tt>
|
||||
* method, which will be automatically be called by the relevant type.
|
||||
*/
|
||||
void processModule(Module module);
|
||||
|
||||
/**
|
||||
* Additional node settings loaded by the plugin. Note that settings that are explicit in the nodes settings can't be
|
||||
* overwritten with the additional settings. These settings added if they don't exist.
|
||||
|
|
|
@ -19,18 +19,12 @@
|
|||
|
||||
package org.elasticsearch.plugins;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.inject.PreProcessModule;
|
||||
import org.elasticsearch.common.inject.SpawnModules;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static org.elasticsearch.common.inject.Modules.createModule;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -47,13 +41,7 @@ public class PluginsModule extends AbstractModule implements SpawnModules, PrePr
|
|||
|
||||
@Override
|
||||
public Iterable<? extends Module> spawnModules() {
|
||||
List<Module> modules = Lists.newArrayList();
|
||||
Collection<Class<? extends Module>> modulesClasses = pluginsService.modules();
|
||||
for (Class<? extends Module> moduleClass : modulesClasses) {
|
||||
modules.add(createModule(moduleClass, settings));
|
||||
}
|
||||
modules.addAll(pluginsService.modules(settings));
|
||||
return modules;
|
||||
return pluginsService.nodeModules();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -184,7 +184,6 @@ public class PluginsService extends AbstractComponent {
|
|||
|
||||
public void processModule(Module module) {
|
||||
for (Tuple<PluginInfo, Plugin> plugin : plugins()) {
|
||||
plugin.v2().processModule(module);
|
||||
// see if there are onModule references
|
||||
List<OnModuleReference> references = onModuleReferences.get(plugin.v2());
|
||||
if (references != null) {
|
||||
|
@ -209,42 +208,26 @@ public class PluginsService extends AbstractComponent {
|
|||
return builder.put(this.settings).build();
|
||||
}
|
||||
|
||||
public Collection<Class<? extends Module>> modules() {
|
||||
List<Class<? extends Module>> modules = new ArrayList<>();
|
||||
for (Tuple<PluginInfo, Plugin> plugin : plugins) {
|
||||
modules.addAll(plugin.v2().modules());
|
||||
}
|
||||
return modules;
|
||||
}
|
||||
|
||||
public Collection<Module> modules(Settings settings) {
|
||||
public Collection<Module> nodeModules() {
|
||||
List<Module> modules = new ArrayList<>();
|
||||
for (Tuple<PluginInfo, Plugin> plugin : plugins) {
|
||||
modules.addAll(plugin.v2().modules(settings));
|
||||
modules.addAll(plugin.v2().nodeModules());
|
||||
}
|
||||
return modules;
|
||||
}
|
||||
|
||||
public Collection<Class<? extends LifecycleComponent>> services() {
|
||||
public Collection<Class<? extends LifecycleComponent>> nodeServices() {
|
||||
List<Class<? extends LifecycleComponent>> services = new ArrayList<>();
|
||||
for (Tuple<PluginInfo, Plugin> plugin : plugins) {
|
||||
services.addAll(plugin.v2().services());
|
||||
services.addAll(plugin.v2().nodeServices());
|
||||
}
|
||||
return services;
|
||||
}
|
||||
|
||||
public Collection<Class<? extends Module>> indexModules() {
|
||||
List<Class<? extends Module>> modules = new ArrayList<>();
|
||||
for (Tuple<PluginInfo, Plugin> plugin : plugins) {
|
||||
modules.addAll(plugin.v2().indexModules());
|
||||
}
|
||||
return modules;
|
||||
}
|
||||
|
||||
public Collection<Module> indexModules(Settings settings) {
|
||||
public Collection<Module> indexModules() {
|
||||
List<Module> modules = new ArrayList<>();
|
||||
for (Tuple<PluginInfo, Plugin> plugin : plugins) {
|
||||
modules.addAll(plugin.v2().indexModules(settings));
|
||||
modules.addAll(plugin.v2().indexModules());
|
||||
}
|
||||
return modules;
|
||||
}
|
||||
|
@ -257,18 +240,10 @@ public class PluginsService extends AbstractComponent {
|
|||
return services;
|
||||
}
|
||||
|
||||
public Collection<Class<? extends Module>> shardModules() {
|
||||
List<Class<? extends Module>> modules = new ArrayList<>();
|
||||
for (Tuple<PluginInfo, Plugin> plugin : plugins) {
|
||||
modules.addAll(plugin.v2().shardModules());
|
||||
}
|
||||
return modules;
|
||||
}
|
||||
|
||||
public Collection<Module> shardModules(Settings settings) {
|
||||
public Collection<Module> shardModules() {
|
||||
List<Module> modules = new ArrayList<>();
|
||||
for (Tuple<PluginInfo, Plugin> plugin : plugins) {
|
||||
modules.addAll(plugin.v2().shardModules(settings));
|
||||
modules.addAll(plugin.v2().shardModules());
|
||||
}
|
||||
return modules;
|
||||
}
|
||||
|
|
|
@ -19,18 +19,12 @@
|
|||
|
||||
package org.elasticsearch.plugins;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.inject.PreProcessModule;
|
||||
import org.elasticsearch.common.inject.SpawnModules;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static org.elasticsearch.common.inject.Modules.createModule;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -47,13 +41,7 @@ public class ShardsPluginsModule extends AbstractModule implements SpawnModules,
|
|||
|
||||
@Override
|
||||
public Iterable<? extends Module> spawnModules() {
|
||||
List<Module> modules = Lists.newArrayList();
|
||||
Collection<Class<? extends Module>> modulesClasses = pluginsService.shardModules();
|
||||
for (Class<? extends Module> moduleClass : modulesClasses) {
|
||||
modules.add(createModule(moduleClass, settings));
|
||||
}
|
||||
modules.addAll(pluginsService.shardModules(settings));
|
||||
return modules;
|
||||
return pluginsService.shardModules();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,16 +19,8 @@
|
|||
|
||||
package org.elasticsearch.plugins;
|
||||
|
||||
import org.elasticsearch.common.component.LifecycleComponent;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
/** A site-only plugin, just serves resources */
|
||||
final class SitePlugin implements Plugin {
|
||||
final class SitePlugin extends AbstractPlugin {
|
||||
final String name;
|
||||
final String description;
|
||||
|
||||
|
@ -46,58 +38,4 @@ final class SitePlugin implements Plugin {
|
|||
public String description() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends Module>> modules() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends Module> modules(Settings settings) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends LifecycleComponent>> services() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends Module>> indexModules() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends Module> indexModules(Settings settings) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends Closeable>> indexServices() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends Module>> shardModules() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends Module> shardModules(Settings settings) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends Closeable>> shardServices() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processModule(Module module) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Settings additionalSettings() {
|
||||
return Settings.EMPTY;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1005,7 +1005,7 @@ public class ClusterServiceIT extends ESIntegTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends LifecycleComponent>> services() {
|
||||
public Collection<Class<? extends LifecycleComponent>> nodeServices() {
|
||||
List<Class<? extends LifecycleComponent>> services = new ArrayList<>(1);
|
||||
services.add(MasterAwareService.class);
|
||||
return services;
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
|||
import org.junit.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static org.elasticsearch.test.ESIntegTestCase.Scope.SUITE;
|
||||
|
@ -67,10 +68,8 @@ public class SettingsFilteringIT extends ESIntegTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends Module>> indexModules() {
|
||||
Collection<Class<? extends Module>> modules = newArrayList();
|
||||
modules.add(SettingsFilteringModule.class);
|
||||
return modules;
|
||||
public Collection<Module> indexModules() {
|
||||
return Collections.<Module>singletonList(new SettingsFilteringModule());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,30 +23,23 @@ import org.elasticsearch.common.inject.Module;
|
|||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
public class ExternalMapperPlugin extends AbstractPlugin {
|
||||
/**
|
||||
* The name of the plugin.
|
||||
*/
|
||||
@Override
|
||||
public String name() {
|
||||
return "external-mappers";
|
||||
}
|
||||
|
||||
/**
|
||||
* The description of the plugin.
|
||||
*/
|
||||
@Override
|
||||
public String description() {
|
||||
return "External Mappers Plugin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends Module>> indexModules() {
|
||||
Collection<Class<? extends Module>> modules = newArrayList();
|
||||
modules.add(ExternalIndexModule.class);
|
||||
return modules;
|
||||
public Collection<Module> indexModules() {
|
||||
return Collections.<Module>singletonList(new ExternalIndexModule());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,9 +23,8 @@ import org.elasticsearch.plugins.AbstractPlugin;
|
|||
import org.elasticsearch.test.engine.MockEngineFactory;
|
||||
import org.elasticsearch.test.engine.MockEngineSupportModule;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
// this must exist in the same package as IndexShardModule to allow access to setting the impl
|
||||
public class MockEngineFactoryPlugin extends AbstractPlugin {
|
||||
|
@ -38,10 +37,8 @@ public class MockEngineFactoryPlugin extends AbstractPlugin {
|
|||
return "a mock engine factory for testing";
|
||||
}
|
||||
@Override
|
||||
public Collection<Class<? extends Module>> indexModules() {
|
||||
List<Class<? extends Module>> modules = new ArrayList<>();
|
||||
modules.add(MockEngineSupportModule.class);
|
||||
return modules;
|
||||
public Collection<Module> indexModules() {
|
||||
return Collections.<Module>singletonList(new MockEngineSupportModule());
|
||||
}
|
||||
public void onModule(IndexShardModule module) {
|
||||
module.engineFactoryImpl = MockEngineFactory.class;
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
|
||||
package org.elasticsearch.indices.analysis;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.index.analysis.AnalysisModule;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public class DummyAnalysisPlugin extends AbstractPlugin {
|
||||
/**
|
||||
|
@ -44,8 +44,8 @@ public class DummyAnalysisPlugin extends AbstractPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends Module>> modules() {
|
||||
return ImmutableList.<Class<? extends Module>>of(DummyIndicesAnalysisModule.class);
|
||||
public Collection<Module> nodeModules() {
|
||||
return Collections.<Module>singletonList(new DummyIndicesAnalysisModule());
|
||||
}
|
||||
|
||||
public void onModule(AnalysisModule module) {
|
||||
|
|
|
@ -128,14 +128,10 @@ public class CustomScriptContextIT extends ESIntegTestCase {
|
|||
return "Custom script context plugin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processModule(Module module) {
|
||||
if (module instanceof ScriptModule) {
|
||||
ScriptModule scriptModule = (ScriptModule) module;
|
||||
scriptModule.registerScriptContext(new ScriptContext.Plugin(PLUGIN_NAME, "custom_op"));
|
||||
scriptModule.registerScriptContext(new ScriptContext.Plugin(PLUGIN_NAME, "custom_exp_disabled_op"));
|
||||
scriptModule.registerScriptContext(new ScriptContext.Plugin(PLUGIN_NAME, "custom_globally_disabled_op"));
|
||||
}
|
||||
public void onModule(ScriptModule scriptModule) {
|
||||
scriptModule.registerScriptContext(new ScriptContext.Plugin(PLUGIN_NAME, "custom_op"));
|
||||
scriptModule.registerScriptContext(new ScriptContext.Plugin(PLUGIN_NAME, "custom_exp_disabled_op"));
|
||||
scriptModule.registerScriptContext(new ScriptContext.Plugin(PLUGIN_NAME, "custom_globally_disabled_op"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.plugins.AbstractPlugin;
|
|||
import org.elasticsearch.repositories.RepositoriesModule;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
|
@ -47,10 +48,8 @@ public class MockRepositoryPlugin extends AbstractPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends Module>> modules() {
|
||||
Collection<Class<? extends Module>> modules = newArrayList();
|
||||
modules.add(SettingsFilteringModule.class);
|
||||
return modules;
|
||||
public Collection<Module> nodeModules() {
|
||||
return Collections.<Module>singletonList(new SettingsFilteringModule());
|
||||
}
|
||||
|
||||
public static class SettingsFilteringModule extends AbstractModule {
|
||||
|
|
|
@ -378,10 +378,8 @@ public class ContextAndHeaderTransportIT extends ESIntegTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends Module>> modules() {
|
||||
Collection<Class<? extends Module>> classes = new ArrayList<>();
|
||||
classes.add(ActionLoggingModule.class);
|
||||
return classes;
|
||||
public Collection<Module> nodeModules() {
|
||||
return Collections.<Module>singletonList(new ActionLoggingModule());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.plugins.AbstractPlugin;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -44,10 +45,8 @@ public class AnalysisICUPlugin extends AbstractPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends Module>> modules() {
|
||||
Collection<Class<? extends Module>> classes = new ArrayList<>();
|
||||
classes.add(IcuIndicesAnalysisModule.class);
|
||||
return classes;
|
||||
public Collection<Module> nodeModules() {
|
||||
return Collections.<Module>singletonList(new IcuIndicesAnalysisModule());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,12 +20,21 @@
|
|||
package org.elasticsearch.plugin.analysis.kuromoji;
|
||||
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.index.analysis.*;
|
||||
import org.elasticsearch.index.analysis.AnalysisModule;
|
||||
import org.elasticsearch.index.analysis.JapaneseStopTokenFilterFactory;
|
||||
import org.elasticsearch.index.analysis.KuromojiAnalyzerProvider;
|
||||
import org.elasticsearch.index.analysis.KuromojiBaseFormFilterFactory;
|
||||
import org.elasticsearch.index.analysis.KuromojiIterationMarkCharFilterFactory;
|
||||
import org.elasticsearch.index.analysis.KuromojiKatakanaStemmerFactory;
|
||||
import org.elasticsearch.index.analysis.KuromojiPartOfSpeechFilterFactory;
|
||||
import org.elasticsearch.index.analysis.KuromojiReadingFormFilterFactory;
|
||||
import org.elasticsearch.index.analysis.KuromojiTokenizerFactory;
|
||||
import org.elasticsearch.indices.analysis.KuromojiIndicesAnalysisModule;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -43,10 +52,8 @@ public class AnalysisKuromojiPlugin extends AbstractPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends Module>> modules() {
|
||||
Collection<Class<? extends Module>> classes = new ArrayList<>();
|
||||
classes.add(KuromojiIndicesAnalysisModule.class);
|
||||
return classes;
|
||||
public Collection<Module> nodeModules() {
|
||||
return Collections.<Module>singletonList(new KuromojiIndicesAnalysisModule());
|
||||
}
|
||||
|
||||
public void onModule(AnalysisModule module) {
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.plugins.AbstractPlugin;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -44,10 +45,8 @@ public class AnalysisSmartChinesePlugin extends AbstractPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends Module>> modules() {
|
||||
Collection<Class<? extends Module>> classes = new ArrayList<>();
|
||||
classes.add(SmartChineseIndicesAnalysisModule.class);
|
||||
return classes;
|
||||
public Collection<Module> nodeModules() {
|
||||
return Collections.<Module>singletonList(new SmartChineseIndicesAnalysisModule());
|
||||
}
|
||||
|
||||
public void onModule(AnalysisModule module) {
|
||||
|
|
|
@ -43,10 +43,8 @@ public class AnalysisStempelPlugin extends AbstractPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends Module>> modules() {
|
||||
Collection<Class<? extends Module>> classes = new ArrayList<>();
|
||||
classes.add(PolishIndicesAnalysisModule.class);
|
||||
return classes;
|
||||
public Collection<Module> nodeModules() {
|
||||
return Collections.<Module>singletonList(new PolishIndicesAnalysisModule());
|
||||
}
|
||||
|
||||
public void onModule(AnalysisModule module) {
|
||||
|
|
|
@ -56,7 +56,7 @@ public class CloudAwsPlugin extends AbstractPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<Module> modules(Settings settings) {
|
||||
public Collection<Module> nodeModules() {
|
||||
Collection<Module> modules = new ArrayList<>();
|
||||
if (settings.getAsBoolean("cloud.enabled", true)) {
|
||||
modules.add(new AwsModule());
|
||||
|
@ -65,7 +65,7 @@ public class CloudAwsPlugin extends AbstractPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends LifecycleComponent>> services() {
|
||||
public Collection<Class<? extends LifecycleComponent>> nodeServices() {
|
||||
Collection<Class<? extends LifecycleComponent>> services = new ArrayList<>();
|
||||
if (settings.getAsBoolean("cloud.enabled", true)) {
|
||||
services.add(AwsModule.getS3ServiceImpl());
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.elasticsearch.repositories.azure.AzureRepositoryModule;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static org.elasticsearch.cloud.azure.AzureModule.isSnapshotReady;
|
||||
|
||||
|
@ -63,20 +64,16 @@ public class CloudAzurePlugin extends AbstractPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends Module>> modules() {
|
||||
Collection<Class<? extends Module>> modules = new ArrayList<>();
|
||||
public Collection<Module> nodeModules() {
|
||||
List<Module> modules = new ArrayList<>();
|
||||
if (AzureModule.isCloudReady(settings)) {
|
||||
modules.add(AzureModule.class);
|
||||
modules.add(new AzureModule(settings));
|
||||
}
|
||||
return modules;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processModule(Module module) {
|
||||
if (isSnapshotReady(settings, logger)
|
||||
&& module instanceof RepositoriesModule) {
|
||||
((RepositoriesModule)module).registerRepository(AzureRepository.TYPE, AzureRepositoryModule.class);
|
||||
}
|
||||
public void onModule(RepositoriesModule module) {
|
||||
module.registerRepository(AzureRepository.TYPE, AzureRepositoryModule.class);
|
||||
}
|
||||
|
||||
public void onModule(DiscoveryModule discoveryModule) {
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.plugins.AbstractPlugin;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -52,16 +53,16 @@ public class CloudGcePlugin extends AbstractPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends Module>> modules() {
|
||||
Collection<Class<? extends Module>> modules = new ArrayList<>();
|
||||
public Collection<Module> nodeModules() {
|
||||
List<Module> modules = new ArrayList<>();
|
||||
if (settings.getAsBoolean("cloud.enabled", true)) {
|
||||
modules.add(GceModule.class);
|
||||
modules.add(new GceModule());
|
||||
}
|
||||
return modules;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends LifecycleComponent>> services() {
|
||||
public Collection<Class<? extends LifecycleComponent>> nodeServices() {
|
||||
Collection<Class<? extends LifecycleComponent>> services = new ArrayList<>();
|
||||
if (settings.getAsBoolean("cloud.enabled", true)) {
|
||||
services.add(GceModule.getComputeServiceImpl());
|
||||
|
|
|
@ -20,11 +20,10 @@
|
|||
package org.elasticsearch.plugin.deletebyquery;
|
||||
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public class DeleteByQueryPlugin extends AbstractPlugin {
|
||||
|
||||
|
@ -41,7 +40,7 @@ public class DeleteByQueryPlugin extends AbstractPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<Module> modules(Settings settings) {
|
||||
return Arrays.asList((Module) new DeleteByQueryModule());
|
||||
public Collection<Module> nodeModules() {
|
||||
return Collections.<Module>singletonList(new DeleteByQueryModule());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.elasticsearch.common.inject.Module;
|
|||
import org.elasticsearch.common.inject.multibindings.Multibinder;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
import org.elasticsearch.repositories.RepositoriesModule;
|
||||
import org.elasticsearch.rest.action.cat.AbstractCatAction;
|
||||
|
||||
|
@ -56,31 +55,18 @@ public class JvmExamplePlugin implements Plugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends Module>> modules() {
|
||||
Collection<Class<? extends Module>> modules = new ArrayList<>();
|
||||
modules.add(ConfiguredExampleModule.class);
|
||||
return modules;
|
||||
public Collection<Module> nodeModules() {
|
||||
return Collections.<Module>singletonList(new ConfiguredExampleModule());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Module> modules(Settings settings) {
|
||||
Collection<Module> modules = new ArrayList<>();
|
||||
return modules;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends LifecycleComponent>> services() {
|
||||
public Collection<Class<? extends LifecycleComponent>> nodeServices() {
|
||||
Collection<Class<? extends LifecycleComponent>> services = new ArrayList<>();
|
||||
return services;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends Module>> indexModules() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends Module> indexModules(Settings settings) {
|
||||
public Collection<Module> indexModules() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
@ -90,12 +76,7 @@ public class JvmExamplePlugin implements Plugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends Module>> shardModules() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends Module> shardModules(Settings settings) {
|
||||
public Collection<Module> shardModules() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
@ -104,11 +85,6 @@ public class JvmExamplePlugin implements Plugin {
|
|||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processModule(Module module) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Settings additionalSettings() {
|
||||
return Settings.EMPTY;
|
||||
|
|
|
@ -38,8 +38,8 @@ public class MapperSizePlugin extends AbstractPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends Module>> indexModules() {
|
||||
return Collections.<Class<? extends Module>>singleton(MapperSizeIndexModule.class);
|
||||
public Collection<Module> indexModules() {
|
||||
return Collections.<Module>singletonList(new MapperSizeIndexModule());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue