本文整理了Java中org.apache.zookeeper.data.Stat.getCtime()
方法的一些代码示例,展示了Stat.getCtime()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Stat.getCtime()
方法的具体详情如下:
包路径:org.apache.zookeeper.data.Stat
类名称:Stat
方法名:getCtime
暂无
代码示例来源:origin: Netflix/curator
@Override
public long getCreateTime(String path) throws KeeperException, InterruptedException
{
try
{
Stat stat = curator.checkExists().forPath(path);
return (stat != null) ? stat.getCtime() : 0;
}
catch ( Exception e )
{
adjustException(e);
}
return 0;
}
代码示例来源: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: 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/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: Alluxio/alluxio
for (String master : masters) {
Stat stat = zookeeper.exists(PathUtils.concatPath(leaderPath, master), null);
if (stat != null && stat.getCtime() > maxTime) {
maxTime = stat.getCtime();
leader = master;
代码示例来源:origin: soabase/exhibitor
private void processNode(String path, NodeEntry parent) throws Exception
{
Stat stat = exhibitor.getLocalConnection().checkExists().forPath(path);
if ( stat == null )
{
return; // probably got deleted
}
NodeEntry entry = new NodeEntry(parent, stat.getNumChildren(), stat.getCtime());
details.put(path, entry);
entry.addToDeepCount(stat.getNumChildren());
if ( stat.getNumChildren() <= maxChildren )
{
List<String> children = exhibitor.getLocalConnection().getChildren().forPath(path);
for ( String child : children )
{
String thisPath = ZKPaths.makePath(path, child);
processNode(thisPath, entry);
}
}
}
}
代码示例来源:origin: liuyangming/ByteTCC
long createdAt = event.getStat().getCtime();
long interval = System.currentTimeMillis() - createdAt;
代码示例来源:origin: apache/zookeeper
private void create_get_stat_test()
throws IOException, InterruptedException, KeeperException {
checkRoot();
ZooKeeper zk = new ZooKeeper(hostPort, 10000, this);
String parentName = testDirOnZK;
String nodeName = parentName + "/create_with_stat_tmp";
deleteNodeIfExists(zk, nodeName);
deleteNodeIfExists(zk, nodeName + "_2");
Stat stat = new Stat();
zk.create(nodeName, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT,
stat);
Assert.assertNotNull(stat);
Assert.assertTrue(stat.getCzxid() > 0);
Assert.assertTrue(stat.getCtime() > 0);
Stat stat2 = new Stat();
zk.create(nodeName + "_2", null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT,
stat2);
Assert.assertNotNull(stat2);
Assert.assertTrue(stat2.getCzxid() > stat.getCzxid());
Assert.assertTrue(stat2.getCtime() > stat.getCtime());
deleteNodeIfExists(zk, nodeName);
deleteNodeIfExists(zk, nodeName + "_2");
zk.close();
}
代码示例来源:origin: apache/zookeeper
Assert.assertEquals(stat.getCtime(), stat.getMtime());
Assert.assertEquals(i + 1, stat.getCversion());
Assert.assertEquals(0, stat.getVersion());
代码示例来源: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
Assert.assertEquals(stat.getCtime(), stat.getMtime());
Assert.assertEquals(1, stat.getCversion());
Assert.assertEquals(0, stat.getVersion());
Assert.assertEquals(stat.getCtime(), stat.getMtime());
Assert.assertEquals(0, stat.getCversion());
Assert.assertEquals(0, stat.getVersion());
代码示例来源: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: 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(stat.getCtime(), stat.getMtime());
Assert.assertEquals(1, stat.getCversion());
Assert.assertEquals(0, stat.getVersion());
Assert.assertEquals(stat.getCtime(), stat.getMtime());
Assert.assertEquals(0, stat.getCversion());
Assert.assertEquals(0, stat.getVersion());
代码示例来源: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
Assert.assertEquals(stat.getCtime(), stat.getMtime());
Assert.assertEquals(0, stat.getCversion());
Assert.assertEquals(0, stat.getVersion());
Assert.assertNotSame(stat.getCtime(), stat.getMtime());
Assert.assertEquals(0, stat.getCversion());
Assert.assertEquals(1, stat.getVersion());
代码示例来源: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());
}
内容来源于网络,如有侵权,请联系作者删除!