diff --git a/docs/services/emr.md b/docs/services/emr.md index 0cddaa136f..007e6ee6f7 100644 --- a/docs/services/emr.md +++ b/docs/services/emr.md @@ -871,7 +871,9 @@ holding the driver and its executors, or a command or a script. The cluster itse The image's own catalogs go, as EMR's Trino has those the cluster configures. `trino-node`'s and `trino-log`'s properties go into the image's own `node.properties` and `log.properties`, after its lines, a property given twice taking the later, so an image of `trino.image`'s keeps its settings where the cluster gives none, and Floci names the - node, with hyphens for the host name's dots, only where neither gives it an id; and the variables `trino-env`'s nested + node, with hyphens for the host name's dots, only where neither gives it an id; a `node.id` of `trino-node`'s is the + coordinator's alone, as Trino needs it "unique for every node", each worker named after its node's host; and the + variables `trino-env`'s nested `export` gives, as "If any classification ends in env, use the export sub-classification", are Trino's environment, which a catalog reads as `${ENV:NAME}` where its connector takes Trino's configuration, as Iceberg's and the memory connector's do, after Floci's own AWS settings, which they may change. `trino-exchange-manager`, which on EMR diff --git a/src/main/java/io/floci/aws/services/emr/EmrTrino.java b/src/main/java/io/floci/aws/services/emr/EmrTrino.java index e33cc239af..b1b578232b 100644 --- a/src/main/java/io/floci/aws/services/emr/EmrTrino.java +++ b/src/main/java/io/floci/aws/services/emr/EmrTrino.java @@ -112,6 +112,8 @@ final class EmrTrino { * other with, which Trino needs with authentication on and every node shares. */ static final String SHARED_SECRET = "internal-communication.shared-secret"; + /** The property of Trino's {@code node.properties} that names a node, which must be every node's own. */ + static final String NODE_ID = "node.id"; /** The prefix of the variables it writes its catalogs from, one each, the rest of whose name names it. */ static final String CATALOG_PREFIX = "FLOCI_TRINO_CATALOG_"; /** @@ -251,12 +253,15 @@ final class EmrTrino { /** * A worker's {@code node.properties} additions: the address the other nodes reach it at, its node's * {@code host}, which Trino would otherwise pick from the node's addresses, link-local ones and those of other - * networks among them; then the cluster's {@code trino-node}, each in its place. + * networks among them; then the cluster's {@code trino-node}, each in its place, but a {@code node.id}, which Trino + * needs "unique for every node": that one is the coordinator's, and the entrypoint names a worker after its + * node's host, as it does a node given no id. */ static Map workerNode(Map classification, String host) { Map node = new LinkedHashMap<>(); node.put("node.internal-address", host); node.putAll(classification); + node.remove(NODE_ID); return node; } diff --git a/src/test/java/io/floci/aws/services/emr/EmrTrinoTest.java b/src/test/java/io/floci/aws/services/emr/EmrTrinoTest.java index 1f685507c9..714c668d3b 100644 --- a/src/test/java/io/floci/aws/services/emr/EmrTrinoTest.java +++ b/src/test/java/io/floci/aws/services/emr/EmrTrinoTest.java @@ -198,6 +198,18 @@ class EmrTrinoTest { "ip-10-0-0-2.ec2.internal")).split("\n"))); } + @Test + void aNodeIdTheClusterGivesIsTheCoordinatorsAloneAsTrinoNeedsEveryNodesOwn() { + Map classification = new LinkedHashMap<>(); + classification.put("node.id", "coordinator-1"); + classification.put("node.environment", "production"); + + // Each worker is then named after its node's host by the entrypoint, as a node given no id is. + assertEquals(List.of("node.internal-address=ip-10-0-0-2.ec2.internal", "node.environment=production"), + List.of(EmrTrino.properties(EmrTrino.workerNode(classification, "ip-10-0-0-2.ec2.internal")) + .split("\n"))); + } + @Test void aWorkersCatalogsReachTheMetastoreOnThePrimaryNode() { assertEquals("thrift://ip-10-0-0-1.ec2.internal:9083",