sv2000 commented on a change in pull request #2611: [GOBBLIN-746] Async loading 
FlowSpec
URL: https://github.com/apache/incubator-gobblin/pull/2611#discussion_r277917952
 
 

 ##########
 File path: 
gobblin-service/src/main/java/org/apache/gobblin/service/modules/scheduler/GobblinServiceJobScheduler.java
 ##########
 @@ -136,6 +136,46 @@ public synchronized void setActive(boolean isActive) {
     }
   }
 
+  /**
+   * Load all {@link FlowSpec}s from {@link FlowCatalog} as one of the 
initialization step,
+   * and make schedulers be aware of that.
+   *
+   */
+  private void scheduleSpecsFromCatalog() {
+    Iterator<URI> specUris = null;
+    long startTime = System.currentTimeMillis();
+
+    try {
+      specUris = this.flowCatalog.get().getSpecURIs();
+    } catch (SpecSerDeException ssde) {
+      throw new RuntimeException("Failed to get the iterator of all Spec 
URIS", ssde);
+    }
+
+
+    try {
+      while (specUris.hasNext()) {
+        Spec spec = null;
+        try {
+          spec = this.flowCatalog.get().getSpec(specUris.next());
+        } catch (SpecNotFoundException snfe) {
+          _log.error(String.format("The URI %s discovered in SpecStore is 
missing in FlowCatlog"
+              + ", suspecting current modification on SpecStore", 
specUris.next()), snfe);
+        }
+
+        //Disable FLOW_RUN_IMMEDIATELY on service startup or leadership change
+        if (spec instanceof FlowSpec) {
+          Spec modifiedSpec = disableFlowRunImmediatelyOnStart((FlowSpec) 
spec);
+          onAddSpec(modifiedSpec);
+        } else {
+          onAddSpec(spec);
+        }
+      }
+    } finally {
+      flowSpecInitFinished.countDown();
 
 Review comment:
   Is this countdown latch being used only in the test case? Your test case is 
waiting for at most 2 secs anyway. Can you simply do an AssertWithBackoff in 
your test case?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to