Stop running Kettle Job/Transformation using Java
Asked Answered
F

1

7

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

Faddish answered 13/10, 2015 at 6:8 Comment(0)
T
6

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.

Trueblood answered 13/10, 2015 at 7:9 Comment(2)
Thanks. But, what's the approach to guarantee it? Does Pentaho provide any sample? I posted on their site also - but found no response yet. stackoverflow is much more developer-friendly!Faddish
Actually, I suppose any guarantees are hardly possible. In Java, there is no legal way to manually stop threads. Since Job is derived from Thread and transformations' steps are normally executed in separate threads, there is no way to stop immediately them either.Trueblood

© 2022 - 2024 — McMap. All rights reserved.