Use unique ID from node-repo
@@ -79,7 +79,7 @@ public class NodeAdminImpl implements NodeAdmin {
@Override
public void refreshContainersToRun(Set<NodeAgentContext> nodeAgentContexts) {
Map<String, NodeAgentContext> nodeAgentContextsByHostname = nodeAgentContexts.stream()
- .collect(Collectors.toMap(NodeAdminImpl::nodeAgentId, Function.identity()));
+ .collect(Collectors.toMap(ctx -> ctx.node().id(), Function.identity()));
// Stop and remove NodeAgents that should no longer be running
diff(nodeAgentWithSchedulerByHostname.keySet(), nodeAgentContextsByHostname.keySet())
@@ -222,14 +222,4 @@ public class NodeAdminImpl implements NodeAdmin {
NodeAgent nodeAgent = nodeAgentFactory.create(contextManager, context);
return new NodeAgentWithScheduler(nodeAgent, contextManager);
}
-
- private static String nodeAgentId(NodeAgentContext nac) {
- // NodeAgentImpl has some internal state that should not be reused when the same hostname is re-allocated
- // to a different application/cluster, solve this by including reservation timestamp in the key.
- return nac.hostname().value() + "-" + nac.node().events().stream()
- .filter(event -> "reserved".equals(event.type()))
- .findFirst()
- .map(event -> Long.toString(event.at().toEpochMilli()))
- .orElse("");
- }
}
