Search in sources :

Example 96 with RaftClientReply

use of org.apache.ratis.protocol.RaftClientReply in project alluxio by Alluxio.

the class RaftJournalWriterTest method setupRaftJournalWriter.

private void setupRaftJournalWriter() throws IOException {
    mClient = mock(RaftJournalAppender.class);
    RaftClientReply reply = RaftClientReply.newBuilder().setClientId(ClientId.randomId()).setServerId(RaftGroupMemberId.valueOf(RaftJournalUtils.getPeerId(new InetSocketAddress(1)), RaftGroupId.valueOf(UUID.fromString("02511d47-d67c-49a3-9011-abb3109a44c1")))).setCallId(1L).setSuccess(true).setMessage(Message.valueOf("mp")).setException(null).setLogIndex(1L).setCommitInfos(null).build();
    CompletableFuture<RaftClientReply> future = new CompletableFuture<RaftClientReply>() {

        @Override
        public boolean cancel(boolean mayInterruptIfRunning) {
            return false;
        }

        @Override
        public boolean isCancelled() {
            return false;
        }

        @Override
        public boolean isDone() {
            return false;
        }

        @Override
        public RaftClientReply get() {
            return reply;
        }

        @Override
        public RaftClientReply get(long timeout, TimeUnit unit) {
            return reply;
        }
    };
    when(mClient.sendAsync(any(), any())).thenReturn(future);
    mRaftJournalWriter = new RaftJournalWriter(1, mClient);
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) RaftClientReply(org.apache.ratis.protocol.RaftClientReply) InetSocketAddress(java.net.InetSocketAddress) TimeUnit(java.util.concurrent.TimeUnit)

Aggregations

RaftClientReply (org.apache.ratis.protocol.RaftClientReply)96 RaftClient (org.apache.ratis.client.RaftClient)71 RaftPeerId (org.apache.ratis.protocol.RaftPeerId)43 RaftServer (org.apache.ratis.server.RaftServer)40 IOException (java.io.IOException)32 SimpleMessage (org.apache.ratis.RaftTestUtil.SimpleMessage)25 CompletableFuture (java.util.concurrent.CompletableFuture)22 RaftPeer (org.apache.ratis.protocol.RaftPeer)22 Test (org.junit.Test)22 ArrayList (java.util.ArrayList)20 TimeDuration (org.apache.ratis.util.TimeDuration)18 RaftClientRequest (org.apache.ratis.protocol.RaftClientRequest)14 RaftTestUtil (org.apache.ratis.RaftTestUtil)13 RaftProperties (org.apache.ratis.conf.RaftProperties)13 MiniRaftCluster (org.apache.ratis.server.impl.MiniRaftCluster)13 SimpleStateMachine4Testing (org.apache.ratis.statemachine.SimpleStateMachine4Testing)13 List (java.util.List)12 RetryPolicy (org.apache.ratis.retry.RetryPolicy)12 CompletionException (java.util.concurrent.CompletionException)11 ExecutionException (java.util.concurrent.ExecutionException)11