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

The following examples show how to use org.quartz.Scheduler#isStarted() . 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: QuartzManager.java    From quartz-web with Apache License 2.0 5 votes vote down vote up
/**
 * 启动
 * @param schedulerName
 * @throws SchedulerException
 */
public void schedulerStart(String schedulerName) throws SchedulerException {
    Scheduler scheduler = this.getAssertScheduler(schedulerName);
    if (!scheduler.isStarted()) {
        scheduler.start();
    }
}
 
Example 2
Source File: QuartzManager.java    From quartz-web with Apache License 2.0 5 votes vote down vote up
/**
 * 延时启动
 * @param schedulerName
 * @param delayed 延迟秒数
 * @throws SchedulerException
 */
public void schedulerStart(String schedulerName, int delayed) throws SchedulerException {
    Scheduler scheduler = this.getAssertScheduler(schedulerName);
    if (!scheduler.isStarted()) {
        if (delayed <= 0) {
            scheduler.start();
        } else {
            scheduler.startDelayed(delayed);
        }
    }
}
 
Example 3
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();
}