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


Java Stat.getCzxid方法代码示例

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


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

示例1: getLastFailedRSFromZK

import org.apache.zookeeper.data.Stat; //导入方法依赖的package包/类
/**
 * Return the last failed RS name under /hbase/recovering-regions/encodedRegionName
 *
 * @param encodedRegionName
 * @throws KeeperException
 */
private String getLastFailedRSFromZK(String encodedRegionName) throws KeeperException {
  String result = null;
  long maxZxid = 0;
  ZooKeeperWatcher zkw = this.getZooKeeper();
  String nodePath = ZKUtil.joinZNode(zkw.recoveringRegionsZNode, encodedRegionName);
  List<String> failedServers = ZKUtil.listChildrenNoWatch(zkw, nodePath);
  if (failedServers == null || failedServers.isEmpty()) {
    return result;
  }
  for (String failedServer : failedServers) {
    String rsPath = ZKUtil.joinZNode(nodePath, failedServer);
    Stat stat = new Stat();
    ZKUtil.getDataNoWatch(zkw, rsPath, stat);
    if (maxZxid < stat.getCzxid()) {
      maxZxid = stat.getCzxid();
      result = failedServer;
    }
  }
  return result;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:27,代码来源:HRegionServer.java

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

示例3: testLocalSessionUpgrade

import org.apache.zookeeper.data.Stat; //导入方法依赖的package包/类
private void testLocalSessionUpgrade(boolean testLeader) throws Exception {

        int leaderIdx = qb.getLeaderIndex();
        Assert.assertFalse("No leader in quorum?", leaderIdx == -1);
        int followerIdx = (leaderIdx + 1) % 5;
        int testPeerIdx = testLeader ? leaderIdx : followerIdx;
        String hostPorts[] = qb.hostPort.split(",");

        CountdownWatcher watcher = new CountdownWatcher();
        ZooKeeper zk = qb.createClient(watcher, hostPorts[testPeerIdx],
                CONNECTION_TIMEOUT);
        watcher.waitForConnected(CONNECTION_TIMEOUT);

        final String firstPath = "/first";
        final String secondPath = "/ephemeral";

        // Just create some node so that we know the current zxid
        zk.create(firstPath, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE,
                CreateMode.PERSISTENT);

        // Now, try an ephemeral node. This will trigger session upgrade
        // so there will be createSession request inject into the pipeline
        // prior to this request
        zk.create(secondPath, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE,
                CreateMode.EPHEMERAL);

        Stat firstStat = zk.exists(firstPath, null);
        Assert.assertNotNull(firstStat);

        Stat secondStat = zk.exists(secondPath, null);
        Assert.assertNotNull(secondStat);

        long zxidDiff = secondStat.getCzxid() - firstStat.getCzxid();

        // If there is only one createSession request in between, zxid diff
        // will be exactly 2. The alternative way of checking is to actually
        // read txnlog but this should be sufficient
        Assert.assertEquals(2L, zxidDiff);

    }
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:41,代码来源:DuplicateLocalSessionUpgradeTest.java


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