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 ofClusterSingletonplugins and to track the changes in loaded plugins inContainerPluginsRegistry.
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_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.PluginRegistryListenergetPluginRegistryListener()Map<String,ClusterSingleton>getSingletons()Return modifiable registry of name /ClusterSingleton.booleanisReady()Return true when this helper is ready to be used for singleton management.voidsetReady()Mark this helper as ready to be used for singleton management.voidstartClusterSingletons()Start singletons when the helper is ready and when it's supposed to start (as determined byrunSingletonsfunction).voidstopClusterSingletons()Stop all registered singletons.voidwaitUntilReady(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, TimeoutExceptionWait 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 byrunSingletonsfunction). If the helper is not ready this method will useasyncRunnerto wait in another thread forDEFAULT_WAIT_TIMEOUT_SECseconds.
-
stopClusterSingletons
public void stopClusterSingletons()
Stop all registered singletons.
-
-