当前位置: 首页>>代码示例>>Java>>正文


Java ChildData.getPath方法代码示例

本文整理汇总了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;
        }
    }
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:21,代码来源:SnapshotManager.java

示例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);

}
 
开发者ID:actiontech,项目名称:dble,代码行数:22,代码来源:ViewChildListener.java

示例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={}");
    }
}
 
开发者ID:mpusher,项目名称:mpush,代码行数:22,代码来源:ZKCacheListener.java

示例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);
    }
}
 
开发者ID:artoderk,项目名称:elastic-jobx,代码行数:20,代码来源:MonitorService.java

示例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);
    }
}
 
开发者ID:ErinDavid,项目名称:elastic-config,代码行数:22,代码来源:DumpConfigService.java

示例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);
    }

}
 
开发者ID:actiontech,项目名称:dble,代码行数:20,代码来源:ViewChildListener.java

示例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);
}
 
开发者ID:netboynb,项目名称:coco,代码行数:12,代码来源:Refresher.java

示例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;
	}
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:41,代码来源:EndpointListener.java

示例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());
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:5,代码来源:ZkAbstractStore.java

示例10: AbstractGenericData

import org.apache.curator.framework.recipes.cache.ChildData; //导入方法依赖的package包/类
public AbstractGenericData(ChildData childData) {
    this(childData.getPath(), childData.getData());
}
 
开发者ID:xiaolongzuo,项目名称:niubi-job,代码行数:4,代码来源:AbstractGenericData.java

示例11: toChildPath

import org.apache.curator.framework.recipes.cache.ChildData; //导入方法依赖的package包/类
protected String toChildPath(ChildData childData) {
    String fullPath = childData.getPath();
    return ZKPaths.getNodeFromPath(fullPath);
}
 
开发者ID:netboynb,项目名称:coco,代码行数:5,代码来源:Refresher.java


注:本文中的org.apache.curator.framework.recipes.cache.ChildData.getPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。