求助:使用Kettle api 停止运行的Job
最近我们项目需要使用Kettle,本人成功的将其集成到项目中,但是中途遇到一个很郁闷的问题,就是不知道如何使用api停止正在运行的Job,我使用的是kettle3.2版本。下面是我调用并执行资源库中的Job的代码:
public void executeJobToResorce() throws KettleException {
//初始化
EnvUtil.environmentInit();
JobEntryLoader.init();
StepLoader.init();
//日志
LogWriter log=LogWriter.getInstance("KettleTest.log", true, LogWriter.LOG_LEVEL_DETAILED);
//用户
UserInfo userInfo=new UserInfo();
userInfo.setLogin("admin");
userInfo.setName("admin");
//数据库连接元对象
/**
* Construct a new database connections. Note that not all these parameters are not always mandatory.
*
* @param name The database name
* @param type The type of database
* @param access The type of database access
* @param host The hostname or IP address
* @param db The database name
* @param port The port on which the database listens.
* @param user The username
* @param pass The password
*/
DatabaseMeta connection=new DatabaseMeta("10.207.6.109-sspa", "Oracle", "Native", "10.207.6.109", "orcl", "1521", "sspa", "sspa");
//资源库元对象
RepositoryMeta repinfo=new RepositoryMeta();
repinfo.setConnection(connection);
//资源库
Repository rep=new Repository(log, repinfo, userInfo);
//连接资源库
rep.connect("");
//资源库目录对象
RepositoryDirectory dir=new RepositoryDirectory(rep);
//步骤加载对象
StepLoader steploader=StepLoader.getInstance();
//Job元对象
JobMeta jobMeta=new JobMeta(log, rep,"ceshiJob", dir);
//Job
Job job=new Job(log, steploader, rep, jobMeta);
//执行Job
job.execute();
//job.run();
//System.out.println("--------------------------"+job.getStatus());
//等待Job执行结束
job.waitUntilFinished();
}