Source:
public Collection<Partition<AbstractKafkaInputOperator>> definePartitions(Collection<Partition<AbstractKafkaInputOperator>> collection, PartitioningContext partitioningContext) { initMetadataClients(); Map<String, Map<String, List<PartitionInfo>>> metadata = new HashMap<>(); for (int i = 0; i < clusters.length; i++) { metadata.put(clusters[i], new HashMap<String, List<PartitionInfo>>()); for (String topic : topics) { List<PartitionInfo> ptis = metadataRefreshClients[i].partitionsFor(topic); if (logger.isDebugEnabled()) { logger.debug("Partition metadata for topic : {}", topic, Joiner.on(';').join(ptis)); } metadata.get(clusters[i]).put(topic, ptis); } metadataRefreshClients[i].close(); } metadataRefreshClients = null; List<Set<AbstractKafkaPartitioner.PartitionMeta>> parts = assign(metadata); if (currentPartitions == parts || currentPartitions.equals(parts)) { logger.debug("No partition change found"); return collection; } else { logger.info("Partition change detected: "); currentPartitions.clear(); currentPartitions.addAll(parts); int i = 0; List<Partition<AbstractKafkaInputOperator>> result = new LinkedList<>(); for (Iterator<Partition<AbstractKafkaInputOperator>> iter = collection.iterator(); iter.hasNext();) { Partition<AbstractKafkaInputOperator> nextPartition = iter.next(); if (parts.remove(nextPartition.getPartitionedInstance().getAssignment())) { if (logger.isInfoEnabled()) { logger.info("[Existing] Partition with assignment ", i, Joiner.on(';').join(nextPartition.getPartitionedInstance().getAssignment())); } result.add(nextPartition); i++; } } for (Set<AbstractKafkaPartitioner.PartitionMeta> partitionAssignment : parts) { if (logger.isInfoEnabled()) { logger.info("[New] Partition with assignment ", i, Joiner.on(';').join(partitionAssignment)); } result.add(createPartition(partitionAssignment)); i++; } return result; } }

Target:
public Collection<Partition<AbstractKafkaInputOperator>> definePartitions(Collection<Partition<AbstractKafkaInputOperator>> collection, PartitioningContext partitioningContext) { initMetadataClients(); Map<String, Map<String, List<PartitionInfo>>> metadata = new HashMap<>(); for (int i = 0; i < clusters.length; i++) { metadata.put(clusters[i], new HashMap<String, List<PartitionInfo>>()); for (String topic : topics) { List<PartitionInfo> ptis = metadataRefreshClients.get(i).partitionsFor(topic); if (logger.isDebugEnabled()) { logger.debug("Partition metadata for topic : {}", topic, Joiner.on(';').join(ptis)); } metadata.get(clusters[i]).put(topic, ptis); } metadataRefreshClients.get(i).close(); } metadataRefreshClients = null; List<Set<AbstractKafkaPartitioner.PartitionMeta>> parts = assign(metadata); if (currentPartitions == parts || currentPartitions.equals(parts)) { logger.debug("No partition change found"); return collection; } else { logger.info("Partition change detected: "); currentPartitions.clear(); currentPartitions.addAll(parts); int i = 0; List<Partition<AbstractKafkaInputOperator>> result = new LinkedList<>(); for (Iterator<Partition<AbstractKafkaInputOperator>> iter = collection.iterator(); iter.hasNext();) { Partition<AbstractKafkaInputOperator> nextPartition = iter.next(); if (parts.remove(nextPartition.getPartitionedInstance().assignment())) { if (logger.isInfoEnabled()) { logger.info("[Existing] Partition with assignment ", i, Joiner.on(';').join(nextPartition.getPartitionedInstance().assignment())); } result.add(nextPartition); i++; } } for (Set<AbstractKafkaPartitioner.PartitionMeta> partitionAssignment : parts) { if (logger.isInfoEnabled()) { logger.info("[New] Partition with assignment ", i, Joiner.on(';').join(partitionAssignment)); } result.add(createPartition(partitionAssignment)); i++; } return result; } }