use of com.google.cloud.dataproc.v1.Job in project pentaho-platform by pentaho.
the class SchedulerService method resumeJob.
public JobState resumeJob(String jobId) throws SchedulerException {
Job job = getJob(jobId);
if (isScheduleAllowed() || PentahoSessionHolder.getSession().getName().equals(job.getUserName())) {
getScheduler().resumeJob(jobId);
}
job = getJob(jobId);
return job.getState();
}
use of com.google.cloud.dataproc.v1.Job in project pentaho-platform by pentaho.
the class ScheduleExportUtilTest method testCreateJobScheduleRequest_NoStreamProvider.
@Test
public void testCreateJobScheduleRequest_NoStreamProvider() throws Exception {
String jobName = "JOB";
Job job = mock(Job.class);
SimpleJobTrigger trigger = mock(SimpleJobTrigger.class);
when(job.getJobTrigger()).thenReturn(trigger);
when(job.getJobName()).thenReturn(jobName);
Map<String, Serializable> params = new HashMap<>();
params.put("directory", "/home/admin");
params.put("transformation", "myTransform");
HashMap<String, String> pdiParams = new HashMap<>();
pdiParams.put("pdiParam", "pdiParamValue");
params.put(ScheduleExportUtil.RUN_PARAMETERS_KEY, pdiParams);
when(job.getJobParams()).thenReturn(params);
JobScheduleRequest jobScheduleRequest = ScheduleExportUtil.createJobScheduleRequest(job);
assertNotNull(jobScheduleRequest);
assertEquals(jobName, jobScheduleRequest.getJobName());
assertEquals(trigger, jobScheduleRequest.getSimpleJobTrigger());
assertEquals("/home/admin/myTransform.ktr", jobScheduleRequest.getInputFile());
assertEquals("/home/admin/myTransform*", jobScheduleRequest.getOutputFile());
assertEquals("pdiParamValue", jobScheduleRequest.getPdiParameters().get("pdiParam"));
}
use of com.google.cloud.dataproc.v1.Job in project pentaho-platform by pentaho.
the class ScheduleExportUtilTest method testCreateJobScheduleRequest_MultipleTypesJobParam.
@Test
public void testCreateJobScheduleRequest_MultipleTypesJobParam() throws Exception {
String jobName = "JOB";
Long l = Long.MAX_VALUE;
Date d = new Date();
Boolean b = true;
Map<String, Serializable> params = new HashMap<>();
params.put("NumberValue", l);
params.put("DateValue", d);
params.put("BooleanValue", b);
Job job = mock(Job.class);
CronJobTrigger trigger = mock(CronJobTrigger.class);
when(job.getJobTrigger()).thenReturn(trigger);
when(job.getJobName()).thenReturn(jobName);
when(job.getJobParams()).thenReturn(params);
JobScheduleRequest jobScheduleRequest = ScheduleExportUtil.createJobScheduleRequest(job);
for (JobScheduleParam jobScheduleParam : jobScheduleRequest.getJobParameters()) {
assertTrue(jobScheduleParam.getValue().equals(l) || jobScheduleParam.getValue().equals(d) || jobScheduleParam.getValue().equals(b));
}
}
use of com.google.cloud.dataproc.v1.Job in project pentaho-platform by pentaho.
the class ScheduleExportUtilTest method testCreateJobScheduleRequest_StringStreamProvider.
@Test
public void testCreateJobScheduleRequest_StringStreamProvider() throws Exception {
String jobName = "JOB";
Job job = mock(Job.class);
SimpleJobTrigger trigger = mock(SimpleJobTrigger.class);
when(job.getJobTrigger()).thenReturn(trigger);
when(job.getJobName()).thenReturn(jobName);
Map<String, Serializable> params = new HashMap<>();
params.put(QuartzScheduler.RESERVEDMAPKEY_STREAMPROVIDER, "import file = /home/admin/myJob.kjb:output file=/home/admin/myJob*");
when(job.getJobParams()).thenReturn(params);
JobScheduleRequest jobScheduleRequest = ScheduleExportUtil.createJobScheduleRequest(job);
assertNotNull(jobScheduleRequest);
assertEquals(jobName, jobScheduleRequest.getJobName());
assertEquals(trigger, jobScheduleRequest.getSimpleJobTrigger());
assertEquals("/home/admin/myJob.kjb", jobScheduleRequest.getInputFile());
assertEquals("/home/admin/myJob*", jobScheduleRequest.getOutputFile());
}
use of com.google.cloud.dataproc.v1.Job in project pentaho-platform by pentaho.
the class ScheduleExportUtilTest method testCreateJobScheduleRequest_ActionClassJobParam.
@Test
public void testCreateJobScheduleRequest_ActionClassJobParam() throws Exception {
String jobName = "JOB";
String actionClass = "com.pentaho.Action";
Map<String, Serializable> params = new HashMap<>();
params.put(QuartzScheduler.RESERVEDMAPKEY_ACTIONCLASS, actionClass);
Job job = mock(Job.class);
CronJobTrigger trigger = mock(CronJobTrigger.class);
when(job.getJobTrigger()).thenReturn(trigger);
when(job.getJobName()).thenReturn(jobName);
when(job.getJobParams()).thenReturn(params);
JobScheduleRequest jobScheduleRequest = ScheduleExportUtil.createJobScheduleRequest(job);
assertEquals(actionClass, jobScheduleRequest.getActionClass());
assertEquals(actionClass, jobScheduleRequest.getJobParameters().get(0).getValue());
}
Aggregations