public class DataTree extends 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 |
---|---|
long |
lastProcessedZxid |
Constructor and Description |
---|
DataTree() |
Modifier and Type | Method and Description |
---|---|
int |
aclCacheSize() |
void |
addConfigNode()
create a /zookeeper/config node for maintaining the configuration (membership and quorum system) info for
zookeeper
|
long |
approximateDataSize()
Get the size of the nodes based on path and data length.
|
boolean |
containsWatcher(String path,
Watcher.WatcherType type,
Watcher watcher) |
static void |
copyStat(Stat from,
Stat to) |
static void |
copyStatPersisted(StatPersisted from,
StatPersisted to) |
void |
createNode(String path,
byte[] data,
List<ACL> acl,
long ephemeralOwner,
int parentCVersion,
long zxid,
long time)
Add a new node to the DataTree.
|
void |
createNode(String path,
byte[] data,
List<ACL> acl,
long ephemeralOwner,
int parentCVersion,
long zxid,
long time,
Stat outputStat)
Add a new node to the DataTree.
|
void |
deleteNode(String path,
long zxid)
remove the path from the datatree
|
void |
deserialize(InputArchive ia,
String tag) |
void |
dumpEphemerals(PrintWriter pwriter)
Write a text dump of all the ephemerals in the datatree.
|
void |
dumpWatches(PrintWriter pwriter,
boolean byPath)
Write a text dump of all the watches on the datatree.
|
void |
dumpWatchesSummary(PrintWriter pwriter)
Summary of the watches on the datatree.
|
List<ACL> |
getACL(DataNode node) |
List<ACL> |
getACL(String path,
Stat stat) |
List<String> |
getChildren(String path,
Stat stat,
Watcher watcher) |
Set<String> |
getContainers() |
byte[] |
getData(String path,
Stat stat,
Watcher watcher) |
Map<Long,Set<String>> |
getEphemerals()
Returns a mapping of session ID to ephemeral znodes.
|
Set<String> |
getEphemerals(long sessionId) |
int |
getEphemeralsCount() |
String |
getMaxPrefixWithQuota(String path)
If there is a quota set, return the appropriate prefix for that quota
Else return null
|
DataNode |
getNode(String path) |
int |
getNodeCount() |
ReferenceCountedACLCache |
getReferenceCountedAclCache() |
Collection<Long> |
getSessions() |
Set<String> |
getTtls() |
int |
getWatchCount() |
WatchesReport |
getWatches()
Returns a watch report.
|
WatchesPathReport |
getWatchesByPath()
Returns a watch report by path.
|
WatchesSummary |
getWatchesSummary()
Returns a watch summary.
|
DataTree.ProcessTxnResult |
processTxn(TxnHeader header,
Record txn) |
DataTree.ProcessTxnResult |
processTxn(TxnHeader header,
Record txn,
boolean isSubTxn) |
void |
removeCnxn(Watcher watcher) |
boolean |
removeWatch(String path,
Watcher.WatcherType type,
Watcher watcher) |
void |
serialize(OutputArchive oa,
String tag) |
void |
serializeNodeData(OutputArchive oa,
String path,
DataNode node) |
Stat |
setACL(String path,
List<ACL> acl,
int version) |
void |
setCversionPzxid(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(String path,
byte[] data,
int version,
long zxid,
long time) |
void |
setWatches(long relativeZxid,
List<String> dataWatches,
List<String> existWatches,
List<String> childWatches,
Watcher watcher) |
Stat |
statNode(String path,
Watcher watcher) |
void |
updateBytes(String lastPrefix,
long diff)
update the count of bytes of this stat datanode
|
void |
updateCount(String lastPrefix,
int diff)
update the count of this stat datanode
|
public Collection<Long> getSessions()
public int getNodeCount()
public int getWatchCount()
public int getEphemeralsCount()
public long approximateDataSize()
public void addConfigNode()
public static void copyStatPersisted(StatPersisted from, StatPersisted to)
public void updateCount(String lastPrefix, int diff)
lastPrefix
- the path of the node that is quotaed.diff
- the diff to be added to the countpublic void updateBytes(String lastPrefix, long diff)
lastPrefix
- the path of the node that is quotaeddiff
- the diff to added to number of bytesIOException
- if path is not foundpublic void createNode(String path, byte[] data, List<ACL> acl, long ephemeralOwner, int parentCVersion, long zxid, long time) throws KeeperException.NoNodeException, KeeperException.NodeExistsException
path
- Path for the new node.data
- Data to store in the node.acl
- Node aclsephemeralOwner
- the session id that owns this node. -1 indicates this is not
an ephemeral node.zxid
- Transaction IDtime
- KeeperException.NodeExistsException
KeeperException.NoNodeException
KeeperException
public void createNode(String path, byte[] data, List<ACL> acl, long ephemeralOwner, int parentCVersion, long zxid, long time, Stat outputStat) throws KeeperException.NoNodeException, KeeperException.NodeExistsException
path
- Path for the new node.data
- Data to store in the node.acl
- Node aclsephemeralOwner
- the session id that owns this node. -1 indicates this is not
an ephemeral node.zxid
- Transaction IDtime
- outputStat
- A Stat object to store Stat output results into.KeeperException.NodeExistsException
KeeperException.NoNodeException
KeeperException
public void deleteNode(String path, long zxid) throws KeeperException.NoNodeException
path
- the path to of the node to be deletedzxid
- the current zxidKeeperException.NoNodeException
public Stat setData(String path, byte[] data, int version, long zxid, long time) throws KeeperException.NoNodeException
KeeperException.NoNodeException
public String getMaxPrefixWithQuota(String path)
path
- The ZK path to check for quotapublic byte[] getData(String path, Stat stat, Watcher watcher) throws KeeperException.NoNodeException
KeeperException.NoNodeException
public Stat statNode(String path, Watcher watcher) throws KeeperException.NoNodeException
KeeperException.NoNodeException
public List<String> getChildren(String path, Stat stat, Watcher watcher) throws KeeperException.NoNodeException
KeeperException.NoNodeException
public Stat setACL(String path, List<ACL> acl, int version) throws KeeperException.NoNodeException
KeeperException.NoNodeException
public List<ACL> getACL(String path, Stat stat) throws KeeperException.NoNodeException
KeeperException.NoNodeException
public int aclCacheSize()
public DataTree.ProcessTxnResult processTxn(TxnHeader header, Record txn)
public DataTree.ProcessTxnResult processTxn(TxnHeader header, Record txn, boolean isSubTxn)
public void serializeNodeData(OutputArchive oa, String path, DataNode node) throws IOException
IOException
public void serialize(OutputArchive oa, String tag) throws IOException
IOException
public void deserialize(InputArchive ia, String tag) throws IOException
IOException
public void dumpWatchesSummary(PrintWriter pwriter)
pwriter
- the output to write topublic void dumpWatches(PrintWriter pwriter, boolean byPath)
pwriter
- the output to write topublic WatchesReport getWatches()
WatchesReport
public WatchesPathReport getWatchesByPath()
WatchesPathReport
public WatchesSummary getWatchesSummary()
WatchesSummary
public void dumpEphemerals(PrintWriter pwriter)
pwriter
- the output to write topublic Map<Long,Set<String>> getEphemerals()
public void removeCnxn(Watcher watcher)
public void setWatches(long relativeZxid, List<String> dataWatches, List<String> existWatches, List<String> childWatches, Watcher watcher)
public void setCversionPzxid(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.public boolean containsWatcher(String path, Watcher.WatcherType type, Watcher watcher)
public boolean removeWatch(String path, Watcher.WatcherType type, Watcher watcher)
public ReferenceCountedACLCache getReferenceCountedAclCache()
Copyright © 2008–2019 The Apache Software Foundation. All rights reserved.