sanpwc commented on code in PR #2078: URL: https://github.com/apache/ignite-3/pull/2078#discussion_r1197861881
########## modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/PlacementDriver.java: ########## @@ -0,0 +1,51 @@ +/* + * 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.internal.placementdriver; + +import java.util.concurrent.CompletableFuture; +import org.apache.ignite.internal.hlc.HybridTimestamp; +import org.apache.ignite.internal.replicator.ReplicationGroupId; + +/** + * Service that provides an ability to await and retrieve primary replicas for replication groups. + */ +public interface PlacementDriver { + /** + * Returns a future for the primary replica for the specified replication group whose expiration time (the right border of the + * corresponding lease interval) is greater than or equal to the timestamp passed as a parameter. Please pay attention that there are + * no restriction on the lease start time (left border), it can either be less or greater than or equal to proposed timestamp. + * Given method will await for an appropriate primary replica appearance if there's no already existing one. Such awaiting logic is + * unbounded, so it's mandatory to use explicit await termination like {@code orTimeout}. + * + * @param groupId Replication group id. + * @param timestamp Timestamp reference value. + * @return Primary replica future. + */ + CompletableFuture<LeaseMeta> awaitPrimaryReplica(ReplicationGroupId groupId, HybridTimestamp timestamp); + + /** + * Same as {@link #awaitPrimaryReplica(ReplicationGroupId, HybridTimestamp)} despite the fact that given method await logic is bounded. + * It will wait for a primary replica for a reasonable period of time, and complete a future with {@code TimeoutException} if a matching + * lease isn't found. Generally speaking reasonable here means enough for distribution across cluster nodes. + * + * @param replicationGroupId Replication group id. + * @param timestamp Timestamp reference value. + * @return Primary replica future. + */ + CompletableFuture<LeaseMeta> getPrimaryReplica(ReplicationGroupId replicationGroupId, HybridTimestamp timestamp); +} Review Comment: Added. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
