pkuwm commented on a change in pull request #357: [WIP] Add getWorkflows(long
timeout) to TaskDriver.
URL: https://github.com/apache/helix/pull/357#discussion_r307070494
##########
File path: helix-core/src/main/java/org/apache/helix/task/WorkflowConfig.java
##########
@@ -322,6 +322,22 @@ public static WorkflowConfig
fromHelixProperty(HelixProperty property)
return Builder.fromMap(configs).setWorkflowId(property.getId()).build();
}
+ /**
+ * Build a WorkflowConfig from a HelixProperty.
+ *
+ * @param property a HelixProperty
+ * @return a WorkflowConfig if the property is a valid WorkflowConfig.
+ * Otherwise return null
+ */
+ public static WorkflowConfig parseWorkflowConfig(HelixProperty property)
+ throws IllegalArgumentException {
+ Map<String, String> configs = property.getRecord().getSimpleFields();
+ if (!configs.containsKey(WorkflowConfigProperty.Dag.name())) {
+ return null;
Review comment:
I absolutely agree! Optional is a better way to handle this situation than
throw exception or return null. If we add one `isWorkflowConfig()` in the
`WorkflowConfig` class, `isWorkflowConfig()` and `fromHelixProperty()` still
shares the partial same code. Well, to me, it is fine. Just like the way we use
in a Map:
```java
if (map.containsKey(key)) {
value = map.get(key);
}
```
Anyway, I will create a new issue for the discussion about this and include
all the existing related comments in that issue.
----------------------------------------------------------------
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