org.elasticsearch.node.internal.InternalSettingsPreparer Java Examples

The following examples show how to use org.elasticsearch.node.internal.InternalSettingsPreparer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PluginManagerCliParser.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    // initialize default for es.logger.level because we will not read the logging.yml
    String loggerLevel = System.getProperty("es.logger.level", "INFO");
    // Set the appender for all potential log files to terminal so that other components that use the logger print out the
    // same terminal.
    // The reason for this is that the plugin cli cannot be configured with a file appender because when the plugin command is
    // executed there is no way of knowing where the logfiles should be placed. For example, if elasticsearch
    // is run as service then the logs should be at /var/log/elasticsearch but when started from the tar they should be at es.home/logs.
    // Therefore we print to Terminal.
    Environment env = InternalSettingsPreparer.prepareEnvironment(Settings.builder()
            .put("appender.terminal.type", "terminal")
            .put("rootLogger", "${es.logger.level}, terminal")
            .put("es.logger.level", loggerLevel)
            .build(), Terminal.DEFAULT);
    // configure but do not read the logging conf file
    LogConfigurator.configure(env.settings(), false);
    int status = new PluginManagerCliParser().execute(args).status();
    exit(status);
}
 
Example #2
Source File: CliTool.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
protected CliTool(CliToolConfig config, Terminal terminal) {
    Preconditions.checkArgument(config.cmds().size() != 0, "At least one command must be configured");
    this.config = config;
    this.terminal = terminal;
    env = InternalSettingsPreparer.prepareEnvironment(EMPTY_SETTINGS, terminal);
    settings = env.settings();
}
 
Example #3
Source File: Bootstrap.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
private void setup(boolean addShutdownHook, Settings settings, Environment environment) throws Exception {
    initializeNatives(environment.tmpFile(),
                      settings.getAsBoolean("bootstrap.mlockall", false),
                      settings.getAsBoolean("bootstrap.seccomp", true),
                      settings.getAsBoolean("bootstrap.ctrlhandler", true));

    // initialize probes before the security manager is installed
    initializeProbes();

    if (addShutdownHook) {
        Runtime.getRuntime().addShutdownHook(new Thread() {
            @Override
            public void run() {
                if (node != null) {
                    node.close();
                }
            }
        });
    }

    // look for jar hell
    JarHell.checkJarHell();

    // install SM after natives, shutdown hooks, etc.
    setupSecurity(settings, environment);

    // We do not need to reload system properties here as we have already applied them in building the settings and
    // reloading could cause multiple prompts to the user for values if a system property was specified with a prompt
    // placeholder
    Settings nodeSettings = Settings.settingsBuilder()
            .put(settings)
            .put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING, true)
            .build();

    NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder().settings(nodeSettings);
    node = nodeBuilder.build();
}
 
Example #4
Source File: EmbeddedElasticsearchNodeEnvironmentImpl.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public PluginNode(Settings settings) {
	super(InternalSettingsPreparer.prepareEnvironment(settings, null), Collections.<Class<? extends Plugin>>singletonList(Netty3Plugin.class));
}
 
Example #5
Source File: EmbeddedElasticsearchNodeEnvironmentImpl.java    From flink with Apache License 2.0 4 votes vote down vote up
public PluginNode(Settings settings) {
	super(InternalSettingsPreparer.prepareEnvironment(settings, null), Collections.<Class<? extends Plugin>>singletonList(Netty3Plugin.class));
}
 
Example #6
Source File: TransportClient.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
/**
 * Builds a new instance of the transport client.
 */
public TransportClient build() {
    Settings settings = InternalSettingsPreparer.prepareSettings(this.settings);
    settings = settingsBuilder()
            .put(NettyTransport.PING_SCHEDULE, "5s") // enable by default the transport schedule ping interval
            .put(settings)
            .put("network.server", false)
            .put("node.client", true)
            .put(CLIENT_TYPE_SETTING, CLIENT_TYPE)
            .build();

    PluginsService pluginsService = new PluginsService(settings, null, null, pluginClasses);
    this.settings = pluginsService.updatedSettings();

    Version version = Version.CURRENT;

    final ThreadPool threadPool = new ThreadPool(settings);
    NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry();

    boolean success = false;
    try {
        ModulesBuilder modules = new ModulesBuilder();
        modules.add(new Version.Module(version));
        // plugin modules must be added here, before others or we can get crazy injection errors...
        for (Module pluginModule : pluginsService.nodeModules()) {
            modules.add(pluginModule);
        }
        modules.add(new PluginsModule(pluginsService));
        modules.add(new SettingsModule(this.settings));
        modules.add(new NetworkModule(namedWriteableRegistry));
        modules.add(new ClusterNameModule(this.settings));
        modules.add(new ThreadPoolModule(threadPool));
        modules.add(new TransportModule(this.settings, namedWriteableRegistry));
        modules.add(new SearchModule() {
            @Override
            protected void configure() {
                // noop
            }
        });
        modules.add(new ActionModule(true));
        modules.add(new ClientTransportModule());
        modules.add(new CircuitBreakerModule(this.settings));

        pluginsService.processModules(modules);

        Injector injector = modules.createInjector();
        final TransportService transportService = injector.getInstance(TransportService.class);
        transportService.start();
        transportService.acceptIncomingRequests();

        TransportClient transportClient = new TransportClient(injector);
        success = true;
        return transportClient;
    } finally {
        if (!success) {
            ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS);
        }
    }
}
 
Example #7
Source File: Bootstrap.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
private static Environment initialSettings(boolean foreground) {
    Terminal terminal = foreground ? Terminal.DEFAULT : null;
    return InternalSettingsPreparer.prepareEnvironment(EMPTY_SETTINGS, terminal);
}
 
Example #8
Source File: HadoopFormatIOElasticTest.java    From beam with Apache License 2.0 4 votes vote down vote up
PluginNode(final Settings settings) {
  super(InternalSettingsPreparer.prepareEnvironment(settings, null), PLUGINS);
}
 
Example #9
Source File: PluginUsingNode.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
public PluginUsingNode(final Settings preparedSettings, Collection<Class<? extends Plugin>> plugins) {
  super(InternalSettingsPreparer.prepareEnvironment(preparedSettings, null), Version.CURRENT, plugins);
}
 
Example #10
Source File: PluginEnabledNode.java    From elasticsearch-shield-kerberos-realm with Apache License 2.0 4 votes vote down vote up
public PluginEnabledNode(Settings preparedSettings, Collection<Class<? extends Plugin>> classpathPlugins) {
    super(InternalSettingsPreparer.prepareEnvironment(preparedSettings, null), Version.CURRENT, classpathPlugins);
}
 
Example #11
Source File: MockNode.java    From elasticsearch-xml with Apache License 2.0 4 votes vote down vote up
public MockNode(Settings settings, Collection<Class<? extends Plugin>> classpathPlugins) {
    super(InternalSettingsPreparer.prepareEnvironment(settings, null), Version.CURRENT, classpathPlugins);
}
 
Example #12
Source File: PluginAwareNode.java    From elasticsearch-imap with Apache License 2.0 4 votes vote down vote up
public PluginAwareNode(final Settings preparedSettings, final Collection<Class<? extends Plugin>> classpathPlugins) {
    super(InternalSettingsPreparer.prepareEnvironment(preparedSettings, null), Version.CURRENT, classpathPlugins);
}
 
Example #13
Source File: TransportClient.java    From elasticsearch-helper with Apache License 2.0 4 votes vote down vote up
public TransportClient build() {
    Settings settings = InternalSettingsPreparer.prepareSettings(this.settings);
    settings = settingsBuilder()
            .put("transport.ping.schedule", this.settings.get("ping.interval", "30s"))
            .put(settings)
            .put("network.server", false)
            .put("node.client", true)
            .put(CLIENT_TYPE_SETTING, CLIENT_TYPE)
            .build();
    PluginsService pluginsService = new PluginsService(settings, null, null, pluginClasses);
    this.settings = pluginsService.updatedSettings();
    Version version = Version.CURRENT;
    final ThreadPool threadPool = new ThreadPool(settings);
    final NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry();

    boolean success = false;
    try {
        ModulesBuilder modules = new ModulesBuilder();
        modules.add(new Version.Module(version));
        // plugin modules must be added here, before others or we can get crazy injection errors...
        for (Module pluginModule : pluginsService.nodeModules()) {
            modules.add(pluginModule);
        }
        modules.add(new PluginsModule(pluginsService));
        modules.add(new SettingsModule(this.settings));
        modules.add(new NetworkModule(namedWriteableRegistry));
        modules.add(new ClusterNameModule(this.settings));
        modules.add(new ThreadPoolModule(threadPool));
        modules.add(new TransportModule(this.settings, namedWriteableRegistry));
        modules.add(new SearchModule() {
            @Override
            protected void configure() {
                // noop
            }
        });
        modules.add(new ActionModule(true));
        modules.add(new ClientTransportModule(hostFailedListener));
        modules.add(new CircuitBreakerModule(this.settings));
        pluginsService.processModules(modules);
        Injector injector = modules.createInjector();
        injector.getInstance(TransportService.class).start();
        TransportClient transportClient = new TransportClient(injector);
        success = true;
        return transportClient;
    } finally {
        if (!success) {
            ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS);
        }
    }
}
 
Example #14
Source File: MockNode.java    From elasticsearch-helper with Apache License 2.0 4 votes vote down vote up
public MockNode(Settings settings, Collection<Class<? extends Plugin>> classpathPlugins) {
    super(InternalSettingsPreparer.prepareEnvironment(settings, null), Version.CURRENT, classpathPlugins);
}
 
Example #15
Source File: MockNode.java    From elasticsearch-analysis-baseform with Apache License 2.0 4 votes vote down vote up
public MockNode(Settings settings, Collection<Class<? extends Plugin>> classpathPlugins) {
    super(InternalSettingsPreparer.prepareEnvironment(settings, null), Version.CURRENT, classpathPlugins);
}
 
Example #16
Source File: Node.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Constructs a node with the given settings.
 *
 * @param preparedSettings Base settings to configure the node with
 */
public Node(Settings preparedSettings) {
    this(InternalSettingsPreparer.prepareEnvironment(preparedSettings, null), Version.CURRENT, Collections.<Class<? extends Plugin>>emptyList());
}