Search in sources :

Example 71 with Job

use of com.google.cloud.talent.v4beta1.Job in project pentaho-platform by pentaho.

the class PentahoPlatformExporter method exportSchedules.

protected void exportSchedules() {
    log.debug("export schedules");
    try {
        List<Job> jobs = getScheduler().getJobs(null);
        for (Job job : jobs) {
            if (job.getJobName().equals(EmbeddedVersionCheckSystemListener.VERSION_CHECK_JOBNAME)) {
                // if it doesn't exist and fails if you try to import it due to a null ActionClass
                continue;
            }
            try {
                JobScheduleRequest scheduleRequest = ScheduleExportUtil.createJobScheduleRequest(job);
                getExportManifest().addSchedule(scheduleRequest);
            } catch (IllegalArgumentException e) {
                log.warn(e.getMessage(), e);
            }
        }
    } catch (SchedulerException e) {
        log.error(Messages.getInstance().getString("PentahoPlatformExporter.ERROR_EXPORTING_JOBS"), e);
    }
}
Also used : SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) Job(org.pentaho.platform.api.scheduler2.Job) JobScheduleRequest(org.pentaho.platform.web.http.api.resources.JobScheduleRequest)

Example 72 with Job

use of com.google.cloud.talent.v4beta1.Job in project pentaho-platform by pentaho.

the class QuartzScheduler method getJob.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
public Job getJob(String jobId) throws SchedulerException {
    try {
        Scheduler scheduler = getQuartzScheduler();
        QuartzJobKey jobKey = QuartzJobKey.parse(jobId);
        String groupName = jobKey.getUserName();
        for (Trigger trigger : scheduler.getTriggersOfJob(jobId, groupName)) {
            Job job = new Job();
            JobDetail jobDetail = scheduler.getJobDetail(jobId, groupName);
            if (jobDetail != null) {
                JobDataMap jobDataMap = jobDetail.getJobDataMap();
                if (jobDataMap != null) {
                    Map<String, Serializable> wrappedMap = jobDataMap.getWrappedMap();
                    job.setJobParams(wrappedMap);
                }
            }
            job.setJobId(jobId);
            setJobTrigger(scheduler, job, trigger);
            job.setUserName(jobDetail.getGroup());
            return job;
        }
    } catch (org.quartz.SchedulerException e) {
        throw new SchedulerException(Messages.getInstance().getString("QuartzScheduler.ERROR_0007_FAILED_TO_GET_JOB", jobId), // $NON-NLS-1$
        e);
    }
    return null;
}
Also used : JobDetail(org.quartz.JobDetail) JobDataMap(org.quartz.JobDataMap) Serializable(java.io.Serializable) CronTrigger(org.quartz.CronTrigger) SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) JobTrigger(org.pentaho.platform.api.scheduler2.JobTrigger) ComplexJobTrigger(org.pentaho.platform.api.scheduler2.ComplexJobTrigger) Trigger(org.quartz.Trigger) SimpleTrigger(org.quartz.SimpleTrigger) IJobTrigger(org.pentaho.platform.api.scheduler2.IJobTrigger) SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) Scheduler(org.quartz.Scheduler) IScheduler(org.pentaho.platform.api.scheduler2.IScheduler) Job(org.pentaho.platform.api.scheduler2.Job)

Example 73 with Job

use of com.google.cloud.talent.v4beta1.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)

Example 74 with Job

use of com.google.cloud.talent.v4beta1.Job in project pentaho-platform by pentaho.

the class QuartzScheduler method getJobs.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
public List<Job> getJobs(IJobFilter filter) throws SchedulerException {
    ArrayList<Job> jobs = new ArrayList<Job>();
    try {
        Scheduler scheduler = getQuartzScheduler();
        for (String groupName : scheduler.getJobGroupNames()) {
            for (String jobId : scheduler.getJobNames(groupName)) {
                for (Trigger trigger : scheduler.getTriggersOfJob(jobId, groupName)) {
                    if ("MANUAL_TRIGGER".equals(trigger.getGroup())) {
                        continue;
                    }
                    Job job = new Job();
                    job.setGroupName(groupName);
                    JobDetail jobDetail = scheduler.getJobDetail(jobId, groupName);
                    if (jobDetail != null) {
                        job.setUserName(jobDetail.getGroup());
                        JobDataMap jobDataMap = jobDetail.getJobDataMap();
                        if (jobDataMap != null) {
                            Map<String, Serializable> wrappedMap = jobDataMap.getWrappedMap();
                            job.setJobParams(wrappedMap);
                        }
                    }
                    job.setJobId(jobId);
                    setJobTrigger(scheduler, job, trigger);
                    job.setJobName(QuartzJobKey.parse(jobId).getJobName());
                    setJobNextRun(job, trigger);
                    job.setLastRun(trigger.getPreviousFireTime());
                    if ((filter == null) || filter.accept(job)) {
                        jobs.add(job);
                    }
                }
            }
        }
    } catch (org.quartz.SchedulerException e) {
        throw new SchedulerException(Messages.getInstance().getString("QuartzScheduler.ERROR_0004_FAILED_TO_LIST_JOBS"), // $NON-NLS-1$
        e);
    }
    return jobs;
}
Also used : JobDataMap(org.quartz.JobDataMap) Serializable(java.io.Serializable) SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) Scheduler(org.quartz.Scheduler) IScheduler(org.pentaho.platform.api.scheduler2.IScheduler) ArrayList(java.util.ArrayList) JobDetail(org.quartz.JobDetail) CronTrigger(org.quartz.CronTrigger) SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) JobTrigger(org.pentaho.platform.api.scheduler2.JobTrigger) ComplexJobTrigger(org.pentaho.platform.api.scheduler2.ComplexJobTrigger) Trigger(org.quartz.Trigger) SimpleTrigger(org.quartz.SimpleTrigger) IJobTrigger(org.pentaho.platform.api.scheduler2.IJobTrigger) Job(org.pentaho.platform.api.scheduler2.Job)

Example 75 with Job

use of com.google.cloud.talent.v4beta1.Job in project pentaho-platform by pentaho.

the class DefaultSchedulerServiceTest method mockJob.

private Job mockJob(String userName, String jobName) {
    Job job = mock(Job.class);
    when(job.getUserName()).thenReturn(userName);
    when(job.getJobName()).thenReturn(jobName);
    return job;
}
Also used : Job(org.pentaho.platform.api.scheduler2.Job)

Aggregations

Job (org.pentaho.platform.api.scheduler2.Job)94 Test (org.junit.Test)90 Job (io.fabric8.kubernetes.api.model.batch.v1.Job)38 Serializable (java.io.Serializable)25 ArrayList (java.util.ArrayList)24 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 JobServiceClient (com.google.cloud.talent.v4beta1.JobServiceClient)18 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 JobBuilder (io.fabric8.kubernetes.api.model.batch.v1.JobBuilder)13 IJobTrigger (org.pentaho.platform.api.scheduler2.IJobTrigger)12 Test (org.junit.jupiter.api.Test)10 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)10