Search in sources :

Example 96 with Job

use of com.google.cloud.dataproc.v1beta2.Job in project pentaho-platform by pentaho.

the class SchedulerResourceTest method testGetContentCleanerJob.

@Test
public void testGetContentCleanerJob() throws Exception {
    Job mockJob = mock(Job.class);
    doReturn(mockJob).when(schedulerResource.schedulerService).getContentCleanerJob();
    Job testJob = schedulerResource.getContentCleanerJob();
    assertEquals(mockJob, testJob);
    verify(schedulerResource.schedulerService, times(1)).getContentCleanerJob();
}
Also used : Job(org.pentaho.platform.api.scheduler2.Job) Test(org.junit.Test)

Example 97 with Job

use of com.google.cloud.dataproc.v1beta2.Job in project pentaho-platform by pentaho.

the class SchedulerResourceTest method updateJob_ReturnsJobId.

@Test
public void updateJob_ReturnsJobId() throws Exception {
    JobScheduleRequest request = new JobScheduleRequest();
    Job job = new Job();
    job.setJobId("job-id");
    when(schedulerResource.schedulerService.updateJob(request)).thenReturn(job);
    assertUpdateJob(request, OK, job.getJobId());
}
Also used : Job(org.pentaho.platform.api.scheduler2.Job) Test(org.junit.Test)

Example 98 with Job

use of com.google.cloud.dataproc.v1beta2.Job in project pentaho-platform by pentaho.

the class BlockoutManagerUtil method getFireTimes.

public static List<Date> getFireTimes(IJobTrigger jobTrigger, IScheduler scheduler) {
    // Determines the maximum amount of fire times allowed to be calculated
    int n = 1000;
    Date startDate = new Date(System.currentTimeMillis());
    Date endDate = new Date(startDate.getTime() + 4 * TIME.YEAR.time);
    // Quartz Triggers
    if (scheduler instanceof QuartzScheduler) {
        try {
            List<Date> dates = new ArrayList<Date>();
            boolean endDateIsNull = jobTrigger.getEndTime() == null;
            // $NON-NLS-1$ //$NON-NLS-2$
            Trigger trigger = QuartzScheduler.createQuartzTrigger(jobTrigger, new QuartzJobKey("test", "test"));
            // add previous trigger (it might be currently active)
            // $NON-NLS-1$;
            IBlockoutManager manager = PentahoSystem.get(IBlockoutManager.class, "IBlockoutManager", null);
            if (manager != null) {
                List<Job> blockouts = manager.getBlockOutJobs();
                for (Job blockout : blockouts) {
                    if (blockout.getLastRun() != null) {
                        dates.add(blockout.getLastRun());
                    }
                }
            }
            for (int i = 0; i < n; i++) {
                Date nextFireTime = trigger.getFireTimeAfter(startDate);
                if ((nextFireTime == null) || (nextFireTime.after(endDate) || (!endDateIsNull && nextFireTime.after(jobTrigger.getEndTime())))) {
                    break;
                }
                dates.add(nextFireTime);
                startDate = nextFireTime;
            }
            return dates;
        } catch (SchedulerException e) {
            throw new RuntimeException(e);
        }
    }
    throw new RuntimeException(// $NON-NLS-1$
    "Can not calculate fire times for unsupported Scheduler Type: " + scheduler.getClass().getSimpleName());
}
Also used : SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) QuartzJobKey(org.pentaho.platform.scheduler2.quartz.QuartzJobKey) ArrayList(java.util.ArrayList) QuartzScheduler(org.pentaho.platform.scheduler2.quartz.QuartzScheduler) Date(java.util.Date) CronJobTrigger(org.pentaho.platform.api.scheduler2.CronJobTrigger) SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) Trigger(org.quartz.Trigger) IJobTrigger(org.pentaho.platform.api.scheduler2.IJobTrigger) ComplexJobTrigger(org.pentaho.platform.api.scheduler2.ComplexJobTrigger) Job(org.pentaho.platform.api.scheduler2.Job) IBlockoutManager(org.pentaho.platform.api.scheduler2.IBlockoutManager)

Example 99 with Job

use of com.google.cloud.dataproc.v1beta2.Job in project pentaho-platform by pentaho.

the class PentahoBlockoutManagerIT method testShouldFireNow.

/**
 * Test method for {@link org.pentaho.platform.scheduler2.blockout.PentahoBlockoutManager#shouldFireNow()}.
 */
@Test
public void testShouldFireNow() throws Exception {
    Date blockOutStartDate = new Date(System.currentTimeMillis());
    IJobTrigger blockOutJobTrigger = new SimpleJobTrigger(blockOutStartDate, null, -1, TIME.WEEK.time * 2 / 1000);
    blockOutJobTrigger.setDuration(duration);
    Job blockOutJob = addBlockOutJob(blockOutJobTrigger);
    assertFalse(this.blockOutManager.shouldFireNow());
    deleteJob(blockOutJob.getJobId());
    blockOutStartDate = new Date(System.currentTimeMillis() + TIME.HOUR.time);
    blockOutJobTrigger = new SimpleJobTrigger(blockOutStartDate, null, -1, TIME.WEEK.time * 2 / 1000);
    blockOutJobTrigger.setDuration(duration);
    addBlockOutJob(blockOutJobTrigger);
    assertTrue(this.blockOutManager.shouldFireNow());
}
Also used : SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) IJobTrigger(org.pentaho.platform.api.scheduler2.IJobTrigger) Job(org.pentaho.platform.api.scheduler2.Job) Date(java.util.Date) Test(org.junit.Test)

Example 100 with Job

use of com.google.cloud.dataproc.v1beta2.Job in project pentaho-platform by pentaho.

the class PentahoBlockoutManagerIT method addJob.

private Job addJob(IJobTrigger jobTrigger, String jobName, IAction action, Map<String, Serializable> jobParams) throws Exception {
    Job job = this.scheduler.createJob(jobName, action.getClass(), jobParams, jobTrigger);
    this.jobIdsToClear.add(job.getJobId());
    return job;
}
Also used : Job(org.pentaho.platform.api.scheduler2.Job)

Aggregations

Job (org.pentaho.platform.api.scheduler2.Job)94 Test (org.junit.Test)69 Serializable (java.io.Serializable)25 SimpleJobTrigger (org.pentaho.platform.api.scheduler2.SimpleJobTrigger)21 HashMap (java.util.HashMap)20 ArrayList (java.util.ArrayList)19 JobScheduleRequest (org.pentaho.platform.web.http.api.resources.JobScheduleRequest)19 ComplexJobTrigger (org.pentaho.platform.api.scheduler2.ComplexJobTrigger)18 SchedulerException (org.pentaho.platform.api.scheduler2.SchedulerException)17 Date (java.util.Date)14 IJobFilter (org.pentaho.platform.api.scheduler2.IJobFilter)14 Job (com.google.cloud.video.transcoder.v1.Job)13 TranscoderServiceClient (com.google.cloud.video.transcoder.v1.TranscoderServiceClient)13 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)12 IJobTrigger (org.pentaho.platform.api.scheduler2.IJobTrigger)12 AudioStream (com.google.cloud.video.transcoder.v1.AudioStream)8 JobConfig (com.google.cloud.video.transcoder.v1.JobConfig)8 VideoStream (com.google.cloud.video.transcoder.v1.VideoStream)8 Map (java.util.Map)8 CronJobTrigger (org.pentaho.platform.api.scheduler2.CronJobTrigger)8