This is an automated email from the ASF dual-hosted git repository.

zhaojinchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 10b25c02cbd refactor instance dist sql (#18004)
10b25c02cbd is described below

commit 10b25c02cbd940322dcdc263c5ee8046279ad2f0
Author: Haoran Meng <[email protected]>
AuthorDate: Fri May 27 16:23:16 2022 +0800

    refactor instance dist sql (#18004)
---
 .../ClusterContextManagerCoordinator.java          |  3 +-
 .../cluster/coordinator/RegistryCenter.java        |  2 +-
 .../status/compute/event/LabelsChangedEvent.java   | 35 ++++++++++++++++++++++
 .../compute/event/XaRecoveryIdChangedEvent.java    | 33 ++++++++++++++++++++
 .../compute/service/ComputeNodeStatusService.java  | 17 +----------
 .../subscriber/ComputeNodeStatusSubscriber.java    | 35 ++++++++++++++++++++--
 .../service/ComputeNodeStatusServiceTest.java      |  2 +-
 .../ral/common/queryable/ShowInstanceHandler.java  | 12 ++++----
 .../ral/common/updatable/AlterInstanceHandler.java |  4 +--
 .../ral/common/updatable/LabelInstanceHandler.java |  5 ++--
 .../common/updatable/UnlabelInstanceHandler.java   |  7 +++--
 11 files changed, 119 insertions(+), 36 deletions(-)

diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinator.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinator.java
index 3ea25752e9b..341564768ff 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinator.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinator.java
@@ -261,8 +261,7 @@ public final class ClusterContextManagerCoordinator {
      */
     @Subscribe
     public synchronized void renew(final InstanceOnlineEvent event) {
-        ComputeNodeInstance instance = new 
ComputeNodeInstance(event.getInstanceDefinition());
-        contextManager.getInstanceContext().addComputeNodeInstance(instance);
+        
contextManager.getInstanceContext().addComputeNodeInstance(registryCenter.getComputeNodeStatusService().loadComputeNodeInstance(event.getInstanceDefinition()));
     }
     
     /**
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/RegistryCenter.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/RegistryCenter.java
index edde2f881b8..8a59f409721 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/RegistryCenter.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/RegistryCenter.java
@@ -61,7 +61,7 @@ public final class RegistryCenter {
     
     private void createSubscribers(final ClusterPersistRepository repository) {
         new SchemaMetaDataRegistrySubscriber(repository);
-        new ComputeNodeStatusSubscriber(repository);
+        new ComputeNodeStatusSubscriber(this, repository);
         new StorageNodeStatusSubscriber(repository);
         new ScalingRegistrySubscriber(repository);
         new ProcessRegistrySubscriber(repository);
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/event/LabelsChangedEvent.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/event/LabelsChangedEvent.java
new file mode 100644
index 00000000000..43293f9aa8c
--- /dev/null
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/event/LabelsChangedEvent.java
@@ -0,0 +1,35 @@
+/*
+ * 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.manager.cluster.coordinator.registry.status.compute.event;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+import java.util.Collection;
+
+/**
+ * Labels changed event.
+ */
+@RequiredArgsConstructor
+@Getter
+public final class LabelsChangedEvent {
+    
+    private final String instanceId;
+    
+    private final Collection<String> labels;
+}
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/event/XaRecoveryIdChangedEvent.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/event/XaRecoveryIdChangedEvent.java
new file mode 100644
index 00000000000..0f88390e428
--- /dev/null
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/event/XaRecoveryIdChangedEvent.java
@@ -0,0 +1,33 @@
+/*
+ * 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.manager.cluster.coordinator.registry.status.compute.event;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+/**
+ * Xa recovery id changed event.
+ */
+@RequiredArgsConstructor
+@Getter
+public final class XaRecoveryIdChangedEvent {
+    
+    private final String instanceId;
+    
+    private final String xaRecoveryId;
+}
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusService.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusService.java
index 36178bff7e9..6ecbe83ca6b 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusService.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusService.java
@@ -58,26 +58,11 @@ public final class ComputeNodeStatusService {
      * @param labels collection of label
      */
     public void persistInstanceLabels(final String instanceId, final 
Collection<String> labels) {
-        if (null != labels && !labels.isEmpty()) {
+        if (null != labels) {
             
repository.persistEphemeral(ComputeNode.getInstanceLabelsNodePath(instanceId), 
YamlEngine.marshal(labels));
         }
     }
     
-    /**
-     * Delete instance labels.
-     *
-     * @param instanceId instance id
-     */
-    public void deleteInstanceLabels(final String instanceId) {
-        if (isExisted(instanceId)) {
-            
repository.delete(ComputeNode.getInstanceLabelsNodePath(instanceId));
-        }
-    }
-    
-    private boolean isExisted(final String instanceId) {
-        return 
!Strings.isNullOrEmpty(repository.get(ComputeNode.getInstanceLabelsNodePath(instanceId)));
-    }
-    
     /**
      * Persist instance worker id.
      *
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/subscriber/ComputeNodeStatusSubscriber.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/subscriber/ComputeNodeStatus
 [...]
index 30ecd562ffc..e22be627165 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/subscriber/ComputeNodeStatusSubscriber.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/subscriber/ComputeNodeStatusSubscriber.java
@@ -22,22 +22,29 @@ import com.google.common.eventbus.Subscribe;
 import org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
 import org.apache.shardingsphere.infra.instance.definition.InstanceId;
 import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
+import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.RegistryCenter;
 import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.ComputeNodeStatus;
 import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.event.ComputeNodeStatusChangedEvent;
+import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.event.LabelsChangedEvent;
+import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.event.XaRecoveryIdChangedEvent;
 import org.apache.shardingsphere.mode.metadata.persist.node.ComputeNode;
 import 
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 
 /**
  * Compute node status subscriber.
  */
 public final class ComputeNodeStatusSubscriber {
     
+    private final RegistryCenter registryCenter;
+    
     private final ClusterPersistRepository repository;
     
-    public ComputeNodeStatusSubscriber(final ClusterPersistRepository 
repository) {
+    public ComputeNodeStatusSubscriber(final RegistryCenter registryCenter, 
final ClusterPersistRepository repository) {
+        this.registryCenter = registryCenter;
         this.repository = repository;
         ShardingSphereEventBus.getInstance().register(this);
     }
@@ -57,6 +64,30 @@ public final class ComputeNodeStatusSubscriber {
         } else {
             status.remove(ComputeNodeStatus.CIRCUIT_BREAK.name());
         }
-        repository.persist(computeStatusNodePath, YamlEngine.marshal(status));
+        repository.persistEphemeral(computeStatusNodePath, 
YamlEngine.marshal(status));
+    }
+    
+    /**
+     * Update compute node xa recovery id.
+     * 
+     * @param event xa recovery id changed event
+     */
+    @Subscribe
+    public void update(final XaRecoveryIdChangedEvent event) {
+        
registryCenter.getComputeNodeStatusService().persistInstanceXaRecoveryId(event.getInstanceId(),
 event.getXaRecoveryId());
+    }
+    
+    /**
+     * Update compute node labels.
+     * 
+     * @param event labels changed event
+     */
+    @Subscribe
+    public void update(final LabelsChangedEvent event) {
+        if (event.getLabels().isEmpty()) {
+            
registryCenter.getComputeNodeStatusService().persistInstanceLabels(event.getInstanceId(),
 Collections.EMPTY_LIST);
+        } else {
+            
registryCenter.getComputeNodeStatusService().persistInstanceLabels(event.getInstanceId(),
 event.getLabels());
+        }
     }
 }
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusServiceTest.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusServi
 [...]
index 0aac987ee72..b8216e68ccb 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusServiceTest.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusServiceTest.java
@@ -58,7 +58,7 @@ public final class ComputeNodeStatusServiceTest {
         computeNodeStatusService.persistInstanceLabels(instanceId, 
Collections.singletonList("test"));
         verify(repository, 
times(1)).persistEphemeral(ComputeNode.getInstanceLabelsNodePath(instanceId), 
YamlEngine.marshal(Collections.singletonList("test")));
         computeNodeStatusService.persistInstanceLabels(instanceId, 
Collections.emptyList());
-        verify(repository, 
times(0)).persistEphemeral(ComputeNode.getInstanceLabelsNodePath(instanceId), 
YamlEngine.marshal(Collections.emptyList()));
+        verify(repository, 
times(1)).persistEphemeral(ComputeNode.getInstanceLabelsNodePath(instanceId), 
YamlEngine.marshal(Collections.emptyList()));
     }
     
     @Test
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceHandler.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceHandler.java
index 3179be1abb9..6c4f97506c5 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceHandler.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceHandler.java
@@ -19,7 +19,6 @@ package 
org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.queryabl
 
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.queryable.ShowInstanceStatement;
 import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
-import org.apache.shardingsphere.infra.instance.InstanceContext;
 import org.apache.shardingsphere.infra.instance.definition.InstanceType;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import 
org.apache.shardingsphere.proxy.backend.text.distsql.ral.QueryableRALBackendHandler;
@@ -60,16 +59,15 @@ public final class ShowInstanceHandler extends 
QueryableRALBackendHandler<ShowIn
     
     @Override
     protected Collection<List<Object>> getRows(final ContextManager 
contextManager) {
-        InstanceContext instanceContext = contextManager.getInstanceContext();
-        String modeType = instanceContext.getModeConfiguration().getType();
-        return buildInstanceRows(instanceContext, modeType);
+        return buildInstanceRows(contextManager);
     }
     
-    private Collection<List<Object>> buildInstanceRows(final InstanceContext 
instanceContext, final String modeType) {
+    private Collection<List<Object>> buildInstanceRows(final ContextManager 
contextManager) {
+        String modeType = 
contextManager.getInstanceContext().getModeConfiguration().getType();
         if ("Memory".equalsIgnoreCase(modeType) || 
"Standalone".equalsIgnoreCase(modeType)) {
-            return 
Collections.singletonList(buildRow(instanceContext.getInstance(), modeType));
+            return 
Collections.singletonList(buildRow(contextManager.getInstanceContext().getInstance(),
 modeType));
         }
-        Collection<ComputeNodeInstance> instances = 
instanceContext.getComputeNodeInstances().stream()
+        Collection<ComputeNodeInstance> instances = 
contextManager.getInstanceContext().getComputeNodeInstances().stream()
                 .filter(each -> 
InstanceType.PROXY.equals(each.getInstanceDefinition().getInstanceType())).collect(Collectors.toList());
         return instances.isEmpty() ? Collections.emptyList()
                 : instances.stream().filter(Objects::nonNull).map(each -> 
buildRow(each, modeType)).collect(Collectors.toList());
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterInstanceHandler.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterInstanceHandler.java
index 0a5c7e73151..894e8c2ed66 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterInstanceHandler.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterInstanceHandler.java
@@ -21,7 +21,7 @@ import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.A
 import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
 import org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
 import org.apache.shardingsphere.mode.manager.ContextManager;
-import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.event.XaRecoveryIdEvent;
+import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.event.XaRecoveryIdChangedEvent;
 import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
 import 
org.apache.shardingsphere.proxy.backend.text.distsql.ral.UpdatableRALBackendHandler;
 
@@ -52,6 +52,6 @@ public final class AlterInstanceHandler extends 
UpdatableRALBackendHandler<Alter
             throw new UnsupportedOperationException(String.format("'%s' does 
not exist", sqlStatement.getInstanceId()));
         }
         // TODO need support standalone mode
-        ShardingSphereEventBus.getInstance().post(new 
XaRecoveryIdEvent(sqlStatement.getInstanceId(), sqlStatement.getValue()));
+        ShardingSphereEventBus.getInstance().post(new 
XaRecoveryIdChangedEvent(sqlStatement.getInstanceId(), 
sqlStatement.getValue()));
     }
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/LabelInstanceHandler.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/LabelInstanceHandler.java
index 563ea75a4c6..f012de01053 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/LabelInstanceHandler.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/LabelInstanceHandler.java
@@ -22,7 +22,7 @@ import 
org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
 import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
 import org.apache.shardingsphere.infra.instance.definition.InstanceId;
 import org.apache.shardingsphere.mode.manager.ContextManager;
-import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.event.LabelsEvent;
+import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.event.LabelsChangedEvent;
 import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
 import 
org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRepository;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -30,6 +30,7 @@ import 
org.apache.shardingsphere.proxy.backend.text.distsql.ral.UpdatableRALBack
 
 import java.util.Collection;
 import java.util.LinkedHashSet;
+import java.util.LinkedList;
 import java.util.Optional;
 
 /**
@@ -50,7 +51,7 @@ public final class LabelInstanceHandler extends 
UpdatableRALBackendHandler<Label
             if (!sqlStatement.isOverwrite() && null != 
computeNodeInstance.get().getLabels()) {
                 labels.addAll(computeNodeInstance.get().getLabels());
             }
-            ShardingSphereEventBus.getInstance().post(new 
LabelsEvent(instanceId, labels));
+            ShardingSphereEventBus.getInstance().post(new 
LabelsChangedEvent(instanceId, new LinkedList<>(labels)));
         }
     }
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/UnlabelInstanceHandler.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/UnlabelInstanceHandler.java
index 78294bbbbe7..a54f43901a4 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/UnlabelInstanceHandler.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/UnlabelInstanceHandler.java
@@ -23,7 +23,7 @@ import 
org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
 import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
 import org.apache.shardingsphere.infra.instance.definition.InstanceId;
 import org.apache.shardingsphere.mode.manager.ContextManager;
-import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.event.LabelsEvent;
+import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.event.LabelsChangedEvent;
 import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
 import 
org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRepository;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -32,6 +32,7 @@ import 
org.apache.shardingsphere.proxy.backend.text.distsql.ral.UpdatableRALBack
 import java.util.Collection;
 import java.util.Collections;
 import java.util.LinkedHashSet;
+import java.util.LinkedList;
 import java.util.Optional;
 
 /**
@@ -50,10 +51,10 @@ public final class UnlabelInstanceHandler extends 
UpdatableRALBackendHandler<Unl
         if (computeNodeInstance.isPresent()) {
             Collection<String> labels = new 
LinkedHashSet<>(computeNodeInstance.get().getLabels());
             if (sqlStatement.getLabels().isEmpty()) {
-                ShardingSphereEventBus.getInstance().post(new 
LabelsEvent(instanceId, Collections.EMPTY_LIST));
+                ShardingSphereEventBus.getInstance().post(new 
LabelsChangedEvent(instanceId, Collections.EMPTY_LIST));
             } else {
                 labels.removeAll(sqlStatement.getLabels());
-                ShardingSphereEventBus.getInstance().post(new 
LabelsEvent(instanceId, labels));
+                ShardingSphereEventBus.getInstance().post(new 
LabelsChangedEvent(instanceId, new LinkedList<>(labels)));
             }
         }
     }

Reply via email to