Merge pull request #10 from menghaoranss/issue6653-5
Refactor UI
diff --git a/shardingsphere-ui-backend/pom.xml b/shardingsphere-ui-backend/pom.xml
index 2a5308e..b435945 100644
--- a/shardingsphere-ui-backend/pom.xml
+++ b/shardingsphere-ui-backend/pom.xml
@@ -48,17 +48,17 @@
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-orchestration-core-facade</artifactId>
+ <artifactId>shardingsphere-governance-core-facade</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-orchestration-repository-zookeeper-curator</artifactId>
+ <artifactId>shardingsphere-governance-repository-zookeeper-curator</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-orchestration-repository-etcd</artifactId>
+ <artifactId>shardingsphere-governance-repository-etcd</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
diff --git a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/common/constant/OrchestrationType.java b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/common/constant/OrchestrationType.java
deleted file mode 100644
index 8f3f4b1..0000000
--- a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/common/constant/OrchestrationType.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.ui.common.constant;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-
-/**
- * Orchestration type.
- */
-@RequiredArgsConstructor
-@Getter
-public enum OrchestrationType {
-
- REGISTRY_CENTER("registry_center"),
- CONFIG_CENTER("config_center");
-
- private final String value;
-}
diff --git a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/common/domain/CenterConfig.java b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/common/domain/CenterConfig.java
index aadc740..c627511 100644
--- a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/common/domain/CenterConfig.java
+++ b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/common/domain/CenterConfig.java
@@ -35,14 +35,16 @@
private String serverLists;
- private String namespace;
-
private String orchestrationName;
- private String orchestrationType;
-
private String digest;
+ private String additionalConfigCenterType;
+
+ private String additionalConfigCenterServerList;
+
+ private String additionalDigest;
+
private boolean activated;
private Properties props = new Properties();
diff --git a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/CenterConfigService.java b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/CenterConfigService.java
index 9f5f6e3..a31fe2f 100644
--- a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/CenterConfigService.java
+++ b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/CenterConfigService.java
@@ -33,18 +33,16 @@
* Load center config.
*
* @param name center config name
- * @param orchestrationType orchestration type
* @return center config
*/
- CenterConfig load(String name, String orchestrationType);
+ CenterConfig load(String name);
/**
* Load the activated center config.
*
- * @param orchestrationType orchestration type
* @return activated center config
*/
- Optional<CenterConfig> loadActivated(String orchestrationType);
+ Optional<CenterConfig> loadActivated();
/**
* Add center config.
@@ -57,17 +55,15 @@
* Delete center config.
*
* @param name center config name
- * @param orchestrationType orchestration type
*/
- void delete(String name, String orchestrationType);
+ void delete(String name);
/**
* Set activated center config.
*
* @param name center config name
- * @param orchestrationType orchestration type
*/
- void setActivated(String name, String orchestrationType);
+ void setActivated(String name);
/**
* Load all center configs.
@@ -77,14 +73,6 @@
CenterConfigs loadAll();
/**
- * Load all center configs.
- *
- * @param orchestrationType orchestration type
- * @return all center configs.
- */
- CenterConfigs loadAll(String orchestrationType);
-
- /**
* update config center
*
* @param config center config
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 13e55ab..54fa645 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
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.ui.servcie;
-import org.apache.shardingsphere.orchestration.core.config.ConfigCenterNode;
-import org.apache.shardingsphere.orchestration.repository.api.ConfigurationRepository;
+import org.apache.shardingsphere.governance.core.config.ConfigCenterNode;
+import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
/**
* Config center service
diff --git a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/MetadataCenterService.java b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/MetadataCenterService.java
index 5bb7f1f..163bd51 100644
--- a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/MetadataCenterService.java
+++ b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/MetadataCenterService.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.ui.servcie;
-import org.apache.shardingsphere.orchestration.core.metadata.MetaDataCenterNode;
+import org.apache.shardingsphere.governance.core.metadata.MetaDataCenterNode;
/**
* Metadata center service.
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 db089f0..460e0d6 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
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.ui.servcie;
-import org.apache.shardingsphere.orchestration.core.registry.RegistryCenterNode;
-import org.apache.shardingsphere.orchestration.repository.api.RegistryRepository;
+import org.apache.shardingsphere.governance.core.registry.RegistryCenterNode;
+import org.apache.shardingsphere.governance.repository.api.RegistryRepository;
/**
* Registry center service.
diff --git a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/CenterConfigServiceImpl.java b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/CenterConfigServiceImpl.java
index 0aa80d9..9487eb2 100644
--- a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/CenterConfigServiceImpl.java
+++ b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/CenterConfigServiceImpl.java
@@ -26,8 +26,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Optional;
/**
@@ -40,19 +38,19 @@
private CenterConfigsRepository centerConfigsRepository;
@Override
- public CenterConfig load(final String name, final String orchestrationType) {
- return find(name, orchestrationType, loadAll());
+ public CenterConfig load(final String name) {
+ return find(name, loadAll());
}
@Override
- public Optional<CenterConfig> loadActivated(String orchestrationType) {
- return Optional.ofNullable(findActivatedCenterConfiguration(loadAll(orchestrationType)));
+ public Optional<CenterConfig> loadActivated() {
+ return Optional.ofNullable(findActivatedCenterConfiguration(loadAll()));
}
@Override
public void add(final CenterConfig config) {
CenterConfigs configs = loadAll();
- CenterConfig existedConfig = find(config.getName(), config.getOrchestrationType(), configs);
+ CenterConfig existedConfig = find(config.getName(), configs);
if (null != existedConfig) {
throw new ShardingSphereUIException(ShardingSphereUIException.SERVER_ERROR, String.format("Center %s already existed!", config.getName()));
}
@@ -61,9 +59,9 @@
}
@Override
- public void delete(final String name, final String orchestrationType) {
+ public void delete(final String name) {
CenterConfigs configs = loadAll();
- CenterConfig toBeRemovedConfig = find(name, orchestrationType, configs);
+ CenterConfig toBeRemovedConfig = find(name, configs);
if (null != toBeRemovedConfig) {
configs.getCenterConfigs().remove(toBeRemovedConfig);
centerConfigsRepository.save(configs);
@@ -71,13 +69,13 @@
}
@Override
- public void setActivated(final String name, final String orchestrationType) {
+ public void setActivated(final String name) {
CenterConfigs configs = loadAll();
- CenterConfig config = find(name, orchestrationType, configs);
+ CenterConfig config = find(name, configs);
if (null == config) {
throw new ShardingSphereUIException(ShardingSphereUIException.SERVER_ERROR, "Center not existed!");
}
- CenterConfig activatedConfig = findActivatedCenterConfiguration(configs, orchestrationType);
+ CenterConfig activatedConfig = findActivatedCenterConfiguration(configs);
if (!config.equals(activatedConfig)) {
if (null != activatedConfig) {
activatedConfig.setActivated(false);
@@ -93,30 +91,17 @@
}
@Override
- public CenterConfigs loadAll(String orchestrationType) {
- CenterConfigs result = new CenterConfigs();
- List<CenterConfig> centerConfigs = new ArrayList<>();
- centerConfigsRepository.load().getCenterConfigs().stream()
- .filter(each->orchestrationType.equals(each.getOrchestrationType()))
- .forEach(each->centerConfigs.add(each));
- result.setCenterConfigs(centerConfigs);
- return result;
- }
-
- @Override
public void update(CenterConfigDTO config) {
CenterConfigs configs = loadAll();
if (!config.getPrimaryName().equals(config.getName())) {
- CenterConfig existedConfig = find(config.getName(), config.getOrchestrationType(), configs);
+ CenterConfig existedConfig = find(config.getName(), configs);
if (null != existedConfig) {
throw new ShardingSphereUIException(ShardingSphereUIException.SERVER_ERROR, String.format("Center %s already existed!", config.getName()));
}
}
- CenterConfig toBeUpdatedConfig = find(config.getPrimaryName(), config.getOrchestrationType(), configs);
+ CenterConfig toBeUpdatedConfig = find(config.getPrimaryName(), configs);
if (null != toBeUpdatedConfig) {
toBeUpdatedConfig.setName(config.getName());
- toBeUpdatedConfig.setNamespace(config.getNamespace());
- toBeUpdatedConfig.setOrchestrationType(config.getOrchestrationType());
toBeUpdatedConfig.setInstanceType(config.getInstanceType());
toBeUpdatedConfig.setServerLists(config.getServerLists());
toBeUpdatedConfig.setOrchestrationName(config.getOrchestrationName());
@@ -126,22 +111,15 @@
}
private CenterConfig findActivatedCenterConfiguration(final CenterConfigs centerConfigs) {
- return centerConfigs.getCenterConfigs().stream()
+ return null == centerConfigs ? null : centerConfigs.getCenterConfigs().stream()
.filter(each->each.isActivated())
.findAny()
.orElse(null);
}
- private CenterConfig findActivatedCenterConfiguration(final CenterConfigs centerConfigs, final String orchestrationType) {
- return centerConfigs.getCenterConfigs().stream()
- .filter(each->each.isActivated() && orchestrationType.equals(each.getOrchestrationType()))
- .findAny()
- .orElse(null);
- }
-
- private CenterConfig find(final String name, final String orchestrationType, final CenterConfigs configs) {
+ private CenterConfig find(final String name, final CenterConfigs configs) {
return configs.getCenterConfigs().stream()
- .filter(each->name.equals(each.getName()) && orchestrationType.equals(each.getOrchestrationType()))
+ .filter(each->name.equals(each.getName()))
.findAny()
.orElse(null);
}
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 ac677ce..0dbc1ec 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
@@ -17,9 +17,8 @@
package org.apache.shardingsphere.ui.servcie.impl;
-import org.apache.shardingsphere.orchestration.core.config.ConfigCenterNode;
-import org.apache.shardingsphere.orchestration.repository.api.ConfigurationRepository;
-import org.apache.shardingsphere.ui.common.constant.OrchestrationType;
+import org.apache.shardingsphere.governance.core.config.ConfigCenterNode;
+import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.ui.common.domain.CenterConfig;
import org.apache.shardingsphere.ui.common.exception.ShardingSphereUIException;
import org.apache.shardingsphere.ui.servcie.CenterConfigService;
@@ -41,7 +40,7 @@
@Override
public ConfigurationRepository getActivatedConfigCenter() {
- Optional<CenterConfig> optional = centerConfigService.loadActivated(OrchestrationType.CONFIG_CENTER.getValue());
+ Optional<CenterConfig> optional = centerConfigService.loadActivated();
if (optional.isPresent()) {
return CenterRepositoryFactory.createConfigurationRepository(optional.get());
}
@@ -50,7 +49,7 @@
@Override
public ConfigCenterNode getActivateConfigurationNode() {
- Optional<CenterConfig> optional = centerConfigService.loadActivated(OrchestrationType.CONFIG_CENTER.getValue());
+ Optional<CenterConfig> optional = centerConfigService.loadActivated();
if (optional.isPresent()) {
return new ConfigCenterNode();
}
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 892a8a0..e58ae93 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
@@ -17,8 +17,7 @@
package org.apache.shardingsphere.ui.servcie.impl;
-import org.apache.shardingsphere.orchestration.core.metadata.MetaDataCenterNode;
-import org.apache.shardingsphere.ui.common.constant.OrchestrationType;
+import org.apache.shardingsphere.governance.core.metadata.MetaDataCenterNode;
import org.apache.shardingsphere.ui.common.domain.CenterConfig;
import org.apache.shardingsphere.ui.common.exception.ShardingSphereUIException;
import org.apache.shardingsphere.ui.servcie.CenterConfigService;
@@ -39,7 +38,7 @@
@Override
public MetaDataCenterNode getActivateMetaDataCenterNode() {
- Optional<CenterConfig> optional = centerConfigService.loadActivated(OrchestrationType.CONFIG_CENTER.getValue());
+ Optional<CenterConfig> optional = centerConfigService.loadActivated();
if (optional.isPresent()) {
return new MetaDataCenterNode();
}
diff --git a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/OrchestrationServiceImpl.java b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/OrchestrationServiceImpl.java
index 6c8d57d..1ca61fb 100644
--- a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/OrchestrationServiceImpl.java
+++ b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/OrchestrationServiceImpl.java
@@ -17,10 +17,10 @@
package org.apache.shardingsphere.ui.servcie.impl;
+import org.apache.shardingsphere.governance.core.registry.RegistryCenterNodeStatus;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration;
import org.apache.shardingsphere.masterslave.api.config.rule.MasterSlaveDataSourceRuleConfiguration;
-import org.apache.shardingsphere.orchestration.core.registry.RegistryCenterNodeStatus;
import org.apache.shardingsphere.ui.common.dto.InstanceDTO;
import org.apache.shardingsphere.ui.common.dto.SlaveDataSourceDTO;
import org.apache.shardingsphere.ui.servcie.OrchestrationService;
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 017e1b7..02aad71 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
@@ -17,9 +17,8 @@
package org.apache.shardingsphere.ui.servcie.impl;
-import org.apache.shardingsphere.orchestration.core.registry.RegistryCenterNode;
-import org.apache.shardingsphere.orchestration.repository.api.RegistryRepository;
-import org.apache.shardingsphere.ui.common.constant.OrchestrationType;
+import org.apache.shardingsphere.governance.core.registry.RegistryCenterNode;
+import org.apache.shardingsphere.governance.repository.api.RegistryRepository;
import org.apache.shardingsphere.ui.common.domain.CenterConfig;
import org.apache.shardingsphere.ui.common.exception.ShardingSphereUIException;
import org.apache.shardingsphere.ui.servcie.CenterConfigService;
@@ -41,7 +40,7 @@
@Override
public RegistryRepository getActivatedRegistryCenter() {
- Optional<CenterConfig> optional = centerConfigService.loadActivated(OrchestrationType.REGISTRY_CENTER.getValue());
+ Optional<CenterConfig> optional = centerConfigService.loadActivated();
if (optional.isPresent()) {
return CenterRepositoryFactory.createRegistryRepository(optional.get());
}
@@ -50,7 +49,7 @@
@Override
public RegistryCenterNode getActivatedStateNode() {
- Optional<CenterConfig> optional = centerConfigService.loadActivated(OrchestrationType.REGISTRY_CENTER.getValue());
+ Optional<CenterConfig> optional = centerConfigService.loadActivated();
if (optional.isPresent()) {
return new RegistryCenterNode();
}
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 0978ace..626d276 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
@@ -21,8 +21,8 @@
import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
+import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.infra.config.DataSourceConfiguration;
-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;
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 788b1da..abd3c69 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
@@ -17,13 +17,15 @@
package org.apache.shardingsphere.ui.util;
+import com.google.common.base.Strings;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-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.governance.repository.api.ConfigurationRepository;
+import org.apache.shardingsphere.governance.repository.api.GovernanceRepository;
+import org.apache.shardingsphere.governance.repository.api.RegistryRepository;
+import org.apache.shardingsphere.governance.repository.api.config.GovernanceCenterConfiguration;
+import org.apache.shardingsphere.governance.repository.etcd.EtcdRepository;
+import org.apache.shardingsphere.governance.repository.zookeeper.CuratorZookeeperRepository;
import org.apache.shardingsphere.ui.common.constant.InstanceType;
import org.apache.shardingsphere.ui.common.domain.CenterConfig;
@@ -51,20 +53,8 @@
if (null != result) {
return result;
}
- InstanceType instanceType = InstanceType.nameOf(config.getInstanceType());
- switch (instanceType) {
- case ZOOKEEPER:
- result = new CuratorZookeeperRepository();
- break;
- case ETCD:
- EtcdRepository etcdCenterRepository = new EtcdRepository();
- etcdCenterRepository.setProps(new Properties());
- result = etcdCenterRepository;
- break;
- default:
- throw new UnsupportedOperationException(config.getName());
- }
- result.init(config.getName(), convert(config));
+ result = (RegistryRepository) createOrchestrationRepository(config.getInstanceType());
+ result.init(config.getOrchestrationName(), convert(config));
REGISTRY_REPOSITORY_MAP.put(config.getName(), result);
return result;
}
@@ -80,8 +70,32 @@
if (null != result) {
return result;
}
- InstanceType instanceType = InstanceType.nameOf(config.getInstanceType());
- switch (instanceType) {
+ if (!Strings.isNullOrEmpty(config.getAdditionalConfigCenterServerList())
+ && !Strings.isNullOrEmpty(config.getAdditionalConfigCenterType())) {
+ result = (ConfigurationRepository) createOrchestrationRepository(config.getAdditionalConfigCenterType());
+ } else {
+ RegistryRepository registryRepository = (RegistryRepository) createOrchestrationRepository(config.getInstanceType());
+ if (registryRepository instanceof ConfigurationRepository) {
+ result = (ConfigurationRepository) registryRepository;
+ } else {
+ throw new IllegalArgumentException("Registry repository is not suitable for config center and no additional config center configuration provided.");
+ }
+ }
+ result.init(config.getOrchestrationName(), convert(config));
+ CONFIG_REPOSITORY_MAP.put(config.getName(), result);
+ return result;
+ }
+
+ private static GovernanceCenterConfiguration convert(final CenterConfig config) {
+ GovernanceCenterConfiguration result = new GovernanceCenterConfiguration(config.getInstanceType(), config.getServerLists(), new Properties());
+ result.getProps().put("digest", config.getDigest());
+ return result;
+ }
+
+ private static GovernanceRepository createOrchestrationRepository(final String instanceType) {
+ RegistryRepository result;
+ InstanceType type = InstanceType.nameOf(instanceType);
+ switch (type) {
case ZOOKEEPER:
result = new CuratorZookeeperRepository();
break;
@@ -91,16 +105,8 @@
result = etcdCenterRepository;
break;
default:
- throw new UnsupportedOperationException(config.getName());
+ throw new UnsupportedOperationException(instanceType);
}
- result.init(config.getName(), convert(config));
- CONFIG_REPOSITORY_MAP.put(config.getName(), result);
- return result;
- }
-
- 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 fdd7865..6795bc3 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
@@ -21,7 +21,8 @@
import com.google.common.collect.Maps;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration;
+import org.apache.shardingsphere.governance.core.common.yaml.config.YamlDataSourceConfiguration;
+import org.apache.shardingsphere.governance.core.common.yaml.swapper.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;
@@ -30,8 +31,7 @@
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 org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration;
import java.util.Collection;
import java.util.Map;
diff --git a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/web/controller/ConfigCenterController.java b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/web/controller/ConfigCenterController.java
index 3c4be26..0f7eb84 100644
--- a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/web/controller/ConfigCenterController.java
+++ b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/web/controller/ConfigCenterController.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.ui.web.controller;
-import org.apache.shardingsphere.ui.common.constant.OrchestrationType;
import org.apache.shardingsphere.ui.common.domain.CenterConfig;
import org.apache.shardingsphere.ui.common.dto.CenterConfigDTO;
import org.apache.shardingsphere.ui.servcie.CenterConfigService;
@@ -49,7 +48,7 @@
*/
@RequestMapping(value = "", method = RequestMethod.GET)
public ResponseResult<List<CenterConfig>> loadConfigs() {
- return ResponseResultUtil.build(centerConfigService.loadAll(OrchestrationType.CONFIG_CENTER.getValue()).getCenterConfigs());
+ return ResponseResultUtil.build(centerConfigService.loadAll().getCenterConfigs());
}
/**
@@ -72,7 +71,7 @@
*/
@RequestMapping(value = "", method = RequestMethod.DELETE)
public ResponseResult delete(@RequestBody final CenterConfig config) {
- centerConfigService.delete(config.getName(), OrchestrationType.CONFIG_CENTER.getValue());
+ centerConfigService.delete(config.getName());
return ResponseResultUtil.success();
}
@@ -84,8 +83,8 @@
*/
@RequestMapping(value = "/connect", method = RequestMethod.POST)
public ResponseResult<Boolean> connect(@RequestBody final CenterConfig config) {
- CenterRepositoryFactory.createConfigurationRepository(centerConfigService.load(config.getName(), OrchestrationType.CONFIG_CENTER.getValue()));
- centerConfigService.setActivated(config.getName(), OrchestrationType.CONFIG_CENTER.getValue());
+ CenterRepositoryFactory.createConfigurationRepository(centerConfigService.load(config.getName()));
+ centerConfigService.setActivated(config.getName());
return ResponseResultUtil.build(Boolean.TRUE);
}
@@ -96,7 +95,7 @@
*/
@RequestMapping(value = "/activated", method = RequestMethod.GET)
public ResponseResult<CenterConfig> activated() {
- return ResponseResultUtil.build(centerConfigService.loadActivated(OrchestrationType.CONFIG_CENTER.getValue()).orElse(null));
+ return ResponseResultUtil.build(centerConfigService.loadActivated().orElse(null));
}
/**
diff --git a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/web/controller/RegistryCenterController.java b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/web/controller/RegistryCenterController.java
index 508f16d..cfc5772 100644
--- a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/web/controller/RegistryCenterController.java
+++ b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/web/controller/RegistryCenterController.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.ui.web.controller;
-import org.apache.shardingsphere.ui.common.constant.OrchestrationType;
import org.apache.shardingsphere.ui.common.domain.CenterConfig;
import org.apache.shardingsphere.ui.common.dto.CenterConfigDTO;
import org.apache.shardingsphere.ui.servcie.CenterConfigService;
@@ -49,7 +48,7 @@
*/
@RequestMapping(value = "", method = RequestMethod.GET)
public ResponseResult<List<CenterConfig>> loadConfigs() {
- return ResponseResultUtil.build(centerConfigService.loadAll(OrchestrationType.REGISTRY_CENTER.getValue()).getCenterConfigs());
+ return ResponseResultUtil.build(centerConfigService.loadAll().getCenterConfigs());
}
/**
@@ -72,7 +71,7 @@
*/
@RequestMapping(value = "", method = RequestMethod.DELETE)
public ResponseResult delete(@RequestBody final CenterConfig config) {
- centerConfigService.delete(config.getName(), OrchestrationType.REGISTRY_CENTER.getValue());
+ centerConfigService.delete(config.getName());
return ResponseResultUtil.success();
}
@@ -84,8 +83,8 @@
*/
@RequestMapping(value = "/connect", method = RequestMethod.POST)
public ResponseResult<Boolean> connect(@RequestBody final CenterConfig config) {
- CenterRepositoryFactory.createRegistryRepository(centerConfigService.load(config.getName(), OrchestrationType.REGISTRY_CENTER.getValue()));
- centerConfigService.setActivated(config.getName(), OrchestrationType.REGISTRY_CENTER.getValue());
+ CenterRepositoryFactory.createRegistryRepository(centerConfigService.load(config.getName()));
+ centerConfigService.setActivated(config.getName());
return ResponseResultUtil.build(Boolean.TRUE);
}
@@ -96,7 +95,7 @@
*/
@RequestMapping(value = "/activated", method = RequestMethod.GET)
public ResponseResult<CenterConfig> activated() {
- return ResponseResultUtil.build(centerConfigService.loadActivated(OrchestrationType.REGISTRY_CENTER.getValue()).orElse(null));
+ return ResponseResultUtil.build(centerConfigService.loadActivated().orElse(null));
}
/**
diff --git a/shardingsphere-ui-frontend/src/lang/en-US.js b/shardingsphere-ui-frontend/src/lang/en-US.js
index 05cac08..afff882 100644
--- a/shardingsphere-ui-frontend/src/lang/en-US.js
+++ b/shardingsphere-ui-frontend/src/lang/en-US.js
@@ -20,29 +20,20 @@
home: 'Home',
menuData: [
{
- title: 'Config Center',
+ title: 'Governance',
child: [
{
- title: 'Config Server',
- href: '/config-center'
+ title: 'Registry Center',
+ href: '/registry-center'
},
{
title: 'Rule Config',
href: '/rule-config'
- }
- ]
- },
- {
- title: 'Registry Center',
- child: [
- {
- title: 'Registry Server',
- href: '/registry-center'
},
{
title: 'Runtime Status',
href: '/runtime-status'
- }
+ },
]
},
{
@@ -98,8 +89,10 @@
title: 'Add a registry center',
editTitle: 'Edit registry center',
name: 'Name',
- centerType: 'Instance Type',
+ centerType: 'Type',
+ additionalCenterType: 'Additional type',
address: 'Address',
+ additionalAddress: 'Additional address',
orchestrationName: 'Orchestration Name',
namespaces: 'Namespace',
digest: 'Digest',
diff --git a/shardingsphere-ui-frontend/src/lang/zh-CN.js b/shardingsphere-ui-frontend/src/lang/zh-CN.js
index 5467265..a10870e 100644
--- a/shardingsphere-ui-frontend/src/lang/zh-CN.js
+++ b/shardingsphere-ui-frontend/src/lang/zh-CN.js
@@ -20,29 +20,20 @@
home: '主页',
menuData: [
{
- title: '配置中心',
+ title: '治理',
child: [
{
- title: '服务列表',
- href: '/config-center'
+ title: '注册中心',
+ href: '/registry-center'
},
{
title: '配置管理',
href: '/rule-config'
- }
- ]
- },
- {
- title: '注册中心',
- child: [
- {
- title: '服务列表',
- href: '/registry-center'
},
{
title: '运行状态',
href: '/runtime-status'
- }
+ },
]
},
{
@@ -99,6 +90,8 @@
editTitle: '编辑注册中心',
name: '注册中心名称',
centerType: '注册中心类型',
+ additionalCenterType: '扩展配置中心类型',
+ additionalAddress: '扩展配置中心地址',
address: '注册中心地址',
orchestrationName: '数据治理实例',
namespaces: '命名空间',
diff --git a/shardingsphere-ui-frontend/src/views/registry-center/module/registryCenter.vue b/shardingsphere-ui-frontend/src/views/registry-center/module/registryCenter.vue
index 3a74952..0314d95 100644
--- a/shardingsphere-ui-frontend/src/views/registry-center/module/registryCenter.vue
+++ b/shardingsphere-ui-frontend/src/views/registry-center/module/registryCenter.vue
@@ -118,17 +118,23 @@
autocomplete="off"
/>
</el-form-item>
- <el-form-item :label="$t('registryCenter.registDialog.namespaces')" prop="namespace">
+ <el-form-item :label="$t('registryCenter.registDialog.additionalCenterType')" prop="additionalConfigCenterType">
+ <el-radio-group v-model="form.additionalConfigCenterType">
+ <el-radio label="Zookeeper">Zookeeper</el-radio>
+ <el-radio label="Etcd">Etcd</el-radio>
+ </el-radio-group>
+ </el-form-item>
+ <el-form-item :label="$t('registryCenter.registDialog.additionalAddress')" prop="additionalConfigCenterServerList">
<el-input
- :placeholder="$t('registryCenter.rules.namespaces')"
- v-model="form.namespace"
+ :placeholder="$t('registryCenter.rules.address')"
+ v-model="form.additionalConfigCenterServerList"
autocomplete="off"
/>
</el-form-item>
<el-form-item :label="$t('registryCenter.registDialog.digest')">
<el-input
:placeholder="$t('registryCenter.rules.digest')"
- v-model="form.digest"
+ v-model="form.additionalDigest"
autocomplete="off"
/>
</el-form-item>
@@ -170,17 +176,30 @@
autocomplete="off"
/>
</el-form-item>
- <el-form-item :label="$t('registryCenter.registDialog.namespaces')" prop="namespace">
+ <el-form-item :label="$t('registryCenter.registDialog.digest')">
<el-input
- :placeholder="$t('registryCenter.rules.namespaces')"
- v-model="editForm.namespace"
+ :placeholder="$t('registryCenter.rules.digest')"
+ v-model="editForm.digest"
+ autocomplete="off"
+ />
+ </el-form-item>
+ <el-form-item :label="$t('registryCenter.registDialog.additionalCenterType')" prop="additionalConfigCenterType">
+ <el-radio-group v-model="editForm.additionalConfigCenterType">
+ <el-radio label="Zookeeper">Zookeeper</el-radio>
+ <el-radio label="Etcd">Etcd</el-radio>
+ </el-radio-group>
+ </el-form-item>
+ <el-form-item :label="$t('registryCenter.registDialog.additionalAddress')" prop="additionalConfigCenterServerList">
+ <el-input
+ :placeholder="$t('registryCenter.rules.address')"
+ v-model="editForm.additionalConfigCenterServerList"
autocomplete="off"
/>
</el-form-item>
<el-form-item :label="$t('registryCenter.registDialog.digest')">
<el-input
:placeholder="$t('registryCenter.rules.digest')"
- v-model="editForm.digest"
+ v-model="editForm.additionalDigest"
autocomplete="off"
/>
</el-form-item>
@@ -219,32 +238,38 @@
prop: 'serverLists'
},
{
- label: this.$t('registryCenter').registDialog.namespaces,
- prop: 'namespace'
- },
- {
label: this.$t('registryCenter').registDialog.orchestrationName,
prop: 'orchestrationName'
- }
+ },
+ {
+ label: this.$t('registryCenter').registDialog.additionalCenterType,
+ prop: 'additionalConfigCenterType'
+ },
+ {
+ label: this.$t('registryCenter').registDialog.additionalAddress,
+ prop: 'additionalConfigCenterServerList'
+ },
],
form: {
name: '',
serverLists: '',
- namespace: '',
instanceType: 'Zookeeper',
orchestrationName: '',
- orchestrationType: 'registry_center',
- digest: ''
+ digest: '',
+ additionalConfigCenterType: '',
+ additionalConfigCenterServerList: '',
+ additionalDigest: ''
},
editForm: {
primaryName: '',
name: '',
serverLists: '',
- namespace: '',
instanceType: 'Zookeeper',
orchestrationName: '',
- orchestrationType: 'registry_center',
- digest: ''
+ digest: '',
+ additionalConfigCenterType: '',
+ additionalConfigCenterServerList: '',
+ additionalDigest: ''
},
rules: {
name: [
diff --git a/shardingsphere-ui-frontend/src/views/rule-config/module/schema.vue b/shardingsphere-ui-frontend/src/views/rule-config/module/schema.vue
index fa7efa3..e37f804 100644
--- a/shardingsphere-ui-frontend/src/views/rule-config/module/schema.vue
+++ b/shardingsphere-ui-frontend/src/views/rule-config/module/schema.vue
@@ -214,7 +214,7 @@
computed: {
textarea2() {
const dsYamlType = new yaml.Type(
- 'tag:yaml.org,2002:org.apache.shardingsphere.orchestration.core.common.configuration.YamlDataSourceConfiguration',
+ 'tag:yaml.org,2002:org.apache.shardingsphere.orchestration.core.common.yaml.config.YamlDataSourceConfiguration',
{
kind: 'mapping',
construct(data) {