简体   繁体   English

使用Java停止运行Kettle Job / Transformation

[英]Stop running Kettle Job/Transformation using Java

I'm developing a web-app based ETL too (with Kettle engine), using Java. 我正在使用Java开发基于Web应用程序的ETL(使用Kettle引擎)。

I'm running into issues, while trying to stop a running Job. 我在试图阻止正在运行的Job时遇到问题。 I'm not sure if using the CarteSingleton.java is correct. 我不确定使用CarteSingleton.java是否正确。 I'm using a custom singleton map. 我正在使用自定义单例映射。

My code is as below 我的代码如下

Job job = new Job(null, jobMeta);
job.setLogLevel(LogLevel.DETAILED);
job.setGatheringMetrics(true);
job.start();

Once job.start() is invoked, I'm trying to store that job object in a custom singleton map and retrieve the exact Job object that was stored in map, and on invocation of stopAll() (see code below) with another REST call, while the Job's status is RUNNING, to stop it. 调用job.start()后,我试图将该作业对象存储在自定义单例映射中,并检索存储在映射中的确切Job对象,以及使用另一个REST调用stopAll()(请参阅下面的代码)在Job的状态为RUNNING时调用,以阻止它。 But that doesn't stop the running job. 但这并不能阻止正在运行的工作。 Kettle Engine is not getting notified of this! Kettle Engine没有得到通知! Job Execution continues. 工作执行继续。 The .kjb / .ktr was creating using SPOON, although I'm not using SPOON to run/stop execution. .kjb / .ktr正在使用SPOON创建,尽管我没有使用SPOON来运行/停止执行。

Is there any Kettle API config I've to change, to be able to use 是否有任何Kettle API配置我要更改,以便能够使用

   same job object
   job.stopAll();

Could you please enlighten on the API and sample example, if any to stop a running JOB or transformation using Java? 您能否请教一下API和示例示例,如果有的话要停止正在运行的JOB或使用Java进行转换?

Any pointers or help here would be great! 任何指针或帮助都会很棒! Thanks, again. 再次感谢。

Regards, Sanjeev 此致,Sanjeev

Your approach seems to be correct. 你的方法似乎是正确的。 However, note that the immediate stoppage cannot be guaranteed - it simply sets a flag indicating the execution should not be to continued. 但请注意,无法保证立即停止 - 它只是设置一个标志,指示执行不应继续。

Job.stopAll() sets the flag and it is checked before the execution starts , but if it has begun it will not stop it on the spot Job.stopAll()设置标志在执行开始之前进行检查 ,但如果它已经开始,它将不会在现场停止

Trans.stopAll() behaves similarly. Trans.stopAll()行为类似。 It asks each step to stop and that flag is checked inside steps. 它要求每个步骤停止,步骤内检查该标志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM