Search in sources :

Example 1 with UpgradeCcmSuccessEvent

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

the class UpgradeCcmActions method finishedAction.

@Bean(name = "UPGRADE_CCM_FINISHED_STATE")
public Action<?, ?> finishedAction() {
    return new AbstractUpgradeCcmSdxAction<>(UpgradeCcmSuccessEvent.class) {

        @Override
        protected void doExecute(SdxContext context, UpgradeCcmSuccessEvent payload, Map<Object, Object> variables) {
            LOGGER.info("CCM upgrade finalized for SDX: {}", payload.getResourceId());
            SdxCluster sdxCluster = sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.RUNNING, "Cluster Connectivity Manager upgrade completed successfully", payload.getResourceId());
            metricService.incrementMetricCounter(MetricType.UPGRADE_CCM_FINISHED, sdxCluster);
            sendEvent(context, UPGRADE_CCM_FINALIZED_EVENT.event(), payload);
        }
    };
}
Also used : UpgradeCcmSuccessEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmSuccessEvent) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) Map(java.util.Map) SdxContext(com.sequenceiq.datalake.flow.SdxContext) Bean(org.springframework.context.annotation.Bean)

Example 2 with UpgradeCcmSuccessEvent

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

the class UpgradeCcmActionsTest method finishedFailPath.

@Test
void finishedFailPath() {
    actionPayload = new UpgradeCcmSuccessEvent(SDX_ID, USER_ID);
    setupContextWithPayload();
    testErrorInSdxStatusService(underTest::finishedAction);
    verify(sdxStatusService).setStatusForDatalakeAndNotify(DatalakeStatusEnum.RUNNING, "Cluster Connectivity Manager upgrade completed successfully", SDX_ID);
    UpgradeCcmSuccessEvent payload = (UpgradeCcmSuccessEvent) payloadArgumentCaptor.getValue();
    assertThat(payload.getResourceId()).isEqualTo(SDX_ID);
    assertThat(payload.getUserId()).isEqualTo(USER_ID);
}
Also used : UpgradeCcmSuccessEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmSuccessEvent) Test(org.junit.jupiter.api.Test)

Example 3 with UpgradeCcmSuccessEvent

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

the class UpgradeCcmActionsTest method finishedHappyPath.

@Test
void finishedHappyPath() {
    actionPayload = new UpgradeCcmSuccessEvent(SDX_ID, USER_ID);
    setupContextWithPayload();
    SdxCluster sdxCluster = mock(SdxCluster.class);
    when(sdxStatusService.setStatusForDatalakeAndNotify(any(), any(), anyLong())).thenReturn(sdxCluster);
    testUpgradeActionHappyPath(underTest::finishedAction);
    verify(metricService).incrementMetricCounter(MetricType.UPGRADE_CCM_FINISHED, sdxCluster);
    verify(sdxStatusService).setStatusForDatalakeAndNotify(DatalakeStatusEnum.RUNNING, "Cluster Connectivity Manager upgrade completed successfully", SDX_ID);
    UpgradeCcmSuccessEvent payload = (UpgradeCcmSuccessEvent) payloadArgumentCaptor.getValue();
    assertThat(selectorArgumentCaptor.getValue()).isEqualTo(UPGRADE_CCM_FINALIZED_EVENT.event());
    assertThat(payload.getResourceId()).isEqualTo(SDX_ID);
    assertThat(payload.getUserId()).isEqualTo(USER_ID);
}
Also used : UpgradeCcmSuccessEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmSuccessEvent) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) Test(org.junit.jupiter.api.Test)

Example 4 with UpgradeCcmSuccessEvent

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

the class UpgradeCcmStackHandlerTest method acceptSuccess.

@Test
void acceptSuccess() throws Exception {
    SdxCluster sdxCluster = getSdxCluster();
    when(sdxService.getById(any())).thenReturn(sdxCluster);
    UpgradeCcmStackRequest request = new UpgradeCcmStackRequest(1L, "user");
    PollingConfig expectedPollingConfig = new PollingConfig(1, TimeUnit.SECONDS, 2, TimeUnit.MINUTES);
    Event.Headers headers = new Event.Headers();
    Event<UpgradeCcmStackRequest> event = new Event<>(headers, request);
    Selectable selectable = new ExceptionCatcherEventHandlerTestSupport<>(underTest).doAccept(event);
    UpgradeCcmSuccessEvent successEvent = new UpgradeCcmSuccessEvent(1L, "user");
    assertThat(selectable).usingRecursiveComparison().isEqualTo(successEvent);
    verify(ccmUpgradeService).initAndWaitForStackUpgrade(eq(sdxCluster), refEq(expectedPollingConfig));
}
Also used : UpgradeCcmSuccessEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmSuccessEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) Event(reactor.bus.Event) UpgradeCcmFailedEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent) UpgradeCcmSuccessEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmSuccessEvent) UpgradeCcmStackRequest(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmStackRequest) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with UpgradeCcmSuccessEvent

use of com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmSuccessEvent 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

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