Source:
public XceiverClientReply watchForCommit(long index, long timeout) throws InterruptedException, ExecutionException, TimeoutException, IOException { long commitIndex = getReplicatedMinCommitIndex(); XceiverClientReply clientReply = new XceiverClientReply(null); if (commitIndex >= index) { clientReply.setLogIndex(commitIndex); return clientReply; } LOG.debug("commit index : watch timeout : {}", index, timeout); RaftClientReply reply; try { CompletableFuture<RaftClientReply> replyFuture = getClient() .sendWatchAsync(index, RaftProtos.ReplicationLevel.ALL_COMMITTED); replyFuture.get(timeout, TimeUnit.MILLISECONDS); } catch (Exception e) { String nodes = " with Datanodes : "; Throwable t = HddsClientUtils.checkForException(e); for (DatanodeDetails datanodeDetails : pipeline.getNodes()) { nodes += datanodeDetails.getHostName() + "[" + datanodeDetails.getIpAddress() + "] "; } LOG.warn("3 way commit failed on pipeline " + pipeline.getId().getId() + nodes, e); if (t instanceof GroupMismatchException) { throw e; } reply = getClient() .sendWatchAsync(index, RaftProtos.ReplicationLevel.MAJORITY_COMMITTED) .get(timeout, TimeUnit.MILLISECONDS); List<RaftProtos.CommitInfoProto> commitInfoProtoList = reply.getCommitInfos().stream() .filter(i -> i.getCommitIndex() < index) .collect(Collectors.toList()); commitInfoProtoList.parallelStream().forEach(proto -> { UUID address = RatisHelper.toDatanodeId(proto.getServer()); addDatanodetoReply(address, clientReply); commitInfoMap.remove(address); LOG.info( "Could not commit " + index + " on pipeline " + pipeline.getId().getId() + " to all the nodes. Server " + address + " has failed. Committed by majority."); }); } clientReply.setLogIndex(index); return clientReply; }

Target:
public XceiverClientReply watchForCommit(long index, long timeout) throws InterruptedException, ExecutionException, TimeoutException, IOException { long commitIndex = getReplicatedMinCommitIndex(); XceiverClientReply clientReply = new XceiverClientReply(null); if (commitIndex >= index) { clientReply.setLogIndex(commitIndex); return clientReply; } LOG.debug("commit index : watch timeout : {}", index, timeout); RaftClientReply reply; try { CompletableFuture<RaftClientReply> replyFuture = getClient() .sendWatchAsync(index, RaftProtos.ReplicationLevel.ALL_COMMITTED); replyFuture.get(timeout, TimeUnit.MILLISECONDS); } catch (Exception e) { Throwable t = HddsClientUtils.checkForException(e); LOG.warn("3 way commit failed on pipeline {}", pipeline, e); if (t instanceof GroupMismatchException) { throw e; } reply = getClient() .sendWatchAsync(index, RaftProtos.ReplicationLevel.MAJORITY_COMMITTED) .get(timeout, TimeUnit.MILLISECONDS); List<RaftProtos.CommitInfoProto> commitInfoProtoList = reply.getCommitInfos().stream() .filter(i -> i.getCommitIndex() < index) .collect(Collectors.toList()); commitInfoProtoList.parallelStream().forEach(proto -> { UUID address = RatisHelper.toDatanodeId(proto.getServer()); addDatanodetoReply(address, clientReply); commitInfoMap.remove(address); LOG.info( "Could not commit index on pipeline to all the nodes. " + "Server has failed. Committed by majority.", index, pipeline, address); }); } clientReply.setLogIndex(index); return clientReply; }