2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package org.openecomp.mso.apihandlerinfra;
\r
23 import javax.ws.rs.GET;
\r
24 import javax.ws.rs.HEAD;
\r
25 import javax.ws.rs.Path;
\r
26 import javax.ws.rs.Produces;
\r
27 import javax.ws.rs.core.Response;
\r
29 import org.openecomp.mso.HealthCheckUtils;
\r
30 import org.openecomp.mso.logger.MsoLogger;
\r
31 import org.openecomp.mso.utils.UUIDChecker;
\r
33 import com.wordnik.swagger.annotations.Api;
\r
34 import com.wordnik.swagger.annotations.ApiOperation;
\r
36 @Path("/nodehealthcheck")
\r
37 @Api(value="/nodehealthcheck",description="API Handler Infra Node Health Check")
\r
38 public class NodeHealthcheckHandler {
\r
40 private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
\r
44 @Produces("text/html")
\r
45 @ApiOperation(value="Performing node health check",response=Response.class)
\r
46 public Response nodeHealthcheck () {
\r
47 long startTime = System.currentTimeMillis ();
\r
48 MsoLogger.setServiceName ("NodeHealthcheck");
\r
49 // Generate a Request Id
\r
50 String requestId = UUIDChecker.generateUUID(msoLogger);
\r
51 HealthCheckUtils healthCheck = new HealthCheckUtils ();
\r
52 if (!healthCheck.siteStatusCheck (msoLogger)) {
\r
53 return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE;
\r
56 if (healthCheck.verifyNodeHealthCheck(HealthCheckUtils.NodeType.APIH, requestId)) {
\r
57 msoLogger.debug("nodeHealthcheck - Successful");
\r
58 return HealthCheckUtils.HEALTH_CHECK_RESPONSE;
\r
60 msoLogger.debug("nodeHealthcheck - At leaset one of the sub-modules is not available.");
\r
61 return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE;
\r