|
|||||||||
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 |
Field Summary | |
---|---|
int |
commitLogBuffer
|
static int |
commitLogCount
|
LinkedList<Leader.Proposal> |
committedLog
|
DataTree |
dataTree
|
static int |
DEFAULT_TICK_TIME
|
protected RequestProcessor |
firstProcessor
|
protected long |
hzxid
|
protected DataTreeBean |
jmxDataTreeBean
|
protected ZooKeeperServerBean |
jmxServerBean
|
protected static org.apache.log4j.Logger |
LOG
|
long |
maxCommittedLog
|
long |
minCommittedLog
|
static Exception |
ok
|
protected boolean |
running
|
protected ConcurrentHashMap<Long,Integer> |
sessionsWithTimeouts
|
protected SessionTracker |
sessionTracker
|
protected int |
tickTime
|
Constructor Summary | |
---|---|
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,
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 | |
---|---|
void |
addCommittedProposal(Request request)
maintains a list of last 500 or so committed requests. |
static void |
byteBuffer2Record(ByteBuffer bb,
Record record)
|
protected boolean |
checkPasswd(long sessionId,
byte[] passwd)
|
void |
closeSession(long sessionId)
|
void |
closeSession(ServerCnxn cnxn,
org.apache.zookeeper.proto.RequestHeader requestHeader)
|
protected void |
createSessionTracker()
|
void |
decInProcess()
|
void |
deserializeSnapshot(InputArchive ia)
|
void |
expire(long sessionId)
|
int |
getClientPort()
|
int |
getGlobalOutstandingLimit()
|
int |
getInProcess()
|
long |
getLastProcessedZxid()
return the last proceesed id from the datatree |
FileTxnSnapLog |
getLogWriter()
the snapshot and logwriter for this instance |
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()
|
ZooKeeperServer.DataTreeBuilder |
getTreeBuilder()
|
FileTxnSnapLog |
getTxnLogFactory()
|
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)
|
void |
serializeSnapshot(OutputArchive oa)
|
ServerStats |
serverStats()
|
void |
setOwner(long id,
Object owner)
set the owner of this session as owner |
void |
setServerCnxnFactory(NIOServerCnxn.Factory factory)
|
void |
setTickTime(int tickTime)
|
void |
setTreeBuilder(ZooKeeperServer.DataTreeBuilder treeBuilder)
|
void |
setTxnLogFactory(FileTxnSnapLog txnLog)
|
protected void |
setupRequestProcessors()
|
void |
setZxid(long zxid)
|
void |
shutdown()
|
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
public static final int commitLogCount
public int commitLogBuffer
public LinkedList<Leader.Proposal> committedLog
public long minCommittedLog
public long maxCommittedLog
public DataTree dataTree
protected SessionTracker sessionTracker
protected ConcurrentHashMap<Long,Integer> sessionsWithTimeouts
protected long hzxid
public static final Exception ok
protected RequestProcessor firstProcessor
protected volatile boolean running
Constructor Detail |
---|
public ZooKeeperServer()
IOException
public ZooKeeperServer(FileTxnSnapLog txnLogFactory, int tickTime, ZooKeeperServer.DataTreeBuilder treeBuilder) throws IOException
dataDir
- the directory to put the data
IOException
public ZooKeeperServer(File snapDir, File logDir, int tickTime) throws IOException
IOException
public ZooKeeperServer(FileTxnSnapLog txnLogFactory, ZooKeeperServer.DataTreeBuilder treeBuilder) throws IOException
IOException
Method Detail |
---|
public ServerStats serverStats()
public void loadData() throws IOException, InterruptedException
IOException
InterruptedException
public void addCommittedProposal(Request request)
request
- committed requestpublic void takeSnapshot()
public void serializeSnapshot(OutputArchive oa) throws IOException, InterruptedException
IOException
InterruptedException
public void deserializeSnapshot(InputArchive ia) throws IOException
IOException
public long getZxid()
public void setZxid(long zxid)
public void closeSession(long sessionId)
protected void killSession(long sessionId, long zxid)
public void expire(long sessionId)
expire
in interface SessionTracker.SessionExpirer
protected void registerJMX()
public void startup() throws IOException, InterruptedException
IOException
InterruptedException
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, 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 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, org.apache.zookeeper.proto.RequestHeader requestHeader)
public long getServerId()
getServerId
in interface SessionTracker.SessionExpirer
public void submitRequest(Request si)
public static void byteBuffer2Record(ByteBuffer bb, 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 others
IOException
public FileTxnSnapLog getLogWriter()
public int getTickTime()
public void setTickTime(int tickTime)
public ZooKeeperServer.DataTreeBuilder getTreeBuilder()
public void setTreeBuilder(ZooKeeperServer.DataTreeBuilder treeBuilder)
public int getClientPort()
public void setTxnLogFactory(FileTxnSnapLog txnLog)
public FileTxnSnapLog getTxnLogFactory()
public String getState()
getState
in interface ServerStats.Provider
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |