Package org.apache.zookeeper.server
Class ContainerManager
- java.lang.Object
- 
- org.apache.zookeeper.server.ContainerManager
 
- 
 public class ContainerManager extends Object 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 SummaryConstructors Constructor Description ContainerManager(ZKDatabase zkDb, RequestProcessor requestProcessor, int checkIntervalMs, int maxPerMinute)ContainerManager(ZKDatabase zkDb, RequestProcessor requestProcessor, int checkIntervalMs, int maxPerMinute, long maxNeverUsedIntervalMs)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckContainers()Manually check the containers.protected Collection<String>getCandidates()protected longgetElapsed(DataNode node)protected longgetMinIntervalMs()protected voidpostDeleteRequest(Request request)voidstart()start/restart the timer the runs the check.voidstop()stop the timer if necessary.
 
- 
- 
- 
Constructor Detail- 
ContainerManagerpublic ContainerManager(ZKDatabase zkDb, RequestProcessor requestProcessor, int checkIntervalMs, int maxPerMinute) - Parameters:
- zkDb- the ZK database
- requestProcessor- request processer - used to inject delete container requests
- checkIntervalMs- how often to check containers in milliseconds
- maxPerMinute- the max containers to delete per second - avoids herding of container deletions
 
 - 
ContainerManagerpublic ContainerManager(ZKDatabase zkDb, RequestProcessor requestProcessor, int checkIntervalMs, int maxPerMinute, long maxNeverUsedIntervalMs) - Parameters:
- zkDb- the ZK database
- requestProcessor- request processer - used to inject delete container requests
- checkIntervalMs- how often to check containers in milliseconds
- maxPerMinute- the max containers to delete per second - avoids herding of container deletions
- maxNeverUsedIntervalMs- the max time in milliseconds that a container that has never had any children is retained
 
 
- 
 - 
Method Detail- 
startpublic void start() start/restart the timer the runs the check. Can safely be called multiple times.
 - 
stoppublic void stop() stop the timer if necessary. Can safely be called multiple times.
 - 
checkContainerspublic void checkContainers() throws InterruptedExceptionManually check the containers. Not normally used directly- Throws:
- InterruptedException
 
 - 
postDeleteRequestprotected void postDeleteRequest(Request request) throws RequestProcessor.RequestProcessorException 
 - 
getMinIntervalMsprotected long getMinIntervalMs() 
 - 
getCandidatesprotected Collection<String> getCandidates() 
 - 
getElapsedprotected long getElapsed(DataNode node) 
 
- 
 
-