@Test public void testQueuedJobsExceedThreshold() { long queuedJobs = 1200; when(statistics.getNumberOfQueuedJobs()).thenReturn(queuedJobs); Result result = healthCheck.execute(); String msg = "Found 1200 queued jobs."; assertTrue("Message should say it found queued jobs", result.toString().contains(msg)); assertEquals("Result should not be ok", false, result.isOk()); assertEquals("Status should not be OK", Result.Status.WARN, result.getStatus()); }
@Override public Result execute() { FormattingResultLog resultLog = new FormattingResultLog(); if(jobManager != null) { Iterable<Queue> queues = jobManager.getQueues(); if(queues != null) { for (Queue queue : queues) { String name = queue.getName(); String info = queue.getStateInfo(); resultLog.info("The queue {} is currently {}", name, info); } } else { resultLog.info("There are currently no queues available."); } Statistics statistics = jobManager.getStatistics(); long totalJobs = statistics.getNumberOfJobs(); if (totalJobs > 0) resultLog.info("Found {} total jobs.", totalJobs); else resultLog.debug("Found no jobs in the Job Manager."); long queuedJobs = statistics.getNumberOfQueuedJobs(); if(queuedJobs > 0) resultLog.info("Found {} queued jobs.", queuedJobs); else resultLog.debug("Found no queued jobs."); long activeJobs = statistics.getNumberOfActiveJobs(); if(activeJobs > 0) resultLog.info("Found {} active jobs.", activeJobs); else resultLog.debug("Found no active jobs."); long cancelledJobs = statistics.getNumberOfCancelledJobs(); if(cancelledJobs > 0) resultLog.info("Found {} cancelled jobs.", cancelledJobs); else resultLog.debug("Found no cancelled jobs."); long failedJobs = statistics.getNumberOfFailedJobs(); if(failedJobs > 0) resultLog.info("Found {} failed jobs.", failedJobs); else resultLog.debug("Found no failed jobs."); long averageProcessingTime = statistics.getAverageProcessingTime(); if(averageProcessingTime > 0) resultLog.debug("The average processing time is {}.", averageProcessingTime); long averageWaitingTime = statistics.getAverageWaitingTime(); if(averageWaitingTime > 0) resultLog.debug("The average waiting time is [{}.", averageWaitingTime); if(queuedJobs > MAX_JOBS_QUEUED) { resultLog.warn("Found more than {} jobs queued: {}", MAX_JOBS_QUEUED, queuedJobs); } } else { resultLog.info("No Job Manager available"); } return new Result(resultLog); }
SlingJobsHealthCheck implements HealthCheck { @Override public Result execute() { FormattingResultLog resultLog = new FormattingResultLog(); if(jobManager != null) { Iterable<Queue> queues = jobManager.getQueues(); if(queues != null) { for (Queue queue : queues) { String name = queue.getName(); String info = queue.getStateInfo(); resultLog.info("The queue {} is currently {}", name, info); } } else { resultLog.info("There are currently no queues available."); } Statistics statistics = jobManager.getStatistics(); long totalJobs = statistics.getNumberOfJobs(); if (totalJobs > 0) resultLog.info("Found {} total jobs.", totalJobs); else resultLog.debug("Found no jobs in the Job Manager."); long queuedJobs = statistics.getNumberOfQueuedJobs(); if(queuedJobs > 0) resultLog.info("Found {} queued jobs.", queuedJobs); else resultLog.debug("Found no queued jobs."); long activeJobs = statistics.getNumberOfActiveJobs(); if(activeJobs > 0) resultLog.info("Found {} active jobs.", activeJobs); else resultLog.debug("Found no active jobs."); long cancelledJobs = statistics.getNumberOfCancelledJobs(); if(cancelledJobs > 0) resultLog.info("Found {} cancelled jobs.", cancelledJobs); else resultLog.debug("Found no cancelled jobs."); long failedJobs = statistics.getNumberOfFailedJobs(); if(failedJobs > 0) resultLog.info("Found {} failed jobs.", failedJobs); else resultLog.debug("Found no failed jobs."); long averageProcessingTime = statistics.getAverageProcessingTime(); if(averageProcessingTime > 0) resultLog.debug("The average processing time is {}.", averageProcessingTime); long averageWaitingTime = statistics.getAverageWaitingTime(); if(averageWaitingTime > 0) resultLog.debug("The average waiting time is [{}.", averageWaitingTime); if(queuedJobs > MAX_JOBS_QUEUED) { resultLog.warn("Found more than {} jobs queued: {}", MAX_JOBS_QUEUED, queuedJobs); } } else { resultLog.info("No Job Manager available"); } return new Result(resultLog); } }
SlingJobsHealthCheck implements HealthCheck { @Override public Result execute() { FormattingResultLog resultLog = new FormattingResultLog(); if(jobManager != null) { Iterable<Queue> queues = jobManager.getQueues(); if(queues != null) { for (Queue queue : queues) { String name = queue.getName(); String info = queue.getStateInfo(); resultLog.info("The queue {} is currently {}", name, info); } } else { resultLog.info("There are currently no queues available."); } Statistics statistics = jobManager.getStatistics(); long totalJobs = statistics.getNumberOfJobs(); if (totalJobs > 0) resultLog.info("Found {} total jobs.", totalJobs); else resultLog.debug("Found no jobs in the Job Manager."); long queuedJobs = statistics.getNumberOfQueuedJobs(); if(queuedJobs > 0) resultLog.info("Found {} queued jobs.", queuedJobs); else resultLog.debug("Found no queued jobs."); long activeJobs = statistics.getNumberOfActiveJobs(); if(activeJobs > 0) resultLog.info("Found {} active jobs.", activeJobs); else resultLog.debug("Found no active jobs."); long cancelledJobs = statistics.getNumberOfCancelledJobs(); if(cancelledJobs > 0) resultLog.info("Found {} cancelled jobs.", cancelledJobs); else resultLog.debug("Found no cancelled jobs."); long failedJobs = statistics.getNumberOfFailedJobs(); if(failedJobs > 0) resultLog.info("Found {} failed jobs.", failedJobs); else resultLog.debug("Found no failed jobs."); long averageProcessingTime = statistics.getAverageProcessingTime(); if(averageProcessingTime > 0) resultLog.debug("The average processing time is {}.", averageProcessingTime); long averageWaitingTime = statistics.getAverageWaitingTime(); if(averageWaitingTime > 0) resultLog.debug("The average waiting time is [{}.", averageWaitingTime); if(queuedJobs > MAX_JOBS_QUEUED) { resultLog.warn("Found more than {} jobs queued: {}", MAX_JOBS_QUEUED, queuedJobs); } } else { resultLog.info("No Job Manager available"); } return new Result(resultLog); }  }
SlingJobsHealthCheck implements HealthCheck { @Override public Result execute() { FormattingResultLog resultLog = new FormattingResultLog(); if(jobManager != null) { Iterable<Queue> queues = jobManager.getQueues(); if(queues != null) { for (Queue queue : queues) { String name = queue.getName(); String info = queue.getStateInfo(); resultLog.info("The queue {} is currently {}", name, info); } } else { resultLog.info("There are currently no queues available."); } Statistics statistics = jobManager.getStatistics(); long totalJobs = statistics.getNumberOfJobs(); if (totalJobs > 0) resultLog.info("Found {} total jobs.", totalJobs); else resultLog.debug("Found no jobs in the Job Manager."); long queuedJobs = statistics.getNumberOfQueuedJobs(); if(queuedJobs > 0) resultLog.info("Found {} queued jobs.", queuedJobs); else resultLog.debug("Found no queued jobs."); long activeJobs = statistics.getNumberOfActiveJobs(); if(activeJobs > 0) resultLog.info("Found {} active jobs.", activeJobs); else resultLog.debug("Found no active jobs."); long cancelledJobs = statistics.getNumberOfCancelledJobs(); if(cancelledJobs > 0) resultLog.info("Found {} cancelled jobs.", cancelledJobs); else resultLog.debug("Found no cancelled jobs."); long failedJobs = statistics.getNumberOfFailedJobs(); if(failedJobs > 0) resultLog.info("Found {} failed jobs.", failedJobs); else resultLog.debug("Found no failed jobs."); long averageProcessingTime = statistics.getAverageProcessingTime(); if(averageProcessingTime > 0) resultLog.debug("The average processing time is {}.", averageProcessingTime); long averageWaitingTime = statistics.getAverageWaitingTime(); if(averageWaitingTime > 0) resultLog.debug("The average waiting time is [{}.", averageWaitingTime); if(queuedJobs > MAX_JOBS_QUEUED) { resultLog.warn("Found more than {} jobs queued: {}", MAX_JOBS_QUEUED, queuedJobs); } } else { resultLog.info("No Job Manager available"); } return new Result(resultLog); }  @Override Result execute(); }
SlingJobsHealthCheck implements HealthCheck { @Override public Result execute() { FormattingResultLog resultLog = new FormattingResultLog(); if(jobManager != null) { Iterable<Queue> queues = jobManager.getQueues(); if(queues != null) { for (Queue queue : queues) { String name = queue.getName(); String info = queue.getStateInfo(); resultLog.info("The queue {} is currently {}", name, info); } } else { resultLog.info("There are currently no queues available."); } Statistics statistics = jobManager.getStatistics(); long totalJobs = statistics.getNumberOfJobs(); if (totalJobs > 0) resultLog.info("Found {} total jobs.", totalJobs); else resultLog.debug("Found no jobs in the Job Manager."); long queuedJobs = statistics.getNumberOfQueuedJobs(); if(queuedJobs > 0) resultLog.info("Found {} queued jobs.", queuedJobs); else resultLog.debug("Found no queued jobs."); long activeJobs = statistics.getNumberOfActiveJobs(); if(activeJobs > 0) resultLog.info("Found {} active jobs.", activeJobs); else resultLog.debug("Found no active jobs."); long cancelledJobs = statistics.getNumberOfCancelledJobs(); if(cancelledJobs > 0) resultLog.info("Found {} cancelled jobs.", cancelledJobs); else resultLog.debug("Found no cancelled jobs."); long failedJobs = statistics.getNumberOfFailedJobs(); if(failedJobs > 0) resultLog.info("Found {} failed jobs.", failedJobs); else resultLog.debug("Found no failed jobs."); long averageProcessingTime = statistics.getAverageProcessingTime(); if(averageProcessingTime > 0) resultLog.debug("The average processing time is {}.", averageProcessingTime); long averageWaitingTime = statistics.getAverageWaitingTime(); if(averageWaitingTime > 0) resultLog.debug("The average waiting time is [{}.", averageWaitingTime); if(queuedJobs > MAX_JOBS_QUEUED) { resultLog.warn("Found more than {} jobs queued: {}", MAX_JOBS_QUEUED, queuedJobs); } } else { resultLog.info("No Job Manager available"); } return new Result(resultLog); }  @Override Result execute();  }