public CollectedInfo(String host, int port) throws Exception { init(host, port); } public void init(String host, int port) throws Exception {
if (sender == null) { if (proxyList == null) sender = new MultiCastSender(); else sender = new TcpSender(); coll = new CollectedInfo(host, port); this.port = coll.port; this.host = coll.host; sender.init(this); } catch (Exception ex) { log.error("Unable to initialize Sender: " + ex); coll.refresh(); } catch (Exception ex) { log.error("Unable to collect load information: " + ex); output = "v=1&ready=" + coll.ready + "&busy=" + coll.busy + "&port=" + port; try { sender.send(output); } catch (Exception ex) { log.error("Unable to send colllected load information: " + ex);
@Override public void init(HeartbeatListener config) throws Exception { this.config = config; StringTokenizer tok = new StringTokenizer(config.getProxyList(), ","); proxies = new Proxy[tok.countTokens()]; int i = 0; while (tok.hasMoreTokens()) { String token = tok.nextToken().trim(); int pos = token.indexOf(':'); if (pos <=0) throw new Exception("bad ProxyList"); proxies[i] = new Proxy(); proxies[i].port = Integer.parseInt(token.substring(pos + 1)); try { proxies[i].address = InetAddress.getByName(token.substring(0, pos)); } catch (Exception e) { throw new Exception("bad ProxyList"); } i++; } connections = new Socket[proxies.length]; connectionReaders = new BufferedReader[proxies.length]; connectionWriters = new BufferedWriter[proxies.length]; }
if (s == null) { try { group = InetAddress.getByName(config.getGroup()); if (config.getHost() != null) { InetAddress addr = InetAddress.getByName(config.getHost()); InetSocketAddress addrs = new InetSocketAddress(addr, config.getMultiport()); s = new MulticastSocket(addrs); } else s = new MulticastSocket(config.getMultiport()); s.setTimeToLive(config.getTtl()); s.joinGroup(group); } catch (Exception ex) { DatagramPacket data = new DatagramPacket(buf, buf.length, group, config.getMultiport()); try { s.send(data);
public int send(String mess) throws Exception { if (s == null) { try { group = InetAddress.getByName(config.getGroup()); if (config.host != null) { InetAddress addr = InetAddress.getByName(config.host); InetSocketAddress addrs = new InetSocketAddress(addr, config.getMultiport()); s = new MulticastSocket(addrs); } else s = new MulticastSocket(config.getMultiport()); s.setTimeToLive(config.getTtl()); s.joinGroup(group); } catch (Exception ex) { buf = mess.getBytes(); DatagramPacket data = new DatagramPacket(buf, buf.length, group, config.getMultiport()); try { s.send(data);
String requestLine = "POST " + config.getProxyURL() + " HTTP/1.0"; if (config.getHost() != null) { connections[i] = new Socket(); InetAddress addr = InetAddress.getByName(config.getHost()); InetSocketAddress addrs = new InetSocketAddress(addr, 0); connections[i].setReuseAddress(true); } catch (Exception ex) { log.error("Unable to connect to proxy: " + ex); close(i); } catch (Exception ex) { log.error("Unable to send collected load information to proxy: " + ex); close(i); if (responseStatus == null) { log.error("Unable to read response from proxy"); close(i); continue; } else { if (status != 200) { log.error("Status is " + status); close(i); continue; if (n <= 0) { log.error("Read content failed");
return -1; String requestLine = "POST " + config.getProxyURL() + " HTTP/1.0"; } catch (Exception ex) { log.error("Unable to connect to proxy: " + ex); close(i); } catch (Exception ex) { log.error("Unable to send collected load information to proxy: " + ex); close(i); if (responseStatus == null) { log.error("Unable to read response from proxy"); close(i); continue; } else { if (status != 200) { log.error("Status is " + status); close(i); continue; if (n <= 0) { log.error("Read content failed"); close(i); break; } else {
if (sender == null) { if (proxyList == null) sender = new MultiCastSender(); else sender = new TcpSender(); coll = new CollectedInfo(host, port); this.port = coll.port; this.host = coll.host; sender.init(this); } catch (Exception ex) { log.error("Unable to initialize Sender: " + ex); coll.refresh(); } catch (Exception ex) { log.error("Unable to collect load information: " + ex); "&port=" + port; try { sender.send(output); } catch (Exception ex) { log.error("Unable to send collected load information: " + ex);
if (s == null) { try { group = InetAddress.getByName(config.getGroup()); if (config.getHost() != null) { InetAddress addr = InetAddress.getByName(config.getHost()); InetSocketAddress addrs = new InetSocketAddress(addr, config.getMultiport()); s = new MulticastSocket(addrs); } else s = new MulticastSocket(config.getMultiport()); s.setTimeToLive(config.getTtl()); s.joinGroup(group); } catch (Exception ex) { DatagramPacket data = new DatagramPacket(buf, buf.length, group, config.getMultiport()); try { s.send(data);
if (s == null) { try { group = InetAddress.getByName(config.getGroup()); if (config.host != null) { InetAddress addr = InetAddress.getByName(config.host); InetSocketAddress addrs = new InetSocketAddress(addr, config.getMultiport()); s = new MulticastSocket(addrs); } else s = new MulticastSocket(config.getMultiport()); s.setTimeToLive(config.getTtl()); s.joinGroup(group); } catch (Exception ex) { DatagramPacket data = new DatagramPacket(buf, buf.length, group, config.getMultiport()); try { s.send(data);
@Override public void init(HeartbeatListener config) throws Exception { this.config = config; StringTokenizer tok = new StringTokenizer(config.getProxyList(), ","); proxies = new Proxy[tok.countTokens()]; int i = 0; while (tok.hasMoreTokens()) { String token = tok.nextToken().trim(); int pos = token.indexOf(':'); if (pos <=0) throw new Exception("bad ProxyList"); proxies[i] = new Proxy(); proxies[i].port = Integer.parseInt(token.substring(pos + 1)); try { proxies[i].address = InetAddress.getByName(token.substring(0, pos)); } catch (Exception e) { throw new Exception("bad ProxyList"); } i++; } connections = new Socket[proxies.length]; connectionReaders = new BufferedReader[proxies.length]; connectionWriters = new BufferedWriter[proxies.length]; }
String requestLine = "POST " + config.getProxyURL() + " HTTP/1.0"; if (config.getHost() != null) { connections[i] = new Socket(); InetAddress addr = InetAddress.getByName(config.getHost()); InetSocketAddress addrs = new InetSocketAddress(addr, 0); connections[i].setReuseAddress(true); } catch (Exception ex) { log.error("Unable to connect to proxy: " + ex); close(i); } catch (Exception ex) { log.error("Unable to send collected load information to proxy: " + ex); close(i); if (responseStatus == null) { log.error("Unable to read response from proxy"); close(i); continue; } else { if (status != 200) { log.error("Status is " + status); close(i); continue; if (n <= 0) { log.error("Read content failed");
return -1; String requestLine = "POST " + config.getProxyURL() + " HTTP/1.0"; } catch (Exception ex) { log.error("Unable to connect to proxy: " + ex); close(i); } catch (Exception ex) { log.error("Unable to send collected load information to proxy: " + ex); close(i); if (responseStatus == null) { log.error("Unable to read response from proxy"); close(i); continue; } else { if (status != 200) { log.error("Status is " + status); close(i); continue; if (n <= 0) { log.error("Read content failed"); close(i); break; } else {
public CollectedInfo(String host, int port) throws Exception { init(host, port); } public void init(String host, int port) throws Exception {
if (sender == null) { if (proxyList == null) sender = new MultiCastSender(); else sender = new TcpSender(); coll = new CollectedInfo(host, port); this.port = coll.port; this.host = coll.host; sender.init(this); } catch (Exception ex) { log.error("Unable to initialize Sender: " + ex); coll.refresh(); } catch (Exception ex) { log.error("Unable to collect load information: " + ex); "&port=" + port; try { sender.send(output); } catch (Exception ex) { log.error("Unable to send colllected load information: " + ex);
public void init(HeartbeatListener config) throws Exception { this.config = config; StringTokenizer tok = new StringTokenizer(config.getProxyList(), ","); proxies = new Proxy[tok.countTokens()]; int i = 0; while (tok.hasMoreTokens()) { String token = tok.nextToken().trim(); int pos = token.indexOf(':'); if (pos <=0) throw new Exception("bad ProxyList"); proxies[i] = new Proxy(); proxies[i].port = Integer.parseInt(token.substring(pos + 1)); try { proxies[i].address = InetAddress.getByName(token.substring(0, pos)); } catch (Exception e) { throw new Exception("bad ProxyList"); } i++; } connections = new Socket[proxies.length]; connectionReaders = new BufferedReader[proxies.length]; connectionWriters = new BufferedWriter[proxies.length]; }
public CollectedInfo(String host, int port) throws Exception { init(host, port); } public void init(String host, int port) throws Exception {
if (sender == null) { if (proxyList == null) sender = new MultiCastSender(); else sender = new TcpSender(); coll = new CollectedInfo(host, port); this.port = coll.port; this.host = coll.host; sender.init(this); } catch (Exception ex) { log.error("Unable to initialize Sender: " + ex); coll.refresh(); } catch (Exception ex) { log.error("Unable to collect load information: " + ex); "&port=" + port; try { sender.send(output); } catch (Exception ex) { log.error("Unable to send colllected load information: " + ex);
@Override public void init(HeartbeatListener config) throws Exception { this.config = config; StringTokenizer tok = new StringTokenizer(config.getProxyList(), ","); proxies = new Proxy[tok.countTokens()]; int i = 0; while (tok.hasMoreTokens()) { String token = tok.nextToken().trim(); int pos = token.indexOf(':'); if (pos <=0) throw new Exception("bad ProxyList"); proxies[i] = new Proxy(); proxies[i].port = Integer.parseInt(token.substring(pos + 1)); try { proxies[i].address = InetAddress.getByName(token.substring(0, pos)); } catch (Exception e) { throw new Exception("bad ProxyList"); } i++; } connections = new Socket[proxies.length]; connectionReaders = new BufferedReader[proxies.length]; connectionWriters = new BufferedWriter[proxies.length]; }
public CollectedInfo(String host, int port) throws Exception { init(host, port); } public void init(String host, int port) throws Exception {