Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,13 @@ public void setJavaHome(File javaHome) {

@Override
public void start() {
commonNodeConfig();
nodes.forEach(ElasticsearchNode::start);
}

private void commonNodeConfig() {
final String nodeNames;
if (nodes.stream().map(ElasticsearchNode::getName).anyMatch( name -> name == null)) {
if (nodes.stream().map(ElasticsearchNode::getName).anyMatch(name -> name == null)) {
nodeNames = null;
} else {
nodeNames = nodes.stream().map(ElasticsearchNode::getName).map(this::safeName).collect(Collectors.joining(","));
Expand All @@ -259,6 +264,10 @@ public void start() {
// Can only configure master nodes if we have node names defined
if (nodeNames != null) {
if (node.getVersion().onOrAfter("7.0.0")) {
node.defaultConfig.keySet().stream()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure that, with the exception of initial_master_nodes all this can, and probably should, go in ElasticsearchNode#start().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically yes, but these are settings relating to how the cluster forms that relate to each-other,
so the settings are per node, but relate to the cluster itself.
Granted we could pull other such settings up to the cluster level.
I agree on your points on refactoring but would like to complete the back-port first.

.filter(name -> name.startsWith("discovery.zen."))
.collect(Collectors.toList())
.forEach(node.defaultConfig::remove);
node.defaultConfig.put("cluster.initial_master_nodes", "[" + nodeNames + "]");
node.defaultConfig.put("discovery.seed_providers", "file");
node.defaultConfig.put("discovery.seed_hosts", "[]");
Expand All @@ -280,7 +289,6 @@ public void start() {
}
}
}
node.start();
if (firstNode == null) {
firstNode = node;
}
Expand All @@ -292,17 +300,23 @@ public void restart() {
nodes.forEach(ElasticsearchNode::restart);
}

@Override
public void goToNextVersion() {
stop(false);
nodes.all(ElasticsearchNode::goToNextVersion);
start();
writeUnicastHostsFiles();
}

public void nextNodeToNextVersion() {
if (nodeIndex + 1 > nodes.size()) {
throw new TestClustersException("Ran out of nodes to take to the next version");
}
nodes.getByName(clusterName + "-" + nodeIndex).goToNextVersion();
ElasticsearchNode node = nodes.getByName(clusterName + "-" + nodeIndex);
node.stop(false);
node.goToNextVersion();
commonNodeConfig();
nodeIndex += 1;
node.start();
}

@Override
Expand Down Expand Up @@ -356,9 +370,6 @@ public List<String> getAllTransportPortURI() {
}

public void waitForAllConditions() {
LOGGER.info("Waiting for nodes");
nodes.forEach(ElasticsearchNode::waitForAllConditions);

writeUnicastHostsFiles();

LOGGER.info("Starting to wait for cluster to form");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,16 +490,13 @@ public void restart() {
start();
}

@Override
public void goToNextVersion() {
void goToNextVersion() {
if (currentDistro + 1 >= distributions.size()) {
throw new TestClustersException("Ran out of versions to go to for " + this);
}
logToProcessStdout("Switch version from " + getVersion() + " to " + distributions.get(currentDistro + 1).getVersion());
stop(false);
currentDistro += 1;
setting("node.attr.upgraded", "true");
start();
}

private boolean isSettingTrue(String name) {
Expand Down Expand Up @@ -717,11 +714,13 @@ public String getTransportPortURI() {

@Override
public List<String> getAllHttpSocketURI() {
waitForAllConditions();
return getHttpPortInternal();
}

@Override
public List<String> getAllTransportPortURI() {
waitForAllConditions();
return getTransportPortInternal();
}

Expand Down Expand Up @@ -760,6 +759,17 @@ public synchronized void stop(boolean tailLogs) {
logFileContents("Standard error of node", esStderrFile);
}
esProcess = null;
// Clean up the ports file in case this is started again.
try {
if (Files.exists(httpPortsFile)) {
Files.delete(httpPortsFile);
}
if (Files.exists(transportPortFile)) {
Files.delete(transportPortFile);
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ public interface TestClusterConfiguration {

void restart();

void goToNextVersion();

void extraConfigFile(String destination, File from);

void extraConfigFile(String destination, File from, PropertyNormalization normalization);
Expand Down