使用java创建job
Posted 衰草寒烟
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用java创建job相关的知识,希望对你有一定的参考价值。
/** * This method generates a job definition from scratch. * * It demonstrates the following: * * - Creating a new job * - Creating and connecting job entries * * @return the generated job definition */ public JobMeta generateJob() { try { System.out.println("Generating a job definition"); // create empty transformation definition JobMeta jobMeta = new JobMeta(); jobMeta.setName("Generated Demo Job"); // ------------------------------------------------------------------------------------ // Create start entry and put it into the job // ------------------------------------------------------------------------------------ System.out.println("- Adding Start Entry"); // Create and configure start entry JobEntrySpecial start = new JobEntrySpecial(); start.setName("START"); start.setStart(true); // wrap into JobEntryCopy object, which holds generic job entry information JobEntryCopy startEntry = new JobEntryCopy(start); // place it on Spoon canvas properly startEntry.setDrawn(true); startEntry.setLocation(100, 100); jobMeta.addJobEntry(startEntry); // ------------------------------------------------------------------------------------ // Create "write to log" entry and put it into the job // ------------------------------------------------------------------------------------ System.out.println("- Adding Write To Log Entry"); // Create and configure entry JobEntryWriteToLog writeToLog = new JobEntryWriteToLog(); writeToLog.setName("Output PDI Stats"); writeToLog.setLogLevel(LogLevel.MINIMAL); writeToLog.setLogSubject("Logging PDI Build Information:"); writeToLog.setLogMessage("Version: ${Internal.Kettle.Version}\n" + "Build Date: ${Internal.Kettle.Build.Date}"); // wrap into JobEntryCopy object, which holds generic job entry information JobEntryCopy writeToLogEntry = new JobEntryCopy(writeToLog); // place it on Spoon canvas properly writeToLogEntry.setDrawn(true); writeToLogEntry.setLocation(200, 100); jobMeta.addJobEntry(writeToLogEntry); // connect start entry to logging entry using simple hop jobMeta.addJobHop(new JobHopMeta(startEntry, writeToLogEntry)); // ------------------------------------------------------------------------------------ // Create "success" entry and put it into the job // ------------------------------------------------------------------------------------ System.out.println("- Adding Success Entry"); // crate and configure entry JobEntrySuccess success = new JobEntrySuccess(); success.setName("Success"); // wrap into JobEntryCopy object, which holds generic job entry information JobEntryCopy successEntry = new JobEntryCopy(success); // place it on Spoon canvas properly successEntry.setDrawn(true); successEntry.setLocation(400, 100); jobMeta.addJobEntry(successEntry); // connect logging entry to success entry on TRUE evaluation JobHopMeta greenHop = new JobHopMeta(writeToLogEntry, successEntry); greenHop.setEvaluation(true); jobMeta.addJobHop(greenHop); // ------------------------------------------------------------------------------------ // Create "abort" entry and put it into the job // ------------------------------------------------------------------------------------ System.out.println("- Adding Abort Entry"); // crate and configure entry JobEntryAbort abort = new JobEntryAbort(); abort.setName("Abort Job"); // wrap into JobEntryCopy object, which holds generic job entry information JobEntryCopy abortEntry = new JobEntryCopy(abort); // place it on Spoon canvas properly abortEntry.setDrawn(true); abortEntry.setLocation(400, 300); jobMeta.addJobEntry(abortEntry); // connect logging entry to abort entry on TRUE evaluation JobHopMeta redHop = new JobHopMeta(writeToLogEntry, abortEntry); redHop.setEvaluation(true); jobMeta.addJobHop(redHop); return jobMeta; } catch (Exception e) { // something went wrong, just log and return e.printStackTrace(); return null; } }
以上是关于使用java创建job的主要内容,如果未能解决你的问题,请参考以下文章
LockSupport.java 中的 FIFO 互斥代码片段