當前位置: 首頁>>代碼示例>>Java>>正文


Java PathChildrenCacheEvent.getType方法代碼示例

本文整理匯總了Java中org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent.getType方法的典型用法代碼示例。如果您正苦於以下問題:Java PathChildrenCacheEvent.getType方法的具體用法?Java PathChildrenCacheEvent.getType怎麽用?Java PathChildrenCacheEvent.getType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent的用法示例。


在下文中一共展示了PathChildrenCacheEvent.getType方法的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 {
    final Type eventType = event.getType();
    final String path = event.getData().getPath();
    final String name = ZKHelper.getNameFromPath(path);
    LOGGER.debugMarker("ZoneEventListener", "Receive zookeeper event %s %s", eventType, path);

    if (eventType == Type.CHILD_ADDED || eventType == Type.CHILD_UPDATED) {
        agentService.report(new AgentPath(zone.getName(), name), AgentStatus.IDLE);
        return;
    }

    if (eventType == Type.CHILD_REMOVED) {
        agentService.report(new AgentPath(zone.getName(), name), AgentStatus.OFFLINE);
        return;
    }
}
 
開發者ID:FlowCI,項目名稱:flow-platform,代碼行數:18,代碼來源:ZoneServiceImpl.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:
            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

示例4: 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

示例5: 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

示例6: childEvent

import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //導入方法依賴的package包/類
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
    switch (event.getType()) {
        case CHILD_ADDED:
        case CHILD_UPDATED: {
            addProvider(event.getData(), false);
            break;
        }

        case CHILD_REMOVED: {
            providers.remove(ZKPaths.getNodeFromPath(event.getData().getPath()));
            break;
        }
        default:
            break;
    }
}
 
開發者ID:dinstone,項目名稱:jrpc,代碼行數:18,代碼來源:ZookeeperServiceDiscovery.java

示例7: childEvent

import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //導入方法依賴的package包/類
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
    switch (event.getType()) {
        case CHILD_ADDED:
            applicationAdded(ApplicationId.fromSerializedForm(Path.fromString(event.getData().getPath()).getName()));
            break;
        // Event CHILD_REMOVED will be triggered on all config servers if deleteApplication() above is called on one of them
        case CHILD_REMOVED:
            applicationRemoved(ApplicationId.fromSerializedForm(Path.fromString(event.getData().getPath()).getName()));
            break;
        case CHILD_UPDATED:
            // do nothing, application just got redeployed
            break;
        default:
            break;
    }
    // We might have lost events and might need to remove applications (new applications are
    // not added by listening for events here, they are added when session is added, see RemoteSessionRepo)
    removeApplications();
}
 
開發者ID:vespa-engine,項目名稱:vespa,代碼行數:21,代碼來源:ZKTenantApplications.java

示例8: onZkEvent

import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //導入方法依賴的package包/類
private void onZkEvent(final PathChildrenCacheEvent event) {
    // Lock is needed only to support massive load on startup. In all other cases it will be called for
    // event type creation/update, so it won't create any additional load.
    String invalidatedEventType = null;
    rwLock.readLock().lock();
    try {
        final boolean needInvalidate = event.getType() == PathChildrenCacheEvent.Type.CHILD_UPDATED ||
                event.getType() == PathChildrenCacheEvent.Type.CHILD_REMOVED ||
                event.getType() == PathChildrenCacheEvent.Type.CHILD_ADDED;
        if (needInvalidate) {
            final String[] path = event.getData().getPath().split("/");
            invalidatedEventType = path[path.length - 1];
            eventTypeCache.invalidate(invalidatedEventType);
        }
    } finally {
        rwLock.readLock().unlock();
    }
    if (null != invalidatedEventType) {
        for (final Consumer<String> listener : invalidationListeners) {
            listener.accept(invalidatedEventType);
        }
    }
}
 
開發者ID:zalando,項目名稱:nakadi,代碼行數:24,代碼來源:EventTypeCache.java

示例9: 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

示例10: childEvent

import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //導入方法依賴的package包/類
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event)
    throws Exception {
  switch ( event.getType() ) {
  case CHILD_ADDED:
    PathsUpdate newUpdate = new PathsUpdate();
    PluginCacheSyncUtil.setUpdateFromChildEvent(event, newUpdate);
    metastorePlugin.processCacheNotification(newUpdate);
    break;
  case INITIALIZED:
  case CHILD_UPDATED:
  case CHILD_REMOVED:
    break;
  case CONNECTION_RECONNECTED:
    MetastoreAuthzBinding.setSentryCacheOutOfSync(false);
    break;
  case CONNECTION_SUSPENDED:
  case CONNECTION_LOST:
    MetastoreAuthzBinding.setSentryCacheOutOfSync(true);
    break;
  default:
    break;
  }
}
 
開發者ID:apache,項目名稱:incubator-sentry,代碼行數:25,代碼來源:MetastorePluginWithHA.java

示例11: childEvent

import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //導入方法依賴的package包/類
@Override
public synchronized void childEvent(CuratorFramework client,
    PathChildrenCacheEvent event) throws Exception {
  switch ( event.getType() ) {
  case CHILD_ADDED:
    K newUpdate = (K) baseUpdate.getClass().newInstance();
    PluginCacheSyncUtil.setUpdateFromChildEvent(event, newUpdate);
    updateForwarder.postNotificationToLog(newUpdate);
    break;
  case INITIALIZED:
  case CHILD_UPDATED:
  case CHILD_REMOVED:
    break;
  case CONNECTION_RECONNECTED:
    // resume the node
    SentryPlugin.instance.setOutOfSync(false);
    break;
  case CONNECTION_SUSPENDED:
  case CONNECTION_LOST:
    // suspend the node
    SentryPlugin.instance.setOutOfSync(true);
    break;
  default:
    break;
  }
}
 
開發者ID:apache,項目名稱:incubator-sentry,代碼行數:27,代碼來源:UpdateForwarderWithHA.java

示例12: childEvent

import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //導入方法依賴的package包/類
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
    logger.debug("Listener parent path: {} currentData {}",
            new Object[]{event.getData().getPath(), StringSerializer.deserialize(event.getData().getData())});
    switch (event.getType()) {
        case CHILD_ADDED:
            synchronized (this) {
                testGroupMembers.add(event.getData().getPath().substring(
                        event.getData().getPath().lastIndexOf("/")+1));
            }
            barrier.await(10, TimeUnit.SECONDS);
            break;
        case CHILD_REMOVED:
            synchronized (this) {
                testGroupMembers.remove(event.getData().getPath().substring(
                        event.getData().getPath().lastIndexOf("/")+1));
            }
            barrier.await(10, TimeUnit.SECONDS);
            break;
    }

}
 
開發者ID:addthis,項目名稱:bark,代碼行數:23,代碼來源:ZkGroupMembershipTest.java

示例13: 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

示例14: childEvent

import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //導入方法依賴的package包/類
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event)
        throws Exception {
    PathChildrenCacheEvent.Type eventType = event.getType();
    switch (eventType) {
    case INITIALIZED:
        LOG.debug("initailize the service instance list from zookeeper.");
        break;
    case CHILD_ADDED:
        LOG.debug("add new service instance from zookeeper.");
        this.addChild(event.getData());
        break;
    case CHILD_UPDATED:
        LOG.debug("update service instance  from zookeeper.");
        this.addChild(event.getData());
        break;
    case CONNECTION_RECONNECTED:
        this.cache.rebuild();
        break;
    case CHILD_REMOVED:
    case CONNECTION_SUSPENDED:
    case CONNECTION_LOST:
        LOG.debug("remove service instance  from zookeeper.");
        this.removeChild(event.getData());
        break;
    default:
        LOG.debug("Ignore PathChildrenCache event : {path:"
                + event.getData().getPath() + " data:"
                + new String(event.getData().getData()) + "}");
    }
}
 
開發者ID:jigsaw-projects,項目名稱:jigsaw-payment,代碼行數:32,代碼來源:RefreshableTransportPool.java

示例15: childEvent

import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //導入方法依賴的package包/類
@Override
public void childEvent(CuratorFramework unused, PathChildrenCacheEvent event) throws Exception {
    if (event.getType() != PathChildrenCacheEvent.Type.CHILD_ADDED) {
        return;
    }

    final long lastKnownRevision = revisionFromPath(event.getData().getPath());
    replayLogs(lastKnownRevision);
    oldLogRemover.touch();
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:11,代碼來源:ZooKeeperCommandExecutor.java


注:本文中的org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent.getType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。