Search in sources :

Example 91 with Job

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

the class SchedulerService method getJobs.

public List<Job> getJobs() throws SchedulerException {
    IPentahoSession session = getSession();
    // this authentication wasn't matching with the job user name,
    final String principalName = session.getName();
    // changed to get name via the current session
    final Boolean canAdminister = canAdminister(session);
    List<Job> jobs = getScheduler().getJobs(new IJobFilter() {

        @Override
        public boolean accept(Job job) {
            if (canAdminister) {
                return !IBlockoutManager.BLOCK_OUT_JOB_NAME.equals(job.getJobName());
            }
            return principalName.equals(job.getUserName());
        }
    });
    return jobs;
}
Also used : IJobFilter(org.pentaho.platform.api.scheduler2.IJobFilter) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) Job(org.pentaho.platform.api.scheduler2.Job)

Example 92 with Job

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

the class SchedulerService method getJobInfo.

public Job getJobInfo(String jobId) throws SchedulerException {
    Job job = getJob(jobId);
    if (job == null) {
        return null;
    }
    if (canAdminister() || getSession().getName().equals(job.getUserName())) {
        for (String key : job.getJobParams().keySet()) {
            Serializable value = job.getJobParams().get(key);
            if (value != null && value.getClass() != null && value.getClass().isArray()) {
                String[] sa = (new String[0]).getClass().cast(value);
                ArrayList<String> list = new ArrayList<>();
                for (int i = 0; i < sa.length; i++) {
                    list.add(sa[i]);
                }
                job.getJobParams().put(key, list);
            }
        }
        return job;
    } else {
        throw new RuntimeException("Job not found or improper credentials for access");
    }
}
Also used : Serializable(java.io.Serializable) ArrayList(java.util.ArrayList) Job(org.pentaho.platform.api.scheduler2.Job)

Example 93 with Job

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

the class RepositoryCleanerSystemListener method unscheduleJob.

private void unscheduleJob(IScheduler scheduler, List<Job> jobs) throws SchedulerException {
    for (Job job : jobs) {
        logger.info("Removing job with id: " + job.getJobId());
        scheduler.removeJob(job.getJobId());
    }
}
Also used : Job(org.pentaho.platform.api.scheduler2.Job)

Example 94 with Job

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

the class RepositoryCleanerSystemListener method rescheduleIfNecessary.

private void rescheduleIfNecessary(IScheduler scheduler, List<Job> jobs) throws SchedulerException {
    JobTrigger trigger = findJobTrigger();
    if (trigger == null) {
        return;
    }
    List<Job> matched = new ArrayList<Job>(jobs.size());
    for (Job job : jobs) {
        JobTrigger tr = job.getJobTrigger();
        // unfortunately, JobTrigger does not override equals
        if (trigger.getClass() != tr.getClass()) {
            logger.info("Removing job with id: " + job.getJobId());
            scheduler.removeJob(job.getJobId());
        } else {
            matched.add(job);
        }
    }
    if (matched.isEmpty()) {
        logger.info("Need to re-schedule job");
        scheduleJob(scheduler);
    }
}
Also used : ArrayList(java.util.ArrayList) Job(org.pentaho.platform.api.scheduler2.Job) SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) JobTrigger(org.pentaho.platform.api.scheduler2.JobTrigger) ComplexJobTrigger(org.pentaho.platform.api.scheduler2.ComplexJobTrigger)

Example 95 with Job

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

the class PentahoPlatformExporterTest method testExportSchedules.

@Test
public void testExportSchedules() throws Exception {
    List<Job> jobs = new ArrayList<>();
    ComplexJobTrigger trigger = mock(ComplexJobTrigger.class);
    JobTrigger unknownTrigger = mock(JobTrigger.class);
    Job job1 = mock(Job.class);
    Job job2 = mock(Job.class);
    Job job3 = mock(Job.class);
    jobs.add(job1);
    jobs.add(job2);
    jobs.add(job3);
    when(scheduler.getJobs(null)).thenReturn(jobs);
    when(job1.getJobName()).thenReturn(EmbeddedVersionCheckSystemListener.VERSION_CHECK_JOBNAME);
    when(job2.getJobName()).thenReturn("job 2");
    when(job2.getJobTrigger()).thenReturn(trigger);
    when(job3.getJobName()).thenReturn("job 3");
    when(job3.getJobTrigger()).thenReturn(unknownTrigger);
    exporterSpy.exportSchedules();
    verify(scheduler).getJobs(null);
    assertEquals(1, exporterSpy.getExportManifest().getScheduleList().size());
}
Also used : ComplexJobTrigger(org.pentaho.platform.api.scheduler2.ComplexJobTrigger) ArrayList(java.util.ArrayList) Job(org.pentaho.platform.api.scheduler2.Job) JobTrigger(org.pentaho.platform.api.scheduler2.JobTrigger) ComplexJobTrigger(org.pentaho.platform.api.scheduler2.ComplexJobTrigger) Test(org.junit.Test)

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