public static String getConfigOrExit(String[] args) { ArgsHolder.init(args, ArgsHolder.ArgType.LAUNCH_MASTER); if (ArgsHolder.getConfigFile() == null) { ArgsHolder.printUsageAndExit(ArgsHolder.ArgType.LAUNCH_MASTER); } return ArgsHolder.getConfigFile(); }
public static void main(String[] args) { ArgsHolder.init(args, ArgsHolder.ArgType.SLAVE); RestartHelper.init(); if (ArgsHolder.getMasterHost() == null) { ArgsHolder.printUsageAndExit(ArgsHolder.ArgType.SLAVE); } Slave slave = new Slave(new RemoteMasterConnection(ArgsHolder.getMasterHost(), ArgsHolder.getMasterPort())); try { slave.run(ArgsHolder.getSlaveIndex()); } catch (Exception e) { System.err.println("Unexpected error in scenario"); e.printStackTrace(); ShutDownHook.exit(127); } }
public static void init() { if (ArgsHolder.getTempConfigDir() != null) { Utils.deleteOnExitRecursive(new File(ArgsHolder.getTempConfigDir())); } }
String[] slaveArgs = {"--master", "127.0.0.1:2103", "--slaveIndex", "1", "--add-plugin=/foo/plugin1", "--add-config=plugin1:/foo/config.xml", "--add-config=plugin1:/foo/jgroups.xml", "--add-plugin=/bar/plugin2", "--add-config=plugin2:/bar/config.xml"}; ArgsHolder.init(masterArgs, ArgsHolder.ArgType.LAUNCH_MASTER); ArgsHolder.init(slaveArgs, ArgsHolder.ArgType.SLAVE); assertEquals("127.0.0.1", ArgsHolder.getMasterHost()); assertEquals(2103, ArgsHolder.getMasterPort()); assertEquals(1, ArgsHolder.getSlaveIndex()); assertEquals("/foo/configFile.xml", ArgsHolder.getConfigFile()); List<String> reporterPaths = ArgsHolder.getReporterPaths(); assertTrue(reporterPaths.contains("/bar/reporterDir")); assertTrue(reporterPaths.contains("/foo/reporterDir")); Map<String, ArgsHolder.PluginParam> pluginParams = ArgsHolder.getPluginParams(); ArgsHolder.PluginParam plugin1 = pluginParams.get("plugin1"); assertNotNull(plugin1); ArgsHolder.init(deprecatedMasterArgs, ArgsHolder.ArgType.LAUNCH_MASTER); ArgsHolder.init(deprecatedSlaveArgs, ArgsHolder.ArgType.SLAVE); assertEquals("127.0.0.2", ArgsHolder.getMasterHost()); assertEquals(2101, ArgsHolder.getMasterPort()); assertEquals(2, ArgsHolder.getSlaveIndex()); assertEquals("/deprecated/configFile.xml", ArgsHolder.getConfigFile());
StringBuilder classpathBuilder = new StringBuilder(); ArgsHolder.PluginParam pluginParam = ArgsHolder.getPluginParams().get(plugin); Path tempConfigDir = null; if (pluginParam != null) { .add(createLockedTempFile(slaveIndex)); command.add(javaExecutable); List<String> defaultVmArgs = ArgsHolder.getDefaultVmArgs(); command.addAll(vmArgs.getVmArgs(defaultVmArgs)); command.add(ArgsHolder.MASTER).add(ArgsHolder.getMasterHost() + ":" + ArgsHolder.getMasterPort()); command.add(ArgsHolder.SLAVE_INDEX).add(String.valueOf(slaveIndex)); command.add(ArgsHolder.UUID).add(nextUuid.toString()); for (Map.Entry<String, ArgsHolder.PluginParam> entry : ArgsHolder.getPluginParams().entrySet()) { ArgsHolder.PluginParam pp = entry.getValue(); if (pp.getPath() != null) {
public static Properties getPluginProperties(String plugin) { ArgsHolder.PluginParam pluginParam = ArgsHolder.getPluginParams().get(plugin); Properties properties = new Properties(); File pluginDir = pluginParam != null && pluginParam.getPath() != null ? new File(pluginParam.getPath()) : new File(Directories.PLUGINS_DIR, plugin); File confDir = new File(pluginDir, "conf"); File file = new File(confDir, PROPERTIES_FILE); if (!file.exists()) { log.warn("Could not find a plugin descriptor : " + file); return properties; } try { loadProperties(properties, file); } catch (IOException e) { log.error(String.format("Exception while loading plugin specific properties file %s.", PROPERTIES_FILE), e); } return properties; }
UUID uuid = ArgsHolder.getUuid(); if (uuid == null) { buffer.putLong(0);
private void run(int slaveIndex) throws Exception { log.debugf("Started with UUID %s", ArgsHolder.getUuid()); InetAddress address = connection.connectToMaster(slaveIndex);