You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2021/01/25 11:35:14 UTC
[shardingsphere-ui] branch master updated: Add filter for load yaml
configurations
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-ui.git
The following commit(s) were added to refs/heads/master by this push:
new 48348cf Add filter for load yaml configurations
new 32b16ba Merge pull request #76 from menghaoranss/dev
48348cf is described below
commit 48348cf8fa6d9e28cabe1a6c97a8793164a2626e
Author: menghaoranss <lo...@163.com>
AuthorDate: Mon Jan 25 18:30:33 2021 +0800
Add filter for load yaml configurations
---
pom.xml | 4 ++--
shardingsphere-ui-backend/pom.xml | 2 +-
.../ui/servcie/impl/ShardingPropertiesServiceImpl.java | 2 +-
.../ui/servcie/impl/ShardingSchemaServiceImpl.java | 12 ++++++------
.../shardingsphere/ui/util/ConfigurationYamlConverter.java | 12 +++++++-----
5 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/pom.xml b/pom.xml
index cb6583f..eacaddc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,7 +44,7 @@
<os-maven-plugin.version>1.5.0.Final</os-maven-plugin.version>
<takari-maven-plugin.version>0.6.1</takari-maven-plugin.version>
<guava.version>20.0</guava.version>
- <shardingsphere.version>5.0.0-alpha</shardingsphere.version>
+ <shardingsphere.version>5.0.0-RC1-SNAPSHOT</shardingsphere.version>
<maven.deploy.skip>true</maven.deploy.skip>
</properties>
@@ -70,7 +70,7 @@
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-governance-core-facade</artifactId>
+ <artifactId>shardingsphere-governance-core</artifactId>
<version>${shardingsphere.version}</version>
</dependency>
<dependency>
diff --git a/shardingsphere-ui-backend/pom.xml b/shardingsphere-ui-backend/pom.xml
index 0476d78..6436ba4 100644
--- a/shardingsphere-ui-backend/pom.xml
+++ b/shardingsphere-ui-backend/pom.xml
@@ -47,7 +47,7 @@
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-governance-core-facade</artifactId>
+ <artifactId>shardingsphere-governance-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
diff --git a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/ShardingPropertiesServiceImpl.java b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/ShardingPropertiesServiceImpl.java
index e7a81a7..976db1c 100644
--- a/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/ShardingPropertiesServiceImpl.java
+++ b/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/ShardingPropertiesServiceImpl.java
@@ -53,7 +53,7 @@ public final class ShardingPropertiesServiceImpl implements ShardingPropertiesSe
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
- throw new IllegalArgumentException("Sharding properties is invalid.");
+ throw new IllegalArgumentException("Sharding properties is invalid.", ex);
}
}
}
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 be41540..b65a568 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
@@ -45,7 +45,7 @@ public final class ShardingSchemaServiceImpl implements ShardingSchemaService {
@Override
public Collection<String> getAllSchemaNames() {
- return configCenterService.getActivatedConfigCenter().getChildrenKeys(configCenterService.getActivateConfigurationNode().getSchemasPath());
+ return configCenterService.getActivatedConfigCenter().getChildrenKeys(configCenterService.getActivateConfigurationNode().getMetadataNodePath());
}
@Override
@@ -85,16 +85,16 @@ public final class ShardingSchemaServiceImpl implements ShardingSchemaService {
ConfigurationRepository configCenterRepository = configCenterService.getActivatedConfigCenter();
String schemaNamePath = configCenterService.getActivateConfigurationNode().getSchemaNamePath(schemaName);
configCenterRepository.delete(schemaNamePath);
- String schemaNames = configCenterRepository.get(configCenterService.getActivateConfigurationNode().getSchemasPath());
+ String schemaNames = configCenterRepository.get(configCenterService.getActivateConfigurationNode().getMetadataNodePath());
List<String> schemaNameList = new ArrayList<>(Splitter.on(",").splitToList(schemaNames));
schemaNameList.remove(schemaName);
- configCenterRepository.persist(configCenterService.getActivateConfigurationNode().getSchemasPath(), Joiner.on(",").join(schemaNameList));
+ configCenterRepository.persist(configCenterService.getActivateConfigurationNode().getMetadataNodePath(), Joiner.on(",").join(schemaNameList));
}
@Override
public String getMetadataConfiguration(final String schemaName) {
return configCenterService.getActivatedConfigCenter().get(
- configCenterService.getActivateConfigurationNode().getTablePath(schemaName));
+ configCenterService.getActivateConfigurationNode().getSchemaPath(schemaName));
}
private void checkRuleConfiguration(final String configData) {
@@ -118,7 +118,7 @@ public final class ShardingSchemaServiceImpl implements ShardingSchemaService {
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
- throw new IllegalArgumentException("data source configuration is invalid.");
+ throw new IllegalArgumentException("data source configuration is invalid.", ex);
}
}
@@ -133,7 +133,7 @@ public final class ShardingSchemaServiceImpl implements ShardingSchemaService {
private void persistSchemaName(final String schemaName) {
ConfigurationRepository configCenterRepository = configCenterService.getActivatedConfigCenter();
- String schemaPath = configCenterService.getActivateConfigurationNode().getSchemasPath();
+ String schemaPath = configCenterService.getActivateConfigurationNode().getMetadataNodePath();
String schemaNames = configCenterRepository.get(schemaPath);
List<String> schemaNameList = Strings.isNullOrEmpty(schemaNames) ? new ArrayList<>() : new ArrayList<>(Splitter.on(",").splitToList(schemaNames));
if (!schemaNameList.contains(schemaName)) {
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 f8de507..ad48109 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
@@ -24,8 +24,8 @@ import lombok.NoArgsConstructor;
import org.apache.shardingsphere.governance.core.yaml.config.YamlDataSourceConfiguration;
import org.apache.shardingsphere.governance.core.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;
+import org.apache.shardingsphere.infra.auth.builtin.yaml.config.YamlAuthenticationConfiguration;
+import org.apache.shardingsphere.infra.auth.builtin.yaml.swapper.AuthenticationYamlSwapper;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
import org.apache.shardingsphere.infra.yaml.config.YamlRootRuleConfigurations;
@@ -33,7 +33,9 @@ import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
import org.apache.shardingsphere.replicaquery.api.config.ReplicaQueryRuleConfiguration;
+import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
@@ -52,7 +54,7 @@ public final class ConfigurationYamlConverter {
*/
@SuppressWarnings("unchecked")
public static Map<String, DataSourceConfiguration> loadDataSourceConfigurations(final String data) {
- Map<String, YamlDataSourceConfiguration> result = (Map) YamlEngine.unmarshal(data);
+ Map<String, YamlDataSourceConfiguration> result = (Map) YamlEngine.unmarshal(data, Collections.emptyList());
Preconditions.checkState(null != result && !result.isEmpty(), "No available data sources to load for governance.");
return Maps.transformValues(result, new DataSourceConfigurationYamlSwapper()::swapToObject);
}
@@ -64,7 +66,7 @@ public final class ConfigurationYamlConverter {
* @return rule configurations
*/
public static Collection<RuleConfiguration> loadRuleConfigurations(final String data) {
- return new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(data, YamlRootRuleConfigurations.class).getRules());
+ return new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(data, YamlRootRuleConfigurations.class, true).getRules());
}
/**
@@ -98,6 +100,6 @@ public final class ConfigurationYamlConverter {
* @return properties
*/
public static Properties loadProperties(final String data) {
- return YamlEngine.unmarshalProperties(data);
+ return YamlEngine.unmarshalProperties(data, Arrays.asList(Properties.class));
}
}