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 |
---|---|
boolean |
initialized |
long |
lastProcessedZxid |
Constructor and Description |
---|
DataTree() |
Modifier and Type | Method and Description |
---|---|
int |
aclCacheSize() |
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() |
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,
int parentCVersion,
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(DataNode node) |
java.lang.Long |
getACL(DataNodeV1 oldDataNode) |
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) |
int |
getEphemeralsCount() |
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() |
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) |
void |
setCversionPzxid(java.lang.String path,
int newCversion,
long zxid)
This method sets the Cversion and Pzxid for the specified node to the
values passed as arguments.
|
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 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.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 int getEphemeralsCount()
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, int parentCVersion, 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 java.lang.Long getACL(DataNodeV1 oldDataNode)
public int aclCacheSize()
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 setCversionPzxid(java.lang.String path, int newCversion, long zxid) throws KeeperException.NoNodeException
path
- Full path to the znode whose Cversion needs to be modified.
A "/" at the end of the path is ignored.newCversion
- Value to be assigned to Cversionzxid
- Value to be assigned to PzxidKeeperException.NoNodeException
- If znode not found.Copyright © 2024 The Apache Software Foundation