diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenter.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenter.java index 56babde32a50ca3d6f065bc82744c614ecb251ae..3b0fcfd43168f5a99c3a147640ce0f4cdb690b53 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenter.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenter.java @@ -68,8 +68,8 @@ public final class ConfigCenter { private final ConfigurationRepository repository; - public ConfigCenter(final String name, final ConfigurationRepository repository) { - node = new ConfigCenterNode(name); + public ConfigCenter(final ConfigurationRepository repository) { + node = new ConfigCenterNode(); this.repository = repository; DataSourceCallback.getInstance().register(this::persistDataSourceConfiguration); RuleCallback.getInstance().register(this::persistRuleConfigurations); diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNode.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNode.java index b61576595fe77b217c454c518be41ef699ff9c86..527ff510de2d0e0d873e767521267ff85fe3d732 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNode.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNode.java @@ -54,15 +54,13 @@ public final class ConfigCenterNode { private static final String PATH_SEPARATOR = "/"; - private final String name; - /** * Get schema path. * * @return schema path */ public String getSchemaPath() { - return Joiner.on(PATH_SEPARATOR).join("", name, ROOT, SCHEMA_NODE); + return Joiner.on(PATH_SEPARATOR).join("", ROOT, SCHEMA_NODE); } /** @@ -72,7 +70,7 @@ public final class ConfigCenterNode { * @return schema name path */ public String getSchemaNamePath(final String schemaName) { - return Joiner.on(PATH_SEPARATOR).join("", name, ROOT, SCHEMA_NODE, schemaName); + return Joiner.on(PATH_SEPARATOR).join("", ROOT, SCHEMA_NODE, schemaName); } /** @@ -114,11 +112,11 @@ public final class ConfigCenterNode { } private String getFullPath(final String schemaName, final String node) { - return Joiner.on(PATH_SEPARATOR).join("", name, ROOT, SCHEMA_NODE, schemaName, node); + return Joiner.on(PATH_SEPARATOR).join("", ROOT, SCHEMA_NODE, schemaName, node); } private String getFullPath(final String node) { - return Joiner.on(PATH_SEPARATOR).join("", name, ROOT, node); + return Joiner.on(PATH_SEPARATOR).join("", ROOT, node); } /** diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/AuthenticationChangedListener.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/AuthenticationChangedListener.java index 4e0fc977ef91e0580413de8d6f6e5f5967e18b95..7f164c5bce6e2dd6655fe16a26b42257c0fbcf43 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/AuthenticationChangedListener.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/AuthenticationChangedListener.java @@ -33,8 +33,8 @@ import java.util.Collections; */ public final class AuthenticationChangedListener extends PostOrchestrationRepositoryEventListener { - public AuthenticationChangedListener(final String name, final ConfigurationRepository configurationRepository) { - super(configurationRepository, Collections.singletonList(new ConfigCenterNode(name).getAuthenticationPath())); + public AuthenticationChangedListener(final ConfigurationRepository configurationRepository) { + super(configurationRepository, Collections.singletonList(new ConfigCenterNode().getAuthenticationPath())); } @Override diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/ClusterConfigurationChangedListener.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/ClusterConfigurationChangedListener.java index 0027966e3297744f635215d4087fd20d628661c2..1f5e35b5af7242478b0eec3615b72825beb1d736 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/ClusterConfigurationChangedListener.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/ClusterConfigurationChangedListener.java @@ -33,8 +33,8 @@ import java.util.Collections; */ public final class ClusterConfigurationChangedListener extends PostOrchestrationRepositoryEventListener { - public ClusterConfigurationChangedListener(final String name, final ConfigurationRepository configurationRepository) { - super(configurationRepository, Collections.singletonList(new ConfigCenterNode(name).getClusterPath())); + public ClusterConfigurationChangedListener(final ConfigurationRepository configurationRepository) { + super(configurationRepository, Collections.singletonList(new ConfigCenterNode().getClusterPath())); } @Override diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/ConfigurationListenerManager.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/ConfigurationListenerManager.java index 5a169564432f5e9571944b6d5e304bf0abf3e1f0..d9c693bc41978117ccbafd2f6f4d889950f8610b 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/ConfigurationListenerManager.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/ConfigurationListenerManager.java @@ -37,12 +37,12 @@ public final class ConfigurationListenerManager { private final ClusterConfigurationChangedListener clusterConfigurationChangedListener; - public ConfigurationListenerManager(final String name, final ConfigurationRepository configurationRepository, final Collection schemaNames) { - schemaChangedListener = new SchemaChangedListener(name, configurationRepository, schemaNames); - propertiesChangedListener = new PropertiesChangedListener(name, configurationRepository); - authenticationChangedListener = new AuthenticationChangedListener(name, configurationRepository); - metricsConfigurationChangedListener = new MetricsConfigurationChangedListener(name, configurationRepository); - clusterConfigurationChangedListener = new ClusterConfigurationChangedListener(name, configurationRepository); + public ConfigurationListenerManager(final ConfigurationRepository configurationRepository, final Collection schemaNames) { + schemaChangedListener = new SchemaChangedListener(configurationRepository, schemaNames); + propertiesChangedListener = new PropertiesChangedListener(configurationRepository); + authenticationChangedListener = new AuthenticationChangedListener(configurationRepository); + metricsConfigurationChangedListener = new MetricsConfigurationChangedListener(configurationRepository); + clusterConfigurationChangedListener = new ClusterConfigurationChangedListener(configurationRepository); } /** diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/MetricsConfigurationChangedListener.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/MetricsConfigurationChangedListener.java index 7a3799b28c978b414f3040ae10507b62dc038ea8..8a9fa82db0adab0818148894831df985682c9460 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/MetricsConfigurationChangedListener.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/MetricsConfigurationChangedListener.java @@ -33,8 +33,8 @@ import java.util.Collections; */ public final class MetricsConfigurationChangedListener extends PostOrchestrationRepositoryEventListener { - public MetricsConfigurationChangedListener(final String name, final ConfigurationRepository configurationRepository) { - super(configurationRepository, Collections.singletonList(new ConfigCenterNode(name).getMetricsPath())); + public MetricsConfigurationChangedListener(final ConfigurationRepository configurationRepository) { + super(configurationRepository, Collections.singletonList(new ConfigCenterNode().getMetricsPath())); } @Override diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/PropertiesChangedListener.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/PropertiesChangedListener.java index b2671836ec60b63c3848a44a3ce2b74371aae680..ebe5d79ae7ee24084ba6dfa9954286c969e9b518 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/PropertiesChangedListener.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/PropertiesChangedListener.java @@ -31,8 +31,8 @@ import java.util.Collections; */ public final class PropertiesChangedListener extends PostOrchestrationRepositoryEventListener { - public PropertiesChangedListener(final String name, final ConfigurationRepository configurationRepository) { - super(configurationRepository, Collections.singletonList(new ConfigCenterNode(name).getPropsPath())); + public PropertiesChangedListener(final ConfigurationRepository configurationRepository) { + super(configurationRepository, Collections.singletonList(new ConfigCenterNode().getPropsPath())); } @Override diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/SchemaChangedListener.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/SchemaChangedListener.java index 2dd93d2b2c3aa8a3e1b0fdadb90deaabae161ae9..240171e75f05e85fe9860a2de8895290376a8987 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/SchemaChangedListener.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/SchemaChangedListener.java @@ -59,10 +59,10 @@ public final class SchemaChangedListener extends PostOrchestrationRepositoryEven private final Collection existedSchemaNames = new LinkedHashSet<>(); - public SchemaChangedListener(final String name, final ConfigurationRepository configurationRepository, final Collection schemaNames) { - super(configurationRepository, new ConfigCenterNode(name).getAllSchemaConfigPaths(schemaNames)); - configurationService = new ConfigCenter(name, configurationRepository); - configurationNode = new ConfigCenterNode(name); + public SchemaChangedListener(final ConfigurationRepository configurationRepository, final Collection schemaNames) { + super(configurationRepository, new ConfigCenterNode().getAllSchemaConfigPaths(schemaNames)); + configurationService = new ConfigCenter(configurationRepository); + configurationNode = new ConfigCenterNode(); existedSchemaNames.addAll(schemaNames); } diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNodeTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNodeTest.java index d9cf7f6a07ec7d48b4cd3ccb75b60034e3391926..8d12715678d715007891170f600d480d7e1efc2b 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNodeTest.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNodeTest.java @@ -30,60 +30,60 @@ import static org.junit.Assert.assertTrue; public final class ConfigCenterNodeTest { - private final ConfigCenterNode configurationNode = new ConfigCenterNode("test"); + private final ConfigCenterNode configurationNode = new ConfigCenterNode(); @Test public void assertGetSchemaPath() { - assertThat(configurationNode.getRulePath(DefaultSchema.LOGIC_NAME), is("/test/config/schema/logic_db/rule")); + assertThat(configurationNode.getRulePath(DefaultSchema.LOGIC_NAME), is("/config/schema/logic_db/rule")); } @Test public void assertGetDataSourcePath() { - assertThat(configurationNode.getDataSourcePath(DefaultSchema.LOGIC_NAME), is("/test/config/schema/logic_db/datasource")); + assertThat(configurationNode.getDataSourcePath(DefaultSchema.LOGIC_NAME), is("/config/schema/logic_db/datasource")); } @Test public void assertGetRulePath() { - assertThat(configurationNode.getRulePath(DefaultSchema.LOGIC_NAME), is("/test/config/schema/logic_db/rule")); + assertThat(configurationNode.getRulePath(DefaultSchema.LOGIC_NAME), is("/config/schema/logic_db/rule")); } @Test public void assertGetAuthenticationPath() { - assertThat(configurationNode.getAuthenticationPath(), is("/test/config/authentication")); + assertThat(configurationNode.getAuthenticationPath(), is("/config/authentication")); } @Test public void assertGetPropsPath() { - assertThat(configurationNode.getPropsPath(), is("/test/config/props")); + assertThat(configurationNode.getPropsPath(), is("/config/props")); } @Test public void assertGetSchemaName() { - assertThat(configurationNode.getSchemaName("/test/config/schema/logic_db/rule"), is(DefaultSchema.LOGIC_NAME)); + assertThat(configurationNode.getSchemaName("/config/schema/logic_db/rule"), is(DefaultSchema.LOGIC_NAME)); } @Test public void assertGetAllSchemaConfigPaths() { Collection actual = configurationNode.getAllSchemaConfigPaths(Collections.singletonList(DefaultSchema.LOGIC_NAME)); assertThat(actual.size(), is(4)); - assertThat(actual, hasItems("/test/config/schema")); - assertThat(actual, hasItems("/test/config/schema/logic_db")); - assertThat(actual, hasItems("/test/config/schema/logic_db/rule")); - assertThat(actual, hasItems("/test/config/schema/logic_db/datasource")); + assertThat(actual, hasItems("/config/schema")); + assertThat(actual, hasItems("/config/schema/logic_db")); + assertThat(actual, hasItems("/config/schema/logic_db/rule")); + assertThat(actual, hasItems("/config/schema/logic_db/datasource")); } @Test public void assertGetClusterPath() { - assertThat(configurationNode.getClusterPath(), is("/test/config/cluster")); + assertThat(configurationNode.getClusterPath(), is("/config/cluster")); } @Test public void assertGetMetricsPath() { - assertTrue(configurationNode.getMetricsPath().contains("/test/config/metrics")); + assertTrue(configurationNode.getMetricsPath().contains("/config/metrics")); } @Test public void assertGetSchemaNamePath() { - assertThat(configurationNode.getSchemaNamePath("sharding_db"), is("/test/config/schema/sharding_db")); + assertThat(configurationNode.getSchemaNamePath("sharding_db"), is("/config/schema/sharding_db")); } } diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterTest.java index c700ec080474f29dc98475c04e505dd5ab033122..b696b9973cb789cc1dc6719428046948a39f3cbe 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterTest.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterTest.java @@ -99,144 +99,144 @@ public final class ConfigCenterTest { @Test public void assertPersistConfigurationForShardingRuleWithoutAuthenticationAndIsNotOverwriteAndConfigurationIsExisted() { - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); configurationService.persistConfigurations("sharding_db", createDataSourceConfigurations(), createRuleConfigurations(), false); - verify(configurationRepository, times(0)).persist(eq("/test/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); - verify(configurationRepository, times(0)).persist("/test/config/schema/sharding_db/rule", readYAML(SHARDING_RULE_YAML)); + verify(configurationRepository, times(0)).persist(eq("/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); + verify(configurationRepository, times(0)).persist("/config/schema/sharding_db/rule", readYAML(SHARDING_RULE_YAML)); } @Test public void assertMoreShardingSchema() { - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); configurationService.persistConfigurations("sharding_db", createDataSourceConfigurations(), createRuleConfigurations(), false); - verify(configurationRepository, times(0)).persist("/test/config/schema", "myTest1,myTest2,sharding_db"); + verify(configurationRepository, times(0)).persist("/config/schema", "myTest1,myTest2,sharding_db"); } @Test public void assertMoreAndContainsShardingSchema() { - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); configurationService.persistConfigurations("sharding_db", createDataSourceConfigurations(), createRuleConfigurations(), false); - verify(configurationRepository, times(0)).persist("/test/config/schema", "myTest1,sharding_db"); + verify(configurationRepository, times(0)).persist("/config/schema", "myTest1,sharding_db"); } @Test public void assertPersistConfigurationForShardingRuleWithoutAuthenticationAndIsNotOverwriteAndConfigurationIsNotExisted() { - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); configurationService.persistConfigurations("sharding_db", createDataSourceConfigurations(), createRuleConfigurations(), false); - verify(configurationRepository, times(0)).persist(eq("/test/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); - verify(configurationRepository, times(0)).persist("/test/config/schema/sharding_db/rule", readYAML(SHARDING_RULE_YAML)); + verify(configurationRepository, times(0)).persist(eq("/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); + verify(configurationRepository, times(0)).persist("/config/schema/sharding_db/rule", readYAML(SHARDING_RULE_YAML)); } @Test public void assertPersistConfigurationForShardingRuleWithoutAuthenticationAndIsOverwrite() { - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); configurationService.persistConfigurations("sharding_db", createDataSourceConfigurations(), createRuleConfigurations(), true); - verify(configurationRepository).persist(eq("/test/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); - verify(configurationRepository, times(0)).persist("/test/config/schema/sharding_db/rule", readYAML(SHARDING_RULE_YAML)); + verify(configurationRepository).persist(eq("/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); + verify(configurationRepository, times(0)).persist("/config/schema/sharding_db/rule", readYAML(SHARDING_RULE_YAML)); } @Test public void assertPersistConfigurationForMasterSlaveRuleWithoutAuthenticationAndIsNotOverwriteAndConfigurationIsExisted() { - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); configurationService.persistConfigurations("sharding_db", createDataSourceConfigurations(), createMasterSlaveRuleConfiguration(), false); - verify(configurationRepository, times(0)).persist(eq("/test/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); - verify(configurationRepository, times(0)).persist("/test/config/schema/sharding_db/rule", readYAML(MASTER_SLAVE_RULE_YAML)); + verify(configurationRepository, times(0)).persist(eq("/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); + verify(configurationRepository, times(0)).persist("/config/schema/sharding_db/rule", readYAML(MASTER_SLAVE_RULE_YAML)); } @Test public void assertPersistConfigurationForMasterSlaveRuleWithoutAuthenticationAndIsNotOverwriteAndConfigurationIsNotExisted() { - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); configurationService.persistConfigurations("sharding_db", createDataSourceConfigurations(), createMasterSlaveRuleConfiguration(), false); - verify(configurationRepository, times(0)).persist(eq("/test/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); - verify(configurationRepository, times(0)).persist("/test/config/schema/sharding_db/rule", readYAML(MASTER_SLAVE_RULE_YAML)); + verify(configurationRepository, times(0)).persist(eq("/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); + verify(configurationRepository, times(0)).persist("/config/schema/sharding_db/rule", readYAML(MASTER_SLAVE_RULE_YAML)); } @Test public void assertPersistConfigurationForMasterSlaveRuleWithoutAuthenticationAndIsOverwrite() { - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); configurationService.persistConfigurations("sharding_db", createDataSourceConfigurations(), createMasterSlaveRuleConfiguration(), true); - verify(configurationRepository).persist(eq("/test/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); - verify(configurationRepository, times(0)).persist("/test/config/schema/sharding_db/rule", readYAML(MASTER_SLAVE_RULE_YAML)); + verify(configurationRepository).persist(eq("/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); + verify(configurationRepository, times(0)).persist("/config/schema/sharding_db/rule", readYAML(MASTER_SLAVE_RULE_YAML)); } @Test public void assertPersistConfigurationForShardingRuleWithAuthenticationAndIsNotOverwriteAndConfigurationIsExisted() { - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); configurationService.persistConfigurations("sharding_db", createDataSourceConfigurations(), createRuleConfigurations(), false); - verify(configurationRepository, times(0)).persist(eq("/test/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); - verify(configurationRepository, times(0)).persist("/test/config/schema/sharding_db/rule", readYAML(SHARDING_RULE_YAML)); + verify(configurationRepository, times(0)).persist(eq("/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); + verify(configurationRepository, times(0)).persist("/config/schema/sharding_db/rule", readYAML(SHARDING_RULE_YAML)); } @Test public void assertPersistConfigurationForShardingRuleWithAuthenticationAndIsNotOverwriteAndConfigurationIsNotExisted() { - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); configurationService.persistConfigurations("sharding_db", createDataSourceConfigurations(), createRuleConfigurations(), false); - verify(configurationRepository, times(0)).persist(eq("/test/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); - verify(configurationRepository, times(0)).persist("/test/config/schema/sharding_db/rule", readYAML(SHARDING_RULE_YAML)); + verify(configurationRepository, times(0)).persist(eq("/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); + verify(configurationRepository, times(0)).persist("/config/schema/sharding_db/rule", readYAML(SHARDING_RULE_YAML)); } @Test public void assertPersistConfigurationForShardingRuleWithAuthenticationAndIsOverwrite() { - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); configurationService.persistConfigurations("sharding_db", createDataSourceConfigurations(), createRuleConfigurations(), true); - verify(configurationRepository).persist(eq("/test/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); - verify(configurationRepository, times(0)).persist("/test/config/schema/sharding_db/rule", readYAML(SHARDING_RULE_YAML)); + verify(configurationRepository).persist(eq("/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); + verify(configurationRepository, times(0)).persist("/config/schema/sharding_db/rule", readYAML(SHARDING_RULE_YAML)); } @Test public void assertPersistConfigurationForMasterSlaveRuleWithAuthenticationAndIsNotOverwriteAndConfigurationIsExisted() { - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); configurationService.persistConfigurations("sharding_db", createDataSourceConfigurations(), createMasterSlaveRuleConfiguration(), false); - verify(configurationRepository, times(0)).persist(eq("/test/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); - verify(configurationRepository, times(0)).persist("/test/config/schema/sharding_db/rule", readYAML(MASTER_SLAVE_RULE_YAML)); + verify(configurationRepository, times(0)).persist(eq("/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); + verify(configurationRepository, times(0)).persist("/config/schema/sharding_db/rule", readYAML(MASTER_SLAVE_RULE_YAML)); } @Test public void assertPersistConfigurationForMasterSlaveRuleWithAuthenticationAndIsNotOverwriteAndConfigurationIsNotExisted() { - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); configurationService.persistConfigurations("sharding_db", createDataSourceConfigurations(), createMasterSlaveRuleConfiguration(), false); - verify(configurationRepository, times(0)).persist(eq("/test/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); - verify(configurationRepository, times(0)).persist("/test/config/schema/sharding_db/rule", readYAML(MASTER_SLAVE_RULE_YAML)); + verify(configurationRepository, times(0)).persist(eq("/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); + verify(configurationRepository, times(0)).persist("/config/schema/sharding_db/rule", readYAML(MASTER_SLAVE_RULE_YAML)); } @Test public void assertPersistConfigurationForMasterSlaveRuleWithAuthenticationAndIsOverwrite() { - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); configurationService.persistConfigurations("sharding_db", createDataSourceConfigurations(), createMasterSlaveRuleConfiguration(), true); - verify(configurationRepository).persist(eq("/test/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); - verify(configurationRepository, times(0)).persist("/test/config/schema/sharding_db/rule", readYAML(MASTER_SLAVE_RULE_YAML)); + verify(configurationRepository).persist(eq("/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); + verify(configurationRepository, times(0)).persist("/config/schema/sharding_db/rule", readYAML(MASTER_SLAVE_RULE_YAML)); } @Test public void assertPersistConfigurationForEncrypt() { - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); configurationService.persistConfigurations("sharding_db", createDataSourceConfigurations(), createEncryptRuleConfiguration(), true); - verify(configurationRepository).persist(eq("/test/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); - verify(configurationRepository, times(0)).persist("/test/config/schema/sharding_db/rule", readYAML(ENCRYPT_RULE_YAML)); + verify(configurationRepository).persist(eq("/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); + verify(configurationRepository, times(0)).persist("/config/schema/sharding_db/rule", readYAML(ENCRYPT_RULE_YAML)); } @Test public void assertNullRuleConfiguration() { - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); configurationService.persistConfigurations("sharding_db", createDataSourceConfigurations(), Collections.emptyList(), true); } @Test public void assertPersistConfigurationForShadow() { - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); configurationService.persistConfigurations("sharding_db", createDataSourceConfigurations(), createShadowRuleConfiguration(), true); - verify(configurationRepository).persist(eq("/test/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); - verify(configurationRepository, times(0)).persist("/test/config/schema/sharding_db/rule", readYAML(SHADOW_RULE_YAML)); + verify(configurationRepository).persist(eq("/config/schema/sharding_db/datasource"), ArgumentMatchers.any()); + verify(configurationRepository, times(0)).persist("/config/schema/sharding_db/rule", readYAML(SHADOW_RULE_YAML)); } @Test public void assertPersistGlobalConfiguration() { - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); configurationService.persistGlobalConfiguration(createAuthentication(), createProperties(), true); - verify(configurationRepository, times(0)).persist("/test/config/authentication", readYAML(AUTHENTICATION_YAML)); - verify(configurationRepository).persist("/test/config/props", PROPS_YAML); + verify(configurationRepository, times(0)).persist("/config/authentication", readYAML(AUTHENTICATION_YAML)); + verify(configurationRepository).persist("/config/props", PROPS_YAML); } private Map createDataSourceConfigurations() { @@ -291,8 +291,8 @@ public final class ConfigCenterTest { @Test public void assertLoadDataSourceConfigurations() { - when(configurationRepository.get("/test/config/schema/sharding_db/datasource")).thenReturn(readYAML(DATA_SOURCE_YAM)); - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + when(configurationRepository.get("/config/schema/sharding_db/datasource")).thenReturn(readYAML(DATA_SOURCE_YAM)); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); Map actual = configurationService.loadDataSourceConfigurations("sharding_db"); assertThat(actual.size(), is(2)); assertDataSourceConfiguration(actual.get("ds_0"), createDataSourceConfiguration(createDataSource("ds_0"))); @@ -308,16 +308,16 @@ public final class ConfigCenterTest { @Test public void assertLoadDataSourceConfigurationsNotExistPath() { - when(configurationRepository.get("/test/config/schema/sharding_db/datasource")).thenReturn(""); - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + when(configurationRepository.get("/config/schema/sharding_db/datasource")).thenReturn(""); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); Map actual = configurationService.loadDataSourceConfigurations("sharding_db"); assertThat(actual.size(), is(0)); } @Test public void assertLoadShardingAndEncryptRuleConfiguration() { - when(configurationRepository.get("/test/config/schema/sharding_db/rule")).thenReturn(readYAML(SHARDING_AND_ENCRYPT_RULE_YAML)); - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + when(configurationRepository.get("/config/schema/sharding_db/rule")).thenReturn(readYAML(SHARDING_AND_ENCRYPT_RULE_YAML)); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); Collection ruleConfigurations = configurationService.loadRuleConfigurations("sharding_db"); assertThat(ruleConfigurations.size(), is(2)); for (RuleConfiguration each : ruleConfigurations) { @@ -337,8 +337,8 @@ public final class ConfigCenterTest { @Test public void assertLoadShardingRuleConfiguration() { - when(configurationRepository.get("/test/config/schema/sharding_db/rule")).thenReturn(readYAML(SHARDING_RULE_YAML)); - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + when(configurationRepository.get("/config/schema/sharding_db/rule")).thenReturn(readYAML(SHARDING_RULE_YAML)); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); Collection actual = configurationService.loadRuleConfigurations("sharding_db"); assertThat(actual.size(), is(1)); ShardingRuleConfiguration actualShardingRuleConfiguration = (ShardingRuleConfiguration) actual.iterator().next(); @@ -348,8 +348,8 @@ public final class ConfigCenterTest { @Test public void assertLoadMasterSlaveRuleConfiguration() { - when(configurationRepository.get("/test/config/schema/sharding_db/rule")).thenReturn(readYAML(MASTER_SLAVE_RULE_YAML)); - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + when(configurationRepository.get("/config/schema/sharding_db/rule")).thenReturn(readYAML(MASTER_SLAVE_RULE_YAML)); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); Collection actual = configurationService.loadRuleConfigurations("sharding_db"); MasterSlaveRuleConfiguration masterSlaveRuleConfiguration = (MasterSlaveRuleConfiguration) actual.iterator().next(); assertThat(masterSlaveRuleConfiguration.getDataSources().size(), is(1)); @@ -359,8 +359,8 @@ public final class ConfigCenterTest { @Test public void assertLoadEncryptRuleConfiguration() { - when(configurationRepository.get("/test/config/schema/sharding_db/rule")).thenReturn(readYAML(ENCRYPT_RULE_YAML)); - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + when(configurationRepository.get("/config/schema/sharding_db/rule")).thenReturn(readYAML(ENCRYPT_RULE_YAML)); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); EncryptRuleConfiguration actual = (EncryptRuleConfiguration) configurationService.loadRuleConfigurations("sharding_db").iterator().next(); assertThat(actual.getEncryptors().size(), is(1)); ShardingSphereAlgorithmConfiguration encryptAlgorithmConfiguration = actual.getEncryptors().get("order_encryptor"); @@ -370,8 +370,8 @@ public final class ConfigCenterTest { @Test public void assertLoadShadowRuleConfiguration() { - when(configurationRepository.get("/test/config/schema/sharding_db/rule")).thenReturn(readYAML(SHADOW_RULE_YAML)); - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + when(configurationRepository.get("/config/schema/sharding_db/rule")).thenReturn(readYAML(SHADOW_RULE_YAML)); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); ShadowRuleConfiguration actual = (ShadowRuleConfiguration) configurationService.loadRuleConfigurations("sharding_db").iterator().next(); assertThat(actual.getShadowMappings().get("ds"), is("shadow_ds")); assertThat(actual.getColumn(), is("shadow")); @@ -379,8 +379,8 @@ public final class ConfigCenterTest { @Test public void assertLoadAuthentication() { - when(configurationRepository.get("/test/config/authentication")).thenReturn(readYAML(AUTHENTICATION_YAML)); - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + when(configurationRepository.get("/config/authentication")).thenReturn(readYAML(AUTHENTICATION_YAML)); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); Authentication actual = configurationService.loadAuthentication(); assertThat(actual.getUsers().size(), is(2)); assertThat(actual.getUsers().get("root1").getPassword(), is("root1")); @@ -388,8 +388,8 @@ public final class ConfigCenterTest { @Test public void assertLoadMetricsConfiguration() { - when(configurationRepository.get("/test/config/metrics")).thenReturn(readYAML(DATA_METRICS_YAML)); - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + when(configurationRepository.get("/config/metrics")).thenReturn(readYAML(DATA_METRICS_YAML)); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); MetricsConfiguration actual = configurationService.loadMetricsConfiguration(); assertNotNull(actual); assertThat(actual.getMetricsName(), is("prometheus")); @@ -401,16 +401,16 @@ public final class ConfigCenterTest { @Test public void assertLoadProperties() { - when(configurationRepository.get("/test/config/props")).thenReturn(PROPS_YAML); - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + when(configurationRepository.get("/config/props")).thenReturn(PROPS_YAML); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); Properties actual = configurationService.loadProperties(); assertThat(actual.get(ConfigurationPropertyKey.SQL_SHOW.getKey()), is(Boolean.FALSE)); } @Test public void assertGetAllSchemaNames() { - when(configurationRepository.get("/test/config/schema")).thenReturn("sharding_db,masterslave_db"); - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + when(configurationRepository.get("/config/schema")).thenReturn("sharding_db,masterslave_db"); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); Collection actual = configurationService.getAllSchemaNames(); assertThat(actual.size(), is(2)); assertThat(actual, hasItems("sharding_db")); @@ -419,8 +419,8 @@ public final class ConfigCenterTest { @Test public void assertLoadDataSourceConfigurationsWithConnectionInitSqls() { - when(configurationRepository.get("/test/config/schema/sharding_db/datasource")).thenReturn(readYAML(DATA_SOURCE_YAML_WITH_CONNECTION_INIT_SQL)); - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + when(configurationRepository.get("/config/schema/sharding_db/datasource")).thenReturn(readYAML(DATA_SOURCE_YAML_WITH_CONNECTION_INIT_SQL)); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); Map actual = configurationService.loadDataSourceConfigurations("sharding_db"); assertThat(actual.size(), is(2)); assertDataSourceConfigurationWithConnectionInitSqls(actual.get("ds_0"), createDataSourceConfiguration(createDataSourceWithConnectionInitSqls("ds_0"))); @@ -431,15 +431,15 @@ public final class ConfigCenterTest { public void assertPersistClusterConfiguration() { ClusterConfiguration clusterConfiguration = new ClusterConfigurationYamlSwapper() .swapToObject(YamlEngine.unmarshal(readYAML(DATA_CLUSTER_YAML), YamlClusterConfiguration.class)); - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); configurationService.persistClusterConfiguration(clusterConfiguration, true); - verify(configurationRepository, times(0)).persist(eq("/test/config/cluster"), eq(readYAML(DATA_CLUSTER_YAML))); + verify(configurationRepository, times(0)).persist(eq("/config/cluster"), eq(readYAML(DATA_CLUSTER_YAML))); } @Test public void loadClusterConfiguration() { - when(configurationRepository.get("/test/config/cluster")).thenReturn(readYAML(DATA_CLUSTER_YAML)); - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + when(configurationRepository.get("/config/cluster")).thenReturn(readYAML(DATA_CLUSTER_YAML)); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); ClusterConfiguration clusterConfiguration = configurationService.loadClusterConfiguration(); assertNotNull(clusterConfiguration); assertNotNull(clusterConfiguration.getHeartbeat()); @@ -479,24 +479,24 @@ public final class ConfigCenterTest { public void assertPersistMetricsConfiguration() { MetricsConfiguration metricsConfiguration = new MetricsConfigurationYamlSwapper() .swapToObject(YamlEngine.unmarshal(readYAML(DATA_METRICS_YAML), YamlMetricsConfiguration.class)); - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); configurationService.persistMetricsConfiguration(metricsConfiguration, true); - verify(configurationRepository, times(0)).persist(eq("/test/config/metrics"), eq(readYAML(DATA_METRICS_YAML))); + verify(configurationRepository, times(0)).persist(eq("/config/metrics"), eq(readYAML(DATA_METRICS_YAML))); } @Test public void assertPersistSchemaNameWithExistSchema() { - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); - when(configurationRepository.get("/test/config/schema")).thenReturn("sharding_db"); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); + when(configurationRepository.get("/config/schema")).thenReturn("sharding_db"); configurationService.persistConfigurations("sharding_db", createDataSourceConfigurations(), createRuleConfigurations(), true); - verify(configurationRepository, times(0)).persist(eq("/test/config/schema"), eq("sharding_db")); + verify(configurationRepository, times(0)).persist(eq("/config/schema"), eq("sharding_db")); } @Test public void assertPersistSchemaNameWithExistAndNewSchema() { - ConfigCenter configurationService = new ConfigCenter("test", configurationRepository); - when(configurationRepository.get("/test/config/schema")).thenReturn("master_slave_db"); + ConfigCenter configurationService = new ConfigCenter(configurationRepository); + when(configurationRepository.get("/config/schema")).thenReturn("master_slave_db"); configurationService.persistConfigurations("sharding_db", createDataSourceConfigurations(), createRuleConfigurations(), true); - verify(configurationRepository).persist(eq("/test/config/schema"), eq("master_slave_db,sharding_db")); + verify(configurationRepository).persist(eq("/config/schema"), eq("master_slave_db,sharding_db")); } } diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/AuthenticationChangedListenerTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/AuthenticationChangedListenerTest.java index 29bbcc7d9f91c23e6ab5e78e3fe3733b79352fb7..e3e45e174e6aa1ec586d68eceb3ee9af254cccf5 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/AuthenticationChangedListenerTest.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/AuthenticationChangedListenerTest.java @@ -42,7 +42,7 @@ public final class AuthenticationChangedListenerTest { @Before public void setUp() { - authenticationChangedListener = new AuthenticationChangedListener("test", configurationRepository); + authenticationChangedListener = new AuthenticationChangedListener(configurationRepository); } @Test diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/ClusterConfigurationChangedListenerTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/ClusterConfigurationChangedListenerTest.java index a126bb12b960c4bf9732c96ffa0007ff1e9c1e7a..bf205cb75f818e560d59bb81ac255d6613871e3c 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/ClusterConfigurationChangedListenerTest.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/ClusterConfigurationChangedListenerTest.java @@ -46,7 +46,7 @@ public final class ClusterConfigurationChangedListenerTest { @Before public void setUp() { - clusterConfigurationChangedListener = new ClusterConfigurationChangedListener("test", configurationRepository); + clusterConfigurationChangedListener = new ClusterConfigurationChangedListener(configurationRepository); } @Test diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/ConfigurationListenerManagerTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/ConfigurationListenerManagerTest.java index 23287727228226f5ed7e04432851e9a975e7962e..df885e4cd23c8299d63e8dc813edc3bc92f5d893 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/ConfigurationListenerManagerTest.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/ConfigurationListenerManagerTest.java @@ -47,7 +47,7 @@ public final class ConfigurationListenerManagerTest { @Test public void assertInitListeners() { - ConfigurationListenerManager actual = new ConfigurationListenerManager("test", configurationRepository, Arrays.asList("sharding_db", "masterslave_db")); + ConfigurationListenerManager actual = new ConfigurationListenerManager(configurationRepository, Arrays.asList("sharding_db", "masterslave_db")); setField(actual, "schemaChangedListener", schemaChangedListener); setField(actual, "propertiesChangedListener", propertiesChangedListener); setField(actual, "authenticationChangedListener", authenticationChangedListener); diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/MetricsConfigurationChangedListenerTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/MetricsConfigurationChangedListenerTest.java index e7cdf3ae231ac176cbaa39860aae533d2b9f976b..f87311d5d2b6bcb2a050ccf1c82905d25e7c9373 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/MetricsConfigurationChangedListenerTest.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/MetricsConfigurationChangedListenerTest.java @@ -48,7 +48,7 @@ public final class MetricsConfigurationChangedListenerTest { @Before public void setUp() { - metricsConfigurationChangedListener = new MetricsConfigurationChangedListener("test", configurationRepository); + metricsConfigurationChangedListener = new MetricsConfigurationChangedListener(configurationRepository); } @Test diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/PropertiesChangedListenerTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/PropertiesChangedListenerTest.java index 8d7fa2dde7cc2b54b876bb1a46f3b559b6bc3e9f..b53662f28eff82639a2ed228812de93fd525a291 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/PropertiesChangedListenerTest.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/PropertiesChangedListenerTest.java @@ -41,7 +41,7 @@ public final class PropertiesChangedListenerTest { @Before public void setUp() { - propertiesChangedListener = new PropertiesChangedListener("test", configurationRepository); + propertiesChangedListener = new PropertiesChangedListener(configurationRepository); } @Test diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/SchemaChangedListenerTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/SchemaChangedListenerTest.java index 81953d0d4c5b7e71f76136afbe2c682ce99bfac8..b3c56ad2605729977c783116e28a3ca02e3f2245 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/SchemaChangedListenerTest.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/SchemaChangedListenerTest.java @@ -67,21 +67,21 @@ public final class SchemaChangedListenerTest { @Before public void setUp() { - schemaChangedListener = new SchemaChangedListener("test", configurationRepository, Arrays.asList("sharding_db", "masterslave_db", "encrypt_db")); + schemaChangedListener = new SchemaChangedListener(configurationRepository, Arrays.asList("sharding_db", "masterslave_db", "encrypt_db")); } @Test public void assertCreateIgnoredEvent() { - assertThat(schemaChangedListener.createOrchestrationEvent(new DataChangedEvent("/test/config/schema/encrypt_db", "test", ChangedType.UPDATED)), + assertThat(schemaChangedListener.createOrchestrationEvent(new DataChangedEvent("/config/schema/encrypt_db", "test", ChangedType.UPDATED)), instanceOf(IgnoredOrchestrationEvent.class)); - assertThat(schemaChangedListener.createOrchestrationEvent(new DataChangedEvent("/test/config/schema/encrypt_db/rule", "test", ChangedType.IGNORED)), + assertThat(schemaChangedListener.createOrchestrationEvent(new DataChangedEvent("/config/schema/encrypt_db/rule", "test", ChangedType.IGNORED)), instanceOf(IgnoredOrchestrationEvent.class)); } @Test public void assertCreateDataSourceChangedEventForExistedSchema() { String dataSource = readYAML(DATA_SOURCE_FILE); - DataChangedEvent dataChangedEvent = new DataChangedEvent("/test/config/schema/sharding_db/datasource", dataSource, ChangedType.UPDATED); + DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/sharding_db/datasource", dataSource, ChangedType.UPDATED); OrchestrationEvent actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent); assertThat(actual, instanceOf(DataSourceChangedEvent.class)); assertThat(((DataSourceChangedEvent) actual).getShardingSchemaName(), is("sharding_db")); @@ -90,7 +90,7 @@ public final class SchemaChangedListenerTest { @Test public void assertCreateRuleConfigurationsChangedEventForExistedSchema() { String shardingRule = readYAML(SHARDING_RULE_FILE); - DataChangedEvent dataChangedEvent = new DataChangedEvent("/test/config/schema/sharding_db/rule", shardingRule, ChangedType.UPDATED); + DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/sharding_db/rule", shardingRule, ChangedType.UPDATED); OrchestrationEvent actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent); assertThat(actual, instanceOf(RuleConfigurationsChangedEvent.class)); assertThat(((RuleConfigurationsChangedEvent) actual).getShardingSchemaName(), is("sharding_db")); @@ -102,7 +102,7 @@ public final class SchemaChangedListenerTest { @Test public void assertCreateMasterSlaveRuleChangedEventForExistedSchema() { String masterSlaveRule = readYAML(MASTER_SLAVE_RULE_FILE); - DataChangedEvent dataChangedEvent = new DataChangedEvent("/test/config/schema/masterslave_db/rule", masterSlaveRule, ChangedType.UPDATED); + DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/masterslave_db/rule", masterSlaveRule, ChangedType.UPDATED); OrchestrationEvent actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent); assertThat(actual, instanceOf(RuleConfigurationsChangedEvent.class)); RuleConfigurationsChangedEvent event = (RuleConfigurationsChangedEvent) actual; @@ -115,7 +115,7 @@ public final class SchemaChangedListenerTest { @Test public void assertCreateEncryptRuleChangedEventForExistedSchema() { String encryptRule = readYAML(ENCRYPT_RULE_FILE); - DataChangedEvent dataChangedEvent = new DataChangedEvent("/test/config/schema/encrypt_db/rule", encryptRule, ChangedType.UPDATED); + DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/encrypt_db/rule", encryptRule, ChangedType.UPDATED); OrchestrationEvent actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent); assertThat(actual, instanceOf(RuleConfigurationsChangedEvent.class)); RuleConfigurationsChangedEvent event = (RuleConfigurationsChangedEvent) actual; @@ -130,8 +130,8 @@ public final class SchemaChangedListenerTest { @Test public void assertCreateIgnoredOrchestrationEventForNewSchema() { - when(configurationRepository.get("/test/config/schema/logic_db/datasource")).thenReturn(""); - DataChangedEvent dataChangedEvent = new DataChangedEvent("/test/config/schema/logic_db/rule", "rule", ChangedType.UPDATED); + when(configurationRepository.get("/config/schema/logic_db/datasource")).thenReturn(""); + DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/logic_db/rule", "rule", ChangedType.UPDATED); OrchestrationEvent actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent); assertThat(actual, instanceOf(SchemaAddedEvent.class)); } @@ -140,11 +140,11 @@ public final class SchemaChangedListenerTest { public void assertCreateShardingSchemaAddedEventForNewSchema() { String shardingRule = readYAML(SHARDING_RULE_FILE); String dataSource = readYAML(DATA_SOURCE_FILE); - when(configurationRepository.get("/test/config/schema/logic_db/rule")).thenReturn(shardingRule); - when(configurationRepository.get("/test/config/schema/logic_db/datasource")).thenReturn(dataSource); - when(configurationRepository.get("/test/config/schema/logic_db/rule")).thenReturn(shardingRule); - when(configurationRepository.get("/test/config/schema/logic_db/datasource")).thenReturn(dataSource); - DataChangedEvent dataChangedEvent = new DataChangedEvent("/test/config/schema/logic_db/datasource", dataSource, ChangedType.UPDATED); + when(configurationRepository.get("/config/schema/logic_db/rule")).thenReturn(shardingRule); + when(configurationRepository.get("/config/schema/logic_db/datasource")).thenReturn(dataSource); + when(configurationRepository.get("/config/schema/logic_db/rule")).thenReturn(shardingRule); + when(configurationRepository.get("/config/schema/logic_db/datasource")).thenReturn(dataSource); + DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/logic_db/datasource", dataSource, ChangedType.UPDATED); OrchestrationEvent actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent); assertThat(actual, instanceOf(SchemaAddedEvent.class)); assertThat(((SchemaAddedEvent) actual).getRuleConfigurations().iterator().next(), instanceOf(ShardingRuleConfiguration.class)); @@ -154,11 +154,11 @@ public final class SchemaChangedListenerTest { public void assertCreateMasterSlaveSchemaAddedEventForNewSchema() { String dataSource = readYAML(DATA_SOURCE_FILE); String masterSlaveRule = readYAML(MASTER_SLAVE_RULE_FILE); - when(configurationRepository.get("/test/config/schema/logic_db/rule")).thenReturn(masterSlaveRule); - when(configurationRepository.get("/test/config/schema/logic_db/datasource")).thenReturn(dataSource); - when(configurationRepository.get("/test/config/schema/logic_db/rule")).thenReturn(masterSlaveRule); - when(configurationRepository.get("/test/config/schema/logic_db/datasource")).thenReturn(dataSource); - DataChangedEvent dataChangedEvent = new DataChangedEvent("/test/config/schema/logic_db/datasource", dataSource, ChangedType.UPDATED); + when(configurationRepository.get("/config/schema/logic_db/rule")).thenReturn(masterSlaveRule); + when(configurationRepository.get("/config/schema/logic_db/datasource")).thenReturn(dataSource); + when(configurationRepository.get("/config/schema/logic_db/rule")).thenReturn(masterSlaveRule); + when(configurationRepository.get("/config/schema/logic_db/datasource")).thenReturn(dataSource); + DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/logic_db/datasource", dataSource, ChangedType.UPDATED); OrchestrationEvent actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent); assertThat(actual, instanceOf(SchemaAddedEvent.class)); assertThat(((SchemaAddedEvent) actual).getRuleConfigurations().iterator().next(), instanceOf(MasterSlaveRuleConfiguration.class)); @@ -168,11 +168,11 @@ public final class SchemaChangedListenerTest { public void assertCreateEncryptSchemaAddedEventForNewSchema() { String dataSource = readYAML(DATA_SOURCE_FILE); String encryptRule = readYAML(ENCRYPT_RULE_FILE); - when(configurationRepository.get("/test/config/schema/logic_db/rule")).thenReturn(encryptRule); - when(configurationRepository.get("/test/config/schema/logic_db/datasource")).thenReturn(dataSource); - when(configurationRepository.get("/test/config/schema/logic_db/rule")).thenReturn(encryptRule); - when(configurationRepository.get("/test/config/schema/logic_db/datasource")).thenReturn(dataSource); - DataChangedEvent dataChangedEvent = new DataChangedEvent("/test/config/schema/logic_db/datasource", dataSource, ChangedType.UPDATED); + when(configurationRepository.get("/config/schema/logic_db/rule")).thenReturn(encryptRule); + when(configurationRepository.get("/config/schema/logic_db/datasource")).thenReturn(dataSource); + when(configurationRepository.get("/config/schema/logic_db/rule")).thenReturn(encryptRule); + when(configurationRepository.get("/config/schema/logic_db/datasource")).thenReturn(dataSource); + DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/logic_db/datasource", dataSource, ChangedType.UPDATED); OrchestrationEvent actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent); assertThat(actual, instanceOf(SchemaAddedEvent.class)); assertThat(((SchemaAddedEvent) actual).getRuleConfigurations().iterator().next(), instanceOf(EncryptRuleConfiguration.class)); @@ -181,7 +181,7 @@ public final class SchemaChangedListenerTest { @Test public void assertCreateSchemaDeletedEventForNewSchema() { String dataSource = readYAML(DATA_SOURCE_FILE); - DataChangedEvent dataChangedEvent = new DataChangedEvent("/test/config/schema/logic_db/datasource", dataSource, ChangedType.DELETED); + DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/logic_db/datasource", dataSource, ChangedType.DELETED); OrchestrationEvent actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent); assertThat(actual, instanceOf(SchemaDeletedEvent.class)); assertThat(((SchemaDeletedEvent) actual).getShardingSchemaName(), is("logic_db")); @@ -190,7 +190,7 @@ public final class SchemaChangedListenerTest { @Test public void assertCreateWithSchemaDeletedEvent() { String dataSource = readYAML(DATA_SOURCE_FILE); - DataChangedEvent dataChangedEvent = new DataChangedEvent("/test/config/schema/logic_db", dataSource, ChangedType.DELETED); + DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/logic_db", dataSource, ChangedType.DELETED); OrchestrationEvent actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent); assertThat(actual, instanceOf(SchemaDeletedEvent.class)); } @@ -198,7 +198,7 @@ public final class SchemaChangedListenerTest { @Test public void assertCreateWithSchemaDeletedEventWithDataSourceNode() { String dataSource = readYAML(DATA_SOURCE_FILE); - DataChangedEvent dataChangedEvent = new DataChangedEvent("/test/config/schema/datasource", dataSource, ChangedType.DELETED); + DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/datasource", dataSource, ChangedType.DELETED); OrchestrationEvent actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent); assertThat(actual, instanceOf(SchemaDeletedEvent.class)); } @@ -207,9 +207,9 @@ public final class SchemaChangedListenerTest { public void assertCreateAddedEventWithEncryptRuleConfigurationForNewSchema() { String dataSource = readYAML(DATA_SOURCE_FILE); String encryptRule = readYAML(ENCRYPT_RULE_FILE); - when(configurationRepository.get("/test/config/schema/logic_db/rule")).thenReturn(encryptRule); - when(configurationRepository.get("/test/config/schema/logic_db/datasource")).thenReturn(dataSource); - DataChangedEvent dataChangedEvent = new DataChangedEvent("/test/config/schema/logic_db/rule", encryptRule, ChangedType.UPDATED); + when(configurationRepository.get("/config/schema/logic_db/rule")).thenReturn(encryptRule); + when(configurationRepository.get("/config/schema/logic_db/datasource")).thenReturn(dataSource); + DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/logic_db/rule", encryptRule, ChangedType.UPDATED); OrchestrationEvent actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent); assertThat(actual, instanceOf(SchemaAddedEvent.class)); assertThat(((SchemaAddedEvent) actual).getRuleConfigurations().iterator().next(), instanceOf(EncryptRuleConfiguration.class)); @@ -219,9 +219,9 @@ public final class SchemaChangedListenerTest { public void assertCreateAddedEventWithShardingRuleConfigurationForNewSchema() { String dataSource = readYAML(DATA_SOURCE_FILE); String shardingRule = readYAML(SHARDING_RULE_FILE); - when(configurationRepository.get("/test/config/schema/logic_db/rule")).thenReturn(shardingRule); - when(configurationRepository.get("/test/config/schema/logic_db/datasource")).thenReturn(dataSource); - DataChangedEvent dataChangedEvent = new DataChangedEvent("/test/config/schema/logic_db/rule", shardingRule, ChangedType.UPDATED); + when(configurationRepository.get("/config/schema/logic_db/rule")).thenReturn(shardingRule); + when(configurationRepository.get("/config/schema/logic_db/datasource")).thenReturn(dataSource); + DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/logic_db/rule", shardingRule, ChangedType.UPDATED); OrchestrationEvent actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent); assertThat(actual, instanceOf(SchemaAddedEvent.class)); assertThat(((SchemaAddedEvent) actual).getRuleConfigurations().iterator().next(), instanceOf(ShardingRuleConfiguration.class)); @@ -231,9 +231,9 @@ public final class SchemaChangedListenerTest { public void assertCreateAddedEventWithMasterSlaveRuleConfigurationForNewSchema() { String dataSource = readYAML(DATA_SOURCE_FILE); String masterSlaveRule = readYAML(MASTER_SLAVE_RULE_FILE); - when(configurationRepository.get("/test/config/schema/logic_db/rule")).thenReturn(masterSlaveRule); - when(configurationRepository.get("/test/config/schema/logic_db/datasource")).thenReturn(dataSource); - DataChangedEvent dataChangedEvent = new DataChangedEvent("/test/config/schema/logic_db/rule", masterSlaveRule, ChangedType.UPDATED); + when(configurationRepository.get("/config/schema/logic_db/rule")).thenReturn(masterSlaveRule); + when(configurationRepository.get("/config/schema/logic_db/datasource")).thenReturn(dataSource); + DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/logic_db/rule", masterSlaveRule, ChangedType.UPDATED); OrchestrationEvent actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent); assertThat(actual, instanceOf(SchemaAddedEvent.class)); assertThat(((SchemaAddedEvent) actual).getRuleConfigurations().iterator().next(), instanceOf(MasterSlaveRuleConfiguration.class)); @@ -241,7 +241,7 @@ public final class SchemaChangedListenerTest { @Test public void assertCreateSchemaNamesUpdatedEventForAdd() { - DataChangedEvent dataChangedEvent = new DataChangedEvent("/test/config/schema", "sharding_db,masterslave_db,encrypt_db,shadow_db", ChangedType.UPDATED); + DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema", "sharding_db,masterslave_db,encrypt_db,shadow_db", ChangedType.UPDATED); OrchestrationEvent actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent); assertThat(actual, instanceOf(SchemaAddedEvent.class)); assertThat(((SchemaAddedEvent) actual).getShardingSchemaName(), is("shadow_db")); @@ -249,7 +249,7 @@ public final class SchemaChangedListenerTest { @Test public void assertCreateSchemaNamesUpdatedEventForDelete() { - DataChangedEvent dataChangedEvent = new DataChangedEvent("/test/config/schema", "sharding_db,masterslave_db", ChangedType.UPDATED); + DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema", "sharding_db,masterslave_db", ChangedType.UPDATED); OrchestrationEvent actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent); assertThat(actual, instanceOf(SchemaDeletedEvent.class)); assertThat(((SchemaDeletedEvent) actual).getShardingSchemaName(), is("encrypt_db")); @@ -257,14 +257,14 @@ public final class SchemaChangedListenerTest { @Test public void assertCreateSchemaNamesUpdatedEventForIgnore() { - DataChangedEvent dataChangedEvent = new DataChangedEvent("/test/config/schema", "sharding_db,masterslave_db,encrypt_db", ChangedType.UPDATED); + DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema", "sharding_db,masterslave_db,encrypt_db", ChangedType.UPDATED); OrchestrationEvent actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent); assertThat(actual, instanceOf(IgnoredOrchestrationEvent.class)); } @Test public void assertCreateSchemaNameAddEvent() { - DataChangedEvent dataChangedEvent = new DataChangedEvent("/test/config/schema/shadow_db", "", ChangedType.ADDED); + DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/shadow_db", "", ChangedType.ADDED); OrchestrationEvent actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent); assertThat(actual, instanceOf(SchemaAddedEvent.class)); assertThat(((SchemaAddedEvent) actual).getShardingSchemaName(), is("shadow_db")); diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/main/java/org/apache/shardingsphere/orchestration/core/facade/OrchestrationFacade.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/main/java/org/apache/shardingsphere/orchestration/core/facade/OrchestrationFacade.java index 426dc6970c52432f45da1cca5334468502e354bf..342cd4243059144ffe538c55e34419c2e60627b0 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/main/java/org/apache/shardingsphere/orchestration/core/facade/OrchestrationFacade.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/main/java/org/apache/shardingsphere/orchestration/core/facade/OrchestrationFacade.java @@ -66,11 +66,11 @@ public final class OrchestrationFacade implements AutoCloseable { public void init(final OrchestrationConfiguration config, final Collection schemaNames) { isOverwrite = config.isOverwrite(); repositoryFacade = new OrchestrationRepositoryFacade(config); - registryCenter = new RegistryCenter(config.getName(), repositoryFacade.getRegistryRepository()); - configCenter = new ConfigCenter(config.getName(), repositoryFacade.getConfigurationRepository()); - metaDataCenter = new MetaDataCenter(config.getName(), repositoryFacade.getConfigurationRepository()); - listenerManager = new OrchestrationListenerManager(config.getName(), - repositoryFacade.getRegistryRepository(), repositoryFacade.getConfigurationRepository(), schemaNames.isEmpty() ? configCenter.getAllSchemaNames() : schemaNames); + registryCenter = new RegistryCenter(repositoryFacade.getRegistryRepository()); + configCenter = new ConfigCenter(repositoryFacade.getConfigurationRepository()); + metaDataCenter = new MetaDataCenter(repositoryFacade.getConfigurationRepository()); + listenerManager = new OrchestrationListenerManager(repositoryFacade.getRegistryRepository(), + repositoryFacade.getConfigurationRepository(), schemaNames.isEmpty() ? configCenter.getAllSchemaNames() : schemaNames); } /** diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/main/java/org/apache/shardingsphere/orchestration/core/facade/listener/OrchestrationListenerManager.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/main/java/org/apache/shardingsphere/orchestration/core/facade/listener/OrchestrationListenerManager.java index 8b2a9929a13ea6b4f32b36967309beffd5f3288c..8fa2dd667ca358da8af98890281de584c3d91f6a 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/main/java/org/apache/shardingsphere/orchestration/core/facade/listener/OrchestrationListenerManager.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/main/java/org/apache/shardingsphere/orchestration/core/facade/listener/OrchestrationListenerManager.java @@ -36,10 +36,10 @@ public final class OrchestrationListenerManager { private final MetaDataListenerManager metaDataListenerManager; - public OrchestrationListenerManager(final String name, final RegistryRepository registryRepository, final ConfigurationRepository configurationRepository, final Collection schemaNames) { - configurationListenerManager = new ConfigurationListenerManager(name, configurationRepository, schemaNames); - registryListenerManager = new RegistryListenerManager(name, registryRepository); - metaDataListenerManager = new MetaDataListenerManager(name, configurationRepository, schemaNames); + public OrchestrationListenerManager(final RegistryRepository registryRepository, final ConfigurationRepository configurationRepository, final Collection schemaNames) { + configurationListenerManager = new ConfigurationListenerManager(configurationRepository, schemaNames); + registryListenerManager = new RegistryListenerManager(registryRepository); + metaDataListenerManager = new MetaDataListenerManager(configurationRepository, schemaNames); } /** diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/test/java/org/apache/shardingsphere/orchestration/core/facade/listener/OrchestrationListenerManagerTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/test/java/org/apache/shardingsphere/orchestration/core/facade/listener/OrchestrationListenerManagerTest.java index 35cccc8fbb264ce9744105ec65e44322932b63e6..d03609db64837ac7d566edfd9552738b19dd757b 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/test/java/org/apache/shardingsphere/orchestration/core/facade/listener/OrchestrationListenerManagerTest.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/test/java/org/apache/shardingsphere/orchestration/core/facade/listener/OrchestrationListenerManagerTest.java @@ -52,7 +52,7 @@ public final class OrchestrationListenerManagerTest { @Test public void assertInit() { - OrchestrationListenerManager actual = new OrchestrationListenerManager("test_name", registryRepository, configurationRepository, Collections.emptyList()); + OrchestrationListenerManager actual = new OrchestrationListenerManager(registryRepository, configurationRepository, Collections.emptyList()); FieldUtil.setField(actual, "configurationListenerManager", configurationListenerManager); FieldUtil.setField(actual, "registryListenerManager", registryListenerManager); FieldUtil.setField(actual, "metaDataListenerManager", metaDataListenerManager); diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenter.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenter.java index ea65a6de7718f6aa5f94dfc469ee2e2c5497d8cd..47e5709373bf0a14c76eb70cacde3d854c3aa082 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenter.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenter.java @@ -36,8 +36,8 @@ public final class MetaDataCenter { private final OrchestrationRepository repository; - public MetaDataCenter(final String name, final OrchestrationRepository orchestrationRepository) { - node = new MetaDataCenterNode(name); + public MetaDataCenter(final OrchestrationRepository orchestrationRepository) { + node = new MetaDataCenterNode(); repository = orchestrationRepository; MetaDataCallback.getInstance().register(this::persistMetaDataCenterNode); } diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterNode.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterNode.java index b7df7137a8bb26c751c5e0d079dc4cecea241c57..8c0f732808b25cee77e9c5315115a5712ca1339a 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterNode.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterNode.java @@ -31,8 +31,6 @@ public final class MetaDataCenterNode { private static final String ROOT = "metadata"; - private final String name; - /** * Get meta data node full path. * @@ -40,7 +38,7 @@ public final class MetaDataCenterNode { * @return meta data node full path */ public String getMetaDataCenterNodeFullPath(final String schemaName) { - return Joiner.on("/").join("", name, ROOT, schemaName); + return Joiner.on("/").join("", ROOT, schemaName); } /** diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataChangedListener.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataChangedListener.java index 1e4a4a9a2234fd0e62a309dcb789b45d900acd3c..e8812822580de4477abe963198669950abff400e 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataChangedListener.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataChangedListener.java @@ -37,8 +37,8 @@ public final class MetaDataChangedListener extends PostOrchestrationRepositoryEv private final Collection schemaNames; - public MetaDataChangedListener(final String name, final OrchestrationRepository orchestrationRepository, final Collection schemaNames) { - super(orchestrationRepository, new MetaDataCenterNode(name).getAllSchemaMetadataPaths(schemaNames)); + public MetaDataChangedListener(final OrchestrationRepository orchestrationRepository, final Collection schemaNames) { + super(orchestrationRepository, new MetaDataCenterNode().getAllSchemaMetadataPaths(schemaNames)); this.schemaNames = schemaNames; } diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataListenerManager.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataListenerManager.java index e1e905bdbc1e2f1d11104acc359a58ac495b20b8..b32fc051078c03fdcfa4159f65b3c9182325deba 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataListenerManager.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataListenerManager.java @@ -29,8 +29,8 @@ public final class MetaDataListenerManager { private final MetaDataChangedListener metaDataChangedListener; - public MetaDataListenerManager(final String name, final OrchestrationRepository orchestrationRepository, final Collection schemaNames) { - metaDataChangedListener = new MetaDataChangedListener(name, orchestrationRepository, schemaNames); + public MetaDataListenerManager(final OrchestrationRepository orchestrationRepository, final Collection schemaNames) { + metaDataChangedListener = new MetaDataChangedListener(orchestrationRepository, schemaNames); } /** diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterNodeTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterNodeTest.java index 554e88966e479e71f79626b5bb9d53b900be8f50..dfb714e881835b5fbbe3794d2435bfebe5a4dbe3 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterNodeTest.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterNodeTest.java @@ -24,11 +24,11 @@ import static org.junit.Assert.assertThat; public final class MetaDataCenterNodeTest { - private final MetaDataCenterNode metaDataCenterNode = new MetaDataCenterNode("test"); + private final MetaDataCenterNode metaDataCenterNode = new MetaDataCenterNode(); @Test public void assertGetMetaDataCenterNodeFullPath() { assertThat(metaDataCenterNode.getMetaDataCenterNodeFullPath("schema"), - is("/test/metadata/schema")); + is("/metadata/schema")); } } diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterTest.java index 420251522d0b26082c30d831fed85aa59fe9cb71..4c91cf5f22dc64f5bd37c481e1605e165d376920 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterTest.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterTest.java @@ -50,25 +50,25 @@ public final class MetaDataCenterTest { @Before public void setUp() { - metaDataCenter = new MetaDataCenter("test", repository); + metaDataCenter = new MetaDataCenter(repository); } @Test public void assertPersistMetaDataCenterNode() { RuleSchemaMetaData ruleSchemaMetaData = new RuleSchemaMetaDataYamlSwapper().swapToObject(YamlEngine.unmarshal(MetaDataJson.META_DATA, YamlRuleSchemaMetaData.class)); metaDataCenter.persistMetaDataCenterNode("schema", ruleSchemaMetaData); - verify(repository).persist(eq("/test/metadata/schema"), anyString()); + verify(repository).persist(eq("/metadata/schema"), anyString()); } @Test public void assertLoadRuleSchemaMetaData() { - when(repository.get("/test/metadata/schema")).thenReturn(MetaDataJson.META_DATA); + when(repository.get("/metadata/schema")).thenReturn(MetaDataJson.META_DATA); Optional optionalRuleSchemaMetaData = metaDataCenter.loadRuleSchemaMetaData("schema"); assertTrue(optionalRuleSchemaMetaData.isPresent()); Optional empty = metaDataCenter.loadRuleSchemaMetaData("test"); assertThat(empty, is(Optional.empty())); RuleSchemaMetaData ruleSchemaMetaData = optionalRuleSchemaMetaData.get(); - verify(repository).get(eq("/test/metadata/schema")); + verify(repository).get(eq("/metadata/schema")); assertNotNull(ruleSchemaMetaData); assertNotNull(ruleSchemaMetaData.getConfiguredSchemaMetaData()); assertNotNull(ruleSchemaMetaData.getUnconfiguredSchemaMetaDataMap()); diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataChangedListenerTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataChangedListenerTest.java index 94eb44a3bac3f15134faa5c25b88fa42ebfff38e..fe8f45384e0b02617aef59072b55828c79a8d9ca 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataChangedListenerTest.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataChangedListenerTest.java @@ -41,12 +41,12 @@ public final class MetaDataChangedListenerTest { @Before public void setUp() { - metaDataChangedListener = new MetaDataChangedListener("test", orchestrationRepository, Collections.singleton("schema")); + metaDataChangedListener = new MetaDataChangedListener(orchestrationRepository, Collections.singleton("schema")); } @Test public void createOrchestrationEvent() { - DataChangedEvent event = new DataChangedEvent("/test/metadata/schema", MetaDataJson.META_DATA, ChangedType.UPDATED); + DataChangedEvent event = new DataChangedEvent("/metadata/schema", MetaDataJson.META_DATA, ChangedType.UPDATED); MetaDataChangedEvent metaDataChangedEvent = (MetaDataChangedEvent) metaDataChangedListener.createOrchestrationEvent(event); assertNotNull(metaDataChangedEvent); assertThat(metaDataChangedEvent.getSchemaNames(), is(Collections.singleton("schema"))); diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataListenerManagerTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataListenerManagerTest.java index f74870bbffe9f544d4fbd57d7962b0e7599acc40..23aa4711f40ea71c64c39dfeb3ef789e4f9dec50 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataListenerManagerTest.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataListenerManagerTest.java @@ -40,7 +40,7 @@ public final class MetaDataListenerManagerTest { @Test public void assertInitListeners() { - MetaDataListenerManager actual = new MetaDataListenerManager("test", orchestrationRepository, Collections.singleton("sharding_db")); + MetaDataListenerManager actual = new MetaDataListenerManager(orchestrationRepository, Collections.singleton("sharding_db")); FieldUtil.setField(actual, "metaDataChangedListener", metaDataChangedListener); actual.initListeners(); verify(metaDataChangedListener).watch(ChangedType.UPDATED); diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenter.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenter.java index b875eccab2f5dba2f3dd90c5af89eb0fae46a0ff..ba4bdf4bfacaff32a9ec24b4266f384d696416a5 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenter.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenter.java @@ -35,8 +35,8 @@ public final class RegistryCenter { private final OrchestrationInstance instance; - public RegistryCenter(final String name, final RegistryRepository registryRepository) { - node = new RegistryCenterNode(name); + public RegistryCenter(final RegistryRepository registryRepository) { + node = new RegistryCenterNode(); repository = registryRepository; instance = OrchestrationInstance.getInstance(); } diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterNode.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterNode.java index 7fc2f75385efdcfcdba01f063fffa650d424746d..6c2b6c607c6f5311c0177aa038da3a0fafe4c386 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterNode.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterNode.java @@ -33,8 +33,6 @@ public final class RegistryCenterNode { private static final String DATA_SOURCES_NODE_PATH = "datasources"; - private final String name; - /** * Get instance node full path. * @@ -42,7 +40,7 @@ public final class RegistryCenterNode { * @return instance node full path */ public String getInstancesNodeFullPath(final String instanceId) { - return Joiner.on("/").join("", name, ROOT, INSTANCES_NODE_PATH, instanceId); + return Joiner.on("/").join("", ROOT, INSTANCES_NODE_PATH, instanceId); } /** @@ -51,7 +49,7 @@ public final class RegistryCenterNode { * @return data source node full root path */ public String getDataSourcesNodeFullRootPath() { - return Joiner.on("/").join("", name, ROOT, DATA_SOURCES_NODE_PATH); + return Joiner.on("/").join("", ROOT, DATA_SOURCES_NODE_PATH); } /** @@ -61,7 +59,7 @@ public final class RegistryCenterNode { * @return data source node full path */ public String getDataSourcesNodeFullPath(final String schemaDataSourceName) { - return Joiner.on("/").join("", name, ROOT, DATA_SOURCES_NODE_PATH, schemaDataSourceName); + return Joiner.on("/").join("", ROOT, DATA_SOURCES_NODE_PATH, schemaDataSourceName); } /** diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/DataSourceStateChangedListener.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/DataSourceStateChangedListener.java index 7338b999faca519f8624179f1274b73091e7fd7a..b19f8f9ca6c200c2b89903022cc36b4c022d971a 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/DataSourceStateChangedListener.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/DataSourceStateChangedListener.java @@ -35,9 +35,9 @@ public final class DataSourceStateChangedListener extends PostOrchestrationRepos private final RegistryCenterNode registryCenterNode; - public DataSourceStateChangedListener(final String name, final RegistryRepository registryRepository) { - super(registryRepository, Collections.singleton(new RegistryCenterNode(name).getDataSourcesNodeFullRootPath())); - registryCenterNode = new RegistryCenterNode(name); + public DataSourceStateChangedListener(final RegistryRepository registryRepository) { + super(registryRepository, Collections.singleton(new RegistryCenterNode().getDataSourcesNodeFullRootPath())); + registryCenterNode = new RegistryCenterNode(); } @Override diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateChangedListener.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateChangedListener.java index 22635673214066f45a8b8f6f3a0511908c5143c8..21a93834b810284e8cf960d33c0e71ac41791b1b 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateChangedListener.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateChangedListener.java @@ -35,8 +35,8 @@ import java.util.Collections; */ public final class InstanceStateChangedListener extends PostOrchestrationRepositoryEventListener { - public InstanceStateChangedListener(final String name, final RegistryRepository registryRepository) { - super(registryRepository, Collections.singleton(new RegistryCenterNode(name).getInstancesNodeFullPath(OrchestrationInstance.getInstance().getInstanceId()))); + public InstanceStateChangedListener(final RegistryRepository registryRepository) { + super(registryRepository, Collections.singleton(new RegistryCenterNode().getInstancesNodeFullPath(OrchestrationInstance.getInstance().getInstanceId()))); } @Override diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/RegistryListenerManager.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/RegistryListenerManager.java index f2d9dd616a76a0599221d28a2e18d002d8a466d1..aa6497f362dd68d2c3edd7edd7f24e92c7f19c5d 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/RegistryListenerManager.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/RegistryListenerManager.java @@ -29,9 +29,9 @@ public final class RegistryListenerManager { private final DataSourceStateChangedListener dataSourceStateChangedListener; - public RegistryListenerManager(final String name, final RegistryRepository registryRepository) { - instanceStateChangedListener = new InstanceStateChangedListener(name, registryRepository); - dataSourceStateChangedListener = new DataSourceStateChangedListener(name, registryRepository); + public RegistryListenerManager(final RegistryRepository registryRepository) { + instanceStateChangedListener = new InstanceStateChangedListener(registryRepository); + dataSourceStateChangedListener = new DataSourceStateChangedListener(registryRepository); } /** diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterNodeTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterNodeTest.java index 5c978604244a8127dc7b4219d6d6aa87dd472f21..dbb7603fa1b5173fadaecb75213b1ba5a38953d9 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterNodeTest.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterNodeTest.java @@ -24,25 +24,25 @@ import static org.junit.Assert.assertThat; public final class RegistryCenterNodeTest { - private final RegistryCenterNode registryCenterNode = new RegistryCenterNode("test"); + private final RegistryCenterNode registryCenterNode = new RegistryCenterNode(); @Test public void assertGetInstancesNodeFullPath() { - assertThat(registryCenterNode.getInstancesNodeFullPath("testId"), is("/test/registry/instances/testId")); + assertThat(registryCenterNode.getInstancesNodeFullPath("testId"), is("/registry/instances/testId")); } @Test public void assertGetDataSourcesNodeFullRootPath() { - assertThat(registryCenterNode.getDataSourcesNodeFullRootPath(), is("/test/registry/datasources")); + assertThat(registryCenterNode.getDataSourcesNodeFullRootPath(), is("/registry/datasources")); } @Test public void assertGetDataSourcesNodeFullPath() { - assertThat(registryCenterNode.getDataSourcesNodeFullPath("sharding_db"), is("/test/registry/datasources/sharding_db")); + assertThat(registryCenterNode.getDataSourcesNodeFullPath("sharding_db"), is("/registry/datasources/sharding_db")); } @Test public void assertGetOrchestrationShardingSchema() { - assertThat(registryCenterNode.getOrchestrationShardingSchema("/test/registry/datasources/master_slave_db.slave_ds_0").getSchemaName(), is("master_slave_db")); + assertThat(registryCenterNode.getOrchestrationShardingSchema("/registry/datasources/master_slave_db.slave_ds_0").getSchemaName(), is("master_slave_db")); } } diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterTest.java index e8c5d3991170c11b08057950e05e2af98fedf814..0f4ea766cc70f75c13dcaa30e89a53a1c8b58f9a 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterTest.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterTest.java @@ -42,7 +42,7 @@ public final class RegistryCenterTest { @Before public void setUp() throws ReflectiveOperationException { - registryCenter = new RegistryCenter("test", registryRepository); + registryCenter = new RegistryCenter(registryRepository); Field field = registryCenter.getClass().getDeclaredField("repository"); field.setAccessible(true); field.set(registryCenter, registryRepository); @@ -57,7 +57,7 @@ public final class RegistryCenterTest { @Test public void assertPersistDataSourcesNode() { registryCenter.persistDataSourcesNode(); - verify(registryRepository).persist("/test/registry/datasources", ""); + verify(registryRepository).persist("/registry/datasources", ""); } @Test diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/DataSourceStateChangedListenerTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/DataSourceStateChangedListenerTest.java index 79011ff53874b68fd4facaeaf2b2e6380b2da8a0..eda95cb55cec915867bec06ec5a3e07aa47b02b3 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/DataSourceStateChangedListenerTest.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/DataSourceStateChangedListenerTest.java @@ -40,13 +40,13 @@ public final class DataSourceStateChangedListenerTest { @Before public void setUp() { - dataSourceStateChangedListener = new DataSourceStateChangedListener("test", registryRepository); + dataSourceStateChangedListener = new DataSourceStateChangedListener(registryRepository); } @Test public void assertCreateOrchestrationEvent() { OrchestrationSchema expected = new OrchestrationSchema("master_slave_db", "slave_ds_0"); - DataChangedEvent dataChangedEvent = new DataChangedEvent("/test/registry/datasources/master_slave_db.slave_ds_0", "disabled", ChangedType.UPDATED); + DataChangedEvent dataChangedEvent = new DataChangedEvent("/registry/datasources/master_slave_db.slave_ds_0", "disabled", ChangedType.UPDATED); assertThat(dataSourceStateChangedListener.createOrchestrationEvent(dataChangedEvent).getOrchestrationSchema().getSchemaName(), is(expected.getSchemaName())); } } diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateChangedListenerTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateChangedListenerTest.java index 4335c4c5ef8da9a568469efaade14aa00077daed..e78ccb1b0b535c1041325933512097ff2c1a1666 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateChangedListenerTest.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateChangedListenerTest.java @@ -40,17 +40,17 @@ public final class InstanceStateChangedListenerTest { @Before public void setUp() { - instanceStateChangedListener = new InstanceStateChangedListener("test", registryRepository); + instanceStateChangedListener = new InstanceStateChangedListener(registryRepository); } @Test public void assertCreateOrchestrationEventWhenEnabled() { - assertFalse(instanceStateChangedListener.createOrchestrationEvent(new DataChangedEvent("test/test_ds", "", ChangedType.UPDATED)).isCircuitBreak()); + assertFalse(instanceStateChangedListener.createOrchestrationEvent(new DataChangedEvent("/test_ds", "", ChangedType.UPDATED)).isCircuitBreak()); } @Test public void assertCreateOrchestrationEventWhenDisabled() { - assertTrue(instanceStateChangedListener.createOrchestrationEvent(new DataChangedEvent("test/test_ds", + assertTrue(instanceStateChangedListener.createOrchestrationEvent(new DataChangedEvent("/test_ds", "state: " + RegistryCenterNodeStatus.DISABLED.name(), ChangedType.UPDATED)).isCircuitBreak()); } } diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/RegistryListenerManagerTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/RegistryListenerManagerTest.java index 69e0dcf702906ffd65552eb83d4a88599235c506..18f33c0648bf47ece0e6e4974b065248a80fcd55 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/RegistryListenerManagerTest.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/RegistryListenerManagerTest.java @@ -41,7 +41,7 @@ public final class RegistryListenerManagerTest { @Test public void assertInitListeners() { - RegistryListenerManager actual = new RegistryListenerManager("test", registryRepository); + RegistryListenerManager actual = new RegistryListenerManager(registryRepository); FieldUtil.setField(actual, "instanceStateChangedListener", instanceStateChangedListener); FieldUtil.setField(actual, "dataSourceStateChangedListener", dataSourceStateChangedListener); actual.initListeners(); diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-etcd/src/main/java/org/apache/shardingsphere/orchestration/repository/etcd/EtcdRepository.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-etcd/src/main/java/org/apache/shardingsphere/orchestration/repository/etcd/EtcdRepository.java index 9e9852f13b64275d1df2a1dd9c28d6c106a7aa31..1d1a707ecfc8cda20f55925c34f4a853ab054df2 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-etcd/src/main/java/org/apache/shardingsphere/orchestration/repository/etcd/EtcdRepository.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-etcd/src/main/java/org/apache/shardingsphere/orchestration/repository/etcd/EtcdRepository.java @@ -59,7 +59,7 @@ public final class EtcdRepository implements ConfigurationRepository, RegistryRe @Override public void init(final String name, final OrchestrationCenterConfiguration config) { etcdProperties = new EtcdProperties(props); - client = Client.builder().endpoints(Util.toURIs(Splitter.on(",").trimResults().splitToList(config.getServerLists()))).build(); + client = Client.builder().endpoints(Util.toURIs(Splitter.on(",").trimResults().splitToList(config.getServerLists()))).namespace(ByteSequence.from(name, Charsets.UTF_8)).build(); } @SneakyThrows({InterruptedException.class, ExecutionException.class}) diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-zookeeper-curator/src/main/java/org/apache/shardingsphere/orchestration/repository/zookeeper/CuratorZookeeperRepository.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-zookeeper-curator/src/main/java/org/apache/shardingsphere/orchestration/repository/zookeeper/CuratorZookeeperRepository.java index 1720a4c2e03ee3296fb400b91669b97aded08e92..8bebc067de1bb3ba5578e526e3ffdbe843df4064 100644 --- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-zookeeper-curator/src/main/java/org/apache/shardingsphere/orchestration/repository/zookeeper/CuratorZookeeperRepository.java +++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-zookeeper-curator/src/main/java/org/apache/shardingsphere/orchestration/repository/zookeeper/CuratorZookeeperRepository.java @@ -69,11 +69,11 @@ public final class CuratorZookeeperRepository implements ConfigurationRepository @Override public void init(final String name, final OrchestrationCenterConfiguration config) { ZookeeperProperties zookeeperProperties = new ZookeeperProperties(props); - client = buildCuratorClient(config, zookeeperProperties); + client = buildCuratorClient(name, config, zookeeperProperties); initCuratorClient(zookeeperProperties); } - private CuratorFramework buildCuratorClient(final OrchestrationCenterConfiguration config, final ZookeeperProperties zookeeperProperties) { + private CuratorFramework buildCuratorClient(final String namespace, final OrchestrationCenterConfiguration config, final ZookeeperProperties zookeeperProperties) { int retryIntervalMilliseconds = zookeeperProperties.getValue(ZookeeperPropertyKey.RETRY_INTERVAL_MILLISECONDS); int maxRetries = zookeeperProperties.getValue(ZookeeperPropertyKey.MAX_RETRIES); int timeToLiveSeconds = zookeeperProperties.getValue(ZookeeperPropertyKey.TIME_TO_LIVE_SECONDS); @@ -81,7 +81,8 @@ public final class CuratorZookeeperRepository implements ConfigurationRepository String digest = zookeeperProperties.getValue(ZookeeperPropertyKey.DIGEST); CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder() .connectString(config.getServerLists()) - .retryPolicy(new ExponentialBackoffRetry(retryIntervalMilliseconds, maxRetries, retryIntervalMilliseconds * maxRetries)); + .retryPolicy(new ExponentialBackoffRetry(retryIntervalMilliseconds, maxRetries, retryIntervalMilliseconds * maxRetries)) + .namespace(namespace); if (0 != timeToLiveSeconds) { builder.sessionTimeoutMs(timeToLiveSeconds * 1000); } diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootMasterSlaveTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootMasterSlaveTest.java index 57c5fe5bf083c1dcecf60cd675e3a8a96b4d5a1d..1b0d5a8eff284864342812fdb6fc167b5ad64f9b 100644 --- a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootMasterSlaveTest.java +++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootMasterSlaveTest.java @@ -65,7 +65,7 @@ public class OrchestrationSpringBootMasterSlaveTest { ShardingSphereDataSource shardingSphereDataSource = (ShardingSphereDataSource) field.get(dataSource); for (DataSource each : shardingSphereDataSource.getDataSourceMap().values()) { assertThat(((BasicDataSource) each).getMaxTotal(), is(16)); - assertThat(((BasicDataSource) each).getUsername(), is("root")); + assertThat(((BasicDataSource) each).getUsername(), is("sa")); } Collection rules = shardingSphereDataSource.getSchemaContexts().getDefaultSchemaContext().getSchema().getRules(); assertThat(rules.size(), is(1)); diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootRegistryEncryptTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootRegistryEncryptTest.java index ab6c938f37961783fbeba8e5d7d975118e46f343..4243e30ae53c9fabb1b74bda4d2f78f42474bbc6 100644 --- a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootRegistryEncryptTest.java +++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootRegistryEncryptTest.java @@ -64,10 +64,10 @@ public class OrchestrationSpringBootRegistryEncryptTest { String dataSource = readYAML(DATA_SOURCE_FILE); String encryptRule = readYAML(ENCRYPT_RULE_FILE); TestOrchestrationRepository repository = new TestOrchestrationRepository(); - repository.persist("/orchestration-spring-boot-test/config/schema/logic_db/datasource", dataSource); - repository.persist("/orchestration-spring-boot-test/config/schema/logic_db/rule", encryptRule); - repository.persist("/orchestration-spring-boot-test/config/props", "sql.show: 'true'\n"); - repository.persist("/orchestration-spring-boot-test/registry/datasources", ""); + repository.persist("/config/schema/logic_db/datasource", dataSource); + repository.persist("/config/schema/logic_db/rule", encryptRule); + repository.persist("/config/props", "sql.show: 'true'\n"); + repository.persist("/registry/datasources", ""); } @Test diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootRegistryMasterSlaveTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootRegistryMasterSlaveTest.java index 9020ba7ddef2c2bf62224d18e02022ae4ba34a84..3366ea7770275e26bbea36bd9ab380eb40938796 100644 --- a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootRegistryMasterSlaveTest.java +++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootRegistryMasterSlaveTest.java @@ -43,7 +43,7 @@ import static org.junit.Assert.assertTrue; @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = OrchestrationSpringBootRegistryMasterSlaveTest.class) @SpringBootApplication -@ActiveProfiles("registry") +@ActiveProfiles("registry-masterslave") public class OrchestrationSpringBootRegistryMasterSlaveTest { @Resource @@ -53,29 +53,29 @@ public class OrchestrationSpringBootRegistryMasterSlaveTest { public static void init() { EmbedTestingServer.start(); TestOrchestrationRepository repository = new TestOrchestrationRepository(); - repository.persist("/orchestration-spring-boot-test/config/schema/logic_db/datasource", "" + repository.persist("/config/schema/logic_db/datasource", "" + "ds_master: !!" + YamlDataSourceConfiguration.class.getName() + "\n" + " dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource\n" + " props:\n" + " url: jdbc:h2:mem:ds_master;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL\n" + " maxTotal: 16\n" - + " password: ''\n" - + " username: root\n" + + " password: \n" + + " username: sa\n" + "ds_slave_0: !!" + YamlDataSourceConfiguration.class.getName() + "\n" + " dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource\n" + " props:\n" + " url: jdbc:h2:mem:demo_ds_slave_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL\n" + " maxTotal: 16\n" - + " password: ''\n" - + " username: root\n" + + " password: \n" + + " username: sa\n" + "ds_slave_1: !!" + YamlDataSourceConfiguration.class.getName() + "\n" + " dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource\n" + " props:\n" + " url: jdbc:h2:mem:demo_ds_slave_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL\n" + " maxTotal: 16\n" - + " password: ''\n" - + " username: root\n"); - repository.persist("/orchestration-spring-boot-test/config/schema/logic_db/rule", "" + + " password: \n" + + " username: sa\n"); + repository.persist("/config/schema/logic_db/rule", "" + "rules:\n" + "- !MASTER_SLAVE\n" + " loadBalancers:\n" @@ -89,8 +89,8 @@ public class OrchestrationSpringBootRegistryMasterSlaveTest { + " slaveDataSourceNames: \n" + " - ds_slave_0\n" + " - ds_slave_1\n"); - repository.persist("/orchestration-spring-boot-test/config/props", "{}\n"); - repository.persist("/orchestration-spring-boot-test/registry/datasources", ""); + repository.persist("/config/props", "{}\n"); + repository.persist("/registry/datasources", ""); } @Test @@ -102,7 +102,7 @@ public class OrchestrationSpringBootRegistryMasterSlaveTest { ShardingSphereDataSource shardingSphereDataSource = (ShardingSphereDataSource) field.get(dataSource); for (DataSource each : shardingSphereDataSource.getDataSourceMap().values()) { assertThat(((BasicDataSource) each).getMaxTotal(), is(16)); - assertThat(((BasicDataSource) each).getUsername(), is("root")); + assertThat(((BasicDataSource) each).getUsername(), is("sa")); } } } diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootRegistryShardingTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootRegistryShardingTest.java index d78707108558213fcb7b75c481479915ba55018e..7afcc11030f061ff91d320efcbd083268882ad11 100644 --- a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootRegistryShardingTest.java +++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootRegistryShardingTest.java @@ -68,12 +68,12 @@ public class OrchestrationSpringBootRegistryShardingTest { String shardingDatabases = readYAML(SHARDING_DATABASES_FILE); String shardingRule = readYAML(SHARDING_RULE_FILE); TestOrchestrationRepository repository = new TestOrchestrationRepository(); - repository.persist("/orchestration-spring-boot-test/config/schema/logic_db/datasource", shardingDatabases); - repository.persist("/orchestration-spring-boot-test/config/schema/logic_db/rule", shardingRule); - repository.persist("/orchestration-spring-boot-test/config/props", "" + repository.persist("/config/schema/logic_db/datasource", shardingDatabases); + repository.persist("/config/schema/logic_db/rule", shardingRule); + repository.persist("/config/props", "" + "executor.size: '100'\n" + "sql.show: 'true'\n"); - repository.persist("/orchestration-spring-boot-test/registry/datasources", ""); + repository.persist("/registry/datasources", ""); } @Test @@ -86,7 +86,6 @@ public class OrchestrationSpringBootRegistryShardingTest { } assertTrue(schemaContexts.getProps().getValue(ConfigurationPropertyKey.SQL_SHOW)); assertTrue(schemaContexts.getProps().getValue(ConfigurationPropertyKey.SQL_SHOW)); - assertThat(schemaContexts.getProps().getValue(ConfigurationPropertyKey.EXECUTOR_SIZE), is(100)); } @Test diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-encrypt.properties b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-encrypt.properties index 537cb833748b2635fce24c9d609b1fff2884e360..a07d414b75ea9830d8c7591c617da716296b353c 100644 --- a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-encrypt.properties +++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-encrypt.properties @@ -32,7 +32,7 @@ spring.shardingsphere.rules.encrypt.tables.t_order.columns.order_id.encryptor-na spring.shardingsphere.props.sql.show=true -spring.shardingsphere.orchestration.name=orchestration-spring-boot-master-slave-test +spring.shardingsphere.orchestration.name=orchestration-spring-boot-encrypt-test spring.shardingsphere.orchestration.overwrite=true spring.shardingsphere.orchestration.registry-center.type=TestRegistry diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-masterslave.properties b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-masterslave.properties index 95cee52c504eebebbbd6743811e7b0efd57f8152..aaecf9d0107a8dd4380e27700d4205e9ead82f95 100644 --- a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-masterslave.properties +++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-masterslave.properties @@ -21,21 +21,21 @@ spring.shardingsphere.datasource.names=${spring.example.datasource.name},ds_slav spring.shardingsphere.datasource.ds_master.type=org.apache.commons.dbcp2.BasicDataSource spring.shardingsphere.datasource.ds_master.driver-class-name=org.h2.Driver spring.shardingsphere.datasource.ds_master.url=jdbc:h2:mem:ds_master;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL -spring.shardingsphere.datasource.ds_master.username=root +spring.shardingsphere.datasource.ds_master.username=sa spring.shardingsphere.datasource.ds_master.password= spring.shardingsphere.datasource.ds_master.max-total=16 spring.shardingsphere.datasource.ds_slave_0.type=org.apache.commons.dbcp2.BasicDataSource spring.shardingsphere.datasource.ds_slave_0.driver-class-name=org.h2.Driver spring.shardingsphere.datasource.ds_slave_0.url=jdbc:h2:mem:demo_ds_slave_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL -spring.shardingsphere.datasource.ds_slave_0.username=root +spring.shardingsphere.datasource.ds_slave_0.username=sa spring.shardingsphere.datasource.ds_slave_0.password= spring.shardingsphere.datasource.ds_slave_0.max-total=16 spring.shardingsphere.datasource.ds_slave_1.type=org.apache.commons.dbcp2.BasicDataSource spring.shardingsphere.datasource.ds_slave_1.driver-class-name=org.h2.Driver spring.shardingsphere.datasource.ds_slave_1.url=jdbc:h2:mem:demo_ds_slave_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL -spring.shardingsphere.datasource.ds_slave_1.username=root +spring.shardingsphere.datasource.ds_slave_1.username=sa spring.shardingsphere.datasource.ds_slave_1.password= spring.shardingsphere.datasource.ds_slave_1.max-total=16 diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-registry-masterslave.properties b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-registry-masterslave.properties new file mode 100644 index 0000000000000000000000000000000000000000..d140ba02f8a89a2e6b5a8a11d059b9852f66277d --- /dev/null +++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-registry-masterslave.properties @@ -0,0 +1,22 @@ +# +# 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. +# + +spring.shardingsphere.orchestration.name=orchestration-spring-boot-registry-master-slave-test +spring.shardingsphere.orchestration.overwrite=true + +spring.shardingsphere.orchestration.registry-center.type=TestRegistry +spring.shardingsphere.orchestration.registry-center.server-lists=localhost:3181