-
Notifications
You must be signed in to change notification settings - Fork 416
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
51 additions
and
13 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
core/src/main/java/org/mapfish/print/metrics/ApplicationStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.mapfish.print.metrics; | ||
|
||
import com.codahale.metrics.health.HealthCheck; | ||
import org.mapfish.print.servlet.job.JobQueue; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
class ApplicationStatus extends HealthCheck { | ||
public static final int MAX_WAITING_JOBS_TILL_UNHEALTHY = 5; | ||
@Autowired private JobQueue jobQueue; | ||
|
||
@Override | ||
protected Result check() throws Exception { | ||
long waitingJobsCount = jobQueue.getWaitingJobsCount(); | ||
String health = "Number of jobs waiting is " + waitingJobsCount; | ||
|
||
if (waitingJobsCount >= MAX_WAITING_JOBS_TILL_UNHEALTHY) { | ||
return Result.unhealthy(health + ". It is too high."); | ||
} else { | ||
return Result.healthy(health); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
core/src/main/java/org/mapfish/print/metrics/HealthCheckRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.mapfish.print.metrics; | ||
|
||
import javax.annotation.PostConstruct; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
public class HealthCheckRegistry extends com.codahale.metrics.health.HealthCheckRegistry { | ||
@Autowired private ApplicationStatus applicationStatus; | ||
|
||
@PostConstruct | ||
public void registerHealthCheck() { | ||
register("application", applicationStatus); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters