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();
}
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());
}
Aggregations