private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicUtil.class);
private static final String ACTIVE_STATUS = "ACTIVE";
+ private static final String INVALID_STATUS = "INVALID";
+ private static final String INACTIVE_STATUS = "INACTIVE";
+ private static final String INVALID_MESSAGE = "Consistency level is invalid...";
+ private static final String INACTIVE_MESSAGE = "One or more nodes in the Cluster is/are down or not responding.";
+ private static final String ACTIVE_MESSAGE = "Cassandra Running and Listening to requests";
@GET
@Path("/pingCassandra/{consistency}")
@ApiOperation(value = "Get Health Status", response = Map.class)
@Produces(MediaType.APPLICATION_JSON)
- public Response cassandraStatus(@Context HttpServletResponse response, @ApiParam(value = "Consistency level",
- required = true) @PathParam("consistency") String consistency) {
+ public Response cassandraStatus(
+ @Context HttpServletResponse response,
+ @ApiParam(value = "Consistency level",required = true)
+ @PathParam("consistency") String consistency) {
logger.info(EELFLoggerDelegate.applicationLogger,"Replying to request for MUSIC Health Check status for Cassandra");
Map<String, Object> resultMap = new HashMap<>();
if(ConsistencyLevel.valueOf(consistency) == null) {
- resultMap.put("INVALID", "Consistency level is invalid...");
+ resultMap.put("status",INVALID_STATUS);
+ resultMap.put("message", INVALID_MESSAGE);
+ resultMap.put(INVALID_STATUS, INVALID_STATUS);
return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
}
MusicHealthCheck cassHealthCheck = new MusicHealthCheck();
String status = cassHealthCheck.getCassandraStatus(consistency);
if(status.equals(ACTIVE_STATUS)) {
- resultMap.put(ACTIVE_STATUS, "Cassandra Running and Listening to requests");
+ resultMap.put("status",ACTIVE_STATUS);
+ resultMap.put("message", ACTIVE_MESSAGE);
+ resultMap.put(ACTIVE_STATUS, ACTIVE_MESSAGE);
return Response.status(Status.OK).entity(resultMap).build();
} else {
- resultMap.put("INACTIVE", "One or more nodes in the Cluster is/are down or not responding.");
- return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
- }
-
-
-
- }
-
- @GET
- @Path("/pingZookeeper")
- @ApiOperation(value = "Get Health Status", response = Map.class)
- @Produces(MediaType.APPLICATION_JSON)
- public Response ZKStatus(@Context HttpServletResponse response) {
- logger.info(EELFLoggerDelegate.applicationLogger,"Replying to request for MUSIC Health Check status for Zookeeper");
- Map<String, Object> resultMap = new HashMap<>();
- MusicHealthCheck ZKHealthCheck = new MusicHealthCheck();
- String status = ZKHealthCheck.getZookeeperStatus();
- if(status.equals(ACTIVE_STATUS)) {
- resultMap.put(ACTIVE_STATUS, "Zookeeper is Active and Running");
- return Response.status(Status.OK).entity(resultMap).build();
- }else {
- resultMap.put("INACTIVE", "Zookeeper is not responding");
+ resultMap.put("status",INACTIVE_STATUS);
+ resultMap.put("message", INACTIVE_MESSAGE);
+ resultMap.put(INACTIVE_STATUS, INACTIVE_MESSAGE);
return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
}
}
logger.info(EELFLoggerDelegate.applicationLogger,"Replying to request for Health Check status for MUSIC");
Map<String, Object> resultMap = new HashMap<>();
MusicHealthCheck healthCheck = new MusicHealthCheck();
- String status = healthCheck.getZookeeperStatus();
- if(status.equals(ACTIVE_STATUS)) {
- resultMap.put("ZooKeeper", "Active");
- }else {
- resultMap.put("ZooKeeper", "Inactive");
- }
- status = healthCheck.getCassandraStatus(ConsistencyLevel.ANY.toString());
+
+ String status = healthCheck.getCassandraStatus(ConsistencyLevel.ANY.toString());
if(status.equals(ACTIVE_STATUS)) {
resultMap.put("Cassandra", "Active");
} else {