Search in sources :

Example 31 with UserBreakException

use of com.dyngr.exception.UserBreakException in project cloudbreak by hortonworks.

the class SdxDiagnosticsCollectionHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<SdxDiagnosticsWaitRequest> event) {
    SdxDiagnosticsWaitRequest request = event.getData();
    Long sdxId = request.getResourceId();
    String userId = request.getUserId();
    Map<String, Object> properties = request.getProperties();
    Selectable response;
    try {
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        diagnosticsFlowService.waitForDiagnosticsCollection(sdxId, pollingConfig, request.getFlowIdentifier());
        response = new SdxDiagnosticsSuccessEvent(sdxId, userId, properties);
        LOGGER.debug("SDX diagnostics collection event finished");
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Polling exited before timeout for SDX (diagnostic collection): {}. Cause: ", sdxId, userBreakException);
        response = new SdxDiagnosticsFailedEvent(sdxId, userId, properties, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Poller stopped for SDX (diagnostic collection): {}", sdxId, pollerStoppedException);
        response = new SdxDiagnosticsFailedEvent(sdxId, userId, properties, new PollerStoppedException("Datalake diagnostic collection timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.error("Polling failed for stack (diagnostic collection): {}", sdxId, exception);
        response = new SdxDiagnosticsFailedEvent(sdxId, userId, properties, exception);
    } catch (Exception anotherException) {
        LOGGER.error("Something wrong happened in diagnostic collection wait phase", anotherException);
        response = new SdxDiagnosticsFailedEvent(sdxId, userId, properties, anotherException);
    }
    return response;
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) PollerException(com.dyngr.exception.PollerException) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) UserBreakException(com.dyngr.exception.UserBreakException) PollerException(com.dyngr.exception.PollerException) PollerStoppedException(com.dyngr.exception.PollerStoppedException) SdxDiagnosticsFailedEvent(com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsFailedEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) SdxDiagnosticsSuccessEvent(com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsSuccessEvent) SdxDiagnosticsWaitRequest(com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsWaitRequest) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Example 32 with UserBreakException

use of com.dyngr.exception.UserBreakException in project cloudbreak by hortonworks.

the class DatalakeChangeImageWaitHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<DatalakeChangeImageWaitRequest> event) {
    DatalakeChangeImageWaitRequest request = event.getData();
    Long sdxId = request.getResourceId();
    String userId = request.getUserId();
    Selectable response;
    try {
        LOGGER.info("Start polling change image process for id: {}", sdxId);
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        upgradeService.waitCloudbreakFlow(sdxId, pollingConfig, "Change image");
        String imageId = upgradeService.getImageId(sdxId);
        String expectedImageId = request.getUpgradeOption().getUpgrade().getImageId();
        if (Objects.equals(imageId, expectedImageId)) {
            LOGGER.info("Image changed in cloudbreak side for SDX {}, actual image: {}", sdxId, imageId);
            response = new DatalakeVmReplaceEvent(sdxId, userId);
        } else {
            String message = String.format("Image not changed in cloudbreak side, expected image: %s, actual image: %s", expectedImageId, imageId);
            LOGGER.info(message);
            response = new DatalakeUpgradeFailedEvent(sdxId, userId, new IllegalStateException(message));
        }
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Change image polling exited before timeout. Cause: ", userBreakException);
        response = new DatalakeUpgradeFailedEvent(sdxId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Change image poller stopped for cluster: {}", sdxId);
        response = new DatalakeUpgradeFailedEvent(sdxId, userId, new PollerStoppedException("Change image poller timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.error("Change image polling failed for cluster: {}", sdxId);
        response = new DatalakeUpgradeFailedEvent(sdxId, userId, exception);
    }
    return response;
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) DatalakeVmReplaceEvent(com.sequenceiq.datalake.flow.datalake.upgrade.event.DatalakeVmReplaceEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PollerException(com.dyngr.exception.PollerException) DatalakeUpgradeFailedEvent(com.sequenceiq.datalake.flow.datalake.upgrade.event.DatalakeUpgradeFailedEvent) DatalakeChangeImageWaitRequest(com.sequenceiq.datalake.flow.datalake.upgrade.event.DatalakeChangeImageWaitRequest) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Example 33 with UserBreakException

use of com.dyngr.exception.UserBreakException in project cloudbreak by hortonworks.

the class DatalakeUpgradeWaitHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<DatalakeUpgradeWaitRequest> event) {
    DatalakeUpgradeWaitRequest request = event.getData();
    Long sdxId = request.getResourceId();
    String userId = request.getUserId();
    Selectable response;
    try {
        LOGGER.info("Start polling cluster upgrade process for id: {}", sdxId);
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        upgradeService.waitCloudbreakFlow(sdxId, pollingConfig, "Stack Upgrade");
        response = new DatalakeImageChangeEvent(sdxId, userId, request.getImageId());
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Upgrade polling exited before timeout. Cause: ", userBreakException);
        if (userBreakException.getCause() instanceof UpgradeValidationFailedException) {
            response = new DatalakeUpgradeValidationFailedEvent(sdxId, userId);
        } else {
            response = new DatalakeUpgradeFailedEvent(sdxId, userId, userBreakException);
        }
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Upgrade poller stopped for cluster: {}", sdxId);
        response = new DatalakeUpgradeFailedEvent(sdxId, userId, new PollerStoppedException("Datalake upgrade timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.error("Upgrade polling failed for cluster: {}", sdxId);
        response = new DatalakeUpgradeFailedEvent(sdxId, userId, exception);
    }
    return response;
}
Also used : DatalakeUpgradeWaitRequest(com.sequenceiq.datalake.flow.datalake.upgrade.event.DatalakeUpgradeWaitRequest) UserBreakException(com.dyngr.exception.UserBreakException) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PollerException(com.dyngr.exception.PollerException) DatalakeImageChangeEvent(com.sequenceiq.datalake.flow.datalake.upgrade.event.DatalakeImageChangeEvent) DatalakeUpgradeValidationFailedEvent(com.sequenceiq.datalake.flow.datalake.upgrade.event.DatalakeUpgradeValidationFailedEvent) DatalakeUpgradeFailedEvent(com.sequenceiq.datalake.flow.datalake.upgrade.event.DatalakeUpgradeFailedEvent) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) PollerStoppedException(com.dyngr.exception.PollerStoppedException) UpgradeValidationFailedException(com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException)

Example 34 with UserBreakException

use of com.dyngr.exception.UserBreakException in project cloudbreak by hortonworks.

the class SdxUpgradeService method waitCloudbreakFlow.

public void waitCloudbreakFlow(Long id, PollingConfig pollingConfig, String pollingMessage) {
    SdxCluster sdxCluster = sdxService.getById(id);
    cloudbreakPoller.pollUpdateUntilAvailable(pollingMessage, sdxCluster, pollingConfig);
    if (cloudbreakFlowResultProvider.isValidationFailed(sdxCluster)) {
        throw new UserBreakException(new UpgradeValidationFailedException("Upgrade validation failed."));
    }
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) UpgradeValidationFailedException(com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException)

Example 35 with UserBreakException

use of com.dyngr.exception.UserBreakException in project cloudbreak by hortonworks.

the class SdxStopAllDatahubHandlerTest method testUserBreakException.

@Test
public void testUserBreakException() {
    UserBreakException userBreakException = new UserBreakException("");
    doThrow(userBreakException).when(sdxStopService).stopAllDatahub(anyLong());
    underTest.accept(new Event<>(new SdxStopAllDatahubRequest(1L, "USER_ID")));
    verify(eventBus).notify(anyString(), captor.capture());
    SdxStopFailedEvent sdxStopFailedEvent = captor.getValue().getData();
    assertEquals(SDX_ID, sdxStopFailedEvent.getResourceId());
    assertEquals(USER_ID, sdxStopFailedEvent.getUserId());
    assertEquals(userBreakException, sdxStopFailedEvent.getException());
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) SdxStopAllDatahubRequest(com.sequenceiq.datalake.flow.stop.event.SdxStopAllDatahubRequest) SdxStopFailedEvent(com.sequenceiq.datalake.flow.stop.event.SdxStopFailedEvent) Test(org.junit.jupiter.api.Test)

Aggregations

UserBreakException (com.dyngr.exception.UserBreakException)41 PollerException (com.dyngr.exception.PollerException)30 PollerStoppedException (com.dyngr.exception.PollerStoppedException)30 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)28 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)21 Test (org.junit.jupiter.api.Test)10 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)7 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)7 SdxCreateFailedEvent (com.sequenceiq.datalake.flow.create.event.SdxCreateFailedEvent)5 DatabaseAvailabilityType (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseAvailabilityType)4 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)4 SdxEvent (com.sequenceiq.datalake.flow.SdxEvent)4 SdxStopFailedEvent (com.sequenceiq.datalake.flow.stop.event.SdxStopFailedEvent)4 DatalakeUpgradeFailedEvent (com.sequenceiq.datalake.flow.datalake.upgrade.event.DatalakeUpgradeFailedEvent)3 SdxDeletionFailedEvent (com.sequenceiq.datalake.flow.delete.event.SdxDeletionFailedEvent)3 SdxDiagnosticsSuccessEvent (com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsSuccessEvent)3 UpgradeValidationFailedException (com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException)2 CloudbreakApiException (com.sequenceiq.cloudbreak.exception.CloudbreakApiException)2 StackCreationSuccessEvent (com.sequenceiq.datalake.flow.create.event.StackCreationSuccessEvent)2 StackCreationWaitRequest (com.sequenceiq.datalake.flow.create.event.StackCreationWaitRequest)2