未验证 提交 64410d38 编写于 作者: kimmking's avatar kimmking 提交者: GitHub

move orchestration module to a level 1 sub-project named governance (#7139)

* adjust structure

* rename files

* adjust references

* refactor shardingsphere-jdbc-spring

* refactor shardingsphere-jdbc-spring

* refactor shardingsphere-proxy

* refactor scaling

* refactor dist

* fix scaling test
上级 37ae8c32
......@@ -22,7 +22,7 @@
## Overview
Apache ShardingSphere is an open-source ecosystem consisted of a set of distributed database middleware solutions, including 3 independent products, JDBC, Proxy & Sidecar (Planning).
They all provide functions of data sharding, distributed transaction and database orchestration, applicable in a variety of situations such as Java isomorphism, heterogeneous language and cloud native.
They all provide functions of data sharding, distributed transaction and database governance, applicable in a variety of situations such as Java isomorphism, heterogeneous language and cloud native.
Aiming at reasonably making full use of the computation and storage capacity of database in distributed system, ShardingSphere defines itself as a middleware, rather than a totally new type of database.
As the cornerstone of many enterprises, relational database still takes a huge market share. Therefore, at current stage, we prefer to focus on its increment instead of a total overturn.
......@@ -111,7 +111,7 @@ Architects can adjust the system architecture to the most applicable one to curr
* XA transaction
* BASE transaction
### Database Orchestration
### Database Governance
* Distributed Governance
* Data migration & Scale out
......
......@@ -23,7 +23,7 @@ import org.apache.shardingsphere.example.core.jdbc.service.OrderServiceImpl;
import org.apache.shardingsphere.example.type.RegistryCenterType;
import org.apache.shardingsphere.example.type.ShardingType;
import org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
import org.apache.shardingsphere.driver.orchestration.api.yaml.YamlOrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.driver.governance.api.yaml.YamlOrchestrationShardingSphereDataSourceFactory;
import javax.sql.DataSource;
import java.io.File;
......
......@@ -17,7 +17,7 @@
package org.apache.shardingsphere.example.orchestration.raw.jdbc.config.cloud;
import org.apache.shardingsphere.driver.orchestration.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.driver.governance.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationConfiguration;
......
......@@ -17,7 +17,7 @@
package org.apache.shardingsphere.example.orchestration.raw.jdbc.config.cloud;
import org.apache.shardingsphere.driver.orchestration.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.driver.governance.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationConfiguration;
......
......@@ -17,7 +17,7 @@
package org.apache.shardingsphere.example.orchestration.raw.jdbc.config.cloud;
import org.apache.shardingsphere.driver.orchestration.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.driver.governance.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationConfiguration;
......
......@@ -17,7 +17,7 @@
package org.apache.shardingsphere.example.orchestration.raw.jdbc.config.cloud;
import org.apache.shardingsphere.driver.orchestration.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.driver.governance.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationConfiguration;
......
......@@ -18,7 +18,7 @@
package org.apache.shardingsphere.example.orchestration.raw.jdbc.config.local;
import com.google.common.collect.ImmutableMap;
import org.apache.shardingsphere.driver.orchestration.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.driver.governance.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
......
......@@ -17,7 +17,7 @@
package org.apache.shardingsphere.example.orchestration.raw.jdbc.config.local;
import org.apache.shardingsphere.driver.orchestration.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.driver.governance.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.example.core.api.DataSourceUtil;
import org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration;
......
......@@ -17,7 +17,7 @@
package org.apache.shardingsphere.example.orchestration.raw.jdbc.config.local;
import org.apache.shardingsphere.driver.orchestration.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.driver.governance.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.example.core.api.DataSourceUtil;
import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationConfiguration;
......
......@@ -17,7 +17,7 @@
package org.apache.shardingsphere.example.orchestration.raw.jdbc.config.local;
import org.apache.shardingsphere.driver.orchestration.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.driver.governance.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.example.core.api.DataSourceUtil;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
......
......@@ -17,7 +17,7 @@
package org.apache.shardingsphere.example.orchestration.raw.jdbc.config.local;
import org.apache.shardingsphere.driver.orchestration.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.driver.governance.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.example.core.api.DataSourceUtil;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
......
......@@ -17,7 +17,7 @@
package org.apache.shardingsphere.example.orchestration.raw.jdbc.config.local;
import org.apache.shardingsphere.driver.orchestration.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.driver.governance.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.example.core.api.DataSourceUtil;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
......
......@@ -17,7 +17,7 @@
package org.apache.shardingsphere.example.orchestration.raw.jdbc.config.local;
import org.apache.shardingsphere.driver.orchestration.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.driver.governance.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.example.core.api.DataSourceUtil;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
......
......@@ -42,7 +42,7 @@
<module>shardingsphere-features</module>
<module>shardingsphere-scaling</module>
<module>shardingsphere-transaction</module>
<module>shardingsphere-control-panel</module>
<module>shardingsphere-governance</module>
<module>shardingsphere-observability</module>
<module>shardingsphere-test</module>
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
<artifactId>shardingsphere-control-panel</artifactId>
<name>${project.artifactId}</name>
<packaging>pom</packaging>
<modules>
<module>shardingsphere-orchestration</module>
</modules>
</project>
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
org.apache.shardingsphere.orchestration.core.facade.fixture.TestRegistryRepository
org.apache.shardingsphere.orchestration.core.facade.fixture.TestAllRepository
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
org.apache.shardingsphere.orchestration.repository.etcd.EtcdRepository
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
org.apache.shardingsphere.orchestration.repository.nacos.NacosRepository
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
org.apache.shardingsphere.orchestration.repository.zookeeper.CuratorZookeeperRepository
......@@ -105,7 +105,7 @@
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-orchestration</artifactId>
<artifactId>shardingsphere-jdbc-governance</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
......@@ -125,42 +125,42 @@
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-core-common</artifactId>
<artifactId>shardingsphere-governance-core-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-core-config</artifactId>
<artifactId>shardingsphere-governance-core-config</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-core-registry</artifactId>
<artifactId>shardingsphere-governance-core-registry</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-core-facade</artifactId>
<artifactId>shardingsphere-governance-core-facade</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-repository-api</artifactId>
<artifactId>shardingsphere-governance-repository-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-repository-zookeeper-curator</artifactId>
<artifactId>shardingsphere-governance-repository-zookeeper-curator</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-repository-apollo</artifactId>
<artifactId>shardingsphere-governance-repository-apollo</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-repository-nacos</artifactId>
<artifactId>shardingsphere-governance-repository-nacos</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
......@@ -180,12 +180,12 @@
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-orchestration-spring-boot-starter</artifactId>
<artifactId>shardingsphere-jdbc-governance-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-orchestration-spring-namespace</artifactId>
<artifactId>shardingsphere-jdbc-governance-spring-namespace</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
......
......@@ -17,12 +17,12 @@
######################################################################################################
#
# If you want to configure orchestration, authorization and proxy properties, please refer to this file.
# If you want to configure governance, authorization and proxy properties, please refer to this file.
#
######################################################################################################
#
#orchestration:
# name: orchestration_ds
#governance:
# name: governance_ds
# registryCenter:
# type: ZooKeeper
# serverLists: localhost:2181
......
......@@ -105,7 +105,7 @@
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-orchestration</artifactId>
<artifactId>shardingsphere-jdbc-governance</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
......@@ -175,42 +175,42 @@
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-core-common</artifactId>
<artifactId>shardingsphere-governance-core-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-core-config</artifactId>
<artifactId>shardingsphere-governance-core-config</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-core-registry</artifactId>
<artifactId>shardingsphere-governance-core-registry</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-core-facade</artifactId>
<artifactId>shardingsphere-governance-core-facade</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-repository-api</artifactId>
<artifactId>shardingsphere-governance-repository-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-repository-zookeeper-curator</artifactId>
<artifactId>shardingsphere-governance-repository-zookeeper-curator</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-repository-apollo</artifactId>
<artifactId>shardingsphere-governance-repository-apollo</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-repository-nacos</artifactId>
<artifactId>shardingsphere-governance-repository-nacos</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
......@@ -230,12 +230,12 @@
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-orchestration-spring-boot-starter</artifactId>
<artifactId>shardingsphere-jdbc-governance-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-orchestration-spring-namespace</artifactId>
<artifactId>shardingsphere-jdbc-governance-spring-namespace</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
......
......@@ -20,15 +20,15 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-control-panel</artifactId>
<artifactId>shardingsphere</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
<artifactId>shardingsphere-orchestration</artifactId>
<artifactId>shardingsphere-governance</artifactId>
<name>${project.artifactId}</name>
<packaging>pom</packaging>
<modules>
<module>shardingsphere-orchestration-core</module>
<module>shardingsphere-orchestration-repository</module>
<module>shardingsphere-governance-core</module>
<module>shardingsphere-governance-repository</module>
</modules>
</project>
......@@ -20,19 +20,19 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration</artifactId>
<artifactId>shardingsphere-governance</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
<artifactId>shardingsphere-orchestration-core</artifactId>
<artifactId>shardingsphere-governance-core</artifactId>
<name>${project.artifactId}</name>
<packaging>pom</packaging>
<modules>
<module>shardingsphere-orchestration-core-common</module>
<module>shardingsphere-orchestration-core-config</module>
<module>shardingsphere-orchestration-core-registry</module>
<module>shardingsphere-orchestration-core-metadata</module>
<module>shardingsphere-orchestration-core-schema</module>
<module>shardingsphere-orchestration-core-facade</module>
<module>shardingsphere-governance-core-common</module>
<module>shardingsphere-governance-core-config</module>
<module>shardingsphere-governance-core-registry</module>
<module>shardingsphere-governance-core-metadata</module>
<module>shardingsphere-governance-core-schema</module>
<module>shardingsphere-governance-core-facade</module>
</modules>
</project>
......@@ -20,16 +20,16 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-core</artifactId>
<artifactId>shardingsphere-governance-core</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
<artifactId>shardingsphere-orchestration-core-common</artifactId>
<artifactId>shardingsphere-governance-core-common</artifactId>
<name>${project.artifactId}</name>
<dependencies>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-repository-api</artifactId>
<artifactId>shardingsphere-governance-repository-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
......
......@@ -15,10 +15,10 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.common.event;
package org.apache.shardingsphere.governance.core.common.event;
/**
* Orchestration event.
* Governance event.
*/
public interface OrchestrationEvent {
public interface GovernanceEvent {
}
......@@ -15,19 +15,19 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.common.event.auth;
package org.apache.shardingsphere.governance.core.common.event.auth;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.auth.Authentication;
import org.apache.shardingsphere.orchestration.core.common.event.OrchestrationEvent;
import org.apache.shardingsphere.governance.core.common.event.GovernanceEvent;
/**
* Authentication changed event.
*/
@RequiredArgsConstructor
@Getter
public final class AuthenticationChangedEvent implements OrchestrationEvent {
public final class AuthenticationChangedEvent implements GovernanceEvent {
private final Authentication authentication;
}
......@@ -15,12 +15,12 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.common.event.datasource;
package org.apache.shardingsphere.governance.core.common.event.datasource;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.config.DataSourceConfiguration;
import org.apache.shardingsphere.orchestration.core.common.event.OrchestrationEvent;
import org.apache.shardingsphere.governance.core.common.event.GovernanceEvent;
import java.util.Map;
......@@ -29,7 +29,7 @@ import java.util.Map;
*/
@RequiredArgsConstructor
@Getter
public final class DataSourceChangedEvent implements OrchestrationEvent {
public final class DataSourceChangedEvent implements GovernanceEvent {
private final String schemaName;
......
......@@ -15,11 +15,11 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.common.event.props;
package org.apache.shardingsphere.governance.core.common.event.props;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.orchestration.core.common.event.OrchestrationEvent;
import org.apache.shardingsphere.governance.core.common.event.GovernanceEvent;
import java.util.Properties;
......@@ -28,7 +28,7 @@ import java.util.Properties;
*/
@RequiredArgsConstructor
@Getter
public final class PropertiesChangedEvent implements OrchestrationEvent {
public final class PropertiesChangedEvent implements GovernanceEvent {
private final Properties props;
}
......@@ -15,19 +15,19 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.common.event.rule;
package org.apache.shardingsphere.governance.core.common.event.rule;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.orchestration.core.common.event.OrchestrationEvent;
import org.apache.shardingsphere.governance.core.common.event.GovernanceEvent;
/**
* Encrypt rule changed event.
*/
@RequiredArgsConstructor
@Getter
public final class EncryptRuleChangedEvent implements OrchestrationEvent {
public final class EncryptRuleChangedEvent implements GovernanceEvent {
private final String schemaName;
......
......@@ -15,19 +15,19 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.common.event.rule;
package org.apache.shardingsphere.governance.core.common.event.rule;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration;
import org.apache.shardingsphere.orchestration.core.common.event.OrchestrationEvent;
import org.apache.shardingsphere.governance.core.common.event.GovernanceEvent;
/**
* Master slave rule changed event.
*/
@RequiredArgsConstructor
@Getter
public final class MasterSlaveRuleChangedEvent implements OrchestrationEvent {
public final class MasterSlaveRuleChangedEvent implements GovernanceEvent {
private final String schemaName;
......
......@@ -15,12 +15,12 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.common.event.rule;
package org.apache.shardingsphere.governance.core.common.event.rule;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.orchestration.core.common.event.OrchestrationEvent;
import org.apache.shardingsphere.governance.core.common.event.GovernanceEvent;
import java.util.Collection;
......@@ -29,7 +29,7 @@ import java.util.Collection;
*/
@RequiredArgsConstructor
@Getter
public final class RuleConfigurationsChangedEvent implements OrchestrationEvent {
public final class RuleConfigurationsChangedEvent implements GovernanceEvent {
private final String schemaName;
......
......@@ -15,11 +15,11 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.common.event.rule;
package org.apache.shardingsphere.governance.core.common.event.rule;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.orchestration.core.common.event.OrchestrationEvent;
import org.apache.shardingsphere.governance.core.common.event.GovernanceEvent;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
/**
......@@ -27,7 +27,7 @@ import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
*/
@RequiredArgsConstructor
@Getter
public final class ShadowRuleChangedEvent implements OrchestrationEvent {
public final class ShadowRuleChangedEvent implements GovernanceEvent {
private final String schemaName;
......
......@@ -15,14 +15,14 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.common.event.schema;
package org.apache.shardingsphere.governance.core.common.event.schema;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.config.DataSourceConfiguration;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.orchestration.core.common.event.OrchestrationEvent;
import org.apache.shardingsphere.governance.core.common.event.GovernanceEvent;
import java.util.Collection;
import java.util.Map;
......@@ -32,7 +32,7 @@ import java.util.Map;
*/
@RequiredArgsConstructor
@Getter
public final class SchemaAddedEvent implements OrchestrationEvent {
public final class SchemaAddedEvent implements GovernanceEvent {
private final String schemaName;
......
......@@ -15,18 +15,18 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.common.event.schema;
package org.apache.shardingsphere.governance.core.common.event.schema;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.orchestration.core.common.event.OrchestrationEvent;
import org.apache.shardingsphere.governance.core.common.event.GovernanceEvent;
/**
* Schema deleted event.
*/
@RequiredArgsConstructor
@Getter
public final class SchemaDeletedEvent implements OrchestrationEvent {
public final class SchemaDeletedEvent implements GovernanceEvent {
private final String schemaName;
}
......@@ -15,28 +15,28 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.common.eventbus;
package org.apache.shardingsphere.governance.core.common.eventbus;
import com.google.common.eventbus.EventBus;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
/**
* Orchestration event bus.
* Governance event bus.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class OrchestrationEventBus {
public final class GovernanceEventBus {
/**
* Get instance of orchestration event bus.
* Get instance of governance event bus.
*
* @return instance of orchestration event bus
* @return instance of governance event bus
*/
public static EventBus getInstance() {
return OrchestrationEventBusHolder.INSTANCE;
return GovernanceEventBusHolder.INSTANCE;
}
private static final class OrchestrationEventBusHolder {
private static final class GovernanceEventBusHolder {
private static final EventBus INSTANCE = new EventBus();
}
}
......@@ -15,14 +15,14 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.common.listener;
package org.apache.shardingsphere.governance.core.common.listener;
import org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEvent.ChangedType;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent.ChangedType;
/**
* Orchestration listener.
* Governance listener.
*/
public interface OrchestrationListener {
public interface GovernanceListener {
/**
* Start to watch.
......
......@@ -15,29 +15,29 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.common.listener;
package org.apache.shardingsphere.governance.core.common.listener;
import com.google.common.eventbus.EventBus;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.orchestration.repository.api.OrchestrationRepository;
import org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEvent;
import org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEvent.ChangedType;
import org.apache.shardingsphere.orchestration.core.common.event.OrchestrationEvent;
import org.apache.shardingsphere.orchestration.core.common.eventbus.OrchestrationEventBus;
import org.apache.shardingsphere.governance.repository.api.GovernanceRepository;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent.ChangedType;
import org.apache.shardingsphere.governance.core.common.event.GovernanceEvent;
import org.apache.shardingsphere.governance.core.common.eventbus.GovernanceEventBus;
import java.util.Arrays;
import java.util.Collection;
import java.util.Optional;
/**
* Post orchestration repository event listener.
* Post governance repository event listener.
*/
@RequiredArgsConstructor
public abstract class PostOrchestrationRepositoryEventListener implements OrchestrationListener {
public abstract class PostGovernanceRepositoryEventListener implements GovernanceListener {
private final EventBus eventBus = OrchestrationEventBus.getInstance();
private final EventBus eventBus = GovernanceEventBus.getInstance();
private final OrchestrationRepository orchestrationRepository;
private final GovernanceRepository governanceRepository;
private final Collection<String> watchKeys;
......@@ -50,13 +50,13 @@ public abstract class PostOrchestrationRepositoryEventListener implements Orches
}
private void watch(final String watchKey, final Collection<ChangedType> watchedChangedTypeList) {
orchestrationRepository.watch(watchKey, dataChangedEvent -> {
governanceRepository.watch(watchKey, dataChangedEvent -> {
if (watchedChangedTypeList.contains(dataChangedEvent.getChangedType())) {
Optional<OrchestrationEvent> event = createOrchestrationEvent(dataChangedEvent);
Optional<GovernanceEvent> event = createGovernanceEvent(dataChangedEvent);
event.ifPresent(eventBus::post);
}
});
}
protected abstract Optional<OrchestrationEvent> createOrchestrationEvent(DataChangedEvent event);
protected abstract Optional<GovernanceEvent> createGovernanceEvent(DataChangedEvent event);
}
......@@ -15,7 +15,7 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.common.yaml.config;
package org.apache.shardingsphere.governance.core.common.yaml.config;
import lombok.Getter;
import lombok.Setter;
......@@ -24,11 +24,11 @@ import org.apache.shardingsphere.infra.yaml.config.YamlConfiguration;
import java.util.Properties;
/**
* Orchestration center configuration for YAML.
* Governance center configuration for YAML.
*/
@Getter
@Setter
public final class YamlOrchestrationCenterConfiguration implements YamlConfiguration {
public final class YamlGovernanceCenterConfiguration implements YamlConfiguration {
private String type;
......
......@@ -15,24 +15,24 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.common.yaml.config;
package org.apache.shardingsphere.governance.core.common.yaml.config;
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.infra.yaml.config.YamlConfiguration;
/**
* Orchestration configuration for YAML.
* Governance configuration for YAML.
*/
@Getter
@Setter
public final class YamlOrchestrationConfiguration implements YamlConfiguration {
public final class YamlGovernanceConfiguration implements YamlConfiguration {
private String name;
private YamlOrchestrationCenterConfiguration registryCenter;
private YamlGovernanceCenterConfiguration registryCenter;
private YamlOrchestrationCenterConfiguration additionalConfigCenter;
private YamlGovernanceCenterConfiguration additionalConfigCenter;
private boolean overwrite;
}
......@@ -15,11 +15,11 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.common.yaml.swapper;
package org.apache.shardingsphere.governance.core.common.yaml.swapper;
import org.apache.shardingsphere.infra.config.DataSourceConfiguration;
import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
import org.apache.shardingsphere.orchestration.core.common.yaml.config.YamlDataSourceConfiguration;
import org.apache.shardingsphere.governance.core.common.yaml.config.YamlDataSourceConfiguration;
/**
* Data source configuration YAML swapper.
......
......@@ -15,20 +15,20 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.common.yaml.swapper;
package org.apache.shardingsphere.governance.core.common.yaml.swapper;
import org.apache.shardingsphere.orchestration.core.common.yaml.config.YamlOrchestrationCenterConfiguration;
import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationCenterConfiguration;
import org.apache.shardingsphere.governance.core.common.yaml.config.YamlGovernanceCenterConfiguration;
import org.apache.shardingsphere.governance.repository.api.config.GovernanceCenterConfiguration;
import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
/**
* Orchestration center configuration YAML swapper.
* Governance center configuration YAML swapper.
*/
public final class OrchestrationCenterConfigurationYamlSwapper implements YamlSwapper<YamlOrchestrationCenterConfiguration, OrchestrationCenterConfiguration> {
public final class GovernanceCenterConfigurationYamlSwapper implements YamlSwapper<YamlGovernanceCenterConfiguration, GovernanceCenterConfiguration> {
@Override
public YamlOrchestrationCenterConfiguration swapToYamlConfiguration(final OrchestrationCenterConfiguration config) {
YamlOrchestrationCenterConfiguration result = new YamlOrchestrationCenterConfiguration();
public YamlGovernanceCenterConfiguration swapToYamlConfiguration(final GovernanceCenterConfiguration config) {
YamlGovernanceCenterConfiguration result = new YamlGovernanceCenterConfiguration();
result.setType(config.getType());
result.setServerLists(config.getServerLists());
result.setProps(config.getProps());
......@@ -36,7 +36,7 @@ public final class OrchestrationCenterConfigurationYamlSwapper implements YamlSw
}
@Override
public OrchestrationCenterConfiguration swapToObject(final YamlOrchestrationCenterConfiguration yamlConfig) {
return new OrchestrationCenterConfiguration(yamlConfig.getType(), yamlConfig.getServerLists(), yamlConfig.getProps());
public GovernanceCenterConfiguration swapToObject(final YamlGovernanceCenterConfiguration yamlConfig) {
return new GovernanceCenterConfiguration(yamlConfig.getType(), yamlConfig.getServerLists(), yamlConfig.getProps());
}
}
......@@ -15,38 +15,38 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.common.yaml.swapper;
package org.apache.shardingsphere.governance.core.common.yaml.swapper;
import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
import org.apache.shardingsphere.orchestration.core.common.yaml.config.YamlOrchestrationConfiguration;
import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationCenterConfiguration;
import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationConfiguration;
import org.apache.shardingsphere.governance.core.common.yaml.config.YamlGovernanceConfiguration;
import org.apache.shardingsphere.governance.repository.api.config.GovernanceCenterConfiguration;
import org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
/**
* Orchestration configuration YAML swapper.
* Governance configuration YAML swapper.
*/
public final class OrchestrationConfigurationYamlSwapper implements YamlSwapper<YamlOrchestrationConfiguration, OrchestrationConfiguration> {
public final class GovernanceConfigurationYamlSwapper implements YamlSwapper<YamlGovernanceConfiguration, GovernanceConfiguration> {
private final OrchestrationCenterConfigurationYamlSwapper orchestrationCenterConfigurationSwapper = new OrchestrationCenterConfigurationYamlSwapper();
private final GovernanceCenterConfigurationYamlSwapper governanceCenterConfigurationSwapper = new GovernanceCenterConfigurationYamlSwapper();
@Override
public YamlOrchestrationConfiguration swapToYamlConfiguration(final OrchestrationConfiguration data) {
YamlOrchestrationConfiguration result = new YamlOrchestrationConfiguration();
public YamlGovernanceConfiguration swapToYamlConfiguration(final GovernanceConfiguration data) {
YamlGovernanceConfiguration result = new YamlGovernanceConfiguration();
result.setName(data.getName());
result.setRegistryCenter(orchestrationCenterConfigurationSwapper.swapToYamlConfiguration(data.getRegistryCenterConfiguration()));
result.setRegistryCenter(governanceCenterConfigurationSwapper.swapToYamlConfiguration(data.getRegistryCenterConfiguration()));
if (data.getAdditionalConfigCenterConfiguration().isPresent()) {
result.setAdditionalConfigCenter(orchestrationCenterConfigurationSwapper.swapToYamlConfiguration(data.getAdditionalConfigCenterConfiguration().get()));
result.setAdditionalConfigCenter(governanceCenterConfigurationSwapper.swapToYamlConfiguration(data.getAdditionalConfigCenterConfiguration().get()));
}
return result;
}
@Override
public OrchestrationConfiguration swapToObject(final YamlOrchestrationConfiguration yamlConfig) {
OrchestrationCenterConfiguration registryCenter = orchestrationCenterConfigurationSwapper.swapToObject(yamlConfig.getRegistryCenter());
public GovernanceConfiguration swapToObject(final YamlGovernanceConfiguration yamlConfig) {
GovernanceCenterConfiguration registryCenter = governanceCenterConfigurationSwapper.swapToObject(yamlConfig.getRegistryCenter());
if (null == yamlConfig.getAdditionalConfigCenter()) {
return new OrchestrationConfiguration(yamlConfig.getName(), registryCenter, yamlConfig.isOverwrite());
return new GovernanceConfiguration(yamlConfig.getName(), registryCenter, yamlConfig.isOverwrite());
}
OrchestrationCenterConfiguration additionalConfigCenter = orchestrationCenterConfigurationSwapper.swapToObject(yamlConfig.getAdditionalConfigCenter());
return new OrchestrationConfiguration(yamlConfig.getName(), registryCenter, additionalConfigCenter, yamlConfig.isOverwrite());
GovernanceCenterConfiguration additionalConfigCenter = governanceCenterConfigurationSwapper.swapToObject(yamlConfig.getAdditionalConfigCenter());
return new GovernanceConfiguration(yamlConfig.getName(), registryCenter, additionalConfigCenter, yamlConfig.isOverwrite());
}
}
......@@ -15,17 +15,17 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.common.eventbus;
package org.apache.shardingsphere.governance.core.common.eventbus;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
public final class OrchestrationEventBusTest {
public final class GovernanceEventBusTest {
@Test
public void assertGetInstance() {
assertThat(OrchestrationEventBus.getInstance(), is(OrchestrationEventBus.getInstance()));
assertThat(GovernanceEventBus.getInstance(), is(GovernanceEventBus.getInstance()));
}
}
......@@ -15,13 +15,13 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.common.listener;
package org.apache.shardingsphere.governance.core.common.listener;
import org.apache.shardingsphere.orchestration.core.common.event.OrchestrationEvent;
import org.apache.shardingsphere.orchestration.repository.api.OrchestrationRepository;
import org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEvent;
import org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEvent.ChangedType;
import org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEventListener;
import org.apache.shardingsphere.governance.core.common.event.GovernanceEvent;
import org.apache.shardingsphere.governance.repository.api.GovernanceRepository;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent.ChangedType;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEventListener;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
......@@ -39,45 +39,45 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@RunWith(MockitoJUnitRunner.class)
public final class PostOrchestrationRepositoryEventListenerTest {
public final class PostGovernanceRepositoryEventListenerTest {
@Mock
private OrchestrationRepository orchestrationRepository;
private GovernanceRepository governanceRepository;
@Test
public void assertWatch() {
PostOrchestrationRepositoryEventListener postEventListener = new PostOrchestrationRepositoryEventListener(orchestrationRepository, Collections.singletonList("test")) {
PostGovernanceRepositoryEventListener postEventListener = new PostGovernanceRepositoryEventListener(governanceRepository, Collections.singletonList("test")) {
@Override
protected Optional<OrchestrationEvent> createOrchestrationEvent(final DataChangedEvent event) {
return Optional.of(mock(OrchestrationEvent.class));
protected Optional<GovernanceEvent> createGovernanceEvent(final DataChangedEvent event) {
return Optional.of(mock(GovernanceEvent.class));
}
};
doAnswer(invocationOnMock -> {
DataChangedEventListener listener = (DataChangedEventListener) invocationOnMock.getArguments()[1];
listener.onChange(new DataChangedEvent("test", "value", ChangedType.UPDATED));
return mock(DataChangedEventListener.class);
}).when(orchestrationRepository).watch(anyString(), any(DataChangedEventListener.class));
}).when(governanceRepository).watch(anyString(), any(DataChangedEventListener.class));
postEventListener.watch(ChangedType.UPDATED);
verify(orchestrationRepository).watch(eq("test"), any());
verify(governanceRepository).watch(eq("test"), any());
}
@Test
public void assertWatchMultipleKey() {
PostOrchestrationRepositoryEventListener postEventListener = new PostOrchestrationRepositoryEventListener(orchestrationRepository, Arrays.asList("test", "dev")) {
PostGovernanceRepositoryEventListener postEventListener = new PostGovernanceRepositoryEventListener(governanceRepository, Arrays.asList("test", "dev")) {
@Override
protected Optional<OrchestrationEvent> createOrchestrationEvent(final DataChangedEvent event) {
return Optional.of(mock(OrchestrationEvent.class));
protected Optional<GovernanceEvent> createGovernanceEvent(final DataChangedEvent event) {
return Optional.of(mock(GovernanceEvent.class));
}
};
doAnswer(invocationOnMock -> {
DataChangedEventListener listener = (DataChangedEventListener) invocationOnMock.getArguments()[1];
listener.onChange(new DataChangedEvent("test", "value", ChangedType.UPDATED));
return mock(DataChangedEventListener.class);
}).when(orchestrationRepository).watch(anyString(), any(DataChangedEventListener.class));
}).when(governanceRepository).watch(anyString(), any(DataChangedEventListener.class));
postEventListener.watch(ChangedType.UPDATED, ChangedType.DELETED);
verify(orchestrationRepository).watch(eq("test"), any());
verify(orchestrationRepository).watch(eq("dev"), any());
verify(governanceRepository).watch(eq("test"), any());
verify(governanceRepository).watch(eq("dev"), any());
}
}
......@@ -15,10 +15,10 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.common.yaml.swapper;
package org.apache.shardingsphere.governance.core.common.yaml.swapper;
import org.apache.shardingsphere.infra.config.DataSourceConfiguration;
import org.apache.shardingsphere.orchestration.core.common.yaml.config.YamlDataSourceConfiguration;
import org.apache.shardingsphere.governance.core.common.yaml.config.YamlDataSourceConfiguration;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
......
......@@ -15,10 +15,10 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.common.yaml.swapper;
package org.apache.shardingsphere.governance.core.common.yaml.swapper;
import org.apache.shardingsphere.orchestration.core.common.yaml.config.YamlOrchestrationCenterConfiguration;
import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationCenterConfiguration;
import org.apache.shardingsphere.governance.core.common.yaml.config.YamlGovernanceCenterConfiguration;
import org.apache.shardingsphere.governance.repository.api.config.GovernanceCenterConfiguration;
import org.junit.Test;
import java.util.Properties;
......@@ -26,12 +26,12 @@ import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
public final class OrchestrationCenterConfigurationYamlSwapperTest {
public final class GovernanceCenterConfigurationYamlSwapperTest {
@Test
public void assertToYamlConfiguration() {
OrchestrationCenterConfiguration expected = new OrchestrationCenterConfiguration("TEST", "127.0.0.1:2181", new Properties());
YamlOrchestrationCenterConfiguration actual = new OrchestrationCenterConfigurationYamlSwapper().swapToYamlConfiguration(expected);
GovernanceCenterConfiguration expected = new GovernanceCenterConfiguration("TEST", "127.0.0.1:2181", new Properties());
YamlGovernanceCenterConfiguration actual = new GovernanceCenterConfigurationYamlSwapper().swapToYamlConfiguration(expected);
assertThat(actual.getType(), is(expected.getType()));
assertThat(actual.getServerLists(), is(expected.getServerLists()));
assertThat(actual.getProps(), is(expected.getProps()));
......@@ -39,15 +39,15 @@ public final class OrchestrationCenterConfigurationYamlSwapperTest {
@Test
public void assertSwapToObject() {
YamlOrchestrationCenterConfiguration yamlConfiguration = getYamlOrchestrationCenterConfiguration();
OrchestrationCenterConfiguration orchestrationCenterConfig = new OrchestrationCenterConfigurationYamlSwapper().swapToObject(yamlConfiguration);
assertThat(orchestrationCenterConfig.getType(), is(yamlConfiguration.getType()));
assertThat(orchestrationCenterConfig.getServerLists(), is(yamlConfiguration.getServerLists()));
assertThat(orchestrationCenterConfig.getProps(), is(yamlConfiguration.getProps()));
YamlGovernanceCenterConfiguration yamlConfiguration = getYamlGovernanceCenterConfiguration();
GovernanceCenterConfiguration governanceCenterConfig = new GovernanceCenterConfigurationYamlSwapper().swapToObject(yamlConfiguration);
assertThat(governanceCenterConfig.getType(), is(yamlConfiguration.getType()));
assertThat(governanceCenterConfig.getServerLists(), is(yamlConfiguration.getServerLists()));
assertThat(governanceCenterConfig.getProps(), is(yamlConfiguration.getProps()));
}
private YamlOrchestrationCenterConfiguration getYamlOrchestrationCenterConfiguration() {
YamlOrchestrationCenterConfiguration result = new YamlOrchestrationCenterConfiguration();
private YamlGovernanceCenterConfiguration getYamlGovernanceCenterConfiguration() {
YamlGovernanceCenterConfiguration result = new YamlGovernanceCenterConfiguration();
result.setType("TEST");
result.setProps(new Properties());
result.setServerLists("127.0.0.1:2181");
......
......@@ -15,12 +15,12 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.common.yaml.swapper;
package org.apache.shardingsphere.governance.core.common.yaml.swapper;
import org.apache.shardingsphere.orchestration.core.common.yaml.config.YamlOrchestrationCenterConfiguration;
import org.apache.shardingsphere.orchestration.core.common.yaml.config.YamlOrchestrationConfiguration;
import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationCenterConfiguration;
import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationConfiguration;
import org.apache.shardingsphere.governance.core.common.yaml.config.YamlGovernanceCenterConfiguration;
import org.apache.shardingsphere.governance.core.common.yaml.config.YamlGovernanceConfiguration;
import org.apache.shardingsphere.governance.repository.api.config.GovernanceCenterConfiguration;
import org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
import org.junit.Test;
import java.util.Properties;
......@@ -30,12 +30,12 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public final class OrchestrationConfigurationYamlSwapperTest {
public final class GovernanceConfigurationYamlSwapperTest {
@Test
public void assertSwapToYamlOrchestrationConfigurationWithoutAdditionalConfigCenterConfiguration() {
OrchestrationConfiguration expected = createOrchestrationConfigurationWithoutAdditionalConfigCenterConfiguration();
YamlOrchestrationConfiguration actual = new OrchestrationConfigurationYamlSwapper().swapToYamlConfiguration(expected);
public void assertSwapToYamlGovernanceConfigurationWithoutAdditionalConfigCenterConfiguration() {
GovernanceConfiguration expected = createGovernanceConfigurationWithoutAdditionalConfigCenterConfiguration();
YamlGovernanceConfiguration actual = new GovernanceConfigurationYamlSwapper().swapToYamlConfiguration(expected);
assertThat(actual.getName(), is(expected.getName()));
assertThat(actual.isOverwrite(), is(expected.isOverwrite()));
assertThat(actual.getRegistryCenter().getType(), is(expected.getRegistryCenterConfiguration().getType()));
......@@ -44,14 +44,14 @@ public final class OrchestrationConfigurationYamlSwapperTest {
assertFalse(expected.getAdditionalConfigCenterConfiguration().isPresent());
}
private OrchestrationConfiguration createOrchestrationConfigurationWithoutAdditionalConfigCenterConfiguration() {
return new OrchestrationConfiguration("logic_schema", new OrchestrationCenterConfiguration("TEST", "127.0.0.1:2181", new Properties()), false);
private GovernanceConfiguration createGovernanceConfigurationWithoutAdditionalConfigCenterConfiguration() {
return new GovernanceConfiguration("logic_schema", new GovernanceCenterConfiguration("TEST", "127.0.0.1:2181", new Properties()), false);
}
@Test
public void assertSwapToYamlOrchestrationConfigurationWithAdditionalConfigCenterConfiguration() {
OrchestrationConfiguration expected = createOrchestrationConfigurationWithAdditionalConfigCenterConfiguration();
YamlOrchestrationConfiguration actual = new OrchestrationConfigurationYamlSwapper().swapToYamlConfiguration(expected);
public void assertSwapToYamlGovernanceConfigurationWithAdditionalConfigCenterConfiguration() {
GovernanceConfiguration expected = createGovernanceConfigurationWithAdditionalConfigCenterConfiguration();
YamlGovernanceConfiguration actual = new GovernanceConfigurationYamlSwapper().swapToYamlConfiguration(expected);
assertThat(actual.getName(), is(expected.getName()));
assertThat(actual.isOverwrite(), is(expected.isOverwrite()));
assertThat(actual.getRegistryCenter().getType(), is(expected.getRegistryCenterConfiguration().getType()));
......@@ -63,15 +63,15 @@ public final class OrchestrationConfigurationYamlSwapperTest {
assertThat(actual.getAdditionalConfigCenter().getProps(), is(expected.getAdditionalConfigCenterConfiguration().get().getProps()));
}
private OrchestrationConfiguration createOrchestrationConfigurationWithAdditionalConfigCenterConfiguration() {
return new OrchestrationConfiguration("logic_schema",
new OrchestrationCenterConfiguration("TEST", "127.0.0.1:2181", new Properties()), new OrchestrationCenterConfiguration("ADDITIONAL", "127.0.0.1:2181", new Properties()), false);
private GovernanceConfiguration createGovernanceConfigurationWithAdditionalConfigCenterConfiguration() {
return new GovernanceConfiguration("logic_schema",
new GovernanceCenterConfiguration("TEST", "127.0.0.1:2181", new Properties()), new GovernanceCenterConfiguration("ADDITIONAL", "127.0.0.1:2181", new Properties()), false);
}
@Test
public void assertSwapToOrchestrationConfigurationWithoutAdditionalConfigCenterConfiguration() {
YamlOrchestrationConfiguration expected = createYamlOrchestrationConfigurationWithoutAdditionalConfigCenterConfiguration();
OrchestrationConfiguration actual = new OrchestrationConfigurationYamlSwapper().swapToObject(expected);
public void assertSwapToGovernanceConfigurationWithoutAdditionalConfigCenterConfiguration() {
YamlGovernanceConfiguration expected = createYamlGovernanceConfigurationWithoutAdditionalConfigCenterConfiguration();
GovernanceConfiguration actual = new GovernanceConfigurationYamlSwapper().swapToObject(expected);
assertThat(actual.getName(), is(expected.getName()));
assertThat(actual.isOverwrite(), is(expected.isOverwrite()));
assertThat(actual.getRegistryCenterConfiguration().getType(), is(expected.getRegistryCenter().getType()));
......@@ -80,17 +80,17 @@ public final class OrchestrationConfigurationYamlSwapperTest {
assertFalse(actual.getAdditionalConfigCenterConfiguration().isPresent());
}
private YamlOrchestrationConfiguration createYamlOrchestrationConfigurationWithoutAdditionalConfigCenterConfiguration() {
YamlOrchestrationConfiguration result = new YamlOrchestrationConfiguration();
private YamlGovernanceConfiguration createYamlGovernanceConfigurationWithoutAdditionalConfigCenterConfiguration() {
YamlGovernanceConfiguration result = new YamlGovernanceConfiguration();
result.setName("logic_schema");
result.setRegistryCenter(createYamlRegistryCenterConfiguration());
return result;
}
@Test
public void assertSwapToOrchestrationConfigurationWithAdditionalConfigCenterConfiguration() {
YamlOrchestrationConfiguration expected = createYamlOrchestrationConfigurationWithAdditionalConfigCenterConfiguration();
OrchestrationConfiguration actual = new OrchestrationConfigurationYamlSwapper().swapToObject(expected);
public void assertSwapToGovernanceConfigurationWithAdditionalConfigCenterConfiguration() {
YamlGovernanceConfiguration expected = createYamlGovernanceConfigurationWithAdditionalConfigCenterConfiguration();
GovernanceConfiguration actual = new GovernanceConfigurationYamlSwapper().swapToObject(expected);
assertThat(actual.getName(), is(expected.getName()));
assertThat(actual.isOverwrite(), is(expected.isOverwrite()));
assertThat(actual.getRegistryCenterConfiguration().getType(), is(expected.getRegistryCenter().getType()));
......@@ -102,24 +102,24 @@ public final class OrchestrationConfigurationYamlSwapperTest {
assertThat(actual.getAdditionalConfigCenterConfiguration().get().getProps(), is(expected.getAdditionalConfigCenter().getProps()));
}
private YamlOrchestrationConfiguration createYamlOrchestrationConfigurationWithAdditionalConfigCenterConfiguration() {
YamlOrchestrationConfiguration result = new YamlOrchestrationConfiguration();
private YamlGovernanceConfiguration createYamlGovernanceConfigurationWithAdditionalConfigCenterConfiguration() {
YamlGovernanceConfiguration result = new YamlGovernanceConfiguration();
result.setName("logic_schema");
result.setRegistryCenter(createYamlRegistryCenterConfiguration());
result.setAdditionalConfigCenter(createYamlAdditionalConfigCenterConfiguration());
return result;
}
private YamlOrchestrationCenterConfiguration createYamlRegistryCenterConfiguration() {
YamlOrchestrationCenterConfiguration result = new YamlOrchestrationCenterConfiguration();
private YamlGovernanceCenterConfiguration createYamlRegistryCenterConfiguration() {
YamlGovernanceCenterConfiguration result = new YamlGovernanceCenterConfiguration();
result.setType("TEST");
result.setProps(new Properties());
result.setServerLists("127.0.0.1:2181");
return result;
}
private YamlOrchestrationCenterConfiguration createYamlAdditionalConfigCenterConfiguration() {
YamlOrchestrationCenterConfiguration result = new YamlOrchestrationCenterConfiguration();
private YamlGovernanceCenterConfiguration createYamlAdditionalConfigCenterConfiguration() {
YamlGovernanceCenterConfiguration result = new YamlGovernanceCenterConfiguration();
result.setType("ADDITIONAL");
result.setProps(new Properties());
result.setServerLists("127.0.0.1:2182");
......
......@@ -20,21 +20,21 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-core</artifactId>
<artifactId>shardingsphere-governance-core</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
<artifactId>shardingsphere-orchestration-core-config</artifactId>
<artifactId>shardingsphere-governance-core-config</artifactId>
<name>${project.artifactId}</name>
<dependencies>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-core-common</artifactId>
<artifactId>shardingsphere-governance-core-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-repository-api</artifactId>
<artifactId>shardingsphere-governance-repository-api</artifactId>
<version>${project.version}</version>
</dependency>
......
......@@ -15,7 +15,7 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.config;
package org.apache.shardingsphere.governance.core.config;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
......@@ -26,9 +26,9 @@ import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.infra.auth.Authentication;
import org.apache.shardingsphere.infra.auth.yaml.config.YamlAuthenticationConfiguration;
import org.apache.shardingsphere.infra.auth.yaml.swapper.AuthenticationYamlSwapper;
import org.apache.shardingsphere.infra.callback.orchestration.DataSourceCallback;
import org.apache.shardingsphere.infra.callback.orchestration.RuleCallback;
import org.apache.shardingsphere.infra.callback.orchestration.SchemaNameCallback;
import org.apache.shardingsphere.infra.callback.governance.DataSourceCallback;
import org.apache.shardingsphere.infra.callback.governance.RuleCallback;
import org.apache.shardingsphere.infra.callback.governance.SchemaNameCallback;
import org.apache.shardingsphere.infra.config.DataSourceConfiguration;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.yaml.config.YamlRootRuleConfigurations;
......@@ -36,9 +36,9 @@ import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
import org.apache.shardingsphere.masterslave.algorithm.config.AlgorithmProvidedMasterSlaveRuleConfiguration;
import org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration;
import org.apache.shardingsphere.orchestration.core.common.yaml.config.YamlDataSourceConfiguration;
import org.apache.shardingsphere.orchestration.core.common.yaml.swapper.DataSourceConfigurationYamlSwapper;
import org.apache.shardingsphere.orchestration.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.governance.core.common.yaml.config.YamlDataSourceConfiguration;
import org.apache.shardingsphere.governance.core.common.yaml.swapper.DataSourceConfigurationYamlSwapper;
import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.sharding.algorithm.config.AlgorithmProvidedShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
......@@ -106,7 +106,7 @@ public final class ConfigCenter {
}
private void persistDataSourceConfiguration(final String schemaName, final Map<String, DataSourceConfiguration> dataSourceConfigurations) {
Preconditions.checkState(null != dataSourceConfigurations && !dataSourceConfigurations.isEmpty(), "No available data source in `%s` for orchestration.", schemaName);
Preconditions.checkState(null != dataSourceConfigurations && !dataSourceConfigurations.isEmpty(), "No available data source in `%s` for governance.", schemaName);
Map<String, YamlDataSourceConfiguration> yamlDataSourceConfigurations = dataSourceConfigurations.entrySet().stream()
.collect(Collectors.toMap(Entry::getKey, entry -> new DataSourceConfigurationYamlSwapper().swapToYamlConfiguration(entry.getValue())));
repository.persist(node.getDataSourcePath(schemaName), YamlEngine.marshal(yamlDataSourceConfigurations));
......@@ -125,34 +125,34 @@ public final class ConfigCenter {
if (each instanceof ShardingRuleConfiguration) {
ShardingRuleConfiguration config = (ShardingRuleConfiguration) each;
Preconditions.checkState(hasAvailableTableConfigurations(config),
"No available rule configurations in `%s` for orchestration.", schemaName);
"No available rule configurations in `%s` for governance.", schemaName);
configurations.add(each);
} else if (each instanceof AlgorithmProvidedShardingRuleConfiguration) {
AlgorithmProvidedShardingRuleConfiguration config = (AlgorithmProvidedShardingRuleConfiguration) each;
Preconditions.checkState(hasAvailableTableConfigurations(config),
"No available rule configurations in `%s` for orchestration.", schemaName);
"No available rule configurations in `%s` for governance.", schemaName);
configurations.add(each);
} else if (each instanceof AlgorithmProvidedMasterSlaveRuleConfiguration) {
AlgorithmProvidedMasterSlaveRuleConfiguration config = (AlgorithmProvidedMasterSlaveRuleConfiguration) each;
config.getDataSources().forEach(group -> Preconditions.checkState(
!group.getMasterDataSourceName().isEmpty(), "No available master-slave rule configuration in `%s` for orchestration.", schemaName));
!group.getMasterDataSourceName().isEmpty(), "No available master-slave rule configuration in `%s` for governance.", schemaName));
configurations.add(each);
} else if (each instanceof AlgorithmProvidedEncryptRuleConfiguration) {
AlgorithmProvidedEncryptRuleConfiguration config = (AlgorithmProvidedEncryptRuleConfiguration) each;
Preconditions.checkState(!config.getEncryptors().isEmpty(), "No available encrypt rule configuration in `%s` for orchestration.", schemaName);
Preconditions.checkState(!config.getEncryptors().isEmpty(), "No available encrypt rule configuration in `%s` for governance.", schemaName);
configurations.add(each);
} else if (each instanceof MasterSlaveRuleConfiguration) {
MasterSlaveRuleConfiguration config = (MasterSlaveRuleConfiguration) each;
config.getDataSources().forEach(group -> Preconditions.checkState(
!group.getMasterDataSourceName().isEmpty(), "No available master-slave rule configuration in `%s` for orchestration.", schemaName));
!group.getMasterDataSourceName().isEmpty(), "No available master-slave rule configuration in `%s` for governance.", schemaName));
configurations.add(each);
} else if (each instanceof EncryptRuleConfiguration) {
EncryptRuleConfiguration config = (EncryptRuleConfiguration) each;
Preconditions.checkState(!config.getEncryptors().isEmpty(), "No available encrypt rule configuration in `%s` for orchestration.", schemaName);
Preconditions.checkState(!config.getEncryptors().isEmpty(), "No available encrypt rule configuration in `%s` for governance.", schemaName);
configurations.add(each);
} else if (each instanceof ShadowRuleConfiguration) {
ShadowRuleConfiguration config = (ShadowRuleConfiguration) each;
Preconditions.checkState(!config.getColumn().isEmpty() && null != config.getShadowMappings(), "No available shadow rule configuration in `%s` for orchestration.", schemaName);
Preconditions.checkState(!config.getColumn().isEmpty() && null != config.getShadowMappings(), "No available shadow rule configuration in `%s` for governance.", schemaName);
configurations.add(each);
}
}
......
......@@ -15,17 +15,17 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.config.listener;
package org.apache.shardingsphere.governance.core.config.listener;
import org.apache.shardingsphere.infra.auth.yaml.config.YamlAuthenticationConfiguration;
import org.apache.shardingsphere.infra.auth.yaml.swapper.AuthenticationYamlSwapper;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.apache.shardingsphere.orchestration.core.common.event.OrchestrationEvent;
import org.apache.shardingsphere.orchestration.core.common.event.auth.AuthenticationChangedEvent;
import org.apache.shardingsphere.orchestration.core.common.listener.PostOrchestrationRepositoryEventListener;
import org.apache.shardingsphere.orchestration.core.config.ConfigCenterNode;
import org.apache.shardingsphere.orchestration.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEvent;
import org.apache.shardingsphere.governance.core.common.event.GovernanceEvent;
import org.apache.shardingsphere.governance.core.common.event.auth.AuthenticationChangedEvent;
import org.apache.shardingsphere.governance.core.common.listener.PostGovernanceRepositoryEventListener;
import org.apache.shardingsphere.governance.core.config.ConfigCenterNode;
import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent;
import java.util.Collections;
import java.util.Optional;
......@@ -33,14 +33,14 @@ import java.util.Optional;
/**
* Authentication changed listener.
*/
public final class AuthenticationChangedListener extends PostOrchestrationRepositoryEventListener {
public final class AuthenticationChangedListener extends PostGovernanceRepositoryEventListener {
public AuthenticationChangedListener(final ConfigurationRepository configurationRepository) {
super(configurationRepository, Collections.singletonList(new ConfigCenterNode().getAuthenticationPath()));
}
@Override
protected Optional<OrchestrationEvent> createOrchestrationEvent(final DataChangedEvent event) {
protected Optional<GovernanceEvent> createGovernanceEvent(final DataChangedEvent event) {
return Optional.of(new AuthenticationChangedEvent(new AuthenticationYamlSwapper().swapToObject(YamlEngine.unmarshal(event.getValue(), YamlAuthenticationConfiguration.class))));
}
}
......@@ -15,10 +15,10 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.config.listener;
package org.apache.shardingsphere.governance.core.config.listener;
import org.apache.shardingsphere.orchestration.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEvent.ChangedType;
import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent.ChangedType;
import java.util.Collection;
......
......@@ -15,15 +15,15 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.config.listener;
package org.apache.shardingsphere.governance.core.config.listener;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.apache.shardingsphere.orchestration.core.common.event.OrchestrationEvent;
import org.apache.shardingsphere.orchestration.core.common.event.props.PropertiesChangedEvent;
import org.apache.shardingsphere.orchestration.core.common.listener.PostOrchestrationRepositoryEventListener;
import org.apache.shardingsphere.orchestration.core.config.ConfigCenterNode;
import org.apache.shardingsphere.orchestration.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEvent;
import org.apache.shardingsphere.governance.core.common.event.GovernanceEvent;
import org.apache.shardingsphere.governance.core.common.event.props.PropertiesChangedEvent;
import org.apache.shardingsphere.governance.core.common.listener.PostGovernanceRepositoryEventListener;
import org.apache.shardingsphere.governance.core.config.ConfigCenterNode;
import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent;
import java.util.Collections;
import java.util.Optional;
......@@ -31,14 +31,14 @@ import java.util.Optional;
/**
* Properties changed listener.
*/
public final class PropertiesChangedListener extends PostOrchestrationRepositoryEventListener {
public final class PropertiesChangedListener extends PostGovernanceRepositoryEventListener {
public PropertiesChangedListener(final ConfigurationRepository configurationRepository) {
super(configurationRepository, Collections.singletonList(new ConfigCenterNode().getPropsPath()));
}
@Override
protected Optional<OrchestrationEvent> createOrchestrationEvent(final DataChangedEvent event) {
protected Optional<GovernanceEvent> createGovernanceEvent(final DataChangedEvent event) {
return Optional.of(new PropertiesChangedEvent(YamlEngine.unmarshalProperties(event.getValue())));
}
}
......@@ -15,7 +15,7 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.config.listener;
package org.apache.shardingsphere.governance.core.config.listener;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
......@@ -24,19 +24,19 @@ import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.yaml.config.YamlRootRuleConfigurations;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
import org.apache.shardingsphere.orchestration.core.common.event.datasource.DataSourceChangedEvent;
import org.apache.shardingsphere.orchestration.core.common.event.OrchestrationEvent;
import org.apache.shardingsphere.orchestration.core.common.event.rule.RuleConfigurationsChangedEvent;
import org.apache.shardingsphere.orchestration.core.common.event.schema.SchemaAddedEvent;
import org.apache.shardingsphere.orchestration.core.common.event.schema.SchemaDeletedEvent;
import org.apache.shardingsphere.orchestration.core.common.listener.PostOrchestrationRepositoryEventListener;
import org.apache.shardingsphere.orchestration.core.common.yaml.config.YamlDataSourceConfiguration;
import org.apache.shardingsphere.orchestration.core.common.yaml.swapper.DataSourceConfigurationYamlSwapper;
import org.apache.shardingsphere.orchestration.core.config.ConfigCenter;
import org.apache.shardingsphere.orchestration.core.config.ConfigCenterNode;
import org.apache.shardingsphere.orchestration.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEvent;
import org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEvent.ChangedType;
import org.apache.shardingsphere.governance.core.common.event.datasource.DataSourceChangedEvent;
import org.apache.shardingsphere.governance.core.common.event.GovernanceEvent;
import org.apache.shardingsphere.governance.core.common.event.rule.RuleConfigurationsChangedEvent;
import org.apache.shardingsphere.governance.core.common.event.schema.SchemaAddedEvent;
import org.apache.shardingsphere.governance.core.common.event.schema.SchemaDeletedEvent;
import org.apache.shardingsphere.governance.core.common.listener.PostGovernanceRepositoryEventListener;
import org.apache.shardingsphere.governance.core.common.yaml.config.YamlDataSourceConfiguration;
import org.apache.shardingsphere.governance.core.common.yaml.swapper.DataSourceConfigurationYamlSwapper;
import org.apache.shardingsphere.governance.core.config.ConfigCenter;
import org.apache.shardingsphere.governance.core.config.ConfigCenterNode;
import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent.ChangedType;
import java.util.Collection;
import java.util.Collections;
......@@ -51,7 +51,7 @@ import java.util.stream.Collectors;
/**
* Schema changed listener.
*/
public final class SchemaChangedListener extends PostOrchestrationRepositoryEventListener {
public final class SchemaChangedListener extends PostGovernanceRepositoryEventListener {
private final ConfigCenter configurationService;
......@@ -67,7 +67,7 @@ public final class SchemaChangedListener extends PostOrchestrationRepositoryEven
}
@Override
protected Optional<OrchestrationEvent> createOrchestrationEvent(final DataChangedEvent event) {
protected Optional<GovernanceEvent> createGovernanceEvent(final DataChangedEvent event) {
// TODO Consider removing the following one.
if (configurationNode.getSchemaPath().equals(event.getKey())) {
return createSchemaNamesUpdatedEvent(event.getValue());
......@@ -88,7 +88,7 @@ public final class SchemaChangedListener extends PostOrchestrationRepositoryEven
return Optional.empty();
}
private Optional<OrchestrationEvent> createSchemaNamesUpdatedEvent(final String shardingSchemaNames) {
private Optional<GovernanceEvent> createSchemaNamesUpdatedEvent(final String shardingSchemaNames) {
Collection<String> persistShardingSchemaNames = configurationNode.splitSchemaName(shardingSchemaNames);
Set<String> addedSchemaNames = SetUtils.difference(new HashSet<>(persistShardingSchemaNames), new HashSet<>(existedSchemaNames));
if (!addedSchemaNames.isEmpty()) {
......@@ -106,7 +106,7 @@ public final class SchemaChangedListener extends PostOrchestrationRepositoryEven
|| configurationNode.getDataSourcePath(shardingSchemaName).equals(nodeFullPath) || configurationNode.getRulePath(shardingSchemaName).equals(nodeFullPath);
}
private OrchestrationEvent createAddedEvent(final String shardingSchemaName) {
private GovernanceEvent createAddedEvent(final String shardingSchemaName) {
existedSchemaNames.add(shardingSchemaName);
if (!isOwnCompleteConfigurations(shardingSchemaName)) {
return new SchemaAddedEvent(shardingSchemaName, Collections.emptyMap(), Collections.emptyList());
......@@ -114,12 +114,12 @@ public final class SchemaChangedListener extends PostOrchestrationRepositoryEven
return new SchemaAddedEvent(shardingSchemaName, configurationService.loadDataSourceConfigurations(shardingSchemaName), createRuleConfigurations(shardingSchemaName));
}
private OrchestrationEvent createUpdatedEvent(final String shardingSchemaName, final DataChangedEvent event) {
private GovernanceEvent createUpdatedEvent(final String shardingSchemaName, final DataChangedEvent event) {
// TODO Consider remove judgement.
return existedSchemaNames.contains(shardingSchemaName) ? createUpdatedEventForExistedSchema(event, shardingSchemaName) : createAddedEvent(shardingSchemaName);
}
private OrchestrationEvent createUpdatedEventForExistedSchema(final DataChangedEvent event, final String shardingSchemaName) {
private GovernanceEvent createUpdatedEventForExistedSchema(final DataChangedEvent event, final String shardingSchemaName) {
return event.getKey().equals(configurationNode.getDataSourcePath(shardingSchemaName))
? createDataSourceChangedEvent(shardingSchemaName, event) : createRuleChangedEvent(shardingSchemaName, event);
}
......@@ -127,14 +127,14 @@ public final class SchemaChangedListener extends PostOrchestrationRepositoryEven
@SuppressWarnings("unchecked")
private DataSourceChangedEvent createDataSourceChangedEvent(final String shardingSchemaName, final DataChangedEvent event) {
Map<String, YamlDataSourceConfiguration> dataSourceConfigurations = (Map) YamlEngine.unmarshal(event.getValue());
Preconditions.checkState(null != dataSourceConfigurations && !dataSourceConfigurations.isEmpty(), "No available data sources to load for orchestration.");
Preconditions.checkState(null != dataSourceConfigurations && !dataSourceConfigurations.isEmpty(), "No available data sources to load for governance.");
return new DataSourceChangedEvent(shardingSchemaName, dataSourceConfigurations.entrySet().stream()
.collect(Collectors.toMap(Entry::getKey, entry -> new DataSourceConfigurationYamlSwapper().swapToObject(entry.getValue()))));
}
private OrchestrationEvent createRuleChangedEvent(final String shardingSchemaName, final DataChangedEvent event) {
private GovernanceEvent createRuleChangedEvent(final String shardingSchemaName, final DataChangedEvent event) {
YamlRootRuleConfigurations configurations = YamlEngine.unmarshal(event.getValue(), YamlRootRuleConfigurations.class);
Preconditions.checkState(null != configurations, "No available rule to load for orchestration.");
Preconditions.checkState(null != configurations, "No available rule to load for governance.");
return new RuleConfigurationsChangedEvent(
shardingSchemaName, new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(configurations.getRules()));
}
......@@ -147,7 +147,7 @@ public final class SchemaChangedListener extends PostOrchestrationRepositoryEven
return configurationService.loadRuleConfigurations(shardingSchemaName);
}
private OrchestrationEvent createDeletedEvent(final String shardingSchemaName) {
private GovernanceEvent createDeletedEvent(final String shardingSchemaName) {
existedSchemaNames.remove(shardingSchemaName);
return new SchemaDeletedEvent(shardingSchemaName);
}
......
......@@ -15,7 +15,7 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.config;
package org.apache.shardingsphere.governance.core.config;
import lombok.SneakyThrows;
import org.apache.commons.dbcp2.BasicDataSource;
......@@ -31,7 +31,7 @@ import org.apache.shardingsphere.infra.yaml.config.YamlRootRuleConfigurations;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
import org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration;
import org.apache.shardingsphere.orchestration.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.junit.Test;
......
......@@ -15,13 +15,13 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.config.listener;
package org.apache.shardingsphere.governance.core.config.listener;
import org.apache.shardingsphere.orchestration.core.common.event.OrchestrationEvent;
import org.apache.shardingsphere.orchestration.core.common.event.auth.AuthenticationChangedEvent;
import org.apache.shardingsphere.orchestration.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEvent;
import org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEvent.ChangedType;
import org.apache.shardingsphere.governance.core.common.event.GovernanceEvent;
import org.apache.shardingsphere.governance.core.common.event.auth.AuthenticationChangedEvent;
import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent.ChangedType;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -51,8 +51,8 @@ public final class AuthenticationChangedListenerTest {
}
@Test
public void assertCreateOrchestrationEvent() {
Optional<OrchestrationEvent> actual = authenticationChangedListener.createOrchestrationEvent(new DataChangedEvent("test", AUTHENTICATION_YAML, ChangedType.UPDATED));
public void assertCreateGovernanceEvent() {
Optional<GovernanceEvent> actual = authenticationChangedListener.createGovernanceEvent(new DataChangedEvent("test", AUTHENTICATION_YAML, ChangedType.UPDATED));
assertTrue(actual.isPresent());
assertThat(((AuthenticationChangedEvent) actual.get()).getAuthentication().getUsers().get("root1").getPassword(), is("root1"));
}
......
......@@ -15,11 +15,11 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.config.listener;
package org.apache.shardingsphere.governance.core.config.listener;
import lombok.SneakyThrows;
import org.apache.shardingsphere.orchestration.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEvent.ChangedType;
import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent.ChangedType;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
......
......@@ -15,13 +15,13 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.config.listener;
package org.apache.shardingsphere.governance.core.config.listener;
import org.apache.shardingsphere.orchestration.core.common.event.OrchestrationEvent;
import org.apache.shardingsphere.orchestration.core.common.event.props.PropertiesChangedEvent;
import org.apache.shardingsphere.orchestration.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEvent;
import org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEvent.ChangedType;
import org.apache.shardingsphere.governance.core.common.event.GovernanceEvent;
import org.apache.shardingsphere.governance.core.common.event.props.PropertiesChangedEvent;
import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent.ChangedType;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -50,8 +50,8 @@ public final class PropertiesChangedListenerTest {
}
@Test
public void assertCreateOrchestrationEvent() {
Optional<OrchestrationEvent> actual = propertiesChangedListener.createOrchestrationEvent(new DataChangedEvent("test", PROPERTIES_YAML, ChangedType.UPDATED));
public void assertCreateGovernanceEvent() {
Optional<GovernanceEvent> actual = propertiesChangedListener.createGovernanceEvent(new DataChangedEvent("test", PROPERTIES_YAML, ChangedType.UPDATED));
assertTrue(actual.isPresent());
assertThat(((PropertiesChangedEvent) actual.get()).getProps().get("sql.show"), is(true));
}
......
......@@ -15,21 +15,21 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.config.listener;
package org.apache.shardingsphere.governance.core.config.listener;
import lombok.SneakyThrows;
import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration;
import org.apache.shardingsphere.orchestration.core.common.event.datasource.DataSourceChangedEvent;
import org.apache.shardingsphere.orchestration.core.common.event.OrchestrationEvent;
import org.apache.shardingsphere.orchestration.core.common.event.rule.RuleConfigurationsChangedEvent;
import org.apache.shardingsphere.orchestration.core.common.event.schema.SchemaAddedEvent;
import org.apache.shardingsphere.orchestration.core.common.event.schema.SchemaDeletedEvent;
import org.apache.shardingsphere.orchestration.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEvent;
import org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEvent.ChangedType;
import org.apache.shardingsphere.governance.core.common.event.datasource.DataSourceChangedEvent;
import org.apache.shardingsphere.governance.core.common.event.GovernanceEvent;
import org.apache.shardingsphere.governance.core.common.event.rule.RuleConfigurationsChangedEvent;
import org.apache.shardingsphere.governance.core.common.event.schema.SchemaAddedEvent;
import org.apache.shardingsphere.governance.core.common.event.schema.SchemaDeletedEvent;
import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent.ChangedType;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.junit.Before;
import org.junit.Test;
......@@ -74,15 +74,15 @@ public final class SchemaChangedListenerTest {
@Test
public void assertCreateIgnoredEvent() {
assertFalse(schemaChangedListener.createOrchestrationEvent(new DataChangedEvent("/config/schema/encrypt_db", "test", ChangedType.UPDATED)).isPresent());
assertFalse(schemaChangedListener.createOrchestrationEvent(new DataChangedEvent("/config/schema/encrypt_db/rule", "test", ChangedType.IGNORED)).isPresent());
assertFalse(schemaChangedListener.createGovernanceEvent(new DataChangedEvent("/config/schema/encrypt_db", "test", ChangedType.UPDATED)).isPresent());
assertFalse(schemaChangedListener.createGovernanceEvent(new DataChangedEvent("/config/schema/encrypt_db/rule", "test", ChangedType.IGNORED)).isPresent());
}
@Test
public void assertCreateDataSourceChangedEventForExistedSchema() {
String dataSource = readYAML(DATA_SOURCE_FILE);
DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/sharding_db/datasource", dataSource, ChangedType.UPDATED);
Optional<OrchestrationEvent> actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
Optional<GovernanceEvent> actual = schemaChangedListener.createGovernanceEvent(dataChangedEvent);
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(DataSourceChangedEvent.class));
assertThat(((DataSourceChangedEvent) actual.get()).getSchemaName(), is("sharding_db"));
......@@ -92,7 +92,7 @@ public final class SchemaChangedListenerTest {
public void assertCreateRuleConfigurationsChangedEventForExistedSchema() {
String shardingRule = readYAML(SHARDING_RULE_FILE);
DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/sharding_db/rule", shardingRule, ChangedType.UPDATED);
Optional<OrchestrationEvent> actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
Optional<GovernanceEvent> actual = schemaChangedListener.createGovernanceEvent(dataChangedEvent);
assertTrue(actual.isPresent());
assertThat(((RuleConfigurationsChangedEvent) actual.get()).getSchemaName(), is("sharding_db"));
Collection<RuleConfiguration> ruleConfigurations = ((RuleConfigurationsChangedEvent) actual.get()).getRuleConfigurations();
......@@ -104,7 +104,7 @@ public final class SchemaChangedListenerTest {
public void assertCreateMasterSlaveRuleChangedEventForExistedSchema() {
String masterSlaveRule = readYAML(MASTER_SLAVE_RULE_FILE);
DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/masterslave_db/rule", masterSlaveRule, ChangedType.UPDATED);
Optional<OrchestrationEvent> actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
Optional<GovernanceEvent> actual = schemaChangedListener.createGovernanceEvent(dataChangedEvent);
assertTrue(actual.isPresent());
RuleConfigurationsChangedEvent event = (RuleConfigurationsChangedEvent) actual.get();
assertThat(event.getSchemaName(), is("masterslave_db"));
......@@ -117,7 +117,7 @@ public final class SchemaChangedListenerTest {
public void assertCreateEncryptRuleChangedEventForExistedSchema() {
String encryptRule = readYAML(ENCRYPT_RULE_FILE);
DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/encrypt_db/rule", encryptRule, ChangedType.UPDATED);
Optional<OrchestrationEvent> actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
Optional<GovernanceEvent> actual = schemaChangedListener.createGovernanceEvent(dataChangedEvent);
assertTrue(actual.isPresent());
RuleConfigurationsChangedEvent event = (RuleConfigurationsChangedEvent) actual.get();
assertThat(event.getSchemaName(), is("encrypt_db"));
......@@ -130,10 +130,10 @@ public final class SchemaChangedListenerTest {
}
@Test
public void assertCreateIgnoredOrchestrationEventForNewSchema() {
public void assertCreateIgnoredGovernanceEventForNewSchema() {
when(configurationRepository.get("/config/schema/logic_db/datasource")).thenReturn("");
DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/logic_db/rule", "rule", ChangedType.UPDATED);
Optional<OrchestrationEvent> actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
Optional<GovernanceEvent> actual = schemaChangedListener.createGovernanceEvent(dataChangedEvent);
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(SchemaAddedEvent.class));
}
......@@ -147,7 +147,7 @@ public final class SchemaChangedListenerTest {
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);
Optional<OrchestrationEvent> actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
Optional<GovernanceEvent> actual = schemaChangedListener.createGovernanceEvent(dataChangedEvent);
assertTrue(actual.isPresent());
assertThat(((SchemaAddedEvent) actual.get()).getRuleConfigurations().iterator().next(), instanceOf(ShardingRuleConfiguration.class));
}
......@@ -161,7 +161,7 @@ public final class SchemaChangedListenerTest {
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);
Optional<OrchestrationEvent> actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
Optional<GovernanceEvent> actual = schemaChangedListener.createGovernanceEvent(dataChangedEvent);
assertTrue(actual.isPresent());
assertThat(((SchemaAddedEvent) actual.get()).getRuleConfigurations().iterator().next(), instanceOf(MasterSlaveRuleConfiguration.class));
}
......@@ -175,7 +175,7 @@ public final class SchemaChangedListenerTest {
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);
Optional<OrchestrationEvent> actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
Optional<GovernanceEvent> actual = schemaChangedListener.createGovernanceEvent(dataChangedEvent);
assertTrue(actual.isPresent());
assertThat(((SchemaAddedEvent) actual.get()).getRuleConfigurations().iterator().next(), instanceOf(EncryptRuleConfiguration.class));
}
......@@ -184,7 +184,7 @@ public final class SchemaChangedListenerTest {
public void assertCreateSchemaDeletedEventForNewSchema() {
String dataSource = readYAML(DATA_SOURCE_FILE);
DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/logic_db/datasource", dataSource, ChangedType.DELETED);
Optional<OrchestrationEvent> actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
Optional<GovernanceEvent> actual = schemaChangedListener.createGovernanceEvent(dataChangedEvent);
assertTrue(actual.isPresent());
assertThat(((SchemaDeletedEvent) actual.get()).getSchemaName(), is("logic_db"));
}
......@@ -193,7 +193,7 @@ public final class SchemaChangedListenerTest {
public void assertCreateWithSchemaDeletedEvent() {
String dataSource = readYAML(DATA_SOURCE_FILE);
DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/logic_db", dataSource, ChangedType.DELETED);
Optional<OrchestrationEvent> actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
Optional<GovernanceEvent> actual = schemaChangedListener.createGovernanceEvent(dataChangedEvent);
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(SchemaDeletedEvent.class));
}
......@@ -202,7 +202,7 @@ public final class SchemaChangedListenerTest {
public void assertCreateWithSchemaDeletedEventWithDataSourceNode() {
String dataSource = readYAML(DATA_SOURCE_FILE);
DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/datasource", dataSource, ChangedType.DELETED);
Optional<OrchestrationEvent> actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
Optional<GovernanceEvent> actual = schemaChangedListener.createGovernanceEvent(dataChangedEvent);
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(SchemaDeletedEvent.class));
}
......@@ -214,7 +214,7 @@ public final class SchemaChangedListenerTest {
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);
Optional<OrchestrationEvent> actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
Optional<GovernanceEvent> actual = schemaChangedListener.createGovernanceEvent(dataChangedEvent);
assertTrue(actual.isPresent());
assertThat(((SchemaAddedEvent) actual.get()).getRuleConfigurations().iterator().next(), instanceOf(EncryptRuleConfiguration.class));
}
......@@ -226,7 +226,7 @@ public final class SchemaChangedListenerTest {
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);
Optional<OrchestrationEvent> actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
Optional<GovernanceEvent> actual = schemaChangedListener.createGovernanceEvent(dataChangedEvent);
assertTrue(actual.isPresent());
assertThat(((SchemaAddedEvent) actual.get()).getRuleConfigurations().iterator().next(), instanceOf(ShardingRuleConfiguration.class));
}
......@@ -238,7 +238,7 @@ public final class SchemaChangedListenerTest {
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);
Optional<OrchestrationEvent> actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
Optional<GovernanceEvent> actual = schemaChangedListener.createGovernanceEvent(dataChangedEvent);
assertTrue(actual.isPresent());
assertThat(((SchemaAddedEvent) actual.get()).getRuleConfigurations().iterator().next(), instanceOf(MasterSlaveRuleConfiguration.class));
}
......@@ -246,7 +246,7 @@ public final class SchemaChangedListenerTest {
@Test
public void assertCreateSchemaNamesUpdatedEventForAdd() {
DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema", "sharding_db,masterslave_db,encrypt_db,shadow_db", ChangedType.UPDATED);
Optional<OrchestrationEvent> actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
Optional<GovernanceEvent> actual = schemaChangedListener.createGovernanceEvent(dataChangedEvent);
assertTrue(actual.isPresent());
assertThat(((SchemaAddedEvent) actual.get()).getSchemaName(), is("shadow_db"));
}
......@@ -254,7 +254,7 @@ public final class SchemaChangedListenerTest {
@Test
public void assertCreateSchemaNamesUpdatedEventForDelete() {
DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema", "sharding_db,masterslave_db", ChangedType.UPDATED);
Optional<OrchestrationEvent> actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
Optional<GovernanceEvent> actual = schemaChangedListener.createGovernanceEvent(dataChangedEvent);
assertTrue(actual.isPresent());
assertThat(((SchemaDeletedEvent) actual.get()).getSchemaName(), is("encrypt_db"));
}
......@@ -262,13 +262,13 @@ public final class SchemaChangedListenerTest {
@Test
public void assertCreateSchemaNamesUpdatedEventForIgnore() {
DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema", "sharding_db,masterslave_db,encrypt_db", ChangedType.UPDATED);
assertFalse(schemaChangedListener.createOrchestrationEvent(dataChangedEvent).isPresent());
assertFalse(schemaChangedListener.createGovernanceEvent(dataChangedEvent).isPresent());
}
@Test
public void assertCreateSchemaNameAddEvent() {
DataChangedEvent dataChangedEvent = new DataChangedEvent("/config/schema/shadow_db", "", ChangedType.ADDED);
Optional<OrchestrationEvent> actual = schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
Optional<GovernanceEvent> actual = schemaChangedListener.createGovernanceEvent(dataChangedEvent);
assertTrue(actual.isPresent());
assertThat(((SchemaAddedEvent) actual.get()).getSchemaName(), is("shadow_db"));
}
......
......@@ -15,7 +15,7 @@
# limitations under the License.
#
ds_0: !!org.apache.shardingsphere.orchestration.core.common.yaml.config.YamlDataSourceConfiguration
ds_0: !!org.apache.shardingsphere.governance.core.common.yaml.config.YamlDataSourceConfiguration
dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource
props:
driverClassName: com.mysql.jdbc.Driver
......@@ -25,7 +25,7 @@ ds_0: !!org.apache.shardingsphere.orchestration.core.common.yaml.config.YamlData
connectionInitSqls:
- set names utf8mb4;
- set names utf8;
ds_1: !!org.apache.shardingsphere.orchestration.core.common.yaml.config.YamlDataSourceConfiguration
ds_1: !!org.apache.shardingsphere.governance.core.common.yaml.config.YamlDataSourceConfiguration
dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource
props:
driverClassName: com.mysql.jdbc.Driver
......
......@@ -15,14 +15,14 @@
# limitations under the License.
#
ds_0: !!org.apache.shardingsphere.orchestration.core.common.yaml.config.YamlDataSourceConfiguration
ds_0: !!org.apache.shardingsphere.governance.core.common.yaml.config.YamlDataSourceConfiguration
dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource
props:
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/ds_0
username: root
password: root
ds_1: !!org.apache.shardingsphere.orchestration.core.common.yaml.config.YamlDataSourceConfiguration
ds_1: !!org.apache.shardingsphere.governance.core.common.yaml.config.YamlDataSourceConfiguration
dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource
props:
driverClassName: com.mysql.jdbc.Driver
......
......@@ -15,7 +15,7 @@
# limitations under the License.
#
master_ds: !!org.apache.shardingsphere.orchestration.core.common.yaml.config.YamlDataSourceConfiguration
master_ds: !!org.apache.shardingsphere.governance.core.common.yaml.config.YamlDataSourceConfiguration
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
props:
......
......@@ -20,31 +20,31 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-core</artifactId>
<artifactId>shardingsphere-governance-core</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
<artifactId>shardingsphere-orchestration-core-facade</artifactId>
<artifactId>shardingsphere-governance-core-facade</artifactId>
<name>${project.artifactId}</name>
<dependencies>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-core-config</artifactId>
<artifactId>shardingsphere-governance-core-config</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-core-registry</artifactId>
<artifactId>shardingsphere-governance-core-registry</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-core-metadata</artifactId>
<artifactId>shardingsphere-governance-core-metadata</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-repository-api</artifactId>
<artifactId>shardingsphere-governance-repository-api</artifactId>
<version>${project.version}</version>
</dependency>
......
......@@ -15,7 +15,7 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.facade;
package org.apache.shardingsphere.governance.core.facade;
import lombok.AccessLevel;
import lombok.Getter;
......@@ -23,12 +23,12 @@ import lombok.NoArgsConstructor;
import org.apache.shardingsphere.infra.auth.Authentication;
import org.apache.shardingsphere.infra.config.DataSourceConfiguration;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.orchestration.core.config.ConfigCenter;
import org.apache.shardingsphere.orchestration.core.facade.listener.OrchestrationListenerManager;
import org.apache.shardingsphere.orchestration.core.facade.repository.OrchestrationRepositoryFacade;
import org.apache.shardingsphere.orchestration.core.metadata.MetaDataCenter;
import org.apache.shardingsphere.orchestration.core.registry.RegistryCenter;
import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationConfiguration;
import org.apache.shardingsphere.governance.core.config.ConfigCenter;
import org.apache.shardingsphere.governance.core.facade.listener.GovernanceListenerManager;
import org.apache.shardingsphere.governance.core.facade.repository.GovernanceRepositoryFacade;
import org.apache.shardingsphere.governance.core.metadata.MetaDataCenter;
import org.apache.shardingsphere.governance.core.registry.RegistryCenter;
import org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
import java.util.Collection;
import java.util.Map;
......@@ -36,13 +36,13 @@ import java.util.Map.Entry;
import java.util.Properties;
/**
* Orchestration facade.
* Governance facade.
*/
public final class OrchestrationFacade implements AutoCloseable {
public final class GovernanceFacade implements AutoCloseable {
private boolean isOverwrite;
private OrchestrationRepositoryFacade repositoryFacade;
private GovernanceRepositoryFacade repositoryFacade;
@Getter
private ConfigCenter configCenter;
......@@ -53,21 +53,21 @@ public final class OrchestrationFacade implements AutoCloseable {
@Getter
private MetaDataCenter metaDataCenter;
private OrchestrationListenerManager listenerManager;
private GovernanceListenerManager listenerManager;
/**
* Initialize orchestration facade.
* Initialize governance facade.
*
* @param config orchestration configuration
* @param config governance configuration
* @param schemaNames schema names
*/
public void init(final OrchestrationConfiguration config, final Collection<String> schemaNames) {
public void init(final GovernanceConfiguration config, final Collection<String> schemaNames) {
isOverwrite = config.isOverwrite();
repositoryFacade = new OrchestrationRepositoryFacade(config);
repositoryFacade = new GovernanceRepositoryFacade(config);
registryCenter = new RegistryCenter(repositoryFacade.getRegistryRepository());
configCenter = new ConfigCenter(repositoryFacade.getConfigurationRepository());
metaDataCenter = new MetaDataCenter(repositoryFacade.getConfigurationRepository());
listenerManager = new OrchestrationListenerManager(repositoryFacade.getRegistryRepository(),
listenerManager = new GovernanceListenerManager(repositoryFacade.getRegistryRepository(),
repositoryFacade.getConfigurationRepository(), schemaNames.isEmpty() ? configCenter.getAllSchemaNames() : schemaNames);
}
......@@ -103,17 +103,17 @@ public final class OrchestrationFacade implements AutoCloseable {
}
/**
* Get orchestration facade instance.
* Get governance facade instance.
*
* @return orchestration facade instance
* @return governance facade instance
*/
public static OrchestrationFacade getInstance() {
return OrchestrationFacadeHolder.INSTANCE;
public static GovernanceFacade getInstance() {
return GovernanceFacadeHolder.INSTANCE;
}
@NoArgsConstructor(access = AccessLevel.PRIVATE)
private static final class OrchestrationFacadeHolder {
private static final class GovernanceFacadeHolder {
public static final OrchestrationFacade INSTANCE = new OrchestrationFacade();
public static final GovernanceFacade INSTANCE = new GovernanceFacade();
}
}
......@@ -15,20 +15,20 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.facade.listener;
package org.apache.shardingsphere.governance.core.facade.listener;
import org.apache.shardingsphere.orchestration.core.config.listener.ConfigurationListenerManager;
import org.apache.shardingsphere.orchestration.core.metadata.listener.MetaDataListenerManager;
import org.apache.shardingsphere.orchestration.core.registry.listener.RegistryListenerManager;
import org.apache.shardingsphere.orchestration.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.orchestration.repository.api.RegistryRepository;
import org.apache.shardingsphere.governance.core.config.listener.ConfigurationListenerManager;
import org.apache.shardingsphere.governance.core.metadata.listener.MetaDataListenerManager;
import org.apache.shardingsphere.governance.core.registry.listener.RegistryListenerManager;
import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.governance.repository.api.RegistryRepository;
import java.util.Collection;
/**
* Orchestration listener manager.
* Governance listener manager.
*/
public final class OrchestrationListenerManager {
public final class GovernanceListenerManager {
private final ConfigurationListenerManager configurationListenerManager;
......@@ -36,14 +36,14 @@ public final class OrchestrationListenerManager {
private final MetaDataListenerManager metaDataListenerManager;
public OrchestrationListenerManager(final RegistryRepository registryRepository, final ConfigurationRepository configurationRepository, final Collection<String> schemaNames) {
public GovernanceListenerManager(final RegistryRepository registryRepository, final ConfigurationRepository configurationRepository, final Collection<String> schemaNames) {
configurationListenerManager = new ConfigurationListenerManager(configurationRepository, schemaNames);
registryListenerManager = new RegistryListenerManager(registryRepository);
metaDataListenerManager = new MetaDataListenerManager(configurationRepository, schemaNames);
}
/**
* Initialize all orchestration listeners.
* Initialize all governance listeners.
*/
public void init() {
configurationListenerManager.initListeners();
......
......@@ -15,22 +15,22 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.facade.repository;
package org.apache.shardingsphere.governance.core.facade.repository;
import com.google.common.base.Preconditions;
import lombok.Getter;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.type.TypedSPIRegistry;
import org.apache.shardingsphere.orchestration.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.orchestration.repository.api.RegistryRepository;
import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationCenterConfiguration;
import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationConfiguration;
import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.governance.repository.api.RegistryRepository;
import org.apache.shardingsphere.governance.repository.api.config.GovernanceCenterConfiguration;
import org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
/**
* Orchestration repository facade.
* Governance repository facade.
*/
@Getter
public final class OrchestrationRepositoryFacade implements AutoCloseable {
public final class GovernanceRepositoryFacade implements AutoCloseable {
static {
ShardingSphereServiceLoader.register(RegistryRepository.class);
......@@ -41,22 +41,22 @@ public final class OrchestrationRepositoryFacade implements AutoCloseable {
private final ConfigurationRepository configurationRepository;
public OrchestrationRepositoryFacade(final OrchestrationConfiguration config) {
public GovernanceRepositoryFacade(final GovernanceConfiguration config) {
registryRepository = createRegistryRepository(config);
configurationRepository = createConfigurationRepository(config);
}
private RegistryRepository createRegistryRepository(final OrchestrationConfiguration config) {
OrchestrationCenterConfiguration registryCenterConfig = config.getRegistryCenterConfiguration();
private RegistryRepository createRegistryRepository(final GovernanceConfiguration config) {
GovernanceCenterConfiguration registryCenterConfig = config.getRegistryCenterConfiguration();
Preconditions.checkNotNull(registryCenterConfig, "Registry center configuration cannot be null.");
RegistryRepository result = TypedSPIRegistry.getRegisteredService(RegistryRepository.class, registryCenterConfig.getType(), registryCenterConfig.getProps());
result.init(config.getName(), registryCenterConfig);
return result;
}
private ConfigurationRepository createConfigurationRepository(final OrchestrationConfiguration config) {
private ConfigurationRepository createConfigurationRepository(final GovernanceConfiguration config) {
if (config.getAdditionalConfigCenterConfiguration().isPresent()) {
OrchestrationCenterConfiguration additionalConfigCenterConfig = config.getAdditionalConfigCenterConfiguration().get();
GovernanceCenterConfiguration additionalConfigCenterConfig = config.getAdditionalConfigCenterConfiguration().get();
ConfigurationRepository result = TypedSPIRegistry.getRegisteredService(ConfigurationRepository.class, additionalConfigCenterConfig.getType(), additionalConfigCenterConfig.getProps());
result.init(config.getName(), additionalConfigCenterConfig);
return result;
......
......@@ -15,20 +15,20 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.facade;
package org.apache.shardingsphere.governance.core.facade;
import org.apache.shardingsphere.infra.auth.Authentication;
import org.apache.shardingsphere.infra.auth.ProxyUser;
import org.apache.shardingsphere.infra.config.DataSourceConfiguration;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.orchestration.core.config.ConfigCenter;
import org.apache.shardingsphere.orchestration.core.facade.listener.OrchestrationListenerManager;
import org.apache.shardingsphere.orchestration.core.facade.repository.OrchestrationRepositoryFacade;
import org.apache.shardingsphere.orchestration.core.facade.util.FieldUtil;
import org.apache.shardingsphere.orchestration.core.metadata.MetaDataCenter;
import org.apache.shardingsphere.orchestration.core.registry.RegistryCenter;
import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationCenterConfiguration;
import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationConfiguration;
import org.apache.shardingsphere.governance.core.config.ConfigCenter;
import org.apache.shardingsphere.governance.core.facade.listener.GovernanceListenerManager;
import org.apache.shardingsphere.governance.core.facade.repository.GovernanceRepositoryFacade;
import org.apache.shardingsphere.governance.core.facade.util.FieldUtil;
import org.apache.shardingsphere.governance.core.metadata.MetaDataCenter;
import org.apache.shardingsphere.governance.core.registry.RegistryCenter;
import org.apache.shardingsphere.governance.repository.api.config.GovernanceCenterConfiguration;
import org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -45,12 +45,12 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@RunWith(MockitoJUnitRunner.class)
public final class OrchestrationFacadeTest {
public final class GovernanceFacadeTest {
private final OrchestrationFacade orchestrationFacade = OrchestrationFacade.getInstance();
private final GovernanceFacade governanceFacade = GovernanceFacade.getInstance();
@Mock
private OrchestrationRepositoryFacade repositoryFacade;
private GovernanceRepositoryFacade repositoryFacade;
@Mock
private ConfigCenter configCenter;
......@@ -62,17 +62,17 @@ public final class OrchestrationFacadeTest {
private MetaDataCenter metaDataCenter;
@Mock
private OrchestrationListenerManager listenerManager;
private GovernanceListenerManager listenerManager;
@Before
public void setUp() {
OrchestrationConfiguration orchestrationConfiguration = new OrchestrationConfiguration("test_name", new OrchestrationCenterConfiguration("ALL", "127.0.0.1", new Properties()), false);
orchestrationFacade.init(orchestrationConfiguration, Arrays.asList("sharding_db", "masterslave_db"));
FieldUtil.setField(orchestrationFacade, "repositoryFacade", repositoryFacade);
FieldUtil.setField(orchestrationFacade, "configCenter", configCenter);
FieldUtil.setField(orchestrationFacade, "registryCenter", registryCenter);
FieldUtil.setField(orchestrationFacade, "metaDataCenter", metaDataCenter);
FieldUtil.setField(orchestrationFacade, "listenerManager", listenerManager);
GovernanceConfiguration governanceConfiguration = new GovernanceConfiguration("test_name", new GovernanceCenterConfiguration("ALL", "127.0.0.1", new Properties()), false);
governanceFacade.init(governanceConfiguration, Arrays.asList("sharding_db", "masterslave_db"));
FieldUtil.setField(governanceFacade, "repositoryFacade", repositoryFacade);
FieldUtil.setField(governanceFacade, "configCenter", configCenter);
FieldUtil.setField(governanceFacade, "registryCenter", registryCenter);
FieldUtil.setField(governanceFacade, "metaDataCenter", metaDataCenter);
FieldUtil.setField(governanceFacade, "listenerManager", listenerManager);
}
@Test
......@@ -83,7 +83,7 @@ public final class OrchestrationFacadeTest {
Authentication authentication = new Authentication();
authentication.getUsers().put("root", proxyUser);
Properties props = new Properties();
orchestrationFacade.onlineInstance(Collections.singletonMap("sharding_db", dataSourceConfigurationMap), ruleConfigurationMap, authentication, props);
governanceFacade.onlineInstance(Collections.singletonMap("sharding_db", dataSourceConfigurationMap), ruleConfigurationMap, authentication, props);
verify(configCenter).persistConfigurations("sharding_db", dataSourceConfigurationMap, ruleConfigurationMap.get("sharding_db"), false);
verify(configCenter).persistGlobalConfiguration(authentication, props, false);
verify(registryCenter).persistInstanceOnline();
......@@ -93,7 +93,7 @@ public final class OrchestrationFacadeTest {
@Test
public void assertOnlineInstanceWithoutParameters() {
orchestrationFacade.onlineInstance();
governanceFacade.onlineInstance();
verify(registryCenter).persistInstanceOnline();
verify(registryCenter).persistDataSourcesNode();
verify(listenerManager).init();
......@@ -101,7 +101,7 @@ public final class OrchestrationFacadeTest {
@Test
public void assertClose() {
orchestrationFacade.close();
governanceFacade.close();
verify(repositoryFacade).close();
}
}
......@@ -15,14 +15,14 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.facade.fixture;
package org.apache.shardingsphere.governance.core.facade.fixture;
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.orchestration.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.orchestration.repository.api.RegistryRepository;
import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationCenterConfiguration;
import org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEventListener;
import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.governance.repository.api.RegistryRepository;
import org.apache.shardingsphere.governance.repository.api.config.GovernanceCenterConfiguration;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEventListener;
import java.util.Collections;
import java.util.List;
......@@ -35,7 +35,7 @@ public final class TestAllRepository implements RegistryRepository, Configuratio
private Properties props = new Properties();
@Override
public void init(final String name, final OrchestrationCenterConfiguration config) {
public void init(final String name, final GovernanceCenterConfiguration config) {
}
@Override
......
......@@ -15,13 +15,13 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.facade.fixture;
package org.apache.shardingsphere.governance.core.facade.fixture;
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.orchestration.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEventListener;
import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationCenterConfiguration;
import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEventListener;
import org.apache.shardingsphere.governance.repository.api.config.GovernanceCenterConfiguration;
import java.util.Collections;
import java.util.List;
......@@ -34,7 +34,7 @@ public final class TestConfigurationRepository implements ConfigurationRepositor
private Properties props = new Properties();
@Override
public void init(final String name, final OrchestrationCenterConfiguration config) {
public void init(final String name, final GovernanceCenterConfiguration config) {
}
@Override
......
......@@ -15,13 +15,13 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.facade.fixture;
package org.apache.shardingsphere.governance.core.facade.fixture;
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.orchestration.repository.api.RegistryRepository;
import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationCenterConfiguration;
import org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEventListener;
import org.apache.shardingsphere.governance.repository.api.RegistryRepository;
import org.apache.shardingsphere.governance.repository.api.config.GovernanceCenterConfiguration;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEventListener;
import java.util.Collections;
import java.util.List;
......@@ -34,7 +34,7 @@ public final class TestRegistryRepository implements RegistryRepository {
private Properties props = new Properties();
@Override
public void init(final String name, final OrchestrationCenterConfiguration config) {
public void init(final String name, final GovernanceCenterConfiguration config) {
}
@Override
......
......@@ -15,14 +15,14 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.facade.listener;
package org.apache.shardingsphere.governance.core.facade.listener;
import org.apache.shardingsphere.orchestration.core.config.listener.ConfigurationListenerManager;
import org.apache.shardingsphere.orchestration.core.facade.util.FieldUtil;
import org.apache.shardingsphere.orchestration.core.metadata.listener.MetaDataListenerManager;
import org.apache.shardingsphere.orchestration.core.registry.listener.RegistryListenerManager;
import org.apache.shardingsphere.orchestration.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.orchestration.repository.api.RegistryRepository;
import org.apache.shardingsphere.governance.core.config.listener.ConfigurationListenerManager;
import org.apache.shardingsphere.governance.core.facade.util.FieldUtil;
import org.apache.shardingsphere.governance.core.metadata.listener.MetaDataListenerManager;
import org.apache.shardingsphere.governance.core.registry.listener.RegistryListenerManager;
import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.governance.repository.api.RegistryRepository;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
......@@ -33,7 +33,7 @@ import java.util.Collections;
import static org.mockito.Mockito.verify;
@RunWith(MockitoJUnitRunner.class)
public final class OrchestrationListenerManagerTest {
public final class GovernanceListenerManagerTest {
@Mock
private RegistryRepository registryRepository;
......@@ -52,7 +52,7 @@ public final class OrchestrationListenerManagerTest {
@Test
public void assertInit() {
OrchestrationListenerManager actual = new OrchestrationListenerManager(registryRepository, configurationRepository, Collections.emptyList());
GovernanceListenerManager actual = new GovernanceListenerManager(registryRepository, configurationRepository, Collections.emptyList());
FieldUtil.setField(actual, "configurationListenerManager", configurationListenerManager);
FieldUtil.setField(actual, "registryListenerManager", registryListenerManager);
FieldUtil.setField(actual, "metaDataListenerManager", metaDataListenerManager);
......
......@@ -15,14 +15,14 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.facade.repository;
package org.apache.shardingsphere.governance.core.facade.repository;
import org.apache.shardingsphere.orchestration.core.facade.fixture.TestAllRepository;
import org.apache.shardingsphere.orchestration.core.facade.util.FieldUtil;
import org.apache.shardingsphere.orchestration.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.orchestration.repository.api.RegistryRepository;
import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationCenterConfiguration;
import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationConfiguration;
import org.apache.shardingsphere.governance.core.facade.fixture.TestAllRepository;
import org.apache.shardingsphere.governance.core.facade.util.FieldUtil;
import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.governance.repository.api.RegistryRepository;
import org.apache.shardingsphere.governance.repository.api.config.GovernanceCenterConfiguration;
import org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
import org.junit.Test;
import java.util.Properties;
......@@ -33,31 +33,31 @@ import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
public final class OrchestrationRepositoryFacadeTest {
public final class GovernanceRepositoryFacadeTest {
@Test
public void assertNewWithoutAdditionalConfigurationRepository() {
OrchestrationRepositoryFacade actual = new OrchestrationRepositoryFacade(
new OrchestrationConfiguration("test", new OrchestrationCenterConfiguration("ALL", "127.0.0.1:8888", new Properties()), true));
GovernanceRepositoryFacade actual = new GovernanceRepositoryFacade(
new GovernanceConfiguration("test", new GovernanceCenterConfiguration("ALL", "127.0.0.1:8888", new Properties()), true));
assertThat(actual.getRegistryRepository(), is(actual.getConfigurationRepository()));
}
@Test
public void assertNewWithAdditionalConfigurationRepository() {
OrchestrationRepositoryFacade actual = new OrchestrationRepositoryFacade(new OrchestrationConfiguration("test",
new OrchestrationCenterConfiguration("ALL", "127.0.0.1:8888", new Properties()), new OrchestrationCenterConfiguration("CONFIG", "127.0.0.1:9999", new Properties()), true));
GovernanceRepositoryFacade actual = new GovernanceRepositoryFacade(new GovernanceConfiguration("test",
new GovernanceCenterConfiguration("ALL", "127.0.0.1:8888", new Properties()), new GovernanceCenterConfiguration("CONFIG", "127.0.0.1:9999", new Properties()), true));
assertThat(actual.getRegistryRepository(), not(actual.getConfigurationRepository()));
}
@Test(expected = IllegalArgumentException.class)
public void assertNewWithoutAdditionalConfigurationRepositoryAndInvalidRegistryRepository() {
new OrchestrationRepositoryFacade(new OrchestrationConfiguration("test", new OrchestrationCenterConfiguration("REG", "127.0.0.1:8888", new Properties()), true));
new GovernanceRepositoryFacade(new GovernanceConfiguration("test", new GovernanceCenterConfiguration("REG", "127.0.0.1:8888", new Properties()), true));
}
@Test
public void assertCloseWithoutAdditionalConfigurationRepository() {
OrchestrationRepositoryFacade actual = new OrchestrationRepositoryFacade(
new OrchestrationConfiguration("test", new OrchestrationCenterConfiguration("ALL", "127.0.0.1:8888", new Properties()), true));
GovernanceRepositoryFacade actual = new GovernanceRepositoryFacade(
new GovernanceConfiguration("test", new GovernanceCenterConfiguration("ALL", "127.0.0.1:8888", new Properties()), true));
TestAllRepository repository = mock(TestAllRepository.class);
FieldUtil.setField(actual, "registryRepository", repository);
FieldUtil.setField(actual, "configurationRepository", repository);
......@@ -67,8 +67,8 @@ public final class OrchestrationRepositoryFacadeTest {
@Test
public void assertCloseWithAdditionalConfigurationRepository() {
OrchestrationRepositoryFacade actual = new OrchestrationRepositoryFacade(new OrchestrationConfiguration("test",
new OrchestrationCenterConfiguration("ALL", "127.0.0.1:8888", new Properties()), new OrchestrationCenterConfiguration("CONFIG", "127.0.0.1:9999", new Properties()), true));
GovernanceRepositoryFacade actual = new GovernanceRepositoryFacade(new GovernanceConfiguration("test",
new GovernanceCenterConfiguration("ALL", "127.0.0.1:8888", new Properties()), new GovernanceCenterConfiguration("CONFIG", "127.0.0.1:9999", new Properties()), true));
RegistryRepository registryRepository = mock(RegistryRepository.class);
ConfigurationRepository configurationRepository = mock(ConfigurationRepository.class);
FieldUtil.setField(actual, "registryRepository", registryRepository);
......
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
org.apache.shardingsphere.governance.core.facade.fixture.TestConfigurationRepository
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
org.apache.shardingsphere.governance.core.facade.fixture.TestRegistryRepository
org.apache.shardingsphere.governance.core.facade.fixture.TestAllRepository
......@@ -20,21 +20,21 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-core</artifactId>
<artifactId>shardingsphere-governance-core</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
<artifactId>shardingsphere-orchestration-core-metadata</artifactId>
<artifactId>shardingsphere-governance-core-metadata</artifactId>
<name>${project.artifactId}</name>
<dependencies>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-core-common</artifactId>
<artifactId>shardingsphere-governance-core-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-orchestration-repository-api</artifactId>
<artifactId>shardingsphere-governance-repository-api</artifactId>
<version>${project.version}</version>
</dependency>
......
......@@ -15,13 +15,13 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.metadata;
package org.apache.shardingsphere.governance.core.metadata;
import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.callback.orchestration.MetaDataCallback;
import org.apache.shardingsphere.orchestration.repository.api.OrchestrationRepository;
import org.apache.shardingsphere.orchestration.core.metadata.yaml.RuleSchemaMetaDataYamlSwapper;
import org.apache.shardingsphere.orchestration.core.metadata.yaml.YamlRuleSchemaMetaData;
import org.apache.shardingsphere.infra.callback.governance.MetaDataCallback;
import org.apache.shardingsphere.governance.repository.api.GovernanceRepository;
import org.apache.shardingsphere.governance.core.metadata.yaml.RuleSchemaMetaDataYamlSwapper;
import org.apache.shardingsphere.governance.core.metadata.yaml.YamlRuleSchemaMetaData;
import org.apache.shardingsphere.infra.metadata.schema.RuleSchemaMetaData;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
......@@ -34,11 +34,11 @@ public final class MetaDataCenter {
private final MetaDataCenterNode node;
private final OrchestrationRepository repository;
private final GovernanceRepository repository;
public MetaDataCenter(final OrchestrationRepository orchestrationRepository) {
public MetaDataCenter(final GovernanceRepository governanceRepository) {
node = new MetaDataCenterNode();
repository = orchestrationRepository;
repository = governanceRepository;
MetaDataCallback.getInstance().register(this::persistMetaDataCenterNode);
}
......
......@@ -15,11 +15,11 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.metadata.event;
package org.apache.shardingsphere.governance.core.metadata.event;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.orchestration.core.common.event.OrchestrationEvent;
import org.apache.shardingsphere.governance.core.common.event.GovernanceEvent;
import org.apache.shardingsphere.infra.metadata.schema.RuleSchemaMetaData;
import java.util.Collection;
......@@ -29,7 +29,7 @@ import java.util.Collection;
*/
@RequiredArgsConstructor
@Getter
public final class MetaDataChangedEvent implements OrchestrationEvent {
public final class MetaDataChangedEvent implements GovernanceEvent {
private final Collection<String> schemaNames;
......
......@@ -15,16 +15,16 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.metadata.listener;
package org.apache.shardingsphere.governance.core.metadata.listener;
import org.apache.shardingsphere.orchestration.core.metadata.event.MetaDataChangedEvent;
import org.apache.shardingsphere.orchestration.repository.api.OrchestrationRepository;
import org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEvent;
import org.apache.shardingsphere.orchestration.core.common.event.OrchestrationEvent;
import org.apache.shardingsphere.orchestration.core.common.listener.PostOrchestrationRepositoryEventListener;
import org.apache.shardingsphere.orchestration.core.metadata.yaml.RuleSchemaMetaDataYamlSwapper;
import org.apache.shardingsphere.orchestration.core.metadata.MetaDataCenterNode;
import org.apache.shardingsphere.orchestration.core.metadata.yaml.YamlRuleSchemaMetaData;
import org.apache.shardingsphere.governance.core.metadata.event.MetaDataChangedEvent;
import org.apache.shardingsphere.governance.repository.api.GovernanceRepository;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent;
import org.apache.shardingsphere.governance.core.common.event.GovernanceEvent;
import org.apache.shardingsphere.governance.core.common.listener.PostGovernanceRepositoryEventListener;
import org.apache.shardingsphere.governance.core.metadata.yaml.RuleSchemaMetaDataYamlSwapper;
import org.apache.shardingsphere.governance.core.metadata.MetaDataCenterNode;
import org.apache.shardingsphere.governance.core.metadata.yaml.YamlRuleSchemaMetaData;
import org.apache.shardingsphere.infra.metadata.schema.RuleSchemaMetaData;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
......@@ -34,17 +34,17 @@ import java.util.Optional;
/**
* Meta data changed listener.
*/
public final class MetaDataChangedListener extends PostOrchestrationRepositoryEventListener {
public final class MetaDataChangedListener extends PostGovernanceRepositoryEventListener {
private final Collection<String> schemaNames;
public MetaDataChangedListener(final OrchestrationRepository orchestrationRepository, final Collection<String> schemaNames) {
super(orchestrationRepository, new MetaDataCenterNode().getAllSchemaMetadataPaths(schemaNames));
public MetaDataChangedListener(final GovernanceRepository governanceRepository, final Collection<String> schemaNames) {
super(governanceRepository, new MetaDataCenterNode().getAllSchemaMetadataPaths(schemaNames));
this.schemaNames = schemaNames;
}
@Override
protected Optional<OrchestrationEvent> createOrchestrationEvent(final DataChangedEvent event) {
protected Optional<GovernanceEvent> createGovernanceEvent(final DataChangedEvent event) {
RuleSchemaMetaData ruleSchemaMetaData = new RuleSchemaMetaDataYamlSwapper().swapToObject(YamlEngine.unmarshal(event.getValue(), YamlRuleSchemaMetaData.class));
return Optional.of(new MetaDataChangedEvent(schemaNames, ruleSchemaMetaData));
}
......
......@@ -15,10 +15,10 @@
* limitations under the License.
*/
package org.apache.shardingsphere.orchestration.core.metadata.listener;
package org.apache.shardingsphere.governance.core.metadata.listener;
import org.apache.shardingsphere.orchestration.repository.api.OrchestrationRepository;
import org.apache.shardingsphere.orchestration.repository.api.listener.DataChangedEvent.ChangedType;
import org.apache.shardingsphere.governance.repository.api.GovernanceRepository;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent.ChangedType;
import java.util.Collection;
......@@ -29,8 +29,8 @@ public final class MetaDataListenerManager {
private final MetaDataChangedListener metaDataChangedListener;
public MetaDataListenerManager(final OrchestrationRepository orchestrationRepository, final Collection<String> schemaNames) {
metaDataChangedListener = new MetaDataChangedListener(orchestrationRepository, schemaNames);
public MetaDataListenerManager(final GovernanceRepository governanceRepository, final Collection<String> schemaNames) {
metaDataChangedListener = new MetaDataChangedListener(governanceRepository, schemaNames);
}
/**
......
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册