Source:
public Result compute( DefaultMetadata oldMetadata, boolean tokenMapEnabled, InternalDriverContext context) { String logPrefix = context.getSessionName(); TokenFactoryRegistry tokenFactoryRegistry = context.getTokenFactoryRegistry(); assert oldMetadata.getNodes().isEmpty(); TokenFactory tokenFactory = oldMetadata.getTokenMap().map(m -> ((DefaultTokenMap) m).getTokenFactory()).orElse(null); boolean tokensChanged = false; ImmutableMap.Builder<UUID, DefaultNode> newNodesBuilder = ImmutableMap.builder(); String clusterName = null; for (NodeInfo nodeInfo : nodeInfos) { if (clusterName == null) { clusterName = nodeInfo.getClusterName(); } EndPoint endPoint = nodeInfo.getEndPoint(); DefaultNode node = findIn(contactPoints, endPoint); if (node == null) { node = new DefaultNode(endPoint, context); LOG.debug("[{}] Adding new node {}", logPrefix, node); } else { LOG.debug("[{}] Copying contact point {}", logPrefix, node); } if (tokenFactory == null && nodeInfo.getPartitioner() != null) { tokenFactory = tokenFactoryRegistry.tokenFactoryFor(nodeInfo.getPartitioner()); } tokensChanged |= copyInfos(nodeInfo, node, tokenFactory, context); newNodesBuilder.put(node.getHostId(), node); } ImmutableMap<UUID, DefaultNode> newNodes = newNodesBuilder.build(); ImmutableList.Builder<Object> eventsBuilder = ImmutableList.builder(); for (DefaultNode newNode : newNodes.values()) { if (findIn(contactPoints, newNode.getEndPoint()) == null) { eventsBuilder.add(NodeStateEvent.added(newNode)); } } for (DefaultNode contactPoint : contactPoints) { if (findIn(newNodes.values(), contactPoint.getEndPoint()) == null) { eventsBuilder.add(NodeStateEvent.removed(contactPoint)); } } return new Result( oldMetadata.withNodesAndClusterName( ImmutableMap.copyOf(newNodes), tokenMapEnabled, tokensChanged, tokenFactory, context, clusterName), eventsBuilder.build()); }

Target:
public Result compute( DefaultMetadata oldMetadata, boolean tokenMapEnabled, InternalDriverContext context) { String logPrefix = context.getSessionName(); TokenFactoryRegistry tokenFactoryRegistry = context.getTokenFactoryRegistry(); assert oldMetadata.getNodes().isEmpty(); TokenFactory tokenFactory = oldMetadata.getTokenMap().map(m -> ((DefaultTokenMap) m).getTokenFactory()).orElse(null); boolean tokensChanged = false; ImmutableMap.Builder<UUID, DefaultNode> newNodesBuilder = ImmutableMap.builder(); for (NodeInfo nodeInfo : nodeInfos) { EndPoint endPoint = nodeInfo.getEndPoint(); DefaultNode node = findIn(contactPoints, endPoint); if (node == null) { node = new DefaultNode(endPoint, context); LOG.debug("[{}] Adding new node {}", logPrefix, node); } else { LOG.debug("[{}] Copying contact point {}", logPrefix, node); } if (tokenFactory == null && nodeInfo.getPartitioner() != null) { tokenFactory = tokenFactoryRegistry.tokenFactoryFor(nodeInfo.getPartitioner()); } tokensChanged |= copyInfos(nodeInfo, node, tokenFactory, context); newNodesBuilder.put(node.getHostId(), node); } ImmutableMap<UUID, DefaultNode> newNodes = newNodesBuilder.build(); ImmutableList.Builder<Object> eventsBuilder = ImmutableList.builder(); for (DefaultNode newNode : newNodes.values()) { if (findIn(contactPoints, newNode.getEndPoint()) == null) { eventsBuilder.add(NodeStateEvent.added(newNode)); } } for (DefaultNode contactPoint : contactPoints) { if (findIn(newNodes.values(), contactPoint.getEndPoint()) == null) { eventsBuilder.add(NodeStateEvent.removed(contactPoint)); } } return new Result( oldMetadata.withNodes( ImmutableMap.copyOf(newNodes), tokenMapEnabled, tokensChanged, tokenFactory, context), eventsBuilder.build()); }