Class ClusterSingletons

    • 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 invoking startClusterSingletons().
        asyncRunner - async runner that will be used for starting up each singleton.
    • Method Detail

      • 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.
      • startClusterSingletons

        public void startClusterSingletons()
        Start singletons when the helper is ready and when it's supposed to start (as determined by runSingletons function). If the helper is not ready this method will use asyncRunner to wait in another thread for DEFAULT_WAIT_TIMEOUT_SEC seconds.
      • stopClusterSingletons

        public void stopClusterSingletons()
        Stop all registered singletons.