soulasuna commented on a change in pull request #16185: URL: https://github.com/apache/shardingsphere/pull/16185#discussion_r829790147
########## File path: shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-repository/shardingsphere-cluster-mode-repository-provider/shardingsphere-cluster-mode-repository-zookeeper-curator/src/main/java/org/apache/shardingsphere/mode/repository/cluster/zookeeper/listener/SessionConnectionListener.java ########## @@ -0,0 +1,71 @@ +/* + * 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.shardingsphere.mode.repository.cluster.zookeeper.listener; + +import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.state.ConnectionState; +import org.apache.curator.framework.state.ConnectionStateListener; +import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition; +import org.apache.shardingsphere.mode.metadata.persist.node.ComputeNode; +import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository; +import org.apache.shardingsphere.mode.repository.cluster.zookeeper.handler.CuratorZookeeperExceptionHandler; + +import java.util.concurrent.TimeUnit; + +/** + * Session connection state listener. + */ +@RequiredArgsConstructor +public final class SessionConnectionListener implements ConnectionStateListener { + + private static final int RECONNECT_INTERVAL_SECONDS = 5; + + private final InstanceDefinition instanceDefinition; + + private final ClusterPersistRepository repository; + + @Override + public void stateChanged(final CuratorFramework client, final ConnectionState connectionState) { + if (ConnectionState.LOST == connectionState) { + while (reRegister(client)) { Review comment: Here is an asynchronous process. When session time out will keep trying to connect to the registry will always try to connect to the registry every 5 seconds. Return when re-registered. -- 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]
