use of org.cristalise.kernel.entity.agent.JobArrayList in project kernel by cristal-ise.
the class ItemProxy method getJobList.
/**
* @param agentPath
* @param filter
* @return
* @throws AccessRightsException
* @throws ObjectNotFoundException
* @throws PersistencyException
*/
private ArrayList<Job> getJobList(AgentPath agentPath, boolean filter) throws AccessRightsException, ObjectNotFoundException, PersistencyException {
JobArrayList thisJobList;
String jobs = getItem().queryLifeCycle(agentPath.getSystemKey(), filter);
try {
thisJobList = (JobArrayList) Gateway.getMarshaller().unmarshall(jobs);
} catch (Exception e) {
Logger.error(e);
throw new PersistencyException("Exception::ItemProxy::getJobList() - Cannot unmarshall the jobs");
}
return thisJobList.list;
}
use of org.cristalise.kernel.entity.agent.JobArrayList in project kernel by cristal-ise.
the class ItemImplementation method queryLifeCycle.
/**
*/
@Override
public String queryLifeCycle(SystemKey agentId, boolean filter) throws AccessRightsException, ObjectNotFoundException, PersistencyException {
Logger.msg(1, "ItemImplementation::queryLifeCycle(" + mItemPath + ") - agent: " + agentId);
try {
AgentPath agent;
try {
agent = new AgentPath(agentId);
} catch (InvalidItemPathException e) {
throw new AccessRightsException("Agent " + agentId + " doesn't exist");
}
Workflow wf = (Workflow) mStorage.get(mItemPath, ClusterType.LIFECYCLE + "/workflow", null);
JobArrayList jobBag = new JobArrayList();
CompositeActivity domainWf = (CompositeActivity) wf.search("workflow/domain");
jobBag.list = filter ? domainWf.calculateJobs(agent, mItemPath, true) : domainWf.calculateAllJobs(agent, mItemPath, true);
Logger.msg(1, "ItemImplementation::queryLifeCycle(" + mItemPath + ") - Returning " + jobBag.list.size() + " jobs.");
try {
return Gateway.getMarshaller().marshall(jobBag);
} catch (Exception e) {
Logger.error(e);
throw new PersistencyException("Error marshalling job bag");
}
} catch (AccessRightsException | ObjectNotFoundException | PersistencyException e) {
Logger.error(e);
throw e;
} catch (Throwable ex) {
Logger.error("ItemImplementation::queryLifeCycle(" + mItemPath + ") - Unknown error");
Logger.error(ex);
throw new PersistencyException("Unknown error querying jobs. Please see server log.");
}
}
use of org.cristalise.kernel.entity.agent.JobArrayList in project kernel by cristal-ise.
the class JobPusher method run.
@Override
public void run() {
String tName = "Agent job pusher for " + itemPath + ":" + activity.getPath() + " to role " + myRole;
Thread.currentThread().setName(tName);
Logger.msg(7, "JobPusher.run() - Started:" + tName);
try {
for (AgentPath nextAgent : Gateway.getLookup().getAgents(myRole)) {
Logger.msg(7, "JobPusher.run() - Calculating jobs for agent:" + nextAgent);
try {
// get joblist for agent
JobArrayList jobList = new JobArrayList(this.activity.calculateJobs(nextAgent, itemPath, false));
// push it to the agent
String stringJobs = Gateway.getMarshaller().marshall(jobList);
Agent thisAgent = AgentHelper.narrow(nextAgent.getIOR());
Logger.msg(7, "JobPusher.run() - Calling refreshJobList() with " + jobList.list.size() + " jobs for agent " + nextAgent + " from " + activity.getPath());
thisAgent.refreshJobList(itemPath.getSystemKey(), activity.getPath(), stringJobs);
} catch (Exception ex) {
Logger.error("JobPusher.run() - Agent " + nextAgent + " of role " + myRole + " could not be found to be informed of a change in " + itemPath);
Logger.error(ex);
}
}
} catch (ObjectNotFoundException e) {
Logger.warning("JobPusher cannot push jobs, it did not find any agents for role:" + myRole);
}
Logger.msg(7, "JobPusher.run() - FINISHED:" + tName);
}
Aggregations