Class ReadOnlyZooKeeperServer
- java.lang.Object
-
- org.apache.zookeeper.server.ZooKeeperServer
-
- org.apache.zookeeper.server.quorum.QuorumZooKeeperServer
-
- org.apache.zookeeper.server.quorum.ReadOnlyZooKeeperServer
-
- All Implemented Interfaces:
ServerStats.Provider
,SessionTracker.SessionExpirer
public class ReadOnlyZooKeeperServer extends QuorumZooKeeperServer
A ZooKeeperServer which comes into play when peer is partitioned from the majority. Handles read-only clients, but drops connections from not-read-only ones.The very first processor in the chain of request processors is a ReadOnlyRequestProcessor which drops state-changing requests.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.zookeeper.server.ZooKeeperServer
ZooKeeperServer.BasicDataTreeBuilder, ZooKeeperServer.DataTreeBuilder, ZooKeeperServer.MissingSessionException, ZooKeeperServer.State
-
-
Field Summary
-
Fields inherited from class org.apache.zookeeper.server.quorum.QuorumZooKeeperServer
self
-
Fields inherited from class org.apache.zookeeper.server.ZooKeeperServer
DEFAULT_TICK_TIME, firstProcessor, jmxDataTreeBean, jmxServerBean, LOG, maxSessionTimeout, minSessionTimeout, ok, sessionTracker, state, tickTime
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getServerId()
Returns the id of the associated QuorumPeer, which will do for a unique id of this server.java.lang.String
getState()
protected void
registerJMX()
void
registerJMX(ZooKeeperServerBean serverBean, LocalPeerBean localPeerBean)
protected void
setState(ZooKeeperServer.State state)
Sets the state of ZooKeeper server.protected void
setupRequestProcessors()
void
shutdown()
void
startup()
protected void
unregisterJMX()
protected void
unregisterJMX(ZooKeeperServer zks)
-
Methods inherited from class org.apache.zookeeper.server.quorum.QuorumZooKeeperServer
dumpConf
-
Methods inherited from class org.apache.zookeeper.server.ZooKeeperServer
canShutdown, checkPasswd, closeSession, closeSession, createSessionTracker, decInProcess, dumpEphemerals, expire, finishSessionInit, getClientPort, getGlobalOutstandingLimit, getInProcess, getLastProcessedZxid, getMaxSessionTimeout, getMinSessionTimeout, getNumAliveConnections, getOutstandingRequests, getServerCnxnFactory, getSnapCount, getTickTime, getTxnLogFactory, getZKDatabase, getZooKeeperServerListener, getZxid, incInProcess, isRunning, killSession, loadData, processConnectRequest, processPacket, processTxn, reopenSession, revalidateSession, serverStats, setMaxSessionTimeout, setMinSessionTimeout, setOwner, setServerCnxnFactory, setTickTime, setTxnLogFactory, setZKDatabase, setZxid, shouldThrottle, shutdown, startdata, startSessionTracker, submitRequest, takeSnapshot, truncateLog
-
-
-
-
Method Detail
-
setupRequestProcessors
protected void setupRequestProcessors()
- Overrides:
setupRequestProcessors
in classZooKeeperServer
-
startup
public void startup()
- Overrides:
startup
in classZooKeeperServer
-
registerJMX
protected void registerJMX()
- Overrides:
registerJMX
in classZooKeeperServer
-
registerJMX
public void registerJMX(ZooKeeperServerBean serverBean, LocalPeerBean localPeerBean)
-
setState
protected void setState(ZooKeeperServer.State state)
Description copied from class:ZooKeeperServer
Sets the state of ZooKeeper server. After changing the state, it notifies the server state change to a registered shutdown handler, if any.The following are the server state transitions:
- During startup the server will be in the INITIAL state.
- After successfully starting, the server sets the state to RUNNING.
- The server transitions to the ERROR state if it hits an internal error.
ZooKeeperServerListenerImpl
notifies any critical resource error events, e.g., SyncRequestProcessor not being able to write a txn to disk.- During shutdown the server sets the state to SHUTDOWN, which corresponds to the server not running.
- Overrides:
setState
in classQuorumZooKeeperServer
- Parameters:
state
- new server state.
-
unregisterJMX
protected void unregisterJMX()
- Overrides:
unregisterJMX
in classZooKeeperServer
-
unregisterJMX
protected void unregisterJMX(ZooKeeperServer zks)
-
getState
public java.lang.String getState()
- Specified by:
getState
in interfaceServerStats.Provider
- Overrides:
getState
in classZooKeeperServer
-
getServerId
public long getServerId()
Returns the id of the associated QuorumPeer, which will do for a unique id of this server.- Specified by:
getServerId
in interfaceSessionTracker.SessionExpirer
- Overrides:
getServerId
in classZooKeeperServer
-
shutdown
public void shutdown()
- Overrides:
shutdown
in classZooKeeperServer
-
-