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


Java ZKPaths.getNodeFromPath方法代码示例

本文整理汇总了Java中org.apache.curator.utils.ZKPaths.getNodeFromPath方法的典型用法代码示例。如果您正苦于以下问题:Java ZKPaths.getNodeFromPath方法的具体用法?Java ZKPaths.getNodeFromPath怎么用?Java ZKPaths.getNodeFromPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.curator.utils.ZKPaths的用法示例。


在下文中一共展示了ZKPaths.getNodeFromPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startInitialTasks

import org.apache.curator.utils.ZKPaths; //导入方法依赖的package包/类
private void startInitialTasks()
{
	if( !startedInitialTasks )
	{
		List<ChildData> currentData = taskCache.getCurrentData();
		List<String> taskIds = Lists.newArrayList();
		for( ChildData task : currentData )
		{
			String taskId = ZKPaths.getNodeFromPath(task.getPath());
			LOGGER.debug("Task added " + taskId);
			taskIds.add(taskId);
			addRunner(taskId);
		}
		requestFullStatus(taskIds);
		startedInitialTasks = true;
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:18,代码来源:ClusteredTaskServiceImpl.java

示例2: handleReconnection

import org.apache.curator.utils.ZKPaths; //导入方法依赖的package包/类
private void handleReconnection() {

		log.info("Reading current cache data from ZK and synchronizing local cache");

		final List<ChildData> cacheData = curatorConsumerCache.getCurrentData();

		// Remove all the consumers in this API nodes cache that now belong to
		// other API nodes.
		for (ChildData cachedConsumer : cacheData) {
			final String consumerId = ZKPaths.getNodeFromPath(cachedConsumer.getPath());
			final String owningApiId = (cachedConsumer.getData() != null) ? new String(cachedConsumer.getData())
					: "undefined";

			if (!fApiId.equals(owningApiId)) {
				fConsumers.remove(consumerId);
			}
		}

		setStatus(Status.CONNECTED);
	}
 
开发者ID:att,项目名称:dmaap-framework,代码行数:21,代码来源:KafkaConsumerCache.java

示例3: newListener

import org.apache.curator.utils.ZKPaths; //导入方法依赖的package包/类
private PathChildrenCacheListener newListener(final EventType eventType, final GroupChangedListener delegate) {
    return
        (client, event) -> {
        switch (event.getType()) {

            case CHILD_ADDED : {
                String addedMemberId = ZKPaths.getNodeFromPath(event.getData().getPath());
                delegate.memberAdded(eventType, addedMemberId);
                break;
            }

            case CHILD_REMOVED : {
                final String removedMemberId = ZKPaths.getNodeFromPath(event.getData().getPath());
                delegate.memberRemoved(eventType, removedMemberId);
                break;
            }

            default :
                break;
        }
    };
}
 
开发者ID:zalando-nakadi,项目名称:paradox-nakadi-consumer,代码行数:23,代码来源:ZKConsumerGroupMember.java

示例4: childEvent

import org.apache.curator.utils.ZKPaths; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception
{
	Type type = event.getType();
	if( type.equals(Type.CHILD_ADDED) || type.equals(Type.CHILD_UPDATED) || type.equals(Type.CHILD_REMOVED) )
	{
		String remoteId = ZKPaths.getNodeFromPath(event.getData().getPath());
		String[] clientInfo = new String(event.getData().getData()).split(":");
		if( !isThisNode(remoteId) && !hasSameInfo(clientInfo) )
		{
			if( type.equals(Type.CHILD_ADDED) )
			{
				senders.get(remoteId);
				addReceiver(remoteId, clientInfo);
			}
			else if( type.equals(Type.CHILD_UPDATED) )
			{
				senders.get(remoteId);
				removeReceiver(remoteId);
				addReceiver(remoteId, clientInfo);
			}
			else
			{
				removeReceiver(remoteId);
			}
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:29,代码来源:ClusterMessagingServiceImpl.java

示例5: childEvent

import org.apache.curator.utils.ZKPaths; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
    if (logger.isDebugEnabled()) {
        logger.debug("path={} event={}", event.getData().getPath(), event.getType());
    }
    switch (event.getType()) {
        case CHILD_ADDED:
            logChildChanged(client, event);
            addOrUpdate(event);
            break;
        case CHILD_UPDATED:
            logChildChanged(client, event);
            addOrUpdate(event);
            break;
        case CHILD_REMOVED:
            logChildChanged(client, event);
            String key = ZKPaths.getNodeFromPath(event.getData().getPath());
            itemSet.remove(key);
            break;
        case CONNECTION_SUSPENDED:
            logChildChanged(client, event);
            break;
        case CONNECTION_RECONNECTED:
            logChildChanged(client, event);
            initDataFromZk();
            break;
        case CONNECTION_LOST:
            logChildChanged(client, event);
            break;
        case INITIALIZED:
            logChildChanged(client, event);
            break;
    }
}
 
开发者ID:netboynb,项目名称:coco,代码行数:35,代码来源:SimpleModeCenter.java

示例6: addProvider

import org.apache.curator.utils.ZKPaths; //导入方法依赖的package包/类
private void addProvider(ChildData childData, boolean onlyIfAbsent) throws Exception {
    String instanceId = ZKPaths.getNodeFromPath(childData.getPath());
    ServiceDescription serviceInstance = serializer.deserialize(childData.getData());
    if (onlyIfAbsent) {
        providers.putIfAbsent(instanceId, serviceInstance);
    } else {
        providers.put(instanceId, serviceInstance);
    }
    cache.clearDataBytes(childData.getPath(), childData.getStat().getVersion());
}
 
开发者ID:dinstone,项目名称:jrpc,代码行数:11,代码来源:ZookeeperServiceDiscovery.java

示例7: nodeAdd

import org.apache.curator.utils.ZKPaths; //导入方法依赖的package包/类
/**
 * zookeeper listen the node add event ret: 0: failed ,1:the node is root
 * node,2:success
 */
private int nodeAdd(long logIndex, CuratorFramework client, TreeCacheEvent event) {
    String flag = getClassName() + ".nodeAdd";

    String strNode = null;
    String strVal = null;
    String strPath = null;
    try {
        strPath = event.getData().getPath();
        if (strPath.equals(ZK_ROOT)) {
            FRCLogger.getInstance().info(logIndex, flag, "NODE_ADDED ROOT dir!", null);
            return DefaultValues.ZK_ADD_ROOT;
        }

        strNode = ZKPaths.getNodeFromPath(strPath);
        strVal = new String(client.getData().forPath(strPath));

        FRCLogger.getInstance().info(logIndex, flag, "Node:{}\n value:{}", null, strNode,
            strVal);

        RedisInfo redisInfo = (RedisInfo) JSONProvider.parseObject(logIndex, strVal,
            RedisInfo.class);
        if (null == redisInfo) {
            FRCLogger.getInstance().warn(logIndex, flag, ":{}", null, strVal);
            this.delPath(logIndex, strPath);
            return DefaultValues.ZK_ADD_FAIL;
        }
        redisInfo.setRedis_name(strPath);
        cnm.nodeAdd(logIndex, redisInfo);

    } catch (Exception e) {
        FRCLogger.getInstance().warn(logIndex, flag,
            "nodeAdd event :path:{}->[{}] add fail,exception detail: {}", e, strVal);
        return DefaultValues.ZK_ADD_FAIL;
    }
    return DefaultValues.ZK_ADD_SUC;
}
 
开发者ID:songbin,项目名称:frc,代码行数:41,代码来源:ZkClient.java

示例8: updateNode

import org.apache.curator.utils.ZKPaths; //导入方法依赖的package包/类
/**
 * zookeeper listen the node update event
 */
private boolean updateNode(long logIndex, TreeCacheEvent event) {
    String flag = this.getClassName() + ".updateNode";
    try {
        String strPath = event.getData().getPath();
        if (strPath.equals(ZK_ROOT)) {
            FRCLogger.getInstance().info(logIndex, flag, "NODE_ADDED ROOT dir!", null);
            return true;
        }
        strPath = event.getData().getPath();
        String strNode = ZKPaths.getNodeFromPath(strPath);
        String strVal = new String(client.getData().forPath(strPath));

        FRCLogger.getInstance().info(logIndex, flag, "Node:{}\n value:{}", null, strNode,
            strVal);

        RedisInfo redisInfo = getRedisInfo(logIndex, event);
        if (null == redisInfo)
            return false;

        redisInfo.setRedis_name(strPath);

        int state = this.getState(redisInfo.getRedis_state());
        if (RedisState.STATE_UNKOWN == state) {
            FRCLogger.getInstance().warn(logIndex, flag, "redis workstate is wrong! data:{}",
                null, JSONProvider.toJSONString(logIndex, redisInfo));
            return false;
        }
        cnm.nodeUpdate(logIndex, redisInfo);
        return true;
    } catch (Exception e) {
        FRCLogger.getInstance().warn(logIndex, flag, "exception", e);
        return false;
    }

}
 
开发者ID:songbin,项目名称:frc,代码行数:39,代码来源:ZkClient.java

示例9: removeNode

import org.apache.curator.utils.ZKPaths; //导入方法依赖的package包/类
private boolean removeNode(long logIndex, TreeCacheEvent event) {
    String flag = this.getClassName() + ".removeNode";
    try {
        String strPath = event.getData().getPath();
        if (strPath.equals(ZK_ROOT)) {
            FRCLogger.getInstance().info(logIndex, flag, "NODE_ADDED ROOT dir!", null);
            return true;
        }

        String strNode = ZKPaths.getNodeFromPath(strPath);
        String strVal = new String(client.getData().forPath(strPath));

        FRCLogger.getInstance().info(logIndex, flag, "Node:{}\n value:{}", null, strNode,
            strVal);

        RedisInfo redisInfo = getRedisInfo(logIndex, event);
        if (null == redisInfo)
            return false;

        cnm.nodeRemove(logIndex, redisInfo);
    } catch (Exception e) {
        FRCLogger.getInstance().warn(logIndex, flag, "exception", e);
        return false;
    }

    return true;
}
 
开发者ID:songbin,项目名称:frc,代码行数:28,代码来源:ZkClient.java

示例10: getRedisName

import org.apache.curator.utils.ZKPaths; //导入方法依赖的package包/类
/**
 * get the zookeeper data of node of the event
 * 
 * @param logIndex
 * @param event
 *            zookeeper event
 * @return
 */
@SuppressWarnings("unused")
private String getRedisName(long logIndex, TreeCacheEvent event) {
    String flag = getClassName() + ".getRedisName";
    try {
        return ZKPaths.getNodeFromPath(event.getData().getPath());
    } catch (Exception e) {
        FRCLogger.getInstance().warn(logIndex, flag,
            "zookeeper getRedisName fail exception detail: {}", e);
        return null;
    }
}
 
开发者ID:songbin,项目名称:frc,代码行数:20,代码来源:ZkClient.java

示例11: childEvent

import org.apache.curator.utils.ZKPaths; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception
{
	Type type = event.getType();
	LOGGER.debug("Event = " + type);
	if( type == Type.CHILD_ADDED || type == Type.CHILD_REMOVED )
	{
		final boolean init;
		if( !startedInitialTasks )
		{
			synchronized( initialTasksLock )
			{
				init = startedInitialTasks;
			}
		}
		else
		{
			init = startedInitialTasks;
		}
		if( init )
		{
			String taskId = ZKPaths.getNodeFromPath(event.getData().getPath());
			switch( type )
			{
				case CHILD_ADDED:
					LOGGER.debug("Task added " + taskId);
					requestFullStatus(Collections.singleton(taskId));
					addRunner(taskId);
					break;
				case CHILD_REMOVED:
					LOGGER.debug("Task removed " + taskId);
					statusHandler.retireStatus(taskId);
					runnerHandler.deleteRunner(taskId, false);
					break;
			}
		}
		else
		{
			LOGGER.debug("Not init yet. " + event.getData().getPath());
		}
	}
	else
	{
		long sessionId = client.getZookeeperClient().getZooKeeper().getSessionId();
		if( type == Type.CONNECTION_SUSPENDED )
		{
			suspendedSessionId = sessionId;
		}
		else
			if( (type == Type.CONNECTION_RECONNECTED && suspendedSessionId != sessionId)
				|| type == Type.CONNECTION_LOST )
		{
			runnerHandler.lostConnection();
		}
		else if( type == Type.INITIALIZED )
		{
			synchronized( initialTasksLock )
			{
				startInitialTasks();
			}
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:64,代码来源:ClusteredTaskServiceImpl.java

示例12: getNameFromPath

import org.apache.curator.utils.ZKPaths; //导入方法依赖的package包/类
public static String getNameFromPath(String path) {
    return ZKPaths.getNodeFromPath(path);
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:4,代码来源:ZKHelper.java

示例13: toChildPath

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

示例14: addOrUpdate

import org.apache.curator.utils.ZKPaths; //导入方法依赖的package包/类
void addOrUpdate(PathChildrenCacheEvent event) {
    String key = ZKPaths.getNodeFromPath(event.getData().getPath());
    itemSet.add(key);
}
 
开发者ID:netboynb,项目名称:coco,代码行数:5,代码来源:SimpleModeCenter.java

示例15: reload

import org.apache.curator.utils.ZKPaths; //导入方法依赖的package包/类
/**
 * 重加载路径path配置节点
 * 
 * @param path 配置节点路径
 */
private void reload(String path) {
    log.debug("reload the config node:{}", ZKPaths.getNodeFromPath(path));
    String key = ZKPaths.getNodeFromPath(path);
    zookeeperConfigGroup.reloadKey(key);
}
 
开发者ID:ErinDavid,项目名称:elastic-config,代码行数:11,代码来源:ZookeeperListenerManager.java


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