Package org.apache.zookeeper.server
Class ContainerManager
java.lang.Object
org.apache.zookeeper.server.ContainerManager
Manages cleanup of container ZNodes. This class is meant to only
be run from the leader. There's no harm in running from followers/observers
but that will be extra work that's not needed. Once started, it periodically
checks container nodes that have a cversion > 0 and have no children. A
delete is attempted on the node. The result of the delete is unimportant.
If the proposal fails or the container node is not empty there's no harm.
-
Constructor Summary
ConstructorsConstructorDescriptionContainerManager
(ZKDatabase zkDb, RequestProcessor requestProcessor, int checkIntervalMs, int maxPerMinute) ContainerManager
(ZKDatabase zkDb, RequestProcessor requestProcessor, int checkIntervalMs, int maxPerMinute, long maxNeverUsedIntervalMs) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Manually check the containers.protected Collection
<String> protected long
getElapsed
(DataNode node) protected long
protected void
postDeleteRequest
(Request request) void
start()
start/restart the timer the runs the check.void
stop()
stop the timer if necessary.
-
Constructor Details
-
ContainerManager
public ContainerManager(ZKDatabase zkDb, RequestProcessor requestProcessor, int checkIntervalMs, int maxPerMinute) - Parameters:
zkDb
- the ZK databaserequestProcessor
- request processer - used to inject delete container requestscheckIntervalMs
- how often to check containers in millisecondsmaxPerMinute
- the max containers to delete per second - avoids herding of container deletions
-
ContainerManager
public ContainerManager(ZKDatabase zkDb, RequestProcessor requestProcessor, int checkIntervalMs, int maxPerMinute, long maxNeverUsedIntervalMs) - Parameters:
zkDb
- the ZK databaserequestProcessor
- request processer - used to inject delete container requestscheckIntervalMs
- how often to check containers in millisecondsmaxPerMinute
- the max containers to delete per second - avoids herding of container deletionsmaxNeverUsedIntervalMs
- the max time in milliseconds that a container that has never had any children is retained
-
-
Method Details
-
start
public void start()start/restart the timer the runs the check. Can safely be called multiple times. -
stop
public void stop()stop the timer if necessary. Can safely be called multiple times. -
checkContainers
Manually check the containers. Not normally used directly- Throws:
InterruptedException
-
postDeleteRequest
-
getMinIntervalMs
protected long getMinIntervalMs() -
getCandidates
-
getElapsed
-