ascherbakoff commented on a change in pull request #59: URL: https://github.com/apache/ignite-3/pull/59#discussion_r602071152
########## File path: modules/raft-client/src/main/java/org/apache/ignite/raft/client/service/RaftGroupService.java ########## @@ -0,0 +1,197 @@ +/* + * 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.ignite.raft.client.service; + +import java.util.Collection; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeoutException; +import org.apache.ignite.raft.client.Command; +import org.apache.ignite.raft.client.PeerId; +import org.apache.ignite.raft.client.ReadCommand; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * A service providing operations on a replication group. + * <p> + * Most of operations require a known group leader. The group leader can be refreshed at any time by calling + * {@link #refreshLeader()} method, otherwise it will happen automatically on a first call. + * <p> + * If a leader has been changed while the operation in progress, the operation will be transparently retried until + * timeout is reached. The current leader will be refreshed automatically (maybe several times) in the process. + * <p> + * Each asynchronous method (returning a future) uses a default timeout to finish, see {@link #timeout()}. + * If a result is not ready within the timeout, the future will be completed with a {@link TimeoutException} + * <p> + * If an error is occured during operation execution, the future will be completed with the corresponding + * IgniteException having an error code and a related message. + * <p> + * Async operations provided by the service are not cancellable. + */ +public interface RaftGroupService { + /** + * @return Group id. + */ + @NotNull String groupId(); + + /** + * @return Default timeout for the operations in milliseconds. + */ + long timeout(); + + /** + * Changes default timeout value for all subsequent operations. + * + * @param newTimeout New timeout value. + */ + void timeout(long newTimeout); + + /** + * @return Current leader id or {@code null} if it has not been yet initialized. + */ + @Nullable PeerId leader(); + + /** + * @return List of voting peers or {@code null} if it has not been yet initialized. + */ + @Nullable List<PeerId> peers(); Review comment: The position in the list reflects the time a peer has been added to the group. I prefer to have a List here for efficiency as well. -- 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: [email protected]
