本文整理汇总了Java中org.apache.curator.framework.recipes.cache.ChildData.getPath方法的典型用法代码示例。如果您正苦于以下问题:Java ChildData.getPath方法的具体用法?Java ChildData.getPath怎么用?Java ChildData.getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.curator.framework.recipes.cache.ChildData
的用法示例。
在下文中一共展示了ChildData.getPath方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onChanged
import org.apache.curator.framework.recipes.cache.ChildData; //导入方法依赖的package包/类
@Override
public void onChanged(TreeCacheEvent event) {
ChildData data = event.getData();
if (data == null) {
return;
}
String path = data.getPath();
switch (event.getType()) {
case NODE_ADDED:
case NODE_REMOVED:
case NODE_UPDATED: {
boolean isFullHostPath = StringUtils.isNotBlank(path) && path.split(RedirectorConstants.DELIMETER).length == 7;
if (isFullHostPath && path.contains(RedirectorConstants.DELIMETER + applicationName + RedirectorConstants.DELIMETER)) {
snapshotNeeded = true;
}
break;
}
}
}
示例2: createOrUpdateViewMeta
import org.apache.curator.framework.recipes.cache.ChildData; //导入方法依赖的package包/类
/**
* update the meta if the view updated
*/
private void createOrUpdateViewMeta(ChildData childData, boolean isReplace) throws Exception {
String path = childData.getPath();
String[] paths = path.split("/");
String jsonValue = new String(childData.getData(), StandardCharsets.UTF_8);
JSONObject obj = (JSONObject) JSONObject.parse(jsonValue);
//if the view is create or replace by this server it self
String serverId = obj.getString(SERVER_ID);
if (serverId.equals(ZkConfig.getInstance().getValue(ZkParamCfg.ZK_CFG_MYID))) {
return;
}
String createSql = obj.getString(CREATE_SQL);
String schema = paths[paths.length - 1].split(SCHEMA_VIEW_SPLIT)[0];
ViewMeta vm = new ViewMeta(createSql, schema, DbleServer.getInstance().getTmManager());
vm.initAndSet(isReplace);
}
示例3: childEvent
import org.apache.curator.framework.recipes.cache.ChildData; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework curator, TreeCacheEvent event) throws Exception {
ChildData data = event.getData();
if (data == null) return;
String dataPath = data.getPath();
if (Strings.isNullOrEmpty(dataPath)) return;
if (dataPath.startsWith(watchPath)) {
switch (event.getType()) {
case NODE_ADDED:
listener.onServiceAdded(dataPath, Jsons.fromJson(data.getData(), CommonServiceNode.class));
break;
case NODE_REMOVED:
listener.onServiceRemoved(dataPath, Jsons.fromJson(data.getData(), CommonServiceNode.class));
break;
case NODE_UPDATED:
listener.onServiceUpdated(dataPath, Jsons.fromJson(data.getData(), CommonServiceNode.class));
break;
}
Logs.RSD.info("ZK node data change={}, nodePath={}, watchPath={}, ns={}");
}
}
示例4: dumpDirectly
import org.apache.curator.framework.recipes.cache.ChildData; //导入方法依赖的package包/类
private void dumpDirectly(final String path, final List<String> result) {
for (String each : coordinatorRegistryCenter.getChildrenKeys(path)) {
String zkPath = path + "/" + each;
String zkValue = coordinatorRegistryCenter.get(zkPath);
if (null == zkValue) {
zkValue = "";
}
TreeCache treeCache = (TreeCache) coordinatorRegistryCenter.getRawCache("/" + jobName);
ChildData treeCacheData = treeCache.getCurrentData(zkPath);
String treeCachePath = null == treeCacheData ? "" : treeCacheData.getPath();
String treeCacheValue = null == treeCacheData ? "" : new String(treeCacheData.getData());
if (zkValue.equals(treeCacheValue) && zkPath.equals(treeCachePath)) {
result.add(Joiner.on(" | ").join(zkPath, zkValue));
} else {
result.add(Joiner.on(" | ").join(zkPath, zkValue, treeCachePath, treeCacheValue));
}
dumpDirectly(zkPath, result);
}
}
示例5: dumpDirectly
import org.apache.curator.framework.recipes.cache.ChildData; //导入方法依赖的package包/类
private void dumpDirectly(final String path, final List<String> result) {
for (String each : coordinatorRegistryCenter.getElasticConfigRegistryCenter().getChildrenKeys(path)) {
String zkPath = path + "/" + each;
String zkValue = coordinatorRegistryCenter.getElasticConfigRegistryCenter().get(zkPath);
if (null == zkValue) {
zkValue = "";
}
TreeCache treeCache = (TreeCache) coordinatorRegistryCenter.getElasticConfigRegistryCenter().getRawCache(
"/" + configProfile.getNode());
ChildData treeCacheData = treeCache.getCurrentData(zkPath);
String treeCachePath = null == treeCacheData ? "" : treeCacheData.getPath();
String treeCacheValue = null == treeCacheData ? "" : new String(treeCacheData.getData());
if (zkValue.equals(treeCacheValue) && zkPath.equals(treeCachePath)) {
result.add(Joiner.on(" | ").join(zkPath, zkValue));
}
else {
result.add(Joiner.on(" | ").join(zkPath, zkValue, treeCachePath, treeCacheValue));
}
dumpDirectly(zkPath, result);
}
}
示例6: deleteNode
import org.apache.curator.framework.recipes.cache.ChildData; //导入方法依赖的package包/类
/**
* delete the view data from view meta
*
* @param childData
*/
private void deleteNode(ChildData childData) throws Exception {
String path = childData.getPath();
String[] paths = path.split("/");
String schema = paths[paths.length - 1].split(":")[0];
String viewName = paths[paths.length - 1].split(":")[1];
DbleServer.getInstance().getTmManager().addMetaLock(schema, viewName);
try {
DbleServer.getInstance().getTmManager().getCatalogs().get(schema).getViewMetas().remove(viewName);
} finally {
DbleServer.getInstance().getTmManager().removeMetaLock(schema, viewName);
}
}
示例7: parseTreeCacheEvent
import org.apache.curator.framework.recipes.cache.ChildData; //导入方法依赖的package包/类
protected Node parseTreeCacheEvent(TreeCacheEvent event) {
Node node = new Node();
ChildData childData = event.getData();
String fullPath = childData.getPath();
String nodeName = null;
if(StringUtils.isNotBlank(fullPath)){
List<String> list =CocoUtils.splitStr(fullPath, "/");
nodeName = list.get(list.size()-1);
}
return node.setData(toJsonString(childData)).setFullPath(childData.getPath()).setNodeName(nodeName);
}
示例8: childEvent
import org.apache.curator.framework.recipes.cache.ChildData; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* @see org.apache.curator.framework.recipes.cache.TreeCacheListener#childEvent(org.apache.curator.framework.CuratorFramework, org.apache.curator.framework.recipes.cache.TreeCacheEvent)
*/
@Override
public void childEvent(final CuratorFramework client, final TreeCacheEvent event) throws Exception {
final String path;
final long eph;
final ChildData childData = event.getData();
if(childData!=null) {
path = childData.getPath();
final Stat stat = childData.getStat();
if(stat!=null) {
eph = stat.getEphemeralOwner();
} else {
eph = -1;
}
} else {
path = "{}";
eph = -1;
}
log.debug("Cache Change [{}] --> [{}], eph:{}", event.getType().name(), path, eph);
switch(event.getType()) {
case NODE_ADDED:
if(childData!=null) {
onNodeAdded(childData);
}
break;
case NODE_REMOVED:
if(childData!=null) {
onNodeRemoved(childData);
}
break;
case NODE_UPDATED:
break;
default:
break;
}
}
示例9: keyFromPath
import org.apache.curator.framework.recipes.cache.ChildData; //导入方法依赖的package包/类
private String keyFromPath(ChildData data){
String path = data.getPath();
return path.substring(prefix.length(), path.length());
}
示例10: AbstractGenericData
import org.apache.curator.framework.recipes.cache.ChildData; //导入方法依赖的package包/类
public AbstractGenericData(ChildData childData) {
this(childData.getPath(), childData.getData());
}
示例11: toChildPath
import org.apache.curator.framework.recipes.cache.ChildData; //导入方法依赖的package包/类
protected String toChildPath(ChildData childData) {
String fullPath = childData.getPath();
return ZKPaths.getNodeFromPath(fullPath);
}