class ReportDecider implements HttpRequestProcessor {

    void refreshAddressCache() {
        //get a new one
        Address oldOne = addressHolder.get();
        Address newOne = addressService.getAgentServerHost();
        if (newOne == null) {
            logger.debug("No gateway address found!");
            return;
        }
        //check new address
        try {
            boolean ok = sendGetRequest(
                new HttpGet(String.format("http://%s:%d/datas", newOne.ip(), newOne.port())), null);
            if (!ok) {
                return;
            }
            // address is checked!
            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());

        }

    }

    public  ReportDecider(AddressService addressService, MetricConfig metricConfig);

}