本文整理汇总了Java中org.apache.zookeeper.data.StatPersisted类的典型用法代码示例。如果您正苦于以下问题:Java StatPersisted类的具体用法?Java StatPersisted怎么用?Java StatPersisted使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StatPersisted类属于org.apache.zookeeper.data包,在下文中一共展示了StatPersisted类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertStat
import org.apache.zookeeper.data.StatPersisted; //导入依赖的package包/类
/**
* convert the old stat to new stat
* @param oldStat the old stat
* @return the new stat
*/
private StatPersisted convertStat(StatPersistedV1 oldStat) {
StatPersisted stat = new StatPersisted();
stat.setAversion(oldStat.getAversion());
stat.setCtime(oldStat.getCtime());
stat.setCversion(oldStat.getCversion());
stat.setCzxid(oldStat.getCzxid());
stat.setEphemeralOwner(oldStat.getEphemeralOwner());
stat.setMtime(oldStat.getMtime());
stat.setMzxid(oldStat.getMzxid());
stat.setVersion(oldStat.getVersion());
return stat;
}
示例2: convertDataNode
import org.apache.zookeeper.data.StatPersisted; //导入依赖的package包/类
/**
* convert a given old datanode to new datanode
* @param dt the new datatree
* @param parent the parent of the datanode to be constructed
* @param oldDataNode the old datanode
* @return the new datanode
*/
private DataNode convertDataNode(DataTree dt, DataNode parent,
DataNodeV1 oldDataNode) {
StatPersisted stat = convertStat(oldDataNode.stat);
DataNode dataNode = new DataNode(parent, oldDataNode.data,
dt.getACL(oldDataNode), stat);
dataNode.setChildren(oldDataNode.children);
return dataNode;
}
示例3: deserialize
import org.apache.zookeeper.data.StatPersisted; //导入依赖的package包/类
synchronized public void deserialize(InputArchive archive, String tag)
throws IOException {
archive.startRecord("node");
data = archive.readBuffer("data");
acl = archive.readLong("acl");
stat = new StatPersisted();
stat.deserialize(archive, "statpersisted");
archive.endRecord("node");
}
示例4: copyStatPersisted
import org.apache.zookeeper.data.StatPersisted; //导入依赖的package包/类
static public void copyStatPersisted(StatPersisted from, StatPersisted 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());
}
示例5: serializeNode
import org.apache.zookeeper.data.StatPersisted; //导入依赖的package包/类
/**
* this method uses a stringbuilder to create a new path for children. This
* is faster than string appends ( str1 + str2).
*
* @param oa
* OutputArchive to write to.
* @param path
* a string builder.
* @throws IOException
* @throws InterruptedException
*/
void serializeNode(OutputArchive oa, StringBuilder path) throws IOException {
String pathString = path.toString();
DataNode node = getNode(pathString);
if (node == null) {
return;
}
String children[] = null;
DataNode nodeCopy;
synchronized (node) {
scount++;
StatPersisted statCopy = new StatPersisted();
copyStatPersisted(node.stat, statCopy);
//we do not need to make a copy of node.data because the contents
//are never changed
nodeCopy = new DataNode(node.parent, node.data, node.acl, statCopy);
Set<String> childs = node.getChildren();
if (childs != null) {
children = childs.toArray(new String[childs.size()]);
}
}
oa.writeString(pathString, "path");
oa.writeRecord(nodeCopy, "node");
path.append('/');
int off = path.length();
if (children != null) {
for (String child : children) {
// since this is single buffer being resused
// we need
// to truncate the previous bytes of string.
path.delete(off, Integer.MAX_VALUE);
path.append(child);
serializeNode(oa, path);
}
}
}
示例6: printStat
import org.apache.zookeeper.data.StatPersisted; //导入依赖的package包/类
private void printStat(StatPersisted stat) {
printHex("cZxid", stat.getCzxid());
System.out.println(" ctime = " + new Date(stat.getCtime()).toString());
printHex("mZxid", stat.getMzxid());
System.out.println(" mtime = " + new Date(stat.getMtime()).toString());
printHex("pZxid", stat.getPzxid());
System.out.println(" cversion = " + stat.getCversion());
System.out.println(" dataVersion = " + stat.getVersion());
System.out.println(" aclVersion = " + stat.getAversion());
printHex("ephemeralOwner", stat.getEphemeralOwner());
}
示例7: ChangeRecord
import org.apache.zookeeper.data.StatPersisted; //导入依赖的package包/类
ChangeRecord(long zxid, String path, StatPersisted stat, int childCount,
List<ACL> acl) {
this.zxid = zxid;
this.path = path;
this.stat = stat;
this.childCount = childCount;
this.acl = acl;
}
示例8: duplicate
import org.apache.zookeeper.data.StatPersisted; //导入依赖的package包/类
@SuppressWarnings("unchecked")
ChangeRecord duplicate(long zxid) {
StatPersisted stat = new StatPersisted();
if (this.stat != null) {
DataTree.copyStatPersisted(this.stat, stat);
}
return new ChangeRecord(zxid, path, stat, childCount,
acl == null ? new ArrayList<ACL>() : new ArrayList(acl));
}
示例9: getClientEphemeralOwner
import org.apache.zookeeper.data.StatPersisted; //导入依赖的package包/类
private static long getClientEphemeralOwner(StatPersisted stat) {
EphemeralType ephemeralType = EphemeralType.get(stat.getEphemeralOwner());
if (ephemeralType != EphemeralType.NORMAL) {
return 0;
}
return stat.getEphemeralOwner();
}
示例10: serializeNode
import org.apache.zookeeper.data.StatPersisted; //导入依赖的package包/类
/**
* this method uses a stringbuilder to create a new path for children. This
* is faster than string appends ( str1 + str2).
*
* @param oa
* OutputArchive to write to.
* @param path
* a string builder.
* @throws IOException
* @throws InterruptedException
*/
void serializeNode(OutputArchive oa, StringBuilder path) throws IOException {
String pathString = path.toString();
DataNode node = getNode(pathString);
if (node == null) {
return;
}
String children[] = null;
DataNode nodeCopy;
synchronized (node) {
StatPersisted statCopy = new StatPersisted();
copyStatPersisted(node.stat, statCopy);
//we do not need to make a copy of node.data because the contents
//are never changed
nodeCopy = new DataNode(node.data, node.acl, statCopy);
Set<String> childs = node.getChildren();
children = childs.toArray(new String[childs.size()]);
}
oa.writeString(pathString, "path");
oa.writeRecord(nodeCopy, "node");
path.append('/');
int off = path.length();
for (String child : children) {
// since this is single buffer being resused
// we need
// to truncate the previous bytes of string.
path.delete(off, Integer.MAX_VALUE);
path.append(child);
serializeNode(oa, path);
}
}
示例11: duplicate
import org.apache.zookeeper.data.StatPersisted; //导入依赖的package包/类
ChangeRecord duplicate(long zxid) {
StatPersisted stat = new StatPersisted();
if (this.stat != null) {
DataTree.copyStatPersisted(this.stat, stat);
}
return new ChangeRecord(zxid, path, stat, childCount,
acl == null ? new ArrayList<ACL>() : new ArrayList<ACL>(acl));
}
示例12: serializeNode
import org.apache.zookeeper.data.StatPersisted; //导入依赖的package包/类
/**
* this method uses a stringbuilder to create a new path for children. This
* is faster than string appends ( str1 + str2).
*
* @param oa
* OutputArchive to write to.
* @param path
* a string builder.
* @throws IOException
* @throws InterruptedException
*/
void serializeNode(OutputArchive oa, StringBuilder path) throws IOException {
String pathString = path.toString();
DataNode node = getNode(pathString);
if (node == null) {
return;
}
String children[] = null;
DataNode nodeCopy;
synchronized (node) {
scount++;
StatPersisted statCopy = new StatPersisted();
copyStatPersisted(node.stat, statCopy);
//we do not need to make a copy of node.data because the contents
//are never changed
nodeCopy = new DataNode(node.parent, node.data, node.acl, statCopy);
Set<String> childs = node.getChildren();
children = childs.toArray(new String[childs.size()]);
}
oa.writeString(pathString, "path");
oa.writeRecord(nodeCopy, "node");
path.append('/');
int off = path.length();
for (String child : children) {
// since this is single buffer being resused
// we need
// to truncate the previous bytes of string.
path.delete(off, Integer.MAX_VALUE);
path.append(child);
serializeNode(oa, path);
}
}
示例13: convertDataNode
import org.apache.zookeeper.data.StatPersisted; //导入依赖的package包/类
/**
* convert a given old datanode to new datanode
* @param dt the new datatree
* @param parent the parent of the datanode to be constructed
* @param oldDataNode the old datanode
* @return the new datanode
*/
private DataNode convertDataNode(DataTree dt, DataNode parent,
DataNodeV1 oldDataNode) {
StatPersisted stat = convertStat(oldDataNode.stat);
DataNode dataNode = new DataNode(parent, oldDataNode.data,
dt.convertAcls(oldDataNode.acl), stat);
dataNode.setChildren(oldDataNode.children);
return dataNode;
}