Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 1 | package net.floodlightcontroller.core.web; |
| 2 | |
| 3 | import org.restlet.resource.Get; |
| 4 | import org.restlet.resource.ServerResource; |
| 5 | |
| 6 | public class HealthCheckResource extends ServerResource { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 7 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 8 | public static class HealthCheckInfo { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 9 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 10 | protected boolean healthy; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 11 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 12 | public HealthCheckInfo() { |
| 13 | this.healthy = true; |
| 14 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 15 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 16 | public boolean isHealthy() { |
| 17 | return healthy; |
| 18 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 19 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 20 | public void setHealthy(boolean healthy) { |
| 21 | this.healthy = healthy; |
| 22 | } |
| 23 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 24 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 25 | @Get("json") |
| 26 | public HealthCheckInfo healthCheck() { |
| 27 | // Currently this is the simplest possible health check -- basically |
| 28 | // just that the controller is still running and able to respond to |
| 29 | // REST calls. |
| 30 | // Eventually this should be more sophisticated and do things |
| 31 | // like monitoring internal data structures of the controller |
| 32 | // (e.g. async storage queue length). |
| 33 | return new HealthCheckInfo(); |
| 34 | } |
| 35 | |
| 36 | } |