
org.bonitasoft.engine.scheduler.SchedulerService Maven / Gradle / Ivy
/**
* Copyright (C) 2015 BonitaSoft S.A.
* BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation
* version 2.1 of the License.
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301, USA.
**/
package org.bonitasoft.engine.scheduler;
import java.util.Date;
import java.util.List;
import org.bonitasoft.engine.commons.PlatformLifecycleService;
import org.bonitasoft.engine.commons.exceptions.SBonitaException;
import org.bonitasoft.engine.scheduler.exception.SSchedulerException;
import org.bonitasoft.engine.scheduler.model.SJobDescriptor;
import org.bonitasoft.engine.scheduler.model.SJobParameter;
import org.bonitasoft.engine.scheduler.trigger.Trigger;
/**
* @author Matthieu Chaffotte
* @since 6.0
*/
public interface SchedulerService extends PlatformLifecycleService {
String JOB_DESCRIPTOR = "JOB_DESCRIPTOR";
String JOB_PARAMETER = "JOB_PARAMETER";
/**
* This service will fire the following events :
*
* - SCHEDULER_STARTED = "SCHEDULER_STARTED"
* - SCHEDULER_STOPPED = "SCHEDULER_STOPPED"
* - JOB_FAILED = "JOB_FAILED"
*
*/
String SCHEDULER_STARTED = "SCHEDULER_STARTED";
String SCHEDULER_STOPPED = "SCHEDULER_STOPPED";
String JOB_FAILED = "JOB_FAILED";
/**
* Checks whether the service is started.
*
* @return true if the service is started; false otherwise.
* @throws SSchedulerException
* if an exception occurs.
*/
boolean isStarted() throws SSchedulerException;
/**
* Checks whether the service is shutdown.
*
* @return true if the service is shutdown; false otherwise.
* @throws SSchedulerException
*/
boolean isStopped() throws SSchedulerException;
/**
* Schedules a job.
*
* @param jobDescriptor
* @param trigger
* @throws SSchedulerException
* if an exception occurs.
*/
void schedule(SJobDescriptor jobDescriptor, Trigger trigger) throws SSchedulerException;
/**
* Schedules a job.
*
* @param jobDescriptor
* @param jobParameters
* @param trigger
* @throws SSchedulerException
* if an exception occurs.
*/
void schedule(SJobDescriptor jobDescriptor, List parameters, Trigger trigger) throws SSchedulerException;
void executeAgain(long jobDescriptorId) throws SSchedulerException;
/**
* Schedules a job.
*
* @param jobDescriptorId
* @param jobParameters
* @throws SSchedulerException
* if an exception occurs.
*/
void executeAgain(long jobDescriptorId, List parameters) throws SSchedulerException;
/**
* execute a job.
*
* @param jobDescriptor
* @param jobParameters
* @throws SSchedulerException
* if an exception occurs.
*/
void executeNow(SJobDescriptor jobDescriptor, List parameters) throws SSchedulerException;
/**
* Deletes a job according to its name.
*
* @param jobName
* the job name
* @return true if delete a job, otherwise return false.
* @throws SSchedulerException
* if an exception occurs.
*/
boolean delete(String jobName) throws SSchedulerException;
/**
* Deletes all jobs.
*
* @throws SSchedulerException
* if an exception occurs.
*/
void deleteJobs() throws SSchedulerException;
/**
* Get all jobs on the current tenant
*
* @return all jobs on the current tenant
* @throws SSchedulerException
* if an exception occurs.
*/
List getJobs() throws SSchedulerException;
/**
* Get all jobs on all tenants
* \/!\Must be replaced by a platform scheduler/!\
*
* @return all jobs on the current tenant
* @throws SSchedulerException
* if an exception occurs.
*/
List getAllJobs() throws SSchedulerException;
boolean isStillScheduled(SJobDescriptor jobDescriptor) throws SSchedulerException;
void rescheduleErroneousTriggers() throws SSchedulerException;
/**
* Pause all jobs running on the tenant
*
* @param tenantId
* @throws SSchedulerException
*/
void pauseJobs(long tenantId) throws SSchedulerException;
/**
* Resume all jobs paused on the tenant
*
* @param tenantId
* @throws SSchedulerException
*/
void resumeJobs(long tenantId) throws SSchedulerException;
/**
* Remove (delete) the Trigger
with the
* given key, and store the new given one - which must be associated
* with the same job (the new trigger must have the job name & group specified)
* - however, the new trigger need not have the same name as the old trigger.
*
* @param triggerName
* The name of the trigger to replace
* @param groupName
* The group name of the trigger to replace
* @param triggerStartTime
* The start date of the new trigger
* @return null
if a Trigger
with the given
* name & group was not found and removed from the store (and the
* new trigger is therefore not stored), otherwise
* the first fire time of the newly scheduled trigger is returned.
* @throws SSchedulerException
* @since 6.4.0
*/
Date rescheduleJob(String triggerName, String groupName, Date triggerStartTime) throws SSchedulerException;
/**
* Add the given {@link AbstractBonitaTenantJobListener}s
to the Scheduler
,
* and register it to receive events for Jobs that are matched by the group name.
*
* @param jobListeners
* The job listeners to add to the scheduler
* @param groupName
* The group name to filter
* @throws SSchedulerException
* @since 6.4.0
*/
void addJobListener(List jobListeners, String groupName) throws SSchedulerException;
/**
* Add the given {@link AbstractBonitaPlatformJobListener}s
to the Scheduler
, and register it to receive events for all Jobs.
*
* @param jobListeners
* The job listeners to add to the scheduler
* @throws SSchedulerException
* @since 6.4.0
*/
void addJobListener(List jobListeners) throws SSchedulerException;
/**
* Initialize the scheduler if this method has not be previously called (after shutdown); otherwise, do nothing.
*
* @throws SSchedulerException
* @since 6.4.0
*/
void initializeScheduler() throws SSchedulerException;
/**
* Note that once a scheduler is shutdown, it cannot be restarted without being re-instantiated.
*
* @throws SSchedulerException
* @see {@link #initializeScheduler()}
* @since 6.4.0
*/
@Override
void start() throws SBonitaException;
/**
* Note that once a scheduler is shutdown, it cannot be restarted without being re-instantiated.
*
* @throws SSchedulerException
* @see {@link #initializeScheduler()}
* @since 6.4.0
*/
@Override
void stop() throws SBonitaException;
/**
* Check if a job exists.
*
* @param jobName
* The name of the job
* @return True if the job exists, else False.
* @throws SSchedulerException
* @since 6.4.0
*/
boolean isExistingJob(String jobName) throws SSchedulerException;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy