Search in sources :

Example 6 with UpgradeCcmStackRequest

use of com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmStackRequest in project cloudbreak by hortonworks.

the class UpgradeCcmStackHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<UpgradeCcmStackRequest> event) {
    UpgradeCcmStackRequest request = event.getData();
    SdxCluster sdxCluster = sdxService.getById(request.getResourceId());
    Long sdxId = request.getResourceId();
    String userId = request.getUserId();
    Selectable response;
    try {
        LOGGER.debug("Initiating CCM upgrade and start polling for SDX: {}", sdxCluster.getName());
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        ccmUpgradeService.initAndWaitForStackUpgrade(sdxCluster, pollingConfig);
        response = new UpgradeCcmSuccessEvent(sdxId, userId);
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Upgrade CCM poller exited before timeout. Cause: ", userBreakException);
        response = new UpgradeCcmFailedEvent(sdxId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Upgrade CCM poller stopped for stack: {}", sdxId);
        response = new UpgradeCcmFailedEvent(sdxId, userId, new PollerStoppedException("Upgrade CCM timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.error("Upgrade CCM polling failed for stack: {}", sdxId);
        response = new UpgradeCcmFailedEvent(sdxId, userId, exception);
    }
    return response;
}
Also used : UpgradeCcmSuccessEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmSuccessEvent) UserBreakException(com.dyngr.exception.UserBreakException) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) UpgradeCcmFailedEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent) PollerException(com.dyngr.exception.PollerException) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) UpgradeCcmStackRequest(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmStackRequest) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Aggregations

UpgradeCcmStackRequest (com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmStackRequest)6 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)4 PollerException (com.dyngr.exception.PollerException)3 PollerStoppedException (com.dyngr.exception.PollerStoppedException)3 UserBreakException (com.dyngr.exception.UserBreakException)3 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)3 UpgradeCcmFailedEvent (com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent)3 UpgradeCcmSuccessEvent (com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmSuccessEvent)3 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)3 Test (org.junit.jupiter.api.Test)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 UpgradeCcmStackEvent (com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmStackEvent)2 Event (reactor.bus.Event)2 SdxContext (com.sequenceiq.datalake.flow.SdxContext)1 Map (java.util.Map)1 Optional (java.util.Optional)1 ValueSource (org.junit.jupiter.params.provider.ValueSource)1 Bean (org.springframework.context.annotation.Bean)1