Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

NIFI-14156 Improve Bootstrap Process on Windows with Attach API #9683

Closed
wants to merge 1 commit into from

Conversation

exceptionfactory
Copy link
Contributor

@exceptionfactory exceptionfactory commented Feb 1, 2025

Summary

NIFI-14156 Improves the application bootstrap process when running on Microsoft Windows using the Java Attach API to find the application process for status and shutdown. These changes resolve issues with the nifi.cmd stop and nifi.cmd status commands not working.

The restructured bootstrap process for NiFi 2 uses the ProcessHandle interface added in Java 9. The OpenJDK implementation for Linux and macOS provides command arguments for the associated process, but the implementation in Windows does not provide command arguments as of Java 21. JDK-8176725 describes the lack of support on Windows.

To maintain the stateless behavior of the application bootstrap process on Windows, changes in this pull request introduce new process handle discovery classes based on the Attach API and the VirtualMachine class. The VirtualMachine.getSystemProperties() method returns the system properties containing the information required to identify the bootstrap and application processes. This approach is implemented using feature detection when ProcessHandle.Info.arguments() is empty, preserving existing behavior on Linux and macOS.

Additional changes include correcting the nifi.cmd to avoid passing the application properties argument to the bootstrap process, and adjusting the start command behavior to launch the application in a new minimized window. The adjusted start behavior then returns to the command prompt, enabling subsequent commands such as status or stop as needed.

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

Pull Request Tracking

  • Pull Request title starts with Apache NiFi Jira issue number, such as NIFI-00000
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-00000

Pull Request Formatting

  • Pull Request based on current revision of the main branch
  • Pull Request refers to a feature branch with one commit containing changes

Verification

Please indicate the verification steps performed prior to pull request creation.

Build

  • Build completed using mvn clean install -P contrib-check
    • JDK 21

Licensing

  • New dependencies are compatible with the Apache License 2.0 according to the License Policy
  • New dependencies are documented in applicable LICENSE and NOTICE files

Documentation

  • Documentation formatting appears as expected in rendered files

- Added Virtual Machine Attach API implementation of to support Bootstrap commands on Windows
- Improved nifi.cmd start handling to launch in minimized window
@balazsgerner
Copy link
Contributor

Thank you for the fix, I reviewed the changes and tested the start-stop and status functionality on Windows and MacOS as well, everything is working as expected.
One thing to note is that when I start nifi on Windows, a minified windows appears on the taskbar. Is this wanted/exptected behaviour? See attached image.
Screenshot 2025-02-03 at 11 16 33

@exceptionfactory
Copy link
Contributor Author

Thank you for the fix, I reviewed the changes and tested the start-stop and status functionality on Windows and MacOS as well, everything is working as expected. One thing to note is that when I start nifi on Windows, a minified windows appears on the taskbar. Is this wanted/exptected behaviour?

Thanks for the testing and feedback @balazsgerner!

Yes, the minimized background window is expected when running nifi.cmd start. The updates to nifi.cmd start include this change so that the NiFi process starts in the background and the command returns to the prompt. The previous behavior left the command running in the same prompt window, blocking further use of that prompt window. The behavior adjustment aligns more closely to nifi.sh start on Linux and macOS, starting NiFi in the background and returning to the command prompt.

Copy link
Contributor

@mark-bathori mark-bathori left a comment

Choose a reason for hiding this comment

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

Thanks @exceptionfactory for fixing this issue and thanks @balazsgerner for testing.
The changes looks good to me +1
Merging.

@asfgit asfgit closed this in 2b1055e Feb 3, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants