|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.zookeeper.server.ZooKeeperServer
public class ZooKeeperServer
This class implements a simple standalone ZooKeeperServer. It sets up the following chain of RequestProcessors to process requests: PrepRequestProcessor -> SyncRequestProcessor -> FinalRequestProcessor
Nested Class Summary | |
---|---|
static class |
ZooKeeperServer.BasicDataTreeBuilder
|
static interface |
ZooKeeperServer.DataTreeBuilder
The server delegates loading of the tree to an instance of the interface |
static interface |
ZooKeeperServer.Factory
Create an instance of ZooKeeper server |
static class |
ZooKeeperServer.MissingSessionException
|
Field Summary | |
---|---|
static int |
DEFAULT_TICK_TIME
|
protected RequestProcessor |
firstProcessor
|
protected long |
hzxid
|
protected DataTreeBean |
jmxDataTreeBean
|
protected ZooKeeperServerBean |
jmxServerBean
|
protected static org.apache.log4j.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 Summary | |
---|---|
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 |
Method Summary | |
---|---|
static void |
byteBuffer2Record(java.nio.ByteBuffer bb,
org.apache.jute.Record record)
|
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)
|
int |
getClientPort()
|
int |
getGlobalOutstandingLimit()
|
int |
getInProcess()
|
long |
getLastProcessedZxid()
return the last proceesed id from the datatree |
int |
getMaxSessionTimeout()
|
int |
getMinSessionTimeout()
|
long |
getOutstandingRequests()
return the outstanding requests in the queue, which havent been processed yet |
NIOServerCnxn.Factory |
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 |
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(NIOServerCnxn.Factory 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)
|
void |
shutdown()
|
void |
startdata()
|
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()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final org.apache.log4j.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
Constructor Detail |
---|
public ZooKeeperServer()
java.io.IOException
public ZooKeeperServer(FileTxnSnapLog txnLogFactory, int tickTime, int minSessionTimeout, int maxSessionTimeout, ZooKeeperServer.DataTreeBuilder treeBuilder, ZKDatabase zkDb) throws java.io.IOException
dataDir
- the directory to put the data
java.io.IOException
public 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 builder
java.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
Method Detail |
---|
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()
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 session
KeeperException.SessionExpiredException
protected void revalidateSession(ServerCnxn cnxn, long sessionId, int sessionTimeout) throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
public void reopenSession(ServerCnxn cnxn, long sessionId, byte[] passwd, int sessionTimeout) throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
public void closeSession(ServerCnxn cnxn, RequestHeader requestHeader)
public long getServerId()
getServerId
in interface SessionTracker.SessionExpirer
public void submitRequest(Request si)
public static void byteBuffer2Record(java.nio.ByteBuffer bb, org.apache.jute.Record record) throws java.io.IOException
java.io.IOException
public static int getSnapCount()
public int getGlobalOutstandingLimit()
public void setServerCnxnFactory(NIOServerCnxn.Factory factory)
public NIOServerCnxn.Factory 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 others
java.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)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |