public static void main(String[] args) throws Exception { // parse arguments if (args.length != 3 || !args[1].equals("-config")) { usage(); } // Determine type Type type = null; String software; if (args[0].equals("-w")) { type = Type.WELCOME; software = "TAISHI/WelcomeThreadServer"; } else if (args[0].equals("-b")) { type = Type.BUSY; software = "TAISHI/BusyWaitServer"; } else if (args[0].equals("-s")) { type = Type.SUSPENSION; software = "TAISHI/SuspensionServer"; } else { software = ""; usage(); } // Reading configuration file String config_file = args[2]; ReadConfig parse = new ReadConfig(config_file, software); HashMap<String, String> config_map = parse.getConfig(); Debug.debug(config_map.toString()); // check if config_map is valid // necessary to check the thread pool size is set if (config_map == null || !config_map.containsKey("ThreadPoolSize")) { throw new Exception("Incomplete configuration"); } // create cache Debug.debug("Create cache with size: " + config_map.get("CacheSize")); ThreadSafeCache cache = new ThreadSafeCache(Integer.parseInt(config_map.get("CacheSize"))); // create server ThreadPoolServer server = new ThreadPoolServer(type, config_map, cache); server.run(); }
/** * Gets the configfile * * @return */ public static Config getConfig() { ReadConfig reader = new ReadConfig(); Config cfg = reader.getConfiguration(); return cfg; }