blob: a0d5c0ca7258b30b587c649882ce6ba41e786460 [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001package net.floodlightcontroller.core.web;
2
3import org.restlet.resource.Get;
4import org.restlet.resource.ServerResource;
5
6public class HealthCheckResource extends ServerResource {
Ray Milkey269ffb92014-04-03 14:43:30 -07007
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08008 public static class HealthCheckInfo {
Ray Milkey269ffb92014-04-03 14:43:30 -07009
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080010 protected boolean healthy;
Ray Milkey269ffb92014-04-03 14:43:30 -070011
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080012 public HealthCheckInfo() {
13 this.healthy = true;
14 }
Ray Milkey269ffb92014-04-03 14:43:30 -070015
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080016 public boolean isHealthy() {
17 return healthy;
18 }
Ray Milkey269ffb92014-04-03 14:43:30 -070019
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080020 public void setHealthy(boolean healthy) {
21 this.healthy = healthy;
22 }
23 }
Ray Milkey269ffb92014-04-03 14:43:30 -070024
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080025 @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}