use of com.sequenceiq.cloudbreak.client.RPCResponse in project cloudbreak by hortonworks.
the class UserRemoveOperationTest method testInvoke.
@Test
public void testInvoke() throws FreeIpaClientException {
RPCResponse<Object> rpcResponse = new RPCResponse<>();
rpcResponse.setResult(new User());
when(freeIpaClient.invoke(any(), anyList(), any(), any())).thenReturn(rpcResponse);
UserRemoveOperation.create(USER_NAME).invoke(freeIpaClient);
verify(freeIpaClient).invoke(eq("user_del"), anyList(), any(), any());
}
use of com.sequenceiq.cloudbreak.client.RPCResponse in project cloudbreak by hortonworks.
the class FreeipaChecker method checkStatus.
private Pair<Map<InstanceMetaData, DetailedStackStatus>, String> checkStatus(Stack stack, Set<InstanceMetaData> checkableInstances) throws Exception {
return checkedMeasure(() -> {
Map<InstanceMetaData, DetailedStackStatus> statuses = new HashMap<>();
List<RPCResponse<Boolean>> responses = new LinkedList<>();
LOGGER.info("Checking FreeIPA status for instance IDs {}", checkableInstances.stream().map(InstanceMetaData::getInstanceId).collect(Collectors.toList()));
for (InstanceMetaData instanceMetaData : checkableInstances) {
try {
RPCResponse<Boolean> response = checkedMeasure(() -> freeIpaInstanceHealthDetailsService.checkFreeIpaHealth(stack, instanceMetaData), LOGGER, ":::Auto sync::: FreeIPA health check ran in {}ms");
responses.add(response);
DetailedStackStatus newDetailedStackStatus;
if (response.getResult()) {
newDetailedStackStatus = DetailedStackStatus.AVAILABLE;
} else {
newDetailedStackStatus = DetailedStackStatus.UNHEALTHY;
}
LOGGER.info("FreeIpa health check reported {} for {}", newDetailedStackStatus, instanceMetaData);
statuses.put(instanceMetaData, newDetailedStackStatus);
} catch (Exception e) {
LOGGER.info("FreeIpaClientException occurred during status fetch for {}: {}", instanceMetaData, e.getMessage(), e);
statuses.put(instanceMetaData, DetailedStackStatus.UNREACHABLE);
}
}
String message = getMessages(responses);
return Pair.of(statuses, message);
}, LOGGER, ":::Auto sync::: freeipa server status is checked in {}ms");
}
use of com.sequenceiq.cloudbreak.client.RPCResponse 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