Source:
public void useReplicaNotSucceededSendTest() { int replicaCount = 4; ArrayList<Port> portList = new ArrayList<Port>(); portList.add(new Port(6666, PortType.PLAINTEXT)); List<String> mountPaths = Arrays.asList("mockMountPath"); datanodes = new ArrayList<MockDataNodeId>(); datanodes.add(new MockDataNodeId(portList, mountPaths, "local-0")); mockPartition = generateMockPartition(replicaCount, datanodes); localDcName = datanodes.get(0).getDatacenterName(); inflightReplicas = new LinkedList<ReplicaId>(); ot = new SimpleOperationTracker(datanodes.get(0).getDatacenterName(), mockPartition, true, 1, 2); Iterator<ReplicaId> itr = ot.getReplicaIterator(); ReplicaId nextReplica; int oddEvenFlag = 0; while (itr.hasNext()) { nextReplica = itr.next(); assertNotNull(nextReplica); if (oddEvenFlag % 2 == 0) { sendReplica(nextReplica); itr.remove(); } oddEvenFlag++; } ot.onResponse(inflightReplicas.poll(), new Exception()); ot.onResponse(inflightReplicas.poll(), new Exception()); assertFalse(ot.hasSucceeded()); assertFalse(ot.isDone()); itr = ot.getReplicaIterator(); oddEvenFlag = 0; while (itr.hasNext()) { nextReplica = itr.next(); assertNotNull(nextReplica); if (oddEvenFlag % 2 == 0) { sendReplica(nextReplica); itr.remove(); } oddEvenFlag++; } ot.onResponse(inflightReplicas.poll(), new Exception()); assertFalse(ot.hasSucceeded()); assertFalse(ot.isDone()); itr = ot.getReplicaIterator(); while (itr.hasNext()) { nextReplica = itr.next(); assertNotNull(nextReplica); sendReplica(nextReplica); itr.remove(); } ot.onResponse(inflightReplicas.poll(), null); assertTrue(ot.hasSucceeded()); assertTrue(ot.isDone()); }

Target:
public void useReplicaNotSucceededSendTest() { int replicaCount = 4; ArrayList<Port> portList = new ArrayList<Port>(); portList.add(new Port(6666, PortType.PLAINTEXT)); List<String> mountPaths = Arrays.asList("mockMountPath"); datanodes = new ArrayList<MockDataNodeId>(); datanodes.add(new MockDataNodeId(portList, mountPaths, "local-0")); mockPartition = new MockPartitionId(); populateReplicaList(mockPartition, replicaCount, datanodes); localDcName = datanodes.get(0).getDatacenterName(); inflightReplicas = new LinkedList<ReplicaId>(); ot = new SimpleOperationTracker(localDcName, mockPartition, true, 1, 2); Iterator<ReplicaId> itr = ot.getReplicaIterator(); ReplicaId nextReplica; int oddEvenFlag = 0; while (itr.hasNext()) { nextReplica = itr.next(); assertNotNull(nextReplica); if (oddEvenFlag % 2 == 0) { sendReplica(nextReplica); itr.remove(); } oddEvenFlag++; } ot.onResponse(inflightReplicas.poll(), new Exception()); ot.onResponse(inflightReplicas.poll(), new Exception()); assertFalse(ot.hasSucceeded()); assertFalse(ot.isDone()); itr = ot.getReplicaIterator(); oddEvenFlag = 0; while (itr.hasNext()) { nextReplica = itr.next(); assertNotNull(nextReplica); if (oddEvenFlag % 2 == 0) { sendReplica(nextReplica); itr.remove(); } oddEvenFlag++; } ot.onResponse(inflightReplicas.poll(), new Exception()); assertFalse(ot.hasSucceeded()); assertFalse(ot.isDone()); itr = ot.getReplicaIterator(); while (itr.hasNext()) { nextReplica = itr.next(); assertNotNull(nextReplica); sendReplica(nextReplica); itr.remove(); } ot.onResponse(inflightReplicas.poll(), null); assertTrue(ot.hasSucceeded()); assertTrue(ot.isDone()); }