Class SingletonManager


  • public class SingletonManager
    extends Object
    This class automates management of static singletons that maintain state for Accumulo clients. Historically, Accumulo client code that used Connector had no control over these singletons. The new AccumuloClient API that replaces Connector is closeable. When all AccumuloClients are closed then resources used by the singletons are released. This class coordinates releasing those resources. For compatibility purposes this class will not release resources when the user has created Connectors.

    This class is intermediate solution to resource management. Ideally there would be no static state and AccumuloClients would own all of their state and clean it up on close. If AccumuloClient is not closable at inception, then it is harder to make it closable later. If AccumuloClient is not closable, then its hard to remove the static state. This class enables making AccumuloClient closable at inception so that static state can be removed later.

    • Constructor Detail

      • SingletonManager

        public SingletonManager()
    • Method Detail

      • register

        public static void register​(SingletonService service)
        Register a static singleton that should be disabled and enabled as needed.
      • getClientReservation

        public static SingletonReservation getClientReservation()
        This method should be called when creating Accumulo clients using the public API. Accumulo clients created internally within Accumulo code should probably call SingletonReservation.noop() instead. While a client holds a reservation, singleton services are enabled.
        Returns:
        A reservation that must be closed when the AccumuloClient is closed.
      • getReservationCount

        public static long getReservationCount()