Search in sources :

Example 6 with CmSyncOperationStatus

use of com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationStatus in project cloudbreak by hortonworks.

the class CmSyncHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<CmSyncRequest> event) {
    CmSyncRequest request = event.getData();
    try {
        Stack stack = stackService.getByIdWithListsInTransaction(request.getResourceId());
        Set<Image> candidateImages = cmSyncImageCollectorService.collectImages(request.getFlowTriggerUserCrn(), stack, request.getCandidateImageUuids());
        CmSyncOperationSummary cmSyncOperationSummary = cmSyncerService.syncFromCmToDb(stack, candidateImages);
        CmSyncOperationStatus cmSyncOperationStatus = cmSyncOperationSummary.getSyncOperationStatus();
        if (!cmSyncOperationStatus.hasSucceeded()) {
            LOGGER.debug("Reading CM and active parcel versions from CM server encountered failures. Details: {}", cmSyncOperationStatus.getMessage());
            Exception e = new CloudbreakServiceException(cmSyncOperationStatus.getMessage());
            return new CmSyncResult(cmSyncOperationStatus.getMessage(), e, request);
        }
        return new CmSyncResult(request, cmSyncOperationStatus.getMessage());
    } catch (Exception e) {
        LOGGER.warn("Reading CM and active parcel versions from CM server resulted in error ", e);
        String message = String.format("unexpected error: %s", e.getMessage());
        return new CmSyncResult(message, new CloudbreakServiceException(message, e), request);
    }
}
Also used : CmSyncResult(com.sequenceiq.cloudbreak.reactor.api.event.resource.CmSyncResult) CmSyncOperationStatus(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationStatus) CmSyncRequest(com.sequenceiq.cloudbreak.reactor.api.event.resource.CmSyncRequest) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) CmSyncOperationSummary(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationSummary) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 7 with CmSyncOperationStatus

use of com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationStatus in project cloudbreak by hortonworks.

the class CmSyncerService method syncInternal.

private CmSyncOperationSummary syncInternal(Stack stack, Set<Image> candidateImages) {
    CmSyncOperationResult cmSyncOperationResult = new CmSyncOperationResult(cmInstalledComponentFinderService.findCmRepoComponent(stack, candidateImages), cmInstalledComponentFinderService.findParcelComponents(stack, candidateImages));
    LOGGER.debug("Synced CM versions and found components: {}", cmSyncOperationResult);
    componentPersistingService.persistComponentsToDb(stack, cmSyncOperationResult);
    CmSyncOperationStatus cmSyncOperationStatus = cmSyncOperationSummaryService.evaluate(cmSyncOperationResult);
    mixedPackageVersionService.validatePackageVersions(stack.getId(), cmSyncOperationResult, candidateImages);
    LOGGER.info("CM sync was executed, summary: {}", cmSyncOperationStatus);
    return new CmSyncOperationSummary(cmSyncOperationStatus, cmSyncOperationResult);
}
Also used : CmSyncOperationStatus(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationStatus) CmSyncOperationResult(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationResult) CmSyncOperationSummary(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationSummary)

Aggregations

CmSyncOperationStatus (com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationStatus)7 CmSyncOperationSummary (com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationSummary)7 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)6 Test (org.junit.jupiter.api.Test)5 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)3 CmSyncRequest (com.sequenceiq.cloudbreak.reactor.api.event.resource.CmSyncRequest)3 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)2 CmSyncResult (com.sequenceiq.cloudbreak.reactor.api.event.resource.CmSyncResult)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 CmParcelSyncOperationResult (com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmParcelSyncOperationResult)1 CmRepoSyncOperationResult (com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmRepoSyncOperationResult)1 CmSyncOperationResult (com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationResult)1