[ 
https://issues.apache.org/jira/browse/GOBBLIN-1705?focusedWorklogId=807579&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-807579
 ]

ASF GitHub Bot logged work on GOBBLIN-1705:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 09/Sep/22 19:40
            Start Date: 09/Sep/22 19:40
    Worklog Time Spent: 10m 
      Work Description: umustafi commented on code in PR #3557:
URL: https://github.com/apache/gobblin/pull/3557#discussion_r967408078


##########
gobblin-service/src/main/java/org/apache/gobblin/service/monitoring/SpecStoreChangeMonitor.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gobblin.service.monitoring;
+
+import java.util.HashSet;
+
+import com.google.inject.Inject;
+import com.typesafe.config.Config;
+
+import lombok.extern.slf4j.Slf4j;
+
+import org.apache.gobblin.kafka.client.DecodeableKafkaRecord;
+import org.apache.gobblin.runtime.api.Spec;
+import org.apache.gobblin.runtime.kafka.HighLevelConsumer;
+import org.apache.gobblin.runtime.spec_catalog.FlowCatalog;
+import org.apache.gobblin.service.modules.scheduler.GobblinServiceJobScheduler;
+
+
+/**
+ * A Flow Spec Store change monitor that uses {@link SpecStoreChangeEvent} 
schema to process Kafka messages received
+ * from the consumer service. This monitor responds to changes to flow specs 
(creations, updates, deletes) and acts as
+ * a connector between the API and execution layers of GaaS.
+ */
+@Slf4j
+public class SpecStoreChangeMonitor extends HighLevelConsumer {
+  protected HashSet<Long> timestampsSeenBefore;
+
+  @Inject
+  protected FlowCatalog flowCatalog;
+
+  @Inject
+  protected GobblinServiceJobScheduler scheduler;
+
+  @Inject
+  public SpecStoreChangeMonitor(String topic, Config config, int numThreads) {
+    super(topic, config, numThreads);
+    this.timestampsSeenBefore = new HashSet();
+  }
+
+  @Override
+  protected void processMessage(DecodeableKafkaRecord message) {
+    String specUri = (String) message.getKey();
+    SpecStoreChangeEvent value = (SpecStoreChangeEvent) message.getValue();
+
+    Long timestamp = value.getTimestamp();
+    String operation = value.getOperationType().name();
+    log.info("Processing message with specUri is {} timestamp is {} operation 
is {}", specUri, timestamp, operation);
+
+    // If we've already processed a message with this timestamp before then 
skip duplicate message
+    if (timestampsSeenBefore.contains(timestamp)) {

Review Comment:
   Good point, we may have cases where different specs are altered at exact 
same timestamp. 





Issue Time Tracking
-------------------

    Worklog Id:     (was: 807579)
    Time Spent: 50m  (was: 40m)

> New Consumer service that processes changes to Flow Spec Store
> --------------------------------------------------------------
>
>                 Key: GOBBLIN-1705
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-1705
>             Project: Apache Gobblin
>          Issue Type: New Feature
>          Components: gobblin-service
>            Reporter: Urmi Mustafi
>            Assignee: Abhishek Tiwari
>            Priority: Major
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> In the multi-leader version of GaaS, the REST API layer will not directly 
> contact the `GobblinServiceJobScheduler` to respond to API requests. Instead 
> after flow level updates are persisted to MySQL, this new monitor will 
> subscribe to Kafka events informing it of Flow Spec changes corresponding to 
> the API requests and trigger their execution. There will be a similar change 
> to follow to respond to other API requests. 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to