Search in sources :

Example 1 with JobArrayList

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;
}
Also used : PersistencyException(org.cristalise.kernel.common.PersistencyException) JobArrayList(org.cristalise.kernel.entity.agent.JobArrayList) MappingException(org.exolab.castor.mapping.MappingException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) ValidationException(org.exolab.castor.xml.ValidationException) AccessRightsException(org.cristalise.kernel.common.AccessRightsException) MarshalException(org.exolab.castor.xml.MarshalException) InvalidTransitionException(org.cristalise.kernel.common.InvalidTransitionException) ObjectAlreadyExistsException(org.cristalise.kernel.common.ObjectAlreadyExistsException) IOException(java.io.IOException) PersistencyException(org.cristalise.kernel.common.PersistencyException)

Example 2 with JobArrayList

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.");
    }
}
Also used : InvalidItemPathException(org.cristalise.kernel.lookup.InvalidItemPathException) AccessRightsException(org.cristalise.kernel.common.AccessRightsException) AgentPath(org.cristalise.kernel.lookup.AgentPath) CompositeActivity(org.cristalise.kernel.lifecycle.instance.CompositeActivity) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) Workflow(org.cristalise.kernel.lifecycle.instance.Workflow) PersistencyException(org.cristalise.kernel.common.PersistencyException) JobArrayList(org.cristalise.kernel.entity.agent.JobArrayList) MappingException(org.exolab.castor.mapping.MappingException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) InvalidItemPathException(org.cristalise.kernel.lookup.InvalidItemPathException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) ValidationException(org.exolab.castor.xml.ValidationException) AccessRightsException(org.cristalise.kernel.common.AccessRightsException) MarshalException(org.exolab.castor.xml.MarshalException) InvalidTransitionException(org.cristalise.kernel.common.InvalidTransitionException) ObjectAlreadyExistsException(org.cristalise.kernel.common.ObjectAlreadyExistsException) IOException(java.io.IOException) PersistencyException(org.cristalise.kernel.common.PersistencyException) CannotManageException(org.cristalise.kernel.common.CannotManageException) InvalidAgentPathException(org.cristalise.kernel.lookup.InvalidAgentPathException)

Example 3 with JobArrayList

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);
}
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)3 JobArrayList (org.cristalise.kernel.entity.agent.JobArrayList)3 IOException (java.io.IOException)2 AccessRightsException (org.cristalise.kernel.common.AccessRightsException)2 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)2 InvalidTransitionException (org.cristalise.kernel.common.InvalidTransitionException)2 ObjectAlreadyExistsException (org.cristalise.kernel.common.ObjectAlreadyExistsException)2 PersistencyException (org.cristalise.kernel.common.PersistencyException)2 AgentPath (org.cristalise.kernel.lookup.AgentPath)2 MappingException (org.exolab.castor.mapping.MappingException)2 MarshalException (org.exolab.castor.xml.MarshalException)2 ValidationException (org.exolab.castor.xml.ValidationException)2 CannotManageException (org.cristalise.kernel.common.CannotManageException)1 Agent (org.cristalise.kernel.entity.Agent)1 CompositeActivity (org.cristalise.kernel.lifecycle.instance.CompositeActivity)1 Workflow (org.cristalise.kernel.lifecycle.instance.Workflow)1 InvalidAgentPathException (org.cristalise.kernel.lookup.InvalidAgentPathException)1 InvalidItemPathException (org.cristalise.kernel.lookup.InvalidItemPathException)1