@Override public Socket createSocket(final String host, final int port) throws IOException { return SocketUtils.createAndConnect(host, port, config); }
@Override public Socket createSocket(final String host, final int port) throws IOException { return SocketUtils.createAndConnect(host, port, config); }
public static Socket createAndConnect(String host, int port, SocketOptionsConfig options) throws IOException { final InetAddress addr = InetAddress.getByName(host); final SocketAddress endpoint = new InetSocketAddress(addr, port); return createAndConnect(endpoint, options); } }
public static Socket createAndConnect(String host, int port, SocketOptionsConfig options) throws IOException { final InetAddress addr = InetAddress.getByName(host); final SocketAddress endpoint = new InetSocketAddress(addr, port); return createAndConnect(endpoint, options); } }
@Override public Metrics readAllMetrics() throws MetricReadException { try(final Socket socket = createAndConnect(config.getHost(), config.getPort(), config.getSocketOptions())) { final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), ASCII_CHARSET)); final BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), ASCII_CHARSET)); final Metrics result = new Metrics(); fetchStatistics("general", reader, writer, result); quit(writer); return result; } catch (IOException e) { throw new MetricReadException(e); } }