rpuch commented on code in PR #5352: URL: https://github.com/apache/ignite-3/pull/5352#discussion_r1983145082
########## modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/ReplicaPrimacyEngine.java: ########## @@ -0,0 +1,165 @@ +/* + * 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.partition.replicator; + +import static java.util.concurrent.CompletableFuture.completedFuture; +import static java.util.concurrent.CompletableFuture.failedFuture; + +import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.function.Function; +import org.apache.ignite.internal.hlc.ClockService; +import org.apache.ignite.internal.hlc.HybridTimestamp; +import org.apache.ignite.internal.partition.replicator.network.replication.ReadOnlyReplicaRequest; +import org.apache.ignite.internal.placementdriver.LeasePlacementDriver; +import org.apache.ignite.internal.placementdriver.ReplicaMeta; +import org.apache.ignite.internal.replicator.ReplicationGroupId; +import org.apache.ignite.internal.replicator.exception.PrimaryReplicaMissException; +import org.apache.ignite.internal.replicator.message.PrimaryReplicaRequest; +import org.apache.ignite.internal.replicator.message.ReplicaRequest; +import org.apache.ignite.internal.replicator.message.ReplicaSafeTimeSyncRequest; +import org.apache.ignite.network.ClusterNode; + +/** + * Logic related to replica primacy checks. + */ +public class ReplicaPrimacyEngine { + private final LeasePlacementDriver placementDriver; + private final ClockService clockService; + private final ReplicationGroupId replicationGroupId; + private final ClusterNode localNode; + + /** Constructor. */ + public ReplicaPrimacyEngine( + LeasePlacementDriver placementDriver, + ClockService clockService, + ReplicationGroupId replicationGroupId, + ClusterNode localNode + ) { + this.placementDriver = placementDriver; + this.clockService = clockService; + this.replicationGroupId = replicationGroupId; + this.localNode = localNode; + } + + /** + * Validates replica primacy. + * + * <ul> + * <li>For {@link PrimaryReplicaRequest}s, ensures that the primary replica is known, that it is hosted to this node, + * that it has not expired and corresponds to the request (i.e. it has not changed). If something of the above is violated, the Review Comment: Rephrased -- 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org