Search in sources :

Example 1 with JobTrigger

use of com.google.privacy.dlp.v2.JobTrigger in project pentaho-platform by pentaho.

the class GatherStatsListener method scheduleJob.

private void scheduleJob(int intervalInSeconds) throws Exception {
    // $NON-NLS-1$
    IScheduler scheduler = PentahoSystem.get(IScheduler.class, "IScheduler2", null);
    JobTrigger trigger = new SimpleJobTrigger(new Date(), null, -1, intervalInSeconds);
    jobMap.put("transFileName", getTransFileName());
    scheduler.createJob(GatherStatsListener.JOB_NAME, GatherStatsAction.class, jobMap, trigger);
    logger.info("Statistics gathering jop has been scheduled.");
}
Also used : SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) IScheduler(org.pentaho.platform.api.scheduler2.IScheduler) SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) JobTrigger(org.pentaho.platform.api.scheduler2.JobTrigger) Date(java.util.Date)

Example 2 with JobTrigger

use of com.google.privacy.dlp.v2.JobTrigger 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)

Example 3 with JobTrigger

use of com.google.privacy.dlp.v2.JobTrigger in project pentaho-platform by pentaho.

the class ScheduleExportUtilTest method testCreateJobScheduleRequest_unknownTrigger.

@Test(expected = IllegalArgumentException.class)
public void testCreateJobScheduleRequest_unknownTrigger() throws Exception {
    String jobName = "JOB";
    Job job = mock(Job.class);
    JobTrigger trigger = mock(JobTrigger.class);
    when(job.getJobTrigger()).thenReturn(trigger);
    JobScheduleRequest jobScheduleRequest = ScheduleExportUtil.createJobScheduleRequest(job);
}
Also used : Job(org.pentaho.platform.api.scheduler2.Job) JobScheduleRequest(org.pentaho.platform.web.http.api.resources.JobScheduleRequest) CronJobTrigger(org.pentaho.platform.api.scheduler2.CronJobTrigger) SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) JobTrigger(org.pentaho.platform.api.scheduler2.JobTrigger) ComplexJobTrigger(org.pentaho.platform.api.scheduler2.ComplexJobTrigger) Test(org.junit.Test)

Example 4 with JobTrigger

use of com.google.privacy.dlp.v2.JobTrigger 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 5 with JobTrigger

use of com.google.privacy.dlp.v2.JobTrigger in project pentaho-platform by pentaho.

the class RepositoryCleanerSystemListener method scheduleJob.

private void scheduleJob(IScheduler scheduler) throws SchedulerException {
    JobTrigger trigger = findJobTrigger();
    if (trigger != null) {
        logger.info("Creating new job with trigger: " + trigger);
        scheduler.createJob(RepositoryGcJob.JOB_NAME, RepositoryGcJob.class, null, trigger);
    }
}
Also used : SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) JobTrigger(org.pentaho.platform.api.scheduler2.JobTrigger) ComplexJobTrigger(org.pentaho.platform.api.scheduler2.ComplexJobTrigger)

Aggregations

JobTrigger (org.pentaho.platform.api.scheduler2.JobTrigger)7 SimpleJobTrigger (org.pentaho.platform.api.scheduler2.SimpleJobTrigger)6 ComplexJobTrigger (org.pentaho.platform.api.scheduler2.ComplexJobTrigger)5 Job (org.pentaho.platform.api.scheduler2.Job)4 IScheduler (org.pentaho.platform.api.scheduler2.IScheduler)3 Serializable (java.io.Serializable)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 Test (org.junit.Test)2 DlpServiceClient (com.google.cloud.dlp.v2.DlpServiceClient)1 CloudStorageOptions (com.google.privacy.dlp.v2.CloudStorageOptions)1 CreateJobTriggerRequest (com.google.privacy.dlp.v2.CreateJobTriggerRequest)1 InspectConfig (com.google.privacy.dlp.v2.InspectConfig)1 InspectJobConfig (com.google.privacy.dlp.v2.InspectJobConfig)1 JobTrigger (com.google.privacy.dlp.v2.JobTrigger)1 Schedule (com.google.privacy.dlp.v2.Schedule)1 StorageConfig (com.google.privacy.dlp.v2.StorageConfig)1 Duration (com.google.protobuf.Duration)1 HashMap (java.util.HashMap)1 ParseException (org.apache.commons.cli.ParseException)1