-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
NIFI-13008 - CLI command to upgrade all instances of a versioned flow #8611
Conversation
Example of command and output:
|
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.
Thanks @pvillard31. I have some minor stylistic comments for now, but I'd like to test this out and provide some runtime feedback.
@@ -133,6 +134,7 @@ protected List<Command> createCommands() { | |||
commands.add(new PGGetVersion()); | |||
commands.add(new PGStopVersionControl()); | |||
commands.add(new PGChangeVersion()); | |||
commands.add(new PGChangeAllVersions()); |
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.
The new command should be added to the toolkit guide as well
final List<ProcessGroupDTO> processGroups = new ArrayList<>(); | ||
final Map<String, ChangeVersionResult> changeVersionResults = new HashMap<String, ChangeVersionResult>(); | ||
|
||
for (ProcessGroupDTO pgDTO : pgList) { |
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.
This can be final
as well.
parentPgId = flowClient.getRootGroupId(); | ||
} | ||
|
||
PGList doPGList = new PGList(); |
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.
We can have a few more final
variables here, such as doPGList
, pgList
, and doPGChangeVersion
.
processGroups.add(pgDTO); | ||
|
||
final Integer previousVersion = pgDTO.getVersionControlInformation().getVersion(); | ||
if(previousVersion == newVersion) { |
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.
Let's add a space after the if
for style consistency.
changeVersionResults.put(pgDTO.getId(), new ChangeVersionResult(previousVersion, newVersion, "SUCCESS")); | ||
} catch (Exception e) { | ||
changeVersionResults.put(pgDTO.getId(), new ChangeVersionResult(previousVersion, null, e.getMessage())); | ||
if(forceOperation) { |
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.
Space after the if
...lkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/pg/PGChangeVersion.java
Outdated
Show resolved
Hide resolved
@@ -121,7 +132,7 @@ public VoidResult doExecute(final NiFiClient client, final Properties properties | |||
return VoidResult.getInstance(); | |||
} | |||
|
|||
private int getLatestVersion(final NiFiClient client, final VersionControlInformationDTO existingVersionControlDTO) | |||
public int getLatestVersion(final NiFiClient client, final VersionControlInformationDTO existingVersionControlDTO) |
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.
If I'm not mistaken, this could be package scope (just remove the public
)
return getList(client, properties, parentPgId); | ||
} | ||
|
||
public ProcessGroupsResult getList(final NiFiClient client, final Properties properties, String pgID) |
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.
final pgID
Integer newVersion; | ||
String message; | ||
|
||
public ChangeVersionResult(Integer previousVersion, Integer newVersion, String message) { |
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.
Arguments could be final
|
||
@Override | ||
public ReferenceResolver createReferenceResolver(final Context context) { | ||
final Map<Integer,ProcessGroupDTO> backRefs = new HashMap<>(); |
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.
Space after the comma
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.
Thanks for the updates, @pvillard31, this works well.
Signed-off-by: Joe Gresock <[email protected]> This closes apache#8611.
Signed-off-by: Joe Gresock <[email protected]> This closes apache#8611.
Summary
NIFI-13008 - CLI command to upgrade all instances of a versioned flow
Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000
NIFI-00000
Pull Request Formatting
main
branchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
mvn clean install -P contrib-check
Licensing
LICENSE
andNOTICE
filesDocumentation