You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by sh...@apache.org on 2021/11/30 09:17:51 UTC
[ratis] branch master updated: RATIS-1450. Remove ProtoUtils.addCommitInfos(..). (#544)
This is an automated email from the ASF dual-hosted git repository.
shashikant pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ratis.git
The following commit(s) were added to refs/heads/master by this push:
new b8fca7e RATIS-1450. Remove ProtoUtils.addCommitInfos(..). (#544)
b8fca7e is described below
commit b8fca7e90f6216b6bfcb666b3e5175d60bcafa75
Author: Tsz-Wo Nicholas Sze <sz...@apache.org>
AuthorDate: Tue Nov 30 17:17:46 2021 +0800
RATIS-1450. Remove ProtoUtils.addCommitInfos(..). (#544)
---
.../apache/ratis/client/impl/ClientProtoUtils.java | 4 ++--
.../java/org/apache/ratis/util/ProtoUtils.java | 24 ----------------------
.../apache/ratis/server/impl/ServerProtoUtils.java | 3 +--
3 files changed, 3 insertions(+), 28 deletions(-)
diff --git a/ratis-client/src/main/java/org/apache/ratis/client/impl/ClientProtoUtils.java b/ratis-client/src/main/java/org/apache/ratis/client/impl/ClientProtoUtils.java
index 0379353..9262186 100644
--- a/ratis-client/src/main/java/org/apache/ratis/client/impl/ClientProtoUtils.java
+++ b/ratis-client/src/main/java/org/apache/ratis/client/impl/ClientProtoUtils.java
@@ -253,7 +253,7 @@ public interface ClientProtoUtils {
if (reply.getMessage() != null) {
b.setMessage(toClientMessageEntryProtoBuilder(reply.getMessage()));
}
- ProtoUtils.addCommitInfos(reply.getCommitInfos(), b::addCommitInfos);
+ b.addAllCommitInfos(reply.getCommitInfos());
final NotLeaderException nle = reply.getNotLeaderException();
if (nle != null) {
@@ -344,7 +344,7 @@ public interface ClientProtoUtils {
b.setGroup(ProtoUtils.toRaftGroupProtoBuilder(reply.getGroup()));
b.setIsRaftStorageHealthy(reply.isRaftStorageHealthy());
b.setRole(reply.getRoleInfoProto());
- ProtoUtils.addCommitInfos(reply.getCommitInfos(), b::addCommitInfos);
+ b.addAllCommitInfos(reply.getCommitInfos());
}
}
return b.build();
diff --git a/ratis-common/src/main/java/org/apache/ratis/util/ProtoUtils.java b/ratis-common/src/main/java/org/apache/ratis/util/ProtoUtils.java
index 4fff8c1..80348ff 100644
--- a/ratis-common/src/main/java/org/apache/ratis/util/ProtoUtils.java
+++ b/ratis-common/src/main/java/org/apache/ratis/util/ProtoUtils.java
@@ -34,7 +34,6 @@ import org.apache.ratis.protocol.RaftGroupMemberId;
import org.apache.ratis.protocol.RaftPeer;
import org.apache.ratis.protocol.RaftPeerId;
import org.apache.ratis.thirdparty.com.google.protobuf.ByteString;
-import org.apache.ratis.thirdparty.com.google.protobuf.ServiceException;
import java.io.IOException;
import java.io.ObjectOutputStream;
@@ -44,7 +43,6 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
-import java.util.function.Consumer;
import java.util.stream.Collectors;
public interface ProtoUtils {
@@ -127,14 +125,6 @@ public interface ProtoUtils {
return protos.stream().map(ProtoUtils::toRaftPeer).collect(Collectors.toList());
}
- static RaftPeerId toRaftPeerId(RaftPeerIdProto p) {
- return RaftPeerId.valueOf(p.getId());
- }
-
- static List<RaftPeerId> toRaftPeerIds(List<RaftPeerIdProto> protos) {
- return protos.stream().map(ProtoUtils::toRaftPeerId).collect(Collectors.toList());
- }
-
static Iterable<RaftPeerProto> toRaftPeerProtos(
final Collection<RaftPeer> peers) {
return () -> new Iterator<RaftPeerProto>() {
@@ -229,12 +219,6 @@ public interface ProtoUtils {
.build();
}
- static void addCommitInfos(Collection<CommitInfoProto> commitInfos, Consumer<CommitInfoProto> accumulator) {
- if (commitInfos != null && !commitInfos.isEmpty()) {
- commitInfos.forEach(accumulator);
- }
- }
-
static String toString(CommitInfoProto proto) {
return RaftPeerId.valueOf(proto.getServer().getId()) + ":c" + proto.getCommitIndex();
}
@@ -251,14 +235,6 @@ public interface ProtoUtils {
return proto.getSeqNum() + (proto.getIsFirst()? "*": "");
}
- static IOException toIOException(ServiceException se) {
- final Throwable t = se.getCause();
- if (t == null) {
- return new IOException(se);
- }
- return t instanceof IOException? (IOException)t : new IOException(se);
- }
-
static String toString(RaftRpcRequestProto proto) {
return proto.getRequestorId().toStringUtf8() + "->" + proto.getReplyId().toStringUtf8()
+ "#" + proto.getCallId();
diff --git a/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerProtoUtils.java b/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerProtoUtils.java
index c4e7f90..0c44561 100644
--- a/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerProtoUtils.java
+++ b/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerProtoUtils.java
@@ -24,7 +24,6 @@ import org.apache.ratis.protocol.RaftGroupMemberId;
import org.apache.ratis.protocol.RaftPeer;
import org.apache.ratis.protocol.RaftPeerId;
import org.apache.ratis.server.protocol.TermIndex;
-import org.apache.ratis.util.ProtoUtils;
import java.util.Collection;
import java.util.List;
@@ -147,7 +146,7 @@ final class ServerProtoUtils {
}
Optional.ofNullable(previous).map(TermIndex::toProto).ifPresent(b::setPreviousLog);
- ProtoUtils.addCommitInfos(commitInfos, b::addCommitInfos);
+ Optional.ofNullable(commitInfos).ifPresent(b::addAllCommitInfos);
return b.build();
}