use of com.emc.storageos.systemservices.impl.resource.util.NodeInfo in project coprhd-controller by CoprHD.
the class LogNetworkStreamMerger method getLogNetworkStreams.
private List<LogNetworkReader> getLogNetworkStreams() {
List<NodeInfo> nodeInfo;
List<LogNetworkReader> logNetworkStreams = new ArrayList<>();
// Getting all nodes information
if (request.getNodeIds().isEmpty()) {
logger.info("No nodes specified, getting all nodes");
nodeInfo = ClusterNodesUtil.getClusterNodeInfo();
} else {
nodeInfo = getClusterNodesWithIds(request.getNodeIds());
}
if (nodeInfo.isEmpty()) {
throw APIException.internalServerErrors.noNodeAvailableError("collect logs info");
}
List<String> failedNodes = ClusterNodesUtil.getUnavailableControllerNodes();
if (!request.getNodeIds().isEmpty()) {
failedNodes.retainAll(request.getNodeIds());
}
if (!failedNodes.isEmpty()) {
logger.error("Cannot collect logs from unavailable nodes: {}", failedNodes.toString());
}
for (final NodeInfo node : nodeInfo) {
LogRequest req;
SysClientFactory.SysClient sysClient;
String baseNodeURL = String.format(SysClientFactory.BASE_URL_FORMAT, node.getIpAddress(), node.getPort());
logger.debug("getting stream from node: " + baseNodeURL);
logger.debug("connectTimeout=" + propertiesLoader.getNodeLogConnectionTimeout() * 1000);
logger.debug("readTimeout=" + propertiesLoader.getNodeLogCollectorTimeout() * 1000);
sysClient = SysClientFactory.getSysClient(URI.create(baseNodeURL), propertiesLoader.getNodeLogCollectorTimeout() * 1000, propertiesLoader.getNodeLogConnectionTimeout() * 1000);
logger.debug("sysclient=" + sysClient + " uri=" + URI.create(baseNodeURL));
try {
req = request;
req.setNodeIds(new ArrayList<String>() {
{
add(node.getId());
}
});
InputStream nodeResponseStream = sysClient.post(SysClientFactory.URI_NODE_LOGS, InputStream.class, req);
if (nodeResponseStream != null && nodeResponseStream.available() > 0) {
LogNetworkReader reader = new LogNetworkReader(node.getId(), node.getName(), nodeResponseStream, status);
logNetworkStreams.add(reader);
}
} catch (Exception e) {
logger.error("Exception accessing node {}:", baseNodeURL, e);
// socketTimeoutException wrapped in ClientHandlerException
if (e.getCause() != null && e.getCause().getCause() instanceof SocketTimeoutException) {
throw InternalServerErrorException.internalServerErrors.logCollectionTimeout();
}
}
}
return logNetworkStreams;
}
use of com.emc.storageos.systemservices.impl.resource.util.NodeInfo in project coprhd-controller by CoprHD.
the class NodeInfoTest method getPort.
/**
* Tests the getPort method.
*/
@Test
public void getPort() {
boolean wasException = false;
try {
NodeInfo nodeInfo = new NodeInfo(TEST_ID, TEST_NAME, TEST_ENDPOIT);
Assert.assertEquals(nodeInfo.getPort(), Integer.parseInt(TEST_PORT));
} catch (Exception e) {
wasException = true;
}
Assert.assertFalse(wasException);
}
use of com.emc.storageos.systemservices.impl.resource.util.NodeInfo in project coprhd-controller by CoprHD.
the class NodeInfoTest method testGetId.
/**
* Tests the getId method.
*/
@Test
public void testGetId() {
boolean wasException = false;
try {
NodeInfo nodeInfo = new NodeInfo(TEST_ID, TEST_NAME, TEST_ENDPOIT);
Assert.assertEquals(nodeInfo.getId(), TEST_ID);
} catch (Exception e) {
wasException = true;
}
Assert.assertFalse(wasException);
}
use of com.emc.storageos.systemservices.impl.resource.util.NodeInfo in project coprhd-controller by CoprHD.
the class HealthMonitorService method getDiagnostics.
/**
* Get results of diagtool shell script for all virtual machines in a ViPR
* controller appliance. Also gives test details when verbose option
* is set.
*
* @brief Get diagtool script results
* @param nodeIds node ids for which diagnostic results are collected.
* @param nodeNames node names for which diagnostic results are collected.
* @param verbose when set to "1" will run command with -v option.
* @prereq none
* @return Returns diagnostic test results.
*/
@GET
@Path("/diagnostics")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public DiagnosticsRestRep getDiagnostics(@QueryParam("node_id") List<String> nodeIds, @QueryParam("verbose") String verbose, @QueryParam("node_name") List<String> nodeNames) {
_log.info("Initiating diagnostics test for nodes");
nodeIds = _coordinatorClientExt.combineNodeNamesWithNodeIds(nodeNames, nodeIds);
boolean isVerbose = ("1".equals(verbose)) ? true : false;
DiagRequestParams diagRequestParams = new DiagRequestParams(isVerbose);
DiagnosticsRestRep diagnosticsRestRep = new DiagnosticsRestRep();
List<NodeInfo> nodeInfoList = ClusterNodesUtil.getClusterNodeInfo(nodeIds);
Map<String, NodeDiagnostics> nodesData = NodeDataCollector.getDataFromNodes(nodeInfoList, INTERNAL_NODE_DIAGNOSTICS_URI, Action.POST, diagRequestParams, NodeDiagnostics.class, null);
String allocationResult = _checker.getNodeResourceAllocationCheckResult();
DiagTest allocationTest = new DiagTest("Resource allocation", allocationResult, new ArrayList<TestParam>());
for (Map.Entry<String, NodeDiagnostics> entry : nodesData.entrySet()) {
List<DiagTest> diagTests = entry.getValue().getDiagTests();
diagTests.add(allocationTest);
entry.getValue().setDiagTests(diagTests);
}
diagnosticsRestRep.getNodeDiagnosticsList().addAll(nodesData.values());
return diagnosticsRestRep;
}
use of com.emc.storageos.systemservices.impl.resource.util.NodeInfo 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;
}
Aggregations