ContainerManager (Apache ZooKeeper - Server 3.7.0 API)
Date: 2021-03-17

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 and 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 and 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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ContainerManager

          public 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

    - #### ContainerManager

          public 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

    - #### 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

      Throws:
        `RequestProcessor.RequestProcessorException`

    - #### getMinIntervalMs

          protected long getMinIntervalMs()

    - #### getCandidates

          protected Collection<String> getCandidates()

    - #### getElapsed

          protected long getElapsed(DataNode node)

Copyright © 2008–2021 The Apache Software Foundation. All rights reserved.