-
Notifications
You must be signed in to change notification settings - Fork 751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix FlowSpec Updating Function #3823
Changes from all commits
73cf30a
c88da7a
24cba18
3001cd6
906a65d
5a3e735
3d80b3e
36162db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -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(); | ||||
Comment on lines
+511
to
+512
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doesn't actually say what/how it failed flow compilation... is that because such a message would have already been logged? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, we don't have that information available here yet. We emit a flow compilation failed event that we can check Line 89 in 9e30c6c
|
||||
} | ||||
// Upon handling the action, delete it so on leadership change this is not duplicated | ||||
this.dagActionStore.get().deleteDagAction(launchAction); | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,10 +64,14 @@ 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 for scheduled (non-ad-hoc) flows, to pass the ID "laundered" via the DB; | ||
* see: {@link MysqlMultiActiveLeaseArbiter javadoc section titled | ||
* `Database event_timestamp laundering`} | ||
* @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 { | ||
Comment on lines
+73
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The other optionals used in this class are the guava one and reliant on intertwined |
||
Config flowConfig = flowSpec.getConfig(); | ||
String flowGroup = flowConfig.getString(ConfigurationKeys.FLOW_GROUP_KEY); | ||
String flowName = flowConfig.getString(ConfigurationKeys.FLOW_NAME_KEY); | ||
|
@@ -90,7 +94,7 @@ public Optional<Dag<JobExecutionPlan>> createExecutionPlanIfValid(FlowSpec flowS | |
return Optional.absent(); | ||
} | ||
|
||
addFlowExecutionIdIfAbsent(flowMetadata, jobExecutionPlanDagOptional.get()); | ||
addFlowExecutionIdIfAbsent(flowMetadata, optionalFlowExecutionId, jobExecutionPlanDagOptional.get()); | ||
if (flowCompilationTimer.isPresent()) { | ||
flowCompilationTimer.get().stop(flowMetadata); | ||
} | ||
|
@@ -177,11 +181,23 @@ 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, retrieve flowExecutionId from the JobSpec. | ||
*/ | ||
public static void addFlowExecutionIdIfAbsent(Map<String,String> flowMetadata, | ||
Dag<JobExecutionPlan> jobExecutionPlanDag) { | ||
addFlowExecutionIdIfAbsent(flowMetadata, Optional.absent(), jobExecutionPlanDag); | ||
} | ||
|
||
/** | ||
* 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, | ||
Optional<String> optionalFlowExecutionId, Dag<JobExecutionPlan> jobExecutionPlanDag) { | ||
if (optionalFlowExecutionId.isPresent()) { | ||
flowMetadata.putIfAbsent(TimingEvent.FlowEventConstants.FLOW_EXECUTION_ID_FIELD, optionalFlowExecutionId.get()); | ||
} | ||
flowMetadata.putIfAbsent(TimingEvent.FlowEventConstants.FLOW_EXECUTION_ID_FIELD, | ||
jobExecutionPlanDag.getNodes().get(0).getValue().getJobSpec().getConfigAsProperties().getProperty( | ||
ConfigurationKeys.FLOW_EXECUTION_ID_KEY)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() { | ||
umustafi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
HashMap<String, String> flowMetadata = new HashMap<>(); | ||
FlowCompilationValidationHelper.addFlowExecutionIdIfAbsent(flowMetadata, Optional.of(newFlowExecutionId), jobExecutionPlanDag); | ||
Assert.assertEquals(flowMetadata.get(TimingEvent.FlowEventConstants.FLOW_EXECUTION_ID_FIELD), newFlowExecutionId); | ||
} | ||
|
||
/* | ||
Tests that addFlowExecutionIdIfAbsent does not update an existing flowExecutionId in a flowMetadata object | ||
*/ | ||
@Test | ||
public void testSkipAddingFlowExecutionIdWhenPresent() { | ||
HashMap<String, String> flowMetadata = new HashMap<>(); | ||
flowMetadata.put(TimingEvent.FlowEventConstants.FLOW_EXECUTION_ID_FIELD, existingFlowExecutionId); | ||
FlowCompilationValidationHelper.addFlowExecutionIdIfAbsent(flowMetadata, Optional.of(newFlowExecutionId), jobExecutionPlanDag); | ||
Assert.assertEquals(flowMetadata.get(TimingEvent.FlowEventConstants.FLOW_EXECUTION_ID_FIELD), existingFlowExecutionId); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my hunch is that this
.build()
is what generated all the garbage. most likely the conversion of config to props