下面列出了org.quartz.Scheduler#isInStandbyMode ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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);
}
}
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);
}
}
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);
}
}
@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();
}