Remove cluster state
diff --git a/shardingsphere-ui-backend/pom.xml b/shardingsphere-ui-backend/pom.xml
index 9d2304e..2a5308e 100644
--- a/shardingsphere-ui-backend/pom.xml
+++ b/shardingsphere-ui-backend/pom.xml
@@ -62,11 +62,6 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-cluster-facade</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
diff --git a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/ClusterService.java b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/ClusterService.java
deleted file mode 100644
index 182f530..0000000
--- a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/ClusterService.java
+++ /dev/null
@@ -1,35 +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.ui.servcie;
-
-import org.apache.shardingsphere.cluster.state.InstanceState;
-
-import java.util.Map;
-
-/**
- * Cluster service.
- */
-public interface ClusterService {
-
- /**
- * Load all instance states.
- *
- * @return all instance states
- */
- Map<String, InstanceState> loadAllInstanceStates();
-}
diff --git a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/ConfigCenterService.java b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/ConfigCenterService.java
index bd466bb..13e55ab 100644
--- a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/ConfigCenterService.java
+++ b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/ConfigCenterService.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.ui.servcie;
import org.apache.shardingsphere.orchestration.core.config.ConfigCenterNode;
-import org.apache.shardingsphere.orchestration.repository.api.ConfigCenterRepository;
+import org.apache.shardingsphere.orchestration.repository.api.ConfigurationRepository;
/**
* Config center service
@@ -30,7 +30,7 @@
*
* @return config center
*/
- ConfigCenterRepository getActivatedConfigCenter();
+ ConfigurationRepository getActivatedConfigCenter();
/**
* Get activated configuration node.
diff --git a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/RegistryCenterService.java b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/RegistryCenterService.java
index d60c98b..db089f0 100644
--- a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/RegistryCenterService.java
+++ b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/RegistryCenterService.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.ui.servcie;
import org.apache.shardingsphere.orchestration.core.registry.RegistryCenterNode;
-import org.apache.shardingsphere.orchestration.repository.api.RegistryCenterRepository;
+import org.apache.shardingsphere.orchestration.repository.api.RegistryRepository;
/**
* Registry center service.
@@ -30,7 +30,7 @@
*
* @return registry center
*/
- RegistryCenterRepository getActivatedRegistryCenter();
+ RegistryRepository getActivatedRegistryCenter();
/**
* Get activated state node.
diff --git a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/ClusterServiceImpl.java b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/ClusterServiceImpl.java
deleted file mode 100644
index e68fe6e..0000000
--- a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/ClusterServiceImpl.java
+++ /dev/null
@@ -1,62 +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.ui.servcie.impl;
-
-import lombok.extern.slf4j.Slf4j;
-import org.apache.shardingsphere.cluster.state.InstanceState;
-import org.apache.shardingsphere.cluster.state.enums.NodeState;
-import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
-import org.apache.shardingsphere.ui.servcie.ClusterService;
-import org.apache.shardingsphere.ui.servcie.RegistryCenterService;
-import org.springframework.stereotype.Service;
-import org.springframework.util.StringUtils;
-
-import javax.annotation.Resource;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Implementation of cluster service.
- */
-@Service
-@Slf4j
-public final class ClusterServiceImpl implements ClusterService {
-
- @Resource
- private RegistryCenterService registryCenterService;
-
- @Override
- public Map<String, InstanceState> loadAllInstanceStates() {
- List<String> instanceIds = registryCenterService.getActivatedRegistryCenter()
- .getChildrenKeys(registryCenterService.getActivatedStateNode().getInstanceNodeRootPath());
- Map<String, InstanceState> instanceStateMap = new HashMap<>();
- instanceIds.forEach(each -> instanceStateMap.put(each, loadInstanceState(each)));
- return instanceStateMap;
- }
-
- private InstanceState loadInstanceState(final String instanceId) {
- String instanceStateData = registryCenterService.getActivatedRegistryCenter()
- .get(registryCenterService.getActivatedStateNode().getInstancesNodeFullPath(instanceId));
- if (StringUtils.isEmpty(instanceStateData)) {
- log.error("can not load instance '{}' state data", instanceId);
- return new InstanceState(NodeState.UNKNOWN, new HashMap<>());
- }
- return YamlEngine.unmarshal(instanceStateData, InstanceState.class);
- }
-}
diff --git a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/ConfigCenterServiceImpl.java b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/ConfigCenterServiceImpl.java
index a59d9eb..f166be2 100644
--- a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/ConfigCenterServiceImpl.java
+++ b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/ConfigCenterServiceImpl.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.ui.servcie.impl;
import org.apache.shardingsphere.orchestration.core.config.ConfigCenterNode;
-import org.apache.shardingsphere.orchestration.repository.api.ConfigCenterRepository;
+import org.apache.shardingsphere.orchestration.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.ui.common.constant.OrchestrationType;
import org.apache.shardingsphere.ui.common.domain.CenterConfig;
import org.apache.shardingsphere.ui.common.exception.ShardingSphereUIException;
@@ -40,7 +40,7 @@
private CenterConfigService centerConfigService;
@Override
- public ConfigCenterRepository getActivatedConfigCenter() {
+ public ConfigurationRepository getActivatedConfigCenter() {
Optional<CenterConfig> optional = centerConfigService.loadActivated(OrchestrationType.CONFIG_CENTER.getValue());
if (optional.isPresent()) {
return CenterRepositoryFactory.createConfigCenter(optional.get());
@@ -52,7 +52,7 @@
public ConfigCenterNode getActivateConfigurationNode() {
Optional<CenterConfig> optional = centerConfigService.loadActivated(OrchestrationType.CONFIG_CENTER.getValue());
if (optional.isPresent()) {
- return new ConfigCenterNode(optional.get().getOrchestrationName());
+ return new ConfigCenterNode();
}
throw new ShardingSphereUIException(ShardingSphereUIException.SERVER_ERROR, "No activated config center!");
}
diff --git a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/MetadataCenterServiceImpl.java b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/MetadataCenterServiceImpl.java
index cd33dfa..892a8a0 100644
--- a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/MetadataCenterServiceImpl.java
+++ b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/MetadataCenterServiceImpl.java
@@ -41,7 +41,7 @@
public MetaDataCenterNode getActivateMetaDataCenterNode() {
Optional<CenterConfig> optional = centerConfigService.loadActivated(OrchestrationType.CONFIG_CENTER.getValue());
if (optional.isPresent()) {
- return new MetaDataCenterNode(optional.get().getOrchestrationName());
+ return new MetaDataCenterNode();
}
throw new ShardingSphereUIException(ShardingSphereUIException.SERVER_ERROR, "No activated metadata center!");
}
diff --git a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/RegistryCenterServiceImpl.java b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/RegistryCenterServiceImpl.java
index f3b0a74..588bc91 100644
--- a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/RegistryCenterServiceImpl.java
+++ b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/RegistryCenterServiceImpl.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.ui.servcie.impl;
import org.apache.shardingsphere.orchestration.core.registry.RegistryCenterNode;
-import org.apache.shardingsphere.orchestration.repository.api.RegistryCenterRepository;
+import org.apache.shardingsphere.orchestration.repository.api.RegistryRepository;
import org.apache.shardingsphere.ui.common.constant.OrchestrationType;
import org.apache.shardingsphere.ui.common.domain.CenterConfig;
import org.apache.shardingsphere.ui.common.exception.ShardingSphereUIException;
@@ -40,7 +40,7 @@
private CenterConfigService centerConfigService;
@Override
- public RegistryCenterRepository getActivatedRegistryCenter() {
+ public RegistryRepository getActivatedRegistryCenter() {
Optional<CenterConfig> optional = centerConfigService.loadActivated(OrchestrationType.REGISTRY_CENTER.getValue());
if (optional.isPresent()) {
return CenterRepositoryFactory.createRegistryCenter(optional.get());
@@ -52,7 +52,7 @@
public RegistryCenterNode getActivatedStateNode() {
Optional<CenterConfig> optional = centerConfigService.loadActivated(OrchestrationType.REGISTRY_CENTER.getValue());
if (optional.isPresent()) {
- return new RegistryCenterNode(optional.get().getOrchestrationName());
+ return new RegistryCenterNode();
}
throw new ShardingSphereUIException(ShardingSphereUIException.SERVER_ERROR, "No activated registry center!");
}
diff --git a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/ShardingSchemaServiceImpl.java b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/ShardingSchemaServiceImpl.java
index cdd374f..0978ace 100644
--- a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/ShardingSchemaServiceImpl.java
+++ b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/ShardingSchemaServiceImpl.java
@@ -22,7 +22,7 @@
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.config.DataSourceConfiguration;
-import org.apache.shardingsphere.orchestration.repository.api.ConfigCenterRepository;
+import org.apache.shardingsphere.orchestration.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.ui.servcie.ConfigCenterService;
import org.apache.shardingsphere.ui.servcie.MetadataCenterService;
import org.apache.shardingsphere.ui.servcie.ShardingSchemaService;
@@ -86,7 +86,7 @@
@Override
public void deleteSchemaConfiguration(final String schemaName) {
- ConfigCenterRepository configCenterRepository = configCenterService.getActivatedConfigCenter();
+ ConfigurationRepository configCenterRepository = configCenterService.getActivatedConfigCenter();
String schemaNamePath = configCenterService.getActivateConfigurationNode().getSchemaNamePath(schemaName);
configCenterRepository.delete(schemaNamePath);
String schemaNames = configCenterRepository.get(configCenterService.getActivateConfigurationNode().getSchemaPath());
@@ -136,7 +136,7 @@
}
private void persistSchemaName(final String schemaName) {
- ConfigCenterRepository configCenterRepository = configCenterService.getActivatedConfigCenter();
+ ConfigurationRepository configCenterRepository = configCenterService.getActivatedConfigCenter();
String schemaPath = configCenterService.getActivateConfigurationNode().getSchemaPath();
String schemaNames = configCenterRepository.get(schemaPath);
List<String> schemaNameList = Strings.isNullOrEmpty(schemaNames) ? new ArrayList<>() : new ArrayList<>(Splitter.on(",").splitToList(schemaNames));
diff --git a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/util/CenterRepositoryFactory.java b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/util/CenterRepositoryFactory.java
index dbc0b14..4f79ca6 100644
--- a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/util/CenterRepositoryFactory.java
+++ b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/util/CenterRepositoryFactory.java
@@ -19,11 +19,11 @@
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.orchestration.repository.zookeeper.CuratorZookeeperCenterRepository;
-import org.apache.shardingsphere.orchestration.repository.api.ConfigCenterRepository;
-import org.apache.shardingsphere.orchestration.repository.api.RegistryCenterRepository;
-import org.apache.shardingsphere.orchestration.repository.api.config.CenterConfiguration;
-import org.apache.shardingsphere.orchestration.repository.etcd.EtcdCenterRepository;
+import org.apache.shardingsphere.orchestration.repository.api.ConfigurationRepository;
+import org.apache.shardingsphere.orchestration.repository.api.RegistryRepository;
+import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationCenterConfiguration;
+import org.apache.shardingsphere.orchestration.repository.etcd.EtcdRepository;
+import org.apache.shardingsphere.orchestration.repository.zookeeper.CuratorZookeeperRepository;
import org.apache.shardingsphere.ui.common.constant.InstanceType;
import org.apache.shardingsphere.ui.common.domain.CenterConfig;
@@ -36,9 +36,9 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class CenterRepositoryFactory {
- private static final ConcurrentHashMap<String, RegistryCenterRepository> REGISTRY_CENTER_MAP = new ConcurrentHashMap<>();
+ private static final ConcurrentHashMap<String, RegistryRepository> REGISTRY_CENTER_MAP = new ConcurrentHashMap<>();
- private static final ConcurrentHashMap<String, ConfigCenterRepository> CONFIG_CENTER_MAP = new ConcurrentHashMap<>();
+ private static final ConcurrentHashMap<String, ConfigurationRepository> CONFIG_CENTER_MAP = new ConcurrentHashMap<>();
/**
* Create registry center instance.
@@ -46,25 +46,25 @@
* @param config registry center config
* @return registry center
*/
- public static RegistryCenterRepository createRegistryCenter(final CenterConfig config) {
- RegistryCenterRepository result = REGISTRY_CENTER_MAP.get(config.getName());
+ public static RegistryRepository createRegistryCenter(final CenterConfig config) {
+ RegistryRepository result = REGISTRY_CENTER_MAP.get(config.getName());
if (null != result) {
return result;
}
InstanceType instanceType = InstanceType.nameOf(config.getInstanceType());
switch (instanceType) {
case ZOOKEEPER:
- result = new CuratorZookeeperCenterRepository();
+ result = new CuratorZookeeperRepository();
break;
case ETCD:
- EtcdCenterRepository etcdCenterRepository = new EtcdCenterRepository();
+ EtcdRepository etcdCenterRepository = new EtcdRepository();
etcdCenterRepository.setProps(new Properties());
result = etcdCenterRepository;
break;
default:
throw new UnsupportedOperationException(config.getName());
}
- result.init(convert(config));
+ result.init(config.getName(), convert(config));
REGISTRY_CENTER_MAP.put(config.getName(), result);
return result;
}
@@ -75,33 +75,31 @@
* @param config config center config
* @return config center
*/
- public static ConfigCenterRepository createConfigCenter(final CenterConfig config) {
- ConfigCenterRepository result = CONFIG_CENTER_MAP.get(config.getName());
+ public static ConfigurationRepository createConfigCenter(final CenterConfig config) {
+ ConfigurationRepository result = CONFIG_CENTER_MAP.get(config.getName());
if (null != result) {
return result;
}
InstanceType instanceType = InstanceType.nameOf(config.getInstanceType());
switch (instanceType) {
case ZOOKEEPER:
- result = new CuratorZookeeperCenterRepository();
+ result = new CuratorZookeeperRepository();
break;
case ETCD:
- EtcdCenterRepository etcdCenterRepository = new EtcdCenterRepository();
+ EtcdRepository etcdCenterRepository = new EtcdRepository();
etcdCenterRepository.setProps(new Properties());
result = etcdCenterRepository;
break;
default:
throw new UnsupportedOperationException(config.getName());
}
- result.init(convert(config));
+ result.init(config.getName(), convert(config));
CONFIG_CENTER_MAP.put(config.getName(), result);
return result;
}
- private static CenterConfiguration convert(final CenterConfig config) {
- CenterConfiguration result = new CenterConfiguration(config.getInstanceType(), new Properties());
- result.setServerLists(config.getServerLists());
- result.setNamespace(config.getNamespace());
+ private static OrchestrationCenterConfiguration convert(final CenterConfig config) {
+ OrchestrationCenterConfiguration result = new OrchestrationCenterConfiguration(config.getInstanceType(), config.getServerLists(), new Properties());
result.getProps().put("digest", config.getDigest());
return result;
}
diff --git a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/util/ConfigurationYamlConverter.java b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/util/ConfigurationYamlConverter.java
index c16595f..fdd7865 100644
--- a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/util/ConfigurationYamlConverter.java
+++ b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/util/ConfigurationYamlConverter.java
@@ -22,8 +22,6 @@
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration;
-import org.apache.shardingsphere.orchestration.core.common.configuration.YamlDataSourceConfiguration;
-import org.apache.shardingsphere.orchestration.core.common.configuration.DataSourceConfigurationYamlSwapper;
import org.apache.shardingsphere.infra.auth.Authentication;
import org.apache.shardingsphere.infra.auth.yaml.config.YamlAuthenticationConfiguration;
import org.apache.shardingsphere.infra.auth.yaml.swapper.AuthenticationYamlSwapper;
@@ -32,6 +30,8 @@
import org.apache.shardingsphere.infra.yaml.config.YamlRootRuleConfigurations;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
+import org.apache.shardingsphere.orchestration.core.common.yaml.config.YamlDataSourceConfiguration;
+import org.apache.shardingsphere.orchestration.core.common.yaml.swapper.DataSourceConfigurationYamlSwapper;
import java.util.Collection;
import java.util.Map;
diff --git a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/web/controller/ClusterStateController.java b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/web/controller/ClusterStateController.java
deleted file mode 100644
index 1c479d6..0000000
--- a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/web/controller/ClusterStateController.java
+++ /dev/null
@@ -1,58 +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.ui.web.controller;
-
-import org.apache.shardingsphere.cluster.state.DataSourceState;
-import org.apache.shardingsphere.cluster.state.InstanceState;
-import org.apache.shardingsphere.ui.servcie.ClusterService;
-import org.apache.shardingsphere.ui.web.response.ResponseResult;
-import org.apache.shardingsphere.ui.web.response.ResponseResultUtil;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * RESTful API of cluster state.
- */
-@RestController
-@RequestMapping("/api/cluster-state")
-public final class ClusterStateController {
-
- @Autowired
- private ClusterService clusterService;
-
- @RequestMapping(value = "", method = RequestMethod.GET)
- public ResponseResult<Map<String, Object>> loadAllInstanceStates() {
- return ResponseResultUtil.build(mergeDataSources(clusterService.loadAllInstanceStates()));
- }
-
- private Map<String, Object> mergeDataSources(final Map<String, InstanceState> instanceStateMap) {
- Map<String, Object> result = new HashMap<>();
- Map<String, DataSourceState> dataSourceStateMap = new HashMap<>();
- result.put("instanceStates", instanceStateMap);
- result.put("dataSourceStates", dataSourceStateMap);
- instanceStateMap.values().forEach(each ->
- each.getDataSources().entrySet().forEach(entry -> dataSourceStateMap.put(entry.getKey(), entry.getValue()))
- );
- return result;
- }
-}
diff --git a/shardingsphere-ui-frontend/src/lang/en-US.js b/shardingsphere-ui-frontend/src/lang/en-US.js
index 1b4828f..05cac08 100644
--- a/shardingsphere-ui-frontend/src/lang/en-US.js
+++ b/shardingsphere-ui-frontend/src/lang/en-US.js
@@ -48,10 +48,6 @@
{
title: 'Data scaling',
href: '/data-scaling'
- },
- {
- title: 'Cluster state',
- href: '/cluster-state'
}
],
connected: 'Connected',
@@ -236,16 +232,5 @@
serviceNamePlaceholder: 'Please enter serviceName',
serviceUrlPlaceholder: 'Please enter serviceUrl'
}
- },
- clusterState: {
- legendLabel: {
- onLine: 'ONLINE',
- offLine: 'OFFLINE',
- disabled: 'DISABLED',
- unknown: 'UNKNOWN'
- },
- configBar: {
- refreshPeriodLabel: 'Auto Refresh'
- }
}
}
diff --git a/shardingsphere-ui-frontend/src/lang/zh-CN.js b/shardingsphere-ui-frontend/src/lang/zh-CN.js
index 9f034eb..5467265 100644
--- a/shardingsphere-ui-frontend/src/lang/zh-CN.js
+++ b/shardingsphere-ui-frontend/src/lang/zh-CN.js
@@ -48,10 +48,6 @@
{
title: '数据扩容',
href: '/data-scaling'
- },
- {
- title: '节点状态',
- href: '/cluster-state'
}
],
connect: '已连接',
@@ -234,16 +230,5 @@
serviceNamePlaceholder: '请输入服务名称',
serviceUrlPlaceholder: '请输入服务地址'
}
- },
- clusterState: {
- legendLabel: {
- onLine: '正常',
- offLine: '下线',
- disabled: '禁用',
- unknown: '未知'
- },
- configBar: {
- refreshPeriodLabel: '定时刷新'
- }
}
}
diff --git a/shardingsphere-ui-frontend/src/router/index.js b/shardingsphere-ui-frontend/src/router/index.js
index 8206071..6b65ab0 100644
--- a/shardingsphere-ui-frontend/src/router/index.js
+++ b/shardingsphere-ui-frontend/src/router/index.js
@@ -59,12 +59,6 @@
component: () => import('@/views/data-scaling'),
hidden: true,
name: 'Data scaling'
- },
- {
- path: '/cluster-state',
- component: () => import('@/views/cluster'),
- hidden: true,
- name: 'Cluster state'
}
]
diff --git a/shardingsphere-ui-frontend/src/views/cluster/api.js b/shardingsphere-ui-frontend/src/views/cluster/api.js
deleted file mode 100644
index 1288de3..0000000
--- a/shardingsphere-ui-frontend/src/views/cluster/api.js
+++ /dev/null
@@ -1,22 +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.
- */
-
-import API from '@/utils/api'
-
-export default {
- loadInstanceStates: (params = {}) => API.get(`/api/cluster-state`, params)
-}
diff --git a/shardingsphere-ui-frontend/src/views/cluster/index.vue b/shardingsphere-ui-frontend/src/views/cluster/index.vue
deleted file mode 100644
index d331490..0000000
--- a/shardingsphere-ui-frontend/src/views/cluster/index.vue
+++ /dev/null
@@ -1,33 +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.
- -->
-
-<template>
- <s-cluster-state/>
-</template>
-
-<script>
-import SClusterState from './module/clusterstate'
-export default {
- name: 'ClusterState',
- components: {
- SClusterState
- }
-}
-</script>
-
-<style lang="scss" scoped>
-</style>
diff --git a/shardingsphere-ui-frontend/src/views/cluster/module/clusterstate.vue b/shardingsphere-ui-frontend/src/views/cluster/module/clusterstate.vue
deleted file mode 100644
index 9125b9a..0000000
--- a/shardingsphere-ui-frontend/src/views/cluster/module/clusterstate.vue
+++ /dev/null
@@ -1,412 +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.
- -->
-
-<template>
- <div style="width: 100%; height: 100%; position: relative;">
- <div class="configBar">
- <label for="refreshPeriod">{{ $t("clusterState.configBar.refreshPeriodLabel") }}:</label>
- <el-switch
- v-model="autoRefreshFlag"
- active-color="#13ce66"
- inactive-color="#ff4949">
- </el-switch>
- <select v-model="refreshInterval" name="refreshPeriod">
- <option v-for="(item,index) of refreshOptions" :value="item.millis" :key="index">{{ item.name }}</option>
- </select>
- </div>
- <div id="myChart" class="echarts"></div>
- </div>
-</template>
-<script>
-
-import echarts from 'echarts'
-import Vue from 'vue'
-Vue.prototype.$echarts = echarts
-import 'echarts-liquidfill'
-import API from '../api'
-export default {
- name: 'ClusterState',
- data() {
- return {
- allData: {},
- instanceData: {},
- proxy: [],
- datasource: [],
- categories: [],
- linesData: [],
- links: [],
- option: {},
- state: {
- ONLINE: '#01acca',
- OFFLINE: '#FF0A14',
- DISABLED: '#A9A9A9',
- UNKNOWN: '#ffb402'
- },
- myChart: {},
- timer: {},
- refreshOptions: [
- { name: '30s', millis: 30000 },
- { name: '60s', millis: 60000 },
- { name: '2min', millis: 120000 },
- { name: '5min', millis: 300000 },
- { name: '30min', millis: 1800000 }
- ],
- prevRefreshMillis: 0,
- autoRefreshFlag: true,
- refreshInterval: 60000
- }
- },
- mounted() {
- this.initChart()
- this.loadAllInstanceStates()
- },
- activated() {
- this.myChart && this.myChart.resize()
- },
- destroyed() {
- this.close()
- },
- methods: {
- refresh() {
- this.loadAllInstanceStates()
- },
- tryAutoRefresh() {
- const curMillis = new Date().getTime()
- if (!this.autoRefreshFlag) {
- return
- } else if (!this.prevRefreshMillis) {
- this.prevRefreshMillis = curMillis
- return
- } else if (curMillis - this.prevRefreshMillis < this.refreshInterval) {
- return
- }
- this.prevRefreshMillis = curMillis
- this.refresh()
- },
- loadAllInstanceStates() {
- API.loadInstanceStates().then(res => {
- const data = res.model
- this.allData = data
- this.instanceData = data.instanceStates
- this.createChart()
- })
- },
- initChart() {
- this.initCategories()
- this.myChart = this.$echarts.init(document.getElementById('myChart'))
- this.myChart.setOption(this.getOption(), true)
- window.addEventListener("resize", () => { this.myChart.resize() })
- this.startTimer()
- },
- createChart() {
- this.initProxy()
- this.initDatasource()
- this.initLines()
- this.setChartData()
- this.myChart.setOption(this.option)
- },
- startTimer() {
- this.timer = setInterval(this.tryAutoRefresh, 1)
- },
- initProxy() {
- this.proxy = []
- let x = 20
- for (const key in this.allData.instanceStates) {
- this.proxy.push({
- name: key,
- value: [x, 130],
- category: this.getCategory(this.allData.instanceStates[key]),
- symbolSize: 100,
- label: {
- position: 'top'
- }
- })
- x += 50
- }
- },
- initDatasource() {
- this.datasource = []
- let x = 0
- for (const key in this.allData.dataSourceStates) {
- this.datasource.push({
- name: key,
- category: this.getCategory(this.allData.dataSourceStates[key]),
- state: this.allData.dataSourceStates[key].state,
- speed: '',
- value: [x, 20]
- })
- x += 20
- }
- },
- initLines() {
- this.links = []
- this.linesData = []
- this.datasource.slice().forEach((ds) => {
- this.proxy.slice().forEach((p) => {
- if (p.category === 2) {
- this.links.push({
- source: p.name,
- target: ds.name,
- speed: ds.speed,
- lineStyle: {
- normal: {
- color: this.state.DISABLED,
- curveness: 0
- }
- }
- })
- } else {
- const ids = this.instanceData[p.name].dataSources[ds.name]
- if (ids) {
- if (ids.state === 'ONLINE') {
- this.linesData.push([{
- coord: p.value
- }, {
- coord: ds.value
- }])
- }
- this.links.push({
- source: p.name,
- target: ds.name,
- speed: ds.speed,
- lineStyle: {
- normal: {
- color: this.state[ids.state],
- curveness: 0
- }
- }
- })
- }
- }
- })
- })
- },
- initCategories() {
- this.categories = [{
- name: this.$t('clusterState').legendLabel.onLine,
- itemStyle: {
- normal: {
- color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
- offset: 0,
- color: '#01acca'
- }, {
- offset: 1,
- color: '#5adbe7'
- }])
- }
- },
- label: {
- normal: {
- fontSize: '14'
- }
- }
- }, {
- name: this.$t('clusterState').legendLabel.offLine,
- itemStyle: {
- normal: {
- color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
- offset: 0,
- color: '#FF0A14'
- }, {
- offset: 1,
- color: '#FF9387'
- }])
- }
- },
- label: {
- normal: {
- fontSize: '14'
- }
- }
- }, {
- name: this.$t('clusterState').legendLabel.disabled,
- itemStyle: {
- normal: {
- color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
- offset: 0,
- color: '#FF199D'
- }, {
- offset: 1,
- color: '#FF8EE6'
- }])
- }
- },
- label: {
- normal: {
- fontSize: '14'
- }
- }
- }, {
- name: this.$t('clusterState').legendLabel.unknown,
- itemStyle: {
- normal: {
- color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
- offset: 0,
- color: '#ffb402'
- }, {
- offset: 1,
- color: '#ffdc84'
- }])
- }
- },
- label: {
- normal: {
- fontSize: '14'
- }
- }
- }]
- },
- getCategory(nodeState) {
- if (nodeState.state === 'ONLINE') {
- return 0
- } else if (nodeState.state === 'OFFLINE') {
- return 1
- } else if (nodeState.state === 'DISABLED') {
- return 2
- }
- return 3
- },
- setChartData() {
- this.option.series[0].data = this.proxy.concat(this.datasource)
- this.option.series[1].data = this.linesData
- this.option.series[0].links = this.links
- },
- getOption() {
- this.option = {
- legend: [{
- formatter: function(name) {
- return echarts.format.truncateText(name, 100, '14px Microsoft Yahei', '…');
- },
- tooltip: {
- show: true
- },
- textStyle: {
- color: '#999'
- },
- selectedMode: false,
- right: 0,
- data: this.categories.map(function(c) {
- return c.name
- })
- }],
- xAxis: {
- show: false,
- type: 'value'
- },
- yAxis: {
- show: false,
- type: 'value'
- },
- series: [{
- type: 'graph',
- layout: 'none',
- roam: 'scale',
- coordinateSystem: 'cartesian2d',
- symbolSize: 60,
- z: 3,
- edgeLabel: {
- normal: {
- show: true,
- textStyle: {
- fontSize: 14
- },
- formatter: function(params) {
- let txt = ''
- if (params.data.speed !== undefined) {
- txt = params.data.speed
- }
- return txt
- },
- }
- },
- label: {
- normal: {
- show: true,
- position: 'bottom',
- color: '#5e5e5e'
- }
- },
- itemStyle: {
- normal: {
- shadowColor: 'none'
- },
- emphasis: {
-
- }
- },
- lineStyle: {
- normal: {
- width: 2,
- shadowColor: 'none'
- },
- },
- edgeSymbol: ['none', 'arrow'],
- edgeSymbolSize: 8,
- data: [],
- links: [],
- categories: this.categories
- }, {
- name: 'A',
- type: 'lines',
- coordinateSystem: 'cartesian2d',
- z: 1,
- effect: {
- show: true,
- smooth: false,
- trailLength: 0,
- symbol: "arrow",
- color: 'rgba(55,155,255,0.5)',
- symbolSize: 12
- },
- lineStyle: {
- normal: {
- curveness: 0
- }
- },
- data: []
- }]
- }
- return this.option
- },
- close() {
- clearTimeout(this.timer)
- }
- }
-}
-</script>
-<style lang='scss' scoped>
-.btn-group {
- margin-bottom: 20px;
-}
-.pagination {
- float: right;
- margin: 10px -10px 10px 0;
-}
-.echarts {
- height: 100%;
- width: 100%;
- padding-top: 10px;
-}
-.configBar {
- z-index: 100;
- position: absolute;
- top: 10px;
- left: 10px;
- font-size: 14px;
- font-weight: 500;
-}
-</style>