use of com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyError in project cloudbreak by hortonworks.
the class ClusterProxyErrorRpcListener method deserializeAsClusterProxyError.
private Optional<ClusterProxyError> deserializeAsClusterProxyError(ObjectNode objectNode) {
ObjectMapper mapper = new ObjectMapper();
ClusterProxyError clusterProxyError;
try {
clusterProxyError = mapper.treeToValue(objectNode, ClusterProxyError.class);
if (!clusterProxyError.getCode().contains("cluster-proxy")) {
return Optional.empty();
}
} catch (Exception ex) {
return Optional.empty();
}
return Optional.of(clusterProxyError);
}
use of com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyError in project cloudbreak by hortonworks.
the class FreeIpaHealthCheckClusterProxyErrorRpcListenerTest method testClusterProxyNotAClusterProxyError.
@Test
public void testClusterProxyNotAClusterProxyError() throws IOException {
ClusterProxyError clusterProxyError = new ClusterProxyError("status", "error from something other than cluster proxy", "message", true);
Response response = mock(Response.class);
when(response.readEntity(any(Class.class))).thenReturn(clusterProxyError);
assertDoesNotThrow(() -> {
clusterProxyErrorRpcListener.onBeforeResponseProcessed(response);
});
}
use of com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyError in project cloudbreak by hortonworks.
the class JaxRSUtil method handleUnexpectedError.
private static WebApplicationException handleUnexpectedError(Response response) {
String textResponse = response.readEntity(String.class);
LOGGER.debug("Received error: {}", textResponse);
String errorMessage = transformErrorMessage(textResponse);
String errormsg = "Status: " + response.getStatusInfo().getStatusCode() + ' ' + response.getStatusInfo().getReasonPhrase() + " Response: " + errorMessage;
try {
if (JsonUtil.isValid(errorMessage)) {
ClusterProxyError clusterProxyError = JsonUtil.jsonToType(errorMessage, ClusterProxyErrorTypeReference.get());
if (clusterProxyError.getRetryable()) {
return new ClusterProxyWebApplicationException(errormsg, clusterProxyError);
}
}
} catch (IllegalArgumentException e) {
LOGGER.trace("Error message is not a json or not a cluster proxy error, thus we cannot parse it.", e);
}
return new WebApplicationException(errormsg);
}
use of com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyError in project cloudbreak by hortonworks.
the class FreeIpaHealthCheckClusterProxyErrorRpcListenerTest method testClusterProxyError.
@Test
public void testClusterProxyError() throws IOException {
ClusterProxyError clusterProxyError = new ClusterProxyError("status", "cluster-proxy.proxy.timeout", "message", true);
Response response = mock(Response.class);
when(response.readEntity(any(Class.class))).thenReturn(clusterProxyError);
assertThrows(ClusterProxyException.class, () -> {
clusterProxyErrorRpcListener.onBeforeResponseProcessed(response);
});
}
Aggregations