1 31 package org.objectweb.proactive.examples.migration; 32 33 import org.apache.log4j.Logger; 34 import org.objectweb.proactive.ProActive; 35 import org.objectweb.proactive.core.config.ProActiveConfiguration; 36 import org.objectweb.proactive.core.descriptor.data.ProActiveDescriptor; 37 import org.objectweb.proactive.core.descriptor.data.VirtualNode; 38 39 42 public class AgentClient { 43 44 45 static Logger logger = Logger.getLogger(AgentClient.class.getName()); 46 47 public static void main(String [] args) { 48 Agent myServer; 49 String nodeName, hostName; 50 ProActiveDescriptor proActiveDescriptor; 51 ProActiveConfiguration.load(); 52 try { 53 54 proActiveDescriptor = ProActive.getProactiveDescriptor("file:"+args[0]); 55 proActiveDescriptor.activateMappings(); 56 57 58 VirtualNode agent = proActiveDescriptor.getVirtualNode("Agent"); 59 String [] nodeList = agent.getNodesURL(); 60 myServer = (Agent)org.objectweb.proactive.ProActive.newActive(Agent.class.getName(), new Object []{"local"}); 62 hostName = myServer.getName(); 64 nodeName=myServer.getNodeName(); 65 logger.info("Agent is on: host " + hostName+" Node " + nodeName); 66 67 for(int i=0; i<nodeList.length;i++){ 68 myServer.moveTo(nodeList[i]); 70 nodeName=myServer.getNodeName(); 71 hostName=myServer.getName(); 72 logger.info("Agent is on: host " + hostName+" Node " + nodeName); 73 } 74 myServer.endBodyActivity(); 75 } 76 77 catch (Exception e) { 78 logger.error("Could not reach/create server object"); 79 e.printStackTrace(); 80 System.exit(1); 81 } 82 } 83 } 84 85 86 | Popular Tags |