abstractdog commented on code in PR #543:
URL: https://github.com/apache/tez/pull/543#discussion_r4512096709
##########
tez-dag/src/main/java/org/apache/tez/dag/api/client/registry/zookeeper/ZkAMRegistry.java:
##########
@@ -95,23 +97,27 @@ public void close() {
//zkNode at the path: <TEZ_AM_REGISTRY_NAMESPACE>/<appId>
@Override
public void add(AMRecord server) throws Exception {
- String json = AMRegistryUtils.recordToJsonString(server);
- try {
- final String path = pathFor(server);
- client.setData().forPath(path, json.getBytes(StandardCharsets.UTF_8));
- LOG.info("Added AMRecord to zkpath {}", path);
- } catch (KeeperException.NoNodeException nne) {
-
client.create().creatingParentContainersIfNeeded().withMode(CreateMode.EPHEMERAL)
- .forPath(pathFor(server), json.getBytes(StandardCharsets.UTF_8));
+ // PersistentNode re-creates the ephemeral node after a session loss or a
delete; a plain create would leave
+ // the AM running but unregistered.
+ final String path = pathFor(server);
+ byte[] json =
AMRegistryUtils.recordToJsonString(server).getBytes(StandardCharsets.UTF_8);
+ PersistentNode node = new PersistentNode(client, CreateMode.EPHEMERAL,
false, path, json);
+ node.start();
+ if (!node.waitForInitialCreate(zkConfig.getConnectionTimeoutMs(),
TimeUnit.MILLISECONDS)) {
Review Comment:
`add()` used to be bounded by the client's retry policy
(`tez.am.curator.max-retries`/`backoff-sleep`), and now waits a single
`getConnectionTimeoutMs()`. The setting still applies to `generateNewId()` and
to PersistentNode's background creates, so it isn't dead, but someone tuning
`max-retries` might expect registration to wait longer. Scaling the wait by
`getCuratorMaxRetries()` would only make that setting mean something it
doesn't, so I'd keep the single timeout and add a comment saying `add()` waits
one connection timeout for the initial create and is not governed by the retry
settings.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]