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


Java PathChildrenCacheEvent.getData方法代码示例

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


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

示例1: childEvent

import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
    ChildData data = event.getData();
    switch (event.getType()) {

        case CHILD_ADDED:

            add(data.getPath().substring(data.getPath().lastIndexOf("/")+1),event.getData().getData()) ;
            break;
        case CHILD_REMOVED:
            delete(data.getPath().substring(data.getPath().lastIndexOf("/")+1),event.getData().getData()); ;
            break;
        case CHILD_UPDATED:
            add(data.getPath().substring(data.getPath().lastIndexOf("/")+1),event.getData().getData()) ;
            break;
        default:
            break;
    }
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:19,代码来源:BinDataPathChildrenCacheListener.java

示例2: childEvent

import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
    ChildData childData = event.getData();
    switch (event.getType()) {
        case CHILD_ADDED:
            try {
                lockTableByNewNode(childData);
            } catch (Exception e) {
                LOGGER.info("CHILD_ADDED error", e);
            }
            break;
        case CHILD_UPDATED:
            updateMeta(childData);
            break;
        case CHILD_REMOVED:
            deleteNode(childData);
            break;
        default:
            break;
    }
}
 
开发者ID:actiontech,项目名称:dble,代码行数:22,代码来源:DDLChildListener.java

示例3: childEvent

import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
    ChildData childData = event.getData();
    switch (event.getType()) {
        case CHILD_ADDED:
            createOrUpdateViewMeta(childData, false);
            break;
        case CHILD_UPDATED:
            createOrUpdateViewMeta(childData, true);
            break;
        case CHILD_REMOVED:
            deleteNode(childData);
            break;
        default:
            break;
    }
}
 
开发者ID:actiontech,项目名称:dble,代码行数:18,代码来源:ViewChildListener.java

示例4: childEvent

import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
    ChildData data = event.getData();
    switch (event.getType()) {
        case CHILD_ADDED:
            add(data, false);
            break;
        case CHILD_UPDATED:
            add(data, true);
            break;
        case CHILD_REMOVED:
            delete(data);
            break;
        default:
            break;
    }
}
 
开发者ID:actiontech,项目名称:dble,代码行数:18,代码来源:BinDataPathChildrenCacheListener.java

示例5: childEvent

import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public synchronized void childEvent(CuratorFramework curatorFramework, PathChildrenCacheEvent event) throws Exception {
    AssertHelper.isTrue(isJoined(), "illegal state .");
    boolean hasLeadership = leaderSelector != null && leaderSelector.hasLeadership();
    if (!hasLeadership) {
        return;
    }
    if (!EventHelper.isChildModifyEvent(event)) {
        return;
    }
    StandbyJobData standbyJobData = new StandbyJobData(event.getData());
    if (StringHelper.isEmpty(standbyJobData.getData().getJobOperation())) {
        return;
    }
    StandbyJobData.Data data = standbyJobData.getData();
    if (data.isUnknownOperation()) {
        return;
    }
    StandbyNodeData.Data nodeData = standbyApiFactory.nodeApi().getNode(nodePath).getData();
    executeOperation(nodeData, data);
}
 
开发者ID:xiaolongzuo,项目名称:niubi-job,代码行数:22,代码来源:StandbyNode.java

示例6: childEvent

import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
    String nodePath = null;
    T nodeData = null;
    if (event.getData() != null) {
        nodePath = event.getData().getPath();
        nodeData = parseChildData(event.getData());
    }
    switch (event.getType()) {
        case CHILD_ADDED:
            addNode(nodePath, nodeData);
            break;

        case CHILD_REMOVED:
            removeNode(nodePath, nodeData);
            break;

        case CHILD_UPDATED:
            updateNode(nodePath, nodeData);
            break;
    }
}
 
开发者ID:bazaarvoice,项目名称:curator-extensions,代码行数:23,代码来源:NodeDiscovery.java

示例7: childEvent

import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
    ChildData data = event.getData();
    if(data==null || data.getData()==null){
        return;
    }
    SlaveNode slaveNode = SlaveNode.parse(JSON.parseObject(data.getData(),JSONObject.class));
    if(slaveNode==null){
        LOGGER.error("get a null slaveNode with eventType={},path={},data={}",event.getType(),data.getPath(),data.getData());
    }else {
        switch (event.getType()) {
            case CHILD_ADDED:
                slaveNodeMap.put(slaveNode.getId(), slaveNode);
                LOGGER.info("CHILD_ADDED with path={},data={},current slaveNode size={}", data.getPath(), new String(data.getData(),CharsetUtil.UTF_8),slaveNodeMap.size());
                break;
            case CHILD_REMOVED:
                slaveNodeMap.remove(slaveNode.getId());
                LOGGER.info("CHILD_REMOVED with path={},data={},current slaveNode size={}", data.getPath(), new String(data.getData(),CharsetUtil.UTF_8),slaveNodeMap.size());
                break;
            case CHILD_UPDATED:
                slaveNodeMap.replace(slaveNode.getId(), slaveNode);
                LOGGER.info("CHILD_UPDATED with path={},data={},current slaveNode size={}", data.getPath(), new String(data.getData(),CharsetUtil.UTF_8),slaveNodeMap.size());
                break;
            default:
                break;
        }
    }
}
 
开发者ID:all4you,项目名称:redant,代码行数:29,代码来源:DefaultServiceDiscovery.java

示例8: childEvent

import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
    if (event.getData() != null) {
        listener.onEvent(
            IDataListener.EventType.NODE_UPDATED,
            event.getData().getPath(),
            event.getData().getData(),
            event.getData().getStat().getVersion()); // TODO: coupled to Zookeeper. Need to decouple
    } else if (event.getType() == PathChildrenCacheEvent.Type.INITIALIZED) {
        listener.onEvent(IDataListener.EventType.INITIALIZED, null, null);
    } else {
        log.error("Null data is coming to zkNode cache - {}", "Change NamespacedList");
    }
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:15,代码来源:ZookeeperConnector.java

示例9: childEvent

import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
    ChildData childData = event.getData();
    switch (event.getType()) {
        case CHILD_ADDED:
            break;
        case CHILD_UPDATED:
            break;
        case CHILD_REMOVED:
            deleteNode(childData);
            break;
        default:
            break;
    }
}
 
开发者ID:actiontech,项目名称:dble,代码行数:16,代码来源:OfflineStatusListener.java

示例10: childEvent

import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework curatorFramework, PathChildrenCacheEvent pathChildrenCacheEvent)
    throws Exception {
  ChildData data = pathChildrenCacheEvent.getData();
  if (data == null) {
    log.debug("Ignoring {} due to empty child data", pathChildrenCacheEvent);
    return;
  } else if (data.getData() == null) {
    log.debug("Ignoring {} due to empty child's data", pathChildrenCacheEvent);
    return;
  } else if (nodePath != null && nodePath.equals(data.getPath())) {
    log.debug("Ignoring event about current server {}", pathChildrenCacheEvent);
    return;
  }
  ServerInstance instance;
  try {
    instance = new ServerInstance(ServerInfo.parseFrom(data.getData()));
  } catch (IOException e) {
    log.error("Failed to decode server instance for node {}", data.getPath(), e);
    throw e;
  }
  log.info("Processing [{}] event for [{}:{}]", pathChildrenCacheEvent.getType(), instance.getHost(),
      instance.getPort());
  switch (pathChildrenCacheEvent.getType()) {
  case CHILD_ADDED:
    listeners.forEach(listener -> listener.onServerAdded(instance));
    break;
  case CHILD_UPDATED:
    listeners.forEach(listener -> listener.onServerUpdated(instance));
    break;
  case CHILD_REMOVED:
    listeners.forEach(listener -> listener.onServerRemoved(instance));
    break;
  }
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:36,代码来源:ZkDiscoveryService.java

示例11: childEvent

import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework curatorFramework, PathChildrenCacheEvent pathChildrenCacheEvent) throws Exception {
    ChildData data = pathChildrenCacheEvent.getData();
    if (data == null) {
        log.debug("Ignoring {} due to empty child data", pathChildrenCacheEvent);
        return;
    } else if (data.getData() == null) {
        log.debug("Ignoring {} due to empty child's data", pathChildrenCacheEvent);
        return;
    } else if (nodePath != null && nodePath.equals(data.getPath())) {
        log.debug("Ignoring event about current server {}", pathChildrenCacheEvent);
        return;
    }
    ServerInstance instance;
    try {
        instance = new ServerInstance(ServerInfo.parseFrom(data.getData()));
    } catch (IOException e) {
        log.error("Failed to decode server instance for node {}", data.getPath(), e);
        throw e;
    }
    log.info("Processing [{}] event for [{}:{}]", pathChildrenCacheEvent.getType(), instance.getHost(), instance.getPort());
    switch (pathChildrenCacheEvent.getType()) {
        case CHILD_ADDED:
            listeners.forEach(listener -> listener.onServerAdded(instance));
            break;
        case CHILD_UPDATED:
            listeners.forEach(listener -> listener.onServerUpdated(instance));
            break;
        case CHILD_REMOVED:
            listeners.forEach(listener -> listener.onServerRemoved(instance));
            break;
        default:
            break;
    }
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:36,代码来源:ZkDiscoveryService.java

示例12: handleChildUpdated

import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
protected void handleChildUpdated(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
    ChildData childData = event.getData();
    String nodeName = safeGetNodeNameFromEvent(event);
    if(Arrays.asList(configProfiles).contains(nodeName) || canApplyForLocalMachine(nodeName)) {
        T newConfig = createConfig(childData.getData(), getObject());
        BeanUtils.copyProperties(newConfig, getObject());
        getObject().reload();
    }
}
 
开发者ID:hekailiang,项目名称:cloud-config,代码行数:11,代码来源:SimpleResourceConfigFactoryBean.java

示例13: handleChildUpdated

import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
protected void handleChildUpdated(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
    String nodeName = safeGetNodeNameFromEvent(event);
    Object configObj = configHolder.get(nodeName);
    if( configObj instanceof CloudResourceConfig) {
        CloudResourceConfig resourceConfig = (CloudResourceConfig)configObj;
        ChildData childData = event.getData();
        Object newConfig = createConfig(childData.getData(), getObject());
        BeanUtils.copyProperties(newConfig, resourceConfig);
        resourceConfig.reload();
    }
}
 
开发者ID:hekailiang,项目名称:cloud-config,代码行数:13,代码来源:RoutingAwareResourceConfigFactoryBean.java

示例14: safeGetNodeNameFromEvent

import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
protected String safeGetNodeNameFromEvent(PathChildrenCacheEvent event) {
    return event.getData() != null ?
            ZKPaths.getNodeFromPath(event.getData().getPath()) : "";
}
 
开发者ID:hekailiang,项目名称:cloud-config,代码行数:5,代码来源:AbstractResourceConfigFactoryBean.java

示例15: handleChildAdded

import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
protected void handleChildAdded(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
    String nodeName = event.getData()!=null ?
            ZKPaths.getNodeFromPath(event.getData().getPath()) : "";
    buildResourceConfig(nodeName);
}
 
开发者ID:hekailiang,项目名称:cloud-config,代码行数:7,代码来源:RoutingAwareResourceConfigFactoryBean.java


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