Rename local Environment var in Node to avoid confusion (#52602)
When the Node class is being constructed, an initial environment is passed in with the initial settings for the node. Once the plugin servicie is initialized, the final Environment+Settings are created, at which point the initial environment should no longer be used. This commit renames the constructor arg to avoid naming clashes with the final environment variable.
This commit is contained in:
parent
8c295cdc87
commit
5fba8cbc7b
|
@ -264,21 +264,21 @@ public class Node implements Closeable {
|
||||||
/**
|
/**
|
||||||
* Constructs a node
|
* Constructs a node
|
||||||
*
|
*
|
||||||
* @param environment the environment for this node
|
* @param initialEnvironment the initial environment for this node, which will be added to by plugins
|
||||||
* @param classpathPlugins the plugins to be loaded from the classpath
|
* @param classpathPlugins the plugins to be loaded from the classpath
|
||||||
* @param forbidPrivateIndexSettings whether or not private index settings are forbidden when creating an index; this is used in the
|
* @param forbidPrivateIndexSettings whether or not private index settings are forbidden when creating an index; this is used in the
|
||||||
* test framework for tests that rely on being able to set private settings
|
* test framework for tests that rely on being able to set private settings
|
||||||
*/
|
*/
|
||||||
protected Node(
|
protected Node(final Environment initialEnvironment,
|
||||||
final Environment environment, Collection<Class<? extends Plugin>> classpathPlugins, boolean forbidPrivateIndexSettings) {
|
Collection<Class<? extends Plugin>> classpathPlugins, boolean forbidPrivateIndexSettings) {
|
||||||
logger = LogManager.getLogger(Node.class);
|
logger = LogManager.getLogger(Node.class);
|
||||||
final List<Closeable> resourcesToClose = new ArrayList<>(); // register everything we need to release in the case of an error
|
final List<Closeable> resourcesToClose = new ArrayList<>(); // register everything we need to release in the case of an error
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
Settings tmpSettings = Settings.builder().put(environment.settings())
|
Settings tmpSettings = Settings.builder().put(initialEnvironment.settings())
|
||||||
.put(Client.CLIENT_TYPE_SETTING_S.getKey(), CLIENT_TYPE).build();
|
.put(Client.CLIENT_TYPE_SETTING_S.getKey(), CLIENT_TYPE).build();
|
||||||
|
|
||||||
nodeEnvironment = new NodeEnvironment(tmpSettings, environment);
|
nodeEnvironment = new NodeEnvironment(tmpSettings, initialEnvironment);
|
||||||
resourcesToClose.add(nodeEnvironment);
|
resourcesToClose.add(nodeEnvironment);
|
||||||
logger.info("node name [{}], node ID [{}], cluster name [{}]",
|
logger.info("node name [{}], node ID [{}], cluster name [{}]",
|
||||||
NODE_NAME_SETTING.get(tmpSettings), nodeEnvironment.nodeId(),
|
NODE_NAME_SETTING.get(tmpSettings), nodeEnvironment.nodeId(),
|
||||||
|
@ -310,11 +310,12 @@ public class Node implements Closeable {
|
||||||
|
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("using config [{}], data [{}], logs [{}], plugins [{}]",
|
logger.debug("using config [{}], data [{}], logs [{}], plugins [{}]",
|
||||||
environment.configFile(), Arrays.toString(environment.dataFiles()), environment.logsFile(), environment.pluginsFile());
|
initialEnvironment.configFile(), Arrays.toString(initialEnvironment.dataFiles()),
|
||||||
|
initialEnvironment.logsFile(), initialEnvironment.pluginsFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.pluginsService = new PluginsService(tmpSettings, environment.configFile(), environment.modulesFile(),
|
this.pluginsService = new PluginsService(tmpSettings, initialEnvironment.configFile(), initialEnvironment.modulesFile(),
|
||||||
environment.pluginsFile(), classpathPlugins);
|
initialEnvironment.pluginsFile(), classpathPlugins);
|
||||||
final Settings settings = pluginsService.updatedSettings();
|
final Settings settings = pluginsService.updatedSettings();
|
||||||
final Set<DiscoveryNodeRole> possibleRoles = Stream.concat(
|
final Set<DiscoveryNodeRole> possibleRoles = Stream.concat(
|
||||||
DiscoveryNodeRole.BUILT_IN_ROLES.stream(),
|
DiscoveryNodeRole.BUILT_IN_ROLES.stream(),
|
||||||
|
@ -328,8 +329,8 @@ public class Node implements Closeable {
|
||||||
|
|
||||||
// create the environment based on the finalized (processed) view of the settings
|
// create the environment based on the finalized (processed) view of the settings
|
||||||
// this is just to makes sure that people get the same settings, no matter where they ask them from
|
// this is just to makes sure that people get the same settings, no matter where they ask them from
|
||||||
this.environment = new Environment(settings, environment.configFile());
|
this.environment = new Environment(settings, initialEnvironment.configFile());
|
||||||
Environment.assertEquivalent(environment, this.environment);
|
Environment.assertEquivalent(initialEnvironment, this.environment);
|
||||||
|
|
||||||
final List<ExecutorBuilder<?>> executorBuilders = pluginsService.getExecutorBuilders(settings);
|
final List<ExecutorBuilder<?>> executorBuilders = pluginsService.getExecutorBuilders(settings);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue