Search in sources :

Example 36 with Job

use of com.google.cloud.video.transcoder.v1.Job in project pentaho-platform by pentaho.

the class QuartzSchedulerIT method createJobTest_ForUser.

@Test
public void createJobTest_ForUser() throws Exception {
    String actionId = "actionId";
    ComplexJobTrigger trigger = getComplexJobTrigger();
    IBackgroundExecutionStreamProvider outputStreamProvider = mock(IBackgroundExecutionStreamProvider.class);
    Map<String, Serializable> paramMap = new HashMap<>();
    paramMap.put(QuartzScheduler.RESERVEDMAPKEY_ACTIONUSER, "ninja");
    final Job job = scheduler.createJob(JOB_NAME, paramMap, trigger, outputStreamProvider);
    assertNotNull(job);
    assertEquals("ninja", job.getUserName());
    assertEquals(Job.JobState.NORMAL, job.getState());
}
Also used : IBackgroundExecutionStreamProvider(org.pentaho.platform.api.scheduler2.IBackgroundExecutionStreamProvider) Serializable(java.io.Serializable) ComplexJobTrigger(org.pentaho.platform.api.scheduler2.ComplexJobTrigger) HashMap(java.util.HashMap) Job(org.pentaho.platform.api.scheduler2.Job) Test(org.junit.Test)

Example 37 with Job

use of com.google.cloud.video.transcoder.v1.Job in project pentaho-platform by pentaho.

the class JaxWsSchedulerServiceIT method testUpdateSimpleJob.

@Test
public void testUpdateSimpleJob() throws SchedulerException {
    long start = System.currentTimeMillis() + 1000;
    long end = System.currentTimeMillis() + 1000 + 5 * 60 * 60 * 100;
    SimpleJobTrigger jobTrigger = new SimpleJobTrigger();
    jobTrigger.setStartTime(new Date(start));
    jobTrigger.setEndTime(new Date(end));
    jobTrigger.setRepeatInterval(10);
    jobTrigger.setRepeatCount(20);
    System.out.println(jobTrigger.toString());
    String jobId = schedulerSvc.createSimpleJob("test job", jobParams, jobTrigger);
    Assert.assertEquals(1, schedulerSvc.getJobs().length);
    jobTrigger = new SimpleJobTrigger();
    start = System.currentTimeMillis() + 1000;
    end = System.currentTimeMillis() + 1000 + 5 * 60 * 60 * 100;
    jobTrigger.setStartTime(new Date(start));
    jobTrigger.setEndTime(new Date(end));
    jobTrigger.setRepeatInterval(40);
    jobTrigger.setRepeatCount(50);
    System.out.println(jobTrigger.toString());
    HashMap<String, ParamValue> newJobParams = new HashMap<String, ParamValue>(jobParams);
    newJobParams.put("newKey", new StringParamValue(""));
    schedulerSvc.updateJobToUseSimpleTrigger(jobId, newJobParams, jobTrigger);
    Assert.assertEquals(1, schedulerSvc.getJobs().length);
    Job job = schedulerSvc.getJobs()[0];
    jobTrigger = (SimpleJobTrigger) job.getJobTrigger();
    Assert.assertEquals(40, jobTrigger.getRepeatInterval());
    Assert.assertEquals(50, jobTrigger.getRepeatCount());
    Assert.assertTrue(job.getJobParams().containsKey("newKey"));
    jobTrigger.getStartTime();
    Assert.assertEquals(new Date(start), jobTrigger.getStartTime());
    Assert.assertEquals(new Date(end), jobTrigger.getEndTime());
}
Also used : SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) HashMap(java.util.HashMap) ListParamValue(org.pentaho.platform.scheduler2.ws.ListParamValue) ParamValue(org.pentaho.platform.scheduler2.ws.ParamValue) StringParamValue(org.pentaho.platform.scheduler2.ws.StringParamValue) MapParamValue(org.pentaho.platform.scheduler2.ws.MapParamValue) StringParamValue(org.pentaho.platform.scheduler2.ws.StringParamValue) Job(org.pentaho.platform.api.scheduler2.Job) Date(java.util.Date) Test(org.junit.Test)

Example 38 with Job

use of com.google.cloud.video.transcoder.v1.Job in project pentaho-platform by pentaho.

the class JaxWsSchedulerServiceIT method testUpdateComplexJob.

/*
  public static class TestQuartzScheduler extends QuartzScheduler {
    @Override
    protected String getCurrentUser() {
      SecurityHelper.getInstance().becomeUser( TEST_USER );
      return super.getCurrentUser();
    }
  }
*/
@Test(timeout = 1000 * 5 * 60)
public void testUpdateComplexJob() throws SchedulerException {
    long start = System.currentTimeMillis() + 1000;
    long end = System.currentTimeMillis() + 1000 + 5 * 60 * 60 * 100;
    int startingMinute = (Calendar.getInstance().get(Calendar.MINUTE) + 10) % 60;
    ComplexJobTrigger jobTrigger = new ComplexJobTrigger();
    jobTrigger.setStartTime(new Date(start));
    jobTrigger.setEndTime(new Date(end));
    jobTrigger.setMinuteRecurrence(new IncrementalRecurrence(startingMinute, 1));
    jobTrigger.setHourlyRecurrence((ITimeRecurrence) null);
    System.out.println(jobTrigger.toString());
    String jobId = schedulerSvc.createComplexJob("test job", jobParams, jobTrigger);
    Assert.assertEquals(1, schedulerSvc.getJobs().length);
    jobTrigger = new ComplexJobTrigger();
    start = System.currentTimeMillis() + 2 * 1000;
    end = System.currentTimeMillis() + 1000 + 7 * 60 * 60 * 100;
    jobTrigger.setStartTime(new Date(start));
    jobTrigger.setEndTime(new Date(end));
    startingMinute = (Calendar.getInstance().get(Calendar.MINUTE) + 20) % 60;
    jobTrigger.setMinuteRecurrence(new IncrementalRecurrence(startingMinute, 5));
    jobTrigger.setHourlyRecurrence((ITimeRecurrence) null);
    System.out.println(jobTrigger.toString());
    HashMap<String, ParamValue> newJobParams = new HashMap<String, ParamValue>(jobParams);
    newJobParams.put("newKey", new StringParamValue(""));
    schedulerSvc.updateJobToUseComplexTrigger(jobId, newJobParams, jobTrigger);
    Assert.assertEquals(1, schedulerSvc.getJobs().length);
    Job job = schedulerSvc.getJobs()[0];
    jobTrigger = (ComplexJobTrigger) job.getJobTrigger();
    Assert.assertEquals((Integer) startingMinute, ((IncrementalRecurrence) jobTrigger.getMinuteRecurrences().get(0)).getStartingValue());
    Assert.assertEquals((Integer) 5, ((IncrementalRecurrence) jobTrigger.getMinuteRecurrences().get(0)).getIncrement());
    Assert.assertTrue(job.getJobParams().containsKey("newKey"));
    Assert.assertEquals(new Date(start), jobTrigger.getStartTime());
    Assert.assertEquals(new Date(end), jobTrigger.getEndTime());
}
Also used : ComplexJobTrigger(org.pentaho.platform.api.scheduler2.ComplexJobTrigger) HashMap(java.util.HashMap) IncrementalRecurrence(org.pentaho.platform.scheduler2.recur.IncrementalRecurrence) ListParamValue(org.pentaho.platform.scheduler2.ws.ListParamValue) ParamValue(org.pentaho.platform.scheduler2.ws.ParamValue) StringParamValue(org.pentaho.platform.scheduler2.ws.StringParamValue) MapParamValue(org.pentaho.platform.scheduler2.ws.MapParamValue) StringParamValue(org.pentaho.platform.scheduler2.ws.StringParamValue) Job(org.pentaho.platform.api.scheduler2.Job) Date(java.util.Date) Test(org.junit.Test)

Example 39 with Job

use of com.google.cloud.video.transcoder.v1.Job in project pentaho-platform by pentaho.

the class EmbeddedVersionCheckSystemListener method deleteJobIfNecessary.

protected void deleteJobIfNecessary() throws SchedulerException {
    // $NON-NLS-1$
    IScheduler scheduler = PentahoSystem.get(IScheduler.class, "IScheduler2", null);
    IJobFilter filter = new IJobFilter() {

        public boolean accept(Job job) {
            return job.getJobName().contains(EmbeddedVersionCheckSystemListener.VERSION_CHECK_JOBNAME);
        }
    };
    // Like old code - remove the existing job and replace it
    List<Job> matchingJobs = scheduler.getJobs(filter);
    if ((matchingJobs != null) && (matchingJobs.size() > 0)) {
        for (Job verCkJob : matchingJobs) {
            scheduler.removeJob(verCkJob.getJobId());
        }
    }
}
Also used : IJobFilter(org.pentaho.platform.api.scheduler2.IJobFilter) Job(org.pentaho.platform.api.scheduler2.Job) IScheduler(org.pentaho.platform.api.scheduler2.IScheduler)

Example 40 with Job

use of com.google.cloud.video.transcoder.v1.Job in project pentaho-platform by pentaho.

the class QuartzScheduler method createJob.

/**
 * {@inheritDoc}
 */
public Job createJob(String jobName, Class<? extends IAction> action, Map<String, Serializable> jobParams, IJobTrigger trigger, IBackgroundExecutionStreamProvider outputStreamProvider) throws SchedulerException {
    if (action == null) {
        // $NON-NLS-1$
        throw new SchedulerException(Messages.getInstance().getString("QuartzScheduler.ERROR_0003_ACTION_IS_NULL"));
    }
    if (jobParams == null) {
        jobParams = new HashMap<String, Serializable>();
    }
    jobParams.put(RESERVEDMAPKEY_ACTIONCLASS, action.getName());
    Job ret = createJob(jobName, jobParams, trigger, outputStreamProvider);
    ret.setSchedulableClass(action.getName());
    return ret;
}
Also used : Serializable(java.io.Serializable) SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) Job(org.pentaho.platform.api.scheduler2.Job)

Aggregations

Job (org.pentaho.platform.api.scheduler2.Job)94 Test (org.junit.Test)80 Job (io.fabric8.kubernetes.api.model.batch.v1.Job)33 Serializable (java.io.Serializable)25 ArrayList (java.util.ArrayList)22 SimpleJobTrigger (org.pentaho.platform.api.scheduler2.SimpleJobTrigger)21 Job (com.google.cloud.talent.v4beta1.Job)20 HashMap (java.util.HashMap)20 JobScheduleRequest (org.pentaho.platform.web.http.api.resources.JobScheduleRequest)19 TranscoderServiceClient (com.google.cloud.video.transcoder.v1.TranscoderServiceClient)18 ComplexJobTrigger (org.pentaho.platform.api.scheduler2.ComplexJobTrigger)18 SchedulerException (org.pentaho.platform.api.scheduler2.SchedulerException)17 JobServiceClient (com.google.cloud.talent.v4beta1.JobServiceClient)16 Date (java.util.Date)14 IJobFilter (org.pentaho.platform.api.scheduler2.IJobFilter)14 Job (com.google.cloud.video.transcoder.v1.Job)13 IJobTrigger (org.pentaho.platform.api.scheduler2.IJobTrigger)12 JobBuilder (io.fabric8.kubernetes.api.model.batch.v1.JobBuilder)11 Map (java.util.Map)11 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)10