org.apache.zookeeper.data.Stat.getVersion()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(154)

本文整理了Java中org.apache.zookeeper.data.Stat.getVersion()方法的一些代码示例,展示了Stat.getVersion()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Stat.getVersion()方法的具体详情如下:
包路径:org.apache.zookeeper.data.Stat
类名称:Stat
方法名:getVersion

Stat.getVersion介绍

暂无

代码示例

代码示例来源:origin: apache/zookeeper

public void print(Stat stat) {
    out.println("cZxid = 0x" + Long.toHexString(stat.getCzxid()));
    out.println("ctime = " + new Date(stat.getCtime()).toString());
    out.println("mZxid = 0x" + Long.toHexString(stat.getMzxid()));
    out.println("mtime = " + new Date(stat.getMtime()).toString());
    out.println("pZxid = 0x" + Long.toHexString(stat.getPzxid()));
    out.println("cversion = " + stat.getCversion());
    out.println("dataVersion = " + stat.getVersion());
    out.println("aclVersion = " + stat.getAversion());
    out.println("ephemeralOwner = 0x"
        + Long.toHexString(stat.getEphemeralOwner()));
    out.println("dataLength = " + stat.getDataLength());
    out.println("numChildren = " + stat.getNumChildren());
  }
}

代码示例来源:origin: apache/pulsar

ZKStat(org.apache.zookeeper.data.Stat stat) {
  this.version = stat.getVersion();
  this.creationTimestamp = stat.getCtime();
  this.modificationTimestamp = stat.getMtime();
}

代码示例来源:origin: apache/incubator-pinot

@Nullable
public static ZNRecord getZnRecord(@Nonnull ZkHelixPropertyStore<ZNRecord> propertyStore, @Nonnull String path) {
 Stat stat = new Stat();
 ZNRecord znRecord = propertyStore.get(path, stat, AccessOption.PERSISTENT);
 if (znRecord != null) {
  znRecord.setCreationTime(stat.getCtime());
  znRecord.setModifiedTime(stat.getMtime());
  znRecord.setVersion(stat.getVersion());
 }
 return znRecord;
}

代码示例来源:origin: alibaba/jstorm

public Integer getVersion(CuratorFramework zk, String path, boolean watch) throws Exception {
  String normPath = PathUtils.normalize_path(path);
  Stat stat;
  if (existsNode(zk, normPath, watch)) {
    if (watch) {
      stat = zk.checkExists().watched().forPath(PathUtils.normalize_path(path));
    } else {
      stat = zk.checkExists().forPath(PathUtils.normalize_path(path));
    }
    return stat.getVersion();
  }
  return null;
}

代码示例来源:origin: apache/hbase

private int getZNodeDataVersion(String znode) throws KeeperException {
 Stat stat = new Stat();
 ZKUtil.getDataNoWatch(ZKW, znode, stat);
 return stat.getVersion();
}

代码示例来源:origin: apache/incubator-gobblin

@Test
public void testCreateHelixCluster() throws Exception {
 // This is tested here instead of in HelixUtilsTest to avoid setting up yet another testing ZooKeeper server.
 HelixUtils
   .createGobblinHelixCluster(this.config.getString(GobblinClusterConfigurationKeys.ZK_CONNECTION_STRING_KEY),
     this.config.getString(GobblinClusterConfigurationKeys.HELIX_CLUSTER_NAME_KEY));
 // Assert to check if there is no pre-existing cluster
 Assert.assertEquals(this.curatorFramework.checkExists().forPath(String.format("/%s",
   this.helixClusterName)).getVersion(), 0);
 Assert.assertEquals(this.curatorFramework.checkExists().forPath(String.format("/%s/CONTROLLER",
   this.helixClusterName)).getVersion(), 0);
}

代码示例来源:origin: twitter/distributedlog

@Override
protected void commitOpResult(OpResult opResult) {
  assert(opResult instanceof OpResult.SetDataResult);
  OpResult.SetDataResult setDataResult = (OpResult.SetDataResult) opResult;
  listener.onCommit(new ZkVersion(setDataResult.getStat().getVersion()));
}

代码示例来源:origin: twitter/distributedlog

@Override
  public void processResult(int rc, String path, Object ctx, Stat stat) {
    if (KeeperException.Code.OK.intValue() == rc) {
      ZKAccessControl.this.zkVersion = stat.getVersion();
      promise.setValue(ZKAccessControl.this);
    } else {
      promise.setException(KeeperException.create(KeeperException.Code.get(rc)));
    }
  }
}, null);

代码示例来源:origin: apache/zookeeper

@Override
  public String toString() {
    return super.toString() + version
      + ":" + new String(data)
      + ":" + (stat == null ? "null" : stat.getAversion() + ":" 
          + stat.getCversion() + ":" + stat.getEphemeralOwner()
          + ":" + stat.getVersion()); 
  }
}

代码示例来源:origin: apache/zookeeper

@Override
  public String toString() {
    return super.toString()
      + ":" + (data == null ? "null" : new String(data))
      + ":" + (stat == null ? "null" : stat.getAversion() + ":" 
        + stat.getCversion() + ":" + stat.getEphemeralOwner()
        + ":" + stat.getVersion()); 
  }
}

代码示例来源:origin: apache/zookeeper

@Test
public void testNodeDataChanged() throws Exception {
  String path = "/test-changed";
  zk1.create(path, new byte[1], ZooDefs.Ids.OPEN_ACL_UNSAFE,
      CreateMode.PERSISTENT);
  Stat stat1 = zk1.exists(path, watcher);
  qu.shutdown(1);
  zk2.setData(path, new byte[2], stat1.getVersion());
  qu.start(1);
  watcher.waitForConnected(TIMEOUT);
  watcher.assertEvent(TIMEOUT, EventType.NodeDataChanged);
}

代码示例来源:origin: apache/zookeeper

@Override
  public String toString() {
    return super.toString() + toString(acl) + ":" 
      + ":" + version + ":" + new String(data)
      + ":" + (stat == null ? "null" : stat.getAversion() + ":" 
          + stat.getCversion() + ":" + stat.getEphemeralOwner()
          + ":" + stat.getVersion()); 
  }
}

代码示例来源:origin: apache/zookeeper

@Override
  public String toString() {
    return super.toString() + name + ":" +
      (stat == null ? "null" : stat.getAversion() + ":" +
         stat.getCversion() + ":" + stat.getEphemeralOwner() +
       ":" + stat.getVersion());
  }
}

代码示例来源:origin: twitter/distributedlog

@Override
  public void processResult(int rc, String path, Object ctx, Stat stat) {
    if (KeeperException.Code.OK.intValue() == rc) {
      promise.updateIfEmpty(new Return<ZkVersion>(new ZkVersion(stat.getVersion())));
      return;
    }
    promise.updateIfEmpty(new Throw<ZkVersion>(
        KeeperException.create(KeeperException.Code.get(rc))));
    return;
  }
}, null);

代码示例来源:origin: twitter/distributedlog

private static MaxLogSegmentSequenceNo getMaxLogSegmentSequenceNo(ZooKeeperClient zkc, URI uri, String streamName,
                                 DistributedLogConfiguration conf) throws Exception {
  Stat stat = new Stat();
  String logSegmentsPath = ZKLogMetadata.getLogSegmentsPath(
      uri, streamName, conf.getUnpartitionedStreamName());
  byte[] data = zkc.get().getData(logSegmentsPath, false, stat);
  Versioned<byte[]> maxLSSNData = new Versioned<byte[]>(data, new ZkVersion(stat.getVersion()));
  return new MaxLogSegmentSequenceNo(maxLSSNData);
}

代码示例来源:origin: twitter/distributedlog

@Override
  public void processResult(int rc, String path, Object ctx, String name, Stat stat) {
    if (KeeperException.Code.OK.intValue() == rc) {
      promise.setValue(new Versioned<byte[]>(DistributedLogConstants.EMPTY_BYTES,
          new ZkVersion(stat.getVersion())));
    } else if (KeeperException.Code.NODEEXISTS.intValue() == rc) {
      Utils.zkGetData(zkc, allocatePath, false).proxyTo(promise);
    } else {
      promise.setException(FutureUtils.zkException(
          KeeperException.create(KeeperException.Code.get(rc)), allocatePath));
    }
  }
}, null);

代码示例来源:origin: apache/zookeeper

@Test
public void testBasic()
  throws IOException, KeeperException, InterruptedException
{
  String name = "/foo";
  zk.create(name, name.getBytes(), Ids.OPEN_ACL_UNSAFE,
      CreateMode.PERSISTENT);
  Stat stat;
  stat = newStat();
  zk.getData(name, false, stat);
  Assert.assertEquals(stat.getCzxid(), stat.getMzxid());
  Assert.assertEquals(stat.getCzxid(), stat.getPzxid());
  Assert.assertEquals(stat.getCtime(), stat.getMtime());
  Assert.assertEquals(0, stat.getCversion());
  Assert.assertEquals(0, stat.getVersion());
  Assert.assertEquals(0, stat.getAversion());
  Assert.assertEquals(0, stat.getEphemeralOwner());
  Assert.assertEquals(name.length(), stat.getDataLength());
  Assert.assertEquals(0, stat.getNumChildren());
}

代码示例来源:origin: apache/zookeeper

static public void copyStat(Stat from, Stat to) {
  to.setAversion(from.getAversion());
  to.setCtime(from.getCtime());
  to.setCversion(from.getCversion());
  to.setCzxid(from.getCzxid());
  to.setMtime(from.getMtime());
  to.setMzxid(from.getMzxid());
  to.setPzxid(from.getPzxid());
  to.setVersion(from.getVersion());
  to.setEphemeralOwner(from.getEphemeralOwner());
  to.setDataLength(from.getDataLength());
  to.setNumChildren(from.getNumChildren());
}

代码示例来源:origin: apache/zookeeper

private void validateCreateStat(Stat stat, String name) {
    Assert.assertEquals(stat.getCzxid(), stat.getMzxid());
    Assert.assertEquals(stat.getCzxid(), stat.getPzxid());
    Assert.assertEquals(stat.getCtime(), stat.getMtime());
    Assert.assertEquals(0, stat.getCversion());
    Assert.assertEquals(0, stat.getVersion());
    Assert.assertEquals(0, stat.getAversion());
    Assert.assertEquals(0, stat.getEphemeralOwner());
    Assert.assertEquals(name.length(), stat.getDataLength());
    Assert.assertEquals(0, stat.getNumChildren());
  }
}

代码示例来源:origin: apache/zookeeper

private void validateCreateStat(Stat stat, String name) {
  Assert.assertEquals(stat.getCzxid(), stat.getMzxid());
  Assert.assertEquals(stat.getCzxid(), stat.getPzxid());
  Assert.assertEquals(stat.getCtime(), stat.getMtime());
  Assert.assertEquals(0, stat.getCversion());
  Assert.assertEquals(0, stat.getVersion());
  Assert.assertEquals(0, stat.getAversion());
  Assert.assertEquals(0, stat.getEphemeralOwner());
  Assert.assertEquals(name.length(), stat.getDataLength());
  Assert.assertEquals(0, stat.getNumChildren());
 }
}

相关文章