Mercurial > hg > Database > Alice
view src/main/java/alice/topology/node/TopologyNodeConfig.java @ 645:cb16036404ba
fix local topology test
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 31 Dec 2017 11:04:29 +0900 |
parents | ffaacab84d1a |
children | 3c060de44c2e |
line wrap: on
line source
package alice.topology.node; import java.util.ArrayList; import java.util.LinkedList; import alice.daemon.Config; public class TopologyNodeConfig extends Config { private String managerHostName; private int managerPort = 10000; public String cookie; private ArrayList<Class> eventList = new ArrayList<Class>(); private String managerKey = "manager"; private String localKey = "local"; public String getLocalKey() { return localKey; } public void setLocalKey(String local) { this.localKey = local; } public void setManagerKey(String manager) { this.manager = manager; } public String getManagerKey() { return manager; } private String manager = "manager"; public TopologyNodeConfig(String[] args) { super(args); for (int i = 0; i< args.length; i++) { if ("-host".equals(args[i])) { setManagerHostName(args[++i]); } else if ("-managerKey".equals(args[i])) { setManagerKey(args[++i]); } else if ("-localKey".equals(args[i])) { setLocalKey(args[++i]); } else if ("-port".equals(args[i])) { setManagerPort(Integer.parseInt(args[++i])); } else if ("-cookie".equals(args[i])) { cookie = args[++i]; } } } public static LinkedList<TopologyNodeConfig> MultiTopologyNodeCongingFactory(String[] args) { LinkedList<TopologyNodeConfig> configList = new LinkedList<TopologyNodeConfig>(); LinkedList<String> nodeConfigArgs = new LinkedList<String>(); for(int i = 0; i < args.length; ++i) { if("-host".equals(args[i])) { if(!nodeConfigArgs.isEmpty()){ configList.add(new TopologyNodeConfig((String[]) nodeConfigArgs.toArray())); nodeConfigArgs = new LinkedList<String>(); } ++i; nodeConfigArgs.add("-host"); nodeConfigArgs.add(args[i]); } else if("-port".equals(args[i])) { ++i; nodeConfigArgs.add("-port"); nodeConfigArgs.add(args[i]); } else if("-cookie".equals(args[i])) { ++i; nodeConfigArgs.add("-cookie"); nodeConfigArgs.add(args[i]); } } configList.add(new TopologyNodeConfig(nodeConfigArgs.toArray(new String[] {}))); return configList; } public String getManagerHostName() { return managerHostName; } public void setManagerHostName(String managerHostName) { this.managerHostName = managerHostName; } public int getManagerPort() { return managerPort; } public void setManagerPort(int managerPort) { this.managerPort = managerPort; } public void register(Class clazz) { if ("CodeSegment".equals(clazz.getSuperclass().getSimpleName())) eventList.add(clazz); } public void executeEvent() { for (Class clazz : eventList) try { clazz.newInstance(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e){ } } }