org.quartz.Scheduler#standby ( )源码实例Demo

下面列出了org.quartz.Scheduler#standby ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: fixflow   文件: ScheduleServiceImpl.java
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);
	}
}
 
源代码2 项目: rice   文件: KENTestCase.java
/**
 * This method makes sure to disable the Quartz scheduler
 * @throws SchedulerException
 */
protected void disableQuartzJobs() throws SchedulerException {
    // do this so that our quartz jobs don't go off - we don't care about
    // these in our unit tests
    Scheduler scheduler = services.getScheduler();
    scheduler.standby();
    //scheduler.shutdown();
}
 
源代码3 项目: fixflow   文件: ScheduleServiceImpl.java
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);
	}
}
 
@Before
public void setUp() throws Exception
{
    actionService = (ActionService) applicationContext.getBean("actionService");
    nodeService = (NodeService) applicationContext.getBean("nodeService");
    transactionService = (TransactionService) applicationContext.getBean("transactionService");
    runtimeActionService = (RuntimeActionService) applicationContext.getBean("actionService");
    service = (ScheduledPersistedActionService) applicationContext.getBean("ScheduledPersistedActionService");
    serviceImpl = (ScheduledPersistedActionServiceImpl) applicationContext.getBean("scheduledPersistedActionService");
    scheduler = (Scheduler) applicationContext.getBean("schedulerFactory");
    bootstrap = (ScheduledPersistedActionServiceBootstrap) applicationContext.getBean("scheduledPersistedActionServiceBootstrap");

    // Set the current security context as admin
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());

    UserTransaction txn = transactionService.getUserTransaction();
    txn.begin();

    // Register the test executor, if needed
    SleepActionExecuter.registerIfNeeded(applicationContext);

    // Zap all test schedules
    List<ScheduledPersistedAction> schedules = service.listSchedules();
    for (ScheduledPersistedAction schedule : schedules)
    {
        service.deleteSchedule(schedule);
    }

    // Persist an action that uses the test executor
    testAction = new TestAction(actionService.createAction(SleepActionExecuter.NAME));
    runtimeActionService.createActionNodeRef(testAction, serviceImpl.SCHEDULED_ACTION_ROOT_NODE_REF,
            ContentModel.ASSOC_CONTAINS, QName.createQName("TestAction"));

    testAction2 = new TestAction(actionService.createAction(SleepActionExecuter.NAME));
    runtimeActionService.createActionNodeRef(testAction2, serviceImpl.SCHEDULED_ACTION_ROOT_NODE_REF,
            ContentModel.ASSOC_CONTAINS, QName.createQName("TestAction2"));

    testAction3 = new TestAction(actionService.createAction(SleepActionExecuter.NAME));

    // Finish setup
    txn.commit();

    // By default, we don't want the scheduler to fire while the tests run
    // Certain tests will enable it as required
    scheduler.standby();
}
 
源代码5 项目: nexus-public   文件: QuartzSchedulerProvider.java
private Scheduler createScheduler() {
  try {
    // ensure executed threads have TCCL set
    ThreadExecutor threadExecutor = new DefaultThreadExecutor()
    {
      @Override
      public void execute(final Thread thread) {
        thread.setContextClassLoader(QuartzSchedulerProvider.class.getClassLoader());
        super.execute(thread);
      }
    };

    // create Scheduler (implicitly registers it with repository)
    DirectSchedulerFactory.getInstance().createScheduler(
        SCHEDULER_NAME,
        nodeAccess.getId(), // instance-id
        new QuartzThreadPool(threadPoolSize, threadPriority),
        threadExecutor,
        jobStore.get(),
        null, // scheduler plugin-map
        null, // rmi-registry host
        0,    // rmi-registry port
        -1,   // idle-wait time
        -1,   // db-failure retry-interval
        true, // jmx-export
        null, // custom jmx object-name, lets use the default
        1,    // max batch-size
        0L    // batch time-window
    );
    Scheduler s = DirectSchedulerFactory.getInstance().getScheduler(SCHEDULER_NAME);
    s.setJobFactory(jobFactory);

    // re-logging with version, as by default we limit quartz logging to WARN, hiding its default version logging
    log.info("Quartz Scheduler v{}", s.getMetaData().getVersion());

    s.standby();

    return s;
  }
  catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
源代码6 项目: iaf   文件: ShowScheduler.java
@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();
}