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


Java ChildData类代码示例

本文整理汇总了Java中org.apache.curator.framework.recipes.cache.ChildData的典型用法代码示例。如果您正苦于以下问题:Java ChildData类的具体用法?Java ChildData怎么用?Java ChildData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: processTokenAddOrUpdate

import org.apache.curator.framework.recipes.cache.ChildData; //导入依赖的package包/类
private void processTokenAddOrUpdate(ChildData data) throws IOException {
  ByteArrayInputStream bin = new ByteArrayInputStream(data.getData());
  DataInputStream din = new DataInputStream(bin);
  TokenIdent ident = createIdentifier();
  ident.readFields(din);
  long renewDate = din.readLong();
  int pwdLen = din.readInt();
  byte[] password = new byte[pwdLen];
  int numRead = din.read(password, 0, pwdLen);
  if (numRead > -1) {
    DelegationTokenInformation tokenInfo =
        new DelegationTokenInformation(renewDate, password);
    synchronized (this) {
      currentTokens.put(ident, tokenInfo);
      // The cancel task might be waiting
      notifyAll();
    }
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:20,代码来源:ZKDelegationTokenSecretManager.java

示例2: addChild

import org.apache.curator.framework.recipes.cache.ChildData; //导入依赖的package包/类
/**
 * add instance;
 *
 * @param data
 */
private void addChild(ChildData data) {
    if (data == null
            || ArrayUtils.isEmpty(data.getData())) {
        return;
    }

    try {
        ServiceInstance<RpcPayload> instance = serializer.deserialize(data
                .getData());
        this.onInstanceAdded(instance);
    } catch (Exception ex) {
        LOG.error("Could not add zk node " + data.getPath() + " to pool.",
                ex);
    }
}
 
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:21,代码来源:RefreshableTransportPool.java

示例3: childEvent

import org.apache.curator.framework.recipes.cache.ChildData; //导入依赖的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

示例4: startInitialTasks

import org.apache.curator.framework.recipes.cache.ChildData; //导入依赖的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

示例5: onChanged

import org.apache.curator.framework.recipes.cache.ChildData; //导入依赖的package包/类
@Override
public void onChanged(TreeCacheEvent event) {
    ChildData data = event.getData();
    if (data == null) {
        return;
    }

    String path = data.getPath();
    switch (event.getType()) {
        case NODE_ADDED:
        case NODE_REMOVED:
        case NODE_UPDATED: {
            boolean isFullHostPath = StringUtils.isNotBlank(path) && path.split(RedirectorConstants.DELIMETER).length == 7;
            if (isFullHostPath && path.contains(RedirectorConstants.DELIMETER + applicationName + RedirectorConstants.DELIMETER)) {
                snapshotNeeded = true;
            }
            break;
        }
    }
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:21,代码来源:SnapshotManager.java

示例6: getCurrentData

import org.apache.curator.framework.recipes.cache.ChildData; //导入依赖的package包/类
@Override
public byte[] getCurrentData() {
    byte[] result = null;
    if (isCacheUsageAllowed()) {
        ChildData data = cache.getCurrentData();
        if (data != null) {
            result = data.getData();
        }
    } else {
        try {
            result = dataIsCompressed ? connector.getDataDecompressed(path) : connector.getData(path);
        } catch (DataSourceConnectorException e) {
            log.warn("Failed to get data for zkPath={} {}", path);
        }
    }
    return result;
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:18,代码来源:ZkNodeCacheWrapper.java

示例7: getCurrentDataVersion

import org.apache.curator.framework.recipes.cache.ChildData; //导入依赖的package包/类
@Override
public int getCurrentDataVersion() {
    int result = RedirectorConstants.NO_MODEL_NODE_VERSION;
    if (isCacheUsageAllowed()) {
        ChildData data = cache.getCurrentData();
        if (data != null && data.getStat() != null) {
            result = data.getStat().getVersion();
        }
    } else {
        try {
            if (connector.isPathExists(path)) {
                result = connector.getNodeVersion(path);
            } else {
                log.warn("Node {} does not exist", path);
            }
        } catch (DataSourceConnectorException e) {
            log.error("Failed to get data for zkPath={} {}", path, e);
        }
    }
    return result;
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:22,代码来源:ZkNodeCacheWrapper.java

示例8: Namespaces

import org.apache.curator.framework.recipes.cache.ChildData; //导入依赖的package包/类
/**
 * Create a zookeeper-based namespace service
 * @param client the curator client
 * @param cache the treecache
 * @param filePath the file
 */
public Namespaces(final CuratorFramework client, final TreeCache cache, final String filePath) {
    requireNonNull(cache, "TreeCache may not be null!");
    this.client = client;
    this.cache = cache;
    try {
        this.client.create().orSetData().forPath(ZNODE_NAMESPACES);
        this.cache.getListenable().addListener((c, e) -> {
            final Map<String, ChildData> tree = cache.getCurrentChildren(ZNODE_NAMESPACES);
            readTree(tree).forEach(data::put);
        });
        init(filePath).forEach(data::put);
    } catch (final Exception ex) {
        LOGGER.error("Could not create a zk node cache: {}", ex);
        throw new RuntimeTrellisException(ex);
    }
}
 
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:23,代码来源:Namespaces.java

示例9: childEvent

import org.apache.curator.framework.recipes.cache.ChildData; //导入依赖的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

示例10: lockTableByNewNode

import org.apache.curator.framework.recipes.cache.ChildData; //导入依赖的package包/类
private void lockTableByNewNode(ChildData childData) throws Exception {
    String data = new String(childData.getData(), StandardCharsets.UTF_8);
    LOGGER.info("DDL node " + childData.getPath() + " created , and data is " + data);
    DDLInfo ddlInfo = new DDLInfo(data);
    final String fromNode = ddlInfo.getFrom();
    if (fromNode.equals(ZkConfig.getInstance().getValue(ZkParamCfg.ZK_CFG_MYID))) {
        return; //self node
    }
    if (DDLStatus.INIT != ddlInfo.getStatus()) {
        return;
    }
    String nodeName = childData.getPath().substring(childData.getPath().lastIndexOf("/") + 1);
    String[] tableInfo = nodeName.split("\\.");
    final String schema = StringUtil.removeBackQuote(tableInfo[0]);
    final String table = StringUtil.removeBackQuote(tableInfo[1]);
    try {
        DbleServer.getInstance().getTmManager().addMetaLock(schema, table);
    } catch (Exception t) {
        DbleServer.getInstance().getTmManager().removeMetaLock(schema, table);
        throw t;
    }
}
 
开发者ID:actiontech,项目名称:dble,代码行数:23,代码来源:DDLChildListener.java

示例11: childEvent

import org.apache.curator.framework.recipes.cache.ChildData; //导入依赖的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

示例12: createOrUpdateViewMeta

import org.apache.curator.framework.recipes.cache.ChildData; //导入依赖的package包/类
/**
 * update the meta if the view updated
 */
private void createOrUpdateViewMeta(ChildData childData, boolean isReplace) throws Exception {
    String path = childData.getPath();
    String[] paths = path.split("/");
    String jsonValue = new String(childData.getData(), StandardCharsets.UTF_8);
    JSONObject obj = (JSONObject) JSONObject.parse(jsonValue);

    //if the view is create or replace by this server it self
    String serverId = obj.getString(SERVER_ID);
    if (serverId.equals(ZkConfig.getInstance().getValue(ZkParamCfg.ZK_CFG_MYID))) {
        return;
    }
    String createSql = obj.getString(CREATE_SQL);
    String schema = paths[paths.length - 1].split(SCHEMA_VIEW_SPLIT)[0];

    ViewMeta vm = new ViewMeta(createSql, schema, DbleServer.getInstance().getTmManager());
    vm.initAndSet(isReplace);

}
 
开发者ID:actiontech,项目名称:dble,代码行数:22,代码来源:ViewChildListener.java

示例13: childEvent

import org.apache.curator.framework.recipes.cache.ChildData; //导入依赖的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

示例14: childEvent

import org.apache.curator.framework.recipes.cache.ChildData; //导入依赖的package包/类
@Override
public void childEvent(CuratorFramework curator, TreeCacheEvent event) throws Exception {
    ChildData data = event.getData();
    if (data == null) return;
    String dataPath = data.getPath();
    if (Strings.isNullOrEmpty(dataPath)) return;
    if (dataPath.startsWith(watchPath)) {
        switch (event.getType()) {
            case NODE_ADDED:
                listener.onServiceAdded(dataPath, Jsons.fromJson(data.getData(), CommonServiceNode.class));
                break;
            case NODE_REMOVED:
                listener.onServiceRemoved(dataPath, Jsons.fromJson(data.getData(), CommonServiceNode.class));
                break;
            case NODE_UPDATED:
                listener.onServiceUpdated(dataPath, Jsons.fromJson(data.getData(), CommonServiceNode.class));
                break;
        }
        Logs.RSD.info("ZK node data change={}, nodePath={}, watchPath={}, ns={}");
    }
}
 
开发者ID:mpusher,项目名称:mpush,代码行数:22,代码来源:ZKCacheListener.java

示例15: get

import org.apache.curator.framework.recipes.cache.ChildData; //导入依赖的package包/类
@Override
public void get(K k, Handler<AsyncResult<ChoosableIterable<V>>> asyncResultHandler) {
  if (!keyIsNull(k, asyncResultHandler)) {
    vertx.runOnContext(event -> {
      Map<String, ChildData> maps = curatorCache.getCurrentChildren(keyPath(k));
      ChoosableSet<V> choosableSet = new ChoosableSet<>(0);
      if (maps != null) {
        for (ChildData childData : maps.values()) {
          try {
            if (childData != null && childData.getData() != null && childData.getData().length > 0)
              choosableSet.add(asObject(childData.getData()));
          } catch (Exception ex) {
            asyncResultHandler.handle(Future.failedFuture(ex));
          }
        }
      }
      asyncResultHandler.handle(Future.succeededFuture(choosableSet));
    });
  }
}
 
开发者ID:IBYoung,项目名称:vert.3x-gateway,代码行数:21,代码来源:ZKAsyncMultiMap.java


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