Skip to content

RATIS-1178. Use RaftClient to submit request#308

Merged
runzhiwang merged 4 commits intoapache:masterfrom
runzhiwang:RaftClient-forward
Dec 1, 2020
Merged

RATIS-1178. Use RaftClient to submit request#308
runzhiwang merged 4 commits intoapache:masterfrom
runzhiwang:RaftClient-forward

Conversation

@runzhiwang
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Use RaftClient to submit request

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/RATIS-1178

How was this patch tested?

No need to add new ut.

@runzhiwang
Copy link
Copy Markdown
Contributor Author

@szetszwo Could you have a brief review ? If you agree with the idea, I will fix the failed ut.

Copy link
Copy Markdown
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks great. It is much cleaner. Some comments inlined.

Comment on lines +157 to +158
final RaftProperties p = new RaftProperties();
RaftConfigKeys.Rpc.setType(p, SupportedRpcType.GRPC);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should call getRaftServer().getProperties(). Then, it will use all the existing settings. We don't have to set RPC type.

    this.raftClient = JavaUtils.memoize(() -> RaftClient.newBuilder()
          .setRaftGroup(group)
          .setProperties(getRaftServer().getProperties())
          .build());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, netty client did not implement async api, so I ignore TestNettyDataStreamWithNettyCluster, otherwise will throw UnsupportedOperationException.

Caused by: java.lang.UnsupportedOperationException: class org.apache.ratis.netty.client.NettyClientRpc does not support this method.
        at org.apache.ratis.client.RaftClientRpc.sendRequestAsync(RaftClientRpc.java:35)
        at org.apache.ratis.client.impl.OrderedAsync.sendRequest(OrderedAsync.java:234)
        at org.apache.ratis.client.impl.OrderedAsync.sendRequestWithRetry(OrderedAsync.java:188)
        at org.apache.ratis.util.SlidingWindow$Client.sendOrDelayRequest(SlidingWindow.java:278)
        at org.apache.ratis.util.SlidingWindow$Client.submitNewRequest(SlidingWindow.java:257)
        at org.apache.ratis.client.impl.OrderedAsync.send(OrderedAsync.java:169)
        at org.apache.ratis.client.impl.OrderedAsync.newInstance(OrderedAsync.java:117)
        at org.apache.ratis.client.impl.RaftClientImpl.lambda$new$0(RaftClientImpl.java:154)
        at org.apache.ratis.util.MemoizedSupplier.get(MemoizedSupplier.java:62)
        at org.apache.ratis.client.impl.RaftClientImpl.getOrderedAsync(RaftClientImpl.java:206)
        at org.apache.ratis.client.impl.AsyncImpl.send(AsyncImpl.java:41)
        at org.apache.ratis.client.impl.AsyncImpl.sendForward(AsyncImpl.java:67)
        at org.apache.ratis.netty.server.DataStreamManagement.startTransaction(DataStreamManagement.java:304)
        at org.apache.ratis.netty.server.DataStreamManagement.lambda$null$7(DataStreamManagement.java:384)
        at java.util.concurrent.CompletableFuture.biApply(CompletableFuture.java:1105)

Copy link
Copy Markdown
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good. Just some minor comments.

Copy link
Copy Markdown
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 the change looks good.

@runzhiwang runzhiwang merged commit aa56a31 into apache:master Dec 1, 2020
@runzhiwang
Copy link
Copy Markdown
Contributor Author

@szetszwo Thanks for review. I have merged the patch, because CI passed.


DataStreamMap getDataStreamMap();

RaftClient getRaftClient();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@szetszwo it seems that we no longer use this method to submit request. If it's the case, I'm willing to figure out whether we can drop this "dead code".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right that we may remove it. But we need to keep it in branch-2 for compatibility.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I submitted #886 already that is against master (3.0). I'll file a JIRA ticket later.

symious pushed a commit to symious/ratis that referenced this pull request Feb 13, 2024
* RATIS-1178. Use RaftClient to submit request

* fix code review

* fix code review

* fix code review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants