create NodeEnvironment outside of guice so if it fails, it fails early and does not takes ages with guice trying to create it per injection
This commit is contained in:
parent
e56086cf7b
commit
0412e3e2e6
|
@ -48,7 +48,7 @@ public class NodeEnvironment extends AbstractComponent {
|
|||
private final int localNodeId;
|
||||
|
||||
@Inject
|
||||
public NodeEnvironment(Settings settings, Environment environment) throws IOException {
|
||||
public NodeEnvironment(Settings settings, Environment environment) {
|
||||
super(settings);
|
||||
|
||||
if (!DiscoveryNode.nodeRequiresLocalStorage(settings)) {
|
||||
|
@ -117,7 +117,7 @@ public class NodeEnvironment extends AbstractComponent {
|
|||
}
|
||||
}
|
||||
if (locks[0] == null) {
|
||||
throw new IOException("Failed to obtain node lock on " + Arrays.toString(environment.dataWithClusterFiles()), lastException);
|
||||
throw new ElasticSearchIllegalStateException("Failed to obtain node lock, is the following location writable?: " + Arrays.toString(environment.dataWithClusterFiles()), lastException);
|
||||
}
|
||||
|
||||
this.localNodeId = localNodeId;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.elasticsearch.env;
|
||||
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
|
||||
/**
|
||||
|
@ -26,11 +27,22 @@ import org.elasticsearch.common.inject.AbstractModule;
|
|||
*/
|
||||
public class NodeEnvironmentModule extends AbstractModule {
|
||||
|
||||
private final NodeEnvironment nodeEnvironment;
|
||||
|
||||
public NodeEnvironmentModule() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public NodeEnvironmentModule(@Nullable NodeEnvironment nodeEnvironment) {
|
||||
this.nodeEnvironment = nodeEnvironment;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(NodeEnvironment.class).asEagerSingleton();
|
||||
if (nodeEnvironment != null) {
|
||||
bind(NodeEnvironment.class).toInstance(nodeEnvironment);
|
||||
} else {
|
||||
bind(NodeEnvironment.class).asEagerSingleton();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -117,6 +117,8 @@ public final class InternalNode implements Node {
|
|||
this.settings = pluginsService.updatedSettings();
|
||||
this.environment = tuple.v2();
|
||||
|
||||
NodeEnvironment nodeEnvironment = new NodeEnvironment(this.settings, this.environment);
|
||||
|
||||
ModulesBuilder modules = new ModulesBuilder();
|
||||
modules.add(new PluginsModule(settings, pluginsService));
|
||||
modules.add(new SettingsModule(settings));
|
||||
|
@ -126,7 +128,7 @@ public final class InternalNode implements Node {
|
|||
modules.add(new ScriptModule(settings));
|
||||
modules.add(new JmxModule(settings));
|
||||
modules.add(new EnvironmentModule(environment));
|
||||
modules.add(new NodeEnvironmentModule());
|
||||
modules.add(new NodeEnvironmentModule(nodeEnvironment));
|
||||
modules.add(new ClusterNameModule(settings));
|
||||
modules.add(new ThreadPoolModule(settings));
|
||||
modules.add(new DiscoveryModule(settings));
|
||||
|
|
Loading…
Reference in New Issue