当前位置: 首页>>代码示例>>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;未经允许,请勿转载。