final long pingTimeout = calcPingTimeout(name);  getPingHelper().ping(name, pingTimeout, new PingListener() { public void pingComplete(String name, int status, long time) { if (status == PingHelper.SUCCESS) { newState(name, stateOnSuccess); if (!isLocal(name)) { pingStats.enter(time); if (pingStats.getCount() == 10 || pingStats.getCount()%25 == 0) { setPingTimeout();
PingHelper pinger = getPingHelper(); if (pinger.pingInProcess(agent)) { logger.info("Duplicate ping requested, new ping not performed: agent=" + agent); } else { final long pingTimeout = calcPingTimeout(agent); logger.info("doPing: agent=" + agent + " timeout=" + pingTimeout); pinger.ping(new String[]{agent}, pingTimeout, new PingListener() { public void pingComplete(PingResult[] pr) { for (int i = 0; i < pr.length; i++) { if (pr[i].getStatus() == PingResult.SUCCESS) { newState(pr[i].getName(), stateOnSuccess); if (!isLocal(pr[i].getName())) { pingStats.enter(pr[i].getRoundTripTime()); if (pingStats.getCount() == 10 || pingStats.getCount() % 25 == 0) { setPingTimeout(); } } } else { logger.info("Ping:" + " agent=" + pr[i].getName() + " state=" + stateName(model.getCurrentState(pr[i].getName())) + " timeout=" + pingTimeout + " actual=" + pr[i].getRoundTripTime() + " result=" + (pr[i].getStatus() == PingResult.SUCCESS ? "SUCCESS" : "FAIL") + (pr[i].getStatus() == PingResult.SUCCESS ? "" : " newState=" + stateName(stateOnFail))); newState(pr[i].getName(), stateOnFail);
  protected void doPing(String name,                        final int stateOnSuccess,                        final int stateOnFail) {    final long pingTimeout = calcPingTimeout(name);    //logger.debug("doPing: agent=" + name + " timeout=" + pingTimeout);    getPingHelper().ping(name, pingTimeout, new PingListener() {      public void pingComplete(String name, int status, long time) {        if (status == PingHelper.SUCCESS) {          newState(name, stateOnSuccess);          if (!isLocal(name)) {            pingStats.enter(time);            if (pingStats.getCount() == 10 || pingStats.getCount()%25 == 0) {              setPingTimeout();            }          }        } else {          logger.info("Ping:" +                       " agent=" + name +                       " state=" + stateName(model.getCurrentState(name)) +                       " timeout=" + pingTimeout +                       " actual=" + time +                       " result=" + (status == PingHelper.SUCCESS ? "SUCCESS" : "FAIL") +                       (status == PingHelper.SUCCESS ? "" : " newState=" + stateName(stateOnFail)));          newState(name, stateOnFail);        }      }    });  }