public class ZKDatabase
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected static int |
commitLogBuffer |
static int |
commitLogCount |
protected java.util.LinkedList<Leader.Proposal> |
committedLog |
protected DataTree |
dataTree
make sure on a clear you take care of
all these members.
|
protected java.util.concurrent.locks.ReentrantReadWriteLock |
logLock |
protected long |
maxCommittedLog |
protected long |
minCommittedLog |
protected java.util.concurrent.ConcurrentHashMap<java.lang.Long,java.lang.Integer> |
sessionsWithTimeouts |
protected FileTxnSnapLog |
snapLog |
| Constructor and Description |
|---|
ZKDatabase(FileTxnSnapLog snapLog)
the filetxnsnaplog that this zk database
maps to.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCommittedProposal(Request request)
maintains a list of last committedLog
or so committed requests.
|
boolean |
append(Request si)
append to the underlying transaction log
|
void |
clear()
clear the zkdatabase.
|
void |
close()
close this database.
|
void |
commit()
commit to the underlying transaction log
|
java.util.List<ACL> |
convertLong(java.lang.Long aclL)
convert from long to the acl entry
|
void |
deserializeSnapshot(org.apache.jute.InputArchive ia)
deserialize a snapshot from an input archive
|
void |
dumpEphemerals(java.io.PrintWriter pwriter)
write a text dump of all the ephemerals in the datatree
|
java.util.List<ACL> |
getACL(java.lang.String path,
Stat stat)
get acl for a path
|
int |
getAclSize()
get the acl size of the datatree
|
java.util.List<java.lang.String> |
getChildren(java.lang.String path,
Stat stat,
Watcher watcher)
get children list for this path
|
java.util.LinkedList<Leader.Proposal> |
getCommittedLog() |
byte[] |
getData(java.lang.String path,
Stat stat,
Watcher watcher)
get data and stat for a path
|
DataTree |
getDataTree()
the datatree for this zkdatabase
|
long |
getDataTreeLastProcessedZxid()
get the last processed zxid from a datatree
|
java.util.HashSet<java.lang.String> |
getEphemerals(long sessionId)
the paths for ephemeral session id
|
java.util.concurrent.locks.ReentrantReadWriteLock |
getLogLock()
Get the lock that controls the committedLog.
|
long |
getmaxCommittedLog()
the committed log for this zk database
|
long |
getminCommittedLog()
the minimum committed transaction log
available in memory
|
DataNode |
getNode(java.lang.String path)
get the datanode for this path
|
int |
getNodeCount()
the node count of the datatree
|
java.util.Collection<java.lang.Long> |
getSessions()
return the sessions in the datatree
|
java.util.concurrent.ConcurrentHashMap<java.lang.Long,java.lang.Integer> |
getSessionWithTimeOuts()
get sessions with timeouts
|
boolean |
isInitialized()
checks to see if the zk database has been
initialized or not.
|
boolean |
isSpecialPath(java.lang.String path)
check if the path is special or not
|
void |
killSession(long sessionId,
long zxid)
kill a given session in the datatree
|
long |
loadDataBase()
load the database from the disk onto memory and also add
the transactions to the committedlog in memory.
|
DataTree.ProcessTxnResult |
processTxn(TxnHeader hdr,
org.apache.jute.Record txn)
the process txn on the data
|
void |
removeCnxn(ServerCnxn cnxn)
remove a cnxn from the datatree
|
void |
rollLog()
roll the underlying log
|
void |
serializeSnapshot(org.apache.jute.OutputArchive oa)
serialize the snapshot
|
void |
setDataTreeInit(boolean b)
set the datatree initialized or not
|
void |
setlastProcessedZxid(long zxid)
the last processed zxid in the datatree
|
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)
set watches on the datatree
|
Stat |
statNode(java.lang.String path,
ServerCnxn serverCnxn)
stat the path
|
boolean |
truncateLog(long zxid)
Truncate the ZKDatabase to the specified zxid
|
protected DataTree dataTree
protected java.util.concurrent.ConcurrentHashMap<java.lang.Long,java.lang.Integer> sessionsWithTimeouts
protected FileTxnSnapLog snapLog
protected long minCommittedLog
protected long maxCommittedLog
public static final int commitLogCount
protected static int commitLogBuffer
protected java.util.LinkedList<Leader.Proposal> committedLog
protected java.util.concurrent.locks.ReentrantReadWriteLock logLock
public ZKDatabase(FileTxnSnapLog snapLog)
snapLog - the FileTxnSnapLog mapping this zkdatabasepublic boolean isInitialized()
public void clear()
public DataTree getDataTree()
public long getmaxCommittedLog()
public long getminCommittedLog()
public java.util.concurrent.locks.ReentrantReadWriteLock getLogLock()
public java.util.LinkedList<Leader.Proposal> getCommittedLog()
public long getDataTreeLastProcessedZxid()
public void setDataTreeInit(boolean b)
b - set the datatree initialized to bpublic java.util.Collection<java.lang.Long> getSessions()
public java.util.concurrent.ConcurrentHashMap<java.lang.Long,java.lang.Integer> getSessionWithTimeOuts()
public long loadDataBase()
throws java.io.IOException
java.io.IOExceptionpublic void addCommittedProposal(Request request)
request - committed requestpublic void removeCnxn(ServerCnxn cnxn)
cnxn - the cnxn to remove from the datatreepublic void killSession(long sessionId,
long zxid)
sessionId - the session id to be killedzxid - the zxid of kill session transactionpublic void dumpEphemerals(java.io.PrintWriter pwriter)
pwriter - the output to write topublic int getNodeCount()
public java.util.HashSet<java.lang.String> getEphemerals(long sessionId)
sessionId - the session id for which paths match topublic void setlastProcessedZxid(long zxid)
zxid - the last processed zxid in the datatreepublic DataTree.ProcessTxnResult processTxn(TxnHeader hdr, org.apache.jute.Record txn)
hdr - the txnheader for the txntxn - the transaction that needs to be processedpublic Stat statNode(java.lang.String path, ServerCnxn serverCnxn) throws KeeperException.NoNodeException
path - the path for which stat is to be doneserverCnxn - the servercnxn attached to this requestKeeperException.NoNodeExceptionpublic DataNode getNode(java.lang.String path)
path - the path to lookuppublic java.util.List<ACL> convertLong(java.lang.Long aclL)
aclL - the long for which to get the aclpublic byte[] getData(java.lang.String path,
Stat stat,
Watcher watcher)
throws KeeperException.NoNodeException
path - the path being queriedstat - the stat for this pathwatcher - the watcher functionKeeperException.NoNodeExceptionpublic 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)
relativeZxid - the relative zxid that client has seendataWatches - the data watches the client wants to resetexistWatches - the exists watches the client wants to resetchildWatches - the child watches the client wants to resetwatcher - the watcher functionpublic java.util.List<ACL> getACL(java.lang.String path, Stat stat) throws KeeperException.NoNodeException
path - the path to query for aclstat - the stat for the nodeKeeperException.NoNodeExceptionpublic java.util.List<java.lang.String> getChildren(java.lang.String path,
Stat stat,
Watcher watcher)
throws KeeperException.NoNodeException
path - the path of the nodestat - the stat of the nodewatcher - the watcher function for this pathKeeperException.NoNodeExceptionpublic boolean isSpecialPath(java.lang.String path)
path - the input pathpublic int getAclSize()
public boolean truncateLog(long zxid)
throws java.io.IOException
zxid - the zxid to truncate zk database tojava.io.IOExceptionpublic void deserializeSnapshot(org.apache.jute.InputArchive ia)
throws java.io.IOException
ia - the input archive you want to deserialize fromjava.io.IOExceptionpublic void serializeSnapshot(org.apache.jute.OutputArchive oa)
throws java.io.IOException,
java.lang.InterruptedException
oa - the output archive to which the snapshot needs to be serializedjava.io.IOExceptionjava.lang.InterruptedExceptionpublic boolean append(Request si) throws java.io.IOException
si - the request to appendjava.io.IOExceptionpublic void rollLog()
throws java.io.IOException
java.io.IOExceptionpublic void commit()
throws java.io.IOException
java.io.IOExceptionpublic void close()
throws java.io.IOException
java.io.IOExceptionCopyright © 2016 The Apache Software Foundation