Search in sources :

Example 1 with Agent

use of org.cristalise.kernel.entity.Agent 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);
}
Also used : Agent(org.cristalise.kernel.entity.Agent) AgentPath(org.cristalise.kernel.lookup.AgentPath) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) JobArrayList(org.cristalise.kernel.entity.agent.JobArrayList) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException)

Aggregations

ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)1 Agent (org.cristalise.kernel.entity.Agent)1 JobArrayList (org.cristalise.kernel.entity.agent.JobArrayList)1 AgentPath (org.cristalise.kernel.lookup.AgentPath)1