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

The following examples show how to use org.quartz.Scheduler#standby() . 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: KENTestCase.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
 * 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();
}
 
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: ScheduledPersistedActionServiceTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@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();
}
 
Example 5
Source File: QuartzSchedulerProvider.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
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);
  }
}
 
Example 6
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();
}