Search in sources :

Example 1 with ResilientJobExecutor

use of com.synopsys.integration.wait.ResilientJobExecutor in project blackduck-common by blackducksoftware.

the class CodeLocationWaiter method checkCodeLocationsAddedToBom.

public CodeLocationWaitResult checkCodeLocationsAddedToBom(UserView userView, NotificationTaskRange notificationTaskRange, NameVersion projectAndVersion, Set<String> codeLocationNames, int expectedNotificationCount, long timeoutInSeconds, int waitIntervalInSeconds) throws IntegrationException, InterruptedException {
    logger.debug("Expected notification count " + expectedNotificationCount);
    logger.debug("Expected code locations:");
    codeLocationNames.forEach(codeLocation -> logger.debug(String.format("  Code Location -> %s", codeLocation)));
    logger.debug("");
    ResilientJobConfig jobConfig = new ResilientJobConfig(logger, timeoutInSeconds, notificationTaskRange.getTaskStartTime(), waitIntervalInSeconds);
    CodeLocationWaitJob codeLocationWaitJob = new CodeLocationWaitJob(logger, projectService, notificationService, userView, notificationTaskRange, projectAndVersion, codeLocationNames, expectedNotificationCount, blackDuckApiClient);
    ResilientJobExecutor resilientJobExecutor = new ResilientJobExecutor(jobConfig);
    return resilientJobExecutor.executeJob(codeLocationWaitJob);
}
Also used : ResilientJobExecutor(com.synopsys.integration.wait.ResilientJobExecutor) ResilientJobConfig(com.synopsys.integration.wait.ResilientJobConfig)

Example 2 with ResilientJobExecutor

use of com.synopsys.integration.wait.ResilientJobExecutor in project blackduck-common by blackducksoftware.

the class Bdio2UploadJobTest method testRetryOnFailedChunkUpload.

@Test
public void testRetryOnFailedChunkUpload() throws IntegrationException, InterruptedException {
    Bdio2StreamUploader bdio2StreamUploader = getUploaderThatGets429OnAppend();
    Bdio2UploadJob bdio2UploadJob = getUploadJob(bdio2StreamUploader);
    ResilientJobExecutor jobExecutor = getJobExecutor();
    Assertions.assertThrows(IntegrationTimeoutException.class, () -> jobExecutor.executeJob(bdio2UploadJob));
}
Also used : ResilientJobExecutor(com.synopsys.integration.wait.ResilientJobExecutor) Test(org.junit.jupiter.api.Test)

Example 3 with ResilientJobExecutor

use of com.synopsys.integration.wait.ResilientJobExecutor in project synopsys-detect by blackducksoftware.

the class RapidModeWaitOperation method waitForScans.

public List<DeveloperScanComponentResultView> waitForScans(List<HttpUrl> uploadedScans, long timeoutInSeconds, int waitIntervalInSeconds) throws IntegrationException, InterruptedException {
    ResilientJobConfig waitJobConfig = new ResilientJobConfig(new Slf4jIntLogger(logger), timeoutInSeconds, System.currentTimeMillis(), waitIntervalInSeconds);
    DetectRapidScanWaitJob waitJob = new DetectRapidScanWaitJob(blackDuckApiClient, uploadedScans);
    ResilientJobExecutor jobExecutor = new ResilientJobExecutor(waitJobConfig);
    return jobExecutor.executeJob(waitJob);
}
Also used : DetectRapidScanWaitJob(com.synopsys.integration.detect.workflow.blackduck.developer.blackduck.DetectRapidScanWaitJob) Slf4jIntLogger(com.synopsys.integration.log.Slf4jIntLogger) ResilientJobExecutor(com.synopsys.integration.wait.ResilientJobExecutor) ResilientJobConfig(com.synopsys.integration.wait.ResilientJobConfig)

Example 4 with ResilientJobExecutor

use of com.synopsys.integration.wait.ResilientJobExecutor in project blackduck-common by blackducksoftware.

the class Bdio2UploadJobTest method testRetryOnFailedHeaderUpload.

@Test
public void testRetryOnFailedHeaderUpload() throws IntegrationException, InterruptedException {
    Bdio2StreamUploader bdio2StreamUploader = getUploaderThatGets429OnStart();
    Bdio2UploadJob bdio2UploadJob = getUploadJob(bdio2StreamUploader);
    ResilientJobExecutor jobExecutor = getJobExecutor();
    Assertions.assertThrows(IntegrationTimeoutException.class, () -> jobExecutor.executeJob(bdio2UploadJob));
}
Also used : ResilientJobExecutor(com.synopsys.integration.wait.ResilientJobExecutor) Test(org.junit.jupiter.api.Test)

Example 5 with ResilientJobExecutor

use of com.synopsys.integration.wait.ResilientJobExecutor in project blackduck-common by blackducksoftware.

the class Bdio2FileUploadService method uploadFiles.

private Bdio2UploadResult uploadFiles(List<BdioFileContent> bdioFiles, @Nullable NameVersion nameVersion, long timeout) throws IntegrationException, InterruptedException {
    if (bdioFiles.isEmpty()) {
        throw new IllegalArgumentException("BDIO files cannot be empty.");
    }
    BdioFileContent header = bdioFiles.stream().filter(content -> content.getFileName().equals(FILE_NAME_BDIO_HEADER_JSONLD)).findFirst().orElseThrow(() -> new BlackDuckIntegrationException("Cannot find BDIO header file" + FILE_NAME_BDIO_HEADER_JSONLD + "."));
    List<BdioFileContent> remainingFiles = bdioFiles.stream().filter(content -> !content.getFileName().equals(FILE_NAME_BDIO_HEADER_JSONLD)).collect(Collectors.toList());
    int count = remainingFiles.size();
    logger.debug("BDIO upload file count = " + count);
    BlackDuckRequestBuilderEditor editor = noOp -> {
    };
    if (nameVersion != null) {
        editor = builder -> builder.addHeader(Bdio2StreamUploader.PROJECT_NAME_HEADER, nameVersion.getName()).addHeader(Bdio2StreamUploader.VERSION_NAME_HEADER, nameVersion.getVersion());
    }
    ResilientJobConfig jobConfig = new ResilientJobConfig(logger, timeout, System.currentTimeMillis(), BD_WAIT_AND_RETRY_INTERVAL);
    Bdio2UploadJob bdio2UploadJob = new Bdio2UploadJob(bdio2Uploader, header, remainingFiles, editor, count);
    ResilientJobExecutor jobExecutor = new ResilientJobExecutor(jobConfig);
    return jobExecutor.executeJob(bdio2UploadJob);
}
Also used : IntegrationException(com.synopsys.integration.exception.IntegrationException) DataService(com.synopsys.integration.blackduck.service.DataService) ResilientJobExecutor(com.synopsys.integration.wait.ResilientJobExecutor) ApiDiscovery(com.synopsys.integration.blackduck.api.generated.discovery.ApiDiscovery) ResilientJobConfig(com.synopsys.integration.wait.ResilientJobConfig) Collectors(java.util.stream.Collectors) IntLogger(com.synopsys.integration.log.IntLogger) HttpUrl(com.synopsys.integration.rest.HttpUrl) Nullable(org.jetbrains.annotations.Nullable) Bdio2ContentExtractor(com.synopsys.integration.blackduck.bdio2.util.Bdio2ContentExtractor) NameVersion(com.synopsys.integration.util.NameVersion) List(java.util.List) BlackDuckRequestBuilderEditor(com.synopsys.integration.blackduck.service.request.BlackDuckRequestBuilderEditor) BdioFileContent(com.synopsys.integration.blackduck.bdio2.model.BdioFileContent) BlackDuckIntegrationException(com.synopsys.integration.blackduck.exception.BlackDuckIntegrationException) UploadTarget(com.synopsys.integration.blackduck.codelocation.upload.UploadTarget) BlackDuckApiClient(com.synopsys.integration.blackduck.service.BlackDuckApiClient) BlackDuckRequestBuilderEditor(com.synopsys.integration.blackduck.service.request.BlackDuckRequestBuilderEditor) BdioFileContent(com.synopsys.integration.blackduck.bdio2.model.BdioFileContent) ResilientJobExecutor(com.synopsys.integration.wait.ResilientJobExecutor) BlackDuckIntegrationException(com.synopsys.integration.blackduck.exception.BlackDuckIntegrationException) ResilientJobConfig(com.synopsys.integration.wait.ResilientJobConfig)

Aggregations

ResilientJobExecutor (com.synopsys.integration.wait.ResilientJobExecutor)5 ResilientJobConfig (com.synopsys.integration.wait.ResilientJobConfig)3 Test (org.junit.jupiter.api.Test)2 ApiDiscovery (com.synopsys.integration.blackduck.api.generated.discovery.ApiDiscovery)1 BdioFileContent (com.synopsys.integration.blackduck.bdio2.model.BdioFileContent)1 Bdio2ContentExtractor (com.synopsys.integration.blackduck.bdio2.util.Bdio2ContentExtractor)1 UploadTarget (com.synopsys.integration.blackduck.codelocation.upload.UploadTarget)1 BlackDuckIntegrationException (com.synopsys.integration.blackduck.exception.BlackDuckIntegrationException)1 BlackDuckApiClient (com.synopsys.integration.blackduck.service.BlackDuckApiClient)1 DataService (com.synopsys.integration.blackduck.service.DataService)1 BlackDuckRequestBuilderEditor (com.synopsys.integration.blackduck.service.request.BlackDuckRequestBuilderEditor)1 DetectRapidScanWaitJob (com.synopsys.integration.detect.workflow.blackduck.developer.blackduck.DetectRapidScanWaitJob)1 IntegrationException (com.synopsys.integration.exception.IntegrationException)1 IntLogger (com.synopsys.integration.log.IntLogger)1 Slf4jIntLogger (com.synopsys.integration.log.Slf4jIntLogger)1 HttpUrl (com.synopsys.integration.rest.HttpUrl)1 NameVersion (com.synopsys.integration.util.NameVersion)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Nullable (org.jetbrains.annotations.Nullable)1