Interface WorkloadManager


  • public interface WorkloadManager
    Interface defines the API of a so called workload manager. Workload managers are able to ensure that is system is not overloaded by too many requests. Therefore they are able to queue and reject requests. Usually workload managers make use of asynchronous process as it is e.g supported for Servlets or REST Resource in the JEE standards. How the workload manager works in details is highly depending on the used implementation and their configuration capabilities. Most workload managers support a concept called pipeline. Each pipeline has its own thread pool and queuing strategy. Which pipeline is used for a concrete request type can be configured using so called workload mappings. All those configurations are done using annotations: StaticWorkloadConfig, ElasticWorkloadConfig, WorkloadMapping and PipelineConfig
    Author:
    JEAF Development Team
    • Method Detail

      • execute

        void execute​(RequestType pRequestType,
                     WorkloadErrorHandler pErrorHandler,
                     java.lang.Runnable pRequest)
        Method tells the workload manager to execute the passed runnable. However the workload manager may not directly execute the passed request but schedule it until resources are available. In most cases this method will return before the request is executed. Thus the passed runnable must be able to handle such a behavior. For further details on the requirements of the runnable implementation see the following locations
        Parameters:
        pRequestType - Meta information about the request. This information can be used by the workload manager implementation to prioritize and dispatch the request. The parameter must not be null.
        pErrorHandler - Error handler that should be used by implementations to indicate problems during the execution of requests.
        pRequest - Runnable object implementing the command / request that should be executed. The parameter must not be null.
      • isPipelineOverloaded

        boolean isPipelineOverloaded​(RequestType pRequestType)
        Method checks if the pipeline that will be used to execute the passed request type is overloaded or not. This method might be used to reject request already on early stages to avoid unnecessary load. An example would be that before a heavy JSON request is converted into Java objects it is checked by a Servlet filter is pipeline is not overloaded. When exactly a pipeline is considered to be overloaded depends on the implementation and configuration of the workload manager. If the workload manager is not able to detect a matching pipeline for the request type then it has to return false as we can not say for sure that there is an overload.
        Parameters:
        pRequestType - Meta information about the request. This information can be used by the workload manager implementation to detect the pipeline that will be used for the request execution.
        Returns:
        boolean Method returns true if the pipeline is already overloaded and otherwise false.