Skip to content

Commit

Permalink
creating new step for shutting down acession generator
Browse files Browse the repository at this point in the history
  • Loading branch information
nitin-ebi committed Apr 18, 2024
1 parent 691e87f commit e1fd1be
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -42,13 +43,15 @@ 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())
.start(processRSMergeCandidatesStep)
.next(processRSSplitCandidatesStep)
.next(clearRSMergeAndSplitCandidatesStep)
.next(clusteringNonClusteredVariantsFromMongoStep)
.next(accessioningShutdownStep)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class DbsnpMonotonicAccessionGenerator<MODEL> extends MonotonicAccessionG

public DbsnpMonotonicAccessionGenerator(String categoryId, String applicationInstanceId,
ContiguousIdBlockService contiguousIdBlockService) {
super(categoryId, applicationInstanceId, contiguousIdBlockService, (long[])null);
super(categoryId, applicationInstanceId, contiguousIdBlockService, null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,9 @@ public AccessionWrapper<IClusteredVariant, String, Long> getLastInactive(Long ac
}
}

public void shutDownAccessionGenerator(){
accessioningService.shutDownAccessioning();
accessioningServiceDbsnp.shutDownAccessioning();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Variant, SubmittedVariantEntity> {
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}

0 comments on commit e1fd1be

Please sign in to comment.