Package org.apache.solr.core
Class ClusterSingletons
- java.lang.Object
-
- org.apache.solr.core.ClusterSingletons
-
public class ClusterSingletons extends Object
Helper class to manage the initial registration ofClusterSingleton
plugins and to track the changes in loaded plugins inContainerPluginsRegistry
.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_WAIT_TIMEOUT_SEC
-
Constructor Summary
Constructors Constructor Description ClusterSingletons(Supplier<Boolean> runSingletons, Consumer<Runnable> asyncRunner)
Create a helper to manage singletons.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ContainerPluginsRegistry.PluginRegistryListener
getPluginRegistryListener()
Map<String,ClusterSingleton>
getSingletons()
Return modifiable registry of name /ClusterSingleton
.boolean
isReady()
Return true when this helper is ready to be used for singleton management.void
setReady()
Mark this helper as ready to be used for singleton management.void
startClusterSingletons()
Start singletons when the helper is ready and when it's supposed to start (as determined byrunSingletons
function).void
stopClusterSingletons()
Stop all registered singletons.void
waitUntilReady(long timeout, TimeUnit timeUnit)
Wait for this helper to become ready.
-
-
-
Field Detail
-
DEFAULT_WAIT_TIMEOUT_SEC
public static final int DEFAULT_WAIT_TIMEOUT_SEC
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ClusterSingletons
public ClusterSingletons(Supplier<Boolean> runSingletons, Consumer<Runnable> asyncRunner)
Create a helper to manage singletons.- Parameters:
runSingletons
- this function returns true when singletons should be running. It's Used when adding or modifying existing plugins, and when invokingstartClusterSingletons()
.asyncRunner
- async runner that will be used for starting up each singleton.
-
-
Method Detail
-
getPluginRegistryListener
public ContainerPluginsRegistry.PluginRegistryListener getPluginRegistryListener()
-
getSingletons
public Map<String,ClusterSingleton> getSingletons()
Return modifiable registry of name /ClusterSingleton
.
-
isReady
public boolean isReady()
Return true when this helper is ready to be used for singleton management.
-
setReady
public void setReady()
Mark this helper as ready to be used for singleton management.
-
waitUntilReady
public void waitUntilReady(long timeout, TimeUnit timeUnit) throws InterruptedException, TimeoutException
Wait for this helper to become ready.- Parameters:
timeout
- timeout value.timeUnit
- timeout unit.- Throws:
InterruptedException
- on this thread being interrupted.TimeoutException
- when specified timeout has elapsed but the helper is not ready.
-
startClusterSingletons
public void startClusterSingletons()
Start singletons when the helper is ready and when it's supposed to start (as determined byrunSingletons
function). If the helper is not ready this method will useasyncRunner
to wait in another thread forDEFAULT_WAIT_TIMEOUT_SEC
seconds.
-
stopClusterSingletons
public void stopClusterSingletons()
Stop all registered singletons.
-
-