Search in sources :

Example 1 with AwsBatchExecutorParameters

use of pipelite.stage.parameters.AwsBatchExecutorParameters in project pipelite by enasequence.

the class AwsBatchDescribeJobsCacheTest method test.

@Test
public void test() {
    AwsBatchDescribeJobsCache cache = new AwsBatchDescribeJobsCache(Mockito.mock(ServiceConfiguration.class), Mockito.mock(InternalErrorService.class));
    AwsBatchExecutorParameters region1 = AwsBatchExecutorParameters.builder().region("1").build();
    AwsBatchExecutorParameters region2 = AwsBatchExecutorParameters.builder().region("2").build();
    AwsBatchExecutor executor1Region1 = new AwsBatchExecutor();
    AwsBatchExecutor executor2Region1 = new AwsBatchExecutor();
    AwsBatchExecutor executor3Region2 = new AwsBatchExecutor();
    AwsBatchExecutor executor4Region1 = new AwsBatchExecutor();
    executor1Region1.setExecutorParams(region1);
    executor2Region1.setExecutorParams(region1);
    executor3Region2.setExecutorParams(region2);
    executor4Region1.setExecutorParams(region1);
    assertThat(cache.getCacheContext(executor1Region1).getRegion()).isEqualTo(region1.getRegion());
    assertThat(cache.getCacheContext(executor2Region1).getRegion()).isEqualTo(region1.getRegion());
    assertThat(cache.getCacheContext(executor3Region2).getRegion()).isEqualTo(region2.getRegion());
    assertThat(cache.getCacheContext(executor4Region1).getRegion()).isEqualTo(region1.getRegion());
    DescribeJobs<String, AwsBatchDescribeJobsCache.ExecutorContext> describeJobs1 = cache.getDescribeJobs(executor1Region1);
    DescribeJobs<String, AwsBatchDescribeJobsCache.ExecutorContext> describeJobs2 = cache.getDescribeJobs(executor2Region1);
    DescribeJobs<String, AwsBatchDescribeJobsCache.ExecutorContext> describeJobs3 = cache.getDescribeJobs(executor3Region2);
    DescribeJobs<String, AwsBatchDescribeJobsCache.ExecutorContext> describeJobs4 = cache.getDescribeJobs(executor4Region1);
    assertThat(describeJobs1 == describeJobs2).isTrue();
    assertThat(describeJobs1 != describeJobs3).isTrue();
    assertThat(describeJobs1 == describeJobs4).isTrue();
}
Also used : AwsBatchDescribeJobsCache(pipelite.executor.describe.cache.AwsBatchDescribeJobsCache) ServiceConfiguration(pipelite.configuration.ServiceConfiguration) AwsBatchExecutor(pipelite.executor.AwsBatchExecutor) InternalErrorService(pipelite.service.InternalErrorService) AwsBatchExecutorParameters(pipelite.stage.parameters.AwsBatchExecutorParameters) Test(org.junit.jupiter.api.Test)

Example 2 with AwsBatchExecutorParameters

use of pipelite.stage.parameters.AwsBatchExecutorParameters in project pipelite by enasequence.

the class AwsBatchExecutor method submit.

@Override
protected SubmitResult submit(StageExecutorRequest request) {
    logContext(log.atFine(), request).log("Submitting AWSBatch job.");
    AwsBatchExecutorParameters params = getExecutorParams();
    region = params.getRegion();
    SubmitJobRequest submitJobRequest = new SubmitJobRequest().withJobName(awsBatchJobName(request)).withJobQueue(params.getQueue()).withJobDefinition(params.getDefinition()).withParameters(params.getParameters()).withTimeout(new JobTimeout().withAttemptDurationSeconds((int) params.getTimeout().getSeconds()));
    // TODO: .withContainerOverrides()
    AWSBatch awsBatch = awsBatchClient(region);
    SubmitJobResult submitJobResult = RetryTask.DEFAULT.execute(r -> awsBatch.submitJob(submitJobRequest));
    if (submitJobResult == null || submitJobResult.getJobId() == null) {
        throw new PipeliteException("Missing AWSBatch submit job id.");
    }
    String jobId = submitJobResult.getJobId();
    logContext(log.atInfo(), request).log("Submitted AWSBatch job " + getJobId());
    return new SubmitResult(jobId, StageExecutorResult.submitted());
}
Also used : AWSBatch(com.amazonaws.services.batch.AWSBatch) AwsBatchExecutorParameters(pipelite.stage.parameters.AwsBatchExecutorParameters) PipeliteException(pipelite.exception.PipeliteException)

Aggregations

AwsBatchExecutorParameters (pipelite.stage.parameters.AwsBatchExecutorParameters)2 AWSBatch (com.amazonaws.services.batch.AWSBatch)1 Test (org.junit.jupiter.api.Test)1 ServiceConfiguration (pipelite.configuration.ServiceConfiguration)1 PipeliteException (pipelite.exception.PipeliteException)1 AwsBatchExecutor (pipelite.executor.AwsBatchExecutor)1 AwsBatchDescribeJobsCache (pipelite.executor.describe.cache.AwsBatchDescribeJobsCache)1 InternalErrorService (pipelite.service.InternalErrorService)1