public class ZooKeeperServer extends java.lang.Object implements SessionTracker.SessionExpirer, ServerStats.Provider
Modifier and Type | Class and Description |
---|---|
static class |
ZooKeeperServer.BasicDataTreeBuilder |
static interface |
ZooKeeperServer.DataTreeBuilder
The server delegates loading of the tree to an instance of the interface
|
static class |
ZooKeeperServer.MissingSessionException |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_TICK_TIME |
protected RequestProcessor |
firstProcessor |
protected long |
hzxid |
protected DataTreeBean |
jmxDataTreeBean |
protected ZooKeeperServerBean |
jmxServerBean |
protected static org.slf4j.Logger |
LOG |
protected int |
maxSessionTimeout
value of -1 indicates unset, use default
|
protected int |
minSessionTimeout
value of -1 indicates unset, use default
|
static java.lang.Exception |
ok |
protected boolean |
running |
protected SessionTracker |
sessionTracker |
protected int |
tickTime |
Constructor and Description |
---|
ZooKeeperServer()
Creates a ZooKeeperServer instance.
|
ZooKeeperServer(java.io.File snapDir,
java.io.File logDir,
int tickTime)
This constructor is for backward compatibility with the existing unit
test code.
|
ZooKeeperServer(FileTxnSnapLog txnLogFactory,
int tickTime,
int minSessionTimeout,
int maxSessionTimeout,
ZooKeeperServer.DataTreeBuilder treeBuilder,
ZKDatabase zkDb)
Creates a ZooKeeperServer instance.
|
ZooKeeperServer(FileTxnSnapLog txnLogFactory,
int tickTime,
ZooKeeperServer.DataTreeBuilder treeBuilder)
creates a zookeeperserver instance.
|
ZooKeeperServer(FileTxnSnapLog txnLogFactory,
ZooKeeperServer.DataTreeBuilder treeBuilder)
Default constructor, relies on the config for its agrument values
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkPasswd(long sessionId,
byte[] passwd) |
void |
closeSession(long sessionId) |
void |
closeSession(ServerCnxn cnxn,
RequestHeader requestHeader) |
protected void |
createSessionTracker() |
void |
decInProcess() |
void |
dumpConf(java.io.PrintWriter pwriter) |
void |
dumpEphemerals(java.io.PrintWriter pwriter) |
void |
expire(SessionTracker.Session session) |
void |
finishSessionInit(ServerCnxn cnxn,
boolean valid) |
int |
getClientPort() |
int |
getGlobalOutstandingLimit() |
int |
getInProcess() |
long |
getLastProcessedZxid()
return the last proceesed id from the
datatree
|
int |
getMaxSessionTimeout() |
int |
getMinSessionTimeout() |
int |
getNumAliveConnections()
return the total number of client connections that are alive
to this server
|
long |
getOutstandingRequests()
return the outstanding requests
in the queue, which havent been
processed yet
|
ServerCnxnFactory |
getServerCnxnFactory() |
long |
getServerId() |
static int |
getSnapCount() |
java.lang.String |
getState() |
int |
getTickTime() |
FileTxnSnapLog |
getTxnLogFactory() |
ZKDatabase |
getZKDatabase()
get the zookeeper database for this server
|
long |
getZxid()
This should be called from a synchronized block on this!
|
void |
incInProcess() |
boolean |
isRunning() |
protected void |
killSession(long sessionId,
long zxid) |
void |
loadData()
Restore sessions and data
|
void |
processConnectRequest(ServerCnxn cnxn,
java.nio.ByteBuffer incomingBuffer) |
void |
processPacket(ServerCnxn cnxn,
java.nio.ByteBuffer incomingBuffer) |
DataTree.ProcessTxnResult |
processTxn(TxnHeader hdr,
org.apache.jute.Record txn) |
protected void |
registerJMX() |
void |
reopenSession(ServerCnxn cnxn,
long sessionId,
byte[] passwd,
int sessionTimeout) |
protected void |
revalidateSession(ServerCnxn cnxn,
long sessionId,
int sessionTimeout) |
ServerStats |
serverStats() |
void |
setMaxSessionTimeout(int max) |
void |
setMinSessionTimeout(int min) |
void |
setOwner(long id,
java.lang.Object owner)
set the owner of this session as owner
|
void |
setServerCnxnFactory(ServerCnxnFactory factory) |
void |
setTickTime(int tickTime) |
void |
setTxnLogFactory(FileTxnSnapLog txnLog) |
protected void |
setupRequestProcessors() |
void |
setZKDatabase(ZKDatabase zkDb)
set the zkdatabase for this zookeeper server
|
void |
setZxid(long zxid) |
boolean |
shouldThrottle(long outStandingCount) |
void |
shutdown() |
void |
startdata() |
protected void |
startSessionTracker() |
void |
startup() |
void |
submitRequest(Request si) |
void |
takeSnapshot() |
void |
truncateLog(long zxid)
trunccate the log to get in sync with others
if in a quorum
|
protected void |
unregisterJMX() |
protected static final org.slf4j.Logger LOG
protected ZooKeeperServerBean jmxServerBean
protected DataTreeBean jmxDataTreeBean
public static final int DEFAULT_TICK_TIME
protected int tickTime
protected int minSessionTimeout
protected int maxSessionTimeout
protected SessionTracker sessionTracker
protected long hzxid
public static final java.lang.Exception ok
protected RequestProcessor firstProcessor
protected volatile boolean running
public ZooKeeperServer()
java.io.IOException
public ZooKeeperServer(FileTxnSnapLog txnLogFactory, int tickTime, int minSessionTimeout, int maxSessionTimeout, ZooKeeperServer.DataTreeBuilder treeBuilder, ZKDatabase zkDb)
dataDir
- the directory to put the datapublic ZooKeeperServer(FileTxnSnapLog txnLogFactory, int tickTime, ZooKeeperServer.DataTreeBuilder treeBuilder) throws java.io.IOException
txnLogFactory
- the file transaction snapshot logging classtickTime
- the ticktime for the servertreeBuilder
- the datatree builderjava.io.IOException
public ZooKeeperServer(java.io.File snapDir, java.io.File logDir, int tickTime) throws java.io.IOException
java.io.IOException
public ZooKeeperServer(FileTxnSnapLog txnLogFactory, ZooKeeperServer.DataTreeBuilder treeBuilder) throws java.io.IOException
java.io.IOException
public ServerStats serverStats()
public void dumpConf(java.io.PrintWriter pwriter)
public ZKDatabase getZKDatabase()
public void setZKDatabase(ZKDatabase zkDb)
zkDb
- public void loadData() throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
public void takeSnapshot()
public long getZxid()
public void setZxid(long zxid)
public void closeSession(long sessionId)
protected void killSession(long sessionId, long zxid)
public void expire(SessionTracker.Session session)
expire
in interface SessionTracker.SessionExpirer
protected void registerJMX()
public void startdata() throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
public void startup()
protected void setupRequestProcessors()
protected void createSessionTracker()
protected void startSessionTracker()
public boolean isRunning()
public void shutdown()
protected void unregisterJMX()
public void incInProcess()
public void decInProcess()
public int getInProcess()
protected boolean checkPasswd(long sessionId, byte[] passwd)
public void setOwner(long id, java.lang.Object owner) throws KeeperException.SessionExpiredException
id
- the session idowner
- the owner of the sessionKeeperException.SessionExpiredException
protected void revalidateSession(ServerCnxn cnxn, long sessionId, int sessionTimeout) throws java.io.IOException
java.io.IOException
public void reopenSession(ServerCnxn cnxn, long sessionId, byte[] passwd, int sessionTimeout) throws java.io.IOException
java.io.IOException
public void finishSessionInit(ServerCnxn cnxn, boolean valid)
public void closeSession(ServerCnxn cnxn, RequestHeader requestHeader)
public long getServerId()
getServerId
in interface SessionTracker.SessionExpirer
public void submitRequest(Request si)
public static int getSnapCount()
public int getGlobalOutstandingLimit()
public void setServerCnxnFactory(ServerCnxnFactory factory)
public ServerCnxnFactory getServerCnxnFactory()
public long getLastProcessedZxid()
getLastProcessedZxid
in interface ServerStats.Provider
public long getOutstandingRequests()
getOutstandingRequests
in interface ServerStats.Provider
public void truncateLog(long zxid) throws java.io.IOException
zxid
- the zxid that it needs to get in sync
with othersjava.io.IOException
public int getTickTime()
public void setTickTime(int tickTime)
public int getMinSessionTimeout()
public void setMinSessionTimeout(int min)
public int getMaxSessionTimeout()
public void setMaxSessionTimeout(int max)
public int getClientPort()
public void setTxnLogFactory(FileTxnSnapLog txnLog)
public FileTxnSnapLog getTxnLogFactory()
public java.lang.String getState()
getState
in interface ServerStats.Provider
public void dumpEphemerals(java.io.PrintWriter pwriter)
public int getNumAliveConnections()
getNumAliveConnections
in interface ServerStats.Provider
public void processConnectRequest(ServerCnxn cnxn, java.nio.ByteBuffer incomingBuffer) throws java.io.IOException
java.io.IOException
public boolean shouldThrottle(long outStandingCount)
public void processPacket(ServerCnxn cnxn, java.nio.ByteBuffer incomingBuffer) throws java.io.IOException
java.io.IOException
public DataTree.ProcessTxnResult processTxn(TxnHeader hdr, org.apache.jute.Record txn)
Copyright © 2015 The Apache Software Foundation