Source:
private void validateBlobOnReplica(Set<BlobId> blobIdSet, ClusterMap clusterMap, String replicaHost, int replicaPort, boolean expiredBlobs) throws Exception { Map<BlobId, ServerErrorCode> resultMap = new HashMap<BlobId, ServerErrorCode>(); for (BlobId blobId : blobIdSet) { Map<ReplicaId, ServerResponse> replicaIdBlobContentMap = new HashMap<>(); ReplicaId targetReplicaId = null; for (ReplicaId replicaId : blobId.getPartition().getReplicaIds()) { if (replicaId.getDataNodeId().getHostname().equals(replicaHost)) { Port port = replicaId.getDataNodeId().getPortToConnectTo(); if (port.getPort() == replicaPort) { targetReplicaId = replicaId; break; } } } if (targetReplicaId == null) { throw new Exception("Can not find blob " + blobId.getID() + " in host " + replicaHost); } logger.debug("Validating blob " + blobId + " on replica " + replicaHost + ":" + replicaPort + "\n"); ServerErrorCode response = null; try { response = validateBlobOnReplica(blobId, clusterMap, targetReplicaId, expiredBlobs, replicaIdBlobContentMap); if (response == ServerErrorCode.No_Error) { logger.trace("Successfully read the blob {}", blobId); } else { logger.error("Failed to read the blob " + blobId + " due to " + response); } resultMap.put(blobId, response); } catch (MessageFormatException e) { resultMap.put(blobId, ServerErrorCode.Data_Corrupt); } catch (IOException e) { resultMap.put(blobId, ServerErrorCode.IO_Error); } catch (Exception e) { resultMap.put(blobId, ServerErrorCode.Unknown_Error); } } logger.debug("Overall Summary"); for (BlobId blobId : resultMap.keySet()) { logger.debug(blobId + " :: " + resultMap.get(blobId)); } }

Target:
private void validateBlobOnReplica(Set<BlobId> blobIdSet, ClusterMap clusterMap, String replicaHost, int replicaPort, boolean expiredBlobs) throws Exception { Map<BlobId, ServerErrorCode> resultMap = new HashMap<BlobId, ServerErrorCode>(); for (BlobId blobId : blobIdSet) { Map<ReplicaId, ServerResponse> replicaIdBlobContentMap = new HashMap<>(); ReplicaId targetReplicaId = null; for (ReplicaId replicaId : blobId.getPartition().getReplicaIds()) { if (replicaId.getDataNodeId().getHostname().equals(replicaHost)) { Port port = replicaId.getDataNodeId().getPortToConnectTo(); if (port.getPort() == replicaPort) { targetReplicaId = replicaId; break; } } } if (targetReplicaId == null) { throw new Exception("Can not find blob " + blobId.getID() + " in host " + replicaHost); } logger.debug("Validating blob on replica {}:{}\n", blobId, replicaHost, replicaPort); ServerErrorCode response = null; try { response = validateBlobOnReplica(blobId, clusterMap, targetReplicaId, expiredBlobs, replicaIdBlobContentMap); if (response == ServerErrorCode.No_Error) { logger.trace("Successfully read the blob {}", blobId); } else { logger.error("Failed to read the blob due to {}", blobId, response); } resultMap.put(blobId, response); } catch (MessageFormatException e) { resultMap.put(blobId, ServerErrorCode.Data_Corrupt); } catch (IOException e) { resultMap.put(blobId, ServerErrorCode.IO_Error); } catch (Exception e) { resultMap.put(blobId, ServerErrorCode.Unknown_Error); } } logger.debug("Overall Summary"); for (BlobId blobId : resultMap.keySet()) { logger.debug("{} :: {}", blobId, resultMap.get(blobId)); } }