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

kimmking 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 f11784d  Refactor instance node (#7093)
f11784d is described below

commit f11784db8c09afc3a631bfb64b24504da8c28aa8
Author: Haoran Meng <[email protected]>
AuthorDate: Thu Aug 27 11:29:31 2020 +0800

    Refactor instance node (#7093)
    
    * Refactor instance node
    
    * Remove useless unit test
---
 .../core/config/ConfigCenterNode.java              | 11 ------
 .../core/config/ConfigCenterNodeTest.java          |  5 ---
 .../core/registry/RegistryCenter.java              |  2 +-
 .../core/registry/RegistryCenterNodeStatus.java    | 12 +------
 .../core/registry/instance/DataSourceState.java    | 34 ------------------
 .../core/registry/instance/InstanceState.java      | 40 ----------------------
 .../listener/InstanceStateChangedListener.java     | 15 ++------
 .../listener/InstanceStateChangedListenerTest.java |  2 +-
 8 files changed, 5 insertions(+), 116 deletions(-)

diff --git 
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNode.java
 
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNode.java
index 527ff51..f91299b 100644
--- 
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNode.java
+++ 
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNode.java
@@ -46,8 +46,6 @@ public final class ConfigCenterNode {
     
     private static final String PROPS_NODE = "props";
     
-    private static final String CLUSTER_NODE = "cluster";
-    
     private static final String METRICS_NODE = "metrics";
     
     private static final String COMMA_SEPARATOR = ",";
@@ -158,15 +156,6 @@ public final class ConfigCenterNode {
     }
     
     /**
-     * Get cluster node path.
-     *
-     * @return cluster node path
-     */
-    public String getClusterPath() {
-        return getFullPath(CLUSTER_NODE);
-    }
-    
-    /**
      * Get metrics node path.
      *
      * @return metrics node path
diff --git 
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNodeTest.java
 
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNodeTest.java
index 8d12715..337f66a 100644
--- 
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNodeTest.java
+++ 
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNodeTest.java
@@ -73,11 +73,6 @@ public final class ConfigCenterNodeTest {
     }
     
     @Test
-    public void assertGetClusterPath() {
-        assertThat(configurationNode.getClusterPath(), is("/config/cluster"));
-    }
-    
-    @Test
     public void assertGetMetricsPath() {
         
assertTrue(configurationNode.getMetricsPath().contains("/config/metrics"));
     }
diff --git 
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenter.java
 
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenter.java
index ba4bdf4..b8a62e8 100644
--- 
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenter.java
+++ 
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenter.java
@@ -45,7 +45,7 @@ public final class RegistryCenter {
      * Persist instance online.
      */
     public void persistInstanceOnline() {
-        
repository.persistEphemeral(node.getInstancesNodeFullPath(instance.getInstanceId()),
 "state: " + RegistryCenterNodeStatus.ONLINE);
+        
repository.persistEphemeral(node.getInstancesNodeFullPath(instance.getInstanceId()),
 "");
     }
     
     /**
diff --git 
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterNodeStatus.java
 
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterNodeStatus.java
index a6bc694..4be71a3 100644
--- 
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterNodeStatus.java
+++ 
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterNodeStatus.java
@@ -25,15 +25,5 @@ public enum RegistryCenterNodeStatus {
     /**
      * Disabled state.
      */
-    DISABLED,
-    
-    /**
-     * Online state.
-     */
-    ONLINE,
-    
-    /**
-     *  Offline state.
-     */
-    OFFLINE
+    DISABLED
 }
diff --git 
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/instance/DataSourceState.java
 
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/instance/DataSourceState.java
deleted file mode 100644
index 010f338..0000000
--- 
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/instance/DataSourceState.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.orchestration.core.registry.instance;
-
-import lombok.Getter;
-import lombok.Setter;
-import 
org.apache.shardingsphere.orchestration.core.registry.RegistryCenterNodeStatus;
-
-/**
- * Data source state.
- */
-@Getter
-@Setter
-public final class DataSourceState {
-    
-    private RegistryCenterNodeStatus state;
-    
-    private Long lastConnect;
-}
diff --git 
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/instance/InstanceState.java
 
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/instance/InstanceState.java
deleted file mode 100644
index e38a550..0000000
--- 
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/instance/InstanceState.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.orchestration.core.registry.instance;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-import 
org.apache.shardingsphere.orchestration.core.registry.RegistryCenterNodeStatus;
-
-import java.util.Map;
-
-/**
- * Instance state.
- */
-@Getter
-@Setter
-@NoArgsConstructor
-@AllArgsConstructor
-public final class InstanceState {
-    
-    private RegistryCenterNodeStatus state;
-    
-    private Map<String, DataSourceState> dataSources;
-}
diff --git 
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateChangedListener.java
 
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateChanged
 [...]
index 21a9383..6aa25ec 100644
--- 
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateChangedListener.java
+++ 
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateChangedListener.java
@@ -17,16 +17,13 @@
 
 package org.apache.shardingsphere.orchestration.core.registry.listener;
 
-import com.google.common.base.Strings;
-import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
+import 
org.apache.shardingsphere.orchestration.core.common.listener.PostOrchestrationRepositoryEventListener;
 import 
org.apache.shardingsphere.orchestration.core.registry.RegistryCenterNode;
 import 
org.apache.shardingsphere.orchestration.core.registry.RegistryCenterNodeStatus;
 import 
org.apache.shardingsphere.orchestration.core.registry.event.CircuitStateChangedEvent;
-import 
org.apache.shardingsphere.orchestration.core.registry.instance.InstanceState;
 import 
org.apache.shardingsphere.orchestration.core.registry.instance.OrchestrationInstance;
 import 
org.apache.shardingsphere.orchestration.repository.api.RegistryRepository;
 import 
org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEvent;
-import 
org.apache.shardingsphere.orchestration.core.common.listener.PostOrchestrationRepositoryEventListener;
 
 import java.util.Collections;
 
@@ -41,14 +38,6 @@ public final class InstanceStateChangedListener extends 
PostOrchestrationReposit
     
     @Override
     protected CircuitStateChangedEvent createOrchestrationEvent(final 
DataChangedEvent event) {
-        return new CircuitStateChangedEvent(isCircuitBreak(event.getValue()));
-    }
-    
-    private boolean isCircuitBreak(final String value) {
-        if (!Strings.isNullOrEmpty(value)) {
-            return RegistryCenterNodeStatus.DISABLED.toString()
-                    .equalsIgnoreCase(YamlEngine.unmarshal(value, 
InstanceState.class).getState().toString());
-        }
-        return false;
+        return new 
CircuitStateChangedEvent(RegistryCenterNodeStatus.DISABLED.toString().equalsIgnoreCase(event.getValue()));
     }
 }
diff --git 
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateChangedListenerTest.java
 
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateCha
 [...]
index e78ccb1..38832f2 100644
--- 
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateChangedListenerTest.java
+++ 
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateChangedListenerTest.java
@@ -51,6 +51,6 @@ public final class InstanceStateChangedListenerTest {
     @Test
     public void assertCreateOrchestrationEventWhenDisabled() {
         assertTrue(instanceStateChangedListener.createOrchestrationEvent(new 
DataChangedEvent("/test_ds",
-                "state: " + RegistryCenterNodeStatus.DISABLED.name(), 
ChangedType.UPDATED)).isCircuitBreak());
+                RegistryCenterNodeStatus.DISABLED.name(), 
ChangedType.UPDATED)).isCircuitBreak());
     }
 }

Reply via email to