class PingTask extends TimerTask {

    private static final TimeValue HTTP_TIMEOUT = new TimeValue(5, TimeUnit.SECONDS);
    private static final Logger LOGGER = LogManager.getLogger(PingTask.class);

    private final ClusterService clusterService;
    private final ExtendedNodeInfo extendedNodeInfo;
    private final String pingUrl;

    private final AtomicLong successCounter = new AtomicLong(0);
    private final AtomicLong failCounter = new AtomicLong(0);

    public PingTask(ClusterService clusterService,
                    ExtendedNodeInfo extendedNodeInfo,
                    String pingUrl) {
        this.clusterService = clusterService;
        this.pingUrl = pingUrl;
        this.extendedNodeInfo = extendedNodeInfo;
    }

    private Map<String, String> getKernelData() {
        return extendedNodeInfo.kernelData();
    }

    private String getClusterId() {
        return clusterService.state().metadata().clusterUUID();
    }

    private Boolean isMasterNode() {
        return clusterService.state().nodes().isLocalNodeElectedMaster();
    }

    private Map<String, Object> getCounters() {
        return Map.of(
            "success", successCounter.get(),
            "failure", failCounter.get()
        );
    }

    @Nullable
    String getHardwareAddress() {
        String macAddress = extendedNodeInfo.networkInfo().primaryInterface().macAddress();
        return macAddress.isEmpty() ? null : macAddress;
    }

    private URL buildPingUrl() throws URISyntaxException, IOException {

        final URI uri = new URI(this.pingUrl);

        // specifying the initialCapacity based on “expected number of elements / load_factor”
        // in this case, the "expected number of elements" = 10 while default load factor = .75
        Map<String, String> queryMap = new HashMap<>(14);
        queryMap.put("cluster_id", getClusterId());
        queryMap.put("kernel", Strings.toString(JsonXContent.builder().map(getKernelData())));
        queryMap.put("master", isMasterNode().toString());
        queryMap.put("ping_count", Strings.toString(JsonXContent.builder().map(getCounters())));
        queryMap.put("hardware_address", getHardwareAddress());
        queryMap.put("num_processors", Integer.toString(Runtime.getRuntime().availableProcessors()));
        queryMap.put("crate_version", Version.CURRENT.externalNumber());
        queryMap.put("java_version", System.getProperty("java.version"));

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Sending data: {}", queryMap);
        }

        List<String> params = new ArrayList<>(queryMap.size());
        for (Map.Entry<String, String> entry : queryMap.entrySet()) {
            String value = entry.getValue();
            if (value != null) {
                params.add(entry.getKey() + '=' + value);
            }
        }
        String query = String.join("&", params);

        return new URI(
            uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(),
            uri.getPath(), query, uri.getFragment()
        ).toURL();
    }

    @Override
    public void run() {<FILL_FUNCTION_BODY>}
}

        try {
            URL url = buildPingUrl();
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Sending UDC information to {}...", url);
            }
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setConnectTimeout((int) HTTP_TIMEOUT.millis());
            conn.setReadTimeout((int) HTTP_TIMEOUT.millis());

            if (conn.getResponseCode() >= 300) {
                throw new Exception(String.format(Locale.ENGLISH, "%s Responded with Code %d", url.getHost(), conn.getResponseCode()));
            }
            if (LOGGER.isDebugEnabled()) {
                BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
                String line = reader.readLine();
                while (line != null) {
                    LOGGER.debug(line);
                    line = reader.readLine();
                }
                reader.close();
            } else {
                conn.getInputStream().close();
            }
            successCounter.incrementAndGet();
        } catch (Exception e) {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Error sending UDC information", e);
            }
            failCounter.incrementAndGet();
        }
    
<methods>public boolean cancel() ,public abstract void run() ,public long scheduledExecutionTime() <variables>static final int CANCELLED,static final int EXECUTED,static final int SCHEDULED,static final int VIRGIN,final java.lang.Object lock,long nextExecutionTime,long period,int state