|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.zookeeper.server.DataTree
public class DataTree
This class maintains the tree data structure. It doesn't have any networking or client connection code in it so that it can be tested in a stand alone way.
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.
Nested Class Summary | |
---|---|
static class |
DataTree.ProcessTxnResult
|
Field Summary | |
---|---|
protected long |
aclIndex
these are the number of acls that we have in the datatree |
Map<List<org.apache.zookeeper.data.ACL>,Long> |
aclKeyMap
this a map from acls to long. |
boolean |
initialized
|
long |
lastProcessedZxid
|
Map<Long,List<org.apache.zookeeper.data.ACL>> |
longKeyMap
this is map from longs to acl's. |
Constructor Summary | |
---|---|
DataTree()
|
Method Summary | |
---|---|
void |
addDataNode(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()
|
Long |
convertAcls(List<org.apache.zookeeper.data.ACL> acls)
converts the list of acls to a list of longs. |
List<org.apache.zookeeper.data.ACL> |
convertLong(Long longVal)
converts a list of longs to a list of acls. |
static void |
copyStat(org.apache.zookeeper.data.Stat from,
org.apache.zookeeper.data.Stat to)
|
static void |
copyStatPersisted(org.apache.zookeeper.data.StatPersisted from,
org.apache.zookeeper.data.StatPersisted to)
|
String |
createNode(String path,
byte[] data,
List<org.apache.zookeeper.data.ACL> acl,
long ephemeralOwner,
long zxid,
long time)
|
void |
deleteNode(String path,
long zxid)
remove the path from the datatree |
void |
deserialize(InputArchive ia,
String tag)
|
String |
dumpEphemerals()
|
List<org.apache.zookeeper.data.ACL> |
getACL(String path,
org.apache.zookeeper.data.Stat stat)
|
List<String> |
getChildren(String path,
org.apache.zookeeper.data.Stat stat,
Watcher watcher)
|
byte[] |
getData(String path,
org.apache.zookeeper.data.Stat stat,
Watcher watcher)
|
HashSet<String> |
getEphemerals(long sessionId)
|
Map<Long,HashSet<String>> |
getEphemeralsMap()
|
DataNode |
getNode(String path)
|
int |
getNodeCount()
|
Collection<Long> |
getSessions()
|
int |
getWatchCount()
|
DataTree.ProcessTxnResult |
processTxn(org.apache.zookeeper.txn.TxnHeader header,
Record txn)
|
void |
removeCnxn(Watcher watcher)
|
void |
serialize(OutputArchive oa,
String tag)
|
org.apache.zookeeper.data.Stat |
setACL(String path,
List<org.apache.zookeeper.data.ACL> acl,
int version)
|
org.apache.zookeeper.data.Stat |
setData(String path,
byte[] data,
int version,
long zxid,
long time)
|
void |
setEphemerals(Map<Long,HashSet<String>> ephemerals)
|
void |
setWatches(long relativeZxid,
List<String> dataWatches,
List<String> existWatches,
List<String> childWatches,
Watcher watcher)
|
org.apache.zookeeper.data.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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public Map<Long,List<org.apache.zookeeper.data.ACL>> longKeyMap
public Map<List<org.apache.zookeeper.data.ACL>,Long> aclKeyMap
protected long aclIndex
public volatile long lastProcessedZxid
public boolean initialized
Constructor Detail |
---|
public DataTree()
Method Detail |
---|
public HashSet<String> getEphemerals(long sessionId)
public Map<Long,HashSet<String>> getEphemeralsMap()
public void setEphemerals(Map<Long,HashSet<String>> ephemerals)
public Long convertAcls(List<org.apache.zookeeper.data.ACL> acls)
acls
-
public List<org.apache.zookeeper.data.ACL> convertLong(Long longVal)
longs
- the list of longs
public Collection<Long> getSessions()
public void addDataNode(String path, DataNode node)
path
- the path of the datanodenode
- the datanode corresponding to this
pathpublic DataNode getNode(String path)
public int getNodeCount()
public int getWatchCount()
public long approximateDataSize()
public static void copyStatPersisted(org.apache.zookeeper.data.StatPersisted from, org.apache.zookeeper.data.StatPersisted to)
public static void copyStat(org.apache.zookeeper.data.Stat from, org.apache.zookeeper.data.Stat 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 bytes
IOException
- if path is not foundpublic String createNode(String path, byte[] data, List<org.apache.zookeeper.data.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(String path, long zxid) throws KeeperException.NoNodeException
path
- the path to of the node to be deletedzxid
- the current zxid
KeeperException.NoNodeException
public org.apache.zookeeper.data.Stat setData(String path, byte[] data, int version, long zxid, long time) throws KeeperException.NoNodeException
KeeperException.NoNodeException
public byte[] getData(String path, org.apache.zookeeper.data.Stat stat, Watcher watcher) throws KeeperException.NoNodeException
KeeperException.NoNodeException
public org.apache.zookeeper.data.Stat statNode(String path, Watcher watcher) throws KeeperException.NoNodeException
KeeperException.NoNodeException
public List<String> getChildren(String path, org.apache.zookeeper.data.Stat stat, Watcher watcher) throws KeeperException.NoNodeException
KeeperException.NoNodeException
public org.apache.zookeeper.data.Stat setACL(String path, List<org.apache.zookeeper.data.ACL> acl, int version) throws KeeperException.NoNodeException
KeeperException.NoNodeException
public List<org.apache.zookeeper.data.ACL> getACL(String path, org.apache.zookeeper.data.Stat stat) throws KeeperException.NoNodeException
KeeperException.NoNodeException
public DataTree.ProcessTxnResult processTxn(org.apache.zookeeper.txn.TxnHeader header, Record txn)
public void serialize(OutputArchive oa, String tag) throws IOException
IOException
public void deserialize(InputArchive ia, String tag) throws IOException
IOException
public String dumpEphemerals()
public void removeCnxn(Watcher watcher)
public void clear()
public void setWatches(long relativeZxid, List<String> dataWatches, List<String> existWatches, List<String> childWatches, Watcher watcher)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |