@Test public void variableAssignment() throws Exception { String path = DockerNodeOperation.DOCKER_INSTALL_BASE_PATH + port; Map<String, String> configs = new HashMap<>(); configs.put("port", "8000"); configs.put("dir", path); configs.put("bind", "10.1.5.6"); RedisConfigUtil.variableAssignment(machine, path, configs, true); }
public static String variableAssignment(Machine machine, String path, Map<String, String> configs, boolean sudo) throws Exception { StringBuffer commands = new StringBuffer(); commands.append("cd " + path).append(SEMICOLON); String cd = SSH2Util.execute(machine, commands.toString()); if (!Strings.isNullOrEmpty(cd)) { throw new RuntimeException(cd); } for (Map.Entry<String, String> entry : configs.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); if (sudo) { commands.append("sudo "); } commands.append("sed -i 's#{").append(key).append("}#").append(value).append("#g' ").append(REDIS_CONF).append(";"); } String result = SSH2Util.execute(machine, commands.toString()); return result; }
RedisConfigUtil { public static String variableAssignment(Machine machine, String path, Map<String, String> configs, boolean sudo) throws Exception { StringBuffer commands = new StringBuffer(); commands.append("cd " + path).append(SEMICOLON); String cd = SSH2Util.execute(machine, commands.toString()); if (!Strings.isNullOrEmpty(cd)) { throw new RuntimeException(cd); } for (Map.Entry<String, String> entry : configs.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); if (sudo) { commands.append("sudo "); } commands.append("sed -i 's#{").append(key).append("}#").append(value).append("#g' ").append(REDIS_CONF).append(";"); } String result = SSH2Util.execute(machine, commands.toString()); return result; } }
RedisConfigUtil { public static String variableAssignment(Machine machine, String path, Map<String, String> configs, boolean sudo) throws Exception { StringBuffer commands = new StringBuffer(); commands.append("cd " + path).append(SEMICOLON); String cd = SSH2Util.execute(machine, commands.toString()); if (!Strings.isNullOrEmpty(cd)) { throw new RuntimeException(cd); } for (Map.Entry<String, String> entry : configs.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); if (sudo) { commands.append("sudo "); } commands.append("sed -i 's#{").append(key).append("}#").append(value).append("#g' ").append(REDIS_CONF).append(";"); } String result = SSH2Util.execute(machine, commands.toString()); return result; } RedisConfigUtil(); }
RedisConfigUtil { public static String variableAssignment(Machine machine, String path, Map<String, String> configs, boolean sudo) throws Exception { StringBuffer commands = new StringBuffer(); commands.append("cd " + path).append(SEMICOLON); String cd = SSH2Util.execute(machine, commands.toString()); if (!Strings.isNullOrEmpty(cd)) { throw new RuntimeException(cd); } for (Map.Entry<String, String> entry : configs.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); if (sudo) { commands.append("sudo "); } commands.append("sed -i 's#{").append(key).append("}#").append(value).append("#g' ").append(REDIS_CONF).append(";"); } String result = SSH2Util.execute(machine, commands.toString()); return result; } RedisConfigUtil(); static String variableAssignment(Machine machine, String path, Map<String, String> configs, boolean sudo); static String getConfigItemDesc(String infoKey); static Set<String> getConfigKeyList(); static void generateRedisConfig(String path, int mode); }
RedisConfigUtil { public static String variableAssignment(Machine machine, String path, Map<String, String> configs, boolean sudo) throws Exception { StringBuffer commands = new StringBuffer(); commands.append("cd " + path).append(SEMICOLON); String cd = SSH2Util.execute(machine, commands.toString()); if (!Strings.isNullOrEmpty(cd)) { throw new RuntimeException(cd); } for (Map.Entry<String, String> entry : configs.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); if (sudo) { commands.append("sudo "); } commands.append("sed -i 's#{").append(key).append("}#").append(value).append("#g' ").append(REDIS_CONF).append(";"); } String result = SSH2Util.execute(machine, commands.toString()); return result; } RedisConfigUtil(); static String variableAssignment(Machine machine, String path, Map<String, String> configs, boolean sudo); static String getConfigItemDesc(String infoKey); static Set<String> getConfigKeyList(); static void generateRedisConfig(String path, int mode); static final String REDIS_CONF; static final String REQUIRE_PASS; static final String MASTER_AUTH; static final String BIND; static final String PORT; static final String DIR; static final String DAEMONIZE; static final int NORMAL_TYPE; static final int STANDALONE_TYPE; static final int CLUSTER_TYPE; }