Interface ClusterHandler

  • All Superinterfaces:
    CustomBean

    public interface ClusterHandler
    extends CustomBean
    Handler for Cyclos 4 cluster, providing aspects like caches and task synchronization
    • Method Detail

      • checkConsistency

        default void checkConsistency()
                               throws IllegalStateException
        This method is invoked after the ApplicationContext gets started. Implementors can add custom logic to ensure the cluster is in the appropriate state.
        Throws:
        IllegalStateException - if the state is not the expected one causing the application to shutdown. NOTE: We decided to implement this with a specific method that will be invoked from the ApplicationHandler instead of doing the check in the PostConstruct method to avoid flood the log with errors.
      • clearCaches

        void clearCaches()
        Clear all caches from all members in the cluster
      • finishBackgroundTaskExecution

        void finishBackgroundTaskExecution​(BackgroundTaskExecutionContext task)
        Masks as finished the given task execution
      • getBackgroundTaskExecutions

        Map<String,​Integer> getBackgroundTaskExecutions()
        Returns a map from background task name to the number of executions it has. A task no contained in the map means it's not running at the moment of the invocation.
      • getBackgroundTasksQueueSize

        int getBackgroundTasksQueueSize()
        Returns the current size of the background tasks queue
      • getCachesInformation

        List<CacheVO> getCachesInformation​(CacheQuery query)
        Returns information of each local cache summarized over all members.
      • getCachesInformationByMember

        Map<String,​List<CacheVO>> getCachesInformationByMember​(CacheQuery query)
        Returns the same information as with getCachesInformation(CacheQuery)
        This method should not be in the ClusterHandler interface because it's defined by debugging purposes and only has sense for this implementation but the dynamic proxy we use only proxies the methods in interfaces.
        Parameters:
        query -
      • getFinishedBackgroundTaskExecutions

        ClusterHandler.FinishedExecutionsHandler getFinishedBackgroundTaskExecutions()
        Returns a handler with the already finished executions at the moment of the invocation.
      • getHostId

        String getHostId()
        Returns the current host identifier
      • getLocalStorage

        <K,​V> LocalStorage<K,​V> getLocalStorage​(LocalStorageType<K,​V> type)
        Returns the local storage for the given type
      • getMaxBackgroundTaskCapacity

        int getMaxBackgroundTaskCapacity()
        Returns number of BackgroundTaskExecution the cluster can accept as max.
      • getMemberConfiguration

        String getMemberConfiguration()
        Return the cluster configuration only if isCluster() returns true. Otherwise return null.
      • getMemberRunningTask

        MemberRunningTaskDescriptor getMemberRunningTask​(String taskName)
        Returns information with the member running the given recurring task or null if the task is not being executed.
      • getMembersData

        List<ServerData> getMembersData()
        Returns information about each cluster member.
        In case isCluster() returns false then the list will contain a single element with the information of the local host.
      • getProfilingManager

        ProfilingManager getProfilingManager()
        Returns the cluster-specific profiling handler
      • getRemainingBackgroundTaskCapacity

        int getRemainingBackgroundTaskCapacity()
        Returns number of BackgroundTaskExecution the cluster can accept.
      • getRunningRecurringTasks

        Map<String,​MemberRunningTaskDescriptor> getRunningRecurringTasks()
        Returns a map from recurring task name to a descriptor with information about the member that is executing it. A task no contained in the map means it's not running at the moment of the invocation.
      • isAlive

        boolean isAlive()
        Returns whether the cluster (or local instance) is still alive
      • isCausedByShutdown

        boolean isCausedByShutdown​(Throwable e)
        Returns whether the given exception was caused by a server shutdown. For example, InterruptedExceptions are considered to be caused by a shutdown.
      • isCluster

        boolean isCluster()
        Returns whether we're actually running in a cluster or as a single node installation
      • lockDatabase

        boolean lockDatabase()
        Checks that there is no other Cyclos instance using the database and afterwards, locks the database. Returns whether the database was actually locked.
      • starTaskTimers

        void starTaskTimers()
        Starts the timers for schedule tasks, send lock keep-alive, etc.
        This method is guaranteed to be called only after all initialisations run.