org.apache.zookeeper.server.upgrade
Class DataTreeV1

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

public class DataTreeV1
extends java.lang.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(Stat from, Stat to)
           
static void copyStatPersisted(StatPersistedV1 from, StatPersistedV1 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)
           
 void deserialize(org.apache.jute.InputArchive ia, java.lang.String tag)
           
 java.lang.String dumpEphemerals()
           
 java.util.List<ACL> getACL(java.lang.String path, Stat stat)
           
 java.util.ArrayList<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()
          return the ephemerals for this tree
 DataNodeV1 getNode(java.lang.String path)
           
 java.util.Collection<java.lang.Long> getSessions()
           
 DataTreeV1.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 setEphemeralsMap(java.util.Map<java.lang.Long,java.util.HashSet<java.lang.String>> ephemerals)
           
 Stat statNode(java.lang.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 java.util.Map<java.lang.Long,java.util.HashSet<java.lang.String>> getEphemeralsMap()
return the ephemerals for this tree

Returns:
the ephemerals for this tree

setEphemeralsMap

public void setEphemeralsMap(java.util.Map<java.lang.Long,java.util.HashSet<java.lang.String>> ephemerals)

getEphemerals

public java.util.HashSet<java.lang.String> getEphemerals(long sessionId)

getSessions

public java.util.Collection<java.lang.Long> getSessions()

getNode

public DataNodeV1 getNode(java.lang.String path)

copyStatPersisted

public static void copyStatPersisted(StatPersistedV1 from,
                                     StatPersistedV1 to)

copyStat

public static void copyStat(Stat from,
                            Stat to)

createNode

public 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
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(java.lang.String path)
                throws KeeperException.NoNodeException
Throws:
KeeperException.NoNodeException

setData

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

getData

public byte[] getData(java.lang.String path,
                      Stat stat,
                      Watcher watcher)
               throws KeeperException.NoNodeException
Throws:
KeeperException.NoNodeException

statNode

public Stat statNode(java.lang.String path,
                     Watcher watcher)
              throws KeeperException.NoNodeException
Throws:
KeeperException.NoNodeException

getChildren

public java.util.ArrayList<java.lang.String> getChildren(java.lang.String path,
                                                         Stat stat,
                                                         Watcher watcher)
                                                  throws KeeperException.NoNodeException
Throws:
KeeperException.NoNodeException

setACL

public Stat setACL(java.lang.String path,
                   java.util.List<ACL> acl,
                   int version)
            throws KeeperException.NoNodeException
Throws:
KeeperException.NoNodeException

getACL

public java.util.List<ACL> getACL(java.lang.String path,
                                  Stat stat)
                           throws KeeperException.NoNodeException
Throws:
KeeperException.NoNodeException

processTxn

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

serialize

public void serialize(org.apache.jute.OutputArchive oa,
                      java.lang.String tag)
               throws java.io.IOException,
                      java.lang.InterruptedException
Throws:
java.io.IOException
java.lang.InterruptedException

deserialize

public void deserialize(org.apache.jute.InputArchive ia,
                        java.lang.String tag)
                 throws java.io.IOException
Throws:
java.io.IOException

dumpEphemerals

public java.lang.String dumpEphemerals()

removeCnxn

public void removeCnxn(Watcher watcher)

clear

public void clear()


Copyright © 2012 The Apache Software Foundation