當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。