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 Summary
Constructors Constructor Description ContainerManager(ZKDatabase zkDb, RequestProcessor requestProcessor, int checkIntervalMs, int maxPerMinute)
ContainerManager(ZKDatabase zkDb, RequestProcessor requestProcessor, int checkIntervalMs, int maxPerMinute, long maxNeverUsedIntervalMs)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkContainers()
Manually check the containers.protected Collection<String>
getCandidates()
protected long
getElapsed(DataNode node)
protected long
getMinIntervalMs()
protected void
postDeleteRequest(Request request)
void
start()
start/restart the timer the runs the check.void
stop()
stop the timer if necessary.
-
-
-
Constructor Detail
-
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 Detail
-
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
public void checkContainers() throws InterruptedException
Manually check the containers. Not normally used directly- Throws:
InterruptedException
-
postDeleteRequest
protected void postDeleteRequest(Request request) throws RequestProcessor.RequestProcessorException
-
getMinIntervalMs
protected long getMinIntervalMs()
-
getCandidates
protected Collection<String> getCandidates()
-
getElapsed
protected long getElapsed(DataNode node)
-
-