use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.
the class DiagnosticsUpgradeTelemetryHandlerTest method testFailureEvent.
@Test
public void testFailureEvent() {
DiagnosticsCollectionEvent event = new DiagnosticsCollectionEvent(UPGRADE_DIAGNOSTICS_EVENT.selector(), STACK_ID, "crn", new DiagnosticParameters(), Set.of(), Set.of(), Set.of());
Selectable result = underTest.defaultFailureEvent(STACK_ID, new IllegalArgumentException("ex"), new Event<>(event));
assertEquals(FAILED_DIAGNOSTICS_COLLECTION_EVENT.selector(), result.selector());
}
use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.
the class DiagnosticsUploadHandlerTest method testFailureEvent.
@Test
public void testFailureEvent() {
DiagnosticsCollectionEvent event = new DiagnosticsCollectionEvent(UPLOAD_DIAGNOSTICS_EVENT.selector(), STACK_ID, "crn", new DiagnosticParameters(), Set.of(), Set.of(), Set.of());
Selectable result = underTest.defaultFailureEvent(STACK_ID, new IllegalArgumentException("ex"), new Event<>(event));
assertEquals(FAILED_DIAGNOSTICS_COLLECTION_EVENT.selector(), result.selector());
}
use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.
the class ProvisionFlowEventChainFactory method createFlowTriggerEventQueue.
@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(StackEvent event) {
Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
flowEventChain.add(new StackEvent(StackProvisionEvent.START_CREATION_EVENT.event(), event.getResourceId(), event.accepted()));
flowEventChain.add(new StackEvent(FreeIpaProvisionEvent.FREEIPA_PROVISION_EVENT.event(), event.getResourceId()));
return new FlowTriggerEventQueue(getName(), event, flowEventChain);
}
use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.
the class UpgradeCcmFlowEventChainFactory method createFlowTriggerEventQueue.
@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(UpgradeCcmFlowChainTriggerEvent event) {
Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
flowEventChain.add(new UpgradeCcmTriggerEvent(UpgradeCcmStateSelector.UPGRADE_CCM_TRIGGER_EVENT.event(), event.getOperationId(), event.getResourceId(), event.getOldTunnel(), event.accepted()).withIsChained(true).withIsFinal(false));
flowEventChain.add(new UserDataUpdateRequest(UpdateUserDataEvents.UPDATE_USERDATA_TRIGGER_EVENT.event(), event.getResourceId(), event.getOldTunnel()).withOperationId(event.getOperationId()).withIsChained(true).withIsFinal(true));
return new FlowTriggerEventQueue(getName(), event, flowEventChain);
}
use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.
the class RdsDeletionHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<RdsDeletionWaitRequest> event) {
RdsDeletionWaitRequest rdsWaitRequest = event.getData();
Long sdxId = rdsWaitRequest.getResourceId();
String userId = rdsWaitRequest.getUserId();
Selectable response;
try {
sdxClusterRepository.findById(sdxId).ifPresent(sdxCluster -> {
if (sdxCluster.hasExternalDatabase() && StringUtils.isNotEmpty(sdxCluster.getDatabaseCrn())) {
LOGGER.debug("start polling database termination for sdx: {}", sdxId);
databaseService.terminate(sdxCluster, rdsWaitRequest.isForced());
} else {
LOGGER.debug("skipping deletion of database for sdx: {}", sdxId);
}
setDeletedStatus(sdxCluster);
});
response = new RdsDeletionSuccessEvent(sdxId, userId);
} catch (UserBreakException userBreakException) {
LOGGER.error("Database polling exited before timeout. Cause: ", userBreakException);
response = new SdxDeletionFailedEvent(sdxId, userId, userBreakException, rdsWaitRequest.isForced());
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Database poller stopped for sdx: {}", sdxId, pollerStoppedException);
response = new SdxDeletionFailedEvent(sdxId, userId, new PollerStoppedException("Database deletion timed out after " + durationInMinutes + " minutes"), rdsWaitRequest.isForced());
} catch (PollerException exception) {
LOGGER.error("Database polling failed for sdx: {}", sdxId, exception);
response = new SdxDeletionFailedEvent(sdxId, userId, exception, rdsWaitRequest.isForced());
} catch (Exception anotherException) {
LOGGER.error("Something wrong happened in sdx database deletion wait phase", anotherException);
response = new SdxDeletionFailedEvent(sdxId, userId, anotherException, rdsWaitRequest.isForced());
}
return response;
}
Aggregations