Cyrill commented on code in PR #7507:
URL: https://github.com/apache/ignite-3/pull/7507#discussion_r2852793905
##########
modules/raft/src/main/java/org/apache/ignite/internal/raft/client/PhysicalTopologyAwareRaftGroupService.java:
##########
@@ -76,21 +90,30 @@ public class PhysicalTopologyAwareRaftGroupService
implements TimeAwareRaftGroup
/** Cluster service. */
private final ClusterService clusterService;
- /** RPC RAFT client. */
- private final RaftGroupService raftClient;
-
- /** Executor to invoke RPC requests. */
- private final ScheduledExecutorService executor;
-
- /** RAFT configuration. */
- private final RaftConfiguration raftConfiguration;
-
/** Factory for creating stopping exceptions. */
private final ExceptionFactory stoppingExceptionFactory;
/** Command executor with retry semantics. */
private final RaftCommandExecutor commandExecutor;
+ /** Sender for subscription messages with retry logic. */
+ private final SubscriptionMessageSender messageSender;
Review Comment:
Well, not really "Now", such approach has been designed when the file was
created, so there are no changes in terms of the logic you described.
Other than that, you're right. Subscription and raft functioning is
implemented using two different ways. Once
[IGNITE-27256](https://issues.apache.org/jira/browse/IGNITE-27256) is
implemented, the subscription should be changed.
##########
modules/raft/src/main/java/org/apache/ignite/internal/raft/client/SubscriptionMessageSender.java:
##########
@@ -0,0 +1,135 @@
+/*
+ * 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.raft.client;
+
+import static org.apache.ignite.internal.util.ExceptionUtils.unwrapCause;
+
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ScheduledExecutorService;
+import org.apache.ignite.internal.lang.NodeStoppingException;
+import org.apache.ignite.internal.logger.IgniteLogger;
+import org.apache.ignite.internal.logger.Loggers;
+import org.apache.ignite.internal.network.InternalClusterNode;
+import org.apache.ignite.internal.network.MessagingService;
+import org.apache.ignite.internal.network.RecipientLeftException;
+import org.apache.ignite.internal.network.handshake.HandshakeException;
+import org.apache.ignite.internal.raft.configuration.RaftConfiguration;
+import
org.apache.ignite.raft.jraft.rpc.CliRequests.SubscriptionLeaderChangeRequest;
+
+/**
+ * Handles sending subscription messages to RAFT group members with retry
logic.
+ */
+class SubscriptionMessageSender {
+ private static final IgniteLogger LOG =
Loggers.forClass(SubscriptionMessageSender.class);
+
+ private final ScheduledExecutorService executor;
+
+ private final RaftConfiguration raftConfiguration;
+
+ private final MessagingService messagingService;
+
+ /**
+ * Constructor.
+ *
+ * @param messagingService Messaging service.
+ * @param executor Executor for async operations.
+ * @param raftConfiguration RAFT configuration.
+ */
+ SubscriptionMessageSender(
+ MessagingService messagingService,
+ ScheduledExecutorService executor,
+ RaftConfiguration raftConfiguration
+ ) {
+ this.messagingService = messagingService;
+ this.executor = executor;
+ this.raftConfiguration = raftConfiguration;
+ }
+
+ /**
+ * Sends a subscription message to the specified node with retry logic.
+ *
+ * @param node Target node.
+ * @param msg Subscription message to send.
+ * @return Future that completes with {@code true} if the message was sent
successfully,
+ * {@code false} if sending failed but should not be treated as an
error,
+ * or completes exceptionally on unrecoverable errors.
+ */
+ CompletableFuture<Boolean> send(InternalClusterNode node,
SubscriptionLeaderChangeRequest msg) {
+ var msgSendFut = new CompletableFuture<Boolean>();
+
+ sendWithRetry(node, msg, msgSendFut);
+
+ return msgSendFut;
+ }
+
+ private void sendWithRetry(InternalClusterNode node,
SubscriptionLeaderChangeRequest msg, CompletableFuture<Boolean> msgSendFut) {
+ Long responseTimeout =
raftConfiguration.responseTimeoutMillis().value();
+
+ messagingService.invoke(node, msg,
responseTimeout).whenCompleteAsync((unused, invokeThrowable) -> {
+ if (invokeThrowable == null) {
+ msgSendFut.complete(true);
+
+ return;
+ }
+
+ Throwable invokeCause = unwrapCause(invokeThrowable);
Review Comment:
done
--
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]