org.apache.zookeeper.server
public class ZooKeeperServer extends 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 interface |
ZooKeeperServer.Factory
Create an instance of ZooKeeper server
|
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.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 Exception |
ok |
protected boolean |
running |
protected SessionTracker |
sessionTracker |
protected int |
tickTime |
Constructor and Description |
---|
ZooKeeperServer()
Creates a ZooKeeperServer instance.
|
ZooKeeperServer(File snapDir,
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 |
---|---|
static void |
byteBuffer2Record(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(PrintWriter pwriter) |
void |
dumpEphemerals(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() |
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
|
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,
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() |
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.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 Exception ok
protected RequestProcessor firstProcessor
protected volatile boolean running
public ZooKeeperServer()
IOException
public ZooKeeperServer(FileTxnSnapLog txnLogFactory, int tickTime, int minSessionTimeout, int maxSessionTimeout, ZooKeeperServer.DataTreeBuilder treeBuilder, ZKDatabase zkDb) throws IOException
dataDir
- the directory to put the dataIOException
public ZooKeeperServer(FileTxnSnapLog txnLogFactory, int tickTime, ZooKeeperServer.DataTreeBuilder treeBuilder) throws IOException
txnLogFactory
- the file transaction snapshot logging classtickTime
- the ticktime for the servertreeBuilder
- the datatree builderIOException
public ZooKeeperServer(File snapDir, File logDir, int tickTime) throws IOException
IOException
public ZooKeeperServer(FileTxnSnapLog txnLogFactory, ZooKeeperServer.DataTreeBuilder treeBuilder) throws IOException
IOException
public ServerStats serverStats()
public void dumpConf(PrintWriter pwriter)
public ZKDatabase getZKDatabase()
public void setZKDatabase(ZKDatabase zkDb)
zkDb
- public void loadData() throws IOException, InterruptedException
IOException
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 IOException, InterruptedException
IOException
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, 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 IOException, InterruptedException
IOException
InterruptedException
public void reopenSession(ServerCnxn cnxn, long sessionId, byte[] passwd, int sessionTimeout) throws IOException, InterruptedException
IOException
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(ByteBuffer bb, org.apache.jute.Record record) throws IOException
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 IOException
zxid
- the zxid that it needs to get in sync
with othersIOException
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 String getState()
getState
in interface ServerStats.Provider
public DataTree.ProcessTxnResult processTxn(TxnHeader hdr, org.apache.jute.Record txn)
public void dumpEphemerals(PrintWriter pwriter)
Copyright © 2014 The Apache Software Foundation