use of org.pentaho.di.job.JobHopMeta in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryJobDelegate method loadJobHopMeta.
public JobHopMeta loadJobHopMeta(ObjectId id_job_hop, List<JobEntryCopy> jobcopies) throws KettleException {
JobHopMeta jobHopMeta = new JobHopMeta();
try {
RowMetaAndData r = getJobHop(id_job_hop);
if (r != null) {
long id_jobentry_copy_from = r.getInteger("ID_JOBENTRY_COPY_FROM", -1L);
long id_jobentry_copy_to = r.getInteger("ID_JOBENTRY_COPY_TO", -1L);
jobHopMeta.setEnabled(r.getBoolean("ENABLED", true));
jobHopMeta.setEvaluation(r.getBoolean("EVALUATION", true));
jobHopMeta.setConditional();
if (r.getBoolean("UNCONDITIONAL", !jobHopMeta.getEvaluation())) {
jobHopMeta.setUnconditional();
}
jobHopMeta.setFromEntry(JobMeta.findJobEntryCopy(jobcopies, new LongObjectId(id_jobentry_copy_from)));
jobHopMeta.setToEntry(JobMeta.findJobEntryCopy(jobcopies, new LongObjectId(id_jobentry_copy_to)));
return jobHopMeta;
} else {
throw new KettleException("Unable to find job hop with ID : " + id_job_hop);
}
} catch (KettleDatabaseException dbe) {
throw new KettleException(BaseMessages.getString(PKG, "JobHopMeta.Exception.UnableToLoadHopInfoRep", "" + id_job_hop), dbe);
}
}
use of org.pentaho.di.job.JobHopMeta in project pentaho-kettle by pentaho.
the class JobEntryTransIntIT method testPDI14676.
/*
* Tests whether the job can force a transformation to stop, when the job is asked to stop.
* A timeout parameter is required, to avoid a failed unit test from running forever.
*/
@Test(timeout = 30000)
public void testPDI14676() throws KettleException, IOException, InterruptedException {
String transFilename = createPDI14676Transformation();
// Setup Job
JobEntrySpecial startEntry = new JobEntrySpecial("Start", true, false);
JobEntryCopy startCopy = new JobEntryCopy(startEntry);
startCopy.setLocation(50, 50);
startCopy.setDrawn();
JobEntryTrans transEntry = new JobEntryTrans("PDI-13676 example");
transEntry.setSpecificationMethod(ObjectLocationSpecificationMethod.FILENAME);
transEntry.setFileName(transFilename);
JobEntryCopy transCopy = new JobEntryCopy(transEntry);
transCopy.setLocation(200, 50);
transCopy.setDrawn();
JobMeta jobMeta = new JobMeta();
jobMeta.addJobEntry(startCopy);
jobMeta.addJobEntry(transCopy);
jobMeta.addJobHop(new JobHopMeta(startCopy, transCopy));
// Run job
Job jobInstance = new Job(null, jobMeta);
jobInstance.start();
// Allow job startup time
while (!jobInstance.isActive()) {
if (jobInstance.isStopped() || jobInstance.isFinished()) {
break;
}
Thread.sleep(10);
}
// Let the job run for a short period
Thread.sleep(300);
assertFalse(jobInstance.isStopped());
assertFalse(jobInstance.isFinished());
// Tell the job to stop.
jobInstance.stopAll();
assertTrue(jobInstance.isStopped());
// Allow the job's thread to stop and be cleaned up
while (!jobInstance.isFinished() || jobInstance.isActive()) {
Thread.sleep(10);
}
// Ensure that the job and the thread have both stopped
assertTrue(jobInstance.isFinished());
assertFalse(jobInstance.isAlive());
}
use of org.pentaho.di.job.JobHopMeta in project pentaho-metaverse by pentaho.
the class JobMetaJsonSerializer method serializeHops.
@Override
protected void serializeHops(JobMeta meta, JsonGenerator json) throws IOException {
// Hops
json.writeArrayFieldStart(JSON_PROPERTY_HOPS);
int numberOfHops = meta.nrJobHops();
for (int i = 0; i < numberOfHops; i++) {
JobHopMeta hopMeta = meta.getJobHop(i);
HopInfo hopInfo = new HopInfo(hopMeta);
json.writeObject(hopInfo);
}
json.writeEndArray();
}
use of org.pentaho.di.job.JobHopMeta in project pentaho-metaverse by pentaho.
the class JobAnalyzerTest method testAnalyzerJobWithEntriesAndHop.
@Test
public void testAnalyzerJobWithEntriesAndHop() throws MetaverseAnalyzerException {
JobEntryCopy mockToEntryMeta = mock(JobEntryCopy.class);
when(mockToEntryMeta.getEntry()).thenReturn(mockJobEntryInterface);
when(mockToEntryMeta.getParentJobMeta()).thenReturn(mockContent);
when(mockContent.nrJobEntries()).thenReturn(2);
when(mockContent.getJobEntry(0)).thenReturn(mockJobEntry);
when(mockContent.getJobEntry(1)).thenReturn(mockToEntryMeta);
when(mockContent.nrJobHops()).thenReturn(1);
final JobHopMeta hop = new JobHopMeta(mockJobEntry, mockToEntryMeta);
when(mockContent.getJobHop(0)).thenReturn(hop);
IMetaverseNode node = analyzer.analyze(descriptor, mockJobDoc);
assertNotNull(node);
}
use of org.pentaho.di.job.JobHopMeta in project pentaho-metaverse by pentaho.
the class JobMetaJsonSerializerTest method testSerializeHops.
@Test
public void testSerializeHops() throws Exception {
JobHopMeta jobHopMeta = mock(JobHopMeta.class);
JobEntryCopy fromJobEntry = mock(JobEntryCopy.class);
JobEntryCopy toJobEntry = mock(JobEntryCopy.class);
when(meta.nrJobHops()).thenReturn(2);
when(meta.getJobHop(anyInt())).thenReturn(jobHopMeta);
when(jobHopMeta.getFromEntry()).thenReturn(fromJobEntry);
when(jobHopMeta.getToEntry()).thenReturn(toJobEntry);
when(jobHopMeta.isEnabled()).thenReturn(true);
when(fromJobEntry.getName()).thenReturn("from");
when(toJobEntry.getName()).thenReturn("to");
serializer.serializeHops(meta, json);
verify(json, times(2)).writeObject(any(HopInfo.class));
}
Aggregations