use of com.sequenceiq.cloudbreak.retry.RetryException in project cloudbreak by hortonworks.
the class StartBindUserCreationHandlerTest method testRetryExceptionReceived.
@Test
public void testRetryExceptionReceived() {
StackView stackView = new StackView();
stackView.setId(1L);
when(stackViewService.getById(1L)).thenReturn(stackView);
Event<StartBindUserCreationEvent> event = new Event<>(new StartBindUserCreationEvent(1L));
RetryException retryException = new RetryException();
when(startBindUserCreationService.startBindUserCreation(stackView)).thenThrow(retryException);
StackFailureEvent result = (StackFailureEvent) underTest.doAccept(new HandlerEvent<>(event));
assertEquals(VALIDATE_KERBEROS_CONFIG_FAILED_EVENT.event(), result.selector());
assertEquals(1L, result.getResourceId());
assertEquals(retryException, result.getException());
}
use of com.sequenceiq.cloudbreak.retry.RetryException in project cloudbreak by hortonworks.
the class ApplicationCreator method waitApplicationCreated.
@Retryable(value = RetryException.class, maxAttempts = 10, backoff = @Backoff(delay = 1000, multiplier = 2, maxDelay = 10000))
public void waitApplicationCreated(String accessToken, String tenantId, String objectId) {
LOGGER.info("Checking the existence of the application: '{}'", objectId);
Client client = ClientBuilder.newClient();
WebTarget resource = client.target(GRAPH_WINDOWS + tenantId);
Builder request = resource.path("/applications/" + objectId).queryParam("api-version", GRAPH_API_VERSION).request();
request.accept(MediaType.APPLICATION_JSON);
request.header("Authorization", "Bearer " + accessToken);
try (Response response = request.get()) {
if (response.getStatus() != HttpStatus.SC_OK) {
throw new RetryException("App with objectId (" + objectId + ") hasn't been created yet");
}
}
}
use of com.sequenceiq.cloudbreak.retry.RetryException in project cloudbreak by hortonworks.
the class PrincipalCreator method checkTheExistenceOnGraph.
private void checkTheExistenceOnGraph(String accessToken, String objectId, String tenantId, Client client) {
WebTarget resource = client.target(GRAPH_WINDOWS + tenantId);
Builder request = resource.path("servicePrincipals/" + objectId).queryParam("api-version", GRAPH_API_VERSION).request();
request.accept(MediaType.APPLICATION_JSON);
request.header("Authorization", "Bearer " + accessToken);
try (Response response = request.get()) {
if (response.getStatus() != HttpStatus.SC_OK) {
throw new RetryException("Principal with objectId (" + objectId + ") hasn't been created yet");
}
}
}
use of com.sequenceiq.cloudbreak.retry.RetryException in project cloudbreak by hortonworks.
the class PrincipalCreator method checkTheAvailabilityWithResourceLogin.
private void checkTheAvailabilityWithResourceLogin(String objectId, String tenantId, AzureApplication app, Client client) {
WebTarget loginResource = client.target(LOGIN_MICROSOFTONLINE + tenantId);
Map<String, String> formData = new HashMap<>();
formData.put("grant_type", "client_credentials");
formData.put("client_id", app.getAppId());
formData.put("client_secret", app.getAzureApplicationCreationView().getAppSecret());
formData.put("resource", app.getAzureApplicationCreationView().getAppIdentifierURI());
try (Response loginResponse = loginResource.path("/oauth2/token").request().accept(MediaType.APPLICATION_JSON).header("Content-Type", "application/x-www-form-urlencoded").post(Entity.form(new MultivaluedHashMap<>(formData)))) {
if (loginResponse.getStatus() != HttpStatus.SC_OK) {
throw new RetryException("Principal with objectId (" + objectId + ") hasn't been available yet");
}
}
}
Aggregations