From 7dcdc1a37d9ee5c72556e71f24c9eef4383d010a Mon Sep 17 00:00:00 2001 From: Mohit Yadav <105265192+mohityadav766@users.noreply.github.com> Date: Wed, 17 Jan 2024 13:22:49 +0530 Subject: [PATCH] Fix Expression Parsing (#14753) --- .../changeEvent/AbstractEventConsumer.java | 61 ++++++++++--------- .../src/pages/AddAlertPage/AddAlertPage.tsx | 4 +- 2 files changed, 35 insertions(+), 30 deletions(-) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/changeEvent/AbstractEventConsumer.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/changeEvent/AbstractEventConsumer.java index f77ff35ff105..47b18f1cbaaa 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/changeEvent/AbstractEventConsumer.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/changeEvent/AbstractEventConsumer.java @@ -273,37 +273,42 @@ public List pollEvents(long offset, long batchSize) { @Override public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { // Must Have , Before Execute the Init, Quartz Requires a Non-Arg Constructor - this.init(jobExecutionContext); - - // Poll Events from Change Event Table - List batch = pollEvents(offset, 100); - int batchSize = batch.size(); - - // Retry Failed Events - Set failedEventsList = - JsonUtils.convertValue( - jobDetail.getJobDataMap().get(FAILED_EVENT_EXTENSION), new TypeReference<>() {}); - if (failedEventsList != null) { - List failedChangeEvents = - failedEventsList.stream() - .filter(failedEvent -> failedEvent.getRetriesLeft() > 0) - .map(FailedEvent::getChangeEvent) - .toList(); - batch.addAll(failedChangeEvents); - } + try { - if (!batch.isEmpty()) { - // Publish Events - alertMetrics.withTotalEvents(alertMetrics.getTotalEvents() + batch.size()); - publishEvents(batch); + this.init(jobExecutionContext); - // Commit the Offset - offset += batchSize; - commit(jobExecutionContext); - } + // Poll Events from Change Event Table + List batch = pollEvents(offset, 100); + int batchSize = batch.size(); + + // Retry Failed Events + Set failedEventsList = + JsonUtils.convertValue( + jobDetail.getJobDataMap().get(FAILED_EVENT_EXTENSION), new TypeReference<>() {}); + if (failedEventsList != null) { + List failedChangeEvents = + failedEventsList.stream() + .filter(failedEvent -> failedEvent.getRetriesLeft() > 0) + .map(FailedEvent::getChangeEvent) + .toList(); + batch.addAll(failedChangeEvents); + } + + if (!batch.isEmpty()) { + // Publish Events + alertMetrics.withTotalEvents(alertMetrics.getTotalEvents() + batch.size()); + publishEvents(batch); - // Call stop to close the client - this.stop(); + // Commit the Offset + offset += batchSize; + commit(jobExecutionContext); + } + } catch (Exception e) { + LOG.error("Error in executing the Job : {} ", e.getMessage()); + } finally { + // Call stop to close the client + this.stop(); + } } public EventSubscription getEventSubscription() { diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/AddAlertPage/AddAlertPage.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/AddAlertPage/AddAlertPage.tsx index 53d260c6b6f1..96d33f2838af 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/AddAlertPage/AddAlertPage.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/AddAlertPage/AddAlertPage.tsx @@ -183,10 +183,10 @@ const AddAlertPage = () => { const requestFilteringRules = filteringRules?.rules?.map((curr) => ({ ...curr, - condition: `${curr.name}(${map( + condition: `${curr.name}({${map( curr.condition, (v: string) => `'${v}'` - )?.join(', ')})`, + )?.join(', ')}})`, })); try {