-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initialize config server module. * Initialize config server module. * Add TypeBasedSPI dependency. * Modify Config Center related. * Add Config Center Zookeeper related. * Modify CuratorZookeeperConfigCenter and format pom.xml. * Add Integration Test for Registry Center and Config Center. * Modify Integration Test for Registry Center. * Modify Config Center related functions. * Modify Config Center related functions. * Modify pom.xml. * Modify services org.apache.shardingsphere.orchestration.config.api.ConfigCenter * Modify pom.xml file. * Add Unit test cases. * format java file. * Add Unit Test for ConfigCenterServiceLoader. * Modify ConfigCenter.
- Loading branch information
1 parent
f69444d
commit 7d84bb5
Showing
21 changed files
with
1,314 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
sharding-orchestration/sharding-orchestration-config/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?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> | ||
<artifactId>sharding-orchestration</artifactId> | ||
<groupId>org.apache.shardingsphere</groupId> | ||
<version>4.0.0-RC3-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>sharding-orchestration-config</artifactId> | ||
<name>${project.artifactId}</name> | ||
<packaging>pom</packaging> | ||
|
||
<modules> | ||
<module>sharding-orchestration-config-api</module> | ||
<module>sharding-orchestration-config-zookeeper-curator</module> | ||
</modules> | ||
</project> |
38 changes: 38 additions & 0 deletions
38
...ing-orchestration/sharding-orchestration-config/sharding-orchestration-config-api/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?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> | ||
<artifactId>sharding-orchestration-config</artifactId> | ||
<groupId>org.apache.shardingsphere</groupId> | ||
<version>4.0.0-RC3-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>sharding-orchestration-config-api</artifactId> | ||
<name>${project.artifactId}</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.shardingsphere</groupId> | ||
<artifactId>sharding-core-api</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
111 changes: 111 additions & 0 deletions
111
...ig-api/src/main/java/org/apache/shardingsphere/orchestration/config/api/ConfigCenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.shardingsphere.orchestration.config.api; | ||
|
||
import org.apache.shardingsphere.orchestration.config.listener.DataChangedEventListener; | ||
import org.apache.shardingsphere.spi.TypeBasedSPI; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Config center. | ||
* | ||
* @author wangguangyuan | ||
*/ | ||
public interface ConfigCenter extends TypeBasedSPI { | ||
|
||
/** | ||
* Initialize config center. | ||
* | ||
* @param config config center configuration | ||
*/ | ||
void init(ConfigCenterConfiguration config); | ||
|
||
/** | ||
* Get data from config center. | ||
* | ||
* <p>Maybe use cache if existed.</p> | ||
* | ||
* @param key key of data | ||
* @return value of data | ||
*/ | ||
String get(String key); | ||
|
||
/** | ||
* Get data from config center directly. | ||
* | ||
* <p>Cannot use cache.</p> | ||
* | ||
* @param key key of data | ||
* @return value of data | ||
*/ | ||
String getDirectly(String key); | ||
|
||
/** | ||
* Judge data is existed or not. | ||
* | ||
* @param key key of data | ||
* @return data is existed or not | ||
*/ | ||
boolean isExisted(String key); | ||
|
||
/** | ||
* Get node's sub-nodes list. | ||
* | ||
* @param key key of data | ||
* @return sub-nodes name list | ||
*/ | ||
List<String> getChildrenKeys(String key); | ||
|
||
/** | ||
* Persist data. | ||
* | ||
* @param key key of data | ||
* @param value value of data | ||
*/ | ||
void persist(String key, String value); | ||
|
||
/** | ||
* Update data. | ||
* | ||
* @param key key of data | ||
* @param value value of data | ||
*/ | ||
void update(String key, String value); | ||
|
||
/** | ||
* Persist ephemeral data. | ||
* | ||
* @param key key of data | ||
* @param value value of data | ||
*/ | ||
void persistEphemeral(String key, String value); | ||
|
||
/** | ||
* Watch key or path of the config server. | ||
* | ||
* @param key key of data | ||
* @param dataChangedEventListener data changed event listener | ||
*/ | ||
void watch(String key, DataChangedEventListener dataChangedEventListener); | ||
|
||
/** | ||
* Close. | ||
*/ | ||
void close(); | ||
} |
77 changes: 77 additions & 0 deletions
77
...in/java/org/apache/shardingsphere/orchestration/config/api/ConfigCenterConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.shardingsphere.orchestration.config.api; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.apache.shardingsphere.api.config.TypeBasedSPIConfiguration; | ||
|
||
import java.util.Properties; | ||
|
||
/** | ||
* Config center configuration. | ||
* | ||
* @author wangguangyuan | ||
*/ | ||
@Getter | ||
@Setter | ||
public final class ConfigCenterConfiguration extends TypeBasedSPIConfiguration { | ||
|
||
/** | ||
* Server list of config center. | ||
*/ | ||
private String serverLists; | ||
|
||
/** | ||
* Namespace of config center. | ||
*/ | ||
private String namespace; | ||
|
||
/** | ||
* Digest of config center. | ||
*/ | ||
private String digest; | ||
|
||
/** | ||
* Operation timeout time in milliseconds. | ||
*/ | ||
private int operationTimeoutMilliseconds = 500; | ||
|
||
/** | ||
* Max number of times to retry. | ||
*/ | ||
private int maxRetries = 3; | ||
|
||
/** | ||
* Time interval in milliseconds on each retry. | ||
*/ | ||
private int retryIntervalMilliseconds = 500; | ||
|
||
/** | ||
* Time to live in seconds of ephemeral keys. | ||
*/ | ||
private int timeToLiveSeconds = 60; | ||
|
||
public ConfigCenterConfiguration(final String type) { | ||
super(type); | ||
} | ||
|
||
public ConfigCenterConfiguration(final String type, final Properties properties) { | ||
super(type, properties); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
.../java/org/apache/shardingsphere/orchestration/config/exception/ConfigCenterException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.shardingsphere.orchestration.config.exception; | ||
|
||
/** | ||
* Config center exception. | ||
* | ||
* @author wangguangyuan | ||
*/ | ||
public final class ConfigCenterException extends RuntimeException { | ||
|
||
private static final long serialVersionUID = -6417179023552012152L; | ||
|
||
public ConfigCenterException(final String errorMessage, final Object... args) { | ||
super(String.format(errorMessage, args)); | ||
} | ||
|
||
public ConfigCenterException(final Exception cause) { | ||
super(cause); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...c/main/java/org/apache/shardingsphere/orchestration/config/listener/DataChangedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.shardingsphere.orchestration.config.listener; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
/** | ||
* Data changed event. | ||
* | ||
* @author wangguangyuan | ||
*/ | ||
@RequiredArgsConstructor | ||
@Getter | ||
public final class DataChangedEvent { | ||
|
||
private final String key; | ||
|
||
private final String value; | ||
|
||
private final ChangedType changedType; | ||
|
||
/** | ||
* Data changed type. | ||
*/ | ||
public enum ChangedType { | ||
|
||
UPDATED, DELETED, IGNORED | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...ava/org/apache/shardingsphere/orchestration/config/listener/DataChangedEventListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.shardingsphere.orchestration.config.listener; | ||
|
||
/** | ||
* Listener for data changed event. | ||
* | ||
* @author wangguangyuan | ||
*/ | ||
public interface DataChangedEventListener { | ||
|
||
/** | ||
* Fire when data changed. | ||
* | ||
* @param dataChangedEvent data changed event | ||
*/ | ||
void onChange(DataChangedEvent dataChangedEvent); | ||
} |
Oops, something went wrong.