public class DataTree
extends java.lang.Object
The tree maintains two parallel data structures: a hashtable that maps from full paths to DataNodes and a tree of DataNodes. All accesses to a path is through the hashtable. The tree is traversed only when serializing to disk.
Modifier and Type | Class and Description |
---|---|
static class |
DataTree.ProcessTxnResult |
Modifier and Type | Field and Description |
---|---|
protected long |
aclIndex
these are the number of acls that we have in the datatree
|
java.util.Map<java.util.List<ACL>,java.lang.Long> |
aclKeyMap
this a map from acls to long.
|
boolean |
initialized |
long |
lastProcessedZxid |
java.util.Map<java.lang.Long,java.util.List<ACL>> |
longKeyMap
this is map from longs to acl's.
|
Constructor and Description |
---|
DataTree() |
Modifier and Type | Method and Description |
---|---|
void |
addDataNode(java.lang.String path,
DataNode node)
just an accessor method to allow raw creation of datatree's from a bunch
of datanodes
|
long |
approximateDataSize()
Get the size of the nodes based on path and data length.
|
void |
clear() |
java.lang.Long |
convertAcls(java.util.List<ACL> acls)
converts the list of acls to a list of longs.
|
java.util.List<ACL> |
convertLong(java.lang.Long longVal)
converts a list of longs to a list of acls.
|
static void |
copyStat(Stat from,
Stat to) |
static void |
copyStatPersisted(StatPersisted from,
StatPersisted to) |
java.lang.String |
createNode(java.lang.String path,
byte[] data,
java.util.List<ACL> acl,
long ephemeralOwner,
long zxid,
long time) |
void |
deleteNode(java.lang.String path,
long zxid)
remove the path from the datatree
|
void |
deserialize(org.apache.jute.InputArchive ia,
java.lang.String tag) |
void |
dumpEphemerals(java.io.PrintWriter pwriter)
Write a text dump of all the ephemerals in the datatree.
|
void |
dumpWatches(java.io.PrintWriter pwriter,
boolean byPath)
Write a text dump of all the watches on the datatree.
|
void |
dumpWatchesSummary(java.io.PrintWriter pwriter)
Summary of the watches on the datatree.
|
java.util.List<ACL> |
getACL(java.lang.String path,
Stat stat) |
java.util.List<java.lang.String> |
getChildren(java.lang.String path,
Stat stat,
Watcher watcher) |
byte[] |
getData(java.lang.String path,
Stat stat,
Watcher watcher) |
java.util.HashSet<java.lang.String> |
getEphemerals(long sessionId) |
java.util.Map<java.lang.Long,java.util.HashSet<java.lang.String>> |
getEphemeralsMap() |
java.lang.String |
getMaxPrefixWithQuota(java.lang.String path)
If there is a quota set, return the appropriate prefix for that quota
Else return null
|
DataNode |
getNode(java.lang.String path) |
int |
getNodeCount() |
java.util.Collection<java.lang.Long> |
getSessions() |
int |
getWatchCount() |
void |
incrementCversion(java.lang.String path,
long zxid)
If the znode for the specified path is found, then this method
increments the cversion and sets its pzxid to the zxid passed
in the second argument.
|
DataTree.ProcessTxnResult |
processTxn(TxnHeader header,
org.apache.jute.Record txn) |
void |
removeCnxn(Watcher watcher) |
void |
serialize(org.apache.jute.OutputArchive oa,
java.lang.String tag) |
Stat |
setACL(java.lang.String path,
java.util.List<ACL> acl,
int version) |
Stat |
setData(java.lang.String path,
byte[] data,
int version,
long zxid,
long time) |
void |
setWatches(long relativeZxid,
java.util.List<java.lang.String> dataWatches,
java.util.List<java.lang.String> existWatches,
java.util.List<java.lang.String> childWatches,
Watcher watcher) |
Stat |
statNode(java.lang.String path,
Watcher watcher) |
void |
updateBytes(java.lang.String lastPrefix,
long diff)
update the count of bytes of this stat datanode
|
void |
updateCount(java.lang.String lastPrefix,
int diff)
update the count of this stat datanode
|
public final java.util.Map<java.lang.Long,java.util.List<ACL>> longKeyMap
public final java.util.Map<java.util.List<ACL>,java.lang.Long> aclKeyMap
protected long aclIndex
public volatile long lastProcessedZxid
public boolean initialized
public java.util.HashSet<java.lang.String> getEphemerals(long sessionId)
public java.util.Map<java.lang.Long,java.util.HashSet<java.lang.String>> getEphemeralsMap()
public java.lang.Long convertAcls(java.util.List<ACL> acls)
acls
- public java.util.List<ACL> convertLong(java.lang.Long longVal)
longVal
- the list of longspublic java.util.Collection<java.lang.Long> getSessions()
public void addDataNode(java.lang.String path, DataNode node)
path
- the path of the datanodenode
- the datanode corresponding to this pathpublic DataNode getNode(java.lang.String path)
public int getNodeCount()
public int getWatchCount()
public long approximateDataSize()
public static void copyStatPersisted(StatPersisted from, StatPersisted to)
public void updateCount(java.lang.String lastPrefix, int diff)
lastPrefix
- the path of the node that is quotaed.diff
- the diff to be added to the countpublic void updateBytes(java.lang.String lastPrefix, long diff)
lastPrefix
- the path of the node that is quotaeddiff
- the diff to added to number of bytesjava.io.IOException
- if path is not foundpublic java.lang.String createNode(java.lang.String path, byte[] data, java.util.List<ACL> acl, long ephemeralOwner, long zxid, long time) throws KeeperException.NoNodeException, KeeperException.NodeExistsException
path
- data
- acl
- ephemeralOwner
- the session id that owns this node. -1 indicates this is not
an ephemeral node.zxid
- time
- KeeperException
KeeperException.NoNodeException
KeeperException.NodeExistsException
public void deleteNode(java.lang.String path, long zxid) throws KeeperException.NoNodeException
path
- the path to of the node to be deletedzxid
- the current zxidKeeperException.NoNodeException
public Stat setData(java.lang.String path, byte[] data, int version, long zxid, long time) throws KeeperException.NoNodeException
KeeperException.NoNodeException
public java.lang.String getMaxPrefixWithQuota(java.lang.String path)
path
- The ZK path to check for quotapublic byte[] getData(java.lang.String path, Stat stat, Watcher watcher) throws KeeperException.NoNodeException
KeeperException.NoNodeException
public Stat statNode(java.lang.String path, Watcher watcher) throws KeeperException.NoNodeException
KeeperException.NoNodeException
public java.util.List<java.lang.String> getChildren(java.lang.String path, Stat stat, Watcher watcher) throws KeeperException.NoNodeException
KeeperException.NoNodeException
public Stat setACL(java.lang.String path, java.util.List<ACL> acl, int version) throws KeeperException.NoNodeException
KeeperException.NoNodeException
public java.util.List<ACL> getACL(java.lang.String path, Stat stat) throws KeeperException.NoNodeException
KeeperException.NoNodeException
public DataTree.ProcessTxnResult processTxn(TxnHeader header, org.apache.jute.Record txn)
public void serialize(org.apache.jute.OutputArchive oa, java.lang.String tag) throws java.io.IOException
java.io.IOException
public void deserialize(org.apache.jute.InputArchive ia, java.lang.String tag) throws java.io.IOException
java.io.IOException
public void dumpWatchesSummary(java.io.PrintWriter pwriter)
pwriter
- the output to write topublic void dumpWatches(java.io.PrintWriter pwriter, boolean byPath)
pwriter
- the output to write topublic void dumpEphemerals(java.io.PrintWriter pwriter)
pwriter
- the output to write topublic void removeCnxn(Watcher watcher)
public void clear()
public void setWatches(long relativeZxid, java.util.List<java.lang.String> dataWatches, java.util.List<java.lang.String> existWatches, java.util.List<java.lang.String> childWatches, Watcher watcher)
public void incrementCversion(java.lang.String path, long zxid) throws KeeperException.NoNodeException
path
- Full path to the znode whose cversion needs to be incremented.
A "/" at the end of the path is ignored.zxid
- Value to be assigned to pzxidKeeperException.NoNodeException
- If znode not found.Copyright © 2012 The Apache Software Foundation