tkalkirill commented on code in PR #4147: URL: https://github.com/apache/ignite-3/pull/4147#discussion_r1693074752
########## modules/cluster-management/src/main/java/org/apache/ignite/internal/cluster/management/network/CmgMessageHandler.java: ########## @@ -0,0 +1,153 @@ +/* + * 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.cluster.management.network; + +import java.util.ArrayList; +import java.util.List; +import org.apache.ignite.internal.cluster.management.ClusterManagementGroupManager; +import org.apache.ignite.internal.cluster.management.network.messages.CancelInitMessage; +import org.apache.ignite.internal.cluster.management.network.messages.ClusterStateMessage; +import org.apache.ignite.internal.cluster.management.network.messages.CmgInitMessage; +import org.apache.ignite.internal.cluster.management.network.messages.CmgMessagesFactory; +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.ClusterService; +import org.apache.ignite.internal.network.NetworkMessage; +import org.apache.ignite.internal.network.NetworkMessageHandler; +import org.apache.ignite.internal.util.IgniteSpinBusyLock; +import org.apache.ignite.network.ClusterNode; +import org.jetbrains.annotations.Nullable; + +/** + * Network message handler for CMG messages. + * + * <p>This handler buffers incoming messages until the parent component signals that its local recovery has been complete (by calling + * {@link #onRecoveryComplete}) after which it passes the buffered messages to the registered callback and then continues to behave like a + * regular message handler. + */ +public class CmgMessageHandler implements NetworkMessageHandler { + private static final IgniteLogger LOG = Loggers.forClass(ClusterManagementGroupManager.class); + + private final IgniteSpinBusyLock busyLock; + + private final CmgMessagesFactory msgFactory; + + private final ClusterService clusterService; + + private final CmgMessageCallback cmgMessageCallback; + + @Nullable + private List<NetworkMessageContext> messageQueue = new ArrayList<>(); + + private boolean isRecoveryComplete = false; + + private static class NetworkMessageContext { + final NetworkMessage message; + + final ClusterNode sender; + + @Nullable + final Long correlationId; Review Comment: Yes, this is a suggestion. -- 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]
