You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ratis.apache.org by GitBox <gi...@apache.org> on 2020/10/12 23:52:37 UTC

[GitHub] [incubator-ratis] amaliujia opened a new pull request #220: RATIS-1094. Move sync api from RaftClient interface to AsyncApi inter…

amaliujia opened a new pull request #220:
URL: https://github.com/apache/incubator-ratis/pull/220


   …face
   
   ## What changes were proposed in this pull request?
   
   Move sync api from RaftClient interface to AsyncApi interface
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/RATIS-1094
   
   ## How was this patch tested?
   
   UT
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-ratis] szetszwo commented on a change in pull request #220: RATIS-1094. Move sync api from RaftClient interface to AsyncApi inter…

Posted by GitBox <gi...@apache.org>.
szetszwo commented on a change in pull request #220:
URL: https://github.com/apache/incubator-ratis/pull/220#discussion_r503606211



##########
File path: ratis-client/src/main/java/org/apache/ratis/client/RaftClient.java
##########
@@ -54,6 +54,9 @@
   /** Get the {@link GroupManagementApi} for the given server. */
   GroupManagementApi getGroupManagementApi(RaftPeerId server);
 
+  /** Get the {@link AsyncApi}. */
+  AsyncApi getAsyncApi();

Review comment:
       Let's rename this to async().

##########
File path: ratis-client/src/main/java/org/apache/ratis/client/api/AsyncApi.java
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ratis.client.api;
+
+import java.util.concurrent.CompletableFuture;
+import org.apache.ratis.proto.RaftProtos.ReplicationLevel;
+import org.apache.ratis.protocol.Message;
+import org.apache.ratis.protocol.RaftClientReply;
+import org.apache.ratis.protocol.RaftPeerId;
+
+/**
+ * APIs to support asynchronous operations such as send message, send (stale)read message and watch request.
+ */
+public interface AsyncApi {
+  /**
+   * Async call to send the given message to the raft service.
+   * The message may change the state of the service.
+   * For readonly messages, use {@link #sendReadOnlyAsync(Message)} instead.
+   *
+   * @param message The request message.
+   * @return a future of the reply.
+   */
+  CompletableFuture<RaftClientReply> sendAsync(Message message);
+
+  /** Async call to send the given readonly message to the raft service. */
+  CompletableFuture<RaftClientReply> sendReadOnlyAsync(Message message);

Review comment:
       Rename this to sendReadOnly().

##########
File path: ratis-client/src/main/java/org/apache/ratis/client/api/AsyncApi.java
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ratis.client.api;
+
+import java.util.concurrent.CompletableFuture;
+import org.apache.ratis.proto.RaftProtos.ReplicationLevel;
+import org.apache.ratis.protocol.Message;
+import org.apache.ratis.protocol.RaftClientReply;
+import org.apache.ratis.protocol.RaftPeerId;
+
+/**
+ * APIs to support asynchronous operations such as send message, send (stale)read message and watch request.
+ */
+public interface AsyncApi {
+  /**
+   * Async call to send the given message to the raft service.
+   * The message may change the state of the service.
+   * For readonly messages, use {@link #sendReadOnlyAsync(Message)} instead.
+   *
+   * @param message The request message.
+   * @return a future of the reply.
+   */
+  CompletableFuture<RaftClientReply> sendAsync(Message message);
+
+  /** Async call to send the given readonly message to the raft service. */
+  CompletableFuture<RaftClientReply> sendReadOnlyAsync(Message message);
+
+  /** Async call to send the given stale-read message to the given server (not the raft service). */
+  CompletableFuture<RaftClientReply> sendStaleReadAsync(Message message, long minIndex, RaftPeerId server);
+
+  /** Async call to watch the given index to satisfy the given replication level. */
+  CompletableFuture<RaftClientReply> sendWatchAsync(long index, ReplicationLevel replication);

Review comment:
       Rename this to watch().

##########
File path: ratis-client/src/main/java/org/apache/ratis/client/impl/AsyncApiImpl.java
##########
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ratis.client.impl;
+
+import java.util.Objects;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ratis.client.api.AsyncApi;
+import org.apache.ratis.proto.RaftProtos.ReplicationLevel;
+import org.apache.ratis.protocol.Message;
+import org.apache.ratis.protocol.RaftClientReply;
+import org.apache.ratis.protocol.RaftClientRequest;
+import org.apache.ratis.protocol.RaftPeerId;
+
+/** Async api implementations. */
+class AsyncApiImpl implements AsyncApi {

Review comment:
       Rename this to AsyncImpl

##########
File path: ratis-client/src/main/java/org/apache/ratis/client/api/AsyncApi.java
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ratis.client.api;
+
+import java.util.concurrent.CompletableFuture;
+import org.apache.ratis.proto.RaftProtos.ReplicationLevel;
+import org.apache.ratis.protocol.Message;
+import org.apache.ratis.protocol.RaftClientReply;
+import org.apache.ratis.protocol.RaftPeerId;
+
+/**
+ * APIs to support asynchronous operations such as send message, send (stale)read message and watch request.
+ */
+public interface AsyncApi {
+  /**
+   * Async call to send the given message to the raft service.
+   * The message may change the state of the service.
+   * For readonly messages, use {@link #sendReadOnlyAsync(Message)} instead.
+   *
+   * @param message The request message.
+   * @return a future of the reply.
+   */
+  CompletableFuture<RaftClientReply> sendAsync(Message message);
+
+  /** Async call to send the given readonly message to the raft service. */
+  CompletableFuture<RaftClientReply> sendReadOnlyAsync(Message message);
+
+  /** Async call to send the given stale-read message to the given server (not the raft service). */
+  CompletableFuture<RaftClientReply> sendStaleReadAsync(Message message, long minIndex, RaftPeerId server);

Review comment:
       Rename this to sendStaleRead().

##########
File path: ratis-client/src/main/java/org/apache/ratis/client/api/AsyncApi.java
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ratis.client.api;
+
+import java.util.concurrent.CompletableFuture;
+import org.apache.ratis.proto.RaftProtos.ReplicationLevel;
+import org.apache.ratis.protocol.Message;
+import org.apache.ratis.protocol.RaftClientReply;
+import org.apache.ratis.protocol.RaftPeerId;
+
+/**
+ * APIs to support asynchronous operations such as send message, send (stale)read message and watch request.
+ */
+public interface AsyncApi {
+  /**
+   * Async call to send the given message to the raft service.
+   * The message may change the state of the service.
+   * For readonly messages, use {@link #sendReadOnlyAsync(Message)} instead.
+   *
+   * @param message The request message.
+   * @return a future of the reply.
+   */
+  CompletableFuture<RaftClientReply> sendAsync(Message message);

Review comment:
       Since this is an AsyncApi, we may remove "Async" from the method names.  Let's rename this to send().




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-ratis] szetszwo merged pull request #220: RATIS-1094. Move async methods from RaftClient to a new AsyncApi interface

Posted by GitBox <gi...@apache.org>.
szetszwo merged pull request #220:
URL: https://github.com/apache/incubator-ratis/pull/220


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-ratis] amaliujia commented on pull request #220: RATIS-1094. Move async api from RaftClient interface to AsyncApi inter…

Posted by GitBox <gi...@apache.org>.
amaliujia commented on pull request #220:
URL: https://github.com/apache/incubator-ratis/pull/220#issuecomment-707462843


   @szetszwo  thanks! comments addressed. 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org