You can translate the question and the replies:

Return code from Denodo Scheduler after job completion.

Team , I am calling a Denodo Job using Scheduler-API script and its running fine.However, I need to capture the return code based on the RESULT (Complete/Fail). Can you please let me know how can we add this in scheduler API script? Or do we already have this.. Thanks
user
13-02-2019 02:27:20 -0500
code

9 Answers

Hello, It’s expected that this class is being used when processing jobs through the Scheduler-API: https://community.denodo.com/docs/html/browse/7.0/scheduler/javadoc/com/denodo/scheduler/client/job/JobData.html You can call the getLastResult() method of the job in question to obtain the last result. https://community.denodo.com/docs/html/browse/7.0/scheduler/javadoc/com/denodo/scheduler/client/job/JobData.html#getLastResult-- Hope this helps.
Denodo Team
13-02-2019 15:55:41 -0500
code
Thanks Team for your prompt response. I have used this getLastResult() method but its returning the result of last time the job was executed. For Eg :- When I run the job for the first time , if the status is "Error" , i get the same status during my second run as well. I need the status of the current run to return the code. Please let me know if here is any method to call the same.
user
15-02-2019 06:29:15 -0500
Team , Can you please provide any update on this issue ? While using getLastResult() method , we are getting the RESULT of previous execution and not current execution. Can you please let us know how can we RESULT of current job and not RESULT of previous job execution.
user
21-02-2019 07:22:52 -0500
Hello, In this case, you will need to do something similar to this: 1) After the job has been started, you will need to block execution of the code to give the job time to finish. You could use a while loop for checking the job's status to know if it's still running. If it's running, you could pause for a given duration. For example, when checking for running status, you might have a condition within the while loop that checks a boolean result like this: (job.getState().compareTo(State.RUNNING) == 0 && job.getName().compareTo(jobName) == 0) When the job is no longer running, exit the loop. 2) Now that the job is no longer running, you can use getLastResult(). Hope this helps.
Denodo Team
25-02-2019 14:41:49 -0500
code
Hi Team , We are still not get the results as expected. Below is the sample that we are using to get the result of the current job execution. We are starting a job , using Startjob method in scheduler-Api. PFB for the code. ================= public static JobData.Result startJob(String jobName, SchedulerManager schedulerManager) throws ConnectException, InternalErrorException, InstanceNotFoundException, InterruptedException { Collection<JobData> jobs = schedulerManager.getJobsInformation(); JobData.Result RC = null; for (JobData job : jobs) { if (job.getName().compareTo(jobName) == 0) { Integer jobId = job.getJobID(); if ((job.getState().compareTo(State.RUNNING) != 0) && (job.getState().compareTo(State.DISABLED) != 0)) { schedulerManager.startJob(projectId, jobId); } } } for (JobData job : jobs) { while((job.getState().compareTo(State.RUNNING) != 0 && (job.getName().compareTo(jobName) == 0) )) { break; } RC = job.getLastResult(); return RC; } return RC; } ======================= Need your help in correcting the code here and getting the expected results.
user
26-02-2019 06:09:46 -0500
public static JobData.Result startJob(String jobName, SchedulerManager schedulerManager) throws ConnectException, InternalErrorException, InstanceNotFoundException, InterruptedException { Collection<JobData> jobs = schedulerManager.getJobsInformation(); JobData.Result RC = null; for (JobData job : jobs) { if (job.getName().compareTo(jobName) == 0) { Integer jobId = job.getJobID(); if ((job.getState().compareTo(State.RUNNING) != 0) && (job.getState().compareTo(State.DISABLED) != 0)) { schedulerManager.startJob(projectId, jobId); } } } for (JobData job : jobs) { while((job.getState().compareTo(State.RUNNING) != 0 && (job.getName().compareTo(jobName) == 0) )) { break; } RC = job.getLastResult(); return RC; } return RC; }
user
26-02-2019 06:10:34 -0500
Hello, The “break;” statement does not pause execution. It immediately exits the loop, which means your loop is not waiting for the job to finish. Try using the Thread.sleep() function instead. In the while loop, you’re also looking for jobs that are not running, instead of looking for the job that is running. Hope this helps.
Denodo Team
26-02-2019 17:47:16 -0500
code
Hi, I'm having the same issue even if I use the thread.sleep() method (I've put a while circle until the job was no longer running): still I got the last but one execution return code. I also printed out the jobdata.toString() to be sure that it finished. Did you find a way?
user
07-06-2019 10:50:49 -0400
Hi, I found a workaround. When the job stops, you will need a new instance of Collection<JobData> class to refresh its result. Hope it helps, Best regards
user
11-06-2019 03:11:05 -0400
You must sign in to add an answer. If you do not have an account, you can register here