You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2019/08/23 06:41:30 UTC
[GitHub] [incubator-shardingsphere] wgy8283335 opened a new issue #2912:
"RegistryCenter" interface has many different methonds,
shall we split them into two parts?
wgy8283335 opened a new issue #2912: "RegistryCenter" interface has many different methonds, shall we split them into two parts?
URL: https://github.com/apache/incubator-shardingsphere/issues/2912
## "RegistryCenter" interface has many different methods, shall we split them into two parts?
### There are some lock related methods in "RegistryCenter" interface, these methods are only used by leaf key generator. And other methods are configuration related methods. So maybe we should split these into two parts. For example:
```
public final class CuratorZookeeperRegistryCenter implements RegistryCenter{
}
```
After RegistryCenter is split into two parts: RegistryCenter and LeafLock. Lock related methods will be moved into LeafLock.
```
public final class CuratorZookeeperRegistryCenter implements RegistryCenter,LeafLock{
}
```
```
public interface RegistryCenter extends TypeBasedSPI {
/**
* Initialize registry center.
*
* @param config registry center configuration
*/
void init(RegistryCenterConfiguration 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 data from registry 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 registry.
*
* @param key key of data
* @param dataChangedEventListener data changed event listener
*/
void watch(String key, DataChangedEventListener dataChangedEventListener);
/**
* Close.
*/
void close();
}
```
```
public interface LeafLock extends TypeBasedSPI {
void initLock(String key);
boolean tryLock();
void tryRelease();
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services