Forums » User questions »
use CreamJobstatus class
Added by Guterl Patrick about 13 years ago
hi,
I search a method for obtain the jobstatus
to determind a wainting state (wait in the URI queue/ running state (execute the code )
CreamJobstatus for example
thank's
Patrick
Replies (3)
RE: use CreamJobstatus class
-
Added by Schwarz Lionel about 13 years ago
Hi Patrick,
As SAGA does not make any difference between "waiting in queue" and "running", you have to use the state detail metric.
Metric m = yourjob.getMetric(Job.JOB_STATEDETAIL)
and add a callback (that you have to implement) to this metric
metric.addCallback(new Callback(){ ... }
Please let me know if you need more code details.
Regards
Lionel
RE: use CreamJobstatus class
-
Added by Schwarz Lionel about 13 years ago
Example:
Metric metric = job.getMetric(Job.JOB_STATEDETAIL); metric.addCallback(new Callback(){ public boolean cb(Monitorable mt, Metric metric, Context ctx) throws NotImplementedException, AuthorizationFailedException { try { String value = metric.getAttribute(Metric.VALUE); System.out.println("Current state: "+value); } catch (NotImplementedException e) {throw e;} catch (AuthorizationFailedException e) {throw e;} catch (Exception e) { e.printStackTrace(); } return true; } }); job.waitFor();
This code prints the current state every N milliseconds until the job is finished.
N is defined in the
job.monitor.poll.period property
Lionel
RE: use CreamJobstatus class
-
Added by Guterl Patrick about 13 years ago
Thank's
it's work fine
Patrick