org.apache.ratis.proto.RaftProtos.RaftRpcRequestProto Java Examples

The following examples show how to use org.apache.ratis.proto.RaftProtos.RaftRpcRequestProto. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FollowerAppendLogEntryGenerator.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
/**
 * Create initial log entry to initialize the log.
 */
private AppendEntriesRequestProto createInitialLogEntry(long callId) {

  RaftRpcRequestProto serverRequest = createServerRequest(callId);

  long index = 0L;
  LogEntryProto logEntry = LogEntryProto.newBuilder()
      .setTerm(term)
      .setIndex(index)
      .setConfigurationEntry(
          RaftConfigurationProto.newBuilder()
              .addPeers(RaftPeerProto.newBuilder()
                  .setId(RaftPeerId.valueOf(serverAddress).toByteString())
                  .setAddress(serverAddress)
                  .build())
              .addPeers(requestor)
              .build()
      )
      .build();

  return AppendEntriesRequestProto.newBuilder()
      .setLeaderTerm(term)
      .addEntries(logEntry)
      .setServerRequest(serverRequest)
      .build();
}
 
Example #2
Source File: FollowerAppendLogEntryGenerator.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
private RaftRpcRequestProto createServerRequest(long callId) {
  RaftGroupId raftGroupId = RaftGroupId
      .valueOf(UUID.fromString(pipelineId));

  return RaftRpcRequestProto.newBuilder()
      .setRaftGroupId(
          RaftGroupIdProto.newBuilder().setId(raftGroupId.toByteString())
              .build())
      .setRequestorId(requestor.getId())
      .setCallId(callId)
      .build();
}
 
Example #3
Source File: GrpcClientStreamer.java    From incubator-ratis with Apache License 2.0 5 votes vote down vote up
private void reQueuePendingRequests(RaftPeerId newLeader) {
  if (isRunning()) {
    // resend all the pending requests
    while (!ackQueue.isEmpty()) {
      final RaftClientRequestProto oldRequest = ackQueue.pollLast();
      final RaftRpcRequestProto.Builder newRpc = RaftRpcRequestProto.newBuilder(oldRequest.getRpcRequest())
          .setReplyId(newLeader.toByteString());
      final RaftClientRequestProto newRequest = RaftClientRequestProto.newBuilder(oldRequest)
          .setRpcRequest(newRpc).build();
      dataQueue.offerFirst(newRequest);
    }
  }
}
 
Example #4
Source File: GrpcClientStreamer.java    From ratis with Apache License 2.0 5 votes vote down vote up
private void reQueuePendingRequests(RaftPeerId newLeader) {
  if (isRunning()) {
    // resend all the pending requests
    while (!ackQueue.isEmpty()) {
      final RaftClientRequestProto oldRequest = ackQueue.pollLast();
      final RaftRpcRequestProto.Builder newRpc = RaftRpcRequestProto.newBuilder(oldRequest.getRpcRequest())
          .setReplyId(newLeader.toByteString());
      final RaftClientRequestProto newRequest = RaftClientRequestProto.newBuilder(oldRequest)
          .setRpcRequest(newRpc).build();
      dataQueue.offerFirst(newRequest);
    }
  }
}
 
Example #5
Source File: ProtoUtils.java    From incubator-ratis with Apache License 2.0 4 votes vote down vote up
static String toString(RaftRpcRequestProto proto) {
  return proto.getRequestorId().toStringUtf8() + "->" + proto.getReplyId().toStringUtf8()
      + "#" + proto.getCallId();
}
 
Example #6
Source File: RaftServerProxy.java    From incubator-ratis with Apache License 2.0 4 votes vote down vote up
private RaftServerImpl getImpl(RaftRpcRequestProto proto) throws IOException {
  return getImpl(ProtoUtils.toRaftGroupId(proto.getRaftGroupId()));
}
 
Example #7
Source File: ProtoUtils.java    From ratis with Apache License 2.0 4 votes vote down vote up
static String toString(RaftRpcRequestProto proto) {
  return proto.getRequestorId().toStringUtf8() + "->" + proto.getReplyId().toStringUtf8()
      + "#" + proto.getCallId();
}
 
Example #8
Source File: RaftServerProxy.java    From ratis with Apache License 2.0 4 votes vote down vote up
private RaftServerImpl getImpl(RaftRpcRequestProto proto) throws IOException {
  return getImpl(ProtoUtils.toRaftGroupId(proto.getRaftGroupId()));
}