@Override
public void run() {
if (Coordinator.isPeriodicallyForceBuildEnable()) {
LOG.info("CoordinatorTrigger started ... ");
Stopwatch watch = Stopwatch.createStarted();
ZKConfig zkConfig = ZKConfigBuilder.getZKConfig(config);
try (ExclusiveExecutor executor = new ExclusiveExecutor(zkConfig)) {
executor.execute(Coordinator.GREEDY_SCHEDULER_ZK_PATH, () -> {
IScheduleContext context = new ScheduleContextBuilder(config, client).buildContext();
TopologyMgmtService mgmtService = new TopologyMgmtService();
IPolicyScheduler scheduler = PolicySchedulerFactory.createScheduler();
scheduler.init(context, mgmtService);
ScheduleState state = scheduler.schedule(new ScheduleOption());
try (ConfigBusProducer producer = new ConfigBusProducer(ZKConfigBuilder.getZKConfig(config))) {
Coordinator.postSchedule(client, state, producer);
}
watch.stop();
LOG.info("CoordinatorTrigger ended, used time {} sm.", watch.elapsed(TimeUnit.MILLISECONDS));
});
} catch (Exception e) {
LOG.error("trigger schedule failed!", e);
}
} else {
LOG.info("CoordinatorTrigger found isPeriodicallyForceBuildEnable = false, skipped build");
}
}