Class JobForecaster

    • Constructor Detail

      • JobForecaster

        public JobForecaster()
    • Method Detail

      • forecastJobToString

        public static String forecastJobToString​(ForecastJob fj)
        Get a string representation of a forecasted job.
        Parameters:
        fj - the forecasted job.
        Returns:
        a string representation.
      • forecastJobs

        public RWIterable<ForecastJob> forecastJobs​(SchedulerSession session,
                                                    DateTimeZone begin,
                                                    DateTimeZone end,
                                                    List<Long> jobUniqueIds)
                                             throws SchedulerAPIException
        Create forecast jobs for all active job groups at the specified date range. If jobUniqueIds is null, all jobs in the system will be forecast. Note that forecasts cannot be persisted.
        Specified by:
        forecastJobs in interface JobForecasterComp
        Parameters:
        session - in which to forecast.
        begin - of the forecast period; an empty list will be returned if not specified.
        end - of the forecast period; an empty list will be returned if not specified.
        jobUniqueIds - is an optional list of Long or UniqueIdObjects, containing the uniqueIds for the jobs to forecast.
        Returns:
        iterator with ForecastJobs.
        Throws:
        SchedulerAPIException - if errors are encountered while computing the ForecastJobs.
      • forecastJobs

        public Map<Long,​ForecastJob> forecastJobs​(SchedulerSession session,
                                                        DateTimeZone begin,
                                                        DateTimeZone end,
                                                        List<Long> jobUniqueIds,
                                                        long maxForecastCount)
        Create forecast jobs for all active job groups at the specified date range. If no jobUniqueIds are specified, all jobs in the system will be forecast. Note that forecasts cannot be persisted. No more than maxForecastCount items will be returned. The algorithm is such, that the forecasts will be limited in time, not in job groups. There are no missing forecasts between the first and the last returned forecast job.
        Parameters:
        session - in which to forecast.
        begin - of the forecast period; an empty list will be returned if not specified.
        end - of the forecast period; if not specified, forecast period is at begin date.
        jobUniqueIds - is an optional list of Long or UniqueIdObjects, containing the uniqueIds for the jobs to forecast.
        maxForecastCount - is the maximum number of forecast jobs to be returned.
        Returns:
        map with ForecastJobs, keyed by their unique id.
      • forecastChildJobs

        public ForecastJob forecastChildJobs​(SchedulerSession session,
                                             Long jobId)
        For job chains, the job chain run will be simulated.
        Parameters:
        session - in which to forecast.
        jobId - to forecast
        Returns:
        the forecastJob for jobId with child jobs filled.
      • getJobsForQueues

        public static List<Long> getJobsForQueues​(SchedulerSession session,
                                                  List<Long> queueIds,
                                                  DateTimeZone jobsFrom,
                                                  DateTimeZone jobsTo,
                                                  boolean includeMaintenanceJobs)
                                           throws SchedulerAPIException
        A helper function for a request to forecast the jobs in a set of queues where the scheduled start time of the jobs are in a certain time range. For each job group, only one job is added to the list.
        Parameters:
        session - to execute the query in
        queueIds - are the uniqueIds of the queues which jobs must be forecast
        jobsFrom - optional start of the time range for the jobs
        jobsTo - optional end of the time range for the jobs
        includeMaintenanceJobs - is true if the maintenance jobs must be forecast as well; if false, the maintenance jobs will be excluded from the result
        Returns:
        a list of jobUniqueIds that must be forecast
        Throws:
        SchedulerAPIException - if errors are encountered while computing the list of jobs.
      • getJobsForProcessServers

        public static List<Long> getJobsForProcessServers​(SchedulerSession session,
                                                          List<Long> processServerIds,
                                                          DateTimeZone jobsFrom,
                                                          DateTimeZone jobsTo,
                                                          boolean includeMaintenanceJobs)
                                                   throws SchedulerAPIException
        A helper function for a request to forecast the jobs in a set of process servers where the scheduled start time of the jobs are in a certain time range. For each job group, only one job is added to the list.
        Parameters:
        session - to execute the query in
        processServerIds - are the uniqueIds of the process servers which jobs must be forecast
        jobsFrom - optional start of the time range for the jobs
        jobsTo - optional end of the time range for the jobs
        includeMaintenanceJobs - is true if the maintenance jobs must be forecast as well; if false, the maintenance jobs will be excluded from the result
        Returns:
        a list of jobUniqueIds that must be forecast
        Throws:
        SchedulerAPIException - if errors are encountered while computing the list of jobs.
      • getJobsForRelatedEntity

        public static List<Long> getJobsForRelatedEntity​(SchedulerSession session,
                                                         String entityType,
                                                         List<Long> entityIds,
                                                         DateTimeZone jobsFrom,
                                                         DateTimeZone jobsTo,
                                                         boolean includeMaintenanceJobs)
                                                  throws SchedulerAPIException
        A helper function for a request to forecast the jobs in a set of entities (queues, process servers) where the scheduled start time of the jobs are in a certain time range. For each job group, only one job is added to the list.
        Parameters:
        session - to execute the query in
        entityType - object type of the entity
        entityIds - are the uniqueIds of the entities for which jobs must be forecast
        jobsFrom - optional start of the time range for the jobs
        jobsTo - optional end of the time range for the jobs
        includeMaintenanceJobs - is true if the maintenance jobs must be forecast as well; if false, the maintenance jobs will be excluded from the result
        Returns:
        a list of jobUniqueIds that must be forecast
        Throws:
        SchedulerAPIException - if errors are encountered while computing the list of jobs.
      • includeExistingJobs

        public boolean includeExistingJobs()
        Description copied from interface: JobForecastContext
        Are existing jobs included in the result or only return the forecasts when forecasting the jobs in a job group. Does not apply to forecasting the child jobs of a job.
        Specified by:
        includeExistingJobs in interface JobForecastContext
        Returns:
        the value.
      • setIncludeExistingJobs

        public void setIncludeExistingJobs​(boolean newIncludeExistingJobs)
        Include existing jobs or not.
        Parameters:
        newIncludeExistingJobs - new value.