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


Java Stat.getNumChildren方法代码示例

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


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

示例1: doWork

import org.apache.zookeeper.data.Stat; //导入方法依赖的package包/类
private void doWork()
{
  for ( String path : paths )
  {
    try
    {
      List<String> children = client.getChildren().forPath(path);
      for ( String name : children )
      {
        String thisPath = ZKPaths.makePath(path, name);
        Stat stat = client.checkExists().forPath(thisPath);
        if ( (stat != null) && (stat.getNumChildren() == 0) )
        {
          reaper.addPath(thisPath, mode);
        }
      }
    }
    catch ( Exception e )
    {
      log.error("Could not get children for path: " + path, e);
    }
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:24,代码来源:ChildReaper.java

示例2: countChildren

import org.apache.zookeeper.data.Stat; //导入方法依赖的package包/类
public int countChildren(String path) {
    try {
        Stat stat = new Stat();
        this.readData(path, stat);
        return stat.getNumChildren();
        //return getChildren(path).size();
    } catch (ZkNoNodeException e) {
        return -1;
    }
}
 
开发者ID:lemonJun,项目名称:TakinRPC,代码行数:11,代码来源:ZkClient.java

示例3: getNumChildren

import org.apache.zookeeper.data.Stat; //导入方法依赖的package包/类
public int getNumChildren(String nodePath) {
    if (connected) {
        try {
            Stat s = zooKeeper.exists(nodePath, false);
            if (s != null) {
                return s.getNumChildren();
            }
        } catch (Exception e) {
            LoggerFactory.getLogger().error(
                    "Error occurred getting the number of children of node: "
                            + nodePath, e);
        }
    }
    return -1;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:16,代码来源:ZooInspectorManagerImpl.java

示例4: setZNode

import org.apache.zookeeper.data.Stat; //导入方法依赖的package包/类
@PUT
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
        MediaType.APPLICATION_XML })
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public Response setZNode(
        @PathParam("path") String path,
        @QueryParam("callback") String callback,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @DefaultValue("base64") @QueryParam("dataformat") String dataformat,
        @DefaultValue("false") @QueryParam("null") String setNull,
        @Context UriInfo ui, byte[] data) throws InterruptedException,
        KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    if (setNull.equals("true")) {
        data = null;
    }

    Stat stat = zk.setData(path, data, version);

    ZStat zstat = new ZStat(path, ui.getAbsolutePath().toString(), null,
            null, stat.getCzxid(), stat.getMzxid(), stat.getCtime(), stat
                    .getMtime(), stat.getVersion(), stat.getCversion(),
            stat.getAversion(), stat.getEphemeralOwner(), stat
                    .getDataLength(), stat.getNumChildren(), stat
                    .getPzxid());

    return Response.status(Response.Status.OK).entity(
            new JSONWithPadding(zstat, callback)).build();
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:41,代码来源:ZNodeResource.java

示例5: getNumChildren

import org.apache.zookeeper.data.Stat; //导入方法依赖的package包/类
@Override
public int getNumChildren(final String key) {
	try {
		Stat stat = client.checkExists().forPath(key);
		if (null != stat) {
			return stat.getNumChildren();
		}
		// CHECKSTYLE:OFF
	} catch (final Exception ex) {
		// CHECKSTYLE:ON
		RegExceptionHandler.handleException(ex);
	}
	return 0;
}
 
开发者ID:imadcn,项目名称:idworker,代码行数:15,代码来源:ZookeeperRegistryCenter.java

示例6: getNumChildren

import org.apache.zookeeper.data.Stat; //导入方法依赖的package包/类
@Override
public int getNumChildren(final String key) {
    try {
        Stat stat = client.checkExists().forPath(key);
        if (null != stat) {
            return stat.getNumChildren();
        }
        //CHECKSTYLE:OFF
    } catch (final Exception ex) {
        //CHECKSTYLE:ON
        RegExceptionHandler.handleException(ex);
    }
    return 0;
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:15,代码来源:ZookeeperRegistryCenter.java

示例7: getNextProcessId

import org.apache.zookeeper.data.Stat; //导入方法依赖的package包/类
public Long getNextProcessId(Long channelId, Long pipelineId) {
    String processRoot = ManagePathUtils.getProcessRoot(channelId, pipelineId);
    IZkConnection connection = zookeeper.getConnection();
    // zkclient会将获取stat信息和正常的操作分开,使用原生的zk进行优化
    ZooKeeper orginZk = ((ZooKeeperx) connection).getZookeeper();

    Stat processParentStat = new Stat();
    // 获取所有的process列表
    try {
        orginZk.getChildren(processRoot, false, processParentStat);
        return (Long) ((processParentStat.getCversion() + processParentStat.getNumChildren()) / 2L);
    } catch (Exception e) {
        return -1L;
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:16,代码来源:ArbitrateViewServiceImpl.java


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