@Test public void testRefreshAddressCache() { addressService.setAgentServerVip("10.0.0.1"); reportDecider.refreshAddressCache(); Assert.assertEquals("10.0.0.1", reportDecider.getAvailableAddress().ip()); }
void refreshAddressCache() { Address oldOne = addressHolder.get(); Address newOne = addressService.getAgentServerHost(); if (newOne == null) { logger.debug("No gateway address found!"); return; } try { boolean ok = sendGetRequest( new HttpGet(String.format("http: if (!ok) { return; } if (oldOne == null) { addressHolder.set(newOne); } else if (!newOne.ip().equals(oldOne.ip())) { addressHolder.compareAndSet(oldOne, newOne); } addressLastModifiedTime = System.currentTimeMillis(); logger.debug("change gateway address ,from {} to {} .", oldOne, newOne); return; } catch (Throwable e) { logger.debug("check gateway address {} fail:{}. old address:{}!", newOne.ip(), e.getMessage(), oldOne == null ? "" : oldOne.ip()); } }
ReportDecider implements HttpRequestProcessor { void refreshAddressCache() { Address oldOne = addressHolder.get(); Address newOne = addressService.getAgentServerHost(); if (newOne == null) { logger.debug("No gateway address found!"); return; } try { boolean ok = sendGetRequest( new HttpGet(String.format("http: if (!ok) { return; } if (oldOne == null) { addressHolder.set(newOne); } else if (!newOne.ip().equals(oldOne.ip())) { addressHolder.compareAndSet(oldOne, newOne); } addressLastModifiedTime = System.currentTimeMillis(); logger.debug("change gateway address ,from {} to {} .", oldOne, newOne); return; } catch (Throwable e) { logger.debug("check gateway address {} fail:{}. old address:{}!", newOne.ip(), e.getMessage(), oldOne == null ? "" : oldOne.ip()); } } }
ReportDecider implements HttpRequestProcessor { void refreshAddressCache() { Address oldOne = addressHolder.get(); Address newOne = addressService.getAgentServerHost(); if (newOne == null) { logger.debug("No gateway address found!"); return; } try { boolean ok = sendGetRequest( new HttpGet(String.format("http: if (!ok) { return; } if (oldOne == null) { addressHolder.set(newOne); } else if (!newOne.ip().equals(oldOne.ip())) { addressHolder.compareAndSet(oldOne, newOne); } addressLastModifiedTime = System.currentTimeMillis(); logger.debug("change gateway address ,from {} to {} .", oldOne, newOne); return; } catch (Throwable e) { logger.debug("check gateway address {} fail:{}. old address:{}!", newOne.ip(), e.getMessage(), oldOne == null ? "" : oldOne.ip()); } } ReportDecider(AddressService addressService, MetricConfig metricConfig); }
ReportDecider implements HttpRequestProcessor { void refreshAddressCache() { Address oldOne = addressHolder.get(); Address newOne = addressService.getAgentServerHost(); if (newOne == null) { logger.debug("No gateway address found!"); return; } try { boolean ok = sendGetRequest( new HttpGet(String.format("http: if (!ok) { return; } if (oldOne == null) { addressHolder.set(newOne); } else if (!newOne.ip().equals(oldOne.ip())) { addressHolder.compareAndSet(oldOne, newOne); } addressLastModifiedTime = System.currentTimeMillis(); logger.debug("change gateway address ,from {} to {} .", oldOne, newOne); return; } catch (Throwable e) { logger.debug("check gateway address {} fail:{}. old address:{}!", newOne.ip(), e.getMessage(), oldOne == null ? "" : oldOne.ip()); } } ReportDecider(AddressService addressService, MetricConfig metricConfig); boolean stillSilent(); synchronized Address getAvailableAddress(); abstract List<LookoutMeasurement> filter(List<LookoutMeasurement> measures); }
ReportDecider implements HttpRequestProcessor { void refreshAddressCache() { Address oldOne = addressHolder.get(); Address newOne = addressService.getAgentServerHost(); if (newOne == null) { logger.debug("No gateway address found!"); return; } try { boolean ok = sendGetRequest( new HttpGet(String.format("http: if (!ok) { return; } if (oldOne == null) { addressHolder.set(newOne); } else if (!newOne.ip().equals(oldOne.ip())) { addressHolder.compareAndSet(oldOne, newOne); } addressLastModifiedTime = System.currentTimeMillis(); logger.debug("change gateway address ,from {} to {} .", oldOne, newOne); return; } catch (Throwable e) { logger.debug("check gateway address {} fail:{}. old address:{}!", newOne.ip(), e.getMessage(), oldOne == null ? "" : oldOne.ip()); } } ReportDecider(AddressService addressService, MetricConfig metricConfig); boolean stillSilent(); synchronized Address getAvailableAddress(); abstract List<LookoutMeasurement> filter(List<LookoutMeasurement> measures);  }