public void run() {
   if (webServerUrl == null) {
     logger.log(Level.WARNING, "Web server url is null!");
     return;
   }
   try {
     while (running.get()) {
       try {
         URL url = new URL(webServerUrl + "collector.do");
         HttpURLConnection connection = (HttpURLConnection) url.openConnection();
         connection.setDoOutput(true);
         connection.setRequestMethod("POST");
         connection.setConnectTimeout(1000);
         connection.setReadTimeout(1000);
         final DataOutputStream out = new DataOutputStream(connection.getOutputStream());
         TimedMemberState ts = getTimedMemberState();
         ts.writeData(out);
         out.flush();
         connection.getInputStream();
       } catch (Exception e) {
         logger.log(Level.FINEST, e.getMessage(), e);
       }
       Thread.sleep(updateIntervalMs);
     }
   } catch (Throwable throwable) {
     logger.log(
         Level.FINEST, "Web Management Center will be closed due to exception.", throwable);
     shutdown();
   }
 }
    public void run() {
      if (webServerUrl == null) {
        logger.log(Level.WARNING, "Web server url is null!");
        return;
      }
      try {
        Random rand = new Random();
        Address address =
            ((MemberImpl) factory.node.getClusterImpl().getLocalMember()).getAddress();
        GroupConfig groupConfig = factory.getConfig().getGroupConfig();
        while (running.get()) {
          try {
            URL url =
                new URL(
                    webServerUrl
                        + "getTask.do?member="
                        + address.getHost()
                        + ":"
                        + address.getPort()
                        + "&cluster="
                        + groupConfig.getName());
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestProperty("Connection", "keep-alive");
            InputStream inputStream = connection.getInputStream();
            DataInputStream input = new DataInputStream(inputStream);

            int taskId = input.readInt();
            if (taskId > 0) {
              int requestType = input.readInt();
              ConsoleRequest request = consoleRequests[requestType];
              request.readData(input);
              sendResponse(taskId, request);
            }
          } catch (Exception e) {
            logger.log(Level.FINEST, e.getMessage(), e);
          }
          Thread.sleep(700 + rand.nextInt(300));
        }
      } catch (Throwable throwable) {
        logger.log(Level.FINEST, "Problem on management center while polling task.", throwable);
      }
    }
 private void interruptThread(Thread t) {
   if (t != null) {
     t.interrupt();
   }
 }