use of com.sequenceiq.datalake.flow.delete.event.StackDeletionWaitRequest in project cloudbreak by hortonworks.
the class StackDeletionHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<StackDeletionWaitRequest> event) {
StackDeletionWaitRequest stackDeletionWaitRequest = event.getData();
Long sdxId = stackDeletionWaitRequest.getResourceId();
String userId = stackDeletionWaitRequest.getUserId();
Selectable response;
try {
LOGGER.debug("Start polling stack deletion process for id: {}", sdxId);
PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
provisionerService.waitCloudbreakClusterDeletion(sdxId, pollingConfig);
response = new StackDeletionSuccessEvent(sdxId, userId, stackDeletionWaitRequest.isForced());
} catch (UserBreakException userBreakException) {
LOGGER.error("Deletion polling exited before timeout. Cause: ", userBreakException);
response = new SdxDeletionFailedEvent(sdxId, userId, userBreakException, stackDeletionWaitRequest.isForced());
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Deletion poller stopped for stack: {}", sdxId);
response = new SdxDeletionFailedEvent(sdxId, userId, new PollerStoppedException("Datalake stack deletion timed out after " + durationInMinutes + " minutes"), stackDeletionWaitRequest.isForced());
} catch (PollerException exception) {
LOGGER.error("Deletion polling failed for stack: {}", sdxId);
response = new SdxDeletionFailedEvent(sdxId, userId, exception, stackDeletionWaitRequest.isForced());
}
return response;
}
use of com.sequenceiq.datalake.flow.delete.event.StackDeletionWaitRequest in project cloudbreak by hortonworks.
the class StackDeletionHandlerTest method acceptTestStackDeletionFailed.
@Test
void acceptTestStackDeletionFailed() {
long id = 2L;
StackDeletionWaitRequest stackCreationWaitRequest = new StackDeletionWaitRequest(id, userId, true);
Event receivedEvent = new Event<>(stackCreationWaitRequest);
doThrow(new UserBreakException("stack deletion failed")).when(provisionerService).waitCloudbreakClusterDeletion(eq(id), any(PollingConfig.class));
stackDeletionHandler.accept(receivedEvent);
verify(provisionerService, times(1)).waitCloudbreakClusterDeletion(eq(id), any(PollingConfig.class));
final ArgumentCaptor<String> eventSelector = ArgumentCaptor.forClass(String.class);
final ArgumentCaptor<Event> sentEvent = ArgumentCaptor.forClass(Event.class);
verify(eventBus, times(1)).notify(eventSelector.capture(), sentEvent.capture());
String eventNotified = eventSelector.getValue();
Event event = sentEvent.getValue();
Assertions.assertEquals("SdxDeletionFailedEvent", eventNotified);
Assertions.assertEquals(SdxDeletionFailedEvent.class, event.getData().getClass());
Assertions.assertEquals(id, ((SdxDeletionFailedEvent) event.getData()).getResourceId());
}
use of com.sequenceiq.datalake.flow.delete.event.StackDeletionWaitRequest in project cloudbreak by hortonworks.
the class StackDeletionHandlerTest method acceptTestPollerStackTimeout.
@Test
void acceptTestPollerStackTimeout() {
long id = 2L;
StackDeletionWaitRequest stackCreationWaitRequest = new StackDeletionWaitRequest(id, userId, true);
Event receivedEvent = new Event<>(stackCreationWaitRequest);
doThrow(new PollerStoppedException("stack deletion timeout")).when(provisionerService).waitCloudbreakClusterDeletion(eq(id), any(PollingConfig.class));
stackDeletionHandler.accept(receivedEvent);
verify(provisionerService, times(1)).waitCloudbreakClusterDeletion(eq(id), any(PollingConfig.class));
final ArgumentCaptor<String> eventSelector = ArgumentCaptor.forClass(String.class);
final ArgumentCaptor<Event> sentEvent = ArgumentCaptor.forClass(Event.class);
verify(eventBus, times(1)).notify(eventSelector.capture(), sentEvent.capture());
String eventNotified = eventSelector.getValue();
Event event = sentEvent.getValue();
Assertions.assertEquals("SdxDeletionFailedEvent", eventNotified);
Assertions.assertEquals(SdxDeletionFailedEvent.class, event.getData().getClass());
Assertions.assertEquals(id, ((SdxDeletionFailedEvent) event.getData()).getResourceId());
}
use of com.sequenceiq.datalake.flow.delete.event.StackDeletionWaitRequest in project cloudbreak by hortonworks.
the class StackDeletionHandlerTest method acceptTestPollerStackOtherError.
@Test
void acceptTestPollerStackOtherError() {
long id = 2L;
StackDeletionWaitRequest stackCreationWaitRequest = new StackDeletionWaitRequest(id, userId, true);
Event receivedEvent = new Event<>(stackCreationWaitRequest);
doThrow(new PollerException("stack deletion error")).when(provisionerService).waitCloudbreakClusterDeletion(eq(id), any(PollingConfig.class));
stackDeletionHandler.accept(receivedEvent);
verify(provisionerService, times(1)).waitCloudbreakClusterDeletion(eq(id), any(PollingConfig.class));
final ArgumentCaptor<String> eventSelector = ArgumentCaptor.forClass(String.class);
final ArgumentCaptor<Event> sentEvent = ArgumentCaptor.forClass(Event.class);
verify(eventBus, times(1)).notify(eventSelector.capture(), sentEvent.capture());
String eventNotified = eventSelector.getValue();
Event event = sentEvent.getValue();
Assertions.assertEquals("SdxDeletionFailedEvent", eventNotified);
Assertions.assertEquals(SdxDeletionFailedEvent.class, event.getData().getClass());
Assertions.assertEquals(id, ((SdxDeletionFailedEvent) event.getData()).getResourceId());
}
use of com.sequenceiq.datalake.flow.delete.event.StackDeletionWaitRequest in project cloudbreak by hortonworks.
the class StackDeletionHandlerTest method acceptTestStackDeletionSuccess.
@Test
void acceptTestStackDeletionSuccess() {
long id = 2L;
StackDeletionWaitRequest stackCreationWaitRequest = new StackDeletionWaitRequest(id, userId, true);
Event receivedEvent = new Event<>(stackCreationWaitRequest);
doNothing().when(provisionerService).waitCloudbreakClusterDeletion(eq(id), any(PollingConfig.class));
stackDeletionHandler.accept(receivedEvent);
verify(provisionerService, times(1)).waitCloudbreakClusterDeletion(eq(id), any(PollingConfig.class));
final ArgumentCaptor<String> eventSelector = ArgumentCaptor.forClass(String.class);
final ArgumentCaptor<Event> sentEvent = ArgumentCaptor.forClass(Event.class);
verify(eventBus, times(1)).notify(eventSelector.capture(), sentEvent.capture());
String eventNotified = eventSelector.getValue();
Event event = sentEvent.getValue();
Assertions.assertEquals("StackDeletionSuccessEvent", eventNotified);
Assertions.assertEquals(StackDeletionSuccessEvent.class, event.getData().getClass());
Assertions.assertEquals(id, ((StackDeletionSuccessEvent) event.getData()).getResourceId());
}
Aggregations