use of org.cristalise.kernel.lookup.AgentPath 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);
}
use of org.cristalise.kernel.lookup.AgentPath in project kernel by cristal-ise.
the class Bootstrap method checkAgent.
/**
* Checks for the existence of a agents so it can be used
*
* @param name
* @param pass
* @param rolePath
* @param uuid
* @return the Proxy representing the Agent
* @throws Exception
*/
private static AgentProxy checkAgent(String name, String pass, RolePath rolePath, String uuid) throws Exception {
Logger.msg(1, "Bootstrap.checkAgent() - Checking for existence of '" + name + "' agent.");
LookupManager lookup = Gateway.getLookupManager();
try {
AgentProxy agentProxy = Gateway.getProxyManager().getAgentProxy(lookup.getAgentPath(name));
systemAgents.put(name, agentProxy);
Logger.msg(3, "Bootstrap.checkAgent() - Agent '" + name + "' found.");
return agentProxy;
} catch (ObjectNotFoundException ex) {
}
Logger.msg("Bootstrap.checkAgent() - Agent '" + name + "' not found. Creating.");
try {
AgentPath agentPath = new AgentPath(new ItemPath(uuid), name);
Gateway.getCorbaServer().createAgent(agentPath);
lookup.add(agentPath);
if (StringUtils.isNotBlank(pass))
lookup.setAgentPassword(agentPath, pass);
// assign admin role
Logger.msg("Bootstrap.checkAgent() - Assigning role '" + rolePath.getName() + "'");
Gateway.getLookupManager().addRole(agentPath, rolePath);
Gateway.getStorage().put(agentPath, new Property(NAME, name, true), null);
Gateway.getStorage().put(agentPath, new Property(TYPE, "Agent", false), null);
AgentProxy agentProxy = Gateway.getProxyManager().getAgentProxy(agentPath);
// TODO: properly init agent here with wf, props and colls
// agentProxy.initialise(agentId, itemProps, workflow, colls);
systemAgents.put(name, agentProxy);
return agentProxy;
} catch (Exception ex) {
Logger.error("Unable to create '" + name + "' Agent.");
throw ex;
}
}
use of org.cristalise.kernel.lookup.AgentPath in project kernel by cristal-ise.
the class Gateway method login.
/**
* Authenticates the agent using the configured {@link Authenticator}
*
* @param agentName the name of the agent
* @param agentPassword the password of the agent
* @param resource check {@link Authenticator#authenticate(String, String, String)}
* @return AgentProxy representing the logged in user/agent
*
* @throws InvalidDataException - bad params
* @throws ObjectNotFoundException - object not found
*/
public static AgentProxy login(String agentName, String agentPassword, String resource) throws InvalidDataException, ObjectNotFoundException {
Authenticator auth = getAuthenticator();
if (!auth.authenticate(agentName, agentPassword, resource))
throw new InvalidDataException("Login failed");
// find agent proxy
AgentPath agentPath = mLookup.getAgentPath(agentName);
AgentProxy agent = (AgentProxy) mProxyManager.getProxy(agentPath);
agent.setAuthObj(auth);
return agent;
}
use of org.cristalise.kernel.lookup.AgentPath in project kernel by cristal-ise.
the class StandardServer method resetAgentIORs.
public static void resetAgentIORs(RolePath root) throws ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException {
Logger.msg("StandardServer.resetAgentIORs() - root:" + root);
Iterator<Path> roles = Gateway.getLookup().getChildren(root);
while (roles.hasNext()) {
RolePath role = (RolePath) roles.next();
resetAgentIORs(role);
for (AgentPath agent : Gateway.getLookup().getAgents(role)) {
Logger.msg("StandardServer.resetAgentIORs() - setting IOR for role:" + role + " agent:" + agent.getAgentName() + " " + agent.getItemPath());
Gateway.getLookupManager().setIOR(agent.getItemPath(), Gateway.getORB().object_to_string(Gateway.getCorbaServer().getAgentIOR(agent)));
}
}
}
use of org.cristalise.kernel.lookup.AgentPath in project kernel by cristal-ise.
the class BulkImport method importPath.
public void importPath(ItemPath item, Object locker) throws PersistencyException {
String[] contents = importCluster.getClusterContents(item, PATH);
AgentPath agentPath = null;
String entity = "";
if (Arrays.asList(contents).contains("Item"))
entity = "Item";
if (Arrays.asList(contents).contains("Agent"))
entity = "Agent";
if (StringUtils.isNotBlank(entity)) {
if (entity.equals("Item"))
importItemPath(item, locker);
else if (entity.equals("Agent"))
agentPath = importAgentPath(item, locker);
} else
Logger.warning("BulkImport.importPath() - WARNING: '" + item + "' has no Path.Item or Path.Agent files");
;
for (String c : contents) {
if (c.equals("Domain"))
importDomainPath(item, locker);
else if (c.equals("Role"))
importRolePath(item, agentPath, locker);
}
}
Aggregations