akpatnam25 commented on code in PR #3347: URL: https://github.com/apache/celeborn/pull/3347#discussion_r2196693446
########## master/src/main/java/org/apache/celeborn/service/deploy/master/SlotsAllocator.java: ########## @@ -344,19 +484,26 @@ static List<WorkerInfo> generateRackAwareWorkers(List<WorkerInfo> workers) { private static List<Integer> roundRobin( Map<WorkerInfo, Tuple2<List<PartitionLocation>, List<PartitionLocation>>> slots, List<Integer> partitionIds, - List<WorkerInfo> workers, + List<WorkerInfo> primaryWorkers, + List<WorkerInfo> replicaWorkers, Map<WorkerInfo, List<UsableDiskInfo>> slotsRestrictions, boolean shouldReplicate, boolean shouldRackAware, - int availableStorageTypes) { + int availableStorageTypes, + boolean replicaSameAsPrimary) { + if (primaryWorkers.isEmpty() || replicaWorkers.isEmpty()) { + return partitionIds; + } // workerInfo -> (diskIndexForPrimaryAndReplica) Map<WorkerInfo, Integer> workerDiskIndex = new HashMap<>(); List<Integer> partitionIdList = new LinkedList<>(partitionIds); - final int workerSize = workers.size(); - final IntUnaryOperator incrementIndex = v -> (v + 1) % workerSize; - int primaryIndex = rand.nextInt(workerSize); - int replicaIndex = rand.nextInt(workerSize); + final int primaryWorkersSize = primaryWorkers.size(); + final int replicaWorkersSize = replicaWorkers.size(); + final IntUnaryOperator primaryWorkersIncrementIndex = v -> (v + 1) % primaryWorkersSize; + final IntUnaryOperator replicaWorkersIncrementIndex = v -> (v + 1) % replicaWorkersSize; + int primaryIndex = rand.nextInt(primaryWorkersSize); + int replicaIndex = rand.nextInt(replicaWorkersSize); Review Comment: We already have a test case where we pass in false for shouldReplicate https://github.com/akpatnam25/incubator-celeborn/blob/CELEBORN-2031-impl/master/src/test/java/org/apache/celeborn/service/deploy/master/SlotsAllocatorSuiteJ.java#L485-L486 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@celeborn.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org