Package org.apache.zookeeper.server
Class DataNode
java.lang.Object
org.apache.zookeeper.server.DataNode
- All Implemented Interfaces:
Record
This class contains the data for a node in the data tree.
A data node contains a reference to its parent, a byte array as its data, an array of ACLs, a stat object, and a set of its children's paths.
-
Field Summary
FieldsModifier and TypeFieldDescriptionthe stat for this node that is persisted to disk. -
Constructor Summary
ConstructorsConstructorDescriptionDataNode(byte[] data, Long acl, StatPersisted stat) create a DataNode with parent, data, acls and stat -
Method Summary
Modifier and TypeMethodDescriptionbooleanMethod that inserts a child into the children setvoidvoiddeserialize(InputArchive archive, String tag) convenience methods to get the childrenbyte[]getData()longbooleanbooleanremoveChild(String child) Method that removes a child from the children setvoidserialize(OutputArchive archive, String tag) voidsetChildren(HashSet<String> children) convenience method for setting the children for this datanodevoidsetDigest(long digest) voidsetDigestCached(boolean digestCached)
-
Field Details
-
stat
the stat for this node that is persisted to disk.
-
-
Constructor Details
-
DataNode
create a DataNode with parent, data, acls and stat- Parameters:
data- the data to be setacl- the acls for this nodestat- the stat for this node.
-
-
Method Details
-
addChild
Method that inserts a child into the children set- Parameters:
child- to be inserted- Returns:
- true if this set did not already contain the specified element
-
removeChild
Method that removes a child from the children set- Parameters:
child-- Returns:
- true if this set contained the specified element
-
setChildren
convenience method for setting the children for this datanode- Parameters:
children-
-
getChildren
convenience methods to get the children- Returns:
- the children of this datanode. If the datanode has no children, empty set is returned
-
copyStat
-
deserialize
- Specified by:
deserializein interfaceRecord- Throws:
IOException
-
serialize
- Specified by:
serializein interfaceRecord- Throws:
IOException
-
isDigestCached
public boolean isDigestCached() -
setDigestCached
public void setDigestCached(boolean digestCached) -
getDigest
public long getDigest() -
setDigest
public void setDigest(long digest) -
getData
public byte[] getData()
-