-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathCron.java
More file actions
42 lines (32 loc) · 932 Bytes
/
Cron.java
File metadata and controls
42 lines (32 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package jenkins.plugins.git.maintenance;
import hudson.Extension;
import hudson.model.PeriodicWork;
import java.util.Calendar;
import java.util.concurrent.TimeUnit;
@Extension
public class Cron extends PeriodicWork {
private TaskScheduler taskScheduler;
@Override
public long getInitialDelay(){
return MIN - (Calendar.getInstance().get(Calendar.SECOND) * 1000L);
}
@Override
public long getRecurrencePeriod() {
return TimeUnit.MINUTES.toMillis(1);
}
@Override
protected void doRun(){
scheduleMaintenanceTask();
}
void terminateMaintenanceTaskExecution(){
if(taskScheduler != null){
taskScheduler.terminateMaintenanceTaskExecution();
}
}
private void scheduleMaintenanceTask(){
if(taskScheduler == null){
taskScheduler = new TaskScheduler();
}
taskScheduler.scheduleTasks();
}
}