@Test public void testStartWheClientErrorException() { SdxCluster sdxCluster = sdxCluster(); ClientErrorException clientErrorException = mock(ClientErrorException.class); when(webApplicationExceptionMessageExtractor.getErrorMessage(any())).thenReturn("Error message: \"error\""); doThrow(clientErrorException).when(stackV4Endpoint).putStartInternal(eq(0L), eq(CLUSTER_NAME), nullable(String.class)); when(sdxService.getById(CLUSTER_ID)).thenReturn(sdxCluster); RuntimeException exception = Assertions.assertThrows(RuntimeException.class, () -> underTest.start(CLUSTER_ID)); verifyNoInteractions(cloudbreakFlowService); assertEquals("Can not start stack, client error happened on Cloudbreak side: Error message: \"error\"", exception.getMessage()); }
public void start(Long sdxId) { SdxCluster sdxCluster = sdxService.getById(sdxId); try { LOGGER.info("Triggering start flow for cluster {}", sdxCluster.getClusterName()); String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn(); FlowIdentifier flowIdentifier = ThreadBasedUserCrnProvider.doAsInternalActor(() -> stackV4Endpoint.putStartInternal(0L, sdxCluster.getClusterName(), initiatorUserCrn)); cloudbreakFlowService.saveLastCloudbreakFlowChainId(sdxCluster, flowIdentifier); sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.START_IN_PROGRESS, "Datalake start in progress", sdxCluster); } catch (NotFoundException e) { LOGGER.info("Can not find stack on cloudbreak side {}", sdxCluster.getClusterName()); } catch (ClientErrorException e) { String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e); LOGGER.info("Can not start stack {} from cloudbreak: {}", sdxCluster.getStackId(), errorMessage, e); throw new RuntimeException("Can not start stack, client error happened on Cloudbreak side: " + errorMessage); } catch (WebApplicationException e) { String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e); LOGGER.info("Can not start stack {} from cloudbreak: {}", sdxCluster.getStackId(), errorMessage, e); throw new RuntimeException("Can not start stack, web application error happened on Cloudbreak side: " + errorMessage); } }
SdxStartService { public void start(Long sdxId) { SdxCluster sdxCluster = sdxService.getById(sdxId); try { LOGGER.info("Triggering start flow for cluster {}", sdxCluster.getClusterName()); String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn(); FlowIdentifier flowIdentifier = ThreadBasedUserCrnProvider.doAsInternalActor(() -> stackV4Endpoint.putStartInternal(0L, sdxCluster.getClusterName(), initiatorUserCrn)); cloudbreakFlowService.saveLastCloudbreakFlowChainId(sdxCluster, flowIdentifier); sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.START_IN_PROGRESS, "Datalake start in progress", sdxCluster); } catch (NotFoundException e) { LOGGER.info("Can not find stack on cloudbreak side {}", sdxCluster.getClusterName()); } catch (ClientErrorException e) { String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e); LOGGER.info("Can not start stack {} from cloudbreak: {}", sdxCluster.getStackId(), errorMessage, e); throw new RuntimeException("Can not start stack, client error happened on Cloudbreak side: " + errorMessage); } catch (WebApplicationException e) { String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e); LOGGER.info("Can not start stack {} from cloudbreak: {}", sdxCluster.getStackId(), errorMessage, e); throw new RuntimeException("Can not start stack, web application error happened on Cloudbreak side: " + errorMessage); } } }
SdxStartService { public void start(Long sdxId) { SdxCluster sdxCluster = sdxService.getById(sdxId); try { LOGGER.info("Triggering start flow for cluster {}", sdxCluster.getClusterName()); String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn(); FlowIdentifier flowIdentifier = ThreadBasedUserCrnProvider.doAsInternalActor(() -> stackV4Endpoint.putStartInternal(0L, sdxCluster.getClusterName(), initiatorUserCrn)); cloudbreakFlowService.saveLastCloudbreakFlowChainId(sdxCluster, flowIdentifier); sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.START_IN_PROGRESS, "Datalake start in progress", sdxCluster); } catch (NotFoundException e) { LOGGER.info("Can not find stack on cloudbreak side {}", sdxCluster.getClusterName()); } catch (ClientErrorException e) { String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e); LOGGER.info("Can not start stack {} from cloudbreak: {}", sdxCluster.getStackId(), errorMessage, e); throw new RuntimeException("Can not start stack, client error happened on Cloudbreak side: " + errorMessage); } catch (WebApplicationException e) { String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e); LOGGER.info("Can not start stack {} from cloudbreak: {}", sdxCluster.getStackId(), errorMessage, e); throw new RuntimeException("Can not start stack, web application error happened on Cloudbreak side: " + errorMessage); } }  }
SdxStartService { public void start(Long sdxId) { SdxCluster sdxCluster = sdxService.getById(sdxId); try { LOGGER.info("Triggering start flow for cluster {}", sdxCluster.getClusterName()); String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn(); FlowIdentifier flowIdentifier = ThreadBasedUserCrnProvider.doAsInternalActor(() -> stackV4Endpoint.putStartInternal(0L, sdxCluster.getClusterName(), initiatorUserCrn)); cloudbreakFlowService.saveLastCloudbreakFlowChainId(sdxCluster, flowIdentifier); sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.START_IN_PROGRESS, "Datalake start in progress", sdxCluster); } catch (NotFoundException e) { LOGGER.info("Can not find stack on cloudbreak side {}", sdxCluster.getClusterName()); } catch (ClientErrorException e) { String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e); LOGGER.info("Can not start stack {} from cloudbreak: {}", sdxCluster.getStackId(), errorMessage, e); throw new RuntimeException("Can not start stack, client error happened on Cloudbreak side: " + errorMessage); } catch (WebApplicationException e) { String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e); LOGGER.info("Can not start stack {} from cloudbreak: {}", sdxCluster.getStackId(), errorMessage, e); throw new RuntimeException("Can not start stack, web application error happened on Cloudbreak side: " + errorMessage); } }  FlowIdentifier triggerStartIfClusterNotRunning(SdxCluster cluster); void start(Long sdxId); void waitCloudbreakCluster(Long sdxId, PollingConfig pollingConfig); }
SdxStartService { public void start(Long sdxId) { SdxCluster sdxCluster = sdxService.getById(sdxId); try { LOGGER.info("Triggering start flow for cluster {}", sdxCluster.getClusterName()); String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn(); FlowIdentifier flowIdentifier = ThreadBasedUserCrnProvider.doAsInternalActor(() -> stackV4Endpoint.putStartInternal(0L, sdxCluster.getClusterName(), initiatorUserCrn)); cloudbreakFlowService.saveLastCloudbreakFlowChainId(sdxCluster, flowIdentifier); sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.START_IN_PROGRESS, "Datalake start in progress", sdxCluster); } catch (NotFoundException e) { LOGGER.info("Can not find stack on cloudbreak side {}", sdxCluster.getClusterName()); } catch (ClientErrorException e) { String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e); LOGGER.info("Can not start stack {} from cloudbreak: {}", sdxCluster.getStackId(), errorMessage, e); throw new RuntimeException("Can not start stack, client error happened on Cloudbreak side: " + errorMessage); } catch (WebApplicationException e) { String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e); LOGGER.info("Can not start stack {} from cloudbreak: {}", sdxCluster.getStackId(), errorMessage, e); throw new RuntimeException("Can not start stack, web application error happened on Cloudbreak side: " + errorMessage); } }  FlowIdentifier triggerStartIfClusterNotRunning(SdxCluster cluster); void start(Long sdxId); void waitCloudbreakCluster(Long sdxId, PollingConfig pollingConfig);  }