org.apache.zookeeper.server.upgrade
Class DataTreeV1

java.lang.Object
  extended by org.apache.zookeeper.server.upgrade.DataTreeV1

public class DataTreeV1
extends Object

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 DataTreeV1.ProcessTxnResult
           
 
Field Summary
 boolean initialized
           
 long lastProcessedZxid
           
 
Constructor Summary
DataTreeV1()
           
 
Method Summary
 void clear()
           
static void copyStat(org.apache.zookeeper.data.Stat from, org.apache.zookeeper.data.Stat to)
           
static void copyStatPersisted(org.apache.zookeeper.data.StatPersistedV1 from, org.apache.zookeeper.data.StatPersistedV1 to)
           
 String createNode(String path, byte[] data, List<org.apache.zookeeper.data.ACL> acl, long ephemeralOwner, long zxid, long time)
           
 void deleteNode(String path)
           
 void deserialize(InputArchive ia, String tag)
           
 String dumpEphemerals()
           
 List<org.apache.zookeeper.data.ACL> getACL(String path, org.apache.zookeeper.data.Stat stat)
           
 ArrayList<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()
          return the ephemerals for this tree
 DataNodeV1 getNode(String path)
           
 Collection<Long> getSessions()
           
 DataTreeV1.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 setEphemeralsMap(Map<Long,HashSet<String>> ephemerals)
           
 org.apache.zookeeper.data.Stat statNode(String path, Watcher watcher)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lastProcessedZxid

public volatile long lastProcessedZxid

initialized

public boolean initialized
Constructor Detail

DataTreeV1

public DataTreeV1()
Method Detail

getEphemeralsMap

public Map<Long,HashSet<String>> getEphemeralsMap()
return the ephemerals for this tree

Returns:
the ephemerals for this tree

setEphemeralsMap

public void setEphemeralsMap(Map<Long,HashSet<String>> ephemerals)

getEphemerals

public HashSet<String> getEphemerals(long sessionId)

getSessions

public Collection<Long> getSessions()

getNode

public DataNodeV1 getNode(String path)

copyStatPersisted

public static void copyStatPersisted(org.apache.zookeeper.data.StatPersistedV1 from,
                                     org.apache.zookeeper.data.StatPersistedV1 to)

copyStat

public static void copyStat(org.apache.zookeeper.data.Stat from,
                            org.apache.zookeeper.data.Stat to)

createNode

public String createNode(String path,
                         byte[] data,
                         List<org.apache.zookeeper.data.ACL> acl,
                         long ephemeralOwner,
                         long zxid,
                         long time)
                  throws KeeperException.NoNodeException,
                         KeeperException.NodeExistsException
Parameters:
path -
data -
acl -
ephemeralOwner - the session id that owns this node. -1 indicates this is not an ephemeral node.
zxid -
time -
Returns:
the patch of the created node
Throws:
KeeperException
KeeperException.NoNodeException
KeeperException.NodeExistsException

deleteNode

public void deleteNode(String path)
                throws KeeperException.NoNodeException
Throws:
KeeperException.NoNodeException

setData

public org.apache.zookeeper.data.Stat setData(String path,
                                              byte[] data,
                                              int version,
                                              long zxid,
                                              long time)
                                       throws KeeperException.NoNodeException
Throws:
KeeperException.NoNodeException

getData

public byte[] getData(String path,
                      org.apache.zookeeper.data.Stat stat,
                      Watcher watcher)
               throws KeeperException.NoNodeException
Throws:
KeeperException.NoNodeException

statNode

public org.apache.zookeeper.data.Stat statNode(String path,
                                               Watcher watcher)
                                        throws KeeperException.NoNodeException
Throws:
KeeperException.NoNodeException

getChildren

public ArrayList<String> getChildren(String path,
                                     org.apache.zookeeper.data.Stat stat,
                                     Watcher watcher)
                              throws KeeperException.NoNodeException
Throws:
KeeperException.NoNodeException

setACL

public org.apache.zookeeper.data.Stat setACL(String path,
                                             List<org.apache.zookeeper.data.ACL> acl,
                                             int version)
                                      throws KeeperException.NoNodeException
Throws:
KeeperException.NoNodeException

getACL

public List<org.apache.zookeeper.data.ACL> getACL(String path,
                                                  org.apache.zookeeper.data.Stat stat)
                                           throws KeeperException.NoNodeException
Throws:
KeeperException.NoNodeException

processTxn

public DataTreeV1.ProcessTxnResult processTxn(org.apache.zookeeper.txn.TxnHeader header,
                                              Record txn)

serialize

public void serialize(OutputArchive oa,
                      String tag)
               throws IOException,
                      InterruptedException
Throws:
IOException
InterruptedException

deserialize

public void deserialize(InputArchive ia,
                        String tag)
                 throws IOException
Throws:
IOException

dumpEphemerals

public String dumpEphemerals()

removeCnxn

public void removeCnxn(Watcher watcher)

clear

public void clear()