@Test public void testAddr() { setAddr(""); assertEquals(0, HttpHeartbeatSender.parseDashboardList().size()); setAddr("a.com"); List<Tuple2<String, Integer>> list = HttpHeartbeatSender.parseDashboardList(); assertEquals(1, list.size()); assertEquals("a.com", list.get(0).r1); assertEquals(Integer.valueOf(80), list.get(0).r2); setAddr("a.com:88"); list = HttpHeartbeatSender.parseDashboardList(); assertEquals(1, list.size()); assertEquals("a.com", list.get(0).r1); assertEquals(Integer.valueOf(88), list.get(0).r2); setAddr("a.com:88,,,,"); list = HttpHeartbeatSender.parseDashboardList(); assertEquals(1, list.size()); assertEquals("a.com", list.get(0).r1); assertEquals(Integer.valueOf(88), list.get(0).r2); setAddr("a.com:88,b.com"); list = HttpHeartbeatSender.parseDashboardList(); assertEquals(2, list.size()); assertEquals("a.com", list.get(0).r1); assertEquals(Integer.valueOf(88), list.get(0).r2); assertEquals("b.com", list.get(1).r1); assertEquals(Integer.valueOf(80), list.get(1).r2); setAddr("a.com:88,b.com:99999"); list = HttpHeartbeatSender.parseDashboardList(); assertEquals(2, list.size()); assertEquals("a.com", list.get(0).r1); assertEquals(Integer.valueOf(88), list.get(0).r2); assertEquals("b.com", list.get(1).r1); assertEquals(Integer.valueOf(99999), list.get(1).r2); }
protected static List<Tuple2<String, Integer>> parseDashboardList() { List<Tuple2<String, Integer>> list = new ArrayList<Tuple2<String, Integer>>(); try { String ipsStr = TransportConfig.getConsoleServer(); if (StringUtil.isBlank(ipsStr)) { RecordLog.warn("[NettyHttpHeartbeatSender] Dashboard server address is not configured"); return list; } for (String ipPortStr : ipsStr.split(",")) { if (ipPortStr.trim().length() == 0) { continue; } ipPortStr = ipPortStr.trim(); if (ipPortStr.startsWith("http: ipPortStr = ipPortStr.substring(7); } if (ipPortStr.startsWith(":")) { continue; } String[] ipPort = ipPortStr.trim().split(":"); int port = 80; if (ipPort.length > 1) { port = Integer.parseInt(ipPort[1].trim()); } list.add(Tuple2.of(ipPort[0].trim(), port)); } } catch (Exception ex) { RecordLog.warn("[NettyHttpHeartbeatSender] Parse dashboard list failed, current address list: " + list, ex); ex.printStackTrace(); } return list; }
HttpHeartbeatSender implements HeartbeatSender { protected static List<Tuple2<String, Integer>> parseDashboardList() { List<Tuple2<String, Integer>> list = new ArrayList<Tuple2<String, Integer>>(); try { String ipsStr = TransportConfig.getConsoleServer(); if (StringUtil.isBlank(ipsStr)) { RecordLog.warn("[NettyHttpHeartbeatSender] Dashboard server address is not configured"); return list; } for (String ipPortStr : ipsStr.split(",")) { if (ipPortStr.trim().length() == 0) { continue; } ipPortStr = ipPortStr.trim(); if (ipPortStr.startsWith("http: ipPortStr = ipPortStr.substring(7); } if (ipPortStr.startsWith(":")) { continue; } String[] ipPort = ipPortStr.trim().split(":"); int port = 80; if (ipPort.length > 1) { port = Integer.parseInt(ipPort[1].trim()); } list.add(Tuple2.of(ipPort[0].trim(), port)); } } catch (Exception ex) { RecordLog.warn("[NettyHttpHeartbeatSender] Parse dashboard list failed, current address list: " + list, ex); ex.printStackTrace(); } return list; } }
HttpHeartbeatSender implements HeartbeatSender { protected static List<Tuple2<String, Integer>> parseDashboardList() { List<Tuple2<String, Integer>> list = new ArrayList<Tuple2<String, Integer>>(); try { String ipsStr = TransportConfig.getConsoleServer(); if (StringUtil.isBlank(ipsStr)) { RecordLog.warn("[NettyHttpHeartbeatSender] Dashboard server address is not configured"); return list; } for (String ipPortStr : ipsStr.split(",")) { if (ipPortStr.trim().length() == 0) { continue; } ipPortStr = ipPortStr.trim(); if (ipPortStr.startsWith("http: ipPortStr = ipPortStr.substring(7); } if (ipPortStr.startsWith(":")) { continue; } String[] ipPort = ipPortStr.trim().split(":"); int port = 80; if (ipPort.length > 1) { port = Integer.parseInt(ipPort[1].trim()); } list.add(Tuple2.of(ipPort[0].trim(), port)); } } catch (Exception ex) { RecordLog.warn("[NettyHttpHeartbeatSender] Parse dashboard list failed, current address list: " + list, ex); ex.printStackTrace(); } return list; } HttpHeartbeatSender(); }
HttpHeartbeatSender implements HeartbeatSender { protected static List<Tuple2<String, Integer>> parseDashboardList() { List<Tuple2<String, Integer>> list = new ArrayList<Tuple2<String, Integer>>(); try { String ipsStr = TransportConfig.getConsoleServer(); if (StringUtil.isBlank(ipsStr)) { RecordLog.warn("[NettyHttpHeartbeatSender] Dashboard server address is not configured"); return list; } for (String ipPortStr : ipsStr.split(",")) { if (ipPortStr.trim().length() == 0) { continue; } ipPortStr = ipPortStr.trim(); if (ipPortStr.startsWith("http: ipPortStr = ipPortStr.substring(7); } if (ipPortStr.startsWith(":")) { continue; } String[] ipPort = ipPortStr.trim().split(":"); int port = 80; if (ipPort.length > 1) { port = Integer.parseInt(ipPort[1].trim()); } list.add(Tuple2.of(ipPort[0].trim(), port)); } } catch (Exception ex) { RecordLog.warn("[NettyHttpHeartbeatSender] Parse dashboard list failed, current address list: " + list, ex); ex.printStackTrace(); } return list; } HttpHeartbeatSender(); @Override boolean sendHeartbeat(); @Override long intervalMs(); }
HttpHeartbeatSender implements HeartbeatSender { protected static List<Tuple2<String, Integer>> parseDashboardList() { List<Tuple2<String, Integer>> list = new ArrayList<Tuple2<String, Integer>>(); try { String ipsStr = TransportConfig.getConsoleServer(); if (StringUtil.isBlank(ipsStr)) { RecordLog.warn("[NettyHttpHeartbeatSender] Dashboard server address is not configured"); return list; } for (String ipPortStr : ipsStr.split(",")) { if (ipPortStr.trim().length() == 0) { continue; } ipPortStr = ipPortStr.trim(); if (ipPortStr.startsWith("http: ipPortStr = ipPortStr.substring(7); } if (ipPortStr.startsWith(":")) { continue; } String[] ipPort = ipPortStr.trim().split(":"); int port = 80; if (ipPort.length > 1) { port = Integer.parseInt(ipPort[1].trim()); } list.add(Tuple2.of(ipPort[0].trim(), port)); } } catch (Exception ex) { RecordLog.warn("[NettyHttpHeartbeatSender] Parse dashboard list failed, current address list: " + list, ex); ex.printStackTrace(); } return list; } HttpHeartbeatSender(); @Override boolean sendHeartbeat(); @Override long intervalMs();  }