fix(error-apps): reset apps in error state (#19052)

This commit is contained in:
Imri Paran 2024-12-19 14:03:01 +01:00 committed by GitHub
parent efbdf21098
commit 6fab88a3d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -38,6 +38,7 @@ import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.TriggerKey;
import org.quartz.impl.StdSchedulerFactory;
import org.quartz.impl.matchers.GroupMatcher;
@Slf4j
public class AppScheduler {
@ -93,10 +94,32 @@ public class AppScheduler {
.getListenerManager()
.addJobListener(new OmAppJobListener(dao), jobGroupEquals(APPS_JOB_GROUP));
this.resetErrorTriggers();
// Start Scheduler
this.scheduler.start();
}
private void resetErrorTriggers() {
try {
scheduler
.getTriggerKeys(GroupMatcher.anyGroup())
.forEach(
triggerKey -> {
try {
if (scheduler.getTriggerState(triggerKey) == Trigger.TriggerState.ERROR) {
LOG.info("Resetting trigger {} from error state", triggerKey);
scheduler.resetTriggerFromErrorState(triggerKey);
}
} catch (SchedulerException e) {
throw new RuntimeException(e);
}
});
} catch (SchedulerException ex) {
LOG.error("Failed to reset failed triggers", ex);
}
}
public static void initialize(
OpenMetadataApplicationConfig config, CollectionDAO dao, SearchRepository searchClient)
throws SchedulerException {