From 4e4bbeb42f73e52901172ceb851248c5cf4742c2 Mon Sep 17 00:00:00 2001 From: LuckyPickleZZ Date: Tue, 21 May 2024 14:38:15 +0800 Subject: [PATCH 1/2] support create event when task framework not enabled --- .../odc/service/quartz/OdcJobListener.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/server/odc-service/src/main/java/com/oceanbase/odc/service/quartz/OdcJobListener.java b/server/odc-service/src/main/java/com/oceanbase/odc/service/quartz/OdcJobListener.java index 6f9bf9a8d0..1ff3d60d65 100644 --- a/server/odc-service/src/main/java/com/oceanbase/odc/service/quartz/OdcJobListener.java +++ b/server/odc-service/src/main/java/com/oceanbase/odc/service/quartz/OdcJobListener.java @@ -165,14 +165,18 @@ public void jobWasExecuted(JobExecutionContext context, JobExecutionException jo ScheduleTaskContextHolder.clear(); Optional scheduleEntityOptional = scheduleRepository.findById(ScheduleTaskUtils.getScheduleId(context)); - if (scheduleEntityOptional.isPresent()) { - ScheduleEntity scheduleEntity = scheduleEntityOptional.get(); - if (jobException != null && notificationProperties.isEnabled()) { - try { + if (notificationProperties.isEnabled() && scheduleEntityOptional.isPresent()) { + try { + ScheduleEntity scheduleEntity = scheduleEntityOptional.get(); + if (jobException != null) { broker.enqueueEvent(eventBuilder.ofFailedTask(scheduleEntity)); - } catch (Exception e) { - log.warn("Failed to enqueue event.", e); + } else if (!taskFrameworkEnabledProperties.isEnabled() + && scheduleEntity.getJobType().executeInTaskFramework()) { + // only create event for DLM jobs when task framework not enabled to avoid duplicate events + broker.enqueueEvent(eventBuilder.ofSucceededTask(scheduleEntity)); } + } catch (Exception e) { + log.warn("Failed to enqueue event.", e); } } } From 40358b5d4adc40e4361eb739f07d66d7ea2571a3 Mon Sep 17 00:00:00 2001 From: LuckyPickleZZ Date: Tue, 21 May 2024 14:38:48 +0800 Subject: [PATCH 2/2] add description for notification --- .../odc/service/notification/constant/EventLabelKeys.java | 1 + .../odc/service/notification/helper/EventBuilder.java | 3 +++ 2 files changed, 4 insertions(+) diff --git a/server/odc-service/src/main/java/com/oceanbase/odc/service/notification/constant/EventLabelKeys.java b/server/odc-service/src/main/java/com/oceanbase/odc/service/notification/constant/EventLabelKeys.java index 3180ba94a3..fa25877eb8 100644 --- a/server/odc-service/src/main/java/com/oceanbase/odc/service/notification/constant/EventLabelKeys.java +++ b/server/odc-service/src/main/java/com/oceanbase/odc/service/notification/constant/EventLabelKeys.java @@ -30,6 +30,7 @@ public class EventLabelKeys { public static final String TASK_TYPE = "taskType"; public static final String TASK_STATUS = "taskStatus"; public static final String TRIGGER_TIME = "triggerTime"; + public static final String DESCRIPTION = "description"; /** * connection info diff --git a/server/odc-service/src/main/java/com/oceanbase/odc/service/notification/helper/EventBuilder.java b/server/odc-service/src/main/java/com/oceanbase/odc/service/notification/helper/EventBuilder.java index 42e00192e7..373b4429c9 100644 --- a/server/odc-service/src/main/java/com/oceanbase/odc/service/notification/helper/EventBuilder.java +++ b/server/odc-service/src/main/java/com/oceanbase/odc/service/notification/helper/EventBuilder.java @@ -23,6 +23,7 @@ import static com.oceanbase.odc.service.notification.constant.EventLabelKeys.CREATOR_NAME; import static com.oceanbase.odc.service.notification.constant.EventLabelKeys.DATABASE_ID; import static com.oceanbase.odc.service.notification.constant.EventLabelKeys.DATABASE_NAME; +import static com.oceanbase.odc.service.notification.constant.EventLabelKeys.DESCRIPTION; import static com.oceanbase.odc.service.notification.constant.EventLabelKeys.ENVIRONMENT; import static com.oceanbase.odc.service.notification.constant.EventLabelKeys.PROJECT_ID; import static com.oceanbase.odc.service.notification.constant.EventLabelKeys.PROJECT_NAME; @@ -188,6 +189,7 @@ private Event ofTask(TaskEntity task, TaskEvent status) { labels.putIfNonNull(CREATOR_ID, task.getCreatorId()); labels.putIfNonNull(TRIGGER_TIME, LocalDateTime.now().format(DATE_FORMATTER)); labels.putIfNonNull(REGION, OB_ARN_PARTITION); + labels.putIfNonNull(DESCRIPTION, task.getDescription()); Long projectId; if (Objects.nonNull(task.getDatabaseId())) { @@ -233,6 +235,7 @@ private Event ofSchedule(ScheduleEntity schedule, TaskEvent status) { labels.putIfNonNull(TASK_STATUS, status.name()); labels.putIfNonNull(TRIGGER_TIME, LocalDateTime.now().format(DATE_FORMATTER)); labels.putIfNonNull(REGION, OB_ARN_PARTITION); + labels.putIfNonNull(DESCRIPTION, schedule.getDescription()); switch (schedule.getJobType()) { case DATA_ARCHIVE: