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

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

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

Stat.<init>介绍

暂无

代码示例

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

private byte[] getKey(ZooKeeperServer zks) {
  ZKDatabase db = zks.getZKDatabase();
  if (db != null) {
    try {
      Stat stat = new Stat();
      return db.getData("/key", stat, null);
    } catch (NoNodeException e) {
      LOG.error("getData failed", e);
    }
  }
  return null;
}

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

private void utestGet(int port)
  throws IOException, InterruptedException, KeeperException
{
  ZooKeeper zk =
    new ZooKeeper("127.0.0.1:" + port, CONNECTION_TIMEOUT, this);
  for (int i = 0; i < 10000; i++) {
    Stat stat = new Stat();
    zk.getData("/" + i, true, stat);
  }
  zk.close();
}

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

private void compareStat(String path, int sid, int compareWithSid) throws Exception{
  Stat stat1 = new Stat();
  zk[sid].getData(path, null, stat1);
  Stat stat2 = new Stat();
  zk[compareWithSid].getData(path, null, stat2);
  Assert.assertEquals(stat1, stat2);
}

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

public Stat statNode(String path, Watcher watcher)
    throws KeeperException.NoNodeException {
  Stat stat = new Stat();
  DataNode n = nodes.get(path);
  if (watcher != null) {
    dataWatches.addWatch(path, watcher);
  }
  if (n == null) {
    throw new KeeperException.NoNodeException();
  }
  synchronized (n) {
    n.copyStat(stat);
    return stat;
  }
}

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

public void deserialize(InputArchive a_, String tag) throws java.io.IOException {
  a_.startRecord(tag);
  stat= new org.apache.zookeeper.data.Stat();
  a_.readRecord(stat,"stat");
  a_.endRecord(tag);
}
 public String toString() {

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

public void deserialize(InputArchive a_, String tag) throws java.io.IOException {
  a_.startRecord(tag);
  stat= new org.apache.zookeeper.data.Stat();
  a_.readRecord(stat,"stat");
  a_.endRecord(tag);
}
 public String toString() {

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

private Stat create2EmptyNode(TestableZooKeeper zkClient, String path) throws Exception {
  Stat stat = new Stat();
  zkClient.create(path, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT, stat);
  return stat;
}

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

public void deserialize(InputArchive a_, String tag) throws java.io.IOException {
  a_.startRecord(tag);
  stat= new org.apache.zookeeper.data.Stat();
  a_.readRecord(stat,"stat");
  a_.endRecord(tag);
}
 public String toString() {

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

public void deserialize(InputArchive a_, String tag) throws java.io.IOException {
  a_.startRecord(tag);
  path=a_.readString("path");
  stat= new org.apache.zookeeper.data.Stat();
  a_.readRecord(stat,"stat");
  a_.endRecord(tag);
}
 public String toString() {

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

public void deserialize(InputArchive a_, String tag) throws java.io.IOException {
  a_.startRecord(tag);
  data=a_.readBuffer("data");
  stat= new org.apache.zookeeper.data.Stat();
  a_.readRecord(stat,"stat");
  a_.endRecord(tag);
}
 public String toString() {

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

private Stat createWithStatVerifyResult(String newName)
    throws KeeperException, InterruptedException {
  Assert.assertNull("Node existed before created", zk.exists(newName, false));
  Stat stat = new Stat();
  zk.create(newName, newName.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.CONTAINER, stat);
  validateCreateStat(stat, newName);
  Stat referenceStat = zk.exists(newName, false);
  Assert.assertNotNull("Node was not created as expected", referenceStat);
  Assert.assertEquals(referenceStat, stat);
  return stat;
}

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

@Test(expected = KeeperException.UnimplementedException.class)
public void testDisabled() throws KeeperException, InterruptedException {
  // note, setUp() enables this test based on the test name
  zk.create("/foo", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_WITH_TTL, new Stat(), 100);
}

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

private Stat createWithStatVerifyResult(String newName)
   throws KeeperException, InterruptedException {
 Assert.assertNull("Node existed before created", zk.exists(newName, false));
 Stat stat = new Stat();
 String path = zk.create(newName, newName.getBytes(),
             Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT, stat);
 Assert.assertEquals(path, newName);
 validateCreateStat(stat, newName);
 Stat referenceStat = zk.exists(newName, false);
 Assert.assertNotNull("Node was not created as expected", referenceStat);
 Assert.assertEquals(referenceStat, stat);
 return stat;
}

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

@Test
public void testSetAndGetACL() throws Exception {
  create2EmptyNode(zkClient, PARENT_PATH);
  Assert.assertEquals(
    String.format("%s Node has open ACL", serverState),
    Ids.OPEN_ACL_UNSAFE,
    zkClient.getACL(PARENT_PATH, new Stat()));
  zkClient.setACL(PARENT_PATH, Ids.READ_ACL_UNSAFE, -1);
  Assert.assertEquals(
    String.format("%s Node has world read-only ACL", serverState),
    Ids.READ_ACL_UNSAFE,
    zkClient.getACL(PARENT_PATH, new Stat()));
}

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

private boolean reconfigPort() throws KeeperException, InterruptedException {
    List<String> joiningServers = new ArrayList<String>();
    int leaderId = 1;
    while (qu.getPeer(leaderId).peer.leader == null)
      leaderId++;
    int followerId = leaderId == 1 ? 2 : 1;
    joiningServers.add("server." + followerId + "=localhost:"
        + qu.getPeer(followerId).peer.getQuorumAddress().getPort() /*quorum port*/
        + ":" + qu.getPeer(followerId).peer.getElectionAddress().getPort() /*election port*/
        + ":participant;localhost:" + PortAssignment.unique()/* new client port */);
    zkAdmin.reconfigure(joiningServers, null, null, -1, new Stat());
    return true;
  }
}

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

private boolean reconfigPort() throws KeeperException, InterruptedException {
    List<String> joiningServers = new ArrayList<String>();
    int leaderId = 1;
    while (qu.getPeer(leaderId).peer.leader == null)
      leaderId++;
    int followerId = leaderId == 1 ? 2 : 1;
    joiningServers.add("server." + followerId + "=localhost:"
        + qu.getPeer(followerId).peer.getQuorumAddress().getPort() /*quorum port*/
        + ":" + qu.getPeer(followerId).peer.getElectionAddress().getPort() /*election port*/
        + ":participant;localhost:" + PortAssignment.unique()/* new client port */);
    zkAdmin.reconfigure(joiningServers, null, null, -1, new Stat());
    return true;
  }
}

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

@Test
public void testCreate()
    throws KeeperException, InterruptedException {
  Stat stat = new Stat();
  zk.create("/foo", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_WITH_TTL, stat, 100);
  Assert.assertEquals(0, stat.getEphemeralOwner());
  final AtomicLong fakeElapsed = new AtomicLong(0);
  ContainerManager containerManager = newContainerManager(fakeElapsed);
  containerManager.checkContainers();
  Assert.assertNotNull("Ttl node should not have been deleted yet", zk.exists("/foo", false));
  fakeElapsed.set(1000);
  containerManager.checkContainers();
  Assert.assertNull("Ttl node should have been deleted", zk.exists("/foo", false));
}

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

@Test
public void testCreate()
    throws KeeperException, InterruptedException {
  Stat stat = new Stat();
  zk.create("/foo", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_WITH_TTL, stat, 100);
  Assert.assertEquals(0, stat.getEphemeralOwner());
  final AtomicLong fakeElapsed = new AtomicLong(0);
  ContainerManager containerManager = newContainerManager(fakeElapsed);
  containerManager.checkContainers();
  Assert.assertNotNull("Ttl node should not have been deleted yet", zk.exists("/foo", false));
  fakeElapsed.set(1000);
  containerManager.checkContainers();
  Assert.assertNull("Ttl node should have been deleted", zk.exists("/foo", false));
}

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

@Test
public void testCreateSequential()
    throws KeeperException, InterruptedException {
  Stat stat = new Stat();
  String path = zk.create("/foo", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL_WITH_TTL, stat, 100);
  Assert.assertEquals(0, stat.getEphemeralOwner());
  final AtomicLong fakeElapsed = new AtomicLong(0);
  ContainerManager containerManager = newContainerManager(fakeElapsed);
  containerManager.checkContainers();
  Assert.assertNotNull("Ttl node should not have been deleted yet", zk.exists(path, false));
  fakeElapsed.set(1000);
  containerManager.checkContainers();
  Assert.assertNull("Ttl node should have been deleted", zk.exists(path, false));
}

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

public void testRoundTrip() throws IOException {
  MultiResponse response = new MultiResponse();
  response.add(new OpResult.CheckResult());
  response.add(new OpResult.CreateResult("foo-bar"));
  response.add(new OpResult.DeleteResult());
  Stat s = new Stat();
  s.setCzxid(546);
  response.add(new OpResult.SetDataResult(s));
  MultiResponse decodedResponse = codeDecode(response);
  Assert.assertEquals(response, decodedResponse);
  Assert.assertEquals(response.hashCode(), decodedResponse.hashCode());
}

相关文章