问题
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
回答1:
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.
来源:https://stackoverflow.com/questions/33095298/stop-running-kettle-job-transformation-using-java