-
Notifications
You must be signed in to change notification settings - Fork 749
[GOBBLIN-1948] Use same flowExecutionId across participants #3819
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -423,6 +423,17 @@ public boolean isScheduled() { | |
| return getConfig().hasPath(ConfigurationKeys.JOB_SCHEDULE_KEY); | ||
| } | ||
|
|
||
| /** | ||
| * Create a new FlowSpec object with the added property defined by path and value parameters | ||
| * @param path key for new property | ||
| * @param value | ||
| */ | ||
| public FlowSpec addProperty(String path, String value) { | ||
| Properties properties = this.getConfigAsProperties(); | ||
| properties.setProperty(path, value); | ||
| return new Builder(this.getUri()).withConfigAsProperties(properties).build(); | ||
|
Contributor
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. Do you intend to clone a new FlowSpec?
Contributor
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. This should create a new FlowSpec with the shared
Contributor
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. also, i think we should add configs to
Contributor
Author
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. Yes I have to clone and create a new FlowSpec because
Contributor
Author
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. I can also update the
Contributor
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. My concern here is mostly that it would create a decent amount of object churn, given the size of configs it should lead to an increase of jvm GC given that this would happen once per execution. That being said it might be an overoptimization to enforce such a rule until you instrument results on a high load, the alternative would be messy, need to add a way for compileSpec() to take in a flow execution ID and enforce using that ID instead of using the provided one in the flow config or from the system time, which would also lead to a bit of an anti-pattern of compiler expecting to use either the flow config's ID (that you provided here) or it's own generated ID.
Contributor
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. Yea, I do not prefer cloning too, but
Contributor
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. with the name changed to |
||
| } | ||
|
|
||
| @Slf4j | ||
| public static class Utils { | ||
| private final static String URI_SCHEME = "gobblin-flow"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package org.apache.gobblin.runtime.api; | ||
|
|
||
| import java.net.URI; | ||
| import java.net.URISyntaxException; | ||
| import java.util.Properties; | ||
| import org.apache.gobblin.configuration.ConfigurationKeys; | ||
| import org.apache.gobblin.service.FlowId; | ||
| import org.testng.Assert; | ||
| import org.testng.annotations.Test; | ||
|
|
||
|
|
||
| public class FlowSpecTest { | ||
|
|
||
| /** | ||
| * Tests that the addProperty() function to ensure the new flowSpec returned has the original properties and updated | ||
| * ones | ||
| * @throws URISyntaxException | ||
| */ | ||
| @Test | ||
| public void testAddProperty() throws URISyntaxException { | ||
| String flowGroup = "myGroup"; | ||
| String flowName = "myName"; | ||
| String flowExecutionId = "myId"; | ||
| FlowId flowId = new FlowId().setFlowGroup(flowGroup).setFlowName(flowName); | ||
| URI flowUri = FlowSpec.Utils.createFlowSpecUri(flowId); | ||
|
|
||
| // Create properties to be used as config | ||
| Properties properties = new Properties(); | ||
| properties.setProperty(ConfigurationKeys.FLOW_GROUP_KEY, flowGroup); | ||
| properties.setProperty(ConfigurationKeys.FLOW_NAME_KEY, flowName); | ||
| properties.setProperty(ConfigurationKeys.FLOW_IS_REMINDER_EVENT_KEY, "true"); | ||
|
|
||
| FlowSpec originalFlowSpec = FlowSpec.builder(flowUri).withConfigAsProperties(properties).build(); | ||
| FlowSpec updatedFlowSpec = originalFlowSpec.addProperty(ConfigurationKeys.FLOW_EXECUTION_ID_KEY, flowExecutionId); | ||
|
|
||
| Properties updatedProperties = updatedFlowSpec.getConfigAsProperties(); | ||
| Assert.assertEquals(updatedProperties.getProperty(ConfigurationKeys.FLOW_EXECUTION_ID_KEY), flowExecutionId); | ||
| Assert.assertEquals(updatedProperties.getProperty(ConfigurationKeys.FLOW_GROUP_KEY), flowGroup); | ||
| Assert.assertEquals(updatedProperties.getProperty(ConfigurationKeys.FLOW_NAME_KEY), flowName); | ||
| Assert.assertEquals(updatedProperties.getProperty(ConfigurationKeys.FLOW_IS_REMINDER_EVENT_KEY), "true"); | ||
| } | ||
| } |
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.
lgtm , one last comment.
lets rename it to
createFlowSpecWithPropertyand move it to FlowSpec.UtilsThere 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.
Done