Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop running Kettle Job/Transformation using Java

I'm developing a web-app based ETL too (with Kettle engine), using Java.

I'm running into issues, while trying to stop a running Job. I'm not sure if using the CarteSingleton.java is correct. 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. But that doesn't stop the running job. Kettle Engine is not getting notified of this! Job Execution continues. The .kjb / .ktr was creating using SPOON, although I'm not using SPOON to run/stop execution.

Is there any Kettle API config I've to change, to be able to use

   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?

Any pointers or help here would be great! Thanks, again.

Regards, Sanjeev

like image 366
Sanjeev Kulkarni N Avatar asked Oct 13 '15 06:10

Sanjeev Kulkarni N


1 Answers

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

Trans.stopAll() behaves similarly. It asks each step to stop and that flag is checked inside steps.

like image 149
Andrey Khayrutdinov Avatar answered Nov 01 '22 16:11

Andrey Khayrutdinov