Source:
private XceiverClientReply sendCommandWithRetry( ContainerCommandRequestProto request, List<CheckedBiFunction> validators) throws IOException { ContainerCommandResponseProto responseProto = null; IOException ioException = null; XceiverClientReply reply = new XceiverClientReply(null); List<DatanodeDetails> datanodeList; if ((request.getCmdType() == ContainerProtos.Type.ReadChunk || request.getCmdType() == ContainerProtos.Type.GetSmallFile) && topologyAwareRead) { datanodeList = pipeline.getNodesInOrder(); } else { datanodeList = pipeline.getNodes(); } for (DatanodeDetails dn : datanodeList) { try { LOG.debug("Executing command " + request + " on datanode " + dn); reply.addDatanode(dn); responseProto = sendCommandAsync(request, dn).getResponse().get(); if (validators != null && !validators.isEmpty()) { for (CheckedBiFunction validator : validators) { validator.apply(request, responseProto); } } break; } catch (ExecutionException | InterruptedException | IOException e) { LOG.info("Failed to execute command " + request + " on datanode " + dn .getUuidString(), e); if (!(e instanceof IOException)) { if (Status.fromThrowable(e.getCause()).getCode() == Status.UNAUTHENTICATED.getCode()) { throw new SCMSecurityException("Failed to authenticate with " + "GRPC XceiverServer with Ozone block token."); } ioException = new IOException(e); } else { ioException = (IOException) e; } responseProto = null; } } if (responseProto != null) { reply.setResponse(CompletableFuture.completedFuture(responseProto)); return reply; } else { Preconditions.checkNotNull(ioException); LOG.error("Failed to execute command " + request + " on the pipeline " + pipeline); throw ioException; } }

Target:
private XceiverClientReply sendCommandWithRetry( ContainerCommandRequestProto request, List<CheckedBiFunction> validators) throws IOException { ContainerCommandResponseProto responseProto = null; IOException ioException = null; XceiverClientReply reply = new XceiverClientReply(null); List<DatanodeDetails> datanodeList; if ((request.getCmdType() == ContainerProtos.Type.ReadChunk || request.getCmdType() == ContainerProtos.Type.GetSmallFile) && topologyAwareRead) { datanodeList = pipeline.getNodesInOrder(); } else { datanodeList = pipeline.getNodes(); } for (DatanodeDetails dn : datanodeList) { try { LOG.debug("Executing command " + request + " on datanode " + dn); reply.addDatanode(dn); responseProto = sendCommandAsync(request, dn).getResponse().get(); if (validators != null && !validators.isEmpty()) { for (CheckedBiFunction validator : validators) { validator.apply(request, responseProto); } } break; } catch (ExecutionException | InterruptedException | IOException e) { LOG.error("Failed to execute command " + request + " on datanode " + dn .getUuidString(), e); if (!(e instanceof IOException)) { if (Status.fromThrowable(e.getCause()).getCode() == Status.UNAUTHENTICATED.getCode()) { throw new SCMSecurityException("Failed to authenticate with " + "GRPC XceiverServer with Ozone block token."); } ioException = new IOException(e); } else { ioException = (IOException) e; } responseProto = null; } } if (responseProto != null) { reply.setResponse(CompletableFuture.completedFuture(responseProto)); return reply; } else { Preconditions.checkNotNull(ioException); LOG.error("Failed to execute command on the pipeline {}.", request, pipeline); throw ioException; } }