public static void modifyBenchmarkYamlFile()

in shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/common/file/yaml/BenchmarkConfigYaml.java [29:73]


    public static void modifyBenchmarkYamlFile(String benchmarkBasePath, int shardingDbCount, int shardingTableCount, int maxConnectionCount, int minConnectionCount, int maxConnectionPerQuery){
        String line = "";
        File yamlFile = null;
        List<File> yamlFileList = getYamlFileList(benchmarkBasePath);
        try {
            for(int i = 0; i < yamlFileList.size(); i++) {
                yamlFile = yamlFileList.get(i);
                StringBuffer bufAll = new StringBuffer();
                BufferedReader br = new BufferedReader(new FileReader(yamlFile));
                while ((line = br.readLine()) != null) {
                    if (line.contains("${0..2}.sbtest${0..99}")){
                        line = line.replace("${0..2}.sbtest${0..99}", "${0.." + (shardingDbCount-1) + "}.sbtest${0.." + (shardingTableCount-1) + "}");
                    }
                    if (line.contains("maximumPoolSize: 200")){
                        line = line.replaceAll("maximumPoolSize: 200", "maximumPoolSize: " + maxConnectionCount);
                    }
                    if (line.contains("{id % 3}")) {
                        line = line.replace("{id % 3}", "{id % " + shardingDbCount + "}");
                    }
                    if (line.contains("{k % 100}")){
                        line = line.replace("{k % 100}", "{k % " + shardingTableCount + "}");
                    } 
                    if (line.contains("max.connections.size.per.query: 2")){
                        line = line.replace("max.connections.size.per.query: 2", "max.connections.size.per.query: " + maxConnectionPerQuery);
                    }
                    if (line.contains("maxPoolSize: 200")){
                        line = line.replaceAll("maxPoolSize: 200", "maxPoolSize: " + maxConnectionCount);
                    }
                    if (line.contains("minPoolSize: 200")){
                        line = line.replaceAll("minPoolSize: 200", "minPoolSize: " + minConnectionCount);
                    }
    
                    bufAll.append(line);
                    bufAll.append(System.getProperty("line.separator"));
                }
                br.close();
                BufferedWriter bw = new BufferedWriter(new FileWriter(yamlFile));
                bw.write(bufAll.toString());
                bw.close();
            } 
        } catch (IOException ex) {
            ex.printStackTrace();
        } finally {
        }
    }