Search in sources :

Example 1 with HealthRestRep

use of com.emc.vipr.model.sys.healthmonitor.HealthRestRep in project coprhd-controller by CoprHD.

the class HealthMonitorService method getHealth.

/**
 * Gets health of node and its services.
 * <p/>
 * Node health status: Good - when node is reachable and all its services are GOOD Unavailable - when node is not reachable Degraded -
 * when node is reachable and any of its service is Unavailable/Degraded Node/syssvc Unavailable - when node is down or syssvc is not
 * Unavailable on the node
 * <p/>
 * Service health status: Good - when a service is up and running Unavailable - when a service is not running but is registered in
 * coordinator Restarted - when service is restarting
 *
 * @brief Show service health of all virtual machines
 * @param nodeIds node ids for which health stats are collected.
 * @param nodeNames node names for which health stats are collected.
 * @prereq none
 * @return Health response.
 */
@GET
@Path("/health")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR, Role.SECURITY_ADMIN })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public HealthRestRep getHealth(@QueryParam("node_id") List<String> nodeIds, @QueryParam("node_name") List<String> nodeNames) {
    HealthRestRep healthRestRep = new HealthRestRep();
    List<NodeHealth> nodehealthList = healthRestRep.getNodeHealthList();
    nodeIds = _coordinatorClientExt.combineNodeNamesWithNodeIds(nodeNames, nodeIds);
    // Collecting data from all nodes
    List<NodeInfo> nodeInfoList = ClusterNodesUtil.getClusterNodeInfo(nodeIds);
    Map<String, NodeHealth> nodesData = NodeDataCollector.getDataFromNodes(nodeInfoList, INTERNAL_NODE_HEALTH_URI, Action.GET, null, NodeHealth.class, null);
    nodehealthList.addAll(nodesData.values());
    String thisNodeId = _coordinatorClientExt.getMyNodeId();
    if (thisNodeId.equals("standalone")) {
        return healthRestRep;
    }
    Map<String, DualInetAddress> ipLookupTable = _coordinatorClientExt.getCoordinatorClient().getInetAddessLookupMap().getControllerNodeIPLookupMap();
    // get all nodes if the input param is empty
    if (nodeIds == null || nodeIds.isEmpty()) {
        int clusterNodeCount = _coordinatorClientExt.getNodeCount();
        nodeIds = new ArrayList<>();
        for (int i = 1; i <= clusterNodeCount; i++) {
            String nodeId = "vipr" + i;
            nodeIds.add(nodeId);
        }
    }
    // Adding health for nodes that are not returned
    for (String nodeId : nodeIds) {
        DualInetAddress ip = ipLookupTable.get(nodeId);
        if (!nodesData.containsKey(nodeId)) {
            String nodeName = _coordinatorClientExt.getPropertyInfo().getProperty("node_" + nodeId.replace("vipr", "") + "_name");
            nodehealthList.add(new NodeHealth(nodeId, nodeName, ip.toString(), Status.NODE_OR_SYSSVC_UNAVAILABLE.toString()));
        }
    }
    return healthRestRep;
}
Also used : NodeInfo(com.emc.storageos.systemservices.impl.resource.util.NodeInfo) HealthRestRep(com.emc.vipr.model.sys.healthmonitor.HealthRestRep) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress) NodeHealth(com.emc.vipr.model.sys.healthmonitor.NodeHealth) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

DualInetAddress (com.emc.storageos.coordinator.client.service.impl.DualInetAddress)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 NodeInfo (com.emc.storageos.systemservices.impl.resource.util.NodeInfo)1 HealthRestRep (com.emc.vipr.model.sys.healthmonitor.HealthRestRep)1 NodeHealth (com.emc.vipr.model.sys.healthmonitor.NodeHealth)1