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();
}
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());
}
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());
}
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());
}
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;
}
Aggregations