Class ReadOnlyZooKeeperServer
- java.lang.Object
-
- org.apache.zookeeper.server.ZooKeeperServer
-
- org.apache.zookeeper.server.quorum.ReadOnlyZooKeeperServer
-
- All Implemented Interfaces:
ServerStats.Provider,SessionTracker.SessionExpirer
public class ReadOnlyZooKeeperServer extends ZooKeeperServer
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.MissingSessionException, ZooKeeperServer.State
-
-
Field Summary
Fields Modifier and Type Field Description protected QuorumPeerself-
Fields inherited from class org.apache.zookeeper.server.ZooKeeperServer
ALLOW_SASL_FAILED_CLIENTS, CLOSE_SESSION_TXN_ENABLED, DEFAULT_STARTING_BUFFER_SIZE, DEFAULT_THROTTLED_OP_WAIT_TIME, DEFAULT_TICK_TIME, ENABLE_EAGER_ACL_CHECK, ENFORCE_QUOTA, enforceQuota, firstProcessor, GET_CHILDREN_RESPONSE_CACHE_SIZE, GET_DATA_RESPONSE_CACHE_SIZE, GLOBAL_OUTSTANDING_LIMIT, initialConfig, INT_BUFFER_STARTING_SIZE_BYTES, intBufferStartingSizeBytes, jmxDataTreeBean, jmxServerBean, jvmPauseMonitor, listenBacklog, LOG, maxSessionTimeout, minSessionTimeout, ok, reconfigEnabled, SASL_SUPER_USER, secureServerCnxnFactory, serverCnxnFactory, sessionTracker, SKIP_ACL, SNAP_COUNT, state, throttledOpWaitTime, tickTime, ZOOKEEPER_DIGEST_ENABLED, ZOOKEEPER_SERIALIZE_LAST_PROCESSED_ZXID_ENABLED
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreateSessionTracker()voiddumpConf(PrintWriter pwriter)longgetServerId()Returns the id of the associated QuorumPeer, which will do for a unique id of this server.StringgetState()protected voidregisterJMX()voidregisterJMX(ZooKeeperServerBean serverBean, LocalPeerBean localPeerBean)protected voidsetLocalSessionFlag(Request si)If the underlying Zookeeper server support local session, this method will set a isLocalSession to true if a request is associated with a local session.protected voidsetState(ZooKeeperServer.State state)Sets the state of ZooKeeper server.protected voidsetupRequestProcessors()protected voidshutdownComponents()protected voidstartSessionTracker()voidstartup()protected voidunregisterJMX()protected voidunregisterJMX(ZooKeeperServer zks)protected voidvalidateSession(ServerCnxn cnxn, long sessionId)Validate if a particular session can be reestablished.-
Methods inherited from class org.apache.zookeeper.server.ZooKeeperServer
authWriteRequest, checkACL, checkPasswd, checkQuota, checkRequestSizeWhenReceivingMessage, closeSession, closeSession, connThrottle, createRequestThrottler, decInProcess, dumpEphemerals, dumpMonitorValues, enqueueRequest, expire, expire, finishSessionInit, getClientPort, getClientPortListenBacklog, getConf, getConnectionDropChance, getDataDirSize, getEphemerals, getGetChildrenResponseCache, getGlobalOutstandingLimit, getInflight, getInitialConfig, getInProcess, getLargeRequestBytes, getLargeRequestMaxBytes, getLargeRequestThreshold, getLastProcessedZxid, getLogDirSize, getMaxClientCnxnsPerHost, getMaxSessionTimeout, getMinSessionTimeout, getNumAliveConnections, getOutstandingHandshakeNum, getOutstandingRequests, getReadResponseCache, getRequestPathMetricsCollector, getSecureClientPort, getSecureServerCnxnFactory, getServerCnxnFactory, getSessionExpiryMap, getSessionTracker, getSnapCount, getSnapSizeInBytes, getThrottledOpWaitTime, getTickTime, getTxnLogElapsedSyncTime, getTxnLogFactory, getZKDatabase, getZkShutdownHandler, getZooKeeperServerListener, getZxid, incInProcess, isCloseSessionTxnEnabled, isDigestEnabled, isEnableEagerACLCheck, isReconfigEnabled, isResponseCachingEnabled, isRunning, isSerializeLastProcessedZxidEnabled, killSession, loadData, processConnectRequest, processPacket, processTxn, registerMetrics, reopenSession, requestFinished, restoreFromSnapshot, revalidateSession, serverStats, setClientPortListenBacklog, setCloseSessionTxnEnabled, setCreateSessionTrackerServerId, setDigestEnabled, setEnableEagerACLCheck, setLargeRequestMaxBytes, setLargeRequestThreshold, setMaxSessionTimeout, setMinSessionTimeout, setOwner, setResponseCachingEnabled, setSecureServerCnxnFactory, setSerializeLastProcessedZxidEnabled, setServerCnxnFactory, setThrottledOpWaitTime, setTickTime, setTxnLogFactory, setZKDatabase, setZxid, shouldForceWriteInitialSnapshotAfterLeaderElection, shouldThrottle, shutdown, shutdown, startdata, startJvmPauseMonitor, startRequestThrottler, submitRequest, submitRequestNow, takeSnapshot, takeSnapshot, takeSnapshot, truncateLog, unregisterMetrics
-
-
-
-
Field Detail
-
self
protected final QuorumPeer self
-
-
Method Detail
-
setupRequestProcessors
protected void setupRequestProcessors()
- Overrides:
setupRequestProcessorsin classZooKeeperServer
-
startup
public void startup()
- Overrides:
startupin classZooKeeperServer
-
createSessionTracker
public void createSessionTracker()
- Overrides:
createSessionTrackerin classZooKeeperServer
-
startSessionTracker
protected void startSessionTracker()
- Overrides:
startSessionTrackerin classZooKeeperServer
-
setLocalSessionFlag
protected void setLocalSessionFlag(Request si)
Description copied from class:ZooKeeperServerIf the underlying Zookeeper server support local session, this method will set a isLocalSession to true if a request is associated with a local session.- Overrides:
setLocalSessionFlagin classZooKeeperServer
-
validateSession
protected void validateSession(ServerCnxn cnxn, long sessionId) throws IOException
Description copied from class:ZooKeeperServerValidate if a particular session can be reestablished.- Overrides:
validateSessionin classZooKeeperServer- Throws:
IOException
-
registerJMX
protected void registerJMX()
- Overrides:
registerJMXin classZooKeeperServer
-
registerJMX
public void registerJMX(ZooKeeperServerBean serverBean, LocalPeerBean localPeerBean)
-
unregisterJMX
protected void unregisterJMX()
- Overrides:
unregisterJMXin classZooKeeperServer
-
unregisterJMX
protected void unregisterJMX(ZooKeeperServer zks)
-
getState
public String getState()
- Specified by:
getStatein interfaceServerStats.Provider- Overrides:
getStatein classZooKeeperServer
-
getServerId
public long getServerId()
Returns the id of the associated QuorumPeer, which will do for a unique id of this server.- Specified by:
getServerIdin interfaceSessionTracker.SessionExpirer- Overrides:
getServerIdin classZooKeeperServer
-
shutdownComponents
protected void shutdownComponents()
- Overrides:
shutdownComponentsin classZooKeeperServer
-
dumpConf
public void dumpConf(PrintWriter pwriter)
- Overrides:
dumpConfin classZooKeeperServer
-
setState
protected void setState(ZooKeeperServer.State state)
Description copied from class:ZooKeeperServerSets 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.
ZooKeeperServerListenerImplnotifies 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.
- During maintenance (e.g. restore) the server sets the state to MAINTENANCE
- Overrides:
setStatein classZooKeeperServer- Parameters:
state- new server state.
-
-