Source:
<code><START> boolean poll(PutRequestRegistrationCallback requestFillCallback) { <END> Iterator<Map.Entry<Integer, ChunkPutRequest>> inFlightRequestsIterator = correlationIdToChunkPutRequest.entrySet().iterator(); while (inFlightRequestsIterator.hasNext()) { Map.Entry<Integer, ChunkPutRequest> entry = inFlightRequestsIterator.next(); if (time.milliseconds() - entry.getValue().startTimeMs > routerConfig.routerRequestTimeoutMs) { operationTracker.onResponse(entry.getValue().replicaId, false); chunkException = new RouterException("Timed out waiting for responses", RouterErrorCode.OperationTimedOut); inFlightRequestsIterator.remove(); } else { break; } } if (completeIfDone()) { return true; } Iterator<ReplicaId> replicaIterator = operationTracker.getReplicaIterator(); while (replicaIterator.hasNext()) { ReplicaId replicaId = replicaIterator.next(); String hostname = replicaId.getDataNodeId().getHostname(); Port port = new Port(replicaId.getDataNodeId().getPort(), PortType.PLAINTEXT); PutRequest putRequest = createPutRequest(); RequestInfo request = new RequestInfo(hostname, port, putRequest); int correlationId = putRequest.getCorrelationId(); correlationIdToChunkPutRequest.put(correlationId, new ChunkPutRequest(replicaId, time.milliseconds())); correlationIdToPutChunk.put(correlationId, this); requestFillCallback.registerRequestToSend(PutOperation.this, request); replicaIterator.remove(); } return false; }</code><technical_language>I if this is good behavior. thought of bringing this up. I that, instead of checking state of a variable, some other method return state avoid making another call. this solves purpose, function un-intuitive. For instance, poll() return if operation is complete not. This is a minor change only, felt good discuss this</technical_language>

Target:
void poll(PutRequestRegistrationCallback requestFillCallback) { Iterator<Map.Entry<Integer, ChunkPutRequestInfo>> inFlightRequestsIterator = correlationIdToChunkPutRequestInfo.entrySet().iterator(); while (inFlightRequestsIterator.hasNext()) { Map.Entry<Integer, ChunkPutRequestInfo> entry = inFlightRequestsIterator.next(); if (time.milliseconds() - entry.getValue().startTimeMs > routerConfig.routerRequestTimeoutMs) { operationTracker.onResponse(entry.getValue().replicaId, false); chunkException = new RouterException("Timed out waiting for responses", RouterErrorCode.OperationTimedOut); inFlightRequestsIterator.remove(); } else { break; } } checkAndMaybeComplete(); if (isComplete()) { return; } Iterator<ReplicaId> replicaIterator = operationTracker.getReplicaIterator(); while (replicaIterator.hasNext()) { ReplicaId replicaId = replicaIterator.next(); String hostname = replicaId.getDataNodeId().getHostname(); Port port = new Port(replicaId.getDataNodeId().getPort(), PortType.PLAINTEXT); PutRequest putRequest = createPutRequest(); RequestInfo request = new RequestInfo(hostname, port, putRequest); int correlationId = putRequest.getCorrelationId(); correlationIdToChunkPutRequestInfo.put(correlationId, new ChunkPutRequestInfo(replicaId, time.milliseconds())); correlationIdToPutChunk.put(correlationId, this); requestFillCallback.registerRequestToSend(PutOperation.this, request); replicaIterator.remove(); } }