Mercurial > hg > Database > Alice
changeset 580:4d013f75c2da dispose
change Config for multi config
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 18 Dec 2015 00:15:34 +0900 |
parents | 56e2397e6c78 |
children | 26033ebb30ec |
files | src/main/java/alice/daemon/Config.java src/main/java/alice/topology/node/TopologyNodeConfig.java |
diffstat | 2 files changed, 29 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/alice/daemon/Config.java Thu Dec 17 21:22:50 2015 +0900 +++ b/src/main/java/alice/daemon/Config.java Fri Dec 18 00:15:34 2015 +0900 @@ -2,6 +2,8 @@ import org.apache.log4j.Level; +import java.util.LinkedList; + public class Config { public int localPort = 10000; @@ -9,17 +11,34 @@ public Level level = Level.FATAL; public String MCSTADDR = "224.0.0.1"; public String nis = "en1"; + public LinkedList<String> configArgs; public Config(String[] args) { for (int i = 0; i< args.length; i++) { + setConfig(i, args); + } + } + + public LinkedList<String> setConfig(int i, String []args){ + configArgs = new LinkedList<String>(); + + if (configArgs.isEmpty()){ if ("-p".equals(args[i])) { localPort = Integer.parseInt(args[++i]); + configArgs.add("-p"); + configArgs.add(args[i]); } else if ("-log".equals(args[i])) { logFile = args[++i]; + configArgs.add("-log"); + configArgs.add(args[i]); } else if ("-n".equals(args[i])) { nis = args[++i]; + configArgs.add("-n"); + configArgs.add(args[i]); } else if ("-a".equals(args[i])) { MCSTADDR = args[++i]; + configArgs.add("-a"); + configArgs.add(args[i]); } else if ("-level".equals(args[i])) { String levelStr = args[++i]; if (levelStr.equals("fatal")) { @@ -33,9 +52,11 @@ } else if (levelStr.equals("debug")) { level = Level.DEBUG; } + configArgs.add("-level"); + configArgs.add(args[i]); } } + return configArgs; } - }
--- a/src/main/java/alice/topology/node/TopologyNodeConfig.java Thu Dec 17 21:22:50 2015 +0900 +++ b/src/main/java/alice/topology/node/TopologyNodeConfig.java Fri Dec 18 00:15:34 2015 +0900 @@ -4,6 +4,7 @@ import java.util.LinkedList; import alice.daemon.Config; +import org.apache.log4j.Level; public class TopologyNodeConfig extends Config { @@ -25,14 +26,14 @@ } } - public static LinkedList<TopologyNodeConfig> MultiTopologyNodeCongingFactory(String[] args) { + public 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) + for (int i = 0; i < args.length; ++i) { if ("-host".equals(args[i])) { if (!nodeConfigArgs.isEmpty()) { - configList.add(new TopologyNodeConfig(nodeConfigArgs.toArray(new String[] {}))); + configList.add(new TopologyNodeConfig(nodeConfigArgs.toArray(new String[]{}))); nodeConfigArgs = new LinkedList<String>(); } ++i; @@ -46,7 +47,10 @@ ++i; nodeConfigArgs.add("-cookie"); nodeConfigArgs.add(args[i]); + } else { + nodeConfigArgs.addAll(setConfig(i, args)); } + } configList.add(new TopologyNodeConfig(nodeConfigArgs.toArray(new String[] {})));