private void addLBMonitor(String nsMonitorName, String lbProtocol, HealthCheckPolicyTO hcp)
throws ExecutionException {
try {
// check if the monitor exists
boolean csMonitorExisis = false;
lbmonitor csMonitor = getMonitorIfExisits(nsMonitorName);
if (csMonitor != null) {
if (!csMonitor.get_type().equalsIgnoreCase(lbProtocol)) {
throw new ExecutionException("Can not update monitor :" + nsMonitorName + " as current protocol:"
+ csMonitor.get_type() + " of monitor is different from the " + " intended protocol:"
+ lbProtocol);
}
csMonitorExisis = true;
}
if (!csMonitorExisis) {
lbmonitor csMon = new lbmonitor();
csMon.set_monitorname(nsMonitorName);
csMon.set_type(lbProtocol);
if (lbProtocol.equalsIgnoreCase("HTTP")) {
csMon.set_httprequest(hcp.getpingPath());
s_logger.trace("LB Protocol is HTTP, Applying ping path on HealthCheck Policy");
} else {
s_logger.debug("LB Protocol is not HTTP, Skipping to apply ping path on HealthCheck Policy");
}
csMon.set_interval(hcp.getHealthcheckInterval());
csMon.set_retries(Math.max(hcp.getHealthcheckThresshold(), hcp.getUnhealthThresshold()) + 1);
csMon.set_resptimeout(hcp.getResponseTime());
csMon.set_failureretries(hcp.getUnhealthThresshold());
csMon.set_successretries(hcp.getHealthcheckThresshold());
s_logger.debug("Monitor properites going to get created :interval :: " + csMon.get_interval() + "respTimeOUt:: " + csMon.get_resptimeout()
+"failure retires(unhealththresshold) :: " + csMon.get_failureretries() + "successtries(healththresshold) ::" + csMon.get_successretries());
lbmonitor.add(_netscalerService, csMon);
} else {
s_logger.debug("Monitor :" + nsMonitorName + " is already existing. Skipping to delete and create it");
}
} catch (nitro_exception e) {