Source:
<code>public static AbstractTopology mutateRecoverTopology(AbstractTopology topology, Set<Integer> liveHosts, int localHostId, String placementGroup, Set<Integer> recoverPartitions) { Host replaceHost = null; for (Host h : topology.hostsById.values()) { if (liveHosts.contains(h.id) || !h.haGroup.equalsIgnoreCase(placementGroup)) { continue; } if (replaceHost == null) { replaceHost = h; } if (recoverPartitions != null && !recoverPartitions.isEmpty()) { Set<Integer> partitions = Sets.newHashSet(); partitions.addAll(h.getPartitionIdList()); <START> if (Sets.difference(partitions, recoverPartitions).isEmpty()) { <END> replaceHost = h; break; } } } if (replaceHost == null) { return null; } Integer replaceHostId = replaceHost.id; ImmutableMap.Builder<Integer, Partition> partitionsByIdBuilder = ImmutableMap.builder(); ArrayList<Integer> hostIds = new ArrayList<>(); for (Map.Entry<Integer, Partition> entry : topology.partitionsById.entrySet()) { Partition partition = entry.getValue(); boolean modified = false; for (Integer id : partition.hostIds) { if (id.equals(replaceHostId)) { modified = true; hostIds.add(localHostId); } else { hostIds.add(id); } } if (modified) { partition = new Partition(partition.id, replaceHostId.equals(partition.leaderHostId) ? localHostId : partition.leaderHostId, hostIds); } partitionsByIdBuilder.put(entry.getKey(), partition); hostIds.clear(); } ImmutableMap<Integer, Partition> partitionsById = partitionsByIdBuilder.build(); ImmutableMap.Builder<Integer, Host> hostsByIdBuilder = ImmutableMap.builder(); for (Map.Entry<Integer, Host> entry : topology.hostsById.entrySet()) { Integer id = entry.getKey().intValue() == replaceHostId ? localHostId : entry.getKey(); hostsByIdBuilder.put(id, new Host(entry.getValue(), id, partitionsById)); } return new AbstractTopology(topology, hostsByIdBuilder.build(), partitionsById); }</code><technical_language>partitions.equals(recoverPartitions)</technical_language>

Target:
public static AbstractTopology mutateRecoverTopology(AbstractTopology topology, Set<Integer> liveHosts, int localHostId, String placementGroup, Set<Integer> recoverPartitions) { Host replaceHost = null; for (Host h : topology.hostsById.values()) { if (liveHosts.contains(h.id) || !h.haGroup.equalsIgnoreCase(placementGroup)) { continue; } if (replaceHost == null) { replaceHost = h; } if (recoverPartitions != null && !recoverPartitions.isEmpty()) { if (h.getPartitionIdList().equals(recoverPartitions)) { replaceHost = h; break; } } } if (replaceHost == null) { return null; } Integer replaceHostId = replaceHost.id; ImmutableMap.Builder<Integer, Partition> partitionsByIdBuilder = ImmutableMap.builder(); ArrayList<Integer> hostIds = new ArrayList<>(); for (Map.Entry<Integer, Partition> entry : topology.partitionsById.entrySet()) { Partition partition = entry.getValue(); boolean modified = false; for (Integer id : partition.hostIds) { if (id.equals(replaceHostId)) { modified = true; hostIds.add(localHostId); } else { hostIds.add(id); } } if (modified) { partition = new Partition(partition.id, replaceHostId.equals(partition.leaderHostId) ? localHostId : partition.leaderHostId, hostIds); } partitionsByIdBuilder.put(entry.getKey(), partition); hostIds.clear(); } ImmutableMap<Integer, Partition> partitionsById = partitionsByIdBuilder.build(); ImmutableMap.Builder<Integer, Host> hostsByIdBuilder = ImmutableMap.builder(); for (Map.Entry<Integer, Host> entry : topology.hostsById.entrySet()) { Integer id = entry.getKey().intValue() == replaceHostId ? localHostId : entry.getKey(); hostsByIdBuilder.put(id, new Host(entry.getValue(), id, partitionsById)); } return new AbstractTopology(topology, hostsByIdBuilder.build(), partitionsById); }