@Test public void createConf() throws IOException { RedisConfigUtil.generateRedisConfig("E:/redis-manager/conf/standalone/", RedisConfigUtil.STANDALONE_TYPE); }
public static void generateRedisConfig(String path, int mode) throws IOException { File tempPath = new File(path); if (!tempPath.exists() && !tempPath.mkdirs()) { throw new RuntimeException(path + " mkdir failed."); } File file = new File(path + REDIS_CONF); if (file.exists() && !file.delete()) { throw new RuntimeException(file.getName() + " delete failed."); } if (!file.createNewFile()) { throw new RuntimeException(file.getName() + " create failed."); } BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(file, true), UTF_8)); for (RedisConfig redisConfig : getRedisConfig(mode)) { String configKey = redisConfig.getConfigKey(); String configValue = redisConfig.getConfigValue(); bufferedWriter.write(configKey + SPACE + configValue); bufferedWriter.newLine(); } bufferedWriter.flush(); bufferedWriter.close(); }
RedisConfigUtil { public static void generateRedisConfig(String path, int mode) throws IOException { File tempPath = new File(path); if (!tempPath.exists() && !tempPath.mkdirs()) { throw new RuntimeException(path + " mkdir failed."); } File file = new File(path + REDIS_CONF); if (file.exists() && !file.delete()) { throw new RuntimeException(file.getName() + " delete failed."); } if (!file.createNewFile()) { throw new RuntimeException(file.getName() + " create failed."); } BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(file, true), UTF_8)); for (RedisConfig redisConfig : getRedisConfig(mode)) { String configKey = redisConfig.getConfigKey(); String configValue = redisConfig.getConfigValue(); bufferedWriter.write(configKey + SPACE + configValue); bufferedWriter.newLine(); } bufferedWriter.flush(); bufferedWriter.close(); } }
RedisConfigUtil { public static void generateRedisConfig(String path, int mode) throws IOException { File tempPath = new File(path); if (!tempPath.exists() && !tempPath.mkdirs()) { throw new RuntimeException(path + " mkdir failed."); } File file = new File(path + REDIS_CONF); if (file.exists() && !file.delete()) { throw new RuntimeException(file.getName() + " delete failed."); } if (!file.createNewFile()) { throw new RuntimeException(file.getName() + " create failed."); } BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(file, true), UTF_8)); for (RedisConfig redisConfig : getRedisConfig(mode)) { String configKey = redisConfig.getConfigKey(); String configValue = redisConfig.getConfigValue(); bufferedWriter.write(configKey + SPACE + configValue); bufferedWriter.newLine(); } bufferedWriter.flush(); bufferedWriter.close(); } RedisConfigUtil(); }
RedisConfigUtil { public static void generateRedisConfig(String path, int mode) throws IOException { File tempPath = new File(path); if (!tempPath.exists() && !tempPath.mkdirs()) { throw new RuntimeException(path + " mkdir failed."); } File file = new File(path + REDIS_CONF); if (file.exists() && !file.delete()) { throw new RuntimeException(file.getName() + " delete failed."); } if (!file.createNewFile()) { throw new RuntimeException(file.getName() + " create failed."); } BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(file, true), UTF_8)); for (RedisConfig redisConfig : getRedisConfig(mode)) { String configKey = redisConfig.getConfigKey(); String configValue = redisConfig.getConfigValue(); bufferedWriter.write(configKey + SPACE + configValue); bufferedWriter.newLine(); } bufferedWriter.flush(); bufferedWriter.close(); } 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 void generateRedisConfig(String path, int mode) throws IOException { File tempPath = new File(path); if (!tempPath.exists() && !tempPath.mkdirs()) { throw new RuntimeException(path + " mkdir failed."); } File file = new File(path + REDIS_CONF); if (file.exists() && !file.delete()) { throw new RuntimeException(file.getName() + " delete failed."); } if (!file.createNewFile()) { throw new RuntimeException(file.getName() + " create failed."); } BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(file, true), UTF_8)); for (RedisConfig redisConfig : getRedisConfig(mode)) { String configKey = redisConfig.getConfigKey(); String configValue = redisConfig.getConfigValue(); bufferedWriter.write(configKey + SPACE + configValue); bufferedWriter.newLine(); } bufferedWriter.flush(); bufferedWriter.close(); } 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; }