Skip to content

Commit 8ec8342

Browse files
authored
Internal: Remove originalSettings from Node (#36569)
This commit removes the originalSettings member from Node. It was only needed to allows test clusters to recreate the node in certain situations. Instead, the test cluster now keeps track of these settings.
1 parent 32ce124 commit 8ec8342

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

server/src/main/java/org/elasticsearch/node/Node.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ public class Node implements Closeable {
238238
private final Logger logger;
239239
private final Injector injector;
240240
private final Settings settings;
241-
private final Settings originalSettings;
242241
private final Environment environment;
243242
private final NodeEnvironment nodeEnvironment;
244243
private final PluginsService pluginsService;
@@ -265,7 +264,6 @@ protected Node(
265264
final List<Closeable> resourcesToClose = new ArrayList<>(); // register everything we need to release in the case of an error
266265
boolean success = false;
267266
try {
268-
originalSettings = environment.settings();
269267
Settings tmpSettings = Settings.builder().put(environment.settings())
270268
.put(Client.CLIENT_TYPE_SETTING_S.getKey(), CLIENT_TYPE).build();
271269

@@ -595,13 +593,6 @@ protected void processRecoverySettings(ClusterSettings clusterSettings, Recovery
595593
// Noop in production, overridden by tests
596594
}
597595

598-
/**
599-
* The original settings that were used to create the node
600-
*/
601-
public Settings originalSettings() {
602-
return originalSettings;
603-
}
604-
605596
/**
606597
* The settings that are used by this node. Contains original settings as well as additional settings provided by plugins.
607598
*/

test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,9 @@ private NodeAndClient buildNode(int nodeId, long seed, Settings settings,
660660
// we clone this here since in the case of a node restart we might need it again
661661
secureSettings = ((MockSecureSettings) secureSettings).clone();
662662
}
663+
final Settings nodeSettings = finalSettings.build();
663664
MockNode node = new MockNode(
664-
finalSettings.build(),
665+
nodeSettings,
665666
plugins,
666667
nodeConfigurationSource.nodeConfigPath(nodeId),
667668
forbidPrivateIndexSettings);
@@ -676,7 +677,7 @@ public void afterStart() {
676677
} catch (IOException e) {
677678
throw new UncheckedIOException(e);
678679
}
679-
return new NodeAndClient(name, node, nodeId);
680+
return new NodeAndClient(name, node, nodeSettings, nodeId);
680681
}
681682

682683
private String buildNodeName(int id, Settings settings) {
@@ -820,15 +821,17 @@ public synchronized void close() {
820821

821822
private final class NodeAndClient implements Closeable {
822823
private MockNode node;
824+
private final Settings originalNodeSettings;
823825
private Client nodeClient;
824826
private Client transportClient;
825827
private final AtomicBoolean closed = new AtomicBoolean(false);
826828
private final String name;
827829
private final int nodeAndClientId;
828830

829-
NodeAndClient(String name, MockNode node, int nodeAndClientId) {
831+
NodeAndClient(String name, MockNode node, Settings originalNodeSettings, int nodeAndClientId) {
830832
this.node = node;
831833
this.name = name;
834+
this.originalNodeSettings = originalNodeSettings;
832835
this.nodeAndClientId = nodeAndClientId;
833836
markNodeDataDirsAsNotEligableForWipe(node);
834837
}
@@ -954,7 +957,7 @@ private void recreateNode(final Settings newSettings, final Runnable onTransport
954957
// use a new seed to make sure we have new node id
955958
final long newIdSeed = NodeEnvironment.NODE_ID_SEED_SETTING.get(node.settings()) + 1;
956959
Settings finalSettings = Settings.builder()
957-
.put(node.originalSettings())
960+
.put(originalNodeSettings)
958961
.put(newSettings)
959962
.put(NodeEnvironment.NODE_ID_SEED_SETTING.getKey(), newIdSeed)
960963
.build();

0 commit comments

Comments
 (0)