scheduled cleaning of runtime table
This commit is contained in:
parent
4a44920db4
commit
ead5f14c1c
|
@ -0,0 +1,39 @@
|
|||
package eu.dnetlib.wfs.manager.service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import eu.dnetlib.wfs.repository.WfRunningJobRepository;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
|
||||
@Service
|
||||
public class ScheduledActions {
|
||||
|
||||
private static final Log log = LogFactory.getLog(ScheduledActions.class);
|
||||
|
||||
@Autowired
|
||||
private WfRunningJobRepository jobRepository;
|
||||
|
||||
@PostConstruct
|
||||
public void firstCheck() {
|
||||
deleteOldWfJobs();
|
||||
}
|
||||
|
||||
@Scheduled(initialDelay = 0, fixedRate = 12, timeUnit = TimeUnit.HOURS)
|
||||
public void cleanAndCheck() {
|
||||
deleteOldWfJobs();
|
||||
}
|
||||
|
||||
private void deleteOldWfJobs() {
|
||||
log.info("Deleting old jobs");
|
||||
final LocalDateTime date = LocalDateTime.now().minusHours(24);
|
||||
this.jobRepository.deleteOldJobs(date);
|
||||
}
|
||||
|
||||
}
|
|
@ -177,9 +177,12 @@
|
|||
<mat-icon fontIcon="edit"></mat-icon>
|
||||
config
|
||||
</button>
|
||||
<button mat-stroked-button (click)="showGraphModal(wf)">
|
||||
<button mat-stroked-button (click)="showGraphModal(wf.workflow)">
|
||||
<mat-icon fontIcon="polyline"></mat-icon> graph
|
||||
</button>
|
||||
<button mat-stroked-button (click)="showGraphModal(wf.destroyWf)" *ngIf="wf.destroyWf">
|
||||
<mat-icon fontIcon="polyline"></mat-icon> graph (destroy)
|
||||
</button>
|
||||
<button mat-stroked-button color="warn" (click)="destroyWfConf(wf.id)">
|
||||
<mat-icon fontIcon="delete"></mat-icon>
|
||||
delete
|
||||
|
|
|
@ -232,8 +232,8 @@ export class DsmApiComponent implements OnInit {
|
|||
dialogRef.afterClosed().subscribe(result => this.reloadWfs());
|
||||
}
|
||||
|
||||
showGraphModal(conf: WfConf): void {
|
||||
this.client.dsmGetWfTemplate(conf.workflow, (data: WfTemplateDesc) => this.dialog.open(WfTemplateDialog, { data: data, width: '80%' }));
|
||||
showGraphModal(wfId: string): void {
|
||||
this.client.dsmGetWfTemplate(wfId, (data: WfTemplateDesc) => this.dialog.open(WfTemplateDialog, { data: data, width: '80%' }));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<h1 mat-dialog-title>Workflow Template</h1>
|
||||
<h1 mat-dialog-title title="{{template.description}}">Workflow Template: {{template.name}}</h1>
|
||||
|
||||
<div mat-dialog-content>
|
||||
|
||||
<mat-tab-group mat-stretch-tabs="false" mat-align-tabs="start" animationDuration="0ms">
|
||||
<mat-tab label="Graph">
|
||||
<div style="height: 500px; overflow: scroll;">
|
||||
|
|
|
@ -17,4 +17,9 @@ public interface WfRunningJobRepository extends JpaRepository<WfRunningJob, Stri
|
|||
@Query(value = "update WfRunningJob set wfExecutor = ?2, status = ?3, startDate = ?4, lastUpdate = ?4 where processId = ?1 and wfExecutor is NULL")
|
||||
void tryAssegnment(String id, String workerId, JobStatus status, LocalDateTime startDate);
|
||||
|
||||
@Modifying
|
||||
@Transactional
|
||||
@Query(value = "delete from WfRunningJob where endDate is NOT NULL and endDate < ?1 and status IN ('success','failure','killed')")
|
||||
void deleteOldJobs(LocalDateTime date);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue