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