phet commented on code in PR #3823:
URL: https://github.com/apache/gobblin/pull/3823#discussion_r1393037130
##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/DagManager.java:
##########
@@ -504,9 +504,12 @@ public void handleLaunchFlowEvent(DagActionStore.DagAction
launchAction) {
URI flowUri = FlowSpec.Utils.createFlowSpecUri(flowId);
FlowSpec spec = (FlowSpec) flowCatalog.getSpecs(flowUri);
Optional<Dag<JobExecutionPlan>> optionalJobExecutionPlanDag =
-
this.flowCompilationValidationHelper.createExecutionPlanIfValid(spec);
+
this.flowCompilationValidationHelper.createExecutionPlanIfValid(spec,
Optional.absent());
if (optionalJobExecutionPlanDag.isPresent()) {
addDag(optionalJobExecutionPlanDag.get(), true, true);
+ } else {
+ log.warn("Failed flow compilation of spec causing launch flow event to
be skipped on startup. Flow {}", flowId);
+ this.dagManagerMetrics.incrementFailedLaunchCount();
Review Comment:
doesn't actually say what/how it failed flow compilation... is that because
such a message would have already been logged?
##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/utils/FlowCompilationValidationHelper.java:
##########
@@ -177,11 +179,14 @@ public static void
populateFlowCompilationFailedEventMessage(Optional<EventSubmi
}
/**
- * If it is a scheduled flow (and hence, does not have flowExecutionId in
the FlowSpec) and the flow compilation is
- * successful, retrieve the flowExecutionId from the JobSpec.
+ * If it is a scheduled flow (which does not have flowExecutionId in the
FlowSpec) and the flow compilation is
+ * successful, add a flowExecutionId using the optional parameter if it
exists otherwise retrieve it from the JobSpec.
*/
public static void addFlowExecutionIdIfAbsent(Map<String,String>
flowMetadata,
- Dag<JobExecutionPlan> jobExecutionPlanDag) {
+ Optional<String> optionalFlowExecutionId, Dag<JobExecutionPlan>
jobExecutionPlanDag) {
Review Comment:
tip: rather than updating various existing invocations to pass
`Optional.absent()`, create an overloaded version and centralize all migration
there:
```
public static void addFlowExecutionIdIfAbsent(Map<String,String>
flowMetadata, Dag<JobExecutionPlan> jobExecutionPlanDag) {
addFlowExecutionIdIfAbsent(flowMetadata, Optional.absent(),
jobExecutionPlanDag);
}
```
##########
gobblin-service/src/test/java/org/apache/gobblin/service/modules/utils/FlowCompilationValidationHelperTest.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * 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.modules.utils;
+
+import com.google.common.base.Optional;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import org.apache.gobblin.metrics.event.TimingEvent;
+import org.apache.gobblin.service.modules.flowgraph.Dag;
+import org.apache.gobblin.service.modules.orchestration.DagTestUtils;
+import org.apache.gobblin.service.modules.spec.JobExecutionPlan;
+import org.junit.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+
+/**
+ * Test functionality provided by the helper class re-used between the
DagManager and Orchestrator for flow compilation.
+ */
+public class FlowCompilationValidationHelperTest {
+ private String dagId = "testDag";
+ private Long jobSpecFlowExecutionId = 1234L;
+ private String newFlowExecutionId = "5678";
+ private String existingFlowExecutionId = "9999";
+ private Dag<JobExecutionPlan> jobExecutionPlanDag;
+
+ @BeforeClass
+ public void setup() throws URISyntaxException {
+ jobExecutionPlanDag = DagTestUtils.buildDag(dagId,
jobSpecFlowExecutionId);
+
+ }
+
+ /*
+ Tests that addFlowExecutionIdIfAbsent adds flowExecutionId to a
flowMetadata object when it is absent, prioritizing
+ the optional flowExecutionId over the one from the job spec
+ */
+ @Test
+ public void testAddFlowExecutionIdWhenAbsent() {
Review Comment:
shall we also test the third case, where it's not present originally and
also not provided as an `Optional`?
##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/utils/FlowCompilationValidationHelper.java:
##########
@@ -64,10 +64,12 @@ public final class FlowCompilationValidationHelper {
* For a given a flowSpec, verifies that an execution is allowed (in case
there is an ongoing execution) and the
* flowspec can be compiled. If the pre-conditions hold, then a
JobExecutionPlan is constructed and returned to the
* caller.
+ * @param flowSpec
+ * @param optionalFlowExecutionId provided for executions of scheduled
events which should use a consistent id
* @return jobExecutionPlan dag if one can be constructed for the given
flowSpec
*/
- public Optional<Dag<JobExecutionPlan>> createExecutionPlanIfValid(FlowSpec
flowSpec)
- throws IOException, InterruptedException {
+ public Optional<Dag<JobExecutionPlan>> createExecutionPlanIfValid(FlowSpec
flowSpec,
+ Optional<String> optionalFlowExecutionId) throws IOException,
InterruptedException {
Review Comment:
though not related to this PR's changes per se, just noting that guava lib
upgrades cause us considerable hassle, and a special challenge we'd face if we
ever elect to shade guava classes, would arise from using guava types as params
or return types.
unless there's a pressing mandate to use guava `Optional`, we should always
prefer `java.util.Optional`. (guava has been deprecated in favor of that one
for a very long time.)
##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/utils/FlowCompilationValidationHelper.java:
##########
@@ -64,10 +64,12 @@ public final class FlowCompilationValidationHelper {
* For a given a flowSpec, verifies that an execution is allowed (in case
there is an ongoing execution) and the
* flowspec can be compiled. If the pre-conditions hold, then a
JobExecutionPlan is constructed and returned to the
* caller.
+ * @param flowSpec
+ * @param optionalFlowExecutionId provided for executions of scheduled
events which should use a consistent id
Review Comment:
how about
```
for scheduled (non-ad-hoc) flows, to pass the ID "laundered" via the DB;
see: {@link MultiActiveLeaseArbiter#whateverMethodHasJavadocToDescribe}
```
?
i.e. there should already be good docs about this, so merely help the
maintainer find them w/ a link
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]