Search in sources :

Example 76 with SchedulerException

use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.

the class EmbeddedVersionCheckSystemListenerIT method init.

@Before
public void init() throws SchedulerException, PlatformInitializationException {
    MicroPlatform mp = new MicroPlatform();
    mp.define(IPluginManager.class, TstPluginManager.class);
    mp.define("IScheduler2", TestQuartzScheduler.class);
    mp.define(IUserRoleListService.class, StubUserRoleListService.class);
    mp.define(UserDetailsService.class, StubUserDetailsService.class);
    mp.start();
    scheduler = PentahoSystem.get(IScheduler.class, "IScheduler2", null);
    scheduler.start();
}
Also used : MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) IScheduler(org.pentaho.platform.api.scheduler2.IScheduler) Before(org.junit.Before)

Example 77 with SchedulerException

use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.

the class JaxWsSchedulerServiceIT method testGetJobs.

@SuppressWarnings("unchecked")
@Test
public void testGetJobs() throws SchedulerException {
    scheduler.pause();
    schedulerSvc.createSimpleJob("testGetJobsJob", generateFullJobParams(), JobTrigger.ONCE_NOW);
    Job[] serviceJobs = schedulerSvc.getJobs();
    // 
    // First make sure the actual scheduler engine can find the newly created job
    // 
    List<Job> engineJobs = scheduler.getJobs(new IJobFilter() {

        public boolean accept(Job job) {
            return job.getJobName().contains("testGetJobsJob");
        }
    });
    Assert.assertEquals("The scheduler engine does not know about the job.", 1, engineJobs.size());
    Job engineJob = engineJobs.get(0);
    // 
    // Now make sure we have the same job available on the webservice client side
    // 
    Assert.assertEquals("The scheduler service does not know about the job.", 1, serviceJobs.length);
    Job serviceJob = schedulerSvc.getJobs()[0];
    Assert.assertEquals("jobName is wrong", engineJob.getJobName(), serviceJob.getJobName());
    Map<String, Serializable> params = serviceJob.getJobParams();
    Assert.assertTrue("string job parameter is wrong", "testStringValue".equals(params.get("stringParam")));
    Assert.assertTrue("list job parameter is missing", params.containsKey("listParam"));
    Assert.assertTrue("map job parameter is missing", params.containsKey("mapParam"));
    Assert.assertTrue("list job parameter is wrong type. Expected List but is " + params.get("listParam").getClass().getName(), params.get("listParam") instanceof List);
    Assert.assertTrue("map job parameter is wrong type. Expected Map but is " + params.get("mapParam").getClass().getName(), params.get("mapParam") instanceof Map);
    List<String> listParam = (List<String>) params.get("listParam");
    Assert.assertTrue("list job parameter has wrong value", "testListVal0".equals(listParam.get(0)));
    Assert.assertTrue("list job parameter has wrong value", "testListVal1".equals(listParam.get(1)));
    Map<String, String> mapParam = (Map<String, String>) params.get("mapParam");
    Assert.assertTrue("map job parameter has wrong value", "testMapVal0".equals(mapParam.get("testMapKey0")));
    Assert.assertTrue("map job parameter has wrong value", "testMapVal1".equals(mapParam.get("testMapKey1")));
}
Also used : IJobFilter(org.pentaho.platform.api.scheduler2.IJobFilter) Serializable(java.io.Serializable) List(java.util.List) Job(org.pentaho.platform.api.scheduler2.Job) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 78 with SchedulerException

use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.

the class QuartzScheduler method shutdown.

/**
 * {@inheritDoc}
 */
public void shutdown() throws SchedulerException {
    try {
        boolean waitForJobsToComplete = true;
        getQuartzScheduler().shutdown(waitForJobsToComplete);
        setQuartzScheduler(null);
    } catch (org.quartz.SchedulerException e) {
        throw new SchedulerException(e);
    }
}
Also used : SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException)

Example 79 with SchedulerException

use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.

the class QuartzScheduler method removeJob.

/**
 * {@inheritDoc}
 */
public void removeJob(String jobId) throws SchedulerException {
    try {
        Scheduler scheduler = getQuartzScheduler();
        scheduler.deleteJob(jobId, QuartzJobKey.parse(jobId).getUserName());
    } catch (org.quartz.SchedulerException e) {
        throw new SchedulerException(Messages.getInstance().getString("QuartzScheduler.ERROR_0005_FAILED_TO_PAUSE_JOBS"), // $NON-NLS-1$
        e);
    }
}
Also used : SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) Scheduler(org.quartz.Scheduler) IScheduler(org.pentaho.platform.api.scheduler2.IScheduler)

Example 80 with SchedulerException

use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.

the class QuartzScheduler method pauseJob.

/**
 * {@inheritDoc}
 */
public void pauseJob(String jobId) throws SchedulerException {
    try {
        Scheduler scheduler = getQuartzScheduler();
        scheduler.pauseJob(jobId, QuartzJobKey.parse(jobId).getUserName());
    } catch (org.quartz.SchedulerException e) {
        throw new SchedulerException(Messages.getInstance().getString("QuartzScheduler.ERROR_0005_FAILED_TO_PAUSE_JOBS"), // $NON-NLS-1$
        e);
    }
}
Also used : SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) Scheduler(org.quartz.Scheduler) IScheduler(org.pentaho.platform.api.scheduler2.IScheduler)

Aggregations

SchedulerException (org.pentaho.platform.api.scheduler2.SchedulerException)51 Test (org.junit.Test)49 Job (org.pentaho.platform.api.scheduler2.Job)43 IScheduler (org.pentaho.platform.api.scheduler2.IScheduler)23 ComplexJobTrigger (org.pentaho.platform.api.scheduler2.ComplexJobTrigger)18 SimpleJobTrigger (org.pentaho.platform.api.scheduler2.SimpleJobTrigger)16 Serializable (java.io.Serializable)15 IJobTrigger (org.pentaho.platform.api.scheduler2.IJobTrigger)11 Date (java.util.Date)10 JobTrigger (org.pentaho.platform.api.scheduler2.JobTrigger)9 Scheduler (org.quartz.Scheduler)9 ArrayList (java.util.ArrayList)8 IJobFilter (org.pentaho.platform.api.scheduler2.IJobFilter)8 IOException (java.io.IOException)6 Calendar (java.util.Calendar)6 HashMap (java.util.HashMap)6 CronTrigger (org.quartz.CronTrigger)6 SimpleTrigger (org.quartz.SimpleTrigger)6 Trigger (org.quartz.Trigger)6 Response (javax.ws.rs.core.Response)5