This is an automated email from the ASF dual-hosted git repository.
menghaoran 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 b9793d7 Remove GovernanceRule (#11836)
b9793d7 is described below
commit b9793d740920f28b6f6142be301cfe24f861767a
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Aug 16 10:54:04 2021 +0800
Remove GovernanceRule (#11836)
* Remove useless YamlGovernanceConfigurationSwapperUtil
* Use mode for governance spring boot starter
* Use mode for governance spring boot starter
* Remove useless code
* Remove YamlGovernanceConfiguration
* Remove YamlRegistryCenterConfiguration
* Remove GovernanceRule
---
.../governance/core/rule/GovernanceRule.java | 45 -------------
.../core/rule/builder/GovernanceRuleBuilder.java | 48 --------------
.../yaml/pojo/YamlGovernanceConfiguration.java | 40 ------------
.../yaml/pojo/YamlRegistryCenterConfiguration.java | 40 ------------
.../GovernanceConfigurationYamlSwapper.java | 61 ------------------
.../RegistryCenterConfigurationYamlSwapper.java | 43 -------------
...here.infra.rule.builder.scope.GlobalRuleBuilder | 18 ------
...aml.config.swapper.YamlRuleConfigurationSwapper | 18 ------
.../GovernanceConfigurationYamlSwapperTest.java | 73 ----------------------
...RegistryCenterConfigurationYamlSwapperTest.java | 56 -----------------
.../additional-spring-configuration-metadata.json | 7 +--
.../swapper/YamlProxyConfigurationSwapperTest.java | 46 ++++----------
12 files changed, 15 insertions(+), 480 deletions(-)
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/rule/GovernanceRule.java
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/rule/GovernanceRule.java
deleted file mode 100644
index 5f7e7df..0000000
---
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/rule/GovernanceRule.java
+++ /dev/null
@@ -1,45 +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.governance.core.rule;
-
-import lombok.Getter;
-import org.apache.shardingsphere.governance.core.registry.RegistryCenter;
-import
org.apache.shardingsphere.governance.core.registry.RegistryCenterRepositoryFactory;
-import
org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
-import
org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository;
-import org.apache.shardingsphere.infra.persist.DistMetaDataPersistService;
-import org.apache.shardingsphere.infra.persist.rule.PersistRule;
-import org.apache.shardingsphere.infra.rule.identifier.level.FeatureRule;
-import org.apache.shardingsphere.infra.rule.identifier.scope.GlobalRule;
-
-/**
- * Governance rule.
- */
-@Getter
-public final class GovernanceRule implements PersistRule, FeatureRule,
GlobalRule {
-
- private final DistMetaDataPersistService distMetaDataPersistService;
-
- private final RegistryCenter registryCenter;
-
- public GovernanceRule(final GovernanceConfiguration config) {
- RegistryCenterRepository repository =
RegistryCenterRepositoryFactory.newInstance(config.getRegistryCenterConfiguration());
- distMetaDataPersistService = new
DistMetaDataPersistService(repository);
- registryCenter = new RegistryCenter(repository);
- }
-}
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/rule/builder/GovernanceRuleBuilder.java
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/rule/builder/GovernanceRuleBuilder.java
deleted file mode 100644
index 99adc45..0000000
---
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/rule/builder/GovernanceRuleBuilder.java
+++ /dev/null
@@ -1,48 +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.governance.core.rule.builder;
-
-import org.apache.shardingsphere.governance.core.constant.GovernanceOrder;
-import org.apache.shardingsphere.governance.core.rule.GovernanceRule;
-import
org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
-import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.infra.rule.builder.level.FeatureRuleBuilder;
-import org.apache.shardingsphere.infra.rule.builder.scope.GlobalRuleBuilder;
-
-import java.util.Map;
-
-/**
- * Governance rule builder.
- */
-public final class GovernanceRuleBuilder implements FeatureRuleBuilder,
GlobalRuleBuilder<GovernanceConfiguration> {
-
- @Override
- public GovernanceRule build(final GovernanceConfiguration ruleConfig,
final Map<String, ShardingSphereMetaData> mataDataMap) {
- return new GovernanceRule(ruleConfig);
- }
-
- @Override
- public int getOrder() {
- return GovernanceOrder.ORDER;
- }
-
- @Override
- public Class<GovernanceConfiguration> getTypeClass() {
- return GovernanceConfiguration.class;
- }
-}
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/pojo/YamlGovernanceConfiguration.java
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/pojo/YamlGovernanceConfiguration.java
deleted file mode 100644
index 975cb4e..0000000
---
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/pojo/YamlGovernanceConfiguration.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.governance.core.yaml.pojo;
-
-import lombok.Getter;
-import lombok.Setter;
-import
org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
-import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRuleConfiguration;
-
-/**
- * Governance configuration for YAML.
- */
-@Getter
-@Setter
-public final class YamlGovernanceConfiguration implements
YamlRuleConfiguration {
-
- private YamlRegistryCenterConfiguration registryCenter;
-
- private boolean overwrite;
-
- @Override
- public Class<GovernanceConfiguration> getRuleConfigurationType() {
- return GovernanceConfiguration.class;
- }
-}
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/pojo/YamlRegistryCenterConfiguration.java
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/pojo/YamlRegistryCenterConfiguration.java
deleted file mode 100644
index e8904c8..0000000
---
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/pojo/YamlRegistryCenterConfiguration.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.governance.core.yaml.pojo;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.apache.shardingsphere.infra.yaml.config.pojo.YamlConfiguration;
-
-import java.util.Properties;
-
-/**
- * Registry center configuration for YAML.
- */
-@Getter
-@Setter
-public final class YamlRegistryCenterConfiguration implements
YamlConfiguration {
-
- private String type;
-
- private String namespace;
-
- private String serverLists;
-
- private Properties props = new Properties();
-}
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/GovernanceConfigurationYamlSwapper.java
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/GovernanceConfigurationYamlSwapper.java
deleted file mode 100644
index f061408..0000000
---
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/GovernanceConfigurationYamlSwapper.java
+++ /dev/null
@@ -1,61 +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.governance.core.yaml.swapper;
-
-import org.apache.shardingsphere.governance.core.constant.GovernanceOrder;
-import
org.apache.shardingsphere.governance.core.yaml.pojo.YamlGovernanceConfiguration;
-import
org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
-import
org.apache.shardingsphere.governance.repository.api.config.RegistryCenterConfiguration;
-import
org.apache.shardingsphere.infra.yaml.config.swapper.YamlRuleConfigurationSwapper;
-
-/**
- * Governance configuration YAML swapper.
- */
-public final class GovernanceConfigurationYamlSwapper implements
YamlRuleConfigurationSwapper<YamlGovernanceConfiguration,
GovernanceConfiguration> {
-
- private final RegistryCenterConfigurationYamlSwapper
registryCenterConfigurationYamlSwapper = new
RegistryCenterConfigurationYamlSwapper();
-
- @Override
- public YamlGovernanceConfiguration swapToYamlConfiguration(final
GovernanceConfiguration data) {
- YamlGovernanceConfiguration result = new YamlGovernanceConfiguration();
-
result.setRegistryCenter(registryCenterConfigurationYamlSwapper.swapToYamlConfiguration(data.getRegistryCenterConfiguration()));
- result.setOverwrite(data.isOverwrite());
- return result;
- }
-
- @Override
- public GovernanceConfiguration swapToObject(final
YamlGovernanceConfiguration yamlConfig) {
- RegistryCenterConfiguration registryCenterConfig =
registryCenterConfigurationYamlSwapper.swapToObject(yamlConfig.getRegistryCenter());
- return new GovernanceConfiguration(registryCenterConfig,
yamlConfig.isOverwrite());
- }
-
- @Override
- public int getOrder() {
- return GovernanceOrder.ORDER;
- }
-
- @Override
- public Class<GovernanceConfiguration> getTypeClass() {
- return GovernanceConfiguration.class;
- }
-
- @Override
- public String getRuleTagName() {
- return "GOVERNANCE";
- }
-}
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/RegistryCenterConfigurationYamlSwapper.java
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/RegistryCenterConfigurationYamlSwapper.java
deleted file mode 100644
index 2b6dcc6..0000000
---
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/RegistryCenterConfigurationYamlSwapper.java
+++ /dev/null
@@ -1,43 +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.governance.core.yaml.swapper;
-
-import
org.apache.shardingsphere.governance.core.yaml.pojo.YamlRegistryCenterConfiguration;
-import
org.apache.shardingsphere.governance.repository.api.config.RegistryCenterConfiguration;
-import
org.apache.shardingsphere.infra.yaml.config.swapper.YamlConfigurationSwapper;
-
-/**
- * Registry center configuration YAML swapper.
- */
-public final class RegistryCenterConfigurationYamlSwapper implements
YamlConfigurationSwapper<YamlRegistryCenterConfiguration,
RegistryCenterConfiguration> {
-
- @Override
- public YamlRegistryCenterConfiguration swapToYamlConfiguration(final
RegistryCenterConfiguration config) {
- YamlRegistryCenterConfiguration result = new
YamlRegistryCenterConfiguration();
- result.setType(config.getType());
- result.setNamespace(config.getNamespace());
- result.setServerLists(config.getServerLists());
- result.setProps(config.getProps());
- return result;
- }
-
- @Override
- public RegistryCenterConfiguration swapToObject(final
YamlRegistryCenterConfiguration yamlConfig) {
- return new RegistryCenterConfiguration(yamlConfig.getType(),
yamlConfig.getNamespace(), yamlConfig.getServerLists(), yamlConfig.getProps());
- }
-}
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.scope.GlobalRuleBuilder
b/shardingsphere-governance/shardingsphere-governance-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.scope.GlobalRuleBuilder
deleted file mode 100644
index 9ab0943..0000000
---
a/shardingsphere-governance/shardingsphere-governance-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.scope.GlobalRuleBuilder
+++ /dev/null
@@ -1,18 +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.
-#
-
-org.apache.shardingsphere.governance.core.rule.builder.GovernanceRuleBuilder
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.yaml.config.swapper.YamlRuleConfigurationSwapper
b/shardingsphere-governance/shardingsphere-governance-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.yaml.config.swapper.YamlRuleConfigurationSwapper
deleted file mode 100644
index a96685d..0000000
---
a/shardingsphere-governance/shardingsphere-governance-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.yaml.config.swapper.YamlRuleConfigurationSwapper
+++ /dev/null
@@ -1,18 +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.
-#
-
-org.apache.shardingsphere.governance.core.yaml.swapper.GovernanceConfigurationYamlSwapper
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/yaml/swapper/GovernanceConfigurationYamlSwapperTest.java
b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/yaml/swapper/GovernanceConfigurationYamlSwapperTest.java
deleted file mode 100644
index b9430d7..0000000
---
a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/yaml/swapper/GovernanceConfigurationYamlSwapperTest.java
+++ /dev/null
@@ -1,73 +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.governance.core.yaml.swapper;
-
-import
org.apache.shardingsphere.governance.core.yaml.pojo.YamlGovernanceConfiguration;
-import
org.apache.shardingsphere.governance.core.yaml.pojo.YamlRegistryCenterConfiguration;
-import
org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
-import
org.apache.shardingsphere.governance.repository.api.config.RegistryCenterConfiguration;
-import org.junit.Test;
-
-import java.util.Properties;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class GovernanceConfigurationYamlSwapperTest {
-
- @Test
- public void assertSwapToYamlGovernanceConfiguration() {
- GovernanceConfiguration expected = createGovernanceConfiguration();
- YamlGovernanceConfiguration actual = new
GovernanceConfigurationYamlSwapper().swapToYamlConfiguration(expected);
- assertThat(actual.isOverwrite(), is(expected.isOverwrite()));
- assertThat(actual.getRegistryCenter().getType(),
is(expected.getRegistryCenterConfiguration().getType()));
- assertThat(actual.getRegistryCenter().getNamespace(),
is(expected.getRegistryCenterConfiguration().getNamespace()));
- assertThat(actual.getRegistryCenter().getServerLists(),
is(expected.getRegistryCenterConfiguration().getServerLists()));
- assertThat(actual.getRegistryCenter().getProps(),
is(expected.getRegistryCenterConfiguration().getProps()));
- }
-
- private GovernanceConfiguration createGovernanceConfiguration() {
- return new GovernanceConfiguration(new
RegistryCenterConfiguration("TEST", "logic_schema", "127.0.0.1:2181", new
Properties()), false);
- }
-
- @Test
- public void assertSwapToGovernanceConfiguration() {
- YamlGovernanceConfiguration expected =
createYamlGovernanceConfiguration();
- GovernanceConfiguration actual = new
GovernanceConfigurationYamlSwapper().swapToObject(expected);
- assertThat(actual.getRegistryCenterConfiguration().getNamespace(),
is(expected.getRegistryCenter().getNamespace()));
- assertThat(actual.isOverwrite(), is(expected.isOverwrite()));
- assertThat(actual.getRegistryCenterConfiguration().getType(),
is(expected.getRegistryCenter().getType()));
- assertThat(actual.getRegistryCenterConfiguration().getServerLists(),
is(expected.getRegistryCenter().getServerLists()));
- assertThat(actual.getRegistryCenterConfiguration().getProps(),
is(expected.getRegistryCenter().getProps()));
- }
-
- private YamlGovernanceConfiguration createYamlGovernanceConfiguration() {
- YamlGovernanceConfiguration result = new YamlGovernanceConfiguration();
- result.setRegistryCenter(createYamlRegistryCenterConfiguration());
- return result;
- }
-
- private YamlRegistryCenterConfiguration
createYamlRegistryCenterConfiguration() {
- YamlRegistryCenterConfiguration result = new
YamlRegistryCenterConfiguration();
- result.setType("TEST");
- result.setNamespace("logic_schema");
- result.setServerLists("127.0.0.1:2181");
- result.setProps(new Properties());
- return result;
- }
-}
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/yaml/swapper/RegistryCenterConfigurationYamlSwapperTest.java
b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/yaml/swapper/RegistryCenterConfigurationYamlSwapperTest.java
deleted file mode 100644
index 68dda13a..0000000
---
a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/yaml/swapper/RegistryCenterConfigurationYamlSwapperTest.java
+++ /dev/null
@@ -1,56 +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.governance.core.yaml.swapper;
-
-import
org.apache.shardingsphere.governance.core.yaml.pojo.YamlRegistryCenterConfiguration;
-import
org.apache.shardingsphere.governance.repository.api.config.RegistryCenterConfiguration;
-import org.junit.Test;
-
-import java.util.Properties;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class RegistryCenterConfigurationYamlSwapperTest {
-
- @Test
- public void assertToYamlConfiguration() {
- RegistryCenterConfiguration expected = new
RegistryCenterConfiguration("TEST", "test", "127.0.0.1:2181", new Properties());
- YamlRegistryCenterConfiguration actual = new
RegistryCenterConfigurationYamlSwapper().swapToYamlConfiguration(expected);
- assertThat(actual.getType(), is(expected.getType()));
- assertThat(actual.getServerLists(), is(expected.getServerLists()));
- assertThat(actual.getProps(), is(expected.getProps()));
- }
-
- @Test
- public void assertSwapToObject() {
- YamlRegistryCenterConfiguration yamlConfig =
getYamlRegistryCenterConfiguration();
- RegistryCenterConfiguration config = new
RegistryCenterConfigurationYamlSwapper().swapToObject(yamlConfig);
- assertThat(config.getType(), is(yamlConfig.getType()));
- assertThat(config.getServerLists(), is(yamlConfig.getServerLists()));
- assertThat(config.getProps(), is(yamlConfig.getProps()));
- }
-
- private YamlRegistryCenterConfiguration
getYamlRegistryCenterConfiguration() {
- YamlRegistryCenterConfiguration result = new
YamlRegistryCenterConfiguration();
- result.setType("TEST");
- result.setProps(new Properties());
- result.setServerLists("127.0.0.1:2181");
- return result;
- }
-}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
index ca8b3d2..6742a91 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
@@ -76,10 +76,9 @@
"description": "Customize shardingsphere properties."
},
{
- "name": "spring.shardingsphere.governance",
- "type":
"java.util.Map<java.lang.String,org.apache.shardingsphere.governance.core.yaml.pojo.YamlRegistryCenterConfiguration>",
- "sourceType":
"org.apache.shardingsphere.spring.boot.governance.common.GovernanceSpringBootRootConfiguration",
- "description": "Customize ShardingSphere governance instance."
+ "name": "spring.shardingsphere.mode",
+ "type":
"org.apache.shardingsphere.infra.yaml.config.pojo.mode.YamlModeConfiguration",
+ "sourceType":
"org.apache.shardingsphere.spring.boot.governance.common.GovernanceSpringBootRootConfiguration"
},
{
"name": "spring.shardingsphere.datasource.names",
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-common/src/test/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapperTest.java
b/shardingsphere-proxy/shardingsphere-proxy-common/src/test/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapperTest.java
index 54dfcc9..6561204 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-common/src/test/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapperTest.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-common/src/test/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapperTest.java
@@ -19,8 +19,6 @@ package org.apache.shardingsphere.proxy.config.yaml.swapper;
import
org.apache.shardingsphere.authority.api.config.AuthorityRuleConfiguration;
import
org.apache.shardingsphere.authority.yaml.config.YamlAuthorityRuleConfiguration;
-import
org.apache.shardingsphere.governance.core.yaml.pojo.YamlGovernanceConfiguration;
-import
org.apache.shardingsphere.governance.core.yaml.pojo.YamlRegistryCenterConfiguration;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceParameter;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
@@ -57,7 +55,7 @@ public final class YamlProxyConfigurationSwapperTest {
@Test
public void assertSwap() {
- YamlProxyConfiguration yamlProxyConfig = getYamlProxyConfiguration();
+ YamlProxyConfiguration yamlProxyConfig = mockYamlProxyConfiguration();
ProxyConfiguration proxyConfig = new
YamlProxyConfigurationSwapper().swap(yamlProxyConfig);
assertAuthority(proxyConfig);
assertProxyConfigurationProps(proxyConfig);
@@ -119,36 +117,24 @@ public final class YamlProxyConfigurationSwapperTest {
return Collections.emptyList();
}
- private YamlProxyConfiguration getYamlProxyConfiguration() {
+ private YamlProxyConfiguration mockYamlProxyConfiguration() {
YamlProxyConfiguration result = mock(YamlProxyConfiguration.class);
YamlProxyServerConfiguration yamlProxyServerConfig =
getYamlProxyServerConfiguration(result);
- prepareAuthentication(yamlProxyServerConfig);
- YamlGovernanceConfiguration yamlGovernanceConfig = createGovernance();
- createRegistryCenter(yamlGovernanceConfig);
- prepareProps(yamlProxyServerConfig);
- YamlProxyRuleConfiguration yamlProxyRuleConfig =
prepareRuleConfigurations(result);
- prepareDataSources(yamlProxyRuleConfig);
- prepareRules(yamlProxyRuleConfig);
+ mockAuthentication(yamlProxyServerConfig);
+ mockProps(yamlProxyServerConfig);
+ YamlProxyRuleConfiguration yamlProxyRuleConfig =
mockRuleConfigurations(result);
+ mockDataSources(yamlProxyRuleConfig);
+ mockRules(yamlProxyRuleConfig);
return result;
}
-
- private void createRegistryCenter(final YamlGovernanceConfiguration
yamlGovernanceConfig) {
- YamlRegistryCenterConfiguration registryCenterConfig = new
YamlRegistryCenterConfiguration();
- registryCenterConfig.setType("typeOne");
- registryCenterConfig.setServerLists("serverLists1");
- Properties props = new Properties();
- props.setProperty("key1", "value1");
- registryCenterConfig.setProps(props);
- yamlGovernanceConfig.setRegistryCenter(registryCenterConfig);
- }
- private void prepareProps(final YamlProxyServerConfiguration
yamlProxyServerConfig) {
+ private void mockProps(final YamlProxyServerConfiguration
yamlProxyServerConfig) {
Properties props = new Properties();
props.setProperty("key4", "value4");
when(yamlProxyServerConfig.getProps()).thenReturn(props);
}
- private YamlProxyRuleConfiguration prepareRuleConfigurations(final
YamlProxyConfiguration yamlProxyConfig) {
+ private YamlProxyRuleConfiguration mockRuleConfigurations(final
YamlProxyConfiguration yamlProxyConfig) {
Map<String, YamlProxyRuleConfiguration> yamlProxyRuleConfigMap = new
HashMap<>(1, 1);
when(yamlProxyConfig.getRuleConfigurations()).thenReturn(yamlProxyRuleConfigMap);
YamlProxyRuleConfiguration result =
mock(YamlProxyRuleConfiguration.class);
@@ -156,7 +142,7 @@ public final class YamlProxyConfigurationSwapperTest {
return result;
}
- private void prepareDataSources(final YamlProxyRuleConfiguration
yamlProxyRuleConfig) {
+ private void mockDataSources(final YamlProxyRuleConfiguration
yamlProxyRuleConfig) {
YamlDataSourceParameter yamlDataSourceParameter =
mock(YamlDataSourceParameter.class);
when(yamlDataSourceParameter.getUrl()).thenReturn("url1");
when(yamlDataSourceParameter.getUsername()).thenReturn("username1");
@@ -172,22 +158,14 @@ public final class YamlProxyConfigurationSwapperTest {
when(yamlProxyRuleConfig.getDataSources()).thenReturn(dataSources);
}
- private void prepareRules(final YamlProxyRuleConfiguration
yamlProxyRuleConfig) {
+ private void mockRules(final YamlProxyRuleConfiguration
yamlProxyRuleConfig) {
Collection<YamlRuleConfiguration> rules = new LinkedList<>();
YamlRuleConfiguration testRuleConfig = new
YamlReadwriteSplittingRuleConfiguration();
rules.add(testRuleConfig);
when(yamlProxyRuleConfig.getRules()).thenReturn(rules);
}
- private YamlGovernanceConfiguration createGovernance() {
- YamlRegistryCenterConfiguration registryCenterConfig = new
YamlRegistryCenterConfiguration();
- registryCenterConfig.setNamespace("test1");
- YamlGovernanceConfiguration result = new YamlGovernanceConfiguration();
- result.setRegistryCenter(registryCenterConfig);
- return result;
- }
-
- private void prepareAuthentication(final YamlProxyServerConfiguration
yamlProxyServerConfig) {
+ private void mockAuthentication(final YamlProxyServerConfiguration
yamlProxyServerConfig) {
YamlAuthorityRuleConfiguration yamlAuthorityRuleConfig = new
YamlAuthorityRuleConfiguration();
yamlAuthorityRuleConfig.setUsers(getUsers());
YamlShardingSphereAlgorithmConfiguration provider = new
YamlShardingSphereAlgorithmConfiguration();