initialize scheduler in constructor
Original commit: elastic/x-pack-elasticsearch@283ddf3aa3
This commit is contained in:
parent
3150bfa876
commit
827d68c7b0
|
@ -130,10 +130,8 @@ public class LicensesService extends AbstractLifecycleComponent implements Clust
|
|||
}
|
||||
populateExpirationCallbacks();
|
||||
this.clock = clock;
|
||||
}
|
||||
|
||||
protected SchedulerEngine getScheduler() {
|
||||
return new SchedulerEngine(clock);
|
||||
this.scheduler = new SchedulerEngine(clock);
|
||||
this.scheduler.register(this);
|
||||
}
|
||||
|
||||
private void populateExpirationCallbacks() {
|
||||
|
@ -395,10 +393,6 @@ public class LicensesService extends AbstractLifecycleComponent implements Clust
|
|||
|
||||
@Override
|
||||
protected void doStart() throws ElasticsearchException {
|
||||
if (scheduler == null) {
|
||||
this.scheduler = getScheduler();
|
||||
this.scheduler.register(this);
|
||||
}
|
||||
clusterService.add(this);
|
||||
try {
|
||||
scheduler.start(Collections.emptyList());
|
||||
|
@ -523,7 +517,8 @@ public class LicensesService extends AbstractLifecycleComponent implements Clust
|
|||
scheduler.add(new SchedulerEngine.Job(LICENSE_JOB, new LicenseSchedule(license)));
|
||||
for (ExpirationCallback expirationCallback : expirationCallbacks) {
|
||||
scheduler.add(new SchedulerEngine.Job(expirationCallback.getId(),
|
||||
expirationCallback.schedule(license.expiryDate())));
|
||||
(startTime, now) ->
|
||||
expirationCallback.nextScheduledTimeForExpiry(license.expiryDate(), startTime, now)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,20 +33,13 @@ public abstract class AbstractLicenseServiceTestCase extends ESTestCase {
|
|||
protected ClusterService clusterService;
|
||||
protected TransportService transportService;
|
||||
protected ClockMock clock;
|
||||
protected SchedulerEngine schedulerEngine;
|
||||
|
||||
@Before
|
||||
public void init() throws Exception {
|
||||
clusterService = mock(ClusterService.class);
|
||||
transportService = mock(TransportService.class);
|
||||
clock = new ClockMock();
|
||||
schedulerEngine = mock(SchedulerEngine.class);
|
||||
licensesService = new LicensesService(Settings.EMPTY, clusterService, transportService, clock) {
|
||||
@Override
|
||||
protected SchedulerEngine getScheduler() {
|
||||
return schedulerEngine;
|
||||
}
|
||||
};
|
||||
licensesService = new LicensesService(Settings.EMPTY, clusterService, transportService, clock);
|
||||
}
|
||||
|
||||
protected void setInitialState(License license) {
|
||||
|
|
Loading…
Reference in New Issue