Package com.yahoo.vespa.curator.api
Interface VespaCurator.SingletonWorker
- All Known Implementing Classes:
AbstractSingletonWorker
- Enclosing interface:
- VespaCurator
public static interface VespaCurator.SingletonWorker
Callback interface for processes of which only a single instance should be active at any time, across all
containers in the cluster, and across all component generations. Notes:
activate()
is called by the system on a singleton whenever it is the newest registered singleton in this container, and this container has the lease for the ID with which the singleton was registered. SeeVespaCurator.registerSingleton(java.lang.String, com.yahoo.vespa.curator.api.VespaCurator.SingletonWorker)
andVespaCurator.isActive(java.lang.String)
.deactivate()
is called by the system on a singleton which is currently active whenever the above no longer holds. SeeVespaCurator.unregisterSingleton(com.yahoo.vespa.curator.api.VespaCurator.SingletonWorker)
.- Callbacks for the same ID are always invoked by the same thread, in serial; the callbacks must return in a timely manner, but are allowed to throw exceptions.
- Activation and deactivation may be triggered by:
- the container acquiring or losing the activation lease; or
- registration of unregistration of a new or obsolete singleton.
- A container without any registered singletons will not attempt to hold the activation lease.
AbstractSingletonWorker
for an abstract superclass to use for implementations.-
Method Summary
Modifier and TypeMethodDescriptionvoid
activate()
Called by the system whenever this singleton becomes the single active worker.void
Called by the system whenever this singleton is no longer the single active worker.
-
Method Details
-
activate
void activate()Called by the system whenever this singleton becomes the single active worker. If this is triggered because the container obtains the activation lease, and activation fails, then the container immediately releases the lease, so another container may acquire it instead. -
deactivate
void deactivate()Called by the system whenever this singleton is no longer the single active worker.
-