Search in sources :

Example 6 with RPCMessage

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

the class FreeIpaInstanceHealthDetailsServiceTest method getGoodPayload.

private RPCResponse<CheckResult> getGoodPayload(String host) {
    CheckResult checkResult = new CheckResult();
    checkResult.setHost(host);
    RPCResponse<CheckResult> goodResponse;
    goodResponse = new RPCResponse<>();
    goodResponse.setResult(checkResult);
    RPCMessage message = new RPCMessage();
    message.setCode(200);
    message.setMessage("success");
    goodResponse.setMessages(List.of(message));
    return goodResponse;
}
Also used : CheckResult(com.sequenceiq.freeipa.client.healthcheckmodel.CheckResult) RPCMessage(com.sequenceiq.cloudbreak.client.RPCMessage)

Example 7 with RPCMessage

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

the class FreeIpaInstanceHealthDetailsService method parseMessages.

private NodeHealthDetails parseMessages(RPCResponse<CheckResult> rpcResponse, InstanceMetaData instanceMetaData) {
    NodeHealthDetails nodeResponse = new NodeHealthDetails();
    nodeResponse.setName(instanceMetaData.getDiscoveryFQDN());
    nodeResponse.setInstanceId(instanceMetaData.getInstanceId());
    if (isHealthCheckPassing(rpcResponse)) {
        nodeResponse.setStatus(HEALTHY_INSTANCE_STATUS);
    } else {
        nodeResponse.setStatus(InstanceStatus.UNHEALTHY);
        nodeResponse.setIssues(rpcResponse.getMessages().stream().map(RPCMessage::getMessage).collect(Collectors.toList()));
    }
    return nodeResponse;
}
Also used : RPCMessage(com.sequenceiq.cloudbreak.client.RPCMessage) NodeHealthDetails(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.health.NodeHealthDetails)

Example 8 with RPCMessage

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

the class FreeIpaInstanceHealthDetailsService method toBooleanRpcResponse.

private RPCResponse<Boolean> toBooleanRpcResponse(RPCResponse<CheckResult> nodeHealth) {
    RPCMessage rpcMessage = createRpcMessageFromCheckResult(nodeHealth);
    RPCResponse<Boolean> response = new RPCResponse<>();
    response.setSummary(nodeHealth.getSummary());
    response.setResult(isHealthCheckPassing(nodeHealth));
    response.setCount(nodeHealth.getCount());
    response.setTruncated(nodeHealth.getTruncated());
    response.setMessages(List.of(rpcMessage));
    response.setCompleted(nodeHealth.getCompleted());
    response.setFailed(nodeHealth.getFailed());
    response.setValue(nodeHealth.getValue());
    return response;
}
Also used : RPCMessage(com.sequenceiq.cloudbreak.client.RPCMessage) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse)

Example 9 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, boolean skipObjectMapping) {
    RPCResponse<T> rpcResponse = new RPCResponse<>();
    String message = response.readEntity(String.class);
    if (!skipObjectMapping) {
        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)

Example 10 with RPCMessage

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

the class NodeServicesCheckerConclusionStepTest method checkShouldBeSuccessfulIfNodeStatusReportIsNullForOlderImageVersions.

@Test
public void checkShouldBeSuccessfulIfNodeStatusReportIsNullForOlderImageVersions() {
    RPCResponse<NodeStatusReport> response = new RPCResponse<>();
    RPCMessage message = new RPCMessage();
    message.setMessage("rpc response");
    response.setMessages(List.of(message));
    when(nodeStatusService.getServicesReport(eq(1L))).thenReturn(response);
    Conclusion stepResult = underTest.check(1L);
    assertFalse(stepResult.isFailureFound());
    assertNull(stepResult.getConclusion());
    assertNull(stepResult.getDetails());
    assertEquals(NodeServicesCheckerConclusionStep.class, stepResult.getConclusionStepClass());
    verify(nodeStatusService, times(1)).getServicesReport(eq(1L));
}
Also used : NodeStatusReport(com.cloudera.thunderhead.telemetry.nodestatus.NodeStatusProto.NodeStatusReport) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) RPCMessage(com.sequenceiq.cloudbreak.client.RPCMessage) Test(org.junit.jupiter.api.Test)

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