Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sharding-orchestration-center module in Orchestration 5.x #3468

Merged
merged 5 commits into from
Nov 7, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sharding-orchestration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@
<module>sharding-orchestration-zookeeper-curator-integration-test</module>
<module>sharding-orchestration-config</module>
<module>sharding-orchestration-distributed-lock</module>
<module>sharding-orchestration-center</module>
</modules>
</project>
59 changes: 59 additions & 0 deletions sharding-orchestration/sharding-orchestration-center/pom.xml
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>
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();
}
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 {
sunbufu marked this conversation as resolved.
Show resolved Hide resolved

/**
* 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();
}
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();
}
Loading