use of org.cristalise.kernel.entity.agent.Job in project kernel by cristal-ise.
the class UserCodeProcess method run.
@Override
public void run() {
Thread.currentThread().setName("Usercode Process");
// subscribe to job list - this will initialise the jobs using the ProxyObserver interface as callback
agent.subscribe(new MemberSubscription<Job>(this, ClusterType.JOB.getName(), true));
while (active) {
Job thisJob = getActualJob();
if (thisJob != null) {
String jobKey = thisJob.getItemPath() + ":" + thisJob.getStepPath();
int transitionId = thisJob.getTransition().getId();
try {
if (transitionId == START)
start(thisJob, jobKey);
else if (transitionId == COMPLETE)
complete(thisJob, jobKey);
} catch (InvalidTransitionException ex) {
// must have already been done by someone else - ignore
} catch (Exception ex) {
Logger.error("Error executing job:" + thisJob);
Logger.error(ex);
}
}
try {
synchronized (jobs) {
if (jobs.size() == 0) {
Logger.msg("UserCodeProcess.run() - Sleeping");
while (active && jobs.size() == 0) jobs.wait(2000);
}
}
} catch (InterruptedException ex) {
}
}
// shut down
try {
Gateway.close();
} catch (Exception ex) {
Logger.error(ex);
}
}
use of org.cristalise.kernel.entity.agent.Job in project kernel by cristal-ise.
the class UserCodeProcess method remove.
/**
* Job removal notification from the AgentProxy.
*/
@Override
public void remove(String id) {
synchronized (jobs) {
Job job = (Job) jobs.remove(id);
Logger.msg(7, "UserCodeProcess.remove() - Removed job:" + job);
}
}
Aggregations