private static double systemPing()

in src/main/java/com/aliyuncs/kms/secretsmanager/client/utils/PingUtils.java [30:60]


    private static double systemPing(String pingCommand, String addr, Pattern pattern) {
        BufferedReader in = null;
        try {
            Process process = Runtime.getRuntime().exec(pingCommand + addr);
            if (process == null) {
                return -1;
            }
            in = new BufferedReader(new InputStreamReader(process.getInputStream()));
            StringBuffer sb = new StringBuffer();
            String line = null;
            while ((line = in.readLine()) != null) {
                sb.append(line + "\n");
            }
            boolean finished = process.waitFor(2, TimeUnit.SECONDS);
            if (!finished) {
                return -1;
            } else {
                return getCheckResult(sb.toString(), pattern);
            }
        } catch (InterruptedException | IOException ignore) {
            CommonLogger.getCommonLogger(CacheClientConstant.MODE_NAME).errorf("action:ping", ignore);
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException ignore) {
                }
            }
        }
        return -1;
    }