NIFI-9967: Added FlowSerializationStrategy to determine which flow formats (XML,JSON) to save#6001
NIFI-9967: Added FlowSerializationStrategy to determine which flow formats (XML,JSON) to save#6001mattyb149 wants to merge 2 commits intoapache:mainfrom
Conversation
simonbence
left a comment
There was a problem hiding this comment.
Some minimal remarks, otherwise it looks good to me.
| package org.apache.nifi.controller; | ||
|
|
||
| public enum FlowSerializationStrategy { | ||
| WRITE_XML, |
There was a problem hiding this comment.
Minor suggestion: according to the WRITE_XML_AND_JSON value and the usage, we do not plan to use this like having a set of possible strategies, but always using only a single value. As of this, I would suggest to name the values like WRITE_XML_ONLY, and WRITE_JSON_ONLY.
|
|
||
| saveJson(controller, archive); | ||
| saveXml(controller, archive); | ||
| if (serializationStrategy == FlowSerializationStrategy.WRITE_JSON || serializationStrategy == FlowSerializationStrategy.WRITE_XML_AND_JSON) { |
There was a problem hiding this comment.
I think it would be useful to encapsulate the decision logic within the enum. The FlowSerializationStrategy could have a writesJSON and a writesXML methods with boolean return values. By this, the condition would change simply to serializationStrategy.writesJSON() and serializationStrategy.writesXML() accordingly.
|
|
||
| return new StandardFlowService(controller, nifiProperties, senderListener, encryptor, true, coordinator, revisionManager, authorizer); | ||
| return new StandardFlowService(controller, nifiProperties, senderListener, encryptor, true, coordinator, revisionManager, authorizer, | ||
| FlowSerializationStrategy.WRITE_XML_AND_JSON); |
There was a problem hiding this comment.
Due to simmerty and having the same responsibilities for standalone and clustered methods, I would add an argument for this as well. As I found, it is callled only in the StandardFlowServiceFactoryBean, and the used enum might be specified there (like in case of standalone)
There was a problem hiding this comment.
Only NiFi itself runs in clustered mode, the reason we have an extra argument in the standalone instance is for MiNiFi, which needs WRITE_XML_ONLY and calls getStandaloneInstance() directly (not via Spring)
bejancsaba
left a comment
There was a problem hiding this comment.
+1 from me I just had a minor enum structuring related proposal. Thanks for the change, the issue came up at our current minifi c2 work as well.
| */ | ||
| package org.apache.nifi.controller; | ||
|
|
||
| public enum FlowSerializationStrategy { |
There was a problem hiding this comment.
It is just syntactical but maybe better to read (but this could be really subjective), what do you think about:
public enum FlowSerializationStrategy {
WRITE_XML_ONLY(false, true),
WRITE_JSON_ONLY(true, false),
WRITE_XML_AND_JSON(true, true);
private final boolean writesJson;
private final boolean writesXml;
FlowSerializationStrategy(boolean writesJson, boolean writesXml) {
this.writesJson = writesJson;
this.writesXml = writesXml;
}
public boolean writesJson() {
return writesJson;
}
public boolean writesXml() {
return writesXml;
}
}
kevdoran
left a comment
There was a problem hiding this comment.
I don't have any objection to this, and it is a small change that fixes key functionality, so overall I'm a +1.
That said, I hope that eventually we can move minifi to using our VersionedFlowSnapshot JSON format everywhere (in C2, in place of config.yml, in place of flow/xml.gz) which I feel will simplify a lot of the codebase in places where we have to deal with different formats.
…rmats (XML,JSON) to save This closes #6001. Signed-off-by: Kevin Doran <kdoran@apache.org>
Description of PR
Adds a FlowSerializationStrategy enum to determine whether to save the flow in XML and/or JSON formats. NiFi saves both, MiNiFi saves only the XML version (as this is what is overwritten by config.yml)
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
For all changes:
Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
Has your PR been rebased against the latest commit within the target branch (typically
main)?Is your initial contribution a single, squashed commit? Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not
squashor use--forcewhen pushing to allow for clean monitoring of changes.For code changes:
mvn -Pcontrib-check clean installat the rootnififolder?LICENSEfile, including the mainLICENSEfile undernifi-assembly?NOTICEfile, including the mainNOTICEfile found undernifi-assembly?.displayNamein addition to .name (programmatic access) for each of the new properties?For documentation related changes:
Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI for build issues and submit an update to your PR as soon as possible.