mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
Remove settings members from Node (#40811)
This commit removes the settings member variable from Node. This member made it confusing which settings should actually be looked at. Now all settings are accessed through the final environment.
This commit is contained in:
parent
b522de975d
commit
5cdd87deb7
@ -238,7 +238,6 @@ public class Node implements Closeable {
|
|||||||
*/
|
*/
|
||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
private final Injector injector;
|
private final Injector injector;
|
||||||
private final Settings settings;
|
|
||||||
private final Environment environment;
|
private final Environment environment;
|
||||||
private final NodeEnvironment nodeEnvironment;
|
private final NodeEnvironment nodeEnvironment;
|
||||||
private final PluginsService pluginsService;
|
private final PluginsService pluginsService;
|
||||||
@ -304,12 +303,12 @@ public class Node implements Closeable {
|
|||||||
|
|
||||||
this.pluginsService = new PluginsService(tmpSettings, environment.configFile(), environment.modulesFile(),
|
this.pluginsService = new PluginsService(tmpSettings, environment.configFile(), environment.modulesFile(),
|
||||||
environment.pluginsFile(), classpathPlugins);
|
environment.pluginsFile(), classpathPlugins);
|
||||||
this.settings = pluginsService.updatedSettings();
|
final Settings settings = pluginsService.updatedSettings();
|
||||||
localNodeFactory = new LocalNodeFactory(settings, nodeEnvironment.nodeId());
|
localNodeFactory = new LocalNodeFactory(settings, nodeEnvironment.nodeId());
|
||||||
|
|
||||||
// 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(this.settings, environment.configFile());
|
this.environment = new Environment(settings, environment.configFile());
|
||||||
Environment.assertEquivalent(environment, this.environment);
|
Environment.assertEquivalent(environment, this.environment);
|
||||||
|
|
||||||
final List<ExecutorBuilder<?>> executorBuilders = pluginsService.getExecutorBuilders(settings);
|
final List<ExecutorBuilder<?>> executorBuilders = pluginsService.getExecutorBuilders(settings);
|
||||||
@ -339,7 +338,7 @@ public class Node implements Closeable {
|
|||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
final SettingsModule settingsModule =
|
final SettingsModule settingsModule =
|
||||||
new SettingsModule(this.settings, additionalSettings, additionalSettingsFilter, settingsUpgraders);
|
new SettingsModule(settings, additionalSettings, additionalSettingsFilter, settingsUpgraders);
|
||||||
scriptModule.registerClusterSettingsListeners(settingsModule.getClusterSettings());
|
scriptModule.registerClusterSettingsListeners(settingsModule.getClusterSettings());
|
||||||
resourcesToClose.add(resourceWatcherService);
|
resourcesToClose.add(resourceWatcherService);
|
||||||
final NetworkService networkService = new NetworkService(
|
final NetworkService networkService = new NetworkService(
|
||||||
@ -481,7 +480,7 @@ public class Node implements Closeable {
|
|||||||
modules.add(new RepositoriesModule(this.environment, pluginsService.filterPlugins(RepositoryPlugin.class), transportService,
|
modules.add(new RepositoriesModule(this.environment, pluginsService.filterPlugins(RepositoryPlugin.class), transportService,
|
||||||
clusterService, threadPool, xContentRegistry));
|
clusterService, threadPool, xContentRegistry));
|
||||||
|
|
||||||
final DiscoveryModule discoveryModule = new DiscoveryModule(this.settings, threadPool, transportService, namedWriteableRegistry,
|
final DiscoveryModule discoveryModule = new DiscoveryModule(settings, threadPool, transportService, namedWriteableRegistry,
|
||||||
networkService, clusterService.getMasterService(), clusterService.getClusterApplierService(),
|
networkService, clusterService.getMasterService(), clusterService.getClusterApplierService(),
|
||||||
clusterService.getClusterSettings(), pluginsService.filterPlugins(DiscoveryPlugin.class),
|
clusterService.getClusterSettings(), pluginsService.filterPlugins(DiscoveryPlugin.class),
|
||||||
clusterModule.getAllocationService(), environment.configFile(), gatewayMetaState);
|
clusterModule.getAllocationService(), environment.configFile(), gatewayMetaState);
|
||||||
@ -600,7 +599,7 @@ public class Node implements Closeable {
|
|||||||
* The settings that are used by this node. Contains original settings as well as additional settings provided by plugins.
|
* The settings that are used by this node. Contains original settings as well as additional settings provided by plugins.
|
||||||
*/
|
*/
|
||||||
public Settings settings() {
|
public Settings settings() {
|
||||||
return this.settings;
|
return this.environment.settings();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -666,7 +665,7 @@ public class Node implements Closeable {
|
|||||||
final MetaData onDiskMetadata;
|
final MetaData onDiskMetadata;
|
||||||
// we load the global state here (the persistent part of the cluster state stored on disk) to
|
// we load the global state here (the persistent part of the cluster state stored on disk) to
|
||||||
// pass it to the bootstrap checks to allow plugins to enforce certain preconditions based on the recovered state.
|
// pass it to the bootstrap checks to allow plugins to enforce certain preconditions based on the recovered state.
|
||||||
if (DiscoveryNode.isMasterNode(settings) || DiscoveryNode.isDataNode(settings)) {
|
if (DiscoveryNode.isMasterNode(settings()) || DiscoveryNode.isDataNode(settings())) {
|
||||||
onDiskMetadata = injector.getInstance(GatewayMetaState.class).getMetaData();
|
onDiskMetadata = injector.getInstance(GatewayMetaState.class).getMetaData();
|
||||||
} else {
|
} else {
|
||||||
onDiskMetadata = MetaData.EMPTY_META_DATA;
|
onDiskMetadata = MetaData.EMPTY_META_DATA;
|
||||||
@ -684,7 +683,7 @@ public class Node implements Closeable {
|
|||||||
: "clusterService has a different local node than the factory provided";
|
: "clusterService has a different local node than the factory provided";
|
||||||
transportService.acceptIncomingRequests();
|
transportService.acceptIncomingRequests();
|
||||||
discovery.startInitialJoin();
|
discovery.startInitialJoin();
|
||||||
final TimeValue initialStateTimeout = DiscoverySettings.INITIAL_STATE_TIMEOUT_SETTING.get(settings);
|
final TimeValue initialStateTimeout = DiscoverySettings.INITIAL_STATE_TIMEOUT_SETTING.get(settings());
|
||||||
configureNodeAndClusterIdStateListener(clusterService);
|
configureNodeAndClusterIdStateListener(clusterService);
|
||||||
|
|
||||||
if (initialStateTimeout.millis() > 0) {
|
if (initialStateTimeout.millis() > 0) {
|
||||||
@ -723,7 +722,7 @@ public class Node implements Closeable {
|
|||||||
|
|
||||||
injector.getInstance(HttpServerTransport.class).start();
|
injector.getInstance(HttpServerTransport.class).start();
|
||||||
|
|
||||||
if (WRITE_PORTS_FILE_SETTING.get(settings)) {
|
if (WRITE_PORTS_FILE_SETTING.get(settings())) {
|
||||||
TransportService transport = injector.getInstance(TransportService.class);
|
TransportService transport = injector.getInstance(TransportService.class);
|
||||||
writePortsFile("transport", transport.boundAddress());
|
writePortsFile("transport", transport.boundAddress());
|
||||||
HttpServerTransport http = injector.getInstance(HttpServerTransport.class);
|
HttpServerTransport http = injector.getInstance(HttpServerTransport.class);
|
||||||
@ -961,7 +960,7 @@ public class Node implements Closeable {
|
|||||||
private List<NetworkService.CustomNameResolver> getCustomNameResolvers(List<DiscoveryPlugin> discoveryPlugins) {
|
private List<NetworkService.CustomNameResolver> getCustomNameResolvers(List<DiscoveryPlugin> discoveryPlugins) {
|
||||||
List<NetworkService.CustomNameResolver> customNameResolvers = new ArrayList<>();
|
List<NetworkService.CustomNameResolver> customNameResolvers = new ArrayList<>();
|
||||||
for (DiscoveryPlugin discoveryPlugin : discoveryPlugins) {
|
for (DiscoveryPlugin discoveryPlugin : discoveryPlugins) {
|
||||||
NetworkService.CustomNameResolver customNameResolver = discoveryPlugin.getCustomNameResolver(settings);
|
NetworkService.CustomNameResolver customNameResolver = discoveryPlugin.getCustomNameResolver(settings());
|
||||||
if (customNameResolver != null) {
|
if (customNameResolver != null) {
|
||||||
customNameResolvers.add(customNameResolver);
|
customNameResolvers.add(customNameResolver);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user