use of org.pentaho.platform.api.scheduler2.Job in project pentaho-platform by pentaho.
the class QuartzJobKey method parse.
/**
* Parses an existing jobId into a {@link QuartzJobKey}
*
* @param jobId
* an existing jobId
* @return a quartz job key
* @throws SchedulerException
*/
public static QuartzJobKey parse(String jobId) throws SchedulerException {
String delimiter = jobId.contains("\t") || jobId.isEmpty() ? "\t" : ":";
// $NON-NLS-1$
String[] elements = jobId.split(delimiter);
if (elements == null || elements.length < 3) {
throw new SchedulerException(MessageFormat.format(Messages.getInstance().getErrorString("QuartzJobKey.ERROR_0002"), // $NON-NLS-1$
jobId));
}
QuartzJobKey key = new QuartzJobKey();
key.userName = elements[0];
key.jobName = elements[1];
try {
key.timeInMillis = Long.parseLong(elements[2]);
} catch (NumberFormatException ex) {
throw new SchedulerException(MessageFormat.format(Messages.getInstance().getErrorString("QuartzJobKey.ERROR_0002"), // $NON-NLS-1$
jobId));
}
return key;
}
use of org.pentaho.platform.api.scheduler2.Job in project pravega by pravega.
the class RemoteSequential method newJob.
private Job newJob(String id, String className, String methodName) {
Map<String, String> labels = new HashMap<>(1);
labels.put("testMethodName", methodName);
// This can be used to set environment variables while executing the job on Metronome.
Map<String, String> env = new HashMap<>(2);
env.put("masterIP", System.getProperty("masterIP"));
env.put("env2", "value102");
Artifact art = new Artifact();
// It caches the artifacts, disabling it for now.
art.setCache(false);
// jar is not executable.
art.setExecutable(false);
art.setExtract(false);
art.setUri(System.getProperty("testArtifactUrl", "InvalidTestArtifactURL"));
Restart restart = new Restart();
// the tests are expected to finish in 2 mins, this can be changed to
restart.setActiveDeadlineSeconds(120);
// a higher value if required.
restart.setPolicy("NEVER");
Run run = new Run();
run.setArtifacts(Collections.singletonList(art));
run.setCmd("docker run --rm -v $(pwd):/data " + System.getProperty("dockerImageRegistry") + "/java:8 java" + " -DmasterIP=" + LoginClient.MESOS_MASTER + " -DskipServiceInstallation=" + Utils.isSkipServiceInstallationEnabled() + " -cp /data/pravega-test-system-" + System.getProperty("testVersion") + ".jar io.pravega.test.system.SingleJUnitTestRunner " + className + "#" + methodName + " > server.log 2>&1" + "; exit $?");
// CPU shares.
run.setCpus(0.5);
// amount of memory required for running test in MB.
run.setMem(512.0);
run.setDisk(50.0);
run.setEnv(env);
run.setMaxLaunchDelay(3600);
run.setRestart(restart);
run.setUser("root");
Job job = new Job();
job.setId(id);
job.setDescription(id);
job.setLabels(labels);
job.setRun(run);
return job;
}
use of org.pentaho.platform.api.scheduler2.Job in project pentaho-platform by pentaho.
the class RepositoryCleanerSystemListenerTest method removesJobs_WhenDisabled.
@Test
public void removesJobs_WhenDisabled() throws Exception {
final String jobId = "jobId";
Job job = new Job();
job.setJobId(jobId);
when(scheduler.getJobs(any(IJobFilter.class))).thenReturn(Collections.singletonList(job));
prepareMp();
listener.setGcEnabled(false);
assertTrue(listener.startup(null));
verifyJobRemoved(jobId);
}
use of org.pentaho.platform.api.scheduler2.Job in project pentaho-platform by pentaho.
the class RepositoryCleanerSystemListenerTest method reschedulesJob_IfFoundDifferent.
@Test
public void reschedulesJob_IfFoundDifferent() throws Exception {
final String oldJobId = "oldJobId";
Job oldJob = new Job();
oldJob.setJobTrigger(new CronJobTrigger());
oldJob.setJobId(oldJobId);
when(scheduler.getJobs(any(IJobFilter.class))).thenReturn(Collections.singletonList(oldJob));
prepareMp();
listener.setExecute(Frequency.NOW.getValue());
assertTrue(listener.startup(null));
verifyJobRemoved(oldJobId);
verifyJobCreated(Frequency.NOW);
}
use of org.pentaho.platform.api.scheduler2.Job in project pentaho-platform by pentaho.
the class RepositoryCleanerSystemListenerTest method doesNotRescheduleJob_IfFoundSame.
@Test
public void doesNotRescheduleJob_IfFoundSame() throws Exception {
final String oldJobId = "oldJobId";
Job oldJob = new Job();
oldJob.setJobTrigger(Frequency.WEEKLY.createTrigger());
oldJob.setJobId(oldJobId);
when(scheduler.getJobs(any(IJobFilter.class))).thenReturn(Collections.singletonList(oldJob));
prepareMp();
listener.setExecute(Frequency.WEEKLY.getValue());
assertTrue(listener.startup(null));
verify(scheduler, never()).removeJob(oldJobId);
verifyJobHaveNotCreated();
}
Aggregations