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

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

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

Stat.getEphemeralOwner介绍

暂无

代码示例

代码示例来源: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: org.apache.zookeeper/zookeeper

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

代码示例来源: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

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

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

@Test(timeout = 60_000L)
 public void testStatusAnnouncementsArePersistent() throws Exception
 {
  cf.create()
   .creatingParentsIfNeeded()
   .forPath(joiner.join(tasksPath, task.getId()), jsonMapper.writeValueAsBytes(task));

  Assert.assertTrue(
    TestUtils.conditionValid(
      new IndexingServiceCondition()
      {
       @Override
       public boolean isValid()
       {
        try {
         return cf.checkExists().forPath(joiner.join(statusPath, task.getId())) != null;
        }
        catch (Exception e) {
         return false;
        }
       }
      }
    )
  );
  // ephemeral owner is 0 is created node is PERSISTENT
  Assert.assertEquals(0, cf.checkExists().forPath(joiner.join(statusPath, task.getId())).getEphemeralOwner());

 }
}

代码示例来源: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: 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

@Test
public void testModifying()
    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));
  for ( int i = 0; i < 10; ++i ) {
    fakeElapsed.set(50);
    zk.setData("/foo", new byte[i + 1], -1);
    containerManager.checkContainers();
    Assert.assertNotNull("Ttl node should not have been deleted yet", zk.exists("/foo", false));
  }
  fakeElapsed.set(200);
  containerManager.checkContainers();
  Assert.assertNull("Ttl node should have been deleted", zk.exists("/foo", false));
}

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

@Test
public void testChildren()
  throws IOException, KeeperException, InterruptedException
{
  String name = "/foo";
  zk.create(name, name.getBytes(), Ids.OPEN_ACL_UNSAFE,
      CreateMode.PERSISTENT);
  for(int i = 0; i < 10; i++) {
    String childname = name + "/bar" + i;
    zk.create(childname, childname.getBytes(), Ids.OPEN_ACL_UNSAFE,
        CreateMode.EPHEMERAL);
    Stat stat;
    stat = newStat();
    zk.getData(name, false, stat);
    Assert.assertEquals(stat.getCzxid(), stat.getMzxid());
    Assert.assertEquals(stat.getCzxid() + i + 1, stat.getPzxid());
    Assert.assertEquals(stat.getCtime(), stat.getMtime());
    Assert.assertEquals(i + 1, 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(i + 1, stat.getNumChildren());
  }
}

代码示例来源: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

Assert.assertEquals(0, stat.getVersion());
Assert.assertEquals(0, stat.getAversion());
Assert.assertEquals(0, stat.getEphemeralOwner());
Assert.assertEquals(name.length(), stat.getDataLength());
Assert.assertEquals(1, stat.getNumChildren());
Assert.assertEquals(0, stat.getVersion());
Assert.assertEquals(0, stat.getAversion());
Assert.assertEquals(zk.getSessionId(), stat.getEphemeralOwner());
Assert.assertEquals(childname.length(), stat.getDataLength());
Assert.assertEquals(0, stat.getNumChildren());

代码示例来源:origin: org.apache.zookeeper/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.setVersion(from.getVersion());
  to.setEphemeralOwner(from.getEphemeralOwner());
  to.setDataLength(from.getDataLength());
  to.setNumChildren(from.getNumChildren());
}

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

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());
Assert.assertEquals(1, stat.getVersion());
Assert.assertEquals(0, stat.getAversion());
Assert.assertEquals(0, stat.getEphemeralOwner());
Assert.assertEquals(name.length() * 2, 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());
  }
}

代码示例来源:origin: org.apache.zookeeper/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());
 }
}

相关文章