try
{
// iterate all validators and execute its validate method.
for (Iterator it = validators.iterator(); it.hasNext();)
{
HealthCheckValidator hcv = (HealthCheckValidator) it.next();
if (isDebugEnabled)
{
log.debug("Starting validator execution: " + hcv.getClass().getName());
}
HealthCheckValidatorResult result = null;
// execute the validator until it succeeds or until the
// number of retries runs out
for (int i = 0; i <= hcv.getNumberOfRetries(); i++)
{
result = hcv.validate();
if (isDebugEnabled)
{
log.debug("Validator execution: " +
(result.getHealthCheckResult() == HealthCheckValidatorResult.VALIDATOR_SUCCEEDED));
}
if (result.getHealthCheckResult() == HealthCheckValidatorResult.VALIDATOR_SUCCEEDED)
{
// the validator succeeded so stop this loop and go for
// the next validator
break;
}
if ((i + 1) <= hcv.getNumberOfRetries())
{
// the validator did not succeed. If there are any
// retries left and if a retry delay was defined then
// wait before re-executing the same validator
if (hcv.getRetryDelay() > 0)
{
try
{
Thread.sleep(hcv.getRetryDelay());
}
catch (InterruptedException e)
{
}
}