Skip to content

NIFI-7788 Start and Stop actions on a Process Group should enable/disable transmission of RPG's#4516

Closed
tpalfy wants to merge 6 commits intoapache:mainfrom
tpalfy:NIFI-7788
Closed

NIFI-7788 Start and Stop actions on a Process Group should enable/disable transmission of RPG's#4516
tpalfy wants to merge 6 commits intoapache:mainfrom
tpalfy:NIFI-7788

Conversation

@tpalfy
Copy link
Contributor

@tpalfy tpalfy commented Sep 8, 2020

https://issues.apache.org/jira/browse/NIFI-7788

Created a new endpoint in RemoteProcessGroupResource to allow updating run statuses/transmission state of all remote process groups within a process group. When selecting run/stop on a process group/canvas/selection, it will try to enable/disable transmission of all involved remote process groups.

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 squash or use --force when pushing to allow for clean monitoring of changes.

For code changes:

  • Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
  • Have you written or updated unit tests to verify your changes?
  • Have you verified that the full build is successful on JDK 8?
  • Have you verified that the full build is successful on JDK 11?
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
  • If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
  • If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?

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.

Copy link
Contributor

@simonbence simonbence left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the permutations of the following:

  • Initiating start/stop from within the relevant group or from outside
  • Selecting nothing or relevant items
  • Clicking on Operate menu vs right click menu

Most of the combinations looks working fine, expect the following: from outside the containing process group, right click on the relevant process group and stop/start. It changes the state of every component expect the RPG.

In other cases I saw two PUT request which from one was explicitly for the RPG. In this case I did not see the additional PUT request.

Could you please take a look? Thanks!

* @param processGroupId The process group in which to verify remote process groups
* @param shouldTransmit The transmission state to verify for
*/
void verifyUpdateRemoteProcessGroups(String processGroupId, boolean shouldTransmit);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: just to make it more clear it looks to be a good improvement to change processGroupId into containingProcessGroupId (it's easy to to slip take it as RPG id as the scope is the RPG)

…ow updating run statuses/transmission state of all remote process groups within a process group. When selecting run/stop on a process group/canvas/selection, it will try to enable/disable transmission of all involved remote process groups.
Copy link
Contributor

@simonbence simonbence left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LFGM (other than one minor question)

@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("process-group/run-status/{id}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: the URI looks like the following: http://localhost:8888/nifi-api/remote-process-groups/process-group/run-status/82ed213b-0178-1000-f0de-db399db203fc. Is this intentional? As the method name differs from the original by using plural, I would suggest something like: http://localhost:8888/nifi-api/remote-process-groups/run-statuses/82ed213b-0178-1000-f0de-db399db203fc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw no good pattern for this so I came up with this one: I added /process-group to indicate that the scope of the operation is all RPGs within a process group.

As for the other part, nowhere else do we use run-statuses in this plural form in the urls.
Method names should be more precise because they also serve as a form of documentation. If the method name was updateRemoteProcessGroupRunStatus it would imply that it updates the run status of a single RPG.

URLs on the other hand don't need to have this implication. They merely indicate the type of the resources they manage. For example plurality can be even dependent on the payload instead of the URL.

Overall I'd rather leave it as it is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can go with your consideration. LGTM

Copy link
Contributor

@turcsanyip turcsanyip Apr 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the existing endpoints and found that

  • starting/stopping all processors in a process group:/flow/process-groups/{id}
  • enabling/disabling controller all services in a process group: /flow/process-groups/{id}/controller-services

Following the same scheme, I think the new endpoint should be: /flow/process-groups/{id}/remote-process-groups

@tpalfy, @simonbence What is your opinion?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RemoteProcessGroup is significantly different from Connectables (handled by the /flow/process-groups/{id} endpoint) and the ControllerServices (handled by the /flow/process-groups/{id}/remote-process-groups) endpoint.

The most prominent manifestation of this is how the merging of the request fits perfectly into the RemoteProcessGroupsEndpointMerger and not at all into the FlowMerger.

There are other signs that this functionality is more suited to handled here, like private methods in this class that would be needed to be accessed from the FlowResource.

Leaving it here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I myself am okay with this but still not fund of the naming of the URI

Copy link
Contributor

@turcsanyip turcsanyip Apr 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tpalfy I can see the problematic points now (eg. private methods) and leaving the endpoint in RemoteProcessGroup is fine with me.

Regarding the path, I would suggest a minor change: /remote-process-groups/process-group/{id}/run-status
In case of other endpoints, the {id} follows the entity it identifies (in our case it is a process group id). So I believe it would be more straightforward in this way and also similar to the single RPG start/stop endpoint: /remote-process-groups/{id}/run-status

@turcsanyip
Copy link
Contributor

@tpalfy Thanks for changing the endpoint path!

I found the following issue while I was testing the feature on the UI (not related to the path change, I just did not catch it earlier):
If you have an RPG already running and send a start request (within the PG), the RPG's widget gets cleared on the UI. The same is true for an already stopped RPG + stop request. When I refresh the canvas, the content of the widget comes back and shows the right status.

@turcsanyip
Copy link
Contributor

turcsanyip commented May 4, 2021

@tpalfy The latest change works properly with a standalone NiFi but I get the following error in cluster mode:

An unexpected error has occurred. Please check the logs for additional details.

Otherwise it starts/stops the RPGs.

Copy link
Contributor

@turcsanyip turcsanyip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retested the fix and it works es expected now.

Merging to main.

@asfgit asfgit closed this in 5bcfcf4 May 4, 2021
krisztina-zsihovszki pushed a commit to krisztina-zsihovszki/nifi that referenced this pull request Jun 28, 2022
…ow updating run statuses/transmission state of all remote process groups within a process group.

When selecting run/stop on a process group/canvas/selection, it will try to enable/disable transmission of all involved remote process groups.

NIFI-7788 Supplied same functionality missed when selecting a process group.
NIFI-7788 Updated endpoint URL paths.
NIFI-7788 No need to return list of remote process groups when updating en masse.
NIFI-7788 Added some null checks in RemoteProcessGroupsEndpointMerger.merge.
NIFI-7788 Fix checkstyle violation.

This closes apache#4516.

Signed-off-by: Peter Turcsanyi <turcsanyi@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants