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


Java Stat.getEphemeralOwner方法代码示例

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


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

示例1: expireActiveLockHolder

import org.apache.zookeeper.data.Stat; //导入方法依赖的package包/类
/**
 * Expire the ZK session of the given service. This requires
 * (and asserts) that the given service be the current active.
 * @throws NoNodeException if no service holds the lock
 */
public void expireActiveLockHolder(int idx)
    throws NoNodeException {
  Stat stat = new Stat();
  byte[] data = zks.getZKDatabase().getData(
      DummyZKFC.LOCK_ZNODE, stat, null);
  
  assertArrayEquals(Ints.toByteArray(svcs.get(idx).index), data);
  long session = stat.getEphemeralOwner();
  LOG.info("Expiring svc " + idx + "'s zookeeper session " + session);
  zks.closeSession(session);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:17,代码来源:MiniZKFCCluster.java

示例2: isAllowsChildren

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

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

示例4: expireActiveLockHolder

import org.apache.zookeeper.data.Stat; //导入方法依赖的package包/类
/**
 * Expire the ZK session of the given service. This requires
 * (and asserts) that the given service be the current active.
 * @throws NoNodeException if no service holds the lock
 */
public void expireActiveLockHolder(int idx)
    throws NoNodeException {
  Stat stat = new Stat();
  byte[] data = zks.getZKDatabase().getData(
      DummyZKFC.LOCK_ZNODE, stat, null);
  
  assertArrayEquals(Ints.toByteArray(svcs[idx].index), data);
  long session = stat.getEphemeralOwner();
  LOG.info("Expiring svc " + idx + "'s zookeeper session " + session);
  zks.closeSession(session);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:MiniZKFCCluster.java

示例5: expand

import org.apache.zookeeper.data.Stat; //导入方法依赖的package包/类
/**
 * Recursively expand the path into the supplied string builder, increasing
 * the indentation by {@link #INDENT} as it proceeds (depth first) down
 * the tree
 * @param builder string build to append to
 * @param path path to examine
 * @param indent current indentation
 */
private void expand(StringBuilder builder,
    String path,
    int indent) {
  try {
    GetChildrenBuilder childrenBuilder = curator.getChildren();
    List<String> children = childrenBuilder.forPath(path);
    for (String child : children) {
      String childPath = path + "/" + child;
      String body;
      Stat stat = curator.checkExists().forPath(childPath);
      StringBuilder bodyBuilder = new StringBuilder(256);
      bodyBuilder.append("  [")
                        .append(stat.getDataLength())
                        .append("]");
      if (stat.getEphemeralOwner() > 0) {
        bodyBuilder.append("*");
      }
      if (verbose) {
        // verbose: extract ACLs
        builder.append(" -- ");
        List<ACL> acls =
            curator.getACL().forPath(childPath);
        for (ACL acl : acls) {
          builder.append(RegistrySecurity.aclToString(acl));
          builder.append(" ");
        }
      }
      body = bodyBuilder.toString();
      // print each child
      append(builder, indent, ' ');
      builder.append('/').append(child);
      builder.append(body);
      builder.append('\n');
      // recurse
      expand(builder, childPath, indent + INDENT);
    }
  } catch (Exception e) {
    builder.append(e.toString()).append("\n");
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:49,代码来源:ZKPathDumper.java


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