Skip to content

Commit e148cc4

Browse files
committed
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 5c46a61 commit e148cc4

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
@@ -244,7 +244,6 @@ public abstract class Node implements Closeable {
244244
private final Logger logger;
245245
private final Injector injector;
246246
private final Settings settings;
247-
private final Settings originalSettings;
248247
private final Environment environment;
249248
private final NodeEnvironment nodeEnvironment;
250249
private final PluginsService pluginsService;
@@ -280,7 +279,6 @@ protected Node(
280279
final List<Closeable> resourcesToClose = new ArrayList<>(); // register everything we need to release in the case of an error
281280
boolean success = false;
282281
try {
283-
originalSettings = environment.settings();
284282
Settings tmpSettings = Settings.builder().put(environment.settings())
285283
.put(Client.CLIENT_TYPE_SETTING_S.getKey(), CLIENT_TYPE).build();
286284

@@ -652,13 +650,6 @@ protected void processRecoverySettings(ClusterSettings clusterSettings, Recovery
652650
// Noop in production, overridden by tests
653651
}
654652

655-
/**
656-
* The original settings that were used to create the node
657-
*/
658-
public Settings originalSettings() {
659-
return originalSettings;
660-
}
661-
662653
/**
663654
* The settings that are used by this node. Contains original settings as well as additional settings provided by plugins.
664655
*/

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

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

681682
private String buildNodeName(int id, Settings settings) {
@@ -841,15 +842,17 @@ public synchronized void close() {
841842

842843
private final class NodeAndClient implements Closeable {
843844
private MockNode node;
845+
private final Settings originalNodeSettings;
844846
private Client nodeClient;
845847
private Client transportClient;
846848
private final AtomicBoolean closed = new AtomicBoolean(false);
847849
private final String name;
848850
private final int nodeAndClientId;
849851

850-
NodeAndClient(String name, MockNode node, int nodeAndClientId) {
852+
NodeAndClient(String name, MockNode node, Settings originalNodeSettings, int nodeAndClientId) {
851853
this.node = node;
852854
this.name = name;
855+
this.originalNodeSettings = originalNodeSettings;
853856
this.nodeAndClientId = nodeAndClientId;
854857
markNodeDataDirsAsNotEligableForWipe(node);
855858
}
@@ -975,7 +978,7 @@ private void recreateNode(final Settings newSettings, final Runnable onTransport
975978
// use a new seed to make sure we have new node id
976979
final long newIdSeed = NodeEnvironment.NODE_ID_SEED_SETTING.get(node.settings()) + 1;
977980
Settings finalSettings = Settings.builder()
978-
.put(node.originalSettings())
981+
.put(originalNodeSettings)
979982
.put(newSettings)
980983
.put(NodeEnvironment.NODE_ID_SEED_SETTING.getKey(), newIdSeed)
981984
.build();

0 commit comments

Comments
 (0)