-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EVA-3570 Add jobs for recovering blocks through recovery agent for ca…
…tegory ss and rs (#447) add recovery jobs using monotonic accession recovery agent to recover blocks for category ss and rs
- Loading branch information
Showing
39 changed files
with
1,285 additions
and
20 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...in/java/uk/ac/ebi/eva/accession/clustering/batch/recovery/RSAccessionRecoveryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package uk.ac.ebi.eva.accession.clustering.batch.recovery; | ||
|
||
import org.springframework.batch.core.JobExecution; | ||
import uk.ac.ebi.ampt2d.commons.accession.generators.monotonic.MonotonicAccessionRecoveryAgent; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
public class RSAccessionRecoveryService { | ||
private final static String CATEGORY_ID = "rs"; | ||
private MonotonicAccessionRecoveryAgent monotonicAccessionRecoveryAgent; | ||
private JobExecution jobExecution; | ||
private long recoveryCutOffDays; | ||
|
||
public RSAccessionRecoveryService(MonotonicAccessionRecoveryAgent monotonicAccessionRecoveryAgent, | ||
long recoveryCutOffDays) { | ||
this.monotonicAccessionRecoveryAgent = monotonicAccessionRecoveryAgent; | ||
this.recoveryCutOffDays = recoveryCutOffDays; | ||
} | ||
|
||
public void runRecoveryForCategoryRS() { | ||
LocalDateTime recoveryCutOffTime = LocalDateTime.now().minusDays(recoveryCutOffDays); | ||
monotonicAccessionRecoveryAgent.runRecovery(CATEGORY_ID, jobExecution.getJobId().toString(), recoveryCutOffTime); | ||
} | ||
|
||
public void setJobExecution(JobExecution jobExecution) { | ||
this.jobExecution = jobExecution; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...va/accession/clustering/configuration/batch/jobs/RSAccessionRecoveryJobConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package uk.ac.ebi.eva.accession.clustering.configuration.batch.jobs; | ||
|
||
import org.springframework.batch.core.Job; | ||
import org.springframework.batch.core.JobExecutionListener; | ||
import org.springframework.batch.core.Step; | ||
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; | ||
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; | ||
import org.springframework.batch.core.launch.support.RunIdIncrementer; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import static uk.ac.ebi.eva.accession.clustering.configuration.BeanNames.RS_ACCESSION_RECOVERY_JOB; | ||
import static uk.ac.ebi.eva.accession.clustering.configuration.BeanNames.RS_ACCESSION_RECOVERY_JOB_LISTENER; | ||
import static uk.ac.ebi.eva.accession.clustering.configuration.BeanNames.RS_ACCESSION_RECOVERY_STEP; | ||
|
||
@Configuration | ||
@EnableBatchProcessing | ||
public class RSAccessionRecoveryJobConfiguration { | ||
|
||
@Autowired | ||
@Qualifier(RS_ACCESSION_RECOVERY_STEP) | ||
private Step monotonicAccessionRecoveryAgentCategoryRSStep; | ||
|
||
@Autowired | ||
@Qualifier(RS_ACCESSION_RECOVERY_JOB_LISTENER) | ||
private JobExecutionListener monotonicAccessionRecoveryAgentCategoryRSJobListener; | ||
|
||
@Bean(RS_ACCESSION_RECOVERY_JOB) | ||
public Job createMonotonicAccessionRecoveryAgentCategoryRSJob(JobBuilderFactory jobBuilderFactory) { | ||
return jobBuilderFactory.get(RS_ACCESSION_RECOVERY_JOB) | ||
.incrementer(new RunIdIncrementer()) | ||
.start(monotonicAccessionRecoveryAgentCategoryRSStep) | ||
.listener(monotonicAccessionRecoveryAgentCategoryRSJobListener) | ||
.build(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...clustering/configuration/batch/listeners/RSAccessionRecoveryJobListenerConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package uk.ac.ebi.eva.accession.clustering.configuration.batch.listeners; | ||
|
||
import org.springframework.batch.core.JobExecution; | ||
import org.springframework.batch.core.JobExecutionListener; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import uk.ac.ebi.eva.accession.clustering.batch.recovery.RSAccessionRecoveryService; | ||
|
||
import static uk.ac.ebi.eva.accession.clustering.configuration.BeanNames.RS_ACCESSION_RECOVERY_JOB_LISTENER; | ||
import static uk.ac.ebi.eva.accession.clustering.configuration.BeanNames.RS_ACCESSION_RECOVERY_SERVICE; | ||
|
||
@Configuration | ||
public class RSAccessionRecoveryJobListenerConfiguration { | ||
@Bean(RS_ACCESSION_RECOVERY_JOB_LISTENER) | ||
public JobExecutionListener jobExecutionListener(@Qualifier(RS_ACCESSION_RECOVERY_SERVICE) | ||
RSAccessionRecoveryService RSAccessionRecoveryService) { | ||
return new JobExecutionListener() { | ||
@Override | ||
public void beforeJob(JobExecution jobExecution) { | ||
RSAccessionRecoveryService.setJobExecution(jobExecution); | ||
} | ||
|
||
@Override | ||
public void afterJob(JobExecution jobExecution) { | ||
} | ||
}; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...sion/clustering/configuration/batch/recovery/RSAccessionRecoveryServiceConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package uk.ac.ebi.eva.accession.clustering.configuration.batch.recovery; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import uk.ac.ebi.ampt2d.commons.accession.generators.monotonic.MonotonicAccessionRecoveryAgent; | ||
import uk.ac.ebi.ampt2d.commons.accession.persistence.jpa.monotonic.service.ContiguousIdBlockService; | ||
import uk.ac.ebi.eva.accession.clustering.batch.recovery.RSAccessionRecoveryService; | ||
import uk.ac.ebi.eva.accession.core.service.nonhuman.eva.ClusteredVariantAccessioningDatabaseService; | ||
|
||
import static uk.ac.ebi.eva.accession.clustering.configuration.BeanNames.RS_ACCESSION_RECOVERY_SERVICE; | ||
|
||
@Configuration | ||
public class RSAccessionRecoveryServiceConfiguration { | ||
@Autowired | ||
private ContiguousIdBlockService blockService; | ||
@Autowired | ||
private ClusteredVariantAccessioningDatabaseService clusteredVariantAccessioningDatabaseService; | ||
|
||
@Value("${recovery.cutoff.days}") | ||
private long recoveryCutOffDays; | ||
|
||
@Bean(RS_ACCESSION_RECOVERY_SERVICE) | ||
public RSAccessionRecoveryService getMonotonicAccessionRecoveryAgentCategoryRSService() { | ||
return new RSAccessionRecoveryService(getMonotonicAccessionRecoveryAgent(), recoveryCutOffDays); | ||
} | ||
|
||
private MonotonicAccessionRecoveryAgent getMonotonicAccessionRecoveryAgent() { | ||
return new MonotonicAccessionRecoveryAgent(blockService, clusteredVariantAccessioningDatabaseService); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
.../accession/clustering/configuration/batch/steps/RSAccessionRecoveryStepConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
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.beans.factory.annotation.Qualifier; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import uk.ac.ebi.eva.accession.clustering.batch.recovery.RSAccessionRecoveryService; | ||
|
||
import static uk.ac.ebi.eva.accession.clustering.configuration.BeanNames.RS_ACCESSION_RECOVERY_SERVICE; | ||
import static uk.ac.ebi.eva.accession.clustering.configuration.BeanNames.RS_ACCESSION_RECOVERY_STEP; | ||
|
||
@Configuration | ||
@EnableBatchProcessing | ||
public class RSAccessionRecoveryStepConfiguration { | ||
@Autowired | ||
@Qualifier(RS_ACCESSION_RECOVERY_SERVICE) | ||
private RSAccessionRecoveryService RSAccessionRecoveryService; | ||
|
||
@Bean(RS_ACCESSION_RECOVERY_STEP) | ||
public Step monotonicAccessionRecoveryAgentCategoryRSStep(StepBuilderFactory stepBuilderFactory) { | ||
return stepBuilderFactory.get(RS_ACCESSION_RECOVERY_STEP) | ||
.tasklet((contribution, chunkContext) -> { | ||
RSAccessionRecoveryService.runRecoveryForCategoryRS(); | ||
return null; | ||
}) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.