diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/AbstractNativeApplication.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/AbstractNativeApplication.java index 9bdc74f2183..203599c3af0 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/AbstractNativeApplication.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/AbstractNativeApplication.java @@ -105,7 +105,7 @@ public class AbstractNativeApplication implements NativeApplication { AppRuntime runtime = JsonUtils.convertValue(app.getRuntime(), ScheduledExecutionContext.class); validateServerExecutableApp(runtime); // Schedule New Application Run - AppScheduler.getInstance().addApplicationSchedule(app); + AppScheduler.getInstance().scheduleApplication(app); } public void scheduleExternal() { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/ApplicationHandler.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/ApplicationHandler.java index c62a0fb85e5..9bf625c5d02 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/ApplicationHandler.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/ApplicationHandler.java @@ -176,7 +176,7 @@ public class ApplicationHandler { appRepository.getUpdater(currentApp, updatedApp, EntityRepository.Operation.PATCH); updater.update(); AppScheduler.getInstance().deleteScheduledApplication(updatedApp); - AppScheduler.getInstance().addApplicationSchedule(updatedApp); + AppScheduler.getInstance().scheduleApplication(updatedApp); LOG.info("migrated app configuration for {}", application.getName()); } @@ -197,7 +197,7 @@ public class ApplicationHandler { LOG.info("corrupt entry for app {}, reinstalling", application.getName()); App app = appRepository.getDao().findEntityByName(application.getName()); AppScheduler.getInstance().deleteScheduledApplication(app); - AppScheduler.getInstance().addApplicationSchedule(app); + AppScheduler.getInstance().scheduleApplication(app); } } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/scheduler/AppScheduler.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/scheduler/AppScheduler.java index 542edba0ccd..c9db40ee835 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/scheduler/AppScheduler.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/scheduler/AppScheduler.java @@ -156,10 +156,13 @@ public class AppScheduler { throw new UnhandledServerException("App Scheduler is not Initialized"); } - public void addApplicationSchedule(App application) { + public void scheduleApplication(App application) { try { if (scheduler.getJobDetail(new JobKey(application.getName(), APPS_JOB_GROUP)) != null) { - LOG.info("Job already exists for the application, skipping the scheduling"); + LOG.info( + "Job already exists for the application {}, rescheduling it", application.getName()); + scheduler.rescheduleJob( + new TriggerKey(application.getName(), APPS_TRIGGER_GROUP), trigger(application)); return; } AppRuntime context = getAppRuntime(application); diff --git a/openmetadata-spec/src/main/resources/json/schema/configuration/appsPrivateConfiguration.json b/openmetadata-spec/src/main/resources/json/schema/configuration/appsPrivateConfiguration.json index 0ac3ba5b7c3..03e11c4aa23 100644 --- a/openmetadata-spec/src/main/resources/json/schema/configuration/appsPrivateConfiguration.json +++ b/openmetadata-spec/src/main/resources/json/schema/configuration/appsPrivateConfiguration.json @@ -21,6 +21,9 @@ "description": "Flag to enable/disable preview for the application. If the app is in preview mode, it can't be installed.", "default": false }, + "schedule": { + "$ref": "../entity/applications/app.json#/definitions/appSchedule" + }, "parameters": { "javaType": "org.openmetadata.schema.api.configuration.apps.Parameters", "description": "Parameters to initialize the Applications.", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/configuration/appsPrivateConfiguration.ts b/openmetadata-ui/src/main/resources/ui/src/generated/configuration/appsPrivateConfiguration.ts index 65b195c3434..c216b3e39ac 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/configuration/appsPrivateConfiguration.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/configuration/appsPrivateConfiguration.ts @@ -1,5 +1,5 @@ /* - * Copyright 2024 Collate. + * Copyright 2025 Collate. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -10,9 +10,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - - /** +/** * This schema defines a list of configurations for the Application Framework */ export interface AppsPrivateConfiguration { @@ -38,5 +36,26 @@ export interface AppPrivateConfig { * Flag to enable/disable preview for the application. If the app is in preview mode, it * can't be installed. */ - preview?: boolean; + preview?: boolean; + schedule?: any[] | boolean | AppScheduleClass | number | number | null | string; +} + +export interface AppScheduleClass { + /** + * Cron Expression in case of Custom scheduled Trigger + */ + cronExpression?: string; + scheduleTimeline: ScheduleTimeline; +} + +/** + * This schema defines the Application ScheduleTimeline Options + */ +export enum ScheduleTimeline { + Custom = "Custom", + Daily = " Daily", + Hourly = "Hourly", + Monthly = "Monthly", + None = "None", + Weekly = "Weekly", }