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;
}
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;
}
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;
}
Aggregations