清除elastic集群缓存实现

    /**
     * 清除集群缓存
     * 
     * @param url
     * @throws IOException
     */
    public static boolean callClearCache(String ip) throws IOException {
        String url = "http://" + ip + ":9200/_cache/clear";
        System.out.println("clear url :" + url);
        String[] cmds = { "curl", url };
        ProcessBuilder pb = new ProcessBuilder(cmds);
        pb.redirectErrorStream(true);
        Process p;
        try {
            p = pb.start();
            BufferedReader br = null;
            String line = null;
            br = new BufferedReader(new InputStreamReader(p.getInputStream()));
            while ((line = br.readLine()) != null) {
                System.out.println("\t" + line);
            }
            br.close();
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }

你可能感兴趣的:(elasticsearch)