public class SingletonManager extends ObjectThis 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.
Nested Class Summary
Nested Classes Modifier and Type Class Description
SingletonManager.ModeThese enums determine the behavior of the SingletonManager.
Constructors Constructor Description
All Methods Static Methods Concrete Methods Modifier and Type Method Description
getClientReservation()This method should be called when creating Accumulo clients using the public API.
register(SingletonService service)Register a static singleton that should be disabled and enabled as needed.
setMode(SingletonManager.Mode mode)Change how singletons are managed.
public static void register(SingletonService service)Register a static singleton that should be disabled and enabled as needed.
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.
- A reservation that must be closed when the AccumuloClient is closed.
public static long getReservationCount()
public static void setMode(SingletonManager.Mode mode)Change how singletons are managed. The default mode is
public static SingletonManager.Mode getMode()