Search in sources :

Example 16 with RPCMessage

use of com.sequenceiq.cloudbreak.client.RPCMessage in project cloudbreak by hortonworks.

the class FreeIpaInstanceHealthDetailsService method createRpcMessageFromCheckResult.

private RPCMessage createRpcMessageFromCheckResult(RPCResponse<CheckResult> nodeHealth) {
    List<CheckEntry> checkEntries = filterCheckEntries(nodeHealth);
    List<PluginStatusEntry> pluginStatusEntries = filterPluginStatusEntries(nodeHealth);
    CheckResult filteredCheckResult = new CheckResult();
    filteredCheckResult.setChecks(checkEntries);
    filteredCheckResult.setPluginStats(pluginStatusEntries);
    if (nodeHealth.getResult() != null) {
        filteredCheckResult.setStatus(nodeHealth.getResult().getStatus());
        filteredCheckResult.setHost(nodeHealth.getResult().getHost());
    }
    RPCMessage rpcMessage = new RPCMessage();
    rpcMessage.setName("node health check");
    rpcMessage.setMessage(JsonUtil.writeValueAsStringSilent(filteredCheckResult));
    if (nodeHealth.getFirstRpcMessage() != null) {
        rpcMessage.setCode(nodeHealth.getFirstRpcMessage().getCode());
    }
    return rpcMessage;
}
Also used : CheckEntry(com.sequenceiq.freeipa.client.healthcheckmodel.CheckEntry) PluginStatusEntry(com.sequenceiq.freeipa.client.healthcheckmodel.PluginStatusEntry) CheckResult(com.sequenceiq.freeipa.client.healthcheckmodel.CheckResult) RPCMessage(com.sequenceiq.cloudbreak.client.RPCMessage)

Example 17 with RPCMessage

use of com.sequenceiq.cloudbreak.client.RPCMessage in project cloudbreak by hortonworks.

the class FreeIpaInstanceHealthDetailsService method legacyParseMessages.

private NodeHealthDetails legacyParseMessages(RPCResponse<Boolean> rpcResponse, InstanceMetaData instanceMetaData) {
    String precedingMessage = MESSAGE_UNAVAILABLE;
    NodeHealthDetails nodeResponse = new NodeHealthDetails();
    nodeResponse.setStatus(rpcResponse.getResult() ? InstanceStatus.CREATED : InstanceStatus.UNHEALTHY);
    nodeResponse.setName(instanceMetaData.getDiscoveryFQDN());
    nodeResponse.setInstanceId(instanceMetaData.getInstanceId());
    boolean found = false;
    for (RPCMessage message : rpcResponse.getMessages()) {
        Matcher nodeMatcher = NEW_NODE_PATTERN.matcher(message.getMessage());
        if (nodeMatcher.find()) {
            found = true;
        }
        if (!found) {
            LOGGER.info("No node for message: {}" + message.getMessage());
        } else {
            // appears in the preceding message.
            if (EXTERNAL_COMMAND_OUTPUT.equals(message.getName())) {
                Matcher matcher = RESULT_PATTERN.matcher(message.getMessage());
                if (matcher.find()) {
                    if (!STATUS_OK.equals(matcher.group(STATUS_GROUP))) {
                        nodeResponse.addIssue(precedingMessage);
                    }
                }
                precedingMessage = message.getMessage();
            }
        }
    }
    return nodeResponse;
}
Also used : Matcher(java.util.regex.Matcher) RPCMessage(com.sequenceiq.cloudbreak.client.RPCMessage) NodeHealthDetails(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.health.NodeHealthDetails)

Example 18 with RPCMessage

use of com.sequenceiq.cloudbreak.client.RPCMessage in project cloudbreak by hortonworks.

the class CdpNodeStatusMonitorClient method toRpcResponse.

private <T> RPCResponse<T> toRpcResponse(String name, Response response, Function<String, T> builderFunc) {
    RPCResponse<T> rpcResponse = new RPCResponse<>();
    String message = response.readEntity(String.class);
    rpcResponse.setResult(builderFunc.apply(message));
    RPCMessage rpcMessage = new RPCMessage();
    rpcMessage.setName(name);
    rpcMessage.setCode(response.getStatus());
    rpcMessage.setMessage(message);
    rpcResponse.setSummary(name);
    rpcResponse.setMessages(List.of(rpcMessage));
    rpcResponse.setCount(1);
    rpcResponse.setTruncated(Boolean.FALSE);
    return rpcResponse;
}
Also used : RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) RPCMessage(com.sequenceiq.cloudbreak.client.RPCMessage)

Aggregations

RPCMessage (com.sequenceiq.cloudbreak.client.RPCMessage)18 RPCResponse (com.sequenceiq.cloudbreak.client.RPCResponse)8 CheckResult (com.sequenceiq.freeipa.client.healthcheckmodel.CheckResult)4 Test (org.junit.jupiter.api.Test)4 NodeStatusReport (com.cloudera.thunderhead.telemetry.nodestatus.NodeStatusProto.NodeStatusReport)2 SaltHealthReport (com.cloudera.thunderhead.telemetry.nodestatus.NodeStatusProto.SaltHealthReport)2 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)2 NodeHealthDetails (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.health.NodeHealthDetails)2 CheckEntry (com.sequenceiq.freeipa.client.healthcheckmodel.CheckEntry)2 PluginStatusEntry (com.sequenceiq.freeipa.client.healthcheckmodel.PluginStatusEntry)2 Node (com.sequenceiq.cloudbreak.common.orchestration.Node)1 NodesUnreachableException (com.sequenceiq.cloudbreak.util.NodesUnreachableException)1 Matcher (java.util.regex.Matcher)1