private static class MonitoringThread implements Runnable {        /**         * 日志类         */        private Logger log = Logger.getLogger(MonitoringThread.class);        /**         * 客户端连接对象         */        private Socket socket;        /**         * 输出内容对象         */        private PrintWriter out;                @Override        public void run() {            // 监听的端口号            int port = Integer.parseInt(MsgUtil.getConfig("port"));            try {                ServerSocket ss = new ServerSocket(port);                while (true) {                    log.info("Cycle to monitor port " + port);                    socket = ss.accept();                    log.info("The socket is connected ..." + socket.hashCode());                    String performanceData = PerformanceCollect.getPerformanceData();                    log.debug(performanceData);                    out = new PrintWriter(socket.getOutputStream(), true);                    out.println(performanceData);                    out.close();                    socket.close();                    log.info("The socket is closed ..." + socket.hashCode());                }            } catch (IOException e) {                log.error("ListenPort io exception : " + e);            }        }    }

    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()