Class SingletonManager
- java.lang.Object
-
- org.apache.accumulo.core.singletons.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SingletonManager.Mode
These enums determine the behavior of the SingletonManager.
-
Constructor Summary
Constructors Constructor Description SingletonManager()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SingletonReservation
getClientReservation()
This method should be called when creating Accumulo clients using the public API.static SingletonManager.Mode
getMode()
static long
getReservationCount()
static void
register(SingletonService service)
Register a static singleton that should be disabled and enabled as needed.static void
setMode(SingletonManager.Mode mode)
Change how singletons are managed.
-
-
-
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 callSingletonReservation.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()
-
setMode
public static void setMode(SingletonManager.Mode mode)
Change how singletons are managed. The default mode isSingletonManager.Mode.CLIENT
-
getMode
public static SingletonManager.Mode getMode()
-
-