diff --git a/eva-accession-clustering/src/main/java/uk/ac/ebi/eva/accession/clustering/configuration/BeanNames.java b/eva-accession-clustering/src/main/java/uk/ac/ebi/eva/accession/clustering/configuration/BeanNames.java index 26c704e7e..927c29213 100644 --- a/eva-accession-clustering/src/main/java/uk/ac/ebi/eva/accession/clustering/configuration/BeanNames.java +++ b/eva-accession-clustering/src/main/java/uk/ac/ebi/eva/accession/clustering/configuration/BeanNames.java @@ -55,6 +55,8 @@ public class BeanNames { public static final String PROGRESS_LISTENER = "PROGRESS_LISTENER"; + public static final String ACCESSIONING_SHUTDOWN_STEP = "ACCESSIONING_SHUTDOWN_STEP"; + public static final String CLUSTERING_FROM_VCF_STEP = "CLUSTERING_FROM_VCF_STEP"; public static final String CLUSTERING_CLUSTERED_VARIANTS_FROM_MONGO_STEP = "CLUSTERING_CLUSTERED_VARIANTS_FROM_MONGO_STEP"; diff --git a/eva-accession-clustering/src/main/java/uk/ac/ebi/eva/accession/clustering/configuration/batch/jobs/ClusterUnclusteredVariantsJobConfiguration.java b/eva-accession-clustering/src/main/java/uk/ac/ebi/eva/accession/clustering/configuration/batch/jobs/ClusterUnclusteredVariantsJobConfiguration.java index df7c621c3..b9517c10a 100644 --- a/eva-accession-clustering/src/main/java/uk/ac/ebi/eva/accession/clustering/configuration/batch/jobs/ClusterUnclusteredVariantsJobConfiguration.java +++ b/eva-accession-clustering/src/main/java/uk/ac/ebi/eva/accession/clustering/configuration/batch/jobs/ClusterUnclusteredVariantsJobConfiguration.java @@ -24,6 +24,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import static uk.ac.ebi.eva.accession.clustering.configuration.BeanNames.ACCESSIONING_SHUTDOWN_STEP; import static uk.ac.ebi.eva.accession.clustering.configuration.BeanNames.CLEAR_RS_MERGE_AND_SPLIT_CANDIDATES_STEP; import static uk.ac.ebi.eva.accession.clustering.configuration.BeanNames.CLUSTERING_NON_CLUSTERED_VARIANTS_FROM_MONGO_STEP; import static uk.ac.ebi.eva.accession.clustering.configuration.BeanNames.CLUSTER_UNCLUSTERED_VARIANTS_JOB; @@ -42,6 +43,7 @@ public Job clusteringFromMongoJob( @Qualifier(PROCESS_RS_SPLIT_CANDIDATES_STEP) Step processRSSplitCandidatesStep, @Qualifier(CLEAR_RS_MERGE_AND_SPLIT_CANDIDATES_STEP) Step clearRSMergeAndSplitCandidatesStep, @Qualifier(CLUSTERING_NON_CLUSTERED_VARIANTS_FROM_MONGO_STEP) Step clusteringNonClusteredVariantsFromMongoStep, + @Qualifier(ACCESSIONING_SHUTDOWN_STEP) Step accessioningShutdownStep, JobBuilderFactory jobBuilderFactory) { return jobBuilderFactory.get(CLUSTER_UNCLUSTERED_VARIANTS_JOB) .incrementer(new RunIdIncrementer()) @@ -49,6 +51,7 @@ public Job clusteringFromMongoJob( .next(processRSSplitCandidatesStep) .next(clearRSMergeAndSplitCandidatesStep) .next(clusteringNonClusteredVariantsFromMongoStep) + .next(accessioningShutdownStep) .build(); } } diff --git a/eva-accession-clustering/src/main/java/uk/ac/ebi/eva/accession/clustering/configuration/batch/jobs/ClusteringFromMongoJobConfiguration.java b/eva-accession-clustering/src/main/java/uk/ac/ebi/eva/accession/clustering/configuration/batch/jobs/ClusteringFromMongoJobConfiguration.java index 16a422fcd..786900cd2 100644 --- a/eva-accession-clustering/src/main/java/uk/ac/ebi/eva/accession/clustering/configuration/batch/jobs/ClusteringFromMongoJobConfiguration.java +++ b/eva-accession-clustering/src/main/java/uk/ac/ebi/eva/accession/clustering/configuration/batch/jobs/ClusteringFromMongoJobConfiguration.java @@ -40,6 +40,7 @@ import uk.ac.ebi.eva.accession.clustering.parameters.InputParameters; +import static uk.ac.ebi.eva.accession.clustering.configuration.BeanNames.ACCESSIONING_SHUTDOWN_STEP; import static uk.ac.ebi.eva.accession.clustering.configuration.BeanNames.BACK_PROPAGATE_NEW_RS_STEP; import static uk.ac.ebi.eva.accession.clustering.configuration.BeanNames.BACK_PROPAGATE_SPLIT_OR_MERGED_RS_STEP; import static uk.ac.ebi.eva.accession.clustering.configuration.BeanNames.CLEAR_RS_MERGE_AND_SPLIT_CANDIDATES_STEP; @@ -79,6 +80,7 @@ public Job clusteringFromMongoJob(@Qualifier(CLUSTERING_CLUSTERED_VARIANTS_FROM_ @Qualifier(PROCESS_RS_SPLIT_CANDIDATES_STEP) Step processRSSplitCandidatesStep, @Qualifier(CLEAR_RS_MERGE_AND_SPLIT_CANDIDATES_STEP) Step clearRSMergeAndSplitCandidatesStep, @Qualifier(CLUSTERING_NON_CLUSTERED_VARIANTS_FROM_MONGO_STEP) Step clusteringNonClusteredVariantsFromMongoStep, + @Qualifier(ACCESSIONING_SHUTDOWN_STEP) Step accessioningShutdownStep, // Back-propagate RS that were newly created in the remapped assembly @Qualifier(BACK_PROPAGATE_NEW_RS_STEP) Step backPropagateNewRSStep, // Back-propagate RS in the remapped assembly that were split or merged @@ -101,12 +103,14 @@ public Job clusteringFromMongoJob(@Qualifier(CLUSTERING_CLUSTERED_VARIANTS_FROM_ .next(processRSSplitCandidatesStep) .next(clearRSMergeAndSplitCandidatesStep) .next(clusteringNonClusteredVariantsFromMongoStep) + .next(accessioningShutdownStep) .next(backPropagateNewRSStep) .next(backPropagateSplitMergedRSStep).build()) .on("*").end() .from(jobExecutionDecider) .on("FALSE") .to(clusteringNonClusteredVariantsFromMongoStep) + .next(accessioningShutdownStep) .on("*").end() .end().build(); } diff --git a/eva-accession-clustering/src/main/java/uk/ac/ebi/eva/accession/clustering/configuration/batch/jobs/StudyClusteringJobConfiguration.java b/eva-accession-clustering/src/main/java/uk/ac/ebi/eva/accession/clustering/configuration/batch/jobs/StudyClusteringJobConfiguration.java index 5d78ca2ec..4b4262503 100644 --- a/eva-accession-clustering/src/main/java/uk/ac/ebi/eva/accession/clustering/configuration/batch/jobs/StudyClusteringJobConfiguration.java +++ b/eva-accession-clustering/src/main/java/uk/ac/ebi/eva/accession/clustering/configuration/batch/jobs/StudyClusteringJobConfiguration.java @@ -24,6 +24,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import static uk.ac.ebi.eva.accession.clustering.configuration.BeanNames.ACCESSIONING_SHUTDOWN_STEP; import static uk.ac.ebi.eva.accession.clustering.configuration.BeanNames.STUDY_CLUSTERING_JOB; import static uk.ac.ebi.eva.accession.clustering.configuration.BeanNames.STUDY_CLUSTERING_STEP; @@ -33,10 +34,12 @@ public class StudyClusteringJobConfiguration { @Bean(STUDY_CLUSTERING_JOB) public Job studyClusteringJob(@Qualifier(STUDY_CLUSTERING_STEP) Step clusteringStep, + @Qualifier(ACCESSIONING_SHUTDOWN_STEP) Step accessioningShutdownStep, JobBuilderFactory jobBuilderFactory) { return jobBuilderFactory.get(STUDY_CLUSTERING_JOB) .incrementer(new RunIdIncrementer()) .start(clusteringStep) + .next(accessioningShutdownStep) .build(); } } diff --git a/eva-accession-clustering/src/main/java/uk/ac/ebi/eva/accession/clustering/configuration/batch/steps/AccessioningShutdownStep.java b/eva-accession-clustering/src/main/java/uk/ac/ebi/eva/accession/clustering/configuration/batch/steps/AccessioningShutdownStep.java new file mode 100644 index 000000000..05bc5c844 --- /dev/null +++ b/eva-accession-clustering/src/main/java/uk/ac/ebi/eva/accession/clustering/configuration/batch/steps/AccessioningShutdownStep.java @@ -0,0 +1,33 @@ +package uk.ac.ebi.eva.accession.clustering.configuration.batch.steps; + +import org.springframework.batch.core.Step; +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import uk.ac.ebi.eva.accession.core.service.nonhuman.ClusteredVariantAccessioningService; +import uk.ac.ebi.eva.accession.core.service.nonhuman.SubmittedVariantAccessioningService; + +import static uk.ac.ebi.eva.accession.clustering.configuration.BeanNames.ACCESSIONING_SHUTDOWN_STEP; + +@Configuration +@EnableBatchProcessing +public class AccessioningShutdownStep { + @Autowired + private SubmittedVariantAccessioningService submittedVariantAccessioningService; + + @Autowired + private ClusteredVariantAccessioningService clusteredVariantAccessioningService; + + @Bean(ACCESSIONING_SHUTDOWN_STEP) + public Step accessioningShutDownStep(StepBuilderFactory stepBuilderFactory) { + return stepBuilderFactory.get("accessioningShutdownStep") + .tasklet((contribution, chunkContext) -> { + submittedVariantAccessioningService.shutDownAccessionGenerator(); + clusteredVariantAccessioningService.shutDownAccessionGenerator(); + return null; + }) + .build(); + } +} \ No newline at end of file diff --git a/eva-accession-core/src/main/java/uk/ac/ebi/eva/accession/core/generators/DbsnpMonotonicAccessionGenerator.java b/eva-accession-core/src/main/java/uk/ac/ebi/eva/accession/core/generators/DbsnpMonotonicAccessionGenerator.java index cfdf9713b..a6d5bff6b 100644 --- a/eva-accession-core/src/main/java/uk/ac/ebi/eva/accession/core/generators/DbsnpMonotonicAccessionGenerator.java +++ b/eva-accession-core/src/main/java/uk/ac/ebi/eva/accession/core/generators/DbsnpMonotonicAccessionGenerator.java @@ -30,7 +30,7 @@ public class DbsnpMonotonicAccessionGenerator extends MonotonicAccessionG public DbsnpMonotonicAccessionGenerator(String categoryId, String applicationInstanceId, ContiguousIdBlockService contiguousIdBlockService) { - super(categoryId, applicationInstanceId, contiguousIdBlockService, (long[])null); + super(categoryId, applicationInstanceId, contiguousIdBlockService, null); } @Override diff --git a/eva-accession-core/src/main/java/uk/ac/ebi/eva/accession/core/service/nonhuman/ClusteredVariantAccessioningService.java b/eva-accession-core/src/main/java/uk/ac/ebi/eva/accession/core/service/nonhuman/ClusteredVariantAccessioningService.java index 93a5bf20e..cde6aad1f 100644 --- a/eva-accession-core/src/main/java/uk/ac/ebi/eva/accession/core/service/nonhuman/ClusteredVariantAccessioningService.java +++ b/eva-accession-core/src/main/java/uk/ac/ebi/eva/accession/core/service/nonhuman/ClusteredVariantAccessioningService.java @@ -243,4 +243,9 @@ public AccessionWrapper getLastInactive(Long ac } } + public void shutDownAccessionGenerator(){ + accessioningService.shutDownAccessioning(); + accessioningServiceDbsnp.shutDownAccessioning(); + } + } diff --git a/eva-accession-pipeline/src/main/java/uk/ac/ebi/eva/accession/pipeline/batch/listeners/SubsnpAccessionsStepListener.java b/eva-accession-pipeline/src/main/java/uk/ac/ebi/eva/accession/pipeline/batch/listeners/SubsnpAccessionsStepListener.java index 5d45ebb45..673e8a4bb 100644 --- a/eva-accession-pipeline/src/main/java/uk/ac/ebi/eva/accession/pipeline/batch/listeners/SubsnpAccessionsStepListener.java +++ b/eva-accession-pipeline/src/main/java/uk/ac/ebi/eva/accession/pipeline/batch/listeners/SubsnpAccessionsStepListener.java @@ -4,26 +4,21 @@ import org.springframework.batch.core.StepExecution; import uk.ac.ebi.eva.accession.core.batch.listeners.GenericProgressListener; import uk.ac.ebi.eva.accession.core.model.eva.SubmittedVariantEntity; -import uk.ac.ebi.eva.accession.core.service.nonhuman.SubmittedVariantAccessioningService; import uk.ac.ebi.eva.accession.pipeline.parameters.InputParameters; import uk.ac.ebi.eva.commons.core.models.pipeline.Variant; import uk.ac.ebi.eva.metrics.metric.MetricCompute; public class SubsnpAccessionsStepListener extends GenericProgressListener { private final MetricCompute metricCompute; - private final SubmittedVariantAccessioningService submittedVariantAccessioningService; - public SubsnpAccessionsStepListener(InputParameters inputParameters, MetricCompute metricCompute, - SubmittedVariantAccessioningService submittedVariantAccessioningService) { + public SubsnpAccessionsStepListener(InputParameters inputParameters, MetricCompute metricCompute) { super(inputParameters.getChunkSize()); this.metricCompute = metricCompute; - this.submittedVariantAccessioningService = submittedVariantAccessioningService; } @Override public ExitStatus afterStep(StepExecution stepExecution) { ExitStatus status = super.afterStep(stepExecution); - submittedVariantAccessioningService.shutDownAccessionGenerator(); metricCompute.saveMetricsCountsInDB(); return status; } diff --git a/eva-accession-pipeline/src/main/java/uk/ac/ebi/eva/accession/pipeline/configuration/BeanNames.java b/eva-accession-pipeline/src/main/java/uk/ac/ebi/eva/accession/pipeline/configuration/BeanNames.java index 4e924ac67..f6f92fd04 100644 --- a/eva-accession-pipeline/src/main/java/uk/ac/ebi/eva/accession/pipeline/configuration/BeanNames.java +++ b/eva-accession-pipeline/src/main/java/uk/ac/ebi/eva/accession/pipeline/configuration/BeanNames.java @@ -35,4 +35,6 @@ public class BeanNames { public static final String CREATE_SUBSNP_ACCESSION_JOB = "CREATE_SUBSNP_ACCESSION_JOB"; public static final String SUBSNP_ACCESSION_STEP_LISTENER = "SUBSNP_ACCESSION_STEP_LISTENER"; + + public static final String ACCESSIONING_SHUTDOWN_STEP = "ACCESSIONING_SHUTDOWN_STEP"; } diff --git a/eva-accession-pipeline/src/main/java/uk/ac/ebi/eva/accession/pipeline/configuration/batch/jobs/CreateSubsnpAccessionsJobConfiguration.java b/eva-accession-pipeline/src/main/java/uk/ac/ebi/eva/accession/pipeline/configuration/batch/jobs/CreateSubsnpAccessionsJobConfiguration.java index 27fe57eef..03ea811e4 100644 --- a/eva-accession-pipeline/src/main/java/uk/ac/ebi/eva/accession/pipeline/configuration/batch/jobs/CreateSubsnpAccessionsJobConfiguration.java +++ b/eva-accession-pipeline/src/main/java/uk/ac/ebi/eva/accession/pipeline/configuration/batch/jobs/CreateSubsnpAccessionsJobConfiguration.java @@ -26,6 +26,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import static uk.ac.ebi.eva.accession.pipeline.configuration.BeanNames.ACCESSIONING_SHUTDOWN_STEP; import static uk.ac.ebi.eva.accession.pipeline.configuration.BeanNames.BUILD_REPORT_STEP; import static uk.ac.ebi.eva.accession.pipeline.configuration.BeanNames.CHECK_SUBSNP_ACCESSION_STEP; import static uk.ac.ebi.eva.accession.pipeline.configuration.BeanNames.CREATE_SUBSNP_ACCESSION_JOB; @@ -47,11 +48,16 @@ public class CreateSubsnpAccessionsJobConfiguration { @Qualifier(BUILD_REPORT_STEP) private Step buildReportStep; + @Autowired + @Qualifier(ACCESSIONING_SHUTDOWN_STEP) + private Step accessioningShutdownStep; + @Bean(CREATE_SUBSNP_ACCESSION_JOB) public Job createSubsnpAccessionJob(JobBuilderFactory jobBuilderFactory) { return jobBuilderFactory.get(CREATE_SUBSNP_ACCESSION_JOB) .incrementer(new RunIdIncrementer()) .start(createSubsnpAccessionStep) + .next(accessioningShutdownStep) .next(buildReportStep) .next(checkSubsnpAccessionStep) .build(); diff --git a/eva-accession-pipeline/src/main/java/uk/ac/ebi/eva/accession/pipeline/configuration/batch/listeners/ListenersConfiguration.java b/eva-accession-pipeline/src/main/java/uk/ac/ebi/eva/accession/pipeline/configuration/batch/listeners/ListenersConfiguration.java index 6150bbc7c..bb183662d 100644 --- a/eva-accession-pipeline/src/main/java/uk/ac/ebi/eva/accession/pipeline/configuration/batch/listeners/ListenersConfiguration.java +++ b/eva-accession-pipeline/src/main/java/uk/ac/ebi/eva/accession/pipeline/configuration/batch/listeners/ListenersConfiguration.java @@ -5,7 +5,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.web.client.RestTemplate; -import uk.ac.ebi.eva.accession.core.service.nonhuman.SubmittedVariantAccessioningService; import uk.ac.ebi.eva.accession.pipeline.batch.listeners.SubsnpAccessionsStepListener; import uk.ac.ebi.eva.accession.pipeline.metric.AccessioningMetricCompute; import uk.ac.ebi.eva.accession.pipeline.parameters.InputParameters; @@ -19,9 +18,8 @@ @Import({MetricConfiguration.class}) public class ListenersConfiguration { @Bean(SUBSNP_ACCESSION_STEP_LISTENER) - public SubsnpAccessionsStepListener clusteringProgressListener(InputParameters parameters, MetricCompute metricCompute, - SubmittedVariantAccessioningService submittedVariantAccessioningService) { - return new SubsnpAccessionsStepListener(parameters, metricCompute, submittedVariantAccessioningService); + public SubsnpAccessionsStepListener clusteringProgressListener(InputParameters parameters, MetricCompute metricCompute) { + return new SubsnpAccessionsStepListener(parameters, metricCompute); } @Bean diff --git a/eva-accession-pipeline/src/main/java/uk/ac/ebi/eva/accession/pipeline/configuration/batch/steps/AccessioningShutdownStep.java b/eva-accession-pipeline/src/main/java/uk/ac/ebi/eva/accession/pipeline/configuration/batch/steps/AccessioningShutdownStep.java new file mode 100644 index 000000000..e9eafcfa7 --- /dev/null +++ b/eva-accession-pipeline/src/main/java/uk/ac/ebi/eva/accession/pipeline/configuration/batch/steps/AccessioningShutdownStep.java @@ -0,0 +1,28 @@ +package uk.ac.ebi.eva.accession.pipeline.configuration.batch.steps; + +import org.springframework.batch.core.Step; +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import uk.ac.ebi.eva.accession.core.service.nonhuman.SubmittedVariantAccessioningService; + +import static uk.ac.ebi.eva.accession.pipeline.configuration.BeanNames.ACCESSIONING_SHUTDOWN_STEP; + +@Configuration +@EnableBatchProcessing +public class AccessioningShutdownStep { + @Autowired + private SubmittedVariantAccessioningService submittedVariantAccessioningService; + + @Bean(ACCESSIONING_SHUTDOWN_STEP) + public Step accessioningShutDownStep(StepBuilderFactory stepBuilderFactory) { + return stepBuilderFactory.get("accessioningShutdownStep") + .tasklet((contribution, chunkContext) -> { + submittedVariantAccessioningService.shutDownAccessionGenerator(); + return null; + }) + .build(); + } +} \ No newline at end of file