use of com.sequenceiq.cloudbreak.client.RPCResponse in project cloudbreak by hortonworks.
the class UserSyncOperationsTest method testDisableUsersSingle.
@Test
public void testDisableUsersSingle() throws FreeIpaClientException, TimeoutException {
Multimap<String, String> warnings = ArrayListMultimap.create();
Set<String> users = Set.of("user1", "user2");
ArgumentCaptor<List<Object>> flagsCaptor = ArgumentCaptor.forClass(List.class);
ArgumentCaptor<Map<String, Object>> paramsCaptor = ArgumentCaptor.forClass(Map.class);
RPCResponse<Object> response1 = new RPCResponse<>();
response1.setResult(new User());
RPCResponse<Object> response2 = new RPCResponse<>();
response2.setResult(new User());
when(freeIpaClient.invoke(eq("user_disable"), flagsCaptor.capture(), paramsCaptor.capture(), eq(Object.class))).thenReturn(response1, response2);
underTest.disableUsers(false, freeIpaClient, users, warnings::put);
assertTrue(warnings.isEmpty());
verifyNoInteractions(batchPartitionSizeProperties);
verify(freeIpaClient, never()).callBatch(any(), any(), any(), any(), any());
List<List<Object>> flagsList = flagsCaptor.getAllValues();
assertThat(flagsList, allOf(hasItem(hasItem("user1")), hasItem(hasItem("user2"))));
List<Map<String, Object>> paramsList = paramsCaptor.getAllValues();
assertThat(paramsList, everyItem(aMapWithSize(0)));
verify(interruptChecker, times(4)).throwTimeoutExIfInterrupted();
}
use of com.sequenceiq.cloudbreak.client.RPCResponse 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;
}
use of com.sequenceiq.cloudbreak.client.RPCResponse in project cloudbreak by hortonworks.
the class CdpNodeStatusMonitorClient method invoke.
private <T> RPCResponse<T> invoke(String name, String path, Function<String, T> buildProtoFunction, boolean acceptNotFound, boolean skipObjectMapping) throws CdpNodeStatusMonitorClientException {
Builder builder = rpcTarget.path(path).request().headers(headers);
try (Response response = builder.get()) {
bufferResponseEntity(response);
processRpcListener(response);
checkResponseStatus(response);
return toRpcResponse(name, response, buildProtoFunction, skipObjectMapping);
} catch (CdpNodeStatusMonitorClientException e) {
if (acceptNotFound) {
LOGGER.debug("Get 404 from node status response for {}, but it is accepted as an empty response.", path);
return null;
} else {
throw e;
}
} catch (Throwable throwable) {
String message = String.format("Invoke node status check failed: %s", throwable.getLocalizedMessage());
LOGGER.warn(message);
throw new CdpNodeStatusMonitorClientException(message, throwable);
}
}
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, 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;
}
use of com.sequenceiq.cloudbreak.client.RPCResponse in project cloudbreak by hortonworks.
the class WorkloadCredentialServiceTest method getRpcResponse.
private RPCResponse<Object> getRpcResponse() {
RPCResponse<Object> response = new RPCResponse<>();
response.setResult(new User());
return response;
}
Aggregations