Java Code Examples for org.quartz.Scheduler#isInStandbyMode()

The following examples show how to use org.quartz.Scheduler#isInStandbyMode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScheduleServiceImpl.java    From fixflow with Apache License 2.0 6 votes vote down vote up
public void schedulerRestart() {
	if(!getIsEnabled()){
		throw new FixFlowScheduleException(ExceptionCode.QUARZTEXCEPTION_ISENABLE);
	}
	Scheduler scheduler;
	try {
		scheduler = getScheduler();
		if(scheduler.isInStandbyMode()){
			scheduler.start();
		}else{
			scheduler.standby();
			scheduler.start();
		}
	} catch (SchedulerException e) {
		throw new FixFlowException(e.getMessage(),e);
	}
}
 
Example 2
Source File: ScheduleServiceImpl.java    From fixflow with Apache License 2.0 5 votes vote down vote up
public void schedulerStart() {
	if(!getIsEnabled()){
		throw new FixFlowScheduleException(ExceptionCode.QUARZTEXCEPTION_ISENABLE);
	}
	Scheduler scheduler;
	try {
		scheduler = getScheduler();
		if(scheduler.isInStandbyMode()){
			scheduler.start();
		}
	} catch (SchedulerException e) {
		throw new FixFlowException(e.getMessage(),e);
	}
}
 
Example 3
Source File: ScheduleServiceImpl.java    From fixflow with Apache License 2.0 5 votes vote down vote up
public void schedulerShutdown() {
	if(!getIsEnabled()){
		throw new FixFlowScheduleException(ExceptionCode.QUARZTEXCEPTION_ISENABLE);
	}
	Scheduler scheduler;
	try {
		scheduler = getScheduler();
		if(!scheduler.isInStandbyMode()){
			scheduler.standby();
		}
	} catch (SchedulerException e) {
		throw new FixFlowException(e.getMessage(),e);
	}
}
 
Example 4
Source File: ShowScheduler.java    From iaf with Apache License 2.0 4 votes vote down vote up
@PUT
@RolesAllowed({"IbisDataAdmin", "IbisAdmin", "IbisTester"})
@Path("/schedules/")
@Relation("schedules")
@Produces(MediaType.APPLICATION_JSON)
public Response updateScheduler(LinkedHashMap<String, Object> json) throws ApiException {
	Scheduler scheduler = getScheduler();

	String action = null;
	for (Entry<String, Object> entry : json.entrySet()) {
		String key = entry.getKey();
		if(key.equalsIgnoreCase("action")) {
			action = entry.getValue().toString();
		}
	}

	try {
		String commandIssuedBy = servletConfig.getInitParameter("remoteHost");
		commandIssuedBy += servletConfig.getInitParameter("remoteAddress");
		commandIssuedBy += servletConfig.getInitParameter("remoteUser");

		if (action.equalsIgnoreCase("start")) {
			if(scheduler.isInStandbyMode() || scheduler.isShutdown()) {
				scheduler.start();
				log.info("start scheduler:" + new Date() + commandIssuedBy);
			}
			else {
				throw new ApiException("Failed to start scheduler");
			}
		}
		else if (action.equalsIgnoreCase("pause")) {
			if(scheduler.isStarted()) {
				scheduler.standby();
				log.info("pause scheduler:" + new Date() + commandIssuedBy);
			}
			else {
				throw new ApiException("Failed to pause scheduler");
			}
		}
		else if (action.equalsIgnoreCase("stop")) {
			if(scheduler.isStarted() || scheduler.isInStandbyMode()) {
				scheduler.shutdown();
				log.info("shutdown scheduler:" + new Date() + commandIssuedBy);
			}
			else {
				throw new ApiException("Failed to stop scheduler");
			}
		} else {
			return Response.status(Response.Status.BAD_REQUEST).build();
		}

	} catch (Exception e) {
		log.error("unable to run action ["+action+"]",e);
	}
	return Response.status(Response.Status.OK).build();
}