Source:
public void start() throws ReplicationException { try { for (String mountPath : partitionGroupedByMountPath.keySet()) { readFromFile(mountPath); } logger.info("replica threads " + replicationConfig.replicationNoOfReplicaThreads); if (partitionGroupedByMountPath.size() >= replicationConfig.replicationNoOfReplicaThreads) { logger.info("Number of replica threads is less than or equal to the number of mount paths"); int numberOfMountPathPerThread = partitionGroupedByMountPath.size() / replicationConfig.replicationNoOfReplicaThreads; int remainingMountPaths = partitionGroupedByMountPath.size() % replicationConfig.replicationNoOfReplicaThreads; Iterator<Map.Entry<String, List<PartitionInfo>>> mountPathEntries = partitionGroupedByMountPath.entrySet().iterator(); for (int i = 0; i < replicationConfig.replicationNoOfReplicaThreads; i++) { List<PartitionInfo> partitionInfoList = new ArrayList<PartitionInfo>(); int mountPathAssignedToThread = 0; while (mountPathAssignedToThread < numberOfMountPathPerThread) { partitionInfoList.addAll(mountPathEntries.next().getValue()); mountPathAssignedToThread++; } if (remainingMountPaths > 0) { partitionInfoList.addAll(mountPathEntries.next().getValue()); remainingMountPaths--; } ReplicaThread replicaThread = new ReplicaThread("Replica Thread " + i, partitionInfoList, factory, clusterMap, correlationIdGenerator, dataNodeId, connectionPool, replicationConfig.replicationConnectionPoolCheckoutTimeoutMs); replicaThreads.add(replicaThread); } } else { } for (ReplicaThread thread : replicaThreads) { Thread replicaThread = new Thread(thread, thread.getName()); logger.info("Starting replica thread " + thread.getName()); replicaThread.start(); } this.scheduler.schedule("replica token persistor", persistor, replicationConfig.replicationTokenFlushDelaySeconds, replicationConfig.replicationTokenFlushIntervalSeconds, TimeUnit.SECONDS); } catch (IOException e) { logger.error("IO error while starting replication"); } }

Target:
public void start() throws ReplicationException { try { for (String mountPath : partitionGroupedByMountPath.keySet()) { readFromFile(mountPath); } logger.info("replica threads " + replicationConfig.replicationNumReplicaThreads); if (partitionGroupedByMountPath.size() >= replicationConfig.replicationNumReplicaThreads) { logger.info("Number of replica threads is less than or equal to the number of mount paths"); int numberOfMountPathPerThread = partitionGroupedByMountPath.size() / replicationConfig.replicationNumReplicaThreads; int remainingMountPaths = partitionGroupedByMountPath.size() % replicationConfig.replicationNumReplicaThreads; Iterator<Map.Entry<String, List<PartitionInfo>>> mountPathEntries = partitionGroupedByMountPath.entrySet().iterator(); for (int i = 0; i < replicationConfig.replicationNumReplicaThreads; i++) { List<PartitionInfo> partitionInfoList = new ArrayList<PartitionInfo>(); int mountPathAssignedToThread = 0; while (mountPathAssignedToThread < numberOfMountPathPerThread) { partitionInfoList.addAll(mountPathEntries.next().getValue()); mountPathAssignedToThread++; } if (remainingMountPaths > 0) { partitionInfoList.addAll(mountPathEntries.next().getValue()); remainingMountPaths--; } ReplicaThread replicaThread = new ReplicaThread("Replica Thread " + i, partitionInfoList, factory, clusterMap, correlationIdGenerator, dataNodeId, connectionPool, replicationConfig, replicationMetrics); replicaThreads.add(replicaThread); } } else { } for (ReplicaThread thread : replicaThreads) { Thread replicaThread = new Thread(thread, thread.getName()); logger.info("Starting replica thread " + thread.getName()); replicaThread.start(); } this.scheduler.schedule("replica token persistor", persistor, replicationConfig.replicationTokenFlushDelaySeconds, replicationConfig.replicationTokenFlushIntervalSeconds, TimeUnit.SECONDS); } catch (IOException e) { logger.error("IO error while starting replication"); } }