-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add sharding-orchestration-center module in Orchestration 5.x (#3468)
* Add distributed lock center module * In distributed lock center module, modify code style. * Add sharding-orchestration-center. * modify META-INF.services files in sharding-orchestration-center.
- Loading branch information
1 parent
34c0d0e
commit b2a1930
Showing
16 changed files
with
1,106 additions
and
0 deletions.
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
59 changes: 59 additions & 0 deletions
59
sharding-orchestration/sharding-orchestration-center/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,59 @@ | ||
<?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-center</artifactId> | ||
<name>${project.artifactId}</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.shardingsphere</groupId> | ||
<artifactId>sharding-core-api</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.shardingsphere</groupId> | ||
<artifactId>sharding-orchestration-reg-api</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.curator</groupId> | ||
<artifactId>curator-framework</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.curator</groupId> | ||
<artifactId>curator-client</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.curator</groupId> | ||
<artifactId>curator-recipes</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.curator</groupId> | ||
<artifactId>curator-test</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
81 changes: 81 additions & 0 deletions
81
...center/src/main/java/org/apache/shardingsphere/orchestration/center/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,81 @@ | ||
/* | ||
* 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.center.api; | ||
|
||
import org.apache.shardingsphere.orchestration.center.configuration.OrchestrationConfiguration; | ||
import org.apache.shardingsphere.orchestration.center.listener.DataChangedEventListener; | ||
import org.apache.shardingsphere.spi.TypeBasedSPI; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Config center. | ||
* | ||
* @author zhangliang | ||
* @author sunbufu | ||
* @author dongzonglei | ||
* @author wangguangyuan | ||
*/ | ||
public interface ConfigCenter extends TypeBasedSPI { | ||
|
||
/** | ||
* Initialize config center. | ||
* | ||
* @param config config center configuration | ||
*/ | ||
void init(OrchestrationConfiguration 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 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); | ||
|
||
/** | ||
* 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(); | ||
} |
82 changes: 82 additions & 0 deletions
82
...in/java/org/apache/shardingsphere/orchestration/center/api/DistributedLockManagement.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,82 @@ | ||
/* | ||
* 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.center.api; | ||
|
||
import org.apache.shardingsphere.orchestration.center.configuration.OrchestrationConfiguration; | ||
import org.apache.shardingsphere.spi.TypeBasedSPI; | ||
|
||
/** | ||
* Distributed Lock center. | ||
* | ||
* @author zhangliang | ||
* @author sunbufu | ||
* @author dongzonglei | ||
* @author wangguangyuan | ||
*/ | ||
public interface DistributedLockManagement extends TypeBasedSPI { | ||
|
||
/** | ||
* Initialize distributed lock center. | ||
* | ||
* @param config distributed lock center configuration | ||
*/ | ||
void init(OrchestrationConfiguration config); | ||
|
||
/** | ||
* Get data from distributed lock center. | ||
* | ||
* <p>Maybe use cache if existed.</p> | ||
* | ||
* @param key key of data | ||
* @return value of data | ||
*/ | ||
String get(String key); | ||
|
||
/** | ||
* Persist data. | ||
* | ||
* @param key key of data | ||
* @param value value of data | ||
*/ | ||
void persist(String key, String value); | ||
|
||
/** | ||
* Close. | ||
*/ | ||
void close(); | ||
|
||
/** | ||
* Initialize the lock of the key. | ||
* | ||
* @param key key of data | ||
*/ | ||
void initLock(String key); | ||
|
||
/** | ||
* Try to get the lock of the key. | ||
* | ||
* @return get the lock or not | ||
*/ | ||
boolean tryLock(); | ||
|
||
/** | ||
* Try to release the lock of the key. | ||
* | ||
*/ | ||
void tryRelease(); | ||
} |
90 changes: 90 additions & 0 deletions
90
...nter/src/main/java/org/apache/shardingsphere/orchestration/center/api/RegistryCenter.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,90 @@ | ||
/* | ||
* 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.center.api; | ||
|
||
import org.apache.shardingsphere.orchestration.center.configuration.OrchestrationConfiguration; | ||
import org.apache.shardingsphere.orchestration.center.listener.DataChangedEventListener; | ||
import org.apache.shardingsphere.spi.TypeBasedSPI; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Registry center. | ||
* | ||
* @author zhangliang | ||
* @author zhaojun | ||
* @author sunbufu | ||
* @author dongzonglei | ||
* @author wangguangyuan | ||
*/ | ||
public interface RegistryCenter extends TypeBasedSPI { | ||
|
||
/** | ||
* Initialize registry center. | ||
* | ||
* @param config registry center configuration | ||
*/ | ||
void init(OrchestrationConfiguration config); | ||
|
||
/** | ||
* Get data from registry center. | ||
* | ||
* <p>Maybe use cache if existed.</p> | ||
* | ||
* @param key key of data | ||
* @return value of data | ||
*/ | ||
String get(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); | ||
|
||
/** | ||
* 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 registry. | ||
* | ||
* @param key key of data | ||
* @param dataChangedEventListener data changed event listener | ||
*/ | ||
void watch(String key, DataChangedEventListener dataChangedEventListener); | ||
|
||
/** | ||
* Close. | ||
*/ | ||
void close(); | ||
} |
Oops, something went wrong.