Skip to content

Commit

Permalink
Internal: Remove originalSettings from Node (#36569)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rjernst committed Dec 18, 2018
1 parent 32ce124 commit 8ec8342
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
9 changes: 0 additions & 9 deletions server/src/main/java/org/elasticsearch/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ public class Node implements Closeable {
private final Logger logger;
private final Injector injector;
private final Settings settings;
private final Settings originalSettings;
private final Environment environment;
private final NodeEnvironment nodeEnvironment;
private final PluginsService pluginsService;
Expand All @@ -265,7 +264,6 @@ protected Node(
final List<Closeable> resourcesToClose = new ArrayList<>(); // register everything we need to release in the case of an error
boolean success = false;
try {
originalSettings = environment.settings();
Settings tmpSettings = Settings.builder().put(environment.settings())
.put(Client.CLIENT_TYPE_SETTING_S.getKey(), CLIENT_TYPE).build();

Expand Down Expand Up @@ -595,13 +593,6 @@ protected void processRecoverySettings(ClusterSettings clusterSettings, Recovery
// Noop in production, overridden by tests
}

/**
* The original settings that were used to create the node
*/
public Settings originalSettings() {
return originalSettings;
}

/**
* The settings that are used by this node. Contains original settings as well as additional settings provided by plugins.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,9 @@ private NodeAndClient buildNode(int nodeId, long seed, Settings settings,
// we clone this here since in the case of a node restart we might need it again
secureSettings = ((MockSecureSettings) secureSettings).clone();
}
final Settings nodeSettings = finalSettings.build();
MockNode node = new MockNode(
finalSettings.build(),
nodeSettings,
plugins,
nodeConfigurationSource.nodeConfigPath(nodeId),
forbidPrivateIndexSettings);
Expand All @@ -676,7 +677,7 @@ public void afterStart() {
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return new NodeAndClient(name, node, nodeId);
return new NodeAndClient(name, node, nodeSettings, nodeId);
}

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

private final class NodeAndClient implements Closeable {
private MockNode node;
private final Settings originalNodeSettings;
private Client nodeClient;
private Client transportClient;
private final AtomicBoolean closed = new AtomicBoolean(false);
private final String name;
private final int nodeAndClientId;

NodeAndClient(String name, MockNode node, int nodeAndClientId) {
NodeAndClient(String name, MockNode node, Settings originalNodeSettings, int nodeAndClientId) {
this.node = node;
this.name = name;
this.originalNodeSettings = originalNodeSettings;
this.nodeAndClientId = nodeAndClientId;
markNodeDataDirsAsNotEligableForWipe(node);
}
Expand Down Expand Up @@ -954,7 +957,7 @@ private void recreateNode(final Settings newSettings, final Runnable onTransport
// use a new seed to make sure we have new node id
final long newIdSeed = NodeEnvironment.NODE_ID_SEED_SETTING.get(node.settings()) + 1;
Settings finalSettings = Settings.builder()
.put(node.originalSettings())
.put(originalNodeSettings)
.put(newSettings)
.put(NodeEnvironment.NODE_ID_SEED_SETTING.getKey(), newIdSeed)
.build();
Expand Down

0 comments on commit 8ec8342

Please sign in to comment.