Skip to content

Commit 2052e0c

Browse files
CR: only compute unicast hosts txt once
1 parent a3b9e55 commit 2052e0c

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,8 @@ class ClusterFormationTasks {
351351
// Don't force discovery provider if one is set by the test cluster specs already
352352
if (esConfig.containsKey('discovery.zen.hosts_provider') == false) {
353353
esConfig['discovery.zen.hosts_provider'] = 'file'
354-
esConfig['discovery.zen.ping.unicast.hosts'] = []
355354
}
355+
esConfig['discovery.zen.ping.unicast.hosts'] = []
356356
} else {
357357
String unicastTransportUri = node.config.unicastTransportUri(seedNode, node, project.ant)
358358
if (unicastTransportUri == null) {
@@ -692,17 +692,16 @@ class ClusterFormationTasks {
692692
Task wait = project.tasks.create(name: name, dependsOn: startTasks)
693693
wait.doLast {
694694

695-
nodes.forEach { node ->
696-
Collection<String> unicastHosts = new HashSet<>()
697-
nodes.forEach { otherNode ->
698-
String unicastHost = node.config.unicastTransportUri(otherNode, node, project.ant)
699-
if (unicastHost != null) {
700-
unicastHosts.addAll(Arrays.asList(unicastHost.split(",")))
701-
}
695+
Collection<String> unicastHosts = new HashSet<>()
696+
nodes.forEach { otherNode ->
697+
String unicastHost = otherNode.config.unicastTransportUri(otherNode, null, project.ant)
698+
if (unicastHost != null) {
699+
unicastHosts.addAll(Arrays.asList(unicastHost.split(",")))
702700
}
703-
node.pathConf.toPath().resolve("unicast_hosts.txt").setText(
704-
String.join("\n", unicastHosts)
705-
)
701+
}
702+
String unicastHostsTxt = String.join("\n", unicastHosts)
703+
nodes.forEach { node ->
704+
node.pathConf.toPath().resolve("unicast_hosts.txt").setText(unicastHostsTxt)
706705
}
707706

708707
ant.waitfor(maxwait: "${waitSeconds}", maxwaitunit: 'second', checkevery: '500', checkeveryunit: 'millisecond', timeoutproperty: "failed${name}") {

0 commit comments

Comments
 (0)