Skip to content

Commit

Permalink
Always write unicast hosts file in tests (elastic#118121)
Browse files Browse the repository at this point in the history
This commit adds the ability to restart a node within a test cluster.
The newly started node uses the same configuration and directories.
Since we use ephemeral ports, the unicast hosts list is rewritten for
all nodes once the restarted node comes back up.
  • Loading branch information
rjernst committed Dec 7, 2024
1 parent a0c27ab commit 002bf5d
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ public long getPid(int index) {
return nodes.get(index).getPid();
}

@Override
public void stopNode(int index, boolean forcibly) {
nodes.get(index).stop(false);
nodes.get(index).stop(forcibly);
}

@Override
Expand Down Expand Up @@ -252,9 +253,8 @@ private void writeUnicastHostsFile() {
execute(() -> nodes.parallelStream().forEach(node -> {
try {
Path hostsFile = node.getWorkingDir().resolve("config").resolve("unicast_hosts.txt");
if (Files.notExists(hostsFile)) {
Files.writeString(hostsFile, transportUris);
}
LOGGER.info("Writing unicast hosts file {} for node {}", hostsFile, node.getName());
Files.writeString(hostsFile, transportUris);
} catch (IOException e) {
throw new UncheckedIOException("Failed to write unicast_hosts for: " + node, e);
}
Expand Down

0 comments on commit 002bf5d

Please sign in to comment.