diff --git a/KEYS b/KEYS index cac752ff96..2ac237717f 100644 --- a/KEYS +++ b/KEYS @@ -144,3 +144,61 @@ lLqlJSFiuV7mNyu7u15/EO9S+ITRYdvsncRRYYdQdYZCyvgxP038P2WUeyRMtQSp F9jzEw== =IZsE -----END PGP PUBLIC KEY BLOCK----- +pub 4096R/432AEE37 2015-05-04 +uid Matt Gilman (CODE SIGNING KEY) +sig 3 432AEE37 2015-05-04 Matt Gilman (CODE SIGNING KEY) +sub 4096R/69B51990 2015-05-04 +sig 432AEE37 2015-05-04 Matt Gilman (CODE SIGNING KEY) + +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1 + +mQINBFVHcNsBEADbogfcroNIO8PbGENtCr4VISn2ZSW3XVBUv4xhiZeH/M/horu9 +IwtQmWilbJi20nraEbYg4rxxuNDSt+EjN0zb1yVfISmfzIXrTclE2wbHWdUbjaRA +kdxkBKt2Gc7x0OEONfOFKP26hF24zMN7348iwzjML610P0yaMoDT1kwt36qpr5d7 +dIy+e+6zJ4p6ypyqyG+scxPzC2QFQmwPtRAvgbnHRPwsef0zo3qLc7Otvw+0MiC8 +qxFsdiCzc8yLnebHzWTyqZdkp/TRoVGi8m5OMrKRmiOBhcGwK31Z7cDlwfzHNt3O +wYEUFDw2cA/8k8S2ctkybJGiBXgDjZoGjGpocAbObrcZq9iCn0k8x3MY3yqTA+7h +BVNQXmydh1Sj0fAI/CUMDvSEdTPwSK93W4sj7p0fyL8eSunCXDAWtmfRFLsB8BPC +o4g5SH1Q8VvW4LRaFrrvWL//2v+y+klF3FMaInKPtHP96F5ZI2VMgQrL1UjX/bq5 +ctEym6pH887eUcxR7OvpQEZZm3dw1/LAk7ZN18hGeJuoZ2R97Q9gdP4r8p09Rj6n +bzGPh1N4NuwTo2Xs20ESW5UiJh96O0mqJ2kB8GrvitxOVqnUwaAUQvUgFVR7m941 +yNSddMbmCznj7eYngC8AGVsjzU2L1dJDjfHFHKNJ3pgZcjZkpIwT3imlBwARAQAB +tDRNYXR0IEdpbG1hbiAoQ09ERSBTSUdOSU5HIEtFWSkgPG1jZ2lsbWFuQGFwYWNo +ZS5vcmc+iQI3BBMBAgAhAhsDAh4BAheABQJVR3KCBQsJCAcDBRUKCQgLBRYCAwEA +AAoJEN9h7BlDKu432C4QAJ8y0lGgxIKiLEBAsmm/E/bh2Eaw8YeWj/zbQT3IGh/G +vFKCec2NZSGdObgD8mg4SieW6nYW/GZSMtlsVawCB4kavD6TKeYacq90E7nqeWJm +4oZxiWuQuPuJgPqJJMmk0aiUb9EiZRFQqYmDOsrXausxbcVzpzQwKTrKyzWIO7hT +79ii+D/bdDYL10bju/9gmFvzAABnolL98fstr/sJcoZBd4FmWXdEFR2oXONukqJB +rRGiAny1q+5QwQdHs7nNVewFjuu9AzibOY5omPGJLTsfH+aBgrpIAg4vFlG4H6tn +RnB5VcxtOfr8b0xIjPIV93HtlU4Vfft1pIJxULknbKDArpam3wVYLNmsyRmD1AKY +Xumii1Rzf10k6jxUJuK8EdvbrSjfNWuaZ1lVi9robKhpYZ3oVEikOmg8nD4aSMJ6 +a2i16GgmZ+QHUbFdaSEtNftptlxtFI31LzjLRX3EOsQJ96J+frmzH9I+Vjxys6DH +TTPuvANQViaxgEJ8I73OntTsuywqXXOg67+Eyz4ieeYDdxGnKBK/n8pl1xLUvyN9 +K55a9/Lk26mRNsRFxSp37gTHCcYDgDkC4BA4fxvakl/IAAdXxjXg92sQ9A27qNcw +OqzlnGd7yobwtgGqHXM9ORgnDXl6zuRLXjYMGjTrwuhbbSHxqt/huvpWISTEJe59 +uQINBFVHcNsBEADFVADjCu8IZi/lNPRoTZv+QVqAuFfIVHaX2Niu1RUVvm1yIqCr +Kba5b88vQJjn2iDTMP+1Kcv/szhIli0TZENUE6hg/vZpbJVumDqb9QkdOlxVWzug +3jUIu4ZxY4sqfLLAawlYzgnm/Nl4URrUoh1bUEdTrfW+gaLLGgiUsDWHMDQVr7KU +sJtR0RVcFm7fCjfqDyaYPGsrRHftH585Ym9e72fj7E4C/9gYOwJqBMkvD8rClCKf +4GpJKYbD8/np3uhU/hE2T+Jso+z/9ROiFN1EsiqWyyPzClVFDdh65LERxZfFbQ3s +T1jml0vuW7szxoHWMh+ruivl+ojL27GtJ9QHMS83ie4XNDDG2NZiShi+dKb4/a3C +cKTcDtL0vlwUHHXEjwZXmG2ZcwkAiUC42cLYmgfucdG0oBLpWbvqH4GBEH6rzx3s +QVihhS30/U12dEBRZ/5emgzJ3NSuS3T/3JGrmB9sbY6GhmGM3O/8/R1rfOoO1Y1d +wak9GJhzvromLK70P9dfYy1u/rWbLDmoJf6xcqIVHlr7jWj1dhx0q1vsXwdGOCLZ +6NOpigrSxFTW+iHDPOxG7dQYbDfimCUdrF+eK+W9CjoIntdfUqJSivwpkhnfOYMZ +Jva7x84cxtKT2W5+flNiw448j30RQtDNhZwjAUvORbGiyWYm9boiPR5FMQARAQAB +iQIfBBgBAgAJBQJVR3DbAhsMAAoJEN9h7BlDKu43AR0P/A7ZJsEl/bwRZpENKPWB +Ynb0xEhZ0hDclKCEpT41c87Ft6gxEJ+mFofLdS+NCcGXDv+zQtkATLqRlrRXFTBS +VULtDFnTC0GpYFa/zVhVmPZERD2PexrSUs4YlmddYGNJODTiQ407jFQDLIYAzim6 +r025MwzIvu8QLBJ+MJoysvZgzWCH9bq702LQm69ax/pj9LEvYQPLimCBpRzuwvCB +P/XuxMEyKt/3521SRTsmEQ75TPoApBMyds1ykT4uwUrxIu3e+Hov7WxHUYWT9hy5 +1rETKu6/vMhmA3ivdFN06/sImJ3LZnJBp21CCj/kb9UjVFotiQaBsWW0nkaDQ9Nu +ndwQaGV6bgHlvFBryG44lYIVE5ZkETYSTXy66AeUZ4rOw5sEpJD29iYb8qqvxKIj +pUe0a2pG2z6V3hS/btgvvrojroBxs80DohaA9R46+g4KK5Pv6ps+CVCWigSW1S66 +mhoQwhDC2CHObMDkywmFUOvJoEGFmNndnZmnLlH4mofjbH4zBbM7jldQGFW55j8p +qM3m3uQikpC5YAogpX6B1oMGTmqkFOKKkKjEmfngc4+BpGgMON/iw6Nq8DIjKRM7 +iZTTlg8bBsOEKzTIpC6P0Dz/xTu2Ge9VoAi17ssGjYjXMbzrX7+NLjP8FafLezQx +xbKM3K7lORLPg4LK0hcG2ZaO +=gvH7 +-----END PGP PUBLIC KEY BLOCK----- diff --git a/README.md b/README.md index 75b79c2d67..d7a04c4098 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,42 @@ Apache NiFi is an easy to use, powerful, and reliable system to process and dist ## Getting Started -- Build the nifi-nar-maven-plugin. Change directory to 'nifi-nar-maven-plugin' and -follow the directions found there. -- Build nifi. Change directory to 'nifi' and follow the directions found there. +- Read through the [quickstart guide for development](http://nifi.incubator.apache.org/development/quickstart.html). + It will include information on getting a local copy of the source, give pointers on issue + tracking, and provide some warnings about common problems with development environments. +- Optional: Build supporting modules. This should only be needed if the current 'nifi' module is in + the process of updating to a new version of either the 'nifi-parent' or 'nifi-nar-maven-plugin' + artifacts. + + If in doubt, just skip to building the main nifi project. If the build fails, come back here and + figure out which optional step you are missing; each entry below will give an example of the + errors you'll receive if that step needs to be followed. The version numbers may change but the + error text should still look very familiar. + - Install the nifi-parent pom. Change directory to 'nifi-parent' and follow the directions found + there in [README.md](nifi-parent/README.md). + + If you don't build the nifi-parent pom and the main nifi code relies on an unreleased version + you'll see an erorr like the following: + + [ERROR] Non-resolvable parent POM: Could not find artifact + org.apache.nifi:nifi-parent:pom:1.0.0-incubating-SNAPSHOT in example.snapshots.repo + (https://repository.example.com/content/repositories/snapshots) and + 'parent.relativePath' points at no local POM @ line 18, column 13 -> [Help 2] + - Build the nifi-nar-maven-plugin. Change directory to 'nifi-nar-maven-plugin' and + follow the directions found there in [README.md](nifi-nar-maven-plugin/README.md). + + If you don't build the nifi-nar-maven-plugin and the main nifi code relies on an unreleased + version you'll see an error like the following: + + [ERROR] Unresolveable build extension: Plugin + org.apache.nifi:nifi-nar-maven-plugin:1.0.1-incubating-SNAPSHOT or one of its + dependencies could not be resolved: Could not find artifact + org.apache.nifi:nifi-nar-maven-plugin:jar:1.0.1-incubating-SNAPSHOT -> [Help 2] +- Build nifi. Change directory to 'nifi' and follow the directions found there in + [README.md](nifi/README.md). +- Run NiFi. The directions found in the [README.md](nifi/README.md) file within the 'nifi' module + will also include how to run an instance of NiFi. For help on how to build your first data flow, + see the [NiFi User Guide](http://nifi.incubator.apache.org/docs/nifi-docs/user-guide.html). ## Documentation diff --git a/nifi-nar-maven-plugin/README.md b/nifi-nar-maven-plugin/README.md index 1b554d9153..4fd3a2777a 100644 --- a/nifi-nar-maven-plugin/README.md +++ b/nifi-nar-maven-plugin/README.md @@ -18,16 +18,25 @@ Apache NiFi NAR Maven Plugin helps to build NiFi Archive bundles to support the ## Table of Contents +- [Requirements](#requirements) - [Getting Started](#getting-started) - [Getting Help](#getting-help) -- [Requirements](#requirements) - [License](#license) - [Disclaimer](#disclaimer) +## Requirements +* JDK 1.7 or higher +* Apache Maven 3.0.5 or higher + ## Getting Started -To Build: -- Executed 'mvn clean install' +Building the nifi-nar-maven-plugin module should be rare since it will be released infrequently compared to +the main 'nifi' code tree. + +- Build with `mvn clean install` +- Presuming you need to make use of changes to the nifi-nar-maven-plugin module, you should next + go to the [nifi](../nifi) directory and follow its instructions. + ## Getting Help If you have questions, you can reach out to our mailing list: dev@nifi.incubator.apache.org @@ -36,9 +45,6 @@ We're also often available in IRC: #nifi on [irc.freenode.net](http://webchat.freenode.net/?channels=#nifi). -## Requirements -* JDK 1.7 or higher - ## License Except as otherwise noted this software is licensed under the diff --git a/nifi-nar-maven-plugin/pom.xml b/nifi-nar-maven-plugin/pom.xml index 7ba2d7c002..95cee00528 100644 --- a/nifi-nar-maven-plugin/pom.xml +++ b/nifi-nar-maven-plugin/pom.xml @@ -15,142 +15,22 @@ --> 4.0.0 - - org.apache - apache - 16 + org.apache.nifi + nifi-parent + 1.0.0-incubating-SNAPSHOT - org.apache.nifi nifi-nar-maven-plugin 1.0.1-incubating-SNAPSHOT maven-plugin Apache NiFi Nar Plugin. It is currently a part of the Apache Incubator. - http://nifi.incubator.apache.org - - Apache NiFi (incubating) - http://nifi.incubator.apache.org/ - - - - Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0 - - - - - Dev - dev-subscribe@nifi.incubator.apache.org - dev-unsubscribe@nifi.incubator.apache.org - dev@nifi.incubator.apache.org - http://mail-archives.apache.org/mod_mbox/incubator-nifi-dev - - - Commits - commits-subscribe@nifi.incubator.apache.org - commits-unsubscribe@nifi.incubator.apache.org - commits@nifi.incubator.apache.org - http://mail-archives.apache.org/mod_mbox/incubator-nifi-commits - - - - scm:git:git://git.apache.org/incubator-nifi.git - scm:git:https://git-wip-us.apache.org/repos/asf/incubator-nifi.git - https://git-wip-us.apache.org/repos/asf?p=incubator-nifi.git - HEAD - - - JIRA - https://issues.apache.org/jira/browse/NIFI - - - 1.7 - 1.7 - 3.0.5 - UTF-8 - UTF-8 - - - ${maven.min-version} - - - org.apache.maven.plugins - maven-compiler-plugin - 3.2 - - true - true - true - true - - - - org.apache.maven.plugins - maven-resources-plugin - 2.7 - - - org.apache.maven.plugins - maven-surefire-plugin - 2.18 - - -Xmx1G - - - - org.apache.maven.plugins - maven-assembly-plugin - 2.5.2 - - gnu - - - - org.apache.maven.plugins - maven-source-plugin - 2.4 - - - org.apache.maven.plugins - maven-site-plugin - 3.4 - - - org.codehaus.mojo - exec-maven-plugin - 1.3.2 - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10.1 - - false - true - private - UTF-8 - true - 1.7 - -J-Xmx512m - - org.apache.maven.plugins maven-release-plugin - 2.5.1 - - true - apache-release - true - deploy - @{project.artifactId}-@{project.version} - false - true - default @@ -158,29 +38,14 @@ perform - nar-maven-plugin/pom.xml + nifi-nar-maven-plugin/pom.xml - - org.apache.maven.plugins - maven-jar-plugin - 2.5 - - + - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.5 - true - - repository.apache.org - https://repository.apache.org/ - - org.apache.maven.plugins maven-plugin-plugin @@ -202,19 +67,15 @@ - org.apache.rat - apache-rat-plugin + org.apache.maven.plugins + maven-checkstyle-plugin - - nb-configuration.xml - nbactions.xml - DEPENDENCIES - + **/HelpMojo.java - - + + - + org.apache.maven maven-plugin-api @@ -240,27 +101,4 @@ 3.3 - - - - check-licenses - - - - org.apache.rat - apache-rat-plugin - - - - check - - verify - - - - - - - diff --git a/nifi-nar-maven-plugin/src/main/java/org/apache/nifi/NarMojo.java b/nifi-nar-maven-plugin/src/main/java/org/apache/nifi/NarMojo.java index da03182b92..0e3290208e 100644 --- a/nifi-nar-maven-plugin/src/main/java/org/apache/nifi/NarMojo.java +++ b/nifi-nar-maven-plugin/src/main/java/org/apache/nifi/NarMojo.java @@ -290,8 +290,8 @@ public class NarMojo extends AbstractMojo { */ @Parameter(property = "overWriteIfNewer", required = false, defaultValue = "true") protected boolean overWriteIfNewer; - - @Parameter( property = "projectBuildDirectory", required = false, defaultValue = "${project.build.directory}") + + @Parameter(property = "projectBuildDirectory", required = false, defaultValue = "${project.build.directory}") protected File projectBuildDirectory; /** diff --git a/nifi-parent/DISCLAIMER b/nifi-parent/DISCLAIMER new file mode 100644 index 0000000000..0f8e7a1ecc --- /dev/null +++ b/nifi-parent/DISCLAIMER @@ -0,0 +1,15 @@ +Apache NiFi is an effort undergoing incubation at the Apache Software +Foundation (ASF), sponsored by the Apache Incubator PMC. + +Incubation is required of all newly accepted projects until a further review +indicates that the infrastructure, communications, and decision making process +have stabilized in a manner consistent with other successful ASF projects. + +While incubation status is not necessarily a reflection of the completeness +or stability of the code, it does indicate that the project has yet to be +fully endorsed by the ASF. + +For more information about the incubation status of the Apache NiFi project +you can go to the following page: + +http://nifi.incubator.apache.org/ diff --git a/nifi-parent/LICENSE b/nifi-parent/LICENSE new file mode 100644 index 0000000000..7a4a3ea242 --- /dev/null +++ b/nifi-parent/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/nifi-parent/NOTICE b/nifi-parent/NOTICE new file mode 100644 index 0000000000..76a23fbb6d --- /dev/null +++ b/nifi-parent/NOTICE @@ -0,0 +1,5 @@ +Apache NiFi +Copyright 2014-2015 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). diff --git a/nifi-parent/README.md b/nifi-parent/README.md new file mode 100644 index 0000000000..d2c10d8615 --- /dev/null +++ b/nifi-parent/README.md @@ -0,0 +1,73 @@ + +# Apache NiFi Parent + +Apache NiFi Parent provides a nice aggregation of shared concerns for all NiFi Poms to follow + +## Table of Contents + +- [Requirements](#requirements) +- [Getting Started](#getting-started) +- [License](#license) +- [Disclaimer](#disclaimer) + +## Requirements +* JDK 1.7 or higher +* Apache Maven 3.0.5 or higher + +## Getting Started + +Building the nifi-parent module should be rare since it will be released infrequently compared to +the main 'nifi' code tree. + +- Build the nifi-parent module using `mvn clean install`. +- Presuming you need to make use of changes to the nifi-parent module, you should next + go to the [nifi-nar-maven-plugin](../nifi-nar-maven-plugin) directory and follow its instructions + and finally the [nifi](../nifi) directory. + +## Documentation + +See http://nifi.incubator.apache.org/ for the latest documentation. + +## License + +Except as otherwise noted this software is licensed under the +[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +## Disclaimer + +Apache NiFi is an effort undergoing incubation at the Apache Software +Foundation (ASF), sponsored by the Apache Incubator PMC. + +Incubation is required of all newly accepted projects until a further review +indicates that the infrastructure, communications, and decision making process +have stabilized in a manner consistent with other successful ASF projects. + +While incubation status is not necessarily a reflection of the completeness +or stability of the code, it does indicate that the project has yet to be +fully endorsed by the ASF. + diff --git a/nifi-parent/pom.xml b/nifi-parent/pom.xml new file mode 100644 index 0000000000..fb2f827b7d --- /dev/null +++ b/nifi-parent/pom.xml @@ -0,0 +1,431 @@ + + + + 4.0.0 + + org.apache + apache + 16 + + + org.apache.nifi + nifi-parent + 1.0.0-incubating-SNAPSHOT + pom + The nifi-parent enables each apache nifi project to ensure consistent approaches and DRY + http://nifi.incubator.apache.org + + Apache NiFi(incubating) Project + http://nifi.incubator.apache.org/ + + + + Apache License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0 + + + + + Dev + dev-subscribe@nifi.incubator.apache.org + dev-unsubscribe@nifi.incubator.apache.org + dev@nifi.incubator.apache.org + http://mail-archives.apache.org/mod_mbox/incubator-nifi-dev + + + Commits + commits-subscribe@nifi.incubator.apache.org + commits-unsubscribe@nifi.incubator.apache.org + commits@nifi.incubator.apache.org + http://mail-archives.apache.org/mod_mbox/incubator-nifi-commits + + + + ${maven.min-version} + + + scm:git:git://git.apache.org/incubator-nifi.git + scm:git:https://git-wip-us.apache.org/repos/asf/incubator-nifi.git + https://git-wip-us.apache.org/repos/asf?p=incubator-nifi.git + HEAD + + + JIRA + https://issues.apache.org/jira/browse/NIFI + + + 1.7 + 1.7 + 3.0.5 + UTF-8 + UTF-8 + 2014 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.2 + + true + true + true + true + + + + org.apache.maven.plugins + maven-war-plugin + 2.5 + + + org.apache.maven.plugins + maven-dependency-plugin + 2.9 + + + org.apache.maven.plugins + maven-resources-plugin + 2.7 + + + org.apache.maven.plugins + maven-surefire-plugin + 2.18 + + true + -Xmx1G + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.5.2 + + gnu + + + + org.codehaus.mojo + jaxb2-maven-plugin + 1.6 + + + org.apache.maven.plugins + maven-source-plugin + 2.4 + + + org.apache.maven.plugins + maven-site-plugin + 3.4 + + + org.codehaus.mojo + exec-maven-plugin + 1.3.2 + + + org.apache.maven.plugins + maven-jar-plugin + 2.5 + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.1 + + false + true + private + UTF-8 + true + 1.7 + -J-Xmx512m + + + + org.apache.maven.plugins + maven-release-plugin + 2.5.1 + + true + apache-release + true + deploy + @{project.artifactId}-@{project.version} + false + true + + + + default + + perform + + + nifi-parent/pom.xml + + + + + + org.codehaus.mojo + rpm-maven-plugin + 2.1.1 + + + org.antlr + antlr3-maven-plugin + 3.5.2 + + + org.apache.maven.plugins + maven-checkstyle-plugin + 2.15 + + + com.puppycrawl.tools + checkstyle + 6.5 + + + + + org.codehaus.mojo + findbugs-maven-plugin + 3.0.1 + + true + Max + true + 14 + + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.5 + true + + repository.apache.org + https://repository.apache.org/ + + + + org.apache.maven.plugins + maven-enforcer-plugin + + + enforce-maven + + enforce + + + + + + org.apache.maven.plugins:maven-surefire-plugin + org.apache.maven.plugins:maven-failsafe-plugin + org.apache.maven.plugins:maven-surefire-report-plugin + + + + ${maven.min-version} + + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + warning + true + + + + org.apache.rat + apache-rat-plugin + + + nb-configuration.xml + nbactions.xml + DEPENDENCIES + + + + + + org.apache.maven.doxia + doxia-core + 1.6 + + + xerces + xercesImpl + + + + + + + + + + + contrib-check + + + + org.apache.rat + apache-rat-plugin + + + + check + + verify + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + check-style + + check + + + + + + + + + + findbugs + + + + org.codehaus.mojo + findbugs-maven-plugin + + + run-findbugs + + check + + + + + + + + + diff --git a/nifi-site/Gruntfile.js b/nifi-site/Gruntfile.js index c9e9bb8333..782f5e4853 100644 --- a/nifi-site/Gruntfile.js +++ b/nifi-site/Gruntfile.js @@ -1,17 +1,24 @@ +/* global module */ + module.exports = function (grunt) { // Project configuration. grunt.initConfig({ + config: { + svn: { + url: 'https://svn.apache.org/repos/asf/incubator/nifi/site/trunk' + } + }, pkg: grunt.file.readJSON('package.json'), - clean: { options: { force: true }, js: ['dist/js/'], css: ['dist/css/'], - assets: ['dist/assets/*'] + assets: ['dist/assets/*'], + generated: ['dist/docs'], + all: ['dist'] }, - assemble: { options: { partials: 'src/includes/*.hbs', @@ -32,7 +39,6 @@ module.exports = function (grunt) { } } }, - compass: { dist: { options: { @@ -40,7 +46,6 @@ module.exports = function (grunt) { } } }, - concat: { options: { separator: ';' @@ -66,48 +71,199 @@ module.exports = function (grunt) { dest: 'dist/js/app.js' } }, - copy: { + generated: { + files: [{ + expand: true, + cwd: '../nifi/nifi-docs/target/generated-docs', + src: ['*.html', 'images/*'], + dest: 'dist/docs/' + }, { + expand: true, + cwd: '../nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api', + src: ['target/nifi-web-api-*/docs/rest-api/index.html', 'target/nifi-web-api-*/docs/rest-api/images/*'], + dest: 'dist/docs/', + rename: function (dest, src) { + var path = require('path'); + + if (src.indexOf('images') > 0) { + return path.join(dest, 'rest-api/images', path.basename(src)); + } else { + return path.join(dest, 'rest-api', path.basename(src)); + } + } + }] + }, dist: { files: [{ - expand: true, - cwd: 'src/images/', - src: ['**/*.{png,jpg,gif,svg,ico}'], - dest: 'dist/images/' - }, { - expand: true, - cwd: 'bower_components/jquery/dist', - src: ['jquery.min.js'], - dest: 'dist/assets/js/' - }, { - expand: true, - cwd: 'bower_components/webfontloader', - src: ['webfontloader.js'], - dest: 'dist/assets/js/' - }, { - expand: true, - cwd: 'bower_components/font-awesome/css', - src: ['font-awesome.min.css'], - dest: 'dist/assets/stylesheets/' - }, { - expand: true, - cwd: 'bower_components/font-awesome', - src: ['fonts/*'], - dest: 'dist/assets/' + expand: true, + cwd: 'src/images/', + src: ['**/*.{png,jpg,gif,svg,ico}'], + dest: 'dist/images/' + }, { + expand: true, + cwd: 'bower_components/jquery/dist', + src: ['jquery.min.js'], + dest: 'dist/assets/js/' + }, { + expand: true, + cwd: 'bower_components/webfontloader', + src: ['webfontloader.js'], + dest: 'dist/assets/js/' + }, { + expand: true, + cwd: 'bower_components/font-awesome/css', + src: ['font-awesome.min.css'], + dest: 'dist/assets/stylesheets/' + }, { + expand: true, + cwd: 'bower_components/font-awesome', + src: ['fonts/*'], + dest: 'dist/assets/' + }] + } + }, + prompt: { + username: { + options: { + questions: [{ + config: 'config.svn.username', + type: 'input', + message: 'Enter SVN username if different from current user:' + }] + } + }, + commit: { + options: { + questions: [{ + config: 'config.svn.commit.confirmation', + type: 'list', + choices: ['Show diff', 'Commit', 'Abort'], + message: 'Commit the changes listed above?' + }], + then: function (results) { + if (results['config.svn.commit.confirmation'] === 'Commit') { + grunt.task.run('prompt:message'); + } else if (results['config.svn.commit.confirmation'] === 'Show diff') { + grunt.task.run('exec:diff'); + grunt.task.run('prompt:commit'); + } + } + } + }, + message: { + options: { + questions: [{ + config: 'config.svn.commit.message', + type: 'input', + message: 'Commit message:' + }, { + config: 'config.svn.password', + type: 'password', + message: 'SVN password:' + }], + then: function () { + grunt.task.run('exec:commit'); + } + } + } + }, + exec: { + generateDocs: { + command: 'mvn clean package', + cwd: '../nifi/nifi-docs', + stdout: true, + stderr: true + }, + generateRestApiDocs: { + command: 'mvn clean package -DskipTests', + cwd: '../nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api', + stdout: true, + stderr: true + }, + checkout: { + command: function() { + var url = grunt.config('config.svn.url'); + var username = grunt.config('config.svn.username'); + if (username === '') { + return 'svn checkout ' + url + ' --trust-server-cert --non-interactive dist'; + } else { + return 'svn checkout --username ' + username + ' ' + url + ' --trust-server-cert --non-interactive dist'; + } + }, + stdout: true, + stderr: true + }, + status: { + cwd: 'dist', + command: 'svn status', + stdout: true, + stderr: true + }, + diff: { + cwd: 'dist', + command: 'svn diff', + stdout: true, + stderr: true + }, + commit: { + cwd: 'dist', + command: function() { + var username = grunt.config('config.svn.username'); + var password = grunt.config('config.svn.password'); + var message = grunt.config('config.svn.commit.message'); + if (username === '') { + return 'svn commit --password "' + password + '" -m "' + message + '" --trust-server-cert --non-interactive .'; + } else { + return 'svn commit --username ' + username + ' --password "' + password + '" -m "' + message + '" --trust-server-cert --non-interactive .'; + } + } + } + }, + replace: { + addGoogleAnalytics: { + src: ['dist/docs/*.html', 'dist/docs/rest-api/index.html'], + overwrite: true, + replacements: [{ + from: /<\/head>/g, + to: "\n" + + "" + }] + }, + moveTearDrop: { + src: ['dist/docs/rest-api/index.html'], + overwrite: true, + replacements: [{ + from: //g, + to: '' + }] + }, + removeVersion: { + src: ['dist/docs/rest-api/index.html'], + overwrite: true, + replacements: [{ + from: /
.*<\/div>/g, + to: '
NiFi Rest Api
' }] } }, - watch: { - grunt: { - files: ['Gruntfile.js'], - tasks: ['dev'] + grunt: { + files: ['Gruntfile.js'], + tasks: ['dev'] }, css: { files: 'src/scss/*.scss', tasks: ['css'] }, - script: { + script: { files: 'src/js/*.js', tasks: ['js'] }, @@ -121,7 +277,7 @@ module.exports = function (grunt) { } } }); - + grunt.loadNpmTasks('grunt-newer'); grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-copy'); @@ -129,10 +285,18 @@ module.exports = function (grunt) { grunt.loadNpmTasks('assemble'); grunt.loadNpmTasks('grunt-contrib-compass'); grunt.loadNpmTasks('grunt-contrib-watch'); - + grunt.loadNpmTasks('grunt-exec'); + grunt.loadNpmTasks('grunt-text-replace'); + grunt.loadNpmTasks('grunt-prompt'); + grunt.registerTask('img', ['newer:copy']); grunt.registerTask('css', ['clean:css', 'compass']); - grunt.registerTask('js', ['clean:js', 'concat']); - grunt.registerTask('default', ['clean', 'assemble', 'css', 'js', 'img', 'copy']); - grunt.registerTask('dev', ['default', 'watch']); + grunt.registerTask('js', ['clean:js', 'concat']); + grunt.registerTask('generate-docs', ['clean:generated', 'exec:generateDocs', 'exec:generateRestApiDocs', 'copy:generated', 'replace:addGoogleAnalytics', 'replace:moveTearDrop', 'replace:removeVersion']); + + grunt.registerTask('build', ['assemble', 'css', 'js', 'img', 'generate-docs', 'copy:dist']); + grunt.registerTask('deploy', ['clean:all', 'prompt:username', 'exec:checkout', 'build', 'exec:status', 'prompt:commit']); + grunt.registerTask('dev', ['default', 'watch']); + + grunt.registerTask('default', ['clean:all', 'build']); }; diff --git a/nifi-site/README.md b/nifi-site/README.md index 05cabd087e..3ba231b415 100644 --- a/nifi-site/README.md +++ b/nifi-site/README.md @@ -62,7 +62,13 @@ gem install compass ## Grunt Tasks To build the site run the default grunt task. This will assemble the site and -place the resulting site in the dist folder. +place the resulting site in the dist folder. Part of this assembly is actually +building the various guides and Rest Api documentation bundled in the application. +Because of this, Maven must be installed and available on the PATH. Additionally Java +must be installed in order for the Maven build to succeed. Refer to the [NiFi][] +documentation for minimum requirements for Maven and Java. + +[NiFi]: https://nifi.incubator.apache.org/quickstart.html ```bash grunt @@ -76,6 +82,35 @@ files for changes. Any changes will cause the site to be rebuilt. grunt dev ``` +To deploy new changes to the live site, run the deploy task + +```bash +grunt deploy +``` + +This will go through each step required to deploy changes to the site. Updates +are performed by committing to a SVN repository. This means that svn must be installed +and available on the PATH. Additionally, it requires SVN 1.6+. The deployment +process will show the files being committed and provide an option to view a diff, +proceed with the commit, or abort. + +## Source overview + +### src/includes + +Contains fragments that will be included on all pages of the site. Most notably +here is the topbar.hbs that defines the Menus on the top of the site. If a new +page is being added or removed it is done here. + +### src/pages/html + +Contains pages that are written in HTML. Any new HTML based content should reside here. + +### src/pages/markdown + +Contains pages that are written in Markdown. Any new Markdown based content should +reside here. + ## Application Style Properties ### Font @@ -114,6 +149,4 @@ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and -limitations under the License. - - +limitations under the License. \ No newline at end of file diff --git a/nifi-site/package.json b/nifi-site/package.json index 170d4ad104..dbd8ab52ec 100644 --- a/nifi-site/package.json +++ b/nifi-site/package.json @@ -1,6 +1,6 @@ { "name": "apache-nifi-site", - "version": "0.0.2-incubating", + "version": "0.1.0-incubating", "description": "The artifacts for the Apache NiFi site.", "private": "true", "repository": { @@ -15,10 +15,15 @@ "grunt-contrib-concat": "^0.5.0", "grunt-contrib-copy": "^0.7.0", "grunt-contrib-watch": "^0.6.1", - "grunt-newer": "^1.1.0" + "grunt-exec": "^0.4.6", + "grunt-newer": "^1.1.0", + "grunt-prompt": "^1.3.0", + "grunt-text-replace": "^0.4.0" }, - "licenses" : [{ - "type": "Apache", - "url": "http://www.apache.org/licenses/LICENSE-2.0.html" - }] + "licenses": [ + { + "type": "Apache", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + } + ] } diff --git a/nifi-site/src/images/flow.png b/nifi-site/src/images/flow.png index 2b481407e9..0308d6bacf 100644 Binary files a/nifi-site/src/images/flow.png and b/nifi-site/src/images/flow.png differ diff --git a/nifi-site/src/includes/header.hbs b/nifi-site/src/includes/header.hbs index 5940e6bb31..49f320d081 100644 --- a/nifi-site/src/includes/header.hbs +++ b/nifi-site/src/includes/header.hbs @@ -16,7 +16,7 @@ })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-57264262-1', 'auto'); ga('send', 'pageview'); - + {{> topbar}} \ No newline at end of file diff --git a/nifi-site/src/includes/topbar.hbs b/nifi-site/src/includes/topbar.hbs index 6069a34a4f..959771c65a 100644 --- a/nifi-site/src/includes/topbar.hbs +++ b/nifi-site/src/includes/topbar.hbs @@ -20,7 +20,6 @@ @@ -32,6 +31,8 @@
  • NiFi Overview
  • User Guide
  • Developer Guide
  • +
  • Admin Guide
  • +
  • Rest Api
  • @@ -52,6 +53,8 @@ diff --git a/nifi-site/src/pages/html/administrator-guide.hbs b/nifi-site/src/pages/html/administrator-guide.hbs new file mode 100644 index 0000000000..a58e8d281e --- /dev/null +++ b/nifi-site/src/pages/html/administrator-guide.hbs @@ -0,0 +1,7 @@ +--- +title: Apache NiFi Administrator Guide +--- + +
    + +
    \ No newline at end of file diff --git a/nifi-site/src/pages/html/developer-guide.hbs b/nifi-site/src/pages/html/developer-guide.hbs index 7d8a250299..690923ea53 100644 --- a/nifi-site/src/pages/html/developer-guide.hbs +++ b/nifi-site/src/pages/html/developer-guide.hbs @@ -3,5 +3,5 @@ title: Apache NiFi Developer Guide ---
    - +
    \ No newline at end of file diff --git a/nifi-site/src/pages/html/download.hbs b/nifi-site/src/pages/html/download.hbs index 6e03b28483..9e4ba7cb3a 100644 --- a/nifi-site/src/pages/html/download.hbs +++ b/nifi-site/src/pages/html/download.hbs @@ -23,6 +23,24 @@ title: Apache NiFi Downloads

    Releases

      +
    • 0.0.2-incubating + +
    • 0.0.1-incubating
      • Release Notes
      • diff --git a/nifi-site/src/pages/html/mailing_lists.hbs b/nifi-site/src/pages/html/mailing_lists.hbs index 076b684581..049e470d73 100644 --- a/nifi-site/src/pages/html/mailing_lists.hbs +++ b/nifi-site/src/pages/html/mailing_lists.hbs @@ -29,6 +29,13 @@ title: Apache NiFi Mailing Lists Post Archive + + Users Mailing List + Subscribe + Unsubscribe + Post + mail-archives.apache.org + Developers Mailing List Subscribe diff --git a/nifi-site/src/pages/html/overview.hbs b/nifi-site/src/pages/html/overview.hbs index eaaee22157..b2eae1ca09 100644 --- a/nifi-site/src/pages/html/overview.hbs +++ b/nifi-site/src/pages/html/overview.hbs @@ -3,5 +3,5 @@ title: Apache NiFi Overview ---
        - +
        \ No newline at end of file diff --git a/nifi-site/src/pages/html/people.hbs b/nifi-site/src/pages/html/people.hbs index 77b8d9c26f..66ab0d0f72 100644 --- a/nifi-site/src/pages/html/people.hbs +++ b/nifi-site/src/pages/html/people.hbs @@ -36,6 +36,11 @@ title: Apache NiFi Team Name Affiliation + + aldrin + Aldrin Piri + + apurtell Andrew Purtell @@ -113,24 +118,4 @@ title: Apache NiFi Team
    -
  • -
    -
    -
    -

    - - Committers - -

    -
    -
    -
    -
    - - - - - -
    IdName
    -
    -
    + \ No newline at end of file diff --git a/nifi-site/src/pages/html/rest-api.hbs b/nifi-site/src/pages/html/rest-api.hbs new file mode 100644 index 0000000000..7efb462e5c --- /dev/null +++ b/nifi-site/src/pages/html/rest-api.hbs @@ -0,0 +1,7 @@ +--- +title: Apache NiFi Rest Api +--- + +
    + +
    \ No newline at end of file diff --git a/nifi-site/src/pages/html/roadmap.hbs b/nifi-site/src/pages/html/roadmap.hbs deleted file mode 100644 index 45da108de3..0000000000 --- a/nifi-site/src/pages/html/roadmap.hbs +++ /dev/null @@ -1,30 +0,0 @@ ---- -title: Apache NiFi Roadmap ---- - -
    -
    -
    -

    - - Apache nifi Roadmap - -

    -
    -
    -
    -
    -

    - - First steps - -

    -
    -
    -
    -
    -

    - Initial work on Apache NiFi (incubating) will be focused on an initial incubating release. This means, migrating to apache infrastructure, using apache license compatible dependencies, developing developer documentation, and working out bugs introduced or discovered during this process. -

    -
    -
    diff --git a/nifi-site/src/pages/html/screencasts.hbs b/nifi-site/src/pages/html/screencasts.hbs index 78c0466876..fcd78f9a5e 100644 --- a/nifi-site/src/pages/html/screencasts.hbs +++ b/nifi-site/src/pages/html/screencasts.hbs @@ -15,7 +15,25 @@ title: Apache NiFi Screencasts

    NiFi Toolbar Overview

    - + +
    + × +
    +
    + Build a Simple Flow - Part 1 +
    +

    Build a Simple Flow - Part 1

    +
    + +
    + × +
    +
    + Build a Simple Flow - Part 2 +
    +

    Build a Simple Flow - Part 2

    +
    +
    ×
    @@ -24,7 +42,7 @@ title: Apache NiFi Screencasts

    Creating Process Groups

    - +
    ×
    @@ -33,7 +51,25 @@ title: Apache NiFi Screencasts

    Creating Templates

    - + +
    + × +
    +
    + Summary Overview +
    +

    Summary Overview

    +
    + +
    + × +
    +
    + Provenance Overview +
    +

    Summary Page Overview

    +
    +
    ×
    @@ -42,9 +78,10 @@ title: Apache NiFi Screencasts

    Managing Templates

    - +
    ×
    +
    \ No newline at end of file diff --git a/nifi-site/src/pages/html/user-guide.hbs b/nifi-site/src/pages/html/user-guide.hbs index 19537d897c..8fa6c7d9c9 100644 --- a/nifi-site/src/pages/html/user-guide.hbs +++ b/nifi-site/src/pages/html/user-guide.hbs @@ -3,5 +3,5 @@ title: Apache NiFi User Guide ---
    - +
    \ No newline at end of file diff --git a/nifi-site/src/pages/markdown/licensing-guide.md b/nifi-site/src/pages/markdown/licensing-guide.md new file mode 100644 index 0000000000..ac7fb3b549 --- /dev/null +++ b/nifi-site/src/pages/markdown/licensing-guide.md @@ -0,0 +1,120 @@ +--- +title: Apache NiFi Licensing Guide +--- + +# Apache NiFi Release Guidelines + +This document provides guidance to contributors of Apache NiFi (incubating) to help properly account for licensing, notice, and legal requirements. + +#### Disclaimer: + +This document is not written by lawyers. The guidance in this document is meant to compliment Apache Incubator and Apache Software Foundation guides and policies. If anything in this document is inconsistent with those then it is a defect in this document. + +## Background Material + +- [ASLv2](http://apache.org/licenses/LICENSE-2.0) +- [ASF License Apply](http://www.apache.org/dev/apply-license.html) +- [ASF Licensing How-To](http://www.apache.org/dev/licensing-howto.html) +- [ASF Legal Resolved](http://www.apache.org/legal/resolved.html) +- [ASF Release Policy](http://www.apache.org/dev/release.html) +- [ASF Incubator License and Notice Guidance](http://incubator.apache.org/guides/releasemanagement.html#note-license-and-notice) + +## How to consistently apply licensing/legal notice information for Apache NiFi + +### Apply the source header to each source file + +Every source file for works submitted directly to the ASF must follow: http://apache.org/legal/src-headers.html#headers + +Question: Every source file? What about test files and so on? +Answer: There are a few exceptions. Test files can be argued to have no degree of creativity. We also need our test materials at times to be exactly as they will be found in the wild. We should ensure test files have the license when possible but not to the point that it requires altering the test itself. + http://apache.org/legal/src-headers.html#faq-exceptions + +Question: Do items which are generated from source during the build process require the header? +Answer: Taken directly from http://incubator.apache.org/guides/releasemanagement.html#notes-license-headers it reads: + "Copyright may not subsist in a document which is generated by an transformation from an original. In which case, the license header may be unnecessary. License headers should always be present in the original. Where it is reasonable to do so, the templates should also add the license header to the generated documents." + +### Apply the proper NOTICE / LICENSE Information + +For every addition or removal of a 3rd party work as a dependency or as pulled into our source directly we must ensure full +accounting of the correct LICENSE and NOTICE information. + +Our source release must only account for the LICENSE/NOTICE of items that are actually in the source release itself. +Binary dependencies which are pulled in during the generation of a binary convenience package should not have their +LICENSE/NOTICE data in the source release. But, they must be accounted for in the binary package. + +The LICENSE and NOTICE files found at the root of the Apache NiFi (nifi) component is considered 'The' LICENSE/NOTICE +covering the source release of 'nifi' and all subcomponents. + +The LICENSE and NOTICE files found within the 'nifi-assembly' is considered 'The' LICENSE/NOTICE pair covering the binary +convenience package of 'nifi' (tar.gz, ZIP, etc..) + +The Release Manager (RM) of a given release is responsible for checking all subcomponents for the presence of specific +LICENSE/NOTICE to gather all source dependency clauses as needed and place them into the overall LICENSE/NOTICE for the +source release. If generating a binary convenience package the RM will gather up a listing of all binary dependencies +as called out on subcomponents (including the assembly itself), which can contain binary dependencies, and promote +their specific NOTICE/LICENSE text to the binary package LICENSE/NOTICE associated with the assembly. The binary package +LICENSE/NOTICE then should be a combination of source license data and binary license data. + +A binary artifact is any artifact which is created as the result of "compiling" or processing a source artifact. + +For every subcomponent of nifi some binary artifact is produced because we make these things available as Maven artifacts. You must consider whether that artifact stands on its own as built from source or whether that artifact is comprised of materials built from source combined with other binary artifacts pulled in as dependencies. + +In the case of subcomponents which produce binary artifacts which stand on their own (as would be typical in most Jar +files) then you must only account for any 3rd party works source dependencies. If you have any 3rd party works source +dependencies then you should create or edit the LICENSE and/or NOTICE local to that subcomponent AND modify the +NOTICE and/or LICENSE of the top level nifi source. + +In the case of subcomponents which produce binary artifacts which themselves can bunde 3rd party works (as would be +typical in a NAR, WAR, tar.gz, zip bundle) then you must ensure that the subcomponent binary artifact itself includes +a full and complete LICENSE and/or NOTICE as needed to cover those 3rd party works. For every modification to the +subcomponent LICENSE/NOTICE for a given 3rd party work the overall Apache NiFi source and binary LICENSE/NOTICE pairs +need to be updated and/or verified as well. + +To provide a subcomponent local LICENSE/NOTICE ensure there is a 'src/main/resources/META-INF/NOTICE' and +'src/main/resources/META-INF/LICENSE' as needed. During the build process Maven will place them in the customary +locations for the binary artifact. This way for every binary artifact produced from Apache NiFi there will be a +local and accurate LICENSE/NOTICE for that artifact. + +### How to go about working with the LICENSE/NOTICE modifications + +If the dependency is a source dependency (ie you copied in javascript, css, java source files from a website) then you + must ensure it is from [Category-A](http://www.apache.org/legal/resolved.html#category-a) licenses. + +If the dependency is a binary dependency (ie maven pulled in a jar file) then you must ensure it is either from +[Category-A](http://www.apache.org/legal/resolved.html#category-a) or +[Category-B](http://www.apache.org/legal/resolved.html#category-b). + +The key guides for how to apply the LICENSE/NOTICE is found in the following: + + - [Source Headers](http://apache.org/legal/src-headers.html#3party) + - [Third Party Notices](http://apache.org/legal/resolved.html#required-third-party-notices.) + - [How to modify the NOTICE](http://www.apache.org/dev/licensing-howto.html#mod-notice) + +Specific guidance for handling LICENSE/NOTICE application for typical MIT/BSD licenses is +described [here](http://www.apache.org/dev/licensing-howto.html#permissive-deps). For understanding what to put in the +LICENSE file look at the license of the 3rd party work. BSD licenses for instance have this statement "Redistributions +in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution." In the event you cannot find the actual +Copyright statement for a dependency then place a link to the license text they claim and indicate no copyright marks +found and provide a link to the project website. + +Specific guidance for handling Apache Licensed dependencies is describe [here](http://www.apache.org/dev/licensing-howto.html#alv2-dep). +"If the dependency supplies a NOTICE file, its contents must be analyzed and the relevant portions bubbled up into the top-level NOTICE file." + +Specific guidance for handling other ASF projects is found [here](http://www.apache.org/dev/licensing-howto.html#bundle-asf-product). +"It is not necessary to duplicate the line "This product includes software developed at the Apache Software +Foundation...", though the ASF copyright line and any other portions of NOTICE must be considered for propagation." + +Specific guidance for handling LICENSE/NOTICE information for category-B licensed works is [here](http://apache.org/legal/resolved.html#category-b). +Place an entry in the notice indicating the work is included in binary distribution. Provide a link to the +homepage of the work. Indicate it's license. Group like licensed items together. "By attaching a prominent label to +the distribution and requiring an explicit action by the user to get the reciprocally-licensed source, users are less +likely to be unaware of restrictions significantly different from those of the Apache License. Please include the URL +to the product's homepage in the prominent label." You should not modify the LICENSE file to include the LICENSE +information of the 3rd party work in this case. That is explained nicely in http://opensource.org/faq#copyleft as +stated "Copyleft provisions apply only to actual derivatives, that is, cases where an existing copylefted work was +modified. Merely distributing a copyleft work alongside a non-copyleft work does not cause the latter to fall under +the copyleft terms." + +Specific guidance for handling works in the public domain is [here](http://apache.org/legal/resolved.html#can-works-placed-in-the-public-domain-be-included-in-apache-products) + diff --git a/nifi-site/src/pages/markdown/quickstart.md b/nifi-site/src/pages/markdown/quickstart.md index c0148d76c7..379cda99c3 100644 --- a/nifi-site/src/pages/markdown/quickstart.md +++ b/nifi-site/src/pages/markdown/quickstart.md @@ -4,20 +4,11 @@ title: Apache NiFi Development Quickstart # Apache NiFi Development Quickstart -This documentation is in progress, but should get many started at building Apache NiFi. - ## Source Code Apache NiFi source code is version controlled using [Git][git] version control ([browse][gitbrowse]|[checkout][gitrepo]). - The code is also mirrored to [Github][githubrepo] -The code as it was initially contributed and entered the incubator is on the 'master' branch. - -To view the lastest codebase as we work toward an initial release checkout the 'develop' branch. - -All guidance that follows assumes you are working on the 'develop' branch. - ## Issue Tracking Track issues on the "NIFI" Project on the Apache Jira ([browse][jira]). @@ -42,9 +33,13 @@ git checkout develop 1. You need a recent Java 7 (or newer) JDK. 2. You need Apache [Maven 3.X][maven]. We've successfully used 3.2.3 and as far back as 3.0.5 -3. Build the maven plugins. In the root dir of the source tree cd to `nifi-nar-maven-plugin`. +3. Ensure your MAVEN_OPTS provides sufficient memory. Some build steps are fairly memory intensive + - These settings have worked well `MAVEN_OPTS="-Xms1024m -Xmx3076m -XX:MaxPermSize=256m"` +4. Build the nifi parent. In the root dir of the source tree cd to `nifi-parent`. Run `mvn clean install` -4. Build the entire code base. In the root dir of the source tree cd to `nifi` and run `mvn -T C2.0 clean install` +5. Build the nifi nar maven plugin. In the root dir of the source tree cd to `nifi-nar-maven-plugin`. + Run `mvn clean install` +6. Build the entire code base. In the root dir of the source tree cd to `nifi` and run `mvn -T C2.0 clean install` You can tweak the maven build settings as you like but the previous command will execute with 2 threads per core. Now you should have a fully functioning build off the latest code in the develop branch. diff --git a/nifi-site/src/pages/markdown/release-guide.md b/nifi-site/src/pages/markdown/release-guide.md index 7387692bd6..b1df726655 100644 --- a/nifi-site/src/pages/markdown/release-guide.md +++ b/nifi-site/src/pages/markdown/release-guide.md @@ -50,20 +50,18 @@ There are two lists here: one of specific incubator requirements, and another of - Specifically look in the *-sources.zip artifact and ensure these items are present at the root of the archive. - Evaluate the sources and dependencies. Does the overall LICENSE and NOTICE appear correct? Do all licenses fit within the ASF approved licenses? - Here is an example path to a sources artifact: - - `https://repository.apache.org/service/local/repositories/orgapachenifi-1011/content/org/apache/nifi/nifi-nar-maven-plugin/0.0.1-incubating/nifi-nar-maven-plugin-0.0.1-incubating-source-release.zip` + - `https://repository.apache.org/service/local/repositories/orgapachenifi-1011/content/org/apache/nifi/nifi/0.0.1-incubating/nifi-0.0.1-incubating-source-release.zip` - Is there a README available that explains how to build the application and to execute it? - Look in the *-sources.zip artifact root for the readme. - Are the signatures and hashes correct for the source release? - Validate the hashes of the sources artifact do in fact match: - - `https://repository.apache.org/service/local/repositories/orgapachenifi-1011/content/org/apache/nifi/nifi-nar-maven-plugin/0.0.1-incubating/nifi-nar-maven-plugin-0.0.1-incubating-source-release.zip.md5` - - `https://repository.apache.org/service/local/repositories/orgapachenifi-1011/content/org/apache/nifi/nifi-nar-maven-plugin/0.0.1-incubating/nifi-nar-maven-plugin-0.0.1-incubating-source-release.zip.sha1` - - Validate the signatures of the sources artifact and of each of the hashes. Here are example paths: - - `https://repository.apache.org/service/local/repositories/orgapachenifi-1011/content/org/apache/nifi/nifi-nar-maven-plugin/0.0.1-incubating/nifi-nar-maven-plugin-0.0.1-incubating-source-release.zip.asc` - - `https://repository.apache.org/service/local/repositories/orgapachenifi-1011/content/org/apache/nifi/nifi-nar-maven-plugin/0.0.1-incubating/nifi-nar-maven-plugin-0.0.1-incubating-source-release.zip.asc.md5` - - `https://repository.apache.org/service/local/repositories/orgapachenifi-1011/content/org/apache/nifi/nifi-nar-maven-plugin/0.0.1-incubating/nifi-nar-maven-plugin-0.0.1-incubating-source-release.zip.asc.sha1` + - `https://repository.apache.org/service/local/repositories/orgapachenifi-1011/content/org/apache/nifi/nifi/0.0.1-incubating/nifi-0.0.1-incubating-source-release.zip.md5` + - `https://repository.apache.org/service/local/repositories/orgapachenifi-1011/content/org/apache/nifi/nifi/0.0.1-incubating/nifi-0.0.1-incubating-source-release.zip.sha1` + - Validate the signature of the source artifact. Here is an example path: + - `https://repository.apache.org/service/local/repositories/orgapachenifi-1011/content/org/apache/nifi/nifi/0.0.1-incubating/nifi-0.0.1-incubating-source-release.zip.asc` - Need a quick reminder on how to [verify a signature](http://www.apache.org/dev/release-signing.html#verifying-signature)? - Do all sources have necessary headers? - - Unzip the sources file into a directory and execute `mvn install -Pcheck-licenses` + - Unzip the sources file into a directory and execute `mvn install -Pcontrib-check` - Are there no unexpected binary files in the release? - The only thing we'd expect would be potentially test resources files. - Does the app (if appropriate) execute and function as expected? @@ -95,9 +93,9 @@ have in mind the release version you are planning for. For example we'll consid Create the next version in JIRA if necessary so develop work can continue towards that release. Create new branch off develop named after the JIRA ticket or just use the develop branch itself. Here we'll use a branch off of develop with -`git checkout -b NIFI-270` +`git checkout -b NIFI-270-RC1` -Change directory into that of the project you wish to release. For example either `cd nifi` or `cd nifi-nar-maven-plugin` +Change directory into that of the project you wish to release. For example `cd nifi` Verify that Maven has sufficient heap space to perform the build tasks. Some plugins and parts of the build consumes a surprisingly large amount of space. These settings have been shown to @@ -128,34 +126,34 @@ Ensure your settings.xml has been updated as shown below. There are other ways Ensure the the full application build and tests all work by executing `mvn -T 2.5C clean install` for a parallel build. Once that completes you can -startup and test the application by `cd assembly/target` then run `bin/nifi.sh start` in the nifi build. +startup and test the application by `cd nifi-assembly/target` then run `bin/nifi.sh start` in the nifi build. The application should be up and running in a few seconds at `http://localhost:8080/nifi` Evaluate and ensure the appropriate license headers are present on all source files. Ensure LICENSE and NOTICE files are complete and accurate. Developers should always be keeping these up to date as they go along adding source and modifying dependencies to keep this burden manageable. -This command `mvn install -Pcheck-licenses` should be run as well to help validate. If that doesn't complete cleanly it must be addressed. +This command `mvn install -Pcontrib-check` should be run as well to help validate. If that doesn't complete cleanly it must be addressed. -Now its time to have maven prepare the release so execute `mvn release:prepare -Psigned_release -DscmCommentPrefix="NIFI-270 " -Darguments="-DskipTests"`. +Now its time to have maven prepare the release so execute `mvn release:prepare -Psigned_release -DscmCommentPrefix="NIFI-270-RC1 " -Darguments="-DskipTests"`. Maven will ask: -`What is the release version for "Apache NiFi NAR Plugin"? (org.apache.nifi:nifi-nar-maven-plugin) 0.0.1-incubating: :` +`What is the release version for "Apache NiFi"? (org.apache.nifi:nifi) 0.0.1-incubating: :` Just hit enter to accept the default. Maven will then ask: -`What is SCM release tag or label for "Apache NiFi NAR Plugin"? (org.apache.nifi:nifi-nar-maven-plugin) nifi-nar-maven-plugin-0.0.1-incubating: : ` +`What is SCM release tag or label for "Apache NiFi"? (org.apache.nifi:nifi) nifi-0.0.1-incubating: : ` -Enter `nifi-nar-maven-plugin-0.0.1-incubating-RC1` or whatever the appropriate release candidate (RC) number is. +Enter `nifi-0.0.1-incubating-RC1` or whatever the appropriate release candidate (RC) number is. Maven will then ask: -`What is the new development version for "Apache NiFi NAR Plugin"? (org.apache.nifi:nifi-nifi-nar-maven-plugin) 0.0.2-incubating-SNAPSHOT: :` +`What is the new development version for "Apache NiFi"? (org.apache.nifi:nifi) 0.0.2-incubating-SNAPSHOT: :` Just hit enter to accept the default. Now that preparation went perfectly it is time to perform the release and deploy artifacts to staging. To do that execute -`mvn release:perform -Psigned_release -DscmCommentPrefix="NIFI-270 " -Darguments="-DskipTests"` +`mvn release:perform -Psigned_release -DscmCommentPrefix="NIFI-270-RC1 " -Darguments="-DskipTests"` That will complete successfully and this means the artifacts have been released to the Apache Nexus staging repository. You will see something like @@ -174,6 +172,11 @@ Validate that all the various aspects of the staged artifacts appear correct If all looks good then push the branch to origin `git push origin NIFI-270` +If it is intended that convenience binaries will be provided for this release then the community has requested that +a copy it be made available for reviewing of the release candidate. The convenience binary, its hashes, and signature + should be placed here: + - https://dist.apache.org/repos/dist/dev/incubator/nifi + If anything isn't correct about the staged artifacts you can drop the staged repo from repository.apache.org and delete the local tag in git. If you also delete the local branch and clear your local maven repository under org/apache/nifi then it is as if the release never happened. Before doing that though try to figure out what went wrong. So as described here you see @@ -181,21 +184,21 @@ that you can pretty easily test the release process until you get it right. The commands can come in handy to help do this so you can set versions to something clearly release test related. Now it's time to initiate a vote within the PPMC. Send the vote request to `dev@nifi.incubator.apache.org` -with a subject of `[VOTE] Release Apache NiFi nifi-nar-maven-plugin-0.0.1-incubating`. The following template can be used: +with a subject of `[VOTE] Release Apache NiFi 0.0.1-incubating`. The following template can be used: ``` Hello I am pleased to be calling this vote for the source release of Apache NiFi -nifi-nar-maven-plugin-0.0.1-incubating. +nifi-0.0.1-incubating. The source zip, including signatures, digests, etc. can be found at: https://repository.apache.org/content/repositories/orgapachenifi-1011 -The Git tag is nifi-nar-maven-plugin-0.0.1-incubating-RC1 +The Git tag is nifi-0.0.1-incubating-RC1 The Git commit ID is 72abf18c2e045e9ef404050e2bffc9cef67d2558 https://git-wip-us.apache.org/repos/asf?p=incubator-nifi.git;a=commit;h=72abf18c2e045e9ef404050e2bffc9cef67d2558 -Checksums of nifi-nar-maven-plugin-0.0.1-incubating-source-release.zip: +Checksums of nifi-0.0.1-incubating-source-release.zip: MD5: 5a580756a17b0573efa3070c70585698 SHA1: a79ff8fd0d2f81523b675e4c69a7656160ff1214 @@ -211,19 +214,19 @@ https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12316020&versio The vote will be open for 72 hours. Please download the release candidate and evaluate the necessary items including checking hashes, signatures, build from source, and test. The please vote: -[ ] +1 Release this package as nifi-nar-maven-plugin-0.0.1-incubating +[ ] +1 Release this package as nifi-0.0.1-incubating [ ] +0 no opinion [ ] -1 Do not release this package because because... ```
    -A release vote is majority rule. So wait 72 hours and see if there are at least 3 binding +1 votes and no more negative votes than positive. +A release vote is majority rule. So wait 72 hours and see if there are at least 3 binding (in the PPMC sense of binding) +1 votes and no more negative votes than positive. If so forward the vote to the IPMC. Send the vote request to `general@incubator.apache.org` with a subject of -`[VOTE] Release Apache NiFi nifi-nar-maven-plugin-0.0.1-incubating`. The following template can be used: +`[VOTE] Release Apache NiFi 0.0.1-incubating`. The following template can be used: ``` Hello -The Apache NiFi PPMC has voted to release Apache NiFi nar-maven-plugin-0.0.1-incubating. +The Apache NiFi PPMC has voted to release Apache NiFi 0.0.1-incubating. The vote was based on the release candidate and thread described below. We now request the IPMC to vote on this release. @@ -236,11 +239,11 @@ Here is the PPMC vote thread: [URL TO PPMC Vote Thread] The source zip, including signatures, digests, etc. can be found at: https://repository.apache.org/content/repositories/orgapachenifi-1011 -The Git tag is nar-maven-plugin-0.0.1-incubating-RC1 +The Git tag is nifi-0.0.1-incubating-RC1 The Git commit ID is 72abf18c2e045e9ef404050e2bffc9cef67d2558 https://git-wip-us.apache.org/repos/asf?p=incubator-nifi.git;a=commit;h=72abf18c2e045e9ef404050e2bffc9cef67d2558 -Checksums of nar-maven-plugin-0.0.1-incubating-source-release.zip: +Checksums of nifi-0.0.1-incubating-source-release.zip: MD5: 5a580756a17b0573efa3070c70585698 SHA1: a79ff8fd0d2f81523b675e4c69a7656160ff1214 @@ -256,13 +259,13 @@ https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12316020&versio The vote will be open for 72 hours. Please download the release candidate and evaluate the necessary items including checking hashes, signatures, build from source, and test. The please vote: -[ ] +1 Release this package as nar-maven-plugin-0.0.1-incubating +[ ] +1 Release this package as nifi-0.0.1-incubating [ ] +0 no opinion [ ] -1 Do not release this package because because... ```
    Wait 72 hours. If the vote passes then send a vote result email. Send the email to `general@incubator.apache.org, dev@nifi.incubator.apache.org` -with a subject of `[RESULT][VOTE] Release Apache NiFi nar-maven-plugin-0.0.1-incubating`. Use a template such as: +with a subject of `[RESULT][VOTE] Release Apache NiFi 0.0.1-incubating`. Use a template such as: ``` Hello @@ -277,12 +280,69 @@ Thanks to all who helped make this release possible. Here is the IPMC vote thread: [INSERT URL OF IPMC Vote Thread] ```
    -Now all the voting is done and the release is good to go. In repository.apache.org go to the staging repository -and select `release`. Then publish the source, hashes, and signatures to `https://dist.apache.org/repos/dist/release/incubator/nifi/` -Then merge the release git tag to develop and to master. +Now all the voting is done and the release is good to go. + +Here are the steps of the release once the release is approved: + +1. Upload source-release artifacts to dist. If the release version is 0.0.1-incubating then upload them (zip, asc, md5, sha1) to +`https://dist.apache.org/repos/dist/release/incubator/nifi/0.0.1-incubating` + +2. To produce binary convenience release build the application from the raw source in staging. For each binary convenience artifact: + - Generate ascii armored detached signature by running `gpg -a -b nifi-0.0.1-incubating-bin.tar.gz` + - Generate md5 hash summary by running `md5sum nifi-0.0.1-incubating-bin.tar.gz | awk '{ printf substr($0,0,32)}' > nifi-0.0.1-incubating-bin.tar.gz.md5` + - Generate sha1 hash summary by running `sha1sum nifi-0.0.1-incubating-bin.tar.gz | awk '{ printf substr($0,0,40)}' > nifi-0.0.1-incubating-bin.tar.gz.sha1` + - Upload the bin, asc, sha1, md5 for each binary convenience build to the same location as the source release + +3. In repository.apache.org go to the staging repository and select `release` and follow instructions on the site. + +4. Merge the release branch into master + +5. Merge the release branch into develop + +6. Update the NiFi website to point to the new download(s) + +7. Update the NiFi incubator status page to indicate NEWS of the release + +8. In Jira mark the release version as 'Released' and 'Archived' through 'version' management in the 'administration' console. + +9. Wait 24 hours then send release announcement. + - See [here][release-announce] for an understanding of why you need to wait 24 hours + - Then create an announcement like the one shown below addressed to 'announce@apache.org, general@incubator.apache.org, dev@nifi.incubator.apache.org' with a reply-to of 'general@incubator.apache.org'. + - The email has to be sent from an apache.org email address and should be by the release manager of the build. + +``` +SUBJECT: [ANNOUNCE] Apache NiFi 0.0.2-incubating release +BODY: +Hello + +The Apache NiFi team would like to announce the release of Apache NiFi 0.0.2-incubating. + +Apache NiFi is an easy to use, powerful, and reliable system to process and distribute data. Apache NiFi was made for dataflow. It supports highly configurable directed graphs of data routing, transformation, and system mediation logic. + +More details on Apache NiFi can be found here: +http://nifi.incubator.apache.org/ + +The release artifacts can be downloaded from here: +http://nifi.incubator.apache.org/downloads/ + +Maven artifacts have been made available here: +https://repository.apache.org/content/repositories/releases/org/apache/nifi/ + +Release notes available here: +https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12316020&version=12329373 + +Thank you +The Apache NiFi team + +---- +DISCLAIMER + +Apache NiFi is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by Apache Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF. +``` [quickstart-guide]: http://nifi.incubator.apache.org/development/quickstart.html [release-manager]: http://www.apache.org/dev/release-publishing.html#release_manager +[release-announce]: http://www.apache.org/dev/release.html#release-announcements [apache-license]: http://apache.org/licenses/LICENSE-2.0 [apache-license-apply]: http://www.apache.org/dev/apply-license.html [apache-legal-resolve]: http://www.apache.org/legal/resolved.html diff --git a/nifi-site/src/scss/app.scss b/nifi-site/src/scss/app.scss index ddd0c875a3..70de9e7b59 100644 --- a/nifi-site/src/scss/app.scss +++ b/nifi-site/src/scss/app.scss @@ -187,6 +187,8 @@ div.external-guide { div.external-guide iframe { width: 100%; height: 100%; + border-width: 0; + display: block; } /* diff --git a/nifi/LICENSE b/nifi/LICENSE index 50150e3537..59075cdb25 100644 --- a/nifi/LICENSE +++ b/nifi/LICENSE @@ -455,3 +455,25 @@ This product bundles 'json2.js' which is available in the 'public domain'. This product bundles 'reset.css' which is available in the 'public domain'. For details see http://meyerweb.com/eric/tools/css/reset/ +This product bundles HexViewJS available under an MIT License + + Copyright (c) 2010 Nick McVeity + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/nifi/README.md b/nifi/README.md index 5545539247..cffa09ad87 100644 --- a/nifi/README.md +++ b/nifi/README.md @@ -19,9 +19,9 @@ Apache NiFi is an easy to use, powerful, and reliable system to process and dist ## Table of Contents - [Features](#features) +- [Requirements](#requirements) - [Getting Started](#getting-started) - [Getting Help](#getting-help) -- [Requirements](#requirements) - [License](#license) - [Disclaimer](#disclaimer) - [Export Control] (#export-control) @@ -47,17 +47,64 @@ Apache NiFi was made for dataflow. It supports highly configurable directed grap - SSL, SSH, HTTPS, encrypted content, etc... - Pluggable role-based authentication/authorization +## Requirements +* JDK 1.7 or higher +* Apache Maven 3.0.5 or higher + ## Getting Started To build: -- Execute 'mvn clean install' or for parallel build execute 'mvn -T 2.0C clean install' -- Change directory to 'nifi-assembly'. In the target directory, there should be a build of nifi. -- Unpack the build wherever you like or use the already unpacked build. +- Execute `mvn clean install` or for parallel build execute `mvn -T 2.0C clean install`. On a + modest development laptop that is a couple of years old, the latter build takes a bit under ten + minutes. After a large amount of output you should eventually see a success message. -To start NiFi: -- Change directory to the location where you installed NiFi -- '/bin/nifi.sh start' -- Direct your browser to http://localhost:8080/nifi/ + laptop:nifi fhampton$ mvn -T 2.0C clean install + [INFO] Scanning for projects... + [INFO] Inspecting build with total of 115 modules... + ...tens of thousands of lines elided... + [INFO] ------------------------------------------------------------------------ + [INFO] BUILD SUCCESS + [INFO] ------------------------------------------------------------------------ + [INFO] Total time: 09:24 min (Wall Clock) + [INFO] Finished at: 2015-04-30T00:30:36-05:00 + [INFO] Final Memory: 173M/1359M + [INFO] ------------------------------------------------------------------------ + +To deploy: +- Change directory to 'nifi-assembly'. In the target directory, there should be a build of nifi. + + laptop:nifi fhampton$ cd nifi-assembly + laptop:nifi-assembly fhampton$ ls -lhd target/nifi* + drwxr-xr-x 3 fhampton staff 102B Apr 30 00:29 target/nifi-0.1.0-incubating-SNAPSHOT-bin + -rw-r--r-- 1 fhampton staff 144M Apr 30 00:30 target/nifi-0.1.0-incubating-SNAPSHOT-bin.tar.gz + -rw-r--r-- 1 fhampton staff 144M Apr 30 00:30 target/nifi-0.1.0-incubating-SNAPSHOT-bin.zip + +- For testing ongoing development you could use the already unpacked build present in the directory + named "nifi-*version*-bin", where *version* is the current project version. To deploy in another + location make use of either the tarball or zipfile and unpack them wherever you like. The + distribution will be within a common parent directory named for the version. + + laptop:nifi-assembly fhampton$ mkdir ~/example-nifi-deploy + laptop:nifi-assembly fhampton$ tar xzf target/nifi-*-bin.tar.gz -C ~/example-nifi-deploy + laptop:nifi-assembly fhampton$ ls -lh ~/example-nifi-deploy/ + total 0 + drwxr-xr-x 10 fhampton staff 340B Apr 30 01:06 nifi-0.1.0-incubating-SNAPSHOT + +To run NiFi: +- Change directory to the location where you installed NiFi and run it. + + laptop:~ fhampton$ cd ~/example-nifi-deploy/nifi-* + laptop:nifi-0.1.0-incubating-SNAPSHOT fhampton$ ./bin/nifi.sh start + +- Direct your browser to http://localhost:8080/nifi/ and you should see a screen like this screenshot: + ![image of a NiFi dataflow canvas](nifi-docs/src/main/asciidoc/images/nifi_first_launch_screenshot.png?raw=true) + +- For help building your first data flow see the [NiFi User Guide](http://nifi.incubator.apache.org/docs/nifi-docs/user-guide.html) + +- If you are testing ongoing development, you will likely want to stop your instance. + + laptop:~ fhampton$ cd ~/example-nifi-deploy/nifi-* + laptop:nifi-0.1.0-incubating-SNAPSHOT fhampton$ ./bin/nifi.sh stop ## Getting Help If you have questions, you can reach out to our mailing list: dev@nifi.incubator.apache.org @@ -65,9 +112,6 @@ If you have questions, you can reach out to our mailing list: dev@nifi.incubator We're also often available in IRC: #nifi on [irc.freenode.net](http://webchat.freenode.net/?channels=#nifi). -## Requirements -* JDK 1.7 or higher - ## License Except as otherwise noted this software is licensed under the diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicProperties.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicProperties.java index 6dbc86d792..902f5e9459 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicProperties.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicProperties.java @@ -25,18 +25,13 @@ import java.lang.annotation.Target; /** * Indicates that a component has more than one dynamic property - * - * @author * */ @Documented -@Target({ ElementType.TYPE }) +@Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Inherited public @interface DynamicProperties { - /** - * A list of the dynamic properties supported by a component - * @return A list of the dynamic properties supported by a component - */ + public DynamicProperty[] value(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicProperty.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicProperty.java index 07f349c388..dbb34b6b49 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicProperty.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicProperty.java @@ -28,40 +28,19 @@ import org.apache.nifi.components.ConfigurableComponent; /** * An annotation that may be placed on a {@link ConfigurableComponent} to * indicate that it supports a dynamic property. - * - * @author * */ @Documented -@Target({ ElementType.TYPE }) +@Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Inherited public @interface DynamicProperty { - /** - * A description of what the name of the dynamic property may be - * - * @return A description of what the name of the dynamic property may be - */ + public String name(); - /** - * Indicates whether or not the dynamic property supports expression - * language - * - * @return whether or not the dynamic property supports expression - * language - */ public boolean supportsExpressionLanguage() default false; - - /** - * A description of what the value of the dynamic property may be - * @return a description of what the value of the dynamic property may be - */ + public String value(); - - /** - * Provides a description of what the meaning of the property is, and what the expected values are - * @return a description of what the meaning of the property is, and what the expected values are - */ + public String description(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicRelationship.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicRelationship.java index df0799fb6a..4129201b79 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicRelationship.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicRelationship.java @@ -31,26 +31,15 @@ import org.apache.nifi.processor.Relationship; * Annotation to indicate that a {@link Processor} supports dynamic * relationship. A dynamic {@link Relationship} is one where the relationship is * generated based on a user defined {@link PropertyDescriptor} - * - * @author * */ @Documented -@Target({ ElementType.TYPE }) +@Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Inherited public @interface DynamicRelationship { - /** - * Describes the name(s) of the dynamic relationship(s) - * - * @return a description of the name(s) of the dynamic relationship(s) - */ + public String name(); - /** - * Describes the data that should be routed to the dynamic relationship(s) - * - * @return a description the data that should be routed to the dynamic relationship(s) - */ public String description(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/EventDriven.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/EventDriven.java index 279a49eadb..c548b59df9 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/EventDriven.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/EventDriven.java @@ -38,7 +38,6 @@ import java.lang.annotation.Target; * eligible to be scheduled in Event-Driven mode. *

    * - * @author none */ @Documented @Target({ElementType.TYPE}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/ReadsAttribute.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/ReadsAttribute.java index d17ec2fed3..fb9e2abf91 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/ReadsAttribute.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/ReadsAttribute.java @@ -24,27 +24,18 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Annotation that may be placed on a {@link org.apache.nifi.processor.Processor Processor} - * indicating that this processor reads a specific FlowFile attribute. - * - * @author + * Annotation that may be placed on a + * {@link org.apache.nifi.processor.Processor Processor} indicating that this + * processor reads a specific FlowFile attribute. * */ - @Documented @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Inherited public @interface ReadsAttribute { - /** - * The FlowFile attribute that is being read - * @return - */ + public String attribute(); - - /** - * The description of how the attribute is being used - * @return - */ + public String description() default ""; } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/ReadsAttributes.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/ReadsAttributes.java index dfa3513edf..2610e1c6e4 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/ReadsAttributes.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/ReadsAttributes.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.annotation.behavior; -import org.apache.nifi.annotation.behavior.ReadsAttribute; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; @@ -25,10 +24,9 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Annotation that may be placed on a {@link org.apache.nifi.processor.Processor Processor} - * indicating that this processor reads specific FlowFile attributes. - * - * @author + * Annotation that may be placed on a + * {@link org.apache.nifi.processor.Processor Processor} indicating that this + * processor reads specific FlowFile attributes. * */ @Documented @@ -36,9 +34,6 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Inherited public @interface ReadsAttributes { - /** - * A list of attributes that may be read - * @return - */ + public ReadsAttribute[] value(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/SideEffectFree.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/SideEffectFree.java index f32acc37db..9a64f4be43 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/SideEffectFree.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/SideEffectFree.java @@ -24,20 +24,18 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Marker annotation a {@link org.apache.nifi.processor.Processor Processor} - * implementation can use to indicate that its - * operations on FlowFiles can be safely repeated across process sessions. If a - * processor has this annotation and it allows the framework to manage session - * commit and rollback then the framework may elect to cascade a - * {@link org.apache.nifi.processor.ProcessSession ProcessSession} given to this - * processor's onTrigger method to the - * onTrigger method of another processor. It can do this knowing that if - * something fails along a series of processors using this same session that it - * can all be safely rolled back without any ill effects on external services - * which could not be rolled back and thus all the processes could be safely - * repeated (implied idempotent behavior). + * Marker annotation a {@link org.apache.nifi.processor.Processor Processor} + * implementation can use to indicate that its operations on FlowFiles can be + * safely repeated across process sessions. If a processor has this annotation + * and it allows the framework to manage session commit and rollback then the + * framework may elect to cascade a + * {@link org.apache.nifi.processor.ProcessSession ProcessSession} given to this + * processor's onTrigger method to the onTrigger method of another processor. It + * can do this knowing that if something fails along a series of processors + * using this same session that it can all be safely rolled back without any ill + * effects on external services which could not be rolled back and thus all the + * processes could be safely repeated (implied idempotent behavior). * - * @author none */ @Documented @Target({ElementType.TYPE}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/SupportsBatching.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/SupportsBatching.java index f5fd61f0df..807e637f94 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/SupportsBatching.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/SupportsBatching.java @@ -41,7 +41,6 @@ import java.lang.annotation.Target; * ProcessSession.commit() to ensure data is persisted before deleting the data * from a remote source. * - * @author none */ @Documented @Target({ElementType.TYPE}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/TriggerSerially.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/TriggerSerially.java index 7bf7d0b62f..974e3589c1 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/TriggerSerially.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/TriggerSerially.java @@ -24,13 +24,11 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Marker annotation a {@link org.apache.nifi.processor.Processor Processor} - * implementation can use to indicate that the - * Processor is not safe for concurrent execution of its onTrigger() - * method. By default, Processors are assumed to be safe for concurrent - * execution. + * Marker annotation a {@link org.apache.nifi.processor.Processor Processor} + * implementation can use to indicate that the Processor is not safe for + * concurrent execution of its onTrigger() method. By default, Processors are + * assumed to be safe for concurrent execution. * - * @author none */ @Documented @Target({ElementType.TYPE}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/TriggerWhenAnyDestinationAvailable.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/TriggerWhenAnyDestinationAvailable.java index 803aa2f904..db115cbfa9 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/TriggerWhenAnyDestinationAvailable.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/TriggerWhenAnyDestinationAvailable.java @@ -25,13 +25,11 @@ import java.lang.annotation.Target; /** * Marker annotation a {@link org.apache.nifi.processor.Processor Processor} - * implementation can use to indicate that the - * Processor is to be triggered if any of its destinations has available space - * for incoming FlowFiles. By default, Processors are triggered only when all - * destinations report that they have available space (i.e., none of the outgoing - * Connections is full). + * implementation can use to indicate that the Processor is to be triggered if + * any of its destinations has available space for incoming FlowFiles. By + * default, Processors are triggered only when all destinations report that they + * have available space (i.e., none of the outgoing Connections is full). * - * @author none */ @Documented @Target({ElementType.TYPE}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/TriggerWhenEmpty.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/TriggerWhenEmpty.java index fed9b34823..f442b80eb5 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/TriggerWhenEmpty.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/TriggerWhenEmpty.java @@ -24,15 +24,14 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Marker annotation a {@link org.apache.nifi.processor.Processor Processor} - * implementation can use to indicate that the - * Processor should still be triggered even when it has no data in its work - * queue. By default, Processors which have no non-self incoming edges will be - * triggered even if there is no work in its queue. However, Processors that - * have non-self incoming edges will only be triggered if they have work in - * their queue or they present this annotation. + * Marker annotation a {@link org.apache.nifi.processor.Processor Processor} + * implementation can use to indicate that the Processor should still be + * triggered even when it has no data in its work queue. By default, Processors + * which have no non-self incoming edges will be triggered even if there is no + * work in its queue. However, Processors that have non-self incoming edges will + * only be triggered if they have work in their queue or they present this + * annotation. * - * @author none */ @Documented @Target({ElementType.TYPE}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/WritesAttribute.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/WritesAttribute.java index 31d05d105b..841cf40e91 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/WritesAttribute.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/WritesAttribute.java @@ -24,28 +24,18 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Annotation that may be placed on a {@link org.apache.nifi.processor.Processor Processor} - * indicating that this processor writes/updates a specific FlowFile attribute. - * - * @author + * Annotation that may be placed on a + * {@link org.apache.nifi.processor.Processor Processor} indicating that this + * processor writes/updates a specific FlowFile attribute. * */ - @Documented @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Inherited public @interface WritesAttribute { - - /** - * The FlowFile attribute that is being created or updated - * @return - */ + public String attribute(); - - /** - * A description of what is being written to the FlowFile attribute - * @return - */ + public String description() default ""; } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/WritesAttributes.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/WritesAttributes.java index 4b03af9b53..3537e7270e 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/WritesAttributes.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/WritesAttributes.java @@ -24,21 +24,16 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Annotation that may be placed on a {@link org.apache.nifi.processor.Processor Processor} - * indicating that this processor writes/updates specific FlowFile attributes. - * - * @author + * Annotation that may be placed on a + * {@link org.apache.nifi.processor.Processor Processor} indicating that this + * processor writes/updates specific FlowFile attributes. * */ - @Documented @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Inherited public @interface WritesAttributes { - /** - * A list of FlowFile attributes that may be written or updated - * @return - */ + public WritesAttribute[] value(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/documentation/CapabilityDescription.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/documentation/CapabilityDescription.java index d69788a9b1..cff6743177 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/documentation/CapabilityDescription.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/documentation/CapabilityDescription.java @@ -24,12 +24,12 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Annotation that may be placed on a {@link org.apache.nifi.processor.Processor Processor}, + * Annotation that may be placed on a {@link org.apache.nifi.processor.Processor Processor}, * {@link org.apache.nifi.controller.ControllerService ControllerService}, or - * {@link org.apache.nifi.reporting.ReportingTask ReportingTask} allowing for a description to be - * provided. This description can be provided to a user in logs, UI, etc. + * {@link org.apache.nifi.reporting.ReportingTask ReportingTask} allowing for a + * description to be provided. This description can be provided to a user in + * logs, UI, etc. * - * @author none */ @Documented @Target({ElementType.TYPE}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/documentation/SeeAlso.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/documentation/SeeAlso.java index d664117984..35ca3db704 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/documentation/SeeAlso.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/documentation/SeeAlso.java @@ -26,34 +26,19 @@ import java.lang.annotation.Target; import org.apache.nifi.components.ConfigurableComponent; /** - * Annotation that may be placed on a - * {@link org.apache.nifi.processor.Processor Processor}, + * Annotation that may be placed on a null {@link org.apache.nifi.processor.Processor Processor}, * {@link org.apache.nifi.controller.ControllerService ControllerService}, or * {@link org.apache.nifi.reporting.ReportingTask ReportingTask} that indicates * this component is related to the components listed. - * - * @author * */ - @Documented -@Target({ ElementType.TYPE }) +@Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Inherited public @interface SeeAlso { - /** - * Classes you want to link to. - * - * @return - */ + public Class[] value() default {}; - /** - * Fully qualified class names you want to link to. Use this when the class - * you want to link to is not in the class path of the component you are - * linking from. - * - * @return - */ public String[] classNames() default {}; } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/documentation/Tags.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/documentation/Tags.java index 8bd8f9a051..366dd4c6ae 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/documentation/Tags.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/documentation/Tags.java @@ -24,14 +24,13 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Annotation that can be applied to a {@link org.apache.nifi.processor.Processor Processor}, + * Annotation that can be applied to a {@link org.apache.nifi.processor.Processor Processor}, * {@link org.apache.nifi.controller.ControllerService ControllerService}, or - * {@link org.apache.nifi.reporting.ReportingTask ReportingTask} in order to associate - * tags (keywords) with the component. These tags do not affect the component in - * any way but serve as additional documentation and can be used to sort/filter - * Processors. + * {@link org.apache.nifi.reporting.ReportingTask ReportingTask} in order to + * associate tags (keywords) with the component. These tags do not affect the + * component in any way but serve as additional documentation and can be used to + * sort/filter Processors. * - * @author none */ @Documented @Target({ElementType.TYPE}) @@ -39,8 +38,5 @@ import java.lang.annotation.Target; @Inherited public @interface Tags { - /** - * @return all tag values associated with the given processor - */ public String[] value(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnAdded.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnAdded.java index a1286ea473..95edc0ac37 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnAdded.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnAdded.java @@ -25,25 +25,24 @@ import java.lang.annotation.Target; /** *

    - * Marker annotation a {@link org.apache.nifi.processor.Processor Processor}, + * Marker annotation a {@link org.apache.nifi.processor.Processor Processor}, * {@link org.apache.nifi.controller.ControllerService ControllerService}, or - * {@link org.apache.nifi.reporting.ReportingTask ReportingTask} - * implementation can use to indicate a method - * should be called whenever the component is added to the flow. This method - * will be called once for the entire life of a component instance. + * {@link org.apache.nifi.reporting.ReportingTask ReportingTask} implementation + * can use to indicate a method should be called whenever the component is added + * to the flow. This method will be called once for the entire life of a + * component instance. *

    - * + * *

    - * Methods with this annotation are called without any arguments, as all settings - * and properties can be assumed to be the defaults. + * Methods with this annotation are called without any arguments, as all + * settings and properties can be assumed to be the defaults. *

    - * + * *

    - * If any method annotated with this annotation throws a Throwable, the component - * will not be added to the flow. + * If any method annotated with this annotation throws a Throwable, the + * component will not be added to the flow. *

    - * - * @author none + * */ @Documented @Target({ElementType.METHOD}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnDisabled.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnDisabled.java index b227968931..f205bc748c 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnDisabled.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnDisabled.java @@ -27,26 +27,29 @@ import org.apache.nifi.controller.ConfigurationContext; /** *

    - * Marker annotation a {@link org.apache.nifi.controller.ControllerService ControllerService} - * can use to indicate a method should be called whenever the service is disabled. - *

    + * Marker annotation a + * {@link org.apache.nifi.controller.ControllerService ControllerService} can + * use to indicate a method should be called whenever the service is disabled. + *

    * *

    - * Methods using this annotation are permitted to take zero arguments or to take a single - * argument of type {@link ConfigurationContext}. If a method with this annotation - * throws a Throwable, a log message and bulletin will be issued for the service, and the - * service will remain in a 'DISABLING' state. When this occurs, the method with this annotation - * will be called again after some period of time. This will continue until the method returns - * without throwing any Throwable. Until that time, the service will remain in a 'DISABLING' state - * and cannot be enabled again. + * Methods using this annotation are permitted to take zero arguments or to take + * a single argument of type {@link ConfigurationContext}. If a method with this + * annotation throws a Throwable, a log message and bulletin will be issued for + * the service, and the service will remain in a 'DISABLING' state. When this + * occurs, the method with this annotation will be called again after some + * period of time. This will continue until the method returns without throwing + * any Throwable. Until that time, the service will remain in a 'DISABLING' + * state and cannot be enabled again. *

    - * + * *

    - * Note that this annotation will be ignored if applied to a ReportingTask or Processor. For a Controller - * Service, enabling and disabling are considered lifecycle events, as the action makes them usable or - * unusable by other components. However, for a Processor and a Reporting - * Task, these are not lifecycle events but rather a mechanism to allow a component to be excluded when - * starting or stopping a group of components. + * Note that this annotation will be ignored if applied to a ReportingTask or + * Processor. For a Controller Service, enabling and disabling are considered + * lifecycle events, as the action makes them usable or unusable by other + * components. However, for a Processor and a Reporting Task, these are not + * lifecycle events but rather a mechanism to allow a component to be excluded + * when starting or stopping a group of components. *

    * */ diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnEnabled.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnEnabled.java index 32aeec6e7c..289b6c4a27 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnEnabled.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnEnabled.java @@ -25,35 +25,40 @@ import java.lang.annotation.Target; /** *

    - * Marker annotation a {@link org.apache.nifi.controller.ControllerService ControllerService} - * can use to indicate a method should be called whenever the service is enabled. - * Any method that has this annotation will be called every time a user enables the service. - * Additionally, each time that NiFi is restarted, if NiFi is configured to "auto-resume state" - * and the service is enabled, the method will be invoked. + * Marker annotation a + * {@link org.apache.nifi.controller.ControllerService ControllerService} can + * use to indicate a method should be called whenever the service is enabled. + * Any method that has this annotation will be called every time a user enables + * the service. Additionally, each time that NiFi is restarted, if NiFi is + * configured to "auto-resume state" and the service is enabled, the method will + * be invoked. *

    * *

    - * Methods using this annotation must take either 0 arguments or a single argument of type + * Methods using this annotation must take either 0 arguments or a single + * argument of type * {@link org.apache.nifi.controller.ConfigurationContext ConfigurationContext}. *

    - * + * *

    - * If a method with this annotation throws a Throwable, a log message and bulletin will be issued - * for the component. In this event, the service will remain in an 'ENABLING' state and will not be - * usable. All methods with this annotation will then be called again after a delay. The service will - * not be made available for use until all methods with this annotation have returned without throwing - * anything. - *

    - * - *

    - * Note that this annotation will be ignored if applied to a ReportingTask or Processor. For a Controller - * Service, enabling and disabling are considered lifecycle events, as the action makes them usable or - * unusable by other components. However, for a Processor and a Reporting - * Task, these are not lifecycle events but rather a mechanism to allow a component to be excluded when - * starting or stopping a group of components. + * If a method with this annotation throws a Throwable, a log message and + * bulletin will be issued for the component. In this event, the service will + * remain in an 'ENABLING' state and will not be usable. All methods with this + * annotation will then be called again after a delay. The service will not be + * made available for use until all methods with this annotation have returned + * without throwing anything. *

    * - * + *

    + * Note that this annotation will be ignored if applied to a ReportingTask or + * Processor. For a Controller Service, enabling and disabling are considered + * lifecycle events, as the action makes them usable or unusable by other + * components. However, for a Processor and a Reporting Task, these are not + * lifecycle events but rather a mechanism to allow a component to be excluded + * when starting or stopping a group of components. + *

    + * + * */ @Documented @Target({ElementType.METHOD}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnRemoved.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnRemoved.java index 71202b4317..54817e4f4b 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnRemoved.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnRemoved.java @@ -28,24 +28,24 @@ import org.apache.nifi.processor.ProcessContext; /** *

    - * Marker annotation a {@link org.apache.nifi.processor.Processor Processor}, + * Marker annotation a {@link org.apache.nifi.processor.Processor Processor}, * {@link org.apache.nifi.controller.ControllerService ControllerService}, or - * {@link org.apache.nifi.reporting.ReportingTask ReportingTask} implementation - * can use to indicate a method should be called whenever the component is removed - * from the flow. This method will be called once for the entire life of a - * component instance. If the method throw any Throwable, that Throwable will be - * caught and logged but will not prevent subsequent methods with this annotation - * or removal of the component from the flow. + * {@link org.apache.nifi.reporting.ReportingTask ReportingTask} implementation + * can use to indicate a method should be called whenever the component is + * removed from the flow. This method will be called once for the entire life of + * a component instance. If the method throw any Throwable, that Throwable will + * be caught and logged but will not prevent subsequent methods with this + * annotation or removal of the component from the flow. *

    - * + * *

    - * Methods with this annotation are permitted to take no arguments or to take a single - * argument. If using a single argument, that argument must be of type {@link ConfigurationContext} - * if the component is a ReportingTask or a ControllerService. If the component is a Processor, - * then the argument must be of type {@link ProcessContext}. + * Methods with this annotation are permitted to take no arguments or to take a + * single argument. If using a single argument, that argument must be of type + * {@link ConfigurationContext} if the component is a ReportingTask or a + * ControllerService. If the component is a Processor, then the argument must be + * of type {@link ProcessContext}. *

    - * - * @author none + * */ @Documented @Target({ElementType.METHOD}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnScheduled.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnScheduled.java index c012bd728b..8fa752b778 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnScheduled.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnScheduled.java @@ -25,34 +25,39 @@ import java.lang.annotation.Target; /** *

    - * Marker annotation a {@link org.apache.nifi.processor.Processor Processor} or - * {@link org.apache.nifi.reporting.ReportingTask ReportingTask} implementation - * can use to indicate a method should be called whenever the component is scheduled - * to run. This will be called before any call to 'onTrigger' and will be called once each time - * a Processor or Reporting Task is scheduled to run. This occurs in one of two ways: either - * a user clicks to schedule the component to run, or NiFi is restarted with the "auto-resume state" - * configuration set to true (the default value) and the component is already running. - *

    - * - *

    - * Methods using this annotation must take either 0 arguments or a single argument. - *

    - * - *

    - * If using 1 argument and the component using the annotation is a Processor, that argument must - * be of type {@link org.apache.nifi.processor.ProcessContext ProcessContext}. - *

    - * - *

    - * If using 1 argument and the component using the annotation is a Reporting Task, that argument must - * be of type {@link org.apache.nifi.controller.ConfigurationContext ConfigurationContext}. + * Marker annotation a {@link org.apache.nifi.processor.Processor Processor} or + * {@link org.apache.nifi.reporting.ReportingTask ReportingTask} implementation + * can use to indicate a method should be called whenever the component is + * scheduled to run. This will be called before any call to 'onTrigger' and will + * be called once each time a Processor or Reporting Task is scheduled to run. + * This occurs in one of two ways: either a user clicks to schedule the + * component to run, or NiFi is restarted with the "auto-resume state" + * configuration set to true (the default value) and the component is already + * running. *

    * - * If any method annotated with this annotation throws any Throwable, the framework will wait a while - * and then attempt to invoke the method again. This will continue until the method succeeds, and the - * component will then be scheduled to run after this method return successfully. + *

    + * Methods using this annotation must take either 0 arguments or a single + * argument. + *

    + * + *

    + * If using 1 argument and the component using the annotation is a Processor, + * that argument must be of type + * {@link org.apache.nifi.processor.ProcessContext ProcessContext}. + *

    + * + *

    + * If using 1 argument and the component using the annotation is a Reporting + * Task, that argument must be of type + * {@link org.apache.nifi.controller.ConfigurationContext ConfigurationContext}. + *

    + * + * If any method annotated with this annotation throws any Throwable, the + * framework will wait a while and then attempt to invoke the method again. This + * will continue until the method succeeds, and the component will then be + * scheduled to run after this method return successfully. * - * @author none */ @Documented @Target({ElementType.METHOD}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnShutdown.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnShutdown.java index 3d1ce6c642..44098ff2bc 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnShutdown.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnShutdown.java @@ -28,22 +28,22 @@ import org.apache.nifi.processor.ProcessContext; /** *

    - * Marker annotation a {@link org.apache.nifi.processor.Processor Processor}, + * Marker annotation a {@link org.apache.nifi.processor.Processor Processor}, * {@link org.apache.nifi.controller.ControllerService ControllerService}, or - * {@link org.apache.nifi.reporting.ReportingTask ReportingTask} implementation - * can use to indicate a method should be called whenever the flow is being shutdown. - * This will be called at most once for each component in a JVM lifetime. - * It is not, however, guaranteed that this method will be called on shutdown, as - * the service may be killed suddenly. + * {@link org.apache.nifi.reporting.ReportingTask ReportingTask} implementation + * can use to indicate a method should be called whenever the flow is being + * shutdown. This will be called at most once for each component in a JVM + * lifetime. It is not, however, guaranteed that this method will be called on + * shutdown, as the service may be killed suddenly. *

    - * + * *

    - * Methods with this annotation are permitted to take either 0 or 1 argument. If an argument - * is used, it must be of type {@link ConfigurationContext} if the component is a ReportingTask - * or Controller Service, or of type {@link ProcessContext} if the component is a Processor. + * Methods with this annotation are permitted to take either 0 or 1 argument. If + * an argument is used, it must be of type {@link ConfigurationContext} if the + * component is a ReportingTask or Controller Service, or of type + * {@link ProcessContext} if the component is a Processor. *

    - * - * @author none + * */ @Documented @Target({ElementType.METHOD}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnStopped.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnStopped.java index fdc4fd8e09..622f158f89 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnStopped.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnStopped.java @@ -29,12 +29,11 @@ import org.apache.nifi.processor.ProcessContext; /** *

    * Marker annotation a {@link org.apache.nifi.processor.Processor Processor} or - * {@link org.apache.nifi.reporting.ReportingTask ReportingTask} - * implementation can use to indicate that a method - * should be called whenever the component is no longer scheduled to run. - * Methods marked with this annotation will be invoked each time the component - * is stopped and will be invoked only after the last thread has returned from - * the onTrigger method. + * {@link org.apache.nifi.reporting.ReportingTask ReportingTask} implementation + * can use to indicate that a method should be called whenever the component is + * no longer scheduled to run. Methods marked with this annotation will be + * invoked each time the component is stopped and will be invoked only after the + * last thread has returned from the onTrigger method. *

    * *

    @@ -47,17 +46,17 @@ import org.apache.nifi.processor.ProcessContext; * *

    * To indicate that a method should be called immediately when a component is no - * longer scheduled to run (as opposed to after all threads have returned from the - * onTrigger method), see the {@link OnUnscheduled} annotation. - *

    - * - *

    - * Methods with this annotation are permitted to take either 0 or 1 argument. If an argument - * is used, it must be of type {@link ConfigurationContext} if the component is a ReportingTask - * or of type {@link ProcessContext} if the component is a Processor. + * longer scheduled to run (as opposed to after all threads have returned from + * the onTrigger method), see the {@link OnUnscheduled} annotation. + *

    + * + *

    + * Methods with this annotation are permitted to take either 0 or 1 argument. If + * an argument is used, it must be of type {@link ConfigurationContext} if the + * component is a ReportingTask or of type {@link ProcessContext} if the + * component is a Processor. *

    * - * @author none */ @Documented @Target({ElementType.METHOD}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnUnscheduled.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnUnscheduled.java index 5c7e13dc2c..b7d50277c2 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnUnscheduled.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/lifecycle/OnUnscheduled.java @@ -26,26 +26,29 @@ import java.lang.annotation.Target; /** *

    * Marker annotation a {@link org.apache.nifi.processor.Processor Processor} or - * {@link org.apache.nifi.reporting.ReportingTask ReportingTask} - * should be called whenever the component is no longer scheduled to run. - * Methods marked with this annotation will be invoked each time the framework - * is notified to stop scheduling the component. This method is invoked as other - * threads are potentially running. To invoke a method after all threads have - * finished processing, see the {@link OnStopped} annotation. + * {@link org.apache.nifi.reporting.ReportingTask ReportingTask} should be + * called whenever the component is no longer scheduled to run. Methods marked + * with this annotation will be invoked each time the framework is notified to + * stop scheduling the component. This method is invoked as other threads are + * potentially running. To invoke a method after all threads have finished + * processing, see the {@link OnStopped} annotation. *

    - * + * *

    - * Methods using this annotation must take either 0 arguments or a single argument. + * Methods using this annotation must take either 0 arguments or a single + * argument. *

    - * + * *

    - * If using 1 argument and the component using the annotation is a Processor, that argument must - * be of type {@link org.apache.nifi.processor.ProcessContext ProcessContext}. + * If using 1 argument and the component using the annotation is a Processor, + * that argument must be of type + * {@link org.apache.nifi.processor.ProcessContext ProcessContext}. *

    - * + * *

    - * If using 1 argument and the component using the annotation is a Reporting Task, that argument must - * be of type {@link org.apache.nifi.controller.ConfigurationContext ConfigurationContext}. + * If using 1 argument and the component using the annotation is a Reporting + * Task, that argument must be of type + * {@link org.apache.nifi.controller.ConfigurationContext ConfigurationContext}. *

    */ @Documented diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/notification/OnPrimaryNodeStateChange.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/notification/OnPrimaryNodeStateChange.java new file mode 100644 index 0000000000..4ea2170a00 --- /dev/null +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/notification/OnPrimaryNodeStateChange.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.annotation.notification; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + *

    + * Marker annotation that a component can use to indicate that a method should be + * called whenever the state of the Primary Node in a cluster has changed. + *

    + * + *

    + * Methods with this annotation should take either no arguments or one argument of type + * {@link PrimaryNodeState}. The {@link PrimaryNodeState} provides context about what changed + * so that the component can take appropriate action. + *

    + */ +@Documented +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Inherited +public @interface OnPrimaryNodeStateChange { + +} diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/notification/PrimaryNodeState.java b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/notification/PrimaryNodeState.java new file mode 100644 index 0000000000..0d65b65d33 --- /dev/null +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/annotation/notification/PrimaryNodeState.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.annotation.notification; + +/** + * Represents a state change that occurred for the Primary Node of a NiFi cluster. + */ +public enum PrimaryNodeState { + /** + * The node receiving this state has been elected the Primary Node of the NiFi cluster. + */ + ELECTED_PRIMARY_NODE, + + /** + * The node receiving this state was the Primary Node but has now had its Primary Node + * role revoked. + */ + PRIMARY_NODE_REVOKED; +} diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/Authority.java b/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/Authority.java index 823f463644..4502c1196f 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/Authority.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/Authority.java @@ -34,11 +34,9 @@ public enum Authority { ROLE_NIFI; /** - * Returns the matching role or null if the specified role does not match - * any roles. - * - * @param rawAuthority - * @return + * @param rawAuthority string form of authority + * @return the matching role or null if the specified role does not match + * any roles */ public static Authority valueOfAuthority(String rawAuthority) { Authority desiredAuthority = null; @@ -54,9 +52,7 @@ public enum Authority { } /** - * Gets the string value of each authority. - * - * @return + * @return the string value of each authority */ public static Set getRawAuthorities() { Set authorities = new LinkedHashSet<>(); diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorityProvider.java b/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorityProvider.java index 7754c3502a..723ec33085 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorityProvider.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorityProvider.java @@ -31,11 +31,9 @@ import org.apache.nifi.authorization.exception.UnknownIdentityException; public interface AuthorityProvider { /** - * Returns whether the user with the specified DN is known to this authority - * provider. It is not necessary for the user to have any authorities. - * - * @param dn - * @return + * @param dn of the user + * @return whether the user with the specified DN is known to this authority + * provider. It is not necessary for the user to have any authorities */ boolean doesDnExist(String dn) throws AuthorityAccessException; @@ -43,29 +41,30 @@ public interface AuthorityProvider { * Get the authorities for the specified user. If the specified user exists * but does not have any authorities, an empty set should be returned. * - * @param dn - * @return - * @throws UnknownIdentityException - * @throws AuthorityAccessException + * @param dn of the user to lookup + * @return the authorities for the specified user. If the specified user + * exists but does not have any authorities, an empty set should be returned + * @throws UnknownIdentityException if identity is not known + * @throws AuthorityAccessException if unable to access authorities */ Set getAuthorities(String dn) throws UnknownIdentityException, AuthorityAccessException; /** * Sets the specified authorities for the specified user. * - * @param dn - * @param authorities - * @throws UnknownIdentityException - * @throws AuthorityAccessException + * @param dn the specified user + * @param authorities the new authorities for the user + * @throws UnknownIdentityException if identity is not known + * @throws AuthorityAccessException if unable to access authorities */ void setAuthorities(String dn, Set authorities) throws UnknownIdentityException, AuthorityAccessException; /** * Gets the users for the specified authority. * - * @param authority - * @return - * @throws AuthorityAccessException + * @param authority for which to determine membership of + * @return all users with the specified authority + * @throws AuthorityAccessException if unable to access authorities */ Set getUsers(Authority authority) throws AuthorityAccessException; @@ -73,19 +72,19 @@ public interface AuthorityProvider { * Revokes the specified user. Its up to the implementor to determine the * semantics of revocation. * - * @param dn - * @throws UnknownIdentityException - * @throws AuthorityAccessException + * @param dn the dn of the user + * @throws UnknownIdentityException if the user is not known + * @throws AuthorityAccessException if unable to access the authorities */ void revokeUser(String dn) throws UnknownIdentityException, AuthorityAccessException; /** * Add the specified user. * - * @param dn + * @param dn of the user * @param group Optional - * @throws IdentityAlreadyExistsException - * @throws AuthorityAccessException + * @throws UnknownIdentityException if the user is not known + * @throws AuthorityAccessException if unable to access the authorities */ void addUser(String dn, String group) throws IdentityAlreadyExistsException, AuthorityAccessException; @@ -93,10 +92,10 @@ public interface AuthorityProvider { * Gets the group for the specified user. Return null if the user does not * belong to a group. * - * @param dn - * @return - * @throws UnknownIdentityException - * @throws AuthorityAccessException + * @param dn the user + * @return the group of the given user + * @throws UnknownIdentityException if the user is not known + * @throws AuthorityAccessException if unable to access the authorities */ String getGroupForUser(String dn) throws UnknownIdentityException, AuthorityAccessException; @@ -104,26 +103,28 @@ public interface AuthorityProvider { * Revokes all users for a specified group. Its up to the implementor to * determine the semantics of revocation. * - * @param group - * @throws AuthorityAccessException + * @param group to revoke the users of + * @throws UnknownIdentityException if the user is not known + * @throws AuthorityAccessException if unable to access the authorities */ void revokeGroup(String group) throws UnknownIdentityException, AuthorityAccessException; /** * Adds the specified users to the specified group. * - * @param dn - * @param group - * @throws AuthorityAccessException + * @param dn the set of users to add to the group + * @param group to add users to + * @throws UnknownIdentityException if the user is not known + * @throws AuthorityAccessException if unable to access the authorities */ void setUsersGroup(Set dn, String group) throws UnknownIdentityException, AuthorityAccessException; /** * Ungroups the specified user. * - * @param dn - * @throws UnknownIdentityException - * @throws AuthorityAccessException + * @param dn of the user + * @throws UnknownIdentityException if the user is not known + * @throws AuthorityAccessException if unable to access the authorities */ void ungroupUser(String dn) throws UnknownIdentityException, AuthorityAccessException; @@ -133,41 +134,41 @@ public interface AuthorityProvider { * does not exist. If an admin revoked this group before calling ungroup, it * may or may not exist. * - * @param group - * @throws AuthorityAccessException + * @param group to ungroup + * @throws AuthorityAccessException if unable to access the authorities */ void ungroup(String group) throws AuthorityAccessException; /** - * Determines whether the user in the specified dnChain should be able to + * Determines whether the user in the specified dnChain should be able to * download the content for the flowfile with the specified attributes. - * - * The first dn in the chain is the end user that the request was issued on + * + * The first dn in the chain is the end user that the request was issued on * behalf of. The subsequent dn's in the chain represent entities proxying * the user's request with the last being the proxy that sent the current * request. - * - * @param dnChain - * @param attributes - * @return - * @throws UnknownIdentityException - * @throws AuthorityAccessException + * + * @param dnChain of the user + * @param attributes of the flowfile being requested + * @return the authorization result + * @throws UnknownIdentityException if the user is not known + * @throws AuthorityAccessException if unable to access the authorities */ DownloadAuthorization authorizeDownload(List dnChain, Map attributes) throws UnknownIdentityException, AuthorityAccessException; - + /** * Called immediately after instance creation for implementers to perform * additional setup * - * @param initializationContext + * @param initializationContext in which to initialize */ void initialize(AuthorityProviderInitializationContext initializationContext) throws ProviderCreationException; /** * Called to configure the AuthorityProvider. * - * @param configurationContext - * @throws ProviderCreationException + * @param configurationContext at the time of configuration + * @throws ProviderCreationException for any issues configuring the provider */ void onConfigured(AuthorityProviderConfigurationContext configurationContext) throws ProviderCreationException; diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorityProviderConfigurationContext.java b/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorityProviderConfigurationContext.java index 6765ed4afe..c1ba5dfd80 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorityProviderConfigurationContext.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorityProviderConfigurationContext.java @@ -24,9 +24,7 @@ import java.util.Map; public interface AuthorityProviderConfigurationContext { /** - * The identifier for the authority provider. - * - * @return + * @return identifier for the authority provider */ String getIdentifier(); @@ -41,12 +39,10 @@ public interface AuthorityProviderConfigurationContext { Map getProperties(); /** - * Retrieves the value the component currently understands for the given + * @param property to lookup the descriptor and value of + * @return the value the component currently understands for the given * PropertyDescriptor. This method does not substitute default - * PropertyDescriptor values, so the value returned will be null if not set. - * - * @param property - * @return + * PropertyDescriptor values, so the value returned will be null if not set */ String getProperty(String property); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/DownloadAuthorization.java b/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/DownloadAuthorization.java index 08695fa91e..02fd839fa0 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/DownloadAuthorization.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/DownloadAuthorization.java @@ -22,6 +22,7 @@ package org.apache.nifi.authorization; public class DownloadAuthorization { private static enum Result { + Approved, Denied; }; @@ -32,10 +33,11 @@ public class DownloadAuthorization { private final String explanation; /** - * Creates a new DownloadAuthorization with the specified result and explanation. - * - * @param result - * @param explanation + * Creates a new DownloadAuthorization with the specified result and + * explanation. + * + * @param result of the authorization + * @param explanation for the authorization attempt */ private DownloadAuthorization(Result result, String explanation) { if (Result.Denied.equals(result) && explanation == null) { @@ -47,38 +49,33 @@ public class DownloadAuthorization { } /** - * Whether or not the download request is approved. - * - * @return + * @return Whether or not the download request is approved */ public boolean isApproved() { return Result.Approved.equals(result); } /** - * If the download request is denied, the reason why. Null otherwise. - * - * @return + * @return If the download request is denied, the reason why. Null otherwise */ public String getExplanation() { return explanation; } /** - * Creates a new approved DownloadAuthorization. - * - * @return + * @return a new approved DownloadAuthorization */ public static DownloadAuthorization approved() { return APPROVED; } /** - * Creates a new denied DownloadAuthorization with the specified explanation. - * - * @param explanation - * @return - * @throws IllegalArgumentException if explanation is null + * Creates a new denied DownloadAuthorization with the specified + * explanation. + * + * @param explanation for why it was denied + * @return a new denied DownloadAuthorization with the specified explanation + * @throws IllegalArgumentException if explanation is null */ public static DownloadAuthorization denied(String explanation) { return new DownloadAuthorization(Result.Denied, explanation); diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/annotation/AuthorityProviderContext.java b/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/annotation/AuthorityProviderContext.java index 406c0c0403..5ac2af7450 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/annotation/AuthorityProviderContext.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/annotation/AuthorityProviderContext.java @@ -26,7 +26,6 @@ import java.lang.annotation.Target; /** * * - * @author none */ @Documented @Target({ElementType.FIELD, ElementType.METHOD}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/exception/ProviderCreationException.java b/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/exception/ProviderCreationException.java index e2e7e1daa3..24ac7938e7 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/exception/ProviderCreationException.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/exception/ProviderCreationException.java @@ -19,7 +19,6 @@ package org.apache.nifi.authorization.exception; /** * Represents the exceptional case when an AuthorityProvider fails instantiated. * - * @author unattributed */ public class ProviderCreationException extends RuntimeException { diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/exception/ProviderDestructionException.java b/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/exception/ProviderDestructionException.java index e27509732a..985d3fbdf8 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/exception/ProviderDestructionException.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/authorization/exception/ProviderDestructionException.java @@ -19,7 +19,6 @@ package org.apache.nifi.authorization.exception; /** * Represents the exceptional case when an AuthorityProvider fails destruction. * - * @author unattributed */ public class ProviderDestructionException extends RuntimeException { diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/components/AbstractConfigurableComponent.java b/nifi/nifi-api/src/main/java/org/apache/nifi/components/AbstractConfigurableComponent.java index 6736788a84..1d4e0c200e 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/components/AbstractConfigurableComponent.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/components/AbstractConfigurableComponent.java @@ -46,11 +46,9 @@ public abstract class AbstractConfigurableComponent implements ConfigurableCompo } /** - * Returns a PropertyDescriptor for the name specified that is fully + * @param descriptorName to lookup the descriptor + * @return a PropertyDescriptor for the name specified that is fully * populated - * - * @param descriptorName - * @return */ @Override public final PropertyDescriptor getPropertyDescriptor(final String descriptorName) { @@ -141,11 +139,12 @@ public abstract class AbstractConfigurableComponent implements ConfigurableCompo * method a processor may simply get the latest value whenever it needs it * and if necessary lazily evaluate it. * - * @param descriptor + * @param descriptor of the modified property * @param oldValue non-null property value (previous) * @param newValue the new property value or if null indicates the property * was removed */ + @Override public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) { } @@ -168,7 +167,7 @@ public abstract class AbstractConfigurableComponent implements ConfigurableCompo *

    * Default is null. * - * @param propertyDescriptorName + * @param propertyDescriptorName used to lookup if any property descriptors exist for that name * @return new property descriptor if supported */ protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) { @@ -186,9 +185,10 @@ public abstract class AbstractConfigurableComponent implements ConfigurableCompo return Collections.EMPTY_LIST; } + @Override public final List getPropertyDescriptors() { final List supported = getSupportedPropertyDescriptors(); - return supported == null ? Collections.emptyList() :new ArrayList<>(supported); + return supported == null ? Collections.emptyList() : new ArrayList<>(supported); } @Override diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/components/AllowableValue.java b/nifi/nifi-api/src/main/java/org/apache/nifi/components/AllowableValue.java index 8921340611..a4809616d6 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/components/AllowableValue.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/components/AllowableValue.java @@ -33,7 +33,7 @@ public class AllowableValue { * Constructs a new AllowableValue with the given value and and the same * display name and no description. * - * @param value + * @param value that is allowed */ public AllowableValue(final String value) { this(value, value); @@ -43,8 +43,8 @@ public class AllowableValue { * Constructs a new AllowableValue with the given value and display name and * no description * - * @param value - * @param displayName + * @param value that is allowed + * @param displayName to display for the value * * @throws NullPointerException if either argument is null */ @@ -56,9 +56,9 @@ public class AllowableValue { * Constructs a new AllowableValue with the given value, display name, and * description * - * @param value - * @param displayName - * @param description + * @param value that is valid + * @param displayName to show for the value + * @param description of the value * * @throws NullPointerException if identifier or value is null */ @@ -69,40 +69,33 @@ public class AllowableValue { } /** - * Returns the value of this AllowableValue - * - * @return + * @return the value of this AllowableValue */ public String getValue() { return value; } /** - * Returns a human-readable name for this AllowableValue - * - * @return + * @return a human-readable name for this AllowableValue */ public String getDisplayName() { return displayName; } /** - * Returns a description for this value, or null if no + * @return a description for this value, or null if no * description was provided - * - * @return */ public String getDescription() { return description; } /** - * this is equal to obj of obj is the + * @return true if this is equal to obj of obj is the * same object as this or if obj is an instance of * AllowableValue and both have the same value, or if * obj is a String and is equal to * {@link #getValue() this.getValue()}. - * @return */ @Override public boolean equals(final Object obj) { @@ -121,8 +114,7 @@ public class AllowableValue { } /** - * Hash Code is based solely off of the value - * @return + * @return based solely off of the value */ @Override public int hashCode() { diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/components/ConfigurableComponent.java b/nifi/nifi-api/src/main/java/org/apache/nifi/components/ConfigurableComponent.java index 24e1f3c9ea..8b56f482a6 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/components/ConfigurableComponent.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/components/ConfigurableComponent.java @@ -27,7 +27,7 @@ public interface ConfigurableComponent { * not included in the in the purposed configuration, the default value will * be used. * - * @param context + * @param context of validation * @return Collection of validation result objects for any invalid findings * only. If the collection is empty then the component is valid. Guaranteed * non-null @@ -35,11 +35,9 @@ public interface ConfigurableComponent { Collection validate(ValidationContext context); /** - * Returns the PropertyDescriptor with the given name, if it exists; - * otherwise, returns null. - * - * @param name - * @return + * @param name to lookup the descriptor + * @return the PropertyDescriptor with the given name, if it exists; + * otherwise, returns null */ PropertyDescriptor getPropertyDescriptor(String name); @@ -51,7 +49,7 @@ public interface ConfigurableComponent { * necessary lazily evaluate it. Any throwable that escapes this method will * simply be ignored. * - * @param descriptor + * @param descriptor the descriptor for the property being modified * @param oldValue the value that was previously set, or null if no value * was previously set for this property * @param newValue the new property value or if null indicates the property @@ -68,10 +66,8 @@ public interface ConfigurableComponent { List getPropertyDescriptors(); /** - * Returns the unique identifier that the framework assigned to this + * @return the unique identifier that the framework assigned to this * component - * - * @return */ String getIdentifier(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/components/PropertyDescriptor.java b/nifi/nifi-api/src/main/java/org/apache/nifi/components/PropertyDescriptor.java index e62ff7962c..acda6c4bfa 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/components/PropertyDescriptor.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/components/PropertyDescriptor.java @@ -29,7 +29,6 @@ import org.apache.nifi.controller.ControllerService; * An immutable object for holding information about a type of processor * property. * - * @author unattributed */ public final class PropertyDescriptor implements Comparable { @@ -121,9 +120,9 @@ public final class PropertyDescriptor implements Comparable * If this descriptor has a set of allowable values then the given value is * only checked against the allowable values. * - * @param input - * @param context - * @return + * @param input the value to validate + * @param context the context of validation + * @return the result of validating the input */ public ValidationResult validate(final String input, final ValidationContext context) { ValidationResult lastResult = Validator.INVALID.validate(this.name, input, context); @@ -142,17 +141,17 @@ public final class PropertyDescriptor implements Comparable final Set validIdentifiers = context.getControllerServiceLookup().getControllerServiceIdentifiers(controllerServiceDefinition); if (validIdentifiers != null && validIdentifiers.contains(input)) { final ControllerService controllerService = context.getControllerServiceLookup().getControllerService(input); - if ( !context.isValidationRequired(controllerService) ) { + if (!context.isValidationRequired(controllerService)) { return new ValidationResult.Builder() - .input(input) - .subject(getName()) - .valid(true) - .build(); + .input(input) + .subject(getName()) + .valid(true) + .build(); } - + final String serviceId = controllerService.getIdentifier(); - if (!context.getControllerServiceLookup().isControllerServiceEnabled(serviceId) && - !context.getControllerServiceLookup().isControllerServiceEnabling(serviceId)) { + if (!context.getControllerServiceLookup().isControllerServiceEnabled(serviceId) + && !context.getControllerServiceLookup().isControllerServiceEnabling(serviceId)) { return new ValidationResult.Builder() .input(context.getControllerServiceLookup().getControllerServiceName(serviceId)) .subject(getName()) @@ -235,8 +234,8 @@ public final class PropertyDescriptor implements Comparable * This is beneficial because it allows a User Interface to represent * the name differently. * - * @param displayName - * @return + * @param displayName of the property + * @return the builder */ public Builder displayName(final String displayName) { if (null != displayName) { @@ -249,8 +248,8 @@ public final class PropertyDescriptor implements Comparable /** * Sets the property name. * - * @param name - * @return + * @param name of the property + * @return the builder */ public Builder name(final String name) { if (null != name) { @@ -263,8 +262,8 @@ public final class PropertyDescriptor implements Comparable * Sets the value indicating whether or not this Property will support * the Attribute Expression Language. * - * @param supported - * @return + * @param supported true if yes; false otherwise + * @return the builder */ public Builder expressionLanguageSupported(final boolean supported) { this.expressionLanguageSupported = supported; @@ -272,9 +271,8 @@ public final class PropertyDescriptor implements Comparable } /** - * - * @param description - * @return + * @param description of the property + * @return the builder */ public Builder description(final String description) { if (null != description) { @@ -294,8 +292,8 @@ public final class PropertyDescriptor implements Comparable * should be set to the "Value" of the {@link AllowableValue} object * (see {@link AllowableValue#getValue()}). * - * @param value - * @return + * @param value default value + * @return the builder */ public Builder defaultValue(final String value) { if (null != value) { @@ -310,9 +308,8 @@ public final class PropertyDescriptor implements Comparable } /** - * - * @param values - * @return + * @param values contrained set of values + * @return the builder */ public Builder allowableValues(final Set values) { if (null != values) { @@ -336,9 +333,8 @@ public final class PropertyDescriptor implements Comparable } /** - * - * @param values - * @return + * @param values constrained set of values + * @return the builder */ public Builder allowableValues(final String... values) { if (null != values) { @@ -353,8 +349,8 @@ public final class PropertyDescriptor implements Comparable /** * Sets the Allowable Values for this Property * - * @param values - * @return + * @param values contrained set of values + * @return the builder */ public Builder allowableValues(final AllowableValue... values) { if (null != values) { @@ -364,9 +360,8 @@ public final class PropertyDescriptor implements Comparable } /** - * - * @param required - * @return + * @param required true if yes; false otherwise + * @return the builder */ public Builder required(final boolean required) { this.required = required; @@ -374,9 +369,8 @@ public final class PropertyDescriptor implements Comparable } /** - * - * @param sensitive - * @return + * @param sensitive true if sensitive; false otherwise + * @return the builder */ public Builder sensitive(final boolean sensitive) { this.sensitive = sensitive; @@ -384,9 +378,8 @@ public final class PropertyDescriptor implements Comparable } /** - * - * @param validator - * @return + * @param validator for the property + * @return the builder */ public Builder addValidator(final Validator validator) { if (validator != null) { @@ -401,7 +394,7 @@ public final class PropertyDescriptor implements Comparable * * @param controllerServiceDefinition the interface that is implemented * by the Controller Service - * @return + * @return the builder */ public Builder identifiesControllerService(final Class controllerServiceDefinition) { if (controllerServiceDefinition != null) { @@ -436,7 +429,7 @@ public final class PropertyDescriptor implements Comparable throw new IllegalStateException("Must specify a name"); } if (!isValueAllowed(defaultValue)) { - throw new IllegalStateException("Default value ["+ defaultValue +"] is not in the set of allowable values"); + throw new IllegalStateException("Default value [" + defaultValue + "] is not in the set of allowable values"); } return new PropertyDescriptor(this); @@ -525,7 +518,7 @@ public final class PropertyDescriptor implements Comparable * Constructs a validator that will check if the given value is in the * given set. * - * @param validValues + * @param validValues values which are acceptible * @throws NullPointerException if the given validValues is null */ private ConstrainedSetValidator(final Collection validValues) { diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/components/PropertyValue.java b/nifi/nifi-api/src/main/java/org/apache/nifi/components/PropertyValue.java index 1c5f04a943..1845ed224c 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/components/PropertyValue.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/components/PropertyValue.java @@ -89,25 +89,21 @@ public interface PropertyValue { public Double asDataSize(DataUnit dataUnit); /** - * Returns the ControllerService whose identifier is the raw value of + * @return the ControllerService whose identifier is the raw value of * this, or null if either the value is not set or * the value does not identify a ControllerService - * - * @return */ public ControllerService asControllerService(); /** - * Returns the ControllerService whose identifier is the raw value of the + * @param the generic type of the controller service + * @param serviceType the class of the Controller Service + * @return the ControllerService whose identifier is the raw value of the * this, or null if either the value is not set or * the value does not identify a ControllerService. The object returned by * this method is explicitly cast to type specified, if the type specified * is valid. Otherwise, throws an IllegalArgumentException * - * @param - * @param serviceType - * @return - * * @throws IllegalArgumentException if the value of this points * to a ControllerService but that service is not of type * serviceType or if serviceType references a @@ -116,11 +112,9 @@ public interface PropertyValue { public T asControllerService(Class serviceType) throws IllegalArgumentException; /** - * Returns true if the user has configured a value, or if the + * @return true if the user has configured a value, or if the * {@link PropertyDescriptor} for the associated property has a default - * value, false otherwise. - * - * @return + * value, false otherwise */ public boolean isSet(); @@ -131,7 +125,8 @@ public interface PropertyValue { * call chaining. *

    * - * @return + * @return a PropertyValue with the new value is returned, supporting call + * chaining * * @throws ProcessException if the Query cannot be compiled or evaluating * the query against the given attributes causes an Exception to be thrown @@ -145,8 +140,9 @@ public interface PropertyValue { * call chaining. *

    * - * @param flowFile - * @return + * @param flowFile to evaluate attributes of + * @return a PropertyValue with the new value is returned, supporting call + * chaining * * @throws ProcessException if the Query cannot be compiled or evaluating * the query against the given attributes causes an Exception to be thrown @@ -161,8 +157,10 @@ public interface PropertyValue { * supporting call chaining. *

    * - * @param decorator - * @return + * @param decorator The supplied decorator is then given a chance to + * decorate the value + * @return a PropertyValue with the new value is then returned, supporting + * call chaining * * @throws ProcessException if the Query cannot be compiled or evaluating * the query against the given attributes causes an Exception to be thrown @@ -177,10 +175,12 @@ public interface PropertyValue { * supporting call chaining. *

    * - * @param flowFile - * @param decorator + * @param flowFile to evaluate expressions against + * @param decorator The supplied decorator is then given a chance to + * decorate the value * - * @return + * @return a PropertyValue with the new value is then returned, supporting + * call chaining * * @throws ProcessException if the Query cannot be compiled or evaluating * the query against the given attributes causes an Exception to be thrown diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/components/ValidationContext.java b/nifi/nifi-api/src/main/java/org/apache/nifi/components/ValidationContext.java index 61b68a249c..a1dcf438dd 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/components/ValidationContext.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/components/ValidationContext.java @@ -25,86 +25,71 @@ import org.apache.nifi.expression.ExpressionLanguageCompiler; public interface ValidationContext { /** - * Returns the {@link ControllerServiceLookup} which can be used to obtain + * @return the {@link ControllerServiceLookup} which can be used to obtain * Controller Services - * - * @return */ ControllerServiceLookup getControllerServiceLookup(); /** - * Returns a ValidationContext that is appropriate for validating the given + * @param controllerService to lookup the validation context of + * @return a ValidationContext that is appropriate for validating the given * {@link ControllerService} - * - * @param controllerService - * @return */ ValidationContext getControllerServiceValidationContext(ControllerService controllerService); /** - * Creates and returns a new {@link ExpressionLanguageCompiler} that can be - * used to compile & evaluate Attribute Expressions - * - * @return + * @return a new {@link ExpressionLanguageCompiler} that can be used to + * compile & evaluate Attribute Expressions */ ExpressionLanguageCompiler newExpressionLanguageCompiler(); /** - * Returns a PropertyValue that encapsulates the value configured for the + * @param property being validated + * @return a PropertyValue that encapsulates the value configured for the * given PropertyDescriptor - * - * @param property - * @return */ PropertyValue getProperty(PropertyDescriptor property); /** - * Returns a PropertyValue that represents the given value - * - * @param value - * @return + * @param value to make a PropertyValue object for + * @return a PropertyValue that represents the given value */ PropertyValue newPropertyValue(String value); /** - * Returns a Map of all configured Properties. - * - * @return + * @return a Map of all configured Properties */ Map getProperties(); /** - * Returns the currently configured Annotation Data - * - * @return + * @return the currently configured Annotation Data */ String getAnnotationData(); - + /** - * There are times when the framework needs to consider a component valid, even if it - * references an invalid ControllerService. This method will return false - * if the component is to be considered valid even if the given Controller Service is referenced - * and is invalid. - * @param service + * There are times when the framework needs to consider a component valid, + * even if it references an invalid ControllerService. This method will + * return false if the component is to be considered valid even + * if the given Controller Service is referenced and is invalid. + * + * @param service to check if validation is required + * @return false if the component is to be considered valid + * even if the given Controller Service is referenced and is invalid */ boolean isValidationRequired(ControllerService service); - + /** - * Returns true if the given value contains a NiFi Expression Language expression, - * false if it does not - * - * @param value - * @return + * @param value to test whether expression language is present + * @return true if the given value contains a NiFi Expression + * Language expression, false if it does not */ boolean isExpressionLanguagePresent(String value); - + /** - * Returns true if the property with the given name supports the NiFi Expression Language, - * false if the property does not support the Expression Language or is not a valid property - * name - * - * @param propertyName - * @return + * @param propertyName to test whether expression language is supported + * @return true if the property with the given name supports + * the NiFi Expression Language, false if the property does not + * support the Expression Language or is not a valid property name */ boolean isExpressionLanguageSupported(String propertyName); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/components/ValidationResult.java b/nifi/nifi-api/src/main/java/org/apache/nifi/components/ValidationResult.java index 3a54848fa0..e0beec8432 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/components/ValidationResult.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/components/ValidationResult.java @@ -22,7 +22,6 @@ import java.util.Objects; * * Immutable - thread safe * - * @author unattributed */ public class ValidationResult { @@ -119,8 +118,8 @@ public class ValidationResult { /** * Defaults to false * - * @param valid - * @return + * @param valid true if is valid; false otherwise + * @return the builder */ public Builder valid(final boolean valid) { this.valid = valid; @@ -130,8 +129,8 @@ public class ValidationResult { /** * Defaults to empty string * - * @param input - * @return + * @param input what was validated + * @return the builder */ public Builder input(final String input) { if (null != input) { @@ -143,8 +142,8 @@ public class ValidationResult { /** * Defaults to empty string * - * @param explanation - * @return + * @param explanation of validation result + * @return the builder */ public Builder explanation(final String explanation) { if (null != explanation) { @@ -156,8 +155,8 @@ public class ValidationResult { /** * Defaults to empty string * - * @param subject - * @return + * @param subject the thing that was validated + * @return the builder */ public Builder subject(final String subject) { if (null != subject) { diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/components/Validator.java b/nifi/nifi-api/src/main/java/org/apache/nifi/components/Validator.java index 768659b37b..a12b532b4a 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/components/Validator.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/components/Validator.java @@ -18,7 +18,6 @@ package org.apache.nifi.components; /** * - * @author unattributed */ public interface Validator { diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/AbstractControllerService.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/AbstractControllerService.java index 71cdd231ea..cd3b9bdc10 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/AbstractControllerService.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/AbstractControllerService.java @@ -32,7 +32,7 @@ public abstract class AbstractControllerService extends AbstractConfigurableComp private ControllerServiceLookup serviceLookup; private volatile ConfigurationContext configContext; private ComponentLog logger; - + @Override public final void initialize(final ControllerServiceInitializationContext context) throws InitializationException { this.identifier = context.getIdentifier(); @@ -52,31 +52,25 @@ public abstract class AbstractControllerService extends AbstractConfigurableComp } /** - * Returns the currently configured value for the given + * @param descriptor to retrieve value of + * @return the currently configured value for the given * {@link PropertyDescriptor} - * - * @param descriptor - * @return */ protected final PropertyValue getProperty(final PropertyDescriptor descriptor) { return configContext.getProperty(descriptor); } /** - * Returns an unmodifiable map of all configured properties for this + * @return an unmodifiable map of all configured properties for this * {@link ControllerService} - * - * @return */ protected final Map getProperties() { return configContext.getProperties(); } /** - * Returns the {@link ControllerServiceLookup} that was passed to the + * @return the {@link ControllerServiceLookup} that was passed to the * {@link #init(ProcessorInitializationContext)} method - * - * @return */ protected final ControllerServiceLookup getControllerServiceLookup() { return serviceLookup; @@ -86,15 +80,15 @@ public abstract class AbstractControllerService extends AbstractConfigurableComp * Provides a mechanism by which subclasses can perform initialization of * the Reporting Task before it is scheduled to be run * - * @param config - * @throws InitializationException + * @param config of initialization context + * @throws InitializationException if unable to init */ protected void init(final ControllerServiceInitializationContext config) throws InitializationException { } - + /** - * Returns the logger that has been provided to the component by the framework in its initialize method. - * @return + * @return the logger that has been provided to the component by the + * framework in its initialize method */ protected ComponentLog getLogger() { return logger; diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/ConfigurationContext.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/ConfigurationContext.java index 7ed09170ed..1fff6b9b34 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/ConfigurationContext.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/ConfigurationContext.java @@ -28,18 +28,14 @@ import org.apache.nifi.components.PropertyValue; public interface ConfigurationContext { /** - * Returns the configured value for the property with the given name - * - * @param property - * @return + * @param property to retrieve by name + * @return the configured value for the property with the given name */ PropertyValue getProperty(PropertyDescriptor property); /** - * Returns an unmodifiable map of all configured properties for this + * @return an unmodifiable map of all configured properties for this * {@link ControllerService} - * - * @return */ Map getProperties(); diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/ControllerService.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/ControllerService.java index cbf81a5a9b..a77c69d7a6 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/ControllerService.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/ControllerService.java @@ -68,21 +68,20 @@ import org.apache.nifi.reporting.ReportingTask; *

    *

    *

    - * 			public static final PropertyDescriptor MY_PROPERTY = new PropertyDescriptor.Builder()
    - * 				.name("My Property")
    - * 				.description("Example Property")
    - * 				.identifiesControllerService( MyControllerServiceInterface.class )
    - * 				.build();
    + *    public static final PropertyDescriptor MY_PROPERTY = new PropertyDescriptor.Builder()
    + *     .name("My Property")
    + *     .description("Example Property")
    + *     .identifiesControllerService( MyControllerServiceInterface.class )
    + *     .build();
      *
    - * 			...
    + *    ...
    + *    public void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException {
    + *     // Obtain the user-selected controller service
    + *     final MyControllerServiceInterface service = context.getProperty(MY_PROPERTY).asControllerService( MyControllerServiceInterface.class );
    + *     ...
    + *    }
      *
    - * 			public void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException {
    - * 				// Obtain the user-selected controller service
    - * 				final MyControllerServiceInterface service = context.getProperty(MY_PROPERTY).asControllerService( MyControllerServiceInterface.class );
    - * 				...
    - * 			}
    - *
    - * 		

    + *

    * *
  • A Controller Service can be obtained via a * {@link ControllerServiceLookup}. This lookup may be obtained, for example, @@ -94,10 +93,9 @@ import org.apache.nifi.reporting.ReportingTask; *

    *

    *

    - * 			public void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException {
    - * 				final MyControllerServiceInterface service = (MyControllerServiceInterface)
    - * 					context.getControllerServiceLookup().getControllerService("service_identifier");
    - * 			}
    + *    public void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException {
    + *      final MyControllerServiceInterface service = (MyControllerServiceInterface) context.getControllerServiceLookup().getControllerService("service_identifier");
    + *    }
      * 

    *
  • * @@ -142,12 +140,12 @@ import org.apache.nifi.reporting.ReportingTask; *

    * Typically, this is done by creating a NAR structure as follows: *

    - * 	+ my-services-api-nar
    - *	+--- service-X-implementation-nar
    - *	+--- service-Y-implementation-nar
    - *	+--- service-Z-implementation-nar
    - *	+--- processor-A-nar
    - *	+--- processor-B-nar
    + *   + my-services-api-nar
    + *   +--- service-X-implementation-nar
    + *   +--- service-Y-implementation-nar
    + *   +--- service-Z-implementation-nar
    + *   +--- processor-A-nar
    + *   +--- processor-B-nar
      * 
    *

    * @@ -174,8 +172,8 @@ public interface ControllerService extends ConfigurableComponent { * throughout the life of the service. This method will be called before any * properties are set * - * @param context - * @throws org.apache.nifi.reporting.InitializationException + * @param context of initialization + * @throws org.apache.nifi.reporting.InitializationException if unable to init */ void initialize(ControllerServiceInitializationContext context) throws InitializationException; diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/ControllerServiceInitializationContext.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/ControllerServiceInitializationContext.java index d34c6354ad..6fcee0c7bd 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/ControllerServiceInitializationContext.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/ControllerServiceInitializationContext.java @@ -21,26 +21,20 @@ import org.apache.nifi.logging.ComponentLog; public interface ControllerServiceInitializationContext { /** - * Returns the identifier associated with the {@link ControllerService} with + * @return the identifier associated with the {@link ControllerService} with * which this context is associated - * - * @return */ String getIdentifier(); /** - * Returns the {@link ControllerServiceLookup} which can be used to obtain + * @return the {@link ControllerServiceLookup} which can be used to obtain * Controller Services - * - * @return */ ControllerServiceLookup getControllerServiceLookup(); - + /** - * Returns a logger that can be used to log important events in a standard way and generate - * bulletins when appropriate - * - * @return + * @return a logger that can be used to log important events in a standard + * way and generate bulletins when appropriate */ ComponentLog getLogger(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/ControllerServiceLookup.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/ControllerServiceLookup.java index 4b96f626a6..f5300b15c5 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/ControllerServiceLookup.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/ControllerServiceLookup.java @@ -18,68 +18,53 @@ package org.apache.nifi.controller; import java.util.Set; - public interface ControllerServiceLookup { /** - * Returns the ControllerService that is registered with the given + * @param serviceIdentifier of controller service + * @return the ControllerService that is registered with the given * identifier - * - * @param serviceIdentifier - * @return */ ControllerService getControllerService(String serviceIdentifier); /** - * Returns true if the Controller Service with the given + * @param serviceIdentifier identifier of service to check + * @return true if the Controller Service with the given * identifier is enabled, false otherwise. If the given * identifier is not known by this ControllerServiceLookup, returns * false - * - * @param serviceIdentifier - * @return */ boolean isControllerServiceEnabled(String serviceIdentifier); /** - * Returns true if the Controller Service with the given + * @param serviceIdentifier idenfitier of service to check + * @return true if the Controller Service with the given * identifier has been enabled but is still in the transitioning state, - * otherwise returns false. - * If the given identifier is not known by this ControllerServiceLookup, - * returns false. - * - * @param serviceIdentifier - * @return + * otherwise returns false. If the given identifier is not + * known by this ControllerServiceLookup, returns false */ boolean isControllerServiceEnabling(String serviceIdentifier); - + /** - * Returns true if the given Controller Service is enabled, + * @param service service to check + * @return true if the given Controller Service is enabled, * false otherwise. If the given Controller Service is not * known by this ControllerServiceLookup, returns false - * - * @param service - * @return */ boolean isControllerServiceEnabled(ControllerService service); /** - * Returns the set of all Controller Service Identifiers whose Controller - * Service is of the given type. The class specified MUST be an interface, - * or an IllegalArgumentExcption will be thrown - * - * @param serviceType - * @return - * + * @param serviceType type of service to get identifiers for + * @return the set of all Controller Service Identifiers whose Controller + * Service is of the given type. * @throws IllegalArgumentException if the given class is not an interface */ Set getControllerServiceIdentifiers(Class serviceType) throws IllegalArgumentException; /** - * Returns the name of the Controller service with the given identifier. If no service can be - * found with this identifier, returns {@code null}. - * @param serviceIdentifier - * @return + * @param serviceIdentifier identifier to look up + * @return the name of the Controller service with the given identifier. If + * no service can be found with this identifier, returns {@code null} */ String getControllerServiceName(String serviceIdentifier); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/FlowFileQueue.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/FlowFileQueue.java index 86742c77db..92a4ee0301 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/FlowFileQueue.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/FlowFileQueue.java @@ -40,10 +40,8 @@ public interface FlowFileQueue { List getPriorities(); /** - * Returns the minimum number of FlowFiles that must be present in order for + * @return the minimum number of FlowFiles that must be present in order for * FlowFiles to begin being swapped out of the queue - * - * @return */ int getSwapThreshold(); @@ -71,9 +69,7 @@ public interface FlowFileQueue { long getBackPressureObjectThreshold(); /** - * Establishes this queue's preferred maximum data size. - * - * @param maxDataSize + * @param maxDataSize Establishes this queue's preferred maximum data size. */ void setBackPressureDataSizeThreshold(String maxDataSize); @@ -117,21 +113,21 @@ public interface FlowFileQueue { /** * places the given file into the queue * - * @param file + * @param file to place into queue */ void put(FlowFileRecord file); /** * places the given files into the queue * - * @param files + * @param files to place into queue */ void putAll(Collection files); /** * Removes all records from the internal swap queue and returns them. * - * @return + * @return all removed records from internal swap queue */ List pollSwappableRecords(); @@ -139,7 +135,7 @@ public interface FlowFileQueue { * Restores the records from swap space into this queue, adding the records * that have expired to the given set instead of enqueuing them. * - * @param records + * @param records that were swapped in */ void putSwappedRecords(Collection records); @@ -147,15 +143,13 @@ public interface FlowFileQueue { * Updates the internal counters of how much data is queued, based on * swapped data that is being restored. * - * @param numRecords - * @param contentSize + * @param numRecords count of records swapped in + * @param contentSize total size of records being swapped in */ void incrementSwapCount(int numRecords, long contentSize); /** - * Returns the number of FlowFiles that are enqueued and not swapped - * - * @return + * @return the number of FlowFiles that are enqueued and not swapped */ int unswappedSize(); @@ -164,14 +158,14 @@ public interface FlowFileQueue { int getSwapQueueSize(); /** - * @param expiredRecords + * @param expiredRecords expired records * @return the next flow file on the queue; null if empty */ FlowFileRecord poll(Set expiredRecords); /** - * @param maxResults - * @param expiredRecords + * @param maxResults limits how many results can be polled + * @param expiredRecords for expired records * @return the next flow files on the queue up to the max results; null if * empty */ @@ -181,10 +175,10 @@ public interface FlowFileQueue { * Drains flow files from the given source queue into the given destination * list. * - * @param sourceQueue - * @param destination + * @param sourceQueue queue to drain from + * @param destination Collection to drain to * @param maxResults max number to drain - * @param expiredRecords + * @param expiredRecords for expired records * @return size (bytes) of flow files drained from queue */ long drainQueue(Queue sourceQueue, List destination, int maxResults, Set expiredRecords); diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/Snippet.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/Snippet.java index 8ce106e8ec..93f332735b 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/Snippet.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/Snippet.java @@ -24,89 +24,65 @@ import java.util.Set; public interface Snippet { /** - * The id of this snippet. - * - * @return + * @return id of this snippet */ public String getId(); /** - * Whether or not this snippet is linked to the data flow. If the Snippet is + * @return Whether or not this snippet is linked to the data flow. If the Snippet is * deleted and is linked, then the underlying components will also be * deleted. If the Snippet is deleted and is NOT linked, only the Snippet is * removed - * - * @return */ public boolean isLinked(); /** - * The parent group id of the components in this snippet. - * - * @return + * @return parent group id of the components in this snippet */ public String getParentGroupId(); /** - * The connections in this snippet. - * - * @return + * @return connections in this snippet */ public Set getConnections(); /** - * The funnels in this snippet. - * - * @return + * @return funnels in this snippet */ public Set getFunnels(); /** - * The input ports in this snippet. - * - * @return + * @return input ports in this snippet */ public Set getInputPorts(); /** - * The output ports in this snippet. - * - * @return + * @return output ports in this snippet */ public Set getOutputPorts(); /** - * The labels in this snippet. - * - * @return + * @return labels in this snippet */ public Set getLabels(); /** - * Returns the identifiers of all ProcessGroups in this Snippet - * - * @return + * @return the identifiers of all ProcessGroups in this Snippet */ public Set getProcessGroups(); /** - * Returns the identifiers of all Processors in this Snippet - * - * @return + * @return the identifiers of all Processors in this Snippet */ public Set getProcessors(); /** - * Returns the identifiers of all RemoteProcessGroups in this Snippet - * - * @return + * @return the identifiers of all RemoteProcessGroups in this Snippet */ public Set getRemoteProcessGroups(); /** - * Determines if this snippet is empty. - * - * @return + * @return Determines if this snippet is empty */ public boolean isEmpty(); diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/Triggerable.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/Triggerable.java index 2eba911610..4b3149b213 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/Triggerable.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/Triggerable.java @@ -44,9 +44,9 @@ public interface Triggerable { * be committed or the framework may use the session again for another * processor down stream

    * - * @param context - * @param sessionFactory used to generate {@link ProcessSession}s to use - * for operating on flow files within the repository + * @param context in which the component is triggered + * @param sessionFactory used to generate {@link ProcessSession}s to use for + * operating on flow files within the repository * * @throws ProcessException if processing did not complete normally though * indicates the problem is an understood potential outcome of processing. @@ -81,7 +81,7 @@ public interface Triggerable { * Triggerable has any active threads, see * {@link ProcessScheduler#getActiveThreadCount(nifi.connectable.Connectable)}. * - * @return + * @return the schedule state */ ScheduledState getScheduledState(); @@ -92,12 +92,12 @@ public interface Triggerable { * invocation of {@link #onTrigger(ProcessContext, ProcessSessionFactory)} * have not yet returned * - * @return + * @return true if running;false otherwise */ boolean isRunning(); /** - * @param timeUnit + * @param timeUnit for the scheduling period of the component * @return the amount of time between each scheduling period */ long getSchedulingPeriod(TimeUnit timeUnit); @@ -110,7 +110,8 @@ public interface Triggerable { /** * Updates how often this Triggerable should be triggered to run - * @param schedulingPeriod + * + * @param schedulingPeriod to set */ void setScheduldingPeriod(String schedulingPeriod); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/annotation/OnConfigured.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/annotation/OnConfigured.java index 78cc04b77e..aef80acdb9 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/annotation/OnConfigured.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/annotation/OnConfigured.java @@ -30,9 +30,9 @@ import java.lang.annotation.Target; * arguments or a single argument of type * {@link nifi.controller.ConfigurationContext ConfigurationContext}. * - * @author none - * - * @deprecated This annotation has been replaced by those in the {@link org.apache.nifi.annotation.lifecycle} package. + * + * @deprecated This annotation has been replaced by those in the + * {@link org.apache.nifi.annotation.lifecycle} package. */ @Documented @Target({ElementType.METHOD}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/ContentRepository.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/ContentRepository.java index d66b8a6499..ee3ead9905 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/ContentRepository.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/ContentRepository.java @@ -31,7 +31,6 @@ import org.apache.nifi.controller.repository.claim.ContentClaimManager; * available on the methods but a merge capability is provided which between * that and creating new claims a merge is available. * - * @author none */ public interface ContentRepository { @@ -40,46 +39,38 @@ public interface ContentRepository { * ContentClaimManager that is to be used for interacting with Content * Claims * - * @param claimManager - * @throws java.io.IOException + * @param claimManager to handle claims + * @throws java.io.IOException if unable to init */ void initialize(ContentClaimManager claimManager) throws IOException; /** - * Shuts down the Content Repository, freeing any resources that may be held. - * This is called when an administrator shuts down NiFi. + * Shuts down the Content Repository, freeing any resources that may be + * held. This is called when an administrator shuts down NiFi. */ void shutdown(); - + /** - * Returns the names of all Containers that exist for this Content + * @return the names of all Containers that exist for this Content * Repository - * - * @return */ Set getContainerNames(); /** - * Returns the maximum number of bytes that can be stored in the storage + * @param containerName name of container to check capacity on + * @return the maximum number of bytes that can be stored in the storage * mechanism that backs the container with the given name - * - * @param containerName - * @return - * @throws java.io.IOException - * + * @throws java.io.IOException if unable to check capacity * @throws IllegalArgumentException if no container exists with the given * name */ long getContainerCapacity(String containerName) throws IOException; /** - * Returns the number of bytes available to be used used by the storage + * @param containerName to check space on + * @return the number of bytes available to be used used by the storage * mechanism that backs the container with the given name - * - * @param containerName - * @return - * @throws java.io.IOException - * + * @throws java.io.IOException if unable to check space * @throws IllegalArgumentException if no container exists with the given * name */ @@ -92,14 +83,14 @@ public interface ContentRepository { * loss tolerant. If true the repository might choose more volatile storage * options which could increase performance for a tradeoff with reliability * @return newly created claim - * @throws java.io.IOException + * @throws java.io.IOException if unable to create claim */ ContentClaim create(boolean lossTolerant) throws IOException; /** * Increments the number of claimants for the given claim * - * @param claim + * @param claim to increment * @return the number of claimants after incrementing */ int incrementClaimaintCount(ContentClaim claim); @@ -107,7 +98,7 @@ public interface ContentRepository { /** * Obtains the current number of claimants for the given claim * - * @param claim + * @param claim to get count of * @return the number of claimants */ int getClaimantCount(ContentClaim claim); @@ -117,15 +108,15 @@ public interface ContentRepository { * claim is null or content cannot be found or removed no exception will be * thrown. * - * @param claim - * @return + * @param claim to decrement + * @return new claimant count for the given claim */ int decrementClaimantCount(ContentClaim claim); /** * Removes the content indicated by the given claim * - * @param claim + * @param claim to remove * * @return a boolean indicating whether or not the destruction of the claim * was successful @@ -136,9 +127,9 @@ public interface ContentRepository { * Clones the content for the given content claim and returns content claim * of the new object * - * @param original - * @param lossTolerant - * @return + * @param original to clone + * @param lossTolerant if can be place in a loss tolerant repository + * @return new claim * @throws IOException if an IO error occurs. Any content written to the new * destination prior to the error will be destroyed */ @@ -156,7 +147,7 @@ public interface ContentRepository { * @param footer if supplied will be appended to the output * @param demarcator if supplied will be placed in between each merged * object - * @throws IOException + * @throws IOException if unable to merge * @throws IllegalArgumentException if the given destination is included in * the given claims */ @@ -167,9 +158,9 @@ public interface ContentRepository { * claim within the repository. * * @return the size of the claim - * @param content + * @param content to import from * @param claim the claim to write imported content to - * @throws IOException + * @throws IOException if failure to read given content */ long importFrom(Path content, ContentClaim claim) throws IOException; @@ -179,11 +170,11 @@ public interface ContentRepository { * argument * * @return the size of the claim - * @param content + * @param content to import from * @param claim the claim to write imported content to * @param append if true, the content will be appended to the claim; if * false, the content will replace the contents of the claim - * @throws IOException + * @throws IOException if unable to read content */ long importFrom(Path content, ContentClaim claim, boolean append) throws IOException; @@ -192,9 +183,9 @@ public interface ContentRepository { * claim within the repository. * * @return the size of the claim - * @param content + * @param content to import from * @param claim the claim to write imported content to - * @throws IOException + * @throws IOException if unable to read content */ long importFrom(InputStream content, ContentClaim claim) throws IOException; @@ -202,11 +193,11 @@ public interface ContentRepository { * Imports content from the given stream, appending or replacing the current * claim, according to the value of the appen dargument * - * @param content - * @param claim - * @param append - * @return - * @throws IOException + * @param content to import from + * @param claim to write to + * @param append whether to append or replace + * @return length of data imported in bytes + * @throws IOException if failure to read or write stream */ long importFrom(InputStream content, ContentClaim claim, boolean append) throws IOException; @@ -214,7 +205,7 @@ public interface ContentRepository { * Exports the content of the given claim to the given destination. * * @return the size of the destination or the claim - * @param claim + * @param claim to export from * @param destination where to export data * @param append if true appends to the destination; false overwrites * @throws IOException if an IO error occurs. The state of the content for @@ -227,7 +218,7 @@ public interface ContentRepository { * Exports the content of the given claim to the given destination. * * @return the size of the destination or the claim - * @param claim + * @param claim to export from * @param destination where to export data * @param append if true appends to the destination; false overwrites * @param offset the offset at which the claim should start being copied @@ -242,7 +233,7 @@ public interface ContentRepository { * Exports the content of the given claim to the given destination. * * @return the size of the claim - * @param claim + * @param claim to export from * @param destination where to export data * @throws IOException if an IO error occurs. */ @@ -253,7 +244,7 @@ public interface ContentRepository { * and copying length bytes, to the given destination. * * @return the number of bytes copied - * @param claim + * @param claim to export from * @param destination where to export data * @param offset the offset into the claim at which the copy should begin * @param length the number of bytes to copy @@ -262,27 +253,27 @@ public interface ContentRepository { long exportTo(ContentClaim claim, OutputStream destination, long offset, long length) throws IOException; /** - * @param claim + * @param claim to get size of * @return size in bytes of content for given claim - * @throws IOException + * @throws IOException if size check failed */ long size(ContentClaim claim) throws IOException; /** * Provides access to the input stream for the given claim * - * @param claim + * @param claim to read from * @return InputStream over the content of the given claim - * @throws IOException + * @throws IOException if unable to read */ InputStream read(ContentClaim claim) throws IOException; /** * Obtains an OutputStream to the content for the given claim. * - * @param claim - * @return - * @throws IOException + * @param claim to write to + * @return the stream to write to + * @throws IOException if unable to obtain stream */ OutputStream write(ContentClaim claim) throws IOException; @@ -300,15 +291,13 @@ public interface ContentRepository { void cleanup(); /** - * Returns a boolean indicating whether or not the content specified by the - * given claim can be read, regardless of whether the content has been - * archived or not. If the ContentRepository does not implement archiving - * capabilities, this method will return false. - * * @param contentClaim the Content Claim to check - * @return + * @return Returns a boolean indicating whether or not the content specified + * by the given claim can be read, regardless of whether the content has + * been archived or not. If the ContentRepository does not implement + * archiving capabilities, this method will return false * - * @throws IOException + * @throws IOException if unable to determine accessibility */ boolean isAccessible(ContentClaim contentClaim) throws IOException; } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRecord.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRecord.java index 13548a2c03..f2493f616e 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRecord.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRecord.java @@ -27,28 +27,22 @@ import org.apache.nifi.flowfile.FlowFile; public interface FlowFileRecord extends FlowFile { /** - * Returns the time (in millis since epoch) at which this FlowFile should no - * longer be penalized. - * - * @return + * @return the time (in millis since epoch) at which this FlowFile should no + * longer be penalized */ long getPenaltyExpirationMillis(); /** - * Returns the {@link ContentClaim} that holds the FlowFile's content - * - * @return + * @return the {@link ContentClaim} that holds the FlowFile's content */ ContentClaim getContentClaim(); /** - * Returns the byte offset into the {@link ContentClaim} at which the + * @return the byte offset into the {@link ContentClaim} at which the * FlowFile's content occurs. This mechanism allows multiple FlowFiles to * have the same ContentClaim, which can be significantly more efficient for * some implementations of * {@link nifi.controller.repository.ContentRepository ContentRepository} - * - * @return */ long getContentClaimOffset(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRepository.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRepository.java index 999a087d8a..5e59e04890 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRepository.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRepository.java @@ -27,7 +27,6 @@ import org.apache.nifi.controller.repository.claim.ContentClaimManager; /** * Implementations must be thread safe * - * @author none */ public interface FlowFileRepository extends Closeable { @@ -36,28 +35,24 @@ public interface FlowFileRepository extends Closeable { * ContentClaimManager that is to be used for interacting with Content * Claims * - * @param claimManager - * @throws java.io.IOException + * @param claimManager for handling claims + * @throws java.io.IOException if unable to initialize repository */ void initialize(ContentClaimManager claimManager) throws IOException; /** - * Returns the maximum number of bytes that can be stored in the underlying + * @return the maximum number of bytes that can be stored in the underlying * storage mechanism * - * @return - * - * @throws IOException + * @throws IOException if computing capacity fails */ long getStorageCapacity() throws IOException; /** - * Returns the number of bytes currently available for use by the underlying + * @return the number of bytes currently available for use by the underlying * storage mechanism * - * @return - * - * @throws IOException + * @throws IOException if computing usable space fails */ long getUsableStorageSpace() throws IOException; @@ -65,7 +60,7 @@ public interface FlowFileRepository extends Closeable { * Updates the repository with the given RepositoryRecords. * * @param records the records to update the repository with - * @throws java.io.IOException + * @throws java.io.IOException if update fails */ void updateRepository(Collection records) throws IOException; @@ -79,7 +74,7 @@ public interface FlowFileRepository extends Closeable { * returned by a call to {@link #getNextFlowFileSequence()} * * @return index of highest flow file identifier - * @throws IOException + * @throws IOException if load fails */ long loadFlowFiles(QueueProvider queueProvider, long minimumSequenceNumber) throws IOException; @@ -97,7 +92,7 @@ public interface FlowFileRepository extends Closeable { /** * @return the max ID of all FlowFiles that currently exist in * the repository. - * @throws IOException + * @throws IOException if computing max identifier fails */ long getMaxFlowFileIdentifier() throws IOException; @@ -109,7 +104,7 @@ public interface FlowFileRepository extends Closeable { * @param flowFileQueue the queue that the FlowFiles belong to * @param swapLocation the location to which the FlowFiles were swapped * - * @throws IOException + * @throws IOException if swap fails */ void swapFlowFilesOut(List swappedOut, FlowFileQueue flowFileQueue, String swapLocation) throws IOException; @@ -122,7 +117,7 @@ public interface FlowFileRepository extends Closeable { * @param flowFileRecords the records that were swapped in * @param flowFileQueue the queue that the FlowFiles belong to * - * @throws IOException + * @throws IOException if swap fails */ void swapFlowFilesIn(String swapLocation, List flowFileRecords, FlowFileQueue flowFileQueue) throws IOException; } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileSwapManager.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileSwapManager.java index c6daab8303..869e2b355b 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileSwapManager.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileSwapManager.java @@ -55,9 +55,9 @@ public interface FlowFileSwapManager { * Notifies FlowFile queues of the number of FlowFiles and content size of * all FlowFiles that are currently swapped out * - * @param connectionProvider - * @param claimManager - * @return + * @param connectionProvider provider + * @param claimManager manager + * @return how many flowfiles have been recovered */ long recoverSwappedFlowFiles(QueueProvider connectionProvider, ContentClaimManager claimManager); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/QueueProvider.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/QueueProvider.java index 42cf319afd..fcb516d5ea 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/QueueProvider.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/QueueProvider.java @@ -27,9 +27,7 @@ import org.apache.nifi.controller.FlowFileQueue; public interface QueueProvider { /** - * Returns all FlowFileQueues that currently exist in the flow - * - * @return + * @return all FlowFileQueues that currently exist in the flow */ Collection getAllQueues(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecord.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecord.java index d4b9c86ba3..40d44a84c6 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecord.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecord.java @@ -26,60 +26,44 @@ import org.apache.nifi.controller.repository.claim.ContentClaim; public interface RepositoryRecord { /** - * The FlowFileQueue to which the FlowFile is to be transferred - * - * @return + * @return FlowFileQueue to which the FlowFile is to be transferred */ FlowFileQueue getDestination(); /** - * The FlowFileQueue from which the record was pulled - * - * @return + * @return FlowFileQueue from which the record was pulled */ FlowFileQueue getOriginalQueue(); /** - * The type of update that this record encapsulates - * - * @return + * @return type of update that this record encapsulates */ RepositoryRecordType getType(); /** - * The current ContentClaim for the FlowFile - * - * @return + * @return current ContentClaim for the FlowFile */ ContentClaim getCurrentClaim(); /** - * The original ContentClaim for the FlowFile before any changes were made - * - * @return + * @return original ContentClaim for the FlowFile before any changes were made */ ContentClaim getOriginalClaim(); /** - * The byte offset into the Content Claim where this FlowFile's content + * @return byte offset into the Content Claim where this FlowFile's content * begins - * - * @return */ long getCurrentClaimOffset(); /** - * The FlowFile being encapsulated by this record - * - * @return + * @return FlowFile being encapsulated by this record */ FlowFileRecord getCurrent(); /** - * Whether or not the FlowFile's attributes have changed since the FlowFile + * @return Whether or not the FlowFile's attributes have changed since the FlowFile * was pulled from its queue (or created) - * - * @return */ boolean isAttributesChanged(); @@ -90,11 +74,9 @@ public interface RepositoryRecord { boolean isMarkedForAbort(); /** - * If the FlowFile is swapped out of the Java heap space, provides the + * @return If the FlowFile is swapped out of the Java heap space, provides the * location of the swap file, or null if the FlowFile is not * swapped out - * - * @return */ String getSwapLocation(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecordType.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecordType.java index 5ba52d9afd..ff8dc504fa 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecordType.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecordType.java @@ -18,7 +18,6 @@ package org.apache.nifi.controller.repository; /** * - * @author none */ public enum RepositoryRecordType { diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/claim/ContentClaim.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/claim/ContentClaim.java index e321217fd3..53cc44f7d5 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/claim/ContentClaim.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/claim/ContentClaim.java @@ -25,7 +25,6 @@ package org.apache.nifi.controller.repository.claim; *

    * Must be thread safe

    * - * @author none */ public interface ContentClaim extends Comparable { @@ -45,11 +44,9 @@ public interface ContentClaim extends Comparable { String getSection(); /** - * Specifies whether or not the Claim is loss-tolerant. If so, we will + * @return Indicates whether or not the Claim is loss-tolerant. If so, we will * attempt to keep the content but will not sacrifice a great deal of - * performance to do so. - * - * @return + * performance to do so */ boolean isLossTolerant(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/claim/ContentClaimManager.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/claim/ContentClaimManager.java index 6a5b38b4b5..bffcec321b 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/claim/ContentClaimManager.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/claim/ContentClaimManager.java @@ -28,20 +28,18 @@ public interface ContentClaimManager { * Creates a new Content Claim with the given id, container, section, and * loss tolerance. * - * @param id - * @param container - * @param section - * @param lossTolerant - * @return + * @param id of claim + * @param container of claim + * @param section of claim + * @param lossTolerant of claim + * @return new claim */ ContentClaim newContentClaim(String container, String section, String id, boolean lossTolerant); /** - * Returns the number of FlowFiles that hold a claim to a particular piece + * @param claim to obtain reference count for + * @return the number of FlowFiles that hold a claim to a particular piece * of FlowFile content - * - * @param claim - * @return */ int getClaimantCount(ContentClaim claim); @@ -49,8 +47,8 @@ public interface ContentClaimManager { * Decreases by 1 the count of how many FlowFiles hold a claim to a * particular piece of FlowFile content and returns the new count * - * @param claim - * @return + * @param claim to decrement claimants on + * @return new claimaint count */ int decrementClaimantCount(ContentClaim claim); @@ -58,8 +56,8 @@ public interface ContentClaimManager { * Increases by 1 the count of how many FlowFiles hold a claim to a * particular piece of FlowFile content and returns the new count * - * @param claim - * @return + * @param claim to increment claims on + * @return new claimant count */ int incrementClaimantCount(ContentClaim claim); @@ -73,9 +71,10 @@ public interface ContentClaimManager { * optimize its tasks, knowing that the Content Claim cannot be referenced * by any other component * - * @param claim - * @param newClaim - * @return + * @param claim to increment + * @param newClaim provides a hint that no other process can have access to this + * claim right now + * @return new claim count */ int incrementClaimantCount(ContentClaim claim, boolean newClaim); @@ -105,7 +104,7 @@ public interface ContentClaimManager { * unneeded claim. As such, it is now safe to destroy the contents. *

    * - * @param claim + * @param claim to mark as now destructable */ void markDestructable(ContentClaim claim); @@ -114,8 +113,8 @@ public interface ContentClaimManager { * of destructable content claims to the given {@code destination} so that * they can be destroyed. * - * @param destination - * @param maxElements + * @param destination to drain to + * @param maxElements max items to drain */ void drainDestructableClaims(Collection destination, int maxElements); @@ -128,10 +127,10 @@ public interface ContentClaimManager { * ready to be destroyed, the method will return without having added * anything to the given {@code destination}. * - * @param destination - * @param maxElements - * @param timeout - * @param unit + * @param destination to drain to + * @param maxElements max items to drain + * @param timeout maximum time to wait + * @param unit unit of time to wait */ void drainDestructableClaims(Collection destination, int maxElements, long timeout, TimeUnit unit); diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/ConnectionStatus.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/ConnectionStatus.java index 453ac9db89..cebb2b4d00 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/ConnectionStatus.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/ConnectionStatus.java @@ -17,7 +17,6 @@ package org.apache.nifi.controller.status; /** - * @author unattributed */ public class ConnectionStatus implements Cloneable { diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/ProcessGroupStatus.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/ProcessGroupStatus.java index dba3a19b17..eb0339fe60 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/ProcessGroupStatus.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/ProcessGroupStatus.java @@ -23,7 +23,6 @@ import java.util.List; import java.util.Map; /** - * @author unattributed */ public class ProcessGroupStatus implements Cloneable { @@ -43,6 +42,8 @@ public class ProcessGroupStatus implements Cloneable { private long bytesReceived; private int flowFilesSent; private long bytesSent; + private int flowFilesTransferred; + private long bytesTransferred; private Collection connectionStatus = new ArrayList<>(); private Collection processorStatus = new ArrayList<>(); @@ -227,6 +228,22 @@ public class ProcessGroupStatus implements Cloneable { this.bytesSent = bytesSent; } + public int getFlowFilesTransferred() { + return flowFilesTransferred; + } + + public void setFlowFilesTransferred(int flowFilesTransferred) { + this.flowFilesTransferred = flowFilesTransferred; + } + + public long getBytesTransferred() { + return bytesTransferred; + } + + public void setBytesTransferred(long bytesTransferred) { + this.bytesTransferred = bytesTransferred; + } + @Override public ProcessGroupStatus clone() { @@ -248,6 +265,8 @@ public class ProcessGroupStatus implements Cloneable { clonedObj.bytesReceived = bytesReceived; clonedObj.flowFilesSent = flowFilesSent; clonedObj.bytesSent = bytesSent; + clonedObj.flowFilesTransferred = flowFilesTransferred; + clonedObj.bytesTransferred = bytesTransferred; if (connectionStatus != null) { final Collection statusList = new ArrayList<>(); @@ -317,6 +336,18 @@ public class ProcessGroupStatus implements Cloneable { builder.append(creationTimestamp); builder.append(", activeThreadCount="); builder.append(activeThreadCount); + builder.append(", flowFilesTransferred="); + builder.append(flowFilesTransferred); + builder.append(", bytesTransferred="); + builder.append(bytesTransferred); + builder.append(", flowFilesReceived="); + builder.append(flowFilesReceived); + builder.append(", bytesReceived="); + builder.append(bytesReceived); + builder.append(", flowFilesSent="); + builder.append(flowFilesSent); + builder.append(", bytesSent="); + builder.append(bytesSent); builder.append(",\n\tconnectionStatus="); for (final ConnectionStatus status : connectionStatus) { @@ -374,6 +405,12 @@ public class ProcessGroupStatus implements Cloneable { target.setBytesRead(target.getBytesRead() + toMerge.getBytesRead()); target.setBytesWritten(target.getBytesWritten() + toMerge.getBytesWritten()); target.setActiveThreadCount(target.getActiveThreadCount() + toMerge.getActiveThreadCount()); + target.setFlowFilesTransferred(target.getFlowFilesTransferred() + toMerge.getFlowFilesTransferred()); + target.setBytesTransferred(target.getBytesTransferred() + toMerge.getBytesTransferred()); + target.setFlowFilesReceived(target.getFlowFilesReceived() + toMerge.getFlowFilesReceived()); + target.setBytesReceived(target.getBytesReceived() + toMerge.getBytesReceived()); + target.setFlowFilesSent(target.getFlowFilesSent() + toMerge.getFlowFilesSent()); + target.setBytesSent(target.getBytesSent() + toMerge.getBytesSent()); // connection status // sort by id @@ -425,7 +462,7 @@ public class ProcessGroupStatus implements Cloneable { // processor run status is disabled/stopped/running is part of the flow configuration // and should not differ amongst nodes. however, whether a processor is invalid // can be driven by environmental conditions. this check allows any of those to - // take precedence over the configured run status. + // take precedence over the configured run status. if (RunStatus.Invalid.equals(statusToMerge.getRunStatus())) { merged.setRunStatus(RunStatus.Invalid); } @@ -454,7 +491,7 @@ public class ProcessGroupStatus implements Cloneable { merged.setTransmitting(true); } - // should be unnecessary here since ports run status should not be affected by + // should be unnecessary here since ports run status should not be affected by // environmental conditions but doing so in case that changes if (RunStatus.Invalid.equals(statusToMerge.getRunStatus())) { merged.setRunStatus(RunStatus.Invalid); @@ -484,7 +521,7 @@ public class ProcessGroupStatus implements Cloneable { merged.setTransmitting(true); } - // should be unnecessary here since ports run status not should be affected by + // should be unnecessary here since ports run status not should be affected by // environmental conditions but doing so in case that changes if (RunStatus.Invalid.equals(statusToMerge.getRunStatus())) { merged.setRunStatus(RunStatus.Invalid); diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/ProcessorStatus.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/ProcessorStatus.java index bd7778b71c..54be7ba757 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/ProcessorStatus.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/ProcessorStatus.java @@ -19,7 +19,6 @@ package org.apache.nifi.controller.status; import java.util.concurrent.TimeUnit; /** - * @author unattributed */ public class ProcessorStatus implements Cloneable { diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/history/ComponentStatusRepository.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/history/ComponentStatusRepository.java index 6fe13fc870..4628a288f7 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/history/ComponentStatusRepository.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/history/ComponentStatusRepository.java @@ -33,7 +33,7 @@ public interface ComponentStatusRepository { /** * Captures the status information provided in the given report * - * @param rootGroupStatus + * @param rootGroupStatus status of root group */ void capture(ProcessGroupStatus rootGroupStatus); @@ -42,22 +42,17 @@ public interface ComponentStatusRepository { * timestamp that indicates the time at which the status report was * generated. This can be used to replay historical values. * - * @param rootGroupStatus - * @param timestamp + * @param rootGroupStatus status + * @param timestamp timestamp of capture */ void capture(ProcessGroupStatus rootGroupStatus, Date timestamp); /** - * Returns the Date at which the latest capture was performed - * - * @return + * @return the Date at which the latest capture was performed */ Date getLastCaptureDate(); /** - * Returns a {@link StatusHistory} that provides the status information - * about the Connection with the given ID during the given time period. - * * @param connectionId the ID of the Connection for which the Status is * desired * @param start the earliest date for which status information should be @@ -70,15 +65,13 @@ public interface ComponentStatusRepository { * If the date range is large, the total number of data points could be far * too many to process. Therefore, this parameter allows the requestor to * indicate how many samples to return. - * @return + * @return a {@link StatusHistory} that provides the status information + * about the Connection with the given ID during the given time period */ StatusHistory getConnectionStatusHistory(String connectionId, Date start, Date end, int preferredDataPoints); /** - * Returns a {@link StatusHistory} that provides the status information - * about the Process Group with the given ID during the given time period. - * - * @param processGroupId + * @param processGroupId of group to get status of * @param start the earliest date for which status information should be * returned; if null, the start date should be assumed to be * the beginning of time @@ -89,15 +82,13 @@ public interface ComponentStatusRepository { * If the date range is large, the total number of data points could be far * too many to process. Therefore, this parameter allows the requestor to * indicate how many samples to return. - * @return + * @return a {@link StatusHistory} that provides the status information + * about the Process Group with the given ID during the given time period */ StatusHistory getProcessGroupStatusHistory(String processGroupId, Date start, Date end, int preferredDataPoints); /** - * Returns a {@link StatusHistory} that provides the status information - * about the Processor with the given ID during the given time period. - * - * @param processorId + * @param processorId to get status of * @param start the earliest date for which status information should be * returned; if null, the start date should be assumed to be * the beginning of time @@ -108,16 +99,13 @@ public interface ComponentStatusRepository { * If the date range is large, the total number of data points could be far * too many to process. Therefore, this parameter allows the requestor to * indicate how many samples to return. - * @return + * @return a {@link StatusHistory} that provides the status information + * about the Processor with the given ID during the given time period */ StatusHistory getProcessorStatusHistory(String processorId, Date start, Date end, int preferredDataPoints); /** - * Returns a {@link StatusHistory} that provides the status information - * about the Remote Process Group with the given ID during the given time - * period. - * - * @param remoteGroupId + * @param remoteGroupId to get history of * @param start the earliest date for which status information should be * returned; if null, the start date should be assumed to be * the beginning of time @@ -128,39 +116,33 @@ public interface ComponentStatusRepository { * If the date range is large, the total number of data points could be far * too many to process. Therefore, this parameter allows the requestor to * indicate how many samples to return. - * @return + * @return a {@link StatusHistory} that provides the status information + * about the Remote Process Group with the given ID during the given time + * period */ StatusHistory getRemoteProcessGroupStatusHistory(String remoteGroupId, Date start, Date end, int preferredDataPoints); /** - * Returns a List of all {@link MetricDescriptor}s that are applicable to + * @return a List of all {@link MetricDescriptor}s that are applicable to * Process Groups - * - * @return */ List> getProcessGroupMetricDescriptors(); /** - * Returns a List of all {@link MetricDescriptor}s that are applicable to + * @return a List of all {@link MetricDescriptor}s that are applicable to * Processors - * - * @return */ List> getProcessorMetricDescriptors(); /** - * Returns a List of all {@link MetricDescriptor}s that are applicable to + * @return a List of all {@link MetricDescriptor}s that are applicable to * Remote Process Groups - * - * @return */ List> getRemoteProcessGroupMetricDescriptors(); /** - * Returns a List of all {@link MetricDescriptor}s that are applicable to + * @return a List of all {@link MetricDescriptor}s that are applicable to * Connections - * - * @return */ List> getConnectionMetricDescriptors(); diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/history/MetricDescriptor.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/history/MetricDescriptor.java index 3986c86bfb..8fdce05cad 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/history/MetricDescriptor.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/history/MetricDescriptor.java @@ -18,7 +18,8 @@ package org.apache.nifi.controller.status.history; /** * Describes a particular metric that is derived from a Status History - * @param + * + * @param type of metric */ public interface MetricDescriptor { @@ -32,44 +33,34 @@ public interface MetricDescriptor { /** * Specifies how the values should be formatted * - * @return + * @return formatter for values */ Formatter getFormatter(); /** - * Returns a human-readable description of the field - * - * @return + * @return a human-readable description of the field */ String getDescription(); /** - * Returns a human-readable label for the field - * - * @return + * @return a human-readable label for the field */ String getLabel(); /** - * Returns the name of a field - * - * @return + * @return the name of a field */ String getField(); /** - * Returns a {@link ValueMapper} that can be used to extract a value for the + * @return a {@link ValueMapper} that can be used to extract a value for the * status history - * - * @return */ ValueMapper getValueFunction(); /** - * Returns a {@link ValueReducer} that can reduce multiple StatusSnapshots + * @return a {@link ValueReducer} that can reduce multiple StatusSnapshots * into a single Long value - * - * @return */ ValueReducer getValueReducer(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/history/StatusHistory.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/history/StatusHistory.java index b053d33d77..f1bb946837 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/history/StatusHistory.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/history/StatusHistory.java @@ -26,25 +26,19 @@ import java.util.Map; public interface StatusHistory { /** - * Returns a Date indicating when this report was generated - * - * @return + * @return a Date indicating when this report was generated */ Date getDateGenerated(); /** - * Returns a Map of component field names and their values. The order in + * @return a Map of component field names and their values. The order in * which these values are displayed is dependent on the natural ordering of - * the Map returned. - * - * @return + * the Map returned */ Map getComponentDetails(); /** - * A List of snapshots for a given component - * - * @return + * @return List of snapshots for a given component */ List getStatusSnapshots(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/history/StatusSnapshot.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/history/StatusSnapshot.java index d52c1cc081..551ceb2552 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/history/StatusSnapshot.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/history/StatusSnapshot.java @@ -25,24 +25,18 @@ import java.util.Map; public interface StatusSnapshot { /** - * Rreturns the point in time for which the status values were obtained - * - * @return + * @return the point in time for which the status values were obtained */ Date getTimestamp(); /** - * Returns a Map of MetricDescriptor to value - * - * @return + * @return a Map of MetricDescriptor to value */ Map, Long> getStatusMetrics(); /** - * Returns a {@link ValueReducer} that is capable of merging multiple + * @return a {@link ValueReducer} that is capable of merging multiple * StatusSnapshot objects into a single one - * - * @return */ ValueReducer getValueReducer(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/expression/AttributeExpression.java b/nifi/nifi-api/src/main/java/org/apache/nifi/expression/AttributeExpression.java index b71c83dacd..ed409ea2ad 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/expression/AttributeExpression.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/expression/AttributeExpression.java @@ -22,12 +22,10 @@ import org.apache.nifi.processor.exception.ProcessException; public interface AttributeExpression { /** - * Evaluates the expression without providing any FlowFile Attributes. This + * @return Evaluates the expression without providing any FlowFile Attributes. This * will evaluate the expression based only on System Properties and JVM * Environment properties - * - * @return - * @throws ProcessException + * @throws ProcessException if unable to evaluate */ String evaluate() throws ProcessException; @@ -36,9 +34,9 @@ public interface AttributeExpression { * will evaluate the expression based only on System Properties and JVM * Environment properties but allows the values to be decorated * - * @param decorator - * @return - * @throws ProcessException + * @param decorator for attribute value + * @return evaluated value + * @throws ProcessException if failure in evaluation */ String evaluate(AttributeValueDecorator decorator) throws ProcessException; @@ -47,9 +45,9 @@ public interface AttributeExpression { * id, etc. of the given FlowFile, as well as System Properties and JVM * Environment properties * - * @param flowFile - * @return - * @throws ProcessException + * @param flowFile to evaluate + * @return evaluated value + * @throws ProcessException if failure evaluating */ String evaluate(FlowFile flowFile) throws ProcessException; @@ -58,17 +56,15 @@ public interface AttributeExpression { * id, etc. of the given FlowFile, as well as System Properties and JVM * Environment properties and allows the values to be decorated * - * @param flowFile - * @param decorator - * @return - * @throws ProcessException + * @param flowFile to evaluate + * @param decorator for evaluation + * @return evaluated value + * @throws ProcessException if failed to evaluate */ String evaluate(FlowFile flowFile, AttributeValueDecorator decorator) throws ProcessException; /** - * Returns the type that is returned by the Expression - * - * @return + * @return the type that is returned by the Expression */ ResultType getResultType(); diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/expression/AttributeValueDecorator.java b/nifi/nifi-api/src/main/java/org/apache/nifi/expression/AttributeValueDecorator.java index af071f3cee..4cea248961 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/expression/AttributeValueDecorator.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/expression/AttributeValueDecorator.java @@ -22,8 +22,8 @@ public interface AttributeValueDecorator { * Decorates the value of a FlowFile Attribute or System/JVM property in * some way * - * @param attributeValue - * @return + * @param attributeValue to decorate + * @return decorated value */ String decorate(String attributeValue); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/expression/ExpressionLanguageCompiler.java b/nifi/nifi-api/src/main/java/org/apache/nifi/expression/ExpressionLanguageCompiler.java index aced2e6a23..9383d2722e 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/expression/ExpressionLanguageCompiler.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/expression/ExpressionLanguageCompiler.java @@ -25,7 +25,7 @@ public interface ExpressionLanguageCompiler { * AttributeExpression that can be evaluated * * @param expression the Attribute Expression to be compiled - * @return + * @return expression that can be evaluated * @throws IllegalArgumentException if the given expression is not valid */ AttributeExpression compile(String expression) throws IllegalArgumentException; @@ -34,8 +34,8 @@ public interface ExpressionLanguageCompiler { * Indicates whether or not the given string is a valid Attribute * Expression. * - * @param expression - * @return + * @param expression to validate + * @return if is value or not */ boolean isValidExpression(String expression); @@ -44,7 +44,7 @@ public interface ExpressionLanguageCompiler { * if the expression is syntactically valid or a String indicating why the * expression is invalid otherwise. * - * @param expression + * @param expression to validate * @param allowSurroundingCharacters if true allows characters * to surround the Expression, otherwise the expression must be exactly * equal to a valid Expression. E.g., /${path} is valid if and @@ -60,7 +60,7 @@ public interface ExpressionLanguageCompiler { * Returns the ResultType that will be returned by the given Expression * * @param expression the Expression to evaluate - * @return + * @return result type for the given expression * @throws IllegalArgumentException if the given Expression is not a valid * Expression Language Expression; the message of this Exception will * indicate the problem if the expression is not syntactically valid. diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/flowfile/FlowFile.java b/nifi/nifi-api/src/main/java/org/apache/nifi/flowfile/FlowFile.java index bce92ee9a1..0e2c19d6ea 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/flowfile/FlowFile.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/flowfile/FlowFile.java @@ -48,24 +48,22 @@ public interface FlowFile extends Comparable { long getLineageStartDate(); /** - * Returns the time at which the FlowFile was most recently added to a + * @return the time at which the FlowFile was most recently added to a * FlowFile queue, or {@code null} if the FlowFile has never been enqueued. * This value will always be populated before it is passed to a - * {@link FlowFilePrioritizer}. - * - * @return + * {@link FlowFilePrioritizer} */ Long getLastQueueDate(); /** - * @return a set of identifiers that are unique to this FlowFile's lineage. - * If FlowFile X is derived from FlowFile Y, both FlowFiles will have the - * same value for the Lineage Claim ID. - * *

    * If a FlowFile is derived from multiple "parent" FlowFiles, all of the * parents' Lineage Identifiers will be in the set. *

    + * + * @return a set of identifiers that are unique to this FlowFile's lineage. + * If FlowFile X is derived from FlowFile Y, both FlowFiles will have the + * same value for the Lineage Claim ID. */ Set getLineageIdentifiers(); @@ -77,7 +75,7 @@ public interface FlowFile extends Comparable { /** * Obtains the attribute value for the given key * - * @param key + * @param key of the attribute * @return value if found; null otherwise */ String getAttribute(String key); diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/flowfile/FlowFilePrioritizer.java b/nifi/nifi-api/src/main/java/org/apache/nifi/flowfile/FlowFilePrioritizer.java index 16d5962827..684f454f57 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/flowfile/FlowFilePrioritizer.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/flowfile/FlowFilePrioritizer.java @@ -24,7 +24,6 @@ import java.util.Comparator; * so if features of that content are necessary for prioritization it should be * extracted to be used as an attribute of the flow file. * - * @author none */ public interface FlowFilePrioritizer extends Comparator { } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/logging/ComponentLog.java b/nifi/nifi-api/src/main/java/org/apache/nifi/logging/ComponentLog.java index c070e23698..b4b3c6a565 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/logging/ComponentLog.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/logging/ComponentLog.java @@ -16,36 +16,40 @@ */ package org.apache.nifi.logging; - /** *

    - * The ComponentLog provides a mechanism to ensure that all NiFi components are logging and reporting - * information in a consistent way. When messages are logged to the ComponentLog, each message has the - * following characteristics: + * The ComponentLog provides a mechanism to ensure that all NiFi components are + * logging and reporting information in a consistent way. When messages are + * logged to the ComponentLog, each message has the following characteristics: *

    - * + * *
      - *
    • - * The toString() of the component is automatically prepended to the message so that it is clear - * which component is providing the information. This is important, since a single component may have many - * different instances within the same NiFi instance. - *
    • - *
    • - * If the last value in an Object[] argument that is passed to the logger is a Throwable, then the logged message - * will include a toString() of the Throwable; in addition, if the component's logger is set to - * DEBUG level via the logback configuration, the Stacktrace will also be logged. This provides a mechanism to easily - * enable stacktraces in the logs when they are desired without filling the logs with unneeded stack traces for messages - * that end up occurring often. - *
    • - *
    • - * Any message that is logged with a Severity level that meets or exceeds the configured Bulletin Level for that component - * will also cause a Bulletin to be generated, so that the message is visible in the UI, allowing Dataflow Managers - * to understand that a problem exists and what the issue is. - *
    • + *
    • + * The toString() of the component is automatically prepended to + * the message so that it is clear which component is providing the information. + * This is important, since a single component may have many different instances + * within the same NiFi instance. + *
    • + *
    • + * If the last value in an Object[] argument that is passed to the logger is a + * Throwable, then the logged message will include a toString() of + * the Throwable; in addition, if the component's logger is set to DEBUG level + * via the logback configuration, the Stacktrace will also be logged. This + * provides a mechanism to easily enable stacktraces in the logs when they are + * desired without filling the logs with unneeded stack traces for messages that + * end up occurring often. + *
    • + *
    • + * Any message that is logged with a Severity level that meets or exceeds the + * configured Bulletin Level for that component will also cause a Bulletin to be + * generated, so that the message is visible in the UI, allowing Dataflow + * Managers to understand that a problem exists and what the issue is. + *
    • *
    - * + * */ public interface ComponentLog { + void warn(String msg, Throwable t); void warn(String msg, Object[] os); diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/logging/ProcessorLog.java b/nifi/nifi-api/src/main/java/org/apache/nifi/logging/ProcessorLog.java index 0d66d8553b..a90ee26cc9 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/logging/ProcessorLog.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/logging/ProcessorLog.java @@ -16,14 +16,14 @@ */ package org.apache.nifi.logging; - /** - * The ProcessorLog is an extension of ComponentLog but provides no additional functionality. - * It exists because ProcessorLog was created first, - * but when Controller Services and Reporting Tasks began to be used more heavily loggers - * were needed for them as well. We did not want to return a ProcessorLog to a ControllerService - * or a ReportingTask, so all of the methods were moved to a higher interface named ComponentLog. - * However, we kept the ProcessorLog interface around in order to maintain backward compatibility. + * The ProcessorLog is an extension of ComponentLog but provides no additional + * functionality. It exists because ProcessorLog was created first, but when + * Controller Services and Reporting Tasks began to be used more heavily loggers + * were needed for them as well. We did not want to return a ProcessorLog to a + * ControllerService or a ReportingTask, so all of the methods were moved to a + * higher interface named ComponentLog. However, we kept the ProcessorLog + * interface around in order to maintain backward compatibility. */ public interface ProcessorLog extends ComponentLog { diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/AbstractSessionFactoryProcessor.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/AbstractSessionFactoryProcessor.java index f13a14304d..2695dcddfa 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/AbstractSessionFactoryProcessor.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/AbstractSessionFactoryProcessor.java @@ -41,7 +41,6 @@ import org.apache.nifi.logging.ProcessorLog; *

    * Thread safe

    * - * @author none */ public abstract class AbstractSessionFactoryProcessor extends AbstractConfigurableComponent implements Processor { @@ -62,10 +61,8 @@ public abstract class AbstractSessionFactoryProcessor extends AbstractConfigurab } /** - * Returns the {@link ControllerServiceLookup} that was passed to the + * @return the {@link ControllerServiceLookup} that was passed to the * {@link #init(ProcessorInitializationContext)} method - * - * @return */ protected final ControllerServiceLookup getControllerServiceLookup() { return serviceLookup; @@ -83,17 +80,15 @@ public abstract class AbstractSessionFactoryProcessor extends AbstractConfigurab /** * Provides subclasses the ability to perform initialization logic * - * @param context + * @param context in which to perform initialization */ protected void init(final ProcessorInitializationContext context) { // Provided for subclasses to override } /** - * Returns true if the processor is scheduled to run, + * @return true if the processor is scheduled to run, * false otherwise - * - * @return */ protected final boolean isScheduled() { return scheduled; diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/DataUnit.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/DataUnit.java index dc0a66f631..4980b97d55 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/DataUnit.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/DataUnit.java @@ -21,9 +21,6 @@ import java.util.regex.Pattern; public enum DataUnit { - // 1024 * 1024 = - // 1024 * 1024 * 1024 - // 1024 * 1024 * 1024 * 1024 /** * Bytes */ diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/FlowFileFilter.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/FlowFileFilter.java index 20147ca5d0..3bd6546a61 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/FlowFileFilter.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/FlowFileFilter.java @@ -35,8 +35,10 @@ public interface FlowFileFilter { * whether or not the Processor is interested in filtering additional * FlowFiles * - * @param flowFile - * @return + * @param flowFile to apply the filter to + * @return true if the given FlowFile should be selected and + * if Processor is interested in filtering additional + * FlowFiles */ FlowFileFilterResult filter(FlowFile flowFile); diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/ProcessContext.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/ProcessContext.java index 7fa183f824..c61a31802f 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/ProcessContext.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/ProcessContext.java @@ -39,8 +39,8 @@ public interface ProcessContext { * Retrieves the current value set for the given descriptor, if a value is * set - else uses the descriptor to determine the appropriate default value * - * @param descriptor - * @return + * @param descriptor to lookup the value of + * @return the property value of the given descriptor */ PropertyValue getProperty(PropertyDescriptor descriptor); @@ -48,8 +48,8 @@ public interface ProcessContext { * Retrieves the current value set for the given descriptor, if a value is * set - else uses the descriptor to determine the appropriate default value * - * @param propertyName - * @return + * @param propertyName of the property to lookup the value for + * @return property value as retrieved by property name */ PropertyValue getProperty(String propertyName); @@ -57,8 +57,9 @@ public interface ProcessContext { * Creates and returns a {@link PropertyValue} object that can be used for * evaluating the value of the given String * - * @param rawValue - * @return + * @param rawValue the raw input before any property evaluation has occurred + * @return a {@link PropertyValue} object that can be used for + * evaluating the value of the given String */ PropertyValue newPropertyValue(String rawValue); @@ -89,11 +90,9 @@ public interface ProcessContext { String getAnnotationData(); /** - * Returns a Map of all PropertyDescriptors to their configured values. This + * @return a Map of all PropertyDescriptors to their configured values. This * Map may or may not be modifiable, but modifying its values will not * change the values of the processor's properties - * - * @return */ Map getProperties(); @@ -101,8 +100,8 @@ public interface ProcessContext { * Encrypts the given value using the password provided in the NiFi * Properties * - * @param unencrypted - * @return + * @param unencrypted plaintext value + * @return encrypted value */ String encrypt(String unencrypted); @@ -110,19 +109,17 @@ public interface ProcessContext { * Decrypts the given value using the password provided in the NiFi * Properties * - * @param encrypted - * @return + * @param encrypted the encrypted value + * @return the plaintext value */ String decrypt(String encrypted); /** - * Provides a {@code ControllerServiceLookup} that can be used to obtain a + * @return a {@code ControllerServiceLookup} that can be used to obtain a * Controller Service - * - * @return */ ControllerServiceLookup getControllerServiceLookup(); - + /** * @return the set of all relationships for which space is available to * receive new objects diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/ProcessSession.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/ProcessSession.java index 7b855f2833..ed46d68071 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/ProcessSession.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/ProcessSession.java @@ -60,7 +60,6 @@ import org.apache.nifi.provenance.ProvenanceReporter; * A process session instance may be used continuously. That is, after each * commit or rollback, the session can be used again.

    * - * @author unattributed */ public interface ProcessSession { @@ -136,7 +135,8 @@ public interface ProcessSession { * single call. * * @param maxResults the maximum number of FlowFiles to return - * @return + * @return up to maxResults FlowFiles from the work queue. If + * no FlowFiles are available, returns an empty list. Will not return null. * @throws IllegalArgumentException if maxResults is less than * 0 */ @@ -152,8 +152,9 @@ public interface ProcessSession { * returned. *

    * - * @param filter - * @return + * @param filter to limit which flow files are returned + * @return all FlowFiles from all of the incoming queues for which the given + * {@link FlowFileFilter} indicates should be accepted. */ List get(FlowFileFilter filter); @@ -170,7 +171,7 @@ public interface ProcessSession { * linkage to a parent FlowFile. This method is appropriate only when data * is received or created from an external system. Otherwise, this method * should be avoided and should instead use {@link #create(FlowFile)} or - * {@link #create(Collection)}. + * {@see #create(Collection)}. * * When this method is used, a Provenance CREATE or RECEIVE Event should be * generated. See the {@link #getProvenanceReporter()} method and @@ -188,8 +189,8 @@ public interface ProcessSession { * event, depending on whether or not other FlowFiles are generated from the * same parent before the ProcessSession is committed. * - * @param parent - * @return + * @param parent to base the new flowfile on + * @return newly created flowfile */ FlowFile create(FlowFile parent); @@ -201,8 +202,8 @@ public interface ProcessSession { * only a single parent exists). This method will automatically generate a * Provenance JOIN event. * - * @param parents - * @return + * @param parents which the new flowfile should inherit shared attributes from + * @return new flowfile */ FlowFile create(Collection parents); @@ -239,9 +240,9 @@ public interface ProcessSession { * Event, if the offset is 0 and the size is exactly equal to the size of * the example FlowFile). * - * @param example - * @param offset - * @param size + * @param parent to base the new flowfile attributes on + * @param offset of the parent flowfile to base the child flowfile content on + * @param size of the new flowfile from the offset * @return a FlowFile with the specified size whose parent is first argument * to this function * @@ -250,14 +251,14 @@ public interface ProcessSession { * the given FlowFile * @throws FlowFileHandlingException if the given FlowFile is already * transferred or removed or doesn't belong to this session, or if the - * specified offset + size exceeds that of the size of the example FlowFile. + * specified offset + size exceeds that of the size of the parent FlowFile. * Automatic rollback will occur. * @throws MissingFlowFileException if the given FlowFile content cannot be * found. The FlowFile should no longer be reference, will be internally * destroyed, and the session is automatically rolled back and what is left * of the FlowFile is destroyed. */ - FlowFile clone(FlowFile example, long offset, long size); + FlowFile clone(FlowFile parent, long offset, long size); /** * Sets a penalty for the given FlowFile which will make it unavailable to @@ -368,8 +369,8 @@ public interface ProcessSession { * destination processor will have immediate visibility of the transferred * FlowFiles within the session. * - * @param flowFile - * @param relationship + * @param flowFile to transfer + * @param relationship to transfer to * @throws IllegalStateException if detected that this method is being * called from within a callback of another method in this session and for * the given FlowFile(s) @@ -389,7 +390,7 @@ public interface ProcessSession { * the FlowFile will be maintained. FlowFiles that are created by the * processor cannot be transferred back to themselves via this method. * - * @param flowFile + * @param flowFile to transfer * @throws IllegalStateException if detected that this method is being * called from within a callback of another method in this session and for * the given FlowFile(s) @@ -410,7 +411,7 @@ public interface ProcessSession { * created by the processor cannot be transferred back to themselves via * this method. * - * @param flowFiles + * @param flowFiles to transfer * @throws IllegalStateException if detected that this method is being * called from within a callback of another method in this session and for * the given FlowFile(s) @@ -435,8 +436,8 @@ public interface ProcessSession { * destination processor will have immediate visibility of the transferred * FlowFiles within the session. * - * @param flowFiles - * @param relationship + * @param flowFiles to transfer + * @param relationship to transfer to * @throws IllegalStateException if detected that this method is being * called from within a callback of another method in this session and for * the given FlowFile(s) @@ -455,7 +456,7 @@ public interface ProcessSession { * nothing else references it and this FlowFile will no longer be available * for further operation. * - * @param flowFile + * @param flowFile to remove * @throws IllegalStateException if detected that this method is being * called from within a callback of another method in this session and for * the given FlowFile(s) @@ -471,7 +472,7 @@ public interface ProcessSession { * nothing else references it and this FlowFile will no longer be available * for further operation. * - * @param flowFiles + * @param flowFiles to remove * @throws IllegalStateException if detected that this method is being * called from within a callback of another method in this session and for * the given FlowFile(s) @@ -484,12 +485,12 @@ public interface ProcessSession { /** * Executes the given callback against the contents corresponding to the * given FlowFile. - * - * Note: The OutputStream provided to the given OutputStreamCallback + * + * Note: The OutputStream provided to the given OutputStreamCallback * will not be accessible once this method has completed its execution. * - * @param source - * @param reader + * @param source flowfile to retrieve content of + * @param reader that will be called to read the flowfile content * @throws IllegalStateException if detected that this method is being * called from within a callback of another method in this session and for * the given FlowFile(s) @@ -501,7 +502,7 @@ public interface ProcessSession { * destroyed, and the session is automatically rolled back and what is left * of the FlowFile is destroyed. * @throws FlowFileAccessException if some IO problem occurs accessing - * FlowFile content; if an attempt is made to access the InputStream + * FlowFile content; if an attempt is made to access the InputStream * provided to the given InputStreamCallback after this method completed its * execution */ @@ -511,8 +512,8 @@ public interface ProcessSession { * Combines the content of all given source FlowFiles into a single given * destination FlowFile. * - * @param sources - * @param destination + * @param sources the flowfiles to merge + * @param destination the flowfile to use as the merged result * @return updated destination FlowFile (new size, etc...) * @throws IllegalStateException if detected that this method is being * called from within a callback of another method in this session and for @@ -536,8 +537,8 @@ public interface ProcessSession { * Combines the content of all given source FlowFiles into a single given * destination FlowFile. * - * @param sources - * @param destination + * @param sources to merge together + * @param destination to merge to * @param header bytes that will be added to the beginning of the merged * output. May be null or empty. * @param footer bytes that will be added to the end of the merged output. @@ -566,12 +567,12 @@ public interface ProcessSession { /** * Executes the given callback against the content corresponding to the * given FlowFile. - * - * Note: The OutputStream provided to the given OutputStreamCallback - * will not be accessible once this method has completed its execution. * - * @param source - * @param writer + * Note: The OutputStream provided to the given OutputStreamCallback + * will not be accessible once this method has completed its execution. + * + * @param source to write to + * @param writer used to write new content * @return updated FlowFile * @throws IllegalStateException if detected that this method is being * called from within a callback of another method in this session and for @@ -584,8 +585,8 @@ public interface ProcessSession { * destroyed, and the session is automatically rolled back and what is left * of the FlowFile is destroyed. * @throws FlowFileAccessException if some IO problem occurs accessing - * FlowFile content; if an attempt is made to access the OutputStream - * provided to the given OutputStreamCallaback after this method completed + * FlowFile content; if an attempt is made to access the OutputStream + * provided to the given OutputStreamCallaback after this method completed * its execution */ FlowFile write(FlowFile source, OutputStreamCallback writer) throws FlowFileAccessException; @@ -593,13 +594,13 @@ public interface ProcessSession { /** * Executes the given callback against the content corresponding to the * given flow file. - * - * Note: The InputStream & OutputStream provided to the given - * StreamCallback will not be accessible once this method has completed its - * execution. * - * @param source - * @param writer + * Note: The InputStream & OutputStream provided to the given + * StreamCallback will not be accessible once this method has completed its + * execution. + * + * @param source to read from and write to + * @param writer used to read the old content and write new content * @return updated FlowFile * @throws IllegalStateException if detected that this method is being * called from within a callback of another method in this session and for @@ -612,8 +613,8 @@ public interface ProcessSession { * destroyed, and the session is automatically rolled back and what is left * of the FlowFile is destroyed. * @throws FlowFileAccessException if some IO problem occurs accessing - * FlowFile content; if an attempt is made to access the InputStream or - * OutputStream provided to the given StreamCallback after this method + * FlowFile content; if an attempt is made to access the InputStream or + * OutputStream provided to the given StreamCallback after this method * completed its execution */ FlowFile write(FlowFile source, StreamCallback writer) throws FlowFileAccessException; @@ -622,16 +623,16 @@ public interface ProcessSession { * Executes the given callback against the content corresponding to the * given FlowFile, such that any data written to the OutputStream of the * content will be appended to the end of FlowFile. - * - * Note: The OutputStream provided to the given OutputStreamCallback + * + * Note: The OutputStream provided to the given OutputStreamCallback * will not be accessible once this method has completed its execution. * - * @param source - * @param writer - * @return - * @throws FlowFileAccessException if an attempt is made to access the - * OutputStream provided to the given OutputStreamCallaback after this method - * completed its execution + * @param source the flowfile for which content should be appended + * @param writer used to write new bytes to the flowfile content + * @return the updated flowfile reference for the new content + * @throws FlowFileAccessException if an attempt is made to access the + * OutputStream provided to the given OutputStreamCallaback after this + * method completed its execution */ FlowFile append(FlowFile source, OutputStreamCallback writer) throws FlowFileAccessException; @@ -687,8 +688,8 @@ public interface ProcessSession { /** * Writes the content of the given FlowFile to the given destination path. * - * @param flowFile - * @param destination + * @param flowFile to export the content of + * @param destination to export the content to * @param append if true will append to the current content at the given * path; if false will replace any current content * @throws IllegalStateException if detected that this method is being @@ -709,8 +710,8 @@ public interface ProcessSession { /** * Writes the content of the given FlowFile to the given destination stream * - * @param flowFile - * @param destination + * @param flowFile to export the content of + * @param destination to export the content to * @throws IllegalStateException if detected that this method is being * called from within a callback of another method in this session and for * the given FlowFile(s) @@ -729,7 +730,7 @@ public interface ProcessSession { /** * Returns a ProvenanceReporter that is tied to this ProcessSession. * - * @return + * @return the provenance reporter */ ProvenanceReporter getProvenanceReporter(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/Processor.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/Processor.java index eff5b5958c..53c7c70301 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/Processor.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/Processor.java @@ -46,7 +46,6 @@ import org.apache.nifi.processor.exception.ProcessException; * default no-args constructor to facilitate the java service loader * mechanism.

    * - * @author none */ public interface Processor extends ConfigurableComponent { @@ -54,7 +53,7 @@ public interface Processor extends ConfigurableComponent { * Provides the processor with access to objects that may be of use * throughout the life of the Processor * - * @param context + * @param context of initialization */ void initialize(ProcessorInitializationContext context); diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/ProcessorInitializationContext.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/ProcessorInitializationContext.java index 6e3679c440..7b09e1bafd 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/ProcessorInitializationContext.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/ProcessorInitializationContext.java @@ -29,25 +29,19 @@ import org.apache.nifi.logging.ProcessorLog; public interface ProcessorInitializationContext { /** - * Returns the unique identifier for this processor - * - * @return + * @return the unique identifier for this processor */ String getIdentifier(); /** - * Returns a {@link ProcessorLog} that is tied to this processor that can be + * @return a {@link ProcessorLog} that is tied to this processor that can be * used to log events - * - * @return */ ProcessorLog getLogger(); /** - * Returns the {@link ControllerServiceLookup} which can be used to obtain + * @return the {@link ControllerServiceLookup} which can be used to obtain * Controller Services - * - * @return */ ControllerServiceLookup getControllerServiceLookup(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/QueueSize.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/QueueSize.java index 45d2d3aaca..c3c2ccc488 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/QueueSize.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/QueueSize.java @@ -18,7 +18,6 @@ package org.apache.nifi.processor; /** * - * @author */ public class QueueSize { diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/Relationship.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/Relationship.java index aa19fd01b7..d9f13be8c8 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/Relationship.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/Relationship.java @@ -19,7 +19,6 @@ package org.apache.nifi.processor; /** * An immutable object for holding information about a type of relationship. * - * @author unattributed */ public final class Relationship implements Comparable { diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/CapabilityDescription.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/CapabilityDescription.java index fad1ebb90d..f966f89d28 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/CapabilityDescription.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/CapabilityDescription.java @@ -27,8 +27,8 @@ import java.lang.annotation.Target; * Annotation that may be placed on a processor allowing for a description to be * provided. This description can be provided to a user in logs, UI, etc. * - * @author none - * @deprecated This Annotation has been replaced by the {@link org.apache.nifi.annotation.documentation.CapabilityDescription} + * @deprecated This Annotation has been replaced by the + * {@link org.apache.nifi.annotation.documentation.CapabilityDescription} * annotation. */ @Documented diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/EventDriven.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/EventDriven.java index 615216828f..0f412ca5b2 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/EventDriven.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/EventDriven.java @@ -38,9 +38,8 @@ import java.lang.annotation.Target; * eligible to be scheduled in Event-Driven mode. *

    * - * @author none - * @deprecated This Annotation has been replaced by the {@link org.apache.nifi.annotation.behavior.EventDriven} - * annotation. + * @deprecated This Annotation has been replaced by the + * {@link org.apache.nifi.annotation.behavior.EventDriven} annotation. */ @Documented @Target({ElementType.TYPE}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnAdded.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnAdded.java index b2ea5eb43d..ff0b75fbf8 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnAdded.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnAdded.java @@ -31,8 +31,8 @@ import java.lang.annotation.Target; * If any method annotated with this annotation throws, the processor will not * be added to the graph. * - * @author none - * @deprecated This Annotation has been replaced by the {@link org.apache.nifi.annotation.lifecycle.OnAdded} annotation. + * @deprecated This Annotation has been replaced by the + * {@link org.apache.nifi.annotation.lifecycle.OnAdded} annotation. */ @Documented @Target({ElementType.METHOD}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnRemoved.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnRemoved.java index fae4e34610..740e9f860b 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnRemoved.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnRemoved.java @@ -32,8 +32,8 @@ import java.lang.annotation.Target; * If any method annotated with this annotation throws, the processor will not * be removed from the graph. * - * @author none - * @deprecated This Annotation has been replaced by the {@link org.apache.nifi.annotation.lifecycle.OnRemoved} annotation. + * @deprecated This Annotation has been replaced by the + * {@link org.apache.nifi.annotation.lifecycle.OnRemoved} annotation. */ @Documented @Target({ElementType.METHOD}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnScheduled.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnScheduled.java index ed65ce0459..3815de2f40 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnScheduled.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnScheduled.java @@ -34,9 +34,9 @@ import java.lang.annotation.Target; * If any method annotated with this annotation throws, the processor will not * be scheduled to run. * - * @author none - * @deprecated This Annotation has been replaced by the {@link org.apache.nifi.annotation.lifecycle.OnScheduled} annotation. -*/ + * @deprecated This Annotation has been replaced by the + * {@link org.apache.nifi.annotation.lifecycle.OnScheduled} annotation. + */ @Documented @Target({ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnShutdown.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnShutdown.java index bb38221c28..930a9dffa9 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnShutdown.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnShutdown.java @@ -28,8 +28,8 @@ import java.lang.annotation.Target; * should be called whenever the flow is being shutdown. This will be called at * most once for each processor instance in a process lifetime. * - * @author none - * @deprecated This Annotation has been replaced by the {@link org.apache.nifi.annotation.lifecycle.OnShutdown} annotation. + * @deprecated This Annotation has been replaced by the + * {@link org.apache.nifi.annotation.lifecycle.OnShutdown} annotation. */ @Documented @Target({ElementType.METHOD}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnStopped.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnStopped.java index 3f61850a54..4fbaf95618 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnStopped.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnStopped.java @@ -45,8 +45,8 @@ import java.lang.annotation.Target; * longer scheduled to run, see the {@link OnUnscheduled} annotation. *

    * - * @author none - * @deprecated This Annotation has been replaced by the {@link org.apache.nifi.annotation.lifecycle.OnStopped} annotation. + * @deprecated This Annotation has been replaced by the + * {@link org.apache.nifi.annotation.lifecycle.OnStopped} annotation. */ @Documented @Target({ElementType.METHOD}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnUnscheduled.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnUnscheduled.java index a9b94fc17d..7b4c1f6585 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnUnscheduled.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnUnscheduled.java @@ -36,8 +36,8 @@ import java.lang.annotation.Target; * If any method annotated with this annotation throws, the processor will not * be scheduled to run. * - * @author none - * @deprecated This Annotation has been replaced by the {@link org.apache.nifi.annotation.lifecycle.OnUnscheduled} annotation. + * @deprecated This Annotation has been replaced by the + * {@link org.apache.nifi.annotation.lifecycle.OnUnscheduled} annotation. */ @Documented @Target({ElementType.METHOD}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/SideEffectFree.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/SideEffectFree.java index 281b38d902..6c65caa11a 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/SideEffectFree.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/SideEffectFree.java @@ -35,8 +35,8 @@ import java.lang.annotation.Target; * which could not be rolled back and thus all the processes could be safely * repeated (implied idempotent behavior). * - * @author none - * @deprecated This Annotation has been replaced by the {@link org.apache.nifi.annotation.behavior.SideEffectFree} annotation. + * @deprecated This Annotation has been replaced by the + * {@link org.apache.nifi.annotation.behavior.SideEffectFree} annotation. */ @Documented @Target({ElementType.TYPE}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/SupportsBatching.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/SupportsBatching.java index 2b89e4e9ef..5b3d1aa2f1 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/SupportsBatching.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/SupportsBatching.java @@ -40,8 +40,8 @@ import java.lang.annotation.Target; * ProcessSession.commit() to ensure data is persisted before deleting the data * from a remote source. * - * @author none - * @deprecated This Annotation has been replaced by the {@link org.apache.nifi.annotation.behavior.SupportsBatching} annotation. + * @deprecated This Annotation has been replaced by the + * {@link org.apache.nifi.annotation.behavior.SupportsBatching} annotation. */ @Documented @Target({ElementType.TYPE}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/Tags.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/Tags.java index c06302d52e..81428d7531 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/Tags.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/Tags.java @@ -29,9 +29,8 @@ import java.lang.annotation.Target; * any way but serve as additional documentation and can be used to sort/filter * Processors. * - * @author none - * @deprecated This Annotation has been replaced by the {@link org.apache.nifi.annotation.documentation.Tags} - * annotation. + * @deprecated This Annotation has been replaced by the + * {@link org.apache.nifi.annotation.documentation.Tags} annotation. */ @Documented @Target({ElementType.TYPE}) @@ -40,8 +39,5 @@ import java.lang.annotation.Target; @Deprecated public @interface Tags { - /** - * @return all tag values associated with the given processor - */ public String[] value(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerSerially.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerSerially.java index 0b3d1e6d05..6e80cef48d 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerSerially.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerSerially.java @@ -29,9 +29,9 @@ import java.lang.annotation.Target; * method. By default processors are assumed to be thread safe for concurrent * execution. * - * @author none - * @deprecated This Annotation has been replaced by the {@link org.apache.nifi.annotation.behavior.TriggerSerially} annotation. -*/ + * @deprecated This Annotation has been replaced by the + * {@link org.apache.nifi.annotation.behavior.TriggerSerially} annotation. + */ @Documented @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerWhenAnyDestinationAvailable.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerWhenAnyDestinationAvailable.java index 52f6c5e132..6e01f6c6a0 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerWhenAnyDestinationAvailable.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerWhenAnyDestinationAvailable.java @@ -29,8 +29,9 @@ import java.lang.annotation.Target; * for incoming FlowFiles. By default processors are triggered only when all * destinations report that they have available space. * - * @author none - * @deprecated This Annotation has been replaced by the {@link org.apache.nifi.annotation.behavior.TriggerWhenAnyDestinationAvailable} annotation. + * @deprecated This Annotation has been replaced by the + * {@link org.apache.nifi.annotation.behavior.TriggerWhenAnyDestinationAvailable} + * annotation. */ @Documented @Target({ElementType.TYPE}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerWhenEmpty.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerWhenEmpty.java index 1d2f755f48..d068a9e91d 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerWhenEmpty.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerWhenEmpty.java @@ -31,8 +31,8 @@ import java.lang.annotation.Target; * have non-self incoming edges will only be triggered if they have work in * their queue or they present this annotation. * - * @author none - * @deprecated This Annotation has been replaced by the {@link org.apache.nifi.annotation.behavior.TriggerWhenEmpty} annotation. + * @deprecated This Annotation has been replaced by the + * {@link org.apache.nifi.annotation.behavior.TriggerWhenEmpty} annotation. */ @Documented @Target({ElementType.TYPE}) diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/exception/FlowFileAccessException.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/exception/FlowFileAccessException.java index ac3559c306..c7e9c22197 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/exception/FlowFileAccessException.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/exception/FlowFileAccessException.java @@ -20,7 +20,6 @@ package org.apache.nifi.processor.exception; * Indicates an issue occurred while accessing the content of a FlowFile, such * as an IOException. * - * @author none */ public class FlowFileAccessException extends RuntimeException { diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/exception/FlowFileHandlingException.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/exception/FlowFileHandlingException.java index 82c8873804..d5bf62d257 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/exception/FlowFileHandlingException.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/exception/FlowFileHandlingException.java @@ -22,7 +22,6 @@ package org.apache.nifi.processor.exception; * session. In any event this exception indicates a logic or programming error * within the processor interacting with the offending session. * - * @author none */ public class FlowFileHandlingException extends ProcessException { diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/exception/MissingFlowFileException.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/exception/MissingFlowFileException.java index a198ace799..700afd5f93 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/exception/MissingFlowFileException.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/exception/MissingFlowFileException.java @@ -24,7 +24,6 @@ package org.apache.nifi.processor.exception; * framework and it is not something any processor or the framework can recover * so it must discard the object. * - * @author none */ public class MissingFlowFileException extends RuntimeException { diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/exception/ProcessException.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/exception/ProcessException.java index ca22778f2e..f162b14c10 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/exception/ProcessException.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/exception/ProcessException.java @@ -19,7 +19,6 @@ package org.apache.nifi.processor.exception; /** * Indicates an issue occurred in user code while processing a FlowFile. * - * @author none */ public class ProcessException extends RuntimeException { diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/io/InputStreamCallback.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/io/InputStreamCallback.java index e227156d65..6873f2e2bd 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/io/InputStreamCallback.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/io/InputStreamCallback.java @@ -21,7 +21,6 @@ import java.io.InputStream; /** * - * @author unattributed */ public interface InputStreamCallback { @@ -30,8 +29,8 @@ public interface InputStreamCallback { * automatically opened and closed though it is ok to close the stream * manually. * - * @param in - * @throws IOException + * @param in the stream to read bytes from + * @throws IOException if issues reading from the underlying stream */ void process(InputStream in) throws IOException; diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/io/OutputStreamCallback.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/io/OutputStreamCallback.java index a991a1c7ab..86fe1a733f 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/io/OutputStreamCallback.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/io/OutputStreamCallback.java @@ -21,7 +21,6 @@ import java.io.OutputStream; /** * - * @author unattributed */ public interface OutputStreamCallback { @@ -31,8 +30,8 @@ public interface OutputStreamCallback { * manually - and quite important if any streams wrapping these streams open * resources which should be cleared. * - * @param out - * @throws IOException + * @param out the stream to write bytes to + * @throws IOException if issues writing to output stream */ void process(OutputStream out) throws IOException; diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/io/StreamCallback.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/io/StreamCallback.java index 2d47c8903f..54f0e3bbca 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/processor/io/StreamCallback.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/io/StreamCallback.java @@ -20,10 +20,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -/** - * - * @author unattributed - */ public interface StreamCallback { /** @@ -32,9 +28,9 @@ public interface StreamCallback { * manually - and quite important if any streams wrapping these streams open * resources which should be cleared. * - * @param in - * @param out - * @throws IOException + * @param in the stream to read bytes from + * @param out the stream to write bytes to + * @throws IOException if issues occur reading or writing the underlying streams */ void process(InputStream in, OutputStream out) throws IOException; diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventBuilder.java b/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventBuilder.java index 4978eba533..0ffccd56d4 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventBuilder.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventBuilder.java @@ -28,8 +28,8 @@ public interface ProvenanceEventBuilder { /** * Sets the type of {@link ProvenanceEventRecord} * - * @param eventType - * @return + * @param eventType of the event + * @return the builder */ ProvenanceEventBuilder setEventType(ProvenanceEventType eventType); @@ -38,15 +38,15 @@ public interface ProvenanceEventBuilder { * given event * * @param event the event from which to populate the Builders values - * @return + * @return the builder */ ProvenanceEventBuilder fromEvent(ProvenanceEventRecord event); /** * Sets the date and time at which the FlowFile entered the flow * - * @param entryDate - * @return + * @param entryDate of the flow file + * @return the builder */ ProvenanceEventBuilder setFlowFileEntryDate(long entryDate); @@ -54,8 +54,8 @@ public interface ProvenanceEventBuilder { * Sets the Lineage Identifiers. This is a set of all FlowFile UUID's that * were involved in making this event occur. * - * @param lineageIdentifiers - * @return + * @param lineageIdentifiers of the flowfiles in this event + * @return the builder */ ProvenanceEventBuilder setLineageIdentifiers(Set lineageIdentifiers); @@ -63,12 +63,12 @@ public interface ProvenanceEventBuilder { * Sets the Content Claim that the FlowFile was previously associated with * before this event occurred. * - * @param container - * @param section - * @param identifier - * @param offset - * @param size - * @return + * @param container for previous content + * @param section for previous content + * @param identifier for previous content + * @param offset for previous content + * @param size for previous content + * @return the builder */ ProvenanceEventBuilder setPreviousContentClaim(String container, String section, String identifier, Long offset, long size); @@ -76,12 +76,12 @@ public interface ProvenanceEventBuilder { * Sets the Content Claim that the FlowFile is associated with as a result * of this event * - * @param container - * @param section - * @param identifier - * @param offset - * @param size - * @return + * @param container for resulting content + * @param section for resulting content + * @param identifier for resulting content + * @param offset for resulting content + * @param size for resulting content + * @return the builder */ ProvenanceEventBuilder setCurrentContentClaim(String container, String section, String identifier, Long offset, long size); @@ -89,8 +89,8 @@ public interface ProvenanceEventBuilder { * Sets the identifier of the FlowFile Queue from which the FlowFile was * pulled * - * @param identifier - * @return + * @param identifier of the source queue + * @return the builder */ ProvenanceEventBuilder setSourceQueueIdentifier(String identifier); @@ -99,28 +99,28 @@ public interface ProvenanceEventBuilder { * occurred and any attributes that were added or updated as a result of * this event. * - * @param previousAttributes + * @param previousAttributes Map of all attributes before the event occurred * @param updatedAttributes Map containing all attributes that were added or * updated. If any entry has a value of null, that attribute is * considered removed * - * @return + * @return the builder */ ProvenanceEventBuilder setAttributes(Map previousAttributes, Map updatedAttributes); /** * Sets the UUID to associate with the FlowFile * - * @param uuid - * @return + * @param uuid of the flowfile + * @return the builder */ ProvenanceEventBuilder setFlowFileUUID(String uuid); /** * Sets the time at which the Provenance Event took place * - * @param eventTime - * @return + * @param eventTime time of the event + * @return the builder */ ProvenanceEventBuilder setEventTime(long eventTime); @@ -128,16 +128,16 @@ public interface ProvenanceEventBuilder { * Sets the amount of time that was required in order to perform the * function referred to by this event * - * @param millis - * @return + * @param millis of the event + * @return the builder */ ProvenanceEventBuilder setEventDuration(long millis); /** * Sets the time at which the FlowFile's lineage began * - * @param startDate - * @return + * @param startDate start date of the event + * @return the builder */ ProvenanceEventBuilder setLineageStartDate(long startDate); @@ -145,8 +145,8 @@ public interface ProvenanceEventBuilder { * Sets the unique identifier of the NiFi Component (such as a * {@link Processor}) that is generating the Event * - * @param componentId - * @return + * @param componentId that produced the event + * @return the builder */ ProvenanceEventBuilder setComponentId(String componentId); @@ -154,8 +154,8 @@ public interface ProvenanceEventBuilder { * Sets the type of the Component that is generating the Event. For * {@link Processor}s, this is the Simple Class Name of the Processor. * - * @param componentType - * @return + * @param componentType of the component that made the event + * @return the builder */ ProvenanceEventBuilder setComponentType(String componentType); @@ -167,8 +167,8 @@ public interface ProvenanceEventBuilder { * and {@link ProvenanceEventType#SEND} and will be ignored for any other * event types. * - * @param sourceSystemFlowFileIdentifier - * @return + * @param sourceSystemFlowFileIdentifier identifier the remote system used + * @return the builder */ ProvenanceEventBuilder setSourceSystemFlowFileIdentifier(String sourceSystemFlowFileIdentifier); @@ -184,8 +184,8 @@ public interface ProvenanceEventBuilder { * and {@link ProvenanceEventType#SEND} and will be ignored for any other * event types. * - * @param transitUri - * @return + * @param transitUri of the event + * @return the builder */ ProvenanceEventBuilder setTransitUri(String transitUri); @@ -194,13 +194,13 @@ public interface ProvenanceEventBuilder { * {@link ProvenanceEventType#FORK}, {@link ProvenanceEventType#JOIN}, and * {@link ProvenanceEventType#CLONE} * - * This is valid only for null null null null null {@link ProvenanceEventType#SPAWN}, + * This is valid only for {@link ProvenanceEventType#SPAWN}, * {@link ProvenanceEventType#FORK}, {@link ProvenanceEventType#JOIN}, and * {@link ProvenanceEventType#CLONE} events and will be ignored for any * other event types. * - * @param parent - * @return + * @param parent flowfile that this event is derived from + * @return the builder */ ProvenanceEventBuilder addParentFlowFile(FlowFile parent); @@ -209,13 +209,13 @@ public interface ProvenanceEventBuilder { * {@link ProvenanceEventType#FORK}, {@link ProvenanceEventType#JOIN}, and * {@link ProvenanceEventType#CLONE} * - * This is valid only for null null null null null {@link ProvenanceEventType#SPAWN}, + * This is valid only for {@link ProvenanceEventType#SPAWN}, * {@link ProvenanceEventType#FORK}, {@link ProvenanceEventType#JOIN}, and * {@link ProvenanceEventType#CLONE} events and will be ignored for any * other event types. * - * @param parent - * @return + * @param parent previous parent of this event + * @return the builder */ ProvenanceEventBuilder removeParentFlowFile(FlowFile parent); @@ -224,13 +224,13 @@ public interface ProvenanceEventBuilder { * {@link ProvenanceEventType#FORK}, {@link ProvenanceEventType#JOIN}, and * {@link ProvenanceEventType#CLONE} * - * This is valid only for null null null null null {@link ProvenanceEventType#SPAWN}, + * This is valid only for {@link ProvenanceEventType#SPAWN}, * {@link ProvenanceEventType#FORK}, {@link ProvenanceEventType#JOIN}, and * {@link ProvenanceEventType#CLONE} events and will be ignored for any * other event types. * - * @param child - * @return + * @param child the child to add + * @return the builder */ ProvenanceEventBuilder addChildFlowFile(FlowFile child); @@ -239,13 +239,13 @@ public interface ProvenanceEventBuilder { * {@link ProvenanceEventType#FORK}, {@link ProvenanceEventType#JOIN}, and * {@link ProvenanceEventType#CLONE} * - * This is valid only for null null null null null {@link ProvenanceEventType#SPAWN}, + * This is valid only for {@link ProvenanceEventType#SPAWN}, * {@link ProvenanceEventType#FORK}, {@link ProvenanceEventType#JOIN}, and * {@link ProvenanceEventType#CLONE} events and will be ignored for any * other event types. * - * @param child - * @return + * @param child to remove + * @return the builder */ ProvenanceEventBuilder removeChildFlowFile(FlowFile child); @@ -259,8 +259,8 @@ public interface ProvenanceEventBuilder { * This is valid only for {@link ProvenanceEventType#ADDINFO} events and * will be ignored for any other event types. * - * @param alternateIdentifierUri - * @return + * @param alternateIdentifierUri another identifier of the flowfile this event is for + * @return the builder */ ProvenanceEventBuilder setAlternateIdentifierUri(String alternateIdentifierUri); @@ -268,8 +268,8 @@ public interface ProvenanceEventBuilder { * Sets the details for this event. This is a free-form String that can * contain any information that is relevant to this event. * - * @param details - * @return + * @param details a description of the event + * @return the builder */ ProvenanceEventBuilder setDetails(String details); @@ -279,8 +279,8 @@ public interface ProvenanceEventBuilder { * {@link ProvenanceEventType#ROUTE} events and will be ignored for any * other event types. * - * @param relationship - * @return + * @param relationship to which flowfiles in this event were routed + * @return the builder */ ProvenanceEventBuilder setRelationship(Relationship relationship); @@ -288,8 +288,8 @@ public interface ProvenanceEventBuilder { * Populates the builder with as much information as it can from the given * FlowFile * - * @param flowFile - * @return + * @param flowFile to source attributes for this event from + * @return the builder */ ProvenanceEventBuilder fromFlowFile(FlowFile flowFile); @@ -301,7 +301,7 @@ public interface ProvenanceEventBuilder { * depend on the {@link ProvevenanceEventRepository} to generate the unique * identifier. * - * @return + * @return the event */ ProvenanceEventRecord build(); diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRecord.java b/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRecord.java index 4b1b1a00c1..dc251b3f17 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRecord.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRecord.java @@ -26,26 +26,20 @@ import java.util.Set; public interface ProvenanceEventRecord { /** - * Returns a unique ID for this Provenance Event. Depending on the + * @return a unique ID for this Provenance Event. Depending on the * implementation, the Event ID may be set to -1 until the event has been * added to the {@link ProvenanceEventRepository} - * - * @return */ long getEventId(); /** - * Returns the time at which this Provenance Event was created, as the + * @return the time at which this Provenance Event was created, as the * number of milliseconds since epoch - * - * @return */ long getEventTime(); /** - * Returns the EntryDate of the FlowFile to which this Event is associated - * - * @return + * @return the EntryDate of the FlowFile to which this Event is associated */ long getFlowFileEntryDate(); @@ -61,236 +55,181 @@ public interface ProvenanceEventRecord { Set getLineageIdentifiers(); /** - * Returns the size of the FlowFile to which this Event is associated - * - * @return + * @return the size of the FlowFile to which this Event is associated */ long getFileSize(); /** - * Returns the previous size of the FlowFile to which this Event is + * @return the previous size of the FlowFile to which this Event is * associated, if the FlowFile previously had content and its size was * known; otherwise, returns null - * - * @return */ Long getPreviousFileSize(); /** - * Returns the amount of time in milliseconds that elapsed while performing - * this event. If not populated, the value -1 will be returned. - * - * @return + * @return the amount of time in milliseconds that elapsed while performing + * this event. If not populated, the value -1 will be returned */ long getEventDuration(); /** - * Returns the type of this Provenance Event - * - * @return + * @return the type of this Provenance Event */ ProvenanceEventType getEventType(); /** - * Returns all FlowFile attributes that were associated with the FlowFile at + * @return all FlowFile attributes that were associated with the FlowFile at * the time that this ProvenanceEvent was created - * - * @return */ Map getAttributes(); /** - * Returns all FlowFile attributes that existed on the FlowFile before this + * @return all FlowFile attributes that existed on the FlowFile before this * event occurred - * - * @return */ Map getPreviousAttributes(); /** - * Returns all FlowFile attributes that were updated as a result of this + * @return all FlowFile attributes that were updated as a result of this * event - * - * @return */ Map getUpdatedAttributes(); /** - * Returns the ID of the Processor/component that created this Provenance + * @return the ID of the Processor/component that created this Provenance * Event - * - * @return */ String getComponentId(); /** - * Returns the fully-qualified Class Name of the Processor/component that + * @return the fully-qualified Class Name of the Processor/component that * created this Provenance Event - * - * @return */ String getComponentType(); /** - * Returns a URI that provides information about the System and Protocol + * @return a URI that provides information about the System and Protocol * information over which the transfer occurred. The intent of this field is * such that both the sender and the receiver can publish the events to an * external Enterprise-wide system that is then able to correlate the SEND * and RECEIVE events. - * - * @return */ String getTransitUri(); /** - * Returns the UUID that the Source System used to refer to this data; this - * is applicable only when the {@link ProvenanceEventType} is of type - * {@link ProvenanceEventType#RECEIVE RECEIVE}. - * * Since the receiving system will usually refer to the data using a * different identifier than the source system, this information is used to * correlate the receive system's FlowFile with the sending system's data * - * @return + * @return the UUID that the Source System used to refer to this data; this + * is applicable only when the {@link ProvenanceEventType} is of type + * {@link ProvenanceEventType#RECEIVE RECEIVE} */ String getSourceSystemFlowFileIdentifier(); /** - * Returns the UUID of the FlowFile with which this Event is associated - * - * @return + * @return the UUID of the FlowFile with which this Event is associated */ String getFlowFileUuid(); /** - * Returns the UUID's of all Parent FlowFiles. This is applicable only when + * @return the UUID's of all Parent FlowFiles. This is applicable only when * the {@link ProvenanceEventType} is of type - * {@link ProvenanceEventType#SPAWN SPAWN}. - * - * @return + * {@link ProvenanceEventType#SPAWN SPAWN} */ List getParentUuids(); /** - * Returns the UUID's of all Child FlowFiles. This is applicable only when + * @return the UUID's of all Child FlowFiles. This is applicable only when * the {@link ProvenanceEventType} is of type - * {@link ProvenanceEventType#SPAWN SPAWN}. - * - * @return + * {@link ProvenanceEventType#SPAWN SPAWN} */ List getChildUuids(); /** - * Returns the Alternate Identifier associated with the FlowFile with which + * @return the Alternate Identifier associated with the FlowFile with which * this Event is associated. This is applicable only when the * {@link ProvenanceEventType} is of type - * {@link ProvenanceEventType#ADDINFO}. - * - * @return + * {@link ProvenanceEventType#ADDINFO} */ String getAlternateIdentifierUri(); /** - * Returns the details for this record, if any were supplied. Otherwise, + * @return the details for this record, if any were supplied. Otherwise, * returns null - * - * @return - * */ String getDetails(); /** - * Returns the relationship to which this record was routed if the event + * @return the relationship to which this record was routed if the event * type is {@link ProvenanceEventType#ROUTE}. The relationship is applicable - * only to this type. - * - * @return - * + * only to this type */ String getRelationship(); /** - * Returns the identifier of the queue from which the FlowFile was taken, if + * @return the identifier of the queue from which the FlowFile was taken, if * any. If the FlowFile is created as a result of this event (in this case, - * the Event Type is one of null null null null null {@link ProvenanceEventType#CREATE}, {@link ProvenanceEventType#RECEIVE}, + * the Event Type is one of null null null null null null null null {@link ProvenanceEventType#CREATE}, {@link ProvenanceEventType#RECEIVE}, * {@link ProvenanceEventType#FORK}, {@link ProvenanceEventType#JOIN}, or * {@link ProvenanceEventType#CLONE}), or if the queue identifier is - * unknown, then this method will return null. - * - * @return + * unknown, then this method will return null * */ String getSourceQueueIdentifier(); /** - * Returns the Section for the Content Claim that this Event refers to, if + * @return the Section for the Content Claim that this Event refers to, if * any; otherwise, returns null * - * @return - * */ String getContentClaimSection(); /** - * Returns the Section for the Content Claim that the FlowFile previously + * @return the Section for the Content Claim that the FlowFile previously * referenced, if any; otherwise, returns null * - * @return - * */ String getPreviousContentClaimSection(); /** - * Returns the Container for the Content Claim that this Event refers to, if + * @return the Container for the Content Claim that this Event refers to, if * any; otherwise, returns null * - * @return - * */ String getContentClaimContainer(); /** - * Returns the Container for the Content Claim that the FlowFile previously + * @return the Container for the Content Claim that the FlowFile previously * referenced, if any; otherwise, returns null - * - * @return - * */ String getPreviousContentClaimContainer(); /** - * Returns the Identifier for the Content Claim that this Event refers to, + * @return the Identifier for the Content Claim that this Event refers to, * if any; otherwise, returns null * - * @return - * */ String getContentClaimIdentifier(); /** - * Returns the Identifier for the Content Claim that the FlowFile previously + * @return the Identifier for the Content Claim that the FlowFile previously * referenced, if any; otherwise, returns null * - * @return - * */ String getPreviousContentClaimIdentifier(); /** - * Returns the offset into the Content Claim at which the FlowFile's content + * @return the offset into the Content Claim at which the FlowFile's content * begins, if any; otherwise, returns null * - * @return - * */ Long getContentClaimOffset(); /** - * Returns the offset into the Content Claim at which the FlowFile's + * @return the offset into the Content Claim at which the FlowFile's * previous content began, if any; otherwise, returns null * - * @return - * */ Long getPreviousContentClaimOffset(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRepository.java b/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRepository.java index 39c829e8d1..25563b7769 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRepository.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRepository.java @@ -36,8 +36,9 @@ public interface ProvenanceEventRepository { /** * Performs any initialization needed. This should be called only by the * framework. - * @param eventReporter - * @throws java.io.IOException + * + * @param eventReporter to report to + * @throws java.io.IOException if unable to initialize */ void initialize(EventReporter eventReporter) throws IOException; @@ -45,7 +46,7 @@ public interface ProvenanceEventRepository { * Returns a {@link ProvenanceEventBuilder} that is capable of building * {@link ProvenanceEventRecord}s * - * @return + * @return builder */ ProvenanceEventBuilder eventBuilder(); @@ -54,7 +55,7 @@ public interface ProvenanceEventRepository { * the event id has been populated. Depending on the implementation, the * returned event may or may not be the same event given * - * @param event + * @param event to register */ void registerEvent(ProvenanceEventRecord event); @@ -66,7 +67,7 @@ public interface ProvenanceEventRepository { * of the Collection are atomic. This detail is implementation-specific. *

    * - * @param events + * @param events to register */ void registerEvents(Iterable events); @@ -75,18 +76,16 @@ public interface ProvenanceEventRepository { * repository starting with the given ID. The first ID in the repository * will always be 0 or higher. * - * @param firstRecordId - * @param maxRecords - * @return - * @throws java.io.IOException + * @param firstRecordId id of the first record to retrieve + * @param maxRecords maximum number of records to retrieve + * @return records + * @throws java.io.IOException if error reading from repository */ List getEvents(long firstRecordId, final int maxRecords) throws IOException; /** - * Returns the largest ID of any event that is queryable in the repository. + * @return the largest ID of any event that is queryable in the repository. * If no queryable events exists, returns null - * - * @return */ Long getMaxEventId(); @@ -94,19 +93,18 @@ public interface ProvenanceEventRepository { * Submits an asynchronous request to process the given query, returning an * identifier that can be used to fetch the results at a later time * - * @param query - * @return + * @param query to submit + * @return an identifier that can be used to fetch the results at a later + * time */ QuerySubmission submitQuery(Query query); /** - * Returns the QueryResult associated with the given identifier, if the + * @param queryIdentifier of the query + * + * @return the QueryResult associated with the given identifier, if the * query has finished processing. If the query has not yet finished running, - * returns null. - * - * @param queryIdentifier - * - * @return + * returns null */ QuerySubmission retrieveQuerySubmission(String queryIdentifier); @@ -123,21 +121,17 @@ public interface ProvenanceEventRepository { ComputeLineageSubmission submitLineageComputation(String flowFileUuid); /** - * Returns the {@link ComputeLineageSubmission} associated with the given + * @param lineageIdentifier identifier of lineage to compute + * @return the {@link ComputeLineageSubmission} associated with the given * identifier - * - * @param lineageIdentifier - * @return */ ComputeLineageSubmission retrieveLineageSubmission(String lineageIdentifier); /** - * Returns the Provenance Event Record with the given ID, if it exists, or + * @param id to lookup + * @return the Provenance Event Record with the given ID, if it exists, or * {@code null} otherwise - * - * @param id - * @return - * @throws IOException + * @throws IOException if failure while retrieving event */ ProvenanceEventRecord getEvent(long id) throws IOException; @@ -145,7 +139,7 @@ public interface ProvenanceEventRepository { * Submits a request to expand the parents of the event with the given id * * @param eventId the one-up id of the Event to expand - * @return + * @return a submission which can be checked for status * * @throws IllegalArgumentException if the given identifier identifies a * Provenance Event that has a Type that is not expandable or if the @@ -157,7 +151,7 @@ public interface ProvenanceEventRepository { * Submits a request to expand the children of the event with the given id * * @param eventId the one-up id of the Event - * @return + * @return a submission which can be checked for status * * @throws IllegalArgumentException if the given identifier identifies a * Provenance Event that has a Type that is not expandable or if the @@ -168,23 +162,19 @@ public interface ProvenanceEventRepository { /** * Closes the repository, freeing any resources * - * @throws IOException + * @throws IOException if failure closing repository */ void close() throws IOException; /** - * Returns a list of all fields that can be searched via the + * @return a list of all fields that can be searched via the * {@link #submitQuery(nifi.provenance.search.Query)} method - * - * @return */ List getSearchableFields(); /** - * Returns a list of all FlowFile attributes that can be searched via the + * @return a list of all FlowFile attributes that can be searched via the * {@link #submitQuery(nifi.provenance.search.Query)} method - * - * @return */ List getSearchableAttributes(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageResult.java b/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageResult.java index c2d55132ab..e754ff7d1a 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageResult.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageResult.java @@ -25,46 +25,34 @@ import java.util.List; public interface ComputeLineageResult { /** - * Returns all nodes for the graph - * - * @return + * @return all nodes for the graph */ public List getNodes(); /** - * Returns all links for the graph - * - * @return + * @return all links for the graph */ public List getEdges(); /** - * Returns the date at which this AsynchronousLineageResult will expire - * - * @return + * @return the date at which this AsynchronousLineageResult will expire */ Date getExpiration(); /** - * If an error occurred while computing the lineage, this will return the - * serialized error; otherwise, returns null. - * - * @return + * @return If an error occurred while computing the lineage, this will return the + * serialized error; otherwise, returns null */ String getError(); /** - * returns an integer between 0 and 100 (inclusive) that indicates what + * @return an integer between 0 and 100 (inclusive) that indicates what * percentage of completion the computation has reached - * - * @return */ int getPercentComplete(); /** - * Indicates whether or not the lineage has finished running - * - * @return + * @return Indicates whether or not the lineage has finished running */ boolean isFinished(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageSubmission.java b/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageSubmission.java index fbbff105e3..a9df26cea1 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageSubmission.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageSubmission.java @@ -22,25 +22,19 @@ import java.util.Date; public interface ComputeLineageSubmission { /** - * Returns the {@link ComputeLineageResult} that contains the results. The + * @return the {@link ComputeLineageResult} that contains the results. The * results may be partial if a call to - * {@link ComputeLineageResult#isFinished()} returns false. - * - * @return + * {@link ComputeLineageResult#isFinished()} returns false */ ComputeLineageResult getResult(); /** - * Returns the date at which this lineage was submitted - * - * @return + * @return the date at which this lineage was submitted */ Date getSubmissionTime(); /** - * Returns the generated identifier for this lineage result - * - * @return + * @return the generated identifier for this lineage result */ String getLineageIdentifier(); @@ -56,27 +50,21 @@ public interface ComputeLineageSubmission { boolean isCanceled(); /** - * Returns the type of Lineage Computation that was submitted - * - * @return + * @return the type of Lineage Computation that was submitted */ LineageComputationType getLineageComputationType(); /** - * If the Lineage Computation Type of this submission is + * @return If the Lineage Computation Type of this submission is * {@link LineageComputationType.EXPAND_CHILDREN} or * {@link LineageComputationType.EXPAND_PARENTS}, indicates the ID event - * that is to be expanded; otherwise, returns null. - * - * @return + * that is to be expanded; otherwise, returns null */ Long getExpandedEventId(); /** - * Returns all FlowFile UUID's that are encapsulated in this lineage + * @return all FlowFile UUID's that are encapsulated in this lineage * computation submission - * - * @return */ Collection getLineageFlowFileUuids(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/Lineage.java b/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/Lineage.java index 252968c0e8..ff5fee7c44 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/Lineage.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/Lineage.java @@ -25,16 +25,12 @@ import java.util.List; public interface Lineage { /** - * Returns all nodes for the graph - * - * @return + * @return all nodes for the graph */ public List getNodes(); /** - * Returns all links for the graph - * - * @return + * @return all links for the graph */ public List getEdges(); diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/LineageNode.java b/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/LineageNode.java index 84e3546e39..c50cdf5840 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/LineageNode.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/LineageNode.java @@ -19,43 +19,33 @@ package org.apache.nifi.provenance.lineage; public interface LineageNode { /** - * Returns the identifier of the Clustered NiFi Node that generated the + * @return the identifier of the Clustered NiFi Node that generated the * event - * - * @return */ String getClusterNodeIdentifier(); /** - * Returns the type of the LineageNode - * - * @return + * @return the type of the LineageNode */ LineageNodeType getNodeType(); /** - * Returns the UUID of the FlowFile for which this Node was created - * - * @return + * @return the UUID of the FlowFile for which this Node was created */ String getFlowFileUuid(); /** - * Returns the UUID for this LineageNode. - * - * @return + * @return the UUID for this LineageNode */ String getIdentifier(); /** - * Returns the timestamp that corresponds to this Node. The meaning of the + * @return the timestamp that corresponds to this Node. The meaning of the * timestamp may differ between implementations. For example, a * {@link ProvenanceEventLineageNode}'s timestamp indicates the time at * which the event occurred. However, for a Node that reperesents a * FlowFile, for example, the timestamp may represent the time at which the - * FlowFile was created. - * - * @return + * FlowFile was created */ long getTimestamp(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/search/Query.java b/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/search/Query.java index a319e36465..3519c1468a 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/search/Query.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/search/Query.java @@ -16,7 +16,12 @@ */ package org.apache.nifi.provenance.search; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Objects; + public class Query { diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/search/QueryResult.java b/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/search/QueryResult.java index 3dd0b71297..0079433ec5 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/search/QueryResult.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/search/QueryResult.java @@ -24,54 +24,40 @@ import org.apache.nifi.provenance.ProvenanceEventRecord; public interface QueryResult { /** - * Returns the Provenance events that match the query (up to the limit + * @return the Provenance events that match the query (up to the limit * specified in the query) - * - * @return */ List getMatchingEvents(); /** - * Returns the total number of Provenance Events that hit - * - * @return + * @return the total number of Provenance Events that hit */ long getTotalHitCount(); /** - * Returns the number of milliseconds the query took to run - * - * @return + * @return the number of milliseconds the query took to run */ long getQueryTime(); /** - * Returns the date at which this QueryResult will expire - * - * @return + * @return the date at which this QueryResult will expire */ Date getExpiration(); /** - * If an error occurred while computing the lineage, this will return the - * serialized error; otherwise, returns null. - * - * @return + * @return If an error occurred while computing the lineage, this will return the + * serialized error; otherwise, returns null */ String getError(); /** - * returns an integer between 0 and 100 (inclusive) that indicates what + * @return an integer between 0 and 100 (inclusive) that indicates what * percentage of completion the query has reached - * - * @return */ int getPercentComplete(); /** - * Indicates whether or not the query has finished running - * - * @return + * @return Indicates whether or not the query has finished running */ boolean isFinished(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/search/QuerySubmission.java b/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/search/QuerySubmission.java index 6c3e1ad81f..4716d2d4e2 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/search/QuerySubmission.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/search/QuerySubmission.java @@ -21,32 +21,24 @@ import java.util.Date; public interface QuerySubmission { /** - * Returns the query that this submission pertains to - * - * @return + * @return the query that this submission pertains to */ Query getQuery(); /** - * Returns the {@link QueryResult} for this query. Note that the result is + * @return the {@link QueryResult} for this query. Note that the result is * only a partial result if the result of calling - * {@link QueryResult#isFinished()} is false. - * - * @return + * {@link QueryResult#isFinished()} is false */ QueryResult getResult(); /** - * Returns the date at which this query was submitted - * - * @return + * @return the date at which this query was submitted */ Date getSubmissionTime(); /** - * Returns the generated identifier for this query result - * - * @return + * @return the generated identifier for this query result */ String getQueryIdentifier(); diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/search/SearchableField.java b/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/search/SearchableField.java index fa3bfe33db..85c6154892 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/search/SearchableField.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/provenance/search/SearchableField.java @@ -23,40 +23,30 @@ package org.apache.nifi.provenance.search; public interface SearchableField { /** - * Returns the identifier that is used to refer to this field - * - * @return + * @return the identifier that is used to refer to this field */ String getIdentifier(); /** - * Returns the name of the field that is used when searching the repository. - * - * @return + * @return the name of the field that is used when searching the repository */ String getSearchableFieldName(); /** - * Returns the "friendly" name or "display name" of the field, which may be + * @return the "friendly" name or "display name" of the field, which may be * more human-readable than the searchable field name - * - * @return */ String getFriendlyName(); /** - * Returns the type of the data stored in this field - * - * @return + * @return the type of the data stored in this field */ SearchableFieldType getFieldType(); /** - * Returns true if this field represents a FlowFile attribute, + * @return true if this field represents a FlowFile attribute, * false if the field represents a Provenance Event detail, * such as Source System URI - * - * @return */ boolean isAttribute(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/remote/RemoteDestination.java b/nifi/nifi-api/src/main/java/org/apache/nifi/remote/RemoteDestination.java index 508ab37d40..c3a34b234e 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/remote/RemoteDestination.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/remote/RemoteDestination.java @@ -18,36 +18,33 @@ package org.apache.nifi.remote; import java.util.concurrent.TimeUnit; - /** - * A model object for referring to a remote destination (i.e., a Port) for site-to-site communications + * A model object for referring to a remote destination (i.e., a Port) for + * site-to-site communications */ public interface RemoteDestination { + /** - * Returns the identifier of the remote destination - * - * @return + * @return the identifier of the remote destination */ - String getIdentifier(); + String getIdentifier(); - /** - * Returns the human-readable name of the remote destination - * @return - */ - String getName(); + /** + * @return the human-readable name of the remote destination + */ + String getName(); - /** - * Returns the amount of time that system should pause sending to a particular node if unable to - * send data to or receive data from this endpoint - * @param timeUnit - * @return - */ - long getYieldPeriod(TimeUnit timeUnit); - - /** - * Returns whether or not compression should be used when transferring data to or receiving - * data from the remote endpoint - * @return - */ - boolean isUseCompression(); + /** + * @param timeUnit to yield + * @return the amount of time that system should pause sending to a + * particular node if unable to send data to or receive data from this + * endpoint + */ + long getYieldPeriod(TimeUnit timeUnit); + + /** + * @return whether or not compression should be used when transferring data + * to or receiving data from the remote endpoint + */ + boolean isUseCompression(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/AbstractReportingTask.java b/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/AbstractReportingTask.java index efcf2a3637..b5afe17a9f 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/AbstractReportingTask.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/AbstractReportingTask.java @@ -43,19 +43,15 @@ public abstract class AbstractReportingTask extends AbstractConfigurableComponen } /** - * Returns the {@link ControllerServiceLookup} that was passed to the + * @return the {@link ControllerServiceLookup} that was passed to the * {@link #init(ProcessorInitializationContext)} method - * - * @return */ protected final ControllerServiceLookup getControllerServiceLookup() { return serviceLookup; } /** - * Returns the identifier of this Reporting Task - * - * @return + * @return the identifier of this Reporting Task */ @Override public String getIdentifier() { @@ -63,22 +59,18 @@ public abstract class AbstractReportingTask extends AbstractConfigurableComponen } /** - * Returns the name of this Reporting Task - * - * @return + * @return the name of this Reporting Task */ protected String getName() { return name; } /** - * Returns the amount of times that elapses between the moment that this + * @param timeUnit of scheduling period + * @return the amount of times that elapses between the moment that this * ReportingTask finishes its invocation of * {@link #onTrigger(ReportingContext)} and the next time that * {@link #onTrigger(ReportingContext)} is called. - * - * @param timeUnit - * @return */ protected long getSchedulingPeriod(final TimeUnit timeUnit) { return timeUnit.convert(schedulingNanos, TimeUnit.NANOSECONDS); @@ -88,15 +80,15 @@ public abstract class AbstractReportingTask extends AbstractConfigurableComponen * Provides a mechanism by which subclasses can perform initialization of * the Reporting Task before it is scheduled to be run * - * @param config - * @throws InitializationException + * @param config context + * @throws InitializationException if failure to init */ protected void init(final ReportingInitializationContext config) throws InitializationException { } /** - * Returns the logger that has been provided to the component by the framework in its initialize method. - * @return + * @return the logger that has been provided to the component by the + * framework in its initialize method */ protected ComponentLog getLogger() { return logger; diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/BulletinRepository.java b/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/BulletinRepository.java index 4d32d40e66..2679099211 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/BulletinRepository.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/BulletinRepository.java @@ -28,61 +28,55 @@ public interface BulletinRepository { /** * Adds a Bulletin to the repository. * - * @param bulletin + * @param bulletin to add */ void addBulletin(Bulletin bulletin); /** - * Returns the capacity for the number of bulletins for the controller. - * - * @return + * @return the capacity for the number of bulletins for the controller */ int getControllerBulletinCapacity(); /** - * Returns the capacity for the number of bulletins per component. - * - * @return + * @return the capacity for the number of bulletins per component */ int getComponentBulletinCapacity(); /** * Finds Bulletin's that meet the specified query. * - * @param bulletinQuery - * @return + * @param bulletinQuery indicates which bulletins are of interest + * @return bulletins that met the query */ List findBulletins(BulletinQuery bulletinQuery); /** * Finds all bulletins for the specified group. * - * @param groupId - * @return + * @param groupId id of the group + * @return bulletins for the given group */ List findBulletinsForGroupBySource(String groupId); /** * Finds all bulletins for the specified group. * - * @param groupId - * @param maxPerComponent - * @return + * @param groupId id of the group + * @param maxPerComponent max responses wanted + * @return bulletins found */ List findBulletinsForGroupBySource(String groupId, int maxPerComponent); /** - * Finds all bulletins for the controller; - * - * @return + * @return all bulletins for the controller */ List findBulletinsForController(); /** * Finds all bulletins for the controller; * - * @param max - * @return + * @param max limits the number of responses + * @return all bulletins for the controller */ List findBulletinsForController(int max); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/EventAccess.java b/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/EventAccess.java index f043efd3ca..bdc23c2635 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/EventAccess.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/EventAccess.java @@ -26,9 +26,7 @@ import java.util.List; public interface EventAccess { /** - * Gets the status for all components in this Controller. - * - * @return + * @return the status for all components in this Controller */ ProcessGroupStatus getControllerStatus(); @@ -39,15 +37,13 @@ public interface EventAccess { * * @param firstEventId the ID of the first event to obtain * @param maxRecords the maximum number of records to obtain - * @return - * @throws java.io.IOException + * @return event records matching query + * @throws java.io.IOException if unable to get records */ List getProvenanceEvents(long firstEventId, final int maxRecords) throws IOException; /** - * Returns the Provenance Event Repository - * - * @return + * @return the Provenance Event Repository */ ProvenanceEventRepository getProvenanceRepository(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/ReportingContext.java b/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/ReportingContext.java index ad4090c7cb..281194c7b5 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/ReportingContext.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/ReportingContext.java @@ -31,37 +31,29 @@ import org.apache.nifi.controller.ControllerServiceLookup; public interface ReportingContext { /** - * Returns a Map of all known {@link PropertyDescriptor}s to their + * @return a Map of all known {@link PropertyDescriptor}s to their * configured properties. This Map will contain a null for any * Property that has not been configured by the user, even if the - * PropertyDescriptor has a default value. - * - * @return + * PropertyDescriptor has a default value */ Map getProperties(); /** - * A PropertyValue that represents the user-configured value for the given - * {@link PropertyDescriptor}. - * - * @param propertyName - * @return + * @param propertyName descriptor of property to lookup the value of + * @return PropertyValue that represents the user-configured value for the given + * {@link PropertyDescriptor} */ PropertyValue getProperty(PropertyDescriptor propertyName); /** - * Returns the {@link EventAccess} object that can be used to obtain + * @return the {@link EventAccess} object that can be used to obtain * information about specific events and reports that have happened - * - * @return */ EventAccess getEventAccess(); /** - * Returns the {@link BulletinRepository} that can be used to analyze + * @return the {@link BulletinRepository} that can be used to analyze * Bulletins that have been emitted and register new Bulletins - * - * @return */ BulletinRepository getBulletinRepository(); @@ -70,10 +62,10 @@ public interface ReportingContext { * level, and message, so that the Bulletin can be added to the * {@link BulletinRepository}. * - * @param category - * @param severity - * @param message - * @return + * @param category of bulletin + * @param severity of bulletin + * @param message of bulletin + * @return new bulletin */ Bulletin createBulletin(String category, Severity severity, String message); @@ -85,15 +77,13 @@ public interface ReportingContext { * @param category the name of the bulletin's category * @param severity the severity level of the bulletin * @param message the bulletin's message - * @return + * @return new bulletin */ Bulletin createBulletin(String componentId, String category, Severity severity, String message); /** - * Returns the {@link ControllerServiceLookup} which can be used to obtain + * @return the {@link ControllerServiceLookup} which can be used to obtain * Controller Services - * - * @return */ ControllerServiceLookup getControllerServiceLookup(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/ReportingInitializationContext.java b/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/ReportingInitializationContext.java index 6b84589d75..d014b26023 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/ReportingInitializationContext.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/ReportingInitializationContext.java @@ -29,16 +29,12 @@ import org.apache.nifi.scheduling.SchedulingStrategy; public interface ReportingInitializationContext { /** - * Returns the identifier for this ReportingTask - * - * @return + * @return the identifier for this ReportingTask */ String getIdentifier(); /** - * Returns the configured name for this ReportingTask - * - * @return + * @return the configured name for this ReportingTask */ String getName(); @@ -51,40 +47,31 @@ public interface ReportingInitializationContext { * -1L if the Scheduling Strategy is not set to * {@link SchedulingStrategy#TIMER_DRIVEN} * - * @param timeUnit - * @return + * @param timeUnit unit of time for scheduling + * @return period of time */ long getSchedulingPeriod(TimeUnit timeUnit); /** - * Returns the {@link ControllerServiceLookup} which can be used to obtain + * @return the {@link ControllerServiceLookup} which can be used to obtain * Controller Services - * - * @return */ ControllerServiceLookup getControllerServiceLookup(); /** - * Returns a String representation of the scheduling period. - * - * @return + * @return a String representation of the scheduling period */ String getSchedulingPeriod(); /** - * Returns the {@link SchedulingStrategy} that is used to trigger the task + * @return the {@link SchedulingStrategy} that is used to trigger the task * to run - * - * @return */ SchedulingStrategy getSchedulingStrategy(); - - + /** - * Returns a logger that can be used to log important events in a standard way and generate - * bulletins when appropriate - * - * @return + * @return a logger that can be used to log important events in a standard + * way and generate bulletins when appropriate */ ComponentLog getLogger(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/ReportingTask.java b/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/ReportingTask.java index 3f777969da..3de9b9386b 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/ReportingTask.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/reporting/ReportingTask.java @@ -60,8 +60,8 @@ public interface ReportingTask extends ConfigurableComponent { * Provides the Reporting Task with access to objects that may be of use * throughout the life of the service * - * @param config - * @throws org.apache.nifi.reporting.InitializationException + * @param config of initialization context + * @throws org.apache.nifi.reporting.InitializationException if unable to init */ void initialize(ReportingInitializationContext config) throws InitializationException; @@ -69,7 +69,7 @@ public interface ReportingTask extends ConfigurableComponent { * This method is called on a scheduled interval to allow the Reporting Task * to perform its tasks. * - * @param context + * @param context reporting context */ void onTrigger(ReportingContext context); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/search/SearchContext.java b/nifi/nifi-api/src/main/java/org/apache/nifi/search/SearchContext.java index 77865bf4dd..1da8c90754 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/search/SearchContext.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/search/SearchContext.java @@ -26,32 +26,24 @@ import org.apache.nifi.components.PropertyValue; public interface SearchContext { /** - * Gets the search term. - * - * @return + * @return the search term */ String getSearchTerm(); /** - * Gets the annotation data. - * - * @return + * @return the annotation data */ String getAnnotationData(); /** - * Returns a PropertyValue that encapsulates the value configured for the + * @param property to get value of + * @return a PropertyValue that encapsulates the value configured for the * given PropertyDescriptor - * - * @param property - * @return */ PropertyValue getProperty(PropertyDescriptor property); /** - * Returns a Map of all configured Properties. - * - * @return + * @return a Map of all configured Properties */ Map getProperties(); } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/search/SearchResult.java b/nifi/nifi-api/src/main/java/org/apache/nifi/search/SearchResult.java index 7ed7d829e9..29e490a5a6 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/search/SearchResult.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/search/SearchResult.java @@ -30,18 +30,14 @@ public class SearchResult { } /** - * Get the label for this search result. - * - * @return + * @return the label for this search result */ public String getLabel() { return label; } /** - * Get the matching string for this search result. - * - * @return + * @return the matching string for this search result */ public String getMatch() { return match; @@ -55,8 +51,8 @@ public class SearchResult { /** * Set the label for the search result. * - * @param label - * @return + * @param label to set + * @return the builder */ public Builder label(final String label) { this.label = label; @@ -66,8 +62,8 @@ public class SearchResult { /** * Set the matching string for the search result. * - * @param match - * @return + * @param match string + * @return the builder */ public Builder match(final String match) { this.match = match; diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/web/ComponentDetails.java b/nifi/nifi-api/src/main/java/org/apache/nifi/web/ComponentDetails.java index 0b68ed95ac..5614fc2e40 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/web/ComponentDetails.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/web/ComponentDetails.java @@ -20,7 +20,8 @@ import java.util.Collection; import java.util.Map; /** - * Details about a given component. Contains configuration and current validation errors. + * Details about a given component. Contains configuration and current + * validation errors. */ public class ComponentDetails { @@ -43,63 +44,49 @@ public class ComponentDetails { } /** - * The component id. - * - * @return + * @return component id */ public String getId() { return id; } /** - * The component name. - * - * @return + * @return component name */ public String getName() { return name; } /** - * The component type. - * - * @return + * @return component type */ public String getType() { return type; } - + /** - * The component state. - * - * @return + * @return component state */ public String getState() { return state; } /** - * The component's annotation data. - * - * @return + * @return component's annotation data */ public String getAnnotationData() { return annotationData; } /** - * Mapping of component properties. - * - * @return + * @return Mapping of component properties */ public Map getProperties() { return properties; } /** - * Current validation errors for the component. - * - * @return + * @return Current validation errors for the component */ public Collection getValidationErrors() { return validationErrors; @@ -124,7 +111,7 @@ public class ComponentDetails { this.name = name; return this; } - + public Builder type(final String type) { this.type = type; return this; diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/web/ConfigurationAction.java b/nifi/nifi-api/src/main/java/org/apache/nifi/web/ConfigurationAction.java index 066e77254c..96f2abf0a6 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/web/ConfigurationAction.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/web/ConfigurationAction.java @@ -38,54 +38,42 @@ public class ConfigurationAction { } /** - * The id of the component being modified. - * - * @return + * @return id of the component being modified */ public String getId() { return id; } /** - * The name of the component being modified. - * - * @return + * @return name of the component being modified */ public String getName() { return name; } /** - * The type of the component being modified. - * - * @return + * @return type of the component being modified */ public String getType() { return type; } /** - * Gets the name of the field, property, etc that has been modified. - * - * @return + * @return the name of the field, property, etc that has been modified */ public String getField() { return field; } /** - * Gets the previous value. - * - * @return + * @return the previous value */ public String getPreviousValue() { return previousValue; } /** - * Gets the new value. - * - * @return + * @return the new value */ public String getValue() { return value; @@ -104,17 +92,17 @@ public class ConfigurationAction { this.id = id; return this; } - + public Builder name(final String name) { this.name = name; return this; } - + public Builder type(final String type) { this.type = type; return this; } - + public Builder field(final String field) { this.field = field; return this; diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationContext.java b/nifi/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationContext.java index 50f0ca30f3..ae32b10490 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationContext.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationContext.java @@ -25,15 +25,13 @@ import org.apache.nifi.controller.ControllerService; * component custom UIs. */ public interface NiFiWebConfigurationContext { - + /** - * Gets the ControllerService for the specified identifier. If a + * @param serviceIdentifier of the controller service + * @return the ControllerService for the specified identifier. If a * corresponding service cannot be found, null is returned. If this NiFi is - * clustered, the only services available will be those those - * availability is NCM only. - * - * @param serviceIdentifier - * @return + * clustered, the only services available will be those those availability + * is NCM only */ ControllerService getControllerService(String serviceIdentifier); @@ -48,55 +46,55 @@ public interface NiFiWebConfigurationContext { * been applied to the flow, we cannot revert them because of a failure to * insert an audit record. * - * @param requestContext - * @param actions - * @throws IllegalArgumentException When the requestContext isn't fully populated or - * isn't appropriate for the given request + * @param requestContext context of the request + * @param actions to save + * @throws IllegalArgumentException When the requestContext isn't fully + * populated or isn't appropriate for the given request */ void saveActions(NiFiWebRequestContext requestContext, Collection actions); /** - * Gets the current user dn. Returns null if no user is found. - * - * @return + * @return the current user dn. Returns null if no user is found */ String getCurrentUserDn(); /** - * Gets the current user name. Returns null if no user is found. - * - * @return + * @return the current user name. Returns null if no user is found */ String getCurrentUserName(); /** * Sets the annotation data for the underlying component. - * - * @param configurationContext - * @param annotationData + * + * @param configurationContext config context + * @param annotationData the data * @return the configuration for the underlying component - * @throws ResourceNotFoundException if the underlying component does not exit + * @throws ResourceNotFoundException if the underlying component does not + * exit * @throws InvalidRevisionException if a revision other than the current * revision is given * @throws ClusterRequestException if the annotation data was unable to be - * set for the underlying component. This exception will only be thrown when operating - * in a cluster. - * @throws IllegalArgumentException When the requestContext isn't fully populated or - * isn't appropriate for the given request - */ - ComponentDetails setAnnotationData(NiFiWebConfigurationRequestContext configurationContext, String annotationData) throws ResourceNotFoundException, InvalidRevisionException, ClusterRequestException; - - /** - * Gets the details for the underlying component (including configuration, validation errors, and annotation data). - * - * @param requestContext - * @return the configuration for the underlying component - * @throws ResourceNotFoundException if the underlying component does not exit - * @throws ClusterRequestException if the underlying component was unable to be - * retrieved from the cluster. This exception will only be thrown when + * set for the underlying component. This exception will only be thrown when * operating in a cluster. - * @throws IllegalArgumentException When the requestContext isn't fully populated or - * isn't appropriate for the given request + * @throws IllegalArgumentException When the requestContext isn't fully + * populated or isn't appropriate for the given request + */ + ComponentDetails setAnnotationData(NiFiWebConfigurationRequestContext configurationContext, String annotationData) + throws ResourceNotFoundException, InvalidRevisionException, ClusterRequestException; + + /** + * Gets the details for the underlying component (including configuration, + * validation errors, and annotation data). + * + * @param requestContext context of request + * @return the configuration for the underlying component + * @throws ResourceNotFoundException if the underlying component does not + * exit + * @throws ClusterRequestException if the underlying component was unable to + * be retrieved from the cluster. This exception will only be thrown when + * operating in a cluster. + * @throws IllegalArgumentException When the requestContext isn't fully + * populated or isn't appropriate for the given request */ ComponentDetails getComponentDetails(NiFiWebRequestContext requestContext) throws ResourceNotFoundException, ClusterRequestException; } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationRequestContext.java b/nifi/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationRequestContext.java index 791224122a..c75d9dc731 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationRequestContext.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationRequestContext.java @@ -17,13 +17,14 @@ package org.apache.nifi.web; /** - * Contextual details required to make a configuration request from a UI extension. + * Contextual details required to make a configuration request from a UI + * extension. */ public interface NiFiWebConfigurationRequestContext extends NiFiWebRequestContext { /** * The revision to include in the request. - * + * * @return the revision */ Revision getRevision(); diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebContext.java b/nifi/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebContext.java index 01702addf8..55e90e867e 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebContext.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebContext.java @@ -28,12 +28,10 @@ import org.apache.nifi.controller.ControllerService; public interface NiFiWebContext { /** - * Gets the ControllerService for the specified identifier. If a + * @param serviceIdentifier identifier of the service + * @return the ControllerService for the specified identifier. If a * corresponding service cannot be found, null is returned. If this NiFi is - * clustered, the ControllerService is loaded from the NCM. - * - * @param serviceIdentifier - * @return + * clustered, the ControllerService is loaded from the NCM */ ControllerService getControllerService(String serviceIdentifier); @@ -48,21 +46,17 @@ public interface NiFiWebContext { * been applied to the flow, we cannot revert them because of a failure to * insert an audit record. * - * @param actions + * @param actions to save */ void saveActions(Collection actions); /** - * Gets the current user dn. Returns null if no user is found. - * - * @return + * @return the current user dn. Returns null if no user is found */ String getCurrentUserDn(); /** - * Gets the current user name. Returns null if no user is found. - * - * @return + * @return the current user name. Returns null if no user is found */ String getCurrentUserName(); diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebRequestContext.java b/nifi/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebRequestContext.java index ac38221ae1..9dd44abf50 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebRequestContext.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebRequestContext.java @@ -22,12 +22,10 @@ package org.apache.nifi.web; public interface NiFiWebRequestContext { /** - * Returns the type of UI extension is making the request. - * - * @return + * @return the type of UI extension is making the request */ UiExtensionType getExtensionType(); - + /** * The request protocol scheme (http or https). When scheme is https, the * X509Certificate can be used for subsequent remote requests. @@ -38,7 +36,7 @@ public interface NiFiWebRequestContext { /** * The id of the component. - * + * * @return the ID */ String getId(); diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/web/ProcessorConfigurationAction.java b/nifi/nifi-api/src/main/java/org/apache/nifi/web/ProcessorConfigurationAction.java index ce5e069d30..f42063fd32 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/web/ProcessorConfigurationAction.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/web/ProcessorConfigurationAction.java @@ -39,54 +39,42 @@ public class ProcessorConfigurationAction { } /** - * Gets the id of the processor. - * - * @return + * @return the id of the processor */ public String getProcessorId() { return processorId; } /** - * Gets the name of the processor being modified. - * - * @return + * @return the name of the processor being modified */ public String getProcessorName() { return processorName; } /** - * Gets the type of the processor being modified. - * - * @return + * @return the type of the processor being modified */ public String getProcessorType() { return processorType; } /** - * Gets the name of the field, property, etc that has been modified. - * - * @return + * @return the name of the field, property, etc that has been modified. */ public String getName() { return name; } /** - * Gets the previous value. - * - * @return + * @return the previous value */ public String getPreviousValue() { return previousValue; } /** - * Gets the new value. - * - * @return + * @return the new value */ public String getValue() { return value; diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/web/Revision.java b/nifi/nifi-api/src/main/java/org/apache/nifi/web/Revision.java index 8a6275e1c5..a4d36d25dd 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/web/Revision.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/web/Revision.java @@ -22,7 +22,6 @@ import java.io.Serializable; * A model object representing a revision. Equality is defined as either a * matching version number or matching non-empty client IDs. * - * @author unattributed * @Immutable * @Threadsafe */ @@ -37,12 +36,12 @@ public class Revision implements Serializable { * the client ID */ private final String clientId; - + public Revision(Long revision, String clientId) { this.version = revision; this.clientId = clientId; } - + public String getClientId() { return clientId; } diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/web/UiExtensionType.java b/nifi/nifi-api/src/main/java/org/apache/nifi/web/UiExtensionType.java index 0bbda16d66..e3b0f8a217 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/web/UiExtensionType.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/web/UiExtensionType.java @@ -17,13 +17,14 @@ package org.apache.nifi.web; /** - * Types of UI extensions. Since a UI extension could support multiple - * types of custom UIs it will need to include the type so the framework - * can appropriate understand and process the request (recording actions - * in the audit database, replicating a request throughout the cluster to - * the appropriate endpoints, etc). + * Types of UI extensions. Since a UI extension could support multiple types of + * custom UIs it will need to include the type so the framework can appropriate + * understand and process the request (recording actions in the audit database, + * replicating a request throughout the cluster to the appropriate endpoints, + * etc). */ public enum UiExtensionType { + ContentViewer, ProcessorConfiguration, ControllerServiceConfiguration, diff --git a/nifi/nifi-api/src/main/java/org/apache/nifi/web/ViewableContent.java b/nifi/nifi-api/src/main/java/org/apache/nifi/web/ViewableContent.java index f90221e97f..180385e2f6 100644 --- a/nifi/nifi-api/src/main/java/org/apache/nifi/web/ViewableContent.java +++ b/nifi/nifi-api/src/main/java/org/apache/nifi/web/ViewableContent.java @@ -25,50 +25,41 @@ import java.io.InputStream; public interface ViewableContent { public static final String CONTENT_REQUEST_ATTRIBUTE = "org.apache.nifi.web.content"; - + public enum DisplayMode { + Original, Formatted, Hex; } - + /** - * The stream to the viewable content. The data stream can only be read once so - * an extension can call this method or getContent. - * - * @return + * @return stream to the viewable content. The data stream can only be read once + * so an extension can call this method or getContent */ InputStream getContentStream(); /** - * Gets the content as a string. The data stream can only be read once so - * an extension can call this method or getContentStream. - * - * @return - * @throws java.io.IOException + * @return the content as a string. The data stream can only be read once so an + * extension can call this method or getContentStream + * @throws java.io.IOException if unable to read content */ String getContent() throws IOException; - + /** - * Returns the desired play mode. If the mode is Hex the - * framework will handle generating the mark up. The only - * values that an extension will see is Original or Formatted. - * - * @return + * @return the desired display mode. If the mode is Hex the framework will + * handle generating the mark up. The only values that an extension will see + * is Original or Formatted */ DisplayMode getDisplayMode(); - + /** - * The contents file name. - * - * @return + * @return contents file name */ String getFileName(); - + /** - * The mime type of the content. - * - * @return + * @return mime type of the content */ String getContentType(); } diff --git a/nifi/nifi-api/src/test/java/org/apache/nifi/components/TestPropertyDescriptor.java b/nifi/nifi-api/src/test/java/org/apache/nifi/components/TestPropertyDescriptor.java index 82b8111089..e3043be6c9 100644 --- a/nifi/nifi-api/src/test/java/org/apache/nifi/components/TestPropertyDescriptor.java +++ b/nifi/nifi-api/src/test/java/org/apache/nifi/components/TestPropertyDescriptor.java @@ -24,34 +24,34 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; - /** - * Regression test for issue NIFI-49, to ensure that if a Processor's Property's Default Value is not allowed, - * the Exception thrown should indicate what the default value is + * Regression test for issue NIFI-49, to ensure that if a Processor's Property's + * Default Value is not allowed, the Exception thrown should indicate what the + * default value is */ public class TestPropertyDescriptor { private static Builder invalidDescriptorBuilder; private static Builder validDescriptorBuilder; private static String DEFAULT_VALUE = "Default Value"; - + @Rule public ExpectedException thrown = ExpectedException.none(); - + @BeforeClass public static void setUp() { validDescriptorBuilder = new PropertyDescriptor.Builder().name("").allowableValues("Allowable Value", "Another Allowable Value").defaultValue("Allowable Value"); invalidDescriptorBuilder = new PropertyDescriptor.Builder().name("").allowableValues("Allowable Value", "Another Allowable Value").defaultValue(DEFAULT_VALUE); } - + @Test public void testExceptionThrownByDescriptorWithInvalidDefaultValue() { thrown.expect(IllegalStateException.class); - thrown.expectMessage("["+ DEFAULT_VALUE +"]"); - + thrown.expectMessage("[" + DEFAULT_VALUE + "]"); + invalidDescriptorBuilder.build(); } - + @Test public void testNoExceptionThrownByPropertyDescriptorWithValidDefaultValue() { assertNotNull(validDescriptorBuilder.build()); diff --git a/nifi/nifi-assembly/LICENSE b/nifi/nifi-assembly/LICENSE index 38386b9a81..ec360de10b 100644 --- a/nifi/nifi-assembly/LICENSE +++ b/nifi/nifi-assembly/LICENSE @@ -455,6 +455,28 @@ This product bundles 'json2.js' which is available in the 'public domain'. This product bundles 'reset.css' which is available in the 'public domain'. For details see http://meyerweb.com/eric/tools/css/reset/ +This product bundles HexViewJS available under an MIT License + + Copyright (c) 2010 Nick McVeity + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. The binary distribution of this product bundles 'Slf4j' which is available under a "3-clause BSD" license. For details see http://www.slf4j.org/ diff --git a/nifi/nifi-assembly/NOTICE b/nifi/nifi-assembly/NOTICE index f14c662257..0edfd961b1 100644 --- a/nifi/nifi-assembly/NOTICE +++ b/nifi/nifi-assembly/NOTICE @@ -69,6 +69,9 @@ The following binary components are provided under the Apache Software License v Apache HttpCore Copyright 2005-2014 The Apache Software Foundation + Apache HttpMime + Copyright 1999-2013 The Apache Software Foundation + This project contains annotations derived from JCIP-ANNOTATIONS Copyright (c) 2005 Brian Goetz and Tim Peierls. See http://www.jcip.net @@ -464,13 +467,10 @@ The following binary components are provided under the Apache Software License v Apache Geronimo Copyright 2003-2008 The Apache Software Foundation - (ASLv2) Enunciate Core Annotations (org.codehaus.enunciate:enunciate-core-annotations:jar:1.28 - http://dist.codehaus.org/enunciate/enunciate-1.28.zip) + (ASLv2) Swagger Core The following NOTICE information applies: - This product includes software developed by the Spring Framework - Project (http://www.springframework.org). - - This product includes software developed by the - Visigoth Software Society (http://www.visigoths.org/). + Swagger Core 1.5.3-M1 + Copyright 2015 Reverb Technologies, Inc. (ASLv2) JSON-SMART The following NOTICE information applies: @@ -511,44 +511,39 @@ The following binary components are provided under the Apache Software License v The following NOTICE information applies: JOAuth Copyright 2010-2013 Twitter, Inc - - Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 (ASLv2) Hosebird Client The following NOTICE information applies: Hosebird Client (hbc) Copyright 2013 Twitter, Inc. - Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 - (ASLv2) GeoIP2 Java API The following NOTICE information applies: GeoIP2 Java API This software is Copyright (c) 2013 by MaxMind, Inc. - - This is free software, licensed under the Apache License, Version 2.0. - - (ASLv2) Google HTTP Client Library for Java + + (ASLv2) Woodstox Core ASL The following NOTICE information applies: - Google HTTP Client Library for Java - - This is free software, licensed under the Apache License, Version 2.0. + This product currently only contains code developed by authors + of specific components, as identified by the source code files. + + Since product implements StAX API, it has dependencies to StAX API + classes. (ASLv2) Amazon Web Services SDK The following NOTICE information applies: - Copyright 2010-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. + Copyright 2010-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. - This product includes software developed by - Amazon Technologies, Inc (http://www.amazon.com/). - - ********************** - THIRD PARTY COMPONENTS - ********************** - This software includes third party software subject to the following copyrights: - - XML parsing and utility functions from JetS3t - Copyright 2006-2009 James Murty. - - JSON parsing and utility functions from JSON.org - Copyright 2002 JSON.org. - - PKCS#1 PEM encoded private key parsing and utility functions from oauth.googlecode.com - Copyright 1998-2010 AOL Inc. + This product includes software developed by + Amazon Technologies, Inc (http://www.amazon.com/). + ********************** + THIRD PARTY COMPONENTS + ********************** + This software includes third party software subject to the following copyrights: + - XML parsing and utility functions from JetS3t - Copyright 2006-2009 James Murty. + - JSON parsing and utility functions from JSON.org - Copyright 2002 JSON.org. + - PKCS#1 PEM encoded private key parsing and utility functions from oauth.googlecode.com - Copyright 1998-2010 AOL Inc. ************************ Common Development and Distribution License 1.1 @@ -586,7 +581,6 @@ The following binary components are provided under the Common Development and Di (CDDL 1.0) (GPL3) Streaming API For XML (javax.xml.stream:stax-api:jar:1.0-2 - no url provided) (CDDL 1.0) JavaBeans Activation Framework (JAF) (javax.activation:activation:jar:1.1 - http://java.sun.com/products/javabeans/jaf/index.jsp) (CDDL 1.0) JavaServer Pages(TM) API (javax.servlet.jsp:jsp-api:jar:2.1 - http://jsp.java.net) - (CDDL 1.0) SR 250 Common Annotations For The JavaTM Platform (javax.annotation:jsr250-api:jar:1.0 - http://jcp.org/aboutJava/communityprocess/final/jsr250/index.html) ************************ Creative Commons Attribution-ShareAlike 3.0 diff --git a/nifi/nifi-assembly/pom.xml b/nifi/nifi-assembly/pom.xml index 13ffba802d..1ac52bbaae 100644 --- a/nifi/nifi-assembly/pom.xml +++ b/nifi/nifi-assembly/pom.xml @@ -1,484 +1,483 @@ - + - 4.0.0 - - org.apache.nifi - nifi - 0.1.0-incubating-SNAPSHOT - - nifi-assembly - pom - This is the assembly Apache NiFi (incubating) - - - - maven-assembly-plugin - - nifi-${project.version} - false - - - - make shared resource - - single - - package - - - src/main/assembly/dependencies.xml - - posix - - - - - - - - - ch.qos.logback - logback-classic - compile - - - org.slf4j - jcl-over-slf4j - compile - - - org.slf4j - jul-to-slf4j - compile - - - org.slf4j - log4j-over-slf4j - compile - - - org.slf4j - slf4j-api - compile - - - org.apache.nifi - nifi-api - - - org.apache.nifi - nifi-runtime - - - org.apache.nifi - nifi-bootstrap - - - org.apache.nifi - nifi-resources - resources - runtime - zip - - - org.apache.nifi - nifi-docs - resources - runtime - zip - - - org.apache.nifi - nifi-framework-nar - nar - - - org.apache.nifi - nifi-provenance-repository-nar - nar - - - org.apache.nifi - nifi-standard-services-api-nar - nar - - - org.apache.nifi - nifi-ssl-context-service-nar - nar - - - org.apache.nifi - nifi-distributed-cache-services-nar - nar - - - org.apache.nifi - nifi-standard-nar - nar - - - org.apache.nifi - nifi-jetty-bundle - nar - - - org.apache.nifi - nifi-update-attribute-nar - nar - - - org.apache.nifi - nifi-hadoop-libraries-nar - nar - - - org.apache.nifi - nifi-hadoop-nar - nar - - - org.apache.nifi - nifi-kafka-nar - nar - - - org.apache.nifi - nifi-http-context-map-nar - nar - - - org.apache.nifi - nifi-kite-nar - nar - - - org.apache.nifi - nifi-social-media-nar - 0.1.0-incubating-SNAPSHOT - nar - - - org.apache.nifi - nifi-hl7-nar - 0.1.0-incubating-SNAPSHOT - nar - - - org.apache.nifi - nifi-language-translation-nar - 0.1.0-incubating-SNAPSHOT - nar - - - org.apache.nifi - nifi-geo-nar - 0.1.0-incubating-SNAPSHOT - nar - - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + 4.0.0 + + org.apache.nifi + nifi + 0.1.0-incubating-SNAPSHOT + + nifi-assembly + pom + This is the assembly Apache NiFi (incubating) + + + + maven-assembly-plugin + + nifi-${project.version} + false + + + + make shared resource + + single + + package + + + src/main/assembly/dependencies.xml + + posix + + + + + + + + + ch.qos.logback + logback-classic + compile + + + org.slf4j + jcl-over-slf4j + compile + + + org.slf4j + jul-to-slf4j + compile + + + org.slf4j + log4j-over-slf4j + compile + + + org.slf4j + slf4j-api + compile + + + org.apache.nifi + nifi-api + + + org.apache.nifi + nifi-runtime + + + org.apache.nifi + nifi-bootstrap + + + org.apache.nifi + nifi-resources + resources + runtime + zip + + + org.apache.nifi + nifi-docs + resources + runtime + zip + + + org.apache.nifi + nifi-framework-nar + nar + + + org.apache.nifi + nifi-provenance-repository-nar + nar + + + org.apache.nifi + nifi-standard-services-api-nar + nar + + + org.apache.nifi + nifi-ssl-context-service-nar + nar + + + org.apache.nifi + nifi-distributed-cache-services-nar + nar + + + org.apache.nifi + nifi-standard-nar + nar + + + org.apache.nifi + nifi-jetty-bundle + nar + + + org.apache.nifi + nifi-update-attribute-nar + nar + + + org.apache.nifi + nifi-hadoop-libraries-nar + nar + + + org.apache.nifi + nifi-hadoop-nar + nar + + + org.apache.nifi + nifi-kafka-nar + nar + + + org.apache.nifi + nifi-http-context-map-nar + nar + + + org.apache.nifi + nifi-kite-nar + nar + + + org.apache.nifi + nifi-solr-nar + nar + + + org.apache.nifi + nifi-social-media-nar + 0.1.0-incubating-SNAPSHOT + nar + + + org.apache.nifi + nifi-hl7-nar + 0.1.0-incubating-SNAPSHOT + nar + + + org.apache.nifi + nifi-language-translation-nar + 0.1.0-incubating-SNAPSHOT + nar + + + org.apache.nifi + nifi-geo-nar + 0.1.0-incubating-SNAPSHOT + nar + + - - - 256 - 512 - 128 - 128 - 10m - 10 + + + 256 + 512 + 128 + 128 + 10m + 10 - - ${project.version} - true - 10 sec - 500 ms - 30 sec - 10 millis + + ${project.version} + true + 10 sec + 500 ms + 30 sec + 10 millis - ./conf/flow.xml.gz - ./conf/archive/ - ./conf/authority-providers.xml - ./conf/templates - ./database_repository + ./conf/flow.xml.gz + ./conf/archive/ + ./conf/authority-providers.xml + ./conf/templates + ./database_repository - org.apache.nifi.controller.repository.WriteAheadFlowFileRepository - ./flowfile_repository - 256 - 2 mins - false - org.apache.nifi.controller.FileSystemSwapManager - 20000 - 5 sec - 1 - 5 sec - 4 + org.apache.nifi.controller.repository.WriteAheadFlowFileRepository + ./flowfile_repository + 256 + 2 mins + false + org.apache.nifi.controller.FileSystemSwapManager + 20000 + 5 sec + 1 + 5 sec + 4 - org.apache.nifi.controller.repository.FileSystemRepository - 10 MB - 100 - ./content_repository - - - false - false - + org.apache.nifi.controller.repository.FileSystemRepository + 10 MB + 100 + ./content_repository + + + false + false + - - - 30 sec - ./lib - ./work/nar/ - ./work/docs/components + + + 30 sec + ./lib + ./work/nar/ + ./work/docs/components - PBEWITHMD5AND256BITAES-CBC-OPENSSL - BC - ;LOCK_TIMEOUT=25000;WRITE_DELAY=0;AUTO_SERVER=FALSE + PBEWITHMD5AND256BITAES-CBC-OPENSSL + BC + ;LOCK_TIMEOUT=25000;WRITE_DELAY=0;AUTO_SERVER=FALSE - 9990 + 9990 - - org.apache.nifi.provenance.PersistentProvenanceRepository - ./provenance_repository - 24 hours - 1 GB - 5 mins - 100 MB - 2 - true - EventType, FlowFileUUID, - Filename, ProcessorID - - 500 MB - false - 16 + + org.apache.nifi.provenance.PersistentProvenanceRepository + ./provenance_repository + 24 hours + 1 GB + 5 mins + 100 MB + 2 + true + EventType, FlowFileUUID, Filename, ProcessorID + + 500 MB + false + 16 - - 100000 + + 100000 - - org.apache.nifi.controller.status.history.VolatileComponentStatusRepository - 288 - 5 mins + + org.apache.nifi.controller.status.history.VolatileComponentStatusRepository + 288 + 5 mins - - ./lib - - 8080 - - - ./work/jetty - 200 + + ./lib + + 8080 + + + ./work/jetty + 200 - - - - - - - - - - ./conf/authorized-users.xml - 24 hours - file-provider - - - - + + + + + + + + + + ./conf/authorized-users.xml + 24 hours + file-provider + + + + - - 5 sec - false - 30 sec - 45 sec - false - - - 500 ms - 3 - 1 sec + + 5 sec + false + 30 sec + 45 sec + false + + + 500 ms + 3 + 1 sec - - false - - - 2 - - + + false + + + 2 + + - - false - - - - 10 - 30 sec - 30 sec - 10 - 5 sec - 10 - 0 sec - - - - rpm - - false - - - - - maven-dependency-plugin - - - unpack-shared-resources - - unpack-dependencies - - generate-resources - - ${project.build.directory}/generated-resources - nifi-resources - org.apache.nifi - false - - - - unpack-docs - - unpack-dependencies - - generate-resources - - ${project.build.directory}/generated-docs - nifi-docs - org.apache.nifi - false - - - - - - org.codehaus.mojo - rpm-maven-plugin - - Apache NiFi (incubating) - Apache Nifi (incubating) is dataflow system based on - the Flow-Based Programming concepts. - Apache License, Version 2.0 and others (see included - LICENSE file) - http://nifi.incubator.apache.org - Utilities - /opt/nifi - - _use_internal_dependency_generator 0 - - 750 - 640 - root - root - - - - build-bin-rpm - - attached-rpm - - - bin - - nifi - - - - /opt/nifi/nifi-${project.version} - - - /opt/nifi/nifi-${project.version} - - - ./LICENSE - - - ./NOTICE - - - ../DISCLAIMER - - - ./README.md - README - - - - - /opt/nifi/nifi-${project.version}/bin - 750 - - - ${project.build.directory}/generated-resources/bin/nifi.sh - nifi.sh - true - - - - - /opt/nifi/nifi-${project.version}/conf - true - - - ${project.build.directory}/generated-resources/conf - true - - - - - /opt/nifi/nifi-${project.version}/lib - - - org.apache.nifi:nifi-bootstrap - org.apache.nifi:nifi-resources - org.apache.nifi:nifi-docs - - - - - /opt/nifi/nifi-${project.version}/lib/bootstrap - - - org.apache.nifi:nifi-bootstrap - - - - - /opt/nifi/nifi-${project.version}/docs - - - ${project.build.directory}/generated-docs - - - - - - - - - - - - + + false + + + + 10 + 30 sec + 30 sec + 10 + 5 sec + 10 + 0 sec + + + + rpm + + false + + + + + maven-dependency-plugin + + + unpack-shared-resources + + unpack-dependencies + + generate-resources + + ${project.build.directory}/generated-resources + nifi-resources + org.apache.nifi + false + + + + unpack-docs + + unpack-dependencies + + generate-resources + + ${project.build.directory}/generated-docs + nifi-docs + org.apache.nifi + false + + + + + + org.codehaus.mojo + rpm-maven-plugin + + Apache NiFi (incubating) + Apache Nifi (incubating) is dataflow system based on the Flow-Based Programming concepts. + Apache License, Version 2.0 and others (see included LICENSE file) + http://nifi.incubator.apache.org + Utilities + /opt/nifi + + _use_internal_dependency_generator 0 + + 750 + 640 + root + root + + + + build-bin-rpm + + attached-rpm + + + bin + + nifi + + + + /opt/nifi/nifi-${project.version} + + + /opt/nifi/nifi-${project.version} + + + ./LICENSE + + + ./NOTICE + + + ../DISCLAIMER + + + ./README.md + README + + + + + /opt/nifi/nifi-${project.version}/bin + 750 + + + ${project.build.directory}/generated-resources/bin/nifi.sh + nifi.sh + true + + + + + /opt/nifi/nifi-${project.version}/conf + true + + + ${project.build.directory}/generated-resources/conf + true + + + + + /opt/nifi/nifi-${project.version}/lib + + + org.apache.nifi:nifi-bootstrap + org.apache.nifi:nifi-resources + org.apache.nifi:nifi-docs + + + + + /opt/nifi/nifi-${project.version}/lib/bootstrap + + + org.apache.nifi:nifi-bootstrap + + + + + /opt/nifi/nifi-${project.version}/docs + + + ${project.build.directory}/generated-docs + + + + + + + + + + + + diff --git a/nifi/nifi-assembly/src/main/assembly/dependencies.xml b/nifi/nifi-assembly/src/main/assembly/dependencies.xml index 8480c144a4..27eb32dd8c 100644 --- a/nifi/nifi-assembly/src/main/assembly/dependencies.xml +++ b/nifi/nifi-assembly/src/main/assembly/dependencies.xml @@ -104,6 +104,11 @@ true false + + + LICENSE + NOTICE + diff --git a/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/BootstrapCodec.java b/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/BootstrapCodec.java index f03bf1edcd..381787512d 100644 --- a/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/BootstrapCodec.java +++ b/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/BootstrapCodec.java @@ -27,66 +27,66 @@ import java.util.Arrays; import org.apache.nifi.bootstrap.exception.InvalidCommandException; - public class BootstrapCodec { - private final RunNiFi runner; - private final BufferedReader reader; - private final BufferedWriter writer; - - public BootstrapCodec(final RunNiFi runner, final InputStream in, final OutputStream out) { - this.runner = runner; - this.reader = new BufferedReader(new InputStreamReader(in)); - this.writer = new BufferedWriter(new OutputStreamWriter(out)); - } - - public void communicate() throws IOException { - final String line = reader.readLine(); - final String[] splits = line.split(" "); - if ( splits.length < 0 ) { - throw new IOException("Received invalid command from NiFi: " + line); - } - - final String cmd = splits[0]; - final String[] args; - if ( splits.length == 1 ) { - args = new String[0]; - } else { - args = Arrays.copyOfRange(splits, 1, splits.length); - } - - try { - processRequest(cmd, args); - } catch (final InvalidCommandException ice) { - throw new IOException("Received invalid command from NiFi: " + line + " : " + ice.getMessage() == null ? "" : "Details: " + ice.toString()); - } - } - private void processRequest(final String cmd, final String[] args) throws InvalidCommandException, IOException { - switch (cmd) { - case "PORT": { - if ( args.length != 2 ) { - throw new InvalidCommandException(); - } - - final int port; - try { - port = Integer.parseInt( args[0] ); - } catch (final NumberFormatException nfe) { - throw new InvalidCommandException("Invalid Port number; should be integer between 1 and 65535"); - } - - if ( port < 1 || port > 65535 ) { - throw new InvalidCommandException("Invalid Port number; should be integer between 1 and 65535"); - } + private final RunNiFi runner; + private final BufferedReader reader; + private final BufferedWriter writer; - final String secretKey = args[1]; - - runner.setNiFiCommandControlPort(port, secretKey); - writer.write("OK"); - writer.newLine(); - writer.flush(); - } - break; - } - } + public BootstrapCodec(final RunNiFi runner, final InputStream in, final OutputStream out) { + this.runner = runner; + this.reader = new BufferedReader(new InputStreamReader(in)); + this.writer = new BufferedWriter(new OutputStreamWriter(out)); + } + + public void communicate() throws IOException { + final String line = reader.readLine(); + final String[] splits = line.split(" "); + if (splits.length < 0) { + throw new IOException("Received invalid command from NiFi: " + line); + } + + final String cmd = splits[0]; + final String[] args; + if (splits.length == 1) { + args = new String[0]; + } else { + args = Arrays.copyOfRange(splits, 1, splits.length); + } + + try { + processRequest(cmd, args); + } catch (final InvalidCommandException ice) { + throw new IOException("Received invalid command from NiFi: " + line + " : " + ice.getMessage() == null ? "" : "Details: " + ice.toString()); + } + } + + private void processRequest(final String cmd, final String[] args) throws InvalidCommandException, IOException { + switch (cmd) { + case "PORT": { + if (args.length != 2) { + throw new InvalidCommandException(); + } + + final int port; + try { + port = Integer.parseInt(args[0]); + } catch (final NumberFormatException nfe) { + throw new InvalidCommandException("Invalid Port number; should be integer between 1 and 65535"); + } + + if (port < 1 || port > 65535) { + throw new InvalidCommandException("Invalid Port number; should be integer between 1 and 65535"); + } + + final String secretKey = args[1]; + + runner.setNiFiCommandControlPort(port, secretKey); + writer.write("OK"); + writer.newLine(); + writer.flush(); + } + break; + } + } } diff --git a/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/NiFiListener.java b/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/NiFiListener.java index f05d45a395..171347880e 100644 --- a/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/NiFiListener.java +++ b/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/NiFiListener.java @@ -28,101 +28,103 @@ import java.util.concurrent.TimeUnit; import org.apache.nifi.bootstrap.util.LimitingInputStream; public class NiFiListener { - private ServerSocket serverSocket; - private volatile Listener listener; - - int start(final RunNiFi runner) throws IOException { - serverSocket = new ServerSocket(); - serverSocket.bind(new InetSocketAddress("localhost", 0)); - - final int localPort = serverSocket.getLocalPort(); - listener = new Listener(serverSocket, runner); - final Thread listenThread = new Thread(listener); - listenThread.setName("Listen to NiFi"); - listenThread.start(); - return localPort; - } - - public void stop() throws IOException { - final Listener listener = this.listener; - if ( listener == null ) { - return; - } - - listener.stop(); - } - - private class Listener implements Runnable { - private final ServerSocket serverSocket; - private final ExecutorService executor; - private final RunNiFi runner; - private volatile boolean stopped = false; - - public Listener(final ServerSocket serverSocket, final RunNiFi runner) { - this.serverSocket = serverSocket; - this.executor = Executors.newFixedThreadPool(2); - this.runner = runner; - } - - public void stop() throws IOException { - stopped = true; - - executor.shutdown(); - try { - executor.awaitTermination(3, TimeUnit.SECONDS); - } catch (final InterruptedException ie) { - } - - serverSocket.close(); - } - - @Override - public void run() { - while (!serverSocket.isClosed()) { - try { - if ( stopped ) { - return; - } - - final Socket socket; - try { - socket = serverSocket.accept(); - } catch (final IOException ioe) { - if ( stopped ) { - return; - } - - throw ioe; - } - - executor.submit(new Runnable() { - @Override - public void run() { - try { - // we want to ensure that we don't try to read data from an InputStream directly - // by a BufferedReader because any user on the system could open a socket and send - // a multi-gigabyte file without any new lines in order to crash the Bootstrap, - // which in turn may cause the Shutdown Hook to shutdown NiFi. - // So we will limit the amount of data to read to 4 KB - final InputStream limitingIn = new LimitingInputStream(socket.getInputStream(), 4096); - final BootstrapCodec codec = new BootstrapCodec(runner, limitingIn, socket.getOutputStream()); - codec.communicate(); - } catch (final Throwable t) { - System.out.println("Failed to communicate with NiFi due to " + t); - t.printStackTrace(); - } finally { - try { - socket.close(); - } catch (final IOException ioe) { - } - } - } - }); - } catch (final Throwable t) { - System.err.println("Failed to receive information from NiFi due to " + t); - t.printStackTrace(); - } - } - } - } + + private ServerSocket serverSocket; + private volatile Listener listener; + + int start(final RunNiFi runner) throws IOException { + serverSocket = new ServerSocket(); + serverSocket.bind(new InetSocketAddress("localhost", 0)); + + final int localPort = serverSocket.getLocalPort(); + listener = new Listener(serverSocket, runner); + final Thread listenThread = new Thread(listener); + listenThread.setName("Listen to NiFi"); + listenThread.start(); + return localPort; + } + + public void stop() throws IOException { + final Listener listener = this.listener; + if (listener == null) { + return; + } + + listener.stop(); + } + + private class Listener implements Runnable { + + private final ServerSocket serverSocket; + private final ExecutorService executor; + private final RunNiFi runner; + private volatile boolean stopped = false; + + public Listener(final ServerSocket serverSocket, final RunNiFi runner) { + this.serverSocket = serverSocket; + this.executor = Executors.newFixedThreadPool(2); + this.runner = runner; + } + + public void stop() throws IOException { + stopped = true; + + executor.shutdown(); + try { + executor.awaitTermination(3, TimeUnit.SECONDS); + } catch (final InterruptedException ie) { + } + + serverSocket.close(); + } + + @Override + public void run() { + while (!serverSocket.isClosed()) { + try { + if (stopped) { + return; + } + + final Socket socket; + try { + socket = serverSocket.accept(); + } catch (final IOException ioe) { + if (stopped) { + return; + } + + throw ioe; + } + + executor.submit(new Runnable() { + @Override + public void run() { + try { + // we want to ensure that we don't try to read data from an InputStream directly + // by a BufferedReader because any user on the system could open a socket and send + // a multi-gigabyte file without any new lines in order to crash the Bootstrap, + // which in turn may cause the Shutdown Hook to shutdown NiFi. + // So we will limit the amount of data to read to 4 KB + final InputStream limitingIn = new LimitingInputStream(socket.getInputStream(), 4096); + final BootstrapCodec codec = new BootstrapCodec(runner, limitingIn, socket.getOutputStream()); + codec.communicate(); + } catch (final Throwable t) { + System.out.println("Failed to communicate with NiFi due to " + t); + t.printStackTrace(); + } finally { + try { + socket.close(); + } catch (final IOException ioe) { + } + } + } + }); + } catch (final Throwable t) { + System.err.println("Failed to receive information from NiFi due to " + t); + t.printStackTrace(); + } + } + } + } } diff --git a/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java b/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java index 28a9b71028..bb83e3d4b3 100644 --- a/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java +++ b/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java @@ -49,218 +49,223 @@ import java.util.logging.ConsoleHandler; import java.util.logging.Handler; import java.util.logging.Level; - /** - * Bootstrap class to run Apache NiFi. - * - * This class looks for the bootstrap.conf file by looking in the following places (in order): + * + *

    + * The class which bootstraps Apache NiFi. This class looks for the + * bootstrap.conf file by looking in the following places (in order):

    *
      - *
    1. Java System Property named {@code org.apache.nifi.bootstrap.config.file}
    2. - *
    3. ${NIFI_HOME}/./conf/bootstrap.conf, where ${NIFI_HOME} references an environment variable {@code NIFI_HOME}
    4. - *
    5. ./conf/bootstrap.conf, where {@code .} represents the working directory. + *
    6. Java System Property named + * {@code org.apache.nifi.bootstrap.config.file}
    7. + *
    8. ${NIFI_HOME}/./conf/bootstrap.conf, where ${NIFI_HOME} references an + * environment variable {@code NIFI_HOME}
    9. + *
    10. ./conf/bootstrap.conf, where {@code ./} represents the working + * directory.
    11. *
    * - * If the {@code bootstrap.conf} file cannot be found, throws a {@code FileNotFoundException]. + * If the {@code bootstrap.conf} file cannot be found, throws a {@code FileNotFoundException}. */ public class RunNiFi { - public static final String DEFAULT_CONFIG_FILE = "./conf/bootstrap.conf"; - public static final String DEFAULT_NIFI_PROPS_FILE = "./conf/nifi.properties"; - public static final String DEFAULT_JAVA_CMD = "java"; - public static final String GRACEFUL_SHUTDOWN_PROP = "graceful.shutdown.seconds"; - public static final String DEFAULT_GRACEFUL_SHUTDOWN_VALUE = "20"; - - public static final String RUN_AS_PROP = "run.as"; - - public static final int MAX_RESTART_ATTEMPTS = 5; - public static final int STARTUP_WAIT_SECONDS = 60; - - public static final String SHUTDOWN_CMD = "SHUTDOWN"; - public static final String PING_CMD = "PING"; - public static final String DUMP_CMD = "DUMP"; - - private volatile boolean autoRestartNiFi = true; - private volatile int ccPort = -1; - private volatile long nifiPid = -1L; - private volatile String secretKey; - private volatile ShutdownHook shutdownHook; - - private final Lock lock = new ReentrantLock(); - private final Condition startupCondition = lock.newCondition(); - - private final File bootstrapConfigFile; + public static final String DEFAULT_CONFIG_FILE = "./conf/bootstrap.conf"; + public static final String DEFAULT_NIFI_PROPS_FILE = "./conf/nifi.properties"; + public static final String DEFAULT_JAVA_CMD = "java"; - private final java.util.logging.Logger logger; - - public RunNiFi(final File bootstrapConfigFile, final boolean verbose) { - this.bootstrapConfigFile = bootstrapConfigFile; - logger = java.util.logging.Logger.getLogger("Bootstrap"); - if ( verbose ) { - logger.info("Enabling Verbose Output"); - - logger.setLevel(Level.FINE); - final Handler handler = new ConsoleHandler(); - handler.setLevel(Level.FINE); - logger.addHandler(handler); - } - } - - private static void printUsage() { - System.out.println("Usage:"); - System.out.println(); - System.out.println("java org.apache.nifi.bootstrap.RunNiFi [<-verbose>] [options]"); - System.out.println(); - System.out.println("Valid commands include:"); - System.out.println(""); - System.out.println("Start : Start a new instance of Apache NiFi"); - System.out.println("Stop : Stop a running instance of Apache NiFi"); - System.out.println("Restart : Stop Apache NiFi, if it is running, and then start a new instance"); - System.out.println("Status : Determine if there is a running instance of Apache NiFi"); - System.out.println("Dump : Write a Thread Dump to the file specified by [options], or to the log if no file is given"); - System.out.println("Run : Start a new instance of Apache NiFi and monitor the Process, restarting if the instance dies"); - System.out.println(); - } + public static final String GRACEFUL_SHUTDOWN_PROP = "graceful.shutdown.seconds"; + public static final String DEFAULT_GRACEFUL_SHUTDOWN_VALUE = "20"; - private static String[] shift(final String[] orig) { - return Arrays.copyOfRange(orig, 1, orig.length); - } - - public static void main(String[] args) throws IOException, InterruptedException { - if ( args.length < 1 || args.length > 3 ) { - printUsage(); - return; - } - - File dumpFile = null; - boolean verbose = false; - if ( args[0].equals("-verbose") ) { - verbose = true; - args = shift(args); - } - - final String cmd = args[0]; - if (cmd.equals("dump") ) { - if ( args.length > 1 ) { - dumpFile = new File(args[1]); - } else { - dumpFile = null; - } - } - - switch (cmd.toLowerCase()) { - case "start": - case "run": - case "stop": - case "status": - case "dump": - case "restart": - break; - default: - printUsage(); - return; - } - - String configFilename = System.getProperty("org.apache.nifi.bootstrap.config.file"); - - if ( configFilename == null ) { - final String nifiHome = System.getenv("NIFI_HOME"); - if ( nifiHome != null ) { - final File nifiHomeFile = new File(nifiHome.trim()); - final File configFile = new File(nifiHomeFile, DEFAULT_CONFIG_FILE); - configFilename = configFile.getAbsolutePath(); - } - } - - if ( configFilename == null ) { - configFilename = DEFAULT_CONFIG_FILE; - } - - final File configFile = new File(configFilename); - - final RunNiFi runNiFi = new RunNiFi(configFile, verbose); - - switch (cmd.toLowerCase()) { - case "start": - runNiFi.start(false); - break; - case "run": - runNiFi.start(true); - break; - case "stop": - runNiFi.stop(); - break; - case "status": - runNiFi.status(); - break; - case "restart": - runNiFi.stop(); - runNiFi.start(false); - break; - case "dump": - runNiFi.dump(dumpFile); - break; - } - } - - - public File getStatusFile() { - final File confDir = bootstrapConfigFile.getParentFile(); - final File nifiHome = confDir.getParentFile(); - final File bin = new File(nifiHome, "bin"); - final File statusFile = new File(bin, "nifi.pid"); - - logger.fine("Status File: " + statusFile); - - return statusFile; - } - - private Properties loadProperties() throws IOException { - final Properties props = new Properties(); - final File statusFile = getStatusFile(); - if ( statusFile == null || !statusFile.exists() ) { - logger.fine("No status file to load properties from"); - return props; - } - - try (final FileInputStream fis = new FileInputStream(getStatusFile())) { - props.load(fis); - } - - logger.fine("Properties: " + props); - return props; - } - - private synchronized void saveProperties(final Properties nifiProps) throws IOException { - final File statusFile = getStatusFile(); - if ( statusFile.exists() && !statusFile.delete() ) { - logger.warning("Failed to delete " + statusFile); - } + public static final String RUN_AS_PROP = "run.as"; - if ( !statusFile.createNewFile() ) { - throw new IOException("Failed to create file " + statusFile); - } + public static final int MAX_RESTART_ATTEMPTS = 5; + public static final int STARTUP_WAIT_SECONDS = 60; + + public static final String SHUTDOWN_CMD = "SHUTDOWN"; + public static final String PING_CMD = "PING"; + public static final String DUMP_CMD = "DUMP"; + + private volatile boolean autoRestartNiFi = true; + private volatile int ccPort = -1; + private volatile long nifiPid = -1L; + private volatile String secretKey; + private volatile ShutdownHook shutdownHook; + + private final Lock lock = new ReentrantLock(); + private final Condition startupCondition = lock.newCondition(); + + private final File bootstrapConfigFile; + + private final java.util.logging.Logger logger; + + public RunNiFi(final File bootstrapConfigFile, final boolean verbose) { + this.bootstrapConfigFile = bootstrapConfigFile; + logger = java.util.logging.Logger.getLogger("Bootstrap"); + if (verbose) { + logger.info("Enabling Verbose Output"); + + logger.setLevel(Level.FINE); + final Handler handler = new ConsoleHandler(); + handler.setLevel(Level.FINE); + logger.addHandler(handler); + } + } + + private static void printUsage() { + System.out.println("Usage:"); + System.out.println(); + System.out.println("java org.apache.nifi.bootstrap.RunNiFi [<-verbose>] [options]"); + System.out.println(); + System.out.println("Valid commands include:"); + System.out.println(""); + System.out.println("Start : Start a new instance of Apache NiFi"); + System.out.println("Stop : Stop a running instance of Apache NiFi"); + System.out.println("Restart : Stop Apache NiFi, if it is running, and then start a new instance"); + System.out.println("Status : Determine if there is a running instance of Apache NiFi"); + System.out.println("Dump : Write a Thread Dump to the file specified by [options], or to the log if no file is given"); + System.out.println("Run : Start a new instance of Apache NiFi and monitor the Process, restarting if the instance dies"); + System.out.println(); + } + + private static String[] shift(final String[] orig) { + return Arrays.copyOfRange(orig, 1, orig.length); + } + + public static void main(String[] args) throws IOException, InterruptedException { + if (args.length < 1 || args.length > 3) { + printUsage(); + return; + } + + File dumpFile = null; + boolean verbose = false; + if (args[0].equals("-verbose")) { + verbose = true; + args = shift(args); + } + + final String cmd = args[0]; + if (cmd.equals("dump")) { + if (args.length > 1) { + dumpFile = new File(args[1]); + } else { + dumpFile = null; + } + } + + switch (cmd.toLowerCase()) { + case "start": + case "run": + case "stop": + case "status": + case "dump": + case "restart": + break; + default: + printUsage(); + return; + } + + String configFilename = System.getProperty("org.apache.nifi.bootstrap.config.file"); + + if (configFilename == null) { + final String nifiHome = System.getenv("NIFI_HOME"); + if (nifiHome != null) { + final File nifiHomeFile = new File(nifiHome.trim()); + final File configFile = new File(nifiHomeFile, DEFAULT_CONFIG_FILE); + configFilename = configFile.getAbsolutePath(); + } + } + + if (configFilename == null) { + configFilename = DEFAULT_CONFIG_FILE; + } + + final File configFile = new File(configFilename); + + final RunNiFi runNiFi = new RunNiFi(configFile, verbose); + + switch (cmd.toLowerCase()) { + case "start": + runNiFi.start(false); + break; + case "run": + runNiFi.start(true); + break; + case "stop": + runNiFi.stop(); + break; + case "status": + runNiFi.status(); + break; + case "restart": + runNiFi.stop(); + runNiFi.start(false); + break; + case "dump": + runNiFi.dump(dumpFile); + break; + } + } + + public File getStatusFile() { + final File confDir = bootstrapConfigFile.getParentFile(); + final File nifiHome = confDir.getParentFile(); + final File bin = new File(nifiHome, "bin"); + final File statusFile = new File(bin, "nifi.pid"); + + logger.log(Level.FINE, "Status File: {0}", statusFile); + + return statusFile; + } + + private Properties loadProperties() throws IOException { + final Properties props = new Properties(); + final File statusFile = getStatusFile(); + if (statusFile == null || !statusFile.exists()) { + logger.fine("No status file to load properties from"); + return props; + } + + try (final FileInputStream fis = new FileInputStream(getStatusFile())) { + props.load(fis); + } + + logger.log(Level.FINE, "Properties: {0}", props); + return props; + } + + private synchronized void saveProperties(final Properties nifiProps) throws IOException { + final File statusFile = getStatusFile(); + if (statusFile.exists() && !statusFile.delete()) { + logger.log(Level.WARNING, "Failed to delete {0}", statusFile); + } + + if (!statusFile.createNewFile()) { + throw new IOException("Failed to create file " + statusFile); + } + + try { + final Set perms = new HashSet<>(); + perms.add(PosixFilePermission.OWNER_READ); + perms.add(PosixFilePermission.OWNER_WRITE); + Files.setPosixFilePermissions(statusFile.toPath(), perms); + } catch (final Exception e) { + logger.log(Level.WARNING, "Failed to set permissions so that only the owner can read status file {0}; " + + "this may allows others to have access to the key needed to communicate with NiFi. " + + "Permissions should be changed so that only the owner can read this file", statusFile); + } - try { - final Set perms = new HashSet<>(); - perms.add(PosixFilePermission.OWNER_READ); - perms.add(PosixFilePermission.OWNER_WRITE); - Files.setPosixFilePermissions(statusFile.toPath(), perms); - } catch (final Exception e) { - logger.warning("Failed to set permissions so that only the owner can read status file " + statusFile + "; this may allows others to have access to the key needed to communicate with NiFi. Permissions should be changed so that only the owner can read this file"); - } - try (final FileOutputStream fos = new FileOutputStream(statusFile)) { nifiProps.store(fos, null); fos.getFD().sync(); } - - logger.fine("Saved Properties " + nifiProps + " to " + statusFile); - } - private boolean isPingSuccessful(final int port, final String secretKey) { - logger.fine("Pinging " + port); - - try (final Socket socket = new Socket("localhost", port)) { + logger.log(Level.FINE, "Saved Properties {0} to {1}", new Object[]{nifiProps, statusFile}); + } + + private boolean isPingSuccessful(final int port, final String secretKey) { + logger.log(Level.FINE, "Pinging {0}", port); + + try (final Socket socket = new Socket("localhost", port)) { final OutputStream out = socket.getOutputStream(); out.write((PING_CMD + " " + secretKey + "\n").getBytes(StandardCharsets.UTF_8)); out.flush(); @@ -270,106 +275,106 @@ public class RunNiFi { final InputStream in = socket.getInputStream(); final BufferedReader reader = new BufferedReader(new InputStreamReader(in)); final String response = reader.readLine(); - logger.fine("PING response: " + response); - - return PING_CMD.equals(response); - } catch (final IOException ioe) { - return false; - } - } - - private Integer getCurrentPort() throws IOException { - final Properties props = loadProperties(); - final String portVal = props.getProperty("port"); - if ( portVal == null ) { - logger.fine("No Port found in status file"); - return null; - } else { - logger.fine("Port defined in status file: " + portVal); - } - - final int port = Integer.parseInt(portVal); - final boolean success = isPingSuccessful(port, props.getProperty("secret.key")); - if ( success ) { - logger.fine("Successful PING on port " + port); - return port; - } + logger.log(Level.FINE, "PING response: {0}", response); + out.close(); + reader.close(); - final String pid = props.getProperty("pid"); - logger.fine("PID in status file is " + pid); - if ( pid != null ) { - final boolean procRunning = isProcessRunning(pid); - if ( procRunning ) { - return port; - } else { - return null; - } - } - - return null; - } - - - private boolean isProcessRunning(final String pid) { - try { - // We use the "ps" command to check if the process is still running. - final ProcessBuilder builder = new ProcessBuilder(); - - builder.command("ps", "-p", pid); - final Process proc = builder.start(); - - // Look for the pid in the output of the 'ps' command. - boolean running = false; - String line; - try (final InputStream in = proc.getInputStream(); - final Reader streamReader = new InputStreamReader(in); - final BufferedReader reader = new BufferedReader(streamReader)) { - - while ((line = reader.readLine()) != null) { - if ( line.trim().startsWith(pid) ) { + return PING_CMD.equals(response); + } catch (final IOException ioe) { + return false; + } + } + + private Integer getCurrentPort() throws IOException { + final Properties props = loadProperties(); + final String portVal = props.getProperty("port"); + if (portVal == null) { + logger.fine("No Port found in status file"); + return null; + } else { + logger.log(Level.FINE, "Port defined in status file: {0}", portVal); + } + + final int port = Integer.parseInt(portVal); + final boolean success = isPingSuccessful(port, props.getProperty("secret.key")); + if (success) { + logger.log(Level.FINE, "Successful PING on port {0}", port); + return port; + } + + final String pid = props.getProperty("pid"); + logger.log(Level.FINE, "PID in status file is {0}", pid); + if (pid != null) { + final boolean procRunning = isProcessRunning(pid); + if (procRunning) { + return port; + } else { + return null; + } + } + + return null; + } + + private boolean isProcessRunning(final String pid) { + try { + // We use the "ps" command to check if the process is still running. + final ProcessBuilder builder = new ProcessBuilder(); + + builder.command("ps", "-p", pid); + final Process proc = builder.start(); + + // Look for the pid in the output of the 'ps' command. + boolean running = false; + String line; + try (final InputStream in = proc.getInputStream(); + final Reader streamReader = new InputStreamReader(in); + final BufferedReader reader = new BufferedReader(streamReader)) { + + while ((line = reader.readLine()) != null) { + if (line.trim().startsWith(pid)) { running = true; } - } - } - - // If output of the ps command had our PID, the process is running. - if ( running ) { - logger.fine("Process with PID " + pid + " is running"); - } else { - logger.fine("Process with PID " + pid + " is not running"); - } - - return running; - } catch (final IOException ioe) { - System.err.println("Failed to determine if Process " + pid + " is running; assuming that it is not"); - return false; - } - } - - - private Status getStatus() { - final Properties props; - try { - props = loadProperties(); - } catch (final IOException ioe) { - return new Status(null, null, false, false); - } - - if ( props == null ) { - return new Status(null, null, false, false); - } - + } + } + + // If output of the ps command had our PID, the process is running. + if (running) { + logger.log(Level.FINE, "Process with PID {0} is running", pid); + } else { + logger.log(Level.FINE, "Process with PID {0} is not running", pid); + } + + return running; + } catch (final IOException ioe) { + System.err.println("Failed to determine if Process " + pid + " is running; assuming that it is not"); + return false; + } + } + + private Status getStatus() { + final Properties props; + try { + props = loadProperties(); + } catch (final IOException ioe) { + return new Status(null, null, false, false); + } + + if (props == null) { + return new Status(null, null, false, false); + } + final String portValue = props.getProperty("port"); final String pid = props.getProperty("pid"); final String secretKey = props.getProperty("secret.key"); - - if ( portValue == null && pid == null ) { + + if (portValue == null && pid == null) { return new Status(null, null, false, false); } - + Integer port = null; boolean pingSuccess = false; - if ( portValue != null ) { + if (portValue != null) { try { port = Integer.parseInt(portValue); pingSuccess = isPingSuccessful(port, secretKey); @@ -377,577 +382,582 @@ public class RunNiFi { return new Status(null, null, false, false); } } - - if ( pingSuccess ) { + + if (pingSuccess) { return new Status(port, pid, true, true); } - + final boolean alive = (pid == null) ? false : isProcessRunning(pid); return new Status(port, pid, pingSuccess, alive); - } - - public void status() throws IOException { - final Status status = getStatus(); - if ( status.isRespondingToPing() ) { - logger.info("Apache NiFi is currently running, listening to Bootstrap on port " + status.getPort() + - ", PID=" + (status.getPid() == null ? "unknkown" : status.getPid())); - return; - } + } - if ( status.isProcessRunning() ) { - logger.info("Apache NiFi is running at PID " + status.getPid() + " but is not responding to ping requests"); - return; - } - - if ( status.getPort() == null ) { - logger.info("Apache NiFi is not running"); - return; - } - - if ( status.getPid() == null ) { - logger.info("Apache NiFi is not responding to Ping requests. The process may have died or may be hung"); - } else { - logger.info("Apache NiFi is not running"); - } - } - - - /** - * Writes a NiFi thread dump to the given file; if file is null, logs at INFO level instead. - * @param dumpFile - * @return - * @throws IOException - */ - public void dump(final File dumpFile) throws IOException { - final Integer port = getCurrentPort(); - if ( port == null ) { - System.out.println("Apache NiFi is not currently running"); + public void status() throws IOException { + final Status status = getStatus(); + if (status.isRespondingToPing()) { + logger.log(Level.INFO, "Apache NiFi is currently running, listening to Bootstrap on port {0}, PID={1}", + new Object[]{status.getPort(), status.getPid() == null ? "unknkown" : status.getPid()}); + return; } - + + if (status.isProcessRunning()) { + logger.log(Level.INFO, "Apache NiFi is running at PID {0} but is not responding to ping requests", status.getPid()); + return; + } + + if (status.getPort() == null) { + logger.info("Apache NiFi is not running"); + return; + } + + if (status.getPid() == null) { + logger.info("Apache NiFi is not responding to Ping requests. The process may have died or may be hung"); + } else { + logger.info("Apache NiFi is not running"); + } + } + + /** + * Writes a NiFi thread dump to the given file; if file is null, logs at + * INFO level instead. + * + * @param dumpFile the file to write the dump content to + * @throws IOException if any issues occur while writing the dump file + */ + public void dump(final File dumpFile) throws IOException { + final Integer port = getCurrentPort(); + if (port == null) { + System.out.println("Apache NiFi is not currently running"); + return; + } + final Properties nifiProps = loadProperties(); final String secretKey = nifiProps.getProperty("secret.key"); final StringBuilder sb = new StringBuilder(); - try (final Socket socket = new Socket()) { + try (final Socket socket = new Socket()) { logger.fine("Connecting to NiFi instance"); socket.setSoTimeout(60000); socket.connect(new InetSocketAddress("localhost", port)); logger.fine("Established connection to NiFi instance."); socket.setSoTimeout(60000); - - logger.fine("Sending DUMP Command to port " + port); + + logger.log(Level.FINE, "Sending DUMP Command to port {0}", port); final OutputStream out = socket.getOutputStream(); out.write((DUMP_CMD + " " + secretKey + "\n").getBytes(StandardCharsets.UTF_8)); out.flush(); - + out.close(); + final InputStream in = socket.getInputStream(); final BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String line; - while ((line = reader.readLine()) != null ) { + while ((line = reader.readLine()) != null) { sb.append(line).append("\n"); } + reader.close(); } - - final String dump = sb.toString(); - if ( dumpFile == null ) { - logger.info(dump); - } else { - try (final FileOutputStream fos = new FileOutputStream(dumpFile)) { - fos.write(dump.getBytes(StandardCharsets.UTF_8)); - } - logger.info("Successfully wrote thread dump to " + dumpFile.getAbsolutePath()); - } - } - - public void stop() throws IOException { - final Integer port = getCurrentPort(); - if ( port == null ) { - System.out.println("Apache NiFi is not currently running"); - return; - } - - final Properties nifiProps = loadProperties(); - final String secretKey = nifiProps.getProperty("secret.key"); - - try (final Socket socket = new Socket()) { - logger.fine("Connecting to NiFi instance"); - socket.setSoTimeout(60000); - socket.connect(new InetSocketAddress("localhost", port)); - logger.fine("Established connection to NiFi instance."); - socket.setSoTimeout(60000); - - logger.fine("Sending SHUTDOWN Command to port " + port); - final OutputStream out = socket.getOutputStream(); - out.write((SHUTDOWN_CMD + " " + secretKey + "\n").getBytes(StandardCharsets.UTF_8)); - out.flush(); - - final InputStream in = socket.getInputStream(); - final BufferedReader reader = new BufferedReader(new InputStreamReader(in)); - final String response = reader.readLine(); - - logger.fine("Received response to SHUTDOWN command: " + response); - - if ( SHUTDOWN_CMD.equals(response) ) { - logger.info("Apache NiFi has accepted the Shutdown Command and is shutting down now"); - - final String pid = nifiProps.getProperty("pid"); - if ( pid != null ) { - final Properties bootstrapProperties = new Properties(); - try (final FileInputStream fis = new FileInputStream(bootstrapConfigFile)) { - bootstrapProperties.load(fis); - } - String gracefulShutdown = bootstrapProperties.getProperty(GRACEFUL_SHUTDOWN_PROP, DEFAULT_GRACEFUL_SHUTDOWN_VALUE); - int gracefulShutdownSeconds; - try { - gracefulShutdownSeconds = Integer.parseInt(gracefulShutdown); - } catch (final NumberFormatException nfe) { - gracefulShutdownSeconds = Integer.parseInt(DEFAULT_GRACEFUL_SHUTDOWN_VALUE); - } - - final long startWait = System.nanoTime(); - while ( isProcessRunning(pid) ) { - logger.info("Waiting for Apache NiFi to finish shutting down..."); - final long waitNanos = System.nanoTime() - startWait; - final long waitSeconds = TimeUnit.NANOSECONDS.toSeconds(waitNanos); - if ( waitSeconds >= gracefulShutdownSeconds && gracefulShutdownSeconds > 0 ) { - if ( isProcessRunning(pid) ) { - logger.warning("NiFi has not finished shutting down after " + gracefulShutdownSeconds + " seconds. Killing process."); - try { - killProcessTree(pid); - } catch (final IOException ioe) { - logger.severe("Failed to kill Process with PID " + pid); - } - } - break; - } else { - try { - Thread.sleep(2000L); - } catch (final InterruptedException ie) {} - } - } - - logger.info("NiFi has finished shutting down."); - } - - final File statusFile = getStatusFile(); - if ( !statusFile.delete() ) { - logger.severe("Failed to delete status file " + statusFile + "; this file should be cleaned up manually"); - } - } else { - logger.severe("When sending SHUTDOWN command to NiFi, got unexpected response " + response); - } - } catch (final IOException ioe) { - logger.severe("Failed to send shutdown command to port " + port + " due to " + ioe); - return; - } - } - - - private static List getChildProcesses(final String ppid) throws IOException { - final Process proc = Runtime.getRuntime().exec(new String[] {"ps", "-o", "pid", "--no-headers", "--ppid", ppid}); - final List childPids = new ArrayList<>(); - try (final InputStream in = proc.getInputStream(); - final BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { - - String line; - while ((line = reader.readLine()) != null) { - childPids.add(line.trim()); - } - } - - return childPids; - } - - private void killProcessTree(final String pid) throws IOException { - logger.fine("Killing Process Tree for PID " + pid); - - final List children = getChildProcesses(pid); - logger.fine("Children of PID " + pid + ": " + children); - - for ( final String childPid : children ) { - killProcessTree(childPid); - } - - Runtime.getRuntime().exec(new String[] {"kill", "-9", pid}); - } - - public static boolean isAlive(final Process process) { - try { - process.exitValue(); - return false; - } catch (final IllegalStateException | IllegalThreadStateException itse) { - return true; - } - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - public void start(final boolean monitor) throws IOException, InterruptedException { - final Integer port = getCurrentPort(); - if ( port != null ) { - System.out.println("Apache NiFi is already running, listening to Bootstrap on port " + port); - return; - } - - final ProcessBuilder builder = new ProcessBuilder(); + final String dump = sb.toString(); + if (dumpFile == null) { + logger.info(dump); + } else { + try (final FileOutputStream fos = new FileOutputStream(dumpFile)) { + fos.write(dump.getBytes(StandardCharsets.UTF_8)); + } + logger.log(Level.INFO, "Successfully wrote thread dump to {0}", dumpFile.getAbsolutePath()); + } + } - if ( !bootstrapConfigFile.exists() ) { - throw new FileNotFoundException(bootstrapConfigFile.getAbsolutePath()); - } - - final Properties properties = new Properties(); - try (final FileInputStream fis = new FileInputStream(bootstrapConfigFile)) { - properties.load(fis); - } - - final Map props = new HashMap<>(); - props.putAll( (Map) properties ); + public void stop() throws IOException { + final Integer port = getCurrentPort(); + if (port == null) { + System.out.println("Apache NiFi is not currently running"); + return; + } - final String specifiedWorkingDir = props.get("working.dir"); - if ( specifiedWorkingDir != null ) { - builder.directory(new File(specifiedWorkingDir)); - } + final Properties nifiProps = loadProperties(); + final String secretKey = nifiProps.getProperty("secret.key"); - final File bootstrapConfigAbsoluteFile = bootstrapConfigFile.getAbsoluteFile(); - final File binDir = bootstrapConfigAbsoluteFile.getParentFile(); - final File workingDir = binDir.getParentFile(); - - if ( specifiedWorkingDir == null ) { - builder.directory(workingDir); - } - - final String libFilename = replaceNull(props.get("lib.dir"), "./lib").trim(); - File libDir = getFile(libFilename, workingDir); - - final String confFilename = replaceNull(props.get("conf.dir"), "./conf").trim(); - File confDir = getFile(confFilename, workingDir); - - String nifiPropsFilename = props.get("props.file"); - if ( nifiPropsFilename == null ) { - if ( confDir.exists() ) { - nifiPropsFilename = new File(confDir, "nifi.properties").getAbsolutePath(); - } else { - nifiPropsFilename = DEFAULT_CONFIG_FILE; - } - } - - nifiPropsFilename = nifiPropsFilename.trim(); - - final List javaAdditionalArgs = new ArrayList<>(); - for ( final Map.Entry entry : props.entrySet() ) { - final String key = entry.getKey(); - final String value = entry.getValue(); - - if ( key.startsWith("java.arg") ) { - javaAdditionalArgs.add(value); - } - } - - final File[] libFiles = libDir.listFiles(new FilenameFilter() { - @Override - public boolean accept(final File dir, final String filename) { - return filename.toLowerCase().endsWith(".jar"); - } - }); - - if ( libFiles == null || libFiles.length == 0 ) { - throw new RuntimeException("Could not find lib directory at " + libDir.getAbsolutePath()); - } - - final File[] confFiles = confDir.listFiles(); - if ( confFiles == null || confFiles.length == 0 ) { - throw new RuntimeException("Could not find conf directory at " + confDir.getAbsolutePath()); - } + try (final Socket socket = new Socket()) { + logger.fine("Connecting to NiFi instance"); + socket.setSoTimeout(60000); + socket.connect(new InetSocketAddress("localhost", port)); + logger.fine("Established connection to NiFi instance."); + socket.setSoTimeout(60000); - final List cpFiles = new ArrayList<>(confFiles.length + libFiles.length); - cpFiles.add(confDir.getAbsolutePath()); - for ( final File file : libFiles ) { - cpFiles.add(file.getAbsolutePath()); - } - - final StringBuilder classPathBuilder = new StringBuilder(); - for (int i=0; i < cpFiles.size(); i++) { - final String filename = cpFiles.get(i); - classPathBuilder.append(filename); - if ( i < cpFiles.size() - 1 ) { - classPathBuilder.append(File.pathSeparatorChar); - } - } + logger.log(Level.FINE, "Sending SHUTDOWN Command to port {0}", port); + final OutputStream out = socket.getOutputStream(); + out.write((SHUTDOWN_CMD + " " + secretKey + "\n").getBytes(StandardCharsets.UTF_8)); + out.flush(); + out.close(); - final String classPath = classPathBuilder.toString(); - String javaCmd = props.get("java"); - if (javaCmd == null) { - javaCmd = DEFAULT_JAVA_CMD; - } - if (javaCmd.equals(DEFAULT_JAVA_CMD)) { - String javaHome = System.getenv("JAVA_HOME"); - if (javaHome != null) { - String fileExtension = isWindows() ? ".exe" : ""; - File javaFile = new File(javaHome + File.separatorChar + "bin" - + File.separatorChar + "java" + fileExtension); - if (javaFile.exists() && javaFile.canExecute()) { - javaCmd = javaFile.getAbsolutePath(); - } - } - } - - final NiFiListener listener = new NiFiListener(); - final int listenPort = listener.start(this); - - String runAs = isWindows() ? null : props.get(RUN_AS_PROP); - if ( runAs != null ) { - runAs = runAs.trim(); - if ( runAs.isEmpty() ) { - runAs = null; - } - } - - final List cmd = new ArrayList<>(); - if ( runAs != null ) { - cmd.add("sudo"); - cmd.add("-u"); - cmd.add(runAs); - } - cmd.add(javaCmd); - cmd.add("-classpath"); - cmd.add(classPath); - cmd.addAll(javaAdditionalArgs); - cmd.add("-Dnifi.properties.file.path=" + nifiPropsFilename); - cmd.add("-Dnifi.bootstrap.listen.port=" + listenPort); - cmd.add("-Dapp=NiFi"); - cmd.add("org.apache.nifi.NiFi"); - - builder.command(cmd); - - final StringBuilder cmdBuilder = new StringBuilder(); - for ( final String s : cmd ) { - cmdBuilder.append(s).append(" "); - } + final InputStream in = socket.getInputStream(); + final BufferedReader reader = new BufferedReader(new InputStreamReader(in)); + final String response = reader.readLine(); + reader.close(); - logger.info("Starting Apache NiFi..."); - logger.info("Working Directory: " + workingDir.getAbsolutePath()); - logger.info("Command: " + cmdBuilder.toString()); - - if ( monitor ) { - String gracefulShutdown = props.get(GRACEFUL_SHUTDOWN_PROP); - if ( gracefulShutdown == null ) { - gracefulShutdown = DEFAULT_GRACEFUL_SHUTDOWN_VALUE; - } + logger.log(Level.FINE, "Received response to SHUTDOWN command: {0}", response); - final int gracefulShutdownSeconds; - try { - gracefulShutdownSeconds = Integer.parseInt(gracefulShutdown); - } catch (final NumberFormatException nfe) { - throw new NumberFormatException("The '" + GRACEFUL_SHUTDOWN_PROP + "' property in Bootstrap Config File " + bootstrapConfigAbsoluteFile.getAbsolutePath() + " has an invalid value. Must be a non-negative integer"); - } - - if ( gracefulShutdownSeconds < 0 ) { - throw new NumberFormatException("The '" + GRACEFUL_SHUTDOWN_PROP + "' property in Bootstrap Config File " + bootstrapConfigAbsoluteFile.getAbsolutePath() + " has an invalid value. Must be a non-negative integer"); - } - - Process process = builder.start(); - Long pid = getPid(process); - if ( pid != null ) { + if (SHUTDOWN_CMD.equals(response)) { + logger.info("Apache NiFi has accepted the Shutdown Command and is shutting down now"); + + final String pid = nifiProps.getProperty("pid"); + if (pid != null) { + final Properties bootstrapProperties = new Properties(); + try (final FileInputStream fis = new FileInputStream(bootstrapConfigFile)) { + bootstrapProperties.load(fis); + } + + String gracefulShutdown = bootstrapProperties.getProperty(GRACEFUL_SHUTDOWN_PROP, DEFAULT_GRACEFUL_SHUTDOWN_VALUE); + int gracefulShutdownSeconds; + try { + gracefulShutdownSeconds = Integer.parseInt(gracefulShutdown); + } catch (final NumberFormatException nfe) { + gracefulShutdownSeconds = Integer.parseInt(DEFAULT_GRACEFUL_SHUTDOWN_VALUE); + } + + final long startWait = System.nanoTime(); + while (isProcessRunning(pid)) { + logger.info("Waiting for Apache NiFi to finish shutting down..."); + final long waitNanos = System.nanoTime() - startWait; + final long waitSeconds = TimeUnit.NANOSECONDS.toSeconds(waitNanos); + if (waitSeconds >= gracefulShutdownSeconds && gracefulShutdownSeconds > 0) { + if (isProcessRunning(pid)) { + logger.log(Level.WARNING, "NiFi has not finished shutting down after {0} seconds. Killing process.", gracefulShutdownSeconds); + try { + killProcessTree(pid); + } catch (final IOException ioe) { + logger.log(Level.SEVERE, "Failed to kill Process with PID {0}", pid); + } + } + break; + } else { + try { + Thread.sleep(2000L); + } catch (final InterruptedException ie) { + } + } + } + + logger.info("NiFi has finished shutting down."); + } + + final File statusFile = getStatusFile(); + if (!statusFile.delete()) { + logger.log(Level.SEVERE, "Failed to delete status file {0}; this file should be cleaned up manually", statusFile); + } + } else { + logger.log(Level.SEVERE, "When sending SHUTDOWN command to NiFi, got unexpected response {0}", response); + } + } catch (final IOException ioe) { + logger.log(Level.SEVERE, "Failed to send shutdown command to port {0} due to {1}", new Object[]{port, ioe}); + } + } + + private static List getChildProcesses(final String ppid) throws IOException { + final Process proc = Runtime.getRuntime().exec(new String[]{"ps", "-o", "pid", "--no-headers", "--ppid", ppid}); + final List childPids = new ArrayList<>(); + try (final InputStream in = proc.getInputStream(); + final BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { + + String line; + while ((line = reader.readLine()) != null) { + childPids.add(line.trim()); + } + } + + return childPids; + } + + private void killProcessTree(final String pid) throws IOException { + logger.log(Level.FINE, "Killing Process Tree for PID {0}", pid); + + final List children = getChildProcesses(pid); + logger.log(Level.FINE, "Children of PID {0}: {1}", new Object[]{pid, children}); + + for (final String childPid : children) { + killProcessTree(childPid); + } + + Runtime.getRuntime().exec(new String[]{"kill", "-9", pid}); + } + + public static boolean isAlive(final Process process) { + try { + process.exitValue(); + return false; + } catch (final IllegalStateException | IllegalThreadStateException itse) { + return true; + } + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + public void start(final boolean monitor) throws IOException, InterruptedException { + final Integer port = getCurrentPort(); + if (port != null) { + System.out.println("Apache NiFi is already running, listening to Bootstrap on port " + port); + return; + } + + final ProcessBuilder builder = new ProcessBuilder(); + + if (!bootstrapConfigFile.exists()) { + throw new FileNotFoundException(bootstrapConfigFile.getAbsolutePath()); + } + + final Properties properties = new Properties(); + try (final FileInputStream fis = new FileInputStream(bootstrapConfigFile)) { + properties.load(fis); + } + + final Map props = new HashMap<>(); + props.putAll((Map) properties); + + final String specifiedWorkingDir = props.get("working.dir"); + if (specifiedWorkingDir != null) { + builder.directory(new File(specifiedWorkingDir)); + } + + final File bootstrapConfigAbsoluteFile = bootstrapConfigFile.getAbsoluteFile(); + final File binDir = bootstrapConfigAbsoluteFile.getParentFile(); + final File workingDir = binDir.getParentFile(); + + if (specifiedWorkingDir == null) { + builder.directory(workingDir); + } + + final String libFilename = replaceNull(props.get("lib.dir"), "./lib").trim(); + File libDir = getFile(libFilename, workingDir); + + final String confFilename = replaceNull(props.get("conf.dir"), "./conf").trim(); + File confDir = getFile(confFilename, workingDir); + + String nifiPropsFilename = props.get("props.file"); + if (nifiPropsFilename == null) { + if (confDir.exists()) { + nifiPropsFilename = new File(confDir, "nifi.properties").getAbsolutePath(); + } else { + nifiPropsFilename = DEFAULT_CONFIG_FILE; + } + } + + nifiPropsFilename = nifiPropsFilename.trim(); + + final List javaAdditionalArgs = new ArrayList<>(); + for (final Map.Entry entry : props.entrySet()) { + final String key = entry.getKey(); + final String value = entry.getValue(); + + if (key.startsWith("java.arg")) { + javaAdditionalArgs.add(value); + } + } + + final File[] libFiles = libDir.listFiles(new FilenameFilter() { + @Override + public boolean accept(final File dir, final String filename) { + return filename.toLowerCase().endsWith(".jar"); + } + }); + + if (libFiles == null || libFiles.length == 0) { + throw new RuntimeException("Could not find lib directory at " + libDir.getAbsolutePath()); + } + + final File[] confFiles = confDir.listFiles(); + if (confFiles == null || confFiles.length == 0) { + throw new RuntimeException("Could not find conf directory at " + confDir.getAbsolutePath()); + } + + final List cpFiles = new ArrayList<>(confFiles.length + libFiles.length); + cpFiles.add(confDir.getAbsolutePath()); + for (final File file : libFiles) { + cpFiles.add(file.getAbsolutePath()); + } + + final StringBuilder classPathBuilder = new StringBuilder(); + for (int i = 0; i < cpFiles.size(); i++) { + final String filename = cpFiles.get(i); + classPathBuilder.append(filename); + if (i < cpFiles.size() - 1) { + classPathBuilder.append(File.pathSeparatorChar); + } + } + + final String classPath = classPathBuilder.toString(); + String javaCmd = props.get("java"); + if (javaCmd == null) { + javaCmd = DEFAULT_JAVA_CMD; + } + if (javaCmd.equals(DEFAULT_JAVA_CMD)) { + String javaHome = System.getenv("JAVA_HOME"); + if (javaHome != null) { + String fileExtension = isWindows() ? ".exe" : ""; + File javaFile = new File(javaHome + File.separatorChar + "bin" + + File.separatorChar + "java" + fileExtension); + if (javaFile.exists() && javaFile.canExecute()) { + javaCmd = javaFile.getAbsolutePath(); + } + } + } + + final NiFiListener listener = new NiFiListener(); + final int listenPort = listener.start(this); + + String runAs = isWindows() ? null : props.get(RUN_AS_PROP); + if (runAs != null) { + runAs = runAs.trim(); + if (runAs.isEmpty()) { + runAs = null; + } + } + + final List cmd = new ArrayList<>(); + if (runAs != null) { + cmd.add("sudo"); + cmd.add("-u"); + cmd.add(runAs); + } + cmd.add(javaCmd); + cmd.add("-classpath"); + cmd.add(classPath); + cmd.addAll(javaAdditionalArgs); + cmd.add("-Dnifi.properties.file.path=" + nifiPropsFilename); + cmd.add("-Dnifi.bootstrap.listen.port=" + listenPort); + cmd.add("-Dapp=NiFi"); + cmd.add("org.apache.nifi.NiFi"); + + builder.command(cmd); + + final StringBuilder cmdBuilder = new StringBuilder(); + for (final String s : cmd) { + cmdBuilder.append(s).append(" "); + } + + logger.info("Starting Apache NiFi..."); + logger.log(Level.INFO, "Working Directory: {0}", workingDir.getAbsolutePath()); + logger.log(Level.INFO, "Command: {0}", cmdBuilder.toString()); + + if (monitor) { + String gracefulShutdown = props.get(GRACEFUL_SHUTDOWN_PROP); + if (gracefulShutdown == null) { + gracefulShutdown = DEFAULT_GRACEFUL_SHUTDOWN_VALUE; + } + + final int gracefulShutdownSeconds; + try { + gracefulShutdownSeconds = Integer.parseInt(gracefulShutdown); + } catch (final NumberFormatException nfe) { + throw new NumberFormatException("The '" + GRACEFUL_SHUTDOWN_PROP + "' property in Bootstrap Config File " + + bootstrapConfigAbsoluteFile.getAbsolutePath() + " has an invalid value. Must be a non-negative integer"); + } + + if (gracefulShutdownSeconds < 0) { + throw new NumberFormatException("The '" + GRACEFUL_SHUTDOWN_PROP + "' property in Bootstrap Config File " + + bootstrapConfigAbsoluteFile.getAbsolutePath() + " has an invalid value. Must be a non-negative integer"); + } + + Process process = builder.start(); + Long pid = getPid(process); + if (pid != null) { nifiPid = pid; final Properties nifiProps = new Properties(); nifiProps.setProperty("pid", String.valueOf(nifiPid)); saveProperties(nifiProps); } - - shutdownHook = new ShutdownHook(process, this, secretKey, gracefulShutdownSeconds); - final Runtime runtime = Runtime.getRuntime(); - runtime.addShutdownHook(shutdownHook); - - while (true) { - final boolean alive = isAlive(process); - - if ( alive ) { - try { - Thread.sleep(1000L); - } catch (final InterruptedException ie) { - } - } else { - try { - runtime.removeShutdownHook(shutdownHook); - } catch (final IllegalStateException ise) { - // happens when already shutting down - } - - if (autoRestartNiFi) { - logger.warning("Apache NiFi appears to have died. Restarting..."); - process = builder.start(); - - pid = getPid(process); - if ( pid != null ) { - nifiPid = pid; - final Properties nifiProps = new Properties(); - nifiProps.setProperty("pid", String.valueOf(nifiPid)); - saveProperties(nifiProps); - } - - shutdownHook = new ShutdownHook(process, this, secretKey, gracefulShutdownSeconds); - runtime.addShutdownHook(shutdownHook); - - final boolean started = waitForStart(); - - if ( started ) { - logger.info("Successfully started Apache NiFi" + (pid == null ? "" : " with PID " + pid)); - } else { - logger.severe("Apache NiFi does not appear to have started"); - } - } else { - return; - } - } - } - } else { - final Process process = builder.start(); - final Long pid = getPid(process); - - if ( pid != null ) { - nifiPid = pid; + + shutdownHook = new ShutdownHook(process, this, secretKey, gracefulShutdownSeconds); + final Runtime runtime = Runtime.getRuntime(); + runtime.addShutdownHook(shutdownHook); + + while (true) { + final boolean alive = isAlive(process); + + if (alive) { + try { + Thread.sleep(1000L); + } catch (final InterruptedException ie) { + } + } else { + try { + runtime.removeShutdownHook(shutdownHook); + } catch (final IllegalStateException ise) { + // happens when already shutting down + } + + if (autoRestartNiFi) { + logger.warning("Apache NiFi appears to have died. Restarting..."); + process = builder.start(); + + pid = getPid(process); + if (pid != null) { + nifiPid = pid; + final Properties nifiProps = new Properties(); + nifiProps.setProperty("pid", String.valueOf(nifiPid)); + saveProperties(nifiProps); + } + + shutdownHook = new ShutdownHook(process, this, secretKey, gracefulShutdownSeconds); + runtime.addShutdownHook(shutdownHook); + + final boolean started = waitForStart(); + + if (started) { + logger.log(Level.INFO, "Successfully started Apache NiFi{0}", (pid == null ? "" : " with PID " + pid)); + } else { + logger.severe("Apache NiFi does not appear to have started"); + } + } else { + return; + } + } + } + } else { + final Process process = builder.start(); + final Long pid = getPid(process); + + if (pid != null) { + nifiPid = pid; final Properties nifiProps = new Properties(); nifiProps.setProperty("pid", String.valueOf(nifiPid)); saveProperties(nifiProps); - } - - boolean started = waitForStart(); - - if ( started ) { - logger.info("Successfully started Apache NiFi" + (pid == null ? "" : " with PID " + pid)); - } else { - logger.severe("Apache NiFi does not appear to have started"); - } - - listener.stop(); - } - } - - - private Long getPid(final Process process) { - try { + } + + boolean started = waitForStart(); + + if (started) { + logger.log(Level.INFO, "Successfully started Apache NiFi{0}", (pid == null ? "" : " with PID " + pid)); + } else { + logger.severe("Apache NiFi does not appear to have started"); + } + + listener.stop(); + } + } + + private Long getPid(final Process process) { + try { final Class procClass = process.getClass(); final Field pidField = procClass.getDeclaredField("pid"); pidField.setAccessible(true); final Object pidObject = pidField.get(process); - - logger.fine("PID Object = " + pidObject); - - if ( pidObject instanceof Number ) { + + logger.log(Level.FINE, "PID Object = {0}", pidObject); + + if (pidObject instanceof Number) { return ((Number) pidObject).longValue(); } return null; } catch (final IllegalAccessException | NoSuchFieldException nsfe) { - logger.fine("Could not find PID for child process due to " + nsfe); + logger.log(Level.FINE, "Could not find PID for child process due to {0}", nsfe); return null; } - } - - private boolean isWindows() { - final String osName = System.getProperty("os.name"); - return osName != null && osName.toLowerCase().contains("win"); - } - - private boolean waitForStart() { - lock.lock(); - try { - final long startTime = System.nanoTime(); - - while ( ccPort < 1 ) { - try { - startupCondition.await(1, TimeUnit.SECONDS); - } catch (final InterruptedException ie) { - return false; - } - - final long waitNanos = System.nanoTime() - startTime; - final long waitSeconds = TimeUnit.NANOSECONDS.toSeconds(waitNanos); - if (waitSeconds > STARTUP_WAIT_SECONDS) { - return false; - } - } - } finally { - lock.unlock(); - } - return true; - } - - private File getFile(final String filename, final File workingDir) { - File file = new File(filename); - if ( !file.isAbsolute() ) { - file = new File(workingDir, filename); - } - - return file; - } - - private String replaceNull(final String value, final String replacement) { - return (value == null) ? replacement : value; - } - - void setAutoRestartNiFi(final boolean restart) { - this.autoRestartNiFi = restart; - } - - void setNiFiCommandControlPort(final int port, final String secretKey) { - this.ccPort = port; - this.secretKey = secretKey; - - if ( shutdownHook != null ) { - shutdownHook.setSecretKey(secretKey); - } - - final File statusFile = getStatusFile(); - - final Properties nifiProps = new Properties(); - if ( nifiPid != -1 ) { - nifiProps.setProperty("pid", String.valueOf(nifiPid)); - } - nifiProps.setProperty("port", String.valueOf(ccPort)); - nifiProps.setProperty("secret.key", secretKey); - - try { - saveProperties(nifiProps); - } catch (final IOException ioe) { - logger.warning("Apache NiFi has started but failed to persist NiFi Port information to " + statusFile.getAbsolutePath() + " due to " + ioe); - } - - logger.info("Apache NiFi now running and listening for Bootstrap requests on port " + port); - } - - int getNiFiCommandControlPort() { - return this.ccPort; - } - - - private static class Status { - private final Integer port; - private final String pid; - - private final Boolean respondingToPing; - private final Boolean processRunning; - - public Status(final Integer port, final String pid, final Boolean respondingToPing, final Boolean processRunning) { - this.port = port; - this.pid = pid; - this.respondingToPing = respondingToPing; - this.processRunning = processRunning; - } - - public String getPid() { - return pid; - } - - public Integer getPort() { - return port; - } - - public boolean isRespondingToPing() { - return Boolean.TRUE.equals(respondingToPing); - } - + } + + private boolean isWindows() { + final String osName = System.getProperty("os.name"); + return osName != null && osName.toLowerCase().contains("win"); + } + + private boolean waitForStart() { + lock.lock(); + try { + final long startTime = System.nanoTime(); + + while (ccPort < 1) { + try { + startupCondition.await(1, TimeUnit.SECONDS); + } catch (final InterruptedException ie) { + return false; + } + + final long waitNanos = System.nanoTime() - startTime; + final long waitSeconds = TimeUnit.NANOSECONDS.toSeconds(waitNanos); + if (waitSeconds > STARTUP_WAIT_SECONDS) { + return false; + } + } + } finally { + lock.unlock(); + } + return true; + } + + private File getFile(final String filename, final File workingDir) { + File file = new File(filename); + if (!file.isAbsolute()) { + file = new File(workingDir, filename); + } + + return file; + } + + private String replaceNull(final String value, final String replacement) { + return (value == null) ? replacement : value; + } + + void setAutoRestartNiFi(final boolean restart) { + this.autoRestartNiFi = restart; + } + + void setNiFiCommandControlPort(final int port, final String secretKey) { + this.ccPort = port; + this.secretKey = secretKey; + + if (shutdownHook != null) { + shutdownHook.setSecretKey(secretKey); + } + + final File statusFile = getStatusFile(); + + final Properties nifiProps = new Properties(); + if (nifiPid != -1) { + nifiProps.setProperty("pid", String.valueOf(nifiPid)); + } + nifiProps.setProperty("port", String.valueOf(ccPort)); + nifiProps.setProperty("secret.key", secretKey); + + try { + saveProperties(nifiProps); + } catch (final IOException ioe) { + logger.log(Level.WARNING, "Apache NiFi has started but failed to persist NiFi Port information to {0} due to {1}", new Object[]{statusFile.getAbsolutePath(), ioe}); + } + + logger.log(Level.INFO, "Apache NiFi now running and listening for Bootstrap requests on port {0}", port); + } + + int getNiFiCommandControlPort() { + return this.ccPort; + } + + private static class Status { + + private final Integer port; + private final String pid; + + private final Boolean respondingToPing; + private final Boolean processRunning; + + public Status(final Integer port, final String pid, final Boolean respondingToPing, final Boolean processRunning) { + this.port = port; + this.pid = pid; + this.respondingToPing = respondingToPing; + this.processRunning = processRunning; + } + + public String getPid() { + return pid; + } + + public Integer getPort() { + return port; + } + + public boolean isRespondingToPing() { + return Boolean.TRUE.equals(respondingToPing); + } + public boolean isProcessRunning() { return Boolean.TRUE.equals(processRunning); } - } + } } diff --git a/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/ShutdownHook.java b/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/ShutdownHook.java index 3d3a241328..023ab84e64 100644 --- a/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/ShutdownHook.java +++ b/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/ShutdownHook.java @@ -24,63 +24,65 @@ import java.nio.charset.StandardCharsets; import java.util.concurrent.TimeUnit; public class ShutdownHook extends Thread { - private final Process nifiProcess; - private final RunNiFi runner; - private final int gracefulShutdownSeconds; - - private volatile String secretKey; - - public ShutdownHook(final Process nifiProcess, final RunNiFi runner, final String secretKey, final int gracefulShutdownSeconds) { - this.nifiProcess = nifiProcess; - this.runner = runner; - this.secretKey = secretKey; - this.gracefulShutdownSeconds = gracefulShutdownSeconds; - } - - void setSecretKey(final String secretKey) { - this.secretKey = secretKey; - } - - @Override - public void run() { - runner.setAutoRestartNiFi(false); - final int ccPort = runner.getNiFiCommandControlPort(); - if ( ccPort > 0 ) { - System.out.println("Initiating Shutdown of NiFi..."); - - try { - final Socket socket = new Socket("localhost", ccPort); - final OutputStream out = socket.getOutputStream(); - out.write(("SHUTDOWN " + secretKey + "\n").getBytes(StandardCharsets.UTF_8)); - out.flush(); - - socket.close(); - } catch (final IOException ioe) { - System.out.println("Failed to Shutdown NiFi due to " + ioe); - } - } - - System.out.println("Waiting for Apache NiFi to finish shutting down..."); - final long startWait = System.nanoTime(); - while ( RunNiFi.isAlive(nifiProcess) ) { - final long waitNanos = System.nanoTime() - startWait; - final long waitSeconds = TimeUnit.NANOSECONDS.toSeconds(waitNanos); - if ( waitSeconds >= gracefulShutdownSeconds && gracefulShutdownSeconds > 0 ) { - if ( RunNiFi.isAlive(nifiProcess) ) { - System.out.println("NiFi has not finished shutting down after " + gracefulShutdownSeconds + " seconds. Killing process."); - nifiProcess.destroy(); - } - break; - } else { - try { - Thread.sleep(1000L); - } catch (final InterruptedException ie) {} - } - } - - final File statusFile = runner.getStatusFile(); - if ( !statusFile.delete() ) { - System.err.println("Failed to delete status file " + statusFile.getAbsolutePath() + "; this file should be cleaned up manually"); - } - } + + private final Process nifiProcess; + private final RunNiFi runner; + private final int gracefulShutdownSeconds; + + private volatile String secretKey; + + public ShutdownHook(final Process nifiProcess, final RunNiFi runner, final String secretKey, final int gracefulShutdownSeconds) { + this.nifiProcess = nifiProcess; + this.runner = runner; + this.secretKey = secretKey; + this.gracefulShutdownSeconds = gracefulShutdownSeconds; + } + + void setSecretKey(final String secretKey) { + this.secretKey = secretKey; + } + + @Override + public void run() { + runner.setAutoRestartNiFi(false); + final int ccPort = runner.getNiFiCommandControlPort(); + if (ccPort > 0) { + System.out.println("Initiating Shutdown of NiFi..."); + + try { + final Socket socket = new Socket("localhost", ccPort); + final OutputStream out = socket.getOutputStream(); + out.write(("SHUTDOWN " + secretKey + "\n").getBytes(StandardCharsets.UTF_8)); + out.flush(); + + socket.close(); + } catch (final IOException ioe) { + System.out.println("Failed to Shutdown NiFi due to " + ioe); + } + } + + System.out.println("Waiting for Apache NiFi to finish shutting down..."); + final long startWait = System.nanoTime(); + while (RunNiFi.isAlive(nifiProcess)) { + final long waitNanos = System.nanoTime() - startWait; + final long waitSeconds = TimeUnit.NANOSECONDS.toSeconds(waitNanos); + if (waitSeconds >= gracefulShutdownSeconds && gracefulShutdownSeconds > 0) { + if (RunNiFi.isAlive(nifiProcess)) { + System.out.println("NiFi has not finished shutting down after " + gracefulShutdownSeconds + " seconds. Killing process."); + nifiProcess.destroy(); + } + break; + } else { + try { + Thread.sleep(1000L); + } catch (final InterruptedException ie) { + } + } + } + + final File statusFile = runner.getStatusFile(); + if (!statusFile.delete()) { + System.err.println("Failed to delete status file " + statusFile.getAbsolutePath() + "; this file should be cleaned up manually"); + } + } } diff --git a/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/exception/InvalidCommandException.java b/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/exception/InvalidCommandException.java index 962aa1c39d..52e36b9a0e 100644 --- a/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/exception/InvalidCommandException.java +++ b/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/exception/InvalidCommandException.java @@ -17,21 +17,22 @@ package org.apache.nifi.bootstrap.exception; public class InvalidCommandException extends Exception { - private static final long serialVersionUID = 1L; - public InvalidCommandException() { - super(); - } - - public InvalidCommandException(final String message) { - super(message); - } - - public InvalidCommandException(final Throwable t) { - super(t); - } - - public InvalidCommandException(final String message, final Throwable t) { - super(message, t); - } + private static final long serialVersionUID = 1L; + + public InvalidCommandException() { + super(); + } + + public InvalidCommandException(final String message) { + super(message); + } + + public InvalidCommandException(final Throwable t) { + super(t); + } + + public InvalidCommandException(final String message, final Throwable t) { + super(message, t); + } } diff --git a/nifi/nifi-commons/nifi-data-provenance-utils/src/main/java/org/apache/nifi/provenance/AsyncLineageSubmission.java b/nifi/nifi-commons/nifi-data-provenance-utils/src/main/java/org/apache/nifi/provenance/AsyncLineageSubmission.java index dc24a93fe4..4a52a89bbf 100644 --- a/nifi/nifi-commons/nifi-data-provenance-utils/src/main/java/org/apache/nifi/provenance/AsyncLineageSubmission.java +++ b/nifi/nifi-commons/nifi-data-provenance-utils/src/main/java/org/apache/nifi/provenance/AsyncLineageSubmission.java @@ -27,6 +27,7 @@ import org.apache.nifi.provenance.lineage.LineageComputationType; * */ public class AsyncLineageSubmission implements ComputeLineageSubmission { + private final String lineageIdentifier = UUID.randomUUID().toString(); private final Date submissionTime = new Date(); diff --git a/nifi/nifi-commons/nifi-data-provenance-utils/src/main/java/org/apache/nifi/provenance/AsyncQuerySubmission.java b/nifi/nifi-commons/nifi-data-provenance-utils/src/main/java/org/apache/nifi/provenance/AsyncQuerySubmission.java index 42444762be..00c617052f 100644 --- a/nifi/nifi-commons/nifi-data-provenance-utils/src/main/java/org/apache/nifi/provenance/AsyncQuerySubmission.java +++ b/nifi/nifi-commons/nifi-data-provenance-utils/src/main/java/org/apache/nifi/provenance/AsyncQuerySubmission.java @@ -22,9 +22,6 @@ import java.util.concurrent.TimeUnit; import org.apache.nifi.provenance.search.Query; import org.apache.nifi.provenance.search.QuerySubmission; -/** - * - */ public class AsyncQuerySubmission implements QuerySubmission { public static final int TTL = (int) TimeUnit.MILLISECONDS.convert(60, TimeUnit.SECONDS); @@ -40,8 +37,8 @@ public class AsyncQuerySubmission implements QuerySubmission { * number of steps, indicating how many results must be added to this * AsyncQuerySubmission before it is considered finished * - * @param query - * @param numSteps + * @param query the query to execute + * @param numSteps how many steps to include */ public AsyncQuerySubmission(final Query query, final int numSteps) { this.query = query; diff --git a/nifi/nifi-commons/nifi-data-provenance-utils/src/main/java/org/apache/nifi/provenance/SearchableFields.java b/nifi/nifi-commons/nifi-data-provenance-utils/src/main/java/org/apache/nifi/provenance/SearchableFields.java index 97c988029a..de62bca813 100644 --- a/nifi/nifi-commons/nifi-data-provenance-utils/src/main/java/org/apache/nifi/provenance/SearchableFields.java +++ b/nifi/nifi-commons/nifi-data-provenance-utils/src/main/java/org/apache/nifi/provenance/SearchableFields.java @@ -41,14 +41,21 @@ public class SearchableFields { public static final SearchableField Details = new NamedSearchableField("Details", "details", "Details", false, SearchableFieldType.STRING); public static final SearchableField Relationship = new NamedSearchableField("Relationship", "relationship", "Relationship", false, SearchableFieldType.STRING); - public static final SearchableField LineageStartDate = new NamedSearchableField("LineageStartDate", "lineageStartDate", "Lineage Start Date", false, SearchableFieldType.DATE); - public static final SearchableField LineageIdentifier = new NamedSearchableField("LineageIdentifiers", "lineageIdentifier", "Lineage Identifier", false, SearchableFieldType.STRING); + public static final SearchableField LineageStartDate + = new NamedSearchableField("LineageStartDate", "lineageStartDate", "Lineage Start Date", false, SearchableFieldType.DATE); + public static final SearchableField LineageIdentifier + = new NamedSearchableField("LineageIdentifiers", "lineageIdentifier", "Lineage Identifier", false, SearchableFieldType.STRING); - public static final SearchableField ContentClaimSection = new NamedSearchableField("ContentClaimSection", "contentClaimSection", "Content Claim Section", false, SearchableFieldType.STRING); - public static final SearchableField ContentClaimContainer = new NamedSearchableField("ContentClaimContainer", "contentClaimContainer", "Content Claim Container", false, SearchableFieldType.STRING); - public static final SearchableField ContentClaimIdentifier = new NamedSearchableField("ContentClaimIdentifier", "contentClaimIdentifier", "Content Claim Identifier", false, SearchableFieldType.STRING); - public static final SearchableField ContentClaimOffset = new NamedSearchableField("ContentClaimOffset", "contentClaimOffset", "Content Claim Offset", false, SearchableFieldType.LONG); - public static final SearchableField SourceQueueIdentifier = new NamedSearchableField("SourceQueueIdentifier", "sourceQueueIdentifier", "Source Queue Identifier", false, SearchableFieldType.STRING); + public static final SearchableField ContentClaimSection + = new NamedSearchableField("ContentClaimSection", "contentClaimSection", "Content Claim Section", false, SearchableFieldType.STRING); + public static final SearchableField ContentClaimContainer + = new NamedSearchableField("ContentClaimContainer", "contentClaimContainer", "Content Claim Container", false, SearchableFieldType.STRING); + public static final SearchableField ContentClaimIdentifier + = new NamedSearchableField("ContentClaimIdentifier", "contentClaimIdentifier", "Content Claim Identifier", false, SearchableFieldType.STRING); + public static final SearchableField ContentClaimOffset + = new NamedSearchableField("ContentClaimOffset", "contentClaimOffset", "Content Claim Offset", false, SearchableFieldType.LONG); + public static final SearchableField SourceQueueIdentifier + = new NamedSearchableField("SourceQueueIdentifier", "sourceQueueIdentifier", "Source Queue Identifier", false, SearchableFieldType.STRING); private static final Map standardFields; diff --git a/nifi/nifi-commons/nifi-data-provenance-utils/src/main/java/org/apache/nifi/provenance/StandardLineageResult.java b/nifi/nifi-commons/nifi-data-provenance-utils/src/main/java/org/apache/nifi/provenance/StandardLineageResult.java index afb56e8bdb..63c53d0635 100644 --- a/nifi/nifi-commons/nifi-data-provenance-utils/src/main/java/org/apache/nifi/provenance/StandardLineageResult.java +++ b/nifi/nifi-commons/nifi-data-provenance-utils/src/main/java/org/apache/nifi/provenance/StandardLineageResult.java @@ -266,7 +266,8 @@ public class StandardLineageResult implements ComputeLineageResult { final FlowFileNode childNode = new FlowFileNode(childUuid, record.getEventTime()); final boolean isNewFlowFile = nodes.add(childNode); if (!isNewFlowFile) { - final String msg = "Unable to generate Lineage Graph because multiple events were registered claiming to have generated the same FlowFile (UUID = " + childNode.getFlowFileUuid() + ")"; + final String msg = "Unable to generate Lineage Graph because multiple " + + "events were registered claiming to have generated the same FlowFile (UUID = " + childNode.getFlowFileUuid() + ")"; logger.error(msg); setError(msg); return; @@ -288,12 +289,13 @@ public class StandardLineageResult implements ComputeLineageResult { break; case RECEIVE: case CREATE: { - // for a receive event, we want to create a FlowFile Node that represents the FlowFile received + // for a receive event, we want to create a FlowFile Node that represents the FlowFile received // and create an edge from the Receive Event to the FlowFile Node final LineageNode flowFileNode = new FlowFileNode(record.getFlowFileUuid(), record.getEventTime()); final boolean isNewFlowFile = nodes.add(flowFileNode); if (!isNewFlowFile) { - final String msg = "Found cycle in graph. This indicates that multiple events were registered claiming to have generated the same FlowFile (UUID = " + flowFileNode.getFlowFileUuid() + ")"; + final String msg = "Found cycle in graph. This indicates that multiple events " + + "were registered claiming to have generated the same FlowFile (UUID = " + flowFileNode.getFlowFileUuid() + ")"; setError(msg); logger.error(msg); return; diff --git a/nifi/nifi-commons/nifi-data-provenance-utils/src/main/java/org/apache/nifi/provenance/StandardProvenanceEventRecord.java b/nifi/nifi-commons/nifi-data-provenance-utils/src/main/java/org/apache/nifi/provenance/StandardProvenanceEventRecord.java index cfbae8892c..4eb7001a7a 100644 --- a/nifi/nifi-commons/nifi-data-provenance-utils/src/main/java/org/apache/nifi/provenance/StandardProvenanceEventRecord.java +++ b/nifi/nifi-commons/nifi-data-provenance-utils/src/main/java/org/apache/nifi/provenance/StandardProvenanceEventRecord.java @@ -32,7 +32,6 @@ import org.apache.nifi.processor.Relationship; /** * Holder for provenance relevant information *

    - * @author none */ public final class StandardProvenanceEventRecord implements ProvenanceEventRecord { diff --git a/nifi/nifi-commons/nifi-expression-language/pom.xml b/nifi/nifi-commons/nifi-expression-language/pom.xml index 3521b55ebf..e27f5b1e17 100644 --- a/nifi/nifi-commons/nifi-expression-language/pom.xml +++ b/nifi/nifi-commons/nifi-expression-language/pom.xml @@ -34,6 +34,13 @@ + + org.apache.maven.plugins + maven-checkstyle-plugin + + **/antlr/AttributeExpressionParser.java,**/antlr/AttributeExpressionLexer.java + + diff --git a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/InvalidPreparedQuery.java b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/InvalidPreparedQuery.java index e23bcc0972..a29e7922da 100644 --- a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/InvalidPreparedQuery.java +++ b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/InvalidPreparedQuery.java @@ -23,21 +23,22 @@ import org.apache.nifi.expression.AttributeValueDecorator; import org.apache.nifi.flowfile.FlowFile; import org.apache.nifi.processor.exception.ProcessException; - /** - * An implementation of PreparedQuery that throws an {@link AttributeExpressionLanguageException} when attempting - * to evaluate the query. This allows a PreparedQuery to be created, even though it can't - * be evaluated. + * An implementation of PreparedQuery that throws an + * {@link AttributeExpressionLanguageException} when attempting to evaluate the + * query. This allows a PreparedQuery to be created, even though it can't be + * evaluated. */ public class InvalidPreparedQuery implements PreparedQuery { + private final String query; private final String explanation; - + public InvalidPreparedQuery(final String query, final String explanation) { this.query = query; this.explanation = explanation; } - + @Override public String evaluateExpressions(final FlowFile flowFile, final AttributeValueDecorator decorator) throws ProcessException { throw new AttributeExpressionLanguageException("Invalid Expression: " + query + " due to " + explanation); diff --git a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/Query.java b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/Query.java index 420a8e21c7..7e40897ac9 100644 --- a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/Query.java +++ b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/Query.java @@ -16,8 +16,6 @@ */ package org.apache.nifi.attribute.expression.language; -import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.*; - import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Collection; @@ -116,6 +114,73 @@ import org.antlr.runtime.ANTLRStringStream; import org.antlr.runtime.CharStream; import org.antlr.runtime.CommonTokenStream; import org.antlr.runtime.tree.Tree; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.ALL_ATTRIBUTES; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.ALL_DELINEATED_VALUES; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.ALL_MATCHING_ATTRIBUTES; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.AND; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.ANY_ATTRIBUTE; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.ANY_DELINEATED_VALUE; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.ANY_MATCHING_ATTRIBUTE; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.APPEND; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.ATTRIBUTE_REFERENCE; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.ATTR_NAME; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.CONTAINS; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.COUNT; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.DIVIDE; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.ENDS_WITH; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.EQUALS; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.EQUALS_IGNORE_CASE; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.EXPRESSION; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.FALSE; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.FIND; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.FORMAT; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.GREATER_THAN; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.GREATER_THAN_OR_EQUAL; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.HOSTNAME; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.INDEX_OF; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.IP; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.IS_EMPTY; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.IS_NULL; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.JOIN; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.LAST_INDEX_OF; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.LENGTH; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.LESS_THAN; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.LESS_THAN_OR_EQUAL; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.MATCHES; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.MINUS; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.MOD; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.MULTIPLY; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.MULTI_ATTRIBUTE_REFERENCE; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.NEXT_INT; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.NOT; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.NOT_NULL; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.NOW; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.NUMBER; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.OR; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.PLUS; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.PREPEND; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.REPLACE; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.REPLACE_ALL; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.REPLACE_EMPTY; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.REPLACE_NULL; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.STARTS_WITH; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.STRING_LITERAL; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.SUBSTRING; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.SUBSTRING_AFTER; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.SUBSTRING_AFTER_LAST; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.SUBSTRING_BEFORE; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.SUBSTRING_BEFORE_LAST; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.TO_DATE; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.TO_LOWER; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.TO_NUMBER; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.TO_RADIX; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.TO_STRING; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.TO_UPPER; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.TRIM; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.TRUE; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.URL_DECODE; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.URL_ENCODE; +import static org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.UUID; import org.apache.nifi.attribute.expression.language.evaluation.selection.MappingEvaluator; /** @@ -229,11 +294,9 @@ public class Query { } /** - * - * - * @param value - * @param allowSurroundingCharacters - * @throws AttributeExpressionLanguageParsingException + * @param value expression to validate + * @param allowSurroundingCharacters whether to allow surrounding chars + * @throws AttributeExpressionLanguageParsingException if problems parsing given expression */ public static void validateExpression(final String value, final boolean allowSurroundingCharacters) throws AttributeExpressionLanguageParsingException { if (!allowSurroundingCharacters) { @@ -333,8 +396,8 @@ public class Query { /** * Un-escapes ${...} patterns that were escaped * - * @param value - * @return + * @param value to un-escape + * @return un-escaped value */ public static String unescape(final String value) { return value.replaceAll("\\$\\$(?=\\$*\\{.*?\\})", "\\$"); diff --git a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/GreaterThanEvaluator.java b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/GreaterThanEvaluator.java index 6c712bbda0..af1ee1d13c 100644 --- a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/GreaterThanEvaluator.java +++ b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/GreaterThanEvaluator.java @@ -49,9 +49,6 @@ public class GreaterThanEvaluator extends BooleanEvaluator { return new BooleanQueryResult(subjectValue > comparisonValue); } - ; - - @Override public Evaluator getSubjectEvaluator() { return subject; diff --git a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/GreaterThanOrEqualEvaluator.java b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/GreaterThanOrEqualEvaluator.java index 98951f27e1..1269fc0b0a 100644 --- a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/GreaterThanOrEqualEvaluator.java +++ b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/GreaterThanOrEqualEvaluator.java @@ -49,9 +49,6 @@ public class GreaterThanOrEqualEvaluator extends BooleanEvaluator { return new BooleanQueryResult(subjectValue >= comparisonValue); } - ; - - @Override public Evaluator getSubjectEvaluator() { return subject; diff --git a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/IsEmptyEvaluator.java b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/IsEmptyEvaluator.java index c5e3c2188f..e6e9fc9eb6 100644 --- a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/IsEmptyEvaluator.java +++ b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/IsEmptyEvaluator.java @@ -24,12 +24,13 @@ import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; public class IsEmptyEvaluator extends BooleanEvaluator { + private final Evaluator subjectEvaluator; - + public IsEmptyEvaluator(final Evaluator subjectEvaluator) { this.subjectEvaluator = subjectEvaluator; } - + @Override public QueryResult evaluate(final Map attributes) { final Object subjectValue = subjectEvaluator.evaluate(attributes).getValue(); diff --git a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/LessThanEvaluator.java b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/LessThanEvaluator.java index 9a589103c6..4b1beac776 100644 --- a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/LessThanEvaluator.java +++ b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/LessThanEvaluator.java @@ -49,9 +49,6 @@ public class LessThanEvaluator extends BooleanEvaluator { return new BooleanQueryResult(subjectValue < comparisonValue); } - ; - - @Override public Evaluator getSubjectEvaluator() { return subject; diff --git a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/LessThanOrEqualEvaluator.java b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/LessThanOrEqualEvaluator.java index 10f3f6aad8..a07e8be521 100644 --- a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/LessThanOrEqualEvaluator.java +++ b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/LessThanOrEqualEvaluator.java @@ -49,9 +49,6 @@ public class LessThanOrEqualEvaluator extends BooleanEvaluator { return new BooleanQueryResult(subjectValue <= comparisonValue); } - ; - - @Override public Evaluator getSubjectEvaluator() { return subject; diff --git a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ReplaceEmptyEvaluator.java b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ReplaceEmptyEvaluator.java index e5c40d229b..fe08303e41 100644 --- a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ReplaceEmptyEvaluator.java +++ b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ReplaceEmptyEvaluator.java @@ -23,20 +23,21 @@ import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator; public class ReplaceEmptyEvaluator extends StringEvaluator { + private final StringEvaluator subjectEvaluator; private final StringEvaluator replacementEvaluator; - + public ReplaceEmptyEvaluator(final StringEvaluator subjectEvaluator, final StringEvaluator replacementEvaluator) { this.subjectEvaluator = subjectEvaluator; this.replacementEvaluator = replacementEvaluator; } - + @Override public QueryResult evaluate(final Map attributes) { final QueryResult subjectResult = subjectEvaluator.evaluate(attributes); final String subjectValue = subjectResult.getValue(); final boolean isEmpty = subjectValue == null || subjectValue.toString().trim().isEmpty(); - if ( isEmpty ) { + if (isEmpty) { return replacementEvaluator.evaluate(attributes); } else { return subjectResult; diff --git a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/reduce/CountEvaluator.java b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/reduce/CountEvaluator.java index f2af268813..f3fb21d638 100644 --- a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/reduce/CountEvaluator.java +++ b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/reduce/CountEvaluator.java @@ -28,19 +28,19 @@ public class CountEvaluator extends NumberEvaluator implements ReduceEvaluator subjectEvaluator; private long count = 0L; - + public CountEvaluator(final Evaluator subjectEvaluator) { this.subjectEvaluator = subjectEvaluator; } - + @Override public QueryResult evaluate(final Map attributes) { final QueryResult result = subjectEvaluator.evaluate(attributes); - if ( result.getValue() == null ) { + if (result.getValue() == null) { return new NumberQueryResult(count); } - - if ( result.getResultType() == ResultType.BOOLEAN && ((Boolean) result.getValue()).equals(Boolean.FALSE) ) { + + if (result.getResultType() == ResultType.BOOLEAN && ((Boolean) result.getValue()).equals(Boolean.FALSE)) { return new NumberQueryResult(count); } diff --git a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/reduce/JoinEvaluator.java b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/reduce/JoinEvaluator.java index eefdadad19..81c325da9e 100644 --- a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/reduce/JoinEvaluator.java +++ b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/reduce/JoinEvaluator.java @@ -24,34 +24,35 @@ import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator; import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult; public class JoinEvaluator extends StringEvaluator implements ReduceEvaluator { + private final StringEvaluator subjectEvaluator; private final StringEvaluator delimiterEvaluator; - + private final StringBuilder sb = new StringBuilder(); private int evalCount = 0; - + public JoinEvaluator(final StringEvaluator subject, final StringEvaluator delimiter) { this.subjectEvaluator = subject; this.delimiterEvaluator = delimiter; } - + @Override public QueryResult evaluate(final Map attributes) { String subject = subjectEvaluator.evaluate(attributes).getValue(); - if ( subject == null ) { + if (subject == null) { subject = ""; } - + final String delimiter = delimiterEvaluator.evaluate(attributes).getValue(); - if ( evalCount > 0 ) { + if (evalCount > 0) { sb.append(delimiter); } sb.append(subject); evalCount++; - return new StringQueryResult( sb.toString() ); + return new StringQueryResult(sb.toString()); } - + @Override public Evaluator getSubjectEvaluator() { return subjectEvaluator; diff --git a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/MappingEvaluator.java b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/MappingEvaluator.java index d872b6e4c2..2b8c488b43 100644 --- a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/MappingEvaluator.java +++ b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/MappingEvaluator.java @@ -24,19 +24,20 @@ import org.apache.nifi.attribute.expression.language.evaluation.reduce.ReduceEva import org.apache.nifi.expression.AttributeExpression.ResultType; public class MappingEvaluator implements Evaluator { + private final ReduceEvaluator mappingEvaluator; private final MultiAttributeEvaluator multiAttributeEvaluator; - + public MappingEvaluator(final ReduceEvaluator mappingEvaluator, final MultiAttributeEvaluator multiAttributeEval) { this.mappingEvaluator = mappingEvaluator; this.multiAttributeEvaluator = multiAttributeEval; } - + @Override public QueryResult evaluate(final Map attributes) { QueryResult result = mappingEvaluator.evaluate(attributes); - while ( multiAttributeEvaluator.getEvaluationsRemaining() > 0 ) { + while (multiAttributeEvaluator.getEvaluationsRemaining() > 0) { result = mappingEvaluator.evaluate(attributes); } diff --git a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/MultiMatchAttributeEvaluator.java b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/MultiMatchAttributeEvaluator.java index 9a441ce35b..1d0be8bf61 100644 --- a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/MultiMatchAttributeEvaluator.java +++ b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/MultiMatchAttributeEvaluator.java @@ -44,7 +44,7 @@ public class MultiMatchAttributeEvaluator extends MultiAttributeEvaluator { /** * Can be called only after the first call to evaluate * - * @return + * @return number of remaining evaluations */ @Override public int getEvaluationsRemaining() { diff --git a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/exception/IllegalAttributeException.java b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/exception/IllegalAttributeException.java index f6f32cac7d..ec94837c75 100644 --- a/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/exception/IllegalAttributeException.java +++ b/nifi/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/exception/IllegalAttributeException.java @@ -17,6 +17,7 @@ package org.apache.nifi.attribute.expression.language.exception; public class IllegalAttributeException extends RuntimeException { + private static final long serialVersionUID = 12348721897342L; public IllegalAttributeException() { diff --git a/nifi/nifi-commons/nifi-expression-language/src/test/java/org/apache/nifi/attribute/expression/language/TestQuery.java b/nifi/nifi-commons/nifi-expression-language/src/test/java/org/apache/nifi/attribute/expression/language/TestQuery.java index 8dfbaf16b8..4bf614f0db 100644 --- a/nifi/nifi-commons/nifi-expression-language/src/test/java/org/apache/nifi/attribute/expression/language/TestQuery.java +++ b/nifi/nifi-commons/nifi-expression-language/src/test/java/org/apache/nifi/attribute/expression/language/TestQuery.java @@ -55,7 +55,7 @@ public class TestQuery { // left here because it's convenient for looking at the output //System.out.println(Query.compile("").evaluate(null)); } - + private void assertValid(final String query) { try { Query.compile(query); @@ -64,7 +64,7 @@ public class TestQuery { Assert.fail("Expected query to be valid, but it failed to compile due to " + e); } } - + private void assertInvalid(final String query) { try { Query.compile(query); @@ -72,63 +72,61 @@ public class TestQuery { } catch (final Exception e) { } } - + @Test public void testIsValidExpression() { Query.validateExpression("${abc:substring(${xyz:length()})}", false); Query.isValidExpression("${now():format('yyyy-MM-dd')}"); - - + try { Query.validateExpression("$${attr}", false); Assert.fail("invalid query validated"); } catch (final AttributeExpressionLanguageParsingException e) { } - + Query.validateExpression("$${attr}", true); - - Query.validateExpression("${filename:startsWith('T8MTXBC')\n" - + ":or( ${filename:startsWith('C4QXABC')} )\n" - + ":or( ${filename:startsWith('U6CXEBC')} )" - + ":or( ${filename:startsWith('KYM3ABC')} )}", false); + + Query.validateExpression("${filename:startsWith('T8MTXBC')\n" + + ":or( ${filename:startsWith('C4QXABC')} )\n" + + ":or( ${filename:startsWith('U6CXEBC')} )" + + ":or( ${filename:startsWith('KYM3ABC')} )}", false); } - @Test public void testCompileEmbedded() { final String expression = "${x:equals( ${y} )}"; final Query query = Query.compile(expression); final Tree tree = query.getTree(); - System.out.println( printTree(tree) ); - + System.out.println(printTree(tree)); + final Map attributes = new HashMap<>(); attributes.put("x", "x"); attributes.put("y", "x"); final String result = Query.evaluateExpressions(expression, attributes, null); assertEquals("true", result); - + Query.validateExpression(expression, false); } - + private String printTree(final Tree tree) { final StringBuilder sb = new StringBuilder(); printTree(tree, 0, sb); - + return sb.toString(); } - + private void printTree(final Tree tree, final int spaces, final StringBuilder sb) { - for (int i=0; i < spaces; i++) { + for (int i = 0; i < spaces; i++) { sb.append(" "); } - - if ( tree.getText().trim().isEmpty() ) { + + if (tree.getText().trim().isEmpty()) { sb.append(tree.toString()).append("\n"); } else { sb.append(tree.getText()).append("\n"); } - - for (int i=0; i < tree.getChildCount(); i++) { + + for (int i = 0; i < tree.getChildCount(); i++) { printTree(tree.getChild(i), spaces + 2, sb); } } @@ -138,7 +136,7 @@ public class TestQuery { final Map attributes = new HashMap<>(); attributes.put("attr", "My Value"); attributes.put("${xx}", "hello"); - + assertEquals("My Value", evaluateQueryForEscape("${attr}", attributes)); assertEquals("${attr}", evaluateQueryForEscape("$${attr}", attributes)); assertEquals("$My Value", evaluateQueryForEscape("$$${attr}", attributes)); @@ -151,15 +149,15 @@ public class TestQuery { final Map attributes = new HashMap<>(); attributes.put("x", "C:\\test\\1.txt"); attributes.put("y", "y\ny"); - + final String query = "${x:substringAfterLast( '/' ):substringAfterLast( '\\\\' )}"; verifyEquals(query, attributes, "1.txt"); attributes.put("x", "C:/test/1.txt"); verifyEquals(query, attributes, "1.txt"); - + verifyEquals("${y:equals('y\\ny')}", attributes, Boolean.TRUE); } - + @Test public void testWithTicksOutside() { final Map attributes = new HashMap<>(); @@ -174,14 +172,13 @@ public class TestQuery { assertEquals("'My Value", Query.evaluateExpressions("'${attr}", attributes, null)); } - @Test @Ignore("Depends on TimeZone") public void testDateToNumber() { final Query query = Query.compile("${dateTime:toDate('yyyy/MM/dd HH:mm:ss.SSS'):toNumber()}"); final Map attributes = new HashMap<>(); attributes.put("dateTime", "2013/11/18 10:22:27.678"); - + final QueryResult result = query.evaluate(attributes); assertEquals(ResultType.NUMBER, result.getResultType()); assertEquals(1384788147678L, result.getValue()); @@ -203,35 +200,34 @@ public class TestQuery { final Query query = Query.compile("${dateTime:format('yyyy/MM/dd HH:mm:ss.SSS')}"); final Map attributes = new HashMap<>(); attributes.put("dateTime", date.toString()); - + // the date.toString() above will end up truncating the milliseconds. So remove millis from the Date before // formatting it final SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS", Locale.US); final long millis = date.getTime() % 1000L; final Date roundedToNearestSecond = new Date(date.getTime() - millis); final String formatted = sdf.format(roundedToNearestSecond); - + final QueryResult result = query.evaluate(attributes); assertEquals(ResultType.STRING, result.getResultType()); assertEquals(formatted, result.getValue()); } - @Test public void testEmbeddedExpressionsAndQuotes() { final Map attributes = new HashMap<>(); attributes.put("x", "abc"); attributes.put("a", "abc"); - + verifyEquals("${x:equals(${a})}", attributes, true); - + Query.validateExpression("${x:equals('${a}')}", false); assertEquals("true", Query.evaluateExpressions("${x:equals('${a}')}", attributes, null)); - + Query.validateExpression("${x:equals(\"${a}\")}", false); assertEquals("true", Query.evaluateExpressions("${x:equals(\"${a}\")}", attributes, null)); } - + @Test public void testJoin() { final Map attributes = new HashMap<>(); @@ -243,13 +239,12 @@ public class TestQuery { verifyEquals("${a.a:join(', ')}", attributes, "a"); verifyEquals("${allAttributes( 'x', 'y' ):join(',')}", attributes, ","); } - - @Test(expected=AttributeExpressionLanguageException.class) + + @Test(expected = AttributeExpressionLanguageException.class) public void testCannotCombineWithNonReducingFunction() { Query.compileTree("${allAttributes( 'a.1' ):plus(1)}"); } - @Test public void testIsEmpty() { final Map attributes = new HashMap<>(); @@ -263,22 +258,19 @@ public class TestQuery { verifyEquals("${d:isEmpty()}", attributes, true); } - @Test public void testReplaceEmpty() { final Map attributes = new HashMap<>(); attributes.put("a", "a"); attributes.put("b", ""); attributes.put("c", " \n"); - + verifyEquals("${a:replaceEmpty('c')}", attributes, "a"); verifyEquals("${b:replaceEmpty('c')}", attributes, "c"); verifyEquals("${c:replaceEmpty('c')}", attributes, "c"); verifyEquals("${d:replaceEmpty('c')}", attributes, "c"); } - - @Test public void testCount() { final Map attributes = new HashMap<>(); @@ -291,20 +283,18 @@ public class TestQuery { verifyEquals("${allMatchingAttributes( '.*' ):count()}", attributes, 6L); verifyEquals("${allMatchingAttributes( '.*' ):length():gt(2):count()}", attributes, 5L); - verifyEquals("${allMatchingAttributes( 'n.*' ):plus(1):count()}", attributes, 3L ); + verifyEquals("${allMatchingAttributes( 'n.*' ):plus(1):count()}", attributes, 3L); } - - + @Test public void testCurlyBracesInQuotes() { final Map attributes = new HashMap<>(); attributes.put("attr", "My Valuee"); - + assertEquals("Val", evaluateQueryForEscape("${attr:replaceAll('My (Val)ue{1,2}', '$1')}", attributes)); assertEquals("Val", evaluateQueryForEscape("${attr:replaceAll(\"My (Val)ue{1,2}\", '$1')}", attributes)); } - - + private String evaluateQueryForEscape(final String queryString, final Map attributes) { FlowFile mockFlowFile = Mockito.mock(FlowFile.class); Mockito.when(mockFlowFile.getAttributes()).thenReturn(attributes); @@ -315,15 +305,14 @@ public class TestQuery { Mockito.when(mockFlowFile.getLineageStartDate()).thenReturn(System.currentTimeMillis()); return Query.evaluateExpressions(queryString, mockFlowFile); } - - + @Test public void testGetAttributeValue() { final Map attributes = new HashMap<>(); attributes.put("attr", "My Value"); verifyEquals("${attr}", attributes, "My Value"); } - + @Test public void testGetAttributeValueEmbedded() { final Map attributes = new HashMap<>(); @@ -331,14 +320,14 @@ public class TestQuery { attributes.put("XX", "My Value"); verifyEquals("${${attr:trim()}}", attributes, "My Value"); } - + @Test public void testSimpleSubstring() { final Map attributes = new HashMap<>(); attributes.put("attr", "My Value"); verifyEquals("${attr:substring(2, 5)}", attributes, " Va"); } - + @Test public void testCallToFunctionWithSubjectResultOfAnotherFunctionCall() { final Map attributes = new HashMap<>(); @@ -359,29 +348,28 @@ public class TestQuery { attributes.put("attr", " XX "); verifyEquals("${attr:trim():equals('XX')}", attributes, true); } - + @Test public void testDeeplyEmbedded() { final Map attributes = new HashMap<>(); attributes.put("x", "false"); attributes.put("abc", "a"); attributes.put("a", "a"); - + verifyEquals("${x:or( ${${abc}:length():equals(1)} )}", attributes, true); } - - + @Test public void testExtractExpressionRanges() { List ranges = Query.extractExpressionRanges("hello"); assertTrue(ranges.isEmpty()); - + ranges = Query.extractExpressionRanges("${hello"); assertTrue(ranges.isEmpty()); - + ranges = Query.extractExpressionRanges("hello}"); assertTrue(ranges.isEmpty()); - + ranges = Query.extractExpressionRanges("$${hello"); assertTrue(ranges.isEmpty()); @@ -393,52 +381,50 @@ public class TestQuery { Range range = ranges.get(0); assertEquals(0, range.getStart()); assertEquals(7, range.getEnd()); - + ranges = Query.extractExpressionRanges("${hello:equals( ${goodbye} )}"); assertEquals(1, ranges.size()); range = ranges.get(0); assertEquals(0, range.getStart()); assertEquals(28, range.getEnd()); - + ranges = Query.extractExpressionRanges("${hello:equals( $${goodbye} )}"); assertEquals(1, ranges.size()); range = ranges.get(0); assertEquals(0, range.getStart()); assertEquals(29, range.getEnd()); - + ranges = Query.extractExpressionRanges("${hello:equals( $${goodbye} )} or just hi, ${bob:or(${jerry})}"); assertEquals(2, ranges.size()); range = ranges.get(0); assertEquals(0, range.getStart()); assertEquals(29, range.getEnd()); - + range = ranges.get(1); assertEquals(43, range.getStart()); assertEquals(61, range.getEnd()); - - + ranges = Query.extractExpressionRanges("${hello:equals( ${goodbye} )} or just hi, ${bob}, are you ${bob.age:toNumber()} yet? $$$${bob}"); assertEquals(3, ranges.size()); range = ranges.get(0); assertEquals(0, range.getStart()); assertEquals(28, range.getEnd()); - + range = ranges.get(1); assertEquals(42, range.getStart()); assertEquals(47, range.getEnd()); - + range = ranges.get(2); assertEquals(58, range.getStart()); assertEquals(78, range.getEnd()); - + ranges = Query.extractExpressionRanges("${x:matches( '.{4}' )}"); assertEquals(1, ranges.size()); range = ranges.get(0); assertEquals(0, range.getStart()); assertEquals(21, range.getEnd()); } - - + @Test public void testExtractExpressionTypes() { List types = Query.extractResultTypes("${hello:equals( ${goodbye} )} or just hi, ${bob}, are you ${bob.age:toNumber()} yet? $$$${bob}"); @@ -447,19 +433,18 @@ public class TestQuery { assertEquals(ResultType.STRING, types.get(1)); assertEquals(ResultType.NUMBER, types.get(2)); } - - + @Test public void testEqualsEmbedded() { final Map attributes = new HashMap<>(); attributes.put("x", "hello"); attributes.put("y", "good-bye"); - + verifyEquals("${x:equals( ${y} )}", attributes, false); - + attributes.put("y", "hello"); verifyEquals("${x:equals( ${y} )}", attributes, true); - + attributes.put("x", "4"); attributes.put("y", "3"); attributes.put("z", "1"); @@ -474,18 +459,17 @@ public class TestQuery { attributes.put("y", "88"); assertEquals("true", Query.evaluateExpressions("${x:equals( '${y}' )}", attributes, null)); } - - + @Test public void testComplicatedEmbeddedExpressions() { final Map attributes = new HashMap<>(); attributes.put("fox", "quick, brown"); attributes.put("dog", "lazy"); - + verifyEquals("${fox:substring( ${ 'dog' :substring(2):length()}, 5 ):equals( 'ick' )}", attributes, true); verifyEquals("${fox:substring( ${ 'dog' :substring(2):length()}, 5 ):equals( 'ick' )}", attributes, true); } - + @Test public void testQuotingQuotes() { final Map attributes = new HashMap<>(); @@ -501,7 +485,7 @@ public class TestQuery { System.out.println(query); verifyEquals(query, attributes, "say \"hi\""); } - + @Test public void testDoubleQuotesWithinSingleQuotes() { final Map attributes = new HashMap<>(); @@ -511,30 +495,30 @@ public class TestQuery { System.out.println(query); verifyEquals(query, attributes, "say \"hello\""); } - + @Test public void testEscapeQuotes() { final long timestamp = 1403620278642L; final Map attributes = new HashMap<>(); attributes.put("date", String.valueOf(timestamp)); - + final String format = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; - + final String query = "startDateTime=\"${date:toNumber():toDate():format(\"" + format + "\")}\""; final String result = Query.evaluateExpressions(query, attributes, null); - + final String expectedTime = new SimpleDateFormat(format, Locale.US).format(timestamp); assertEquals("startDateTime=\"" + expectedTime + "\"", result); - + final List ranges = Query.extractExpressionRanges(query); assertEquals(1, ranges.size()); } - + @Test public void testDateConversion() { final Map attributes = new HashMap<>(); attributes.put("date", "1403620278642"); - + verifyEquals("${date:format('yyyy')}", attributes, "2014"); verifyEquals("${date:toDate():format('yyyy')}", attributes, "2014"); verifyEquals("${date:toNumber():format('yyyy')}", attributes, "2014"); @@ -542,17 +526,16 @@ public class TestQuery { verifyEquals("${date:toDate():toNumber():format('yyyy')}", attributes, "2014"); verifyEquals("${date:toDate():toNumber():toDate():toNumber():toDate():toNumber():format('yyyy')}", attributes, "2014"); } - + @Test public void testSingleLetterAttribute() { final Map attributes = new HashMap<>(); attributes.put("A", "0123456789"); - + verifyEquals("${A}", attributes, "0123456789"); verifyEquals("${'A'}", attributes, "0123456789"); } - @Test public void testImplicitConversions() { final Map attributes = new HashMap<>(); @@ -562,7 +545,7 @@ public class TestQuery { attributes.put("d", "Quick Brown Fox"); attributes.put("F", "-48"); attributes.put("n", "2014/04/04 00:00:00"); - + final Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, 2014); cal.set(Calendar.MONTH, 3); @@ -570,11 +553,10 @@ public class TestQuery { cal.set(Calendar.HOUR, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 45); - + final String dateString = cal.getTime().toString(); attributes.put("z", dateString); - verifyEquals("${A:plus(4)}", attributes, 123456793L); verifyEquals("${A:plus( ${F} )}", attributes, 123456741L); @@ -582,11 +564,11 @@ public class TestQuery { verifyEquals("${A:substring(2,3):plus(21):substring(1,2):plus(0)}", attributes, 3L); verifyEquals("${n:format( 'yyyy' )}", attributes, "2014"); verifyEquals("${z:format( 'yyyy' )}", attributes, "2014"); - + attributes.put("n", "2014/04/04 00:00:00.045"); verifyEquals("${n:format( 'yyyy' ):append(','):append( ${n:format( 'SSS' )} )}", attributes, "2014,045"); } - + @Test public void testNewLinesAndTabsInQuery() { final String query = "${ abc:equals('abc'):or( \n\t${xx:isNull()}\n) }"; @@ -594,12 +576,12 @@ public class TestQuery { Query.validateExpression(query, false); assertEquals("true", Query.evaluateExpressions(query)); } - + @Test public void testAttributeReferencesWithWhiteSpace() { final Map attrs = new HashMap<>(); attrs.put("a b c,d", "abc"); - + final String query = "${ 'a b c,d':equals('abc') }"; verifyEquals(query, attrs, true); } @@ -609,68 +591,68 @@ public class TestQuery { final Map attributes = new HashMap<>(); attributes.put("abc", "xyz"); - final String expression = - "# hello, world\n" + - "${# ref attr\n" + - "\t" + - "abc" + - "\t" + - "#end ref attr\n" + - "}"; + final String expression + = "# hello, world\n" + + "${# ref attr\n" + + "\t" + + "abc" + + "\t" + + "#end ref attr\n" + + "}"; Query query = Query.compile(expression); QueryResult result = query.evaluate(attributes); assertEquals(ResultType.STRING, result.getResultType()); assertEquals("xyz", result.getValue()); - + query = Query.compile("${abc:append('# hello') #good-bye \n}"); result = query.evaluate(attributes); assertEquals(ResultType.STRING, result.getResultType()); assertEquals("xyz# hello", result.getValue()); } - + @Test public void testAppendPrepend() { final Map attributes = new HashMap<>(); attributes.put("attr", "XX"); attributes.put("YXXX", "bingo"); - + verifyEquals("${${attr:append('X'):prepend('Y')}}", attributes, "bingo"); } - + @Test public void testIsNull() { final Map attributes = new HashMap<>(); verifyEquals("${attr:isNull()}", attributes, true); } - + @Test public void testNotNull() { final Map attributes = new HashMap<>(); attributes.put("attr", ""); - + verifyEquals("${attr:notNull()}", attributes, true); } - + @Test public void testIsNullOrLengthEquals0() { final Map attributes = new HashMap<>(); attributes.put("abc", ""); attributes.put("xyz", "xyz"); attributes.put("xx", " "); - + verifyEquals("${abc:isNull():or( ${abc:length():equals(0)} )}", attributes, true); verifyEquals("${xyz:isNull():or( ${xyz:length():equals(0)} )}", attributes, false); verifyEquals("${none:isNull():or( ${none:length():equals(0)} )}", attributes, true); verifyEquals("${xx:isNull():or( ${xx:trim():length():equals(0)} )}", attributes, true); } - + @Test public void testReplaceNull() { final Map attributes = new HashMap<>(); verifyEquals("${attr:replaceNull('hello')}", attributes, "hello"); } - + @Test public void testReplace() { final Map attributes = new HashMap<>(); @@ -683,10 +665,10 @@ public class TestQuery { final Map attributes = new HashMap<>(); attributes.put("attr", "hello"); attributes.put("xyz", "00-00TEST.2014_01_01_000000_value"); - + verifyEquals("${xyz:replaceAll(\"^([^.]+)\\.([0-9]{4})_([0-9]{2})_([0-9]{2}).*$\", \"$3\")}", attributes, "01"); verifyEquals("${attr:replaceAll('l+', 'r')}", attributes, "hero"); - + attributes.clear(); attributes.put("filename1", "abc.gz"); attributes.put("filename2", "abc.g"); @@ -705,10 +687,9 @@ public class TestQuery { verifyEquals("${abc:replaceAll( 'xx', '$0')}", attributes, "hello world"); verifyEquals("${abc:replaceAll( '(xx)', '$1')}", attributes, "hello world"); verifyEquals("${abc:replaceAll( 'lo wor(ld)', '$1')}", attributes, "helld"); - + } - - + @Test public void testReplaceAllWithOddNumberOfBackslashPairs() { final Map attributes = new HashMap<>(); @@ -718,15 +699,15 @@ public class TestQuery { verifyEquals("${filename:replaceAll('\\\\\\\\', '/')}", attributes, "C:/temp/.txt"); verifyEquals("${filename:replaceAll('\\\\\\.txt$', '')}", attributes, "C:\\temp"); } - + @Test public void testReplaceAllWithMatchingGroup() { final Map attributes = new HashMap<>(); attributes.put("attr", "hello"); - + verifyEquals("${attr:replaceAll('.*?(l+).*', '$1')}", attributes, "ll"); } - + @Test public void testMathOperations() { final Map attributes = new HashMap<>(); @@ -746,16 +727,16 @@ public class TestQuery { attributes.put("attr", "https://abc.go"); verifyEquals("${attr:indexOf('/')}", attributes, 6L); } - + @Test public void testDate() { final Calendar now = Calendar.getInstance(); final int year = now.get(Calendar.YEAR); final Map attributes = new HashMap<>(); attributes.put("entryDate", String.valueOf(now.getTimeInMillis())); - + verifyEquals("${entryDate:toNumber():toDate():format('yyyy')}", attributes, String.valueOf(year)); - + attributes.clear(); attributes.put("month", "3"); attributes.put("day", "4"); @@ -765,34 +746,34 @@ public class TestQuery { verifyEquals("${year:append('/'):append(${month}):append('/'):append(${day}):toDate('yyyy/MM/dd'):format('D')}", attributes, "63"); } - + @Test public void testSystemProperty() { System.setProperty("hello", "good-bye"); assertEquals("good-bye", Query.evaluateExpressions("${hello}")); assertEquals("good-bye", Query.compile("${hello}").evaluate().getValue()); } - + @Test public void testAnyAttribute() { final Map attributes = new HashMap<>(); attributes.put("abc", "zzz"); attributes.put("xyz", "abc"); - + verifyEquals("${anyAttribute('abc', 'xyz', 'missingAttr'):substring(1,2):equals('b')}", attributes, true); verifyEquals("${anyAttribute('abc', 'xyz'):substring(1,2):equals('b')}", attributes, true); verifyEquals("${anyAttribute('xyz', 'abc'):substring(1,2):equals('b')}", attributes, true); verifyEquals("${anyAttribute('zz'):substring(1,2):equals('b')}", attributes, false); verifyEquals("${anyAttribute('abc', 'zz'):isNull()}", attributes, true); } - + @Test public void testAnyMatchingAttribute() { final Map attributes = new HashMap<>(); attributes.put("abc", "zzz"); attributes.put("xyz", "abc"); attributes.put("123.cba", "hello"); - + verifyEquals("${anyMatchingAttribute('.{2}x', '.{2}z'):substring(1,2):equals('b')}", attributes, true); verifyEquals("${anyMatchingAttribute('.*'):substring(1,2):equals('b')}", attributes, true); verifyEquals("${anyMatchingAttribute('x{44}'):substring(1,2):equals('b')}", attributes, false); @@ -804,48 +785,46 @@ public class TestQuery { verifyEquals("${anyMatchingAttribute('123\\.c.*'):matches('hello')}", attributes, true); verifyEquals("${anyMatchingAttribute('123\\.c.*|a.c'):matches('zzz')}", attributes, true); } - - + @Test public void testAnyDelineatedValue() { final Map attributes = new HashMap<>(); attributes.put("abc", "a,b,c"); attributes.put("xyz", "abc"); - + final String query = "${anyDelineatedValue('${abc}', ','):equals('b')}"; assertEquals(ResultType.BOOLEAN, Query.getResultType(query)); - + assertEquals("true", Query.evaluateExpressions(query, attributes, null)); assertEquals("true", Query.evaluateExpressions("${anyDelineatedValue('${abc}', ','):equals('a')}", attributes, null)); assertEquals("true", Query.evaluateExpressions("${anyDelineatedValue('${abc}', ','):equals('c')}", attributes, null)); assertEquals("false", Query.evaluateExpressions("${anyDelineatedValue('${abc}', ','):equals('d')}", attributes, null)); - + verifyEquals("${anyDelineatedValue(${abc}, ','):equals('b')}", attributes, true); verifyEquals("${anyDelineatedValue(${abc}, ','):equals('a')}", attributes, true); verifyEquals("${anyDelineatedValue(${abc}, ','):equals('c')}", attributes, true); verifyEquals("${anyDelineatedValue(${abc}, ','):equals('d')}", attributes, false); } - + @Test public void testAllDelineatedValues() { final Map attributes = new HashMap<>(); attributes.put("abc", "a,b,c"); attributes.put("xyz", "abc"); - + final String query = "${allDelineatedValues('${abc}', ','):matches('[abc]')}"; - + assertEquals(ResultType.BOOLEAN, Query.getResultType(query)); assertEquals("true", Query.evaluateExpressions(query, attributes, null)); assertEquals("true", Query.evaluateExpressions(query, attributes, null)); assertEquals("false", Query.evaluateExpressions("${allDelineatedValues('${abc}', ','):matches('[abd]')}", attributes, null)); assertEquals("false", Query.evaluateExpressions("${allDelineatedValues('${abc}', ','):equals('a'):not()}", attributes, null)); - + verifyEquals("${allDelineatedValues(${abc}, ','):matches('[abc]')}", attributes, true); verifyEquals("${allDelineatedValues(${abc}, ','):matches('[abd]')}", attributes, false); verifyEquals("${allDelineatedValues(${abc}, ','):equals('a'):not()}", attributes, false); } - - + @Test public void testAllAttributes() { final Map attributes = new HashMap<>(); @@ -859,7 +838,7 @@ public class TestQuery { verifyEquals("${allAttributes('abc', 'hello'):length():equals(4)}", attributes, false); verifyEquals("${allAttributes('abc', 'xyz'):length():equals(4)}", attributes, true); verifyEquals("${allAttributes('abc', 'xyz', 'other'):isNull()}", attributes, false); - + try { Query.compile("${allAttributes('#ah'):equals('hello')"); Assert.fail("Was able to compile with allAttributes and an invalid attribute name"); @@ -867,8 +846,7 @@ public class TestQuery { // expected behavior } } - - + @Test public void testMathOperators() { final Map attributes = new HashMap<>(); @@ -878,7 +856,7 @@ public class TestQuery { verifyEquals("${xyz:toNumber():gt( ${abc:toNumber()} )}", attributes, true); } - + @Test public void testAllMatchingAttributes() { final Map attributes = new HashMap<>(); @@ -887,17 +865,17 @@ public class TestQuery { attributes.put("hello", "world!"); attributes.put("123.cba", "hell.o"); - System.out.println( printTree(Query.compile("${allMatchingAttributes('(abc|xyz)'):matches('\\\\d+')}").getTree()) ); - + System.out.println(printTree(Query.compile("${allMatchingAttributes('(abc|xyz)'):matches('\\\\d+')}").getTree())); + verifyEquals("${'123.cba':matches('hell\\.o')}", attributes, true); verifyEquals("${allMatchingAttributes('123\\.cba'):equals('hell.o')}", attributes, true); verifyEquals("${allMatchingAttributes('(abc|xyz)'):matches('\\d+')}", attributes, true); verifyEquals("${allMatchingAttributes('[ax].*'):toNumber():lt(99999)}", attributes, true); verifyEquals("${allMatchingAttributes('hell.'):length():gt(3)}", attributes, true); - + verifyEquals("${allMatchingAttributes('123\\.cba'):equals('no')}", attributes, false); } - + @Test public void testMatches() { final Map attributes = new HashMap<>(); @@ -909,15 +887,14 @@ public class TestQuery { final String evaluated = Query.evaluateExpressions("${abc:matches('1234${end}4321')}", attributes, null); assertEquals("true", evaluated); - + attributes.put("end", "888"); final String secondEvaluation = Query.evaluateExpressions("${abc:matches('1234${end}4321')}", attributes, null); assertEquals("false", secondEvaluation); - + verifyEquals("${dotted:matches('abc\\.xyz')}", attributes, true); - } - - + } + @Test public void testFind() { final Map attributes = new HashMap<>(); @@ -929,68 +906,67 @@ public class TestQuery { final String evaluated = Query.evaluateExpressions("${abc:find('1234${end}4321')}", attributes, null); assertEquals("true", evaluated); - + attributes.put("end", "888"); final String secondEvaluation = Query.evaluateExpressions("${abc:find('${end}4321')}", attributes, null); assertEquals("false", secondEvaluation); - + verifyEquals("${dotted:find('\\.')}", attributes, true); - } - + } + @Test public void testSubstringAfter() { final Map attributes = new HashMap<>(); attributes.put("filename", "file-255"); - + verifyEquals("${filename:substringAfter('')}", attributes, "file-255"); verifyEquals("${filename:substringAfterLast('')}", attributes, "file-255"); verifyEquals("${filename:substringBefore('')}", attributes, "file-255"); verifyEquals("${filename:substringBeforeLast('')}", attributes, "file-255"); verifyEquals("${filename:substringBefore('file')}", attributes, ""); - + attributes.put("uri", "sftp://some.uri"); verifyEquals("${uri:substringAfter('sftp')}", attributes, "://some.uri"); } - + @Test public void testSubstringAfterLast() { final Map attributes = new HashMap<>(); attributes.put("filename", "file-file-255"); - + verifyEquals("${filename:substringAfterLast('file-')}", attributes, "255"); verifyEquals("${filename:substringAfterLast('5')}", attributes, ""); verifyEquals("${filename:substringAfterLast('x')}", attributes, "file-file-255"); } - + @Test public void testSubstringBefore() { final Map attributes = new HashMap<>(); attributes.put("something", "some {} or other"); - + verifyEquals("${something:substringBefore('}')}", attributes, "some {"); } - + @Test public void testSubstring() { final Map attributes = new HashMap<>(); attributes.put("filename", "file-255"); - + verifyEquals("${filename:substring(1, 2)}", attributes, "i"); verifyEquals("${filename:substring(4)}", attributes, "-255"); } - + @Test public void testToRadix() { final Map attributes = new HashMap<>(); attributes.put("filename", "file-255"); attributes.put("filename2", "file-99999"); - verifyEquals("${filename:substringAfter('-'):toNumber():toRadix(16):toUpper()}", attributes, "FF"); verifyEquals("${filename:substringAfter('-'):toNumber():toRadix(16, 4):toUpper()}", attributes, "00FF"); verifyEquals("${filename:substringAfter('-'):toNumber():toRadix(36, 3):toUpper()}", attributes, "073"); } - + @Test public void testDateFormatConversion() { final Map attributes = new HashMap<>(); @@ -998,23 +974,22 @@ public class TestQuery { verifyEquals("${blue:toDate('yyyyMMddHHmmss'):format(\"yyyy/MM/dd HH:mm:ss.SSS'Z'\")}", attributes, "2013/09/17 16:26:43.000Z"); } - @Test public void testNot() { verifyEquals("${ab:notNull():not()}", new HashMap(), true); } - + @Test public void testAttributesWithSpaces() { final Map attributes = new HashMap<>(); attributes.put("ab", "abc"); attributes.put("a b", "abc"); - + verifyEquals("${ab}", attributes, "abc"); verifyEquals("${'a b'}", attributes, "abc"); verifyEquals("${'a b':replaceNull('')}", attributes, ""); } - + @Test public void testOr() { final Map attributes = new HashMap<>(); @@ -1029,7 +1004,7 @@ public class TestQuery { verifyEquals("${filename1:startsWith('x'):or( ${filename2:startsWith('y')} )}", attributes, true); verifyEquals("${filename2:startsWith('x'):or( ${filename1:startsWith('y')} )}", attributes, false); } - + @Test public void testAnd() { final Map attributes = new HashMap<>(); @@ -1046,7 +1021,7 @@ public class TestQuery { verifyEquals("${filename2:startsWith('x'):and( ${filename1:startsWith('y')} )}", attributes, false); verifyEquals("${filename1:startsWith('x'):and( ${'filename 3':endsWith('y')} )}", attributes, true); } - + @Test public void testAndOrNot() { final Map attributes = new HashMap<>(); @@ -1054,90 +1029,90 @@ public class TestQuery { attributes.put("filename2", "yabc"); attributes.put("filename 3", "abcxy"); - final String query = - "${" + - " 'non-existing':notNull():not():and(" + // true AND ( - " ${filename1:startsWith('y')" + // false - " :or(" + // or - " ${ filename1:startsWith('x'):and(false) }" + // false - " ):or(" + // or - " ${ filename2:endsWith('xxxx'):or( ${'filename 3':length():gt(1)} ) }" + // true ) - " )}" + - " )" + - "}"; - + final String query + = "${" + + " 'non-existing':notNull():not():and(" + // true AND ( + " ${filename1:startsWith('y')" + // false + " :or(" + // or + " ${ filename1:startsWith('x'):and(false) }" + // false + " ):or(" + // or + " ${ filename2:endsWith('xxxx'):or( ${'filename 3':length():gt(1)} ) }" + // true ) + " )}" + + " )" + + "}"; + System.out.println(query); verifyEquals(query, attributes, true); } - + @Test public void testAndOrLogicWithAnyAll() { final Map attributes = new HashMap<>(); attributes.put("filename1", "xabc"); attributes.put("filename2", "yabc"); attributes.put("filename 3", "abcxy"); - + verifyEquals("${anyMatchingAttribute('filename.*'):contains('abc'):and( ${filename2:equals('yabc')} )}", attributes, true); verifyEquals("${anyMatchingAttribute('filename.*'):contains('abc'):and( ${filename2:equals('xabc')} )}", attributes, false); verifyEquals("${anyMatchingAttribute('filename.*'):contains('abc'):not():or( ${filename2:equals('yabc')} )}", attributes, true); verifyEquals("${anyMatchingAttribute('filename.*'):contains('abc'):not():or( ${filename2:equals('xabc')} )}", attributes, false); } - + @Test public void testKeywords() { final Map attributes = new HashMap<>(); attributes.put("UUID", "123"); verifyEquals("${ 'UUID':toNumber():equals(123) }", attributes, true); } - + @Test public void testEqualsNumber() { final Map attributes = new HashMap<>(); attributes.put("abc", "123"); verifyEquals("${ abc:toNumber():equals(123) }", attributes, true); } - + @Test public void testSubjectAsEmbeddedExpressionWithSurroundChars() { final Map attributes = new HashMap<>(); attributes.put("b", "x"); attributes.put("abcxcba", "hello"); - + final String evaluated = Query.evaluateExpressions("${ 'abc${b}cba':substring(0, 1) }", attributes, null); assertEquals("h", evaluated); } - + @Test public void testToNumberFunctionReturnsNumberType() { assertEquals(ResultType.NUMBER, Query.getResultType("${header.size:toNumber()}")); } - + @Test public void testAnyAttributeEmbedded() { final Map attributes = new HashMap<>(); attributes.put("a1", "test1"); attributes.put("b2", "2test"); attributes.put("c3", "3test3"); - + final String query = "${a1:equals('test1'):and( ${anyAttribute('a1','b2','c3'):contains('2')})}"; verifyEquals(query, attributes, true); } - + private void verifyEquals(final String expression, final Map attributes, final Object expectedResult) { Query.validateExpression(expression, false); assertEquals(String.valueOf(expectedResult), Query.evaluateExpressions(expression, attributes, null)); - + Query query = Query.compile(expression); QueryResult result = query.evaluate(attributes); - - if ( expectedResult instanceof Number ) { + + if (expectedResult instanceof Number) { assertEquals(ResultType.NUMBER, result.getResultType()); - } else if ( expectedResult instanceof Boolean ) { + } else if (expectedResult instanceof Boolean) { assertEquals(ResultType.BOOLEAN, result.getResultType()); } else { assertEquals(ResultType.STRING, result.getResultType()); } - + assertEquals(expectedResult, result.getValue()); } } diff --git a/nifi/nifi-commons/nifi-expression-language/src/test/java/org/apache/nifi/attribute/expression/language/TestStandardPreparedQuery.java b/nifi/nifi-commons/nifi-expression-language/src/test/java/org/apache/nifi/attribute/expression/language/TestStandardPreparedQuery.java index 398a23b640..5acba8deda 100644 --- a/nifi/nifi-commons/nifi-expression-language/src/test/java/org/apache/nifi/attribute/expression/language/TestStandardPreparedQuery.java +++ b/nifi/nifi-commons/nifi-expression-language/src/test/java/org/apache/nifi/attribute/expression/language/TestStandardPreparedQuery.java @@ -31,34 +31,34 @@ public class TestStandardPreparedQuery { public void testSimpleReference() { final Map attrs = new HashMap<>(); attrs.put("xx", "world"); - + assertEquals("world", evaluate("${xx}", attrs)); assertEquals("hello, world!", evaluate("hello, ${xx}!", attrs)); } - + @Test public void testEmbeddedReference() { final Map attrs = new HashMap<>(); attrs.put("xx", "yy"); attrs.put("yy", "world"); - + assertEquals("world", evaluate("${${xx}}", attrs)); } - + @Test public void test10MIterations() { final Map attrs = new HashMap<>(); attrs.put("xx", "world"); - + final StandardPreparedQuery prepared = (StandardPreparedQuery) Query.prepare("${xx}"); final long start = System.nanoTime(); - for (int i=0; i < 10000000; i++) { - assertEquals( "world", prepared.evaluateExpressions(attrs, null) ); + for (int i = 0; i < 10000000; i++) { + assertEquals("world", prepared.evaluateExpressions(attrs, null)); } final long nanos = System.nanoTime() - start; System.out.println(TimeUnit.NANOSECONDS.toMillis(nanos)); } - + @Test @Ignore("Takes too long") public void test10MIterationsWithQuery() { @@ -66,14 +66,14 @@ public class TestStandardPreparedQuery { attrs.put("xx", "world"); final long start = System.nanoTime(); - for (int i=0; i < 10000000; i++) { - assertEquals( "world", Query.evaluateExpressions("${xx}", attrs) ); + for (int i = 0; i < 10000000; i++) { + assertEquals("world", Query.evaluateExpressions("${xx}", attrs)); } final long nanos = System.nanoTime() - start; System.out.println(TimeUnit.NANOSECONDS.toMillis(nanos)); } - + @Test public void testSeveralSequentialExpressions() { final Map attributes = new HashMap<>(); @@ -83,10 +83,10 @@ public class TestStandardPreparedQuery { assertEquals("Hello, World, how are you?!", evaluate("Hello, ${audience}${comma}${question}!", attributes)); } - + private String evaluate(final String query, final Map attrs) { final String evaluated = ((StandardPreparedQuery) Query.prepare(query)).evaluateExpressions(attrs, null); return evaluated; } - + } diff --git a/nifi/nifi-commons/nifi-flowfile-packager/src/main/java/org/apache/nifi/util/FlowFilePackagerV1.java b/nifi/nifi-commons/nifi-flowfile-packager/src/main/java/org/apache/nifi/util/FlowFilePackagerV1.java index 07baab1409..479ac588a4 100644 --- a/nifi/nifi-commons/nifi-flowfile-packager/src/main/java/org/apache/nifi/util/FlowFilePackagerV1.java +++ b/nifi/nifi-commons/nifi-flowfile-packager/src/main/java/org/apache/nifi/util/FlowFilePackagerV1.java @@ -78,7 +78,7 @@ public class FlowFilePackagerV1 implements FlowFilePackager { entry.setMode(tarPermissions); entry.setSize(fileSize); tarOut.putArchiveEntry(entry); - final byte[] buffer = new byte[512 << 10];//512KB + final byte[] buffer = new byte[512 << 10];//512KB int bytesRead = 0; while ((bytesRead = inStream.read(buffer)) != -1) { //still more data to read if (bytesRead > 0) { diff --git a/nifi/nifi-commons/nifi-flowfile-packager/src/main/java/org/apache/nifi/util/FlowFileUnpackagerV1.java b/nifi/nifi-commons/nifi-flowfile-packager/src/main/java/org/apache/nifi/util/FlowFileUnpackagerV1.java index f8ef3d1ab5..b96534a6b2 100644 --- a/nifi/nifi-commons/nifi-flowfile-packager/src/main/java/org/apache/nifi/util/FlowFileUnpackagerV1.java +++ b/nifi/nifi-commons/nifi-flowfile-packager/src/main/java/org/apache/nifi/util/FlowFileUnpackagerV1.java @@ -51,7 +51,7 @@ public class FlowFileUnpackagerV1 implements FlowFileUnpackager { final TarArchiveEntry contentEntry = tarIn.getNextTarEntry(); if (contentEntry != null && contentEntry.getName().equals(FlowFilePackagerV1.FILENAME_CONTENT)) { - final byte[] buffer = new byte[512 << 10];//512KB + final byte[] buffer = new byte[512 << 10];//512KB int bytesRead = 0; while ((bytesRead = tarIn.read(buffer)) != -1) { //still more data to read if (bytesRead > 0) { diff --git a/nifi/nifi-commons/nifi-hl7-query-language/pom.xml b/nifi/nifi-commons/nifi-hl7-query-language/pom.xml index 7daa400835..bcd489effe 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/pom.xml +++ b/nifi/nifi-commons/nifi-hl7-query-language/pom.xml @@ -14,109 +14,115 @@ limitations under the License. --> - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - - org.apache.nifi - nifi-commons - 0.1.0-incubating-SNAPSHOT - + + org.apache.nifi + nifi-commons + 0.1.0-incubating-SNAPSHOT + - nifi-hl7-query-language - jar - - - - maven-compiler-plugin - - 1.7 - 1.7 - - - - org.antlr - antlr3-maven-plugin - - - - antlr - - - - - - org.apache.rat - apache-rat-plugin - - - src/test/resources/hypoglycemia - src/test/resources/hyperglycemia - - - - - + nifi-hl7-query-language + jar + + + + maven-compiler-plugin + + 1.7 + 1.7 + + + + org.antlr + antlr3-maven-plugin + + + + antlr + + + + + + org.apache.rat + apache-rat-plugin + + + src/test/resources/hypoglycemia + src/test/resources/hyperglycemia + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + **/HL7QueryParser.java,**/HL7QueryLexer.java + + + + - - - org.antlr - antlr-runtime - 3.5.2 - + + + org.antlr + antlr-runtime + - - - ca.uhn.hapi - hapi-base - 2.2 - - - ca.uhn.hapi - hapi-structures-v21 - 2.2 - - - ca.uhn.hapi - hapi-structures-v22 - 2.2 - - - ca.uhn.hapi - hapi-structures-v23 - 2.2 - - - ca.uhn.hapi - hapi-structures-v231 - 2.2 - - - ca.uhn.hapi - hapi-structures-v24 - 2.2 - - - ca.uhn.hapi - hapi-structures-v25 - 2.2 - - - ca.uhn.hapi - hapi-structures-v251 - 2.2 - - - ca.uhn.hapi - hapi-structures-v26 - 2.2 - + + + ca.uhn.hapi + hapi-base + 2.2 + + + ca.uhn.hapi + hapi-structures-v21 + 2.2 + + + ca.uhn.hapi + hapi-structures-v22 + 2.2 + + + ca.uhn.hapi + hapi-structures-v23 + 2.2 + + + ca.uhn.hapi + hapi-structures-v231 + 2.2 + + + ca.uhn.hapi + hapi-structures-v24 + 2.2 + + + ca.uhn.hapi + hapi-structures-v25 + 2.2 + + + ca.uhn.hapi + hapi-structures-v251 + 2.2 + + + ca.uhn.hapi + hapi-structures-v26 + 2.2 + - - junit - junit - test - - + + junit + junit + test + + diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/hapi/EmptyField.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/hapi/EmptyField.java index be645e59c8..dc73efbea7 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/hapi/EmptyField.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/hapi/EmptyField.java @@ -24,14 +24,14 @@ import org.apache.nifi.hl7.model.HL7Field; public class EmptyField implements HL7Field { - @Override - public String getValue() { - return null; - } + @Override + public String getValue() { + return null; + } - @Override - public List getComponents() { - return Collections.emptyList(); - } + @Override + public List getComponents() { + return Collections.emptyList(); + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/hapi/HapiField.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/hapi/HapiField.java index 056b6b677d..94cce5c1a9 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/hapi/HapiField.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/hapi/HapiField.java @@ -32,52 +32,53 @@ import ca.uhn.hl7v2.parser.EncodingCharacters; import ca.uhn.hl7v2.parser.PipeParser; public class HapiField implements HL7Field, HL7Component { - private final String value; - private final List components; - - public HapiField(final Type type) { - this.value = PipeParser.encode(type, EncodingCharacters.defaultInstance()); - - final List componentList = new ArrayList<>(); - if ( type instanceof Composite ) { - final Composite composite = (Composite) type; - - for ( final Type component : composite.getComponents() ) { - componentList.add(new HapiField(component)); - } - } - - final ExtraComponents extra = type.getExtraComponents(); - if ( extra != null && extra.numComponents() > 0 ) { - final String singleFieldValue; - if ( type instanceof Primitive ) { - singleFieldValue = ((Primitive) type).getValue(); - } else { - singleFieldValue = this.value; - } - componentList.add(new SingleValueField(singleFieldValue)); - - for (int i=0; i < extra.numComponents(); i++) { - final Varies varies = extra.getComponent(i); - componentList.add(new HapiField(varies)); - } - } - - this.components = Collections.unmodifiableList(componentList); - } - - @Override - public String getValue() { - return value; - } - @Override - public List getComponents() { - return components; - } - - @Override - public String toString() { - return value; - } + private final String value; + private final List components; + + public HapiField(final Type type) { + this.value = PipeParser.encode(type, EncodingCharacters.defaultInstance()); + + final List componentList = new ArrayList<>(); + if (type instanceof Composite) { + final Composite composite = (Composite) type; + + for (final Type component : composite.getComponents()) { + componentList.add(new HapiField(component)); + } + } + + final ExtraComponents extra = type.getExtraComponents(); + if (extra != null && extra.numComponents() > 0) { + final String singleFieldValue; + if (type instanceof Primitive) { + singleFieldValue = ((Primitive) type).getValue(); + } else { + singleFieldValue = this.value; + } + componentList.add(new SingleValueField(singleFieldValue)); + + for (int i = 0; i < extra.numComponents(); i++) { + final Varies varies = extra.getComponent(i); + componentList.add(new HapiField(varies)); + } + } + + this.components = Collections.unmodifiableList(componentList); + } + + @Override + public String getValue() { + return value; + } + + @Override + public List getComponents() { + return components; + } + + @Override + public String toString() { + return value; + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/hapi/HapiMessage.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/hapi/HapiMessage.java index ddd28b2bf9..74a8f6cada 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/hapi/HapiMessage.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/hapi/HapiMessage.java @@ -32,63 +32,64 @@ import ca.uhn.hl7v2.model.Segment; import ca.uhn.hl7v2.model.Structure; public class HapiMessage implements HL7Message { - private final Message message; - private final List allSegments; - private final Map> segmentMap; - - public HapiMessage(final Message message) throws HL7Exception { - this.message = message; - - allSegments = new ArrayList<>(); - populateSegments(message, allSegments); - - segmentMap = new HashMap<>(); - for ( final HL7Segment segment : allSegments ) { - final String segmentName = segment.getName(); - List segmentList = segmentMap.get(segmentName); - if ( segmentList == null ) { - segmentList = new ArrayList<>(); - segmentMap.put(segmentName, segmentList); - } - - segmentList.add(segment); - } - } - - private void populateSegments(final Group group, final List segments) throws HL7Exception { - for ( final String structureName : group.getNames() ) { - final Structure[] structures = group.getAll(structureName); - if ( group.isGroup(structureName) ) { - for ( final Structure structure : structures ) { - populateSegments((Group) structure, segments); - } - } else { - for ( final Structure structure : structures ) { - final Segment segment = (Segment) structure; - final HapiSegment hapiSegment = new HapiSegment(segment); - segments.add(hapiSegment); - } - } - } - } - - @Override - public List getSegments() { - return Collections.unmodifiableList(allSegments); - } - @Override - public List getSegments(final String segmentType) { - final List segments = segmentMap.get(segmentType); - if ( segments == null ) { - return Collections.emptyList(); - } - - return Collections.unmodifiableList(segments); - } + private final Message message; + private final List allSegments; + private final Map> segmentMap; - @Override - public String toString() { - return message.toString(); - } + public HapiMessage(final Message message) throws HL7Exception { + this.message = message; + + allSegments = new ArrayList<>(); + populateSegments(message, allSegments); + + segmentMap = new HashMap<>(); + for (final HL7Segment segment : allSegments) { + final String segmentName = segment.getName(); + List segmentList = segmentMap.get(segmentName); + if (segmentList == null) { + segmentList = new ArrayList<>(); + segmentMap.put(segmentName, segmentList); + } + + segmentList.add(segment); + } + } + + private void populateSegments(final Group group, final List segments) throws HL7Exception { + for (final String structureName : group.getNames()) { + final Structure[] structures = group.getAll(structureName); + if (group.isGroup(structureName)) { + for (final Structure structure : structures) { + populateSegments((Group) structure, segments); + } + } else { + for (final Structure structure : structures) { + final Segment segment = (Segment) structure; + final HapiSegment hapiSegment = new HapiSegment(segment); + segments.add(hapiSegment); + } + } + } + } + + @Override + public List getSegments() { + return Collections.unmodifiableList(allSegments); + } + + @Override + public List getSegments(final String segmentType) { + final List segments = segmentMap.get(segmentType); + if (segments == null) { + return Collections.emptyList(); + } + + return Collections.unmodifiableList(segments); + } + + @Override + public String toString() { + return message.toString(); + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/hapi/HapiSegment.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/hapi/HapiSegment.java index d50afdb960..20e646ccb0 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/hapi/HapiSegment.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/hapi/HapiSegment.java @@ -28,42 +28,42 @@ import ca.uhn.hl7v2.model.Segment; import ca.uhn.hl7v2.model.Type; public class HapiSegment implements HL7Segment { - private final Segment segment; - private final List fields; - - public HapiSegment(final Segment segment) throws HL7Exception { - this.segment = segment; - - final List fieldList = new ArrayList<>(); - for (int i=1; i <= segment.numFields(); i++) { - final Type[] types = segment.getField(i); - if ( types == null || types.length == 0 ) { - fieldList.add(new EmptyField()); - continue; - } - - for ( final Type type : types ) { - fieldList.add(new HapiField(type)); - } - } - - this.fields = Collections.unmodifiableList(fieldList); - } - - - @Override - public String getName() { - return segment.getName(); - } + private final Segment segment; + private final List fields; - @Override - public List getFields() { - return fields; - } + public HapiSegment(final Segment segment) throws HL7Exception { + this.segment = segment; - @Override - public String toString() { - return segment.toString(); - } + final List fieldList = new ArrayList<>(); + for (int i = 1; i <= segment.numFields(); i++) { + final Type[] types = segment.getField(i); + + if (types == null || types.length == 0) { + fieldList.add(new EmptyField()); + continue; + } + + for (final Type type : types) { + fieldList.add(new HapiField(type)); + } + } + + this.fields = Collections.unmodifiableList(fieldList); + } + + @Override + public String getName() { + return segment.getName(); + } + + @Override + public List getFields() { + return fields; + } + + @Override + public String toString() { + return segment.toString(); + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/hapi/SingleValueField.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/hapi/SingleValueField.java index ed99077b45..b8a63510a0 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/hapi/SingleValueField.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/hapi/SingleValueField.java @@ -23,20 +23,21 @@ import org.apache.nifi.hl7.model.HL7Component; import org.apache.nifi.hl7.model.HL7Field; public class SingleValueField implements HL7Field { - private final String value; - - public SingleValueField(final String value) { - this.value = value; - } - - @Override - public String getValue() { - return value; - } - @Override - public List getComponents() { - return Collections.emptyList(); - } + private final String value; + + public SingleValueField(final String value) { + this.value = value; + } + + @Override + public String getValue() { + return value; + } + + @Override + public List getComponents() { + return Collections.emptyList(); + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/io/HL7Reader.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/io/HL7Reader.java index e7b31a4c4a..4d2f2768db 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/io/HL7Reader.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/io/HL7Reader.java @@ -22,6 +22,6 @@ import org.apache.nifi.hl7.model.HL7Message; public interface HL7Reader { - HL7Message nextMessage() throws IOException; - + HL7Message nextMessage() throws IOException; + } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/io/exception/InvalidHL7Exception.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/io/exception/InvalidHL7Exception.java index 669f40c6bc..c0c74f95df 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/io/exception/InvalidHL7Exception.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/io/exception/InvalidHL7Exception.java @@ -19,22 +19,23 @@ package org.apache.nifi.hl7.io.exception; import java.io.IOException; public class InvalidHL7Exception extends IOException { - private static final long serialVersionUID = -5675416667224562441L; - public InvalidHL7Exception() { - super(); - } + private static final long serialVersionUID = -5675416667224562441L; - public InvalidHL7Exception(String message, Throwable cause) { - super(message, cause); - } + public InvalidHL7Exception() { + super(); + } - public InvalidHL7Exception(String message) { - super(message); - } + public InvalidHL7Exception(String message, Throwable cause) { + super(message, cause); + } + + public InvalidHL7Exception(String message) { + super(message); + } + + public InvalidHL7Exception(Throwable cause) { + super(cause); + } - public InvalidHL7Exception(Throwable cause) { - super(cause); - } - } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/model/HL7Component.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/model/HL7Component.java index cf355041b1..d8c1495a1b 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/model/HL7Component.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/model/HL7Component.java @@ -19,6 +19,8 @@ package org.apache.nifi.hl7.model; import java.util.List; public interface HL7Component { - String getValue(); - List getComponents(); + + String getValue(); + + List getComponents(); } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/model/HL7Field.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/model/HL7Field.java index 4086e581d1..ff58d962ef 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/model/HL7Field.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/model/HL7Field.java @@ -16,6 +16,5 @@ */ package org.apache.nifi.hl7.model; - public interface HL7Field extends HL7Component { } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/model/HL7Message.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/model/HL7Message.java index dd9c2a9ff4..dc68c2b4ed 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/model/HL7Message.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/model/HL7Message.java @@ -20,8 +20,8 @@ import java.util.List; public interface HL7Message { - List getSegments(); - - List getSegments(String segmentType); - + List getSegments(); + + List getSegments(String segmentType); + } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/model/HL7Segment.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/model/HL7Segment.java index de5aaa1d4b..d5d67aea05 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/model/HL7Segment.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/model/HL7Segment.java @@ -20,8 +20,8 @@ import java.util.List; public interface HL7Segment { - String getName(); - - List getFields(); - + String getName(); + + List getFields(); + } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/Declaration.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/Declaration.java index 0903cc8d30..94998e78c8 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/Declaration.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/Declaration.java @@ -20,10 +20,10 @@ import org.apache.nifi.hl7.model.HL7Message; public interface Declaration { - String getAlias(); - - boolean isRequired(); - - Object getDeclaredValue(HL7Message message); - + String getAlias(); + + boolean isRequired(); + + Object getDeclaredValue(HL7Message message); + } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/HL7Query.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/HL7Query.java index a036106481..3734b4fe08 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/HL7Query.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/HL7Query.java @@ -16,8 +16,6 @@ */ package org.apache.nifi.hl7.query; -import static org.apache.nifi.hl7.query.antlr.HL7QueryParser.*; - import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -58,196 +56,211 @@ import org.apache.nifi.hl7.query.result.StandardQueryResult; import org.apache.nifi.hl7.query.antlr.HL7QueryLexer; import org.apache.nifi.hl7.query.antlr.HL7QueryParser; - +import static org.apache.nifi.hl7.query.antlr.HL7QueryParser.AND; +import static org.apache.nifi.hl7.query.antlr.HL7QueryParser.DECLARE; +import static org.apache.nifi.hl7.query.antlr.HL7QueryParser.DOT; +import static org.apache.nifi.hl7.query.antlr.HL7QueryParser.EQUALS; +import static org.apache.nifi.hl7.query.antlr.HL7QueryParser.GE; +import static org.apache.nifi.hl7.query.antlr.HL7QueryParser.GT; +import static org.apache.nifi.hl7.query.antlr.HL7QueryParser.IDENTIFIER; +import static org.apache.nifi.hl7.query.antlr.HL7QueryParser.IS_NULL; +import static org.apache.nifi.hl7.query.antlr.HL7QueryParser.LE; +import static org.apache.nifi.hl7.query.antlr.HL7QueryParser.LT; +import static org.apache.nifi.hl7.query.antlr.HL7QueryParser.MESSAGE; +import static org.apache.nifi.hl7.query.antlr.HL7QueryParser.NOT; +import static org.apache.nifi.hl7.query.antlr.HL7QueryParser.NOT_EQUALS; +import static org.apache.nifi.hl7.query.antlr.HL7QueryParser.NOT_NULL; +import static org.apache.nifi.hl7.query.antlr.HL7QueryParser.NUMBER; +import static org.apache.nifi.hl7.query.antlr.HL7QueryParser.OR; +import static org.apache.nifi.hl7.query.antlr.HL7QueryParser.REQUIRED; +import static org.apache.nifi.hl7.query.antlr.HL7QueryParser.SEGMENT_NAME; +import static org.apache.nifi.hl7.query.antlr.HL7QueryParser.SELECT; +import static org.apache.nifi.hl7.query.antlr.HL7QueryParser.STRING_LITERAL; +import static org.apache.nifi.hl7.query.antlr.HL7QueryParser.WHERE; public class HL7Query { - private final Tree tree; - private final String query; - private final Set declarations = new HashSet<>(); - - private final List selections; - private final BooleanEvaluator whereEvaluator; - - private HL7Query(final Tree tree, final String query) { - this.tree = tree; - this.query = query; - List select = null; - BooleanEvaluator where = null; - for (int i=0; i < tree.getChildCount(); i++) { - final Tree child = tree.getChild(i); - - switch (child.getType()) { - case DECLARE: - processDeclare(child); - break; - case SELECT: - select = processSelect(child); - break; - case WHERE: - where = processWhere(child); - break; - default: - throw new HL7QueryParsingException("Found unexpected clause at root level: " + tree.getText()); - } - } - - this.whereEvaluator = where; - this.selections = select; - } - - private void processDeclare(final Tree declare) { - for (int i=0; i < declare.getChildCount(); i++) { - final Tree declarationTree = declare.getChild(i); - - final String identifier = declarationTree.getChild(0).getText(); - final Tree requiredOrOptionalTree = declarationTree.getChild(1); - final boolean required = requiredOrOptionalTree.getType() == REQUIRED; - - final String segmentName = declarationTree.getChild(2).getText(); - - final Declaration declaration = new Declaration() { - @Override - public String getAlias() { - return identifier; - } + private final Tree tree; + private final String query; + private final Set declarations = new HashSet<>(); - @Override - public boolean isRequired() { - return required; - } + private final List selections; + private final BooleanEvaluator whereEvaluator; - @Override - public Object getDeclaredValue(final HL7Message message) { - if ( message == null ) { - return null; - } - - return message.getSegments(segmentName); - } - }; - - declarations.add(declaration); - } - } + private HL7Query(final Tree tree, final String query) { + this.tree = tree; + this.query = query; - private List processSelect(final Tree select) { - final List selections = new ArrayList<>(); + List select = null; + BooleanEvaluator where = null; + for (int i = 0; i < tree.getChildCount(); i++) { + final Tree child = tree.getChild(i); - for (int i=0; i < select.getChildCount(); i++) { - final Tree selectable = select.getChild(i); - - final String alias = getSelectedName(selectable); - final Evaluator selectionEvaluator = buildReferenceEvaluator(selectable); - final Selection selection = new Selection(selectionEvaluator, alias); - selections.add(selection); - } - - return selections; - } - - - private String getSelectedName(final Tree selectable) { - if ( selectable.getChildCount() == 0 ) { - return selectable.getText(); - } else if (selectable.getType() == DOT ) { - return getSelectedName(selectable.getChild(0)) + "." + getSelectedName(selectable.getChild(1)); - } else { - return selectable.getChild(selectable.getChildCount() - 1).getText(); - } - } - + switch (child.getType()) { + case DECLARE: + processDeclare(child); + break; + case SELECT: + select = processSelect(child); + break; + case WHERE: + where = processWhere(child); + break; + default: + throw new HL7QueryParsingException("Found unexpected clause at root level: " + tree.getText()); + } + } - private BooleanEvaluator processWhere(final Tree where) { - return buildBooleanEvaluator(where.getChild(0)); - } - + this.whereEvaluator = where; + this.selections = select; + } - private Evaluator buildReferenceEvaluator(final Tree tree) { - switch (tree.getType()) { - case MESSAGE: - return new MessageEvaluator(); - case SEGMENT_NAME: - return new SegmentEvaluator(new StringLiteralEvaluator(tree.getText())); - case IDENTIFIER: - return new DeclaredReferenceEvaluator(new StringLiteralEvaluator(tree.getText())); - case DOT: - final Tree firstChild = tree.getChild(0); - final Tree secondChild = tree.getChild(1); - return new DotEvaluator(buildReferenceEvaluator(firstChild), buildIntegerEvaluator(secondChild)); - case STRING_LITERAL: - return new StringLiteralEvaluator(tree.getText()); - case NUMBER: - return new IntegerLiteralEvaluator(Integer.parseInt(tree.getText())); - default: - throw new HL7QueryParsingException("Failed to build evaluator for " + tree.getText()); - } - } - - - private IntegerEvaluator buildIntegerEvaluator(final Tree tree) { - switch (tree.getType()) { - case NUMBER: - return new IntegerLiteralEvaluator(Integer.parseInt(tree.getText())); - default: - throw new HL7QueryParsingException("Failed to build Integer Evaluator for " + tree.getText()); - } - } - - - private BooleanEvaluator buildBooleanEvaluator(final Tree tree) { - // TODO: add Date comparisons - // LT/GT/GE/GE should allow for dates based on Field's Type - // BETWEEN - // DATE('2015/01/01') - // DATE('2015/01/01 12:00:00') - // DATE('24 HOURS AGO') - // DATE('YESTERDAY') - - switch (tree.getType()) { - case EQUALS: - return new EqualsEvaluator(buildReferenceEvaluator(tree.getChild(0)), buildReferenceEvaluator(tree.getChild(1))); - case NOT_EQUALS: - return new NotEqualsEvaluator(buildReferenceEvaluator(tree.getChild(0)), buildReferenceEvaluator(tree.getChild(1))); - case GT: - return new GreaterThanEvaluator(buildReferenceEvaluator(tree.getChild(0)), buildReferenceEvaluator(tree.getChild(1))); - case LT: - return new LessThanEvaluator(buildReferenceEvaluator(tree.getChild(0)), buildReferenceEvaluator(tree.getChild(1))); - case GE: - return new GreaterThanOrEqualEvaluator(buildReferenceEvaluator(tree.getChild(0)), buildReferenceEvaluator(tree.getChild(1))); - case LE: - return new LessThanOrEqualEvaluator(buildReferenceEvaluator(tree.getChild(0)), buildReferenceEvaluator(tree.getChild(1))); - case NOT: - return new NotEvaluator(buildBooleanEvaluator(tree.getChild(0))); - case AND: - return new AndEvaluator(buildBooleanEvaluator(tree.getChild(0)), buildBooleanEvaluator(tree.getChild(1))); - case OR: - return new OrEvaluator(buildBooleanEvaluator(tree.getChild(0)), buildBooleanEvaluator(tree.getChild(1))); - case IS_NULL: - return new IsNullEvaluator(buildReferenceEvaluator(tree.getChild(0))); - case NOT_NULL: - return new NotNullEvaluator(buildReferenceEvaluator(tree.getChild(0))); - default: - throw new HL7QueryParsingException("Cannot build boolean evaluator for '" + tree.getText() + "'"); - } - } - - - Tree getTree() { - return tree; - } - - public String getQuery() { - return query; - } - - @Override - public String toString() { - return "HL7Query[" + query + "]"; - } - - public static HL7Query compile(final String query) { - try { + private void processDeclare(final Tree declare) { + for (int i = 0; i < declare.getChildCount(); i++) { + final Tree declarationTree = declare.getChild(i); + + final String identifier = declarationTree.getChild(0).getText(); + final Tree requiredOrOptionalTree = declarationTree.getChild(1); + final boolean required = requiredOrOptionalTree.getType() == REQUIRED; + + final String segmentName = declarationTree.getChild(2).getText(); + + final Declaration declaration = new Declaration() { + @Override + public String getAlias() { + return identifier; + } + + @Override + public boolean isRequired() { + return required; + } + + @Override + public Object getDeclaredValue(final HL7Message message) { + if (message == null) { + return null; + } + + return message.getSegments(segmentName); + } + }; + + declarations.add(declaration); + } + } + + private List processSelect(final Tree select) { + final List selections = new ArrayList<>(); + + for (int i = 0; i < select.getChildCount(); i++) { + final Tree selectable = select.getChild(i); + + final String alias = getSelectedName(selectable); + final Evaluator selectionEvaluator = buildReferenceEvaluator(selectable); + final Selection selection = new Selection(selectionEvaluator, alias); + selections.add(selection); + } + + return selections; + } + + private String getSelectedName(final Tree selectable) { + if (selectable.getChildCount() == 0) { + return selectable.getText(); + } else if (selectable.getType() == DOT) { + return getSelectedName(selectable.getChild(0)) + "." + getSelectedName(selectable.getChild(1)); + } else { + return selectable.getChild(selectable.getChildCount() - 1).getText(); + } + } + + private BooleanEvaluator processWhere(final Tree where) { + return buildBooleanEvaluator(where.getChild(0)); + } + + private Evaluator buildReferenceEvaluator(final Tree tree) { + switch (tree.getType()) { + case MESSAGE: + return new MessageEvaluator(); + case SEGMENT_NAME: + return new SegmentEvaluator(new StringLiteralEvaluator(tree.getText())); + case IDENTIFIER: + return new DeclaredReferenceEvaluator(new StringLiteralEvaluator(tree.getText())); + case DOT: + final Tree firstChild = tree.getChild(0); + final Tree secondChild = tree.getChild(1); + return new DotEvaluator(buildReferenceEvaluator(firstChild), buildIntegerEvaluator(secondChild)); + case STRING_LITERAL: + return new StringLiteralEvaluator(tree.getText()); + case NUMBER: + return new IntegerLiteralEvaluator(Integer.parseInt(tree.getText())); + default: + throw new HL7QueryParsingException("Failed to build evaluator for " + tree.getText()); + } + } + + private IntegerEvaluator buildIntegerEvaluator(final Tree tree) { + switch (tree.getType()) { + case NUMBER: + return new IntegerLiteralEvaluator(Integer.parseInt(tree.getText())); + default: + throw new HL7QueryParsingException("Failed to build Integer Evaluator for " + tree.getText()); + } + } + + private BooleanEvaluator buildBooleanEvaluator(final Tree tree) { + // TODO: add Date comparisons + // LT/GT/GE/GE should allow for dates based on Field's Type + // BETWEEN + // DATE('2015/01/01') + // DATE('2015/01/01 12:00:00') + // DATE('24 HOURS AGO') + // DATE('YESTERDAY') + + switch (tree.getType()) { + case EQUALS: + return new EqualsEvaluator(buildReferenceEvaluator(tree.getChild(0)), buildReferenceEvaluator(tree.getChild(1))); + case NOT_EQUALS: + return new NotEqualsEvaluator(buildReferenceEvaluator(tree.getChild(0)), buildReferenceEvaluator(tree.getChild(1))); + case GT: + return new GreaterThanEvaluator(buildReferenceEvaluator(tree.getChild(0)), buildReferenceEvaluator(tree.getChild(1))); + case LT: + return new LessThanEvaluator(buildReferenceEvaluator(tree.getChild(0)), buildReferenceEvaluator(tree.getChild(1))); + case GE: + return new GreaterThanOrEqualEvaluator(buildReferenceEvaluator(tree.getChild(0)), buildReferenceEvaluator(tree.getChild(1))); + case LE: + return new LessThanOrEqualEvaluator(buildReferenceEvaluator(tree.getChild(0)), buildReferenceEvaluator(tree.getChild(1))); + case NOT: + return new NotEvaluator(buildBooleanEvaluator(tree.getChild(0))); + case AND: + return new AndEvaluator(buildBooleanEvaluator(tree.getChild(0)), buildBooleanEvaluator(tree.getChild(1))); + case OR: + return new OrEvaluator(buildBooleanEvaluator(tree.getChild(0)), buildBooleanEvaluator(tree.getChild(1))); + case IS_NULL: + return new IsNullEvaluator(buildReferenceEvaluator(tree.getChild(0))); + case NOT_NULL: + return new NotNullEvaluator(buildReferenceEvaluator(tree.getChild(0))); + default: + throw new HL7QueryParsingException("Cannot build boolean evaluator for '" + tree.getText() + "'"); + } + } + + Tree getTree() { + return tree; + } + + public String getQuery() { + return query; + } + + @Override + public String toString() { + return "HL7Query[" + query + "]"; + } + + public static HL7Query compile(final String query) { + try { final CommonTokenStream lexerTokenStream = createTokenStream(query); final HL7QueryParser parser = new HL7QueryParser(lexerTokenStream); final Tree tree = (Tree) parser.query().getTree(); @@ -258,155 +271,114 @@ public class HL7Query { } catch (final Exception e) { throw new HL7QueryParsingException(e); } - } - - private static CommonTokenStream createTokenStream(final String expression) throws HL7QueryParsingException { + } + + private static CommonTokenStream createTokenStream(final String expression) throws HL7QueryParsingException { final CharStream input = new ANTLRStringStream(expression); final HL7QueryLexer lexer = new HL7QueryLexer(input); return new CommonTokenStream(lexer); } - - public List> getReturnTypes() { - final List> returnTypes = new ArrayList<>(); - - for ( final Selection selection : selections ) { - returnTypes.add( selection.getEvaluator().getType() ); - } - - return returnTypes; - } - - @SuppressWarnings("unchecked") - public QueryResult evaluate(final HL7Message message) { - - int totalIterations = 1; - final LinkedHashMap> possibleValueMap = new LinkedHashMap<>(); - for ( final Declaration declaration : declarations ) { - final Object value = declaration.getDeclaredValue(message); - if ( value == null && declaration.isRequired() ) { - return new MissedResult(selections); - } - final List possibleValues; - if ( value instanceof List ) { - possibleValues = (List) value; - } else if ( value instanceof Collection ) { - possibleValues = new ArrayList((Collection) value); - } else { - possibleValues = new ArrayList<>(1); - possibleValues.add(value); - } - - if ( possibleValues.isEmpty() ) { - return new MissedResult(selections); - } - - possibleValueMap.put(declaration.getAlias(), possibleValues); - totalIterations *= possibleValues.size(); - } + public List> getReturnTypes() { + final List> returnTypes = new ArrayList<>(); - final Set> resultSet = new HashSet<>(); - for (int i=0; i < totalIterations; i++) { - final Map aliasValues = assignAliases(possibleValueMap, i); + for (final Selection selection : selections) { + returnTypes.add(selection.getEvaluator().getType()); + } - aliasValues.put(Evaluator.MESSAGE_KEY, message); - if (whereEvaluator == null || Boolean.TRUE.equals(whereEvaluator.evaluate(aliasValues))) { - final Map resultMap = new HashMap<>(); + return returnTypes; + } - for ( final Selection selection : selections ) { - final Object value = selection.getEvaluator().evaluate(aliasValues); - resultMap.put(selection.getName(), value); - } - - resultSet.add(resultMap); - } - } - -// for ( final Declaration declaration : declarations ) { -// final Object value = declaration.getDeclaredValue(message); -// if ( value == null && declaration.isRequired() ) { -// return new MissedResult(selections); -// } -// objectMap.put(declaration.getAlias(), value); -// } -// -// if (whereEvaluator == null || Boolean.TRUE.equals(whereEvaluator.evaluate(objectMap))) { -// for ( final Selection selection : selections ) { -// final Object value = selection.getEvaluator().evaluate(objectMap); -// resultMap.put(selection.getName(), value); -// } -// } else { -// return new MissedResult(selections); -// } - - return new StandardQueryResult(selections, resultSet); - } - - - // assigns one of the possible values to each alias, based on which iteration this is. - // require LinkedHashMap just to be very clear and explicit that the order of the Map MUST be guaranteed - // between multiple invocations of this method. - // package protected for testing visibility -// static Map assignAliases(final LinkedHashMap> possibleValues, final int iteration) { -// final Map aliasMap = new HashMap<>(); -// -// int aliasIndex = possibleValues.size() - 1; -// for ( final Map.Entry> entry : possibleValues.entrySet() ) { -// final String alias = entry.getKey(); -// final List validValues = entry.getValue(); -// -// final int validValueIndex; -// if (aliasIndex > 0) { -// validValueIndex = iteration / aliasIndex; -// } else { -// validValueIndex = iteration; -// } -// -// final Object obj = validValues.get(validValueIndex % validValues.size()); -// aliasMap.put(alias, obj); -// -// aliasIndex--; -// } -// -// return aliasMap; -// } -// - - static Map assignAliases(final LinkedHashMap> possibleValues, final int iteration) { - final Map aliasMap = new HashMap<>(); - - int divisor = 1; - for ( final Map.Entry> entry : possibleValues.entrySet() ) { - final String alias = entry.getKey(); - final List validValues = entry.getValue(); + @SuppressWarnings("unchecked") + public QueryResult evaluate(final HL7Message message) { - final int idx = (iteration / divisor) % validValues.size(); - final Object obj = validValues.get(idx); - aliasMap.put(alias, obj); - - divisor *= validValues.size(); - } - - return aliasMap; - } - - public String toTreeString() { - final StringBuilder sb = new StringBuilder(); - toTreeString(tree, sb, 0); - return sb.toString(); - } - - private void toTreeString(final Tree tree, final StringBuilder sb, final int indentLevel) { - final String nodeName = tree.getText(); - for (int i=0; i < indentLevel; i++) { - sb.append(" "); - } - sb.append(nodeName); - sb.append("\n"); - - for (int i=0; i < tree.getChildCount(); i++) { - final Tree child = tree.getChild(i); - toTreeString(child, sb, indentLevel + 2); - } - } + int totalIterations = 1; + final LinkedHashMap> possibleValueMap = new LinkedHashMap<>(); + for (final Declaration declaration : declarations) { + final Object value = declaration.getDeclaredValue(message); + if (value == null && declaration.isRequired()) { + return new MissedResult(selections); + } + + final List possibleValues; + if (value instanceof List) { + possibleValues = (List) value; + } else if (value instanceof Collection) { + possibleValues = new ArrayList((Collection) value); + } else { + possibleValues = new ArrayList<>(1); + possibleValues.add(value); + } + + if (possibleValues.isEmpty()) { + return new MissedResult(selections); + } + + possibleValueMap.put(declaration.getAlias(), possibleValues); + totalIterations *= possibleValues.size(); + } + + final Set> resultSet = new HashSet<>(); + for (int i = 0; i < totalIterations; i++) { + final Map aliasValues = assignAliases(possibleValueMap, i); + + aliasValues.put(Evaluator.MESSAGE_KEY, message); + if (whereEvaluator == null || Boolean.TRUE.equals(whereEvaluator.evaluate(aliasValues))) { + final Map resultMap = new HashMap<>(); + + for (final Selection selection : selections) { + final Object value = selection.getEvaluator().evaluate(aliasValues); + resultMap.put(selection.getName(), value); + } + + resultSet.add(resultMap); + } + } + + return new StandardQueryResult(selections, resultSet); + } + + /** + * assigns one of the possible values to each alias, based on which iteration this is. + * require LinkedHashMap just to be very clear and explicit that the order of the Map MUST be guaranteed + * between multiple invocations of this method. + * package protected for testing visibility + */ + static Map assignAliases(final LinkedHashMap> possibleValues, final int iteration) { + final Map aliasMap = new HashMap<>(); + + int divisor = 1; + for (final Map.Entry> entry : possibleValues.entrySet()) { + final String alias = entry.getKey(); + final List validValues = entry.getValue(); + + final int idx = (iteration / divisor) % validValues.size(); + final Object obj = validValues.get(idx); + aliasMap.put(alias, obj); + + divisor *= validValues.size(); + } + + return aliasMap; + } + + public String toTreeString() { + final StringBuilder sb = new StringBuilder(); + toTreeString(tree, sb, 0); + return sb.toString(); + } + + private void toTreeString(final Tree tree, final StringBuilder sb, final int indentLevel) { + final String nodeName = tree.getText(); + for (int i = 0; i < indentLevel; i++) { + sb.append(" "); + } + sb.append(nodeName); + sb.append("\n"); + + for (int i = 0; i < tree.getChildCount(); i++) { + final Tree child = tree.getChild(i); + toTreeString(child, sb, indentLevel + 2); + } + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/QueryResult.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/QueryResult.java index b198bc7ffb..033ac0a0a2 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/QueryResult.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/QueryResult.java @@ -19,11 +19,12 @@ package org.apache.nifi.hl7.query; import java.util.List; public interface QueryResult { - boolean isMatch(); - - List getLabels(); - - int getHitCount(); - - ResultHit nextHit(); + + boolean isMatch(); + + List getLabels(); + + int getHitCount(); + + ResultHit nextHit(); } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/ResultHit.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/ResultHit.java index ee97e5d94c..9eb1d8f694 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/ResultHit.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/ResultHit.java @@ -19,7 +19,8 @@ package org.apache.nifi.hl7.query; import java.util.Map; public interface ResultHit { - Object getValue(String label); - - Map getSelectedValues(); + + Object getValue(String label); + + Map getSelectedValues(); } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/Selection.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/Selection.java index 36a181f539..7b5b7b37ca 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/Selection.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/Selection.java @@ -19,19 +19,20 @@ package org.apache.nifi.hl7.query; import org.apache.nifi.hl7.query.evaluator.Evaluator; public class Selection { - private final Evaluator evaluator; - private final String name; - - public Selection(final Evaluator evaluator, final String name) { - this.evaluator = evaluator; - this.name = name; - } - - public String getName() { - return name; - } - - public Evaluator getEvaluator() { - return evaluator; - } + + private final Evaluator evaluator; + private final String name; + + public Selection(final Evaluator evaluator, final String name) { + this.evaluator = evaluator; + this.name = name; + } + + public String getName() { + return name; + } + + public Evaluator getEvaluator() { + return evaluator; + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/BooleanEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/BooleanEvaluator.java index fdd807ed3e..98b077eb54 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/BooleanEvaluator.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/BooleanEvaluator.java @@ -18,7 +18,7 @@ package org.apache.nifi.hl7.query.evaluator; public abstract class BooleanEvaluator implements Evaluator { - public Class getType() { - return Boolean.class; - } + public Class getType() { + return Boolean.class; + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/Evaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/Evaluator.java index d86c30e06d..2d1ddc7a96 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/Evaluator.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/Evaluator.java @@ -19,9 +19,10 @@ package org.apache.nifi.hl7.query.evaluator; import java.util.Map; public interface Evaluator { - public static final String MESSAGE_KEY = "message"; - - T evaluate(Map objectMap); - - Class getType(); + + public static final String MESSAGE_KEY = "message"; + + T evaluate(Map objectMap); + + Class getType(); } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/IntegerEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/IntegerEvaluator.java index 6afa9ed46c..ed56d80c8b 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/IntegerEvaluator.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/IntegerEvaluator.java @@ -16,11 +16,10 @@ */ package org.apache.nifi.hl7.query.evaluator; - public abstract class IntegerEvaluator implements Evaluator { - public Class getType() { - return Integer.class; - } + public Class getType() { + return Integer.class; + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/StringEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/StringEvaluator.java index 5f73649318..53ab004cc4 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/StringEvaluator.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/StringEvaluator.java @@ -18,8 +18,8 @@ package org.apache.nifi.hl7.query.evaluator; public abstract class StringEvaluator implements Evaluator { - public Class getType() { - return String.class; - } - + public Class getType() { + return String.class; + } + } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/AbstractComparisonEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/AbstractComparisonEvaluator.java index a7fa1b7a29..45edf64c97 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/AbstractComparisonEvaluator.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/AbstractComparisonEvaluator.java @@ -24,83 +24,88 @@ import org.apache.nifi.hl7.query.evaluator.BooleanEvaluator; import org.apache.nifi.hl7.query.evaluator.Evaluator; public abstract class AbstractComparisonEvaluator extends BooleanEvaluator { - private final Evaluator lhs; - private final Evaluator rhs; - - public AbstractComparisonEvaluator(final Evaluator lhs, final Evaluator rhs) { - this.lhs = lhs; - this.rhs = rhs; - } - - public final Boolean evaluate(final Map objectMap) { - final Object lhsValue = lhs.evaluate(objectMap); - if ( lhsValue == null ) { - return false; - } - - final Object rhsValue = rhs.evaluate(objectMap); - if ( rhsValue == null ) { - return false; - } - - return compareRaw(lhsValue, rhsValue); - } - - - private Boolean compareRaw(Object lhsValue, Object rhsValue) { - if ( lhsValue == null || rhsValue == null ) { - return false; - } - if ( lhsValue instanceof HL7Field ) { - lhsValue = ((HL7Field) lhsValue).getValue(); - } - - if ( rhsValue instanceof HL7Field ) { - rhsValue = ((HL7Field) rhsValue).getValue(); - } + private final Evaluator lhs; + private final Evaluator rhs; - if ( lhsValue == null || rhsValue == null ) { - return false; - } - - // both are collections, and compare(lhsValue, rhsValue) is false. - // this would be the case, for instance, if we compared field 1 of one segment to - // a field in another segment, and both fields had components. - if ( lhsValue instanceof Collection && rhsValue instanceof Collection ) { - return false; - } - - // if one side is a collection but the other is not, check if any element in that - // collection compares to the other element in a way that satisfies the condition. - // this would happen, for instance, if we check Segment1.Field5 = 'X' and field 5 repeats - // with a value "A~B~C~X~Y~Z"; in this case we do want to consider Field 5 = X as true. - if ( lhsValue instanceof Collection ) { - for ( final Object lhsObject : (Collection) lhsValue ) { - if ( compareRaw(lhsObject, rhsValue) ) { - return true; - } - } - - return false; - } - - if ( rhsValue instanceof Collection ) { - for ( final Object rhsObject : (Collection) rhsValue ) { - if ( compareRaw(rhsObject, lhsValue) ) { - return true; - } - } - - return false; - } - - if ( lhsValue != null && rhsValue != null && compare(lhsValue, rhsValue) ) { - return true; - } - - return false; - } - - protected abstract boolean compare(Object lhs, Object rhs); + public AbstractComparisonEvaluator(final Evaluator lhs, final Evaluator rhs) { + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public final Boolean evaluate(final Map objectMap) { + final Object lhsValue = lhs.evaluate(objectMap); + if (lhsValue == null) { + return false; + } + + final Object rhsValue = rhs.evaluate(objectMap); + if (rhsValue == null) { + return false; + } + + return compareRaw(lhsValue, rhsValue); + } + + private Boolean compareRaw(Object lhsValue, Object rhsValue) { + if (lhsValue == null || rhsValue == null) { + return false; + } + + if (lhsValue instanceof HL7Field) { + lhsValue = ((HL7Field) lhsValue).getValue(); + } + + if (rhsValue instanceof HL7Field) { + rhsValue = ((HL7Field) rhsValue).getValue(); + } + + if (lhsValue == null || rhsValue == null) { + return false; + } + + /** + * both are collections, and compare(lhsValue, rhsValue) is false. + * this would be the case, for instance, if we compared field 1 of one segment to + * a field in another segment, and both fields had components. + */ + if (lhsValue instanceof Collection && rhsValue instanceof Collection) { + return false; + } + + /** + * if one side is a collection but the other is not, check if any element in that + * collection compares to the other element in a way that satisfies the condition. + * this would happen, for instance, if we check Segment1.Field5 = 'X' and field 5 repeats + * with a value "A~B~C~X~Y~Z"; in this case we do want to consider Field 5 = X as true. + */ + if (lhsValue instanceof Collection) { + for (final Object lhsObject : (Collection) lhsValue) { + if (compareRaw(lhsObject, rhsValue)) { + return true; + } + } + + return false; + } + + if (rhsValue instanceof Collection) { + for (final Object rhsObject : (Collection) rhsValue) { + if (compareRaw(rhsObject, lhsValue)) { + return true; + } + } + + return false; + } + + if (lhsValue != null && rhsValue != null && compare(lhsValue, rhsValue)) { + return true; + } + + return false; + } + + protected abstract boolean compare(Object lhs, Object rhs); } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/AbstractNumericComparison.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/AbstractNumericComparison.java index 2529c4914b..d74e9cfcc3 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/AbstractNumericComparison.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/AbstractNumericComparison.java @@ -21,47 +21,48 @@ import java.util.regex.Pattern; import org.apache.nifi.hl7.query.evaluator.Evaluator; public abstract class AbstractNumericComparison extends AbstractComparisonEvaluator { - private static final Pattern NUMERIC_PATTERN = Pattern.compile("\\d+(\\.\\d+)?"); - - public AbstractNumericComparison(final Evaluator lhs, final Evaluator rhs) { - super(lhs, rhs); - } - - @Override - protected final boolean compare(final Object lhs, final Object rhs) { - final Double lhsDouble = toDouble(lhs); - if ( lhsDouble == null ) { - return false; - } - - final Double rhsDouble = toDouble(rhs); - if ( rhsDouble == null ) { - return false; - } - - return compareNumbers(lhsDouble, rhsDouble); - } - private Double toDouble(final Object value) { - if ( value == null ) { - return null; - } - - if ( value instanceof Double ) { - return (Double) value; - } - if ( value instanceof Number ) { - return ((Number) value).doubleValue(); - } - - if ( value instanceof String ) { - if ( NUMERIC_PATTERN.matcher((String) value).matches() ) { - return Double.parseDouble((String) value); - } - } - - return null; - } - - protected abstract boolean compareNumbers(final Double lhs, final Double rhs); + private static final Pattern NUMERIC_PATTERN = Pattern.compile("\\d+(\\.\\d+)?"); + + public AbstractNumericComparison(final Evaluator lhs, final Evaluator rhs) { + super(lhs, rhs); + } + + @Override + protected final boolean compare(final Object lhs, final Object rhs) { + final Double lhsDouble = toDouble(lhs); + if (lhsDouble == null) { + return false; + } + + final Double rhsDouble = toDouble(rhs); + if (rhsDouble == null) { + return false; + } + + return compareNumbers(lhsDouble, rhsDouble); + } + + private Double toDouble(final Object value) { + if (value == null) { + return null; + } + + if (value instanceof Double) { + return (Double) value; + } + if (value instanceof Number) { + return ((Number) value).doubleValue(); + } + + if (value instanceof String) { + if (NUMERIC_PATTERN.matcher((String) value).matches()) { + return Double.parseDouble((String) value); + } + } + + return null; + } + + protected abstract boolean compareNumbers(final Double lhs, final Double rhs); } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/EqualsEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/EqualsEvaluator.java index 7ee2f8707b..fa6c57bd7c 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/EqualsEvaluator.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/EqualsEvaluator.java @@ -20,13 +20,13 @@ import org.apache.nifi.hl7.query.evaluator.Evaluator; public class EqualsEvaluator extends AbstractComparisonEvaluator { - public EqualsEvaluator(final Evaluator lhs, final Evaluator rhs) { - super(lhs, rhs); - } - - @Override - protected boolean compare(final Object lhs, final Object rhs) { - return lhs != null && rhs != null && ((lhs == rhs) || (lhs.equals(rhs)) || lhs.toString().equals(rhs.toString())); - } + public EqualsEvaluator(final Evaluator lhs, final Evaluator rhs) { + super(lhs, rhs); + } + + @Override + protected boolean compare(final Object lhs, final Object rhs) { + return lhs != null && rhs != null && ((lhs == rhs) || (lhs.equals(rhs)) || lhs.toString().equals(rhs.toString())); + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/GreaterThanEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/GreaterThanEvaluator.java index bf8596ecc9..cfef7b53a7 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/GreaterThanEvaluator.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/GreaterThanEvaluator.java @@ -18,17 +18,15 @@ package org.apache.nifi.hl7.query.evaluator.comparison; import org.apache.nifi.hl7.query.evaluator.Evaluator; - public class GreaterThanEvaluator extends AbstractNumericComparison { - public GreaterThanEvaluator(final Evaluator lhs, final Evaluator rhs) { - super(lhs, rhs); - } + public GreaterThanEvaluator(final Evaluator lhs, final Evaluator rhs) { + super(lhs, rhs); + } - @Override - protected boolean compareNumbers(final Double lhs, final Double rhs) { - return lhs > rhs; - } + @Override + protected boolean compareNumbers(final Double lhs, final Double rhs) { + return lhs > rhs; + } - } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/GreaterThanOrEqualEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/GreaterThanOrEqualEvaluator.java index 69115a3855..d9da6f77dc 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/GreaterThanOrEqualEvaluator.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/GreaterThanOrEqualEvaluator.java @@ -18,17 +18,15 @@ package org.apache.nifi.hl7.query.evaluator.comparison; import org.apache.nifi.hl7.query.evaluator.Evaluator; - public class GreaterThanOrEqualEvaluator extends AbstractNumericComparison { - public GreaterThanOrEqualEvaluator(final Evaluator lhs, final Evaluator rhs) { - super(lhs, rhs); - } + public GreaterThanOrEqualEvaluator(final Evaluator lhs, final Evaluator rhs) { + super(lhs, rhs); + } - @Override - protected boolean compareNumbers(final Double lhs, final Double rhs) { - return lhs >= rhs; - } + @Override + protected boolean compareNumbers(final Double lhs, final Double rhs) { + return lhs >= rhs; + } - } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/IsNullEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/IsNullEvaluator.java index 69d481e289..0f16dd9390 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/IsNullEvaluator.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/IsNullEvaluator.java @@ -24,46 +24,47 @@ import org.apache.nifi.hl7.query.evaluator.BooleanEvaluator; import org.apache.nifi.hl7.query.evaluator.Evaluator; public class IsNullEvaluator extends BooleanEvaluator { - private final Evaluator subjectEvaluator; - - public IsNullEvaluator(final Evaluator subjectEvaluator) { - this.subjectEvaluator = subjectEvaluator; - } - - @Override - public Boolean evaluate(final Map objectMap) { - Object subjectValue = subjectEvaluator.evaluate(objectMap); - if ( subjectValue == null ) { - return true; - } - - return isNull(subjectValue); - } - private boolean isNull(Object subjectValue) { - if ( subjectValue == null ) { - return true; - } - - if ( subjectValue instanceof HL7Component ) { - subjectValue = ((HL7Component) subjectValue).getValue(); - } - - if ( subjectValue instanceof Collection ) { - final Collection collection = (Collection) subjectValue; - if ( collection.isEmpty() ) { - return true; - } - - for ( final Object obj : collection ) { - if ( !isNull(obj) ) { - return false; - } - } - - return true; - } - - return subjectValue == null; - } + private final Evaluator subjectEvaluator; + + public IsNullEvaluator(final Evaluator subjectEvaluator) { + this.subjectEvaluator = subjectEvaluator; + } + + @Override + public Boolean evaluate(final Map objectMap) { + Object subjectValue = subjectEvaluator.evaluate(objectMap); + if (subjectValue == null) { + return true; + } + + return isNull(subjectValue); + } + + private boolean isNull(Object subjectValue) { + if (subjectValue == null) { + return true; + } + + if (subjectValue instanceof HL7Component) { + subjectValue = ((HL7Component) subjectValue).getValue(); + } + + if (subjectValue instanceof Collection) { + final Collection collection = (Collection) subjectValue; + if (collection.isEmpty()) { + return true; + } + + for (final Object obj : collection) { + if (!isNull(obj)) { + return false; + } + } + + return true; + } + + return subjectValue == null; + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/LessThanEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/LessThanEvaluator.java index 891d5e4c3b..280586011b 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/LessThanEvaluator.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/LessThanEvaluator.java @@ -19,13 +19,14 @@ package org.apache.nifi.hl7.query.evaluator.comparison; import org.apache.nifi.hl7.query.evaluator.Evaluator; public class LessThanEvaluator extends AbstractNumericComparison { - public LessThanEvaluator(final Evaluator lhs, final Evaluator rhs) { - super(lhs, rhs); - } - @Override - protected boolean compareNumbers(final Double lhs, final Double rhs) { - return lhs < rhs; - } + public LessThanEvaluator(final Evaluator lhs, final Evaluator rhs) { + super(lhs, rhs); + } + + @Override + protected boolean compareNumbers(final Double lhs, final Double rhs) { + return lhs < rhs; + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/LessThanOrEqualEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/LessThanOrEqualEvaluator.java index c6fb0974ed..e7eb156196 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/LessThanOrEqualEvaluator.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/LessThanOrEqualEvaluator.java @@ -19,13 +19,14 @@ package org.apache.nifi.hl7.query.evaluator.comparison; import org.apache.nifi.hl7.query.evaluator.Evaluator; public class LessThanOrEqualEvaluator extends AbstractNumericComparison { - public LessThanOrEqualEvaluator(final Evaluator lhs, final Evaluator rhs) { - super(lhs, rhs); - } - @Override - protected boolean compareNumbers(final Double lhs, final Double rhs) { - return lhs <= rhs; - } + public LessThanOrEqualEvaluator(final Evaluator lhs, final Evaluator rhs) { + super(lhs, rhs); + } + + @Override + protected boolean compareNumbers(final Double lhs, final Double rhs) { + return lhs <= rhs; + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/NotEqualsEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/NotEqualsEvaluator.java index b7c1ce28a0..98715ff01d 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/NotEqualsEvaluator.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/NotEqualsEvaluator.java @@ -19,14 +19,14 @@ package org.apache.nifi.hl7.query.evaluator.comparison; import org.apache.nifi.hl7.query.evaluator.Evaluator; public class NotEqualsEvaluator extends AbstractComparisonEvaluator { - - public NotEqualsEvaluator(final Evaluator lhs, final Evaluator rhs) { - super(lhs, rhs); - } - @Override - protected boolean compare(final Object lhs, final Object rhs) { - return lhs != null && rhs != null && lhs != rhs && !lhs.equals(rhs) && !lhs.toString().equals(rhs.toString()); - } + public NotEqualsEvaluator(final Evaluator lhs, final Evaluator rhs) { + super(lhs, rhs); + } + + @Override + protected boolean compare(final Object lhs, final Object rhs) { + return lhs != null && rhs != null && lhs != rhs && !lhs.equals(rhs) && !lhs.toString().equals(rhs.toString()); + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/NotEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/NotEvaluator.java index 58888d9aea..3343c1c37b 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/NotEvaluator.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/NotEvaluator.java @@ -21,16 +21,17 @@ import java.util.Map; import org.apache.nifi.hl7.query.evaluator.BooleanEvaluator; public class NotEvaluator extends BooleanEvaluator { - private final BooleanEvaluator subjectEvaluator; - - public NotEvaluator(final BooleanEvaluator subjectEvaluator) { - this.subjectEvaluator = subjectEvaluator; - } - - @Override - public Boolean evaluate(final Map objectMap) { - final Boolean subjectValue = subjectEvaluator.evaluate(objectMap); - return (subjectValue == null || Boolean.TRUE.equals(subjectValue)); - } + + private final BooleanEvaluator subjectEvaluator; + + public NotEvaluator(final BooleanEvaluator subjectEvaluator) { + this.subjectEvaluator = subjectEvaluator; + } + + @Override + public Boolean evaluate(final Map objectMap) { + final Boolean subjectValue = subjectEvaluator.evaluate(objectMap); + return (subjectValue == null || Boolean.TRUE.equals(subjectValue)); + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/NotNullEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/NotNullEvaluator.java index a764fef61c..80d6c45b56 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/NotNullEvaluator.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/comparison/NotNullEvaluator.java @@ -24,42 +24,43 @@ import org.apache.nifi.hl7.query.evaluator.BooleanEvaluator; import org.apache.nifi.hl7.query.evaluator.Evaluator; public class NotNullEvaluator extends BooleanEvaluator { - private final Evaluator subjectEvaluator; - - public NotNullEvaluator(final Evaluator subjectEvaluator) { - this.subjectEvaluator = subjectEvaluator; - } - - @Override - public Boolean evaluate(final Map objectMap) { - Object subjectValue = subjectEvaluator.evaluate(objectMap); - if ( subjectValue == null ) { - return false; - } - - return isNotNull(subjectValue); - } - private boolean isNotNull(Object subjectValue) { - if ( subjectValue instanceof HL7Component ) { - subjectValue = ((HL7Component) subjectValue).getValue(); - } - - if ( subjectValue instanceof Collection ) { - final Collection collection = (Collection) subjectValue; - if ( collection.isEmpty() ) { - return false; - } - - for ( final Object obj : collection ) { - if ( isNotNull(obj) ) { - return true; - } - } - - return false; - } - - return subjectValue != null; - } + private final Evaluator subjectEvaluator; + + public NotNullEvaluator(final Evaluator subjectEvaluator) { + this.subjectEvaluator = subjectEvaluator; + } + + @Override + public Boolean evaluate(final Map objectMap) { + Object subjectValue = subjectEvaluator.evaluate(objectMap); + if (subjectValue == null) { + return false; + } + + return isNotNull(subjectValue); + } + + private boolean isNotNull(Object subjectValue) { + if (subjectValue instanceof HL7Component) { + subjectValue = ((HL7Component) subjectValue).getValue(); + } + + if (subjectValue instanceof Collection) { + final Collection collection = (Collection) subjectValue; + if (collection.isEmpty()) { + return false; + } + + for (final Object obj : collection) { + if (isNotNull(obj)) { + return true; + } + } + + return false; + } + + return subjectValue != null; + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/literal/IntegerLiteralEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/literal/IntegerLiteralEvaluator.java index c6ff6e479d..dfceee469e 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/literal/IntegerLiteralEvaluator.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/literal/IntegerLiteralEvaluator.java @@ -21,16 +21,16 @@ import java.util.Map; import org.apache.nifi.hl7.query.evaluator.IntegerEvaluator; public class IntegerLiteralEvaluator extends IntegerEvaluator { - private final Integer value; - - public IntegerLiteralEvaluator(final Integer value) { - this.value = value; - } - - - @Override - public Integer evaluate(final Map objectMap) { - return value; - } + + private final Integer value; + + public IntegerLiteralEvaluator(final Integer value) { + this.value = value; + } + + @Override + public Integer evaluate(final Map objectMap) { + return value; + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/literal/StringLiteralEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/literal/StringLiteralEvaluator.java index 3b296117c9..278ac1d071 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/literal/StringLiteralEvaluator.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/literal/StringLiteralEvaluator.java @@ -21,15 +21,16 @@ import java.util.Map; import org.apache.nifi.hl7.query.evaluator.StringEvaluator; public class StringLiteralEvaluator extends StringEvaluator { - private final String value; - - public StringLiteralEvaluator(final String value) { - this.value = value; - } - - @Override - public String evaluate(final Map objectMap) { - return value; - } + + private final String value; + + public StringLiteralEvaluator(final String value) { + this.value = value; + } + + @Override + public String evaluate(final Map objectMap) { + return value; + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/logic/AndEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/logic/AndEvaluator.java index 21f596e3dc..989cee47af 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/logic/AndEvaluator.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/logic/AndEvaluator.java @@ -21,23 +21,24 @@ import java.util.Map; import org.apache.nifi.hl7.query.evaluator.BooleanEvaluator; public class AndEvaluator extends BooleanEvaluator { - private final BooleanEvaluator lhs; - private final BooleanEvaluator rhs; - - public AndEvaluator(final BooleanEvaluator lhs, final BooleanEvaluator rhs) { - this.lhs = lhs; - this.rhs = rhs; - } - - @Override - public Boolean evaluate(final Map objectMap) { - final Boolean lhsValue = lhs.evaluate(objectMap); - if ( lhsValue == null || Boolean.FALSE.equals(lhsValue) ) { - return false; - } - - final Boolean rhsValue = rhs.evaluate(objectMap); - return (rhsValue != null && Boolean.TRUE.equals(rhsValue)); - } + + private final BooleanEvaluator lhs; + private final BooleanEvaluator rhs; + + public AndEvaluator(final BooleanEvaluator lhs, final BooleanEvaluator rhs) { + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public Boolean evaluate(final Map objectMap) { + final Boolean lhsValue = lhs.evaluate(objectMap); + if (lhsValue == null || Boolean.FALSE.equals(lhsValue)) { + return false; + } + + final Boolean rhsValue = rhs.evaluate(objectMap); + return (rhsValue != null && Boolean.TRUE.equals(rhsValue)); + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/logic/OrEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/logic/OrEvaluator.java index d090946da0..e86daad1b4 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/logic/OrEvaluator.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/logic/OrEvaluator.java @@ -21,23 +21,24 @@ import java.util.Map; import org.apache.nifi.hl7.query.evaluator.BooleanEvaluator; public class OrEvaluator extends BooleanEvaluator { - private final BooleanEvaluator lhs; - private final BooleanEvaluator rhs; - - public OrEvaluator(final BooleanEvaluator lhs, final BooleanEvaluator rhs) { - this.lhs = lhs; - this.rhs = rhs; - } - - @Override - public Boolean evaluate(final Map objectMap) { - final Boolean lhsValue = lhs.evaluate(objectMap); - if ( lhsValue != null && Boolean.TRUE.equals(lhsValue) ) { - return true; - } - - final Boolean rhsValue = rhs.evaluate(objectMap); - return (rhsValue != null && Boolean.TRUE.equals(rhsValue)); - } + + private final BooleanEvaluator lhs; + private final BooleanEvaluator rhs; + + public OrEvaluator(final BooleanEvaluator lhs, final BooleanEvaluator rhs) { + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public Boolean evaluate(final Map objectMap) { + final Boolean lhsValue = lhs.evaluate(objectMap); + if (lhsValue != null && Boolean.TRUE.equals(lhsValue)) { + return true; + } + + final Boolean rhsValue = rhs.evaluate(objectMap); + return (rhsValue != null && Boolean.TRUE.equals(rhsValue)); + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/DeclaredReferenceEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/DeclaredReferenceEvaluator.java index 6afb8d7ec1..bb3f20397e 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/DeclaredReferenceEvaluator.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/DeclaredReferenceEvaluator.java @@ -22,21 +22,22 @@ import org.apache.nifi.hl7.query.evaluator.Evaluator; import org.apache.nifi.hl7.query.evaluator.StringEvaluator; public class DeclaredReferenceEvaluator implements Evaluator { - private final StringEvaluator referenceNameEvaluator; - - public DeclaredReferenceEvaluator(final StringEvaluator referenceNameEvaluator) { - this.referenceNameEvaluator = referenceNameEvaluator; - } - - @Override - public Object evaluate(final Map objectMap) { - final String referenceName = referenceNameEvaluator.evaluate(objectMap); - return objectMap.get(referenceName); - } - @Override - public Class getType() { - return Object.class; - } + private final StringEvaluator referenceNameEvaluator; + + public DeclaredReferenceEvaluator(final StringEvaluator referenceNameEvaluator) { + this.referenceNameEvaluator = referenceNameEvaluator; + } + + @Override + public Object evaluate(final Map objectMap) { + final String referenceName = referenceNameEvaluator.evaluate(objectMap); + return objectMap.get(referenceName); + } + + @Override + public Class getType() { + return Object.class; + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/DotEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/DotEvaluator.java index c5fbf41c54..238b540b8e 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/DotEvaluator.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/DotEvaluator.java @@ -28,61 +28,62 @@ import org.apache.nifi.hl7.query.evaluator.Evaluator; import org.apache.nifi.hl7.query.evaluator.IntegerEvaluator; public class DotEvaluator implements Evaluator { - private final Evaluator lhs; - private final IntegerEvaluator rhs; - - public DotEvaluator(final Evaluator lhs, final IntegerEvaluator rhs) { - this.lhs = lhs; - this.rhs = rhs; - } - - @Override - public Object evaluate(final Map objectMap) { - final Object lhsValue = this.lhs.evaluate(objectMap); - final Integer rhsValue = this.rhs.evaluate(objectMap); - - if ( lhsValue == null || rhsValue == null ) { - return null; - } - - final List results = new ArrayList<>(); - if ( lhsValue instanceof Collection ) { - final Collection lhsCollection = (Collection) lhsValue; - for ( final Object obj : lhsCollection ) { - final Object val = getValue(obj, rhsValue); - results.add(val); - } - } else { - final Object val = getValue(lhsValue, rhsValue); - return val; - } - - return results; - } - - private Object getValue(final Object lhsValue, final int rhsValue) { - final List list; - if ( lhsValue instanceof HL7Message ) { - list = ((HL7Message) lhsValue).getSegments(); - } else if ( lhsValue instanceof HL7Segment ) { - list = ((HL7Segment) lhsValue).getFields(); - } else if ( lhsValue instanceof HL7Component ) { - list = ((HL7Component) lhsValue).getComponents(); - } else { - return null; - } - - if ( rhsValue > list.size() ) { - return null; - } - - // convert from 0-based to 1-based - return list.get(rhsValue - 1); - } - @Override - public Class getType() { - return Object.class; - } + private final Evaluator lhs; + private final IntegerEvaluator rhs; + + public DotEvaluator(final Evaluator lhs, final IntegerEvaluator rhs) { + this.lhs = lhs; + this.rhs = rhs; + } + + @Override + public Object evaluate(final Map objectMap) { + final Object lhsValue = this.lhs.evaluate(objectMap); + final Integer rhsValue = this.rhs.evaluate(objectMap); + + if (lhsValue == null || rhsValue == null) { + return null; + } + + final List results = new ArrayList<>(); + if (lhsValue instanceof Collection) { + final Collection lhsCollection = (Collection) lhsValue; + for (final Object obj : lhsCollection) { + final Object val = getValue(obj, rhsValue); + results.add(val); + } + } else { + final Object val = getValue(lhsValue, rhsValue); + return val; + } + + return results; + } + + private Object getValue(final Object lhsValue, final int rhsValue) { + final List list; + if (lhsValue instanceof HL7Message) { + list = ((HL7Message) lhsValue).getSegments(); + } else if (lhsValue instanceof HL7Segment) { + list = ((HL7Segment) lhsValue).getFields(); + } else if (lhsValue instanceof HL7Component) { + list = ((HL7Component) lhsValue).getComponents(); + } else { + return null; + } + + if (rhsValue > list.size()) { + return null; + } + + // convert from 0-based to 1-based + return list.get(rhsValue - 1); + } + + @Override + public Class getType() { + return Object.class; + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/FieldEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/FieldEvaluator.java index 869c2d0783..bc8046ed00 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/FieldEvaluator.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/FieldEvaluator.java @@ -28,40 +28,41 @@ import org.apache.nifi.hl7.query.evaluator.IntegerEvaluator; @SuppressWarnings("rawtypes") public class FieldEvaluator implements Evaluator { - private final SegmentEvaluator segmentEvaluator; - private final IntegerEvaluator indexEvaluator; - - public FieldEvaluator(final SegmentEvaluator segmentEvaluator, final IntegerEvaluator indexEvaluator) { - this.segmentEvaluator = segmentEvaluator; - this.indexEvaluator = indexEvaluator; - } - - public List evaluate(final Map objectMap) { - final List segments = segmentEvaluator.evaluate(objectMap); - if ( segments == null ) { - return Collections.emptyList(); - } - - final Integer index = indexEvaluator.evaluate(objectMap); - if ( index == null ) { - return Collections.emptyList(); - } - - final List fields = new ArrayList<>(); - for ( final HL7Segment segment : segments ) { - final List segmentFields = segment.getFields(); - if ( segmentFields.size() <= index ) { - continue; - } - - fields.add(segmentFields.get(index)); - } - - return fields; - } - public Class getType() { - return List.class; - } + private final SegmentEvaluator segmentEvaluator; + private final IntegerEvaluator indexEvaluator; + + public FieldEvaluator(final SegmentEvaluator segmentEvaluator, final IntegerEvaluator indexEvaluator) { + this.segmentEvaluator = segmentEvaluator; + this.indexEvaluator = indexEvaluator; + } + + public List evaluate(final Map objectMap) { + final List segments = segmentEvaluator.evaluate(objectMap); + if (segments == null) { + return Collections.emptyList(); + } + + final Integer index = indexEvaluator.evaluate(objectMap); + if (index == null) { + return Collections.emptyList(); + } + + final List fields = new ArrayList<>(); + for (final HL7Segment segment : segments) { + final List segmentFields = segment.getFields(); + if (segmentFields.size() <= index) { + continue; + } + + fields.add(segmentFields.get(index)); + } + + return fields; + } + + public Class getType() { + return List.class; + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/MessageEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/MessageEvaluator.java index 5e08961954..f430b505e8 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/MessageEvaluator.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/MessageEvaluator.java @@ -23,12 +23,12 @@ import org.apache.nifi.hl7.query.evaluator.Evaluator; public class MessageEvaluator implements Evaluator { - public HL7Message evaluate(final Map objectMap) { - return (HL7Message) objectMap.get(Evaluator.MESSAGE_KEY); - } + public HL7Message evaluate(final Map objectMap) { + return (HL7Message) objectMap.get(Evaluator.MESSAGE_KEY); + } - public Class getType() { - return HL7Message.class; - } + public Class getType() { + return HL7Message.class; + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/SegmentEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/SegmentEvaluator.java index 1b9782d0e6..9840461c8b 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/SegmentEvaluator.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/SegmentEvaluator.java @@ -27,25 +27,26 @@ import org.apache.nifi.hl7.query.evaluator.StringEvaluator; @SuppressWarnings("rawtypes") public class SegmentEvaluator implements Evaluator { - private final StringEvaluator segmentTypeEvaluator; - - public SegmentEvaluator(final StringEvaluator segmentTypeEvaluator) { - this.segmentTypeEvaluator = segmentTypeEvaluator; - } - - public List evaluate(final Map objectMap) { - final String segmentType = segmentTypeEvaluator.evaluate(objectMap); - if ( segmentType == null ) { - return Collections.emptyList(); - } - - final HL7Message message = (HL7Message) objectMap.get(Evaluator.MESSAGE_KEY); - final List segments = message.getSegments(segmentType); - return (segments == null) ? Collections.emptyList() : segments; - } - public Class getType() { - return List.class; - } + private final StringEvaluator segmentTypeEvaluator; + + public SegmentEvaluator(final StringEvaluator segmentTypeEvaluator) { + this.segmentTypeEvaluator = segmentTypeEvaluator; + } + + public List evaluate(final Map objectMap) { + final String segmentType = segmentTypeEvaluator.evaluate(objectMap); + if (segmentType == null) { + return Collections.emptyList(); + } + + final HL7Message message = (HL7Message) objectMap.get(Evaluator.MESSAGE_KEY); + final List segments = message.getSegments(segmentType); + return (segments == null) ? Collections.emptyList() : segments; + } + + public Class getType() { + return List.class; + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/exception/HL7QueryParsingException.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/exception/HL7QueryParsingException.java index 998f3bc87c..e27dd58164 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/exception/HL7QueryParsingException.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/exception/HL7QueryParsingException.java @@ -17,21 +17,22 @@ package org.apache.nifi.hl7.query.exception; public class HL7QueryParsingException extends RuntimeException { - private static final long serialVersionUID = 1L; - public HL7QueryParsingException() { - super(); - } - - public HL7QueryParsingException(final Throwable cause) { - super(cause); - } - - public HL7QueryParsingException(final String message) { - super(message); - } - - public HL7QueryParsingException(final String message, final Throwable cause) { - super(message, cause); - } + private static final long serialVersionUID = 1L; + + public HL7QueryParsingException() { + super(); + } + + public HL7QueryParsingException(final Throwable cause) { + super(cause); + } + + public HL7QueryParsingException(final String message) { + super(message); + } + + public HL7QueryParsingException(final String message, final Throwable cause) { + super(message, cause); + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/MissedResult.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/MissedResult.java index a6b36c8621..1043ab6df1 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/MissedResult.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/MissedResult.java @@ -24,33 +24,34 @@ import org.apache.nifi.hl7.query.ResultHit; import org.apache.nifi.hl7.query.Selection; public class MissedResult implements QueryResult { - private final List selections; - - public MissedResult(final List selections) { - this.selections = selections; - } - - @Override - public List getLabels() { - final List labels = new ArrayList<>(); - for ( final Selection selection : selections ) { - labels.add(selection.getName()); - } - return labels; - } - @Override - public boolean isMatch() { - return false; - } + private final List selections; - @Override - public ResultHit nextHit() { - return null; - } - - @Override - public int getHitCount() { - return 0; - } + public MissedResult(final List selections) { + this.selections = selections; + } + + @Override + public List getLabels() { + final List labels = new ArrayList<>(); + for (final Selection selection : selections) { + labels.add(selection.getName()); + } + return labels; + } + + @Override + public boolean isMatch() { + return false; + } + + @Override + public ResultHit nextHit() { + return null; + } + + @Override + public int getHitCount() { + return 0; + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/StandardQueryResult.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/StandardQueryResult.java index fbc16cab4c..bcba697136 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/StandardQueryResult.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/StandardQueryResult.java @@ -27,43 +27,44 @@ import org.apache.nifi.hl7.query.ResultHit; import org.apache.nifi.hl7.query.Selection; public class StandardQueryResult implements QueryResult { - private final List selections; - private final Set> hits; - private final Iterator> hitIterator; - - public StandardQueryResult(final List selections, final Set> hits) { - this.selections = selections; - this.hits = hits; - - hitIterator = hits.iterator(); - } - - @Override - public boolean isMatch() { - return !hits.isEmpty(); - } - @Override - public List getLabels() { - final List labels = new ArrayList<>(); - for ( final Selection selection : selections ) { - labels.add(selection.getName()); - } - return labels; - } + private final List selections; + private final Set> hits; + private final Iterator> hitIterator; + + public StandardQueryResult(final List selections, final Set> hits) { + this.selections = selections; + this.hits = hits; + + hitIterator = hits.iterator(); + } + + @Override + public boolean isMatch() { + return !hits.isEmpty(); + } + + @Override + public List getLabels() { + final List labels = new ArrayList<>(); + for (final Selection selection : selections) { + labels.add(selection.getName()); + } + return labels; + } + + @Override + public int getHitCount() { + return hits.size(); + } + + @Override + public ResultHit nextHit() { + if (hitIterator.hasNext()) { + return new StandardResultHit(hitIterator.next()); + } else { + return null; + } + } - @Override - public int getHitCount() { - return hits.size(); - } - - @Override - public ResultHit nextHit() { - if ( hitIterator.hasNext() ) { - return new StandardResultHit(hitIterator.next()); - } else { - return null; - } - } - } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/StandardResultHit.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/StandardResultHit.java index 944e998173..7fe92050f5 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/StandardResultHit.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/StandardResultHit.java @@ -22,20 +22,21 @@ import java.util.Map; import org.apache.nifi.hl7.query.ResultHit; public class StandardResultHit implements ResultHit { - private final Map values; - - public StandardResultHit(final Map values) { - this.values = values; - } - - @Override - public Object getValue(final String label) { - return values.get(label); - } - @Override - public Map getSelectedValues() { - return Collections.unmodifiableMap(values); - } + private final Map values; + + public StandardResultHit(final Map values) { + this.values = values; + } + + @Override + public Object getValue(final String label) { + return values.get(label); + } + + @Override + public Map getSelectedValues() { + return Collections.unmodifiableMap(values); + } } diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/test/java/org/apache/nifi/hl7/query/TestHL7Query.java b/nifi/nifi-commons/nifi-hl7-query-language/src/test/java/org/apache/nifi/hl7/query/TestHL7Query.java index 596440c380..f78f82b40c 100644 --- a/nifi/nifi-commons/nifi-hl7-query-language/src/test/java/org/apache/nifi/hl7/query/TestHL7Query.java +++ b/nifi/nifi-commons/nifi-hl7-query-language/src/test/java/org/apache/nifi/hl7/query/TestHL7Query.java @@ -43,268 +43,264 @@ import ca.uhn.hl7v2.validation.impl.ValidationContextFactory; @SuppressWarnings("resource") public class TestHL7Query { - @Test - public void testAssignAliases() { - final LinkedHashMap> possibleValueMap = new LinkedHashMap<>(); - - final List valuesA = new ArrayList<>(); - valuesA.add("a"); - valuesA.add("b"); - valuesA.add("c"); - - final List valuesB = new ArrayList<>(); - valuesB.add("d"); - - final List valuesC = new ArrayList<>(); - valuesC.add("e"); - valuesC.add("f"); - - final List valuesD = new ArrayList<>(); - valuesD.add("g"); - valuesD.add("h"); - - possibleValueMap.put("A", valuesA); - possibleValueMap.put("B", valuesB); - possibleValueMap.put("C", valuesC); - possibleValueMap.put("D", valuesD); - - for (int i=0; i < valuesA.size() * valuesB.size() * valuesC.size() * valuesD.size(); i++) { - System.out.println(i + " : " + HL7Query.assignAliases(possibleValueMap, i)); - } - - verifyAssignments(HL7Query.assignAliases(possibleValueMap, 0), "a", "d", "e", "g"); - verifyAssignments(HL7Query.assignAliases(possibleValueMap, 1), "b", "d", "e", "g"); - verifyAssignments(HL7Query.assignAliases(possibleValueMap, 2), "c", "d", "e", "g"); - verifyAssignments(HL7Query.assignAliases(possibleValueMap, 3), "a", "d", "f", "g"); - verifyAssignments(HL7Query.assignAliases(possibleValueMap, 4), "b", "d", "f", "g"); - verifyAssignments(HL7Query.assignAliases(possibleValueMap, 5), "c", "d", "f", "g"); - verifyAssignments(HL7Query.assignAliases(possibleValueMap, 6), "a", "d", "e", "h"); - verifyAssignments(HL7Query.assignAliases(possibleValueMap, 7), "b", "d", "e", "h"); - verifyAssignments(HL7Query.assignAliases(possibleValueMap, 8), "c", "d", "e", "h"); - verifyAssignments(HL7Query.assignAliases(possibleValueMap, 9), "a", "d", "f", "h"); - verifyAssignments(HL7Query.assignAliases(possibleValueMap, 10), "b", "d", "f", "h"); - verifyAssignments(HL7Query.assignAliases(possibleValueMap, 11), "c", "d", "f", "h"); - } - - private void verifyAssignments(final Map map, final String a, final String b, final String c, final String d) { - assertEquals(a, map.get("A")); - assertEquals(b, map.get("B")); - assertEquals(c, map.get("C")); - assertEquals(d, map.get("D")); - } - - @Test - public void testSelectMessage() throws HL7Exception, IOException { - final HL7Query query = HL7Query.compile("SELECT MESSAGE"); - final HL7Message msg = createMessage(new File("src/test/resources/hypoglycemia")); - final QueryResult result = query.evaluate(msg); - assertTrue(result.isMatch()); - final List labels = result.getLabels(); - assertEquals(1, labels.size()); - assertEquals("MESSAGE", labels.get(0)); - - assertEquals(1, result.getHitCount()); - assertEquals(msg, result.nextHit().getValue("MESSAGE")); - } - - @Test - @SuppressWarnings({ "unchecked", "rawtypes" }) - public void testSelectField() throws HL7Exception, IOException { - final HL7Query query = HL7Query.compile("SELECT PID.5"); - final HL7Message msg = createMessage(new File("src/test/resources/hypoglycemia")); - final QueryResult result = query.evaluate(msg); - assertTrue(result.isMatch()); - final List labels = result.getLabels(); - assertEquals(1, labels.size()); - assertEquals(1, result.getHitCount()); - - final Object names = result.nextHit().getValue("PID.5"); - assertTrue(names instanceof List); - final List nameList = (List) names; - assertEquals(1, nameList.size()); - final HL7Field nameField = (HL7Field) nameList.get(0); - assertEquals("SMITH^JOHN", nameField.getValue()); - } - - @Test - public void testSelectAbnormalTestResult() throws HL7Exception, IOException { - final String query = "DECLARE result AS REQUIRED OBX SELECT result WHERE result.7 != 'N' AND result.1 = 1"; - - final HL7Query hl7Query = HL7Query.compile(query); - final QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertTrue( result.isMatch() ); - } - - - @Test - public void testFieldEqualsString() throws HL7Exception, IOException { - HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'L'"); - QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertTrue( result.isMatch() ); - - hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'H'"); - result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertFalse( result.isMatch() ); - } - - @Test - public void testLessThan() throws HL7Exception, IOException { - HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 < 600"); - QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertTrue( result.isMatch() ); - - hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 < 59"); - result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertFalse( result.isMatch() ); - } - - @Test - public void testCompareTwoFields() throws HL7Exception, IOException { - HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 < result.6.2"); - QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertTrue( result.isMatch() ); - - hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE NOT(result.4 > result.6.3)"); - result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertFalse( result.isMatch() ); - } - - @Test - public void testLessThanOrEqual() throws HL7Exception, IOException { - HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 <= 59"); - QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertTrue( result.isMatch() ); + @Test + public void testAssignAliases() { + final LinkedHashMap> possibleValueMap = new LinkedHashMap<>(); - hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 <= 600"); - result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertTrue( result.isMatch() ); + final List valuesA = new ArrayList<>(); + valuesA.add("a"); + valuesA.add("b"); + valuesA.add("c"); - hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 <= 58"); - result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertFalse( result.isMatch() ); - } - - @Test - public void testGreaterThanOrEqual() throws HL7Exception, IOException { - HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 >= 59"); - QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertTrue( result.isMatch() ); + final List valuesB = new ArrayList<>(); + valuesB.add("d"); - hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 >= 6"); - result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertTrue( result.isMatch() ); + final List valuesC = new ArrayList<>(); + valuesC.add("e"); + valuesC.add("f"); - hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 >= 580"); - result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertFalse( result.isMatch() ); - } - - @Test - public void testGreaterThan() throws HL7Exception, IOException { - HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 > 58"); - QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertTrue( result.isMatch() ); + final List valuesD = new ArrayList<>(); + valuesD.add("g"); + valuesD.add("h"); - hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 > 6"); - result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertTrue( result.isMatch() ); + possibleValueMap.put("A", valuesA); + possibleValueMap.put("B", valuesB); + possibleValueMap.put("C", valuesC); + possibleValueMap.put("D", valuesD); - hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 > 580"); - result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertFalse( result.isMatch() ); - } + for (int i = 0; i < valuesA.size() * valuesB.size() * valuesC.size() * valuesD.size(); i++) { + System.out.println(i + " : " + HL7Query.assignAliases(possibleValueMap, i)); + } - - @Test - public void testDistinctValuesReturned() throws HL7Exception, IOException { - HL7Query hl7Query = HL7Query.compile("DECLARE result1 AS REQUIRED OBX, result2 AS REQUIRED OBX SELECT MESSAGE WHERE result1.7 = 'L' OR result2.7 != 'H'"); - QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertTrue( result.isMatch() ); - assertEquals(1, result.getHitCount()); - } - - @Test - public void testAndWithParens() throws HL7Exception, IOException { - HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'L' AND result.3.1 = 'GLU'"); - QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertTrue( result.isMatch() ); - - hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'L' AND result.3.1 = 'GLU'"); - result = hl7Query.evaluate(createMessage(new File("src/test/resources/hyperglycemia"))); - assertFalse( result.isMatch() ); - - hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'H' AND result.3.1 = 'GLU'"); - result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertFalse( result.isMatch() ); + verifyAssignments(HL7Query.assignAliases(possibleValueMap, 0), "a", "d", "e", "g"); + verifyAssignments(HL7Query.assignAliases(possibleValueMap, 1), "b", "d", "e", "g"); + verifyAssignments(HL7Query.assignAliases(possibleValueMap, 2), "c", "d", "e", "g"); + verifyAssignments(HL7Query.assignAliases(possibleValueMap, 3), "a", "d", "f", "g"); + verifyAssignments(HL7Query.assignAliases(possibleValueMap, 4), "b", "d", "f", "g"); + verifyAssignments(HL7Query.assignAliases(possibleValueMap, 5), "c", "d", "f", "g"); + verifyAssignments(HL7Query.assignAliases(possibleValueMap, 6), "a", "d", "e", "h"); + verifyAssignments(HL7Query.assignAliases(possibleValueMap, 7), "b", "d", "e", "h"); + verifyAssignments(HL7Query.assignAliases(possibleValueMap, 8), "c", "d", "e", "h"); + verifyAssignments(HL7Query.assignAliases(possibleValueMap, 9), "a", "d", "f", "h"); + verifyAssignments(HL7Query.assignAliases(possibleValueMap, 10), "b", "d", "f", "h"); + verifyAssignments(HL7Query.assignAliases(possibleValueMap, 11), "c", "d", "f", "h"); + } - hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'H' AND result.3.1 = 'GLU'"); - result = hl7Query.evaluate(createMessage(new File("src/test/resources/hyperglycemia"))); - assertTrue( result.isMatch() ); + private void verifyAssignments(final Map map, final String a, final String b, final String c, final String d) { + assertEquals(a, map.get("A")); + assertEquals(b, map.get("B")); + assertEquals(c, map.get("C")); + assertEquals(d, map.get("D")); + } - hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE (result.7 = 'H') AND (result.3.1 = 'GLU')"); - result = hl7Query.evaluate(createMessage(new File("src/test/resources/hyperglycemia"))); - assertTrue( result.isMatch() ); + @Test + public void testSelectMessage() throws HL7Exception, IOException { + final HL7Query query = HL7Query.compile("SELECT MESSAGE"); + final HL7Message msg = createMessage(new File("src/test/resources/hypoglycemia")); + final QueryResult result = query.evaluate(msg); + assertTrue(result.isMatch()); + final List labels = result.getLabels(); + assertEquals(1, labels.size()); + assertEquals("MESSAGE", labels.get(0)); - hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE ((result.7 = 'H') AND (result.3.1 = 'GLU'))"); - result = hl7Query.evaluate(createMessage(new File("src/test/resources/hyperglycemia"))); - assertTrue( result.isMatch() ); + assertEquals(1, result.getHitCount()); + assertEquals(msg, result.nextHit().getValue("MESSAGE")); + } - hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE (( ((result.7 = 'H')) AND ( ((result.3.1 = 'GLU')) )))"); - result = hl7Query.evaluate(createMessage(new File("src/test/resources/hyperglycemia"))); - assertTrue( result.isMatch() ); + @Test + @SuppressWarnings({"unchecked", "rawtypes"}) + public void testSelectField() throws HL7Exception, IOException { + final HL7Query query = HL7Query.compile("SELECT PID.5"); + final HL7Message msg = createMessage(new File("src/test/resources/hypoglycemia")); + final QueryResult result = query.evaluate(msg); + assertTrue(result.isMatch()); + final List labels = result.getLabels(); + assertEquals(1, labels.size()); + assertEquals(1, result.getHitCount()); + + final Object names = result.nextHit().getValue("PID.5"); + assertTrue(names instanceof List); + final List nameList = (List) names; + assertEquals(1, nameList.size()); + final HL7Field nameField = (HL7Field) nameList.get(0); + assertEquals("SMITH^JOHN", nameField.getValue()); + } + + @Test + public void testSelectAbnormalTestResult() throws HL7Exception, IOException { + final String query = "DECLARE result AS REQUIRED OBX SELECT result WHERE result.7 != 'N' AND result.1 = 1"; + + final HL7Query hl7Query = HL7Query.compile(query); + final QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertTrue(result.isMatch()); + } + + @Test + public void testFieldEqualsString() throws HL7Exception, IOException { + HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'L'"); + QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertTrue(result.isMatch()); + + hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'H'"); + result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertFalse(result.isMatch()); + } + + @Test + public void testLessThan() throws HL7Exception, IOException { + HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 < 600"); + QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertTrue(result.isMatch()); + + hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 < 59"); + result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertFalse(result.isMatch()); + } + + @Test + public void testCompareTwoFields() throws HL7Exception, IOException { + HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 < result.6.2"); + QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertTrue(result.isMatch()); + + hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE NOT(result.4 > result.6.3)"); + result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertFalse(result.isMatch()); + } + + @Test + public void testLessThanOrEqual() throws HL7Exception, IOException { + HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 <= 59"); + QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertTrue(result.isMatch()); + + hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 <= 600"); + result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertTrue(result.isMatch()); + + hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 <= 58"); + result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertFalse(result.isMatch()); + } + + @Test + public void testGreaterThanOrEqual() throws HL7Exception, IOException { + HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 >= 59"); + QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertTrue(result.isMatch()); + + hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 >= 6"); + result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertTrue(result.isMatch()); + + hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 >= 580"); + result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertFalse(result.isMatch()); + } + + @Test + public void testGreaterThan() throws HL7Exception, IOException { + HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 > 58"); + QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertTrue(result.isMatch()); + + hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 > 6"); + result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertTrue(result.isMatch()); + + hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 > 580"); + result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertFalse(result.isMatch()); + } + + @Test + public void testDistinctValuesReturned() throws HL7Exception, IOException { + HL7Query hl7Query = HL7Query.compile("DECLARE result1 AS REQUIRED OBX, result2 AS REQUIRED OBX SELECT MESSAGE WHERE result1.7 = 'L' OR result2.7 != 'H'"); + QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertTrue(result.isMatch()); + assertEquals(1, result.getHitCount()); + } + + @Test + public void testAndWithParens() throws HL7Exception, IOException { + HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'L' AND result.3.1 = 'GLU'"); + QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertTrue(result.isMatch()); + + hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'L' AND result.3.1 = 'GLU'"); + result = hl7Query.evaluate(createMessage(new File("src/test/resources/hyperglycemia"))); + assertFalse(result.isMatch()); + + hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'H' AND result.3.1 = 'GLU'"); + result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertFalse(result.isMatch()); + + hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'H' AND result.3.1 = 'GLU'"); + result = hl7Query.evaluate(createMessage(new File("src/test/resources/hyperglycemia"))); + assertTrue(result.isMatch()); + + hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE (result.7 = 'H') AND (result.3.1 = 'GLU')"); + result = hl7Query.evaluate(createMessage(new File("src/test/resources/hyperglycemia"))); + assertTrue(result.isMatch()); + + hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE ((result.7 = 'H') AND (result.3.1 = 'GLU'))"); + result = hl7Query.evaluate(createMessage(new File("src/test/resources/hyperglycemia"))); + assertTrue(result.isMatch()); + + hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE (( ((result.7 = 'H')) AND ( ((result.3.1 = 'GLU')) )))"); + result = hl7Query.evaluate(createMessage(new File("src/test/resources/hyperglycemia"))); + assertTrue(result.isMatch()); + + } + + @Test + public void testIsNull() throws HL7Exception, IOException { + HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.999 IS NULL"); + QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertTrue(result.isMatch()); + + hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.1 IS NULL"); + result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertFalse(result.isMatch()); + + hl7Query = HL7Query.compile("SELECT MESSAGE WHERE ZZZ IS NULL"); + result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertTrue(result.isMatch()); + + hl7Query = HL7Query.compile("SELECT MESSAGE WHERE OBX IS NULL"); + result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertFalse(result.isMatch()); + } + + @Test + public void testNotNull() throws HL7Exception, IOException { + HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.999 NOT NULL"); + QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertFalse(result.isMatch()); + + hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.1 NOT NULL"); + result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertTrue(result.isMatch()); + + hl7Query = HL7Query.compile("SELECT MESSAGE WHERE ZZZ NOT NULL"); + result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertFalse(result.isMatch()); + + hl7Query = HL7Query.compile("SELECT MESSAGE WHERE OBX NOT NULL"); + result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); + assertTrue(result.isMatch()); + } + + private HL7Message createMessage(final File file) throws HL7Exception, IOException { + final byte[] bytes = Files.readAllBytes(file.toPath()); + final String msgText = new String(bytes, "UTF-8"); + + final HapiContext hapiContext = new DefaultHapiContext(); + hapiContext.setValidationContext(ValidationContextFactory.noValidation()); + + final PipeParser parser = hapiContext.getPipeParser(); + final Message message = parser.parse(msgText); + return new HapiMessage(message); + } - } - - - @Test - public void testIsNull() throws HL7Exception, IOException { - HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.999 IS NULL"); - QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertTrue( result.isMatch() ); - - hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.1 IS NULL"); - result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertFalse( result.isMatch() ); - - hl7Query = HL7Query.compile("SELECT MESSAGE WHERE ZZZ IS NULL"); - result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertTrue( result.isMatch() ); - - hl7Query = HL7Query.compile("SELECT MESSAGE WHERE OBX IS NULL"); - result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertFalse( result.isMatch() ); - } - - - @Test - public void testNotNull() throws HL7Exception, IOException { - HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.999 NOT NULL"); - QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertFalse( result.isMatch() ); - - hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.1 NOT NULL"); - result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertTrue( result.isMatch() ); - - hl7Query = HL7Query.compile("SELECT MESSAGE WHERE ZZZ NOT NULL"); - result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertFalse( result.isMatch() ); - - hl7Query = HL7Query.compile("SELECT MESSAGE WHERE OBX NOT NULL"); - result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia"))); - assertTrue( result.isMatch() ); - } - - private HL7Message createMessage(final File file) throws HL7Exception, IOException { - final byte[] bytes = Files.readAllBytes(file.toPath()); - final String msgText = new String(bytes, "UTF-8"); - - final HapiContext hapiContext = new DefaultHapiContext(); - hapiContext.setValidationContext(ValidationContextFactory.noValidation()); - - final PipeParser parser = hapiContext.getPipeParser(); - final Message message = parser.parse(msgText); - return new HapiMessage(message); - } - } diff --git a/nifi/nifi-commons/nifi-logging-utils/src/main/java/org/apache/nifi/logging/NiFiLog.java b/nifi/nifi-commons/nifi-logging-utils/src/main/java/org/apache/nifi/logging/NiFiLog.java index 7c71d8569b..3de8518625 100644 --- a/nifi/nifi-commons/nifi-logging-utils/src/main/java/org/apache/nifi/logging/NiFiLog.java +++ b/nifi/nifi-commons/nifi-logging-utils/src/main/java/org/apache/nifi/logging/NiFiLog.java @@ -21,7 +21,6 @@ import org.slf4j.Marker; /** * - * @author unattributed */ public class NiFiLog implements Logger { diff --git a/nifi/nifi-commons/nifi-processor-utilities/src/main/java/org/apache/nifi/processor/util/FlowFileFilters.java b/nifi/nifi-commons/nifi-processor-utilities/src/main/java/org/apache/nifi/processor/util/FlowFileFilters.java index 1f77093006..2d1a407dac 100644 --- a/nifi/nifi-commons/nifi-processor-utilities/src/main/java/org/apache/nifi/processor/util/FlowFileFilters.java +++ b/nifi/nifi-commons/nifi-processor-utilities/src/main/java/org/apache/nifi/processor/util/FlowFileFilters.java @@ -32,7 +32,7 @@ public class FlowFileFilters { * @param maxSize the maximum size of the group of FlowFiles * @param unit the unit of the maxSize argument * @param maxCount the maximum number of FlowFiles to pull - * @return + * @return filter */ public static FlowFileFilter newSizeBasedFilter(final double maxSize, final DataUnit unit, final int maxCount) { final double maxBytes = DataUnit.B.convert(maxSize, unit); diff --git a/nifi/nifi-commons/nifi-processor-utilities/src/main/java/org/apache/nifi/processor/util/SSLProperties.java b/nifi/nifi-commons/nifi-processor-utilities/src/main/java/org/apache/nifi/processor/util/SSLProperties.java index 0d66df51f8..87d63de017 100644 --- a/nifi/nifi-commons/nifi-processor-utilities/src/main/java/org/apache/nifi/processor/util/SSLProperties.java +++ b/nifi/nifi-commons/nifi-processor-utilities/src/main/java/org/apache/nifi/processor/util/SSLProperties.java @@ -130,7 +130,13 @@ public class SSLProperties { try { final boolean storeValid = CertificateUtils.isStoreValid(file.toURI().toURL(), KeystoreType.valueOf(type), password.toCharArray()); if (!storeValid) { - results.add(new ValidationResult.Builder().subject(keystoreDesc + " Properties").valid(false).explanation("Invalid KeyStore Password or Type specified for file " + filename).build()); + results.add( + new ValidationResult.Builder() + .subject(keystoreDesc + " Properties") + .valid(false) + .explanation("Invalid KeyStore Password or Type specified for file " + filename) + .build() + ); } } catch (MalformedURLException e) { results.add(new ValidationResult.Builder().subject(keystoreDesc + " Properties").valid(false).explanation("Malformed URL from file: " + e).build()); diff --git a/nifi/nifi-commons/nifi-processor-utilities/src/main/java/org/apache/nifi/processor/util/StandardValidators.java b/nifi/nifi-commons/nifi-processor-utilities/src/main/java/org/apache/nifi/processor/util/StandardValidators.java index d1621eda43..37ba7d8b45 100644 --- a/nifi/nifi-commons/nifi-processor-utilities/src/main/java/org/apache/nifi/processor/util/StandardValidators.java +++ b/nifi/nifi-commons/nifi-processor-utilities/src/main/java/org/apache/nifi/processor/util/StandardValidators.java @@ -46,10 +46,10 @@ public class StandardValidators { public ValidationResult validate(final String subject, final String input, final ValidationContext context) { final ValidationResult.Builder builder = new ValidationResult.Builder(); builder.subject(subject).input(input); - if ( context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input) ) { + if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input)) { return builder.valid(true).explanation("Contains Expression Language").build(); } - + try { FlowFile.KeyValidator.validateKey(input); builder.valid(true); @@ -66,10 +66,10 @@ public class StandardValidators { public ValidationResult validate(final String subject, final String input, final ValidationContext context) { final ValidationResult.Builder builder = new ValidationResult.Builder(); builder.subject("Property Name").input(subject); - if ( context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input) ) { + if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input)) { return builder.valid(true).explanation("Contains Expression Language").build(); } - + try { FlowFile.KeyValidator.validateKey(subject); builder.valid(true); @@ -84,10 +84,10 @@ public class StandardValidators { public static final Validator POSITIVE_INTEGER_VALIDATOR = new Validator() { @Override public ValidationResult validate(final String subject, final String value, final ValidationContext context) { - if ( context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(value) ) { + if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(value)) { return new ValidationResult.Builder().subject(subject).input(value).explanation("Expression Language Present").valid(true).build(); } - + String reason = null; try { final int intVal = Integer.parseInt(value); @@ -106,7 +106,7 @@ public class StandardValidators { public static final Validator POSITIVE_LONG_VALIDATOR = new Validator() { @Override public ValidationResult validate(final String subject, final String value, final ValidationContext context) { - if ( context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(value) ) { + if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(value)) { return new ValidationResult.Builder().subject(subject).input(value).explanation("Expression Language Present").valid(true).build(); } @@ -137,7 +137,7 @@ public class StandardValidators { public static final Validator BOOLEAN_VALIDATOR = new Validator() { @Override public ValidationResult validate(final String subject, final String value, final ValidationContext context) { - if ( context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(value) ) { + if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(value)) { return new ValidationResult.Builder().subject(subject).input(value).explanation("Expression Language Present").valid(true).build(); } @@ -150,7 +150,7 @@ public class StandardValidators { public static final Validator INTEGER_VALIDATOR = new Validator() { @Override public ValidationResult validate(final String subject, final String value, final ValidationContext context) { - if ( context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(value) ) { + if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(value)) { return new ValidationResult.Builder().subject(subject).input(value).explanation("Expression Language Present").valid(true).build(); } @@ -168,7 +168,7 @@ public class StandardValidators { public static final Validator LONG_VALIDATOR = new Validator() { @Override public ValidationResult validate(final String subject, final String value, final ValidationContext context) { - if ( context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(value) ) { + if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(value)) { return new ValidationResult.Builder().subject(subject).input(value).explanation("Expression Language Present").valid(true).build(); } @@ -186,7 +186,7 @@ public class StandardValidators { public static final Validator NON_NEGATIVE_INTEGER_VALIDATOR = new Validator() { @Override public ValidationResult validate(final String subject, final String value, final ValidationContext context) { - if ( context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(value) ) { + if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(value)) { return new ValidationResult.Builder().subject(subject).input(value).explanation("Expression Language Present").valid(true).build(); } @@ -208,7 +208,7 @@ public class StandardValidators { public static final Validator CHARACTER_SET_VALIDATOR = new Validator() { @Override public ValidationResult validate(final String subject, final String value, final ValidationContext context) { - if ( context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(value) ) { + if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(value)) { return new ValidationResult.Builder().subject(subject).input(value).explanation("Expression Language Present").valid(true).build(); } @@ -235,7 +235,7 @@ public class StandardValidators { public static final Validator URI_VALIDATOR = new Validator() { @Override public ValidationResult validate(final String subject, final String input, final ValidationContext context) { - if ( context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input) ) { + if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input)) { return new ValidationResult.Builder().subject(subject).input(input).explanation("Expression Language Present").valid(true).build(); } @@ -253,7 +253,7 @@ public class StandardValidators { public static final Validator ATTRIBUTE_EXPRESSION_LANGUAGE_VALIDATOR = new Validator() { @Override public ValidationResult validate(final String subject, final String input, final ValidationContext context) { - if ( context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input) ) { + if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input)) { return new ValidationResult.Builder().subject(subject).input(input).explanation("Expression Language Present").valid(true).build(); } @@ -270,7 +270,7 @@ public class StandardValidators { public static final Validator TIME_PERIOD_VALIDATOR = new Validator() { @Override public ValidationResult validate(final String subject, final String input, final ValidationContext context) { - if ( context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input) ) { + if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input)) { return new ValidationResult.Builder().subject(subject).input(input).explanation("Expression Language Present").valid(true).build(); } @@ -280,7 +280,14 @@ public class StandardValidators { if (Pattern.compile(FormatUtils.TIME_DURATION_REGEX).matcher(input.toLowerCase()).matches()) { return new ValidationResult.Builder().subject(subject).input(input).valid(true).build(); } else { - return new ValidationResult.Builder().subject(subject).input(input).valid(false).explanation("Must be of format where is a non-negative integer and TimeUnit is a supported Time Unit, such as: nanos, millis, secs, mins, hrs, days").build(); + return new ValidationResult.Builder() + .subject(subject) + .input(input) + .valid(false) + .explanation("Must be of format where is a " + + "non-negative integer and TimeUnit is a supported Time Unit, such " + + "as: nanos, millis, secs, mins, hrs, days") + .build(); } } }; @@ -288,17 +295,28 @@ public class StandardValidators { public static final Validator DATA_SIZE_VALIDATOR = new Validator() { @Override public ValidationResult validate(final String subject, final String input, final ValidationContext context) { - if ( context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input) ) { + if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input)) { return new ValidationResult.Builder().subject(subject).input(input).explanation("Expression Language Present").valid(true).build(); } if (input == null) { - return new ValidationResult.Builder().subject(subject).input(input).valid(false).explanation("Data Size cannot be null").build(); + return new ValidationResult.Builder() + .subject(subject) + .input(input) + .valid(false) + .explanation("Data Size cannot be null") + .build(); } if (Pattern.compile(DataUnit.DATA_SIZE_REGEX).matcher(input.toUpperCase()).matches()) { return new ValidationResult.Builder().subject(subject).input(input).valid(true).build(); } else { - return new ValidationResult.Builder().subject(subject).input(input).valid(false).explanation("Must be of format where is a non-negative integer and is a supported Data Unit, such as: B, KB, MB, GB, TB").build(); + return new ValidationResult.Builder() + .subject(subject).input(input) + .valid(false) + .explanation("Must be of format where " + + " is a non-negative integer and is a supported Data" + + " Unit, such as: B, KB, MB, GB, TB") + .build(); } } }; @@ -318,7 +336,7 @@ public class StandardValidators { return new Validator() { @Override public ValidationResult validate(final String subject, final String input, final ValidationContext context) { - if ( context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input) ) { + if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input)) { return new ValidationResult.Builder().subject(subject).input(input).explanation("Expression Language Present").valid(true).build(); } @@ -346,19 +364,19 @@ public class StandardValidators { @Override public ValidationResult validate(final String subject, final String input, final ValidationContext context) { - if ( context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input) ) { + if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input)) { return new ValidationResult.Builder().subject(subject).input(input).explanation("Expression Language Present").valid(true).build(); } final ValidationResult vr = DATA_SIZE_VALIDATOR.validate(subject, input, context); - if(!vr.isValid()){ + if (!vr.isValid()) { return vr; } final long dataSizeBytes = DataUnit.parseDataSize(input, DataUnit.B).longValue(); - if(dataSizeBytes < minBytesInclusive){ + if (dataSizeBytes < minBytesInclusive) { return new ValidationResult.Builder().subject(subject).input(input).valid(false).explanation("Cannot be smaller than " + minBytesInclusive + " bytes").build(); } - if(dataSizeBytes > maxBytesInclusive){ + if (dataSizeBytes > maxBytesInclusive) { return new ValidationResult.Builder().subject(subject).input(input).valid(false).explanation("Cannot be larger than " + maxBytesInclusive + " bytes").build(); } return new ValidationResult.Builder().subject(subject).input(input).valid(true).build(); @@ -371,7 +389,7 @@ public class StandardValidators { return new Validator() { @Override public ValidationResult validate(final String subject, final String input, final ValidationContext context) { - if ( context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input) ) { + if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input)) { return new ValidationResult.Builder().subject(subject).input(input).explanation("Expression Language Present").valid(true).build(); } @@ -397,10 +415,11 @@ public class StandardValidators { * Language will not support FlowFile Attributes but only System/JVM * Properties * - * @param minCapturingGroups - * @param maxCapturingGroups - * @param supportAttributeExpressionLanguage - * @return + * @param minCapturingGroups minimum capturing groups allowed + * @param maxCapturingGroups maximum capturing groups allowed + * @param supportAttributeExpressionLanguage whether or not to support + * expression language + * @return validator */ public static Validator createRegexValidator(final int minCapturingGroups, final int maxCapturingGroups, final boolean supportAttributeExpressionLanguage) { return new Validator() { @@ -412,7 +431,12 @@ public class StandardValidators { try { substituted = context.newPropertyValue(value).evaluateAttributeExpressions().getValue(); } catch (final Exception e) { - return new ValidationResult.Builder().subject(subject).input(value).valid(false).explanation("Failed to evaluate the Attribute Expression Language due to " + e.toString()).build(); + return new ValidationResult.Builder() + .subject(subject) + .input(value) + .valid(false) + .explanation("Failed to evaluate the Attribute Expression Language due to " + e.toString()) + .build(); } } else { substituted = value; @@ -421,12 +445,22 @@ public class StandardValidators { final Pattern pattern = Pattern.compile(substituted); final int numGroups = pattern.matcher("").groupCount(); if (numGroups < minCapturingGroups || numGroups > maxCapturingGroups) { - return new ValidationResult.Builder().subject(subject).input(value).valid(false).explanation("RegEx is required to have between " + minCapturingGroups + " and " + maxCapturingGroups + " Capturing Groups but has " + numGroups).build(); + return new ValidationResult.Builder() + .subject(subject) + .input(value) + .valid(false) + .explanation("RegEx is required to have between " + minCapturingGroups + " and " + maxCapturingGroups + " Capturing Groups but has " + numGroups) + .build(); } return new ValidationResult.Builder().subject(subject).input(value).valid(true).build(); } catch (final Exception e) { - return new ValidationResult.Builder().subject(subject).input(value).valid(false).explanation("Not a valid Java Regular Expression").build(); + return new ValidationResult.Builder() + .subject(subject) + .input(value) + .valid(false) + .explanation("Not a valid Java Regular Expression") + .build(); } } @@ -444,7 +478,12 @@ public class StandardValidators { final ResultType resultType = allowExtraCharacters ? ResultType.STRING : context.newExpressionLanguageCompiler().getResultType(input); if (!resultType.equals(expectedResultType)) { - return new ValidationResult.Builder().subject(subject).input(input).valid(false).explanation("Expected Attribute Query to return type " + expectedResultType + " but query returns type " + resultType).build(); + return new ValidationResult.Builder() + .subject(subject) + .input(input) + .valid(false) + .explanation("Expected Attribute Query to return type " + expectedResultType + " but query returns type " + resultType) + .build(); } return new ValidationResult.Builder().subject(subject).input(input).valid(true).build(); @@ -456,7 +495,7 @@ public class StandardValidators { return new Validator() { @Override public ValidationResult validate(final String subject, final String input, final ValidationContext context) { - if ( context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input) ) { + if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input)) { return new ValidationResult.Builder().subject(subject).input(input).explanation("Expression Language Present").valid(true).build(); } @@ -502,7 +541,7 @@ public class StandardValidators { @Override public ValidationResult validate(final String subject, final String input, final ValidationContext context) { - if ( context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input) ) { + if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input)) { return new ValidationResult.Builder().subject(subject).input(input).explanation("Expression Language Present").valid(true).build(); } @@ -523,7 +562,8 @@ public class StandardValidators { } } else { builder.subject(subject).input(input).valid(false) - .explanation("Must be of format where is a non-negative integer and TimeUnit is a supported Time Unit, such as: nanos, millis, secs, mins, hrs, days"); + .explanation("Must be of format where is a non-negative " + + "integer and TimeUnit is a supported Time Unit, such as: nanos, millis, secs, mins, hrs, days"); } return builder.build(); } @@ -539,7 +579,7 @@ public class StandardValidators { @Override public ValidationResult validate(final String subject, final String value, final ValidationContext context) { - if ( context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(value) ) { + if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(value)) { return new ValidationResult.Builder().subject(subject).input(value).explanation("Expression Language Present").valid(true).build(); } @@ -574,7 +614,7 @@ public class StandardValidators { @Override public ValidationResult validate(final String subject, final String value, final ValidationContext context) { - if ( context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(value) ) { + if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(value)) { return new ValidationResult.Builder().subject(subject).input(value).explanation("Expression Language Present").valid(true).build(); } @@ -617,17 +657,19 @@ public class StandardValidators { /** * Creates a validator based on existence of a {@link ControllerService}. - * - * @param serviceClass the controller service API your {@link ConfigurableComponent} depends on + * + * @param serviceClass the controller service API your + * {@link ConfigurableComponent} depends on * @return a Validator - * @deprecated As of release 0.1.0-incubating, replaced by {@link org.apache.nifi.components.PropertyDescriptor.Builder#identifiesControllerService(Class)} + * @deprecated As of release 0.1.0-incubating, replaced by + * {@link org.apache.nifi.components.PropertyDescriptor.Builder#identifiesControllerService(Class)} */ @Deprecated public static Validator createControllerServiceExistsValidator(final Class serviceClass) { return new Validator() { @Override public ValidationResult validate(final String subject, final String input, final ValidationContext context) { - if ( context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input) ) { + if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input)) { return new ValidationResult.Builder().subject(subject).input(input).explanation("Expression Language Present").valid(true).build(); } @@ -638,14 +680,24 @@ public class StandardValidators { } if (!serviceClass.isAssignableFrom(svc.getClass())) { - return new ValidationResult.Builder().valid(false).input(input).subject(subject).explanation("Controller Service with this ID is of type " + svc.getClass().getName() + " but is expected to be of type " + serviceClass.getName()).build(); + return new ValidationResult.Builder() + .valid(false) + .input(input) + .subject(subject) + .explanation("Controller Service with this ID is of type " + svc.getClass().getName() + " but is expected to be of type " + serviceClass.getName()) + .build(); } final ValidationContext serviceValidationContext = context.getControllerServiceValidationContext(svc); final Collection serviceValidationResults = svc.validate(serviceValidationContext); for (final ValidationResult result : serviceValidationResults) { if (!result.isValid()) { - return new ValidationResult.Builder().valid(false).input(input).subject(subject).explanation("Controller Service " + input + " is not valid: " + result.getExplanation()).build(); + return new ValidationResult.Builder() + .valid(false) + .input(input) + .subject(subject) + .explanation("Controller Service " + input + " is not valid: " + result.getExplanation()) + .build(); } } diff --git a/nifi/nifi-commons/nifi-processor-utilities/src/test/java/org/apache/nifi/processor/util/TestStandardValidators.java b/nifi/nifi-commons/nifi-processor-utilities/src/test/java/org/apache/nifi/processor/util/TestStandardValidators.java index a8f4bae925..bcd402dd1c 100644 --- a/nifi/nifi-commons/nifi-processor-utilities/src/test/java/org/apache/nifi/processor/util/TestStandardValidators.java +++ b/nifi/nifi-commons/nifi-processor-utilities/src/test/java/org/apache/nifi/processor/util/TestStandardValidators.java @@ -35,7 +35,7 @@ public class TestStandardValidators { ValidationResult vr; final ValidationContext validationContext = Mockito.mock(ValidationContext.class); - + vr = val.validate("TimePeriodTest", "0 sense made", validationContext); assertFalse(vr.isValid()); @@ -54,22 +54,22 @@ public class TestStandardValidators { vr = val.validate("TimePeriodTest", "1 sec", validationContext); assertTrue(vr.isValid()); } - + @Test public void testDataSizeBoundsValidator() { Validator val = StandardValidators.createDataSizeBoundsValidator(100, 1000); - ValidationResult vr; - + ValidationResult vr; + final ValidationContext validationContext = Mockito.mock(ValidationContext.class); vr = val.validate("DataSizeBounds", "5 GB", validationContext); assertFalse(vr.isValid()); - + vr = val.validate("DataSizeBounds", "0 B", validationContext); assertFalse(vr.isValid()); vr = val.validate("DataSizeBounds", "99 B", validationContext); assertFalse(vr.isValid()); - + vr = val.validate("DataSizeBounds", "100 B", validationContext); assertTrue(vr.isValid()); @@ -78,12 +78,12 @@ public class TestStandardValidators { vr = val.validate("DataSizeBounds", "1000 B", validationContext); assertTrue(vr.isValid()); - + vr = val.validate("DataSizeBounds", "1001 B", validationContext); assertFalse(vr.isValid()); - + vr = val.validate("DataSizeBounds", "water", validationContext); assertFalse(vr.isValid()); - + } } diff --git a/nifi/nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java b/nifi/nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java index 3b427a77ae..43f02cab77 100644 --- a/nifi/nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java +++ b/nifi/nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java @@ -16,9 +16,6 @@ */ package org.apache.nifi.util; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; @@ -27,10 +24,15 @@ import java.net.InetSocketAddress; import java.nio.file.InvalidPathException; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Properties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class NiFiProperties extends Properties { private static final long serialVersionUID = 2119177359005492702L; @@ -50,6 +52,7 @@ public class NiFiProperties extends Properties { public static final String AUTO_RESUME_STATE = "nifi.flowcontroller.autoResumeState"; public static final String FLOW_CONTROLLER_GRACEFUL_SHUTDOWN_PERIOD = "nifi.flowcontroller.graceful.shutdown.period"; public static final String NAR_LIBRARY_DIRECTORY = "nifi.nar.library.directory"; + public static final String NAR_LIBRARY_DIRECTORY_PREFIX = "nifi.nar.library.directory."; public static final String NAR_WORKING_DIRECTORY = "nifi.nar.working.directory"; public static final String COMPONENT_DOCS_DIRECTORY = "nifi.documentation.working.directory"; public static final String SENSITIVE_PROPS_KEY = "nifi.sensitive.props.key"; @@ -230,21 +233,27 @@ public class NiFiProperties extends Properties { * obtained. * * @return the NiFiProperties object to use - * @throws RuntimeException if unable to load properties file + * @throws RuntimeException + * if unable to load properties file */ public static synchronized NiFiProperties getInstance() { if (null == instance) { final NiFiProperties suspectInstance = new NiFiProperties(); - final String nfPropertiesFilePath = System.getProperty(NiFiProperties.PROPERTIES_FILE_PATH); + final String nfPropertiesFilePath = System + .getProperty(NiFiProperties.PROPERTIES_FILE_PATH); if (null == nfPropertiesFilePath || nfPropertiesFilePath.trim().length() == 0) { - throw new RuntimeException("Requires a system property called \'" + NiFiProperties.PROPERTIES_FILE_PATH + "\' and this is not set or has no value"); + throw new RuntimeException("Requires a system property called \'" + + NiFiProperties.PROPERTIES_FILE_PATH + + "\' and this is not set or has no value"); } final File propertiesFile = new File(nfPropertiesFilePath); if (!propertiesFile.exists()) { - throw new RuntimeException("Properties file doesn't exist \'" + propertiesFile.getAbsolutePath() + "\'"); + throw new RuntimeException("Properties file doesn't exist \'" + + propertiesFile.getAbsolutePath() + "\'"); } if (!propertiesFile.canRead()) { - throw new RuntimeException("Properties file exists but cannot be read \'" + propertiesFile.getAbsolutePath() + "\'"); + throw new RuntimeException("Properties file exists but cannot be read \'" + + propertiesFile.getAbsolutePath() + "\'"); } InputStream inStream = null; try { @@ -252,7 +261,8 @@ public class NiFiProperties extends Properties { suspectInstance.load(inStream); } catch (final Exception ex) { LOG.error("Cannot load properties file due to " + ex.getLocalizedMessage()); - throw new RuntimeException("Cannot load properties file due to " + ex.getLocalizedMessage(), ex); + throw new RuntimeException("Cannot load properties file due to " + + ex.getLocalizedMessage(), ex); } finally { if (null != inStream) { try { @@ -360,7 +370,7 @@ public class NiFiProperties extends Properties { /** * The socket port to listen on for a Remote Input Port. * - * @return + * @return the remote input port */ public Integer getRemoteInputPort() { return getPropertyAsPort(REMOTE_INPUT_PORT, DEFAULT_REMOTE_INPUT_PORT); @@ -374,7 +384,7 @@ public class NiFiProperties extends Properties { if ("false".equalsIgnoreCase(secureVal)) { return false; - }else{ + } else { return true; } @@ -383,7 +393,7 @@ public class NiFiProperties extends Properties { /** * Returns the directory to which Templates are to be persisted * - * @return + * @return the template directory */ public Path getTemplateDirectory() { final String strVal = getProperty(TEMPLATE_DIRECTORY); @@ -406,7 +416,8 @@ public class NiFiProperties extends Properties { * @return Whether to auto start the processors or not */ public boolean getAutoResumeState() { - final String rawAutoResumeState = getProperty(AUTO_RESUME_STATE, DEFAULT_AUTO_RESUME_STATE.toString()); + final String rawAutoResumeState = getProperty(AUTO_RESUME_STATE, + DEFAULT_AUTO_RESUME_STATE.toString()); return Boolean.parseBoolean(rawAutoResumeState); } @@ -414,10 +425,11 @@ public class NiFiProperties extends Properties { * Returns the number of partitions that should be used for the FlowFile * Repository * - * @return + * @return the number of partitions */ public int getFlowFileRepositoryPartitions() { - final String rawProperty = getProperty(FLOWFILE_REPOSITORY_PARTITIONS, DEFAULT_FLOWFILE_REPO_PARTITIONS); + final String rawProperty = getProperty(FLOWFILE_REPOSITORY_PARTITIONS, + DEFAULT_FLOWFILE_REPO_PARTITIONS); return Integer.parseInt(rawProperty); } @@ -425,10 +437,11 @@ public class NiFiProperties extends Properties { * Returns the number of milliseconds between FlowFileRepository * checkpointing * - * @return + * @return the number of milliseconds between checkpoint events */ public String getFlowFileRepositoryCheckpointInterval() { - return getProperty(FLOWFILE_REPOSITORY_CHECKPOINT_INTERVAL, DEFAULT_FLOWFILE_CHECKPOINT_INTERVAL); + return getProperty(FLOWFILE_REPOSITORY_CHECKPOINT_INTERVAL, + DEFAULT_FLOWFILE_CHECKPOINT_INTERVAL); } /** @@ -470,7 +483,8 @@ public class NiFiProperties extends Properties { } public String getUserCredentialCacheDuration() { - return getProperty(SECURITY_USER_CREDENTIAL_CACHE_DURATION, DEFAULT_USER_CREDENTIAL_CACHE_DURATION); + return getProperty(SECURITY_USER_CREDENTIAL_CACHE_DURATION, + DEFAULT_USER_CREDENTIAL_CACHE_DURATION); } public boolean getSupportNewAccountRequests() { @@ -504,7 +518,7 @@ public class NiFiProperties extends Properties { public int getWebThreads() { return getIntegerProperty(WEB_THREADS, DEFAULT_WEB_THREADS); } - + public File getWebWorkingDirectory() { return new File(getProperty(WEB_WORKING_DIR, DEFAULT_WEB_WORKING_DIR)); } @@ -525,8 +539,28 @@ public class NiFiProperties extends Properties { return new File(getNarWorkingDirectory(), "extensions"); } - public File getNarLibraryDirectory() { - return new File(getProperty(NAR_LIBRARY_DIRECTORY, DEFAULT_NAR_LIBRARY_DIR)); + public List getNarLibraryDirectories() { + + List narLibraryPaths = new ArrayList<>(); + + // go through each property + for (String propertyName : stringPropertyNames()) { + // determine if the property is a nar library path + if (StringUtils.startsWith(propertyName, NAR_LIBRARY_DIRECTORY_PREFIX) + || NAR_LIBRARY_DIRECTORY.equals(propertyName)) { + // attempt to resolve the path specified + String narLib = getProperty(propertyName); + if (!StringUtils.isBlank(narLib)) { + narLibraryPaths.add(Paths.get(narLib)); + } + } + } + + if (narLibraryPaths.isEmpty()) { + narLibraryPaths.add(Paths.get(DEFAULT_NAR_LIBRARY_DIR)); + } + + return narLibraryPaths; } // getters for ui properties // @@ -551,7 +585,7 @@ public class NiFiProperties extends Properties { /** * Returns the auto refresh interval in seconds. * - * @return + * @return the interval over which the properties should auto refresh */ public String getAutoRefreshInterval() { return getProperty(UI_AUTO_REFRESH_INTERVAL); @@ -559,7 +593,8 @@ public class NiFiProperties extends Properties { // getters for cluster protocol properties // public String getClusterProtocolHeartbeatInterval() { - return getProperty(CLUSTER_PROTOCOL_HEARTBEAT_INTERVAL, DEFAULT_CLUSTER_PROTOCOL_HEARTBEAT_INTERVAL); + return getProperty(CLUSTER_PROTOCOL_HEARTBEAT_INTERVAL, + DEFAULT_CLUSTER_PROTOCOL_HEARTBEAT_INTERVAL); } public String getNodeHeartbeatInterval() { @@ -571,7 +606,8 @@ public class NiFiProperties extends Properties { } public String getClusterProtocolConnectionHandshakeTimeout() { - return getProperty(CLUSTER_PROTOCOL_CONNECTION_HANDSHAKE_TIMEOUT, DEFAULT_CLUSTER_PROTOCOL_CONNECTION_HANDSHAKE_TIMEOUT); + return getProperty(CLUSTER_PROTOCOL_CONNECTION_HANDSHAKE_TIMEOUT, + DEFAULT_CLUSTER_PROTOCOL_CONNECTION_HANDSHAKE_TIMEOUT); } public boolean getClusterProtocolUseMulticast() { @@ -593,7 +629,8 @@ public class NiFiProperties extends Properties { } public File getPersistentStateDirectory() { - final String dirName = getProperty(PERSISTENT_STATE_DIRECTORY, DEFAULT_PERSISTENT_STATE_DIRECTORY); + final String dirName = getProperty(PERSISTENT_STATE_DIRECTORY, + DEFAULT_PERSISTENT_STATE_DIRECTORY); final File file = new File(dirName); if (!file.exists()) { file.mkdirs(); @@ -603,14 +640,16 @@ public class NiFiProperties extends Properties { public int getClusterProtocolMulticastServiceLocatorAttempts() { try { - return Integer.parseInt(getProperty(CLUSTER_PROTOCOL_MULTICAST_SERVICE_LOCATOR_ATTEMPTS)); + return Integer + .parseInt(getProperty(CLUSTER_PROTOCOL_MULTICAST_SERVICE_LOCATOR_ATTEMPTS)); } catch (NumberFormatException nfe) { return DEFAULT_CLUSTER_PROTOCOL_MULTICAST_SERVICE_LOCATOR_ATTEMPTS; } } public String getClusterProtocolMulticastServiceLocatorAttemptsDelay() { - return getProperty(CLUSTER_PROTOCOL_MULTICAST_SERVICE_LOCATOR_ATTEMPTS_DELAY, DEFAULT_CLUSTER_PROTOCOL_MULTICAST_SERVICE_LOCATOR_ATTEMPTS_DELAY); + return getProperty(CLUSTER_PROTOCOL_MULTICAST_SERVICE_LOCATOR_ATTEMPTS_DELAY, + DEFAULT_CLUSTER_PROTOCOL_MULTICAST_SERVICE_LOCATOR_ATTEMPTS_DELAY); } // getters for cluster node properties // @@ -653,7 +692,8 @@ public class NiFiProperties extends Properties { if (StringUtils.isBlank(socketAddress)) { socketAddress = "localhost"; } - int socketPort = Integer.parseInt(getProperty(CLUSTER_NODE_UNICAST_MANAGER_PROTOCOL_PORT)); + int socketPort = Integer + .parseInt(getProperty(CLUSTER_NODE_UNICAST_MANAGER_PROTOCOL_PORT)); return InetSocketAddress.createUnresolved(socketAddress, socketPort); } catch (Exception ex) { throw new RuntimeException("Invalid unicast manager address/port due to: " + ex, ex); @@ -704,11 +744,13 @@ public class NiFiProperties extends Properties { } public String getClusterManagerNodeApiConnectionTimeout() { - return getProperty(CLUSTER_MANAGER_NODE_API_CONNECTION_TIMEOUT, DEFAULT_CLUSTER_MANAGER_NODE_API_CONNECTION_TIMEOUT); + return getProperty(CLUSTER_MANAGER_NODE_API_CONNECTION_TIMEOUT, + DEFAULT_CLUSTER_MANAGER_NODE_API_CONNECTION_TIMEOUT); } public String getClusterManagerNodeApiReadTimeout() { - return getProperty(CLUSTER_MANAGER_NODE_API_READ_TIMEOUT, DEFAULT_CLUSTER_MANAGER_NODE_API_READ_TIMEOUT); + return getProperty(CLUSTER_MANAGER_NODE_API_READ_TIMEOUT, + DEFAULT_CLUSTER_MANAGER_NODE_API_READ_TIMEOUT); } public int getClusterManagerNodeApiRequestThreads() { @@ -720,7 +762,8 @@ public class NiFiProperties extends Properties { } public String getClusterManagerFlowRetrievalDelay() { - return getProperty(CLUSTER_MANAGER_FLOW_RETRIEVAL_DELAY, DEFAULT_CLUSTER_MANAGER_FLOW_RETRIEVAL_DELAY); + return getProperty(CLUSTER_MANAGER_FLOW_RETRIEVAL_DELAY, + DEFAULT_CLUSTER_MANAGER_FLOW_RETRIEVAL_DELAY); } public int getClusterManagerProtocolThreads() { @@ -732,7 +775,8 @@ public class NiFiProperties extends Properties { } public String getClusterManagerSafeModeDuration() { - return getProperty(CLUSTER_MANAGER_SAFEMODE_DURATION, DEFAULT_CLUSTER_MANAGER_SAFEMODE_DURATION); + return getProperty(CLUSTER_MANAGER_SAFEMODE_DURATION, + DEFAULT_CLUSTER_MANAGER_SAFEMODE_DURATION); } public String getClusterProtocolManagerToNodeApiScheme() { @@ -780,7 +824,8 @@ public class NiFiProperties extends Properties { * configured. No directories will be created as a result of this operation. * * @return database repository path - * @throws InvalidPathException If the configured path is invalid + * @throws InvalidPathException + * If the configured path is invalid */ public Path getDatabaseRepositoryPath() { return Paths.get(getProperty(REPOSITORY_DATABASE_DIRECTORY)); @@ -791,7 +836,8 @@ public class NiFiProperties extends Properties { * configured. No directories will be created as a result of this operation. * * @return database repository path - * @throws InvalidPathException If the configured path is invalid + * @throws InvalidPathException + * If the configured path is invalid */ public Path getFlowFileRepositoryPath() { return Paths.get(getProperty(FLOWFILE_REPOSITORY_DIRECTORY)); @@ -804,7 +850,8 @@ public class NiFiProperties extends Properties { * operation. * * @return file repositories paths - * @throws InvalidPathException If any of the configured paths are invalid + * @throws InvalidPathException + * If any of the configured paths are invalid */ public Map getContentRepositoryPaths() { final Map contentRepositoryPaths = new HashMap<>(); @@ -814,7 +861,8 @@ public class NiFiProperties extends Properties { // determine if the property is a file repository path if (StringUtils.startsWith(propertyName, REPOSITORY_CONTENT_PREFIX)) { // get the repository key - final String key = StringUtils.substringAfter(propertyName, REPOSITORY_CONTENT_PREFIX); + final String key = StringUtils.substringAfter(propertyName, + REPOSITORY_CONTENT_PREFIX); // attempt to resolve the path specified contentRepositoryPaths.put(key, Paths.get(getProperty(propertyName))); @@ -829,7 +877,7 @@ public class NiFiProperties extends Properties { * values configured. No directories will be created as a result of this * operation. * - * @return + * @return the name and paths of all provenance repository locations */ public Map getProvenanceRepositoryPaths() { final Map provenanceRepositoryPaths = new HashMap<>(); @@ -839,7 +887,8 @@ public class NiFiProperties extends Properties { // determine if the property is a file repository path if (StringUtils.startsWith(propertyName, PROVENANCE_REPO_DIRECTORY_PREFIX)) { // get the repository key - final String key = StringUtils.substringAfter(propertyName, PROVENANCE_REPO_DIRECTORY_PREFIX); + final String key = StringUtils.substringAfter(propertyName, + PROVENANCE_REPO_DIRECTORY_PREFIX); // attempt to resolve the path specified provenanceRepositoryPaths.put(key, Paths.get(getProperty(propertyName))); diff --git a/nifi/nifi-commons/nifi-properties/src/test/java/org/apache/nifi/util/NiFiPropertiesTest.java b/nifi/nifi-commons/nifi-properties/src/test/java/org/apache/nifi/util/NiFiPropertiesTest.java new file mode 100644 index 0000000000..0751275222 --- /dev/null +++ b/nifi/nifi-commons/nifi-properties/src/test/java/org/apache/nifi/util/NiFiPropertiesTest.java @@ -0,0 +1,120 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.util; + +import org.junit.Assert; +import org.junit.Test; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.nio.file.Path; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import static org.junit.Assert.assertEquals; + +public class NiFiPropertiesTest { + + @Test + public void testProperties() { + + NiFiProperties properties = loadSpecifiedProperties("/NiFiProperties/conf/nifi.properties"); + + assertEquals("UI Banner Text", properties.getBannerText()); + + Set expectedDirectories = new HashSet<>(); + expectedDirectories.add(new File("./target/resources/NiFiProperties/lib/")); + expectedDirectories.add(new File("./target/resources/NiFiProperties/lib2/")); + + Set directories = new HashSet<>(); + for (Path narLibDir : properties.getNarLibraryDirectories()) { + directories.add(narLibDir.toString()); + } + + Assert.assertEquals("Did not have the anticipated number of directories", expectedDirectories.size(), directories.size()); + for (File expectedDirectory : expectedDirectories) { + Assert.assertTrue("Listed directories did not contain expected directory", directories.contains(expectedDirectory.getPath())); + } + } + + @Test + public void testMissingProperties() { + + NiFiProperties properties = loadSpecifiedProperties("/NiFiProperties/conf/nifi.missing.properties"); + + List directories = properties.getNarLibraryDirectories(); + + assertEquals(1, directories.size()); + + assertEquals(new File(NiFiProperties.DEFAULT_NAR_LIBRARY_DIR).getPath(), directories.get(0) + .toString()); + + } + + @Test + public void testBlankProperties() { + + NiFiProperties properties = loadSpecifiedProperties("/NiFiProperties/conf/nifi.blank.properties"); + + List directories = properties.getNarLibraryDirectories(); + + assertEquals(1, directories.size()); + + assertEquals(new File(NiFiProperties.DEFAULT_NAR_LIBRARY_DIR).getPath(), directories.get(0) + .toString()); + + } + + private NiFiProperties loadSpecifiedProperties(String propertiesFile) { + + String file = NiFiPropertiesTest.class.getResource(propertiesFile).getFile(); + + System.setProperty(NiFiProperties.PROPERTIES_FILE_PATH, file); + + NiFiProperties properties = NiFiProperties.getInstance(); + + // clear out existing properties + for (String prop : properties.stringPropertyNames()) { + properties.remove(prop); + } + + InputStream inStream = null; + try { + inStream = new BufferedInputStream(new FileInputStream(file)); + properties.load(inStream); + } catch (final Exception ex) { + throw new RuntimeException("Cannot load properties file due to " + + ex.getLocalizedMessage(), ex); + } finally { + if (null != inStream) { + try { + inStream.close(); + } catch (final Exception ex) { + /** + * do nothing * + */ + } + } + } + + return properties; + } + +} diff --git a/nifi/nifi-commons/nifi-properties/src/test/resources/NiFiProperties/conf/nifi.blank.properties b/nifi/nifi-commons/nifi-properties/src/test/resources/NiFiProperties/conf/nifi.blank.properties new file mode 100644 index 0000000000..1f853b97ec --- /dev/null +++ b/nifi/nifi-commons/nifi-properties/src/test/resources/NiFiProperties/conf/nifi.blank.properties @@ -0,0 +1,128 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Core Properties # +nifi.version=nifi-test 3.0.0 +nifi.flow.configuration.file=./target/flow.xml.gz +nifi.flow.configuration.archive.dir=./target/archive/ +nifi.flowcontroller.autoResumeState=true +nifi.flowcontroller.graceful.shutdown.period=10 sec +nifi.flowservice.writedelay.interval=2 sec +nifi.administrative.yield.duration=30 sec + +nifi.reporting.task.configuration.file=./target/reporting-tasks.xml +nifi.controller.service.configuration.file=./target/controller-services.xml +nifi.templates.directory=./target/templates +nifi.ui.banner.text=UI Banner Text +nifi.ui.autorefresh.interval=30 sec +nifi.nar.library.directory= +nifi.custom.nar.library.directory.alt= +nifi.nar.working.directory=./target/work/nar/ + +# H2 Settings +nifi.database.directory=./target/database_repository +nifi.h2.url.append=;LOCK_TIMEOUT=25000;WRITE_DELAY=0;AUTO_SERVER=FALSE + +# FlowFile Repository +nifi.flowfile.repository.directory=./target/test-repo +nifi.flowfile.repository.partitions=1 +nifi.flowfile.repository.checkpoint.interval=2 mins +nifi.queue.swap.threshold=20000 +nifi.swap.storage.directory=./target/test-repo/swap +nifi.swap.in.period=5 sec +nifi.swap.in.threads=1 +nifi.swap.out.period=5 sec +nifi.swap.out.threads=4 + +# Content Repository +nifi.content.claim.max.appendable.size=10 MB +nifi.content.claim.max.flow.files=100 +nifi.content.repository.directory.default=./target/content_repository + +# Provenance Repository Properties +nifi.provenance.repository.storage.directory=./target/provenance_repository +nifi.provenance.repository.max.storage.time=24 hours +nifi.provenance.repository.max.storage.size=1 GB +nifi.provenance.repository.rollover.time=5 mins +nifi.provenance.repository.rollover.size=100 MB + +# Site to Site properties +nifi.remote.input.socket.port=9990 +nifi.remote.input.secure=true + +# web properties # +nifi.web.war.directory=./target/lib +nifi.web.http.host= +nifi.web.http.port=8080 +nifi.web.https.host= +nifi.web.https.port= +nifi.web.jetty.working.directory=./target/work/jetty + +# security properties # +nifi.sensitive.props.key=key +nifi.sensitive.props.algorithm=PBEWITHMD5AND256BITAES-CBC-OPENSSL +nifi.sensitive.props.provider=BC + +nifi.security.keystore= +nifi.security.keystoreType= +nifi.security.keystorePasswd= +nifi.security.keyPasswd= +nifi.security.truststore= +nifi.security.truststoreType= +nifi.security.truststorePasswd= +nifi.security.needClientAuth= +nifi.security.authorizedUsers.file=./target/conf/authorized-users.xml +nifi.security.user.credential.cache.duration=24 hours +nifi.security.user.authority.provider=nifi.authorization.FileAuthorizationProvider +nifi.security.support.new.account.requests= +nifi.security.default.user.roles= + +# cluster common properties (cluster manager and nodes must have same values) # +nifi.cluster.protocol.heartbeat.interval=5 sec +nifi.cluster.protocol.is.secure=false +nifi.cluster.protocol.socket.timeout=30 sec +nifi.cluster.protocol.connection.handshake.timeout=45 sec +# if multicast is used, then nifi.cluster.protocol.multicast.xxx properties must be configured # +nifi.cluster.protocol.use.multicast=false +nifi.cluster.protocol.multicast.address= +nifi.cluster.protocol.multicast.port= +nifi.cluster.protocol.multicast.service.broadcast.delay=500 ms +nifi.cluster.protocol.multicast.service.locator.attempts=3 +nifi.cluster.protocol.multicast.service.locator.attempts.delay=1 sec + +# cluster node properties (only configure for cluster nodes) # +nifi.cluster.is.node=false +nifi.cluster.node.address= +nifi.cluster.node.protocol.port= +nifi.cluster.node.protocol.threads=2 +# if multicast is not used, nifi.cluster.node.unicast.xxx must have same values as nifi.cluster.manager.xxx # +nifi.cluster.node.unicast.manager.address= +nifi.cluster.node.unicast.manager.protocol.port= +nifi.cluster.node.unicast.manager.authority.provider.port= + +# cluster manager properties (only configure for cluster manager) # +nifi.cluster.is.manager=false +nifi.cluster.manager.address= +nifi.cluster.manager.protocol.port= +nifi.cluster.manager.authority.provider.port= +nifi.cluster.manager.authority.provider.threads=10 +nifi.cluster.manager.node.firewall.file= +nifi.cluster.manager.node.event.history.size=10 +nifi.cluster.manager.node.api.connection.timeout=30 sec +nifi.cluster.manager.node.api.read.timeout=30 sec +nifi.cluster.manager.node.api.request.threads=10 +nifi.cluster.manager.flow.retrieval.delay=5 sec +nifi.cluster.manager.protocol.threads=10 +nifi.cluster.manager.safemode.duration=0 sec diff --git a/nifi/nifi-commons/nifi-properties/src/test/resources/NiFiProperties/conf/nifi.missing.properties b/nifi/nifi-commons/nifi-properties/src/test/resources/NiFiProperties/conf/nifi.missing.properties new file mode 100644 index 0000000000..dbb8978c6b --- /dev/null +++ b/nifi/nifi-commons/nifi-properties/src/test/resources/NiFiProperties/conf/nifi.missing.properties @@ -0,0 +1,126 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Core Properties # +nifi.version=nifi-test 3.0.0 +nifi.flow.configuration.file=./target/flow.xml.gz +nifi.flow.configuration.archive.dir=./target/archive/ +nifi.flowcontroller.autoResumeState=true +nifi.flowcontroller.graceful.shutdown.period=10 sec +nifi.flowservice.writedelay.interval=2 sec +nifi.administrative.yield.duration=30 sec + +nifi.reporting.task.configuration.file=./target/reporting-tasks.xml +nifi.controller.service.configuration.file=./target/controller-services.xml +nifi.templates.directory=./target/templates +nifi.ui.banner.text=UI Banner Text +nifi.ui.autorefresh.interval=30 sec +nifi.nar.working.directory=./target/work/nar/ + +# H2 Settings +nifi.database.directory=./target/database_repository +nifi.h2.url.append=;LOCK_TIMEOUT=25000;WRITE_DELAY=0;AUTO_SERVER=FALSE + +# FlowFile Repository +nifi.flowfile.repository.directory=./target/test-repo +nifi.flowfile.repository.partitions=1 +nifi.flowfile.repository.checkpoint.interval=2 mins +nifi.queue.swap.threshold=20000 +nifi.swap.storage.directory=./target/test-repo/swap +nifi.swap.in.period=5 sec +nifi.swap.in.threads=1 +nifi.swap.out.period=5 sec +nifi.swap.out.threads=4 + +# Content Repository +nifi.content.claim.max.appendable.size=10 MB +nifi.content.claim.max.flow.files=100 +nifi.content.repository.directory.default=./target/content_repository + +# Provenance Repository Properties +nifi.provenance.repository.storage.directory=./target/provenance_repository +nifi.provenance.repository.max.storage.time=24 hours +nifi.provenance.repository.max.storage.size=1 GB +nifi.provenance.repository.rollover.time=5 mins +nifi.provenance.repository.rollover.size=100 MB + +# Site to Site properties +nifi.remote.input.socket.port=9990 +nifi.remote.input.secure=true + +# web properties # +nifi.web.war.directory=./target/lib +nifi.web.http.host= +nifi.web.http.port=8080 +nifi.web.https.host= +nifi.web.https.port= +nifi.web.jetty.working.directory=./target/work/jetty + +# security properties # +nifi.sensitive.props.key=key +nifi.sensitive.props.algorithm=PBEWITHMD5AND256BITAES-CBC-OPENSSL +nifi.sensitive.props.provider=BC + +nifi.security.keystore= +nifi.security.keystoreType= +nifi.security.keystorePasswd= +nifi.security.keyPasswd= +nifi.security.truststore= +nifi.security.truststoreType= +nifi.security.truststorePasswd= +nifi.security.needClientAuth= +nifi.security.authorizedUsers.file=./target/conf/authorized-users.xml +nifi.security.user.credential.cache.duration=24 hours +nifi.security.user.authority.provider=nifi.authorization.FileAuthorizationProvider +nifi.security.support.new.account.requests= +nifi.security.default.user.roles= + +# cluster common properties (cluster manager and nodes must have same values) # +nifi.cluster.protocol.heartbeat.interval=5 sec +nifi.cluster.protocol.is.secure=false +nifi.cluster.protocol.socket.timeout=30 sec +nifi.cluster.protocol.connection.handshake.timeout=45 sec +# if multicast is used, then nifi.cluster.protocol.multicast.xxx properties must be configured # +nifi.cluster.protocol.use.multicast=false +nifi.cluster.protocol.multicast.address= +nifi.cluster.protocol.multicast.port= +nifi.cluster.protocol.multicast.service.broadcast.delay=500 ms +nifi.cluster.protocol.multicast.service.locator.attempts=3 +nifi.cluster.protocol.multicast.service.locator.attempts.delay=1 sec + +# cluster node properties (only configure for cluster nodes) # +nifi.cluster.is.node=false +nifi.cluster.node.address= +nifi.cluster.node.protocol.port= +nifi.cluster.node.protocol.threads=2 +# if multicast is not used, nifi.cluster.node.unicast.xxx must have same values as nifi.cluster.manager.xxx # +nifi.cluster.node.unicast.manager.address= +nifi.cluster.node.unicast.manager.protocol.port= +nifi.cluster.node.unicast.manager.authority.provider.port= + +# cluster manager properties (only configure for cluster manager) # +nifi.cluster.is.manager=false +nifi.cluster.manager.address= +nifi.cluster.manager.protocol.port= +nifi.cluster.manager.authority.provider.port= +nifi.cluster.manager.authority.provider.threads=10 +nifi.cluster.manager.node.firewall.file= +nifi.cluster.manager.node.event.history.size=10 +nifi.cluster.manager.node.api.connection.timeout=30 sec +nifi.cluster.manager.node.api.read.timeout=30 sec +nifi.cluster.manager.node.api.request.threads=10 +nifi.cluster.manager.flow.retrieval.delay=5 sec +nifi.cluster.manager.protocol.threads=10 +nifi.cluster.manager.safemode.duration=0 sec diff --git a/nifi/nifi-commons/nifi-properties/src/test/resources/NiFiProperties/conf/nifi.properties b/nifi/nifi-commons/nifi-properties/src/test/resources/NiFiProperties/conf/nifi.properties new file mode 100644 index 0000000000..ed44b88ddf --- /dev/null +++ b/nifi/nifi-commons/nifi-properties/src/test/resources/NiFiProperties/conf/nifi.properties @@ -0,0 +1,128 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Core Properties # +nifi.version=nifi-test 3.0.0 +nifi.flow.configuration.file=./target/flow.xml.gz +nifi.flow.configuration.archive.dir=./target/archive/ +nifi.flowcontroller.autoResumeState=true +nifi.flowcontroller.graceful.shutdown.period=10 sec +nifi.flowservice.writedelay.interval=2 sec +nifi.administrative.yield.duration=30 sec + +nifi.reporting.task.configuration.file=./target/reporting-tasks.xml +nifi.controller.service.configuration.file=./target/controller-services.xml +nifi.templates.directory=./target/templates +nifi.ui.banner.text=UI Banner Text +nifi.ui.autorefresh.interval=30 sec +nifi.nar.library.directory=./target/resources/NiFiProperties/lib/ +nifi.nar.library.directory.alt=./target/resources/NiFiProperties/lib2/ +nifi.nar.working.directory=./target/work/nar/ + +# H2 Settings +nifi.database.directory=./target/database_repository +nifi.h2.url.append=;LOCK_TIMEOUT=25000;WRITE_DELAY=0;AUTO_SERVER=FALSE + +# FlowFile Repository +nifi.flowfile.repository.directory=./target/test-repo +nifi.flowfile.repository.partitions=1 +nifi.flowfile.repository.checkpoint.interval=2 mins +nifi.queue.swap.threshold=20000 +nifi.swap.storage.directory=./target/test-repo/swap +nifi.swap.in.period=5 sec +nifi.swap.in.threads=1 +nifi.swap.out.period=5 sec +nifi.swap.out.threads=4 + +# Content Repository +nifi.content.claim.max.appendable.size=10 MB +nifi.content.claim.max.flow.files=100 +nifi.content.repository.directory.default=./target/content_repository + +# Provenance Repository Properties +nifi.provenance.repository.storage.directory=./target/provenance_repository +nifi.provenance.repository.max.storage.time=24 hours +nifi.provenance.repository.max.storage.size=1 GB +nifi.provenance.repository.rollover.time=5 mins +nifi.provenance.repository.rollover.size=100 MB + +# Site to Site properties +nifi.remote.input.socket.port=9990 +nifi.remote.input.secure=true + +# web properties # +nifi.web.war.directory=./target/lib +nifi.web.http.host= +nifi.web.http.port=8080 +nifi.web.https.host= +nifi.web.https.port= +nifi.web.jetty.working.directory=./target/work/jetty + +# security properties # +nifi.sensitive.props.key=key +nifi.sensitive.props.algorithm=PBEWITHMD5AND256BITAES-CBC-OPENSSL +nifi.sensitive.props.provider=BC + +nifi.security.keystore= +nifi.security.keystoreType= +nifi.security.keystorePasswd= +nifi.security.keyPasswd= +nifi.security.truststore= +nifi.security.truststoreType= +nifi.security.truststorePasswd= +nifi.security.needClientAuth= +nifi.security.authorizedUsers.file=./target/conf/authorized-users.xml +nifi.security.user.credential.cache.duration=24 hours +nifi.security.user.authority.provider=nifi.authorization.FileAuthorizationProvider +nifi.security.support.new.account.requests= +nifi.security.default.user.roles= + +# cluster common properties (cluster manager and nodes must have same values) # +nifi.cluster.protocol.heartbeat.interval=5 sec +nifi.cluster.protocol.is.secure=false +nifi.cluster.protocol.socket.timeout=30 sec +nifi.cluster.protocol.connection.handshake.timeout=45 sec +# if multicast is used, then nifi.cluster.protocol.multicast.xxx properties must be configured # +nifi.cluster.protocol.use.multicast=false +nifi.cluster.protocol.multicast.address= +nifi.cluster.protocol.multicast.port= +nifi.cluster.protocol.multicast.service.broadcast.delay=500 ms +nifi.cluster.protocol.multicast.service.locator.attempts=3 +nifi.cluster.protocol.multicast.service.locator.attempts.delay=1 sec + +# cluster node properties (only configure for cluster nodes) # +nifi.cluster.is.node=false +nifi.cluster.node.address= +nifi.cluster.node.protocol.port= +nifi.cluster.node.protocol.threads=2 +# if multicast is not used, nifi.cluster.node.unicast.xxx must have same values as nifi.cluster.manager.xxx # +nifi.cluster.node.unicast.manager.address= +nifi.cluster.node.unicast.manager.protocol.port= +nifi.cluster.node.unicast.manager.authority.provider.port= + +# cluster manager properties (only configure for cluster manager) # +nifi.cluster.is.manager=false +nifi.cluster.manager.address= +nifi.cluster.manager.protocol.port= +nifi.cluster.manager.authority.provider.port= +nifi.cluster.manager.authority.provider.threads=10 +nifi.cluster.manager.node.firewall.file= +nifi.cluster.manager.node.event.history.size=10 +nifi.cluster.manager.node.api.connection.timeout=30 sec +nifi.cluster.manager.node.api.read.timeout=30 sec +nifi.cluster.manager.node.api.request.threads=10 +nifi.cluster.manager.flow.retrieval.delay=5 sec +nifi.cluster.manager.protocol.threads=10 +nifi.cluster.manager.safemode.duration=0 sec diff --git a/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/CertificateUtils.java b/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/CertificateUtils.java index 087d891d29..51269335ed 100644 --- a/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/CertificateUtils.java +++ b/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/CertificateUtils.java @@ -36,10 +36,11 @@ public final class CertificateUtils { /** * Returns true if the given keystore can be loaded using the given keystore * type and password. Returns false otherwise. - * @param keystore - * @param keystoreType - * @param password - * @return + * + * @param keystore the keystore to validate + * @param keystoreType the type of the keystore + * @param password the password to access the keystore + * @return true if valid; false otherwise */ public static boolean isStoreValid(final URL keystore, final KeystoreType keystoreType, final char[] password) { @@ -81,8 +82,8 @@ public final class CertificateUtils { * returned. If the CN cannot be extracted because the DN is in an * unrecognized format, the entire DN is returned. * - * @param dn - * @return + * @param dn the dn to extract the username from + * @return the exatracted username */ public static String extractUsername(String dn) { String username = dn; @@ -135,11 +136,11 @@ public final class CertificateUtils { final List result = new ArrayList<>(); for (final List generalName : altNames) { - /* - * generalName has the name type as the first element a String or - * byte array for the second element. We return any general names + /** + * generalName has the name type as the first element a String or + * byte array for the second element. We return any general names * that are String types. - * + * * We don't inspect the numeric name type because some certificates * incorrectly put IPs and DNS names under the wrong name types. */ diff --git a/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/EncryptionMethod.java b/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/EncryptionMethod.java index 741fdde792..55f5986e4b 100644 --- a/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/EncryptionMethod.java +++ b/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/EncryptionMethod.java @@ -23,7 +23,6 @@ import org.apache.commons.lang3.builder.ToStringStyle; * Enumeration capturing essential information about the various encryption * methods that might be supported. * - * @author none */ public enum EncryptionMethod { @@ -46,7 +45,10 @@ public enum EncryptionMethod { SHA_256AES("PBEWITHSHAAND256BITAES-CBC-BC", "BC", true), SHA_3KEYTRIPLEDES("PBEWITHSHAAND3-KEYTRIPLEDES-CBC", "BC", true), SHA_TWOFISH("PBEWITHSHAANDTWOFISH-CBC", "BC", true), - SHA_128RC4("PBEWITHSHAAND128BITRC4", "BC", true); + SHA_128RC4("PBEWITHSHAAND128BITRC4", "BC", true), + PGP("PGP", "BC", false), + PGP_ASCII_ARMOR("PGP-ASCII-ARMOR", "BC", false); + private final String algorithm; private final String provider; private final boolean unlimitedStrength; diff --git a/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/SecurityStoreTypes.java b/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/SecurityStoreTypes.java index 9abfcc3ccd..f448312ff4 100644 --- a/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/SecurityStoreTypes.java +++ b/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/SecurityStoreTypes.java @@ -100,12 +100,12 @@ public enum SecurityStoreTypes { /** * Creates an instance. * - * @param storeProperty the Java system property for setting the keystore ( - * or truststore) path + * @param storeProperty the Java system property for setting the keystore or + * truststore path * @param storePasswordProperty the Java system property for setting the - * keystore (or truststore) password + * keystore or truststore path * @param storeTypeProperty the Java system property for setting the - * keystore (or truststore) type + * keystore or truststore type */ SecurityStoreTypes(final String storeProperty, final String storePasswordProperty, diff --git a/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/SslContextFactory.java b/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/SslContextFactory.java index 2371b0c138..78cf6e676b 100644 --- a/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/SslContextFactory.java +++ b/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/SslContextFactory.java @@ -37,7 +37,6 @@ import javax.net.ssl.TrustManagerFactory; * A factory for creating SSL contexts using the application's security * properties. * - * @author unattributed */ public final class SslContextFactory { @@ -60,12 +59,12 @@ public final class SslContextFactory { * @param clientAuth the type of client authentication * * @return a SSLContext instance - * @throws java.security.KeyStoreException - * @throws java.io.IOException - * @throws java.security.NoSuchAlgorithmException - * @throws java.security.cert.CertificateException - * @throws java.security.UnrecoverableKeyException - * @throws java.security.KeyManagementException + * @throws java.security.KeyStoreException if any issues accessing the keystore + * @throws java.io.IOException for any problems loading the keystores + * @throws java.security.NoSuchAlgorithmException if an algorithm is found to be used but is unknown + * @throws java.security.cert.CertificateException if there is an issue with the certificate + * @throws java.security.UnrecoverableKeyException if the key is insufficient + * @throws java.security.KeyManagementException if unable to manage the key */ public static SSLContext createSslContext( final String keystore, final char[] keystorePasswd, final String keystoreType, @@ -113,12 +112,12 @@ public final class SslContextFactory { * @param keystoreType the type of keystore (e.g., PKCS12, JKS) * * @return a SSLContext instance - * @throws java.security.KeyStoreException - * @throws java.io.IOException - * @throws java.security.NoSuchAlgorithmException - * @throws java.security.cert.CertificateException - * @throws java.security.UnrecoverableKeyException - * @throws java.security.KeyManagementException + * @throws java.security.KeyStoreException if any issues accessing the keystore + * @throws java.io.IOException for any problems loading the keystores + * @throws java.security.NoSuchAlgorithmException if an algorithm is found to be used but is unknown + * @throws java.security.cert.CertificateException if there is an issue with the certificate + * @throws java.security.UnrecoverableKeyException if the key is insufficient + * @throws java.security.KeyManagementException if unable to manage the key */ public static SSLContext createSslContext( final String keystore, final char[] keystorePasswd, final String keystoreType) @@ -149,12 +148,12 @@ public final class SslContextFactory { * @param truststoreType the type of truststore (e.g., PKCS12, JKS) * * @return a SSLContext instance - * @throws java.security.KeyStoreException - * @throws java.io.IOException - * @throws java.security.NoSuchAlgorithmException - * @throws java.security.cert.CertificateException - * @throws java.security.UnrecoverableKeyException - * @throws java.security.KeyManagementException + * @throws java.security.KeyStoreException if any issues accessing the keystore + * @throws java.io.IOException for any problems loading the keystores + * @throws java.security.NoSuchAlgorithmException if an algorithm is found to be used but is unknown + * @throws java.security.cert.CertificateException if there is an issue with the certificate + * @throws java.security.UnrecoverableKeyException if the key is insufficient + * @throws java.security.KeyManagementException if unable to manage the key */ public static SSLContext createTrustSslContext( final String truststore, final char[] truststorePasswd, final String truststoreType) diff --git a/nifi/nifi-commons/nifi-site-to-site-client/pom.xml b/nifi/nifi-commons/nifi-site-to-site-client/pom.xml index 5d3d93ea31..c024be6f2f 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/pom.xml +++ b/nifi/nifi-commons/nifi-site-to-site-client/pom.xml @@ -14,41 +14,41 @@ limitations under the License. --> - 4.0.0 + 4.0.0 - - org.apache.nifi - nifi-commons - 0.1.0-incubating-SNAPSHOT - + + org.apache.nifi + nifi-commons + 0.1.0-incubating-SNAPSHOT + - nifi-site-to-site-client + nifi-site-to-site-client - - - org.apache.nifi - nifi-api - - - org.apache.nifi - nifi-utils - - - org.codehaus.jackson - jackson-mapper-asl - 1.9.13 - + + + org.apache.nifi + nifi-api + + + org.apache.nifi + nifi-utils + + + org.codehaus.jackson + jackson-mapper-asl + 1.9.13 + - - org.apache.nifi - nifi-client-dto - 0.1.0-incubating-SNAPSHOT - + + org.apache.nifi + nifi-client-dto + 0.1.0-incubating-SNAPSHOT + - - junit - junit - test - - + + junit + junit + test + + diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/AbstractCommunicationsSession.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/AbstractCommunicationsSession.java index 4babb9222c..dacfd64be7 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/AbstractCommunicationsSession.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/AbstractCommunicationsSession.java @@ -19,14 +19,15 @@ package org.apache.nifi.remote; import org.apache.nifi.remote.protocol.CommunicationsSession; public abstract class AbstractCommunicationsSession implements CommunicationsSession { + private String userDn; - + private volatile String uri; - + public AbstractCommunicationsSession(final String uri) { this.uri = uri; } - + @Override public String toString() { return uri; @@ -46,7 +47,7 @@ public abstract class AbstractCommunicationsSession implements CommunicationsSes public String getUserDn() { return userDn; } - + @Override public void setUserDn(final String dn) { this.userDn = dn; diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/Communicant.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/Communicant.java index ac2d49840e..17b990e38b 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/Communicant.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/Communicant.java @@ -20,28 +20,27 @@ package org.apache.nifi.remote; * Represents the remote entity that the client is communicating with */ public interface Communicant { + /** - * Returns the NiFi site-to-site URL for the remote NiFi instance - * @return + * @return the NiFi site-to-site URL for the remote NiFi instance */ String getUrl(); - + /** - * The Host of the remote NiFi instance - * @return + * @return The Host of the remote NiFi instance */ String getHost(); - + /** - * The Port that the remote NiFi instance is listening on for site-to-site communications - * @return + * @return The Port that the remote NiFi instance is listening on for + * site-to-site communications */ int getPort(); - + /** - * The distinguished name that the remote NiFi instance has provided in its certificate if - * using secure communications, or null if the Distinguished Name is unknown - * @return + * @return The distinguished name that the remote NiFi instance has provided + * in its certificate if using secure communications, or null + * if the Distinguished Name is unknown */ String getDistinguishedName(); } diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/Peer.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/Peer.java index 24280781ca..5cb37b0b95 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/Peer.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/Peer.java @@ -31,7 +31,7 @@ public class Peer implements Communicant { private final String clusterUrl; private final String host; private final int port; - + private final Map penaltyExpirationMap = new HashMap<>(); private boolean closed = false; @@ -53,14 +53,14 @@ public class Peer implements Communicant { public PeerDescription getDescription() { return description; } - + @Override public String getUrl() { return url; } - + public String getClusterUrl() { - return clusterUrl; + return clusterUrl; } public CommunicationsSession getCommunicationsSession() { @@ -79,24 +79,24 @@ public class Peer implements Communicant { } /** - * Penalizes this peer for the given destination only for the provided number of milliseconds - * @param destinationId - * @param millis + * Penalizes this peer for the given destination only for the provided + * number of milliseconds + * + * @param destinationId id of destination + * @param millis period of time to penalize peer */ public void penalize(final String destinationId, final long millis) { final Long currentPenalty = penaltyExpirationMap.get(destinationId); final long proposedPenalty = System.currentTimeMillis() + millis; - if ( currentPenalty == null || proposedPenalty > currentPenalty ) { + if (currentPenalty == null || proposedPenalty > currentPenalty) { penaltyExpirationMap.put(destinationId, proposedPenalty); } } - public boolean isPenalized(final String destinationId) { final Long currentPenalty = penaltyExpirationMap.get(destinationId); return (currentPenalty != null && currentPenalty > System.currentTimeMillis()); } - public boolean isClosed() { return closed; diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/PeerDescription.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/PeerDescription.java index 0e8e49897b..6fc90e4748 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/PeerDescription.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/PeerDescription.java @@ -17,10 +17,11 @@ package org.apache.nifi.remote; public class PeerDescription { + private final String hostname; private final int port; private final boolean secure; - + public PeerDescription(final String hostname, final int port, final boolean secure) { this.hostname = hostname; this.port = port; @@ -64,7 +65,7 @@ public class PeerDescription { if (getClass() != obj.getClass()) { return false; } - + final PeerDescription other = (PeerDescription) obj; if (hostname == null) { if (other.hostname != null) { @@ -73,7 +74,7 @@ public class PeerDescription { } else if (!hostname.equals(other.hostname)) { return false; } - + return port == other.port; } } diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/PeerStatus.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/PeerStatus.java index b68ac33648..6c8a4ecebd 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/PeerStatus.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/PeerStatus.java @@ -17,6 +17,7 @@ package org.apache.nifi.remote; public class PeerStatus { + private final PeerDescription description; private final int numFlowFiles; @@ -28,15 +29,15 @@ public class PeerStatus { public PeerDescription getPeerDescription() { return description; } - + public int getFlowFileCount() { return numFlowFiles; } @Override public String toString() { - return "PeerStatus[hostname=" + description.getHostname() + ",port=" + description.getPort() + - ",secure=" + description.isSecure() + ",flowFileCount=" + numFlowFiles + "]"; + return "PeerStatus[hostname=" + description.getHostname() + ",port=" + description.getPort() + + ",secure=" + description.isSecure() + ",flowFileCount=" + numFlowFiles + "]"; } @Override diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/RemoteResourceInitiator.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/RemoteResourceInitiator.java index f469724a49..582916ec80 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/RemoteResourceInitiator.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/RemoteResourceInitiator.java @@ -25,49 +25,51 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class RemoteResourceInitiator { - public static final int RESOURCE_OK = 20; - public static final int DIFFERENT_RESOURCE_VERSION = 21; - public static final int ABORT = 255; - private static final Logger logger = LoggerFactory.getLogger(RemoteResourceInitiator.class); - - public static VersionedRemoteResource initiateResourceNegotiation(final VersionedRemoteResource resource, final DataInputStream dis, final DataOutputStream dos) throws IOException, HandshakeException { + public static final int RESOURCE_OK = 20; + public static final int DIFFERENT_RESOURCE_VERSION = 21; + public static final int ABORT = 255; + + private static final Logger logger = LoggerFactory.getLogger(RemoteResourceInitiator.class); + + public static VersionedRemoteResource initiateResourceNegotiation(final VersionedRemoteResource resource, final DataInputStream dis, final DataOutputStream dos) + throws IOException, HandshakeException { // Write the classname of the RemoteStreamCodec, followed by its version - logger.debug("Negotiating resource; proposal is {}", resource); - dos.writeUTF(resource.getResourceName()); - final VersionNegotiator negotiator = resource.getVersionNegotiator(); - dos.writeInt(negotiator.getVersion()); - dos.flush(); - + logger.debug("Negotiating resource; proposal is {}", resource); + dos.writeUTF(resource.getResourceName()); + final VersionNegotiator negotiator = resource.getVersionNegotiator(); + dos.writeInt(negotiator.getVersion()); + dos.flush(); + // wait for response from server. - logger.debug("Receiving response from remote instance"); + logger.debug("Receiving response from remote instance"); final int statusCode = dis.read(); switch (statusCode) { - case RESOURCE_OK: // server accepted our proposal of codec name/version + case RESOURCE_OK: // server accepted our proposal of codec name/version logger.debug("Response was RESOURCE_OK"); return resource; - case DIFFERENT_RESOURCE_VERSION: // server accepted our proposal of codec name but not the version + case DIFFERENT_RESOURCE_VERSION: // server accepted our proposal of codec name but not the version logger.debug("Response was DIFFERENT_RESOURCE_VERSION"); // Get server's preferred version - final int newVersion = dis.readInt(); - + final int newVersion = dis.readInt(); + // Determine our new preferred version that is no greater than the server's preferred version. final Integer newPreference = negotiator.getPreferredVersion(newVersion); // If we could not agree with server on a version, fail now. - if ( newPreference == null ) { + if (newPreference == null) { throw new HandshakeException("Could not agree on version for " + resource); } - + negotiator.setVersion(newPreference); - + // Attempt negotiation of resource based on our new preferred version. return initiateResourceNegotiation(resource, dis, dos); case ABORT: logger.debug("Response was ABORT"); - throw new HandshakeException("Remote destination aborted connection with message: " + dis.readUTF()); + throw new HandshakeException("Remote destination aborted connection with message: " + dis.readUTF()); default: logger.debug("Response was {}; unable to negotiate codec", statusCode); - return null; // Unable to negotiate codec + return null; // Unable to negotiate codec } - } + } } diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/Transaction.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/Transaction.java index eb7312d0c8..bfa5c82de3 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/Transaction.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/Transaction.java @@ -21,52 +21,57 @@ import java.util.Map; import org.apache.nifi.remote.protocol.DataPacket; - /** *

    * Provides a transaction for performing site-to-site data transfers. *

    - * + * *

    - * A Transaction is created by calling the - * {@link org.apache.nifi.remote.client.SiteToSiteClient#createTransaction(TransferDirection) createTransaction(TransferDirection)} - * method of a {@link org.apache.nifi.remote.client.SiteToSiteClient SiteToSiteClient}. The resulting Transaction - * can be used to either send or receive data but not both. A new Transaction must be created in order perform the - * other operation. + * A Transaction is created by calling the + * {@link org.apache.nifi.remote.client.SiteToSiteClient#createTransaction(TransferDirection) createTransaction(TransferDirection)} + * method of a + * {@link org.apache.nifi.remote.client.SiteToSiteClient SiteToSiteClient}. The + * resulting Transaction can be used to either send or receive data but not + * both. A new Transaction must be created in order perform the other operation. *

    - * + * *

    * The general flow of execute of a Transaction is as follows: *

      - *
    1. Create the transaction as described above.
    2. - *
    3. Send data via the {@link #send(DataPacket)} method or receive data via the {@link #receive()} method. This method - * will be called 1 or more times. In the case of receive, this method should be called until the method returns {@code null}, - * signifying that the remote instance is finished sending data. Note: receive() should not be - * called a second time without first fully consuming the stream from the previous Packet that was received.
    4. - *
    5. Confirm the transaction via the {@link #confirm()} method.
    6. - *
    7. Either complete the transaction via the {@link #complete(boolean)} method or cancel the transaction - * via the {@link #cancel()} method.
    8. + *
    9. Create the transaction as described above.
    10. + *
    11. Send data via the {@link #send(DataPacket)} method or receive data via + * the {@link #receive()} method. This method will be called 1 or more times. In + * the case of receive, this method should be called until the method returns + * {@code null}, signifying that the remote instance is finished sending data. + * Note: receive() should not be called a second time + * without first fully consuming the stream from the previous Packet that was + * received.
    12. + *
    13. Confirm the transaction via the {@link #confirm()} method.
    14. + *
    15. Either complete the transaction via the {@link #complete(boolean)} method + * or cancel the transaction via the {@link #cancel()} method.
    16. *
    *

    - * + * *

    - * It is important that the Transaction be terminated in order to free the resources held - * by the Transaction. If a Transaction is not terminated, its resources will not be freed and - * if the Transaction holds connections from a connection pool, the connections in that pool - * will eventually become exhausted. A Transaction is terminated by calling one of the following + * It is important that the Transaction be terminated in order to free the + * resources held by the Transaction. If a Transaction is not terminated, its + * resources will not be freed and if the Transaction holds connections from a + * connection pool, the connections in that pool will eventually become + * exhausted. A Transaction is terminated by calling one of the following * methods: - *

      - *
    • {@link #complete(boolean)}
    • - *
    • {@link #cancel()}
    • - *
    • {@link #error()}
    • - *
    + *
      + *
    • {@link #complete(boolean)}
    • + *
    • {@link #cancel()}
    • + *
    • {@link #error()}
    • + *
    *

    - * + * *

    - * If at any point an IOException is thrown from one of the methods of the Transaction, that Transaction - * is automatically closed via a call to {@link #error()}. + * If at any point an IOException is thrown from one of the methods of the + * Transaction, that Transaction is automatically closed via a call to + * {@link #error()}. *

    - * + * *

    * The Transaction class should not be assumed to be thread-safe. *

    @@ -75,140 +80,146 @@ public interface Transaction { /** * Sends information to the remote NiFi instance. - * + * * @param dataPacket the data packet to send - * @throws IOException + * @throws IOException if unable to send */ void send(DataPacket dataPacket) throws IOException; - + /** - * Sends the given byte array as the content of a {@link DataPacket} along with the - * provided attributes - * - * @param content - * @param attributes - * @throws IOException + * Sends the given byte array as the content of a {@link DataPacket} along + * with the provided attributes + * + * @param content to send + * @param attributes of the content + * @throws IOException if unable to send */ void send(byte[] content, Map attributes) throws IOException; - + /** - * Retrieves information from the remote NiFi instance, if any is available. If no data is available, will return - * {@code null}. It is important to consume all data from the remote NiFi instance before attempting to - * call {@link #confirm()}. This is because the sender is always responsible for determining when the Transaction - * has finished. This is done in order to prevent the need for a round-trip network request to receive data for + * Retrieves information from the remote NiFi instance, if any is available. + * If no data is available, will return {@code null}. It is important to + * consume all data from the remote NiFi instance before attempting to call + * {@link #confirm()}. This is because the sender is always responsible for + * determining when the Transaction has finished. This is done in order to + * prevent the need for a round-trip network request to receive data for * each data packet. - * - * @return the DataPacket received, or {@code null} if there is no more data to receive. - * @throws IOException + * + * @return the DataPacket received, or {@code null} if there is no more data + * to receive. + * @throws IOException if unable to receive */ DataPacket receive() throws IOException; /** *

    - * Confirms the data that was sent or received by comparing CRC32's of the data sent and the data received. + * Confirms the data that was sent or received by comparing CRC32's of the + * data sent and the data received. *

    - * + * *

    - * Even if the protocol being used to send the data is reliable and guarantees ordering of packets (such as TCP), - * it is still required that we confirm the transaction before completing the transaction. This is done as - * "safety net" or a defensive programming technique. Mistakes happen, and this mechanism helps to ensure that if - * a bug exists somewhere along the line that we do not end up sending or receiving corrupt data. If the - * CRC32 of the sender and the CRC32 of the receiver do not match, an IOException will be thrown and both the - * sender and receiver will cancel the transaction automatically. + * Even if the protocol being used to send the data is reliable and + * guarantees ordering of packets (such as TCP), it is still required that + * we confirm the transaction before completing the transaction. This is + * done as "safety net" or a defensive programming technique. Mistakes + * happen, and this mechanism helps to ensure that if a bug exists somewhere + * along the line that we do not end up sending or receiving corrupt data. + * If the CRC32 of the sender and the CRC32 of the receiver do not match, an + * IOException will be thrown and both the sender and receiver will cancel + * the transaction automatically. *

    - * + * *

    - * If the {@link TransferDirection} of this Transaction is RECEIVE, this method will throw an Exception unless - * all data from the remote instance has been consumed (i.e., a call to {@link #receive()} returns {@code null}). + * If the {@link TransferDirection} of this Transaction is RECEIVE, this + * method will throw an Exception unless all data from the remote instance + * has been consumed (i.e., a call to {@link #receive()} returns + * {@code null}). *

    - * + * *

    - * If the {@link TransferDirection} of this Transaction is SEND, calling this method dictates that no more data will be - * sent in this transaction. I.e., there will be no more calls to {@link #send(DataPacket)}. + * If the {@link TransferDirection} of this Transaction is SEND, calling + * this method dictates that no more data will be sent in this transaction. + * I.e., there will be no more calls to {@link #send(DataPacket)}. *

    - * - * @throws IOException + * + * @throws IOException if unable to confirm transaction */ - void confirm() throws IOException; - - /** + void confirm() throws IOException; + + /** *

    - * Completes the transaction and indicates to both the sender and receiver that the data transfer was - * successful. + * Completes the transaction and indicates to both the sender and receiver + * that the data transfer was successful. *

    - * - * @throws IOException - * - * @return a TransactionCompletion that contains details about the Transaction + * + * @throws IOException if unable to complete + * + * @return a TransactionCompletion that contains details about the + * Transaction */ - TransactionCompletion complete() throws IOException; - - /** - *

    - * Cancels this transaction, indicating to the sender that the data has not been successfully received so that - * the sender can retry or handle however is appropriate. - *

    - * - * @param explanation an explanation to tell the other party why the transaction was canceled. - * @throws IOException - */ - void cancel(final String explanation) throws IOException; - - - /** - *

    - * Sets the TransactionState of the Transaction to {@link TransactionState#ERROR}, and closes - * the Transaction. The underlying connection should not be returned to a connection pool in this case. - *

    - */ - void error(); - - - /** - * Returns the current state of the Transaction. - * @return - * @throws IOException - */ - TransactionState getState() throws IOException; - - /** - * Returns a Communicant that represents the other side of this Transaction (i.e., - * the remote NiFi instance) - * @return - */ - Communicant getCommunicant(); - - - public enum TransactionState { - /** - * Transaction has been started but no data has been sent or received. - */ - TRANSACTION_STARTED, - - /** - * Transaction has been started and data has been sent or received. - */ - DATA_EXCHANGED, - - /** - * Data that has been transferred has been confirmed via its CRC. Transaction is - * ready to be completed. - */ - TRANSACTION_CONFIRMED, - - /** - * Transaction has been successfully completed. - */ - TRANSACTION_COMPLETED, - - /** - * The Transaction has been canceled. - */ - TRANSACTION_CANCELED, - - /** - * The Transaction ended in an error. - */ - ERROR; - } + TransactionCompletion complete() throws IOException; + + /** + *

    + * Cancels this transaction, indicating to the sender that the data has not + * been successfully received so that the sender can retry or handle however + * is appropriate. + *

    + * + * @param explanation an explanation to tell the other party why the + * transaction was canceled. + * @throws IOException if unable to cancel + */ + void cancel(final String explanation) throws IOException; + + /** + *

    + * Sets the TransactionState of the Transaction to + * {@link TransactionState#ERROR}, and closes the Transaction. The + * underlying connection should not be returned to a connection pool in this + * case. + *

    + */ + void error(); + + /** + * @return the current state of the Transaction. + * @throws IOException ioe + */ + TransactionState getState() throws IOException; + + /** + * @return a Communicant that represents the other side of this Transaction + * (i.e., the remote NiFi instance) + */ + Communicant getCommunicant(); + + public enum TransactionState { + + /** + * Transaction has been started but no data has been sent or received. + */ + TRANSACTION_STARTED, + /** + * Transaction has been started and data has been sent or received. + */ + DATA_EXCHANGED, + /** + * Data that has been transferred has been confirmed via its CRC. + * Transaction is ready to be completed. + */ + TRANSACTION_CONFIRMED, + /** + * Transaction has been successfully completed. + */ + TRANSACTION_COMPLETED, + /** + * The Transaction has been canceled. + */ + TRANSACTION_CANCELED, + /** + * The Transaction ended in an error. + */ + ERROR; + } } diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/TransactionCompletion.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/TransactionCompletion.java index be5f73a84e..1587e87c34 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/TransactionCompletion.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/TransactionCompletion.java @@ -21,43 +21,44 @@ import java.util.concurrent.TimeUnit; import org.apache.nifi.remote.protocol.DataPacket; - /** - * A TransactionCompletion provides information about a {@link Transaction} that has completed successfully. + * A TransactionCompletion provides information about a {@link Transaction} that + * has completed successfully. */ public interface TransactionCompletion { - + /** - * When a sending to a NiFi instance, the server may accept the content sent to it - * but indicate that its queues are full and that the client should backoff sending - * data for a bit. This method returns true if the server did in fact - * request that, false otherwise. - * @return + * When a sending to a NiFi instance, the server may accept the content sent + * to it but indicate that its queues are full and that the client should + * backoff sending data for a bit. + * + * @return true if the server did in fact request that, + * false otherwise */ boolean isBackoff(); - + /** - * Returns the number of Data Packets that were sent to or received from the remote - * NiFi instance in the Transaction - * @return + * @return the number of Data Packets that were sent to or received from the + * remote NiFi instance in the Transaction */ int getDataPacketsTransferred(); - + /** - * Returns the number of bytes of DataPacket content that were sent to or received from - * the remote NiFI instance in the Transaction. Note that this is different than the number - * of bytes actually transferred between the client and server, as it does not take into - * account the attributes or protocol-specific information that is exchanged but rather - * takes into account only the data in the {@link InputStream} of the {@link DataPacket} - * @return + * @return the number of bytes of DataPacket content that were sent to or + * received from the remote NiFI instance in the Transaction. Note that this + * is different than the number of bytes actually transferred between the + * client and server, as it does not take into account the attributes or + * protocol-specific information that is exchanged but rather takes into + * account only the data in the {@link InputStream} of the + * {@link DataPacket} */ long getBytesTransferred(); - + /** - * Returns the amount of time that the Transaction took, from the time that the Transaction - * was created to the time that the Transaction was completed. - * @param timeUnit - * @return + * @param timeUnit unit of time for which to report the duration + * @return the amount of time that the Transaction took, from the time that + * the Transaction was created to the time that the Transaction was + * completed */ long getDuration(TimeUnit timeUnit); } diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/TransferDirection.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/TransferDirection.java index 45029a4ca3..979ad9c401 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/TransferDirection.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/TransferDirection.java @@ -16,17 +16,16 @@ */ package org.apache.nifi.remote; - /** - * An enumeration for specifying the direction in which data should be transferred between a client - * and a remote NiFi instance. + * An enumeration for specifying the direction in which data should be + * transferred between a client and a remote NiFi instance. */ public enum TransferDirection { - /** - * The client is to send data to the remote instance. - */ + + /** + * The client is to send data to the remote instance. + */ SEND, - /** * The client is to receive data from the remote instance. */ diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/client/SiteToSiteClient.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/client/SiteToSiteClient.java index 629032a07e..5c4ce55d20 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/client/SiteToSiteClient.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/client/SiteToSiteClient.java @@ -36,358 +36,383 @@ import org.apache.nifi.remote.protocol.DataPacket; /** *

    - * The SiteToSiteClient provides a mechanism for sending data to a remote instance of NiFi - * (or NiFi cluster) and retrieving data from a remote instance of NiFi (or NiFi cluster). - *

    - * - *

    - * When configuring the client via the {@link SiteToSiteClient.Builder}, the Builder must - * be provided the URL of the remote NiFi instance. If the URL points to a standalone instance - * of NiFi, all interaction will take place with that instance of NiFi. However, if the URL - * points to the NiFi Cluster Manager of a cluster, the client will automatically handle load - * balancing the transactions across the different nodes in the cluster. - *

    - * - *

    - * The SiteToSiteClient provides a {@link Transaction} through which all interaction with the - * remote instance takes place. After data has been exchanged or it is determined that no data - * is available, the Transaction can then be canceled (via the {@link Transaction#cancel(String)} - * method) or can be completed (via the {@link Transaction#complete(boolean)} method). - *

    - * - *

    - * An instance of SiteToSiteClient can be obtained by constructing a new instance of the - * {@link SiteToSiteClient.Builder} class, calling the appropriate methods to configured the - * client as desired, and then calling the {@link SiteToSiteClient.Builder#build() build()} method. + * The SiteToSiteClient provides a mechanism for sending data to a remote + * instance of NiFi (or NiFi cluster) and retrieving data from a remote instance + * of NiFi (or NiFi cluster). *

    * *

    - * The SiteToSiteClient itself is immutable once constructed and is thread-safe. Many threads can - * share access to the same client. However, the {@link Transaction} that is created by the client - * is not thread safe and should not be shared among threads. + * When configuring the client via the {@link SiteToSiteClient.Builder}, the + * Builder must be provided the URL of the remote NiFi instance. If the URL + * points to a standalone instance of NiFi, all interaction will take place with + * that instance of NiFi. However, if the URL points to the NiFi Cluster Manager + * of a cluster, the client will automatically handle load balancing the + * transactions across the different nodes in the cluster. + *

    + * + *

    + * The SiteToSiteClient provides a {@link Transaction} through which all + * interaction with the remote instance takes place. After data has been + * exchanged or it is determined that no data is available, the Transaction can + * then be canceled (via the {@link Transaction#cancel(String)} method) or can + * be completed (via the {@link Transaction#complete(boolean)} method). + *

    + * + *

    + * An instance of SiteToSiteClient can be obtained by constructing a new + * instance of the {@link SiteToSiteClient.Builder} class, calling the + * appropriate methods to configured the client as desired, and then calling the + * {@link SiteToSiteClient.Builder#build() build()} method. + *

    + * + *

    + * The SiteToSiteClient itself is immutable once constructed and is thread-safe. + * Many threads can share access to the same client. However, the + * {@link Transaction} that is created by the client is not thread safe and + * should not be shared among threads. *

    */ public interface SiteToSiteClient extends Closeable { - /** - *

    - * Creates a new Transaction that can be used to either send data to a remote NiFi instance - * or receive data from a remote NiFi instance, depending on the value passed for the {@code direction} argument. - *

    - * - *

    - * Note: If all of the nodes are penalized (See {@link Builder#nodePenalizationPeriod(long, TimeUnit)}), then - * this method will return null. - *

    - * - * @param direction specifies which direction the data should be transferred. A value of {@link TransferDirection#SEND} - * indicates that this Transaction will send data to the remote instance; a value of {@link TransferDirection#RECEIVE} indicates - * that this Transaction will be used to receive data from the remote instance. - * - * @return a Transaction to use for sending or receiving data, or null if all nodes are penalized. - * @throws IOException - */ - Transaction createTransaction(TransferDirection direction) throws HandshakeException, PortNotRunningException, ProtocolException, UnknownPortException, IOException; - - /** - *

    - * Returns {@code true} if site-to-site communications with the remote instance are secure, - * {@code false} if site-to-site communications with the remote instance are not secure. Whether or not - * communications are secure depends on the server, not the client. - *

    - * - *

    - * In order to determine whether the server is configured for secure communications, the client may have - * to query the server's RESTful interface. Doing so could result in an IOException. - *

    - * - * @return - * @throws IOException if unable to query the remote instance's RESTful interface or if the remote - * instance is not configured to allow site-to-site communications - */ - boolean isSecure() throws IOException; - - /** - *

    - * Returns the configuration object that was built by the Builder - *

    - * @return - */ - SiteToSiteClientConfig getConfig(); - - /** - *

    - * The Builder is the mechanism by which all configuration is passed to the SiteToSiteClient. - * Once constructed, the SiteToSiteClient cannot be reconfigured (i.e., it is immutable). If - * a change in configuration should be desired, the client should be {@link Closeable#close() closed} - * and a new client created. - *

    - */ - public static class Builder implements Serializable { + /** + *

    + * Creates a new Transaction that can be used to either send data to a + * remote NiFi instance or receive data from a remote NiFi instance, + * depending on the value passed for the {@code direction} argument. + *

    + * + *

    + * Note: If all of the nodes are penalized (See + * {@link Builder#nodePenalizationPeriod(long, TimeUnit)}), then this method + * will return null. + *

    + * + * @param direction specifies which direction the data should be + * transferred. A value of {@link TransferDirection#SEND} indicates that + * this Transaction will send data to the remote instance; a value of + * {@link TransferDirection#RECEIVE} indicates that this Transaction will be + * used to receive data from the remote instance. + * + * @return a Transaction to use for sending or receiving data, or + * null if all nodes are penalized. + * @throws org.apache.nifi.remote.exception.HandshakeException he + * @throws org.apache.nifi.remote.exception.PortNotRunningException pnre + * @throws IOException ioe + * @throws org.apache.nifi.remote.exception.UnknownPortException upe + */ + Transaction createTransaction(TransferDirection direction) throws HandshakeException, PortNotRunningException, ProtocolException, UnknownPortException, IOException; + + /** + *

    + * In order to determine whether the server is configured for secure + * communications, the client may have to query the server's RESTful + * interface. Doing so could result in an IOException. + *

    + * + * @return {@code true} if site-to-site communications with the remote + * instance are secure, {@code false} if site-to-site communications with + * the remote instance are not secure. Whether or not communications are + * secure depends on the server, not the client + * @throws IOException if unable to query the remote instance's RESTful + * interface or if the remote instance is not configured to allow + * site-to-site communications + */ + boolean isSecure() throws IOException; + + /** + * + * @return the configuration object that was built by the Builder + */ + SiteToSiteClientConfig getConfig(); + + /** + *

    + * The Builder is the mechanism by which all configuration is passed to the + * SiteToSiteClient. Once constructed, the SiteToSiteClient cannot be + * reconfigured (i.e., it is immutable). If a change in configuration should + * be desired, the client should be {@link Closeable#close() closed} and a + * new client created. + *

    + */ + public static class Builder implements Serializable { + private static final long serialVersionUID = -4954962284343090219L; - + private String url; - private long timeoutNanos = TimeUnit.SECONDS.toNanos(30); - private long penalizationNanos = TimeUnit.SECONDS.toNanos(3); - private long idleExpirationNanos = TimeUnit.SECONDS.toNanos(30L); - private SSLContext sslContext; - private EventReporter eventReporter; - private File peerPersistenceFile; - private boolean useCompression; - private String portName; - private String portIdentifier; - private int batchCount; - private long batchSize; - private long batchNanos; + private long timeoutNanos = TimeUnit.SECONDS.toNanos(30); + private long penalizationNanos = TimeUnit.SECONDS.toNanos(3); + private long idleExpirationNanos = TimeUnit.SECONDS.toNanos(30L); + private SSLContext sslContext; + private EventReporter eventReporter; + private File peerPersistenceFile; + private boolean useCompression; + private String portName; + private String portIdentifier; + private int batchCount; + private long batchSize; + private long batchNanos; - /** - * Populates the builder with values from the provided config - * @param config - * @return - */ - public Builder fromConfig(final SiteToSiteClientConfig config) { - this.url = config.getUrl(); - this.timeoutNanos = config.getTimeout(TimeUnit.NANOSECONDS); - this.penalizationNanos = config.getPenalizationPeriod(TimeUnit.NANOSECONDS); - this.idleExpirationNanos = config.getIdleConnectionExpiration(TimeUnit.NANOSECONDS); - this.sslContext = config.getSslContext(); - this.eventReporter = config.getEventReporter(); - this.peerPersistenceFile = config.getPeerPersistenceFile(); - this.useCompression = config.isUseCompression(); - this.portName = config.getPortName(); - this.portIdentifier = config.getPortIdentifier(); - this.batchCount = config.getPreferredBatchCount(); - this.batchSize = config.getPreferredBatchSize(); - this.batchNanos = config.getPreferredBatchDuration(TimeUnit.NANOSECONDS); - - return this; - } - - /** - * Specifies the URL of the remote NiFi instance. If this URL points to the Cluster Manager of - * a NiFi cluster, data transfer to and from nodes will be automatically load balanced across - * the different nodes. - * - * @param url - * @return - */ - public Builder url(final String url) { - this.url = url; - return this; - } - - /** - * Specifies the communications timeouts to use when interacting with the remote instances. The - * default value is 30 seconds. - * - * @param timeout - * @param unit - * @return - */ - public Builder timeout(final long timeout, final TimeUnit unit) { - this.timeoutNanos = unit.toNanos(timeout); - return this; - } - - /** - * Specifies the amount of time that a connection can remain idle in the connection pool before it - * is "expired" and shutdown. The default value is 30 seconds. - * - * @param timeout - * @param unit - * @return - */ - public Builder idleExpiration(final long timeout, final TimeUnit unit) { - this.idleExpirationNanos = unit.toNanos(timeout); - return this; - } - - /** - * If there is a problem communicating with a node (i.e., any node in the remote NiFi cluster - * or the remote instance of NiFi if it is standalone), specifies how long the client should - * wait before attempting to communicate with that node again. While a particular node is penalized, - * all other nodes in the remote cluster (if any) will still be available for communication. - * The default value is 3 seconds. - * - * @param period - * @param unit - * @return - */ - public Builder nodePenalizationPeriod(final long period, final TimeUnit unit) { - this.penalizationNanos = unit.toNanos(period); - return this; - } - - /** - * Specifies the SSL Context to use when communicating with the remote NiFi instance(s). If not - * specified, communications will not be secure. The remote instance of NiFi always determines - * whether or not Site-to-Site communications are secure (i.e., the client will always use - * secure or non-secure communications, depending on what the server dictates). - * - * @param sslContext - * @return - */ - public Builder sslContext(final SSLContext sslContext) { - this.sslContext = sslContext; - return this; - } - - - /** - * Provides an EventReporter that can be used by the client in order to report any events that - * could be of interest when communicating with the remote instance. The EventReporter provided - * must be threadsafe. - * - * @param eventReporter - * @return - */ - public Builder eventReporter(final EventReporter eventReporter) { - this.eventReporter = eventReporter; - return this; - } - - - /** - * Specifies a file that the client can write to in order to persist the list of nodes in the - * remote cluster and recover the list of nodes upon restart. This allows the client to function - * if the remote Cluster Manager is unavailable, even after a restart of the client software. - * If not specified, the list of nodes will not be persisted and a failure of the Cluster Manager - * will result in not being able to communicate with the remote instance if a new client - * is created. - * - * @param peerPersistenceFile - * @return - */ - public Builder peerPersistenceFile(final File peerPersistenceFile) { - this.peerPersistenceFile = peerPersistenceFile; - return this; - } - - /** - * Specifies whether or not data should be compressed before being transferred to or from the - * remote instance. - * - * @param compress - * @return - */ - public Builder useCompression(final boolean compress) { - this.useCompression = compress; - return this; - } - - /** - * Specifies the name of the port to communicate with. Either the port name or the port identifier - * must be specified. - * - * @param portName - * @return - */ - public Builder portName(final String portName) { - this.portName = portName; - return this; - } - - /** - * Specifies the unique identifier of the port to communicate with. If it is known, this is preferred over providing - * the port name, as the port name may change. - * - * @param portIdentifier - * @return - */ - public Builder portIdentifier(final String portIdentifier) { - this.portIdentifier = portIdentifier; - return this; - } - - /** - * When pulling data from a NiFi instance, the sender chooses how large a Transaction is. However, - * the client has the ability to request a particular batch size/duration. This method specifies - * the preferred number of {@link DataPacket}s to include in a Transaction. - * - * @return - */ - public Builder requestBatchCount(final int count) { - this.batchCount = count; - return this; - } - - /** - * When pulling data from a NiFi instance, the sender chooses how large a Transaction is. However, - * the client has the ability to request a particular batch size/duration. This method specifies - * the preferred number of bytes to include in a Transaction. - * - * @return - */ - public Builder requestBatchSize(final long bytes) { - this.batchSize = bytes; - return this; - } - /** - * When pulling data from a NiFi instance, the sender chooses how large a Transaction is. However, - * the client has the ability to request a particular batch size/duration. This method specifies - * the preferred amount of time that a Transaction should span. - * - * @return + * Populates the builder with values from the provided config + * + * @param config to start with + * @return the builder */ - public Builder requestBatchDuration(final long value, final TimeUnit unit) { - this.batchNanos = unit.toNanos(value); - return this; - } - - /** - * Returns a {@link SiteToSiteClientConfig} for the configured values but does not create a SiteToSiteClient - * @return - */ - public SiteToSiteClientConfig buildConfig() { - final SiteToSiteClientConfig config = new SiteToSiteClientConfig() { + public Builder fromConfig(final SiteToSiteClientConfig config) { + this.url = config.getUrl(); + this.timeoutNanos = config.getTimeout(TimeUnit.NANOSECONDS); + this.penalizationNanos = config.getPenalizationPeriod(TimeUnit.NANOSECONDS); + this.idleExpirationNanos = config.getIdleConnectionExpiration(TimeUnit.NANOSECONDS); + this.sslContext = config.getSslContext(); + this.eventReporter = config.getEventReporter(); + this.peerPersistenceFile = config.getPeerPersistenceFile(); + this.useCompression = config.isUseCompression(); + this.portName = config.getPortName(); + this.portIdentifier = config.getPortIdentifier(); + this.batchCount = config.getPreferredBatchCount(); + this.batchSize = config.getPreferredBatchSize(); + this.batchNanos = config.getPreferredBatchDuration(TimeUnit.NANOSECONDS); + + return this; + } + + /** + * Specifies the URL of the remote NiFi instance. If this URL points to + * the Cluster Manager of a NiFi cluster, data transfer to and from + * nodes will be automatically load balanced across the different nodes. + * + * @param url url of remote instance + * @return the builder + */ + public Builder url(final String url) { + this.url = url; + return this; + } + + /** + * Specifies the communications timeouts to use when interacting with + * the remote instances. The default value is 30 seconds. + * + * @param timeout to use when interacting with remote instances + * @param unit unit of time over which to interpret the given timeout + * @return the builder + */ + public Builder timeout(final long timeout, final TimeUnit unit) { + this.timeoutNanos = unit.toNanos(timeout); + return this; + } + + /** + * Specifies the amount of time that a connection can remain idle in the + * connection pool before it is "expired" and shutdown. The default + * value is 30 seconds. + * + * @param timeout to use when interacting with remote instances + * @param unit unit of time over which to interpret the given timeout + * @return the builder + */ + public Builder idleExpiration(final long timeout, final TimeUnit unit) { + this.idleExpirationNanos = unit.toNanos(timeout); + return this; + } + + /** + * If there is a problem communicating with a node (i.e., any node in + * the remote NiFi cluster or the remote instance of NiFi if it is + * standalone), specifies how long the client should wait before + * attempting to communicate with that node again. While a particular + * node is penalized, all other nodes in the remote cluster (if any) + * will still be available for communication. The default value is 3 + * seconds. + * + * @param period time to wait between communication attempts + * @param unit over which to evaluate the given period + * @return the builder + */ + public Builder nodePenalizationPeriod(final long period, final TimeUnit unit) { + this.penalizationNanos = unit.toNanos(period); + return this; + } + + /** + * Specifies the SSL Context to use when communicating with the remote + * NiFi instance(s). If not specified, communications will not be + * secure. The remote instance of NiFi always determines whether or not + * Site-to-Site communications are secure (i.e., the client will always + * use secure or non-secure communications, depending on what the server + * dictates). + * + * @param sslContext the context + * @return the builder + */ + public Builder sslContext(final SSLContext sslContext) { + this.sslContext = sslContext; + return this; + } + + /** + * Provides an EventReporter that can be used by the client in order to + * report any events that could be of interest when communicating with + * the remote instance. The EventReporter provided must be threadsafe. + * + * @param eventReporter reporter + * @return the builder + */ + public Builder eventReporter(final EventReporter eventReporter) { + this.eventReporter = eventReporter; + return this; + } + + /** + * Specifies a file that the client can write to in order to persist the + * list of nodes in the remote cluster and recover the list of nodes + * upon restart. This allows the client to function if the remote + * Cluster Manager is unavailable, even after a restart of the client + * software. If not specified, the list of nodes will not be persisted + * and a failure of the Cluster Manager will result in not being able to + * communicate with the remote instance if a new client is created. + * + * @param peerPersistenceFile file + * @return the builder + */ + public Builder peerPersistenceFile(final File peerPersistenceFile) { + this.peerPersistenceFile = peerPersistenceFile; + return this; + } + + /** + * Specifies whether or not data should be compressed before being + * transferred to or from the remote instance. + * + * @param compress true if should compress + * @return the builder + */ + public Builder useCompression(final boolean compress) { + this.useCompression = compress; + return this; + } + + /** + * Specifies the name of the port to communicate with. Either the port + * name or the port identifier must be specified. + * + * @param portName name of port + * @return the builder + */ + public Builder portName(final String portName) { + this.portName = portName; + return this; + } + + /** + * Specifies the unique identifier of the port to communicate with. If + * it is known, this is preferred over providing the port name, as the + * port name may change. + * + * @param portIdentifier identifier of port + * @return the builder + */ + public Builder portIdentifier(final String portIdentifier) { + this.portIdentifier = portIdentifier; + return this; + } + + /** + * When pulling data from a NiFi instance, the sender chooses how large + * a Transaction is. However, the client has the ability to request a + * particular batch size/duration. This method specifies the preferred + * number of {@link DataPacket}s to include in a Transaction. + * + * @param count client preferred batch size + * @return the builder + */ + public Builder requestBatchCount(final int count) { + this.batchCount = count; + return this; + } + + /** + * When pulling data from a NiFi instance, the sender chooses how large + * a Transaction is. However, the client has the ability to request a + * particular batch size/duration. This method specifies the preferred + * number of bytes to include in a Transaction. + * + * @param bytes client preferred batch size + * @return the builder + */ + public Builder requestBatchSize(final long bytes) { + this.batchSize = bytes; + return this; + } + + /** + * When pulling data from a NiFi instance, the sender chooses how large + * a Transaction is. However, the client has the ability to request a + * particular batch size/duration. This method specifies the preferred + * amount of time that a Transaction should span. + * + * @param value client preferred batch duration + * @param unit client preferred batch duration unit + * @return the builder + */ + public Builder requestBatchDuration(final long value, final TimeUnit unit) { + this.batchNanos = unit.toNanos(value); + return this; + } + + /** + * @return a {@link SiteToSiteClientConfig} for the configured values + * but does not create a SiteToSiteClient + */ + public SiteToSiteClientConfig buildConfig() { + final SiteToSiteClientConfig config = new SiteToSiteClientConfig() { private static final long serialVersionUID = 1323119754841633818L; @Override public boolean isUseCompression() { return Builder.this.isUseCompression(); } - + @Override public String getUrl() { return Builder.this.getUrl(); } - + @Override public long getTimeout(final TimeUnit timeUnit) { return Builder.this.getTimeout(timeUnit); } - + @Override public long getIdleConnectionExpiration(final TimeUnit timeUnit) { return Builder.this.getIdleConnectionExpiration(timeUnit); } - + @Override public SSLContext getSslContext() { return Builder.this.getSslContext(); } - + @Override public String getPortName() { return Builder.this.getPortName(); } - + @Override public String getPortIdentifier() { return Builder.this.getPortIdentifier(); } - + @Override public long getPenalizationPeriod(final TimeUnit timeUnit) { return Builder.this.getPenalizationPeriod(timeUnit); } - + @Override public File getPeerPersistenceFile() { return Builder.this.getPeerPersistenceFile(); } - + @Override public EventReporter getEventReporter() { return Builder.this.getEventReporter(); @@ -397,123 +422,117 @@ public interface SiteToSiteClient extends Closeable { public long getPreferredBatchDuration(final TimeUnit timeUnit) { return timeUnit.convert(Builder.this.batchNanos, TimeUnit.NANOSECONDS); } - + @Override public long getPreferredBatchSize() { return Builder.this.batchSize; } - + @Override public int getPreferredBatchCount() { return Builder.this.batchCount; } }; - + return config; - } - - /** - * Builds a new SiteToSiteClient that can be used to send and receive data with remote instances of NiFi - * @return - * - * @throws IllegalStateException if either the url is not set or neither the port name nor port identifier - * is set. - */ - public SiteToSiteClient build() { - if ( url == null ) { - throw new IllegalStateException("Must specify URL to build Site-to-Site client"); - } - - if ( portName == null && portIdentifier == null ) { - throw new IllegalStateException("Must specify either Port Name or Port Identifier to builder Site-to-Site client"); - } - - return new SocketClient(buildConfig()); - } + } - /** - * Returns the configured URL for the remote NiFi instance - * @return - */ - public String getUrl() { - return url; - } + /** + * @return a new SiteToSiteClient that can be used to send and receive + * data with remote instances of NiFi + * + * @throws IllegalStateException if either the url is not set or neither + * the port name nor port identifier is set. + */ + public SiteToSiteClient build() { + if (url == null) { + throw new IllegalStateException("Must specify URL to build Site-to-Site client"); + } - /** - * Returns the communications timeout - * @return - */ - public long getTimeout(final TimeUnit timeUnit) { - return timeUnit.convert(timeoutNanos, TimeUnit.NANOSECONDS); - } - - /** - * Returns the amount of of time that a connection can remain idle in the connection - * pool before being shutdown - * @param timeUnit - * @return - */ - public long getIdleConnectionExpiration(final TimeUnit timeUnit) { - return timeUnit.convert(idleExpirationNanos, TimeUnit.NANOSECONDS); - } + if (portName == null && portIdentifier == null) { + throw new IllegalStateException("Must specify either Port Name or Port Identifier to builder Site-to-Site client"); + } - /** - * Returns the amount of time that a particular node will be ignored after a - * communications error with that node occurs - * @param timeUnit - * @return - */ - public long getPenalizationPeriod(TimeUnit timeUnit) { - return timeUnit.convert(penalizationNanos, TimeUnit.NANOSECONDS); - } + return new SocketClient(buildConfig()); + } - /** - * Returns the SSL Context that is configured for this builder - * @return - */ - public SSLContext getSslContext() { - return sslContext; - } + /** + * @return the configured URL for the remote NiFi instance + */ + public String getUrl() { + return url; + } - /** - * Returns the EventReporter that is to be used by clients to report events - * @return - */ - public EventReporter getEventReporter() { - return eventReporter; - } + /** + * @param timeUnit unit over which to interpret the timeout + * @return the communications timeout + */ + public long getTimeout(final TimeUnit timeUnit) { + return timeUnit.convert(timeoutNanos, TimeUnit.NANOSECONDS); + } - /** - * Returns the file that is to be used for persisting the nodes of a remote cluster, if any. - * @return - */ - public File getPeerPersistenceFile() { - return peerPersistenceFile; - } + /** + * @param timeUnit unit over which to interpret the time + * @return the amount of of time that a connection can remain idle in + * the connection pool before being shutdown + */ + public long getIdleConnectionExpiration(final TimeUnit timeUnit) { + return timeUnit.convert(idleExpirationNanos, TimeUnit.NANOSECONDS); + } - /** - * Returns a boolean indicating whether or not compression will be used to transfer data - * to and from the remote instance - * @return - */ - public boolean isUseCompression() { - return useCompression; - } + /** + * @param timeUnit unit of reported time + * @return the amount of time that a particular node will be ignored + * after a communications error with that node occurs + */ + public long getPenalizationPeriod(TimeUnit timeUnit) { + return timeUnit.convert(penalizationNanos, TimeUnit.NANOSECONDS); + } - /** - * Returns the name of the port that the client is to communicate with. - * @return - */ - public String getPortName() { - return portName; - } + /** + * @return the SSL Context that is configured for this builder + */ + public SSLContext getSslContext() { + return sslContext; + } - /** - * Returns the identifier of the port that the client is to communicate with. - * @return - */ - public String getPortIdentifier() { - return portIdentifier; - } - } + /** + * @return the EventReporter that is to be used by clients to report + * events + */ + public EventReporter getEventReporter() { + return eventReporter; + } + + /** + * @return the file that is to be used for persisting the nodes of a + * remote cluster, if any + */ + public File getPeerPersistenceFile() { + return peerPersistenceFile; + } + + /** + * @return a boolean indicating whether or not compression will be used + * to transfer data to and from the remote instance + */ + public boolean isUseCompression() { + return useCompression; + } + + /** + * @return the name of the port that the client is to communicate with + */ + public String getPortName() { + return portName; + } + + /** + * @return the identifier of the port that the client is to communicate + * with + */ + public String getPortIdentifier() { + return portIdentifier; + } + } } diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/client/SiteToSiteClientConfig.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/client/SiteToSiteClientConfig.java index 5e7fbe8571..c4b0d220e6 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/client/SiteToSiteClientConfig.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/client/SiteToSiteClientConfig.java @@ -27,97 +27,91 @@ import org.apache.nifi.remote.protocol.DataPacket; public interface SiteToSiteClientConfig extends Serializable { - /** - * Returns the configured URL for the remote NiFi instance - * @return - */ - String getUrl(); - - /** - * Returns the communications timeout in nanoseconds - * @return - */ - long getTimeout(final TimeUnit timeUnit); - - /** - * Returns the amount of time that a connection can remain idle before it is - * "expired" and shut down - * @param timeUnit - * @return - */ - long getIdleConnectionExpiration(TimeUnit timeUnit); - - /** - * Returns the amount of time that a particular node will be ignored after a - * communications error with that node occurs - * @param timeUnit - * @return - */ - long getPenalizationPeriod(TimeUnit timeUnit); - - /** - * Returns the SSL Context that is configured for this builder - * @return - */ - SSLContext getSslContext(); - - /** - * Returns the file that is to be used for persisting the nodes of a remote cluster, if any. - * @return - */ - File getPeerPersistenceFile(); - - /** - * Returns a boolean indicating whether or not compression will be used to transfer data - * to and from the remote instance - * @return - */ - boolean isUseCompression(); - - /** - * Returns the name of the port that the client is to communicate with. - * @return - */ - String getPortName(); - - /** - * Returns the identifier of the port that the client is to communicate with. - * @return - */ - String getPortIdentifier(); - - /** - * When pulling data from a NiFi instance, the sender chooses how large a Transaction is. However, - * the client has the ability to request a particular batch size/duration. This returns the maximum - * amount of time that we will request a NiFi instance to send data to us in a Transaction. - * - * @param timeUnit - * @return - */ - long getPreferredBatchDuration(TimeUnit timeUnit); - /** - * When pulling data from a NiFi instance, the sender chooses how large a Transaction is. However, - * the client has the ability to request a particular batch size/duration. This returns the maximum - * number of bytes that we will request a NiFi instance to send data to us in a Transaction. - * - * @return + * @return the configured URL for the remote NiFi instance */ - long getPreferredBatchSize(); - - - /** - * When pulling data from a NiFi instance, the sender chooses how large a Transaction is. However, - * the client has the ability to request a particular batch size/duration. This returns the maximum - * number of {@link DataPacket}s that we will request a NiFi instance to send data to us in a Transaction. - * - * @return + String getUrl(); + + /** + * @param timeUnit unit over which to report the timeout + * @return the communications timeout in given unit */ - int getPreferredBatchCount(); - - /** - * Returns the EventReporter that is to be used by clients to report events - * @return + long getTimeout(final TimeUnit timeUnit); + + /** + * @param timeUnit the unit for which to report the time + * @return the amount of time that a connection can remain idle before it is + * "expired" and shut down + */ + long getIdleConnectionExpiration(TimeUnit timeUnit); + + /** + * @param timeUnit unit over which to report the time + * @return the amount of time that a particular node will be ignored after a + * communications error with that node occurs + */ + long getPenalizationPeriod(TimeUnit timeUnit); + + /** + * @return the SSL Context that is configured for this builder + */ + SSLContext getSslContext(); + + /** + * @return the file that is to be used for persisting the nodes of a remote + * cluster, if any + */ + File getPeerPersistenceFile(); + + /** + * @return a boolean indicating whether or not compression will be used to + * transfer data to and from the remote instance + */ + boolean isUseCompression(); + + /** + * @return the name of the port that the client is to communicate with + */ + String getPortName(); + + /** + * @return the identifier of the port that the client is to communicate with + */ + String getPortIdentifier(); + + /** + * When pulling data from a NiFi instance, the sender chooses how large a + * Transaction is. However, the client has the ability to request a + * particular batch size/duration. + * + * @param timeUnit unit of time over which to report the duration + * @return the maximum amount of time that we will request a NiFi instance + * to send data to us in a Transaction + */ + long getPreferredBatchDuration(TimeUnit timeUnit); + + /** + * When pulling data from a NiFi instance, the sender chooses how large a + * Transaction is. However, the client has the ability to request a + * particular batch size/duration. + * + * @return returns the maximum number of bytes that we will request a NiFi + * instance to send data to us in a Transaction + */ + long getPreferredBatchSize(); + + /** + * When pulling data from a NiFi instance, the sender chooses how large a + * Transaction is. However, the client has the ability to request a + * particular batch size/duration. + * + * @return the maximum number of {@link DataPacket}s that we will request a + * NiFi instance to send data to us in a Transaction + */ + int getPreferredBatchCount(); + + /** + * @return the EventReporter that is to be used by clients to report events */ EventReporter getEventReporter(); diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/client/socket/EndpointConnection.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/client/socket/EndpointConnection.java index 651ae5064b..1a16b022f9 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/client/socket/EndpointConnection.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/client/socket/EndpointConnection.java @@ -21,33 +21,34 @@ import org.apache.nifi.remote.codec.FlowFileCodec; import org.apache.nifi.remote.protocol.socket.SocketClientProtocol; public class EndpointConnection { - private final Peer peer; + + private final Peer peer; private final SocketClientProtocol socketClientProtocol; private final FlowFileCodec codec; private volatile long lastUsed; - + public EndpointConnection(final Peer peer, final SocketClientProtocol socketClientProtocol, final FlowFileCodec codec) { this.peer = peer; this.socketClientProtocol = socketClientProtocol; this.codec = codec; } - + public FlowFileCodec getCodec() { return codec; } - + public SocketClientProtocol getSocketClientProtocol() { return socketClientProtocol; } - + public Peer getPeer() { return peer; } - + public void setLastTimeUsed() { lastUsed = System.currentTimeMillis(); } - + public long getLastTimeUsed() { return lastUsed; } diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/client/socket/EndpointConnectionPool.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/client/socket/EndpointConnectionPool.java index 1b5412cd01..b162b3fb8d 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/client/socket/EndpointConnectionPool.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/client/socket/EndpointConnectionPool.java @@ -91,21 +91,22 @@ import org.slf4j.LoggerFactory; import org.slf4j.helpers.MessageFormatter; public class EndpointConnectionPool { + public static final long PEER_REFRESH_PERIOD = 60000L; public static final String CATEGORY = "Site-to-Site"; public static final long REMOTE_REFRESH_MILLIS = TimeUnit.MILLISECONDS.convert(10, TimeUnit.MINUTES); private static final long PEER_CACHE_MILLIS = TimeUnit.MILLISECONDS.convert(1, TimeUnit.MINUTES); - private static final Logger logger = LoggerFactory.getLogger(EndpointConnectionPool.class); - - private final ConcurrentMap> connectionQueueMap = new ConcurrentHashMap<>(); + private static final Logger logger = LoggerFactory.getLogger(EndpointConnectionPool.class); + + private final ConcurrentMap> connectionQueueMap = new ConcurrentHashMap<>(); private final ConcurrentMap peerTimeoutExpirations = new ConcurrentHashMap<>(); private final URI clusterUrl; private final String apiUri; - + private final AtomicLong peerIndex = new AtomicLong(0L); - + private final ReentrantLock peerRefreshLock = new ReentrantLock(); private volatile List peerStatuses; private volatile long peerRefreshTime = 0L; @@ -118,132 +119,129 @@ public class EndpointConnectionPool { private final ScheduledExecutorService taskExecutor; private final int idleExpirationMillis; private final RemoteDestination remoteDestination; - + private final ReadWriteLock listeningPortRWLock = new ReentrantReadWriteLock(); private final Lock remoteInfoReadLock = listeningPortRWLock.readLock(); private final Lock remoteInfoWriteLock = listeningPortRWLock.writeLock(); private Integer siteToSitePort; private Boolean siteToSiteSecure; private long remoteRefreshTime; - private final Map inputPortMap = new HashMap<>(); // map input port name to identifier - private final Map outputPortMap = new HashMap<>(); // map output port name to identifier - + private final Map inputPortMap = new HashMap<>(); // map input port name to identifier + private final Map outputPortMap = new HashMap<>(); // map output port name to identifier + private volatile int commsTimeout; private volatile boolean shutdown = false; - - - public EndpointConnectionPool(final String clusterUrl, final RemoteDestination remoteDestination, final int commsTimeoutMillis, - final int idleExpirationMillis, final EventReporter eventReporter, final File persistenceFile) - { - this(clusterUrl, remoteDestination, commsTimeoutMillis, idleExpirationMillis, null, eventReporter, persistenceFile); + + public EndpointConnectionPool(final String clusterUrl, final RemoteDestination remoteDestination, final int commsTimeoutMillis, + final int idleExpirationMillis, final EventReporter eventReporter, final File persistenceFile) { + this(clusterUrl, remoteDestination, commsTimeoutMillis, idleExpirationMillis, null, eventReporter, persistenceFile); } - + public EndpointConnectionPool(final String clusterUrl, final RemoteDestination remoteDestination, final int commsTimeoutMillis, final int idleExpirationMillis, - final SSLContext sslContext, final EventReporter eventReporter, final File persistenceFile) - { + final SSLContext sslContext, final EventReporter eventReporter, final File persistenceFile) { Objects.requireNonNull(clusterUrl, "URL cannot be null"); Objects.requireNonNull(remoteDestination, "Remote Destination/Port Identifier cannot be null"); - try { - this.clusterUrl = new URI(clusterUrl); - } catch (final URISyntaxException e) { - throw new IllegalArgumentException("Invalid Cluster URL: " + clusterUrl); - } - - // Trim the trailing / + try { + this.clusterUrl = new URI(clusterUrl); + } catch (final URISyntaxException e) { + throw new IllegalArgumentException("Invalid Cluster URL: " + clusterUrl); + } + + // Trim the trailing / String uriPath = this.clusterUrl.getPath(); if (uriPath.endsWith("/")) { uriPath = uriPath.substring(0, uriPath.length() - 1); } apiUri = this.clusterUrl.getScheme() + "://" + this.clusterUrl.getHost() + ":" + this.clusterUrl.getPort() + uriPath + "-api"; - + this.remoteDestination = remoteDestination; - this.sslContext = sslContext; - this.peersFile = persistenceFile; - this.eventReporter = eventReporter; - this.commsTimeout = commsTimeoutMillis; - this.idleExpirationMillis = idleExpirationMillis; - - Set recoveredStatuses; - if ( persistenceFile != null && persistenceFile.exists() ) { - try { - recoveredStatuses = recoverPersistedPeerStatuses(peersFile); - this.peerStatusCache = new PeerStatusCache(recoveredStatuses, peersFile.lastModified()); - } catch (final IOException ioe) { - logger.warn("Failed to recover peer statuses from {} due to {}; will continue without loading information from file", persistenceFile, ioe); - } - } else { - peerStatusCache = null; - } + this.sslContext = sslContext; + this.peersFile = persistenceFile; + this.eventReporter = eventReporter; + this.commsTimeout = commsTimeoutMillis; + this.idleExpirationMillis = idleExpirationMillis; - // Initialize a scheduled executor and run some maintenance tasks in the background to kill off old, unused - // connections and keep our list of peers up-to-date. - taskExecutor = Executors.newScheduledThreadPool(1, new ThreadFactory() { - private final ThreadFactory defaultFactory = Executors.defaultThreadFactory(); - - @Override - public Thread newThread(final Runnable r) { - final Thread thread = defaultFactory.newThread(r); - thread.setName("NiFi Site-to-Site Connection Pool Maintenance"); - return thread; - } - }); + Set recoveredStatuses; + if (persistenceFile != null && persistenceFile.exists()) { + try { + recoveredStatuses = recoverPersistedPeerStatuses(peersFile); + this.peerStatusCache = new PeerStatusCache(recoveredStatuses, peersFile.lastModified()); + } catch (final IOException ioe) { + logger.warn("Failed to recover peer statuses from {} due to {}; will continue without loading information from file", persistenceFile, ioe); + } + } else { + peerStatusCache = null; + } - taskExecutor.scheduleWithFixedDelay(new Runnable() { - @Override - public void run() { - refreshPeers(); - } - }, 0, 5, TimeUnit.SECONDS); + // Initialize a scheduled executor and run some maintenance tasks in the background to kill off old, unused + // connections and keep our list of peers up-to-date. + taskExecutor = Executors.newScheduledThreadPool(1, new ThreadFactory() { + private final ThreadFactory defaultFactory = Executors.defaultThreadFactory(); - taskExecutor.scheduleWithFixedDelay(new Runnable() { - @Override - public void run() { - cleanupExpiredSockets(); - } - }, 5, 5, TimeUnit.SECONDS); + @Override + public Thread newThread(final Runnable r) { + final Thread thread = defaultFactory.newThread(r); + thread.setName("NiFi Site-to-Site Connection Pool Maintenance"); + return thread; + } + }); + + taskExecutor.scheduleWithFixedDelay(new Runnable() { + @Override + public void run() { + refreshPeers(); + } + }, 0, 5, TimeUnit.SECONDS); + + taskExecutor.scheduleWithFixedDelay(new Runnable() { + @Override + public void run() { + cleanupExpiredSockets(); + } + }, 5, 5, TimeUnit.SECONDS); } - + void warn(final String msg, final Object... args) { - logger.warn(msg, args); - if ( eventReporter != null ) { - eventReporter.reportEvent(Severity.WARNING, "Site-to-Site", MessageFormatter.arrayFormat(msg, args).getMessage()); - } + logger.warn(msg, args); + if (eventReporter != null) { + eventReporter.reportEvent(Severity.WARNING, "Site-to-Site", MessageFormatter.arrayFormat(msg, args).getMessage()); + } } - + void warn(final String msg, final Throwable t) { - logger.warn(msg, t); - - if ( eventReporter != null ) { - eventReporter.reportEvent(Severity.WARNING, "Site-to-Site", msg + ": " + t.toString()); - } + logger.warn(msg, t); + + if (eventReporter != null) { + eventReporter.reportEvent(Severity.WARNING, "Site-to-Site", msg + ": " + t.toString()); + } } - + void error(final String msg, final Object... args) { - logger.error(msg, args); - if ( eventReporter != null ) { - eventReporter.reportEvent(Severity.ERROR, "Site-to-Site", MessageFormatter.arrayFormat(msg, args).getMessage()); - } + logger.error(msg, args); + if (eventReporter != null) { + eventReporter.reportEvent(Severity.ERROR, "Site-to-Site", MessageFormatter.arrayFormat(msg, args).getMessage()); + } } - + private String getPortIdentifier(final TransferDirection transferDirection) throws IOException { - if ( remoteDestination.getIdentifier() != null ) { + if (remoteDestination.getIdentifier() != null) { return remoteDestination.getIdentifier(); } - - if ( transferDirection == TransferDirection.RECEIVE ) { + + if (transferDirection == TransferDirection.RECEIVE) { return getOutputPortIdentifier(remoteDestination.getName()); } else { return getInputPortIdentifier(remoteDestination.getName()); } } - + public EndpointConnection getEndpointConnection(final TransferDirection direction) throws IOException, HandshakeException, PortNotRunningException, UnknownPortException, ProtocolException { return getEndpointConnection(direction, null); } - - - public EndpointConnection getEndpointConnection(final TransferDirection direction, final SiteToSiteClientConfig config) throws IOException, HandshakeException, PortNotRunningException, UnknownPortException, ProtocolException { - // + + public EndpointConnection getEndpointConnection(final TransferDirection direction, final SiteToSiteClientConfig config) + throws IOException, HandshakeException, PortNotRunningException, UnknownPortException, ProtocolException { + // // Attempt to get a connection state that already exists for this URL. // FlowFileCodec codec = null; @@ -255,42 +253,42 @@ public class EndpointConnectionPool { logger.debug("{} getting next peer status", this); final PeerStatus peerStatus = getNextPeerStatus(direction); logger.debug("{} next peer status = {}", this, peerStatus); - if ( peerStatus == null ) { + if (peerStatus == null) { return null; } final PeerDescription peerDescription = peerStatus.getPeerDescription(); - BlockingQueue connectionQueue = connectionQueueMap.get(peerStatus); - if ( connectionQueue == null ) { + BlockingQueue connectionQueue = connectionQueueMap.get(peerDescription); + if (connectionQueue == null) { connectionQueue = new LinkedBlockingQueue<>(); BlockingQueue existing = connectionQueueMap.putIfAbsent(peerDescription, connectionQueue); - if ( existing != null ) { + if (existing != null) { connectionQueue = existing; } } - + final List addBack = new ArrayList<>(); try { do { connection = connectionQueue.poll(); logger.debug("{} Connection State for {} = {}", this, clusterUrl, connection); final String portId = getPortIdentifier(direction); - - if ( connection == null && !addBack.isEmpty() ) { + + if (connection == null && !addBack.isEmpty()) { // all available connections have been penalized. logger.debug("{} all Connections for {} are penalized; returning no Connection", this, portId); return null; } - - if ( connection != null && connection.getPeer().isPenalized(portId) ) { + + if (connection != null && connection.getPeer().isPenalized(portId)) { // we have a connection, but it's penalized. We want to add it back to the queue // when we've found one to use. addBack.add(connection); continue; } - + // if we can't get an existing Connection, create one - if ( connection == null ) { + if (connection == null) { logger.debug("{} No Connection available for Port {}; creating new Connection", this, portId); protocol = new SocketClientProtocol(); protocol.setDestination(new IdEnrichedRemoteDestination(remoteDestination, portId)); @@ -304,7 +302,7 @@ public class EndpointConnectionPool { penalize(peerStatus.getPeerDescription(), penalizationMillis); throw ioe; } - + final DataInputStream dis = new DataInputStream(commsSession.getInput().getInputStream()); final DataOutputStream dos = new DataOutputStream(commsSession.getOutput().getOutputStream()); try { @@ -314,72 +312,72 @@ public class EndpointConnectionPool { try { commsSession.close(); } catch (final IOException ioe) { - throw e; + throw e; } } - + final String peerUrl = "nifi://" + peerDescription.getHostname() + ":" + peerDescription.getPort(); peer = new Peer(peerDescription, commsSession, peerUrl, clusterUrl.toString()); - + // set properties based on config - if ( config != null ) { + if (config != null) { protocol.setTimeout((int) config.getTimeout(TimeUnit.MILLISECONDS)); protocol.setPreferredBatchCount(config.getPreferredBatchCount()); protocol.setPreferredBatchSize(config.getPreferredBatchSize()); protocol.setPreferredBatchDuration(config.getPreferredBatchDuration(TimeUnit.MILLISECONDS)); } - + // perform handshake try { logger.debug("{} performing handshake", this); protocol.handshake(peer); - + // handle error cases - if ( protocol.isDestinationFull() ) { - logger.warn("{} {} indicates that port {}'s destination is full; penalizing peer", - this, peer, config.getPortName() == null ? config.getPortIdentifier() : config.getPortName()); - + if (protocol.isDestinationFull()) { + logger.warn("{} {} indicates that port {}'s destination is full; penalizing peer", + this, peer, config.getPortName() == null ? config.getPortIdentifier() : config.getPortName()); + penalize(peer, penalizationMillis); try { - peer.close(); + peer.close(); } catch (final IOException ioe) { } - + continue; - } else if ( protocol.isPortInvalid() ) { - penalize(peer, penalizationMillis); - cleanup(protocol, peer); - throw new PortNotRunningException(peer.toString() + " indicates that port " + portId + " is not running"); - } else if ( protocol.isPortUnknown() ) { - penalize(peer, penalizationMillis); - cleanup(protocol, peer); - throw new UnknownPortException(peer.toString() + " indicates that port " + portId + " is not known"); + } else if (protocol.isPortInvalid()) { + penalize(peer, penalizationMillis); + cleanup(protocol, peer); + throw new PortNotRunningException(peer.toString() + " indicates that port " + portId + " is not running"); + } else if (protocol.isPortUnknown()) { + penalize(peer, penalizationMillis); + cleanup(protocol, peer); + throw new UnknownPortException(peer.toString() + " indicates that port " + portId + " is not known"); } - + // negotiate the FlowFileCodec to use logger.debug("{} negotiating codec", this); codec = protocol.negotiateCodec(peer); logger.debug("{} negotiated codec is {}", this, codec); } catch (final PortNotRunningException | UnknownPortException e) { - throw e; + throw e; } catch (final Exception e) { penalize(peer, penalizationMillis); cleanup(protocol, peer); - + final String message = String.format("%s failed to communicate with %s due to %s", this, peer == null ? clusterUrl : peer, e.toString()); error(message); - if ( logger.isDebugEnabled() ) { + if (logger.isDebugEnabled()) { logger.error("", e); } throw e; } - + connection = new EndpointConnection(peer, protocol, codec); } else { final long lastTimeUsed = connection.getLastTimeUsed(); final long millisSinceLastUse = System.currentTimeMillis() - lastTimeUsed; - - if ( commsTimeout > 0L && millisSinceLastUse >= commsTimeout ) { + + if (commsTimeout > 0L && millisSinceLastUse >= commsTimeout) { cleanup(connection.getSocketClientProtocol(), connection.getPeer()); connection = null; } else { @@ -389,68 +387,70 @@ public class EndpointConnectionPool { protocol = connection.getSocketClientProtocol(); } } - } while ( connection == null || codec == null || commsSession == null || protocol == null ); + } while (connection == null || codec == null || commsSession == null || protocol == null); } catch (final Throwable t) { - if ( commsSession != null ) { - try { - commsSession.close(); - } catch (final IOException ioe) { - } - } - - throw t; + if (commsSession != null) { + try { + commsSession.close(); + } catch (final IOException ioe) { + } + } + + throw t; } finally { - if ( !addBack.isEmpty() ) { + if (!addBack.isEmpty()) { connectionQueue.addAll(addBack); } } - + activeConnections.add(connection); return connection; } - - + public boolean offer(final EndpointConnection endpointConnection) { - final Peer peer = endpointConnection.getPeer(); - if ( peer == null ) { - return false; - } - - final BlockingQueue connectionQueue = connectionQueueMap.get(peer.getDescription()); - if ( connectionQueue == null ) { - return false; - } - - activeConnections.remove(endpointConnection); - if ( shutdown ) { - terminate(endpointConnection); - return false; - } else { - endpointConnection.setLastTimeUsed(); - return connectionQueue.offer(endpointConnection); - } + final Peer peer = endpointConnection.getPeer(); + if (peer == null) { + return false; + } + + final BlockingQueue connectionQueue = connectionQueueMap.get(peer.getDescription()); + if (connectionQueue == null) { + return false; + } + + activeConnections.remove(endpointConnection); + if (shutdown) { + terminate(endpointConnection); + return false; + } else { + endpointConnection.setLastTimeUsed(); + return connectionQueue.offer(endpointConnection); + } } - + private void penalize(final PeerDescription peerDescription, final long penalizationMillis) { Long expiration = peerTimeoutExpirations.get(peerDescription); - if ( expiration == null ) { + if (expiration == null) { expiration = Long.valueOf(0L); } - + final long newExpiration = Math.max(expiration, System.currentTimeMillis() + penalizationMillis); peerTimeoutExpirations.put(peerDescription, Long.valueOf(newExpiration)); } - + /** - * Updates internal state map to penalize a PeerStatus that points to the specified peer - * @param peer + * Updates internal state map to penalize a PeerStatus that points to the + * specified peer + * + * @param peer the peer + * @param penalizationMillis period of time to penalize a given peer */ public void penalize(final Peer peer, final long penalizationMillis) { penalize(peer.getDescription(), penalizationMillis); } - + private void cleanup(final SocketClientProtocol protocol, final Peer peer) { - if ( protocol != null && peer != null ) { + if (protocol != null && peer != null) { try { protocol.shutdown(peer); } catch (final TransmissionDisabledException e) { @@ -459,8 +459,8 @@ public class EndpointConnectionPool { } catch (IOException e1) { } } - - if ( peer != null ) { + + if (peer != null) { try { peer.close(); } catch (final TransmissionDisabledException e) { @@ -470,15 +470,14 @@ public class EndpointConnectionPool { } } } - + private boolean isPeerRefreshNeeded(final List peerList) { return (peerList == null || peerList.isEmpty() || System.currentTimeMillis() > peerRefreshTime + PEER_REFRESH_PERIOD); } - - + private PeerStatus getNextPeerStatus(final TransferDirection direction) { List peerList = peerStatuses; - if ( isPeerRefreshNeeded(peerList) ) { + if (isPeerRefreshNeeded(peerList)) { peerRefreshLock.lock(); try { // now that we have the lock, check again that we need to refresh (because another thread @@ -490,15 +489,15 @@ public class EndpointConnectionPool { } catch (final Exception e) { final String message = String.format("%s Failed to update list of peers due to %s", this, e.toString()); warn(message); - if ( logger.isDebugEnabled() ) { + if (logger.isDebugEnabled()) { logger.warn("", e); } - - if ( eventReporter != null ) { - eventReporter.reportEvent(Severity.WARNING, CATEGORY, message); + + if (eventReporter != null) { + eventReporter.reportEvent(Severity.WARNING, CATEGORY, message); } } - + this.peerStatuses = peerList; peerRefreshTime = System.currentTimeMillis(); } @@ -507,46 +506,46 @@ public class EndpointConnectionPool { } } - if ( peerList == null || peerList.isEmpty() ) { + if (peerList == null || peerList.isEmpty()) { return null; } PeerStatus peerStatus; - for (int i=0; i < peerList.size(); i++) { + for (int i = 0; i < peerList.size(); i++) { final long idx = peerIndex.getAndIncrement(); final int listIndex = (int) (idx % peerList.size()); peerStatus = peerList.get(listIndex); - - if ( isPenalized(peerStatus) ) { + + if (isPenalized(peerStatus)) { logger.debug("{} {} is penalized; will not communicate with this peer", this, peerStatus); } else { return peerStatus; } } - + logger.debug("{} All peers appear to be penalized; returning null", this); return null; } - + private boolean isPenalized(final PeerStatus peerStatus) { final Long expirationEnd = peerTimeoutExpirations.get(peerStatus.getPeerDescription()); - return (expirationEnd == null ? false : expirationEnd > System.currentTimeMillis() ); + return (expirationEnd == null ? false : expirationEnd > System.currentTimeMillis()); } - + private List createPeerStatusList(final TransferDirection direction) throws IOException, HandshakeException, UnknownPortException, PortNotRunningException { Set statuses = getPeerStatuses(); - if ( statuses == null ) { + if (statuses == null) { refreshPeers(); statuses = getPeerStatuses(); - if ( statuses == null ) { + if (statuses == null) { logger.debug("{} found no peers to connect to", this); return Collections.emptyList(); } } - + final ClusterNodeInformation clusterNodeInfo = new ClusterNodeInformation(); final List nodeInfos = new ArrayList<>(); - for ( final PeerStatus peerStatus : statuses ) { + for (final PeerStatus peerStatus : statuses) { final PeerDescription description = peerStatus.getPeerDescription(); final NodeInformation nodeInfo = new NodeInformation(description.getHostname(), description.getPort(), 0, description.isSecure(), peerStatus.getFlowFileCount()); nodeInfos.add(nodeInfo); @@ -554,8 +553,7 @@ public class EndpointConnectionPool { clusterNodeInfo.setNodeInformation(nodeInfos); return formulateDestinationList(clusterNodeInfo, direction); } - - + private Set getPeerStatuses() { final PeerStatusCache cache = this.peerStatusCache; if (cache == null || cache.getStatuses() == null || cache.getStatuses().isEmpty()) { @@ -576,14 +574,14 @@ public class EndpointConnectionPool { } private Set fetchRemotePeerStatuses() throws IOException, HandshakeException, UnknownPortException, PortNotRunningException { - final String hostname = clusterUrl.getHost(); + final String hostname = clusterUrl.getHost(); final Integer port = getSiteToSitePort(); - if ( port == null ) { + if (port == null) { throw new IOException("Remote instance of NiFi is not configured to allow site-to-site communications"); } - + final PeerDescription clusterPeerDescription = new PeerDescription(hostname, port, clusterUrl.toString().startsWith("https://")); - final CommunicationsSession commsSession = establishSiteToSiteConnection(hostname, port); + final CommunicationsSession commsSession = establishSiteToSiteConnection(hostname, port); final Peer peer = new Peer(clusterPeerDescription, commsSession, "nifi://" + hostname + ":" + port, clusterUrl.toString()); final SocketClientProtocol clientProtocol = new SocketClientProtocol(); final DataInputStream dis = new DataInputStream(commsSession.getInput().getInputStream()); @@ -593,11 +591,11 @@ public class EndpointConnectionPool { clientProtocol.setTimeout(commsTimeout); if (clientProtocol.getVersionNegotiator().getVersion() < 5) { String portId = getPortIdentifier(TransferDirection.RECEIVE); - if ( portId == null ) { + if (portId == null) { portId = getPortIdentifier(TransferDirection.SEND); } - - if ( portId == null ) { + + if (portId == null) { peer.close(); throw new IOException("Failed to determine the identifier of port " + remoteDestination.getName()); } @@ -605,7 +603,7 @@ public class EndpointConnectionPool { } else { clientProtocol.handshake(peer, null); } - + final Set peerStatuses = clientProtocol.getPeerStatuses(peer); persistPeerStatuses(peerStatuses); @@ -632,14 +630,13 @@ public class EndpointConnectionPool { return peerStatuses; } - private void persistPeerStatuses(final Set statuses) { - if ( peersFile == null ) { - return; - } - + if (peersFile == null) { + return; + } + try (final OutputStream fos = new FileOutputStream(peersFile); - final OutputStream out = new BufferedOutputStream(fos)) { + final OutputStream out = new BufferedOutputStream(fos)) { for (final PeerStatus status : statuses) { final PeerDescription description = status.getPeerDescription(); @@ -679,53 +676,52 @@ public class EndpointConnectionPool { return statuses; } - - + private CommunicationsSession establishSiteToSiteConnection(final PeerStatus peerStatus) throws IOException { final PeerDescription description = peerStatus.getPeerDescription(); - return establishSiteToSiteConnection(description.getHostname(), description.getPort()); + return establishSiteToSiteConnection(description.getHostname(), description.getPort()); } - + private CommunicationsSession establishSiteToSiteConnection(final String hostname, final int port) throws IOException { - final boolean siteToSiteSecure = isSecure(); + final boolean siteToSiteSecure = isSecure(); final String destinationUri = "nifi://" + hostname + ":" + port; CommunicationsSession commsSession = null; try { - if ( siteToSiteSecure ) { - if ( sslContext == null ) { - throw new IOException("Unable to communicate with " + hostname + ":" + port + " because it requires Secure Site-to-Site communications, but this instance is not configured for secure communications"); - } - - final SSLSocketChannel socketChannel = new SSLSocketChannel(sslContext, hostname, port, true); - socketChannel.connect(); - - commsSession = new SSLSocketChannelCommunicationsSession(socketChannel, destinationUri); - - try { - commsSession.setUserDn(socketChannel.getDn()); - } catch (final CertificateNotYetValidException | CertificateExpiredException ex) { - throw new IOException(ex); - } - } else { - final SocketChannel socketChannel = SocketChannel.open(new InetSocketAddress(hostname, port)); - commsSession = new SocketChannelCommunicationsSession(socketChannel, destinationUri); - } - - commsSession.getOutput().getOutputStream().write(CommunicationsSession.MAGIC_BYTES); - commsSession.setUri(destinationUri); + if (siteToSiteSecure) { + if (sslContext == null) { + throw new IOException("Unable to communicate with " + hostname + ":" + port + + " because it requires Secure Site-to-Site communications, but this instance is not configured for secure communications"); + } + + final SSLSocketChannel socketChannel = new SSLSocketChannel(sslContext, hostname, port, true); + socketChannel.connect(); + + commsSession = new SSLSocketChannelCommunicationsSession(socketChannel, destinationUri); + + try { + commsSession.setUserDn(socketChannel.getDn()); + } catch (final CertificateNotYetValidException | CertificateExpiredException ex) { + throw new IOException(ex); + } + } else { + final SocketChannel socketChannel = SocketChannel.open(new InetSocketAddress(hostname, port)); + commsSession = new SocketChannelCommunicationsSession(socketChannel, destinationUri); + } + + commsSession.getOutput().getOutputStream().write(CommunicationsSession.MAGIC_BYTES); + commsSession.setUri(destinationUri); } catch (final IOException ioe) { - if ( commsSession != null ) { + if (commsSession != null) { commsSession.close(); } - + throw ioe; } - + return commsSession; } - - + static List formulateDestinationList(final ClusterNodeInformation clusterNodeInfo, final TransferDirection direction) { final Collection nodeInfoSet = clusterNodeInfo.getNodeInformation(); final int numDestinations = Math.max(128, nodeInfoSet.size()); @@ -743,26 +739,26 @@ public class EndpointConnectionPool { final double percentageOfFlowFiles = Math.min(0.8D, ((double) flowFileCount / (double) totalFlowFileCount)); final double relativeWeighting = (direction == TransferDirection.SEND) ? (1 - percentageOfFlowFiles) : percentageOfFlowFiles; final int entries = Math.max(1, (int) (numDestinations * relativeWeighting)); - + entryCountMap.put(nodeInfo, Math.max(1, entries)); totalEntries += entries; } - + final List destinations = new ArrayList<>(totalEntries); - for (int i=0; i < totalEntries; i++) { + for (int i = 0; i < totalEntries; i++) { destinations.add(null); } - for ( final Map.Entry entry : entryCountMap.entrySet() ) { + for (final Map.Entry entry : entryCountMap.entrySet()) { final NodeInformation nodeInfo = entry.getKey(); final int numEntries = entry.getValue(); - + int skipIndex = numEntries; - for (int i=0; i < numEntries; i++) { + for (int i = 0; i < numEntries; i++) { int n = (skipIndex * i); while (true) { final int index = n % destinations.size(); PeerStatus status = destinations.get(index); - if ( status == null ) { + if (status == null) { final PeerDescription description = new PeerDescription(nodeInfo.getHostname(), nodeInfo.getSiteToSitePort(), nodeInfo.isSiteToSiteSecure()); status = new PeerStatus(description, nodeInfo.getTotalFlowFiles()); destinations.set(index, status); @@ -776,7 +772,7 @@ public class EndpointConnectionPool { final StringBuilder distributionDescription = new StringBuilder(); distributionDescription.append("New Weighted Distribution of Nodes:"); - for ( final Map.Entry entry : entryCountMap.entrySet() ) { + for (final Map.Entry entry : entryCountMap.entrySet()) { final double percentage = entry.getValue() * 100D / (double) destinations.size(); distributionDescription.append("\n").append(entry.getKey()).append(" will receive ").append(percentage).append("% of data"); } @@ -785,55 +781,54 @@ public class EndpointConnectionPool { // Jumble the list of destinations. return destinations; } - - + private void cleanupExpiredSockets() { - for ( final BlockingQueue connectionQueue : connectionQueueMap.values()) { + for (final BlockingQueue connectionQueue : connectionQueueMap.values()) { final List connections = new ArrayList<>(); - + EndpointConnection connection; while ((connection = connectionQueue.poll()) != null) { // If the socket has not been used in 10 seconds, shut it down. final long lastUsed = connection.getLastTimeUsed(); - if ( lastUsed < System.currentTimeMillis() - idleExpirationMillis ) { + if (lastUsed < System.currentTimeMillis() - idleExpirationMillis) { try { connection.getSocketClientProtocol().shutdown(connection.getPeer()); } catch (final Exception e) { - logger.debug("Failed to shut down {} using {} due to {}", - new Object[] {connection.getSocketClientProtocol(), connection.getPeer(), e} ); + logger.debug("Failed to shut down {} using {} due to {}", + new Object[]{connection.getSocketClientProtocol(), connection.getPeer(), e}); } - + terminate(connection); } else { connections.add(connection); } } - + connectionQueue.addAll(connections); } } - + public void shutdown() { shutdown = true; - taskExecutor.shutdown(); - peerTimeoutExpirations.clear(); - - for ( final EndpointConnection conn : activeConnections ) { - conn.getPeer().getCommunicationsSession().interrupt(); + taskExecutor.shutdown(); + peerTimeoutExpirations.clear(); + + for (final EndpointConnection conn : activeConnections) { + conn.getPeer().getCommunicationsSession().interrupt(); } - for ( final BlockingQueue connectionQueue : connectionQueueMap.values() ) { + for (final BlockingQueue connectionQueue : connectionQueueMap.values()) { EndpointConnection state; - while ( (state = connectionQueue.poll()) != null) { + while ((state = connectionQueue.poll()) != null) { cleanup(state.getSocketClientProtocol(), state.getPeer()); } } } - + public void terminate(final EndpointConnection connection) { cleanup(connection.getSocketClientProtocol(), connection.getPeer()); } - + private void refreshPeers() { final PeerStatusCache existingCache = peerStatusCache; if (existingCache != null && (existingCache.getTimestamp() + PEER_CACHE_MILLIS > System.currentTimeMillis())) { @@ -851,69 +846,66 @@ public class EndpointConnectionPool { } } } - - + public String getInputPortIdentifier(final String portName) throws IOException { return getPortIdentifier(portName, inputPortMap); } - + public String getOutputPortIdentifier(final String portName) throws IOException { - return getPortIdentifier(portName, outputPortMap); + return getPortIdentifier(portName, outputPortMap); } - - + private String getPortIdentifier(final String portName, final Map portMap) throws IOException { - String identifier; - remoteInfoReadLock.lock(); + String identifier; + remoteInfoReadLock.lock(); try { - identifier = portMap.get(portName); + identifier = portMap.get(portName); } finally { - remoteInfoReadLock.unlock(); + remoteInfoReadLock.unlock(); } - - if ( identifier != null ) { - return identifier; + + if (identifier != null) { + return identifier; } - + refreshRemoteInfo(); - remoteInfoReadLock.lock(); + remoteInfoReadLock.lock(); try { - return portMap.get(portName); + return portMap.get(portName); } finally { - remoteInfoReadLock.unlock(); + remoteInfoReadLock.unlock(); } } - - + private ControllerDTO refreshRemoteInfo() throws IOException { - final boolean webInterfaceSecure = clusterUrl.toString().startsWith("https"); + final boolean webInterfaceSecure = clusterUrl.toString().startsWith("https"); final NiFiRestApiUtil utils = new NiFiRestApiUtil(webInterfaceSecure ? sslContext : null); - final ControllerDTO controller = utils.getController(apiUri + "/controller", commsTimeout); - + final ControllerDTO controller = utils.getController(apiUri + "/controller", commsTimeout); + remoteInfoWriteLock.lock(); try { this.siteToSitePort = controller.getRemoteSiteListeningPort(); this.siteToSiteSecure = controller.isSiteToSiteSecure(); - + inputPortMap.clear(); for (final PortDTO inputPort : controller.getInputPorts()) { - inputPortMap.put(inputPort.getName(), inputPort.getId()); + inputPortMap.put(inputPort.getName(), inputPort.getId()); } - + outputPortMap.clear(); - for ( final PortDTO outputPort : controller.getOutputPorts()) { - outputPortMap.put(outputPort.getName(), outputPort.getId()); + for (final PortDTO outputPort : controller.getOutputPorts()) { + outputPortMap.put(outputPort.getName(), outputPort.getId()); } - + this.remoteRefreshTime = System.currentTimeMillis(); } finally { - remoteInfoWriteLock.unlock(); + remoteInfoWriteLock.unlock(); } - + return controller; } - + /** * @return the port that the remote instance is listening on for * site-to-site communication, or null if the remote instance @@ -930,7 +922,7 @@ public class EndpointConnectionPool { return listeningPort; } } finally { - remoteInfoReadLock.unlock(); + remoteInfoReadLock.unlock(); } final ControllerDTO controller = refreshRemoteInfo(); @@ -938,19 +930,16 @@ public class EndpointConnectionPool { return listeningPort; } - + @Override public String toString() { return "EndpointConnectionPool[Cluster URL=" + clusterUrl + "]"; } - - + /** - * Returns {@code true} if the remote instance is configured for secure site-to-site communications, - * {@code false} otherwise. - * - * @return - * @throws IOException + * @return {@code true} if the remote instance is configured for secure + * site-to-site communications, {@code false} otherwise + * @throws IOException if unable to check if secure */ public boolean isSecure() throws IOException { remoteInfoReadLock.lock(); @@ -960,23 +949,23 @@ public class EndpointConnectionPool { return secure; } } finally { - remoteInfoReadLock.unlock(); + remoteInfoReadLock.unlock(); } final ControllerDTO controller = refreshRemoteInfo(); final Boolean isSecure = controller.isSiteToSiteSecure(); - if ( isSecure == null ) { + if (isSecure == null) { throw new IOException("Remote NiFi instance " + clusterUrl + " is not currently configured to accept site-to-site connections"); } - + return isSecure; } - - + private class IdEnrichedRemoteDestination implements RemoteDestination { + private final RemoteDestination original; private final String identifier; - + public IdEnrichedRemoteDestination(final RemoteDestination original, final String identifier) { this.original = original; this.identifier = identifier; diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/client/socket/SocketClient.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/client/socket/SocketClient.java index 4aab3f7f8e..33e4a6609a 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/client/socket/SocketClient.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/client/socket/SocketClient.java @@ -33,71 +33,71 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SocketClient implements SiteToSiteClient { + private static final Logger logger = LoggerFactory.getLogger(SocketClient.class); - + private final SiteToSiteClientConfig config; - private final EndpointConnectionPool pool; - private final boolean compress; - private final String portName; - private final long penalizationNanos; - private volatile String portIdentifier; - private volatile boolean closed = false; - - public SocketClient(final SiteToSiteClientConfig config) { - pool = new EndpointConnectionPool(config.getUrl(), - createRemoteDestination(config.getPortIdentifier(), config.getPortName()), - (int) config.getTimeout(TimeUnit.MILLISECONDS), - (int) config.getIdleConnectionExpiration(TimeUnit.MILLISECONDS), - config.getSslContext(), config.getEventReporter(), config.getPeerPersistenceFile()); - - this.config = config; - this.compress = config.isUseCompression(); - this.portIdentifier = config.getPortIdentifier(); - this.portName = config.getPortName(); - this.penalizationNanos = config.getPenalizationPeriod(TimeUnit.NANOSECONDS); - } - - @Override - public SiteToSiteClientConfig getConfig() { - return config; - } - - @Override - public boolean isSecure() throws IOException { - return pool.isSecure(); - } - - private String getPortIdentifier(final TransferDirection direction) throws IOException { - final String id = this.portIdentifier; - if ( id != null ) { - return id; - } - - final String portId; - if ( direction == TransferDirection.SEND ) { - portId = pool.getInputPortIdentifier(this.portName); - } else { - portId = pool.getOutputPortIdentifier(this.portName); - } - - if (portId == null) { - logger.debug("Unable to resolve port [{}] to an identifier", portName); - } else { - logger.debug("Resolved port [{}] to identifier [{}]", portName, portId); - this.portIdentifier = portId; - } - - return portId; - } - - - private RemoteDestination createRemoteDestination(final String portId, final String portName) { - return new RemoteDestination() { + private final EndpointConnectionPool pool; + private final boolean compress; + private final String portName; + private final long penalizationNanos; + private volatile String portIdentifier; + private volatile boolean closed = false; + + public SocketClient(final SiteToSiteClientConfig config) { + pool = new EndpointConnectionPool(config.getUrl(), + createRemoteDestination(config.getPortIdentifier(), config.getPortName()), + (int) config.getTimeout(TimeUnit.MILLISECONDS), + (int) config.getIdleConnectionExpiration(TimeUnit.MILLISECONDS), + config.getSslContext(), config.getEventReporter(), config.getPeerPersistenceFile()); + + this.config = config; + this.compress = config.isUseCompression(); + this.portIdentifier = config.getPortIdentifier(); + this.portName = config.getPortName(); + this.penalizationNanos = config.getPenalizationPeriod(TimeUnit.NANOSECONDS); + } + + @Override + public SiteToSiteClientConfig getConfig() { + return config; + } + + @Override + public boolean isSecure() throws IOException { + return pool.isSecure(); + } + + private String getPortIdentifier(final TransferDirection direction) throws IOException { + final String id = this.portIdentifier; + if (id != null) { + return id; + } + + final String portId; + if (direction == TransferDirection.SEND) { + portId = pool.getInputPortIdentifier(this.portName); + } else { + portId = pool.getOutputPortIdentifier(this.portName); + } + + if (portId == null) { + logger.debug("Unable to resolve port [{}] to an identifier", portName); + } else { + logger.debug("Resolved port [{}] to identifier [{}]", portName, portId); + this.portIdentifier = portId; + } + + return portId; + } + + private RemoteDestination createRemoteDestination(final String portId, final String portName) { + return new RemoteDestination() { @Override public String getIdentifier() { return portId; } - + @Override public String getName() { return portName; @@ -113,113 +113,112 @@ public class SocketClient implements SiteToSiteClient { return compress; } }; - } - - @Override - public Transaction createTransaction(final TransferDirection direction) throws IOException { - if ( closed ) { - throw new IllegalStateException("Client is closed"); - } - final String portId = getPortIdentifier(direction); - - if ( portId == null ) { - throw new IOException("Could not find Port with name '" + portName + "' for remote NiFi instance"); - } - - final EndpointConnection connectionState = pool.getEndpointConnection(direction, getConfig()); - if ( connectionState == null ) { - return null; - } - - final Transaction transaction; - try { - transaction = connectionState.getSocketClientProtocol().startTransaction( - connectionState.getPeer(), connectionState.getCodec(), direction); - } catch (final Throwable t) { - pool.terminate(connectionState); - throw new IOException("Unable to create Transaction to communicate with " + connectionState.getPeer(), t); - } - - // Wrap the transaction in a new one that will return the EndpointConnectionState back to the pool whenever - // the transaction is either completed or canceled. - final ObjectHolder connectionStateRef = new ObjectHolder<>(connectionState); - return new Transaction() { - @Override - public void confirm() throws IOException { - transaction.confirm(); - } + } - @Override - public TransactionCompletion complete() throws IOException { - try { - return transaction.complete(); - } finally { - final EndpointConnection state = connectionStateRef.get(); - if ( state != null ) { - pool.offer(connectionState); - connectionStateRef.set(null); - } - } - } + @Override + public Transaction createTransaction(final TransferDirection direction) throws IOException { + if (closed) { + throw new IllegalStateException("Client is closed"); + } + final String portId = getPortIdentifier(direction); - @Override - public void cancel(final String explanation) throws IOException { - try { - transaction.cancel(explanation); - } finally { + if (portId == null) { + throw new IOException("Could not find Port with name '" + portName + "' for remote NiFi instance"); + } + + final EndpointConnection connectionState = pool.getEndpointConnection(direction, getConfig()); + if (connectionState == null) { + return null; + } + + final Transaction transaction; + try { + transaction = connectionState.getSocketClientProtocol().startTransaction( + connectionState.getPeer(), connectionState.getCodec(), direction); + } catch (final Throwable t) { + pool.terminate(connectionState); + throw new IOException("Unable to create Transaction to communicate with " + connectionState.getPeer(), t); + } + + // Wrap the transaction in a new one that will return the EndpointConnectionState back to the pool whenever + // the transaction is either completed or canceled. + final ObjectHolder connectionStateRef = new ObjectHolder<>(connectionState); + return new Transaction() { + @Override + public void confirm() throws IOException { + transaction.confirm(); + } + + @Override + public TransactionCompletion complete() throws IOException { + try { + return transaction.complete(); + } finally { final EndpointConnection state = connectionStateRef.get(); - if ( state != null ) { + if (state != null) { + pool.offer(connectionState); + connectionStateRef.set(null); + } + } + } + + @Override + public void cancel(final String explanation) throws IOException { + try { + transaction.cancel(explanation); + } finally { + final EndpointConnection state = connectionStateRef.get(); + if (state != null) { pool.terminate(connectionState); connectionStateRef.set(null); } - } - } + } + } - @Override - public void error() { - try { - transaction.error(); - } finally { + @Override + public void error() { + try { + transaction.error(); + } finally { final EndpointConnection state = connectionStateRef.get(); - if ( state != null ) { + if (state != null) { pool.terminate(connectionState); connectionStateRef.set(null); } - } - } - - @Override - public void send(final DataPacket dataPacket) throws IOException { - transaction.send(dataPacket); - } + } + } - @Override - public void send(final byte[] content, final Map attributes) throws IOException { - transaction.send(content, attributes); - } - - @Override - public DataPacket receive() throws IOException { - return transaction.receive(); - } + @Override + public void send(final DataPacket dataPacket) throws IOException { + transaction.send(dataPacket); + } - @Override - public TransactionState getState() throws IOException { - return transaction.getState(); - } + @Override + public void send(final byte[] content, final Map attributes) throws IOException { + transaction.send(content, attributes); + } - @Override - public Communicant getCommunicant() { - return transaction.getCommunicant(); - } - }; - } + @Override + public DataPacket receive() throws IOException { + return transaction.receive(); + } + + @Override + public TransactionState getState() throws IOException { + return transaction.getState(); + } + + @Override + public Communicant getCommunicant() { + return transaction.getCommunicant(); + } + }; + } + + @Override + public void close() throws IOException { + closed = true; + pool.shutdown(); + } - - @Override - public void close() throws IOException { - closed = true; - pool.shutdown(); - } - } diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/codec/FlowFileCodec.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/codec/FlowFileCodec.java index 1380e1b50f..e79fc470f9 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/codec/FlowFileCodec.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/codec/FlowFileCodec.java @@ -38,13 +38,13 @@ public interface FlowFileCodec extends VersionedRemoteResource { * Returns a List of all versions that this codec is able to support, in the * order that they are preferred by the codec * - * @return + * @return all supported versions */ public List getSupportedVersions(); /** - * Encodes a DataPacket and its content as a single stream of data and writes - * that stream to the output. + * Encodes a DataPacket and its content as a single stream of data and + * writes that stream to the output. * * @param dataPacket the data to serialize * @param outStream the stream to write the data to @@ -58,12 +58,13 @@ public interface FlowFileCodec extends VersionedRemoteResource { * Decodes the contents of the InputStream, interpreting the data to * determine the next DataPacket's attributes and content. * - * @param stream an InputStream containing DataPacket's content and attributes + * @param stream an InputStream containing DataPacket's content and + * attributes * - * @return the DataPacket that was created, or null if the stream - * was out of data + * @return the DataPacket that was created, or null if the + * stream was out of data * - * @throws IOException + * @throws IOException if unable to read stream * @throws ProtocolException if the input is malformed * @throws TransmissionDisabledException if a user terminates the connection */ diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/codec/StandardFlowFileCodec.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/codec/StandardFlowFileCodec.java index 6fd92de266..0bee537e07 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/codec/StandardFlowFileCodec.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/codec/StandardFlowFileCodec.java @@ -34,7 +34,8 @@ import org.apache.nifi.remote.util.StandardDataPacket; import org.apache.nifi.stream.io.StreamUtils; public class StandardFlowFileCodec implements FlowFileCodec { - public static final int MAX_NUM_ATTRIBUTES = 25000; + + public static final int MAX_NUM_ATTRIBUTES = 25000; public static final String DEFAULT_FLOWFILE_PATH = "./"; @@ -43,30 +44,29 @@ public class StandardFlowFileCodec implements FlowFileCodec { public StandardFlowFileCodec() { versionNegotiator = new StandardVersionNegotiator(1); } - + @Override public void encode(final DataPacket dataPacket, final OutputStream encodedOut) throws IOException { final DataOutputStream out = new DataOutputStream(encodedOut); - + final Map attributes = dataPacket.getAttributes(); out.writeInt(attributes.size()); - for ( final Map.Entry entry : attributes.entrySet() ) { + for (final Map.Entry entry : attributes.entrySet()) { writeString(entry.getKey(), out); writeString(entry.getValue(), out); } - + out.writeLong(dataPacket.getSize()); - + final InputStream in = dataPacket.getData(); StreamUtils.copy(in, encodedOut); encodedOut.flush(); } - @Override public DataPacket decode(final InputStream stream) throws IOException, ProtocolException { final DataInputStream in = new DataInputStream(stream); - + final int numAttributes; try { numAttributes = in.readInt(); @@ -74,22 +74,22 @@ public class StandardFlowFileCodec implements FlowFileCodec { // we're out of data. return null; } - + // This is here because if the stream is not properly formed, we could get up to Integer.MAX_VALUE attributes, which will // generally result in an OutOfMemoryError. - if ( numAttributes > MAX_NUM_ATTRIBUTES ) { - throw new ProtocolException("FlowFile exceeds maximum number of attributes with a total of " + numAttributes); + if (numAttributes > MAX_NUM_ATTRIBUTES) { + throw new ProtocolException("FlowFile exceeds maximum number of attributes with a total of " + numAttributes); } - + final Map attributes = new HashMap<>(numAttributes); - for (int i=0; i < numAttributes; i++) { + for (int i = 0; i < numAttributes; i++) { final String attrName = readString(in); final String attrValue = readString(in); attributes.put(attrName, attrValue); } - + final long numBytes = in.readLong(); - + return new StandardDataPacket(attributes, stream, numBytes); } @@ -99,14 +99,13 @@ public class StandardFlowFileCodec implements FlowFileCodec { out.write(bytes); } - private String readString(final DataInputStream in) throws IOException { final int numBytes = in.readInt(); final byte[] bytes = new byte[numBytes]; StreamUtils.fillBuffer(in, bytes, true); return new String(bytes, "UTF-8"); } - + @Override public List getSupportedVersions() { return versionNegotiator.getSupportedVersions(); diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/exception/HandshakeException.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/exception/HandshakeException.java index d4d55e18c0..198aaefb26 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/exception/HandshakeException.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/exception/HandshakeException.java @@ -18,13 +18,14 @@ package org.apache.nifi.remote.exception; import java.io.IOException; - /** - * A HandshakeException occurs when the client and the remote NiFi instance do not agree - * on some condition during the handshake. For example, if the NiFi instance does not recognize - * one of the parameters that the client passes during the Handshaking phase. + * A HandshakeException occurs when the client and the remote NiFi instance do + * not agree on some condition during the handshake. For example, if the NiFi + * instance does not recognize one of the parameters that the client passes + * during the Handshaking phase. */ public class HandshakeException extends IOException { + private static final long serialVersionUID = 178192341908726L; public HandshakeException(final String message) { diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/exception/PortNotRunningException.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/exception/PortNotRunningException.java index 8b97832466..09fc05c046 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/exception/PortNotRunningException.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/exception/PortNotRunningException.java @@ -17,11 +17,12 @@ package org.apache.nifi.remote.exception; /** - * PortNotRunningException occurs when the remote NiFi instance reports - * that the Port that the client is attempting to communicate with is not - * currently running and therefore communications with that Port are not allowed. + * PortNotRunningException occurs when the remote NiFi instance reports that the + * Port that the client is attempting to communicate with is not currently + * running and therefore communications with that Port are not allowed. */ public class PortNotRunningException extends ProtocolException { + private static final long serialVersionUID = -2790940982005516375L; public PortNotRunningException(final String message) { diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/exception/ProtocolException.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/exception/ProtocolException.java index 45a4e15e57..cc6ae5026f 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/exception/ProtocolException.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/exception/ProtocolException.java @@ -19,8 +19,8 @@ package org.apache.nifi.remote.exception; import java.io.IOException; /** - * A ProtocolException occurs when unexpected data is received, for example - * an invalid Response Code. + * A ProtocolException occurs when unexpected data is received, for example an + * invalid Response Code. */ public class ProtocolException extends IOException { diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/exception/UnknownPortException.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/exception/UnknownPortException.java index 592a1b3777..4249075c72 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/exception/UnknownPortException.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/exception/UnknownPortException.java @@ -17,10 +17,12 @@ package org.apache.nifi.remote.exception; /** - * An UnknownPortException indicates that the remote NiFi instance has reported that - * the endpoint that the client attempted to communicate with does not exist. + * An UnknownPortException indicates that the remote NiFi instance has reported + * that the endpoint that the client attempted to communicate with does not + * exist. */ public class UnknownPortException extends ProtocolException { + private static final long serialVersionUID = -2790940982005516375L; public UnknownPortException(final String message) { diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelCommunicationsSession.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelCommunicationsSession.java index 8065f57027..6180c3c409 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelCommunicationsSession.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelCommunicationsSession.java @@ -22,11 +22,12 @@ import java.nio.channels.SocketChannel; import org.apache.nifi.remote.AbstractCommunicationsSession; public class SocketChannelCommunicationsSession extends AbstractCommunicationsSession { + private final SocketChannel channel; private final SocketChannelInput request; private final SocketChannelOutput response; private int timeout = 30000; - + public SocketChannelCommunicationsSession(final SocketChannel socketChannel, final String uri) throws IOException { super(uri); request = new SocketChannelInput(socketChannel); @@ -34,12 +35,12 @@ public class SocketChannelCommunicationsSession extends AbstractCommunicationsSe channel = socketChannel; socketChannel.configureBlocking(false); } - + @Override public boolean isClosed() { return !channel.isConnected(); } - + @Override public SocketChannelInput getInput() { return request; @@ -65,28 +66,28 @@ public class SocketChannelCommunicationsSession extends AbstractCommunicationsSe @Override public void close() throws IOException { IOException suppressed = null; - + try { request.consume(); } catch (final IOException ioe) { suppressed = ioe; } - + try { channel.close(); } catch (final IOException ioe) { - if ( suppressed != null ) { + if (suppressed != null) { ioe.addSuppressed(suppressed); } - + throw ioe; } - - if ( suppressed != null ) { + + if (suppressed != null) { throw suppressed; } } - + @Override public boolean isDataAvailable() { return request.isDataAvailable(); @@ -101,7 +102,7 @@ public class SocketChannelCommunicationsSession extends AbstractCommunicationsSe public long getBytesRead() { return request.getBytesRead(); } - + @Override public void interrupt() { request.interrupt(); diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelInput.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelInput.java index 7dffdddafe..68a8dc4294 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelInput.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelInput.java @@ -26,18 +26,19 @@ import org.apache.nifi.remote.io.InterruptableInputStream; import org.apache.nifi.remote.protocol.CommunicationsInput; public class SocketChannelInput implements CommunicationsInput { + private final SocketChannelInputStream socketIn; private final ByteCountingInputStream countingIn; private final InputStream bufferedIn; private final InterruptableInputStream interruptableIn; - + public SocketChannelInput(final SocketChannel socketChannel) throws IOException { this.socketIn = new SocketChannelInputStream(socketChannel); countingIn = new ByteCountingInputStream(socketIn); bufferedIn = new BufferedInputStream(countingIn); interruptableIn = new InterruptableInputStream(bufferedIn); } - + @Override public InputStream getInputStream() throws IOException { return interruptableIn; @@ -46,7 +47,7 @@ public class SocketChannelInput implements CommunicationsInput { public void setTimeout(final int millis) { socketIn.setTimeout(millis); } - + public boolean isDataAvailable() { try { return interruptableIn.available() > 0; @@ -54,12 +55,12 @@ public class SocketChannelInput implements CommunicationsInput { return false; } } - + @Override public long getBytesRead() { return countingIn.getBytesRead(); } - + public void interrupt() { interruptableIn.interrupt(); } diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelOutput.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelOutput.java index 26c01649b4..13974a590d 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelOutput.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelOutput.java @@ -26,32 +26,33 @@ import org.apache.nifi.remote.io.InterruptableOutputStream; import org.apache.nifi.remote.protocol.CommunicationsOutput; public class SocketChannelOutput implements CommunicationsOutput { + private final SocketChannelOutputStream socketOutStream; private final ByteCountingOutputStream countingOut; private final OutputStream bufferedOut; private final InterruptableOutputStream interruptableOut; - + public SocketChannelOutput(final SocketChannel socketChannel) throws IOException { socketOutStream = new SocketChannelOutputStream(socketChannel); countingOut = new ByteCountingOutputStream(socketOutStream); bufferedOut = new BufferedOutputStream(countingOut); interruptableOut = new InterruptableOutputStream(bufferedOut); } - + @Override public OutputStream getOutputStream() throws IOException { return interruptableOut; } - + public void setTimeout(final int timeout) { socketOutStream.setTimeout(timeout); } - + @Override public long getBytesWritten() { return countingOut.getBytesWritten(); } - + public void interrupt() { interruptableOut.interrupt(); } diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelCommunicationsSession.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelCommunicationsSession.java index 50e916201e..5e5abc7b19 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelCommunicationsSession.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelCommunicationsSession.java @@ -21,17 +21,18 @@ import java.io.IOException; import org.apache.nifi.remote.AbstractCommunicationsSession; public class SSLSocketChannelCommunicationsSession extends AbstractCommunicationsSession { + private final SSLSocketChannel channel; private final SSLSocketChannelInput request; private final SSLSocketChannelOutput response; - + public SSLSocketChannelCommunicationsSession(final SSLSocketChannel channel, final String uri) { super(uri); request = new SSLSocketChannelInput(channel); response = new SSLSocketChannelOutput(channel); this.channel = channel; } - + @Override public SSLSocketChannelInput getInput() { return request; @@ -55,33 +56,33 @@ public class SSLSocketChannelCommunicationsSession extends AbstractCommunication @Override public void close() throws IOException { IOException suppressed = null; - + try { request.consume(); } catch (final IOException ioe) { suppressed = ioe; } - + try { channel.close(); } catch (final IOException ioe) { - if ( suppressed != null ) { + if (suppressed != null) { ioe.addSuppressed(suppressed); } - + throw ioe; } - - if ( suppressed != null ) { + + if (suppressed != null) { throw suppressed; } } - + @Override public boolean isClosed() { return channel.isClosed(); } - + @Override public boolean isDataAvailable() { try { @@ -105,7 +106,7 @@ public class SSLSocketChannelCommunicationsSession extends AbstractCommunication public void interrupt() { channel.interrupt(); } - + @Override public String toString() { return super.toString() + "[SSLSocketChannel=" + channel + "]"; diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelInput.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelInput.java index 01fb9f23ff..6cd234446e 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelInput.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelInput.java @@ -24,25 +24,26 @@ import org.apache.nifi.stream.io.ByteCountingInputStream; import org.apache.nifi.remote.protocol.CommunicationsInput; public class SSLSocketChannelInput implements CommunicationsInput { + private final SSLSocketChannelInputStream in; private final ByteCountingInputStream countingIn; private final InputStream bufferedIn; - + public SSLSocketChannelInput(final SSLSocketChannel socketChannel) { in = new SSLSocketChannelInputStream(socketChannel); countingIn = new ByteCountingInputStream(in); this.bufferedIn = new BufferedInputStream(countingIn); } - + @Override public InputStream getInputStream() throws IOException { return bufferedIn; } - + public boolean isDataAvailable() throws IOException { return bufferedIn.available() > 0; } - + @Override public long getBytesRead() { return countingIn.getBytesRead(); diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelOutput.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelOutput.java index dc3d68fbbd..33d13cba9e 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelOutput.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelOutput.java @@ -24,9 +24,10 @@ import org.apache.nifi.stream.io.ByteCountingOutputStream; import org.apache.nifi.remote.protocol.CommunicationsOutput; public class SSLSocketChannelOutput implements CommunicationsOutput { + private final OutputStream out; private final ByteCountingOutputStream countingOut; - + public SSLSocketChannelOutput(final SSLSocketChannel channel) { countingOut = new ByteCountingOutputStream(new SSLSocketChannelOutputStream(channel)); out = new BufferedOutputStream(countingOut); @@ -36,7 +37,7 @@ public class SSLSocketChannelOutput implements CommunicationsOutput { public OutputStream getOutputStream() throws IOException { return out; } - + @Override public long getBytesWritten() { return countingOut.getBytesWritten(); diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/ClientProtocol.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/ClientProtocol.java index 36a0e8d8a2..2efea11a21 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/ClientProtocol.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/ClientProtocol.java @@ -48,37 +48,27 @@ public interface ClientProtocol extends VersionedRemoteResource { boolean isReadyForFileTransfer(); - - - Transaction startTransaction(Peer peer, FlowFileCodec codec, TransferDirection direction) throws IOException; - - + /** - * returns true if remote instance indicates that the port is + * @return true if remote instance indicates that the port is * invalid - * - * @return * @throws IllegalStateException if a handshake has not successfully * completed */ boolean isPortInvalid() throws IllegalStateException; /** - * returns true if remote instance indicates that the port is + * @return true if remote instance indicates that the port is * unknown - * - * @return * @throws IllegalStateException if a handshake has not successfully * completed */ boolean isPortUnknown(); /** - * returns true if remote instance indicates that the port's + * @return true if remote instance indicates that the port's * destination is full - * - * @return * @throws IllegalStateException if a handshake has not successfully * completed */ diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/CommunicationsInput.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/CommunicationsInput.java index 5e5690239a..3fa3e964c7 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/CommunicationsInput.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/CommunicationsInput.java @@ -23,10 +23,11 @@ public interface CommunicationsInput { /** * Reads all data currently on the socket and throws it away - * @throws IOException + * + * @throws IOException if unable to consume */ void consume() throws IOException; - + InputStream getInputStream() throws IOException; long getBytesRead(); diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/CommunicationsSession.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/CommunicationsSession.java index d009cec601..aff73ba03f 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/CommunicationsSession.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/CommunicationsSession.java @@ -55,10 +55,8 @@ public interface CommunicationsSession extends Closeable { void interrupt(); /** - * Returns true if the connection is closed, false - * otherwise. - * - * @return + * @return true if the connection is closed, false + * otherwise */ boolean isClosed(); } diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/DataPacket.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/DataPacket.java index 3f0ec4ffda..e7b6d06a08 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/DataPacket.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/DataPacket.java @@ -19,27 +19,30 @@ package org.apache.nifi.remote.protocol; import java.io.InputStream; import java.util.Map; - /** - * Represents a piece of data that is to be sent to or that was received from a NiFi instance. + * Represents a piece of data that is to be sent to or that was received from a + * NiFi instance. */ public interface DataPacket { /** * The key-value attributes that are to be associated with the data - * @return + * + * @return all attributes */ - Map getAttributes(); - - /** - * An InputStream from which the content can be read - * @return - */ - InputStream getData(); + Map getAttributes(); - /** - * The length of the InputStream. - * @return - */ - long getSize(); + /** + * An InputStream from which the content can be read + * + * @return input stream to the data + */ + InputStream getData(); + + /** + * The length of the InputStream. + * + * @return length of the inputstream. + */ + long getSize(); } diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/HandshakeProperty.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/HandshakeProperty.java index 41dc2763c7..016690c372 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/HandshakeProperty.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/HandshakeProperty.java @@ -16,46 +16,44 @@ */ package org.apache.nifi.remote.protocol.socket; - /** - * Enumeration of Properties that can be used for the Site-to-Site Socket Protocol. + * Enumeration of Properties that can be used for the Site-to-Site Socket + * Protocol. */ public enum HandshakeProperty { + /** - * Boolean value indicating whether or not the contents of a FlowFile should be - * GZipped when transferred. + * Boolean value indicating whether or not the contents of a FlowFile should + * be GZipped when transferred. */ GZIP, - /** * The unique identifier of the port to communicate with */ PORT_IDENTIFIER, - /** - * Indicates the number of milliseconds after the request was made that the client - * will wait for a response. If no response has been received by the time this value - * expires, the server can move on without attempting to service the request because - * the client will have already disconnected. + * Indicates the number of milliseconds after the request was made that the + * client will wait for a response. If no response has been received by the + * time this value expires, the server can move on without attempting to + * service the request because the client will have already disconnected. */ REQUEST_EXPIRATION_MILLIS, - /** - * The preferred number of FlowFiles that the server should send to the client - * when pulling data. This property was introduced in version 5 of the protocol. + * The preferred number of FlowFiles that the server should send to the + * client when pulling data. This property was introduced in version 5 of + * the protocol. */ BATCH_COUNT, - /** - * The preferred number of bytes that the server should send to the client when - * pulling data. This property was introduced in version 5 of the protocol. + * The preferred number of bytes that the server should send to the client + * when pulling data. This property was introduced in version 5 of the + * protocol. */ BATCH_SIZE, - /** - * The preferred amount of time that the server should send data to the client - * when pulling data. This property was introduced in version 5 of the protocol. - * Value is in milliseconds. + * The preferred amount of time that the server should send data to the + * client when pulling data. This property was introduced in version 5 of + * the protocol. Value is in milliseconds. */ BATCH_DURATION; } diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/Response.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/Response.java index eae1940d07..6ad2ba046d 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/Response.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/Response.java @@ -22,28 +22,29 @@ import java.io.IOException; import org.apache.nifi.remote.exception.ProtocolException; public class Response { + private final ResponseCode code; private final String message; - + private Response(final ResponseCode code, final String explanation) { this.code = code; this.message = explanation; } - + public ResponseCode getCode() { return code; } - + public String getMessage() { return message; } - + public static Response read(final DataInputStream in) throws IOException, ProtocolException { final ResponseCode code = ResponseCode.readCode(in); final String message = code.containsMessage() ? in.readUTF() : null; return new Response(code, message); } - + @Override public String toString() { return code + ": " + message; diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/ResponseCode.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/ResponseCode.java index 8860e730de..0e1359e8d3 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/ResponseCode.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/ResponseCode.java @@ -23,131 +23,126 @@ import java.io.InputStream; import org.apache.nifi.remote.exception.ProtocolException; - public enum ResponseCode { + RESERVED(0, "Reserved for Future Use", false), // This will likely be used if we ever need to expand the length of - // ResponseCode, so that we can indicate a 0 followed by some other bytes - + // ResponseCode, so that we can indicate a 0 followed by some other bytes + // handshaking properties PROPERTIES_OK(1, "Properties OK", false), UNKNOWN_PROPERTY_NAME(230, "Unknown Property Name", true), ILLEGAL_PROPERTY_VALUE(231, "Illegal Property Value", true), MISSING_PROPERTY(232, "Missing Property", true), - // transaction indicators CONTINUE_TRANSACTION(10, "Continue Transaction", false), FINISH_TRANSACTION(11, "Finish Transaction", false), - CONFIRM_TRANSACTION(12, "Confirm Transaction", true), // "Explanation" of this code is the checksum + CONFIRM_TRANSACTION(12, "Confirm Transaction", true), // "Explanation" of this code is the checksum TRANSACTION_FINISHED(13, "Transaction Finished", false), TRANSACTION_FINISHED_BUT_DESTINATION_FULL(14, "Transaction Finished But Destination is Full", false), CANCEL_TRANSACTION(15, "Cancel Transaction", true), BAD_CHECKSUM(19, "Bad Checksum", false), - // data availability indicators MORE_DATA(20, "More Data Exists", false), NO_MORE_DATA(21, "No More Data Exists", false), - // port state indicators UNKNOWN_PORT(200, "Unknown Port", false), PORT_NOT_IN_VALID_STATE(201, "Port Not in a Valid State", true), PORTS_DESTINATION_FULL(202, "Port's Destination is Full", false), - // authorization UNAUTHORIZED(240, "User Not Authorized", true), - // error indicators ABORT(250, "Abort", true), UNRECOGNIZED_RESPONSE_CODE(254, "Unrecognized Response Code", false), END_OF_STREAM(255, "End of Stream", false); - + private static final ResponseCode[] codeArray = new ResponseCode[256]; - + static { - for ( final ResponseCode responseCode : ResponseCode.values() ) { + for (final ResponseCode responseCode : ResponseCode.values()) { codeArray[responseCode.getCode()] = responseCode; } } - + private static final byte CODE_SEQUENCE_VALUE_1 = (byte) 'R'; private static final byte CODE_SEQUENCE_VALUE_2 = (byte) 'C'; private final int code; private final byte[] codeSequence; private final String description; private final boolean containsMessage; - + private ResponseCode(final int code, final String description, final boolean containsMessage) { - this.codeSequence = new byte[] {CODE_SEQUENCE_VALUE_1, CODE_SEQUENCE_VALUE_2, (byte) code}; + this.codeSequence = new byte[]{CODE_SEQUENCE_VALUE_1, CODE_SEQUENCE_VALUE_2, (byte) code}; this.code = code; this.description = description; this.containsMessage = containsMessage; } - + public int getCode() { return code; } - + public byte[] getCodeSequence() { return codeSequence; } - + @Override public String toString() { return description; } - + public boolean containsMessage() { return containsMessage; } - + public void writeResponse(final DataOutputStream out) throws IOException { - if ( containsMessage() ) { + if (containsMessage()) { throw new IllegalArgumentException("ResponseCode " + code + " expects an explanation"); } - + out.write(getCodeSequence()); out.flush(); } - + public void writeResponse(final DataOutputStream out, final String explanation) throws IOException { - if ( !containsMessage() ) { + if (!containsMessage()) { throw new IllegalArgumentException("ResponseCode " + code + " does not expect an explanation"); } - + out.write(getCodeSequence()); out.writeUTF(explanation); out.flush(); } - + static ResponseCode readCode(final InputStream in) throws IOException, ProtocolException { final int byte1 = in.read(); - if ( byte1 < 0 ) { + if (byte1 < 0) { throw new EOFException(); - } else if ( byte1 != CODE_SEQUENCE_VALUE_1 ) { + } else if (byte1 != CODE_SEQUENCE_VALUE_1) { throw new ProtocolException("Expected to receive ResponseCode, but the stream did not have a ResponseCode"); } - + final int byte2 = in.read(); - if ( byte2 < 0 ) { + if (byte2 < 0) { throw new EOFException(); - } else if ( byte2 != CODE_SEQUENCE_VALUE_2 ) { + } else if (byte2 != CODE_SEQUENCE_VALUE_2) { throw new ProtocolException("Expected to receive ResponseCode, but the stream did not have a ResponseCode"); } final int byte3 = in.read(); - if ( byte3 < 0 ) { + if (byte3 < 0) { throw new EOFException(); } - + final ResponseCode responseCode = codeArray[byte3]; if (responseCode == null) { throw new ProtocolException("Received Response Code of " + byte3 + " but do not recognize this code"); } return responseCode; } - + public static ResponseCode fromSequence(final byte[] value) { final int code = value[3] & 0xFF; final ResponseCode responseCode = codeArray[code]; return (responseCode == null) ? UNRECOGNIZED_RESPONSE_CODE : responseCode; } -} \ No newline at end of file +} diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/SocketClientProtocol.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/SocketClientProtocol.java index 83c5305054..de845eed52 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/SocketClientProtocol.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/SocketClientProtocol.java @@ -58,120 +58,121 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SocketClientProtocol implements ClientProtocol { + private final VersionNegotiator versionNegotiator = new StandardVersionNegotiator(5, 4, 3, 2, 1); private RemoteDestination destination; private boolean useCompression = false; - + private String commsIdentifier; private boolean handshakeComplete = false; - + private final Logger logger = LoggerFactory.getLogger(SocketClientProtocol.class); - + private Response handshakeResponse = null; private boolean readyForFileTransfer = false; private String transitUriPrefix = null; private int timeoutMillis = 30000; - + private int batchCount; private long batchSize; private long batchMillis; private EventReporter eventReporter; private static final long BATCH_SEND_NANOS = TimeUnit.SECONDS.toNanos(5L); // send batches of up to 5 seconds - + public SocketClientProtocol() { } public void setPreferredBatchCount(final int count) { this.batchCount = count; } - + public void setPreferredBatchSize(final long bytes) { this.batchSize = bytes; } - + public void setPreferredBatchDuration(final long millis) { this.batchMillis = millis; } - + public void setEventReporter(final EventReporter eventReporter) { - this.eventReporter = eventReporter; + this.eventReporter = eventReporter; } - + public void setDestination(final RemoteDestination destination) { this.destination = destination; this.useCompression = destination.isUseCompression(); } - + public void setTimeout(final int timeoutMillis) { - this.timeoutMillis = timeoutMillis; + this.timeoutMillis = timeoutMillis; } - + @Override public void handshake(final Peer peer) throws IOException, HandshakeException { - handshake(peer, destination.getIdentifier()); + handshake(peer, destination.getIdentifier()); } - + public void handshake(final Peer peer, final String destinationId) throws IOException, HandshakeException { - if ( handshakeComplete ) { + if (handshakeComplete) { throw new IllegalStateException("Handshake has already been completed"); } commsIdentifier = UUID.randomUUID().toString(); logger.debug("{} handshaking with {}", this, peer); - + final Map properties = new HashMap<>(); properties.put(HandshakeProperty.GZIP, String.valueOf(useCompression)); - - if ( destinationId != null ) { - properties.put(HandshakeProperty.PORT_IDENTIFIER, destinationId); + + if (destinationId != null) { + properties.put(HandshakeProperty.PORT_IDENTIFIER, destinationId); } - - properties.put(HandshakeProperty.REQUEST_EXPIRATION_MILLIS, String.valueOf(timeoutMillis) ); - - if ( versionNegotiator.getVersion() >= 5 ) { - if ( batchCount > 0 ) { + + properties.put(HandshakeProperty.REQUEST_EXPIRATION_MILLIS, String.valueOf(timeoutMillis)); + + if (versionNegotiator.getVersion() >= 5) { + if (batchCount > 0) { properties.put(HandshakeProperty.BATCH_COUNT, String.valueOf(batchCount)); } - if ( batchSize > 0L ) { + if (batchSize > 0L) { properties.put(HandshakeProperty.BATCH_SIZE, String.valueOf(batchSize)); } - if ( batchMillis > 0L ) { + if (batchMillis > 0L) { properties.put(HandshakeProperty.BATCH_DURATION, String.valueOf(batchMillis)); } } - + final CommunicationsSession commsSession = peer.getCommunicationsSession(); commsSession.setTimeout(timeoutMillis); final DataInputStream dis = new DataInputStream(commsSession.getInput().getInputStream()); final DataOutputStream dos = new DataOutputStream(commsSession.getOutput().getOutputStream()); - + dos.writeUTF(commsIdentifier); - - if ( versionNegotiator.getVersion() >= 3 ) { + + if (versionNegotiator.getVersion() >= 3) { dos.writeUTF(peer.getUrl()); transitUriPrefix = peer.getUrl(); - - if ( !transitUriPrefix.endsWith("/") ) { + + if (!transitUriPrefix.endsWith("/")) { transitUriPrefix = transitUriPrefix + "/"; } } - + logger.debug("Handshaking with properties {}", properties); dos.writeInt(properties.size()); - for ( final Map.Entry entry : properties.entrySet() ) { + for (final Map.Entry entry : properties.entrySet()) { dos.writeUTF(entry.getKey().name()); dos.writeUTF(entry.getValue()); } - + dos.flush(); - + try { handshakeResponse = Response.read(dis); } catch (final ProtocolException e) { throw new HandshakeException(e); } - + switch (handshakeResponse.getCode()) { case PORT_NOT_IN_VALID_STATE: case UNKNOWN_PORT: @@ -181,71 +182,75 @@ public class SocketClientProtocol implements ClientProtocol { readyForFileTransfer = true; break; default: - logger.error("{} received unexpected response {} from {} when negotiating Codec", new Object[] { + logger.error("{} received unexpected response {} from {} when negotiating Codec", new Object[]{ this, handshakeResponse, peer}); peer.close(); throw new HandshakeException("Received unexpected response " + handshakeResponse); } - + logger.debug("{} Finished handshake with {}", this, peer); handshakeComplete = true; } - + + @Override public boolean isReadyForFileTransfer() { return readyForFileTransfer; } - + + @Override public boolean isPortInvalid() { - if ( !handshakeComplete ) { + if (!handshakeComplete) { throw new IllegalStateException("Handshake has not completed successfully"); } return handshakeResponse.getCode() == ResponseCode.PORT_NOT_IN_VALID_STATE; } - + + @Override public boolean isPortUnknown() { - if ( !handshakeComplete ) { + if (!handshakeComplete) { throw new IllegalStateException("Handshake has not completed successfully"); } return handshakeResponse.getCode() == ResponseCode.UNKNOWN_PORT; } - + + @Override public boolean isDestinationFull() { - if ( !handshakeComplete ) { + if (!handshakeComplete) { throw new IllegalStateException("Handshake has not completed successfully"); } return handshakeResponse.getCode() == ResponseCode.PORTS_DESTINATION_FULL; } - + @Override public Set getPeerStatuses(final Peer peer) throws IOException { - if ( !handshakeComplete ) { + if (!handshakeComplete) { throw new IllegalStateException("Handshake has not been performed"); } - + logger.debug("{} Get Peer Statuses from {}", this, peer); final CommunicationsSession commsSession = peer.getCommunicationsSession(); final DataInputStream dis = new DataInputStream(commsSession.getInput().getInputStream()); final DataOutputStream dos = new DataOutputStream(commsSession.getOutput().getOutputStream()); - + RequestType.REQUEST_PEER_LIST.writeRequestType(dos); dos.flush(); final int numPeers = dis.readInt(); final Set peers = new HashSet<>(numPeers); - for (int i=0; i < numPeers; i++) { + for (int i = 0; i < numPeers; i++) { final String hostname = dis.readUTF(); final int port = dis.readInt(); final boolean secure = dis.readBoolean(); final int flowFileCount = dis.readInt(); peers.add(new PeerStatus(new PeerDescription(hostname, port, secure), flowFileCount)); } - + logger.debug("{} Received {} Peer Statuses from {}", this, peers.size(), peer); return peers; } - + @Override public FlowFileCodec negotiateCodec(final Peer peer) throws IOException, ProtocolException { - if ( !handshakeComplete ) { + if (!handshakeComplete) { throw new IllegalStateException("Handshake has not been performed"); } @@ -255,177 +260,174 @@ public class SocketClientProtocol implements ClientProtocol { final DataOutputStream dos = new DataOutputStream(commsSession.getOutput().getOutputStream()); RequestType.NEGOTIATE_FLOWFILE_CODEC.writeRequestType(dos); - + FlowFileCodec codec = new StandardFlowFileCodec(); try { codec = (FlowFileCodec) RemoteResourceInitiator.initiateResourceNegotiation(codec, dis, dos); } catch (HandshakeException e) { throw new ProtocolException(e.toString()); } - logger.debug("{} negotiated FlowFileCodec {} with {}", new Object[] {this, codec, commsSession}); + logger.debug("{} negotiated FlowFileCodec {} with {}", new Object[]{this, codec, commsSession}); return codec; } - @Override public Transaction startTransaction(final Peer peer, final FlowFileCodec codec, final TransferDirection direction) throws IOException, ProtocolException { - if ( !handshakeComplete ) { + if (!handshakeComplete) { throw new IllegalStateException("Handshake has not been performed"); } - if ( !readyForFileTransfer ) { + if (!readyForFileTransfer) { throw new IllegalStateException("Cannot start transaction; handshake resolution was " + handshakeResponse); } - - return new SocketClientTransaction(versionNegotiator.getVersion(), destination.getIdentifier(), peer, codec, - direction, useCompression, (int) destination.getYieldPeriod(TimeUnit.MILLISECONDS), eventReporter); - } + return new SocketClientTransaction(versionNegotiator.getVersion(), destination.getIdentifier(), peer, codec, + direction, useCompression, (int) destination.getYieldPeriod(TimeUnit.MILLISECONDS), eventReporter); + } @Override public int receiveFlowFiles(final Peer peer, final ProcessContext context, final ProcessSession session, final FlowFileCodec codec) throws IOException, ProtocolException { - final String userDn = peer.getCommunicationsSession().getUserDn(); - final Transaction transaction = startTransaction(peer, codec, TransferDirection.RECEIVE); - - final StopWatch stopWatch = new StopWatch(true); - final Set flowFilesReceived = new HashSet<>(); - long bytesReceived = 0L; - - while (true) { - final long start = System.nanoTime(); - final DataPacket dataPacket = transaction.receive(); - if ( dataPacket == null ) { - if ( flowFilesReceived.isEmpty() ) { - peer.penalize(destination.getIdentifier(), destination.getYieldPeriod(TimeUnit.MILLISECONDS)); - } - break; - } - - FlowFile flowFile = session.create(); - flowFile = session.putAllAttributes(flowFile, dataPacket.getAttributes()); - flowFile = session.importFrom(dataPacket.getData(), flowFile); - final long receiveNanos = System.nanoTime() - start; - - String sourceFlowFileIdentifier = dataPacket.getAttributes().get(CoreAttributes.UUID.key()); - if ( sourceFlowFileIdentifier == null ) { - sourceFlowFileIdentifier = ""; - } - - final String transitUri = (transitUriPrefix == null) ? peer.getUrl() : transitUriPrefix + sourceFlowFileIdentifier; - session.getProvenanceReporter().receive(flowFile, transitUri, "urn:nifi:" + sourceFlowFileIdentifier, "Remote Host=" + peer.getHost() + ", Remote DN=" + userDn, TimeUnit.NANOSECONDS.toMillis(receiveNanos)); + final String userDn = peer.getCommunicationsSession().getUserDn(); + final Transaction transaction = startTransaction(peer, codec, TransferDirection.RECEIVE); - session.transfer(flowFile, Relationship.ANONYMOUS); - bytesReceived += dataPacket.getSize(); - } + final StopWatch stopWatch = new StopWatch(true); + final Set flowFilesReceived = new HashSet<>(); + long bytesReceived = 0L; - // Confirm that what we received was the correct data. - transaction.confirm(); - - // Commit the session so that we have persisted the data - session.commit(); + while (true) { + final long start = System.nanoTime(); + final DataPacket dataPacket = transaction.receive(); + if (dataPacket == null) { + if (flowFilesReceived.isEmpty()) { + peer.penalize(destination.getIdentifier(), destination.getYieldPeriod(TimeUnit.MILLISECONDS)); + } + break; + } - transaction.complete(); - logger.debug("{} Sending TRANSACTION_FINISHED_BUT_DESTINATION_FULL to {}", this, peer); + FlowFile flowFile = session.create(); + flowFile = session.putAllAttributes(flowFile, dataPacket.getAttributes()); + flowFile = session.importFrom(dataPacket.getData(), flowFile); + final long receiveNanos = System.nanoTime() - start; - if ( !flowFilesReceived.isEmpty() ) { - stopWatch.stop(); - final String flowFileDescription = flowFilesReceived.size() < 20 ? flowFilesReceived.toString() : flowFilesReceived.size() + " FlowFiles"; - final String uploadDataRate = stopWatch.calculateDataRate(bytesReceived); - final long uploadMillis = stopWatch.getDuration(TimeUnit.MILLISECONDS); - final String dataSize = FormatUtils.formatDataSize(bytesReceived); - logger.info("{} Successfully receveied {} ({}) from {} in {} milliseconds at a rate of {}", new Object[] { - this, flowFileDescription, dataSize, peer, uploadMillis, uploadDataRate }); - } - - return flowFilesReceived.size(); + String sourceFlowFileIdentifier = dataPacket.getAttributes().get(CoreAttributes.UUID.key()); + if (sourceFlowFileIdentifier == null) { + sourceFlowFileIdentifier = ""; + } + + final String transitUri = (transitUriPrefix == null) ? peer.getUrl() : transitUriPrefix + sourceFlowFileIdentifier; + session.getProvenanceReporter().receive(flowFile, transitUri, "urn:nifi:" + sourceFlowFileIdentifier, "Remote Host=" + + peer.getHost() + ", Remote DN=" + userDn, TimeUnit.NANOSECONDS.toMillis(receiveNanos)); + + session.transfer(flowFile, Relationship.ANONYMOUS); + bytesReceived += dataPacket.getSize(); + } + + // Confirm that what we received was the correct data. + transaction.confirm(); + + // Commit the session so that we have persisted the data + session.commit(); + + transaction.complete(); + logger.debug("{} Sending TRANSACTION_FINISHED_BUT_DESTINATION_FULL to {}", this, peer); + + if (!flowFilesReceived.isEmpty()) { + stopWatch.stop(); + final String flowFileDescription = flowFilesReceived.size() < 20 ? flowFilesReceived.toString() : flowFilesReceived.size() + " FlowFiles"; + final String uploadDataRate = stopWatch.calculateDataRate(bytesReceived); + final long uploadMillis = stopWatch.getDuration(TimeUnit.MILLISECONDS); + final String dataSize = FormatUtils.formatDataSize(bytesReceived); + logger.info("{} Successfully receveied {} ({}) from {} in {} milliseconds at a rate of {}", new Object[]{ + this, flowFileDescription, dataSize, peer, uploadMillis, uploadDataRate}); + } + + return flowFilesReceived.size(); } - @Override public int transferFlowFiles(final Peer peer, final ProcessContext context, final ProcessSession session, final FlowFileCodec codec) throws IOException, ProtocolException { - FlowFile flowFile = session.get(); - if (flowFile == null) { - return 0; - } + FlowFile flowFile = session.get(); + if (flowFile == null) { + return 0; + } - try { - final String userDn = peer.getCommunicationsSession().getUserDn(); - final long startSendingNanos = System.nanoTime(); - final StopWatch stopWatch = new StopWatch(true); - long bytesSent = 0L; - - final Transaction transaction = startTransaction(peer, codec, TransferDirection.SEND); - - final Set flowFilesSent = new HashSet<>(); - boolean continueTransaction = true; - while (continueTransaction) { - final long startNanos = System.nanoTime(); - // call codec.encode within a session callback so that we have the InputStream to read the FlowFile - final FlowFile toWrap = flowFile; - session.read(flowFile, new InputStreamCallback() { - @Override - public void process(final InputStream in) throws IOException { - final DataPacket dataPacket = new StandardDataPacket(toWrap.getAttributes(), in, toWrap.getSize()); - transaction.send(dataPacket); - } - }); - - final long transferNanos = System.nanoTime() - startNanos; - final long transferMillis = TimeUnit.MILLISECONDS.convert(transferNanos, TimeUnit.NANOSECONDS); - - flowFilesSent.add(flowFile); - bytesSent += flowFile.getSize(); - logger.debug("{} Sent {} to {}", this, flowFile, peer); - - final String transitUri = (transitUriPrefix == null) ? peer.getUrl() : transitUriPrefix + flowFile.getAttribute(CoreAttributes.UUID.key()); - session.getProvenanceReporter().send(flowFile, transitUri, "Remote Host=" + peer.getHost() + ", Remote DN=" + userDn, transferMillis, false); - session.remove(flowFile); - - final long sendingNanos = System.nanoTime() - startSendingNanos; - if ( sendingNanos < BATCH_SEND_NANOS ) { - flowFile = session.get(); - } else { - flowFile = null; - } - - continueTransaction = (flowFile != null); - } - - transaction.confirm(); - - // consume input stream entirely, ignoring its contents. If we - // don't do this, the Connection will not be returned to the pool - stopWatch.stop(); - final String uploadDataRate = stopWatch.calculateDataRate(bytesSent); - final long uploadMillis = stopWatch.getDuration(TimeUnit.MILLISECONDS); - final String dataSize = FormatUtils.formatDataSize(bytesSent); - - session.commit(); - transaction.complete(); - - final String flowFileDescription = (flowFilesSent.size() < 20) ? flowFilesSent.toString() : flowFilesSent.size() + " FlowFiles"; - logger.info("{} Successfully sent {} ({}) to {} in {} milliseconds at a rate of {}", new Object[] { - this, flowFileDescription, dataSize, peer, uploadMillis, uploadDataRate}); - - return flowFilesSent.size(); - } catch (final Exception e) { - session.rollback(); - throw e; - } + try { + final String userDn = peer.getCommunicationsSession().getUserDn(); + final long startSendingNanos = System.nanoTime(); + final StopWatch stopWatch = new StopWatch(true); + long bytesSent = 0L; + + final Transaction transaction = startTransaction(peer, codec, TransferDirection.SEND); + + final Set flowFilesSent = new HashSet<>(); + boolean continueTransaction = true; + while (continueTransaction) { + final long startNanos = System.nanoTime(); + // call codec.encode within a session callback so that we have the InputStream to read the FlowFile + final FlowFile toWrap = flowFile; + session.read(flowFile, new InputStreamCallback() { + @Override + public void process(final InputStream in) throws IOException { + final DataPacket dataPacket = new StandardDataPacket(toWrap.getAttributes(), in, toWrap.getSize()); + transaction.send(dataPacket); + } + }); + + final long transferNanos = System.nanoTime() - startNanos; + final long transferMillis = TimeUnit.MILLISECONDS.convert(transferNanos, TimeUnit.NANOSECONDS); + + flowFilesSent.add(flowFile); + bytesSent += flowFile.getSize(); + logger.debug("{} Sent {} to {}", this, flowFile, peer); + + final String transitUri = (transitUriPrefix == null) ? peer.getUrl() : transitUriPrefix + flowFile.getAttribute(CoreAttributes.UUID.key()); + session.getProvenanceReporter().send(flowFile, transitUri, "Remote Host=" + peer.getHost() + ", Remote DN=" + userDn, transferMillis, false); + session.remove(flowFile); + + final long sendingNanos = System.nanoTime() - startSendingNanos; + if (sendingNanos < BATCH_SEND_NANOS) { + flowFile = session.get(); + } else { + flowFile = null; + } + + continueTransaction = (flowFile != null); + } + + transaction.confirm(); + + // consume input stream entirely, ignoring its contents. If we + // don't do this, the Connection will not be returned to the pool + stopWatch.stop(); + final String uploadDataRate = stopWatch.calculateDataRate(bytesSent); + final long uploadMillis = stopWatch.getDuration(TimeUnit.MILLISECONDS); + final String dataSize = FormatUtils.formatDataSize(bytesSent); + + session.commit(); + transaction.complete(); + + final String flowFileDescription = (flowFilesSent.size() < 20) ? flowFilesSent.toString() : flowFilesSent.size() + " FlowFiles"; + logger.info("{} Successfully sent {} ({}) to {} in {} milliseconds at a rate of {}", new Object[]{ + this, flowFileDescription, dataSize, peer, uploadMillis, uploadDataRate}); + + return flowFilesSent.size(); + } catch (final Exception e) { + session.rollback(); + throw e; + } } - - + @Override public VersionNegotiator getVersionNegotiator() { return versionNegotiator; } - + @Override public void shutdown(final Peer peer) throws IOException { readyForFileTransfer = false; final CommunicationsSession commsSession = peer.getCommunicationsSession(); final DataOutputStream dos = new DataOutputStream(commsSession.getOutput().getOutputStream()); - + logger.debug("{} Shutting down with {}", this, peer); // Indicate that we would like to have some data RequestType.SHUTDOWN.writeRequestType(dos); @@ -436,7 +438,7 @@ public class SocketClientProtocol implements ClientProtocol { public String getResourceName() { return "SocketFlowFileProtocol"; } - + @Override public String toString() { return "SocketClientProtocol[CommsID=" + commsIdentifier + "]"; diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/SocketClientTransaction.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/SocketClientTransaction.java index e69104f201..e83ea28e6e 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/SocketClientTransaction.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/SocketClientTransaction.java @@ -45,50 +45,51 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SocketClientTransaction implements Transaction { - private static final Logger logger = LoggerFactory.getLogger(SocketClientTransaction.class); - - private final long creationNanoTime = System.nanoTime(); - private final CRC32 crc = new CRC32(); - private final int protocolVersion; - private final FlowFileCodec codec; - private final DataInputStream dis; - private final DataOutputStream dos; - private final TransferDirection direction; - private final boolean compress; - private final Peer peer; - private final int penaltyMillis; - private final String destinationId; - private final EventReporter eventReporter; - - private boolean dataAvailable = false; - private int transfers = 0; - private long contentBytes = 0; - private TransactionState state; - - SocketClientTransaction(final int protocolVersion, final String destinationId, final Peer peer, final FlowFileCodec codec, - final TransferDirection direction, final boolean useCompression, final int penaltyMillis, final EventReporter eventReporter) throws IOException { - this.protocolVersion = protocolVersion; - this.destinationId = destinationId; - this.peer = peer; - this.codec = codec; - this.direction = direction; - this.dis = new DataInputStream(peer.getCommunicationsSession().getInput().getInputStream()); - this.dos = new DataOutputStream(peer.getCommunicationsSession().getOutput().getOutputStream()); - this.compress = useCompression; - this.state = TransactionState.TRANSACTION_STARTED; - this.penaltyMillis = penaltyMillis; - this.eventReporter = eventReporter; - - initialize(); - } - - private void initialize() throws IOException { - try { - if ( direction == TransferDirection.RECEIVE ) { + + private static final Logger logger = LoggerFactory.getLogger(SocketClientTransaction.class); + + private final long creationNanoTime = System.nanoTime(); + private final CRC32 crc = new CRC32(); + private final int protocolVersion; + private final FlowFileCodec codec; + private final DataInputStream dis; + private final DataOutputStream dos; + private final TransferDirection direction; + private final boolean compress; + private final Peer peer; + private final int penaltyMillis; + private final String destinationId; + private final EventReporter eventReporter; + + private boolean dataAvailable = false; + private int transfers = 0; + private long contentBytes = 0; + private TransactionState state; + + SocketClientTransaction(final int protocolVersion, final String destinationId, final Peer peer, final FlowFileCodec codec, + final TransferDirection direction, final boolean useCompression, final int penaltyMillis, final EventReporter eventReporter) throws IOException { + this.protocolVersion = protocolVersion; + this.destinationId = destinationId; + this.peer = peer; + this.codec = codec; + this.direction = direction; + this.dis = new DataInputStream(peer.getCommunicationsSession().getInput().getInputStream()); + this.dos = new DataOutputStream(peer.getCommunicationsSession().getOutput().getOutputStream()); + this.compress = useCompression; + this.state = TransactionState.TRANSACTION_STARTED; + this.penaltyMillis = penaltyMillis; + this.eventReporter = eventReporter; + + initialize(); + } + + private void initialize() throws IOException { + try { + if (direction == TransferDirection.RECEIVE) { // Indicate that we would like to have some data RequestType.RECEIVE_FLOWFILES.writeRequestType(dos); dos.flush(); - + final Response dataAvailableCode = Response.read(dis); switch (dataAvailableCode.getCode()) { case MORE_DATA: @@ -102,39 +103,38 @@ public class SocketClientTransaction implements Transaction { default: throw new ProtocolException("Got unexpected response when asking for data: " + dataAvailableCode); } - + } else { // Indicate that we would like to have some data RequestType.SEND_FLOWFILES.writeRequestType(dos); dos.flush(); } - } catch (final Exception e) { - error(); - throw e; - } - } - - - @Override - public DataPacket receive() throws IOException { - try { - try { - if ( state != TransactionState.DATA_EXCHANGED && state != TransactionState.TRANSACTION_STARTED) { - throw new IllegalStateException("Cannot receive data from " + peer + " because Transaction State is " + state); - } - - if ( direction == TransferDirection.SEND ) { - throw new IllegalStateException("Attempting to receive data from " + peer + " but started a SEND Transaction"); - } - - // if we already know there's no data, just return null - if ( !dataAvailable ) { - return null; - } - - // if we have already received a packet, check if another is available. - if ( transfers > 0 ) { - // Determine if Peer will send us data or has no data to send us + } catch (final Exception e) { + error(); + throw e; + } + } + + @Override + public DataPacket receive() throws IOException { + try { + try { + if (state != TransactionState.DATA_EXCHANGED && state != TransactionState.TRANSACTION_STARTED) { + throw new IllegalStateException("Cannot receive data from " + peer + " because Transaction State is " + state); + } + + if (direction == TransferDirection.SEND) { + throw new IllegalStateException("Attempting to receive data from " + peer + " but started a SEND Transaction"); + } + + // if we already know there's no data, just return null + if (!dataAvailable) { + return null; + } + + // if we have already received a packet, check if another is available. + if (transfers > 0) { + // Determine if Peer will send us data or has no data to send us final Response dataAvailableCode = Response.read(dis); switch (dataAvailableCode.getCode()) { case CONTINUE_TRANSACTION: @@ -149,170 +149,166 @@ public class SocketClientTransaction implements Transaction { throw new ProtocolException("Got unexpected response from " + peer + " when asking for data: " + dataAvailableCode); } } - - // if no data available, return null - if ( !dataAvailable ) { - return null; - } - + + // if no data available, return null + if (!dataAvailable) { + return null; + } + logger.debug("{} Receiving data from {}", this, peer); final InputStream dataIn = compress ? new CompressionInputStream(dis) : dis; final DataPacket packet = codec.decode(new CheckedInputStream(dataIn, crc)); - - if ( packet == null ) { + + if (packet == null) { this.dataAvailable = false; } else { - transfers++; - contentBytes += packet.getSize(); + transfers++; + contentBytes += packet.getSize(); } - + this.state = TransactionState.DATA_EXCHANGED; return packet; - } catch (final IOException ioe) { - throw new IOException("Failed to receive data from " + peer + " due to " + ioe, ioe); - } - } catch (final Exception e) { - error(); - throw e; - } - } - - - @Override - public void send(final byte[] content, final Map attributes) throws IOException { - send(new StandardDataPacket(attributes, new ByteArrayInputStream(content), content.length)); - } - - @Override - public void send(final DataPacket dataPacket) throws IOException { - try { - try { - if ( state != TransactionState.DATA_EXCHANGED && state != TransactionState.TRANSACTION_STARTED) { - throw new IllegalStateException("Cannot send data to " + peer + " because Transaction State is " + state); - } - - if ( direction == TransferDirection.RECEIVE ) { + } catch (final IOException ioe) { + throw new IOException("Failed to receive data from " + peer + " due to " + ioe, ioe); + } + } catch (final Exception e) { + error(); + throw e; + } + } + + @Override + public void send(final byte[] content, final Map attributes) throws IOException { + send(new StandardDataPacket(attributes, new ByteArrayInputStream(content), content.length)); + } + + @Override + public void send(final DataPacket dataPacket) throws IOException { + try { + try { + if (state != TransactionState.DATA_EXCHANGED && state != TransactionState.TRANSACTION_STARTED) { + throw new IllegalStateException("Cannot send data to " + peer + " because Transaction State is " + state); + } + + if (direction == TransferDirection.RECEIVE) { throw new IllegalStateException("Attempting to send data to " + peer + " but started a RECEIVE Transaction"); } - - if ( transfers > 0 ) { + + if (transfers > 0) { ResponseCode.CONTINUE_TRANSACTION.writeResponse(dos); } - + logger.debug("{} Sending data to {}", this, peer); - + final OutputStream dataOut = compress ? new CompressionOutputStream(dos) : dos; - final OutputStream out = new CheckedOutputStream(dataOut, crc); + final OutputStream out = new CheckedOutputStream(dataOut, crc); codec.encode(dataPacket, out); - + // need to close the CompressionOutputStream in order to force it write out any remaining bytes. // Otherwise, do NOT close it because we don't want to close the underlying stream // (CompressionOutputStream will not close the underlying stream when it's closed) - if ( compress ) { - out.close(); + if (compress) { + out.close(); } - + transfers++; contentBytes += dataPacket.getSize(); this.state = TransactionState.DATA_EXCHANGED; - } catch (final IOException ioe) { - throw new IOException("Failed to send data to " + peer + " due to " + ioe, ioe); - } - } catch (final Exception e) { - error(); - throw e; - } - } - - - @Override - public void cancel(final String explanation) throws IOException { - if ( state == TransactionState.TRANSACTION_CANCELED || state == TransactionState.TRANSACTION_COMPLETED || state == TransactionState.ERROR ) { - throw new IllegalStateException("Cannot cancel transaction because state is already " + state); - } + } catch (final IOException ioe) { + throw new IOException("Failed to send data to " + peer + " due to " + ioe, ioe); + } + } catch (final Exception e) { + error(); + throw e; + } + } + + @Override + public void cancel(final String explanation) throws IOException { + if (state == TransactionState.TRANSACTION_CANCELED || state == TransactionState.TRANSACTION_COMPLETED || state == TransactionState.ERROR) { + throw new IllegalStateException("Cannot cancel transaction because state is already " + state); + } + + try { + ResponseCode.CANCEL_TRANSACTION.writeResponse(dos, explanation == null ? "" : explanation); + state = TransactionState.TRANSACTION_CANCELED; + } catch (final IOException ioe) { + error(); + throw new IOException("Failed to send 'cancel transaction' message to " + peer + " due to " + ioe, ioe); + } + } + + @Override + public TransactionCompletion complete() throws IOException { + try { + try { + if (state != TransactionState.TRANSACTION_CONFIRMED) { + throw new IllegalStateException("Cannot complete transaction with " + peer + " because state is " + state + + "; Transaction can only be completed when state is " + TransactionState.TRANSACTION_CONFIRMED); + } + + boolean backoff = false; + if (direction == TransferDirection.RECEIVE) { + if (transfers == 0) { + state = TransactionState.TRANSACTION_COMPLETED; + return new SocketClientTransactionCompletion(false, 0, 0L, System.nanoTime() - creationNanoTime); + } - try { - ResponseCode.CANCEL_TRANSACTION.writeResponse(dos, explanation == null ? "" : explanation); - state = TransactionState.TRANSACTION_CANCELED; - } catch (final IOException ioe) { - error(); - throw new IOException("Failed to send 'cancel transaction' message to " + peer + " due to " + ioe, ioe); - } - } - - - @Override - public TransactionCompletion complete() throws IOException { - try { - try { - if ( state != TransactionState.TRANSACTION_CONFIRMED ) { - throw new IllegalStateException("Cannot complete transaction with " + peer + " because state is " + state + - "; Transaction can only be completed when state is " + TransactionState.TRANSACTION_CONFIRMED); - } - - boolean backoff = false; - if ( direction == TransferDirection.RECEIVE ) { - if ( transfers == 0 ) { - state = TransactionState.TRANSACTION_COMPLETED; - return new SocketClientTransactionCompletion(false, 0, 0L, System.nanoTime() - creationNanoTime); - } - // Confirm that we received the data and the peer can now discard it logger.debug("{} Sending TRANSACTION_FINISHED to {}", this, peer); ResponseCode.TRANSACTION_FINISHED.writeResponse(dos); - + state = TransactionState.TRANSACTION_COMPLETED; } else { final Response transactionResponse; try { transactionResponse = Response.read(dis); } catch (final IOException e) { - throw new IOException(this + " Failed to receive a response from " + peer + " when expecting a TransactionFinished Indicator. " + - "It is unknown whether or not the peer successfully received/processed the data.", e); + throw new IOException(this + " Failed to receive a response from " + peer + " when expecting a TransactionFinished Indicator. " + + "It is unknown whether or not the peer successfully received/processed the data.", e); } - + logger.debug("{} Received {} from {}", this, transactionResponse, peer); - if ( transactionResponse.getCode() == ResponseCode.TRANSACTION_FINISHED_BUT_DESTINATION_FULL ) { + if (transactionResponse.getCode() == ResponseCode.TRANSACTION_FINISHED_BUT_DESTINATION_FULL) { peer.penalize(destinationId, penaltyMillis); backoff = true; - } else if ( transactionResponse.getCode() != ResponseCode.TRANSACTION_FINISHED ) { + } else if (transactionResponse.getCode() != ResponseCode.TRANSACTION_FINISHED) { throw new ProtocolException("After sending data to " + peer + ", expected TRANSACTION_FINISHED response but got " + transactionResponse); } - + state = TransactionState.TRANSACTION_COMPLETED; } - - return new SocketClientTransactionCompletion(backoff, transfers, contentBytes, System.nanoTime() - creationNanoTime); - } catch (final IOException ioe) { - throw new IOException("Failed to complete transaction with " + peer + " due to " + ioe, ioe); - } - } catch (final Exception e) { - error(); - throw e; - } - } - - - @Override - public void confirm() throws IOException { - try { - try { - if ( state == TransactionState.TRANSACTION_STARTED && !dataAvailable && direction == TransferDirection.RECEIVE ) { - // client requested to receive data but no data available. no need to confirm. - state = TransactionState.TRANSACTION_CONFIRMED; - return; - } - - if ( state != TransactionState.DATA_EXCHANGED ) { - throw new IllegalStateException("Cannot confirm Transaction because state is " + state + - "; Transaction can only be confirmed when state is " + TransactionState.DATA_EXCHANGED ); - } - - if ( direction == TransferDirection.RECEIVE ) { - if ( dataAvailable ) { + + return new SocketClientTransactionCompletion(backoff, transfers, contentBytes, System.nanoTime() - creationNanoTime); + } catch (final IOException ioe) { + throw new IOException("Failed to complete transaction with " + peer + " due to " + ioe, ioe); + } + } catch (final Exception e) { + error(); + throw e; + } + } + + @Override + public void confirm() throws IOException { + try { + try { + if (state == TransactionState.TRANSACTION_STARTED && !dataAvailable && direction == TransferDirection.RECEIVE) { + // client requested to receive data but no data available. no need to confirm. + state = TransactionState.TRANSACTION_CONFIRMED; + return; + } + + if (state != TransactionState.DATA_EXCHANGED) { + throw new IllegalStateException("Cannot confirm Transaction because state is " + state + + "; Transaction can only be confirmed when state is " + TransactionState.DATA_EXCHANGED); + } + + if (direction == TransferDirection.RECEIVE) { + if (dataAvailable) { throw new IllegalStateException("Cannot complete transaction because the sender has already sent more data than client has consumed."); } - + // we received a FINISH_TRANSACTION indicator. Send back a CONFIRM_TRANSACTION message // to peer so that we can verify that the connection is still open. This is a two-phase commit, // which helps to prevent the chances of data duplication. Without doing this, we may commit the @@ -323,84 +319,88 @@ public class SocketClientTransaction implements Transaction { logger.trace("{} Sending CONFIRM_TRANSACTION Response Code to {}", this, peer); final String calculatedCRC = String.valueOf(crc.getValue()); ResponseCode.CONFIRM_TRANSACTION.writeResponse(dos, calculatedCRC); - + final Response confirmTransactionResponse; try { confirmTransactionResponse = Response.read(dis); } catch (final IOException ioe) { logger.error("Failed to receive response code from {} when expecting confirmation of transaction", peer); - if ( eventReporter != null ) { - eventReporter.reportEvent(Severity.ERROR, "Site-to-Site", "Failed to receive response code from " + peer + " when expecting confirmation of transaction"); + if (eventReporter != null) { + eventReporter.reportEvent(Severity.ERROR, "Site-to-Site", "Failed to receive response code from " + peer + " when expecting confirmation of transaction"); } throw ioe; } - + logger.trace("{} Received {} from {}", this, confirmTransactionResponse, peer); - + switch (confirmTransactionResponse.getCode()) { case CONFIRM_TRANSACTION: break; case BAD_CHECKSUM: throw new IOException(this + " Received a BadChecksum response from peer " + peer); default: - throw new ProtocolException(this + " Received unexpected Response from peer " + peer + " : " + confirmTransactionResponse + "; expected 'Confirm Transaction' Response Code"); + throw new ProtocolException(this + " Received unexpected Response from peer " + peer + " : " + + confirmTransactionResponse + "; expected 'Confirm Transaction' Response Code"); } - + state = TransactionState.TRANSACTION_CONFIRMED; } else { logger.debug("{} Sent FINISH_TRANSACTION indicator to {}", this, peer); ResponseCode.FINISH_TRANSACTION.writeResponse(dos); - + final String calculatedCRC = String.valueOf(crc.getValue()); - + // we've sent a FINISH_TRANSACTION. Now we'll wait for the peer to send a 'Confirm Transaction' response final Response transactionConfirmationResponse = Response.read(dis); - if ( transactionConfirmationResponse.getCode() == ResponseCode.CONFIRM_TRANSACTION ) { + if (transactionConfirmationResponse.getCode() == ResponseCode.CONFIRM_TRANSACTION) { // Confirm checksum and echo back the confirmation. logger.trace("{} Received {} from {}", this, transactionConfirmationResponse, peer); final String receivedCRC = transactionConfirmationResponse.getMessage(); - + // CRC was not used before version 4 - if ( protocolVersion > 3 ) { - if ( !receivedCRC.equals(calculatedCRC) ) { + if (protocolVersion > 3) { + if (!receivedCRC.equals(calculatedCRC)) { ResponseCode.BAD_CHECKSUM.writeResponse(dos); - throw new IOException(this + " Sent data to peer " + peer + " but calculated CRC32 Checksum as " + calculatedCRC + " while peer calculated CRC32 Checksum as " + receivedCRC + "; canceling transaction and rolling back session"); + throw new IOException(this + " Sent data to peer " + peer + " but calculated CRC32 Checksum as " + + calculatedCRC + " while peer calculated CRC32 Checksum as " + + receivedCRC + "; canceling transaction and rolling back session"); } } - + ResponseCode.CONFIRM_TRANSACTION.writeResponse(dos, ""); } else { - throw new ProtocolException("Expected to receive 'Confirm Transaction' response from peer " + peer + " but received " + transactionConfirmationResponse); + throw new ProtocolException("Expected to receive 'Confirm Transaction' response from peer " + + peer + " but received " + transactionConfirmationResponse); } - + state = TransactionState.TRANSACTION_CONFIRMED; } - } catch (final IOException ioe) { - throw new IOException("Failed to confirm transaction with " + peer + " due to " + ioe, ioe); - } - } catch (final Exception e) { - error(); - throw e; - } - } + } catch (final IOException ioe) { + throw new IOException("Failed to confirm transaction with " + peer + " due to " + ioe, ioe); + } + } catch (final Exception e) { + error(); + throw e; + } + } - @Override - public void error() { - this.state = TransactionState.ERROR; - } - - @Override - public TransactionState getState() { - return state; - } + @Override + public void error() { + this.state = TransactionState.ERROR; + } + + @Override + public TransactionState getState() { + return state; + } + + @Override + public Communicant getCommunicant() { + return peer; + } - @Override - public Communicant getCommunicant() { - return peer; - } - @Override public String toString() { - return "SocketClientTransaction[Url=" + peer.getUrl() + ", TransferDirection=" + direction + ", State=" + state + "]"; + return "SocketClientTransaction[Url=" + peer.getUrl() + ", TransferDirection=" + direction + ", State=" + state + "]"; } } diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/SocketClientTransactionCompletion.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/SocketClientTransactionCompletion.java index 5eb6c91c96..bd950130f2 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/SocketClientTransactionCompletion.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/protocol/socket/SocketClientTransactionCompletion.java @@ -26,7 +26,7 @@ public class SocketClientTransactionCompletion implements TransactionCompletion private final int dataPacketsTransferred; private final long bytesTransferred; private final long durationNanos; - + public SocketClientTransactionCompletion(final boolean backoff, final int dataPacketsTransferred, final long bytesTransferred, final long durationNanos) { this.backoff = backoff; this.dataPacketsTransferred = dataPacketsTransferred; diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/util/NiFiRestApiUtil.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/util/NiFiRestApiUtil.java index 10352ecb56..d746abf633 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/util/NiFiRestApiUtil.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/util/NiFiRestApiUtil.java @@ -32,43 +32,44 @@ import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; public class NiFiRestApiUtil { + public static final int RESPONSE_CODE_OK = 200; - + private final SSLContext sslContext; - + public NiFiRestApiUtil(final SSLContext sslContext) { this.sslContext = sslContext; } - + private HttpURLConnection getConnection(final String connUrl, final int timeoutMillis) throws IOException { final URL url = new URL(connUrl); final HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setConnectTimeout(timeoutMillis); connection.setReadTimeout(timeoutMillis); - + // special handling for https if (sslContext != null && connection instanceof HttpsURLConnection) { HttpsURLConnection secureConnection = (HttpsURLConnection) connection; secureConnection.setSSLSocketFactory(sslContext.getSocketFactory()); // check the trusted hostname property and override the HostnameVerifier - secureConnection.setHostnameVerifier(new OverrideHostnameVerifier(url.getHost(), + secureConnection.setHostnameVerifier(new OverrideHostnameVerifier(url.getHost(), secureConnection.getHostnameVerifier())); } - + return connection; } - + public ControllerDTO getController(final String url, final int timeoutMillis) throws IOException { final HttpURLConnection connection = getConnection(url, timeoutMillis); connection.setRequestMethod("GET"); final int responseCode = connection.getResponseCode(); - + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); StreamUtils.copy(connection.getInputStream(), baos); final String responseMessage = baos.toString(); - - if ( responseCode == RESPONSE_CODE_OK ) { + + if (responseCode == RESPONSE_CODE_OK) { final ObjectMapper mapper = new ObjectMapper(); final JsonNode jsonNode = mapper.readTree(responseMessage); final JsonNode controllerNode = jsonNode.get("controller"); @@ -77,8 +78,9 @@ public class NiFiRestApiUtil { throw new IOException("Got HTTP response Code " + responseCode + ": " + connection.getResponseMessage() + " with explanation: " + responseMessage); } } - + private static class OverrideHostnameVerifier implements HostnameVerifier { + private final String trustedHostname; private final HostnameVerifier delegate; diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/util/PeerStatusCache.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/util/PeerStatusCache.java index 6dab77b399..c52b4b7a80 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/util/PeerStatusCache.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/util/PeerStatusCache.java @@ -21,7 +21,8 @@ import java.util.Set; import org.apache.nifi.remote.PeerStatus; public class PeerStatusCache { - private final Set statuses; + + private final Set statuses; private final long timestamp; public PeerStatusCache(final Set statuses) { diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/util/StandardDataPacket.java b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/util/StandardDataPacket.java index bd1b50c5a4..70bb32464d 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/util/StandardDataPacket.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/util/StandardDataPacket.java @@ -25,26 +25,26 @@ import org.apache.nifi.stream.io.MinimumLengthInputStream; public class StandardDataPacket implements DataPacket { - private final Map attributes; - private final InputStream stream; - private final long size; - - public StandardDataPacket(final Map attributes, final InputStream stream, final long size) { - this.attributes = attributes; - this.stream = new MinimumLengthInputStream(new LimitingInputStream(stream, size), size); - this.size = size; - } - - public Map getAttributes() { - return attributes; - } - - public InputStream getData() { - return stream; - } - - public long getSize() { - return size; - } - + private final Map attributes; + private final InputStream stream; + private final long size; + + public StandardDataPacket(final Map attributes, final InputStream stream, final long size) { + this.attributes = attributes; + this.stream = new MinimumLengthInputStream(new LimitingInputStream(stream, size), size); + this.size = size; + } + + public Map getAttributes() { + return attributes; + } + + public InputStream getData() { + return stream; + } + + public long getSize() { + return size; + } + } diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/test/java/org/apache/nifi/remote/client/socket/TestEndpointConnectionStatePool.java b/nifi/nifi-commons/nifi-site-to-site-client/src/test/java/org/apache/nifi/remote/client/socket/TestEndpointConnectionStatePool.java index c5cca78614..8336745e54 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/test/java/org/apache/nifi/remote/client/socket/TestEndpointConnectionStatePool.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/test/java/org/apache/nifi/remote/client/socket/TestEndpointConnectionStatePool.java @@ -40,11 +40,11 @@ public class TestEndpointConnectionStatePool { clusterNodeInfo.setNodeInformation(collection); final List destinations = EndpointConnectionPool.formulateDestinationList(clusterNodeInfo, TransferDirection.RECEIVE); - for ( final PeerStatus peerStatus : destinations ) { + for (final PeerStatus peerStatus : destinations) { System.out.println(peerStatus.getPeerDescription()); } } - + @Test public void testFormulateDestinationListForOutputHugeDifference() throws IOException { final ClusterNodeInformation clusterNodeInfo = new ClusterNodeInformation(); @@ -54,14 +54,11 @@ public class TestEndpointConnectionStatePool { clusterNodeInfo.setNodeInformation(collection); final List destinations = EndpointConnectionPool.formulateDestinationList(clusterNodeInfo, TransferDirection.RECEIVE); - for ( final PeerStatus peerStatus : destinations ) { + for (final PeerStatus peerStatus : destinations) { System.out.println(peerStatus.getPeerDescription()); } } - - - - + @Test public void testFormulateDestinationListForInputPorts() throws IOException { final ClusterNodeInformation clusterNodeInfo = new ClusterNodeInformation(); @@ -74,11 +71,11 @@ public class TestEndpointConnectionStatePool { clusterNodeInfo.setNodeInformation(collection); final List destinations = EndpointConnectionPool.formulateDestinationList(clusterNodeInfo, TransferDirection.SEND); - for ( final PeerStatus peerStatus : destinations ) { + for (final PeerStatus peerStatus : destinations) { System.out.println(peerStatus.getPeerDescription()); } } - + @Test public void testFormulateDestinationListForInputPortsHugeDifference() throws IOException { final ClusterNodeInformation clusterNodeInfo = new ClusterNodeInformation(); @@ -88,7 +85,7 @@ public class TestEndpointConnectionStatePool { clusterNodeInfo.setNodeInformation(collection); final List destinations = EndpointConnectionPool.formulateDestinationList(clusterNodeInfo, TransferDirection.SEND); - for ( final PeerStatus peerStatus : destinations ) { + for (final PeerStatus peerStatus : destinations) { System.out.println(peerStatus.getPeerDescription()); } } diff --git a/nifi/nifi-commons/nifi-site-to-site-client/src/test/java/org/apache/nifi/remote/client/socket/TestSiteToSiteClient.java b/nifi/nifi-commons/nifi-site-to-site-client/src/test/java/org/apache/nifi/remote/client/socket/TestSiteToSiteClient.java index b73e44d4a4..155fc952ac 100644 --- a/nifi/nifi-commons/nifi-site-to-site-client/src/test/java/org/apache/nifi/remote/client/socket/TestSiteToSiteClient.java +++ b/nifi/nifi-commons/nifi-site-to-site-client/src/test/java/org/apache/nifi/remote/client/socket/TestSiteToSiteClient.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; -import java.util.concurrent.TimeUnit; import org.apache.nifi.remote.Transaction; import org.apache.nifi.remote.TransferDirection; @@ -39,32 +38,32 @@ public class TestSiteToSiteClient { @Ignore("For local testing only; not really a unit test but a manual test") public void testReceive() throws IOException { System.setProperty("org.slf4j.simpleLogger.log.org.apache.nifi.remote", "DEBUG"); - + final SiteToSiteClient client = new SiteToSiteClient.Builder() - .url("http://localhost:8080/nifi") - .portName("cba") - .requestBatchCount(10) - .build(); - + .url("http://localhost:8080/nifi") + .portName("cba") + .requestBatchCount(10) + .build(); + try { - for (int i=0; i < 1000; i++) { + for (int i = 0; i < 1000; i++) { final Transaction transaction = client.createTransaction(TransferDirection.RECEIVE); Assert.assertNotNull(transaction); - + DataPacket packet; while (true) { packet = transaction.receive(); - if ( packet == null ) { + if (packet == null) { break; } final InputStream in = packet.getData(); final long size = packet.getSize(); final byte[] buff = new byte[(int) size]; - + StreamUtils.fillBuffer(in, buff); } - + transaction.confirm(); transaction.complete(); } @@ -72,34 +71,33 @@ public class TestSiteToSiteClient { client.close(); } } - - + @Test @Ignore("For local testing only; not really a unit test but a manual test") public void testSend() throws IOException { System.setProperty("org.slf4j.simpleLogger.log.org.apache.nifi.remote", "DEBUG"); - + final SiteToSiteClient client = new SiteToSiteClient.Builder() - .url("http://localhost:8080/nifi") - .portName("input") - .build(); - + .url("http://localhost:8080/nifi") + .portName("input") + .build(); + try { final Transaction transaction = client.createTransaction(TransferDirection.SEND); Assert.assertNotNull(transaction); - + final Map attrs = new HashMap<>(); attrs.put("site-to-site", "yes, please!"); final byte[] bytes = "Hello".getBytes(); final ByteArrayInputStream bais = new ByteArrayInputStream(bytes); final DataPacket packet = new StandardDataPacket(attrs, bais, bytes.length); transaction.send(packet); - + transaction.confirm(); transaction.complete(); } finally { client.close(); } } - + } diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/AbstractChannelReader.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/AbstractChannelReader.java index 172c593995..cc245750e9 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/AbstractChannelReader.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/AbstractChannelReader.java @@ -33,10 +33,6 @@ import org.apache.commons.lang3.builder.ToStringStyle; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - * - * @author none - */ public abstract class AbstractChannelReader implements Runnable { private static final Logger LOGGER = LoggerFactory.getLogger(AbstractChannelReader.class); @@ -91,12 +87,12 @@ public abstract class AbstractChannelReader implements Runnable { * Allows a subclass to specifically handle how it reads from the given * key's channel into the given buffer. * - * @param key - * @param buffer + * @param key of channel to read from + * @param buffer to fill * @return the number of bytes read in the final read cycle. A value of zero * or more indicates the channel is still open but a value of -1 indicates * end of stream. - * @throws IOException + * @throws IOException if reading from channel causes failure */ protected abstract int fillBuffer(SelectionKey key, ByteBuffer buffer) throws IOException; diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/BufferPool.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/BufferPool.java index a413ad26ab..007034b79f 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/BufferPool.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/BufferPool.java @@ -25,10 +25,6 @@ import java.util.concurrent.LinkedBlockingDeque; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - * - * @author none - */ public class BufferPool implements Runnable { private static final Logger LOGGER = LoggerFactory.getLogger(BufferPool.class); @@ -50,9 +46,9 @@ public class BufferPool implements Runnable { /** * Returns the given buffer to the pool - and clears it. * - * @param buffer - * @param bytesProcessed - * @return + * @param buffer buffer to return + * @param bytesProcessed bytes processed for this buffer being returned + * @return true if buffer returned to pool */ public synchronized boolean returnBuffer(ByteBuffer buffer, final int bytesProcessed) { totalBytesExtracted += bytesProcessed; diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/ChannelDispatcher.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/ChannelDispatcher.java index 2ae2c07d00..824f2df990 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/ChannelDispatcher.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/ChannelDispatcher.java @@ -35,10 +35,6 @@ import org.apache.nifi.io.nio.consumer.StreamConsumerFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - * - * @author none - */ public final class ChannelDispatcher implements Runnable { private static final Logger LOGGER = LoggerFactory.getLogger(ChannelDispatcher.class); @@ -81,8 +77,8 @@ public final class ChannelDispatcher implements Runnable { /* * When serverSocketsChannels are registered with the selector, want each invoke of this method to loop through all * channels' keys. - * - * @throws IOException + * + * @throws IOException if unable to select keys */ private void selectServerSocketKeys() throws IOException { int numSelected = serverSocketSelector.select(timeout); @@ -121,8 +117,8 @@ public final class ChannelDispatcher implements Runnable { * When invoking this method, only want to iterate through the selected keys once. When a key is entered into the selectors * selected key set, select will return a positive value. The next select will return 0 if nothing has changed. Note that * the selected key set is not manually changed via a remove operation. - * - * @throws IOException + * + * @throws IOException if unable to select keys */ private void selectSocketChannelKeys() throws IOException { // once a channel associated with a key in this selector is 'ready', it causes this select to immediately return. @@ -138,7 +134,7 @@ public final class ChannelDispatcher implements Runnable { // there are 2 kinds of channels in this selector, both which have their own readers and are executed in their own // threads. We will get here whenever a new SocketChannel is created due to an incoming connection. However, // for a DatagramChannel we don't want to create a new reader unless it is a new DatagramChannel. The only - // way to tell if it's new is the lack of an attachment. + // way to tell if it's new is the lack of an attachment. if (channel instanceof DatagramChannel && socketChannelKey.attachment() == null) { reader = new DatagramChannelReader(UUID.randomUUID().toString(), socketChannelKey, emptyBuffers, factory); socketChannelKey.attach(reader); diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/ChannelListener.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/ChannelListener.java index b0a1cfba2d..7cbf589a92 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/ChannelListener.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/ChannelListener.java @@ -62,7 +62,6 @@ import org.slf4j.LoggerFactory; * All ChannelReaders will get throttled by the unavailability of buffers in the * provided BufferPool. This is designed to create back pressure. * - * @author none */ public final class ChannelListener { @@ -99,7 +98,7 @@ public final class ChannelListener { * @param port - port to bind to * @param receiveBufferSize - size of OS receive buffer to request. If less * than 0 then will not be set and OS default will win. - * @throws IOException + * @throws IOException if unable to add socket */ public void addServerSocket(final InetAddress nicIPAddress, final int port, final int receiveBufferSize) throws IOException { @@ -129,7 +128,7 @@ public final class ChannelListener { * @param port - the port to listen on * @param receiveBufferSize - the number of bytes to request for a receive * buffer from OS - * @throws IOException + * @throws IOException if unable to add channel */ public void addDatagramChannel(final InetAddress nicIPAddress, final int port, final int receiveBufferSize) throws IOException { @@ -156,7 +155,7 @@ public final class ChannelListener { * any network interface on the local host. * @param sendingPort - the port used by the sender of datagrams. Only * datagrams from this port will be received. - * @throws IOException + * @throws IOException if unable to add channel */ public void addDatagramChannel(final InetAddress nicIPAddress, final int port, final int receiveBufferSize, final String sendingHost, final Integer sendingPort) throws IOException { diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/DatagramChannelReader.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/DatagramChannelReader.java index 1eb5c7e3c9..db76279921 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/DatagramChannelReader.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/DatagramChannelReader.java @@ -23,10 +23,6 @@ import java.nio.channels.SelectionKey; import org.apache.nifi.io.nio.consumer.StreamConsumerFactory; -/** - * - * @author none - */ public final class DatagramChannelReader extends AbstractChannelReader { public static final int MAX_UDP_PACKET_SIZE = 65507; @@ -39,10 +35,10 @@ public final class DatagramChannelReader extends AbstractChannelReader { * Will receive UDP data from channel and won't receive anything unless the * given buffer has enough space for at least one full max udp packet. * - * @param key - * @param buffer - * @return - * @throws IOException + * @param key selection key + * @param buffer to fill + * @return bytes read + * @throws IOException if error filling buffer from channel */ @Override protected int fillBuffer(final SelectionKey key, final ByteBuffer buffer) throws IOException { diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/SocketChannelReader.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/SocketChannelReader.java index db2c102cbd..29c2973c34 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/SocketChannelReader.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/SocketChannelReader.java @@ -22,10 +22,6 @@ import java.nio.channels.SelectionKey; import java.nio.channels.SocketChannel; import org.apache.nifi.io.nio.consumer.StreamConsumerFactory; -/** - * - * @author none - */ public final class SocketChannelReader extends AbstractChannelReader { public SocketChannelReader(final String id, final SelectionKey key, final BufferPool empties, final StreamConsumerFactory consumerFactory) { @@ -35,10 +31,10 @@ public final class SocketChannelReader extends AbstractChannelReader { /** * Receives TCP data from the socket channel for the given key. * - * @param key - * @param buffer - * @return - * @throws IOException + * @param key selection key + * @param buffer byte buffer to fill + * @return bytes read + * @throws IOException if error reading bytes */ @Override protected int fillBuffer(final SelectionKey key, final ByteBuffer buffer) throws IOException { diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/consumer/AbstractStreamConsumer.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/consumer/AbstractStreamConsumer.java index fce59c60ab..bb57e26e27 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/consumer/AbstractStreamConsumer.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/consumer/AbstractStreamConsumer.java @@ -29,7 +29,6 @@ import org.apache.commons.lang3.builder.ToStringStyle; /** * - * @author none */ public abstract class AbstractStreamConsumer implements StreamConsumer { diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/consumer/StreamConsumer.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/consumer/StreamConsumer.java index d75b7d7a0b..cac8d8b405 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/consumer/StreamConsumer.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/consumer/StreamConsumer.java @@ -25,7 +25,6 @@ import org.apache.nifi.io.nio.BufferPool; * thread providing data to process and another thread that is processing that * data. * - * @author none */ public interface StreamConsumer { @@ -36,7 +35,7 @@ public interface StreamConsumer { * associated add to this given queue. If not, buffers will run out and all * stream processing will halt. READ THIS!!! * - * @param returnQueue + * @param returnQueue pool of buffers to use */ void setReturnBufferQueue(BufferPool returnQueue); @@ -45,7 +44,7 @@ public interface StreamConsumer { * data to be processed. If the consumer is finished this should simply * return the given buffer to the return buffer queue (after it is cleared) * - * @param buffer + * @param buffer filled buffer */ void addFilledBuffer(ByteBuffer buffer); @@ -53,7 +52,8 @@ public interface StreamConsumer { * Will be called by the thread that executes the consumption of data. May * be called many times though once isConsumerFinished returns * true this method will likely do nothing. - * @throws java.io.IOException + * + * @throws java.io.IOException if there is an issue processing */ void process() throws IOException; @@ -66,14 +66,14 @@ public interface StreamConsumer { * If true signals the consumer is done consuming data and will not process * any more buffers. * - * @return + * @return true if finished */ boolean isConsumerFinished(); /** * Uniquely identifies the consumer * - * @return + * @return identifier of consumer */ String getId(); diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/consumer/StreamConsumerFactory.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/consumer/StreamConsumerFactory.java index df298d57ef..ba858b69ea 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/consumer/StreamConsumerFactory.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/nio/consumer/StreamConsumerFactory.java @@ -18,7 +18,6 @@ package org.apache.nifi.io.nio.consumer; /** * - * @author none */ public interface StreamConsumerFactory { diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/SSLContextFactory.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/SSLContextFactory.java index 7ed5ad4313..9c6cb82161 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/SSLContextFactory.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/SSLContextFactory.java @@ -81,12 +81,12 @@ public class SSLContextFactory { * * * @return a SSLContext instance - * @throws java.security.KeyStoreException - * @throws java.io.IOException - * @throws java.security.NoSuchAlgorithmException - * @throws java.security.cert.CertificateException - * @throws java.security.UnrecoverableKeyException - * @throws java.security.KeyManagementException + * @throws java.security.KeyStoreException if problem with keystore + * @throws java.io.IOException if unable to create context + * @throws java.security.NoSuchAlgorithmException if algorithm isn't known + * @throws java.security.cert.CertificateException if certificate is invalid + * @throws java.security.UnrecoverableKeyException if the key cannot be recovered + * @throws java.security.KeyManagementException if the key is improper */ public SSLContext createSslContext() throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException, UnrecoverableKeyException, KeyManagementException { diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/ServerSocketConfiguration.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/ServerSocketConfiguration.java index fc279fbc3c..d6aca924d0 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/ServerSocketConfiguration.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/ServerSocketConfiguration.java @@ -26,9 +26,6 @@ import java.security.cert.CertificateException; import javax.net.ssl.SSLContext; -/** - * @author unattributed - */ public final class ServerSocketConfiguration { private boolean needClientAuth; @@ -40,7 +37,8 @@ public final class ServerSocketConfiguration { public ServerSocketConfiguration() { } - public SSLContext createSSLContext() throws KeyManagementException, NoSuchAlgorithmException, UnrecoverableKeyException, KeyStoreException, CertificateException, FileNotFoundException, IOException { + public SSLContext createSSLContext() + throws KeyManagementException, NoSuchAlgorithmException, UnrecoverableKeyException, KeyStoreException, CertificateException, FileNotFoundException, IOException { return sslContextFactory == null ? null : sslContextFactory.createSslContext(); } diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/SocketConfiguration.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/SocketConfiguration.java index c24b540cba..8b803dcd64 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/SocketConfiguration.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/SocketConfiguration.java @@ -26,9 +26,6 @@ import java.security.cert.CertificateException; import javax.net.ssl.SSLContext; -/** - * @author unattributed - */ public final class SocketConfiguration { private Integer socketTimeout; @@ -41,7 +38,8 @@ public final class SocketConfiguration { private Integer trafficClass; private SSLContextFactory sslContextFactory; - public SSLContext createSSLContext() throws KeyManagementException, NoSuchAlgorithmException, UnrecoverableKeyException, KeyStoreException, CertificateException, FileNotFoundException, IOException { + public SSLContext createSSLContext() + throws KeyManagementException, NoSuchAlgorithmException, UnrecoverableKeyException, KeyStoreException, CertificateException, FileNotFoundException, IOException { return sslContextFactory == null ? null : sslContextFactory.createSslContext(); } diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/SocketListener.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/SocketListener.java index e02791af07..b509035774 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/SocketListener.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/SocketListener.java @@ -41,7 +41,6 @@ import org.slf4j.LoggerFactory; /** * Implements a listener for TCP/IP messages sent over unicast socket. * - * @author unattributed */ public abstract class SocketListener { diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/SocketUtils.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/SocketUtils.java index fb6a00c6ac..27d676a2e7 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/SocketUtils.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/SocketUtils.java @@ -35,9 +35,6 @@ import org.apache.nifi.logging.NiFiLog; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - * @author unattributed - */ public final class SocketUtils { private static final Logger logger = new NiFiLog(LoggerFactory.getLogger(SocketUtils.class)); @@ -99,7 +96,8 @@ public final class SocketUtils { return socket; } - public static ServerSocket createServerSocket(final int port, final ServerSocketConfiguration config) throws IOException, KeyManagementException, UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, CertificateException { + public static ServerSocket createServerSocket(final int port, final ServerSocketConfiguration config) + throws IOException, KeyManagementException, UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, CertificateException { if (config == null) { throw new NullPointerException("Configuration may not be null."); } diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/DiscoverableService.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/DiscoverableService.java index 7a62813222..fc817e9a07 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/DiscoverableService.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/DiscoverableService.java @@ -23,7 +23,6 @@ import java.net.InetSocketAddress; * unique case-sensitive service name and a socket address where it is * available. * - * @author unattributed */ public interface DiscoverableService { diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/DiscoverableServiceImpl.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/DiscoverableServiceImpl.java index 5f378b94ef..3737e9564f 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/DiscoverableServiceImpl.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/DiscoverableServiceImpl.java @@ -23,7 +23,6 @@ import org.apache.commons.lang3.StringUtils; * A basic implementation of the DiscoverableService interface. To services are * considered equal if they have the same case-sensitive service name. * - * @author unattributed */ public class DiscoverableServiceImpl implements DiscoverableService { diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastConfiguration.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastConfiguration.java index ea0b72a7d8..d1c2156690 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastConfiguration.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastConfiguration.java @@ -17,7 +17,6 @@ package org.apache.nifi.io.socket.multicast; /** - * @author unattributed */ public final class MulticastConfiguration { diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastListener.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastListener.java index e562c25fcd..1ce2ea04a4 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastListener.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastListener.java @@ -35,7 +35,6 @@ import org.slf4j.LoggerFactory; * then the message is wrapped with a MulticastProtocolMessage before being sent * to the originator. * - * @author unattributed */ public abstract class MulticastListener { @@ -80,8 +79,8 @@ public abstract class MulticastListener { * Implements the action to perform when a new datagram is received. This * class must not close the multicast socket. * - * @param multicastSocket - * @param packet the datagram socket + * @param multicastSocket socket + * @param packet the datagram packet */ public abstract void dispatchRequest(final MulticastSocket multicastSocket, final DatagramPacket packet); diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastServiceDiscovery.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastServiceDiscovery.java index c254c117e0..212e20c0ee 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastServiceDiscovery.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastServiceDiscovery.java @@ -22,7 +22,6 @@ import java.net.InetSocketAddress; * Defines the interface for discovering services based on name. Services are * expected to be exposed via socket address and port. * - * @author unattributed */ public interface MulticastServiceDiscovery extends ServiceDiscovery { diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastServicesBroadcaster.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastServicesBroadcaster.java index a3cff9b451..7ef5a5d410 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastServicesBroadcaster.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastServicesBroadcaster.java @@ -21,7 +21,6 @@ import java.net.InetSocketAddress; /** * Defines the interface for broadcasting a service via multicast. * - * @author unattributed */ public interface MulticastServicesBroadcaster extends ServicesBroadcaster { diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastTimeToLive.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastTimeToLive.java index dad117331c..3e96c6152d 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastTimeToLive.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastTimeToLive.java @@ -17,7 +17,6 @@ package org.apache.nifi.io.socket.multicast; /** - * @author unattributed */ public enum MulticastTimeToLive { diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastUtils.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastUtils.java index 8a8b7c034c..84d76d27cf 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastUtils.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/MulticastUtils.java @@ -23,7 +23,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * @author unattributed */ public final class MulticastUtils { diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/ServiceDiscovery.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/ServiceDiscovery.java index 173146ecff..74c1a30f46 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/ServiceDiscovery.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/ServiceDiscovery.java @@ -19,7 +19,6 @@ package org.apache.nifi.io.socket.multicast; /** * Defines a generic interface for discovering services. * - * @author unattributed */ public interface ServiceDiscovery { diff --git a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/ServicesBroadcaster.java b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/ServicesBroadcaster.java index 86260d8882..2a9f9b2fb5 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/ServicesBroadcaster.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/main/java/org/apache/nifi/io/socket/multicast/ServicesBroadcaster.java @@ -22,7 +22,6 @@ import java.util.Set; * Defines the interface for broadcasting a collection of services for client * discovery. * - * @author unattributed */ public interface ServicesBroadcaster { diff --git a/nifi/nifi-commons/nifi-socket-utils/src/test/java/org/apache/nifi/io/nio/example/ServerMain.java b/nifi/nifi-commons/nifi-socket-utils/src/test/java/org/apache/nifi/io/nio/example/ServerMain.java index b5240c948b..27d5ccc7ee 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/test/java/org/apache/nifi/io/nio/example/ServerMain.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/test/java/org/apache/nifi/io/nio/example/ServerMain.java @@ -37,7 +37,6 @@ import org.slf4j.LoggerFactory; /** * - * @author none */ public final class ServerMain { diff --git a/nifi/nifi-commons/nifi-socket-utils/src/test/java/org/apache/nifi/io/nio/example/TCPClient.java b/nifi/nifi-commons/nifi-socket-utils/src/test/java/org/apache/nifi/io/nio/example/TCPClient.java index b3d214e8e7..1c4b70cbef 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/test/java/org/apache/nifi/io/nio/example/TCPClient.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/test/java/org/apache/nifi/io/nio/example/TCPClient.java @@ -24,7 +24,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * @author none */ public class TCPClient { @@ -78,7 +77,8 @@ public class TCPClient { for (int i = 0; i < 1000; i++) { sock.getOutputStream().write(bytes); totalBytes += bytes.length; - } sock.getOutputStream().flush(); + } + sock.getOutputStream().flush(); } logger.info("Total bytes sent: " + totalBytes + " to port " + port); } diff --git a/nifi/nifi-commons/nifi-socket-utils/src/test/java/org/apache/nifi/io/nio/example/UDPClient.java b/nifi/nifi-commons/nifi-socket-utils/src/test/java/org/apache/nifi/io/nio/example/UDPClient.java index 90f4c42015..00a00a10d2 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/test/java/org/apache/nifi/io/nio/example/UDPClient.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/test/java/org/apache/nifi/io/nio/example/UDPClient.java @@ -24,7 +24,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * @author none */ public class UDPClient { diff --git a/nifi/nifi-commons/nifi-socket-utils/src/test/java/org/apache/nifi/io/nio/example/UselessStreamConsumer.java b/nifi/nifi-commons/nifi-socket-utils/src/test/java/org/apache/nifi/io/nio/example/UselessStreamConsumer.java index 9ec26e9401..107c087e85 100644 --- a/nifi/nifi-commons/nifi-socket-utils/src/test/java/org/apache/nifi/io/nio/example/UselessStreamConsumer.java +++ b/nifi/nifi-commons/nifi-socket-utils/src/test/java/org/apache/nifi/io/nio/example/UselessStreamConsumer.java @@ -23,7 +23,6 @@ import org.apache.nifi.io.nio.consumer.AbstractStreamConsumer; /** * - * @author none */ public class UselessStreamConsumer extends AbstractStreamConsumer { diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/flowfile/attributes/CoreAttributes.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/flowfile/attributes/CoreAttributes.java index 24f43ca587..9b4c3af4b7 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/flowfile/attributes/CoreAttributes.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/flowfile/attributes/CoreAttributes.java @@ -17,53 +17,46 @@ package org.apache.nifi.flowfile.attributes; public enum CoreAttributes implements FlowFileAttributeKey { + /** - * The flowfile's path indicates the relative directory to which a FlowFile belongs and does not - * contain the filename + * The flowfile's path indicates the relative directory to which a FlowFile belongs and does not contain the filename */ PATH("path"), - /** - * The flowfile's absolute path indicates the absolute directory to which a FlowFile belongs and does not - * contain the filename + * The flowfile's absolute path indicates the absolute directory to which a FlowFile belongs and does not contain the filename */ ABSOLUTE_PATH("absolute.path"), - /** * The filename of the FlowFile. The filename should not contain any directory structure. */ FILENAME("filename"), - /** * A unique UUID assigned to this FlowFile */ UUID("uuid"), - /** * A numeric value indicating the FlowFile priority */ PRIORITY("priority"), - /** * The MIME Type of this FlowFile */ MIME_TYPE("mime.type"), - /** * Specifies the reason that a FlowFile is being discarded */ DISCARD_REASON("discard.reason"), - /** * Indicates an identifier other than the FlowFile's UUID that is known to refer to this FlowFile. */ ALTERNATE_IDENTIFIER("alternate.identifier"); - + private final String key; + private CoreAttributes(final String key) { this.key = key; } - + @Override public String key() { return key; diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/flowfile/attributes/FlowFileAttributeKey.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/flowfile/attributes/FlowFileAttributeKey.java index cc6c28ebaa..963763108a 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/flowfile/attributes/FlowFileAttributeKey.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/flowfile/attributes/FlowFileAttributeKey.java @@ -17,5 +17,6 @@ package org.apache.nifi.flowfile.attributes; public interface FlowFileAttributeKey { + String key(); } diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/VersionNegotiator.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/VersionNegotiator.java index 74f9b3dbdf..d8ee27a45f 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/VersionNegotiator.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/VersionNegotiator.java @@ -26,13 +26,10 @@ public interface VersionNegotiator { int getVersion(); /** - * Sets the version of this resource to the specified version. Only the - * lower byte of the version is relevant. + * Sets the version of this resource to the specified version. Only the lower byte of the version is relevant. * - * @param version - * @throws IllegalArgumentException if the given Version is not supported by - * this resource, as is indicated by the {@link #isVersionSupported(int)} - * method + * @param version the version to set + * @throws IllegalArgumentException if the given Version is not supported by this resource, as is indicated by the {@link #isVersionSupported(int)} method */ void setVersion(int version) throws IllegalArgumentException; @@ -43,21 +40,19 @@ public interface VersionNegotiator { int getPreferredVersion(); /** - * Gets the preferred version of this resource that is no greater than the - * given maxVersion. If no acceptable version exists that is less than - * maxVersion, then null is returned + * Gets the preferred version of this resource that is no greater than the given maxVersion. If no acceptable version exists that is less than maxVersion, then null is + * returned * - * @param maxVersion - * @return + * @param maxVersion the maximum version desired + * @return the preferred version if found; null otherwise */ Integer getPreferredVersion(int maxVersion); /** - * Indicates whether or not the specified version is supported by this - * resource + * Indicates whether or not the specified version is supported by this resource * - * @param version - * @return + * @param version the version to test + * @return true if supported; false otherwise */ boolean isVersionSupported(int version); diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/exception/TransmissionDisabledException.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/exception/TransmissionDisabledException.java index 05fd915af1..d18c807957 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/exception/TransmissionDisabledException.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/exception/TransmissionDisabledException.java @@ -17,8 +17,7 @@ package org.apache.nifi.remote.exception; /** - * Indicates that the user disabled transmission while communications were - * taking place with a peer + * Indicates that the user disabled transmission while communications were taking place with a peer */ public class TransmissionDisabledException extends RuntimeException { diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/CompressionInputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/CompressionInputStream.java index d953185f90..6434b2d3a2 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/CompressionInputStream.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/CompressionInputStream.java @@ -73,7 +73,7 @@ public class CompressionInputStream extends InputStream { fillBuffer(fourByteBuffer); compressedBuffer = new byte[toInt(fourByteBuffer)]; - bufferIndex = buffer.length; // indicate that buffer is empty + bufferIndex = buffer.length; // indicate that buffer is empty } private int toInt(final byte[] data) { @@ -175,7 +175,8 @@ public class CompressionInputStream extends InputStream { /** * Does nothing. Does NOT close underlying InputStream - * @throws java.io.IOException + * + * @throws java.io.IOException for any issues closing underlying stream */ @Override public void close() throws IOException { diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/CompressionOutputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/CompressionOutputStream.java index bc46b0ff7b..525b5b15db 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/CompressionOutputStream.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/CompressionOutputStream.java @@ -58,10 +58,9 @@ public class CompressionOutputStream extends OutputStream { } /** - * Compresses the currently buffered chunk of data and sends it to the - * output stream + * Compresses the currently buffered chunk of data and sends it to the output stream * - * @throws IOException + * @throws IOException if issues occur writing to stream */ protected void compressAndWrite() throws IOException { if (bufferIndex <= 0) { diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/BufferStateManager.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/BufferStateManager.java index 68913bdc85..6e54d62fff 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/BufferStateManager.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/BufferStateManager.java @@ -38,11 +38,9 @@ public class BufferStateManager { } /** - * Ensures that the buffer is at least as big as the size specified, - * resizing the buffer if necessary. This operation MAY change the direction - * of the buffer. + * Ensures that the buffer is at least as big as the size specified, resizing the buffer if necessary. This operation MAY change the direction of the buffer. * - * @param requiredSize + * @param requiredSize the desired size of the buffer */ public void ensureSize(final int requiredSize) { if (buffer.capacity() < requiredSize) { diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelInputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelInputStream.java index 0ad0b74a43..1ec229df40 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelInputStream.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelInputStream.java @@ -43,17 +43,17 @@ public class SocketChannelInputStream extends InputStream { public void setTimeout(final int timeoutMillis) { this.timeoutMillis = timeoutMillis; } - + public void consume() throws IOException { channel.shutdownInput(); - + final byte[] b = new byte[4096]; final ByteBuffer buffer = ByteBuffer.wrap(b); int bytesRead; do { bytesRead = channel.read(buffer); buffer.flip(); - } while ( bytesRead > 0 ); + } while (bytesRead > 0); } @Override @@ -160,7 +160,8 @@ public class SocketChannelInputStream extends InputStream { /** * Closes the underlying socket channel. - * @throws java.io.IOException + * + * @throws java.io.IOException for issues closing underlying stream */ @Override public void close() throws IOException { diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelOutputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelOutputStream.java index 77049ad1ad..a56d9dd20c 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelOutputStream.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelOutputStream.java @@ -104,7 +104,8 @@ public class SocketChannelOutputStream extends OutputStream { /** * Closes the underlying SocketChannel - * @throws java.io.IOException + * + * @throws java.io.IOException if issues closing underlying stream */ @Override public void close() throws IOException { diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannel.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannel.java index 249ad483fe..1f23d790a2 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannel.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannel.java @@ -260,7 +260,7 @@ public class SSLSocketChannel implements Closeable { public void consume() throws IOException { channel.shutdownInput(); - + final byte[] b = new byte[4096]; final ByteBuffer buffer = ByteBuffer.wrap(b); int readCount; @@ -269,7 +269,7 @@ public class SSLSocketChannel implements Closeable { buffer.flip(); } while (readCount > 0); } - + private int readData(final ByteBuffer dest) throws IOException { final long startTime = System.currentTimeMillis(); diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelInputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelInputStream.java index 6fb79d42ae..ca6de8513f 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelInputStream.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelInputStream.java @@ -30,7 +30,7 @@ public class SSLSocketChannelInputStream extends InputStream { public void consume() throws IOException { channel.consume(); } - + @Override public int read() throws IOException { return channel.read(); @@ -47,8 +47,7 @@ public class SSLSocketChannelInputStream extends InputStream { } /** - * Closes the underlying SSLSocketChannel, which will also close the - * OutputStream and connection + * Closes the underlying SSLSocketChannel, which will also close the OutputStream and connection */ @Override public void close() throws IOException { diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelOutputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelOutputStream.java index ce4e4200fc..262cf54f61 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelOutputStream.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelOutputStream.java @@ -43,8 +43,7 @@ public class SSLSocketChannelOutputStream extends OutputStream { } /** - * Closes the underlying SSLSocketChannel, which also will close the - * InputStream and the connection + * Closes the underlying SSLSocketChannel, which also will close the InputStream and the connection */ @Override public void close() throws IOException { diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/BufferedInputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/BufferedInputStream.java index aaf37ea397..2afaa70623 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/BufferedInputStream.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/BufferedInputStream.java @@ -19,11 +19,8 @@ package org.apache.nifi.stream.io; import java.io.InputStream; /** - * This class is a slight modification of the BufferedInputStream in the java.io - * package. The modification is that this implementation does not provide - * synchronization on method calls, which means that this class is not suitable - * for use by multiple threads. However, the absence of these synchronized - * blocks results in potentially much better performance. + * This class is a slight modification of the BufferedInputStream in the java.io package. The modification is that this implementation does not provide synchronization on method calls, which means + * that this class is not suitable for use by multiple threads. However, the absence of these synchronized blocks results in potentially much better performance. */ public class BufferedInputStream extends java.io.BufferedInputStream { diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/BufferedOutputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/BufferedOutputStream.java index eadfcab953..dc56927175 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/BufferedOutputStream.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/BufferedOutputStream.java @@ -21,11 +21,8 @@ import java.io.IOException; import java.io.OutputStream; /** - * This class is a slight modification of the - * {@link java.io.BufferedOutputStream} class. This implementation differs in - * that it does not mark methods as synchronized. This means that this class is - * not suitable for writing by multiple concurrent threads. However, the removal - * of the synchronized keyword results in potentially much better performance. + * This class is a slight modification of the {@link java.io.BufferedOutputStream} class. This implementation differs in that it does not mark methods as synchronized. This means that this class is + * not suitable for writing by multiple concurrent threads. However, the removal of the synchronized keyword results in potentially much better performance. */ public class BufferedOutputStream extends FilterOutputStream { @@ -35,15 +32,13 @@ public class BufferedOutputStream extends FilterOutputStream { protected byte buf[]; /** - * The number of valid bytes in the buffer. This value is always in the - * range 0 through buf.length; elements + * The number of valid bytes in the buffer. This value is always in the range 0 through buf.length; elements * buf[0] through buf[count-1] contain valid byte data. */ protected int count; /** - * Creates a new buffered output stream to write data to the specified - * underlying output stream. + * Creates a new buffered output stream to write data to the specified underlying output stream. * * @param out the underlying output stream. */ @@ -52,8 +47,7 @@ public class BufferedOutputStream extends FilterOutputStream { } /** - * Creates a new buffered output stream to write data to the specified - * underlying output stream with the specified buffer size. + * Creates a new buffered output stream to write data to the specified underlying output stream with the specified buffer size. * * @param out the underlying output stream. * @param size the buffer size. @@ -92,16 +86,12 @@ public class BufferedOutputStream extends FilterOutputStream { } /** - * Writes len bytes from the specified byte array starting at - * offset off to this buffered output stream. + * Writes len bytes from the specified byte array starting at offset off to this buffered output stream. * *

    - * Ordinarily this method stores bytes from the given array into this - * stream's buffer, flushing the buffer to the underlying output stream as - * needed. If the requested length is at least as large as this stream's - * buffer, however, then this method will flush the buffer and write the - * bytes directly to the underlying output stream. Thus redundant - * BufferedOutputStreams will not copy data unnecessarily. + * Ordinarily this method stores bytes from the given array into this stream's buffer, flushing the buffer to the underlying output stream as needed. If the requested length is at least as large + * as this stream's buffer, however, then this method will flush the buffer and write the bytes directly to the underlying output stream. Thus redundant BufferedOutputStreams will not + * copy data unnecessarily. * * @param b the data. * @param off the start offset in the data. @@ -126,8 +116,7 @@ public class BufferedOutputStream extends FilterOutputStream { } /** - * Flushes this buffered output stream. This forces any buffered output - * bytes to be written out to the underlying output stream. + * Flushes this buffered output stream. This forces any buffered output bytes to be written out to the underlying output stream. * * @exception IOException if an I/O error occurs. * @see java.io.FilterOutputStream#out diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteArrayInputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteArrayInputStream.java index 284cd54837..85c8c4fdd7 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteArrayInputStream.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteArrayInputStream.java @@ -19,55 +19,41 @@ package org.apache.nifi.stream.io; import java.io.InputStream; /** - * This class performs the same function as java.io.ByteArrayInputStream but - * does not mark its methods as synchronized + * This class performs the same function as java.io.ByteArrayInputStream but does not mark its methods as synchronized */ public class ByteArrayInputStream extends InputStream { /** - * An array of bytes that was provided by the creator of the stream. - * Elements buf[0] through buf[count-1] are the - * only bytes that can ever be read from the stream; element - * buf[pos] is the next byte to be read. + * An array of bytes that was provided by the creator of the stream. Elements buf[0] through buf[count-1] are the only bytes that can ever be read from the stream; + * element buf[pos] is the next byte to be read. */ protected byte buf[]; /** - * The index of the next character to read from the input stream buffer. - * This value should always be nonnegative and not larger than the value of - * count. The next byte to be read from the input stream buffer - * will be buf[pos]. + * The index of the next character to read from the input stream buffer. This value should always be nonnegative and not larger than the value of count. The next byte to be read from + * the input stream buffer will be buf[pos]. */ protected int pos; /** - * The currently marked position in the stream. ByteArrayInputStream objects - * are marked at position zero by default when constructed. They may be - * marked at another position within the buffer by the mark() - * method. The current buffer position is set to this point by the - * reset() method. + * The currently marked position in the stream. ByteArrayInputStream objects are marked at position zero by default when constructed. They may be marked at another position within the buffer by + * the mark() method. The current buffer position is set to this point by the reset() method. *

    - * If no mark has been set, then the value of mark is the offset passed to - * the constructor (or 0 if the offset was not supplied). + * If no mark has been set, then the value of mark is the offset passed to the constructor (or 0 if the offset was not supplied). * * @since JDK1.1 */ protected int mark = 0; /** - * The index one greater than the last valid character in the input stream - * buffer. This value should always be nonnegative and not larger than the - * length of buf. It is one greater than the position of the - * last byte within buf that can ever be read from the input - * stream buffer. + * The index one greater than the last valid character in the input stream buffer. This value should always be nonnegative and not larger than the length of buf. It is one greater + * than the position of the last byte within buf that can ever be read from the input stream buffer. */ protected int count; /** - * Creates a ByteArrayInputStream so that it uses - * buf as its buffer array. The buffer array is not copied. The - * initial value of pos is 0 and the initial value - * of count is the length of buf. + * Creates a ByteArrayInputStream so that it uses buf as its buffer array. The buffer array is not copied. The initial value of pos is 0 and the + * initial value of count is the length of buf. * * @param buf the input buffer. */ @@ -78,12 +64,8 @@ public class ByteArrayInputStream extends InputStream { } /** - * Creates ByteArrayInputStream that uses buf as - * its buffer array. The initial value of pos is - * offset and the initial value of count is the - * minimum of offset+length and buf.length. The - * buffer array is not copied. The buffer's mark is set to the specified - * offset. + * Creates ByteArrayInputStream that uses buf as its buffer array. The initial value of pos is offset and the initial value of + * count is the minimum of offset+length and buf.length. The buffer array is not copied. The buffer's mark is set to the specified offset. * * @param buf the input buffer. * @param offset the offset in the buffer of the first byte to read. @@ -97,15 +79,12 @@ public class ByteArrayInputStream extends InputStream { } /** - * Reads the next byte of data from this input stream. The value byte is - * returned as an int in the range 0 to - * 255. If no byte is available because the end of the stream - * has been reached, the value -1 is returned. + * Reads the next byte of data from this input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of + * the stream has been reached, the value -1 is returned. *

    * This read method cannot block. * - * @return the next byte of data, or -1 if the end of the - * stream has been reached. + * @return the next byte of data, or -1 if the end of the stream has been reached. */ @Override public int read() { @@ -113,29 +92,19 @@ public class ByteArrayInputStream extends InputStream { } /** - * Reads up to len bytes of data into an array of bytes from - * this input stream. If pos equals count, then - * -1 is returned to indicate end of file. Otherwise, the - * number k of bytes read is equal to the smaller of - * len and count-pos. If k is - * positive, then bytes buf[pos] through - * buf[pos+k-1] are copied into b[off] through - * b[off+k-1] in the manner performed by - * System.arraycopy. The value k is added into - * pos and k is returned. + * Reads up to len bytes of data into an array of bytes from this input stream. If pos equals count, then -1 is returned to indicate end of + * file. Otherwise, the number k of bytes read is equal to the smaller of len and count-pos. If k is positive, then bytes buf[pos] + * through buf[pos+k-1] are copied into b[off] through b[off+k-1] in the manner performed by System.arraycopy. The value k is added + * into pos and k is returned. *

    * This read method cannot block. * * @param b the buffer into which the data is read. * @param off the start offset in the destination array b * @param len the maximum number of bytes read. - * @return the total number of bytes read into the buffer, or - * -1 if there is no more data because the end of the stream - * has been reached. + * @return the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached. * @exception NullPointerException If b is null. - * @exception IndexOutOfBoundsException If off is negative, - * len is negative, or len is greater than - * b.length - off + * @exception IndexOutOfBoundsException If off is negative, len is negative, or len is greater than b.length - off */ @Override public int read(byte b[], int off, int len) { @@ -162,11 +131,8 @@ public class ByteArrayInputStream extends InputStream { } /** - * Skips n bytes of input from this input stream. Fewer bytes - * might be skipped if the end of the input stream is reached. The actual - * number k of bytes to be skipped is equal to the smaller of - * n and count-pos. The value k is - * added into pos and k is returned. + * Skips n bytes of input from this input stream. Fewer bytes might be skipped if the end of the input stream is reached. The actual number k of bytes to be skipped is + * equal to the smaller of n and count-pos. The value k is added into pos and k is returned. * * @param n the number of bytes to be skipped. * @return the actual number of bytes skipped. @@ -183,14 +149,11 @@ public class ByteArrayInputStream extends InputStream { } /** - * Returns the number of remaining bytes that can be read (or skipped over) - * from this input stream. + * Returns the number of remaining bytes that can be read (or skipped over) from this input stream. *

    - * The value returned is count - pos, which is the number - * of bytes remaining to be read from the input buffer. + * The value returned is count - pos, which is the number of bytes remaining to be read from the input buffer. * - * @return the number of remaining bytes that can be read (or skipped over) - * from this input stream without blocking. + * @return the number of remaining bytes that can be read (or skipped over) from this input stream without blocking. */ @Override public int available() { @@ -198,9 +161,7 @@ public class ByteArrayInputStream extends InputStream { } /** - * Tests if this InputStream supports mark/reset. The - * markSupported method of ByteArrayInputStream - * always returns true. + * Tests if this InputStream supports mark/reset. The markSupported method of ByteArrayInputStream always returns true. * * @since JDK1.1 */ @@ -210,12 +171,10 @@ public class ByteArrayInputStream extends InputStream { } /** - * Set the current marked position in the stream. ByteArrayInputStream - * objects are marked at position zero by default when constructed. They may - * be marked at another position within the buffer by this method. + * Set the current marked position in the stream. ByteArrayInputStream objects are marked at position zero by default when constructed. They may be marked at another position within the buffer by + * this method. *

    - * If no mark has been set, then the value of the mark is the offset passed - * to the constructor (or 0 if the offset was not supplied). + * If no mark has been set, then the value of the mark is the offset passed to the constructor (or 0 if the offset was not supplied). * *

    * Note: The readAheadLimit for this class has no meaning. @@ -228,9 +187,7 @@ public class ByteArrayInputStream extends InputStream { } /** - * Resets the buffer to the marked position. The marked position is 0 unless - * another position was marked or an offset was specified in the - * constructor. + * Resets the buffer to the marked position. The marked position is 0 unless another position was marked or an offset was specified in the constructor. */ @Override public void reset() { @@ -238,9 +195,7 @@ public class ByteArrayInputStream extends InputStream { } /** - * Closing a ByteArrayInputStream has no effect. The methods in - * this class can be called after the stream has been closed without - * generating an IOException. + * Closing a ByteArrayInputStream has no effect. The methods in this class can be called after the stream has been closed without generating an IOException. *

    */ @Override diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteArrayOutputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteArrayOutputStream.java index 459563b967..aade1999b2 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteArrayOutputStream.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteArrayOutputStream.java @@ -22,14 +22,11 @@ import java.io.UnsupportedEncodingException; import java.util.Arrays; /** - * This class provides a more efficient implementation of the - * java.io.ByteArrayOutputStream. The efficiency is gained in two ways: + * This class provides a more efficient implementation of the java.io.ByteArrayOutputStream. The efficiency is gained in two ways: *

      *
    • The write methods are not synchronized
    • - *
    • The class provides {@link #getUnderlyingBuffer()} and - * {@link #getBufferLength()}, which can be used to access the underlying byte - * array directly, rather than the System.arraycopy that {@link #toByteArray()} - * uses + *
    • The class provides {@link #getUnderlyingBuffer()} and {@link #getBufferLength()}, which can be used to access the underlying byte array directly, rather than the System.arraycopy that + * {@link #toByteArray()} uses *
    * */ @@ -46,16 +43,14 @@ public class ByteArrayOutputStream extends OutputStream { protected int count; /** - * Creates a new byte array output stream. The buffer capacity is initially - * 32 bytes, though its size increases if necessary. + * Creates a new byte array output stream. The buffer capacity is initially 32 bytes, though its size increases if necessary. */ public ByteArrayOutputStream() { this(32); } /** - * Creates a new byte array output stream, with a buffer capacity of the - * specified size, in bytes. + * Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes. * * @param size the initial size. * @exception IllegalArgumentException if size is negative. @@ -69,13 +64,10 @@ public class ByteArrayOutputStream extends OutputStream { } /** - * Increases the capacity if necessary to ensure that it can hold at least - * the number of elements specified by the minimum capacity argument. + * Increases the capacity if necessary to ensure that it can hold at least the number of elements specified by the minimum capacity argument. * * @param minCapacity the desired minimum capacity - * @throws OutOfMemoryError if {@code minCapacity < 0}. This is interpreted - * as a request for the unsatisfiably large capacity - * {@code (long) Integer.MAX_VALUE + (minCapacity - Integer.MAX_VALUE)}. + * @throws OutOfMemoryError if {@code minCapacity < 0}. This is interpreted as a request for the unsatisfiably large capacity {@code (long) Integer.MAX_VALUE + (minCapacity - Integer.MAX_VALUE)}. */ private void ensureCapacity(int minCapacity) { // overflow-conscious code @@ -85,8 +77,7 @@ public class ByteArrayOutputStream extends OutputStream { } /** - * Increases the capacity to ensure that it can hold at least the number of - * elements specified by the minimum capacity argument. + * Increases the capacity to ensure that it can hold at least the number of elements specified by the minimum capacity argument. * * @param minCapacity the desired minimum capacity */ @@ -98,8 +89,7 @@ public class ByteArrayOutputStream extends OutputStream { newCapacity = minCapacity; } if (newCapacity < 0) { - if (minCapacity < 0) // overflow - { + if (minCapacity < 0) { // overflow throw new OutOfMemoryError(); } newCapacity = Integer.MAX_VALUE; @@ -120,8 +110,7 @@ public class ByteArrayOutputStream extends OutputStream { } /** - * Writes len bytes from the specified byte array starting at - * offset off to this byte array output stream. + * Writes len bytes from the specified byte array starting at offset off to this byte array output stream. * * @param b the data. * @param off the start offset in the data. @@ -139,9 +128,8 @@ public class ByteArrayOutputStream extends OutputStream { } /** - * Writes the complete contents of this byte array output stream to the - * specified output stream argument, as if by calling the output stream's - * write method using out.write(buf, 0, count). + * Writes the complete contents of this byte array output stream to the specified output stream argument, as if by calling the output stream's write method using + * out.write(buf, 0, count). * * @param out the output stream to which to write the data. * @exception IOException if an I/O error occurs. @@ -151,10 +139,8 @@ public class ByteArrayOutputStream extends OutputStream { } /** - * Resets the count field of this byte array output stream to - * zero, so that all currently accumulated output in the output stream is - * discarded. The output stream can be used again, reusing the already - * allocated buffer space. + * Resets the count field of this byte array output stream to zero, so that all currently accumulated output in the output stream is discarded. The output stream can be used again, + * reusing the already allocated buffer space. * * @see java.io.ByteArrayInputStream#count */ @@ -163,23 +149,19 @@ public class ByteArrayOutputStream extends OutputStream { } /** - * Creates a newly allocated byte array. Its size is the current size of - * this output stream and the valid contents of the buffer have been copied - * into it. + * Creates a newly allocated byte array. Its size is the current size of this output stream and the valid contents of the buffer have been copied into it. * * @return the current contents of this output stream, as a byte array. * @see java.io.ByteArrayOutputStream#size() */ - public byte toByteArray () - [] { + public byte[] toByteArray() { return Arrays.copyOf(buf, count); } /** * Returns the current size of the buffer. * - * @return the value of the count field, which is the number of - * valid bytes in this output stream. + * @return the value of the count field, which is the number of valid bytes in this output stream. * @see java.io.ByteArrayOutputStream#count */ public int size() { @@ -187,16 +169,12 @@ public class ByteArrayOutputStream extends OutputStream { } /** - * Converts the buffer's contents into a string decoding bytes using the - * platform's default character set. The length of the new String - * is a function of the character set, and hence may not be equal to the - * size of the buffer. + * Converts the buffer's contents into a string decoding bytes using the platform's default character set. The length of the new String + * is a function of the character set, and hence may not be equal to the size of the buffer. * *

    - * This method always replaces malformed-input and unmappable-character - * sequences with the default replacement string for the platform's default - * character set. The {@linkplain java.nio.charset.CharsetDecoder} class - * should be used when more control over the decoding process is required. + * This method always replaces malformed-input and unmappable-character sequences with the default replacement string for the platform's default character set. The + * {@linkplain java.nio.charset.CharsetDecoder} class should be used when more control over the decoding process is required. * * @return String decoded from the buffer's contents. * @since JDK1.1 @@ -207,22 +185,16 @@ public class ByteArrayOutputStream extends OutputStream { } /** - * Converts the buffer's contents into a string by decoding the bytes using - * the specified {@link java.nio.charset.Charset charsetName}. The length of - * the new String is a function of the charset, and hence may not - * be equal to the length of the byte array. + * Converts the buffer's contents into a string by decoding the bytes using the specified {@link java.nio.charset.Charset charsetName}. The length of the new String is a function of the + * charset, and hence may not be equal to the length of the byte array. * *

    - * This method always replaces malformed-input and unmappable-character - * sequences with this charset's default replacement string. The {@link - * java.nio.charset.CharsetDecoder} class should be used when more control - * over the decoding process is required. + * This method always replaces malformed-input and unmappable-character sequences with this charset's default replacement string. The {@link + * java.nio.charset.CharsetDecoder} class should be used when more control over the decoding process is required. * - * @param charsetName the name of a supported - * {@linkplain java.nio.charset.Charset charset} + * @param charsetName the name of a supported {@linkplain java.nio.charset.Charset charset} * @return String decoded from the buffer's contents. - * @exception UnsupportedEncodingException If the named charset is not - * supported + * @exception UnsupportedEncodingException If the named charset is not supported * @since JDK1.1 */ public String toString(String charsetName) throws UnsupportedEncodingException { @@ -230,9 +202,7 @@ public class ByteArrayOutputStream extends OutputStream { } /** - * Closing a ByteArrayOutputStream has no effect. The methods in - * this class can be called after the stream has been closed without - * generating an IOException. + * Closing a ByteArrayOutputStream has no effect. The methods in this class can be called after the stream has been closed without generating an IOException. *

    * */ diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteCountingInputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteCountingInputStream.java index 8294af39f8..d1ed023888 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteCountingInputStream.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteCountingInputStream.java @@ -31,6 +31,11 @@ public class ByteCountingInputStream extends InputStream { this.in = in; } + public ByteCountingInputStream(final InputStream in, final long initialOffset) { + this.in = in; + this.bytesSkipped = initialOffset; + } + @Override public int read() throws IOException { final int fromSuper = in.read(); diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteCountingOutputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteCountingOutputStream.java index d8e1a42254..9bbd45ed2a 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteCountingOutputStream.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteCountingOutputStream.java @@ -28,6 +28,11 @@ public class ByteCountingOutputStream extends OutputStream { this.out = out; } + public ByteCountingOutputStream(final OutputStream out, final long initialByteCount) { + this.out = out; + this.bytesWritten = initialByteCount; + } + @Override public void write(int b) throws IOException { out.write(b); @@ -39,8 +44,6 @@ public class ByteCountingOutputStream extends OutputStream { write(b, 0, b.length); } - ; - @Override public void write(byte[] b, int off, int len) throws IOException { out.write(b, off, len); diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/DataOutputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/DataOutputStream.java index 1dd90f5ed3..e2059965a3 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/DataOutputStream.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/DataOutputStream.java @@ -23,14 +23,12 @@ import java.io.OutputStream; import java.io.UTFDataFormatException; /** - * This class is different from java.io.DataOutputStream in that it does - * synchronize on its methods. + * This class is different from java.io.DataOutputStream in that it does synchronize on its methods. */ public class DataOutputStream extends FilterOutputStream implements DataOutput { /** - * The number of bytes written to the data output stream so far. If this - * counter overflows, it will be wrapped to Integer.MAX_VALUE. + * The number of bytes written to the data output stream so far. If this counter overflows, it will be wrapped to Integer.MAX_VALUE. */ protected int written; @@ -40,9 +38,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput { private byte[] bytearr = null; /** - * Creates a new data output stream to write data to the specified - * underlying output stream. The counter written is set to - * zero. + * Creates a new data output stream to write data to the specified underlying output stream. The counter written is set to zero. * * @param out the underlying output stream, to be saved for later use. * @see java.io.FilterOutputStream#out @@ -52,8 +48,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput { } /** - * Increases the written counter by the specified value until it reaches - * Integer.MAX_VALUE. + * Increases the written counter by the specified value until it reaches Integer.MAX_VALUE. */ private void incCount(int value) { int temp = written + value; @@ -64,9 +59,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput { } /** - * Writes the specified byte (the low eight bits of the argument - * b) to the underlying output stream. If no exception is - * thrown, the counter written is incremented by + * Writes the specified byte (the low eight bits of the argument b) to the underlying output stream. If no exception is thrown, the counter written is incremented by * 1. *

    * Implements the write method of OutputStream. @@ -82,10 +75,8 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput { } /** - * Writes len bytes from the specified byte array starting at - * offset off to the underlying output stream. If no exception - * is thrown, the counter written is incremented by - * len. + * Writes len bytes from the specified byte array starting at offset off to the underlying output stream. If no exception is thrown, the counter written is + * incremented by len. * * @param b the data. * @param off the start offset in the data. @@ -100,11 +91,9 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput { } /** - * Flushes this data output stream. This forces any buffered output bytes to - * be written out to the stream. + * Flushes this data output stream. This forces any buffered output bytes to be written out to the stream. *

    - * The flush method of DataOutputStream calls the - * flush method of its underlying output stream. + * The flush method of DataOutputStream calls the flush method of its underlying output stream. * * @exception IOException if an I/O error occurs. * @see java.io.FilterOutputStream#out @@ -116,11 +105,8 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput { } /** - * Writes a boolean to the underlying output stream as a 1-byte - * value. The value true is written out as the value - * (byte)1; the value false is written out as the - * value (byte)0. If no exception is thrown, the counter - * written is incremented by 1. + * Writes a boolean to the underlying output stream as a 1-byte value. The value true is written out as the value (byte)1; the value false is + * written out as the value (byte)0. If no exception is thrown, the counter written is incremented by 1. * * @param v a boolean value to be written. * @exception IOException if an I/O error occurs. @@ -133,9 +119,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput { } /** - * Writes out a byte to the underlying output stream as a - * 1-byte value. If no exception is thrown, the counter written - * is incremented by 1. + * Writes out a byte to the underlying output stream as a 1-byte value. If no exception is thrown, the counter written is incremented by 1. * * @param v a byte value to be written. * @exception IOException if an I/O error occurs. @@ -148,9 +132,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput { } /** - * Writes a short to the underlying output stream as two bytes, - * high byte first. If no exception is thrown, the counter - * written is incremented by 2. + * Writes a short to the underlying output stream as two bytes, high byte first. If no exception is thrown, the counter written is incremented by 2. * * @param v a short to be written. * @exception IOException if an I/O error occurs. @@ -164,9 +146,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput { } /** - * Writes a char to the underlying output stream as a 2-byte - * value, high byte first. If no exception is thrown, the counter - * written is incremented by 2. + * Writes a char to the underlying output stream as a 2-byte value, high byte first. If no exception is thrown, the counter written is incremented by 2. * * @param v a char value to be written. * @exception IOException if an I/O error occurs. @@ -180,9 +160,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput { } /** - * Writes an int to the underlying output stream as four bytes, - * high byte first. If no exception is thrown, the counter - * written is incremented by 4. + * Writes an int to the underlying output stream as four bytes, high byte first. If no exception is thrown, the counter written is incremented by 4. * * @param v an int to be written. * @exception IOException if an I/O error occurs. @@ -200,9 +178,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput { private final byte writeBuffer[] = new byte[8]; /** - * Writes a long to the underlying output stream as eight - * bytes, high byte first. In no exception is thrown, the counter - * written is incremented by 8. + * Writes a long to the underlying output stream as eight bytes, high byte first. In no exception is thrown, the counter written is incremented by 8. * * @param v a long to be written. * @exception IOException if an I/O error occurs. @@ -223,11 +199,8 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput { } /** - * Converts the float argument to an int using the - * floatToIntBits method in class Float, and then - * writes that int value to the underlying output stream as a - * 4-byte quantity, high byte first. If no exception is thrown, the counter - * written is incremented by 4. + * Converts the float argument to an int using the floatToIntBits method in class Float, and then writes that int value to the underlying output + * stream as a 4-byte quantity, high byte first. If no exception is thrown, the counter written is incremented by 4. * * @param v a float value to be written. * @exception IOException if an I/O error occurs. @@ -240,11 +213,8 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput { } /** - * Converts the double argument to a long using the - * doubleToLongBits method in class Double, and - * then writes that long value to the underlying output stream - * as an 8-byte quantity, high byte first. If no exception is thrown, the - * counter written is incremented by 8. + * Converts the double argument to a long using the doubleToLongBits method in class Double, and then writes that long value to the underlying + * output stream as an 8-byte quantity, high byte first. If no exception is thrown, the counter written is incremented by 8. * * @param v a double value to be written. * @exception IOException if an I/O error occurs. @@ -257,10 +227,8 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput { } /** - * Writes out the string to the underlying output stream as a sequence of - * bytes. Each character in the string is written out, in sequence, by - * discarding its high eight bits. If no exception is thrown, the counter - * written is incremented by the length of s. + * Writes out the string to the underlying output stream as a sequence of bytes. Each character in the string is written out, in sequence, by discarding its high eight bits. If no exception is + * thrown, the counter written is incremented by the length of s. * * @param s a string of bytes to be written. * @exception IOException if an I/O error occurs. @@ -276,11 +244,8 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput { } /** - * Writes a string to the underlying output stream as a sequence of - * characters. Each character is written to the data output stream as if by - * the writeChar method. If no exception is thrown, the counter - * written is incremented by twice the length of - * s. + * Writes a string to the underlying output stream as a sequence of characters. Each character is written to the data output stream as if by the writeChar method. If no exception is + * thrown, the counter written is incremented by twice the length of s. * * @param s a String value to be written. * @exception IOException if an I/O error occurs. @@ -303,15 +268,10 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput { * modified UTF-8 * encoding in a machine-independent manner. *

    - * First, two bytes are written to the output stream as if by the - * writeShort method giving the number of bytes to follow. This - * value is the number of bytes actually written out, not the length of the - * string. Following the length, each character of the string is output, in - * sequence, using the modified UTF-8 encoding for the character. If no - * exception is thrown, the counter written is incremented by - * the total number of bytes written to the output stream. This will be at - * least two plus the length of str, and at most two plus - * thrice the length of str. + * First, two bytes are written to the output stream as if by the writeShort method giving the number of bytes to follow. This value is the number of bytes actually written out, not + * the length of the string. Following the length, each character of the string is output, in sequence, using the modified UTF-8 encoding for the character. If no exception is thrown, the counter + * written is incremented by the total number of bytes written to the output stream. This will be at least two plus the length of str, and at most two plus thrice the + * length of str. * * @param str a string to be written. * @exception IOException if an I/O error occurs. @@ -326,15 +286,10 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput { * modified UTF-8 * encoding in a machine-independent manner. *

    - * First, two bytes are written to out as if by the writeShort - * method giving the number of bytes to follow. This value is the number of - * bytes actually written out, not the length of the string. Following the - * length, each character of the string is output, in sequence, using the - * modified UTF-8 encoding for the character. If no exception is thrown, the - * counter written is incremented by the total number of bytes - * written to the output stream. This will be at least two plus the length - * of str, and at most two plus thrice the length of - * str. + * First, two bytes are written to out as if by the writeShort method giving the number of bytes to follow. This value is the number of bytes actually written out, not the length of + * the string. Following the length, each character of the string is output, in sequence, using the modified UTF-8 encoding for the character. If no exception is thrown, the counter + * written is incremented by the total number of bytes written to the output stream. This will be at least two plus the length of str, and at most two plus thrice the + * length of str. * * @param str a string to be written. * @param out destination to write to @@ -404,9 +359,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput { } /** - * Returns the current value of the counter written, the number - * of bytes written to this data output stream so far. If the counter - * overflows, it will be wrapped to Integer.MAX_VALUE. + * Returns the current value of the counter written, the number of bytes written to this data output stream so far. If the counter overflows, it will be wrapped to Integer.MAX_VALUE. * * @return the value of the written field. * @see java.io.DataOutputStream#written diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/GZIPOutputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/GZIPOutputStream.java index 2864bbb176..1e2f3c7c76 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/GZIPOutputStream.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/GZIPOutputStream.java @@ -21,9 +21,7 @@ import java.io.OutputStream; /** *

    - * This class extends the {@link java.util.zip.GZIPOutputStream} by allowing the - * constructor to provide a compression level, and uses a default value of 1, - * rather than 5. + * This class extends the {@link java.util.zip.GZIPOutputStream} by allowing the constructor to provide a compression level, and uses a default value of 1, rather than 5. *

    */ public class GZIPOutputStream extends java.util.zip.GZIPOutputStream { diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/LeakyBucketStreamThrottler.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/LeakyBucketStreamThrottler.java index ae075b5e30..5153db5aff 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/LeakyBucketStreamThrottler.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/LeakyBucketStreamThrottler.java @@ -104,7 +104,7 @@ public class LeakyBucketStreamThrottler implements StreamThrottler { @Override public int read(final byte[] b) throws IOException { - if(b.length == 0){ + if (b.length == 0) { return 0; } return read(b, 0, b.length); @@ -112,13 +112,13 @@ public class LeakyBucketStreamThrottler implements StreamThrottler { @Override public int read(byte[] b, int off, int len) throws IOException { - if ( len < 0 ) { + if (len < 0) { throw new IllegalArgumentException(); } - if ( len == 0 ) { + if (len == 0) { return 0; } - + baos.reset(); final int copied = (int) LeakyBucketStreamThrottler.this.copy(toWrap, baos, len); if (copied == 0) { @@ -190,8 +190,7 @@ public class LeakyBucketStreamThrottler implements StreamThrottler { } /** - * This class is responsible for draining water from the leaky bucket. I.e., - * it actually moves the data + * This class is responsible for draining water from the leaky bucket. I.e., it actually moves the data */ private class Drain implements Runnable { diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/LimitingInputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/LimitingInputStream.java index 421d579c2a..a657030e1a 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/LimitingInputStream.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/LimitingInputStream.java @@ -106,6 +106,6 @@ public class LimitingInputStream extends InputStream { } public long getLimit() { - return limit; + return limit; } } diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/MinimumLengthInputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/MinimumLengthInputStream.java index 2e9359956c..44e9c2e075 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/MinimumLengthInputStream.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/MinimumLengthInputStream.java @@ -22,72 +22,70 @@ import java.io.IOException; import java.io.InputStream; /** - * An InputStream that will throw EOFException if the underlying InputStream runs out of data before reaching the - * configured minimum amount of data + * An InputStream that will throw EOFException if the underlying InputStream runs out of data before reaching the configured minimum amount of data */ public class MinimumLengthInputStream extends FilterInputStream { - private final long minLength; - private long consumedCount = 0L; - - public MinimumLengthInputStream(final InputStream in, final long minLength) { - super(in); - this.minLength = minLength; - } + private final long minLength; + private long consumedCount = 0L; - - @Override - public int read() throws IOException { - final int b = super.read(); - if ( b < 0 && consumedCount < minLength ) { - throw new EOFException(); - } - - if ( b >= 0 ) { - consumedCount++; - } - - return b; - } - - @Override - public int read(byte[] b) throws IOException { - return read(b, 0, b.length); - } - - public int read(byte[] b, int off, int len) throws IOException { - final int num = super.read(b, off, len); - - if ( num < 0 && consumedCount < minLength ) { - throw new EOFException(); - } - - if ( num >= 0 ) { - consumedCount += num; - } + public MinimumLengthInputStream(final InputStream in, final long minLength) { + super(in); + this.minLength = minLength; + } + + @Override + public int read() throws IOException { + final int b = super.read(); + if (b < 0 && consumedCount < minLength) { + throw new EOFException(); + } + + if (b >= 0) { + consumedCount++; + } + + return b; + } + + @Override + public int read(byte[] b) throws IOException { + return read(b, 0, b.length); + } + + public int read(byte[] b, int off, int len) throws IOException { + final int num = super.read(b, off, len); + + if (num < 0 && consumedCount < minLength) { + throw new EOFException(); + } + + if (num >= 0) { + consumedCount += num; + } + + return num; + } + + @Override + public long skip(final long n) throws IOException { + long skipped = super.skip(n); + if (skipped < 1) { + final int b = super.read(); + if (b >= 0) { + skipped = 1; + } + } + + if (skipped < 0 && consumedCount < minLength) { + throw new EOFException(); + } + + if (skipped >= 0) { + consumedCount += skipped; + } + + return skipped; + } - return num; - } - - @Override - public long skip(final long n) throws IOException { - long skipped = super.skip(n); - if ( skipped < 1 ) { - final int b = super.read(); - if ( b >= 0 ) { - skipped = 1; - } - } - - if ( skipped < 0 && consumedCount < minLength ) { - throw new EOFException(); - } - - if ( skipped >= 0 ) { - consumedCount += skipped; - } - - return skipped; - } - } diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/NonCloseableInputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/NonCloseableInputStream.java index 0e75a22495..27a0c474f4 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/NonCloseableInputStream.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/NonCloseableInputStream.java @@ -21,9 +21,8 @@ import java.io.IOException; import java.io.InputStream; /** - * Wraps and InputStream so that the underlying InputStream cannot be closed. - * This is used so that the InputStream can be wrapped with yet another - * InputStream and prevent the outer layer from closing the inner InputStream + * Wraps and InputStream so that the underlying InputStream cannot be closed. This is used so that the InputStream can be wrapped with yet another InputStream and prevent the outer layer from closing + * the inner InputStream */ public class NonCloseableInputStream extends FilterInputStream { diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/StreamUtils.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/StreamUtils.java index 8e3d606273..64f6eaab57 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/StreamUtils.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/StreamUtils.java @@ -40,14 +40,12 @@ public class StreamUtils { } /** - * Copies numBytes from source to - * destination. If numBytes are not available from - * source, throws EOFException + * Copies numBytes from source to destination. If numBytes are not available from source, throws EOFException * - * @param source - * @param destination - * @param numBytes - * @throws IOException + * @param source the source of bytes to copy + * @param destination the destination to copy bytes to + * @param numBytes the number of bytes to copy + * @throws IOException if any issues occur while copying */ public static void copy(final InputStream source, final OutputStream destination, final long numBytes) throws IOException { final byte[] buffer = new byte[8192]; @@ -64,30 +62,25 @@ public class StreamUtils { } /** - * Reads data from the given input stream, copying it to the destination - * byte array. If the InputStream has less data than the given byte array, - * throws an EOFException + * Reads data from the given input stream, copying it to the destination byte array. If the InputStream has less data than the given byte array, throws an EOFException * - * @param source - * @param destination - * @throws IOException + * @param source the source to copy bytes from + * @param destination the destination to fill + * @throws IOException if any issues occur reading bytes */ public static void fillBuffer(final InputStream source, final byte[] destination) throws IOException { fillBuffer(source, destination, true); } /** - * Reads data from the given input stream, copying it to the destination - * byte array. If the InputStream has less data than the given byte array, - * throws an EOFException if ensureCapacity is true and - * otherwise returns the number of bytes copied + * Reads data from the given input stream, copying it to the destination byte array. If the InputStream has less data than the given byte array, throws an EOFException if + * ensureCapacity is true and otherwise returns the number of bytes copied * - * @param source - * @param destination - * @param ensureCapacity whether or not to enforce that the InputStream have - * at least as much data as the capacity of the destination byte array - * @return - * @throws IOException + * @param source the source to read bytes from + * @param destination the destination to fill + * @param ensureCapacity whether or not to enforce that the InputStream have at least as much data as the capacity of the destination byte array + * @return the number of bytes actually filled + * @throws IOException if unable to read from the underlying stream */ public static int fillBuffer(final InputStream source, final byte[] destination, final boolean ensureCapacity) throws IOException { int bytesRead = 0; @@ -109,24 +102,22 @@ public class StreamUtils { } /** - * Copies data from in to out until either we are out of data (returns null) - * or we hit one of the byte patterns identified by the - * stoppers parameter (returns the byte pattern matched). The - * bytes in the stopper will be copied. + * Copies data from in to out until either we are out of data (returns null) or we hit one of the byte patterns identified by the stoppers parameter (returns the byte pattern + * matched). The bytes in the stopper will be copied. * - * @param in - * @param out - * @param maxBytes - * @param stoppers + * @param in the source to read bytes from + * @param out the destination to write bytes to + * @param maxBytes the max bytes to copy + * @param stoppers patterns of bytes which if seen will cause the copy to stop * @return the byte array matched, or null if end of stream was reached - * @throws IOException + * @throws IOException if issues occur reading or writing bytes to the underlying streams */ public static byte[] copyInclusive(final InputStream in, final OutputStream out, final int maxBytes, final byte[]... stoppers) throws IOException { if (stoppers.length == 0) { return null; } - final List circularBuffers = new ArrayList(); + final List circularBuffers = new ArrayList<>(); for (final byte[] stopper : stoppers) { circularBuffers.add(new NonThreadSafeCircularBuffer(stopper)); } @@ -151,18 +142,15 @@ public class StreamUtils { } /** - * Copies data from in to out until either we are out of data (returns null) - * or we hit one of the byte patterns identified by the - * stoppers parameter (returns the byte pattern matched). The - * byte pattern matched will NOT be copied to the output and will be un-read - * from the input. + * Copies data from in to out until either we are out of data (returns null) or we hit one of the byte patterns identified by the stoppers parameter (returns the byte pattern + * matched). The byte pattern matched will NOT be copied to the output and will be un-read from the input. * - * @param in - * @param out - * @param maxBytes - * @param stoppers + * @param in the source to read bytes from + * @param out the destination to write bytes to + * @param maxBytes the maximum number of bytes to copy + * @param stoppers byte patterns which will cause the copy to stop if found * @return the byte array matched, or null if end of stream was reached - * @throws IOException + * @throws IOException for issues reading or writing to underlying streams */ public static byte[] copyExclusive(final InputStream in, final OutputStream out, final int maxBytes, final byte[]... stoppers) throws IOException { if (stoppers.length == 0) { @@ -171,7 +159,7 @@ public class StreamUtils { int longest = 0; NonThreadSafeCircularBuffer longestBuffer = null; - final List circularBuffers = new ArrayList(); + final List circularBuffers = new ArrayList<>(); for (final byte[] stopper : stoppers) { final NonThreadSafeCircularBuffer circularBuffer = new NonThreadSafeCircularBuffer(stopper); if (stopper.length > longest) { @@ -220,9 +208,9 @@ public class StreamUtils { * * If unable to skip that number of bytes, throws EOFException * - * @param stream - * @param bytesToSkip - * @throws IOException + * @param stream the stream to skip over + * @param bytesToSkip the number of bytes to skip + * @throws IOException if any issues reading or skipping underlying stream */ public static void skip(final InputStream stream, final long bytesToSkip) throws IOException { if (bytesToSkip <= 0) { diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ZipOutputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ZipOutputStream.java index 2b9050d888..d30af76bcd 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ZipOutputStream.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ZipOutputStream.java @@ -19,9 +19,8 @@ package org.apache.nifi.stream.io; import java.io.OutputStream; /** - * This class extends the {@link java.util.zip.ZipOutputStream} by providing a - * constructor that allows the user to specify the compression level. The - * default compression level is 1, as opposed to Java's default of 5. + * This class extends the {@link java.util.zip.ZipOutputStream} by providing a constructor that allows the user to specify the compression level. The default compression level is 1, as opposed to + * Java's default of 5. */ public class ZipOutputStream extends java.util.zip.ZipOutputStream { diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/util/NonThreadSafeCircularBuffer.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/util/NonThreadSafeCircularBuffer.java index b4b4c17ca2..f18d824903 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/util/NonThreadSafeCircularBuffer.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/util/NonThreadSafeCircularBuffer.java @@ -38,7 +38,7 @@ public class NonThreadSafeCircularBuffer { /** * Returns the oldest byte in the buffer * - * @return + * @return the oldest byte */ public int getOldestByte() { return buffer[insertionPointer]; diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/EscapeUtils.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/EscapeUtils.java index 9d48d3dc57..46739e3764 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/EscapeUtils.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/EscapeUtils.java @@ -19,24 +19,23 @@ package org.apache.nifi.util; public class EscapeUtils { /** - * Escapes the specified html by replacing &, <, >, ", ', / - * with their corresponding html entity. If html is null, null is returned. - * - * @param html - * @return + * Escapes the specified html by replacing &, <, >, ", ', / with their corresponding html entity. If html is null, null is returned. + * + * @param html to escape + * @return escaped html */ public static String escapeHtml(String html) { if (html == null) { return null; } - + html = html.replace("&", "&"); html = html.replace("<", "<"); html = html.replace(">", ">"); html = html.replace("\"", """); html = html.replace("'", "'"); html = html.replace("/", "/"); - + return html; } } diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/FormatUtils.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/FormatUtils.java index 805223f3b7..03afec0031 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/FormatUtils.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/FormatUtils.java @@ -49,8 +49,8 @@ public class FormatUtils { /** * Formats the specified count by adding commas. * - * @param count - * @return + * @param count the value to add commas to + * @return the string representation of the given value with commas included */ public static String formatCount(final long count) { return NumberFormat.getIntegerInstance().format(count); @@ -59,9 +59,9 @@ public class FormatUtils { /** * Formats the specified duration in 'mm:ss.SSS' format. * - * @param sourceDuration - * @param sourceUnit - * @return + * @param sourceDuration the duration to format + * @param sourceUnit the unit to interpret the duration + * @return representation of the given time data in minutes/seconds */ public static String formatMinutesSeconds(final long sourceDuration, final TimeUnit sourceUnit) { final long millis = TimeUnit.MILLISECONDS.convert(sourceDuration, sourceUnit); @@ -72,9 +72,9 @@ public class FormatUtils { /** * Formats the specified duration in 'HH:mm:ss.SSS' format. * - * @param sourceDuration - * @param sourceUnit - * @return + * @param sourceDuration the duration to format + * @param sourceUnit the unit to interpret the duration + * @return representation of the given time data in hours/minutes/seconds */ public static String formatHoursMinutesSeconds(final long sourceDuration, final TimeUnit sourceUnit) { final long millis = TimeUnit.MILLISECONDS.convert(sourceDuration, sourceUnit); diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/LongHolder.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/LongHolder.java index ef70ce805a..fa2d06333d 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/LongHolder.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/LongHolder.java @@ -17,10 +17,8 @@ package org.apache.nifi.util; /** - * Wraps a Long value so that it can be declared final and still be - * accessed from which inner classes; the functionality is similar to that of an - * AtomicLong, but operations on this class are not atomic. This results in - * greater performance when the atomicity is not needed. + * Wraps a Long value so that it can be declared final and still be accessed from which inner classes; the functionality is similar to that of an AtomicLong, but operations on this class + * are not atomic. This results in greater performance when the atomicity is not needed. */ public class LongHolder extends ObjectHolder { diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/NaiveSearchRingBuffer.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/NaiveSearchRingBuffer.java index 85bfd96e67..0c6c575273 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/NaiveSearchRingBuffer.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/NaiveSearchRingBuffer.java @@ -24,9 +24,8 @@ import java.util.Arrays; *

    * *

    - * This class implements an efficient naive search algorithm, which allows the - * user of the library to identify byte sequences in a stream on-the-fly so that - * the stream can be segmented without having to buffer the data. + * This class implements an efficient naive search algorithm, which allows the user of the library to identify byte sequences in a stream on-the-fly so that the stream can be segmented without having + * to buffer the data. *

    * *

    @@ -60,12 +59,8 @@ public class NaiveSearchRingBuffer { } /** - * Returns the contents of the internal buffer, which represents the last X - * bytes added to the buffer, where X is the minimum of the number of bytes - * added to the buffer or the length of the byte sequence for which we are - * looking - * - * @return + * @return the contents of the internal buffer, which represents the last X bytes added to the buffer, where X is the minimum of the number of bytes added to the buffer or the length of the byte + * sequence for which we are looking */ public byte[] getBufferContents() { final int contentLength = Math.min(lookingFor.length, bufferSize); @@ -78,20 +73,14 @@ public class NaiveSearchRingBuffer { } /** - * Returns the oldest byte in the buffer - * - * @return + * @return the oldest byte in the buffer */ public int getOldestByte() { return buffer[insertionPointer]; } /** - * Returns true if the number of bytes that have been added to - * the buffer is at least equal to the length of the byte sequence for which - * we are searching - * - * @return + * @return true if the number of bytes that have been added to the buffer is at least equal to the length of the byte sequence for which we are searching */ public boolean isFilled() { return bufferSize >= buffer.length; @@ -107,12 +96,10 @@ public class NaiveSearchRingBuffer { } /** - * Add the given byte to the buffer and notify whether or not the byte - * completes the desired byte sequence. + * Add the given byte to the buffer and notify whether or not the byte completes the desired byte sequence. * - * @param data - * @return true if this byte completes the byte sequence, - * false otherwise. + * @param data the data to add to the buffer + * @return true if this byte completes the byte sequence, false otherwise. */ public boolean addAndCompare(final byte data) { buffer[insertionPointer] = data; diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/ObjectHolder.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/ObjectHolder.java index a58ec6a10e..12a887cf9b 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/ObjectHolder.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/ObjectHolder.java @@ -19,7 +19,6 @@ package org.apache.nifi.util; /** * A bean that holds a single value of type T. * - * @param */ public class ObjectHolder { diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/RingBuffer.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/RingBuffer.java index 81f32ab3ed..8cadc01775 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/RingBuffer.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/RingBuffer.java @@ -26,7 +26,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; /** * Thread-safe implementation of a RingBuffer * - * @param */ public class RingBuffer { @@ -43,11 +42,10 @@ public class RingBuffer { } /** - * Adds the given value to the RingBuffer and returns the value that was - * removed in order to make room. + * Adds the given value to the RingBuffer and returns the value that was removed in order to make room. * - * @param value - * @return + * @param value the new value to add + * @return value previously in the buffer */ @SuppressWarnings("unchecked") public T add(final T value) { @@ -135,8 +133,8 @@ public class RingBuffer { /** * Removes all elements from the RingBuffer that match the given filter * - * @param filter - * @return + * @param filter to use for deciding what is removed + * @return always zero */ public int removeSelectedElements(final Filter filter) { int count = 0; @@ -203,28 +201,21 @@ public class RingBuffer { } /** - * Iterates over each element in the RingBuffer, calling the - * {@link ForEachEvaluator#evaluate(Object) evaluate} method on each element - * in the RingBuffer. If the Evaluator returns {@code false}, the method - * will skip all remaining elements in the RingBuffer; otherwise, the next - * element will be evaluated until all elements have been evaluated. + * Iterates over each element in the RingBuffer, calling the {@link ForEachEvaluator#evaluate(Object) evaluate} method on each element in the RingBuffer. If the Evaluator returns {@code false}, + * the method will skip all remaining elements in the RingBuffer; otherwise, the next element will be evaluated until all elements have been evaluated. * - * @param evaluator + * @param evaluator used to evaluate each item in the ring buffer */ public void forEach(final ForEachEvaluator evaluator) { forEach(evaluator, IterationDirection.FORWARD); } /** - * Iterates over each element in the RingBuffer, calling the - * {@link ForEachEvaluator#evaluate(Object) evaluate} method on each element - * in the RingBuffer. If the Evaluator returns {@code false}, the method - * will skip all remaining elements in the RingBuffer; otherwise, the next - * element will be evaluated until all elements have been evaluated. + * Iterates over each element in the RingBuffer, calling the {@link ForEachEvaluator#evaluate(Object) evaluate} method on each element in the RingBuffer. If the Evaluator returns {@code false}, + * the method will skip all remaining elements in the RingBuffer; otherwise, the next element will be evaluated until all elements have been evaluated. * - * @param evaluator - * @param iterationDirection the order in which to iterate over the elements - * in the RingBuffer + * @param evaluator the evaluator + * @param iterationDirection the order in which to iterate over the elements in the RingBuffer */ public void forEach(final ForEachEvaluator evaluator, final IterationDirection iterationDirection) { readLock.lock(); @@ -267,19 +258,17 @@ public class RingBuffer { } /** - * Defines an interface that can be used to iterate over all of the elements - * in the RingBuffer via the {@link #forEach} method + * Defines an interface that can be used to iterate over all of the elements in the RingBuffer via the {@link #forEach} method * - * @param + * @param the type to evaluate */ public static interface ForEachEvaluator { /** - * Evaluates the given element and returns {@code true} if the next - * element should be evaluated, {@code false} otherwise + * Evaluates the given element and returns {@code true} if the next element should be evaluated, {@code false} otherwise * - * @param value - * @return + * @param value the value to evaluate + * @return true if should continue evaluating; false otherwise */ boolean evaluate(S value); } diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/StopWatch.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/StopWatch.java index cd119305f3..cffe49ced7 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/StopWatch.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/StopWatch.java @@ -55,11 +55,10 @@ public final class StopWatch { /** * Returns the amount of time that the StopWatch was running. * - * @param timeUnit - * @return + * @param timeUnit the unit for which the duration should be reported + * @return the duration of the stopwatch in the specified unit * - * @throws IllegalStateException if the StopWatch has not been stopped via - * {@link #stop()} + * @throws IllegalStateException if the StopWatch has not been stopped via {@link #stop()} */ public long getDuration(final TimeUnit timeUnit) { if (duration < 0) { @@ -71,8 +70,8 @@ public final class StopWatch { /** * Returns the amount of time that has elapsed since the timer was started. * - * @param timeUnit - * @return + * @param timeUnit the unit for which the elapsed time should be computed + * @return the elapsed time in the specified unit */ public long getElapsed(final TimeUnit timeUnit) { return timeUnit.convert(System.nanoTime() - startNanos, TimeUnit.NANOSECONDS); diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/Tuple.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/Tuple.java index 63736ed2f6..c797c7f9b0 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/Tuple.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/Tuple.java @@ -16,12 +16,6 @@ */ package org.apache.nifi.util; -/** - * - * @author unattrib - * @param - * @param - */ public class Tuple { final A key; diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/concurrency/DebugDisabledTimedLock.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/concurrency/DebugDisabledTimedLock.java index a8d7e82650..8faf3ba319 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/concurrency/DebugDisabledTimedLock.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/concurrency/DebugDisabledTimedLock.java @@ -29,7 +29,7 @@ public class DebugDisabledTimedLock implements DebuggableTimedLock { /** * - * @return + * @return true if lock obtained; false otherwise */ @Override public boolean tryLock() { @@ -38,9 +38,9 @@ public class DebugDisabledTimedLock implements DebuggableTimedLock { /** * - * @param timeout - * @param timeUnit - * @return + * @param timeout the duration of time to wait for the lock + * @param timeUnit the unit which provides meaning to the duration + * @return true if obtained lock in time; false otherwise */ @Override public boolean tryLock(final long timeout, final TimeUnit timeUnit) { @@ -51,9 +51,6 @@ public class DebugDisabledTimedLock implements DebuggableTimedLock { } } - /** - * - */ @Override public void lock() { lock.lock(); diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/concurrency/DebugEnabledTimedLock.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/concurrency/DebugEnabledTimedLock.java index f082168582..e7d599eb41 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/concurrency/DebugEnabledTimedLock.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/concurrency/DebugEnabledTimedLock.java @@ -44,8 +44,7 @@ public class DebugEnabledTimedLock implements DebuggableTimedLock { } /** - * - * @return + * @return true if lock obtained; false otherwise */ @Override public boolean tryLock() { @@ -61,10 +60,9 @@ public class DebugEnabledTimedLock implements DebuggableTimedLock { } /** - * - * @param timeout - * @param timeUnit - * @return + * @param timeout duration to wait for lock + * @param timeUnit unit to understand given duration + * @return true if lock obtained in time; false otherwise */ @Override public boolean tryLock(final long timeout, final TimeUnit timeUnit) { @@ -84,9 +82,6 @@ public class DebugEnabledTimedLock implements DebuggableTimedLock { return true; } - /** - * - */ @Override public void lock() { logger.trace("Obtaining Lock {}", name); @@ -96,8 +91,7 @@ public class DebugEnabledTimedLock implements DebuggableTimedLock { } /** - * - * @param task + * @param task to release the lock for */ @Override public void unlock(final String task) { diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/file/FileUtils.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/file/FileUtils.java index 41a05576f6..7661e2dc41 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/file/FileUtils.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/file/FileUtils.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.util.file; -import java.io.BufferedInputStream; import java.io.Closeable; import java.io.File; import java.io.FileInputStream; @@ -40,10 +39,8 @@ import java.util.Random; import org.slf4j.Logger; /** - * A utility class containing a few useful static methods to do typical IO - * operations. + * A utility class containing a few useful static methods to do typical IO operations. * - * @author unattributed */ public class FileUtils { @@ -53,7 +50,7 @@ public class FileUtils { /** * Closes the given closeable quietly - no logging, no exceptions... * - * @param closeable + * @param closeable the thing to close */ public static void closeQuietly(final Closeable closeable) { if (null != closeable) { @@ -66,9 +63,9 @@ public class FileUtils { } /** - * Releases the given lock quietly - no logging, no exception + * Releases the given lock quietly no logging, no exception * - * @param lock + * @param lock the lock to release */ public static void releaseQuietly(final FileLock lock) { if (null != lock) { @@ -95,25 +92,22 @@ public class FileUtils { } /** - * Deletes the given file. If the given file exists but could not be deleted - * this will be printed as a warning to the given logger + * Deletes the given file. If the given file exists but could not be deleted this will be printed as a warning to the given logger * - * @param file - * @param logger - * @return + * @param file the file to delete + * @param logger the logger to provide logging information to about the operation + * @return true if given file no longer exists */ public static boolean deleteFile(final File file, final Logger logger) { return FileUtils.deleteFile(file, logger, 1); } /** - * Deletes the given file. If the given file exists but could not be deleted - * this will be printed as a warning to the given logger + * Deletes the given file. If the given file exists but could not be deleted this will be printed as a warning to the given logger * - * @param file - * @param logger - * @param attempts indicates how many times an attempt to delete should be - * made + * @param file the file to delete + * @param logger the logger to write to + * @param attempts indicates how many times an attempt to delete should be made * @return true if given file no longer exists */ public static boolean deleteFile(final File file, final Logger logger, final int attempts) { @@ -143,8 +137,7 @@ public class FileUtils { } /** - * Deletes all of the given files. If any exist and cannot be deleted that - * will be printed at warn to the given logger. + * Deletes all of the given files. If any exist and cannot be deleted that will be printed at warn to the given logger. * * @param files can be null * @param logger can be null @@ -154,13 +147,11 @@ public class FileUtils { } /** - * Deletes all of the given files. If any exist and cannot be deleted that - * will be printed at warn to the given logger. + * Deletes all of the given files. If any exist and cannot be deleted that will be printed at warn to the given logger. * * @param files can be null * @param logger can be null - * @param attempts indicates how many times an attempt should be made to - * delete each file + * @param attempts indicates how many times an attempt should be made to delete each file */ public static void deleteFile(final List files, final Logger logger, final int attempts) { if (null == files || files.isEmpty()) { @@ -188,43 +179,37 @@ public class FileUtils { } /** - * Deletes all files (not directories..) in the given directory (non - * recursive) that match the given filename filter. If any file cannot be - * deleted then this is printed at warn to the given logger. + * Deletes all files (not directories..) in the given directory (non recursive) that match the given filename filter. If any file cannot be deleted then this is printed at warn to the given + * logger. * - * @param directory + * @param directory the directory to scan for files to delete * @param filter if null then no filter is used - * @param logger + * @param logger the logger to use */ public static void deleteFilesInDir(final File directory, final FilenameFilter filter, final Logger logger) { FileUtils.deleteFilesInDir(directory, filter, logger, false); } /** - * Deletes all files (not directories) in the given directory (recursive) - * that match the given filename filter. If any file cannot be deleted then - * this is printed at warn to the given logger. + * Deletes all files (not directories) in the given directory (recursive) that match the given filename filter. If any file cannot be deleted then this is printed at warn to the given logger. * - * @param directory + * @param directory the directory to scan * @param filter if null then no filter is used - * @param logger - * @param recurse + * @param logger the logger to use + * @param recurse indicates whether to recurse subdirectories */ public static void deleteFilesInDir(final File directory, final FilenameFilter filter, final Logger logger, final boolean recurse) { FileUtils.deleteFilesInDir(directory, filter, logger, recurse, false); } /** - * Deletes all files (not directories) in the given directory (recursive) - * that match the given filename filter. If any file cannot be deleted then - * this is printed at warn to the given logger. + * Deletes all files (not directories) in the given directory (recursive) that match the given filename filter. If any file cannot be deleted then this is printed at warn to the given logger. * - * @param directory + * @param directory the directory to scan * @param filter if null then no filter is used - * @param logger - * @param recurse - * @param deleteEmptyDirectories default is false; if true will delete - * directories found that are empty + * @param logger the logger + * @param recurse whether to recurse subdirectories or not + * @param deleteEmptyDirectories default is false; if true will delete directories found that are empty */ public static void deleteFilesInDir(final File directory, final FilenameFilter filter, final Logger logger, final boolean recurse, final boolean deleteEmptyDirectories) { // ensure the specified directory is actually a directory and that it exists @@ -248,9 +233,9 @@ public class FileUtils { /** * Deletes given files. * - * @param files - * @param recurse will recurse - * @throws IOException + * @param files the files to delete + * @param recurse will recurse if true; false otherwise + * @throws IOException if any issues deleting specified files */ public static void deleteFiles(final Collection files, final boolean recurse) throws IOException { for (final File file : files) { @@ -269,11 +254,9 @@ public class FileUtils { } /** - * Randomly generates a sequence of bytes and overwrites the contents of the - * file a number of times. The file is then deleted. + * Randomly generates a sequence of bytes and overwrites the contents of the file a number of times. The file is then deleted. * - * @param file File to be overwritten a number of times and, ultimately, - * deleted + * @param file File to be overwritten a number of times and, ultimately, deleted * @param passes Number of times file should be overwritten * @throws IOException if something makes shredding or deleting a problem */ @@ -349,31 +332,22 @@ public class FileUtils { } /** - * Copies the given source file to the given destination file. The given - * destination will be overwritten if it already exists. + * Copies the given source file to the given destination file. The given destination will be overwritten if it already exists. * - * @param source - * @param destination - * @param lockInputFile if true will lock input file during copy; if false - * will not - * @param lockOutputFile if true will lock output file during copy; if false - * will not - * @param move if true will perform what is effectively a move operation - * rather than a pure copy. This allows for potentially highly efficient - * movement of the file but if not possible this will revert to a copy then - * delete behavior. If false, then the file is copied and the source file is - * retained. If a true rename/move occurs then no lock is held during that - * time. - * @param logger if failures occur, they will be logged to this logger if - * possible. If this logger is null, an IOException will instead be thrown, - * indicating the problem. + * @param source the file to copy + * @param destination the file to copy to + * @param lockInputFile if true will lock input file during copy; if false will not + * @param lockOutputFile if true will lock output file during copy; if false will not + * @param move if true will perform what is effectively a move operation rather than a pure copy. This allows for potentially highly efficient movement of the file but if not possible this will + * revert to a copy then delete behavior. If false, then the file is copied and the source file is retained. If a true rename/move occurs then no lock is held during that time. + * @param logger if failures occur, they will be logged to this logger if possible. If this logger is null, an IOException will instead be thrown, indicating the problem. * @return long number of bytes copied * @throws FileNotFoundException if the source file could not be found - * @throws IOException - * @throws SecurityException if a security manager denies the needed file - * operations + * @throws IOException if unable to read or write the underlying streams + * @throws SecurityException if a security manager denies the needed file operations */ - public static long copyFile(final File source, final File destination, final boolean lockInputFile, final boolean lockOutputFile, final boolean move, final Logger logger) throws FileNotFoundException, IOException { + public static long copyFile(final File source, final File destination, final boolean lockInputFile, final boolean lockOutputFile, final boolean move, final Logger logger) + throws FileNotFoundException, IOException { FileInputStream fis = null; FileOutputStream fos = null; @@ -433,21 +407,17 @@ public class FileUtils { } /** - * Copies the given source file to the given destination file. The given - * destination will be overwritten if it already exists. + * Copies the given source file to the given destination file. The given destination will be overwritten if it already exists. * - * @param source - * @param destination - * @param lockInputFile if true will lock input file during copy; if false - * will not - * @param lockOutputFile if true will lock output file during copy; if false - * will not - * @param logger + * @param source the file to copy from + * @param destination the file to copy to + * @param lockInputFile if true will lock input file during copy; if false will not + * @param lockOutputFile if true will lock output file during copy; if false will not + * @param logger the logger to use * @return long number of bytes copied * @throws FileNotFoundException if the source file could not be found - * @throws IOException - * @throws SecurityException if a security manager denies the needed file - * operations + * @throws IOException if unable to read or write to file + * @throws SecurityException if a security manager denies the needed file operations */ public static long copyFile(final File source, final File destination, final boolean lockInputFile, final boolean lockOutputFile, final Logger logger) throws FileNotFoundException, IOException { return FileUtils.copyFile(source, destination, lockInputFile, lockOutputFile, false, logger); @@ -496,10 +466,8 @@ public class FileUtils { } /** - * Renames the given file from the source path to the destination path. This - * handles multiple attempts. This should only be used to rename within a - * given directory. Renaming across directories might not work well. See the - * File.renameTo for more information. + * Renames the given file from the source path to the destination path. This handles multiple attempts. This should only be used to rename within a given directory. Renaming across directories + * might not work well. See the File.renameTo for more information. * * @param source the file to rename * @param destination the file path to rename to @@ -511,19 +479,14 @@ public class FileUtils { } /** - * Renames the given file from the source path to the destination path. This - * handles multiple attempts. This should only be used to rename within a - * given directory. Renaming across directories might not work well. See the - * File.renameTo for more information. + * Renames the given file from the source path to the destination path. This handles multiple attempts. This should only be used to rename within a given directory. Renaming across directories + * might not work well. See the File.renameTo for more information. * * @param source the file to rename * @param destination the file path to rename to * @param maxAttempts the max number of attempts to attempt the rename - * @param replace if true and a rename attempt fails will check if a file is - * already at the destination path. If so it will delete that file and - * attempt the rename according the remaining maxAttempts. If false, any - * conflicting files will be left as they were and the rename attempts will - * fail if conflicting. + * @param replace if true and a rename attempt fails will check if a file is already at the destination path. If so it will delete that file and attempt the rename according the remaining + * maxAttempts. If false, any conflicting files will be left as they were and the rename attempts will fail if conflicting. * @throws IOException if rename isn't successful */ public static void renameFile(final File source, final File destination, final int maxAttempts, final boolean replace) throws IOException { @@ -552,20 +515,15 @@ public class FileUtils { } /** - * Syncs a primary copy of a file with the copy in the restore directory. If - * the restore directory does not have a file and the primary has a file, - * the the primary's file is copied to the restore directory. Else if the - * restore directory has a file, but the primary does not, then the - * restore's file is copied to the primary directory. Else if the primary - * file is different than the restore file, then an IllegalStateException is - * thrown. Otherwise, if neither file exists, then no syncing is performed. + * Syncs a primary copy of a file with the copy in the restore directory. If the restore directory does not have a file and the primary has a file, the the primary's file is copied to the restore + * directory. Else if the restore directory has a file, but the primary does not, then the restore's file is copied to the primary directory. Else if the primary file is different than the restore + * file, then an IllegalStateException is thrown. Otherwise, if neither file exists, then no syncing is performed. * * @param primaryFile the primary file * @param restoreFile the restore file * @param logger a logger * @throws IOException if an I/O problem was encountered during syncing - * @throws IllegalStateException if the primary and restore copies exist but - * are different + * @throws IllegalStateException if the primary and restore copies exist but are different */ public static void syncWithRestore(final File primaryFile, final File restoreFile, final Logger logger) throws IOException { diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/file/monitor/CompoundUpdateMonitor.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/file/monitor/CompoundUpdateMonitor.java index 6f9c61664a..dc60318379 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/file/monitor/CompoundUpdateMonitor.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/file/monitor/CompoundUpdateMonitor.java @@ -22,11 +22,8 @@ import java.util.ArrayList; import java.util.List; /** - * An {@link UpdateMonitor} that combines multiple UpdateMonitors - * such that it will indicate a change in a file only if ALL sub-monitors - * indicate a change. The sub-monitors will be applied in the order given and if - * any indicates that the state has not changed, the subsequent sub-monitors may - * not be given a chance to run + * An {@link UpdateMonitor} that combines multiple UpdateMonitors such that it will indicate a change in a file only if ALL sub-monitors indicate a change. The sub-monitors will be + * applied in the order given and if any indicates that the state has not changed, the subsequent sub-monitors may not be given a chance to run */ public class CompoundUpdateMonitor implements UpdateMonitor { diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/file/monitor/SynchronousFileWatcher.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/file/monitor/SynchronousFileWatcher.java index e0089c196b..0040037ca6 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/file/monitor/SynchronousFileWatcher.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/file/monitor/SynchronousFileWatcher.java @@ -23,8 +23,7 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; /** - * Allows the user to configure a {@link java.nio.file.Path Path} to watch for - * modifications and periodically poll to check if the file has been modified + * Allows the user to configure a {@link java.nio.file.Path Path} to watch for modifications and periodically poll to check if the file has been modified */ public class SynchronousFileWatcher { @@ -58,11 +57,10 @@ public class SynchronousFileWatcher { } /** - * Checks if the file has been updated according to the configured - * {@link UpdateMonitor} and resets the state + * Checks if the file has been updated according to the configured {@link UpdateMonitor} and resets the state * - * @return - * @throws IOException + * @return true if updated; false otherwise + * @throws IOException if failure occurs checking for changes */ public boolean checkAndReset() throws IOException { if (checkUpdateMillis <= 0) { // if checkUpdateMillis <= 0, always check diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/search/Search.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/search/Search.java index 59b444a457..b407c4da31 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/search/Search.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/search/Search.java @@ -23,34 +23,26 @@ import java.util.Set; import org.apache.nifi.util.search.ahocorasick.SearchState; /** - * Defines an interface to search for content given a set of search terms. Any - * implementation of search must be thread safe. + * Defines an interface to search for content given a set of search terms. Any implementation of search must be thread safe. * - * @author - * @param */ public interface Search { /** - * Establishes the dictionary of terms which will be searched in subsequent - * search calls. This can be called only once + * Establishes the dictionary of terms which will be searched in subsequent search calls. This can be called only once * - * @param terms + * @param terms the terms to create a dictionary of */ void initializeDictionary(Set> terms); /** - * Searches the given input stream for matches between the already specified - * dictionary and the contents scanned. + * Searches the given input stream for matches between the already specified dictionary and the contents scanned. * - * @param haystack - * @param findAll if true will find all matches if false will find only the - * first match - * @return SearchState containing results Map might be empty which indicates - * no matches found but will not be null + * @param haystack the source data to scan for hits + * @param findAll if true will find all matches if false will find only the first match + * @return SearchState containing results Map might be empty which indicates no matches found but will not be null * @throws IOException Thrown for any exceptions occurring while searching. - * @throws IllegalStateException if the dictionary has not yet been - * initialized + * @throws IllegalStateException if the dictionary has not yet been initialized */ SearchState search(InputStream haystack, boolean findAll) throws IOException; diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/search/SearchTerm.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/search/SearchTerm.java index 62de964b9f..48f8678411 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/search/SearchTerm.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/search/SearchTerm.java @@ -22,8 +22,6 @@ import java.util.Arrays; /** * This is an immutable thread safe object representing a search term * - * @author - * @param */ public class SearchTerm { @@ -34,21 +32,20 @@ public class SearchTerm { /** * Constructs a SearchTerm. Defensively copies the given byte array * - * @param bytes - * @throws IllegalArgument exception if given bytes are null or 0 length + * @param bytes the bytes of the search term + * @throws IllegalArgumentException if given bytes are null or 0 length */ public SearchTerm(final byte[] bytes) { this(bytes, true, null); } /** - * Constructs a search term. Optionally performs a defensive copy of the - * given byte array. If the caller indicates a defensive copy is not - * necessary then they must not change the given arrays state any longer + * Constructs a search term. Optionally performs a defensive copy of the given byte array. If the caller indicates a defensive copy is not necessary then they must not change the given arrays + * state any longer * - * @param bytes - * @param defensiveCopy - * @param reference + * @param bytes the bytes of the new search term + * @param defensiveCopy if true will make a defensive copy; false otherwise + * @param reference a holder for an object which can be retrieved when this search term hits */ public SearchTerm(final byte[] bytes, final boolean defensiveCopy, final T reference) { if (bytes == null || bytes.length == 0) { @@ -84,7 +81,7 @@ public class SearchTerm { /** * Determines if the given window starts with the same bytes as this term * - * @param window Current window of bytes from the haystack being evaluated. + * @param window bytes from the haystack being evaluated * @param windowLength The length of the window to consider * @return true if this term starts with the same bytes of the given window */ diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/search/ahocorasick/Node.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/search/ahocorasick/Node.java index 0ac325cf56..d61ae6fcb7 100644 --- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/search/ahocorasick/Node.java +++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/search/ahocorasick/Node.java @@ -23,7 +23,6 @@ import org.apache.nifi.util.search.SearchTerm; /** * - * @author */ public class Node { diff --git a/nifi/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/file/monitor/TestCompoundUpdateMonitor.java b/nifi/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/file/monitor/TestCompoundUpdateMonitor.java index f576e94b1e..ec04efb70c 100644 --- a/nifi/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/file/monitor/TestCompoundUpdateMonitor.java +++ b/nifi/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/file/monitor/TestCompoundUpdateMonitor.java @@ -27,7 +27,6 @@ import java.io.OutputStream; import java.nio.file.Path; import java.util.UUID; - import org.junit.Test; public class TestCompoundUpdateMonitor { diff --git a/nifi/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/file/monitor/TestSynchronousFileWatcher.java b/nifi/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/file/monitor/TestSynchronousFileWatcher.java index 7125581b5e..3440c165ef 100644 --- a/nifi/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/file/monitor/TestSynchronousFileWatcher.java +++ b/nifi/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/file/monitor/TestSynchronousFileWatcher.java @@ -30,7 +30,6 @@ import java.nio.file.StandardCopyOption; import org.junit.Test; - public class TestSynchronousFileWatcher { @Test diff --git a/nifi/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/timebuffer/TestRingBuffer.java b/nifi/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/timebuffer/TestRingBuffer.java index 5f8c4c8db9..b01b495076 100644 --- a/nifi/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/timebuffer/TestRingBuffer.java +++ b/nifi/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/timebuffer/TestRingBuffer.java @@ -36,13 +36,13 @@ public class TestRingBuffer { @Test public void testGetNewestElement() { final RingBuffer ringBuffer = new RingBuffer<>(10); - - for (int i=0; i < 11; i++) { + + for (int i = 0; i < 11; i++) { ringBuffer.add(i); assertEquals(i, ringBuffer.getNewestElement().intValue()); } } - + @Test public void testAsList() { final RingBuffer ringBuffer = new RingBuffer<>(10); diff --git a/nifi/nifi-commons/nifi-web-utils/src/main/java/org/apache/nifi/web/util/ClientUtils.java b/nifi/nifi-commons/nifi-web-utils/src/main/java/org/apache/nifi/web/util/ClientUtils.java index 8c0b1f4363..1eaf366bf5 100644 --- a/nifi/nifi-commons/nifi-web-utils/src/main/java/org/apache/nifi/web/util/ClientUtils.java +++ b/nifi/nifi-commons/nifi-web-utils/src/main/java/org/apache/nifi/web/util/ClientUtils.java @@ -40,10 +40,10 @@ public class ClientUtils { /** * Gets the content at the specified URI. * - * @param uri - * @return - * @throws ClientHandlerException - * @throws UniformInterfaceException + * @param uri the URI to get the content of + * @return the client response resulting from getting the content of the URI + * @throws ClientHandlerException if issues occur handling the request + * @throws UniformInterfaceException if any interface violations occur */ public ClientResponse get(final URI uri) throws ClientHandlerException, UniformInterfaceException { return get(uri, null); @@ -52,11 +52,11 @@ public class ClientUtils { /** * Gets the content at the specified URI using the given query parameters. * - * @param uri - * @param queryParams - * @return - * @throws ClientHandlerException - * @throws UniformInterfaceException + * @param uri the URI to get the content of + * @param queryParams the query parameters to use in the request + * @return the client response resulting from getting the content of the URI + * @throws ClientHandlerException if issues occur handling the request + * @throws UniformInterfaceException if any interface violations occur */ public ClientResponse get(final URI uri, final Map queryParams) throws ClientHandlerException, UniformInterfaceException { // perform the request @@ -73,9 +73,9 @@ public class ClientUtils { /** * Performs a POST using the specified url and entity body. * - * @param uri - * @param entity - * @return + * @param uri the URI to post to + * @param entity the item to post + * @return the client response of the request */ public ClientResponse post(URI uri, Object entity) throws ClientHandlerException, UniformInterfaceException { // get the resource @@ -93,9 +93,9 @@ public class ClientUtils { /** * Performs a POST using the specified url and form data. * - * @param uri - * @param formData - * @return + * @param uri the uri to post to + * @param formData the data to post + * @return the client reponse of the post */ public ClientResponse post(URI uri, Map formData) throws ClientHandlerException, UniformInterfaceException { // convert the form data @@ -119,10 +119,10 @@ public class ClientUtils { /** * Performs a HEAD request to the specified URI. * - * @param uri - * @return - * @throws ClientHandlerException - * @throws UniformInterfaceException + * @param uri the uri to request the head of + * @return the client response of the request + * @throws ClientHandlerException for issues handling the request + * @throws UniformInterfaceException for issues with the request */ public ClientResponse head(final URI uri) throws ClientHandlerException, UniformInterfaceException { // perform the request diff --git a/nifi/nifi-commons/nifi-web-utils/src/main/java/org/apache/nifi/web/util/WebUtils.java b/nifi/nifi-commons/nifi-web-utils/src/main/java/org/apache/nifi/web/util/WebUtils.java index 587b3d8eac..e27f91ccdc 100644 --- a/nifi/nifi-commons/nifi-web-utils/src/main/java/org/apache/nifi/web/util/WebUtils.java +++ b/nifi/nifi-commons/nifi-web-utils/src/main/java/org/apache/nifi/web/util/WebUtils.java @@ -51,7 +51,6 @@ import com.sun.jersey.client.urlconnection.HTTPSProperties; /** * Common utilities related to web development. * - * @author unattributed */ public final class WebUtils { diff --git a/nifi/nifi-commons/nifi-write-ahead-log/src/main/java/org/wali/MinimalLockingWriteAheadLog.java b/nifi/nifi-commons/nifi-write-ahead-log/src/main/java/org/wali/MinimalLockingWriteAheadLog.java index 5b20b93374..5c8b4c8d9f 100644 --- a/nifi/nifi-commons/nifi-write-ahead-log/src/main/java/org/wali/MinimalLockingWriteAheadLog.java +++ b/nifi/nifi-commons/nifi-write-ahead-log/src/main/java/org/wali/MinimalLockingWriteAheadLog.java @@ -72,7 +72,7 @@ import org.slf4j.LoggerFactory; * updates for a given Record at any one time. *

    * - * @param + * @param type of record this WAL is for */ public final class MinimalLockingWriteAheadLog implements WriteAheadRepository { @@ -113,14 +113,12 @@ public final class MinimalLockingWriteAheadLog implements WriteAheadRepositor * @param paths a sorted set of Paths to use for the partitions/journals and * the snapshot. The snapshot will always be written to the first path * specified. - * * @param partitionCount the number of partitions/journals to use. For best * performance, this should be close to the number of threads that are * expected to update the repository simultaneously - * - * @param serde - * @param syncListener - * @throws IOException + * @param serde the serializer/deserializer for records + * @param syncListener the listener + * @throws IOException if unable to initialize due to IO issue */ @SuppressWarnings("unchecked") public MinimalLockingWriteAheadLog(final SortedSet paths, final int partitionCount, final SerDe serde, final SyncListener syncListener) throws IOException { @@ -209,7 +207,9 @@ public final class MinimalLockingWriteAheadLog implements WriteAheadRepositor while (true) { final int numBlackListed = numberBlackListedPartitions.get(); if (numBlackListed >= partitions.length) { - throw new IOException("All Partitions have been blacklisted due to failures when attempting to update. If the Write-Ahead Log is able to perform a checkpoint, this issue may resolve itself. Otherwise, manual intervention will be required."); + throw new IOException("All Partitions have been blacklisted due to " + + "failures when attempting to update. If the Write-Ahead Log is able to perform a checkpoint, " + + "this issue may resolve itself. Otherwise, manual intervention will be required."); } final long partitionIdx = partitionIndex.getAndIncrement(); @@ -248,7 +248,9 @@ public final class MinimalLockingWriteAheadLog implements WriteAheadRepositor } else if (updateType == UpdateType.SWAP_OUT) { final String newLocation = serde.getLocation(record); if (newLocation == null) { - logger.error("Received Record (ID=" + recordIdentifier + ") with UpdateType of SWAP_OUT but no indicator of where the Record is to be Swapped Out to; these records may be lost when the repository is restored!"); + logger.error("Received Record (ID=" + recordIdentifier + ") with UpdateType of SWAP_OUT but " + + "no indicator of where the Record is to be Swapped Out to; these records may be " + + "lost when the repository is restored!"); } else { recordMap.remove(recordIdentifier); this.externalLocations.add(newLocation); @@ -256,7 +258,9 @@ public final class MinimalLockingWriteAheadLog implements WriteAheadRepositor } else if (updateType == UpdateType.SWAP_IN) { final String newLocation = serde.getLocation(record); if (newLocation == null) { - logger.error("Received Record (ID=" + recordIdentifier + ") with UpdateType of SWAP_IN but no indicator of where the Record is to be Swapped In from; these records may be duplicated when the repository is restored!"); + logger.error("Received Record (ID=" + recordIdentifier + ") with UpdateType of SWAP_IN but no " + + "indicator of where the Record is to be Swapped In from; these records may be duplicated " + + "when the repository is restored!"); } else { externalLocations.remove(newLocation); } @@ -345,11 +349,13 @@ public final class MinimalLockingWriteAheadLog implements WriteAheadRepositor final int waliImplementationVersion = dataIn.readInt(); if (!waliImplementationClass.equals(MinimalLockingWriteAheadLog.class.getName())) { - throw new IOException("Write-Ahead Log located at " + snapshotPath + " was written using the " + waliImplementationClass + " class; cannot restore using " + getClass().getName()); + throw new IOException("Write-Ahead Log located at " + snapshotPath + " was written using the " + + waliImplementationClass + " class; cannot restore using " + getClass().getName()); } if (waliImplementationVersion > getVersion()) { - throw new IOException("Write-Ahead Log located at " + snapshotPath + " was written using version " + waliImplementationVersion + " of the " + waliImplementationClass + " class; cannot restore using Version " + getVersion()); + throw new IOException("Write-Ahead Log located at " + snapshotPath + " was written using version " + + waliImplementationVersion + " of the " + waliImplementationClass + " class; cannot restore using Version " + getVersion()); } dataIn.readUTF(); // ignore serde class name for now @@ -380,7 +386,8 @@ public final class MinimalLockingWriteAheadLog implements WriteAheadRepositor } this.recoveredExternalLocations.addAll(swapLocations); - logger.debug("{} restored {} Records and {} Swap Files from Snapshot, ending with Transaction ID {}", new Object[]{this, numRecords, recoveredExternalLocations.size(), maxTransactionId}); + logger.debug("{} restored {} Records and {} Swap Files from Snapshot, ending with Transaction ID {}", + new Object[]{this, numRecords, recoveredExternalLocations.size(), maxTransactionId}); return maxTransactionId; } } @@ -390,10 +397,9 @@ public final class MinimalLockingWriteAheadLog implements WriteAheadRepositor * if recovery of a Partition requires the Write-Ahead Log be checkpointed * before modification. * - * @param modifiableRecordMap - * @param maxTransactionIdRestored - * @return - * @throws IOException + * @param modifiableRecordMap map + * @param maxTransactionIdRestored index of max restored transaction + * @throws IOException if unable to recover from edits */ private void recoverFromEdits(final Map modifiableRecordMap, final Long maxTransactionIdRestored) throws IOException { final Map updateMap = new HashMap<>(); @@ -422,7 +428,8 @@ public final class MinimalLockingWriteAheadLog implements WriteAheadRepositor try { partition.recoverNextTransaction(ignorableMap, updateMap, ignorableSwapLocations); } catch (final EOFException e) { - logger.error("{} unexpectedly reached End of File while reading from {} for Transaction {}; assuming crash and ignoring this transaction.", + logger.error("{} unexpectedly reached End of File while reading from {} for Transaction {}; " + + "assuming crash and ignoring this transaction.", new Object[]{this, partition, transactionId}); } } @@ -442,7 +449,8 @@ public final class MinimalLockingWriteAheadLog implements WriteAheadRepositor modifiableRecordMap.remove(id); } } catch (final EOFException e) { - logger.error("{} unexpectedly reached End-of-File when reading from {} for Transaction ID {}; assuming crash and ignoring this transaction", + logger.error("{} unexpectedly reached End-of-File when reading from {} for Transaction ID {}; " + + "assuming crash and ignoring this transaction", new Object[]{this, nextPartition, firstTransactionId}); } @@ -452,7 +460,8 @@ public final class MinimalLockingWriteAheadLog implements WriteAheadRepositor try { subsequentTransactionId = nextPartition.getNextRecoverableTransactionId(); } catch (final IOException e) { - logger.error("{} unexpectedly found End-of-File when reading from {} for Transaction ID {}; assuming crash and ignoring this transaction", + logger.error("{} unexpectedly found End-of-File when reading from {} for Transaction ID {}; " + + "assuming crash and ignoring this transaction", new Object[]{this, nextPartition, firstTransactionId}); } @@ -576,7 +585,8 @@ public final class MinimalLockingWriteAheadLog implements WriteAheadRepositor final long partitionMillis = TimeUnit.MILLISECONDS.convert(partitionEnd - partitionStart, TimeUnit.NANOSECONDS); final long stopTheWorldMillis = TimeUnit.NANOSECONDS.toMillis(stopTheWorldNanos); - logger.info("{} checkpointed with {} Records and {} Swap Files in {} milliseconds (Stop-the-world time = {} milliseconds, Clear Edit Logs time = {} millis), max Transaction ID {}", + logger.info("{} checkpointed with {} Records and {} Swap Files in {} milliseconds (Stop-the-world " + + "time = {} milliseconds, Clear Edit Logs time = {} millis), max Transaction ID {}", new Object[]{this, records.size(), swapLocations.size(), millis, stopTheWorldMillis, partitionMillis, maxTransactionId}); return records.size(); @@ -605,9 +615,9 @@ public final class MinimalLockingWriteAheadLog implements WriteAheadRepositor * * All methods with the exceptions of {@link #claim()}, {@link #tryClaim()}, * and {@link #releaseClaim()} in this Partition MUST be called while - * holding the claim (via {@link #claim} or {@link #tryClaim()). + * holding the claim (via {@link #claim} or {@link #tryClaim()}). * - * @param + * @param type of record held in the partitions */ private static class Partition { @@ -703,7 +713,7 @@ public final class MinimalLockingWriteAheadLog implements WriteAheadRepositor * Closes resources pointing to the current journal and begins writing * to a new one * - * @throws IOException + * @throws IOException if failure to rollover */ public void rollover() throws IOException { lock.lock(); @@ -777,7 +787,8 @@ public final class MinimalLockingWriteAheadLog implements WriteAheadRepositor if (isJournalFile(file)) { paths.add(file.toPath()); } else { - logger.warn("Found file {}, but could not access it, or it was not in the expected format; will ignore this file", file.getAbsolutePath()); + logger.warn("Found file {}, but could not access it, or it was not in the expected format; " + + "will ignore this file", file.getAbsolutePath()); } } @@ -836,7 +847,8 @@ public final class MinimalLockingWriteAheadLog implements WriteAheadRepositor return true; } - public void update(final Collection records, final long transactionId, final Map recordMap, final boolean forceSync) throws IOException { + public void update(final Collection records, final long transactionId, final Map recordMap, final boolean forceSync) + throws IOException { if (this.closed) { throw new IllegalStateException("Partition is closed"); } @@ -889,7 +901,8 @@ public final class MinimalLockingWriteAheadLog implements WriteAheadRepositor final long waliVersion = recoveryIn.readInt(); if (waliVersion > writeAheadLogVersion) { - throw new IOException("Cannot recovery from file " + nextRecoveryPath + " because it was written using WALI version " + waliVersion + ", but the version used to restore it is only " + writeAheadLogVersion); + throw new IOException("Cannot recovery from file " + nextRecoveryPath + " because it was written using " + + "WALI version " + waliVersion + ", but the version used to restore it is only " + writeAheadLogVersion); } @SuppressWarnings("unused") @@ -936,7 +949,8 @@ public final class MinimalLockingWriteAheadLog implements WriteAheadRepositor final Path nextRecoveryPath = this.recoveryFiles.poll(); if (nextRecoveryPath != null) { - throw new IllegalStateException("Signaled to end recovery, but there are more recovery files for Partition in directory " + editDirectory); + throw new IllegalStateException("Signaled to end recovery, but there are more recovery files for Partition " + + "in directory " + editDirectory); } final Path newEditPath = getNewEditPath(); @@ -999,7 +1013,7 @@ public final class MinimalLockingWriteAheadLog implements WriteAheadRepositor /** * Must be called after recovery has finished * - * @return + * @return max recovered transaction id */ public long getMaxRecoveredTransactionId() { return maxTransactionId.get(); diff --git a/nifi/nifi-commons/nifi-write-ahead-log/src/main/java/org/wali/SerDe.java b/nifi/nifi-commons/nifi-write-ahead-log/src/main/java/org/wali/SerDe.java index bbc7efb8ae..cc984a6122 100644 --- a/nifi/nifi-commons/nifi-write-ahead-log/src/main/java/org/wali/SerDe.java +++ b/nifi/nifi-commons/nifi-write-ahead-log/src/main/java/org/wali/SerDe.java @@ -35,10 +35,10 @@ public interface SerDe { * {@link DataOutputStream}. *

    * - * @param previousRecordState - * @param newRecordState - * @param out - * @throws IOException + * @param previousRecordState previous state + * @param newRecordState new state + * @param out stream to write to + * @throws IOException if fail during write */ void serializeEdit(T previousRecordState, T newRecordState, DataOutputStream out) throws IOException; @@ -48,9 +48,9 @@ public interface SerDe { * {@link DataOutputStream}. *

    * - * @param record - * @param out - * @throws IOException + * @param record to serialize + * @param out to write to + * @throws IOException if failed to write */ void serializeRecord(T record, DataOutputStream out) throws IOException; @@ -63,13 +63,13 @@ public interface SerDe { * This method must never return null. *

    * - * @param in + * @param in to deserialize from * @param currentRecordStates an unmodifiable map of Record ID's to the * current state of that record * @param version the version of the SerDe that was used to serialize the * edit record - * @return - * @throws IOException + * @return deserialized record + * @throws IOException if failure reading */ T deserializeEdit(DataInputStream in, Map currentRecordStates, int version) throws IOException; @@ -79,27 +79,27 @@ public interface SerDe { * record. If no data is available, returns null. *

    * - * @param in + * @param in stream to read from * @param version the version of the SerDe that was used to serialize the * record - * @return - * @throws IOException + * @return record + * @throws IOException failure reading */ T deserializeRecord(DataInputStream in, int version) throws IOException; /** * Returns the unique ID for the given record * - * @param record - * @return + * @param record to obtain identifier for + * @return identifier of record */ Object getRecordIdentifier(T record); /** * Returns the UpdateType for the given record * - * @param record - * @return + * @param record to retrieve update type for + * @return update type */ UpdateType getUpdateType(T record); @@ -112,8 +112,8 @@ public interface SerDe { * WALI with a record of type {@link UpdateType#CREATE} that indicates a * Location of file://tmp/external1 * - * @param record - * @return + * @param record to get location of + * @return location */ String getLocation(T record); @@ -122,7 +122,7 @@ public interface SerDe { * when serializing/deserializing the edit logs so that if the version * changes, we are still able to deserialize old versions * - * @return + * @return version */ int getVersion(); } diff --git a/nifi/nifi-commons/nifi-write-ahead-log/src/main/java/org/wali/WriteAheadRepository.java b/nifi/nifi-commons/nifi-write-ahead-log/src/main/java/org/wali/WriteAheadRepository.java index 4567872f6d..7f0e8281e3 100644 --- a/nifi/nifi-commons/nifi-write-ahead-log/src/main/java/org/wali/WriteAheadRepository.java +++ b/nifi/nifi-commons/nifi-write-ahead-log/src/main/java/org/wali/WriteAheadRepository.java @@ -48,7 +48,7 @@ import java.util.Set; * one partition or may allow many partitions. *

    * - * @param + * @param the type of Record this repository is for */ public interface WriteAheadRepository { @@ -63,7 +63,7 @@ public interface WriteAheadRepository { * to be flushed to disk. If false, the data may be stored in Operating * System buffers, which improves performance but could cause loss of data * if power is lost or the Operating System crashes - * @throws IOException + * @throws IOException if failure to update repo * @throws IllegalArgumentException if multiple records within the given * Collection have the same ID, as specified by {@link Record#getId()} * method @@ -78,8 +78,8 @@ public interface WriteAheadRepository { * before any updates are issued to the Repository. *

    * - * @return - * @throws IOException + * @return recovered records + * @throws IOException if failure to read from repo * @throws IllegalStateException if any updates have been issued against * this Repository before this method is invoked */ @@ -92,8 +92,8 @@ public interface WriteAheadRepository { * BEFORE {@link update}. *

    * - * @return - * @throws IOException + * @return swap location + * @throws IOException if failure reading swap locations */ Set getRecoveredSwapLocations() throws IOException; @@ -107,7 +107,7 @@ public interface WriteAheadRepository { * * * @return the number of records that were written to the new snapshot - * @throws java.io.IOException + * @throws java.io.IOException if failure during checkpoint */ int checkpoint() throws IOException; @@ -116,7 +116,7 @@ public interface WriteAheadRepository { * Causes the repository to checkpoint and then close any open resources. *

    * - * @throws IOException + * @throws IOException if failure to shutdown cleanly */ void shutdown() throws IOException; } diff --git a/nifi/nifi-docs/pom.xml b/nifi/nifi-docs/pom.xml index 7f2b02271f..f724e9690f 100644 --- a/nifi/nifi-docs/pom.xml +++ b/nifi/nifi-docs/pom.xml @@ -103,6 +103,15 @@ + + org.apache.rat + apache-rat-plugin + + + src/main/asciidoc/asciidoc-mod.css + + + maven-assembly-plugin diff --git a/nifi/nifi-docs/src/main/asciidoc/administration-guide.adoc b/nifi/nifi-docs/src/main/asciidoc/administration-guide.adoc index d33b4de975..039e5b9e8d 100644 --- a/nifi/nifi-docs/src/main/asciidoc/administration-guide.adoc +++ b/nifi/nifi-docs/src/main/asciidoc/administration-guide.adoc @@ -128,26 +128,74 @@ For the partitions handling the various NiFi repos turn off things like 'atime'. Doing so can cause a surprising bump in throughput. Edit the '/etc/fstab' file and for the partition(s) of interest add the 'noatime' option. + Security Configuration ---------------------- -NOTE: This section is incomplete. + +NiFi provides several different configuration options for security purposes. The most important properties are those under the +"security properties" heading in the _nifi.properties_ file. In order to run securely, the following properties must be set: + +[options="header,footer"] +|================================================================================================================================================== +| Property Name | Description +|`nifi.security.keystore` | Filename of the Keystore that contains the server's private key. +|`nifi.security.keystoreType` | The type of Keystore. Must be either `PKCS12` or `JKS`. +|`nifi.security.keystorePasswd` | The password for the Keystore. +|`nifi.security.keyPasswd` | The password for the certificate in the Keystore. If not set, the value of `nifi.security.keystorePasswd` will be used. +|`nifi.security.truststore` | Filename of the Truststore that will be used to authorize those connecting to NiFi. If not set, all who + attempt to connect will be provided access as the 'Anonymous' user. +|`nifi.security.truststoreType` | The type of the Truststore. Must be either `PKCS12` or `JKS`. +|`nifi.security.truststorePasswd` | The password for the Truststore. +|`nifi.security.needClientAuth` | Specifies whether or not connecting clients must authenticate themselves. If the Truststore properties are not set, + this must be `false`. Otherwise, a value of `true` indicates that users will be authenticated and must have + certificates that are trusted by the Truststore loaded into their web browsers. A value of `false` indicates + that all users should be given access as the 'Anonymous' user. +|================================================================================================================================================== + +Once the above properties have been configured, we can enable the User Interface to be accessed over HTTPS instead of HTTP. This is accomplished +by setting the `nifi.web.https.host` and `nifi.web.https.port` properties. The `nifi.web.https.host` property indicates which hostname the server +should run on. This allows admins to configure the application to run only on specific network interfaces. If it is desired that the HTTPS interface +be accessible from all network interfaces, a value of `0.0.0.0` should be used. + +NOTE: It is important when enabling HTTPS that the `nifi.web.http.port` property be unset. + +Now that the User Interface has been secured, we can easily secure Site-to-Site connections and inner-cluster communications, as well. This is +accomplished by setting the `nifi.remote.input.secure` and `nifi.cluster.protocol.is.secure` properties, respectively, to `true`. Controlling Levels of Access ---------------------------- Once NiFi is configured to run securely as discussed in the previous section, it is necessary -to manually designate an ADMIN user in the _authorized-users.xml_ file, which is located in the -root installation's conf directory. After this ADMIN user has been added, s/he may grant access +to configure who will have access to the system and what types of access those people will have. +NiFi controls this through the user of an 'Authority Provider.' The Authority Provider is a pluggable +mechanism for providing authorizations to different users. Which Authority Provider to use is configured +using two properties in the _nifi.properties_ file. + +The `nifi.authority.provider.configuration.file` property specifies the configuration file for Authority Providers. +The `nifi.security.user.authority.provider` property indicates which of the configured Authority Providers should be +used. + +By default, the `file-provider` Authority Provider is selected and is configured to use the permissions granted in +the _authorized-users.xml_ file. This is typically sufficient for instances of NiFi that are run in "standalone" mode. +If the NiFi instance is configured to run in a cluster, the node will typically use the `cluster-node-provider` +Provider and the Cluster Manager will typically use the `cluster-ncm-provider` Provider. Both of these Providers +have a default configuration in the _authority-providers.xml_ file but are commented out. + +When using the `cluster-node-provider` Provider, all of the authorization is provided by the Cluster Manager. In this +way, the configuration only has to be maintained in one place and will be consistent across the entire cluster. + +When configuring the Cluster Manager or a standalone node, it is necessary to manually designate an ADMIN user +in the _authorized-users.xml_ file, which is located in the root installation's conf directory. +After this ADMIN user has been added, s/he may grant access to other users, systems, and other instances of NiFi, through the User Interface (UI) without having to manually edit the _authorized-users.xml_ file. If you are the administrator, you would add yourself as the ADMIN user in this file. Open the _authorized-users.xml_ file in a text editor. You will notice that it includes a template to guide you, with example entries that are commented out. -It is only necessary to manually add one user, the ADMIN user, -to this file. -So, at a minimum, the following example entry should be included and contain the user Distinguished Name (dn) +It is only necessary to manually add one user, the ADMIN user, to this file. +So, at a minimum, the following example entry should be included and contain the user Distinguished Name (DN) in place of "user dn - read only and admin": ---- @@ -170,7 +218,7 @@ Here is an example entry using the name John Smith: After the _authorized-users.xml_ file has been edited and saved, restart NiFi. Once the application starts, the ADMIN user is -able to access the UI at the https URL that is configured in the _nifi.properties_ file. +able to access the UI at the HTTPS URL that is configured in the _nifi.properties_ file. From the UI, click on the Users icon ( image:iconUsers.png["Users", width=32] ) in the Management Toolbar (upper-right corner of the UI), and the User Management Page opens. @@ -178,7 +226,40 @@ Management Toolbar (upper-right corner of the UI), and the User Management Page The ADMIN user should be listed. Click on the pencil icon to see this user's role(s). You may edit the roles by selecting the appropriate checkboxes. -When other users want access to the NiFi UI, they navigate to the configured URL and are +The following roles are available in NiFi: + +[options="header,footer"] +|======================================================================================================== +| Role Name | Description +| Administrator | Administrator is able to configure thread pool sizes and user accounts as well as + purge the dataflow change history. +| Data Flow Manager | Data Flow Manager is given the ability to manipulate the dataflow. S/he is able to + add, remove, and manipulate components on the graph; add, remove, and manipulate + Controller Services and Reporting Tasks; create and manage templates; + view statistics; and view the bulletin board. +| Read Only | Users with Read Only access are able to view the dataflow but are unable to change anything. +| Provenance | Users with Provenance access are able to query the Data Provenance repository and view + the lineage of data. Additionally, this role provides the ability to view or download + the content of a FlowFile from a Provenance event (assuming that the content is still + available in the Content Repository and that the Authority Provider also grants access). + This access is not provided to users with Read Only + (unless the user has both Read Only and Provenance roles) because the information provided + to users with this role can potentially be very sensitive in nature, as all FlowFile attributes + and data are exposed. In order to Replay a Provenance event, a user is required to have both + the Provenance role as well as the Data Flow Manager role. +| NiFi | The NiFi Role is intended to be assigned to machines that will interact with an instance of NiFi + via Site-to-Site. This role provides the ability to send data to or retrieve data from Root + Group Ports (but only those that they are given permissions to interact with - see the User Guide + for more information on providing access to specific Ports) as well as obtain information about + which Ports exist. Note that this role allows the client to know only about the Ports that it + has permissions to interact with. +| Proxy | The Proxy Role is assigned to a system in order to grant that system permission to make requests + on behalf of a user. For instance, if an HTTP proxy service is used to gain access to the system, + the certificate being used by that service can be given the Proxy Role. +|======================================================================================================== + + +When users want access to the NiFi UI, they navigate to the configured URL and are prompted to request access. When someone has requested access, the ADMIN user sees a star on the Users icon in the Management Toolbar, alerting the ADMIN to the fact that a request is pending. Upon opening the User Management Page, the pending request is visible, and the ADMIN @@ -200,7 +281,11 @@ Clustering Configuration This section provides a quick overview of NiFi Clustering and instructions on how to set up a basic cluster. In the future, we hope to provide supplemental documentation that covers the NiFi Cluster Architecture in depth. -The design of NiFi clustering is a simple master/slave model where there is a master and one or more slaves. While the model is that of master and slave, if the master dies, the slaves are all instructed to continue operating as they were to ensure the dataflow remains live. The absence of the master simply means new slaves cannot join the cluster and cluster flow changes cannot occur until the master is restored. In NiFi clustering, we call the master the NiFi Cluster Manager (NCM), and the slaves are called Nodes. See a full description of each in the Terminology section below. +The design of NiFi clustering is a simple master/slave model where there is a master and one or more slaves. +While the model is that of master and slave, if the master dies, the slaves are all instructed to continue operating +as they were to ensure the dataflow remains live. The absence of the master simply means new slaves cannot join the +cluster and cluster flow changes cannot occur until the master is restored. In NiFi clustering, we call the master +the NiFi Cluster Manager (NCM), and the slaves are called Nodes. See a full description of each in the Terminology section below. *Why Cluster?* + @@ -217,7 +302,7 @@ NiFi Clustering is unique and has its own terminology. It's important to underst *Primary Node*: Every cluster has one Primary Node. On this node, it is possible to run "Isolated Processors" (see below). By default, the NCM will elect the first node that connects to the cluster as the Primary Node; however, the DFM may select a new node as the Primary Node in the Cluster Management page of the User Interface if desired. If the cluster restarts, the NCM will "remember" which node was the Primary Node and wait for that node to re-connect before allowing the DFM to make any changes to the dataflow. The ADMIN may adjust how long the NCM waits for the Primary Node to reconnect by adjusting the property _nifi.cluster.manager.safemode.duration_ in the _nifi.properties_ file, which is discussed in the <> section of this document. -*Isolated Processors*: In a NiFi cluster, the same dataflow runs on all the nodes. As a result, every component in the flow runs on every node. However, there may be cases when the DFM would not want every processor to run on every node. The most common case is when using a processor that communicates with an external service using a protocol that does not scale well. For example, the GetSFTP processor pulls from a remote directory, and if the GetSFTP on every node in the cluster tries simultaneously to pull from the same remote directory, there could be race conditions. Therefore, the DFM could configure the GetSFTP on the Primary Node to run in isolation, meaning that it only runs on that node. It could pull in data and -with the proper dataflow configuration- load-balance it across the rest of the nodes in the cluster. Note that while this feature exists, it is also very common to simply use a standalone NiFi instance to pull data and feed it to the cluster. It just depends on the resources available and how the Administrator decides to configure the cluster. +*Isolated Processors*: In a NiFi cluster, the same dataflow runs on all the nodes. As a result, every component in the flow runs on every node. However, there may be cases when the DFM would not want every processor to run on every node. The most common case is when using a processor that communicates with an external service using a protocol that does not scale well. For example, the GetSFTP processor pulls from a remote directory, and if the GetSFTP on every node in the cluster tries simultaneously to pull from the same remote directory, there could be race conditions. Therefore, the DFM could configure the GetSFTP on the Primary Node to run in isolation, meaning that it only runs on that node. It could pull in data and -with the proper dataflow configuration- load-balance it across the rest of the nodes in the cluster. Note that while this feature exists, it is also very common to simply use a standalone NiFi instance to pull data and feed it to the cluster. It just depends on the resources available and how the Administrator decides to configure the cluster. *Heartbeats*: The nodes communicate their health and status to the NCM via "heartbeats", which let the NCM know they are still connected to the cluster and working properly. By default, the nodes emit heartbeats to the NCM every 5 seconds, and if the NCM does not receive a heartbeat from a node within 45 seconds, it disconnects the node due to "lack of heartbeat". (The 5-second and 45-second settings are configurable in the _nifi.properties_ file. See the <> section of this document for more information.) The reason that the NCM disconnects the node is because the NCM needs to ensure that every node in the cluster is in sync, and if a node is not heard from regularly, the NCM cannot be sure it is still in sync with the rest of the cluster. If, after 45 seconds, the node does send a new heartbeat, the NCM will automatically reconnect the node to the cluster. Both the disconnection due to lack of heartbeat and the reconnection once a heartbeat is received are reported to the DFM in the NCM's User Interface. diff --git a/nifi/nifi-docs/src/main/asciidoc/images/nifi_first_launch_screenshot.png b/nifi/nifi-docs/src/main/asciidoc/images/nifi_first_launch_screenshot.png new file mode 100644 index 0000000000..7735f7e21a Binary files /dev/null and b/nifi/nifi-docs/src/main/asciidoc/images/nifi_first_launch_screenshot.png differ diff --git a/nifi/nifi-external/nifi-spark-receiver/pom.xml b/nifi/nifi-external/nifi-spark-receiver/pom.xml index 5c93f6b2d1..a6d9378f8f 100644 --- a/nifi/nifi-external/nifi-spark-receiver/pom.xml +++ b/nifi/nifi-external/nifi-spark-receiver/pom.xml @@ -23,15 +23,15 @@ org.apache.nifi nifi-spark-receiver - - - org.apache.spark - spark-streaming_2.10 - 1.2.0 - - - org.apache.nifi - nifi-site-to-site-client - - + + + org.apache.spark + spark-streaming_2.10 + 1.2.0 + + + org.apache.nifi + nifi-site-to-site-client + + \ No newline at end of file diff --git a/nifi/nifi-external/nifi-spark-receiver/src/main/java/org/apache/nifi/spark/NiFiDataPacket.java b/nifi/nifi-external/nifi-spark-receiver/src/main/java/org/apache/nifi/spark/NiFiDataPacket.java index 2f08dc5c6d..484c2a95a8 100644 --- a/nifi/nifi-external/nifi-spark-receiver/src/main/java/org/apache/nifi/spark/NiFiDataPacket.java +++ b/nifi/nifi-external/nifi-spark-receiver/src/main/java/org/apache/nifi/spark/NiFiDataPacket.java @@ -20,21 +20,20 @@ import java.util.Map; /** *

    - * The NiFiDataPacket provides a packaging around a NiFi FlowFile. It wraps both a FlowFile's - * content and its attributes so that they can be processed by Spark + * The NiFiDataPacket provides a packaging around a NiFi FlowFile. It wraps both + * a FlowFile's content and its attributes so that they can be processed by + * Spark *

    */ public interface NiFiDataPacket { - /** - * Returns the contents of a NiFi FlowFile - * @return - */ - byte[] getContent(); + /** + * @return the contents of a NiFi FlowFile + */ + byte[] getContent(); - /** - * Returns a Map of attributes that are associated with the NiFi FlowFile - * @return - */ - Map getAttributes(); + /** + * @return a Map of attributes that are associated with the NiFi FlowFile + */ + Map getAttributes(); } diff --git a/nifi/nifi-external/nifi-spark-receiver/src/main/java/org/apache/nifi/spark/NiFiReceiver.java b/nifi/nifi-external/nifi-spark-receiver/src/main/java/org/apache/nifi/spark/NiFiReceiver.java index 9f3106210c..8cbf60c484 100644 --- a/nifi/nifi-external/nifi-spark-receiver/src/main/java/org/apache/nifi/spark/NiFiReceiver.java +++ b/nifi/nifi-external/nifi-spark-receiver/src/main/java/org/apache/nifi/spark/NiFiReceiver.java @@ -31,64 +31,67 @@ import org.apache.nifi.stream.io.StreamUtils; import org.apache.spark.storage.StorageLevel; import org.apache.spark.streaming.receiver.Receiver; - /** *

    - * The NiFiReceiver is a Reliable Receiver that provides a way to pull data - * from Apache NiFi so that it can be processed by Spark Streaming. The NiFi Receiver connects - * to NiFi instance provided in the config and requests data from - * the OutputPort that is named. In NiFi, when an OutputPort is added to the root process group, - * it acts as a queue of data for remote clients. This receiver is then able to pull that data - * from NiFi reliably. + * The NiFiReceiver is a Reliable Receiver that provides a way to + * pull data from Apache NiFi so that it can be processed by Spark Streaming. + * The NiFi Receiver connects to NiFi instance provided in the config and + * requests data from the OutputPort that is named. In NiFi, when an OutputPort + * is added to the root process group, it acts as a queue of data for remote + * clients. This receiver is then able to pull that data from NiFi reliably. *

    - * + * *

    - * It is important to note that if pulling data from a NiFi cluster, the URL that should be used - * is that of the NiFi Cluster Manager. The Receiver will automatically handle determining the nodes - * in that cluster and pull from those nodes as appropriate. + * It is important to note that if pulling data from a NiFi cluster, the URL + * that should be used is that of the NiFi Cluster Manager. The Receiver will + * automatically handle determining the nodes in that cluster and pull from + * those nodes as appropriate. *

    - * + * *

    - * In order to use the NiFiReceiver, you will need to first build a {@link SiteToSiteClientConfig} to provide - * to the constructor. This can be achieved by using the {@link SiteToSiteClient.Builder}. - * Below is an example snippet of driver code to pull data from NiFi that is running on localhost:8080. This - * example assumes that NiFi exposes and OutputPort on the root group named "Data For Spark". - * Additionally, it assumes that the data that it will receive from this OutputPort is text - * data, as it will map the byte array received from NiFi to a UTF-8 Encoded string. + * In order to use the NiFiReceiver, you will need to first build a + * {@link SiteToSiteClientConfig} to provide to the constructor. This can be + * achieved by using the {@link SiteToSiteClient.Builder}. Below is an example + * snippet of driver code to pull data from NiFi that is running on + * localhost:8080. This example assumes that NiFi exposes and OutputPort on the + * root group named "Data For Spark". Additionally, it assumes that the data + * that it will receive from this OutputPort is text data, as it will map the + * byte array received from NiFi to a UTF-8 Encoded string. *

    - * + * * *
    + * {@code
      * Pattern SPACE = Pattern.compile(" ");
    - * 
    + *
      * // Build a Site-to-site client config
      * SiteToSiteClientConfig config = new SiteToSiteClient.Builder()
      *   .setUrl("http://localhost:8080/nifi")
      *   .setPortName("Data For Spark")
      *   .buildConfig();
    - * 
    + *
      * SparkConf sparkConf = new SparkConf().setAppName("NiFi-Spark Streaming example");
      * JavaStreamingContext ssc = new JavaStreamingContext(sparkConf, new Duration(1000L));
    - * 
    - * // Create a JavaReceiverInputDStream using a NiFi receiver so that we can pull data from 
    + *
    + * // Create a JavaReceiverInputDStream using a NiFi receiver so that we can pull data from
      * // specified Port
    - * JavaReceiverInputDStream packetStream = 
    + * JavaReceiverInputDStream packetStream =
      *     ssc.receiverStream(new NiFiReceiver(clientConfig, StorageLevel.MEMORY_ONLY()));
    - * 
    + *
      * // Map the data from NiFi to text, ignoring the attributes
      * JavaDStream text = packetStream.map(new Function() {
      *   public String call(final NiFiDataPacket dataPacket) throws Exception {
      *     return new String(dataPacket.getContent(), StandardCharsets.UTF_8);
      *   }
      * });
    - * 
    + *
      * // Split the words by spaces
      * JavaDStream words = text.flatMap(new FlatMapFunction() {
      *   public Iterable call(final String text) throws Exception {
      *     return Arrays.asList(SPACE.split(text));
      *   }
      * });
    - * 	    
    + *
      * // Map each word to the number 1, then aggregate by key
      * JavaPairDStream wordCounts = words.mapToPair(
      *   new PairFunction() {
    @@ -101,98 +104,105 @@ import org.apache.spark.streaming.receiver.Receiver;
      *     }
      *    }
      *  );
    - * 
    + *
      * // print the results
      * wordCounts.print();
      * ssc.start();
      * ssc.awaitTermination();
    + * }
      * 
    *
    */ public class NiFiReceiver extends Receiver { - private static final long serialVersionUID = 3067274587595578836L; - private final SiteToSiteClientConfig clientConfig; - - public NiFiReceiver(final SiteToSiteClientConfig clientConfig, final StorageLevel storageLevel) { - super(storageLevel); - this.clientConfig = clientConfig; - } - - @Override - public void onStart() { - final Thread thread = new Thread(new ReceiveRunnable()); - thread.setDaemon(true); - thread.setName("NiFi Receiver"); - thread.start(); - } - @Override - public void onStop() { - } + private static final long serialVersionUID = 3067274587595578836L; + private final SiteToSiteClientConfig clientConfig; - class ReceiveRunnable implements Runnable { - public ReceiveRunnable() { - } - - public void run() { - try { - final SiteToSiteClient client = new SiteToSiteClient.Builder().fromConfig(clientConfig).build(); - try { - while ( !isStopped() ) { - final Transaction transaction = client.createTransaction(TransferDirection.RECEIVE); - DataPacket dataPacket = transaction.receive(); - if ( dataPacket == null ) { - transaction.confirm(); - transaction.complete(); - - // no data available. Wait a bit and try again - try { - Thread.sleep(1000L); - } catch (InterruptedException e) {} - - continue; - } - - final List dataPackets = new ArrayList(); - do { - // Read the data into a byte array and wrap it along with the attributes - // into a NiFiDataPacket. - final InputStream inStream = dataPacket.getData(); - final byte[] data = new byte[(int) dataPacket.getSize()]; - StreamUtils.fillBuffer(inStream, data); - - final Map attributes = dataPacket.getAttributes(); - final NiFiDataPacket NiFiDataPacket = new NiFiDataPacket() { - public byte[] getContent() { - return data; - } + public NiFiReceiver(final SiteToSiteClientConfig clientConfig, final StorageLevel storageLevel) { + super(storageLevel); + this.clientConfig = clientConfig; + } - public Map getAttributes() { - return attributes; - } - }; - - dataPackets.add(NiFiDataPacket); - dataPacket = transaction.receive(); - } while ( dataPacket != null ); + @Override + public void onStart() { + final Thread thread = new Thread(new ReceiveRunnable()); + thread.setDaemon(true); + thread.setName("NiFi Receiver"); + thread.start(); + } - // Confirm transaction to verify the data - transaction.confirm(); - - store(dataPackets.iterator()); - - transaction.complete(); - } - } finally { - try { - client.close(); - } catch (final IOException ioe) { - reportError("Failed to close client", ioe); - } - } - } catch (final IOException ioe) { - restart("Failed to receive data from NiFi", ioe); - } - } - } + @Override + public void onStop() { + } + + class ReceiveRunnable implements Runnable { + + public ReceiveRunnable() { + } + + @Override + public void run() { + try { + final SiteToSiteClient client = new SiteToSiteClient.Builder().fromConfig(clientConfig).build(); + try { + while (!isStopped()) { + final Transaction transaction = client.createTransaction(TransferDirection.RECEIVE); + DataPacket dataPacket = transaction.receive(); + if (dataPacket == null) { + transaction.confirm(); + transaction.complete(); + + // no data available. Wait a bit and try again + try { + Thread.sleep(1000L); + } catch (InterruptedException e) { + } + + continue; + } + + final List dataPackets = new ArrayList<>(); + do { + // Read the data into a byte array and wrap it along with the attributes + // into a NiFiDataPacket. + final InputStream inStream = dataPacket.getData(); + final byte[] data = new byte[(int) dataPacket.getSize()]; + StreamUtils.fillBuffer(inStream, data); + + final Map attributes = dataPacket.getAttributes(); + final NiFiDataPacket NiFiDataPacket = new NiFiDataPacket() { + @Override + public byte[] getContent() { + return data; + } + + @Override + public Map getAttributes() { + return attributes; + } + }; + + dataPackets.add(NiFiDataPacket); + dataPacket = transaction.receive(); + } while (dataPacket != null); + + // Confirm transaction to verify the data + transaction.confirm(); + + store(dataPackets.iterator()); + + transaction.complete(); + } + } finally { + try { + client.close(); + } catch (final IOException ioe) { + reportError("Failed to close client", ioe); + } + } + } catch (final IOException ioe) { + restart("Failed to receive data from NiFi", ioe); + } + } + } } diff --git a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockControllerServiceInitializationContext.java b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockControllerServiceInitializationContext.java index fd3c2de562..bff1d628a4 100644 --- a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockControllerServiceInitializationContext.java +++ b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockControllerServiceInitializationContext.java @@ -29,7 +29,7 @@ public class MockControllerServiceInitializationContext extends MockControllerSe public MockControllerServiceInitializationContext(final ControllerService controllerService, final String identifier) { this(controllerService, identifier, new MockProcessorLog(identifier, controllerService)); } - + public MockControllerServiceInitializationContext(final ControllerService controllerService, final String identifier, final ComponentLog logger) { this.identifier = identifier; this.logger = logger; @@ -40,17 +40,17 @@ public class MockControllerServiceInitializationContext extends MockControllerSe public String getIdentifier() { return identifier; } - + @Override public String getControllerServiceName(final String serviceIdentifier) { - return null; + return null; } @Override public ControllerServiceLookup getControllerServiceLookup() { return this; } - + @Override public ComponentLog getLogger() { return logger; diff --git a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockControllerServiceLookup.java b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockControllerServiceLookup.java index 2734440497..219ee24eb4 100644 --- a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockControllerServiceLookup.java +++ b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockControllerServiceLookup.java @@ -40,17 +40,17 @@ public abstract class MockControllerServiceLookup implements ControllerServiceLo public void removeControllerService(ControllerService service) { final ControllerService canonical = getControllerService(service.getIdentifier()); - if ( canonical == null || canonical != service ) { + if (canonical == null || canonical != service) { throw new IllegalArgumentException("Controller Service " + service + " is not known"); } - + controllerServiceMap.remove(service.getIdentifier()); } protected void addControllerServices(final MockControllerServiceLookup other) { this.controllerServiceMap.putAll(other.controllerServiceMap); } - + protected ControllerServiceConfiguration getConfiguration(final String identifier) { return controllerServiceMap.get(identifier); } @@ -80,7 +80,7 @@ public abstract class MockControllerServiceLookup implements ControllerServiceLo public boolean isControllerServiceEnabling(final String serviceIdentifier) { return false; } - + @Override public Set getControllerServiceIdentifiers(final Class serviceType) { final Set ids = new HashSet<>(); @@ -91,10 +91,10 @@ public abstract class MockControllerServiceLookup implements ControllerServiceLo } return ids; } - + @Override public String getControllerServiceName(String serviceIdentifier) { - final ControllerServiceConfiguration status = controllerServiceMap.get(serviceIdentifier); - return status == null ? null : serviceIdentifier; + final ControllerServiceConfiguration status = controllerServiceMap.get(serviceIdentifier); + return status == null ? null : serviceIdentifier; } } diff --git a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockFlowFile.java b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockFlowFile.java index 1be0293414..e9fb9d6382 100644 --- a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockFlowFile.java +++ b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockFlowFile.java @@ -185,8 +185,8 @@ public class MockFlowFile implements FlowFile { * Asserts that the content of this FlowFile is the same as the content of * the given file * - * @param file - * @throws IOException + * @param file to compare content against + * @throws IOException if fails doing IO during comparison */ public void assertContentEquals(final File file) throws IOException { assertContentEquals(file.toPath()); @@ -196,8 +196,8 @@ public class MockFlowFile implements FlowFile { * Asserts that the content of this FlowFile is the same as the content of * the given path * - * @param path - * @throws IOException + * @param path where to find content to compare to + * @throws IOException if io error occurs while comparing content */ public void assertContentEquals(final Path path) throws IOException { try (final InputStream in = Files.newInputStream(path, StandardOpenOption.READ)) { @@ -209,8 +209,8 @@ public class MockFlowFile implements FlowFile { * Asserts that the content of this FlowFile is the same as the content of * the given byte array * - * @param data - * @throws IOException + * @param data the data to compare + * @throws IOException if any ioe occurs while reading flowfile */ public void assertContentEquals(final byte[] data) throws IOException { try (final InputStream in = new ByteArrayInputStream(data)) { @@ -236,8 +236,8 @@ public class MockFlowFile implements FlowFile { * the given InputStream. This method closes the InputStream when it is * finished. * - * @param in - * @throws IOException + * @param in the stream to source comparison data from + * @throws IOException if any issues reading from given source */ public void assertContentEquals(final InputStream in) throws IOException { int bytesRead = 0; @@ -264,9 +264,7 @@ public class MockFlowFile implements FlowFile { } /** - * Returns a copy of the the contents of the FlowFile as a byte array - * - * @return + * @return a copy of the the contents of the FlowFile as a byte array */ public byte[] toByteArray() { return Arrays.copyOf(this.data, this.data.length); diff --git a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessContext.java b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessContext.java index 65369288e7..20a2f7c25c 100644 --- a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessContext.java +++ b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessContext.java @@ -54,7 +54,7 @@ public class MockProcessContext extends MockControllerServiceLookup implements S /** * Creates a new MockProcessContext for the given Processor * - * @param component + * @param component being mocked */ public MockProcessContext(final ConfigurableComponent component) { this.component = Objects.requireNonNull(component); @@ -73,7 +73,7 @@ public class MockProcessContext extends MockControllerServiceLookup implements S // do nothing...the service is being loaded } } - + @Override public PropertyValue getProperty(final PropertyDescriptor descriptor) { return getProperty(descriptor.getName()); @@ -107,9 +107,9 @@ public class MockProcessContext extends MockControllerServiceLookup implements S * either case, the ValidationResult is returned, indicating whether or not * the property is valid * - * @param descriptor - * @param value - * @return + * @param descriptor of property to modify + * @param value new value + * @return result */ public ValidationResult setProperty(final PropertyDescriptor descriptor, final String value) { requireNonNull(descriptor); @@ -154,7 +154,6 @@ public class MockProcessContext extends MockControllerServiceLookup implements S config.setProperties(properties); config.setAnnotationData(annotationData); } - @Override public int getMaxConcurrentTasks() { @@ -268,10 +267,10 @@ public class MockProcessContext extends MockControllerServiceLookup implements S } public Set getAvailableRelationships() { - if ( !(component instanceof Processor) ) { + if (!(component instanceof Processor)) { return Collections.emptySet(); } - + final Set relationships = new HashSet<>(((Processor) component).getRelationships()); relationships.removeAll(unavailableRelationships); return relationships; diff --git a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessSession.java b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessSession.java index 83c75c67b1..e9bb7783f9 100644 --- a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessSession.java +++ b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessSession.java @@ -329,7 +329,6 @@ public class MockProcessSession implements ProcessSession { return newFlowFile; } - @Override public MockFlowFile merge(final Collection sources, final FlowFile destination) { for (final FlowFile source : sources) { @@ -676,11 +675,9 @@ public class MockProcessSession implements ProcessSession { } /** - * Returns a List of FlowFiles in the order in which they were transferred + * @param relationship to get flowfiles for + * @return a List of FlowFiles in the order in which they were transferred * to the given relationship - * - * @param relationship - * @return */ public List getFlowFilesForRelationship(final String relationship) { final Relationship procRel = new Relationship.Builder().name(relationship).build(); @@ -783,7 +780,7 @@ public class MockProcessSession implements ProcessSession { * will capture the uuid of a certain number of source objects and may not * capture all of them. How many it will capture is unspecified. * - * @param sources + * @param sources to inherit common attributes from */ private FlowFile inheritAttributes(final Collection sources, final FlowFile destination) { final StringBuilder parentUuidBuilder = new StringBuilder(); @@ -883,8 +880,8 @@ public class MockProcessSession implements ProcessSession { * Assert that the number of FlowFiles transferred to the given relationship * is equal to the given count * - * @param relationship - * @param count + * @param relationship to validate transfer count of + * @param count items transfer to given relationship */ public void assertTransferCount(final Relationship relationship, final int count) { final int transferCount = getFlowFilesForRelationship(relationship).size(); @@ -896,8 +893,8 @@ public class MockProcessSession implements ProcessSession { * Assert that the number of FlowFiles transferred to the given relationship * is equal to the given count * - * @param relationship - * @param count + * @param relationship to validate transfer count of + * @param count items transfer to given relationship */ public void assertTransferCount(final String relationship, final int count) { assertTransferCount(new Relationship.Builder().name(relationship).build(), count); @@ -921,7 +918,7 @@ public class MockProcessSession implements ProcessSession { * Asserts that all FlowFiles that were transferred were transferred to the * given relationship * - * @param relationship + * @param relationship to check for transferred flow files */ public void assertAllFlowFilesTransferred(final String relationship) { assertAllFlowFilesTransferred(new Relationship.Builder().name(relationship).build()); @@ -931,7 +928,7 @@ public class MockProcessSession implements ProcessSession { * Asserts that all FlowFiles that were transferred were transferred to the * given relationship * - * @param relationship + * @param relationship to validate */ public void assertAllFlowFilesTransferred(final Relationship relationship) { for (final Map.Entry> entry : transferMap.entrySet()) { @@ -956,8 +953,8 @@ public class MockProcessSession implements ProcessSession { * given relationship and that the number of FlowFiles transferred is equal * to count * - * @param relationship - * @param count + * @param relationship to validate + * @param count number of items sent to that relationship (expected) */ public void assertAllFlowFilesTransferred(final Relationship relationship, final int count) { assertAllFlowFilesTransferred(relationship); @@ -969,17 +966,15 @@ public class MockProcessSession implements ProcessSession { * given relationship and that the number of FlowFiles transferred is equal * to count * - * @param relationship - * @param count + * @param relationship to validate + * @param count number of items sent to that relationship (expected) */ public void assertAllFlowFilesTransferred(final String relationship, final int count) { assertAllFlowFilesTransferred(new Relationship.Builder().name(relationship).build(), count); } /** - * Returns the number of FlowFiles that were removed - * - * @return + * @return the number of FlowFiles that were removed */ public int getRemovedCount() { return removedCount; diff --git a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessorInitializationContext.java b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessorInitializationContext.java index 0aa2749a57..2e5d3eb25e 100644 --- a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessorInitializationContext.java +++ b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessorInitializationContext.java @@ -64,9 +64,9 @@ public class MockProcessorInitializationContext implements ProcessorInitializati @Override public String getControllerServiceName(String serviceIdentifier) { - return context.getControllerServiceName(serviceIdentifier); + return context.getControllerServiceName(serviceIdentifier); } - + @Override public boolean isControllerServiceEnabled(String serviceIdentifier) { return context.isControllerServiceEnabled(serviceIdentifier); diff --git a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessorLog.java b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessorLog.java index 5505e88fec..837784b042 100644 --- a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessorLog.java +++ b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessorLog.java @@ -66,21 +66,11 @@ public class MockProcessorLog implements ProcessorLog { return (os != null && os.length > 0 && (os[os.length - 1] instanceof Throwable)); } - /** - * - * @param msg - * @param t - */ @Override public void warn(final String msg, final Throwable t) { warn("{} " + msg, new Object[]{component}, t); } - /** - * - * @param msg - * @param os - */ @Override public void warn(String msg, Object[] os) { if (lastArgIsException(os)) { @@ -92,12 +82,6 @@ public class MockProcessorLog implements ProcessorLog { } } - /** - * - * @param msg - * @param os - * @param t - */ @Override public void warn(String msg, Object[] os, final Throwable t) { os = addProcessorAndThrowable(os, t); @@ -109,21 +93,12 @@ public class MockProcessorLog implements ProcessorLog { } } - /** - * - * @param msg - */ @Override public void warn(String msg) { msg = "{} " + msg; logger.warn(msg, component); } - /** - * - * @param msg - * @param t - */ @Override public void trace(String msg, Throwable t) { msg = "{} " + msg; @@ -131,11 +106,6 @@ public class MockProcessorLog implements ProcessorLog { logger.trace(msg, os, t); } - /** - * - * @param msg - * @param os - */ @Override public void trace(String msg, Object[] os) { msg = "{} " + msg; @@ -143,10 +113,6 @@ public class MockProcessorLog implements ProcessorLog { logger.trace(msg, os); } - /** - * - * @param msg - */ @Override public void trace(String msg) { msg = "{} " + msg; @@ -154,12 +120,6 @@ public class MockProcessorLog implements ProcessorLog { logger.trace(msg, os); } - /** - * - * @param msg - * @param os - * @param t - */ @Override public void trace(String msg, Object[] os, Throwable t) { os = addProcessorAndThrowable(os, t); @@ -169,56 +129,31 @@ public class MockProcessorLog implements ProcessorLog { logger.trace("", t); } - /** - * - * @return - */ @Override public boolean isWarnEnabled() { return logger.isWarnEnabled(); } - /** - * - * @return - */ @Override public boolean isTraceEnabled() { return logger.isTraceEnabled(); } - /** - * - * @return - */ @Override public boolean isInfoEnabled() { return logger.isInfoEnabled(); } - /** - * - * @return - */ @Override public boolean isErrorEnabled() { return logger.isErrorEnabled(); } - /** - * - * @return - */ @Override public boolean isDebugEnabled() { return logger.isDebugEnabled(); } - /** - * - * @param msg - * @param t - */ @Override public void info(String msg, Throwable t) { msg = "{} " + msg; @@ -230,11 +165,6 @@ public class MockProcessorLog implements ProcessorLog { } } - /** - * - * @param msg - * @param os - */ @Override public void info(String msg, Object[] os) { msg = "{} " + msg; @@ -243,10 +173,6 @@ public class MockProcessorLog implements ProcessorLog { logger.info(msg, os); } - /** - * - * @param msg - */ @Override public void info(String msg) { msg = "{} " + msg; @@ -255,12 +181,6 @@ public class MockProcessorLog implements ProcessorLog { logger.info(msg, os); } - /** - * - * @param msg - * @param os - * @param t - */ @Override public void info(String msg, Object[] os, Throwable t) { os = addProcessorAndThrowable(os, t); @@ -272,20 +192,11 @@ public class MockProcessorLog implements ProcessorLog { } } - /** - * - * @return - */ @Override public String getName() { return logger.getName(); } - /** - * - * @param msg - * @param t - */ @Override public void error(String msg, Throwable t) { msg = "{} " + msg; @@ -297,11 +208,6 @@ public class MockProcessorLog implements ProcessorLog { } } - /** - * - * @param msg - * @param os - */ @Override public void error(String msg, Object[] os) { if (lastArgIsException(os)) { @@ -313,10 +219,6 @@ public class MockProcessorLog implements ProcessorLog { } } - /** - * - * @param msg - */ @Override public void error(String msg) { msg = "{} " + msg; @@ -325,12 +227,6 @@ public class MockProcessorLog implements ProcessorLog { logger.error(msg, os); } - /** - * - * @param msg - * @param os - * @param t - */ @Override public void error(String msg, Object[] os, Throwable t) { os = addProcessorAndThrowable(os, t); @@ -342,11 +238,6 @@ public class MockProcessorLog implements ProcessorLog { } } - /** - * - * @param msg - * @param t - */ @Override public void debug(String msg, Throwable t) { msg = "{} " + msg; @@ -355,11 +246,6 @@ public class MockProcessorLog implements ProcessorLog { logger.debug(msg, os, t); } - /** - * - * @param msg - * @param os - */ @Override public void debug(String msg, Object[] os) { os = addProcessor(os); @@ -368,12 +254,6 @@ public class MockProcessorLog implements ProcessorLog { logger.debug(msg, os); } - /** - * - * @param msg - * @param os - * @param t - */ @Override public void debug(String msg, Object[] os, Throwable t) { os = addProcessorAndThrowable(os, t); @@ -385,10 +265,6 @@ public class MockProcessorLog implements ProcessorLog { } } - /** - * - * @param msg - */ @Override public void debug(String msg) { msg = "{} " + msg; diff --git a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockProvenanceReporter.java b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockProvenanceReporter.java index 3451f12f40..097eafdbef 100644 --- a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockProvenanceReporter.java +++ b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockProvenanceReporter.java @@ -88,7 +88,7 @@ public class MockProvenanceReporter implements ProvenanceReporter { public void fork(FlowFile parent, java.util.Collection children, String details, long forkDuration) { } - + @Override public void join(Collection parents, FlowFile child) { @@ -108,7 +108,7 @@ public class MockProvenanceReporter implements ProvenanceReporter { public void join(java.util.Collection parents, FlowFile child, String details, long joinDuration) { } - + @Override public void clone(FlowFile parent, FlowFile child) { diff --git a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockReportingContext.java b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockReportingContext.java index ca4350cd40..63a987626c 100644 --- a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockReportingContext.java +++ b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockReportingContext.java @@ -100,11 +100,9 @@ public class MockReportingContext extends MockControllerServiceLookup implements } /** - * Returns all Bulletins that have been created for the component with the + * @param componentId identifier of component to get bulletins for + * @return all Bulletins that have been created for the component with the * given ID - * - * @param componentId - * @return */ public List getComponentBulletins(final String componentId) { final List created = componentBulletinsCreated.get(componentId); diff --git a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockReportingInitializationContext.java b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockReportingInitializationContext.java index 7cabef22a7..0aea00afad 100644 --- a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockReportingInitializationContext.java +++ b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockReportingInitializationContext.java @@ -81,7 +81,7 @@ public class MockReportingInitializationContext extends MockControllerServiceLoo public SchedulingStrategy getSchedulingStrategy() { return SchedulingStrategy.TIMER_DRIVEN; } - + @Override public ComponentLog getLogger() { return logger; diff --git a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockValidationContext.java b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockValidationContext.java index c9b1cdaf30..d73a09bfe0 100644 --- a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockValidationContext.java +++ b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/MockValidationContext.java @@ -38,10 +38,10 @@ public class MockValidationContext implements ValidationContext, ControllerServi public MockValidationContext(final MockProcessContext processContext) { this.context = processContext; - + final Map properties = processContext.getProperties(); expressionLanguageSupported = new HashMap<>(properties.size()); - for ( final PropertyDescriptor descriptor : properties.keySet() ) { + for (final PropertyDescriptor descriptor : properties.keySet()) { expressionLanguageSupported.put(descriptor.getName(), descriptor.isExpressionLanguageSupported()); } } @@ -101,13 +101,13 @@ public class MockValidationContext implements ValidationContext, ControllerServi public boolean isControllerServiceEnabled(final ControllerService service) { return context.isControllerServiceEnabled(service); } - + @Override public String getControllerServiceName(final String serviceIdentifier) { - final ControllerServiceConfiguration configuration = context.getConfiguration(serviceIdentifier); - return configuration == null ? null : serviceIdentifier; + final ControllerServiceConfiguration configuration = context.getConfiguration(serviceIdentifier); + return configuration == null ? null : serviceIdentifier; } - + @Override public boolean isValidationRequired(final ControllerService service) { return true; @@ -117,16 +117,16 @@ public class MockValidationContext implements ValidationContext, ControllerServi public boolean isControllerServiceEnabling(String serviceIdentifier) { return context.isControllerServiceEnabling(serviceIdentifier); } - + public boolean isExpressionLanguagePresent(final String value) { - if ( value == null ) { + if (value == null) { return false; } - + final List elRanges = Query.extractExpressionRanges(value); return (elRanges != null && !elRanges.isEmpty()); } - + @Override public boolean isExpressionLanguageSupported(final String propertyName) { final Boolean supported = expressionLanguageSupported.get(propertyName); diff --git a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/ReflectionUtils.java b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/ReflectionUtils.java index 9d52eb35d8..940eeeaceb 100644 --- a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/ReflectionUtils.java +++ b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/ReflectionUtils.java @@ -34,14 +34,15 @@ public class ReflectionUtils { * are supplied by the args parameter than needed, the extra * arguments will be ignored. * - * @param annotation - * @param instance - * @param args - * @throws InvocationTargetException - * @throws IllegalArgumentException - * @throws IllegalAccessException + * @param annotation the annotation to look for + * @param instance to invoke a method of + * @param args to supply in a method call + * @throws InvocationTargetException ite + * @throws IllegalArgumentException iae + * @throws IllegalAccessException if not allowed to invoke that method */ - public static void invokeMethodsWithAnnotation(final Class annotation, final Object instance, final Object... args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { + public static void invokeMethodsWithAnnotation(final Class annotation, final Object instance, final Object... args) + throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { for (final Method method : instance.getClass().getMethods()) { if (method.isAnnotationPresent(annotation)) { final boolean isAccessible = method.isAccessible(); @@ -90,9 +91,9 @@ public class ReflectionUtils { * are supplied by the args parameter than needed, the extra * arguments will be ignored. * - * @param annotation - * @param instance - * @param args + * @param annotation the annotation to look for + * @param instance to invoke a method of + * @param args to supply in a method call * @return true if all appropriate methods were invoked and * returned without throwing an Exception, false if one of the * methods threw an Exception or could not be invoked; if false diff --git a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/SharedSessionState.java b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/SharedSessionState.java index 13a87de417..65d79a651c 100644 --- a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/SharedSessionState.java +++ b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/SharedSessionState.java @@ -32,7 +32,6 @@ public class SharedSessionState { private final AtomicLong flowFileIdGenerator; private final ConcurrentMap counterMap = new ConcurrentHashMap<>(); - public SharedSessionState(final Processor processor, final AtomicLong flowFileIdGenerator) { flowFileQueue = new MockFlowFileQueue(); provenanceReporter = new MockProvenanceReporter(); diff --git a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/StandardProcessorTestRunner.java b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/StandardProcessorTestRunner.java index d66ed8165d..7048cfe092 100644 --- a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/StandardProcessorTestRunner.java +++ b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/StandardProcessorTestRunner.java @@ -86,14 +86,14 @@ public class StandardProcessorTestRunner implements TestRunner { private static final Logger logger = LoggerFactory.getLogger(StandardProcessorTestRunner.class); private static final Set> deprecatedTypeAnnotations = new HashSet<>(); private static final Set> deprecatedMethodAnnotations = new HashSet<>(); - + static { // do this in a separate method, just so that we can add a @SuppressWarnings annotation // because we want to indicate explicitly that we know that we are using deprecated // classes here. populateDeprecatedMethods(); } - + StandardProcessorTestRunner(final Processor processor) { this.processor = processor; this.idGenerator = new AtomicLong(0L); @@ -103,7 +103,7 @@ public class StandardProcessorTestRunner implements TestRunner { this.context = new MockProcessContext(processor); detectDeprecatedAnnotations(processor); - + final MockProcessorInitializationContext mockInitContext = new MockProcessorInitializationContext(processor, context); processor.initialize(mockInitContext); @@ -126,7 +126,7 @@ public class StandardProcessorTestRunner implements TestRunner { deprecatedTypeAnnotations.add(org.apache.nifi.processor.annotation.TriggerWhenEmpty.class); deprecatedTypeAnnotations.add(org.apache.nifi.processor.annotation.TriggerWhenAnyDestinationAvailable.class); deprecatedTypeAnnotations.add(org.apache.nifi.processor.annotation.TriggerSerially.class); - + deprecatedMethodAnnotations.add(org.apache.nifi.processor.annotation.OnRemoved.class); deprecatedMethodAnnotations.add(org.apache.nifi.processor.annotation.OnAdded.class); deprecatedMethodAnnotations.add(org.apache.nifi.processor.annotation.OnScheduled.class); @@ -134,24 +134,24 @@ public class StandardProcessorTestRunner implements TestRunner { deprecatedMethodAnnotations.add(org.apache.nifi.processor.annotation.OnStopped.class); deprecatedMethodAnnotations.add(org.apache.nifi.processor.annotation.OnUnscheduled.class); } - + private static void detectDeprecatedAnnotations(final Processor processor) { - for ( final Class annotationClass : deprecatedTypeAnnotations ) { - if ( processor.getClass().isAnnotationPresent(annotationClass) ) { + for (final Class annotationClass : deprecatedTypeAnnotations) { + if (processor.getClass().isAnnotationPresent(annotationClass)) { Assert.fail("Processor is using deprecated Annotation " + annotationClass.getCanonicalName()); } } - - for ( final Class annotationClass : deprecatedMethodAnnotations ) { - for ( final Method method : processor.getClass().getMethods() ) { - if ( method.isAnnotationPresent(annotationClass) ) { + + for (final Class annotationClass : deprecatedMethodAnnotations) { + for (final Method method : processor.getClass().getMethods()) { + if (method.isAnnotationPresent(annotationClass)) { Assert.fail("Processor is using deprecated Annotation " + annotationClass.getCanonicalName() + " for method " + method); } } } - + } - + @Override public void setValidateExpressionUsage(final boolean validate) { context.setValidateExpressionUsage(validate); @@ -181,7 +181,7 @@ public class StandardProcessorTestRunner implements TestRunner { public void run(final int iterations, final boolean stopOnFinish) { run(iterations, stopOnFinish, true); } - + @Override public void run(final int iterations, final boolean stopOnFinish, final boolean initialize) { if (iterations < 1) { @@ -191,7 +191,7 @@ public class StandardProcessorTestRunner implements TestRunner { context.assertValid(); context.enableExpressionValidation(); try { - if ( initialize ) { + if (initialize) { try { ReflectionUtils.invokeMethodsWithAnnotation(OnScheduled.class, processor, context); } catch (Exception e) { @@ -519,7 +519,7 @@ public class StandardProcessorTestRunner implements TestRunner { // Assert.fail("Controller Service " + service + " is using deprecated Annotation " + org.apache.nifi.controller.annotation.OnConfigured.class + " for method " + method); // } // } - + final ComponentLog logger = new MockProcessorLog(identifier, service); final MockControllerServiceInitializationContext initContext = new MockControllerServiceInitializationContext(requireNonNull(service), requireNonNull(identifier), logger); service.initialize(initContext); @@ -538,66 +538,64 @@ public class StandardProcessorTestRunner implements TestRunner { context.addControllerService(identifier, service, resolvedProps, null); } - @Override public void assertNotValid(final ControllerService service) { final ValidationContext validationContext = new MockValidationContext(context).getControllerServiceValidationContext(service); final Collection results = context.getControllerService(service.getIdentifier()).validate(validationContext); - - for ( final ValidationResult result : results ) { - if ( !result.isValid() ) { + + for (final ValidationResult result : results) { + if (!result.isValid()) { return; } } - + Assert.fail("Expected Controller Service " + service + " to be invalid but it is valid"); } - + @Override public void assertValid(final ControllerService service) { final ValidationContext validationContext = new MockValidationContext(context).getControllerServiceValidationContext(service); final Collection results = context.getControllerService(service.getIdentifier()).validate(validationContext); - - for ( final ValidationResult result : results ) { - if ( !result.isValid() ) { + + for (final ValidationResult result : results) { + if (!result.isValid()) { Assert.fail("Expected Controller Service to be valid but it is invalid due to: " + result.toString()); } } } - - + @Override public void disableControllerService(final ControllerService service) { final ControllerServiceConfiguration configuration = context.getConfiguration(service.getIdentifier()); - if ( configuration == null ) { + if (configuration == null) { throw new IllegalArgumentException("Controller Service " + service + " is not known"); } - - if ( !configuration.isEnabled() ) { + + if (!configuration.isEnabled()) { throw new IllegalStateException("Controller service " + service + " cannot be disabled because it is not enabled"); } - + try { ReflectionUtils.invokeMethodsWithAnnotation(OnDisabled.class, service); } catch (final Exception e) { e.printStackTrace(); Assert.fail("Failed to disable Controller Service " + service + " due to " + e); } - + configuration.setEnabled(false); } - + @Override public void enableControllerService(final ControllerService service) { final ControllerServiceConfiguration configuration = context.getConfiguration(service.getIdentifier()); - if ( configuration == null ) { + if (configuration == null) { throw new IllegalArgumentException("Controller Service " + service + " is not known"); } - - if ( configuration.isEnabled() ) { + + if (configuration.isEnabled()) { throw new IllegalStateException("Cannot enable Controller Service " + service + " because it is not disabled"); } - + try { final ConfigurationContext configContext = new MockConfigurationContext(configuration.getProperties(), context); ReflectionUtils.invokeMethodsWithAnnotation(OnEnabled.class, service, configContext); @@ -609,87 +607,86 @@ public class StandardProcessorTestRunner implements TestRunner { Assert.fail("Failed to enable Controller Service " + service + " due to " + e); } - configuration.setEnabled(true); + configuration.setEnabled(true); } - + @Override public boolean isControllerServiceEnabled(final ControllerService service) { final ControllerServiceConfiguration configuration = context.getConfiguration(service.getIdentifier()); - if ( configuration == null ) { + if (configuration == null) { throw new IllegalArgumentException("Controller Service " + service + " is not known"); } return configuration.isEnabled(); } - + @Override public void removeControllerService(final ControllerService service) { disableControllerService(service); - + try { ReflectionUtils.invokeMethodsWithAnnotation(OnRemoved.class, service); } catch (final Exception e) { e.printStackTrace(); Assert.fail("Failed to remove Controller Service " + service + " due to " + e); } - + context.removeControllerService(service); } - + @Override public void setAnnotationData(final ControllerService service, final String annotationData) { final ControllerServiceConfiguration configuration = getConfigToUpdate(service); configuration.setAnnotationData(annotationData); } - + private ControllerServiceConfiguration getConfigToUpdate(final ControllerService service) { final ControllerServiceConfiguration configuration = context.getConfiguration(service.getIdentifier()); - if ( configuration == null ) { + if (configuration == null) { throw new IllegalArgumentException("Controller Service " + service + " is not known"); } - - if ( configuration.isEnabled() ) { + + if (configuration.isEnabled()) { throw new IllegalStateException("Controller service " + service + " cannot be modified because it is not disabled"); } - + return configuration; } - + @Override public ValidationResult setProperty(final ControllerService service, final PropertyDescriptor property, final AllowableValue value) { return setProperty(service, property, value.getValue()); } - + @Override public ValidationResult setProperty(final ControllerService service, final PropertyDescriptor property, final String value) { final ControllerServiceConfiguration configuration = getConfigToUpdate(service); final Map curProps = configuration.getProperties(); final Map updatedProps = new HashMap<>(curProps); - + final ValidationContext validationContext = new MockValidationContext(context).getControllerServiceValidationContext(service); final ValidationResult validationResult = property.validate(value, validationContext); - + updatedProps.put(property, value); configuration.setProperties(updatedProps); - + return validationResult; } - + @Override public ValidationResult setProperty(final ControllerService service, final String propertyName, final String value) { final PropertyDescriptor descriptor = service.getPropertyDescriptor(propertyName); - if ( descriptor == null ) { + if (descriptor == null) { return new ValidationResult.Builder() - .input(propertyName) - .explanation(propertyName + " is not a known Property for Controller Service " + service) - .subject("Invalid property") - .valid(false) - .build(); + .input(propertyName) + .explanation(propertyName + " is not a known Property for Controller Service " + service) + .subject("Invalid property") + .valid(false) + .build(); } return setProperty(service, descriptor, value); } - - + @Override public ControllerService getControllerService(final String identifier) { return context.getControllerService(identifier); diff --git a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/TestRunner.java b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/TestRunner.java index 177c889da9..c4fec35b8d 100644 --- a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/TestRunner.java +++ b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/TestRunner.java @@ -38,29 +38,23 @@ import org.apache.nifi.reporting.InitializationException; public interface TestRunner { /** - * Returns the {@link Processor} for which this TestRunner is + * @return the {@link Processor} for which this TestRunner is * configured - * - * @return */ Processor getProcessor(); /** - * Returns the {@link ProcessSessionFactory} that this + * @return the {@link ProcessSessionFactory} that this * TestRunner will use to invoke the * {@link Processor#onTrigger(ProcessContext, ProcessSessionFactory)} method - * - * @return */ ProcessSessionFactory getProcessSessionFactory(); /** - * Returns the {@Link ProcessContext} that this TestRunner will + * @return the {@Link ProcessContext} that this TestRunner will * use to invoke the * {@link Processor#onTrigger(ProcessContext, ProcessSessionFactory) onTrigger} * method - * - * @return */ ProcessContext getProcessContext(); @@ -74,25 +68,26 @@ public interface TestRunner { * Performs the same operation as calling {@link #run(int, boolean)} with a * value of true * - * @param iterations + * @param iterations number of iterations */ void run(int iterations); /** - * performs the same operation as calling {@link #run(int, boolean, int)} with a value - * of {@code iterations}, {@code stopOnFinish}, {@code true} - * - * @param iterations - * @param stopOnFinish + * performs the same operation as calling {@link #run(int, boolean, int)} + * with a value of {@code iterations}, {@code stopOnFinish}, {@code true} + * + * @param iterations number of iterations + * @param stopOnFinish flag to stop when finished */ void run(int iterations, boolean stopOnFinish); - + /** * This method runs the {@link Processor} iterations times, * using the sequence of steps below: *
      *
    • - * If {@code initialize} is true, run all methods on the Processor that are annotated with the + * If {@code initialize} is true, run all methods on the Processor that are + * annotated with the * {@link nifi.processor.annotation.OnScheduled @OnScheduled} annotation. If * any of these methods throws an Exception, the Unit Test will fail. *
    • @@ -122,14 +117,13 @@ public interface TestRunner { * *
    * - * @param iterations + * @param iterations number of iterations * @param stopOnFinish whether or not to run the Processor methods that are * annotated with {@link nifi.processor.annotation.OnStopped @OnStopped} + * @param initialize true if must initialize */ void run(int iterations, boolean stopOnFinish, final boolean initialize); - - /** * Invokes all methods on the Processor that are annotated with the * {@link nifi.processor.annotation.OnShutdown @OnShutdown} annotation. If @@ -141,16 +135,14 @@ public interface TestRunner { * Updates the number of threads that will be used to run the Processor when * calling the {@link #run()} or {@link #run(int)} methods. * - * @param threadCount + * @param threadCount num threads */ void setThreadCount(int threadCount); /** - * Returns the currently configured number of threads that will be used to + * @return the currently configured number of threads that will be used to * runt he Processor when calling the {@link #run()} or {@link #run(int)} - * methods. - * - * @return + * methods */ int getThreadCount(); @@ -160,9 +152,9 @@ public interface TestRunner { * descriptor's validator. Otherwise, Assert.fail() is called, causing the * unit test to fail * - * @param propertyName - * @param propertyValue - * @return + * @param propertyName name + * @param propertyValue value + * @return result */ ValidationResult setProperty(String propertyName, String propertyValue); @@ -172,9 +164,9 @@ public interface TestRunner { * descriptor's validator. Otherwise, Assert.fail() is called, causing the * unit test to fail * - * @param descriptor - * @param value - * @return + * @param descriptor descriptor + * @param value value + * @return result */ ValidationResult setProperty(PropertyDescriptor descriptor, String value); @@ -184,16 +176,16 @@ public interface TestRunner { * descriptor's validator. Otherwise, Assert.fail() is called, causing the * unit test to fail * - * @param descriptor - * @param value - * @return + * @param descriptor descriptor + * @param value allowable valu + * @return result */ ValidationResult setProperty(PropertyDescriptor descriptor, AllowableValue value); /** - * Sets the annontation data. + * Sets the annotation data. * - * @param annotationData + * @param annotationData data */ void setAnnotationData(String annotationData); @@ -201,7 +193,7 @@ public interface TestRunner { * Asserts that all FlowFiles that were transferred were transferred to the * given relationship * - * @param relationship + * @param relationship to verify */ void assertAllFlowFilesTransferred(String relationship); @@ -209,7 +201,7 @@ public interface TestRunner { * Asserts that all FlowFiles that were transferred were transferred to the * given relationship * - * @param relationship + * @param relationship to verify */ void assertAllFlowFilesTransferred(Relationship relationship); @@ -218,8 +210,8 @@ public interface TestRunner { * given relationship and that the number of FlowFiles transferred is equal * to count * - * @param relationship - * @param count + * @param relationship to verify + * @param count number of expected transfers */ void assertAllFlowFilesTransferred(String relationship, int count); @@ -228,8 +220,8 @@ public interface TestRunner { * given relationship and that the number of FlowFiles transferred is equal * to count * - * @param relationship - * @param count + * @param relationship to verify + * @param count number of expected transfers */ void assertAllFlowFilesTransferred(Relationship relationship, int count); @@ -237,8 +229,8 @@ public interface TestRunner { * Assert that the number of FlowFiles transferred to the given relationship * is equal to the given count * - * @param relationship - * @param count + * @param relationship to verify + * @param count number of expected transfers */ void assertTransferCount(Relationship relationship, int count); @@ -246,8 +238,8 @@ public interface TestRunner { * Assert that the number of FlowFiles transferred to the given relationship * is equal to the given count * - * @param relationship - * @param count + * @param relationship to verify + * @param count number of expected transfers */ void assertTransferCount(String relationship, int count); @@ -257,10 +249,8 @@ public interface TestRunner { void assertQueueEmpty(); /** - * Returns true if the Input Queue to the Processor is empty, + * @return true if the Input Queue to the Processor is empty, * false otherwise - * - * @return */ boolean isQueueEmpty(); @@ -293,7 +283,7 @@ public interface TestRunner { /** * Enqueues the given FlowFiles into the Processor's input queue * - * @param flowFiles + * @param flowFiles to enqueue */ void enqueue(FlowFile... flowFiles); @@ -302,8 +292,8 @@ public interface TestRunner { * FlowFile from this content with no attributes and adds this FlowFile to * the Processor's Input Queue * - * @param path - * @throws IOException + * @param path to read content from + * @throws IOException if unable to read content */ void enqueue(Path path) throws IOException; @@ -312,9 +302,9 @@ public interface TestRunner { * FlowFile from this content with the given attributes and adds this * FlowFile to the Processor's Input Queue * - * @param path - * @param attributes - * @throws IOException + * @param path to read content from + * @param attributes attributes to use for new flow file + * @throws IOException if unable to read content */ void enqueue(Path path, Map attributes) throws IOException; @@ -323,7 +313,7 @@ public interface TestRunner { * FlowFile from this content with no attributes and adds this FlowFile to * the Processor's Input Queue * - * @param data + * @param data to enqueue */ void enqueue(byte[] data); @@ -332,8 +322,8 @@ public interface TestRunner { * FlowFile from this content with the given attributes and adds this * FlowFile to the Processor's Input Queue * - * @param data - * @param attributes + * @param data to enqueue + * @param attributes to use for enqueued items */ void enqueue(byte[] data, Map attributes); @@ -342,7 +332,7 @@ public interface TestRunner { * creates a FlowFile from this content with no attributes and adds this * FlowFile to the Processor's Input Queue * - * @param data + * @param data to source data from */ void enqueue(InputStream data); @@ -351,8 +341,8 @@ public interface TestRunner { * creates a FlowFile from this content with the given attributes and adds * this FlowFile to the Processor's Input Queue * - * @param data - * @param attributes + * @param data source of data + * @param attributes to use for flow files */ void enqueue(InputStream data, Map attributes); @@ -360,8 +350,8 @@ public interface TestRunner { * Copies the contents of the given {@link MockFlowFile} into a byte array * and returns that byte array. * - * @param flowFile - * @return + * @param flowFile to get content for + * @return byte array of flowfile content */ byte[] getContentAsByteArray(MockFlowFile flowFile); @@ -369,8 +359,8 @@ public interface TestRunner { * Returns a List of FlowFiles in the order in which they were transferred * to the given relationship * - * @param relationship - * @return + * @param relationship to get flowfiles for + * @return flowfiles transfered to given relationship */ List getFlowFilesForRelationship(String relationship); @@ -378,39 +368,31 @@ public interface TestRunner { * Returns a List of FlowFiles in the order in which they were transferred * to the given relationship * - * @param relationship - * @return + * @param relationship to get flowfiles for + * @return flowfiles transfered to given relationship */ List getFlowFilesForRelationship(Relationship relationship); /** - * Returns the {@link ProvenanceReporter} that will be used by the - * configured {@link Processor} for reporting Provenance Events. - * - * @return + * @return the {@link ProvenanceReporter} that will be used by the + * configured {@link Processor} for reporting Provenance Events */ ProvenanceReporter getProvenanceReporter(); /** - * Returns the current size of the Processor's Input Queue - * - * @return + * @return the current size of the Processor's Input Queue */ QueueSize getQueueSize(); /** - * Returns the current value of the counter with the specified name, or null + * @param name of counter + * @return the current value of the counter with the specified name, or null * if no counter exists with the specified name - * - * @param name - * @return */ Long getCounterValue(String name); /** - * Returns the number of FlowFiles that have been removed from the system - * - * @return + * @return the number of FlowFiles that have been removed from the system */ int getRemovedCount(); @@ -418,10 +400,11 @@ public interface TestRunner { * Indicates to the Framework that the given Relationship should be * considered "available", meaning that the queues of all Connections that * contain this Relationship are not full. This is generally used only when - * dealing with Processors that use the {@link nifi.processor.annotation.TriggerWhenAnyDestinationAvailable - * @TriggerWhenAnyDestinationAvailable} annotation. + * dealing with Processors that use the + * {@link nifi.processor.annotation.TriggerWhenAnyDestinationAvailable} + * annotation. * - * @param relationship + * @param relationship to mark as available */ void setRelationshipAvailable(Relationship relationship); @@ -429,9 +412,10 @@ public interface TestRunner { * Indicates to the Framework that the given Relationship with the given * name should be considered "available", meaning that the queues of all * Connections that contain this Relationship are not full. This is - * generally used only when dealing with Processors that use the {@link nifi.processor.annotation.TriggerWhenAnyDestinationAvailable - * @param relationshipName - * @TriggerWhenAnyDestinationAvailable} annotation. + * generally used only when dealing with Processors that use the + * {@link nifi.processor.annotation.TriggerWhenAnyDestinationAvailable} + * + * @param relationshipName relationship name */ void setRelationshipAvailable(String relationshipName); @@ -439,10 +423,11 @@ public interface TestRunner { * Indicates to the Framework that the given Relationship should NOT be * considered "available", meaning that the queue of at least one Connection * that contain this Relationship is full. This is generally used only when - * dealing with Processors that use the {@link nifi.processor.annotation.TriggerWhenAnyDestinationAvailable - * @TriggerWhenAnyDestinationAvailable} annotation. + * dealing with Processors that use the + * {@link nifi.processor.annotation.TriggerWhenAnyDestinationAvailable} + * annotation. * - * @param relationship + * @param relationship to mark as unavailable */ void setRelationshipUnavailable(Relationship relationship); @@ -450,9 +435,10 @@ public interface TestRunner { * Indicates to the Framework that the Relationship with the given name * should NOT be considered "available", meaning that the queue of at least * one Connection that contain this Relationship is full. This is generally - * used only when dealing with Processors that use the {@link nifi.processor.annotation.TriggerWhenAnyDestinationAvailable - * @param relationshipName - * @TriggerWhenAnyDestinationAvailable} annotation. + * used only when dealing with Processors that use the + * {@link nifi.processor.annotation.TriggerWhenAnyDestinationAvailable} + * + * @param relationshipName name of relationship. */ void setRelationshipUnavailable(String relationshipName); @@ -464,12 +450,13 @@ public interface TestRunner { * {@link nifi.controller.ControllerServiceInitializationContext ControllerServiceInitializationContext} * and initialize the ControllerService with no specified properties. * - * This will call any method on the given Controller Service that is annotated with - * the {@link org.apache.nifi.annotation.lifecycle.OnAdded @OnAdded} annotation. + * This will call any method on the given Controller Service that is + * annotated with the + * {@link org.apache.nifi.annotation.lifecycle.OnAdded @OnAdded} annotation. * - * @param identifier - * @param service - * @throws InitializationException + * @param identifier of service + * @param service the service + * @throws InitializationException ie */ void addControllerService(String identifier, ControllerService service) throws InitializationException; @@ -481,185 +468,206 @@ public interface TestRunner { * {@link nifi.controller.ControllerServiceInitializationContext ControllerServiceInitializationContext} * and initialize the ControllerService with the given properties. * - * This will call any method on the given Controller Service that is annotated with - * the {@link org.apache.nifi.annotation.lifecycle.OnAdded @OnAdded} annotation. - * - * @param identifier - * @param service - * @param properties - * @throws InitializationException + * This will call any method on the given Controller Service that is + * annotated with the + * {@link org.apache.nifi.annotation.lifecycle.OnAdded @OnAdded} annotation. + * + * @param identifier of service + * @param service the service + * @param properties service properties + * @throws InitializationException ie */ void addControllerService(String identifier, ControllerService service, Map properties) throws InitializationException; /** *

    - * Marks the Controller Service as enabled so that it can be used by other components. + * Marks the Controller Service as enabled so that it can be used by other + * components. *

    - * + * *

    - * This method will result in calling any method in the Controller Service that is - * annotated with the {@link org.apache.nifi.annotation.lifecycle.OnEnabled @OnEnabled} annotation. + * This method will result in calling any method in the Controller Service + * that is annotated with the + * {@link org.apache.nifi.annotation.lifecycle.OnEnabled @OnEnabled} + * annotation. *

    - * - * @param service + * + * @param service the service to enable */ void enableControllerService(ControllerService service); - + /** *

    - * Marks the Controller Service as disabled so that it cannot be used by other components. + * Marks the Controller Service as disabled so that it cannot be used by + * other components. *

    - * + * *

    - * This method will result in calling any method in the Controller Service that is - * annotated with the {@link org.apache.nifi.annotation.lifecycle.OnDisabled @OnDisabled} annotation. + * This method will result in calling any method in the Controller Service + * that is annotated with the + * {@link org.apache.nifi.annotation.lifecycle.OnDisabled @OnDisabled} + * annotation. *

    - * - * @param service + * + * @param service the service to disable */ void disableControllerService(ControllerService service); - + /** - *

    - * Returns {@code true} if the given Controller Service is enabled, {@code false} if it is disabled. - *

    - * - * @param service - * @return - * - * @throws IllegalArgumentException if the given ControllerService is not known by this TestRunner - * (i.e., it has not been added via the {@link #addControllerService(String, ControllerService)} or - * {@link #addControllerService(String, ControllerService, Map)} method or if the Controller Service - * has been removed via the {@link #removeControllerService(ControllerService)} method. + * @param service the service + * @return {@code true} if the given Controller Service is enabled, + * {@code false} if it is disabled + * + * @throws IllegalArgumentException if the given ControllerService is not + * known by this TestRunner (i.e., it has not been added via the + * {@link #addControllerService(String, ControllerService)} or + * {@link #addControllerService(String, ControllerService, Map)} method or + * if the Controller Service has been removed via the + * {@link #removeControllerService(ControllerService)} method. */ boolean isControllerServiceEnabled(ControllerService service); - + /** *

    - * Removes the Controller Service from the TestRunner. This will call any method on the ControllerService - * that is annotated with the {@link org.apache.nifi.annotation.lifecycle.OnRemoved @OnRemoved} annotation. + * Removes the Controller Service from the TestRunner. This will call any + * method on the ControllerService that is annotated with the + * {@link org.apache.nifi.annotation.lifecycle.OnRemoved @OnRemoved} + * annotation. *

    - * - * @param service - * + * + * @param service the service + * * @throws IllegalStateException if the ControllerService is not disabled - * @throws IllegalArgumentException if the given ControllerService is not known by this TestRunner - * (i.e., it has not been added via the {@link #addControllerService(String, ControllerService)} or - * {@link #addControllerService(String, ControllerService, Map)} method or if the Controller Service - * has been removed via the {@link #removeControllerService(ControllerService)} method. - * + * @throws IllegalArgumentException if the given ControllerService is not + * known by this TestRunner (i.e., it has not been added via the + * {@link #addControllerService(String, ControllerService)} or + * {@link #addControllerService(String, ControllerService, Map)} method or + * if the Controller Service has been removed via the + * {@link #removeControllerService(ControllerService)} method. + * */ void removeControllerService(ControllerService service); - + /** * Sets the given property on the given ControllerService - * - * @param service - * @param property - * @param value - * + * + * @param service to modify + * @param property to modify + * @param value value to use + * @return result + * * @throws IllegalStateException if the ControllerService is not disabled - * @throws IllegalArgumentException if the given ControllerService is not known by this TestRunner - * (i.e., it has not been added via the {@link #addControllerService(String, ControllerService)} or - * {@link #addControllerService(String, ControllerService, Map)} method or if the Controller Service - * has been removed via the {@link #removeControllerService(ControllerService)} method. - * + * @throws IllegalArgumentException if the given ControllerService is not + * known by this TestRunner (i.e., it has not been added via the + * {@link #addControllerService(String, ControllerService)} or + * {@link #addControllerService(String, ControllerService, Map)} method or + * if the Controller Service has been removed via the + * {@link #removeControllerService(ControllerService)} method. + * */ ValidationResult setProperty(ControllerService service, PropertyDescriptor property, String value); - - + /** * Sets the given property on the given ControllerService - * - * @param service - * @param property - * @param value - * + * + * @param service to modify + * @param property to modify + * @param value value to use + * @return result + * * @throws IllegalStateException if the ControllerService is not disabled - * @throws IllegalArgumentException if the given ControllerService is not known by this TestRunner - * (i.e., it has not been added via the {@link #addControllerService(String, ControllerService)} or - * {@link #addControllerService(String, ControllerService, Map)} method or if the Controller Service - * has been removed via the {@link #removeControllerService(ControllerService)} method. - * + * @throws IllegalArgumentException if the given ControllerService is not + * known by this TestRunner (i.e., it has not been added via the + * {@link #addControllerService(String, ControllerService)} or + * {@link #addControllerService(String, ControllerService, Map)} method or + * if the Controller Service has been removed via the + * {@link #removeControllerService(ControllerService)} method. + * */ ValidationResult setProperty(ControllerService service, PropertyDescriptor property, AllowableValue value); - - + /** * Sets the property with the given name on the given ControllerService - * - * @param service - * @param property - * @param value - * + * + * @param service to modify + * @param propertyName to modify + * @param value value to use + * @return result + * * @throws IllegalStateException if the ControllerService is not disabled - * @throws IllegalArgumentException if the given ControllerService is not known by this TestRunner - * (i.e., it has not been added via the {@link #addControllerService(String, ControllerService)} or - * {@link #addControllerService(String, ControllerService, Map)} method or if the Controller Service - * has been removed via the {@link #removeControllerService(ControllerService)} method. - * + * @throws IllegalArgumentException if the given ControllerService is not + * known by this TestRunner (i.e., it has not been added via the + * {@link #addControllerService(String, ControllerService)} or + * {@link #addControllerService(String, ControllerService, Map)} method or + * if the Controller Service has been removed via the + * {@link #removeControllerService(ControllerService)} method. + * */ ValidationResult setProperty(ControllerService service, String propertyName, String value); - + /** - * Sets the annontation data of the given service to the provided annotation data. + * Sets the annontation data of the given service to the provided annotation + * data. + * + * @param service to modify + * @param annotationData the data * - * @param service - * @param annotationData - * * @throws IllegalStateException if the Controller Service is not disabled * - * @throws IllegalArgumentException if the given ControllerService is not known by this TestRunner - * (i.e., it has not been added via the {@link #addControllerService(String, ControllerService)} or - * {@link #addControllerService(String, ControllerService, Map)} method or if the Controller Service - * has been removed via the {@link #removeControllerService(ControllerService)} method. + * @throws IllegalArgumentException if the given ControllerService is not + * known by this TestRunner (i.e., it has not been added via the + * {@link #addControllerService(String, ControllerService)} or + * {@link #addControllerService(String, ControllerService, Map)} method or + * if the Controller Service has been removed via the + * {@link #removeControllerService(ControllerService)} method. */ void setAnnotationData(ControllerService service, String annotationData); - /** - * Returns the {@link ControllerService} that is registered with the given + * @param identifier of controller service + * @return the {@link ControllerService} that is registered with the given * identifier, or null if no Controller Service exists with the * given identifier - * - * @param identifier - * @return */ ControllerService getControllerService(String identifier); /** * Assert that the currently configured set of properties/annotation data * are valid for the given Controller Service. - * - * @throws IllegalArgumentException if the given ControllerService is not known by this TestRunner - * (i.e., it has not been added via the {@link #addControllerService(String, ControllerService)} or - * {@link #addControllerService(String, ControllerService, Map)} method or if the Controller Service - * has been removed via the {@link #removeControllerService(ControllerService)} method. + * + * @param service the service to validate + * @throws IllegalArgumentException if the given ControllerService is not + * known by this TestRunner (i.e., it has not been added via the + * {@link #addControllerService(String, ControllerService)} or + * {@link #addControllerService(String, ControllerService, Map)} method or + * if the Controller Service has been removed via the + * {@link #removeControllerService(ControllerService)} method. */ void assertValid(ControllerService service); /** * Assert that the currently configured set of properties/annotation data * are NOT valid for the given Controller Service. - * - * @throws IllegalArgumentException if the given ControllerService is not known by this TestRunner - * (i.e., it has not been added via the {@link #addControllerService(String, ControllerService)} or - * {@link #addControllerService(String, ControllerService, Map)} method or if the Controller Service - * has been removed via the {@link #removeControllerService(ControllerService)} method. - * + * + * @param service the service to validate + * @throws IllegalArgumentException if the given ControllerService is not + * known by this TestRunner (i.e., it has not been added via the + * {@link #addControllerService(String, ControllerService)} or + * {@link #addControllerService(String, ControllerService, Map)} method or + * if the Controller Service has been removed via the + * {@link #removeControllerService(ControllerService)} method. + * */ void assertNotValid(ControllerService service); /** - * Returns the {@link ControllerService} that is registered with the given + * @param type of service + * @param identifier identifier of service + * @param serviceType type of service + * @return the {@link ControllerService} that is registered with the given * identifier, cast as the provided service type, or null if no * Controller Service exists with the given identifier * - * @param - * @param identifier - * @param serviceType - * @return - * * @throws ClassCastException if the identifier given is registered for a * Controller Service but that Controller Service is not of the type * specified @@ -682,7 +690,7 @@ public interface TestRunner { *
    {@link PropertyDescriptor.Builder#expressionLanguageSupported(boolean)} *

    * - * @param validate + * @param validate whether there is any need to validate the EL was used */ void setValidateExpressionUsage(boolean validate); @@ -690,8 +698,8 @@ public interface TestRunner { * Removes the {@link PropertyDescriptor} from the {@link ProcessContext}, * effectively setting its value to null. * - * @param descriptor - * @return + * @param descriptor of property to remove + * @return true if removed */ boolean removeProperty(PropertyDescriptor descriptor); } diff --git a/nifi/nifi-mock/src/test/java/org/apache/nifi/util/TestStandardProcessorTestRunner.java b/nifi/nifi-mock/src/test/java/org/apache/nifi/util/TestStandardProcessorTestRunner.java index a561982479..323a3578e3 100644 --- a/nifi/nifi-mock/src/test/java/org/apache/nifi/util/TestStandardProcessorTestRunner.java +++ b/nifi/nifi-mock/src/test/java/org/apache/nifi/util/TestStandardProcessorTestRunner.java @@ -26,61 +26,63 @@ import org.junit.Test; @Ignore("This should not be enabled until we actually fail processor unit tests for using deprecated methods, which should happen in 0.1.0") public class TestStandardProcessorTestRunner { - @Test(expected=AssertionError.class) + @Test(expected = AssertionError.class) public void testFailOnDeprecatedTypeAnnotation() { new StandardProcessorTestRunner(new DeprecatedAnnotation()); } - + @Test public void testDoesNotFailOnNonDeprecatedTypeAnnotation() { new StandardProcessorTestRunner(new NewAnnotation()); } - - @Test(expected=AssertionError.class) + + @Test(expected = AssertionError.class) public void testFailOnDeprecatedMethodAnnotation() { new StandardProcessorTestRunner(new DeprecatedMethodAnnotation()); } - + @Test public void testDoesNotFailOnNonDeprecatedMethodAnnotation() { new StandardProcessorTestRunner(new NewMethodAnnotation()); } - - @SuppressWarnings("deprecation") @org.apache.nifi.processor.annotation.Tags({"deprecated"}) private static class DeprecatedAnnotation extends AbstractProcessor { + @Override public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException { } } - + @org.apache.nifi.annotation.documentation.Tags({"deprecated"}) private static class NewAnnotation extends AbstractProcessor { + @Override public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException { } } - + private static class NewMethodAnnotation extends AbstractProcessor { + @org.apache.nifi.annotation.lifecycle.OnScheduled public void dummy() { - + } - + @Override public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException { } } - + private static class DeprecatedMethodAnnotation extends AbstractProcessor { + @SuppressWarnings("deprecation") @org.apache.nifi.processor.annotation.OnScheduled public void dummy() { - + } - + @Override public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException { } diff --git a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-nar/src/main/resources/META-INF/NOTICE b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-nar/src/main/resources/META-INF/NOTICE new file mode 100644 index 0000000000..64d497582b --- /dev/null +++ b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-nar/src/main/resources/META-INF/NOTICE @@ -0,0 +1,74 @@ +nifi-aws-nar +Copyright 2015 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + +****************** +Apache Software License v2 +****************** + +The following binary components are provided under the Apache Software License v2 + + (ASLv2) Apache HttpComponents + The following NOTICE information applies: + Apache HttpClient + Copyright 1999-2014 The Apache Software Foundation + + Apache HttpCore + Copyright 2005-2014 The Apache Software Foundation + + This project contains annotations derived from JCIP-ANNOTATIONS + Copyright (c) 2005 Brian Goetz and Tim Peierls. See http://www.jcip.net + + (ASLv2) Joda Time + The following NOTICE information applies: + This product includes software developed by + Joda.org (http://www.joda.org/). + + (ASLv2) Apache Commons Codec + The following NOTICE information applies: + Apache Commons Codec + Copyright 2002-2014 The Apache Software Foundation + + src/test/org/apache/commons/codec/language/DoubleMetaphoneTest.java + contains test data from http://aspell.net/test/orig/batch0.tab. + Copyright (C) 2002 Kevin Atkinson (kevina@gnu.org) + + =============================================================================== + + The content of package org.apache.commons.codec.language.bm has been translated + from the original php source code available at http://stevemorse.org/phoneticinfo.htm + with permission from the original authors. + Original source copyright: + Copyright (c) 2008 Alexander Beider & Stephen P. Morse. + + (ASLv2) Apache Commons Logging + The following NOTICE information applies: + Apache Commons Logging + Copyright 2003-2013 The Apache Software Foundation + + (ASLv2) Apache Commons Lang + The following NOTICE information applies: + Apache Commons Lang + Copyright 2001-2014 The Apache Software Foundation + + This product includes software from the Spring Framework, + under the Apache License 2.0 (see: StringUtils.containsWhitespace()) + + (ASLv2) Amazon Web Services SDK + The following NOTICE information applies: + Copyright 2010-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. + + This product includes software developed by + Amazon Technologies, Inc (http://www.amazon.com/). + + ********************** + THIRD PARTY COMPONENTS + ********************** + This software includes third party software subject to the following copyrights: + - XML parsing and utility functions from JetS3t - Copyright 2006-2009 James Murty. + - JSON parsing and utility functions from JSON.org - Copyright 2002 JSON.org. + - PKCS#1 PEM encoded private key parsing and utility functions from oauth.googlecode.com - Copyright 1998-2010 AOL Inc. + + diff --git a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/pom.xml b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/pom.xml index 227077344e..fdc8718533 100644 --- a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/pom.xml +++ b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/pom.xml @@ -35,9 +35,9 @@ nifi-processor-utils - com.amazonaws - aws-java-sdk - + com.amazonaws + aws-java-sdk + org.apache.nifi @@ -55,4 +55,17 @@ test + + + + org.apache.rat + apache-rat-plugin + + + src/test/resources/hello.txt + + + + + diff --git a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/AbstractAWSProcessor.java b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/AbstractAWSProcessor.java index 11c6a9d69f..a781ff982a 100644 --- a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/AbstractAWSProcessor.java +++ b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/AbstractAWSProcessor.java @@ -58,56 +58,54 @@ public abstract class AbstractAWSProcessor(Arrays.asList(REL_SUCCESS, REL_FAILURE))); public static final PropertyDescriptor CREDENTAILS_FILE = new PropertyDescriptor.Builder() - .name("Credentials File") - .expressionLanguageSupported(false) - .required(false) - .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR) - .build(); + .name("Credentials File") + .expressionLanguageSupported(false) + .required(false) + .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR) + .build(); public static final PropertyDescriptor ACCESS_KEY = new PropertyDescriptor.Builder() - .name("Access Key") - .expressionLanguageSupported(false) - .required(false) - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) - .sensitive(true) - .build(); + .name("Access Key") + .expressionLanguageSupported(false) + .required(false) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .sensitive(true) + .build(); public static final PropertyDescriptor SECRET_KEY = new PropertyDescriptor.Builder() - .name("Secret Key") - .expressionLanguageSupported(false) - .required(false) - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) - .sensitive(true) - .build(); + .name("Secret Key") + .expressionLanguageSupported(false) + .required(false) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .sensitive(true) + .build(); public static final PropertyDescriptor REGION = new PropertyDescriptor.Builder() - .name("Region") - .required(true) - .allowableValues(getAvailableRegions()) - .defaultValue(createAllowableValue(Regions.DEFAULT_REGION).getValue()) - .build(); + .name("Region") + .required(true) + .allowableValues(getAvailableRegions()) + .defaultValue(createAllowableValue(Regions.DEFAULT_REGION).getValue()) + .build(); public static final PropertyDescriptor TIMEOUT = new PropertyDescriptor.Builder() - .name("Communications Timeout") - .required(true) - .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) - .defaultValue("30 secs") - .build(); - + .name("Communications Timeout") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .defaultValue("30 secs") + .build(); private volatile ClientType client; - private static AllowableValue createAllowableValue(final Regions regions) { return new AllowableValue(regions.getName(), regions.getName(), regions.getName()); } - + private static AllowableValue[] getAvailableRegions() { final List values = new ArrayList<>(); - for ( final Regions regions : Regions.values() ) { + for (final Regions regions : Regions.values()) { values.add(createAllowableValue(regions)); } - + return (AllowableValue[]) values.toArray(new AllowableValue[values.size()]); } - + @Override public Set getRelationships() { return relationships; @@ -116,52 +114,50 @@ public abstract class AbstractAWSProcessor customValidate(final ValidationContext validationContext) { final List problems = new ArrayList<>(super.customValidate(validationContext)); - + final boolean accessKeySet = validationContext.getProperty(ACCESS_KEY).isSet(); final boolean secretKeySet = validationContext.getProperty(SECRET_KEY).isSet(); - if ( (accessKeySet && !secretKeySet) || (secretKeySet && !accessKeySet) ) { + if ((accessKeySet && !secretKeySet) || (secretKeySet && !accessKeySet)) { problems.add(new ValidationResult.Builder().input("Access Key").valid(false).explanation("If setting Secret Key or Access Key, must set both").build()); } - + final boolean credentialsFileSet = validationContext.getProperty(CREDENTAILS_FILE).isSet(); - if ( (secretKeySet || accessKeySet) && credentialsFileSet ) { + if ((secretKeySet || accessKeySet) && credentialsFileSet) { problems.add(new ValidationResult.Builder().input("Access Key").valid(false).explanation("Cannot set both Credentials File and Secret Key/Access Key").build()); } - + return problems; } - protected ClientConfiguration createConfiguration(final ProcessContext context) { final ClientConfiguration config = new ClientConfiguration(); config.setMaxConnections(context.getMaxConcurrentTasks()); config.setMaxErrorRetry(0); config.setUserAgent("NiFi"); - + final int commsTimeout = context.getProperty(TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue(); config.setConnectionTimeout(commsTimeout); config.setSocketTimeout(commsTimeout); - + return config; } - @OnScheduled public void onScheduled(final ProcessContext context) { final ClientType awsClient = createClient(context, getCredentials(context), createConfiguration(context)); this.client = awsClient; - + // if the processor supports REGION, get the configured region. - if ( getSupportedPropertyDescriptors().contains(REGION) ) { + if (getSupportedPropertyDescriptors().contains(REGION)) { final String region = context.getProperty(REGION).getValue(); - if ( region != null ) { + if (region != null) { client.setRegion(Region.getRegion(Regions.fromName(region))); } } } protected abstract ClientType createClient(final ProcessContext context, final AWSCredentials credentials, final ClientConfiguration config); - + protected ClientType getClient() { return client; } @@ -171,23 +167,22 @@ public abstract class AbstractAWSProcessor { public static final PropertyDescriptor FULL_CONTROL_USER_LIST = new PropertyDescriptor.Builder() - .name("FullControl User List") - .required(false) - .expressionLanguageSupported(true) - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) - .description("A comma-separated list of Amazon User ID's or E-mail addresses that specifies who should have Full Control for an object") - .defaultValue("${s3.permissions.full.users}") - .build(); + .name("FullControl User List") + .required(false) + .expressionLanguageSupported(true) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .description("A comma-separated list of Amazon User ID's or E-mail addresses that specifies who should have Full Control for an object") + .defaultValue("${s3.permissions.full.users}") + .build(); public static final PropertyDescriptor READ_USER_LIST = new PropertyDescriptor.Builder() - .name("Read Permission User List") - .required(false) - .expressionLanguageSupported(true) - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) - .description("A comma-separated list of Amazon User ID's or E-mail addresses that specifies who should have Read Access for an object") - .defaultValue("${s3.permissions.read.users}") - .build(); + .name("Read Permission User List") + .required(false) + .expressionLanguageSupported(true) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .description("A comma-separated list of Amazon User ID's or E-mail addresses that specifies who should have Read Access for an object") + .defaultValue("${s3.permissions.read.users}") + .build(); public static final PropertyDescriptor WRITE_USER_LIST = new PropertyDescriptor.Builder() - .name("Write Permission User List") - .required(false) - .expressionLanguageSupported(true) - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) - .description("A comma-separated list of Amazon User ID's or E-mail addresses that specifies who should have Write Access for an object") - .defaultValue("${s3.permissions.write.users}") - .build(); + .name("Write Permission User List") + .required(false) + .expressionLanguageSupported(true) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .description("A comma-separated list of Amazon User ID's or E-mail addresses that specifies who should have Write Access for an object") + .defaultValue("${s3.permissions.write.users}") + .build(); public static final PropertyDescriptor READ_ACL_LIST = new PropertyDescriptor.Builder() - .name("Read ACL User List") - .required(false) - .expressionLanguageSupported(true) - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) - .description("A comma-separated list of Amazon User ID's or E-mail addresses that specifies who should have permissions to read the Access Control List for an object") - .defaultValue("${s3.permissions.readacl.users}") - .build(); + .name("Read ACL User List") + .required(false) + .expressionLanguageSupported(true) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .description("A comma-separated list of Amazon User ID's or E-mail addresses that specifies who should have permissions to read the Access Control List for an object") + .defaultValue("${s3.permissions.readacl.users}") + .build(); public static final PropertyDescriptor WRITE_ACL_LIST = new PropertyDescriptor.Builder() - .name("Write ACL User List") - .required(false) - .expressionLanguageSupported(true) - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) - .description("A comma-separated list of Amazon User ID's or E-mail addresses that specifies who should have permissions to change the Access Control List for an object") - .defaultValue("${s3.permissions.writeacl.users}") - .build(); + .name("Write ACL User List") + .required(false) + .expressionLanguageSupported(true) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .description("A comma-separated list of Amazon User ID's or E-mail addresses that specifies who should have permissions to change the Access Control List for an object") + .defaultValue("${s3.permissions.writeacl.users}") + .build(); public static final PropertyDescriptor OWNER = new PropertyDescriptor.Builder() - .name("Owner") - .required(false) - .expressionLanguageSupported(true) - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) - .description("The Amazon ID to use for the object's owner") - .defaultValue("${s3.owner}") - .build(); + .name("Owner") + .required(false) + .expressionLanguageSupported(true) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .description("The Amazon ID to use for the object's owner") + .defaultValue("${s3.owner}") + .build(); public static final PropertyDescriptor BUCKET = new PropertyDescriptor.Builder() - .name("Bucket") - .expressionLanguageSupported(true) - .required(true) - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) - .build(); + .name("Bucket") + .expressionLanguageSupported(true) + .required(true) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); public static final PropertyDescriptor KEY = new PropertyDescriptor.Builder() - .name("Object Key") - .required(true) - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) - .expressionLanguageSupported(true) - .defaultValue("${filename}") - .build(); - - + .name("Object Key") + .required(true) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(true) + .defaultValue("${filename}") + .build(); + @Override protected AmazonS3Client createClient(final ProcessContext context, final AWSCredentials credentials, final ClientConfiguration config) { return new AmazonS3Client(credentials, config); } - - + protected Grantee createGrantee(final String value) { - if ( isEmpty(value) ) { + if (isEmpty(value)) { return null; } - - if ( value.contains("@") ) { + + if (value.contains("@")) { return new EmailAddressGrantee(value); } else { return new CanonicalGrantee(value); } } - + protected final List createGrantees(final String value) { - if ( isEmpty(value) ) { + if (isEmpty(value)) { return Collections.emptyList(); } - + final List grantees = new ArrayList<>(); final String[] vals = value.split(","); - for ( final String val : vals ) { + for (final String val : vals) { final String identifier = val.trim(); final Grantee grantee = createGrantee(identifier); - if ( grantee != null ) { + if (grantee != null) { grantees.add(grantee); } } return grantees; } - + protected final AccessControlList createACL(final ProcessContext context, final FlowFile flowFile) { final AccessControlList acl = new AccessControlList(); - + final String ownerId = context.getProperty(OWNER).evaluateAttributeExpressions(flowFile).getValue(); - if ( !isEmpty(ownerId) ) { + if (!isEmpty(ownerId)) { final Owner owner = new Owner(); owner.setId(ownerId); acl.setOwner(owner); } - - for ( final Grantee grantee : createGrantees(context.getProperty(FULL_CONTROL_USER_LIST).evaluateAttributeExpressions(flowFile).getValue())) { + + for (final Grantee grantee : createGrantees(context.getProperty(FULL_CONTROL_USER_LIST).evaluateAttributeExpressions(flowFile).getValue())) { acl.grantPermission(grantee, Permission.FullControl); } - - for ( final Grantee grantee : createGrantees(context.getProperty(READ_USER_LIST).evaluateAttributeExpressions(flowFile).getValue())) { + + for (final Grantee grantee : createGrantees(context.getProperty(READ_USER_LIST).evaluateAttributeExpressions(flowFile).getValue())) { acl.grantPermission(grantee, Permission.Read); } - for ( final Grantee grantee : createGrantees(context.getProperty(WRITE_USER_LIST).evaluateAttributeExpressions(flowFile).getValue())) { + for (final Grantee grantee : createGrantees(context.getProperty(WRITE_USER_LIST).evaluateAttributeExpressions(flowFile).getValue())) { acl.grantPermission(grantee, Permission.Write); } - - for ( final Grantee grantee : createGrantees(context.getProperty(READ_ACL_LIST).evaluateAttributeExpressions(flowFile).getValue())) { + + for (final Grantee grantee : createGrantees(context.getProperty(READ_ACL_LIST).evaluateAttributeExpressions(flowFile).getValue())) { acl.grantPermission(grantee, Permission.ReadAcp); } - for ( final Grantee grantee : createGrantees(context.getProperty(WRITE_ACL_LIST).evaluateAttributeExpressions(flowFile).getValue())) { + for (final Grantee grantee : createGrantees(context.getProperty(WRITE_ACL_LIST).evaluateAttributeExpressions(flowFile).getValue())) { acl.grantPermission(grantee, Permission.WriteAcp); } - + return acl; } } diff --git a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/FetchS3Object.java b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/FetchS3Object.java index 63c834630c..2406b67f12 100644 --- a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/FetchS3Object.java +++ b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/FetchS3Object.java @@ -43,46 +43,44 @@ import com.amazonaws.services.s3.model.GetObjectRequest; import com.amazonaws.services.s3.model.ObjectMetadata; import com.amazonaws.services.s3.model.S3Object; - @SupportsBatching @SeeAlso({PutS3Object.class}) @Tags({"Amazon", "S3", "AWS", "Get", "Fetch"}) @CapabilityDescription("Retrieves the contents of an S3 Object and writes it to the content of a FlowFile") @WritesAttributes({ - @WritesAttribute(attribute="s3.bucket", description="The name of the S3 bucket"), - @WritesAttribute(attribute="path", description="The path of the file"), - @WritesAttribute(attribute="absolute.path", description="The path of the file"), - @WritesAttribute(attribute="filename", description="The name of the file"), - @WritesAttribute(attribute="hash.value", description="The MD5 sum of the file"), - @WritesAttribute(attribute="hash.algorithm", description="MD5"), - @WritesAttribute(attribute="mime.type", description="If S3 provides the content type/MIME type, this attribute will hold that file"), - @WritesAttribute(attribute="s3.etag", description="The ETag that can be used to see if the file has changed"), - @WritesAttribute(attribute="s3.expirationTime", description="If the file has an expiration date, this attribute will be set, containing the milliseconds since epoch in UTC time"), - @WritesAttribute(attribute="s3.expirationTimeRuleId", description="The ID of the rule that dictates this object's expiration time"), - @WritesAttribute(attribute="s3.version", description="The version of the S3 object"), -}) + @WritesAttribute(attribute = "s3.bucket", description = "The name of the S3 bucket"), + @WritesAttribute(attribute = "path", description = "The path of the file"), + @WritesAttribute(attribute = "absolute.path", description = "The path of the file"), + @WritesAttribute(attribute = "filename", description = "The name of the file"), + @WritesAttribute(attribute = "hash.value", description = "The MD5 sum of the file"), + @WritesAttribute(attribute = "hash.algorithm", description = "MD5"), + @WritesAttribute(attribute = "mime.type", description = "If S3 provides the content type/MIME type, this attribute will hold that file"), + @WritesAttribute(attribute = "s3.etag", description = "The ETag that can be used to see if the file has changed"), + @WritesAttribute(attribute = "s3.expirationTime", description = "If the file has an expiration date, this attribute will be set, containing the milliseconds since epoch in UTC time"), + @WritesAttribute(attribute = "s3.expirationTimeRuleId", description = "The ID of the rule that dictates this object's expiration time"), + @WritesAttribute(attribute = "s3.version", description = "The version of the S3 object"),}) public class FetchS3Object extends AbstractS3Processor { - public static final PropertyDescriptor VERSION_ID = new PropertyDescriptor.Builder() - .name("Version") - .description("The Version of the Object to download") - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) - .expressionLanguageSupported(true) - .required(false) - .build(); - + public static final PropertyDescriptor VERSION_ID = new PropertyDescriptor.Builder() + .name("Version") + .description("The Version of the Object to download") + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(true) + .required(false) + .build(); + public static final List properties = Collections.unmodifiableList( - Arrays.asList(BUCKET, KEY, REGION, ACCESS_KEY, SECRET_KEY, CREDENTAILS_FILE, TIMEOUT, VERSION_ID) ); + Arrays.asList(BUCKET, KEY, REGION, ACCESS_KEY, SECRET_KEY, CREDENTAILS_FILE, TIMEOUT, VERSION_ID)); @Override protected List getSupportedPropertyDescriptors() { return properties; } - + @Override public void onTrigger(final ProcessContext context, final ProcessSession session) { FlowFile flowFile = session.get(); - if ( flowFile == null ) { + if (flowFile == null) { return; } @@ -90,10 +88,10 @@ public class FetchS3Object extends AbstractS3Processor { final String bucket = context.getProperty(BUCKET).evaluateAttributeExpressions(flowFile).getValue(); final String key = context.getProperty(KEY).evaluateAttributeExpressions(flowFile).getValue(); final String versionId = context.getProperty(VERSION_ID).evaluateAttributeExpressions(flowFile).getValue(); - + final AmazonS3 client = getClient(); final GetObjectRequest request; - if ( versionId == null ) { + if (versionId == null) { request = new GetObjectRequest(bucket, key); } else { request = new GetObjectRequest(bucket, key, versionId); @@ -103,12 +101,12 @@ public class FetchS3Object extends AbstractS3Processor { try (final S3Object s3Object = client.getObject(request)) { flowFile = session.importFrom(s3Object.getObjectContent(), flowFile); attributes.put("s3.bucket", s3Object.getBucketName()); - + final ObjectMetadata metadata = s3Object.getObjectMetadata(); - if ( metadata.getContentDisposition() != null ) { + if (metadata.getContentDisposition() != null) { final String fullyQualified = metadata.getContentDisposition(); final int lastSlash = fullyQualified.lastIndexOf("/"); - if ( lastSlash > -1 && lastSlash < fullyQualified.length() - 1 ) { + if (lastSlash > -1 && lastSlash < fullyQualified.length() - 1) { attributes.put(CoreAttributes.PATH.key(), fullyQualified.substring(0, lastSlash)); attributes.put(CoreAttributes.ABSOLUTE_PATH.key(), fullyQualified); attributes.put(CoreAttributes.FILENAME.key(), fullyQualified.substring(lastSlash + 1)); @@ -116,42 +114,42 @@ public class FetchS3Object extends AbstractS3Processor { attributes.put(CoreAttributes.FILENAME.key(), metadata.getContentDisposition()); } } - if (metadata.getContentMD5() != null ) { + if (metadata.getContentMD5() != null) { attributes.put("hash.value", metadata.getContentMD5()); attributes.put("hash.algorithm", "MD5"); } - if ( metadata.getContentType() != null ) { + if (metadata.getContentType() != null) { attributes.put(CoreAttributes.MIME_TYPE.key(), metadata.getContentType()); } - if ( metadata.getETag() != null ) { + if (metadata.getETag() != null) { attributes.put("s3.etag", metadata.getETag()); } - if ( metadata.getExpirationTime() != null ) { + if (metadata.getExpirationTime() != null) { attributes.put("s3.expirationTime", String.valueOf(metadata.getExpirationTime().getTime())); } - if ( metadata.getExpirationTimeRuleId() != null ) { + if (metadata.getExpirationTimeRuleId() != null) { attributes.put("s3.expirationTimeRuleId", metadata.getExpirationTimeRuleId()); } - if ( metadata.getUserMetadata() != null ) { + if (metadata.getUserMetadata() != null) { attributes.putAll(metadata.getUserMetadata()); } - if ( metadata.getVersionId() != null ) { + if (metadata.getVersionId() != null) { attributes.put("s3.version", metadata.getVersionId()); } } catch (final IOException | AmazonClientException ioe) { - getLogger().error("Failed to retrieve S3 Object for {}; routing to failure", new Object[] {flowFile, ioe}); + getLogger().error("Failed to retrieve S3 Object for {}; routing to failure", new Object[]{flowFile, ioe}); session.transfer(flowFile, REL_FAILURE); return; } - if ( !attributes.isEmpty() ) { + if (!attributes.isEmpty()) { flowFile = session.putAllAttributes(flowFile, attributes); } session.transfer(flowFile, REL_SUCCESS); final long transferMillis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNanos); - getLogger().info("Successfully retrieved S3 Object for {} in {} millis; routing to success", new Object[] {flowFile, transferMillis}); + getLogger().info("Successfully retrieved S3 Object for {} in {} millis; routing to success", new Object[]{flowFile, transferMillis}); session.getProvenanceReporter().receive(flowFile, "http://" + bucket + ".amazonaws.com/" + key, transferMillis); } - + } diff --git a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/PutS3Object.java b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/PutS3Object.java index 9a4fc5b995..24c82dd036 100644 --- a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/PutS3Object.java +++ b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/PutS3Object.java @@ -56,35 +56,35 @@ import com.amazonaws.services.s3.model.StorageClass; @SeeAlso({FetchS3Object.class}) @Tags({"Amazon", "S3", "AWS", "Archive", "Put"}) @CapabilityDescription("Puts FlowFiles to an Amazon S3 Bucket") -@DynamicProperty(name="The name of a User-Defined Metadata field to add to the S3 Object", - value="The value of a User-Defined Metadata field to add to the S3 Object", - description="Allows user-defined metadata to be added to the S3 object as key/value pairs", - supportsExpressionLanguage=true) -@ReadsAttribute(attribute="filename", description="Uses the FlowFile's filename as the filename for the S3 object") +@DynamicProperty(name = "The name of a User-Defined Metadata field to add to the S3 Object", + value = "The value of a User-Defined Metadata field to add to the S3 Object", + description = "Allows user-defined metadata to be added to the S3 object as key/value pairs", + supportsExpressionLanguage = true) +@ReadsAttribute(attribute = "filename", description = "Uses the FlowFile's filename as the filename for the S3 object") @WritesAttributes({ - @WritesAttribute(attribute="s3.version", description="The version of the S3 Object that was put to S3"), - @WritesAttribute(attribute="s3.etag", description="The ETag of the S3 Object"), - @WritesAttribute(attribute="s3.expiration", description="A human-readable form of the expiration date of the S3 object, if one is set") + @WritesAttribute(attribute = "s3.version", description = "The version of the S3 Object that was put to S3"), + @WritesAttribute(attribute = "s3.etag", description = "The ETag of the S3 Object"), + @WritesAttribute(attribute = "s3.expiration", description = "A human-readable form of the expiration date of the S3 object, if one is set") }) public class PutS3Object extends AbstractS3Processor { + public static final PropertyDescriptor EXPIRATION_RULE_ID = new PropertyDescriptor.Builder() - .name("Expiration Time Rule") - .required(false) - .expressionLanguageSupported(true) - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) - .build(); + .name("Expiration Time Rule") + .required(false) + .expressionLanguageSupported(true) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); public static final PropertyDescriptor STORAGE_CLASS = new PropertyDescriptor.Builder() - .name("Storage Class") - .required(true) - .allowableValues(StorageClass.Standard.name(), StorageClass.ReducedRedundancy.name()) - .defaultValue(StorageClass.Standard.name()) - .build(); + .name("Storage Class") + .required(true) + .allowableValues(StorageClass.Standard.name(), StorageClass.ReducedRedundancy.name()) + .defaultValue(StorageClass.Standard.name()) + .build(); public static final List properties = Collections.unmodifiableList( - Arrays.asList(KEY, BUCKET, ACCESS_KEY, SECRET_KEY, CREDENTAILS_FILE, STORAGE_CLASS, REGION, TIMEOUT, EXPIRATION_RULE_ID, - FULL_CONTROL_USER_LIST, READ_USER_LIST, WRITE_USER_LIST, READ_ACL_LIST, WRITE_ACL_LIST, OWNER) ); - + Arrays.asList(KEY, BUCKET, ACCESS_KEY, SECRET_KEY, CREDENTAILS_FILE, STORAGE_CLASS, REGION, TIMEOUT, EXPIRATION_RULE_ID, + FULL_CONTROL_USER_LIST, READ_USER_LIST, WRITE_USER_LIST, READ_ACL_LIST, WRITE_ACL_LIST, OWNER)); @Override protected List getSupportedPropertyDescriptors() { @@ -94,21 +94,21 @@ public class PutS3Object extends AbstractS3Processor { @Override protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) { return new PropertyDescriptor.Builder() - .name(propertyDescriptorName) - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) - .expressionLanguageSupported(true) - .dynamic(true) - .build(); + .name(propertyDescriptorName) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(true) + .dynamic(true) + .build(); } public void onTrigger(final ProcessContext context, final ProcessSession session) { FlowFile flowFile = session.get(); - if ( flowFile == null ) { + if (flowFile == null) { return; } - + final long startNanos = System.nanoTime(); - + final String bucket = context.getProperty(BUCKET).evaluateAttributeExpressions(flowFile).getValue(); final String key = context.getProperty(KEY).evaluateAttributeExpressions(flowFile).getValue(); @@ -123,59 +123,59 @@ public class PutS3Object extends AbstractS3Processor { final ObjectMetadata objectMetadata = new ObjectMetadata(); objectMetadata.setContentDisposition(ff.getAttribute(CoreAttributes.FILENAME.key())); objectMetadata.setContentLength(ff.getSize()); - + final String expirationRule = context.getProperty(EXPIRATION_RULE_ID).evaluateAttributeExpressions(ff).getValue(); - if ( expirationRule != null ) { + if (expirationRule != null) { objectMetadata.setExpirationTimeRuleId(expirationRule); } - + final Map userMetadata = new HashMap<>(); - for ( final Map.Entry entry : context.getProperties().entrySet() ) { - if ( entry.getKey().isDynamic() ) { + for (final Map.Entry entry : context.getProperties().entrySet()) { + if (entry.getKey().isDynamic()) { final String value = context.getProperty(entry.getKey()).evaluateAttributeExpressions(ff).getValue(); userMetadata.put(entry.getKey().getName(), value); } } - - if ( !userMetadata.isEmpty() ) { + + if (!userMetadata.isEmpty()) { objectMetadata.setUserMetadata(userMetadata); } - + final PutObjectRequest request = new PutObjectRequest(bucket, key, in, objectMetadata); request.setStorageClass(StorageClass.valueOf(context.getProperty(STORAGE_CLASS).getValue())); final AccessControlList acl = createACL(context, ff); - if ( acl != null ) { + if (acl != null) { request.setAccessControlList(acl); } - + final PutObjectResult result = s3.putObject(request); - if ( result.getVersionId() != null ) { + if (result.getVersionId() != null) { attributes.put("s3.version", result.getVersionId()); } - + attributes.put("s3.etag", result.getETag()); - + final Date expiration = result.getExpirationTime(); - if ( expiration != null ) { + if (expiration != null) { attributes.put("s3.expiration", expiration.toString()); } } } }); - - if ( !attributes.isEmpty() ) { + + if (!attributes.isEmpty()) { flowFile = session.putAllAttributes(flowFile, attributes); } session.transfer(flowFile, REL_SUCCESS); - + final String url = "http://" + bucket + ".s3.amazonaws.com/" + key; final long millis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNanos); session.getProvenanceReporter().send(flowFile, url, millis); - - getLogger().info("Successfully put {} to Amazon S3 in {} milliseconds", new Object[] {ff, millis}); + + getLogger().info("Successfully put {} to Amazon S3 in {} milliseconds", new Object[]{ff, millis}); } catch (final ProcessException | AmazonClientException pe) { - getLogger().error("Failed to put {} to Amazon S3 due to {}", new Object[] {flowFile, pe}); + getLogger().error("Failed to put {} to Amazon S3 due to {}", new Object[]{flowFile, pe}); session.transfer(flowFile, REL_FAILURE); } } -} \ No newline at end of file +} diff --git a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sns/AbstractSNSProcessor.java b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sns/AbstractSNSProcessor.java index 5447169034..5b57647666 100644 --- a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sns/AbstractSNSProcessor.java +++ b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sns/AbstractSNSProcessor.java @@ -28,30 +28,28 @@ import com.amazonaws.services.sns.AmazonSNSClient; public abstract class AbstractSNSProcessor extends AbstractAWSProcessor { - protected static final AllowableValue ARN_TYPE_TOPIC = - new AllowableValue("Topic ARN", "Topic ARN", "The ARN is the name of a topic"); - protected static final AllowableValue ARN_TYPE_TARGET = - new AllowableValue("Target ARN", "Target ARN", "The ARN is the name of a particular Target, used to notify a specific subscriber"); - + protected static final AllowableValue ARN_TYPE_TOPIC + = new AllowableValue("Topic ARN", "Topic ARN", "The ARN is the name of a topic"); + protected static final AllowableValue ARN_TYPE_TARGET + = new AllowableValue("Target ARN", "Target ARN", "The ARN is the name of a particular Target, used to notify a specific subscriber"); + public static final PropertyDescriptor ARN = new PropertyDescriptor.Builder() - .name("Amazon Resource Name (ARN)") - .description("The name of the resource to which notifications should be published") - .expressionLanguageSupported(true) - .required(true) - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) - .build(); - + .name("Amazon Resource Name (ARN)") + .description("The name of the resource to which notifications should be published") + .expressionLanguageSupported(true) + .required(true) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + public static final PropertyDescriptor ARN_TYPE = new PropertyDescriptor.Builder() - .name("ARN Type") - .description("The type of Amazon Resource Name that is being used.") - .expressionLanguageSupported(false) - .required(true) - .allowableValues(ARN_TYPE_TOPIC, ARN_TYPE_TARGET) - .defaultValue(ARN_TYPE_TOPIC.getValue()) - .build(); - - - + .name("ARN Type") + .description("The type of Amazon Resource Name that is being used.") + .expressionLanguageSupported(false) + .required(true) + .allowableValues(ARN_TYPE_TOPIC, ARN_TYPE_TARGET) + .defaultValue(ARN_TYPE_TOPIC.getValue()) + .build(); + @Override protected AmazonSNSClient createClient(final ProcessContext context, final AWSCredentials credentials, final ClientConfiguration config) { return new AmazonSNSClient(credentials, config); diff --git a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sns/PutSNS.java b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sns/PutSNS.java index 1de3251ce8..7d42703b2e 100644 --- a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sns/PutSNS.java +++ b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sns/PutSNS.java @@ -46,34 +46,36 @@ import com.amazonaws.services.sns.model.PublishRequest; public class PutSNS extends AbstractSNSProcessor { public static final PropertyDescriptor CHARACTER_ENCODING = new PropertyDescriptor.Builder() - .name("Character Set") - .description("The character set in which the FlowFile's content is encoded") - .defaultValue("UTF-8") - .expressionLanguageSupported(true) - .addValidator(StandardValidators.CHARACTER_SET_VALIDATOR) - .required(true) - .build(); + .name("Character Set") + .description("The character set in which the FlowFile's content is encoded") + .defaultValue("UTF-8") + .expressionLanguageSupported(true) + .addValidator(StandardValidators.CHARACTER_SET_VALIDATOR) + .required(true) + .build(); public static final PropertyDescriptor USE_JSON_STRUCTURE = new PropertyDescriptor.Builder() - .name("Use JSON Structure") - .description("If true, the contents of the FlowFile must be JSON with a top-level element named 'default'. Additional elements can be used to send different messages to different protocols. See the Amazon SNS Documentation for more information.") - .defaultValue("false") - .allowableValues("true", "false") - .required(true) - .build(); + .name("Use JSON Structure") + .description("If true, the contents of the FlowFile must be JSON with a top-level element named 'default'." + + " Additional elements can be used to send different messages to different protocols. See the Amazon" + + " SNS Documentation for more information.") + .defaultValue("false") + .allowableValues("true", "false") + .required(true) + .build(); public static final PropertyDescriptor SUBJECT = new PropertyDescriptor.Builder() - .name("E-mail Subject") - .description("The optional subject to use for any subscribers that are subscribed via E-mail") - .expressionLanguageSupported(true) - .required(false) - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) - .build(); - + .name("E-mail Subject") + .description("The optional subject to use for any subscribers that are subscribed via E-mail") + .expressionLanguageSupported(true) + .required(false) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + public static final List properties = Collections.unmodifiableList( - Arrays.asList(ARN, ARN_TYPE, SUBJECT, REGION, ACCESS_KEY, SECRET_KEY, CREDENTAILS_FILE, TIMEOUT, - USE_JSON_STRUCTURE, CHARACTER_ENCODING) ); + Arrays.asList(ARN, ARN_TYPE, SUBJECT, REGION, ACCESS_KEY, SECRET_KEY, CREDENTAILS_FILE, TIMEOUT, + USE_JSON_STRUCTURE, CHARACTER_ENCODING)); public static final int MAX_SIZE = 256 * 1024; - + @Override protected List getSupportedPropertyDescriptors() { return properties; @@ -82,73 +84,71 @@ public class PutSNS extends AbstractSNSProcessor { @Override protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) { return new PropertyDescriptor.Builder() - .name(propertyDescriptorName) - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) - .expressionLanguageSupported(true) - .required(false) - .dynamic(true) - .build(); + .name(propertyDescriptorName) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(true) + .required(false) + .dynamic(true) + .build(); } - - + @Override public void onTrigger(final ProcessContext context, final ProcessSession session) { FlowFile flowFile = session.get(); - if ( flowFile == null ) { + if (flowFile == null) { return; } - if ( flowFile.getSize() > MAX_SIZE ) { - getLogger().error("Cannot publish {} to SNS because its size exceeds Amazon SNS's limit of 256KB; routing to failure", new Object[] {flowFile}); + if (flowFile.getSize() > MAX_SIZE) { + getLogger().error("Cannot publish {} to SNS because its size exceeds Amazon SNS's limit of 256KB; routing to failure", new Object[]{flowFile}); session.transfer(flowFile, REL_FAILURE); return; } - + final Charset charset = Charset.forName(context.getProperty(CHARACTER_ENCODING).evaluateAttributeExpressions(flowFile).getValue()); - + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); session.exportTo(flowFile, baos); final String message = new String(baos.toByteArray(), charset); - + final AmazonSNSClient client = getClient(); final PublishRequest request = new PublishRequest(); request.setMessage(message); - - if ( context.getProperty(USE_JSON_STRUCTURE).asBoolean() ) { + + if (context.getProperty(USE_JSON_STRUCTURE).asBoolean()) { request.setMessageStructure("json"); } - + final String arn = context.getProperty(ARN).evaluateAttributeExpressions(flowFile).getValue(); final String arnType = context.getProperty(ARN_TYPE).getValue(); - if ( arnType.equalsIgnoreCase(ARN_TYPE_TOPIC.getValue()) ) { + if (arnType.equalsIgnoreCase(ARN_TYPE_TOPIC.getValue())) { request.setTopicArn(arn); } else { request.setTargetArn(arn); } - + final String subject = context.getProperty(SUBJECT).evaluateAttributeExpressions(flowFile).getValue(); - if ( subject != null ) { + if (subject != null) { request.setSubject(subject); } - for ( final Map.Entry entry : context.getProperties().entrySet() ) { - if ( entry.getKey().isDynamic() && !isEmpty(entry.getValue()) ) { + for (final Map.Entry entry : context.getProperties().entrySet()) { + if (entry.getKey().isDynamic() && !isEmpty(entry.getValue())) { final MessageAttributeValue value = new MessageAttributeValue(); value.setStringValue(context.getProperty(entry.getKey()).evaluateAttributeExpressions(flowFile).getValue()); value.setDataType("String"); request.addMessageAttributesEntry(entry.getKey().getName(), value); } } - + try { client.publish(request); session.transfer(flowFile, REL_SUCCESS); session.getProvenanceReporter().send(flowFile, arn); - getLogger().info("Successfully published notification for {}", new Object[] {flowFile}); + getLogger().info("Successfully published notification for {}", new Object[]{flowFile}); } catch (final Exception e) { - getLogger().error("Failed to publish Amazon SNS message for {} due to {}", new Object[] {flowFile, e}); + getLogger().error("Failed to publish Amazon SNS message for {} due to {}", new Object[]{flowFile, e}); session.transfer(flowFile, REL_FAILURE); - return; } } diff --git a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sqs/AbstractSQSProcessor.java b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sqs/AbstractSQSProcessor.java index 2ef749f6d9..3cee02d61b 100644 --- a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sqs/AbstractSQSProcessor.java +++ b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sqs/AbstractSQSProcessor.java @@ -28,20 +28,20 @@ import com.amazonaws.services.sqs.AmazonSQSClient; public abstract class AbstractSQSProcessor extends AbstractAWSProcessor { public static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() - .name("Batch Size") - .description("The maximum number of messages to send in a single network request") - .required(true) - .addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) - .defaultValue("25") - .build(); + .name("Batch Size") + .description("The maximum number of messages to send in a single network request") + .required(true) + .addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) + .defaultValue("25") + .build(); public static final PropertyDescriptor QUEUE_URL = new PropertyDescriptor.Builder() - .name("Queue URL") - .description("The URL of the queue to act upon") - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) - .expressionLanguageSupported(true) - .required(true) - .build(); + .name("Queue URL") + .description("The URL of the queue to act upon") + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(true) + .required(true) + .build(); @Override protected AmazonSQSClient createClient(final ProcessContext context, final AWSCredentials credentials, final ClientConfiguration config) { diff --git a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sqs/DeleteSQS.java b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sqs/DeleteSQS.java index 2416044af1..65e020d979 100644 --- a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sqs/DeleteSQS.java +++ b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sqs/DeleteSQS.java @@ -40,54 +40,54 @@ import com.amazonaws.services.sqs.model.DeleteMessageBatchRequestEntry; @Tags({"Amazon", "AWS", "SQS", "Queue", "Delete"}) @CapabilityDescription("Deletes a message from an Amazon Simple Queuing Service Queue") public class DeleteSQS extends AbstractSQSProcessor { + public static final PropertyDescriptor RECEIPT_HANDLE = new PropertyDescriptor.Builder() - .name("Receipt Handle") - .description("The identifier that specifies the receipt of the message") - .expressionLanguageSupported(true) - .required(true) - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) - .defaultValue("${sqs.receipt.handle}") - .build(); - + .name("Receipt Handle") + .description("The identifier that specifies the receipt of the message") + .expressionLanguageSupported(true) + .required(true) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .defaultValue("${sqs.receipt.handle}") + .build(); + public static final List properties = Collections.unmodifiableList( - Arrays.asList(ACCESS_KEY, SECRET_KEY, REGION, QUEUE_URL, TIMEOUT) ); + Arrays.asList(ACCESS_KEY, SECRET_KEY, REGION, QUEUE_URL, TIMEOUT)); @Override protected List getSupportedPropertyDescriptors() { return properties; } - @Override public void onTrigger(final ProcessContext context, final ProcessSession session) { List flowFiles = session.get(1); - if ( flowFiles.isEmpty() ) { + if (flowFiles.isEmpty()) { return; } - + final FlowFile firstFlowFile = flowFiles.get(0); final String queueUrl = context.getProperty(QUEUE_URL).evaluateAttributeExpressions(firstFlowFile).getValue(); - + final AmazonSQSClient client = getClient(); final DeleteMessageBatchRequest request = new DeleteMessageBatchRequest(); request.setQueueUrl(queueUrl); - + final List entries = new ArrayList<>(flowFiles.size()); - - for ( final FlowFile flowFile : flowFiles ) { + + for (final FlowFile flowFile : flowFiles) { final DeleteMessageBatchRequestEntry entry = new DeleteMessageBatchRequestEntry(); entry.setReceiptHandle(context.getProperty(RECEIPT_HANDLE).evaluateAttributeExpressions(flowFile).getValue()); entries.add(entry); } - + request.setEntries(entries); - + try { client.deleteMessageBatch(request); - getLogger().info("Successfully deleted {} objects from SQS", new Object[] {flowFiles.size()}); + getLogger().info("Successfully deleted {} objects from SQS", new Object[]{flowFiles.size()}); session.transfer(flowFiles, REL_SUCCESS); } catch (final Exception e) { - getLogger().error("Failed to delete {} objects from SQS due to {}", new Object[] {flowFiles.size(), e}); + getLogger().error("Failed to delete {} objects from SQS due to {}", new Object[]{flowFiles.size(), e}); session.transfer(flowFiles, REL_FAILURE); } } diff --git a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sqs/GetSQS.java b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sqs/GetSQS.java index 6c0257bf45..7c2dd2d3fa 100644 --- a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sqs/GetSQS.java +++ b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sqs/GetSQS.java @@ -51,116 +51,116 @@ import com.amazonaws.services.sqs.model.ReceiveMessageRequest; import com.amazonaws.services.sqs.model.ReceiveMessageResult; @SupportsBatching -@Tags({ "Amazon", "AWS", "SQS", "Queue", "Get", "Fetch", "Poll"}) +@Tags({"Amazon", "AWS", "SQS", "Queue", "Get", "Fetch", "Poll"}) @SeeAlso({PutSQS.class, DeleteSQS.class}) @CapabilityDescription("Fetches messages from an Amazon Simple Queuing Service Queue") @WritesAttributes({ - @WritesAttribute(attribute="hash.value", description="The MD5 sum of the message"), - @WritesAttribute(attribute="hash.algorithm", description="MD5"), - @WritesAttribute(attribute="sqs.message.id", description="The unique identifier of the SQS message"), - @WritesAttribute(attribute="sqs.receipt.handle", description="The SQS Receipt Handle that is to be used to delete the message from the queue") + @WritesAttribute(attribute = "hash.value", description = "The MD5 sum of the message"), + @WritesAttribute(attribute = "hash.algorithm", description = "MD5"), + @WritesAttribute(attribute = "sqs.message.id", description = "The unique identifier of the SQS message"), + @WritesAttribute(attribute = "sqs.receipt.handle", description = "The SQS Receipt Handle that is to be used to delete the message from the queue") }) public class GetSQS extends AbstractSQSProcessor { - public static final PropertyDescriptor CHARSET = new PropertyDescriptor.Builder() - .name("Character Set") - .description("The Character Set that should be used to encode the textual content of the SQS message") - .required(true) - .defaultValue("UTF-8") - .allowableValues(Charset.availableCharsets().keySet().toArray(new String[0])) - .build(); - - public static final PropertyDescriptor AUTO_DELETE = new PropertyDescriptor.Builder() - .name("Auto Delete Messages") - .description("Specifies whether the messages should be automatically deleted by the processors once they have been received.") - .required(true) - .allowableValues("true", "false") - .defaultValue("true") - .build(); - - public static final PropertyDescriptor VISIBILITY_TIMEOUT = new PropertyDescriptor.Builder() - .name("Visibility Timeout") - .description("The amount of time after a message is received but not deleted that the message is hidden from other consumers") - .expressionLanguageSupported(false) - .required(true) - .defaultValue("15 mins") - .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) - .build(); - - public static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() - .name("Batch Size") - .description("The maximum number of messages to send in a single network request") - .required(true) - .addValidator(StandardValidators.createLongValidator(1L, 10L, true)) - .defaultValue("10") - .build(); - + public static final PropertyDescriptor CHARSET = new PropertyDescriptor.Builder() + .name("Character Set") + .description("The Character Set that should be used to encode the textual content of the SQS message") + .required(true) + .defaultValue("UTF-8") + .allowableValues(Charset.availableCharsets().keySet().toArray(new String[0])) + .build(); + + public static final PropertyDescriptor AUTO_DELETE = new PropertyDescriptor.Builder() + .name("Auto Delete Messages") + .description("Specifies whether the messages should be automatically deleted by the processors once they have been received.") + .required(true) + .allowableValues("true", "false") + .defaultValue("true") + .build(); + + public static final PropertyDescriptor VISIBILITY_TIMEOUT = new PropertyDescriptor.Builder() + .name("Visibility Timeout") + .description("The amount of time after a message is received but not deleted that the message is hidden from other consumers") + .expressionLanguageSupported(false) + .required(true) + .defaultValue("15 mins") + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .build(); + + public static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() + .name("Batch Size") + .description("The maximum number of messages to send in a single network request") + .required(true) + .addValidator(StandardValidators.createLongValidator(1L, 10L, true)) + .defaultValue("10") + .build(); + public static final PropertyDescriptor STATIC_QUEUE_URL = new PropertyDescriptor.Builder() - .fromPropertyDescriptor(QUEUE_URL) - .expressionLanguageSupported(false) - .build(); - + .fromPropertyDescriptor(QUEUE_URL) + .expressionLanguageSupported(false) + .build(); + public static final List properties = Collections.unmodifiableList( - Arrays.asList(STATIC_QUEUE_URL, AUTO_DELETE, ACCESS_KEY, SECRET_KEY, CREDENTAILS_FILE, REGION, BATCH_SIZE, TIMEOUT, CHARSET, VISIBILITY_TIMEOUT) ); + Arrays.asList(STATIC_QUEUE_URL, AUTO_DELETE, ACCESS_KEY, SECRET_KEY, CREDENTAILS_FILE, REGION, BATCH_SIZE, TIMEOUT, CHARSET, VISIBILITY_TIMEOUT)); @Override protected List getSupportedPropertyDescriptors() { return properties; } - + @Override public Set getRelationships() { return Collections.singleton(REL_SUCCESS); } - + @Override public void onTrigger(final ProcessContext context, final ProcessSession session) { final String queueUrl = context.getProperty(STATIC_QUEUE_URL).getValue(); - + final AmazonSQSClient client = getClient(); - + final ReceiveMessageRequest request = new ReceiveMessageRequest(); request.setAttributeNames(Collections.singleton("All")); request.setMaxNumberOfMessages(context.getProperty(BATCH_SIZE).asInteger()); request.setVisibilityTimeout(context.getProperty(VISIBILITY_TIMEOUT).asTimePeriod(TimeUnit.SECONDS).intValue()); request.setQueueUrl(queueUrl); - + final Charset charset = Charset.forName(context.getProperty(CHARSET).getValue()); - + final ReceiveMessageResult result; try { result = client.receiveMessage(request); } catch (final Exception e) { - getLogger().error("Failed to receive messages from Amazon SQS due to {}", new Object[] {e}); + getLogger().error("Failed to receive messages from Amazon SQS due to {}", new Object[]{e}); context.yield(); return; } - + final List messages = result.getMessages(); - if ( messages.isEmpty() ) { + if (messages.isEmpty()) { context.yield(); return; } final boolean autoDelete = context.getProperty(AUTO_DELETE).asBoolean(); - - for ( final Message message : messages ) { + + for (final Message message : messages) { FlowFile flowFile = session.create(); - + final Map attributes = new HashMap<>(); - for ( final Map.Entry entry : message.getAttributes().entrySet() ) { + for (final Map.Entry entry : message.getAttributes().entrySet()) { attributes.put("sqs." + entry.getKey(), entry.getValue()); } - - for ( final Map.Entry entry : message.getMessageAttributes().entrySet() ) { + + for (final Map.Entry entry : message.getMessageAttributes().entrySet()) { attributes.put("sqs." + entry.getKey(), entry.getValue().getStringValue()); } - + attributes.put("hash.value", message.getMD5OfBody()); attributes.put("hash.algorithm", "md5"); attributes.put("sqs.message.id", message.getMessageId()); attributes.put("sqs.receipt.handle", message.getReceiptHandle()); - + flowFile = session.putAllAttributes(flowFile, attributes); flowFile = session.write(flowFile, new OutputStreamCallback() { @Override @@ -168,37 +168,38 @@ public class GetSQS extends AbstractSQSProcessor { out.write(message.getBody().getBytes(charset)); } }); - + session.transfer(flowFile, REL_SUCCESS); session.getProvenanceReporter().receive(flowFile, queueUrl); - - getLogger().info("Successfully received {} from Amazon SQS", new Object[] {flowFile}); + + getLogger().info("Successfully received {} from Amazon SQS", new Object[]{flowFile}); } - - if ( autoDelete ) { + + if (autoDelete) { // If we want to auto-delete messages, we must fist commit the session to ensure that the data // is persisted in NiFi's repositories. session.commit(); - + final DeleteMessageBatchRequest deleteRequest = new DeleteMessageBatchRequest(); deleteRequest.setQueueUrl(queueUrl); final List deleteRequestEntries = new ArrayList<>(); - for ( final Message message : messages ) { + for (final Message message : messages) { final DeleteMessageBatchRequestEntry entry = new DeleteMessageBatchRequestEntry(); entry.setId(message.getMessageId()); entry.setReceiptHandle(message.getReceiptHandle()); deleteRequestEntries.add(entry); } - + deleteRequest.setEntries(deleteRequestEntries); - + try { client.deleteMessageBatch(deleteRequest); } catch (final Exception e) { - getLogger().error("Received {} messages from Amazon SQS but failed to delete the messages; these messages may be duplicated. Reason for deletion failure: {}", new Object[] {messages.size(), e}); + getLogger().error("Received {} messages from Amazon SQS but failed to delete the messages; these messages" + + " may be duplicated. Reason for deletion failure: {}", new Object[]{messages.size(), e}); } } - + } } diff --git a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sqs/PutSQS.java b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sqs/PutSQS.java index 81268fe2cd..3961f323ca 100644 --- a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sqs/PutSQS.java +++ b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sqs/PutSQS.java @@ -44,29 +44,28 @@ import com.amazonaws.services.sqs.model.MessageAttributeValue; import com.amazonaws.services.sqs.model.SendMessageBatchRequest; import com.amazonaws.services.sqs.model.SendMessageBatchRequestEntry; - @SupportsBatching @Tags({"Amazon", "AWS", "SQS", "Queue", "Put", "Publish"}) @SeeAlso({GetSQS.class, DeleteSQS.class}) @CapabilityDescription("Publishes a message to an Amazon Simple Queuing Service Queue") -@DynamicProperty(name="The name of a Message Attribute to add to the message", value="The value of the Message Attribute", - description="Allows the user to add key/value pairs as Message Attributes by adding a property whose name will become the name of " - + "the Message Attribute and value will become the value of the Message Attribute", supportsExpressionLanguage=true) +@DynamicProperty(name = "The name of a Message Attribute to add to the message", value = "The value of the Message Attribute", + description = "Allows the user to add key/value pairs as Message Attributes by adding a property whose name will become the name of " + + "the Message Attribute and value will become the value of the Message Attribute", supportsExpressionLanguage = true) public class PutSQS extends AbstractSQSProcessor { public static final PropertyDescriptor DELAY = new PropertyDescriptor.Builder() - .name("Delay") - .description("The amount of time to delay the message before it becomes available to consumers") - .required(true) - .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) - .defaultValue("0 secs") - .build(); + .name("Delay") + .description("The amount of time to delay the message before it becomes available to consumers") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .defaultValue("0 secs") + .build(); public static final List properties = Collections.unmodifiableList( - Arrays.asList(QUEUE_URL, ACCESS_KEY, SECRET_KEY, CREDENTAILS_FILE, REGION, DELAY, TIMEOUT) ); + Arrays.asList(QUEUE_URL, ACCESS_KEY, SECRET_KEY, CREDENTAILS_FILE, REGION, DELAY, TIMEOUT)); private volatile List userDefinedProperties = Collections.emptyList(); - + @Override protected List getSupportedPropertyDescriptors() { return properties; @@ -75,70 +74,70 @@ public class PutSQS extends AbstractSQSProcessor { @Override protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) { return new PropertyDescriptor.Builder() - .name(propertyDescriptorName) - .expressionLanguageSupported(true) - .required(false) - .dynamic(true) - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) - .build(); + .name(propertyDescriptorName) + .expressionLanguageSupported(true) + .required(false) + .dynamic(true) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); } - + @OnScheduled public void setup(final ProcessContext context) { userDefinedProperties = new ArrayList<>(); - for ( final PropertyDescriptor descriptor : context.getProperties().keySet() ) { - if ( descriptor.isDynamic() ) { + for (final PropertyDescriptor descriptor : context.getProperties().keySet()) { + if (descriptor.isDynamic()) { userDefinedProperties.add(descriptor); } } } - + @Override public void onTrigger(final ProcessContext context, final ProcessSession session) { FlowFile flowFile = session.get(); - if ( flowFile == null ) { + if (flowFile == null) { return; } - + final long startNanos = System.nanoTime(); final AmazonSQSClient client = getClient(); final SendMessageBatchRequest request = new SendMessageBatchRequest(); final String queueUrl = context.getProperty(QUEUE_URL).evaluateAttributeExpressions(flowFile).getValue(); request.setQueueUrl(queueUrl); - + final Set entries = new HashSet<>(); - + final SendMessageBatchRequestEntry entry = new SendMessageBatchRequestEntry(); entry.setId(flowFile.getAttribute("uuid")); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); session.exportTo(flowFile, baos); final String flowFileContent = baos.toString(); entry.setMessageBody(flowFileContent); - + final Map messageAttributes = new HashMap<>(); - - for ( final PropertyDescriptor descriptor : userDefinedProperties ) { + + for (final PropertyDescriptor descriptor : userDefinedProperties) { final MessageAttributeValue mav = new MessageAttributeValue(); mav.setDataType("String"); mav.setStringValue(context.getProperty(descriptor).evaluateAttributeExpressions(flowFile).getValue()); messageAttributes.put(descriptor.getName(), mav); } - + entry.setMessageAttributes(messageAttributes); entry.setDelaySeconds(context.getProperty(DELAY).asTimePeriod(TimeUnit.SECONDS).intValue()); entries.add(entry); - + request.setEntries(entries); - + try { client.sendMessageBatch(request); } catch (final Exception e) { - getLogger().error("Failed to send messages to Amazon SQS due to {}; routing to failure", new Object[] {e}); + getLogger().error("Failed to send messages to Amazon SQS due to {}; routing to failure", new Object[]{e}); session.transfer(flowFile, REL_FAILURE); return; } - - getLogger().info("Successfully published message to Amazon SQS for {}", new Object[] {flowFile}); + + getLogger().info("Successfully published message to Amazon SQS for {}", new Object[]{flowFile}); session.transfer(flowFile, REL_SUCCESS); final long transmissionMillis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNanos); session.getProvenanceReporter().send(flowFile, queueUrl, transmissionMillis); diff --git a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestFetchS3Object.java b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestFetchS3Object.java index 40f951538b..0321514946 100644 --- a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestFetchS3Object.java +++ b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestFetchS3Object.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.nifi.processors.aws.s3; import java.io.IOException; @@ -15,30 +31,31 @@ import org.junit.Test; @Ignore("For local testing only - interacts with S3 so the credentials file must be configured and all necessary buckets created") public class TestFetchS3Object { + private final String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties"; - + @Test public void testGet() throws IOException { final TestRunner runner = TestRunners.newTestRunner(new FetchS3Object()); runner.setProperty(FetchS3Object.BUCKET, "anonymous-test-bucket-00000000"); runner.setProperty(FetchS3Object.CREDENTAILS_FILE, CREDENTIALS_FILE); runner.setProperty(FetchS3Object.KEY, "folder/1.txt"); - + final Map attrs = new HashMap<>(); attrs.put("start", "0"); - + runner.enqueue(new byte[0], attrs); runner.run(1); - + runner.assertAllFlowFilesTransferred(FetchS3Object.REL_SUCCESS, 1); final List ffs = runner.getFlowFilesForRelationship(FetchS3Object.REL_SUCCESS); final MockFlowFile out = ffs.iterator().next(); - + final byte[] expectedBytes = Files.readAllBytes(Paths.get("src/test/resources/hello.txt")); out.assertContentEquals(new String(expectedBytes)); - for ( final Map.Entry entry : out.getAttributes().entrySet() ) { + for (final Map.Entry entry : out.getAttributes().entrySet()) { System.out.println(entry.getKey() + " : " + entry.getValue()); } } - + } diff --git a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestPutS3Object.java b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestPutS3Object.java index 0a019f3328..de7816db70 100644 --- a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestPutS3Object.java +++ b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestPutS3Object.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.nifi.processors.aws.s3; import java.io.IOException; @@ -17,55 +33,54 @@ import com.amazonaws.services.s3.model.StorageClass; public class TestPutS3Object { private final String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties"; - + @Test public void testSimplePut() throws IOException { final TestRunner runner = TestRunners.newTestRunner(new PutS3Object()); runner.setProperty(PutS3Object.CREDENTAILS_FILE, CREDENTIALS_FILE); runner.setProperty(PutS3Object.BUCKET, "test-bucket-00000000-0000-0000-0000-123456789012"); runner.setProperty(PutS3Object.EXPIRATION_RULE_ID, "Expire Quickly"); - Assert.assertTrue( runner.setProperty("x-custom-prop", "hello").isValid() ); - - for (int i=0; i < 3; i++) { + Assert.assertTrue(runner.setProperty("x-custom-prop", "hello").isValid()); + + for (int i = 0; i < 3; i++) { final Map attrs = new HashMap<>(); attrs.put("filename", String.valueOf(i) + ".txt"); runner.enqueue(Paths.get("src/test/resources/hello.txt"), attrs); } runner.run(3); - + runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS, 3); } - + @Test public void testPutInFolder() throws IOException { final TestRunner runner = TestRunners.newTestRunner(new PutS3Object()); runner.setProperty(PutS3Object.BUCKET, "test-bucket-00000000-0000-0000-0000-123456789012"); runner.setProperty(PutS3Object.CREDENTAILS_FILE, CREDENTIALS_FILE); runner.setProperty(PutS3Object.EXPIRATION_RULE_ID, "Expire Quickly"); - Assert.assertTrue( runner.setProperty("x-custom-prop", "hello").isValid() ); - + Assert.assertTrue(runner.setProperty("x-custom-prop", "hello").isValid()); + final Map attrs = new HashMap<>(); attrs.put("filename", "folder/1.txt"); runner.enqueue(Paths.get("src/test/resources/hello.txt"), attrs); runner.run(); - + runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS, 1); } - @Test public void testStorageClass() throws IOException { final TestRunner runner = TestRunners.newTestRunner(new PutS3Object()); runner.setProperty(PutS3Object.BUCKET, "test-bucket-00000000-0000-0000-0000-123456789012"); runner.setProperty(PutS3Object.CREDENTAILS_FILE, CREDENTIALS_FILE); runner.setProperty(PutS3Object.STORAGE_CLASS, StorageClass.ReducedRedundancy.name()); - Assert.assertTrue( runner.setProperty("x-custom-prop", "hello").isValid() ); - + Assert.assertTrue(runner.setProperty("x-custom-prop", "hello").isValid()); + final Map attrs = new HashMap<>(); attrs.put("filename", "folder/2.txt"); runner.enqueue(Paths.get("src/test/resources/hello.txt"), attrs); runner.run(); - + runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS, 1); } @@ -75,12 +90,12 @@ public class TestPutS3Object { runner.setProperty(PutS3Object.BUCKET, "test-bucket-00000000-0000-0000-0000-123456789012"); runner.setProperty(PutS3Object.CREDENTAILS_FILE, CREDENTIALS_FILE); runner.setProperty(PutS3Object.FULL_CONTROL_USER_LIST, "28545acd76c35c7e91f8409b95fd1aa0c0914bfa1ac60975d9f48bc3c5e090b5"); - + final Map attrs = new HashMap<>(); attrs.put("filename", "folder/4.txt"); runner.enqueue(Paths.get("src/test/resources/hello.txt"), attrs); runner.run(); - + runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS, 1); } diff --git a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sns/TestPutSNS.java b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sns/TestPutSNS.java index b505622ca0..1e914c7ad8 100644 --- a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sns/TestPutSNS.java +++ b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sns/TestPutSNS.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.nifi.processors.aws.sns; import static org.junit.Assert.assertTrue; @@ -14,20 +30,21 @@ import org.junit.Test; @Ignore("For local testing only - interacts with S3 so the credentials file must be configured and all necessary buckets created") public class TestPutSNS { + private final String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties"; - + @Test public void testPublish() throws IOException { final TestRunner runner = TestRunners.newTestRunner(new PutSNS()); runner.setProperty(PutSNS.CREDENTAILS_FILE, CREDENTIALS_FILE); runner.setProperty(PutSNS.ARN, "arn:aws:sns:us-west-2:100515378163:test-topic-1"); - assertTrue( runner.setProperty("DynamicProperty", "hello!").isValid() ); - + assertTrue(runner.setProperty("DynamicProperty", "hello!").isValid()); + final Map attrs = new HashMap<>(); attrs.put("filename", "1.txt"); runner.enqueue(Paths.get("src/test/resources/hello.txt"), attrs); runner.run(); - + runner.assertAllFlowFilesTransferred(PutSNS.REL_SUCCESS, 1); } diff --git a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sqs/TestGetSQS.java b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sqs/TestGetSQS.java index de4a5d9cc2..0e70e7b642 100644 --- a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sqs/TestGetSQS.java +++ b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sqs/TestGetSQS.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.nifi.processors.aws.sqs; import java.util.List; @@ -11,6 +27,7 @@ import org.junit.Test; @Ignore("For local testing only - interacts with S3 so the credentials file must be configured and all necessary buckets created") public class TestGetSQS { + private final String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties"; @Test @@ -19,11 +36,11 @@ public class TestGetSQS { runner.setProperty(PutSNS.CREDENTAILS_FILE, CREDENTIALS_FILE); runner.setProperty(GetSQS.TIMEOUT, "30 secs"); runner.setProperty(GetSQS.QUEUE_URL, "https://sqs.us-west-2.amazonaws.com/100515378163/test-queue-000000000"); - + runner.run(1); - + final List flowFiles = runner.getFlowFilesForRelationship(GetSQS.REL_SUCCESS); - for ( final MockFlowFile mff : flowFiles ) { + for (final MockFlowFile mff : flowFiles) { System.out.println(mff.getAttributes()); System.out.println(new String(mff.toByteArray())); } diff --git a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sqs/TestPutSQS.java b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sqs/TestPutSQS.java index a90a4ce339..1f9851af4e 100644 --- a/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sqs/TestPutSQS.java +++ b/nifi/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sqs/TestPutSQS.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.nifi.processors.aws.sqs; import java.io.IOException; @@ -14,6 +30,7 @@ import org.junit.Test; @Ignore("For local testing only - interacts with S3 so the credentials file must be configured and all necessary buckets created") public class TestPutSQS { + private final String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties"; @Test @@ -22,13 +39,13 @@ public class TestPutSQS { runner.setProperty(PutSNS.CREDENTAILS_FILE, CREDENTIALS_FILE); runner.setProperty(PutSQS.TIMEOUT, "30 secs"); runner.setProperty(PutSQS.QUEUE_URL, "https://sqs.us-west-2.amazonaws.com/100515378163/test-queue-000000000"); - Assert.assertTrue( runner.setProperty("x-custom-prop", "hello").isValid() ); - + Assert.assertTrue(runner.setProperty("x-custom-prop", "hello").isValid()); + final Map attrs = new HashMap<>(); attrs.put("filename", "1.txt"); runner.enqueue(Paths.get("src/test/resources/hello.txt"), attrs); runner.run(1); - + runner.assertAllFlowFilesTransferred(PutSQS.REL_SUCCESS, 1); } diff --git a/nifi/nifi-nar-bundles/nifi-aws-bundle/pom.xml b/nifi/nifi-nar-bundles/nifi-aws-bundle/pom.xml index 117d7dd1c4..44353278d3 100644 --- a/nifi/nifi-nar-bundles/nifi-aws-bundle/pom.xml +++ b/nifi/nifi-nar-bundles/nifi-aws-bundle/pom.xml @@ -30,14 +30,14 @@ nifi-aws-nar - - - - com.amazonaws - aws-java-sdk - 1.9.24 - - - + + + + com.amazonaws + aws-java-sdk + 1.9.24 + + + diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework-nar/src/main/resources/META-INF/NOTICE b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework-nar/src/main/resources/META-INF/NOTICE index cd0d2a87bb..6794428653 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework-nar/src/main/resources/META-INF/NOTICE +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework-nar/src/main/resources/META-INF/NOTICE @@ -90,6 +90,11 @@ The following binary components are provided under the Apache Software License v Spring Framework 4.1.4.RELEASE Copyright (c) 2002-2014 Pivotal, Inc. + (ASLv2) Swagger Core + The following NOTICE information applies: + Swagger Core 1.5.3-M1 + Copyright 2015 Reverb Technologies, Inc. + ************************ Common Development and Distribution License 1.1 ************************ diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/pom.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/pom.xml index ebf2ceb95b..f474aab604 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/pom.xml +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/pom.xml @@ -46,6 +46,14 @@ + + org.apache.maven.plugins + maven-checkstyle-plugin + + **/authorization/generated/*.java, + + + diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/RepositoryUtils.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/RepositoryUtils.java index b95388b821..f678d5dbc4 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/RepositoryUtils.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/RepositoryUtils.java @@ -25,7 +25,6 @@ import org.slf4j.Logger; /** * A utility class for useful methods dealing with the repository * - * @author unattributed */ public class RepositoryUtils { @@ -45,7 +44,7 @@ public class RepositoryUtils { /** * Closes the given statement quietly - no logging, no exceptions * - * @param statement + * @param statement to close */ public static void closeQuietly(final Statement statement) { @@ -61,7 +60,7 @@ public class RepositoryUtils { /** * Closes the given result set quietly - no logging, no exceptions * - * @param resultSet + * @param resultSet to close */ public static void closeQuietly(final ResultSet resultSet) { if (null != resultSet) { @@ -76,7 +75,7 @@ public class RepositoryUtils { /** * Closes the given connection quietly - no logging, no exceptions * - * @param conn + * @param conn to close */ public static void closeQuietly(final Connection conn) { if (null != conn) { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/UserDataSourceFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/UserDataSourceFactoryBean.java index 1f64f6eba2..ebcf574107 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/UserDataSourceFactoryBean.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/UserDataSourceFactoryBean.java @@ -30,9 +30,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.FactoryBean; -/** - * - */ public class UserDataSourceFactoryBean implements FactoryBean { private static final Logger logger = LoggerFactory.getLogger(UserDataSourceFactoryBean.class); @@ -196,12 +193,6 @@ public class UserDataSourceFactoryBean implements FactoryBean { return connectionPool; } - /** - * Get the database url for the specified database file. - * - * @param databaseFile - * @return - */ private String getDatabaseUrl(File databaseFile) { String databaseUrl = "jdbc:h2:" + databaseFile + ";AUTOCOMMIT=OFF;DB_CLOSE_ON_EXIT=FALSE;LOCK_MODE=3"; String databaseUrlAppend = properties.getProperty(NiFiProperties.H2_URL_APPEND); @@ -225,9 +216,6 @@ public class UserDataSourceFactoryBean implements FactoryBean { this.properties = properties; } - /** - * Disposes resources. - */ public void shutdown() { // shutdown the connection pool diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/dao/ActionDAO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/dao/ActionDAO.java index 5d5d498ee5..925dc80279 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/dao/ActionDAO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/dao/ActionDAO.java @@ -32,43 +32,41 @@ public interface ActionDAO { /** * Persists the specified action. * - * @param action - * @throws DataAccessException + * @param action to persist + * @throws DataAccessException if unable to persist */ void createAction(Action action) throws DataAccessException; /** * Finds all actions that meet the specified criteria. * - * @param actionQuery - * @return - * @throws DataAccessException + * @param actionQuery query for actions + * @return History of actions + * @throws DataAccessException dae */ History findActions(HistoryQuery actionQuery) throws DataAccessException; /** - * Finds the previous values for the specified property in the specified - * component. Returns empty list if there are none. - * - * @param componentId - * @return + * @param componentId to get previous values of + * @return Finds the previous values for the specified property in the + * specified component. Returns empty list if there are none */ Map> getPreviousValues(String componentId); /** * Finds the specified action. * - * @param actionId - * @return - * @throws DataAccessException + * @param actionId action identifier + * @return Action specified + * @throws DataAccessException dae */ Action getAction(Integer actionId) throws DataAccessException; /** * Deletes all actions up to the specified end date. * - * @param endDate - * @throws DataAccessException + * @param endDate date to stop deleting at + * @throws DataAccessException dae */ void deleteActions(Date endDate) throws DataAccessException; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/dao/AuthorityDAO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/dao/AuthorityDAO.java index 2992884cbf..b80b78ed63 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/dao/AuthorityDAO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/dao/AuthorityDAO.java @@ -27,32 +27,33 @@ public interface AuthorityDAO { /** * Finds all Authority for the specified user. * - * @param userId - * @return + * @param userId identifier of user + * @return authorities */ Set findAuthoritiesByUserId(String userId) throws DataAccessException; /** - * Creates a new Authorities for the specified user. + * Creates new Authorities for the specified user in addition to authorities + * they already have. * - * @param authorities - * @param userId + * @param authorities to add to the given user + * @param userId identifier of user */ void createAuthorities(Set authorities, String userId) throws DataAccessException; /** * Removes all Authorities for the specified user. * - * @param userId - * @throws DataAccessException + * @param userId user identifier + * @throws DataAccessException if unable to access authorities */ void deleteAuthorities(String userId) throws DataAccessException; /** * Removes the specified Authority. * - * @param authorities - * @param userId + * @param authorities to remove + * @param userId user id */ void deleteAuthorities(Set authorities, String userId) throws DataAccessException; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/dao/UserDAO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/dao/UserDAO.java index 9ffab5d8e3..6339e5a568 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/dao/UserDAO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/dao/UserDAO.java @@ -29,98 +29,98 @@ public interface UserDAO { /** * Determines whether there are any PENDING user accounts. * - * @return - * @throws DataAccessException + * @return true if pending + * @throws DataAccessException dae */ Boolean hasPendingUserAccounts() throws DataAccessException; /** * Returns all users. * - * @return - * @throws DataAccessException + * @return all users + * @throws DataAccessException dae */ Set findUsers() throws DataAccessException; /** * Returns all user groups. * - * @return - * @throws DataAccessException + * @return all group names + * @throws DataAccessException dae */ Set findUserGroups() throws DataAccessException; /** * Returns all users for the specified group. * - * @param group - * @return - * @throws DataAccessException + * @param group group + * @return users in group + * @throws DataAccessException dae */ Set findUsersForGroup(String group) throws DataAccessException; /** * Returns the user with the specified id. * - * @param id - * @return - * @throws DataAccessException + * @param id user id + * @return user for the given id + * @throws DataAccessException dae */ NiFiUser findUserById(String id) throws DataAccessException; /** * Returns the user with the specified DN. * - * @param dn - * @return + * @param dn user dn + * @return user */ NiFiUser findUserByDn(String dn) throws DataAccessException; /** * Creates a new user based off the specified NiFiUser. * - * @param user + * @param user to create */ void createUser(NiFiUser user) throws DataAccessException; /** * Updates the specified NiFiUser. * - * @param user + * @param user to update */ void updateUser(NiFiUser user) throws DataAccessException; /** * Deletes the specified user. * - * @param id - * @throws DataAccessException + * @param id user identifier + * @throws DataAccessException dae */ void deleteUser(String id) throws DataAccessException; /** * Sets the status of the specified group. * - * @param group - * @param status - * @throws DataAccessException + * @param group group + * @param status status + * @throws DataAccessException dae */ void updateGroupStatus(String group, AccountStatus status) throws DataAccessException; /** * Sets the last verified time for all users in the specified group. * - * @param group - * @param lastVerified - * @throws DataAccessException S + * @param group group + * @param lastVerified date last verified + * @throws DataAccessException dae */ void updateGroupVerification(String group, Date lastVerified) throws DataAccessException; /** * Ungroups the specified group. * - * @param group - * @throws DataAccessException + * @param group to ungroup + * @throws DataAccessException dae */ void ungroup(String group) throws DataAccessException; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/dao/impl/StandardActionDAO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/dao/impl/StandardActionDAO.java index 34623f4248..bb655ebdcf 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/dao/impl/StandardActionDAO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/dao/impl/StandardActionDAO.java @@ -259,13 +259,6 @@ public class StandardActionDAO implements ActionDAO { } } - /** - * Persists the extension details. - * - * @param actionId - * @param extensionDetails - * @throws DataAccessException - */ private void createExtensionDetails(int actionId, ExtensionDetails extensionDetails) throws DataAccessException { PreparedStatement statement = null; try { @@ -288,13 +281,6 @@ public class StandardActionDAO implements ActionDAO { } } - /** - * Persists the remote process group details. - * - * @param actionId - * @param remoteProcessGroupDetails - * @throws DataAccessException - */ private void createRemoteProcessGroupDetails(int actionId, RemoteProcessGroupDetails remoteProcessGroupDetails) throws DataAccessException { PreparedStatement statement = null; try { @@ -317,13 +303,6 @@ public class StandardActionDAO implements ActionDAO { } } - /** - * Persists the connection details. - * - * @param actionId - * @param connectionDetails - * @throws DataAccessException - */ private void createConnectDetails(int actionId, ConnectDetails connectionDetails) throws DataAccessException { PreparedStatement statement = null; try { @@ -352,13 +331,6 @@ public class StandardActionDAO implements ActionDAO { } } - /** - * Persists the move details. - * - * @param actionId - * @param moveDetails - * @throws DataAccessException - */ private void createMoveDetails(int actionId, MoveDetails moveDetails) throws DataAccessException { PreparedStatement statement = null; try { @@ -384,13 +356,6 @@ public class StandardActionDAO implements ActionDAO { } } - /** - * Persists the configuration details. - * - * @param actionId - * @param configurationDetails - * @throws DataAccessException - */ private void createConfigureDetails(int actionId, ConfigureDetails configurationDetails) throws DataAccessException { PreparedStatement statement = null; try { @@ -415,13 +380,6 @@ public class StandardActionDAO implements ActionDAO { } } - /** - * Persists the purge details. - * - * @param actionId - * @param purgeDetails - * @throws DataAccessException - */ private void createPurgeDetails(int actionId, PurgeDetails purgeDetails) throws DataAccessException { PreparedStatement statement = null; try { @@ -444,13 +402,6 @@ public class StandardActionDAO implements ActionDAO { } } - /** - * Finds actions that meet the criteria in the specified query. - * - * @param historyQuery - * @return - * @throws DataAccessException - */ @Override public History findActions(HistoryQuery historyQuery) throws DataAccessException { @@ -601,7 +552,7 @@ public class StandardActionDAO implements ActionDAO { // get the component details if appropriate ComponentDetails componentDetails = null; - if (Component.Processor.equals(component) || Component.ControllerService.equals(component) || Component.ReportingTask.equals(component)) { + if (Component.Processor.equals(component) || Component.ControllerService.equals(component) || Component.ReportingTask.equals(component)) { componentDetails = getExtensionDetails(actionId); } else if (Component.RemoteProcessGroup.equals(component)) { componentDetails = getRemoteProcessGroupDetails(actionId); @@ -712,13 +663,6 @@ public class StandardActionDAO implements ActionDAO { return action; } - /** - * Loads the specified extension details. - * - * @param actionId - * @return - * @throws DataAccessException - */ private ExtensionDetails getExtensionDetails(Integer actionId) throws DataAccessException { ExtensionDetails extensionDetails = null; PreparedStatement statement = null; @@ -746,13 +690,6 @@ public class StandardActionDAO implements ActionDAO { return extensionDetails; } - /** - * Loads the specified remote process group details. - * - * @param actionId - * @return - * @throws DataAccessException - */ private RemoteProcessGroupDetails getRemoteProcessGroupDetails(Integer actionId) throws DataAccessException { RemoteProcessGroupDetails remoteProcessGroupDetails = null; PreparedStatement statement = null; @@ -780,13 +717,6 @@ public class StandardActionDAO implements ActionDAO { return remoteProcessGroupDetails; } - /** - * Loads the specified move details. - * - * @param actionId - * @return - * @throws DataAccessException - */ private MoveDetails getMoveDetails(Integer actionId) throws DataAccessException { MoveDetails moveDetails = null; PreparedStatement statement = null; @@ -817,13 +747,6 @@ public class StandardActionDAO implements ActionDAO { return moveDetails; } - /** - * Loads the specified relationship details. - * - * @param actionId - * @return - * @throws DataAccessException - */ private ConnectDetails getConnectDetails(Integer actionId) throws DataAccessException { ConnectDetails connectionDetails = null; PreparedStatement statement = null; @@ -860,13 +783,6 @@ public class StandardActionDAO implements ActionDAO { return connectionDetails; } - /** - * Loads the specified configuration details. - * - * @param actionId - * @return - * @throws DataAccessException - */ private ConfigureDetails getConfigureDetails(Integer actionId) throws DataAccessException { ConfigureDetails configurationDetails = null; PreparedStatement statement = null; @@ -896,13 +812,6 @@ public class StandardActionDAO implements ActionDAO { return configurationDetails; } - /** - * Loads the specified purge details. - * - * @param actionId - * @return - * @throws DataAccessException - */ private PurgeDetails getPurgeDetails(Integer actionId) throws DataAccessException { PurgeDetails purgeDetails = null; PreparedStatement statement = null; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/AuditService.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/AuditService.java index 7ca4e0618a..680173f8f2 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/AuditService.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/AuditService.java @@ -33,26 +33,24 @@ public interface AuditService { /** * Adds the specified actions. * - * @param actions - * @throws AdministrationException + * @param actions to add + * @throws AdministrationException if failed to add */ void addActions(Collection actions); /** - * Finds the previous values for the specified property in the specified - * component. Returns null if there are none. - * - * @param componentId - * @return + * @param componentId identifier of the component + * @return Finds the previous values for the specified property in the + * specified component. Returns null if there are none */ Map> getPreviousValues(String componentId); /** * Get the actions within the given date range. * - * @param actionQuery - * @return - * @throws AdministrationException + * @param actionQuery query + * @return history of actions + * @throws AdministrationException ae */ History getActions(HistoryQuery actionQuery); @@ -60,17 +58,17 @@ public interface AuditService { * Get the details for the specified action id. If the action cannot be * found, null is returned. * - * @param actionId - * @return + * @param actionId identifier of action + * @return the action */ Action getAction(Integer actionId); /** * Purges all action's that occurred before the specified end date. * - * @param end - * @param purgeAction - * @throws AdministrationException + * @param end the stopper for event purging + * @param purgeAction the action + * @throws AdministrationException ae */ void purgeActions(Date end, Action purgeAction); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/UserService.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/UserService.java index 86256fd408..b02f192d10 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/UserService.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/UserService.java @@ -33,129 +33,125 @@ public interface UserService { /** * Creates a new user account using the specified dn and justification. * - * @param dn - * @param justification - * @return + * @param dn user dn + * @param justification why the account is necessary + * @return the created NiFiUser */ NiFiUser createPendingUserAccount(String dn, String justification); /** - * Determines if there are any PENDING user accounts present. - * - * @return + * @return Determines if there are any PENDING user accounts present */ Boolean hasPendingUserAccount(); /** - * Determines if the users in the dnChain are authorized to download content - * with the specified attributes. - * - * @param dnChain - * @param attributes - * @return + * @param dnChain user dn chain + * @param attributes attributes for authorization request + * @return Determines if the users in the dnChain are authorized to download + * content with the specified attributes */ DownloadAuthorization authorizeDownload(List dnChain, Map attributes); - + /** * Updates a user group using the specified group comprised of the specified * users. Returns all the users that are currently in the specified group. * - * @param group - * @param userIds - * @param authorities - * @return + * @param group group + * @param userIds users + * @param authorities auths + * @return a user group */ NiFiUserGroup updateGroup(String group, Set userIds, Set authorities); /** * Authorizes the user specified. * - * @param dn - * @return + * @param dn user dn + * @return the user for the given dn if found */ NiFiUser checkAuthorization(String dn); /** * Deletes the user with the specified id. * - * @param id + * @param id user identifier */ void deleteUser(String id); /** * Disables the specified users account. * - * @param id - * @return + * @param id user identifier + * @return user for the given identifier */ NiFiUser disable(String id); /** * Disables the specified user group. * - * @param group - * @return + * @param group to disable + * @return user group */ NiFiUserGroup disableGroup(String group); /** * Updates the specified user with the specified authorities. * - * @param id - * @param authorities - * @return + * @param id identifier of user + * @param authorities auths to set + * @return the updated user */ NiFiUser update(String id, Set authorities); /** * Invalidates the specified user account. * - * @param id + * @param id identifier of user account to invalidate */ void invalidateUserAccount(String id); /** * Invalidates the user accounts associated with the specified user group. * - * @param group + * @param group to invalidate user accounts on */ void invalidateUserGroupAccount(String group); /** * Ungroups the specified group. * - * @param group + * @param group to split up */ void ungroup(String group); /** * Ungroups the specified user. * - * @param id + * @param id user to ungroup */ void ungroupUser(String id); /** * Returns a collection of all NiFiUsers. * - * @return + * @return Collection of users */ Collection getUsers(); /** * Finds the specified user by id. * - * @param id - * @return + * @param id of the user + * @return the user object */ NiFiUser getUserById(String id); /** * Finds the specified user by dn. * - * @param dn - * @return - * @throws AdministrationException + * @param dn the user dn + * @return the newly created user + * @throws AdministrationException ae */ NiFiUser getUserByDn(String dn); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/AbstractUserAction.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/AbstractUserAction.java index 41c97fe0cb..b970dc18c3 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/AbstractUserAction.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/AbstractUserAction.java @@ -26,16 +26,16 @@ import org.apache.nifi.user.NiFiUser; /** * - * @param + * @param type of user action */ public abstract class AbstractUserAction implements AdministrationAction { /** * Determines the authorities that need to be added to the specified user. * - * @param user - * @param authorities - * @return + * @param user user + * @param authorities auths + * @return authorities to add */ protected Set determineAuthoritiesToAdd(NiFiUser user, Set authorities) { // not using copyOf since authorities may be empty and copyOf can throw an IllegalArgumentException when empty @@ -53,9 +53,9 @@ public abstract class AbstractUserAction implements AdministrationAction { * Determines the authorities that need to be removed from the specified * user. * - * @param user - * @param authorities - * @return + * @param user user + * @param authorities auths + * @return auths to remove */ protected Set determineAuthoritiesToRemove(NiFiUser user, Set authorities) { Set authoritiesToRemove = EnumSet.copyOf(user.getAuthorities()); @@ -71,8 +71,8 @@ public abstract class AbstractUserAction implements AdministrationAction { * Verifies the specified users account. Includes obtaining the authorities * and group according to the specified authority provider. * - * @param authorityProvider - * @param user + * @param authorityProvider provider + * @param user user to verify */ protected void verifyAccount(AuthorityProvider authorityProvider, NiFiUser user) { // load the roles for the user diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/AdministrationAction.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/AdministrationAction.java index 5818ebe073..f1795a9157 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/AdministrationAction.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/AdministrationAction.java @@ -23,16 +23,16 @@ import org.apache.nifi.authorization.AuthorityProvider; * Defines the administration action. Actions are provided a DAO factory and * authority provider to perform a require action. * - * @param + * @param type */ public interface AdministrationAction { /** * Performs an action using the specified DAOFactory and AuthorityProvider. * - * @param daoFactory - * @param authorityProvider - * @return + * @param daoFactory factory + * @param authorityProvider provider + * @return action result */ T execute(DAOFactory daoFactory, AuthorityProvider authorityProvider); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/AuthorizeUserAction.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/AuthorizeUserAction.java index ea6973dd20..fe32772c7c 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/AuthorizeUserAction.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/AuthorizeUserAction.java @@ -142,9 +142,7 @@ public class AuthorizeUserAction extends AbstractUserAction { } /** - * Determines if account verification is required. - * - * @return + * @return Determines if account verification is required */ private boolean isAccountVerificationRequired(NiFiUser user) { // accounts that have never been verified obviously needs to be re-verified @@ -163,7 +161,7 @@ public class AuthorizeUserAction extends AbstractUserAction { /** * Checks the account status of the specified user. * - * @param user + * @param user to check */ private void checkAccountStatus(NiFiUser user) { if (AccountStatus.DISABLED.equals(user.getStatus())) { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/DeleteUserAction.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/DeleteUserAction.java index f93e97e778..0d59b43522 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/DeleteUserAction.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/DeleteUserAction.java @@ -35,7 +35,7 @@ public class DeleteUserAction implements AdministrationAction { /** * Creates a new transactions for deleting the specified user. * - * @param userId + * @param userId user identifier */ public DeleteUserAction(String userId) { this.userId = userId; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/FindUserByIdAction.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/FindUserByIdAction.java index 3062a2ea75..0a10841368 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/FindUserByIdAction.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/FindUserByIdAction.java @@ -22,9 +22,6 @@ import org.apache.nifi.admin.dao.UserDAO; import org.apache.nifi.authorization.AuthorityProvider; import org.apache.nifi.user.NiFiUser; -/** - * - */ public class FindUserByIdAction implements AdministrationAction { private final String id; @@ -32,7 +29,7 @@ public class FindUserByIdAction implements AdministrationAction { /** * Creates a new transactions for getting a user with the specified id. * - * @param id + * @param id of user */ public FindUserByIdAction(String id) { this.id = id; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/SeedUserAccountsAction.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/SeedUserAccountsAction.java index 72d68db2dc..6665ac09ac 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/SeedUserAccountsAction.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/action/SeedUserAccountsAction.java @@ -102,7 +102,7 @@ public class SeedUserAccountsAction extends AbstractUserAction { CreateUserAction createUser = new CreateUserAction(user); createUser.execute(daoFactory, authorityProvider); } else { - // this is not a new user and we have just verified their + // this is not a new user and we have just verified their // account, do not revoke... accountsToRevoke.remove(user); @@ -144,7 +144,7 @@ public class SeedUserAccountsAction extends AbstractUserAction { try { logger.info(String.format("User not authorized with configured provider: %s. Disabling account...", user.getDn())); - // disable the account and reset its last verified timestamp since it was not found + // disable the account and reset its last verified timestamp since it was not found // in the current configured authority provider user.setStatus(AccountStatus.DISABLED); user.setLastVerified(null); diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/impl/StandardAuditService.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/impl/StandardAuditService.java index 721e6b27ec..e588841fdb 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/impl/StandardAuditService.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/impl/StandardAuditService.java @@ -197,22 +197,12 @@ public class StandardAuditService implements AuditService { } } - /** - * Rolls back the specified transaction. - * - * @param transaction - */ private void rollback(Transaction transaction) { if (transaction != null) { transaction.rollback(); } } - /** - * Closes the specified transaction. - * - * @param transaction - */ private void closeQuietly(final Transaction transaction) { if (transaction != null) { try { @@ -222,7 +212,6 @@ public class StandardAuditService implements AuditService { } } - /* setters */ public void setTransactionBuilder(TransactionBuilder transactionBuilder) { this.transactionBuilder = transactionBuilder; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/impl/StandardUserService.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/impl/StandardUserService.java index 5c9af4b721..424816febb 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/impl/StandardUserService.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/impl/StandardUserService.java @@ -77,7 +77,7 @@ public class StandardUserService implements UserService { * Seed any users from the authority provider that are not already present. */ public void seedUserAccounts() { - // do not seed node's user cache. when/if the node disconnects its + // do not seed node's user cache. when/if the node disconnects its // cache will be populated lazily (as needed) if (properties.isNode()) { return; @@ -143,7 +143,7 @@ public class StandardUserService implements UserService { writeLock.lock(); try { - // if user ids have been specified, invalidate the user accounts before performing + // if user ids have been specified, invalidate the user accounts before performing // the desired updates. if case of an error, this will ensure that these users are // authorized the next time the access the application if (userIds != null) { @@ -409,7 +409,7 @@ public class StandardUserService implements UserService { * modifying a user account. This method should only be invoked from within * a write lock. * - * @param id + * @param id user account identifier */ @Override public void invalidateUserAccount(String id) { @@ -438,14 +438,6 @@ public class StandardUserService implements UserService { } } - /** - * Invalidates the user with the specified id. This is done to ensure a user - * account will need to be re-validated in case an error occurs while - * modifying a user account. This method should only be invoked from within - * a write lock. - * - * @param group - */ @Override public void invalidateUserGroupAccount(String group) { Transaction transaction = null; @@ -533,7 +525,7 @@ public class StandardUserService implements UserService { readLock.unlock(); } } - + @Override public Collection getUsers() { Transaction transaction = null; @@ -624,22 +616,12 @@ public class StandardUserService implements UserService { } } - /** - * Rolls back the specified transaction. - * - * @param transaction - */ private void rollback(final Transaction transaction) { if (transaction != null) { transaction.rollback(); } } - /** - * Closes the specified transaction. - * - * @param transaction - */ private void closeQuietly(final Transaction transaction) { if (transaction != null) { try { @@ -649,9 +631,6 @@ public class StandardUserService implements UserService { } } - /* - * setters - */ public void setTransactionBuilder(TransactionBuilder transactionBuilder) { this.transactionBuilder = transactionBuilder; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/transaction/Transaction.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/transaction/Transaction.java index edd214ba9c..4792581dc2 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/transaction/Transaction.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/transaction/Transaction.java @@ -27,9 +27,9 @@ public interface Transaction extends Closeable { /** * Executes the specified action within the current transaction. * - * @param - * @param action - * @return + * @param type of action to execute + * @param action action to execute + * @return executed action * @throws IllegalStateException - if there is no current transaction */ T execute(AdministrationAction action); diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/authorization/AuthorityProviderFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/authorization/AuthorityProviderFactoryBean.java index 31a01be82f..b3e954725e 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/authorization/AuthorityProviderFactoryBean.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/authorization/AuthorityProviderFactoryBean.java @@ -130,12 +130,6 @@ public class AuthorityProviderFactoryBean implements FactoryBean, ApplicationCon return authorityProvider; } - /** - * Loads the authority providers configuration. - * - * @return - * @throws Exception - */ private AuthorityProviders loadAuthorityProvidersConfiguration() throws Exception { final File authorityProvidersConfigurationFile = properties.getAuthorityProviderConfiguraitonFile(); @@ -159,14 +153,6 @@ public class AuthorityProviderFactoryBean implements FactoryBean, ApplicationCon } } - /** - * Creates the AuthorityProvider instance for the identifier specified. - * - * @param identifier - * @param authorityProviderClassName - * @return - * @throws Exception - */ private AuthorityProvider createAuthorityProvider(final String identifier, final String authorityProviderClassName) throws Exception { // get the classloader for the specified authority provider final ClassLoader authorityProviderClassLoader = ExtensionManager.getClassLoader(authorityProviderClassName); @@ -207,12 +193,6 @@ public class AuthorityProviderFactoryBean implements FactoryBean, ApplicationCon return withNarLoader(instance); } - /** - * Loads the AuthorityProvider configuration. - * - * @param provider - * @return - */ private AuthorityProviderConfigurationContext loadAuthorityProviderConfiguration(final Provider provider) { final Map providerProperties = new HashMap<>(); @@ -223,15 +203,6 @@ public class AuthorityProviderFactoryBean implements FactoryBean, ApplicationCon return new StandardAuthorityProviderConfigurationContext(provider.getIdentifier(), providerProperties); } - /** - * Performs method injection. - * - * @param instance - * @param authorityProviderClass - * @throws IllegalAccessException - * @throws IllegalArgumentException - * @throws InvocationTargetException - */ private void performMethodInjection(final AuthorityProvider instance, final Class authorityProviderClass) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { for (final Method method : authorityProviderClass.getMethods()) { if (method.isAnnotationPresent(AuthorityProviderContext.class)) { @@ -267,14 +238,6 @@ public class AuthorityProviderFactoryBean implements FactoryBean, ApplicationCon } } - /** - * Performs field injection. - * - * @param instance - * @param authorityProviderClass - * @throws IllegalArgumentException - * @throws IllegalAccessException - */ private void performFieldInjection(final AuthorityProvider instance, final Class authorityProviderClass) throws IllegalArgumentException, IllegalAccessException { for (final Field field : authorityProviderClass.getDeclaredFields()) { if (field.isAnnotationPresent(AuthorityProviderContext.class)) { @@ -311,10 +274,8 @@ public class AuthorityProviderFactoryBean implements FactoryBean, ApplicationCon } /** - * Creates a default provider to use when running unsecurely with no - * provider configured. - * - * @return + * @return a default provider to use when running unsecurely with no + * provider configured */ private AuthorityProvider createDefaultProvider() { return new AuthorityProvider() { @@ -389,8 +350,8 @@ public class AuthorityProviderFactoryBean implements FactoryBean, ApplicationCon * Decorates the base provider to ensure the nar context classloader is used * when invoking the underlying methods. * - * @param baseProvider - * @return + * @param baseProvider base provider + * @return provider */ public AuthorityProvider withNarLoader(final AuthorityProvider baseProvider) { return new AuthorityProvider() { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/user/AccountStatus.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/user/AccountStatus.java index 195f6bf139..d7becf1b2b 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/user/AccountStatus.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/user/AccountStatus.java @@ -29,8 +29,8 @@ public enum AccountStatus { * Returns the matching status or null if the specified status does not * match any statuses. * - * @param rawStatus - * @return + * @param rawStatus string form of status + * @return account status object */ public static AccountStatus valueOfStatus(String rawStatus) { AccountStatus desiredStatus = null; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/user/NiFiUser.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/user/NiFiUser.java index 415160af4b..a47bde9b8c 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/user/NiFiUser.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/user/NiFiUser.java @@ -43,7 +43,7 @@ public class NiFiUser implements Serializable { private AccountStatus status; private EnumSet authorities; - + private NiFiUser chain; /* getters / setters */ diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/AuthorizeUserActionTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/AuthorizeUserActionTest.java index 579770557c..28ea4a943b 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/AuthorizeUserActionTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/AuthorizeUserActionTest.java @@ -268,7 +268,7 @@ public class AuthorizeUserActionTest { /** * Tests AuthorityAccessException in doesDnExist. * - * @throws Exception + * @throws Exception ex */ @Test(expected = AdministrationException.class) public void testAuthorityAccessExceptionInDoesDnExist() throws Exception { @@ -279,7 +279,7 @@ public class AuthorizeUserActionTest { /** * Test unknown user in the authority provider. * - * @throws Exception + * @throws Exception ex */ @Test(expected = AccountNotFoundException.class) public void testUnknownUser() throws Exception { @@ -290,7 +290,7 @@ public class AuthorizeUserActionTest { /** * Test a user thats been removed after checking their existence. * - * @throws Exception + * @throws Exception ex */ @Test(expected = AccountNotFoundException.class) public void testUserRemovedAfterCheckingExistence() throws Exception { @@ -301,7 +301,7 @@ public class AuthorizeUserActionTest { /** * Testing AuthorityAccessException when getting authorities. * - * @throws Exception + * @throws Exception ex */ @Test(expected = AdministrationException.class) public void testAuthorityAccessException() throws Exception { @@ -312,7 +312,7 @@ public class AuthorizeUserActionTest { /** * Testing DataAccessException while creating user accounts. * - * @throws Exception + * @throws Exception ex */ @Test(expected = DataAccessException.class) public void testErrorCreatingUserAccount() throws Exception { @@ -323,7 +323,7 @@ public class AuthorizeUserActionTest { /** * Tests the general case when a user account is created. * - * @throws Exception + * @throws Exception ex */ @Test public void testAccountCreation() throws Exception { @@ -343,7 +343,7 @@ public class AuthorizeUserActionTest { * Tests the general case when there is an existing user account that * requires verification. * - * @throws Exception + * @throws Exception ex */ @Test public void testExistingUserRequiresVerification() throws Exception { @@ -364,7 +364,7 @@ public class AuthorizeUserActionTest { * Tests the general case when there is an existing user account that does * not require verification. * - * @throws Exception + * @throws Exception ex */ @Test public void testExistingUserNoVerification() throws Exception { @@ -386,7 +386,7 @@ public class AuthorizeUserActionTest { /** * Tests existing users whose accounts are in a pending status. * - * @throws Exception + * @throws Exception ex */ @Test(expected = AccountPendingException.class) public void testExistingPendingUser() throws Exception { @@ -398,7 +398,7 @@ public class AuthorizeUserActionTest { /** * Tests existing users whose accounts are in a disabled status. * - * @throws Exception + * @throws Exception ex */ @Test(expected = AccountDisabledException.class) public void testExistingDisabledUser() throws Exception { @@ -411,7 +411,7 @@ public class AuthorizeUserActionTest { * Tests the general case where there is an active user that has been * removed from the authority provider. * - * @throws Exception + * @throws Exception ex */ @Test public void testExistingActiveUserNotFoundInProvider() throws Exception { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/CreateUserActionTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/CreateUserActionTest.java index 3d2081b584..6486d32924 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/CreateUserActionTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/CreateUserActionTest.java @@ -37,11 +37,11 @@ import org.mockito.stubbing.Answer; */ public class CreateUserActionTest { - private String USER_ID_2 = "2"; - private String USER_ID_3 = "3"; + private final String USER_ID_2 = "2"; + private final String USER_ID_3 = "3"; - private String USER_DN_1 = "data access exception when creating user"; - private String USER_DN_3 = "general create user case"; + private final String USER_DN_1 = "data access exception when creating user"; + private final String USER_DN_3 = "general create user case"; private DAOFactory daoFactory; private UserDAO userDao; @@ -95,7 +95,7 @@ public class CreateUserActionTest { /** * Tests DataAccessExceptions that occur while creating user accounts. * - * @throws Exception + * @throws Exception ex */ @Test(expected = DataAccessException.class) public void testExceptionCreatingUser() throws Exception { @@ -109,7 +109,7 @@ public class CreateUserActionTest { /** * Tests DataAccessExceptions that occur while create user authorities. * - * @throws Exception + * @throws Exception ex */ @Test(expected = DataAccessException.class) public void testExceptionCreatingAuthoroties() throws Exception { @@ -123,7 +123,7 @@ public class CreateUserActionTest { /** * General case for creating a user. * - * @throws Exception + * @throws Exception ex */ @Test public void testCreateUserAccount() throws Exception { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/DisableUserActionTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/DisableUserActionTest.java index de852984ce..b0e1ac10f6 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/DisableUserActionTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/DisableUserActionTest.java @@ -33,9 +33,6 @@ import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -/** - * - */ public class DisableUserActionTest { private static final String USER_ID_1 = "1"; @@ -119,7 +116,7 @@ public class DisableUserActionTest { /** * Tests the case when the user account is unknown. * - * @throws Exception + * @throws Exception ex */ @Test(expected = AccountNotFoundException.class) public void testUnknownUserAccount() throws Exception { @@ -130,7 +127,7 @@ public class DisableUserActionTest { /** * Tests the case when a DataAccessException is thrown by the userDao. * - * @throws Exception + * @throws Exception ex */ @Test(expected = DataAccessException.class) public void testDataAccessExceptionInUserDao() throws Exception { @@ -141,7 +138,7 @@ public class DisableUserActionTest { /** * Tests the case when a AuthorityAccessException is thrown by the provider. * - * @throws Exception + * @throws Exception ex */ @Test(expected = AdministrationException.class) public void testAuthorityAccessExceptionInProvider() throws Exception { @@ -152,7 +149,7 @@ public class DisableUserActionTest { /** * Tests the general case when the user is disabled. * - * @throws Exception + * @throws Exception ex */ @Test public void testDisableUser() throws Exception { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/InvalidateUserAccountActionTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/InvalidateUserAccountActionTest.java index 93dbe619ca..cffd280e01 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/InvalidateUserAccountActionTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/InvalidateUserAccountActionTest.java @@ -87,11 +87,6 @@ public class InvalidateUserAccountActionTest { Mockito.when(daoFactory.getUserDAO()).thenReturn(userDao); } - /** - * Tests when the user account cannot be found. - * - * @throws Exception - */ @Test(expected = AccountNotFoundException.class) public void testAccountNotFoundException() throws Exception { InvalidateUserAccountAction invalidateUserAccount = new InvalidateUserAccountAction(USER_ID_1); @@ -101,7 +96,7 @@ public class InvalidateUserAccountActionTest { /** * Tests when a data access exception occurs when updating the user record. * - * @throws Exception + * @throws Exception ex */ @Test(expected = DataAccessException.class) public void testDataAccessException() throws Exception { @@ -112,7 +107,7 @@ public class InvalidateUserAccountActionTest { /** * Tests the general case of invalidating a user. * - * @throws Exception + * @throws Exception ex */ @Test public void testInvalidateUser() throws Exception { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/RequestUserAccountActionTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/RequestUserAccountActionTest.java index 6e77d4657f..7707b2cb44 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/RequestUserAccountActionTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/RequestUserAccountActionTest.java @@ -86,7 +86,7 @@ public class RequestUserAccountActionTest { /** * Tests when a user account already exists. * - * @throws Exception + * @throws Exception ex */ @Test(expected = IllegalArgumentException.class) public void testExistingAccount() throws Exception { @@ -98,7 +98,7 @@ public class RequestUserAccountActionTest { * Tests when a DataAccessException occurs while saving the new account * request. * - * @throws Exception + * @throws Exception ex */ @Test(expected = DataAccessException.class) public void testDataAccessException() throws Exception { @@ -109,7 +109,7 @@ public class RequestUserAccountActionTest { /** * Tests the general case for requesting a new user account. * - * @throws Exception + * @throws Exception ex */ @Test public void testRequestUserAccountAction() throws Exception { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/SeedUserAccountsActionTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/SeedUserAccountsActionTest.java index f37fc84edd..652d99209c 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/SeedUserAccountsActionTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/SeedUserAccountsActionTest.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.admin.service.action; -import org.apache.nifi.admin.service.action.SeedUserAccountsAction; import java.util.EnumSet; import java.util.HashSet; import java.util.Set; @@ -187,7 +186,7 @@ public class SeedUserAccountsActionTest { /** * Tests seeding the user accounts. * - * @throws Exception + * @throws Exception ex */ @Test public void testSeedUsers() throws Exception { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/SetUserAuthoritiesActionTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/SetUserAuthoritiesActionTest.java index dd3695c0e5..22504f7b1f 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/SetUserAuthoritiesActionTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/SetUserAuthoritiesActionTest.java @@ -176,7 +176,7 @@ public class SetUserAuthoritiesActionTest { * Test activating an unknown user account. User accounts are unknown then * there is no pending account for the user. * - * @throws Exception + * @throws Exception ex */ @Test(expected = AccountNotFoundException.class) public void testUnknownUser() throws Exception { @@ -188,7 +188,7 @@ public class SetUserAuthoritiesActionTest { * Testing case then an AuthorityAccessException occurs while setting a * users authorities. * - * @throws Exception + * @throws Exception ex */ @Test(expected = AdministrationException.class) public void testAuthorityAccessException() throws Exception { @@ -199,7 +199,7 @@ public class SetUserAuthoritiesActionTest { /** * Tests general case of setting user authorities. * - * @throws Exception + * @throws Exception ex */ @Test public void testSetAuthorities() throws Exception { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/pom.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/pom.xml index 41454a99e3..54997956b9 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/pom.xml +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/pom.xml @@ -21,24 +21,10 @@ 0.1.0-incubating-SNAPSHOT nifi-client-dto - - - - - org.apache.maven.plugins - maven-source-plugin - - - attach-sources - - jar-no-fork - - - - - - + + + com.wordnik + swagger-annotations + + diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/AboutDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/AboutDTO.java index 0e2dcb0c74..83aad410e3 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/AboutDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/AboutDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -33,6 +34,9 @@ public class AboutDTO { * * @return The title */ + @ApiModelProperty( + value = "The title to be used on the page and in the about dialog." + ) public String getTitle() { return title; } @@ -46,6 +50,9 @@ public class AboutDTO { * * @return The version. */ + @ApiModelProperty( + value = "The version of this NiFi." + ) public String getVersion() { return version; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/BannerDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/BannerDTO.java index 70c408b0c7..c0a691b930 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/BannerDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/BannerDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -33,6 +34,9 @@ public class BannerDTO { * * @return The footer text */ + @ApiModelProperty( + value = "The footer text." + ) public String getFooterText() { return footerText; } @@ -46,6 +50,9 @@ public class BannerDTO { * * @return The header text */ + @ApiModelProperty( + value = "The header text." + ) public String getHeaderText() { return headerText; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/BulletinBoardDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/BulletinBoardDTO.java index ddc3d2e904..455769a423 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/BulletinBoardDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/BulletinBoardDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Date; import java.util.List; @@ -24,8 +25,7 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.apache.nifi.web.api.dto.util.TimeAdapter; /** - * The contents for the bulletin board including the bulletins and the timestamp - * when the board was generated. + * The contents for the bulletin board including the bulletins and the timestamp when the board was generated. */ @XmlType(name = "bulletinBoard") public class BulletinBoardDTO { @@ -34,10 +34,11 @@ public class BulletinBoardDTO { private Date generated; /** - * The bulletins to populate in the bulletin board. - * - * @return + * @return bulletins to populate in the bulletin board */ + @ApiModelProperty( + value = "The bulletins in the bulletin board, that matches the supplied request." + ) public List getBulletins() { return bulletins; } @@ -47,11 +48,12 @@ public class BulletinBoardDTO { } /** - * When this bulletin board was generated. - * - * @return + * @return when this bulletin board was generated */ @XmlJavaTypeAdapter(TimeAdapter.class) + @ApiModelProperty( + value = "The timestamp when this report was generated." + ) public Date getGenerated() { return generated; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/BulletinDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/BulletinDTO.java index c6aca24051..4c552f6da5 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/BulletinDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/BulletinDTO.java @@ -16,15 +16,14 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Date; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.apache.nifi.web.api.dto.util.TimeAdapter; /** - * A bulletin that represents a notification about a passing event including, - * the source component (if applicable), the timestamp, the message, and where - * the bulletin originated (if applicable). + * A bulletin that represents a notification about a passing event including, the source component (if applicable), the timestamp, the message, and where the bulletin originated (if applicable). */ @XmlType(name = "bulletin") public class BulletinDTO { @@ -40,10 +39,11 @@ public class BulletinDTO { private Date timestamp; /** - * The id of this message. - * - * @return + * @return id of this message */ + @ApiModelProperty( + value = "The id of the bulletin." + ) public Long getId() { return id; } @@ -53,11 +53,11 @@ public class BulletinDTO { } /** - * When clustered, the address of the node from which this bulletin - * originated. - * - * @return + * @return When clustered, the address of the node from which this bulletin originated */ + @ApiModelProperty( + value = "If clustered, the address of the node from whicih the bulletin originated." + ) public String getNodeAddress() { return nodeAddress; } @@ -67,10 +67,11 @@ public class BulletinDTO { } /** - * The group id of the source component. - * - * @return + * @return group id of the source component */ + @ApiModelProperty( + value = "The group id of the source component." + ) public String getGroupId() { return groupId; } @@ -80,10 +81,11 @@ public class BulletinDTO { } /** - * The category of this message. - * - * @return + * @return category of this message */ + @ApiModelProperty( + value = "The catagory of this bulletin." + ) public String getCategory() { return category; } @@ -93,10 +95,11 @@ public class BulletinDTO { } /** - * The actual message. - * - * @return + * @return actual message */ + @ApiModelProperty( + value = "The bulletin message." + ) public String getMessage() { return message; } @@ -106,10 +109,11 @@ public class BulletinDTO { } /** - * The id of the source of this message. - * - * @return + * @return id of the source of this message */ + @ApiModelProperty( + value = "The id of the source component." + ) public String getSourceId() { return sourceId; } @@ -119,10 +123,11 @@ public class BulletinDTO { } /** - * The name of the source of this message. - * - * @return + * @return name of the source of this message */ + @ApiModelProperty( + value = "The name of the source component." + ) public String getSourceName() { return sourceName; } @@ -132,10 +137,11 @@ public class BulletinDTO { } /** - * The level of this bulletin. - * - * @return + * @return level of this bulletin */ + @ApiModelProperty( + value = "The level of the bulletin." + ) public String getLevel() { return level; } @@ -145,11 +151,12 @@ public class BulletinDTO { } /** - * When this bulletin was generated as a formatted string. - * - * @return + * @return When this bulletin was generated as a formatted string */ @XmlJavaTypeAdapter(TimeAdapter.class) + @ApiModelProperty( + value = "When this bulletin was generated." + ) public Date getTimestamp() { return timestamp; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/BulletinQueryDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/BulletinQueryDTO.java index 015b174bab..e47cdf9058 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/BulletinQueryDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/BulletinQueryDTO.java @@ -16,11 +16,11 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** - * A query for bulletin board. Will filter the resulting bulletin board - * according to the criteria in this query. + * A query for bulletin board. Will filter the resulting bulletin board according to the criteria in this query. */ @XmlType(name = "bulletinQuery") public class BulletinQueryDTO { @@ -33,10 +33,12 @@ public class BulletinQueryDTO { private Integer limit; /** - * Include bulletins after this id. - * - * @return + * @return Include bulletins after this id */ + @ApiModelProperty( + value = "Will include bulletins that occurred after this id. The ids are a one-up number that are used to ensure bulletins that " + + "occur at the same time will not be missed." + ) public Long getAfter() { return after; } @@ -46,10 +48,11 @@ public class BulletinQueryDTO { } /** - * Include bulletin within this group. Supports a regular expression. - * - * @return + * @return Include bulletin within this group. Supports a regular expression */ + @ApiModelProperty( + value = "Will include bulletins that occurred within this group. Supports a regular expression." + ) public String getGroupId() { return groupId; } @@ -59,10 +62,11 @@ public class BulletinQueryDTO { } /** - * Include bulletins that match this message. Supports a regular expression. - * - * @return + * @return Include bulletins that match this message. Supports a regular expression */ + @ApiModelProperty( + value = "Will include bulletins that match this message. Supports a regular expression." + ) public String getMessage() { return message; } @@ -72,10 +76,11 @@ public class BulletinQueryDTO { } /** - * Include bulletins that match this name. Supports a regular expression. - * - * @return + * @return Include bulletins that match this name. Supports a regular expression */ + @ApiModelProperty( + value = "Will include bulletins that match this name. Supports a regular expression." + ) public String getName() { return name; } @@ -85,10 +90,11 @@ public class BulletinQueryDTO { } /** - * Include bulletins that match this id. Supports a source id. - * - * @return + * @return Include bulletins that match this id. Supports a source id */ + @ApiModelProperty( + value = "Will include bulletins from components that match this id. Supports a regular expression." + ) public String getSourceId() { return sourceId; } @@ -98,10 +104,11 @@ public class BulletinQueryDTO { } /** - * The maximum number of bulletins to return. - * - * @return + * @return The maximum number of bulletins to return */ + @ApiModelProperty( + value = "The maximum number of bulletins to return." + ) public Integer getLimit() { return limit; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ClusterDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ClusterDTO.java index 53100e3044..66e19d7c76 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ClusterDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ClusterDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Collection; import java.util.Date; @@ -33,10 +34,11 @@ public class ClusterDTO { private Date generated; /** - * The collection of the node DTOs. - * - * @return + * @return collection of the node DTOs */ + @ApiModelProperty( + value = "The collection of nodes that are part of the cluster." + ) public Collection getNodes() { return nodes; } @@ -46,11 +48,12 @@ public class ClusterDTO { } /** - * Gets the date/time that this report was generated. - * - * @return + * @return the date/time that this report was generated */ @XmlJavaTypeAdapter(TimeAdapter.class) + @ApiModelProperty( + value = "The timestamp the report was generated." + ) public Date getGenerated() { return generated; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ComponentHistoryDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ComponentHistoryDTO.java index 3bdbe2814e..7cf4f73fc2 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ComponentHistoryDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ComponentHistoryDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Map; import javax.xml.bind.annotation.XmlType; @@ -29,10 +30,11 @@ public class ComponentHistoryDTO { private Map propertyHistory; /** - * The component id. - * - * @return + * @return component id */ + @ApiModelProperty( + value = "The component id." + ) public String getComponentId() { return componentId; } @@ -42,10 +44,11 @@ public class ComponentHistoryDTO { } /** - * The history for this components properties. - * - * @return + * @return history for this components properties */ + @ApiModelProperty( + value = "The history for the properties of the component." + ) public Map getPropertyHistory() { return propertyHistory; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ConnectableDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ConnectableDTO.java index 1be480cfb1..22c167f96f 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ConnectableDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ConnectableDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -34,10 +35,12 @@ public class ConnectableDTO { private String comments; /** - * The id of this connectable component. - * - * @return + * @return id of this connectable component */ + @ApiModelProperty( + value = "The id of the connectable component.", + required = true + ) public String getId() { return id; } @@ -47,10 +50,13 @@ public class ConnectableDTO { } /** - * The type of this connectable component. - * - * @return + * @return type of this connectable component */ + @ApiModelProperty( + value = "The type of component the connectable is.", + required = true, + allowableValues = "PROCESSOR, REMOTE_INPUT_PORT, REMOTE_OUTPUT_PORT, INPUT_PORT, OUTPUT_PORT, FUNNEL" + ) public String getType() { return type; } @@ -60,10 +66,12 @@ public class ConnectableDTO { } /** - * The id of the group that this connectable component resides in. - * - * @return + * @return id of the group that this connectable component resides in */ + @ApiModelProperty( + value = "The id of the group that the connectable component resides in", + required = true + ) public String getGroupId() { return groupId; } @@ -73,10 +81,11 @@ public class ConnectableDTO { } /** - * The name of this connectable component. - * - * @return + * @return name of this connectable component */ + @ApiModelProperty( + value = "The name of the connectable component" + ) public String getName() { return name; } @@ -86,10 +95,11 @@ public class ConnectableDTO { } /** - * Used to reflect the current state of this Connectable. - * - * @return + * @return Used to reflect the current state of this Connectable */ + @ApiModelProperty( + value = "Reflects the current state of the connectable component." + ) public Boolean isRunning() { return running; } @@ -99,11 +109,11 @@ public class ConnectableDTO { } /** - * If this represents a remote port it is used to indicate whether the - * target exists. - * - * @return + * @return If this represents a remote port it is used to indicate whether the target exists */ + @ApiModelProperty( + value = "If the connectable component represents a remote port, indicates if the target exists." + ) public Boolean getExists() { return exists; } @@ -113,11 +123,11 @@ public class ConnectableDTO { } /** - * If this represents a remote port it is used to indicate whether is it - * configured to transmit. - * - * @return + * @return If this represents a remote port it is used to indicate whether is it configured to transmit */ + @ApiModelProperty( + value = "If the connectable component represents a remote port, indicates if the target is configured to transmit." + ) public Boolean getTransmitting() { return transmitting; } @@ -127,10 +137,11 @@ public class ConnectableDTO { } /** - * The comments from this Connectable. - * - * @return + * @return The comments from this Connectable */ + @ApiModelProperty( + value = "The comments for the connectable component." + ) public String getComments() { return comments; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ConnectionDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ConnectionDTO.java index 660820c900..96da9e3748 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ConnectionDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ConnectionDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.List; import java.util.Set; import javax.xml.bind.annotation.XmlType; @@ -41,10 +42,13 @@ public class ConnectionDTO extends NiFiComponentDTO { private List bends; /** - * The id of the source processor. + * The source of this connection. * - * @return The id of the source processor + * @return The source of this connection */ + @ApiModelProperty( + value = "The source of the connection." + ) public ConnectableDTO getSource() { return source; } @@ -54,10 +58,13 @@ public class ConnectionDTO extends NiFiComponentDTO { } /** - * The id of the target processor. + * The destination of this connection. * - * @return The id of the target processor + * @return The destination of this connection */ + @ApiModelProperty( + value = "The destination of the connection." + ) public ConnectableDTO getDestination() { return destination; } @@ -67,10 +74,11 @@ public class ConnectionDTO extends NiFiComponentDTO { } /** - * The name of the connection. - * - * @return + * @return name of the connection */ + @ApiModelProperty( + value = "The name of the connection." + ) public String getName() { return name; } @@ -80,10 +88,11 @@ public class ConnectionDTO extends NiFiComponentDTO { } /** - * The position of the bend points on this connection. - * - * @return + * @return position of the bend points on this connection */ + @ApiModelProperty( + value = "The bend points on the connection." + ) public List getBends() { return bends; } @@ -93,11 +102,11 @@ public class ConnectionDTO extends NiFiComponentDTO { } /** - * The index of control point that the connection label should be placed - * over. - * - * @return + * @return The index of control point that the connection label should be placed over */ + @ApiModelProperty( + value = "The index of the bend point where to place the connection label." + ) public Integer getLabelIndex() { return labelIndex; } @@ -107,10 +116,11 @@ public class ConnectionDTO extends NiFiComponentDTO { } /** - * The z index for this connection. - * - * @return + * @return z index for this connection */ + @ApiModelProperty( + value = "The z index of the connection." + ) public Long getzIndex() { return zIndex; } @@ -124,6 +134,9 @@ public class ConnectionDTO extends NiFiComponentDTO { * * @return The relationships */ + @ApiModelProperty( + value = "The selected relationship that comprise the connection." + ) public Set getSelectedRelationships() { return selectedRelationships; } @@ -133,11 +146,12 @@ public class ConnectionDTO extends NiFiComponentDTO { } /** - * The relationships that the source of the connection currently supports. - * This property is read only. - * - * @return + * @return relationships that the source of the connection currently supports. This property is read only */ + @ApiModelProperty( + value = "The relationships that the source of the connection currently supports. This property is read only.", + readOnly = true + ) public Set getAvailableRelationships() { return availableRelationships; } @@ -147,13 +161,15 @@ public class ConnectionDTO extends NiFiComponentDTO { } /** - * The object count threshold for determining when back pressure is applied. - * Updating this value is a passive change in the sense that it won't impact - * whether existing files over the limit are affected but it does help - * feeder processors to stop pushing too much into this work queue. + * The object count threshold for determining when back pressure is applied. Updating this value is a passive change in the sense that it won't impact whether existing files over the limit are + * affected but it does help feeder processors to stop pushing too much into this work queue. * * @return The back pressure object threshold */ + @ApiModelProperty( + value = "The object count threshold for determining when back pressure is applied. Updating this value is a passive change in the sense that it won't impact whether existing files " + + "over the limit are affected but it does help feeder processors to stop pushing too much into this work queue." + ) public Long getBackPressureObjectThreshold() { return backPressureObjectThreshold; } @@ -163,14 +179,15 @@ public class ConnectionDTO extends NiFiComponentDTO { } /** - * The object data size threshold for determining when back pressure is - * applied. Updating this value is a passive change in the sense that it - * won't impact whether existing files over the limit are affected but it - * does help feeder processors to stop pushing too much into this work - * queue. + * The object data size threshold for determining when back pressure is applied. Updating this value is a passive change in the sense that it won't impact whether existing files over the limit are + * affected but it does help feeder processors to stop pushing too much into this work queue. * * @return The back pressure data size threshold */ + @ApiModelProperty( + value = "The object data size threshold for determining when back pressure is applied. Updating this value is a passive change in the sense that it won't impact whether existing " + + "files over the limit are affected but it does help feeder processors to stop pushing too much into this work queue." + ) public String getBackPressureDataSizeThreshold() { return backPressureDataSizeThreshold; } @@ -180,13 +197,15 @@ public class ConnectionDTO extends NiFiComponentDTO { } /** - * The amount of time a flow file may be in the flow before it will be - * automatically aged out of the flow. Once a flow file reaches this age it - * will be terminated from the flow the next time a processor attempts to - * start work on it. + * The amount of time a flow file may be in the flow before it will be automatically aged out of the flow. Once a flow file reaches this age it will be terminated from the flow the next time a + * processor attempts to start work on it. * * @return The flow file expiration in minutes */ + @ApiModelProperty( + value = "The amount of time a flow file may be in the flow before it will be automatically aged out of the flow. Once a flow file reaches this age it will be terminated from " + + "the flow the next time a processor attempts to start work on it." + ) public String getFlowFileExpiration() { return flowFileExpiration; } @@ -196,10 +215,13 @@ public class ConnectionDTO extends NiFiComponentDTO { } /** - * The prioritizers this processor is using. + * The prioritizers this connection is using. * * @return The prioritizer list */ + @ApiModelProperty( + value = "The comparators used to prioritize the queue." + ) public List getPrioritizers() { return prioritizers; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerConfigurationDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerConfigurationDTO.java index 190cb47fe2..9f92598625 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerConfigurationDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerConfigurationDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Date; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; @@ -42,10 +43,11 @@ public class ControllerConfigurationDTO { private String uri; /** - * The maximum number of timer driven threads this NiFi has available. - * - * @return The maximum number of threads + * @return maximum number of timer driven threads this NiFi has available */ + @ApiModelProperty( + value = "The maimum number of timer driven threads the NiFi has available." + ) public Integer getMaxTimerDrivenThreadCount() { return maxTimerDrivenThreadCount; } @@ -55,10 +57,11 @@ public class ControllerConfigurationDTO { } /** - * The maximum number of event driven thread this NiFi has available. - * - * @return + * @return maximum number of event driven thread this NiFi has available */ + @ApiModelProperty( + value = "The maximum number of event driven threads the NiFi has avaiable." + ) public Integer getMaxEventDrivenThreadCount() { return maxEventDrivenThreadCount; } @@ -68,10 +71,11 @@ public class ControllerConfigurationDTO { } /** - * The name of this NiFi. - * - * @return The name + * @return name of this NiFi */ + @ApiModelProperty( + value = "The name of this NiFi." + ) public String getName() { return name; } @@ -81,10 +85,11 @@ public class ControllerConfigurationDTO { } /** - * The comments for this NiFi. - * - * @return + * @return comments for this NiFi */ + @ApiModelProperty( + value = "The comments for this NiFi." + ) public String getComments() { return comments; } @@ -94,11 +99,12 @@ public class ControllerConfigurationDTO { } /** - * The interval in seconds between the automatic NiFi refresh requests. This - * value is read only. - * - * @return The interval in seconds + * @return interval in seconds between the automatic NiFi refresh requests. This value is read only */ + @ApiModelProperty( + value = "The interval in seconds between the automatic NiFi refresh requests.", + readOnly = true + ) public Long getAutoRefreshIntervalSeconds() { return autoRefreshIntervalSeconds; } @@ -108,11 +114,12 @@ public class ControllerConfigurationDTO { } /** - * Indicates whether or not Site-to-Site communications with this instance - * is secure (2-way authentication). This value is read only. - * - * @return + * @return Indicates whether or not Site-to-Site communications with this instance is secure (2-way authentication). This value is read only */ + @ApiModelProperty( + value = "Indicates whether site to site communication with the NiFi is secure (requires 2-way authenticiation).", + readOnly = true + ) public Boolean isSiteToSiteSecure() { return siteToSiteSecure; } @@ -122,11 +129,12 @@ public class ControllerConfigurationDTO { } /** - * The current time on the server. - * - * @return + * @return current time on the server */ @XmlJavaTypeAdapter(TimeAdapter.class) + @ApiModelProperty( + value = "The current time on the system." + ) public Date getCurrentTime() { return currentTime; } @@ -136,10 +144,11 @@ public class ControllerConfigurationDTO { } /** - * The time offset of the server. - * - * @return + * @return time offset of the server */ + @ApiModelProperty( + value = "The time offset of the system." + ) public Integer getTimeOffset() { return timeOffset; } @@ -149,10 +158,11 @@ public class ControllerConfigurationDTO { } /** - * Returns the URL for the content viewer if configured. - * - * @return + * @return the URL for the content viewer if configured */ + @ApiModelProperty( + value = "The URL for the content viewer if configured." + ) public String getContentViewerUrl() { return contentViewerUrl; } @@ -162,10 +172,11 @@ public class ControllerConfigurationDTO { } /** - * The URI for this NiFi controller. - * - * @return + * @return URI for this NiFi controller */ + @ApiModelProperty( + value = "The URI for the NiFi." + ) public String getUri() { return uri; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerDTO.java index 9e15fc1772..a47adcf8b9 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerDTO.java @@ -16,13 +16,12 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Set; import javax.xml.bind.annotation.XmlType; /** - * Configuration details for a NiFi controller. Primary use of this DTO is for - * consumption by a remote NiFi instance to initiate site to site - * communications. + * Configuration details for a NiFi controller. Primary use of this DTO is for consumption by a remote NiFi instance to initiate site to site communications. */ @XmlType(name = "controller") public class ControllerDTO { @@ -48,10 +47,11 @@ public class ControllerDTO { private Set outputPorts; /** - * The id of this NiFi controller. - * - * @return + * @return id of this NiFi controller */ + @ApiModelProperty( + value = "The id of the NiFi." + ) public String getId() { return id; } @@ -65,6 +65,9 @@ public class ControllerDTO { * * @return The name of this controller */ + @ApiModelProperty( + value = "The name of the NiFi." + ) public String getName() { return name; } @@ -74,10 +77,11 @@ public class ControllerDTO { } /** - * The comments of this NiFi controller. - * - * @return + * @return comments of this NiFi controller */ + @ApiModelProperty( + value = "The comments for the NiFi." + ) public String getComments() { return comments; } @@ -87,10 +91,11 @@ public class ControllerDTO { } /** - * The input ports available to send data to this NiFi controller. - * - * @return + * @return input ports available to send data to this NiFi controller */ + @ApiModelProperty( + value = "The input ports available to send data to for the NiFi." + ) public Set getInputPorts() { return inputPorts; } @@ -100,10 +105,11 @@ public class ControllerDTO { } /** - * The output ports available to received data from this NiFi controller. - * - * @return + * @return output ports available to received data from this NiFi controller */ + @ApiModelProperty( + value = "The output ports available to received data from the NiFi." + ) public Set getOutputPorts() { return outputPorts; } @@ -113,11 +119,11 @@ public class ControllerDTO { } /** - * The Instance ID of the cluster, if this node is connected to a Cluster - * Manager, or of this individual instance of in standalone mode - * - * @return + * @return Instance ID of the cluster, if this node is connected to a Cluster Manager, or of this individual instance of in standalone mode */ + @ApiModelProperty( + value = "If clustered, the id of the Cluster Manager, otherwise the id of the NiFi." + ) public String getInstanceId() { return instanceId; } @@ -127,13 +133,14 @@ public class ControllerDTO { } /** - * The Socket Port on which this instance is listening for Remote Transfers - * of Flow Files. If this instance is not configured to receive Flow Files - * from remote instances, this will be null. + * The Socket Port on which this instance is listening for Remote Transfers of Flow Files. If this instance is not configured to receive Flow Files from remote instances, this will be null. * - * @return a integer between 1 and 65535, or null, if not configured for - * remote transfer + * @return a integer between 1 and 65535, or null, if not configured for remote transfer */ + @ApiModelProperty( + value = "The Socket Port on which this instance is listening for Remote Transfers of Flow Files. If this instance is not configured to receive Flow Files from remote " + + "instances, this will be null." + ) public Integer getRemoteSiteListeningPort() { return remoteSiteListeningPort; } @@ -143,11 +150,11 @@ public class ControllerDTO { } /** - * Indicates whether or not Site-to-Site communications with this instance - * is secure (2-way authentication) - * - * @return + * @return Indicates whether or not Site-to-Site communications with this instance is secure (2-way authentication) */ + @ApiModelProperty( + value = "Indicates whether or not Site-to-Site communications with this instance is secure (2-way authentication)." + ) public Boolean isSiteToSiteSecure() { return siteToSiteSecure; } @@ -157,10 +164,11 @@ public class ControllerDTO { } /** - * The number of running components in this process group. - * - * @return + * @return number of running components in this process group */ + @ApiModelProperty( + value = "The number of running components in the NiFi." + ) public Integer getRunningCount() { return runningCount; } @@ -170,10 +178,11 @@ public class ControllerDTO { } /** - * The number of stopped components in this process group. - * - * @return + * @return number of stopped components in this process group */ + @ApiModelProperty( + value = "The number of stopped components in the NiFi." + ) public Integer getStoppedCount() { return stoppedCount; } @@ -183,10 +192,11 @@ public class ControllerDTO { } /** - * The number of active remote ports contained in this process group. - * - * @return + * @return number of active remote ports contained in this process group */ + @ApiModelProperty( + value = "The number of active remote ports contained in the NiFi." + ) public Integer getActiveRemotePortCount() { return activeRemotePortCount; } @@ -196,10 +206,11 @@ public class ControllerDTO { } /** - * The number of inactive remote ports contained in this process group. - * - * @return + * @return number of inactive remote ports contained in this process group */ + @ApiModelProperty( + value = "The number of inactive remote porst contained in the NiFi." + ) public Integer getInactiveRemotePortCount() { return inactiveRemotePortCount; } @@ -209,10 +220,11 @@ public class ControllerDTO { } /** - * The number of input ports contained in this process group. - * - * @return + * @return number of input ports contained in this process group */ + @ApiModelProperty( + value = "The number of input ports contained in the NiFi." + ) public Integer getInputPortCount() { return inputPortCount; } @@ -222,10 +234,11 @@ public class ControllerDTO { } /** - * The number of invalid components in this process group. - * - * @return + * @return number of invalid components in this process group */ + @ApiModelProperty( + value = "The number of invalid components in the NiFi." + ) public Integer getInvalidCount() { return invalidCount; } @@ -235,10 +248,11 @@ public class ControllerDTO { } /** - * The number of disabled components in this process group. - * - * @return + * @return number of disabled components in this process group */ + @ApiModelProperty( + value = "The number of disabled components in the NiFi." + ) public Integer getDisabledCount() { return disabledCount; } @@ -248,10 +262,11 @@ public class ControllerDTO { } /** - * The number of output ports in this process group. - * - * @return + * @return number of output ports in this process group */ + @ApiModelProperty( + value = "The number of output ports in the NiFi." + ) public Integer getOutputPortCount() { return outputPortCount; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerServiceDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerServiceDTO.java index 75d18a2caa..3abd7f2e0c 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerServiceDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerServiceDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Collection; import java.util.Map; import java.util.Set; @@ -32,22 +33,23 @@ public class ControllerServiceDTO extends NiFiComponentDTO { private String comments; private String availability; private String state; - + private Map properties; private Map descriptors; - + private String customUiUrl; private String annotationData; - + private Set referencingComponents; - + private Collection validationErrors; /** - * The controller service name. - * - * @return + * @return controller service name */ + @ApiModelProperty( + value = "The name of the controller service." + ) public String getName() { return name; } @@ -57,10 +59,11 @@ public class ControllerServiceDTO extends NiFiComponentDTO { } /** - * The controller service type. - * - * @return + * @return the controller service type */ + @ApiModelProperty( + value = "The type of the controller service." + ) public String getType() { return type; } @@ -68,25 +71,28 @@ public class ControllerServiceDTO extends NiFiComponentDTO { public void setType(String type) { this.type = type; } - /** - * The comment for the Controller Service - * @return + * @return the comment for the Controller Service */ + @ApiModelProperty( + value = "The comments for the controller service." + ) public String getComments() { - return comments; - } + return comments; + } - public void setComments(String comments) { - this.comments = comments; - } + public void setComments(String comments) { + this.comments = comments; + } - /** - * Where this service is available. Possible values are NCM, NODE. - * - * @return + /** + * @return Where this service is available. Possible values are NCM, NODE */ + @ApiModelProperty( + value = "Where the servcie is available.", + allowableValues = "NCM, NODE" + ) public String getAvailability() { return availability; } @@ -96,9 +102,12 @@ public class ControllerServiceDTO extends NiFiComponentDTO { } /** - * The state of this controller service. Possible values are ENABLED, ENABLING, DISABLED, DISABLING. - * @return + * @return The state of this controller service. Possible values are ENABLED, ENABLING, DISABLED, DISABLING */ + @ApiModelProperty( + value = "The state of the controller service.", + allowableValues = "ENABLED, ENABLING, DISABLED, DISABLING" + ) public String getState() { return state; } @@ -108,10 +117,11 @@ public class ControllerServiceDTO extends NiFiComponentDTO { } /** - * The controller service properties. - * - * @return + * @return controller service properties */ + @ApiModelProperty( + value = "The properties of the controller service." + ) public Map getProperties() { return properties; } @@ -121,10 +131,11 @@ public class ControllerServiceDTO extends NiFiComponentDTO { } /** - * The descriptors for the controller service properties. - * - * @return + * @return descriptors for the controller service properties */ + @ApiModelProperty( + value = "The descriptors for the controller service properties." + ) public Map getDescriptors() { return descriptors; } @@ -134,11 +145,11 @@ public class ControllerServiceDTO extends NiFiComponentDTO { } /** - * Returns the URL for this controller services custom configuration UI - * if applicable. Null otherwise. - * - * @return + * @return the URL for this controller services custom configuration UI if applicable. Null otherwise */ + @ApiModelProperty( + value = "The URL for the controller services custom configuration UI if applicable." + ) public String getCustomUiUrl() { return customUiUrl; } @@ -148,10 +159,11 @@ public class ControllerServiceDTO extends NiFiComponentDTO { } /** - * The annotation data for this controller service. - * - * @return + * @return annotation data for this controller service */ + @ApiModelProperty( + value = "The annontation for the controller service. This is how the custom UI relays configuration to the controller service." + ) public String getAnnotationData() { return annotationData; } @@ -161,10 +173,11 @@ public class ControllerServiceDTO extends NiFiComponentDTO { } /** - * All components referencing this controller service. - * - * @return + * @return all components referencing this controller service */ + @ApiModelProperty( + value = "All components referencing this controller service." + ) public Set getReferencingComponents() { return referencingComponents; } @@ -174,12 +187,13 @@ public class ControllerServiceDTO extends NiFiComponentDTO { } /** - * Gets the validation errors from this controller service. These validation errors - * represent the problems with the controller service that must be resolved before it - * can be enabled. + * Gets the validation errors from this controller service. These validation errors represent the problems with the controller service that must be resolved before it can be enabled. * * @return The validation errors */ + @ApiModelProperty( + value = "The validation errors from the controller service. These validation errors represent the problems with the controller service that must be resolved before it can be enabled." + ) public Collection getValidationErrors() { return validationErrors; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerServiceReferencingComponentDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerServiceReferencingComponentDTO.java index 7fc57ffc0b..f4290ff680 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerServiceReferencingComponentDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerServiceReferencingComponentDTO.java @@ -16,18 +16,18 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Collection; import java.util.Map; import java.util.Set; import javax.xml.bind.annotation.XmlType; /** - * A component referencing a controller service. This can either be another - * controller service or a processor. Depending on the type of component - * different properties may be set. + * A component referencing a controller service. This can either be another controller service or a processor. Depending on the type of component different properties may be set. */ @XmlType(name = "controllerServiceReferencingComponent") public class ControllerServiceReferencingComponentDTO { + private String groupId; private String id; private String name; @@ -36,21 +36,22 @@ public class ControllerServiceReferencingComponentDTO { private Map properties; private Map descriptors; - + private Collection validationErrors; - + private String referenceType; private Integer activeThreadCount; - + private Boolean referenceCycle; private Set referencingComponents; /** - * Group id for this component referencing a controller service. If this - * component is another service, this field is blank. - * - * @return + * @return Group id for this component referencing a controller service. If this component is another service, this field is blank */ + @ApiModelProperty( + value = "The group id for the component referencing a controller service. If this component is another controller service or a reporting " + + "task, this field is blank." + ) public String getGroupId() { return groupId; } @@ -60,10 +61,11 @@ public class ControllerServiceReferencingComponentDTO { } /** - * The id for this component referencing a controller service. - * - * @return + * @return id for this component referencing a controller service */ + @ApiModelProperty( + value = "The id of the component referencing a controller service." + ) public String getId() { return id; } @@ -73,10 +75,11 @@ public class ControllerServiceReferencingComponentDTO { } /** - * The name for this component referencing a controller service. - * - * @return + * @return name for this component referencing a controller service */ + @ApiModelProperty( + value = "The name of the component referencing a controller service." + ) public String getName() { return name; } @@ -86,10 +89,11 @@ public class ControllerServiceReferencingComponentDTO { } /** - * The type for this component referencing a controller service. - * - * @return + * @return type for this component referencing a controller service */ + @ApiModelProperty( + value = "The type of the component referencing a controller service." + ) public String getType() { return type; } @@ -99,11 +103,12 @@ public class ControllerServiceReferencingComponentDTO { } /** - * The state of the processor referencing a controller service. If this - * component is another service, this field is blank. - * - * @return + * @return state of the processor referencing a controller service. If this component is another service, this field is blank */ + @ApiModelProperty( + value = "The state of a processor or reporting task referencing a controller service. If this component is another controller " + + "service, this field is blank." + ) public String getState() { return state; } @@ -113,9 +118,12 @@ public class ControllerServiceReferencingComponentDTO { } /** - * The type of reference this is (Processor, ControllerService, or ReportingTask). - * @return + * @return type of reference this is (Processor, ControllerService, or ReportingTask) */ + @ApiModelProperty( + value = "The type of reference this is.", + allowableValues = "Processor, ControllerService, or ReportingTask" + ) public String getReferenceType() { return referenceType; } @@ -125,10 +133,11 @@ public class ControllerServiceReferencingComponentDTO { } /** - * The component properties. - * - * @return + * @return component properties */ + @ApiModelProperty( + value = "The properties for the component." + ) public Map getProperties() { return properties; } @@ -138,10 +147,11 @@ public class ControllerServiceReferencingComponentDTO { } /** - * The descriptors for the components properties. - * - * @return + * @return descriptors for the components properties */ + @ApiModelProperty( + value = "The descriptors for the componet properties." + ) public Map getDescriptors() { return descriptors; } @@ -149,12 +159,13 @@ public class ControllerServiceReferencingComponentDTO { public void setDescriptors(Map descriptors) { this.descriptors = descriptors; } - + /** - * Any validation error associated with this component. - * - * @return + * @return Any validation error associated with this component */ + @ApiModelProperty( + value = "The validation errors for the component." + ) public Collection getValidationErrors() { return validationErrors; } @@ -162,12 +173,13 @@ public class ControllerServiceReferencingComponentDTO { public void setValidationErrors(Collection validationErrors) { this.validationErrors = validationErrors; } - + /** - * The active thread count for the referencing component. - * - * @return + * @return active thread count for the referencing component */ + @ApiModelProperty( + value = "The number of active threads for the referencing component." + ) public Integer getActiveThreadCount() { return activeThreadCount; } @@ -177,11 +189,11 @@ public class ControllerServiceReferencingComponentDTO { } /** - * If this referencing component represents a ControllerService, these - * are the components that reference it. - * - * @return + * @return If this referencing component represents a ControllerService, these are the components that reference it */ + @ApiModelProperty( + value = "If the referencing component represents a controller service, these are the components that referenc it." + ) public Set getReferencingComponents() { return referencingComponents; } @@ -191,11 +203,11 @@ public class ControllerServiceReferencingComponentDTO { } /** - * If this referencing component represents a ControllerService, this indicates - * whether it has already been represented in this hierarchy. - * - * @return + * @return If this referencing component represents a ControllerService, this indicates whether it has already been represented in this hierarchy */ + @ApiModelProperty( + value = "If the referencing component represents a controller service, this indicates whether it has already been represented in this hierarchy." + ) public Boolean getReferenceCycle() { return referenceCycle; } @@ -204,4 +216,4 @@ public class ControllerServiceReferencingComponentDTO { this.referenceCycle = referenceCycle; } -} \ No newline at end of file +} diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/CounterDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/CounterDTO.java index 10ea41dc74..615ad931d5 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/CounterDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/CounterDTO.java @@ -16,11 +16,11 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** - * Counter value for a specific component in a specific context. A counter is a - * value that a component can adjust during processing. + * Counter value for a specific component in a specific context. A counter is a value that a component can adjust during processing. */ @XmlType(name = "counter") public class CounterDTO { @@ -32,10 +32,11 @@ public class CounterDTO { private String value; /** - * The context of the counter. - * - * @return + * @return context of the counter */ + @ApiModelProperty( + value = "The context of the counter." + ) public String getContext() { return context; } @@ -45,10 +46,11 @@ public class CounterDTO { } /** - * The id of the counter. - * - * @return + * @return id of the counter */ + @ApiModelProperty( + value = "The id of the counter." + ) public String getId() { return id; } @@ -58,10 +60,11 @@ public class CounterDTO { } /** - * The name of the counter - * - * @return + * @return name of the counter */ + @ApiModelProperty( + value = "The name of the counter." + ) public String getName() { return name; } @@ -71,10 +74,11 @@ public class CounterDTO { } /** - * The value for the counter - * - * @return + * @return value for the counter */ + @ApiModelProperty( + value = "The value of the counter." + ) public String getValue() { return value; } @@ -83,6 +87,9 @@ public class CounterDTO { this.value = value; } + @ApiModelProperty( + value = "The value count." + ) public Long getValueCount() { return valueCount; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/CountersDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/CountersDTO.java index ac1aa388df..0f162c9d5c 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/CountersDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/CountersDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Collection; import java.util.Date; @@ -33,10 +34,11 @@ public class CountersDTO { private Collection counters; /** - * Gets the collection of counters. - * - * @return + * @return the collection of counters */ + @ApiModelProperty( + value = "All counters in the NiFi." + ) public Collection getCounters() { return counters; } @@ -46,11 +48,12 @@ public class CountersDTO { } /** - * Gets the date/time that this report was generated. - * - * @return + * @return the date/time that this report was generated */ @XmlJavaTypeAdapter(TimeAdapter.class) + @ApiModelProperty( + value = "The timestamp when the report was generated." + ) public Date getGenerated() { return generated; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/DocumentedTypeDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/DocumentedTypeDTO.java index 6e4aeb9b9b..f82ff6c94b 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/DocumentedTypeDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/DocumentedTypeDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Set; import javax.xml.bind.annotation.XmlType; @@ -30,10 +31,11 @@ public class DocumentedTypeDTO { private Set tags; /** - * An optional description of the corresponding type. - * - * @return + * @return An optional description of the corresponding type */ + @ApiModelProperty( + value = "The description of the type." + ) public String getDescription() { return description; } @@ -43,10 +45,11 @@ public class DocumentedTypeDTO { } /** - * The type is the fully-qualified name of a Java class. - * - * @return + * @return The type is the fully-qualified name of a Java class */ + @ApiModelProperty( + value = "The fulley qualified name of the type." + ) public String getType() { return type; } @@ -56,10 +59,11 @@ public class DocumentedTypeDTO { } /** - * The tags associated with this type. - * - * @return + * @return The tags associated with this type */ + @ApiModelProperty( + value = "The tags associated with this type." + ) public Set getTags() { return tags; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowSnippetDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowSnippetDTO.java index 47a6871b9d..1ce390ed16 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowSnippetDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowSnippetDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.LinkedHashSet; import java.util.Set; import javax.xml.bind.annotation.XmlType; @@ -35,12 +36,13 @@ public class FlowSnippetDTO { private Set labels = new LinkedHashSet<>(); private Set funnels = new LinkedHashSet<>(); private Set controllerServices = new LinkedHashSet<>(); - + /** - * The connections in this flow snippet. - * - * @return + * @return connections in this flow snippet */ + @ApiModelProperty( + value = "The connections in this flow snippet." + ) public Set getConnections() { return connections; } @@ -50,10 +52,11 @@ public class FlowSnippetDTO { } /** - * The input ports in this flow snippet. - * - * @return + * @return input ports in this flow snippet */ + @ApiModelProperty( + value = "The input ports in this flow snippet." + ) public Set getInputPorts() { return inputPorts; } @@ -63,10 +66,11 @@ public class FlowSnippetDTO { } /** - * The labels in this flow snippet. - * - * @return + * @return labels in this flow snippet */ + @ApiModelProperty( + value = "The labels in this flow snippet." + ) public Set getLabels() { return labels; } @@ -76,10 +80,11 @@ public class FlowSnippetDTO { } /** - * The funnels in this flow snippet. - * - * @return + * @return funnels in this flow snippet */ + @ApiModelProperty( + value = "The funnels in this flow snippet." + ) public Set getFunnels() { return funnels; } @@ -89,10 +94,11 @@ public class FlowSnippetDTO { } /** - * The output ports in this flow snippet. - * - * @return + * @return output ports in this flow snippet */ + @ApiModelProperty( + value = "The output ports in this flow snippet." + ) public Set getOutputPorts() { return outputPorts; } @@ -102,10 +108,11 @@ public class FlowSnippetDTO { } /** - * The process groups in this flow snippet. - * - * @return + * @return process groups in this flow snippet */ + @ApiModelProperty( + value = "The process groups in this flow snippet." + ) public Set getProcessGroups() { return processGroups; } @@ -115,10 +122,11 @@ public class FlowSnippetDTO { } /** - * The processors in this flow group. - * - * @return + * @return processors in this flow group */ + @ApiModelProperty( + value = "The processors in this flow snippet." + ) public Set getProcessors() { return processors; } @@ -128,10 +136,11 @@ public class FlowSnippetDTO { } /** - * The remote process groups in this flow snippet. - * - * @return + * @return remote process groups in this flow snippet */ + @ApiModelProperty( + value = "The remote process groups in this flow snippet." + ) public Set getRemoteProcessGroups() { return remoteProcessGroups; } @@ -141,9 +150,11 @@ public class FlowSnippetDTO { } /** - * Returns the Controller Services in this flow snippet - * @return + * @return the Controller Services in this flow snippet */ + @ApiModelProperty( + value = "The controller services in this flow snippet." + ) public Set getControllerServices() { return controllerServices; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/LabelDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/LabelDTO.java index f50c79292b..e9016dbd7e 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/LabelDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/LabelDTO.java @@ -16,7 +16,7 @@ */ package org.apache.nifi.web.api.dto; -import java.util.Collections; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Map; import javax.xml.bind.annotation.XmlType; @@ -33,8 +33,8 @@ public class LabelDTO extends NiFiComponentDTO { private Double height; // font-size = 12px - // color = #eee - private Map style = Collections.emptyMap(); + // background-color = #eee + private Map style; public LabelDTO() { } @@ -44,6 +44,9 @@ public class LabelDTO extends NiFiComponentDTO { * * @return The label text */ + @ApiModelProperty( + value = "The text that appears in the label." + ) public String getLabel() { return label; } @@ -53,10 +56,11 @@ public class LabelDTO extends NiFiComponentDTO { } /** - * The style for this label. - * - * @return + * @return style for this label */ + @ApiModelProperty( + value = "The styles for this label (font-size => 12px, background-color => #eee, etc)." + ) public Map getStyle() { return style; } @@ -66,10 +70,11 @@ public class LabelDTO extends NiFiComponentDTO { } /** - * The height of the label in pixels when at a 1:1 scale. - * - * @return + * @return height of the label in pixels when at a 1:1 scale */ + @ApiModelProperty( + value = "The height of the label in pixels when at a 1:1 scale." + ) public Double getHeight() { return height; } @@ -79,10 +84,11 @@ public class LabelDTO extends NiFiComponentDTO { } /** - * The width of the label in pixels when at a 1:1 scale. - * - * @return + * @return width of the label in pixels when at a 1:1 scale */ + @ApiModelProperty( + value = "The width of the label in pixels when at a 1:1 scale." + ) public Double getWidth() { return width; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/NiFiComponentDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/NiFiComponentDTO.java index 2829287b66..e89fb5df33 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/NiFiComponentDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/NiFiComponentDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -46,6 +47,9 @@ public class NiFiComponentDTO { * * @return The id */ + @ApiModelProperty( + value = "The id of the component." + ) public String getId() { return this.id; } @@ -55,10 +59,11 @@ public class NiFiComponentDTO { } /** - * The id for the parent group of this component if applicable, null otherwise. - * - * @return + * @return id for the parent group of this component if applicable, null otherwise */ + @ApiModelProperty( + value = "The id of parent process group of this component if applicable." + ) public String getParentGroupId() { return parentGroupId; } @@ -72,6 +77,9 @@ public class NiFiComponentDTO { * * @return The uri */ + @ApiModelProperty( + value = "The URI for futures requests to the component." + ) public String getUri() { return uri; } @@ -89,6 +97,9 @@ public class NiFiComponentDTO { * * @return The position */ + @ApiModelProperty( + value = "The position of this component in the UI if applicable." + ) public PositionDTO getPosition() { return position; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/NodeDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/NodeDTO.java index 9499c2efb2..f0aa9c4cc6 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/NodeDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/NodeDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Date; import java.util.List; import javax.xml.bind.annotation.XmlType; @@ -41,11 +42,12 @@ public class NodeDTO { private Date nodeStartTime; /** - * The node's last heartbeat timestamp. - * - * @return + * @return node's last heartbeat timestamp */ @XmlJavaTypeAdapter(DateTimeAdapter.class) + @ApiModelProperty( + value = "the time of the nodes's last heartbeat." + ) public Date getHeartbeat() { return heartbeat; } @@ -55,11 +57,12 @@ public class NodeDTO { } /** - * The time of the node's last connection request. - * - * @return + * @return time of the node's last connection request */ @XmlJavaTypeAdapter(DateTimeAdapter.class) + @ApiModelProperty( + value = "The time of the node's last connection request." + ) public Date getConnectionRequested() { return connectionRequested; } @@ -73,6 +76,9 @@ public class NodeDTO { * * @return The active thread count */ + @ApiModelProperty( + value = "The active threads for the NiFi on the node." + ) public Integer getActiveThreadCount() { return activeThreadCount; } @@ -82,10 +88,11 @@ public class NodeDTO { } /** - * The queue for the controller. - * - * @return + * @return queue for the controller */ + @ApiModelProperty( + value = "The queue the NiFi on the node." + ) public String getQueued() { return queued; } @@ -95,10 +102,11 @@ public class NodeDTO { } /** - * The node's host/IP address. - * - * @return + * @return node's host/IP address */ + @ApiModelProperty( + value = "The node's host/ip address." + ) public String getAddress() { return address; } @@ -108,10 +116,11 @@ public class NodeDTO { } /** - * The node ID. - * - * @return + * @return node ID */ + @ApiModelProperty( + value = "The id of the node." + ) public String getNodeId() { return nodeId; } @@ -121,10 +130,11 @@ public class NodeDTO { } /** - * The port the node is listening for API requests. - * - * @return + * @return port the node is listening for API requests */ + @ApiModelProperty( + value = "The port the node is listening for API requests." + ) public Integer getApiPort() { return apiPort; } @@ -134,10 +144,11 @@ public class NodeDTO { } /** - * The node's status. - * - * @return + * @return node's status */ + @ApiModelProperty( + value = "The node's status." + ) public String getStatus() { return status; } @@ -147,10 +158,11 @@ public class NodeDTO { } /** - * The node's events. - * - * @return + * @return node's events */ + @ApiModelProperty( + value = "The node's events." + ) public List getEvents() { return events; } @@ -160,10 +172,11 @@ public class NodeDTO { } /** - * Whether this node is the primary node within the cluster. - * - * @return + * @return whether this node is the primary node within the cluster */ + @ApiModelProperty( + value = "Whether the node is the primary node within the cluster." + ) public Boolean isPrimary() { return primary; } @@ -173,11 +186,12 @@ public class NodeDTO { } /** - * The time at which this Node was last restarted - * - * @return + * @return time at which this Node was last restarted */ @XmlJavaTypeAdapter(DateTimeAdapter.class) + @ApiModelProperty( + value = "The time at which this Node was last refreshed." + ) public Date getNodeStartTime() { return nodeStartTime; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/NodeEventDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/NodeEventDTO.java index 3cad8d84e4..f0b61a79b0 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/NodeEventDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/NodeEventDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Date; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; @@ -32,10 +33,11 @@ public class NodeEventDTO { private String message; /** - * The category of the node event. - * - * @return + * @return category of the node event */ + @ApiModelProperty( + value = "The category of the node event." + ) public String getCategory() { return category; } @@ -45,10 +47,11 @@ public class NodeEventDTO { } /** - * The message of the node event. - * - * @return + * @return message of the node event */ + @ApiModelProperty( + value = "The message in the node event." + ) public String getMessage() { return message; } @@ -58,11 +61,12 @@ public class NodeEventDTO { } /** - * The timestamp of the node event. - * - * @return + * @return timestamp of the node event */ @XmlJavaTypeAdapter(DateTimeAdapter.class) + @ApiModelProperty( + value = "The timestamp of the node event." + ) public Date getTimestamp() { return timestamp; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/NodeSystemDiagnosticsDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/NodeSystemDiagnosticsDTO.java index 8c83331005..8f925aa0a9 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/NodeSystemDiagnosticsDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/NodeSystemDiagnosticsDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -28,10 +29,11 @@ public class NodeSystemDiagnosticsDTO { private SystemDiagnosticsDTO systemDiagnostics; /** - * The node. - * - * @return + * @return the node */ + @ApiModelProperty( + value = "The node." + ) public NodeDTO getNode() { return node; } @@ -41,10 +43,11 @@ public class NodeSystemDiagnosticsDTO { } /** - * The system diagnostics. - * - * @return + * @return the system diagnostics */ + @ApiModelProperty( + value = "The diagnostics for the system the node is on." + ) public SystemDiagnosticsDTO getSystemDiagnostics() { return systemDiagnostics; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PortDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PortDTO.java index 2a372f4ef4..489ed0c11d 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PortDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PortDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Collection; import java.util.Set; import javax.xml.bind.annotation.XmlType; @@ -38,10 +39,11 @@ public class PortDTO extends NiFiComponentDTO { private Collection validationErrors; /** - * The name of this port. - * - * @return + * @return name of this port */ + @ApiModelProperty( + value = "The name of the port." + ) public String getName() { return name; } @@ -51,11 +53,12 @@ public class PortDTO extends NiFiComponentDTO { } /** - * The state of this port. Possible states are 'RUNNING', 'STOPPED', and - * 'DISABLED'. - * - * @return + * @return The state of this port. Possible states are 'RUNNING', 'STOPPED', and 'DISABLED' */ + @ApiModelProperty( + value = "The state of the port.", + allowableValues = "RUNNING, STOPPED, DISABLED" + ) public String getState() { return state; } @@ -67,8 +70,12 @@ public class PortDTO extends NiFiComponentDTO { /** * The type of port. Possible values are 'INPUT_PORT' or 'OUTPUT_PORT'. * - * @return + * @return The type of port */ + @ApiModelProperty( + value = "The type of port.", + allowableValues = "INPUT_PORT, OUTPUT_PORT" + ) public String getType() { return type; } @@ -78,10 +85,11 @@ public class PortDTO extends NiFiComponentDTO { } /** - * The number of tasks that should be concurrently scheduled for this port. - * - * @return + * @return number of tasks that should be concurrently scheduled for this port */ + @ApiModelProperty( + value = "The number of tasks that should be concurrently scheduled for the port." + ) public Integer getConcurrentlySchedulableTaskCount() { return concurrentlySchedulableTaskCount; } @@ -91,10 +99,11 @@ public class PortDTO extends NiFiComponentDTO { } /** - * The comments for this port. - * - * @return + * @return comments for this port */ + @ApiModelProperty( + value = "The comments for the port." + ) public String getComments() { return comments; } @@ -104,11 +113,11 @@ public class PortDTO extends NiFiComponentDTO { } /** - * Whether this port has incoming or outgoing connections to a remote NiFi. - * This is only applicable when the port is running on the root group. - * - * @return + * @return whether this port has incoming or outgoing connections to a remote NiFi. This is only applicable when the port is running on the root group */ + @ApiModelProperty( + value = "Whether the port has incoming or output connections to a remote NiFi. This is only applicable when the port is running in the root group." + ) public Boolean isTransmitting() { return transmitting; } @@ -118,10 +127,11 @@ public class PortDTO extends NiFiComponentDTO { } /** - * Groups that are allowed to access this port. - * - * @return + * @return groups that are allowed to access this port */ + @ApiModelProperty( + value = "The user groups that are allowed to access the port." + ) public Set getGroupAccessControl() { return groupAccessControl; } @@ -131,10 +141,11 @@ public class PortDTO extends NiFiComponentDTO { } /** - * Users that are allowed to access this port. - * - * @return + * @return users that are allowed to access this port */ + @ApiModelProperty( + value = "The users that are allowed to access the port." + ) public Set getUserAccessControl() { return userAccessControl; } @@ -144,12 +155,13 @@ public class PortDTO extends NiFiComponentDTO { } /** - * Gets the validation errors from this port. These validation errors - * represent the problems with the port that must be resolved before it can - * be started. + * Gets the validation errors from this port. These validation errors represent the problems with the port that must be resolved before it can be started. * * @return The validation errors */ + @ApiModelProperty( + value = "Gets the validation errors from this port. These validation errors represent the problems with the port that must be resolved before it can be started." + ) public Collection getValidationErrors() { return validationErrors; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PositionDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PositionDTO.java index ab077f371b..ef42387f7b 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PositionDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PositionDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -37,10 +38,11 @@ public class PositionDTO { /* getters / setters */ /** - * The x coordinate. - * - * @return + * @return the x coordinate */ + @ApiModelProperty( + value = "The x coordinate." + ) public Double getX() { return x; } @@ -50,10 +52,11 @@ public class PositionDTO { } /** - * The y coordinate. - * - * @return + * @return the y coordinate */ + @ApiModelProperty( + value = "The y coordinate." + ) public Double getY() { return y; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PreviousValueDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PreviousValueDTO.java index fb33c672d3..132456ca93 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PreviousValueDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PreviousValueDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Date; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; @@ -32,10 +33,11 @@ public class PreviousValueDTO { private String userName; /** - * The previous value. - * - * @return + * @return previous value */ + @ApiModelProperty( + value = "The previous value." + ) public String getPreviousValue() { return previousValue; } @@ -45,11 +47,12 @@ public class PreviousValueDTO { } /** - * When it was modified. - * - * @return + * @return when it was modified */ @XmlJavaTypeAdapter(DateTimeAdapter.class) + @ApiModelProperty( + value = "The timestamp when the value was modified." + ) public Date getTimestamp() { return timestamp; } @@ -59,10 +62,11 @@ public class PreviousValueDTO { } /** - * The user who changed the previous value. - * - * @return + * @return user who changed the previous value */ + @ApiModelProperty( + value = "The user who changed the previous value." + ) public String getUserName() { return userName; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessGroupDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessGroupDTO.java index 414004601f..93c4ea9f70 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessGroupDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessGroupDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -51,6 +52,9 @@ public class ProcessGroupDTO extends NiFiComponentDTO { * * @return The name of this Process Group */ + @ApiModelProperty( + value = "The name of the process group." + ) public String getName() { return name; } @@ -64,6 +68,9 @@ public class ProcessGroupDTO extends NiFiComponentDTO { * * @return This Process Group's parent */ + @ApiModelProperty( + value = "The part of the process group." + ) public ProcessGroupDTO getParent() { return parent; } @@ -73,10 +80,11 @@ public class ProcessGroupDTO extends NiFiComponentDTO { } /** - * The comments for this process group. - * - * @return + * @return comments for this process group */ + @ApiModelProperty( + value = "The comments for the process group." + ) public String getComments() { return comments; } @@ -86,11 +94,11 @@ public class ProcessGroupDTO extends NiFiComponentDTO { } /** - * The contents of this process group. This field will be populated if the - * request is marked verbose. - * - * @return + * @return contents of this process group. This field will be populated if the request is marked verbose */ + @ApiModelProperty( + value = "The contents of this process group. This field will be populated if the request is marked verbose." + ) public FlowSnippetDTO getContents() { return contents; } @@ -100,10 +108,11 @@ public class ProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of input ports contained in this process group. - * - * @return + * @return number of input ports contained in this process group */ + @ApiModelProperty( + value = "The number of input ports in the process group." + ) public Integer getInputPortCount() { return inputPortCount; } @@ -113,10 +122,11 @@ public class ProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of invalid components in this process group. - * - * @return + * @return number of invalid components in this process group */ + @ApiModelProperty( + value = "The number of invalid components in the process group." + ) public Integer getInvalidCount() { return invalidCount; } @@ -126,10 +136,11 @@ public class ProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of output ports in this process group. - * - * @return + * @return number of output ports in this process group */ + @ApiModelProperty( + value = "The number of output ports in the process group." + ) public Integer getOutputPortCount() { return outputPortCount; } @@ -139,10 +150,11 @@ public class ProcessGroupDTO extends NiFiComponentDTO { } /** - * Used in requests, indicates whether this process group should be running. - * - * @return + * @return Used in requests, indicates whether this process group should be running */ + @ApiModelProperty( + value = "Used in requests, indicates whether the process group should be running." + ) public Boolean isRunning() { return running; } @@ -152,10 +164,11 @@ public class ProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of running component in this process group. - * - * @return + * @return number of running component in this process group */ + @ApiModelProperty( + value = "The number of running componetns in this process group." + ) public Integer getRunningCount() { return runningCount; } @@ -165,10 +178,11 @@ public class ProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of stopped components in this process group. - * - * @return + * @return number of stopped components in this process group */ + @ApiModelProperty( + value = "The number of stopped components in the process group." + ) public Integer getStoppedCount() { return stoppedCount; } @@ -178,10 +192,11 @@ public class ProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of disabled components in this process group. - * - * @return + * @return number of disabled components in this process group */ + @ApiModelProperty( + value = "The number of disabled components in the process group." + ) public Integer getDisabledCount() { return disabledCount; } @@ -191,10 +206,11 @@ public class ProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of active remote ports in this process group. - * - * @return + * @return number of active remote ports in this process group */ + @ApiModelProperty( + value = "The number of active remote ports in the process group." + ) public Integer getActiveRemotePortCount() { return activeRemotePortCount; } @@ -204,10 +220,11 @@ public class ProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of inactive remote ports in this process group. - * - * @return + * @return number of inactive remote ports in this process group */ + @ApiModelProperty( + value = "The number of inactive remote ports in the process group." + ) public Integer getInactiveRemotePortCount() { return inactiveRemotePortCount; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessorConfigDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessorConfigDTO.java index 63ed005026..ec5df96d36 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessorConfigDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessorConfigDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Map; import java.util.Set; @@ -54,11 +55,13 @@ public class ProcessorConfigDTO { } /** - * The frequency with which to schedule the processor. The format of the value will - * depend on the value of {@link #getSchedulingStrategy()}. + * The frequency with which to schedule the processor. The format of the value will depend on the value of {@link #getSchedulingStrategy()}. * * @return The scheduling period */ + @ApiModelProperty( + value = "The frequency with which to schedule the processor. The format of the value will depend on th value of schedulingStrategy." + ) public String getSchedulingPeriod() { return schedulingPeriod; } @@ -68,11 +71,13 @@ public class ProcessorConfigDTO { } /** - * Indicates whether the processor should be scheduled to run in - * event-driven mode or timer-driven mode + * Indicates whether the processor should be scheduled to run in event-driven mode or timer-driven mode * - * @return + * @return scheduling strategy */ + @ApiModelProperty( + value = "Indcates whether the prcessor should be scheduled to run in event or timer driven mode." + ) public String getSchedulingStrategy() { return schedulingStrategy; } @@ -82,11 +87,11 @@ public class ProcessorConfigDTO { } /** - * The amount of time that is used when this processor penalizes a flow - * file. - * - * @return + * @return the amount of time that is used when this processor penalizes a flowfile */ + @ApiModelProperty( + value = "The amout of time that is used when the process penalizes a flowfile." + ) public String getPenaltyDuration() { return penaltyDuration; } @@ -96,11 +101,11 @@ public class ProcessorConfigDTO { } /** - * When yielding, this amount of time must elaspe before this processor is - * scheduled again. - * - * @return + * @return amount of time must elapse before this processor is scheduled again when yielding */ + @ApiModelProperty( + value = "The amount of time that must elapse before this processor is scheduled again after yielding." + ) public String getYieldDuration() { return yieldDuration; } @@ -110,10 +115,11 @@ public class ProcessorConfigDTO { } /** - * The level at this this processor will report bulletins. - * - * @return + * @return the level at this this processor will report bulletins */ + @ApiModelProperty( + value = "The level at which the processor will report bulletins." + ) public String getBulletinLevel() { return bulletinLevel; } @@ -123,12 +129,13 @@ public class ProcessorConfigDTO { } /** - * The number of tasks that should be concurrently scheduled for this - * processor. If this processor doesn't allow parallel processing then any - * positive input will be ignored. + * The number of tasks that should be concurrently scheduled for this processor. If this processor doesn't allow parallel processing then any positive input will be ignored. * - * @return The concurrently schedulable task count + * @return the concurrently schedulable task count */ + @ApiModelProperty( + value = "The number of tasks that should be concurrently schedule for the processor. If the processor doesn't allow parallol processing then any positive input will be ignored." + ) public Integer getConcurrentlySchedulableTaskCount() { return concurrentlySchedulableTaskCount; } @@ -138,10 +145,11 @@ public class ProcessorConfigDTO { } /** - * Whether or not this Processor is Loss Tolerant - * - * @return + * @return whether or not this Processor is Loss Tolerant */ + @ApiModelProperty( + value = "Whether the processor is loss tolerant." + ) public Boolean isLossTolerant() { return lossTolerant; } @@ -151,10 +159,11 @@ public class ProcessorConfigDTO { } /** - * The comments for this processor. - * - * @return The comments + * @return the comments */ + @ApiModelProperty( + value = "The comments for the processor." + ) public String getComments() { return comments; } @@ -164,14 +173,14 @@ public class ProcessorConfigDTO { } /** - * The properties for this processor. Properties whose value is not set will - * only contain the property name. These properties are (un)marshalled - * differently since we need/want to control the ordering of the properties. - * The descriptors and metadata are used as a lookup when processing these - * properties. + * The properties for this processor. Properties whose value is not set will only contain the property name. These properties are (un)marshalled differently since we need/want to control the + * ordering of the properties. The descriptors and metadata are used as a lookup when processing these properties. * * @return The optional properties */ + @ApiModelProperty( + value = "The properties for the processor. Properties whose value is not set will only contain the property name." + ) public Map getProperties() { return properties; } @@ -181,10 +190,11 @@ public class ProcessorConfigDTO { } /** - * The descriptors for this processor's properties. - * - * @return + * @return descriptors for this processor's properties */ + @ApiModelProperty( + value = "Descriptors for the processor's properties." + ) public Map getDescriptors() { return descriptors; } @@ -198,6 +208,9 @@ public class ProcessorConfigDTO { * * @return The annotation data */ + @ApiModelProperty( + value = "The annotation data for the processor used to relay configuration between a custom UI and the procesosr." + ) public String getAnnotationData() { return annotationData; } @@ -207,11 +220,11 @@ public class ProcessorConfigDTO { } /** - * Returns the URL for this processors custom configuration UI - * if applicable. Null otherwise. - * - * @return + * @return the URL for this processors custom configuration UI if applicable. Null otherwise. */ + @ApiModelProperty( + value = "The URL for the processor's custom configuration UI if applicable." + ) public String getCustomUiUrl() { return customUiUrl; } @@ -221,11 +234,11 @@ public class ProcessorConfigDTO { } /** - * The names of all processor relationships that cause a flow file to be - * terminated if the relationship is not connected to anything - * - * @return + * @return the names of all processor relationships that cause a flow file to be terminated if the relationship is not connected to anything */ + @ApiModelProperty( + value = "The names of all relationships that cause a flow file to be terminated if the relationship is not connected elsewhere." + ) public Set getAutoTerminatedRelationships() { return autoTerminatedRelationships; } @@ -235,11 +248,11 @@ public class ProcessorConfigDTO { } /** - * Maps default values for concurrent tasks for each applicable scheduling - * strategy. - * - * @return + * @return maps default values for concurrent tasks for each applicable scheduling strategy. */ + @ApiModelProperty( + value = "Maps default values for concurrent tasks for each applicable scheduling strategy." + ) public Map getDefaultConcurrentTasks() { return defaultConcurrentTasks; } @@ -249,10 +262,11 @@ public class ProcessorConfigDTO { } /** - * The run duration in milliseconds. - * - * @return + * @return run duration in milliseconds */ + @ApiModelProperty( + value = "The run duration for the processor in milliseconds." + ) public Long getRunDurationMillis() { return runDurationMillis; } @@ -262,11 +276,11 @@ public class ProcessorConfigDTO { } /** - * Maps default values for scheduling period for each applicable scheduling - * strategy. - * - * @return + * @return Maps default values for scheduling period for each applicable scheduling strategy */ + @ApiModelProperty( + value = "Maps default values for scheduling period for each applicable scheduling strategy." + ) public Map getDefaultSchedulingPeriod() { return defaultSchedulingPeriod; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessorDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessorDTO.java index 71ba4edbe1..c65c46ab59 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessorDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessorDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Collection; import java.util.List; import java.util.Map; @@ -49,6 +50,9 @@ public class ProcessorDTO extends NiFiComponentDTO { * * @return This processors name */ + @ApiModelProperty( + value = "The name of the processor." + ) public String getName() { return name; } @@ -62,6 +66,9 @@ public class ProcessorDTO extends NiFiComponentDTO { * * @return This processors type */ + @ApiModelProperty( + value = "The type of the processor." + ) public String getType() { return type; } @@ -71,11 +78,12 @@ public class ProcessorDTO extends NiFiComponentDTO { } /** - * The state of this processor. Possible states are 'RUNNING', 'STOPPED', - * and 'DISABLED'. - * - * @return + * @return The state of this processor. Possible states are 'RUNNING', 'STOPPED', and 'DISABLED' */ + @ApiModelProperty( + value = "The state of the processor", + allowableValues = "RUNNING, STOPPED, DISABLED" + ) public String getState() { return state; } @@ -85,10 +93,11 @@ public class ProcessorDTO extends NiFiComponentDTO { } /** - * The styles for this processor. (Currently only supports color). - * - * @return + * @return The styles for this processor. (Currently only supports color) */ + @ApiModelProperty( + value = "Styles for the processor (background-color => #eee)." + ) public Map getStyle() { return style; } @@ -98,10 +107,11 @@ public class ProcessorDTO extends NiFiComponentDTO { } /** - * Whether this processor supports parallel processing. - * - * @return + * @return whether this processor supports parallel processing */ + @ApiModelProperty( + value = "Whether the processor supports parallel processing." + ) public Boolean getSupportsParallelProcessing() { return supportsParallelProcessing; } @@ -111,10 +121,11 @@ public class ProcessorDTO extends NiFiComponentDTO { } /** - * Whether this processor supports event driven scheduling. - * - * @return + * @return whether this processor supports event driven scheduling */ + @ApiModelProperty( + value = "Whether the processor supports event driven scheduling." + ) public Boolean getSupportsEventDriven() { return supportsEventDriven; } @@ -128,6 +139,9 @@ public class ProcessorDTO extends NiFiComponentDTO { * * @return The available relationships */ + @ApiModelProperty( + value = "The available relationships that the processor currently supports." + ) public List getRelationships() { return relationships; } @@ -137,11 +151,13 @@ public class ProcessorDTO extends NiFiComponentDTO { } /** - * The configuration details for this processor. These details will be - * included in a response if the verbose flag is set to true. + * The configuration details for this processor. These details will be included in a response if the verbose flag is set to true. * * @return The processor configuration details */ + @ApiModelProperty( + value = "The configuration details for the processor. These details will be included in a resopnse if the verbose flag is included in a request." + ) public ProcessorConfigDTO getConfig() { return config; } @@ -151,12 +167,13 @@ public class ProcessorDTO extends NiFiComponentDTO { } /** - * Gets the validation errors from this processor. These validation errors - * represent the problems with the processor that must be resolved before it - * can be started. + * Gets the validation errors from this processor. These validation errors represent the problems with the processor that must be resolved before it can be started. * * @return The validation errors */ + @ApiModelProperty( + value = "The validation errors for the processor. These validation errors represent the problems with the processor that must be resolved before it can be started." + ) public Collection getValidationErrors() { return validationErrors; } @@ -166,10 +183,11 @@ public class ProcessorDTO extends NiFiComponentDTO { } /** - * Gets the description for this processor. - * - * @return + * @return the description for this processor */ + @ApiModelProperty( + value = "The description of the processor." + ) public String getDescription() { return description; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PropertyDescriptorDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PropertyDescriptorDTO.java index ecde255022..dae16f28bf 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PropertyDescriptorDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PropertyDescriptorDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.List; import javax.xml.bind.annotation.XmlType; @@ -37,11 +38,11 @@ public class PropertyDescriptorDTO { private String identifiesControllerService; /** - * The set of allowable values for this property. If empty then the - * allowable values are not constrained. - * - * @return + * @return set of allowable values for this property. If empty then the allowable values are not constrained */ + @ApiModelProperty( + value = "Allowable values for the property. If empty then the allowed values are not constrained." + ) public List getAllowableValues() { return allowableValues; } @@ -51,10 +52,11 @@ public class PropertyDescriptorDTO { } /** - * The default value for this property. - * - * @return + * @return default value for this property */ + @ApiModelProperty( + value = "The default value for the property." + ) public String getDefaultValue() { return defaultValue; } @@ -64,12 +66,11 @@ public class PropertyDescriptorDTO { } /** - * And explanation of the meaning of the given property. This - * description is meant to be displayed to a user or simply provide a - * mechanism of documenting intent. - * - * @return + * @return An explanation of the meaning of the given property. This description is meant to be displayed to a user or simply provide a mechanism of documenting intent */ + @ApiModelProperty( + value = "The descriptoin for the property. Used to relay additional details to a user or provide a mechanism of documenting intent." + ) public String getDescription() { return description; } @@ -79,10 +80,11 @@ public class PropertyDescriptorDTO { } /** - * The property name. - * - * @return + * @return property name */ + @ApiModelProperty( + value = "The name for the property." + ) public String getName() { return name; } @@ -92,10 +94,11 @@ public class PropertyDescriptorDTO { } /** - * The human-readable name to display to users. - * - * @return + * @return human-readable name to display to users */ + @ApiModelProperty( + value = "The human readable name for the property." + ) public String getDisplayName() { return displayName; } @@ -105,10 +108,11 @@ public class PropertyDescriptorDTO { } /** - * Determines whether the property is required for this processor. - * - * @return + * @return whether the property is required for this processor */ + @ApiModelProperty( + value = "Whether the property is required." + ) public boolean isRequired() { return required; } @@ -118,11 +122,11 @@ public class PropertyDescriptorDTO { } /** - * Indicates that the value for this property should be considered - * sensitive and protected whenever stored or represented. - * - * @return + * @return indicates that the value for this property should be considered sensitive and protected whenever stored or represented */ + @ApiModelProperty( + value = "Whether the property is sensitive and protected whenever stored or represented." + ) public boolean isSensitive() { return sensitive; } @@ -132,10 +136,11 @@ public class PropertyDescriptorDTO { } /** - * Indicates whether this property is dynamic. - * - * @return + * @return indicates whether this property is dynamic */ + @ApiModelProperty( + value = "Whether the property is dynamic (user-defined)." + ) public boolean isDynamic() { return dynamic; } @@ -145,10 +150,11 @@ public class PropertyDescriptorDTO { } /** - * Specifies whether or not this property support expression language. - * - * @return + * @return specifies whether or not this property support expression language */ + @ApiModelProperty( + value = "Whether the property supports expression language." + ) public boolean getSupportsEl() { return supportsEl; } @@ -158,11 +164,11 @@ public class PropertyDescriptorDTO { } /** - * If this property identifies a controller service, this returns the - * fully qualified type, null otherwise. - * - * @return + * @return if this property identifies a controller service, this returns the fully qualified type, null otherwise */ + @ApiModelProperty( + value = "If the property identifies a controller service, this returns the fully qualified type." + ) public String getIdentifiesControllerService() { return identifiesControllerService; } @@ -170,7 +176,7 @@ public class PropertyDescriptorDTO { public void setIdentifiesControllerService(String identifiesControllerService) { this.identifiesControllerService = identifiesControllerService; } - + /** * The allowable values for a property with a constrained set of options. */ @@ -182,11 +188,11 @@ public class PropertyDescriptorDTO { private String description; /** - * Returns the human-readable value that is allowed for this - * PropertyDescriptor - * - * @return + * @return the human-readable value that is allowed for this PropertyDescriptor */ + @ApiModelProperty( + value = "A human readable value that is allowed for the property descriptor." + ) public String getDisplayName() { return displayName; } @@ -196,10 +202,11 @@ public class PropertyDescriptorDTO { } /** - * Returns the value for this allowable value. - * - * @return + * @return the value for this allowable value */ + @ApiModelProperty( + value = "A value that is allowed for the property descriptor." + ) public String getValue() { return value; } @@ -209,11 +216,11 @@ public class PropertyDescriptorDTO { } /** - * Returns a description of this Allowable Value, or null - * if no description is given - * - * @return + * @return a description of this Allowable Value, or null if no description is given */ + @ApiModelProperty( + value = "A description for this allowable value." + ) public String getDescription() { return description; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PropertyHistoryDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PropertyHistoryDTO.java index 064ad21b22..35c829389d 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PropertyHistoryDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PropertyHistoryDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.List; import javax.xml.bind.annotation.XmlType; @@ -28,10 +29,11 @@ public class PropertyHistoryDTO { private List previousValues; /** - * The previous values. - * - * @return + * @return previous values */ + @ApiModelProperty( + value = "Previous values for a given property." + ) public List getPreviousValues() { return previousValues; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RelationshipDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RelationshipDTO.java index 7042aaa362..ff5729af6c 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RelationshipDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RelationshipDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -29,10 +30,11 @@ public class RelationshipDTO { private Boolean autoTerminate; /** - * The relationship name. - * - * @return + * @return the relationship name */ + @ApiModelProperty( + value = "The relationship name." + ) public String getName() { return name; } @@ -42,10 +44,11 @@ public class RelationshipDTO { } /** - * The relationship description. - * - * @return + * @return the relationship description */ + @ApiModelProperty( + value = "The relationship description." + ) public String getDescription() { return description; } @@ -55,10 +58,11 @@ public class RelationshipDTO { } /** - * Whether or not this relationship is auto terminated. - * - * @return + * @return true if relationship is auto terminated;false otherwise */ + @ApiModelProperty( + value = "Whether or not flowfiles sent to this relationship should auto terminate." + ) public Boolean isAutoTerminate() { return autoTerminate; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RemoteProcessGroupContentsDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RemoteProcessGroupContentsDTO.java index 1e5356d209..261a84407a 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RemoteProcessGroupContentsDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RemoteProcessGroupContentsDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Set; import javax.xml.bind.annotation.XmlType; @@ -29,10 +30,11 @@ public class RemoteProcessGroupContentsDTO { private Set outputPorts; /** - * The Controller Input Ports to which data can be sent - * - * @return + * @return Controller Input Ports to which data can be sent */ + @ApiModelProperty( + value = "The input ports to which data can be sent." + ) public Set getInputPorts() { return inputPorts; } @@ -42,10 +44,11 @@ public class RemoteProcessGroupContentsDTO { } /** - * The Controller Output Ports from which data can be retrieved - * - * @return + * @return Controller Output Ports from which data can be retrieved */ + @ApiModelProperty( + value = "The output ports from which data can be retrieved." + ) public Set getOutputPorts() { return outputPorts; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RemoteProcessGroupDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RemoteProcessGroupDTO.java index df59b13aaa..2e30001026 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RemoteProcessGroupDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RemoteProcessGroupDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Date; import java.util.List; import javax.xml.bind.annotation.XmlType; @@ -67,19 +68,21 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * The target uri of this remote process group. - * - * @return + * @return target uri of this remote process group */ + @ApiModelProperty( + value = "The target URI of the remote process group." + ) public String getTargetUri() { return this.targetUri; } /** - * The name of this remote process group. - * - * @param name + * @param name of this remote process group */ + @ApiModelProperty( + value = "The name of the remote process group." + ) public void setName(final String name) { this.name = name; } @@ -89,10 +92,11 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * Comments for this remote process group. - * - * @return + * @return Comments for this remote process group */ + @ApiModelProperty( + value = "The comments for the remote process group." + ) public String getComments() { return comments; } @@ -102,10 +106,11 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * Returns any remote authorization issues for this remote process group. - * - * @return + * @return any remote authorization issues for this remote process group */ + @ApiModelProperty( + value = "Any remote authorization issues for the remote process group." + ) public List getAuthorizationIssues() { return authorizationIssues; } @@ -115,10 +120,11 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * Whether or not this remote process group is actively transmitting. - * - * @return + * @return whether or not this remote process group is actively transmitting */ + @ApiModelProperty( + value = "Whether the remote process group is actively transmitting." + ) public Boolean isTransmitting() { return transmitting; } @@ -128,10 +134,11 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * Whether or not the target is running securely. - * - * @return + * @return whether or not the target is running securely */ + @ApiModelProperty( + value = "Whether the target is running securely." + ) public Boolean isTargetSecure() { return targetSecure; } @@ -141,11 +148,11 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * Returns the time period used for the timeout when communicating with this - * RemoteProcessGroup. - * - * @return + * @return the time period used for the timeout when communicating with this RemoteProcessGroup */ + @ApiModelProperty( + value = "The time period used for the timeout when commicating with the target." + ) public String getCommunicationsTimeout() { return communicationsTimeout; } @@ -155,11 +162,11 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * When yielding, this amount of time must elaspe before this remote process - * group is scheduled again. - * - * @return + * @return when yielding, this amount of time must elapse before this remote process group is scheduled again */ + @ApiModelProperty( + value = "When yielding, this amount of time must elapse before the remote process group is scheduled again." + ) public String getYieldDuration() { return yieldDuration; } @@ -169,10 +176,11 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of active remote input ports. - * - * @return + * @return number of active remote input ports */ + @ApiModelProperty( + value = "The number of active remote input ports." + ) public Integer getActiveRemoteInputPortCount() { return activeRemoteInputPortCount; } @@ -182,10 +190,11 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of inactive remote input ports. - * - * @return + * @return number of inactive remote input ports */ + @ApiModelProperty( + value = "The number of inactive remote input ports." + ) public Integer getInactiveRemoteInputPortCount() { return inactiveRemoteInputPortCount; } @@ -195,10 +204,11 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of active remote output ports. - * - * @return + * @return number of active remote output ports */ + @ApiModelProperty( + value = "The number of acitve remote output ports." + ) public Integer getActiveRemoteOutputPortCount() { return activeRemoteOutputPortCount; } @@ -208,10 +218,11 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of inactive remote output ports. - * - * @return + * @return number of inactive remote output ports */ + @ApiModelProperty( + value = "The number of inactive remote output ports." + ) public Integer getInactiveRemoteOutputPortCount() { return inactiveRemoteOutputPortCount; } @@ -221,11 +232,11 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of Remote Input Ports currently available in the remote NiFi - * instance - * - * @return + * @return number of Remote Input Ports currently available in the remote NiFi instance */ + @ApiModelProperty( + value = "The number of remote input ports currently available on the target." + ) public Integer getInputPortCount() { return inputPortCount; } @@ -235,11 +246,11 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of Remote Output Ports currently available in the remote NiFi - * instance - * - * @return + * @return number of Remote Output Ports currently available in the remote NiFi instance */ + @ApiModelProperty( + value = "The number of remote output ports currently available on the target." + ) public Integer getOutputPortCount() { return outputPortCount; } @@ -249,11 +260,11 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * The contents of this remote process group. Will contain available - * input/output ports. - * - * @return + * @return contents of this remote process group. Will contain available input/output ports */ + @ApiModelProperty( + value = "The contents of the remote process group. Will contain available input/output ports." + ) public RemoteProcessGroupContentsDTO getContents() { return contents; } @@ -263,11 +274,12 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * When the flow for this remote group was last refreshed. - * - * @return + * @return the flow for this remote group was last refreshed */ @XmlJavaTypeAdapter(DateTimeAdapter.class) + @ApiModelProperty( + value = "The timestamp when this remote process group was last refreshed." + ) public Date getFlowRefreshed() { return flowRefreshed; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RemoteProcessGroupPortDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RemoteProcessGroupPortDTO.java index 7948dadd82..e4a8131323 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RemoteProcessGroupPortDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RemoteProcessGroupPortDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -36,10 +37,11 @@ public class RemoteProcessGroupPortDTO { private Boolean connected; /** - * The comments as configured in the target port. - * - * @return + * @return comments as configured in the target port */ + @ApiModelProperty( + value = "The comments as configured on the target port." + ) public String getComments() { return comments; } @@ -49,11 +51,11 @@ public class RemoteProcessGroupPortDTO { } /** - * The number tasks that may transmit flow files to the target port - * concurrently. - * - * @return + * @return number tasks that may transmit flow files to the target port concurrently */ + @ApiModelProperty( + value = "The number of task that may transmit flowfiles to the target port concurrently." + ) public Integer getConcurrentlySchedulableTaskCount() { return concurrentlySchedulableTaskCount; } @@ -63,10 +65,11 @@ public class RemoteProcessGroupPortDTO { } /** - * The id of the target port. - * - * @return + * @return id of the target port */ + @ApiModelProperty( + value = "The id of the target port." + ) public String getId() { return id; } @@ -76,10 +79,11 @@ public class RemoteProcessGroupPortDTO { } /** - * The id of the remote process group that this port resides in. - * - * @return + * @return id of the remote process group that this port resides in */ + @ApiModelProperty( + value = "The id of the remote process group that the port resides in." + ) public String getGroupId() { return groupId; } @@ -89,10 +93,11 @@ public class RemoteProcessGroupPortDTO { } /** - * The name of the target port. - * - * @return + * @return name of the target port */ + @ApiModelProperty( + value = "The name of the target port." + ) public String getName() { return name; } @@ -102,10 +107,11 @@ public class RemoteProcessGroupPortDTO { } /** - * Whether or not this remote group port is configured for transmission. - * - * @return + * @return whether or not this remote group port is configured for transmission */ + @ApiModelProperty( + value = "Whether the remote port is configured for transmission." + ) public Boolean isTransmitting() { return transmitting; } @@ -115,10 +121,11 @@ public class RemoteProcessGroupPortDTO { } /** - * Whether or not flow file are compressed when sent to this target port. - * - * @return + * @return whether or not flow file are compressed when sent to this target port */ + @ApiModelProperty( + value = "Whether the flowfiles are compressed when sent to the target port." + ) public Boolean getUseCompression() { return useCompression; } @@ -128,10 +135,11 @@ public class RemoteProcessGroupPortDTO { } /** - * Whether or not the target port exists. - * - * @return + * @return whether or not the target port exists */ + @ApiModelProperty( + value = "Whether the target port exists." + ) public Boolean getExists() { return exists; } @@ -141,10 +149,11 @@ public class RemoteProcessGroupPortDTO { } /** - * Whether or not the target port is running. - * - * @return + * @return whether or not the target port is running */ + @ApiModelProperty( + value = "Whether the target port is running." + ) public Boolean isTargetRunning() { return targetRunning; } @@ -154,10 +163,11 @@ public class RemoteProcessGroupPortDTO { } /** - * Whether or not this port has either an incoming or outgoing connection. - * - * @return + * @return whether or not this port has either an incoming or outgoing connection */ + @ApiModelProperty( + value = "Whether the port has either an incoming or outgoing connection." + ) public Boolean isConnected() { return connected; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ReportingTaskDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ReportingTaskDTO.java index a019f97341..cdc834ce87 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ReportingTaskDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ReportingTaskDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Collection; import java.util.Map; @@ -26,144 +27,162 @@ import javax.xml.bind.annotation.XmlType; */ @XmlType(name = "reportingTask") public class ReportingTaskDTO extends NiFiComponentDTO { - private String name; - private String type; - private String state; - private String availability; + + private String name; + private String type; + private String state; + private String availability; private String comments; - - private String schedulingPeriod; - private String schedulingStrategy; + + private String schedulingPeriod; + private String schedulingStrategy; private Map defaultSchedulingPeriod; - - private Map properties; + + private Map properties; private Map descriptors; - + private String customUiUrl; private String annotationData; - + private Collection validationErrors; private Integer activeThreadCount; - + /** - * The user-defined name of the reporting task - * @return + * @return user-defined name of the reporting task */ - public String getName() { - return name; - } + @ApiModelProperty( + value = "The name of the reporting task." + ) + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } - /** - * The user-defined comments for the reporting task - * @return - */ - public String getComments() { - return comments; - } + /** + * @return user-defined comments for the reporting task + */ + @ApiModelProperty( + value = "The comments of the reporting task." + ) + public String getComments() { + return comments; + } - public void setComments(String comments) { - this.comments = comments; - } + public void setComments(String comments) { + this.comments = comments; + } - /** - * The type of reporting task - * @return - */ - public String getType() { - return type; - } + /** + * @return type of reporting task + */ + @ApiModelProperty( + value = "The fully qualified type of the reporting task." + ) + public String getType() { + return type; + } - public void setType(String type) { - this.type = type; - } + public void setType(String type) { + this.type = type; + } - /** - * The frequency with which to schedule the reporting task. The format of the value will - * depend on the value of {@link #getSchedulingStrategy()}. + /** + * The frequency with which to schedule the reporting task. The format of the value will depend on the value of {@link #getSchedulingStrategy()}. * * @return The scheduling period */ - public String getSchedulingPeriod() { - return schedulingPeriod; - } + @ApiModelProperty( + value = "The frequency with which to schedule the reporting task. The format of the value willd epend on the valud of the schedulingStrategy." + ) + public String getSchedulingPeriod() { + return schedulingPeriod; + } - public void setSchedulingPeriod(String schedulingPeriod) { - this.schedulingPeriod = schedulingPeriod; - } - - /** - * The current scheduling state of the reporting task - * @return - */ - public String getState() { - return state; - } - - public void setState(String state) { - this.state = state; - } - - /** - * The scheduling strategy that determines how the {@link #getSchedulingPeriod()} value should - * be interpreted - * - * @return - */ - public String getSchedulingStrategy() { - return schedulingStrategy; - } - - public void setSchedulingStrategy(String schedulingStrategy) { - this.schedulingStrategy = schedulingStrategy; - } - - /** - * Where this service is available. Possible values are CLUSTER_MANAGER_ONLY, NODE_ONLY, BOTH. - * - * @return - */ - public String getAvailability() { - return availability; - } - - public void setAvailability(String availability) { - this.availability = availability; - } - - /** - * The reporting task's properties - * @return - */ - public Map getProperties() { - return properties; - } - - public void setProperties(Map properties) { - this.properties = properties; - } - - /** - * Map of property name to descriptor - * @return - */ - public Map getDescriptors() { - return descriptors; - } - - public void setDescriptors(Map descriptors) { - this.descriptors = descriptors; - } + public void setSchedulingPeriod(String schedulingPeriod) { + this.schedulingPeriod = schedulingPeriod; + } /** - * Returns the URL for this reporting task custom configuration UI - * if applicable. Null otherwise. - * - * @return + * @return current scheduling state of the reporting task */ + @ApiModelProperty( + value = "The state of the reporting task.", + allowableValues = "RUNNING, STOPPED, DISABLED" + ) + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + /** + * @return The scheduling strategy that determines how the {@link #getSchedulingPeriod()} value should be interpreted + */ + @ApiModelProperty( + value = "The scheduling strategy that determines how the schedulingPeriod value should be interpreted." + ) + public String getSchedulingStrategy() { + return schedulingStrategy; + } + + public void setSchedulingStrategy(String schedulingStrategy) { + this.schedulingStrategy = schedulingStrategy; + } + + /** + * @return Where this service is available. Possible values are NCM, NODE + */ + @ApiModelProperty( + value = "Where the reporting task is available.", + allowableValues = "NCM, NODE" + ) + public String getAvailability() { + return availability; + } + + public void setAvailability(String availability) { + this.availability = availability; + } + + /** + * @return reporting task's properties + */ + @ApiModelProperty( + value = "The properties of the reporting task." + ) + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties = properties; + } + + /** + * @return Map of property name to descriptor + */ + @ApiModelProperty( + value = "The descriptors for the reporting tasks properties." + ) + public Map getDescriptors() { + return descriptors; + } + + public void setDescriptors(Map descriptors) { + this.descriptors = descriptors; + } + + /** + * @return the URL for this reporting task custom configuration UI if applicable. Null otherwise + */ + @ApiModelProperty( + value = "The URL for the custom configuration UI for the reporting task." + ) public String getCustomUiUrl() { return customUiUrl; } @@ -172,25 +191,29 @@ public class ReportingTaskDTO extends NiFiComponentDTO { this.customUiUrl = customUiUrl; } - /** - * The currently configured annotation data for the reporting task - * @return - */ - public String getAnnotationData() { - return annotationData; - } - - public void setAnnotationData(String annotationData) { - this.annotationData = annotationData; - } - /** - * Gets the validation errors from this reporting task. These validation errors - * represent the problems with the reporting task that must be resolved before it - * can be scheduled to run. + * @return currently configured annotation data for the reporting task + */ + @ApiModelProperty( + value = "The anntation data for the repoting task. This is how the custom UI relays configuration to the reporting task." + ) + public String getAnnotationData() { + return annotationData; + } + + public void setAnnotationData(String annotationData) { + this.annotationData = annotationData; + } + + /** + * Gets the validation errors from this reporting task. These validation errors represent the problems with the reporting task that must be resolved before it can be scheduled to run. * * @return The validation errors */ + @ApiModelProperty( + value = "Gets the validation errors from the reporting task. These validation errors represent the problems with the reporting task that must be resolved before " + + "it can be scheduled to run." + ) public Collection getValidationErrors() { return validationErrors; } @@ -200,10 +223,11 @@ public class ReportingTaskDTO extends NiFiComponentDTO { } /** - * The default scheduling period for the different scheduling strategies. - * - * @return + * @return default scheduling period for the different scheduling strategies */ + @ApiModelProperty( + value = "The default scheduling period for the different scheduling strategies." + ) public Map getDefaultSchedulingPeriod() { return defaultSchedulingPeriod; } @@ -213,10 +237,11 @@ public class ReportingTaskDTO extends NiFiComponentDTO { } /** - * The number of active threads for this reporting task. - * - * @return + * @return number of active threads for this reporting task */ + @ApiModelProperty( + value = "The number of active threads for the reporting task." + ) public Integer getActiveThreadCount() { return activeThreadCount; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RevisionDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RevisionDTO.java index 3327b49815..c8ef843e73 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RevisionDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RevisionDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -29,16 +30,16 @@ public class RevisionDTO { private String lastModifier; /* getters / setters */ - /** - * A client identifier used to make a request. By including a client - * identifier, the API can allow multiple requests without needing the - * current revision. Due to the asynchronous nature of requests/responses - * this was implemented to allow the client to make numerous requests - * without having to wait for the previous response to come back. + * A client identifier used to make a request. By including a client identifier, the API can allow multiple requests without needing the current revision. Due to the asynchronous nature of + * requests/responses this was implemented to allow the client to make numerous requests without having to wait for the previous response to come back. * * @return The client id */ + @ApiModelProperty( + value = "A client identifier used to make a request. By including a client identifier, the API can allow multiple requests without needing the current revision. Due to the asynchronous " + + "nature of requests/responses this was implemented to allow the client to make numerous requests without having to wait for the previous response to come back" + ) public String getClientId() { return clientId; } @@ -48,12 +49,14 @@ public class RevisionDTO { } /** - * NiFi employs an optimistic locking strategy where the client must include - * a revision in their request when performing an update. In a response, - * this field represents the updated base version. + * NiFi employs an optimistic locking strategy where the client must include a revision in their request when performing an update. In a response, this field represents the updated base version. * * @return The revision */ + @ApiModelProperty( + value = "NiFi employs an optimistic locking strategy where the client must include a revision in their request when performing an update. In a response to a mutable flow request, this " + + "field represents the updated base version." + ) public Long getVersion() { return version; } @@ -63,10 +66,11 @@ public class RevisionDTO { } /** - * The user that last modified the flow. - * - * @return + * @return The user that last modified the flow */ + @ApiModelProperty( + value = "The user that last modified the flow." + ) public String getLastModifier() { return lastModifier; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/SnippetDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/SnippetDTO.java index 2ee13106da..431df1755b 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/SnippetDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/SnippetDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.HashSet; import java.util.Set; import javax.xml.bind.annotation.XmlType; @@ -44,10 +45,11 @@ public class SnippetDTO { private FlowSnippetDTO contents; /** - * The id of this snippet. - * - * @return + * @return id of this snippet */ + @ApiModelProperty( + value = "The id of the snippet." + ) public String getId() { return id; } @@ -57,10 +59,11 @@ public class SnippetDTO { } /** - * The uri of this snippet. - * - * @return + * @return uri of this snippet */ + @ApiModelProperty( + value = "The URI of the snippet." + ) public String getUri() { return uri; } @@ -70,10 +73,11 @@ public class SnippetDTO { } /** - * The group id for the components in this snippet. - * - * @return + * @return group id for the components in this snippet */ + @ApiModelProperty( + value = "The group id for the components in the snippet." + ) public String getParentGroupId() { return parentGroupId; } @@ -83,10 +87,13 @@ public class SnippetDTO { } /** - * Whether or not this snippet is linked to the underlying data flow. - * - * @return + * @return whether or not this snippet is linked to the underlying data flow */ + @ApiModelProperty( + value = "Whether or not the snippet is linked to the underlying data flow. For instance if linked was set to true and the snippet was deleted " + + "it would also deleted the components in the snippet. If the snippet was not linked, deleting the snippet would only remove the " + + "snippet and leave the component intact." + ) public Boolean isLinked() { return linked; } @@ -96,13 +103,13 @@ public class SnippetDTO { } /** - * The ids of the connections in this snippet. These ids will be populated - * within each response. They can be specified when creating a snippet. - * However, once a snippet has been created its contents cannot be modified - * (these ids are ignored during update requests). - * - * @return + * @return the ids of the connections in this snippet. These ids will be populated within each response. They can be specified when creating a snippet. However, once a snippet has been created its + * contents cannot be modified (these ids are ignored during update requests) */ + @ApiModelProperty( + value = "The ids of the connections in this snippet. These ids will be populated within each response. They can be specified when creating a snippet. However, once a snippet " + + "has been created its contents cannot be modified (these ids are ignored during update requests)." + ) public Set getConnections() { return connections; } @@ -112,13 +119,13 @@ public class SnippetDTO { } /** - * The ids of the funnels in this snippet. These ids will be populated - * within each response. They can be specified when creating a snippet. - * However, once a snippet has been created its contents cannot be modified - * (these ids are ignored during update requests). - * - * @param funnels + * @return the ids of the funnels in this snippet. These ids will be populated within each response. They can be specified when creating a snippet. However, once a snippet has been created its + * contents cannot be modified (these ids are ignored during update requests) */ + @ApiModelProperty( + value = "The ids of the funnels in this snippet. These ids will be populated within each response. They can be specified when creating a snippet. However, once a snippet " + + "has been created its contents cannot be modified (these ids are ignored during update requests)." + ) public Set getFunnels() { return funnels; } @@ -128,13 +135,13 @@ public class SnippetDTO { } /** - * The ids of the input port in this snippet. These ids will be populated - * within each response. They can be specified when creating a snippet. - * However, once a snippet has been created its contents cannot be modified - * (these ids are ignored during update requests). - * - * @return + * @return the ids of the input port in this snippet. These ids will be populated within each response. They can be specified when creating a snippet. However, once a snippet has been created its + * contents cannot be modified (these ids are ignored during update requests) */ + @ApiModelProperty( + value = "The ids of the input ports in this snippet. These ids will be populated within each response. They can be specified when creating a snippet. However, once a snippet " + + "has been created its contents cannot be modified (these ids are ignored during update requests)." + ) public Set getInputPorts() { return inputPorts; } @@ -144,13 +151,13 @@ public class SnippetDTO { } /** - * The ids of the labels in this snippet. These ids will be populated within - * each response. They can be specified when creating a snippet. However, - * once a snippet has been created its contents cannot be modified (these - * ids are ignored during update requests). - * - * @return + * @return the ids of the labels in this snippet. These ids will be populated within each response. They can be specified when creating a snippet. However, once a snippet has been created its + * contents cannot be modified (these ids are ignored during update requests) */ + @ApiModelProperty( + value = "The ids of the labels in this snippet. These ids will be populated within each response. They can be specified when creating a snippet. However, once a snippet " + + "has been created its contents cannot be modified (these ids are ignored during update requests)." + ) public Set getLabels() { return labels; } @@ -160,13 +167,13 @@ public class SnippetDTO { } /** - * The ids of the output ports in this snippet. These ids will be populated - * within each response. They can be specified when creating a snippet. - * However, once a snippet has been created its contents cannot be modified - * (these ids are ignored during update requests). - * - * @return + * @return the ids of the output ports in this snippet. These ids will be populated within each response. They can be specified when creating a snippet. However, once a snippet has been created + * its contents cannot be modified (these ids are ignored during update requests) */ + @ApiModelProperty( + value = "The ids of the output ports in this snippet. These ids will be populated within each response. They can be specified when creating a snippet. However, once a snippet " + + "has been created its contents cannot be modified (these ids are ignored during update requests)." + ) public Set getOutputPorts() { return outputPorts; } @@ -176,13 +183,13 @@ public class SnippetDTO { } /** - * The ids of the process groups in this snippet. These ids will be - * populated within each response. They can be specified when creating a - * snippet. However, once a snippet has been created its contents cannot be - * modified (these ids are ignored during update requests). - * - * @return + * @return The ids of the process groups in this snippet. These ids will be populated within each response. They can be specified when creating a snippet. However, once a snippet has been created + * its contents cannot be modified (these ids are ignored during update requests) */ + @ApiModelProperty( + value = "The ids of the process groups in this snippet. These ids will be populated within each response. They can be specified when creating a snippet. However, once a snippet " + + "has been created its contents cannot be modified (these ids are ignored during update requests)." + ) public Set getProcessGroups() { return processGroups; } @@ -192,13 +199,13 @@ public class SnippetDTO { } /** - * The ids of the processors in this snippet. These ids will be populated - * within each response. They can be specified when creating a snippet. - * However, once a snippet has been created its contents cannot be modified - * (these ids are ignored during update requests). - * - * @return + * @return The ids of the processors in this snippet. These ids will be populated within each response. They can be specified when creating a snippet. However, once a snippet has been created its + * contents cannot be modified (these ids are ignored during update requests) */ + @ApiModelProperty( + value = "The ids of the processors in this snippet. These ids will be populated within each response. They can be specified when creating a snippet. However, once a snippet " + + "has been created its contents cannot be modified (these ids are ignored during update requests)." + ) public Set getProcessors() { return processors; } @@ -208,13 +215,13 @@ public class SnippetDTO { } /** - * The ids of the remote process groups in this snippet. These ids will be - * populated within each response. They can be specified when creating a - * snippet. However, once a snippet has been created its contents cannot be - * modified (these ids are ignored during update requests). - * - * @return + * @return the ids of the remote process groups in this snippet. These ids will be populated within each response. They can be specified when creating a snippet. However, once a snippet has been + * created its contents cannot be modified (these ids are ignored during update requests) */ + @ApiModelProperty( + value = "The ids of the remote process groups in this snippet. These ids will be populated within each response. They can be specified when creating a snippet. However, once a snippet " + + "has been created its contents cannot be modified (these ids are ignored during update requests)." + ) public Set getRemoteProcessGroups() { return remoteProcessGroups; } @@ -224,10 +231,11 @@ public class SnippetDTO { } /** - * The contents of the configuration for this snippet. - * - * @return + * @return the contents of the configuration for this snippet */ + @ApiModelProperty( + value = "The contents of the configuration for the snippet." + ) public FlowSnippetDTO getContents() { return contents; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/SystemDiagnosticsDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/SystemDiagnosticsDTO.java index 0b2085298f..d2a9d1a97a 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/SystemDiagnosticsDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/SystemDiagnosticsDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Date; import java.util.Set; import javax.xml.bind.annotation.XmlType; @@ -54,10 +55,11 @@ public class SystemDiagnosticsDTO { /* getters / setters */ /** - * The number of available processors, if supported. - * - * @return + * @return number of available processors, if supported */ + @ApiModelProperty( + value = "Number of available processors if supported by the underlying system." + ) public Integer getAvailableProcessors() { return availableProcessors; } @@ -67,10 +69,11 @@ public class SystemDiagnosticsDTO { } /** - * The number of daemon threads. - * - * @return + * @return number of daemon threads */ + @ApiModelProperty( + value = "Number of daemon threads." + ) public Integer getDaemonThreads() { return daemonThreads; } @@ -80,10 +83,11 @@ public class SystemDiagnosticsDTO { } /** - * The amount of free heap. - * - * @return + * @return amount of free heap */ + @ApiModelProperty( + value = "Amount of free heap." + ) public String getFreeHeap() { return freeHeap; } @@ -93,10 +97,11 @@ public class SystemDiagnosticsDTO { } /** - * The amount of free non-heap. - * - * @return + * @return amount of free non-heap */ + @ApiModelProperty( + value = "Amount of free non heap." + ) public String getFreeNonHeap() { return freeNonHeap; } @@ -106,10 +111,11 @@ public class SystemDiagnosticsDTO { } /** - * The max size of the heap. - * - * @return + * @return max size of the heap */ + @ApiModelProperty( + value = "Maximum size of heap." + ) public String getMaxHeap() { return maxHeap; } @@ -119,10 +125,11 @@ public class SystemDiagnosticsDTO { } /** - * The max size of the non-heap. - * - * @return + * @return max size of the non-heap */ + @ApiModelProperty( + value = "Maximum size of non heap." + ) public String getMaxNonHeap() { return maxNonHeap; } @@ -132,10 +139,11 @@ public class SystemDiagnosticsDTO { } /** - * The processor load average, if supported. - * - * @return + * @return processor load average, if supported */ + @ApiModelProperty( + value = "The processor load average if supported by the underlying system." + ) public Double getProcessorLoadAverage() { return processorLoadAverage; } @@ -145,10 +153,11 @@ public class SystemDiagnosticsDTO { } /** - * The total size of the heap. - * - * @return + * @return total size of the heap */ + @ApiModelProperty( + value = "Total size of heap." + ) public String getTotalHeap() { return totalHeap; } @@ -158,10 +167,11 @@ public class SystemDiagnosticsDTO { } /** - * The total size of non-heap. - * - * @return + * @return total size of non-heap */ + @ApiModelProperty( + value = "Total size of non heap." + ) public String getTotalNonHeap() { return totalNonHeap; } @@ -171,10 +181,11 @@ public class SystemDiagnosticsDTO { } /** - * The total number of threads. - * - * @return + * @return total number of threads */ + @ApiModelProperty( + value = "Total number of threads." + ) public Integer getTotalThreads() { return totalThreads; } @@ -184,10 +195,11 @@ public class SystemDiagnosticsDTO { } /** - * The amount of used heap. - * - * @return + * @return amount of used heap */ + @ApiModelProperty( + value = "Amount of used heap." + ) public String getUsedHeap() { return usedHeap; } @@ -197,10 +209,11 @@ public class SystemDiagnosticsDTO { } /** - * The amount of used non-heap. - * - * @return + * @return amount of used non-heap */ + @ApiModelProperty( + value = "Amount of use non heap." + ) public String getUsedNonHeap() { return usedNonHeap; } @@ -210,10 +223,11 @@ public class SystemDiagnosticsDTO { } /** - * The heap utilization. - * - * @return + * @return heap utilization */ + @ApiModelProperty( + value = "Utilization of heap." + ) public String getHeapUtilization() { return heapUtilization; } @@ -223,10 +237,11 @@ public class SystemDiagnosticsDTO { } /** - * The non-heap utilization. - * - * @return + * @return non-heap utilization */ + @ApiModelProperty( + value = "Utilization of non heap." + ) public String getNonHeapUtilization() { return nonHeapUtilization; } @@ -236,10 +251,11 @@ public class SystemDiagnosticsDTO { } /** - * The content repository storage usage. - * - * @return + * @return content repository storage usage */ + @ApiModelProperty( + value = "The content repository storage usage." + ) public Set getContentRepositoryStorageUsage() { return contentRepositoryStorageUsage; } @@ -249,10 +265,11 @@ public class SystemDiagnosticsDTO { } /** - * The flowfile repository storage usage. - * - * @return + * @return flowfile repository storage usage */ + @ApiModelProperty( + value = "The flowfile repository storage usage." + ) public StorageUsageDTO getFlowFileRepositoryStorageUsage() { return flowFileRepositoryStorageUsage; } @@ -262,10 +279,11 @@ public class SystemDiagnosticsDTO { } /** - * Garbage collection details. - * - * @return + * @return Garbage collection details */ + @ApiModelProperty( + value = "The garbage collection details." + ) public Set getGarbageCollection() { return garbageCollection; } @@ -275,11 +293,12 @@ public class SystemDiagnosticsDTO { } /** - * When these diagnostics were generated. - * - * @return + * @return When these diagnostics were generated */ @XmlJavaTypeAdapter(TimeAdapter.class) + @ApiModelProperty( + value = "When the diagnostics were generated." + ) public Date getStatsLastRefreshed() { return statsLastRefreshed; } @@ -304,10 +323,11 @@ public class SystemDiagnosticsDTO { private String utilization; /** - * The identifier for this storage location. - * - * @return + * @return identifier for this storage location */ + @ApiModelProperty( + value = "The identifier of this storage location. The identifier will correspond to the identifier keyed in the storage configuration." + ) public String getIdentifier() { return identifier; } @@ -317,10 +337,11 @@ public class SystemDiagnosticsDTO { } /** - * The amount of free space. - * - * @return + * @return amount of free space */ + @ApiModelProperty( + value = "Amount of free space." + ) public String getFreeSpace() { return freeSpace; } @@ -330,10 +351,11 @@ public class SystemDiagnosticsDTO { } /** - * The amount of total space. - * - * @param freeSpace + * @return freeSpace amount of total space */ + @ApiModelProperty( + value = "Amount of total space." + ) public String getTotalSpace() { return totalSpace; } @@ -343,10 +365,11 @@ public class SystemDiagnosticsDTO { } /** - * The amount of used space. - * - * @return + * @return amount of used space */ + @ApiModelProperty( + value = "Amount of used space." + ) public String getUsedSpace() { return usedSpace; } @@ -356,10 +379,11 @@ public class SystemDiagnosticsDTO { } /** - * The utilization of this storage location. - * - * @return + * @return utilization of this storage location */ + @ApiModelProperty( + value = "Utilization of this storage location." + ) public String getUtilization() { return utilization; } @@ -369,10 +393,11 @@ public class SystemDiagnosticsDTO { } /** - * The number of bytes of free space. - * - * @return + * @return number of bytes of free space */ + @ApiModelProperty( + value = "The number of bytes of free space." + ) public Long getFreeSpaceBytes() { return freeSpaceBytes; } @@ -382,10 +407,11 @@ public class SystemDiagnosticsDTO { } /** - * The number of bytes of total space. - * - * @return + * @return number of bytes of total space */ + @ApiModelProperty( + value = "The number of bytes of total space." + ) public Long getTotalSpaceBytes() { return totalSpaceBytes; } @@ -395,10 +421,11 @@ public class SystemDiagnosticsDTO { } /** - * The number of bytes of used space. - * - * @return + * @return number of bytes of used space */ + @ApiModelProperty( + value = "The number of bytes of used space." + ) public Long getUsedSpaceBytes() { return usedSpaceBytes; } @@ -419,10 +446,11 @@ public class SystemDiagnosticsDTO { private String collectionTime; /** - * The name of the garbage collector. - * - * @return + * @return name of the garbage collector */ + @ApiModelProperty( + value = "The name of the garbage collector." + ) public String getName() { return name; } @@ -431,24 +459,26 @@ public class SystemDiagnosticsDTO { this.name = name; } + @ApiModelProperty( + value = "The number of times garbage collection has run." + ) public long getCollectionCount() { return collectionCount; } /** - * The number of times garbage collection has run. - * - * @param collectionCount + * @param collectionCount number of times garbage collection has run */ public void setCollectionCount(long collectionCount) { this.collectionCount = collectionCount; } /** - * The total amount of time spent garbage collecting. - * - * @return + * @return total amount of time spent garbage collecting */ + @ApiModelProperty( + value = "The total amount of time spent garbage collecting." + ) public String getCollectionTime() { return collectionTime; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/TemplateDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/TemplateDTO.java index 156a6e9382..6fa9dafc51 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/TemplateDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/TemplateDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Date; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; @@ -37,10 +38,11 @@ public class TemplateDTO { private FlowSnippetDTO snippet; /** - * The id for this template. - * - * @return + * @return id for this template */ + @ApiModelProperty( + value = "The id of the template." + ) public String getId() { return id; } @@ -50,10 +52,11 @@ public class TemplateDTO { } /** - * The uri for this template. - * - * @return + * @return uri for this template */ + @ApiModelProperty( + value = "The URI for the template." + ) public String getUri() { return uri; } @@ -63,10 +66,11 @@ public class TemplateDTO { } /** - * The name of this template. - * - * @return + * @return name of this template */ + @ApiModelProperty( + value = "The name of the template." + ) public String getName() { return name; } @@ -76,10 +80,11 @@ public class TemplateDTO { } /** - * The description of this template. - * - * @return + * @return description of this template */ + @ApiModelProperty( + value = "The description of the template." + ) public String getDescription() { return description; } @@ -89,11 +94,12 @@ public class TemplateDTO { } /** - * The timestamp when this template was created. - * - * @return + * @return timestamp when this template was created */ @XmlJavaTypeAdapter(DateTimeAdapter.class) + @ApiModelProperty( + value = "The timestamp when this template was created." + ) public Date getTimestamp() { return timestamp; } @@ -103,10 +109,11 @@ public class TemplateDTO { } /** - * The snippet in this template. - * - * @return + * @return snippet in this template */ + @ApiModelProperty( + value = "The contents of the template." + ) public FlowSnippetDTO getSnippet() { return snippet; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/UserDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/UserDTO.java index 85c82dc3a0..3344306171 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/UserDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/UserDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Date; import java.util.Set; import javax.xml.bind.annotation.XmlType; @@ -41,10 +42,11 @@ public class UserDTO { private Set authorities; /** - * The user id. - * - * @return + * @return user id */ + @ApiModelProperty( + value = "The id of the user." + ) public String getId() { return id; } @@ -54,10 +56,11 @@ public class UserDTO { } /** - * The users authorities. - * - * @return + * @return users authorities */ + @ApiModelProperty( + value = "The users authorities." + ) public Set getAuthorities() { return authorities; } @@ -67,11 +70,12 @@ public class UserDTO { } /** - * The creation time for this users account. - * - * @return + * @return creation time for this users account */ @XmlJavaTypeAdapter(DateTimeAdapter.class) + @ApiModelProperty( + value = "The timestamp when the user was created." + ) public Date getCreation() { return creation; } @@ -81,10 +85,11 @@ public class UserDTO { } /** - * The users DN. - * - * @return + * @return users DN */ + @ApiModelProperty( + value = "The dn of the user." + ) public String getDn() { return dn; } @@ -94,11 +99,11 @@ public class UserDTO { } /** - * The users name. If the name could not be extracted from the DN, this - * value will be the entire DN. - * - * @return + * @return users name. If the name could not be extracted from the DN, this value will be the entire DN */ + @ApiModelProperty( + value = "The username. If it could not be extracted from the DN, this value will be the entire DN." + ) public String getUserName() { return userName; } @@ -108,10 +113,11 @@ public class UserDTO { } /** - * The user group. - * - * @return + * @return user group */ + @ApiModelProperty( + value = "The group this user belongs to." + ) public String getUserGroup() { return userGroup; } @@ -121,10 +127,11 @@ public class UserDTO { } /** - * The users account justification. - * - * @return + * @return users account justification */ + @ApiModelProperty( + value = "The justification for the user account." + ) public String getJustification() { return justification; } @@ -134,11 +141,12 @@ public class UserDTO { } /** - * The time that the user last accessed the system. - * - * @return + * @return time that the user last accessed the system */ @XmlJavaTypeAdapter(DateTimeAdapter.class) + @ApiModelProperty( + value = "The timestamp the user last accessed the system." + ) public Date getLastAccessed() { return lastAccessed; } @@ -148,11 +156,12 @@ public class UserDTO { } /** - * The time that the users credentials were last verified. - * - * @return + * @return time that the users credentials were last verified */ @XmlJavaTypeAdapter(DateTimeAdapter.class) + @ApiModelProperty( + value = "The timestamp the user authorities were verified." + ) public Date getLastVerified() { return lastVerified; } @@ -162,10 +171,11 @@ public class UserDTO { } /** - * The status of the users account. - * - * @return + * @return status of the users account */ + @ApiModelProperty( + value = "The user status." + ) public String getStatus() { return status; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/UserGroupDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/UserGroupDTO.java index 285c355841..8f6a3a1463 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/UserGroupDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/UserGroupDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Set; import javax.xml.bind.annotation.XmlType; @@ -31,10 +32,11 @@ public class UserGroupDTO { private String status; /** - * The user group. - * - * @return + * @return user group */ + @ApiModelProperty( + value = "The user group." + ) public String getGroup() { return group; } @@ -44,10 +46,11 @@ public class UserGroupDTO { } /** - * The users in this group. - * - * @return + * @return users in this group */ + @ApiModelProperty( + value = "The users that belong to the group." + ) public Set getUserIds() { return userIds; } @@ -57,10 +60,11 @@ public class UserGroupDTO { } /** - * The status of the users account. - * - * @return + * @return status of the users account */ + @ApiModelProperty( + value = "The status of the users accounts." + ) public String getStatus() { return status; } @@ -70,10 +74,11 @@ public class UserGroupDTO { } /** - * The users authorities. - * - * @return + * @return users authorities */ + @ApiModelProperty( + value = "The authorities of the users." + ) public Set getAuthorities() { return authorities; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/ActionDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/ActionDTO.java index 84024801f2..d4dea38765 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/ActionDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/ActionDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.action; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Date; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; @@ -43,10 +44,11 @@ public class ActionDTO { private ActionDetailsDTO actionDetails; /** - * The action id. - * - * @return + * @return action id */ + @ApiModelProperty( + value = "The action id." + ) public Integer getId() { return id; } @@ -56,10 +58,11 @@ public class ActionDTO { } /** - * The user dn who perform this action. - * - * @return + * @return user dn who perform this action */ + @ApiModelProperty( + value = "The dn of the user that performed the action." + ) public String getUserDn() { return userDn; } @@ -69,10 +72,11 @@ public class ActionDTO { } /** - * The user name who perform this action. - * - * @return + * @return user name who perform this action */ + @ApiModelProperty( + value = "The name of the user that performed the action." + ) public String getUserName() { return userName; } @@ -82,11 +86,12 @@ public class ActionDTO { } /** - * This action's timestamp. - * - * @return + * @return action's timestamp */ @XmlJavaTypeAdapter(DateTimeAdapter.class) + @ApiModelProperty( + value = "The timestamp of the action." + ) public Date getTimestamp() { return timestamp; } @@ -96,10 +101,11 @@ public class ActionDTO { } /** - * The id of the source component of this action. - * - * @return + * @return id of the source component of this action */ + @ApiModelProperty( + value = "The id of the source component." + ) public String getSourceId() { return sourceId; } @@ -109,10 +115,11 @@ public class ActionDTO { } /** - * The name of the source component of this action. - * - * @return + * @return name of the source component of this action */ + @ApiModelProperty( + value = "The name of the source component." + ) public String getSourceName() { return sourceName; } @@ -122,10 +129,11 @@ public class ActionDTO { } /** - * The type of the source component of this action. - * - * @return + * @return type of the source component of this action */ + @ApiModelProperty( + value = "The type of the source component." + ) public String getSourceType() { return sourceType; } @@ -135,10 +143,11 @@ public class ActionDTO { } /** - * The component details (if any) for this action. - * - * @return + * @return component details (if any) for this action */ + @ApiModelProperty( + value = "The details of the source component." + ) public ComponentDetailsDTO getComponentDetails() { return componentDetails; } @@ -148,10 +157,11 @@ public class ActionDTO { } /** - * The operation being performed in this action. - * - * @return + * @return operation being performed in this action */ + @ApiModelProperty( + value = "The operation that was performed." + ) public String getOperation() { return operation; } @@ -161,10 +171,11 @@ public class ActionDTO { } /** - * The action details (if any) for this action. - * - * @return + * @return action details (if any) for this action */ + @ApiModelProperty( + value = "The details of the action." + ) public ActionDetailsDTO getActionDetails() { return actionDetails; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/HistoryDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/HistoryDTO.java index 9ab47ed566..597ef0b8a6 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/HistoryDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/HistoryDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.action; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Collection; import java.util.Date; import javax.xml.bind.annotation.XmlType; @@ -33,10 +34,11 @@ public class HistoryDTO { private Collection actions; /** - * The total number of actions. - * - * @return + * @return total number of actions */ + @ApiModelProperty( + value = "The number of number of actions that matched the search criteria.." + ) public Integer getTotal() { return total; } @@ -46,11 +48,12 @@ public class HistoryDTO { } /** - * Timestamp when these records were returned. - * - * @return + * @return timestamp when these records were returned */ @XmlJavaTypeAdapter(TimeAdapter.class) + @ApiModelProperty( + value = "The timestamp when the report was generated." + ) public Date getLastRefreshed() { return lastRefreshed; } @@ -60,10 +63,11 @@ public class HistoryDTO { } /** - * The actions for this range. - * - * @return + * @return actions for this range */ + @ApiModelProperty( + value = "The actions." + ) public Collection getActions() { return actions; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/HistoryQueryDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/HistoryQueryDTO.java index e8e11e5a05..7d4d21d61a 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/HistoryQueryDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/HistoryQueryDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.action; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Date; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; @@ -37,10 +38,11 @@ public class HistoryQueryDTO { private String sortOrder; /** - * The user name. - * - * @return + * @return user name */ + @ApiModelProperty( + value = "The name of the source component." + ) public String getUserName() { return userName; } @@ -50,10 +52,11 @@ public class HistoryQueryDTO { } /** - * The source component id. - * - * @return + * @return source component id */ + @ApiModelProperty( + value = "The id of the source component." + ) public String getSourceId() { return sourceId; } @@ -63,11 +66,12 @@ public class HistoryQueryDTO { } /** - * The start date. - * - * @return + * @return start date */ @XmlJavaTypeAdapter(DateTimeAdapter.class) + @ApiModelProperty( + value = "The start date of actions to return." + ) public Date getStartDate() { return startDate; } @@ -77,11 +81,12 @@ public class HistoryQueryDTO { } /** - * The end date. - * - * @return + * @return end date */ @XmlJavaTypeAdapter(DateTimeAdapter.class) + @ApiModelProperty( + value = "The end date of actions to return." + ) public Date getEndDate() { return endDate; } @@ -91,10 +96,11 @@ public class HistoryQueryDTO { } /** - * The offset. - * - * @return + * @return offset */ + @ApiModelProperty( + value = "The offset into the result set." + ) public Integer getOffset() { return offset; } @@ -104,10 +110,11 @@ public class HistoryQueryDTO { } /** - * The desired row count. - * - * @return + * @return desired row count */ + @ApiModelProperty( + value = "The number of actions to return." + ) public Integer getCount() { return count; } @@ -117,10 +124,11 @@ public class HistoryQueryDTO { } /** - * The desired sort column. - * - * @return + * @return desired sort column */ + @ApiModelProperty( + value = "The field to sort on." + ) public String getSortColumn() { return sortColumn; } @@ -130,10 +138,11 @@ public class HistoryQueryDTO { } /** - * The desired sort order. - * - * @return + * @return desired sort order */ + @ApiModelProperty( + value = "The sort order." + ) public String getSortOrder() { return sortOrder; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/component/details/ExtensionDetailsDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/component/details/ExtensionDetailsDTO.java index e2e49d67a2..81f87c1766 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/component/details/ExtensionDetailsDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/component/details/ExtensionDetailsDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.action.component.details; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -27,10 +28,11 @@ public class ExtensionDetailsDTO extends ComponentDetailsDTO { private String type; /** - * The extension type. - * - * @return + * @return extension type */ + @ApiModelProperty( + value = "The fully qualified type of extension." + ) public String getType() { return type; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/component/details/RemoteProcessGroupDetailsDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/component/details/RemoteProcessGroupDetailsDTO.java index 280939808d..0d0bc06d40 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/component/details/RemoteProcessGroupDetailsDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/component/details/RemoteProcessGroupDetailsDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.action.component.details; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -27,10 +28,11 @@ public class RemoteProcessGroupDetailsDTO extends ComponentDetailsDTO { private String uri; /** - * The URI of the remote process group. - * - * @return + * @return URI of the remote process group */ + @ApiModelProperty( + value = "The uri of the target of the remote process group." + ) public String getUri() { return uri; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/details/ConfigureDetailsDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/details/ConfigureDetailsDTO.java index 4011b007b6..7b79bd09de 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/details/ConfigureDetailsDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/details/ConfigureDetailsDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.action.details; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -29,10 +30,11 @@ public class ConfigureDetailsDTO extends ActionDetailsDTO { private String value; /** - * The name of the property that was modified. - * - * @return + * @return name of the property that was modified */ + @ApiModelProperty( + value = "The name of the property that was modified." + ) public String getName() { return name; } @@ -42,10 +44,11 @@ public class ConfigureDetailsDTO extends ActionDetailsDTO { } /** - * The previous value. - * - * @return + * @return previous value */ + @ApiModelProperty( + value = "The previous value." + ) public String getPreviousValue() { return previousValue; } @@ -55,10 +58,11 @@ public class ConfigureDetailsDTO extends ActionDetailsDTO { } /** - * The new value. - * - * @return + * @return new value */ + @ApiModelProperty( + value = "The new value." + ) public String getValue() { return value; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/details/ConnectDetailsDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/details/ConnectDetailsDTO.java index ba88bd10da..db2804ff98 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/details/ConnectDetailsDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/details/ConnectDetailsDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.action.details; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -33,10 +34,11 @@ public class ConnectDetailsDTO extends ActionDetailsDTO { private String destinationType; /** - * The id of the source of the connection. - * - * @return + * @return id of the source of the connection */ + @ApiModelProperty( + value = "The id of the source of the connection." + ) public String getSourceId() { return sourceId; } @@ -46,10 +48,11 @@ public class ConnectDetailsDTO extends ActionDetailsDTO { } /** - * The name of the source of the connection. - * - * @return + * @return name of the source of the connection */ + @ApiModelProperty( + value = "The name of the source of the connection." + ) public String getSourceName() { return sourceName; } @@ -59,10 +62,11 @@ public class ConnectDetailsDTO extends ActionDetailsDTO { } /** - * The type of the source of the connection. - * - * @return + * @return type of the source of the connection */ + @ApiModelProperty( + value = "The type of the source of the connection." + ) public String getSourceType() { return sourceType; } @@ -72,10 +76,11 @@ public class ConnectDetailsDTO extends ActionDetailsDTO { } /** - * The name of the relationship that was connected. - * - * @return + * @return name of the relationship that was connected */ + @ApiModelProperty( + value = "The name of the relationship that was connected." + ) public String getRelationship() { return relationship; } @@ -85,10 +90,11 @@ public class ConnectDetailsDTO extends ActionDetailsDTO { } /** - * The id of the destination of the connection. - * - * @return + * @return id of the destination of the connection */ + @ApiModelProperty( + value = "The id of the destination of the connection." + ) public String getDestinationId() { return destinationId; } @@ -98,10 +104,11 @@ public class ConnectDetailsDTO extends ActionDetailsDTO { } /** - * The name of the destination of the connection. - * - * @return + * @return name of the destination of the connection */ + @ApiModelProperty( + value = "The name of the destination of the connection." + ) public String getDestinationName() { return destinationName; } @@ -111,10 +118,11 @@ public class ConnectDetailsDTO extends ActionDetailsDTO { } /** - * The type of the destination of the connection. - * - * @return + * @return type of the destination of the connection */ + @ApiModelProperty( + value = "The type of the destination of the connection." + ) public String getDestinationType() { return destinationType; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/details/MoveDetailsDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/details/MoveDetailsDTO.java index c6f04509d6..f6984a87e7 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/details/MoveDetailsDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/details/MoveDetailsDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.action.details; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -30,10 +31,11 @@ public class MoveDetailsDTO extends ActionDetailsDTO { private String group; /** - * The id of the group the components previously belonged to. - * - * @return + * @return id of the group the components previously belonged to */ + @ApiModelProperty( + value = "The id of the group the components previously belonged to." + ) public String getPreviousGroupId() { return previousGroupId; } @@ -43,10 +45,11 @@ public class MoveDetailsDTO extends ActionDetailsDTO { } /** - * The name of the group of the components previously belonged to. - * - * @return + * @return name of the group of the components previously belonged to */ + @ApiModelProperty( + value = "The name of the group the components previously belonged to." + ) public String getPreviousGroup() { return previousGroup; } @@ -56,10 +59,11 @@ public class MoveDetailsDTO extends ActionDetailsDTO { } /** - * The id of the group the components belong to. - * - * @return + * @return id of the group the components belong to */ + @ApiModelProperty( + value = "The id of the group that components belong to." + ) public String getGroupId() { return groupId; } @@ -69,10 +73,11 @@ public class MoveDetailsDTO extends ActionDetailsDTO { } /** - * The name of the group the components belong to. - * - * @return + * @return name of the group the components belong to */ + @ApiModelProperty( + value = "The name of the group the components belong to." + ) public String getGroup() { return group; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/details/PurgeDetailsDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/details/PurgeDetailsDTO.java index b5a5bcbadf..b83e91d6b3 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/details/PurgeDetailsDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/action/details/PurgeDetailsDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.action.details; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Date; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; @@ -30,11 +31,12 @@ public class PurgeDetailsDTO extends ActionDetailsDTO { private Date endDate; /** - * The end date for this purge action. - * - * @return + * @return end date for this purge action */ @XmlJavaTypeAdapter(DateTimeAdapter.class) + @ApiModelProperty( + value = "The end date for the purge action." + ) public Date getEndDate() { return endDate; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/AttributeDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/AttributeDTO.java index ed5807799c..8228ac3ee6 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/AttributeDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/AttributeDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.provenance; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -29,10 +30,11 @@ public class AttributeDTO { private String previousValue; /** - * The attribute name. - * - * @return + * @return attribute name */ + @ApiModelProperty( + value = "The attribute name." + ) public String getName() { return name; } @@ -42,10 +44,11 @@ public class AttributeDTO { } /** - * The attribute value. - * - * @return + * @return attribute value */ + @ApiModelProperty( + value = "The attribute value." + ) public String getValue() { return value; } @@ -55,10 +58,11 @@ public class AttributeDTO { } /** - * The value of this attribute before the event took place. - * - * @return + * @return value of this attribute before the event took place */ + @ApiModelProperty( + value = "The value of the attribute before the event took place." + ) public String getPreviousValue() { return previousValue; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceDTO.java index 90dd119dca..e755581e0d 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.provenance; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Date; import javax.xml.bind.annotation.XmlType; @@ -24,8 +25,7 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.apache.nifi.web.api.dto.util.TimestampAdapter; /** - * A provenance submission. Incorporates the request, its current status, and - * the results. + * A provenance submission. Incorporates the request, its current status, and the results. */ @XmlType(name = "provenance") public class ProvenanceDTO { @@ -44,10 +44,11 @@ public class ProvenanceDTO { private ProvenanceResultsDTO results; /** - * The id of this provenance query. - * - * @return + * @return id of this provenance query */ + @ApiModelProperty( + value = "The id of the provenance query." + ) public String getId() { return id; } @@ -57,10 +58,11 @@ public class ProvenanceDTO { } /** - * The URI for this query. Used for obtaining the requests at a later time. - * - * @return + * @return URI for this query. Used for obtaining the requests at a later time */ + @ApiModelProperty( + value = "The URI for this query. Used for obtaining/deleting the request at a later time" + ) public String getUri() { return uri; } @@ -70,10 +72,11 @@ public class ProvenanceDTO { } /** - * The id of the node in the cluster where this provenance originated. - * - * @return + * @return id of the node in the cluster where this provenance originated */ + @ApiModelProperty( + value = "The id of the node in the cluster where this provenance originated." + ) public String getClusterNodeId() { return clusterNodeId; } @@ -83,11 +86,12 @@ public class ProvenanceDTO { } /** - * The time the query was submitted. - * - * @return + * @return time the query was submitted */ @XmlJavaTypeAdapter(TimestampAdapter.class) + @ApiModelProperty( + value = "The timestamp when the query was submitted." + ) public Date getSubmissionTime() { return submissionTime; } @@ -97,11 +101,12 @@ public class ProvenanceDTO { } /** - * The expiration time of the query results. - * - * @return + * @return expiration time of the query results */ @XmlJavaTypeAdapter(TimestampAdapter.class) + @ApiModelProperty( + value = "The timestamp when the query will expire." + ) public Date getExpiration() { return expiration; } @@ -111,10 +116,11 @@ public class ProvenanceDTO { } /** - * The percent completed. - * - * @return + * @return percent completed */ + @ApiModelProperty( + value = "The current percent complete." + ) public Integer getPercentCompleted() { return percentCompleted; } @@ -124,10 +130,11 @@ public class ProvenanceDTO { } /** - * Whether the query has finished. - * - * @return + * @return whether the query has finished */ + @ApiModelProperty( + value = "Whether the query has finished." + ) public Boolean isFinished() { return finished; } @@ -137,10 +144,11 @@ public class ProvenanceDTO { } /** - * The provenance request. - * - * @return + * @return provenance request */ + @ApiModelProperty( + value = "The provenance request." + ) public ProvenanceRequestDTO getRequest() { return request; } @@ -150,10 +158,11 @@ public class ProvenanceDTO { } /** - * The results of this query. - * - * @return + * @return results of this query */ + @ApiModelProperty( + value = "The provenance results." + ) public ProvenanceResultsDTO getResults() { return results; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceEventDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceEventDTO.java index b1ead42c65..dcc14619e1 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceEventDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceEventDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.provenance; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Collection; import java.util.Date; import java.util.List; @@ -83,10 +84,11 @@ public class ProvenanceEventDTO { private String sourceConnectionIdentifier; /** - * The event uuid. - * - * @return + * @return event uuid */ + @ApiModelProperty( + value = "The event uuid." + ) public String getId() { return id; } @@ -96,10 +98,11 @@ public class ProvenanceEventDTO { } /** - * The event id. - * - * @return + * @return event id */ + @ApiModelProperty( + value = "The event id. This is a one up number thats unique per node." + ) public Long getEventId() { return eventId; } @@ -109,11 +112,12 @@ public class ProvenanceEventDTO { } /** - * The time the event occurred. - * - * @return + * @return time the event occurred */ @XmlJavaTypeAdapter(TimestampAdapter.class) + @ApiModelProperty( + value = "The timestamp of the event." + ) public Date getEventTime() { return eventTime; } @@ -123,10 +127,11 @@ public class ProvenanceEventDTO { } /** - * The UUID of the FlowFile for this event. - * - * @return + * @return UUID of the FlowFile for this event */ + @ApiModelProperty( + value = "The uuid of the flowfile for the event." + ) public String getFlowFileUuid() { return flowFileUuid; } @@ -136,10 +141,11 @@ public class ProvenanceEventDTO { } /** - * The size of the FlowFile for this event. - * - * @return + * @return size of the FlowFile for this event */ + @ApiModelProperty( + value = "The size of the flowfile for the event." + ) public String getFileSize() { return fileSize; } @@ -149,10 +155,11 @@ public class ProvenanceEventDTO { } /** - * The size of the FlowFile in bytes for this event. - * - * @return + * @return size of the FlowFile in bytes for this event */ + @ApiModelProperty( + value = "The size of the flowfile in bytes for the event." + ) public Long getFileSizeBytes() { return fileSizeBytes; } @@ -162,10 +169,11 @@ public class ProvenanceEventDTO { } /** - * The type of this event. - * - * @return + * @return type of this event */ + @ApiModelProperty( + value = "The type of the event." + ) public String getEventType() { return eventType; } @@ -175,10 +183,11 @@ public class ProvenanceEventDTO { } /** - * The attributes for the FlowFile for this event. - * - * @return + * @return attributes for the FlowFile for this event */ + @ApiModelProperty( + value = "The attributes of the flowfile for the event." + ) public Collection getAttributes() { return attributes; } @@ -188,11 +197,11 @@ public class ProvenanceEventDTO { } /** - * The id of the group that this component resides in. If the component is - * no longer in the flow, the group id will not be set. - * - * @return + * @return id of the group that this component resides in. If the component is no longer in the flow, the group id will not be set */ + @ApiModelProperty( + value = "The id of the group that the component resides in. If the component is no longer in the flow, the group id will not be set." + ) public String getGroupId() { return groupId; } @@ -202,10 +211,11 @@ public class ProvenanceEventDTO { } /** - * The id of the component that generated this event. - * - * @return + * @return id of the component that generated this event */ + @ApiModelProperty( + value = "The id of the component that generated the event." + ) public String getComponentId() { return componentId; } @@ -215,10 +225,11 @@ public class ProvenanceEventDTO { } /** - * The name of the component that generated this event. - * - * @return + * @return name of the component that generated this event */ + @ApiModelProperty( + value = "The name of the component that generated the event." + ) public String getComponentName() { return componentName; } @@ -228,10 +239,11 @@ public class ProvenanceEventDTO { } /** - * The type of the component that generated this event. - * - * @return + * @return type of the component that generated this event */ + @ApiModelProperty( + value = "The type of the component that generated the event." + ) public String getComponentType() { return componentType; } @@ -241,10 +253,11 @@ public class ProvenanceEventDTO { } /** - * The source/destination system URI if the event was a RECEIVE/SEND. - * - * @return + * @return source/destination system URI if the event was a RECEIVE/SEND */ + @ApiModelProperty( + value = "The source/destination system uri if the event was a RECEIVE/SEND." + ) public String getTransitUri() { return transitUri; } @@ -254,10 +267,11 @@ public class ProvenanceEventDTO { } /** - * The alternate identifier URI for the FlowFile for this event. - * - * @return + * @return alternate identifier URI for the FlowFile for this event */ + @ApiModelProperty( + value = "The alternate identifier uri for the fileflow for the event." + ) public String getAlternateIdentifierUri() { return alternateIdentifierUri; } @@ -267,10 +281,11 @@ public class ProvenanceEventDTO { } /** - * The identifier of the node where this event originated. - * - * @return + * @return identifier of the node where this event originated */ + @ApiModelProperty( + value = "The identifier for the node where the event originated." + ) public String getClusterNodeId() { return clusterNodeId; } @@ -280,10 +295,11 @@ public class ProvenanceEventDTO { } /** - * The label to use to show which node this event originated from. - * - * @return + * @return label to use to show which node this event originated from */ + @ApiModelProperty( + value = "The label for the node where the event originated." + ) public String getClusterNodeAddress() { return clusterNodeAddress; } @@ -293,10 +309,11 @@ public class ProvenanceEventDTO { } /** - * The parent uuids for this event. - * - * @return + * @return parent uuids for this event */ + @ApiModelProperty( + value = "The parent uuids for the event." + ) public List getParentUuids() { return parentUuids; } @@ -306,10 +323,11 @@ public class ProvenanceEventDTO { } /** - * The child uuids for this event. - * - * @return + * @return child uuids for this event */ + @ApiModelProperty( + value = "The child uuids for the event." + ) public List getChildUuids() { return childUuids; } @@ -319,10 +337,11 @@ public class ProvenanceEventDTO { } /** - * The duration of the event, in milliseconds. - * - * @return + * @return duration of the event, in milliseconds */ + @ApiModelProperty( + value = "The event duration in milliseconds." + ) public Long getEventDuration() { return eventDuration; } @@ -332,10 +351,11 @@ public class ProvenanceEventDTO { } /** - * The duration since the lineage began, in milliseconds. - * - * @return + * @return duration since the lineage began, in milliseconds */ + @ApiModelProperty( + value = "The duration since the lineage began, in milliseconds." + ) public Long getLineageDuration() { return lineageDuration; } @@ -345,10 +365,11 @@ public class ProvenanceEventDTO { } /** - * The source system FlowFile id. - * - * @return + * @return source system FlowFile id */ + @ApiModelProperty( + value = "The source system flowfile id." + ) public String getSourceSystemFlowFileId() { return sourceSystemFlowFileId; } @@ -358,11 +379,11 @@ public class ProvenanceEventDTO { } /** - * If this represents a route event, this is the relationship to which the - * flowfile was routed. - * - * @return + * @return If this represents a route event, this is the relationship to which the flowfile was routed */ + @ApiModelProperty( + value = "The relationship to which the flowfile was routed if the event is of type ROUTE." + ) public String getRelationship() { return relationship; } @@ -372,10 +393,11 @@ public class ProvenanceEventDTO { } /** - * The event details. - * - * @return + * @return event details */ + @ApiModelProperty( + value = "The event details." + ) public String getDetails() { return details; } @@ -385,10 +407,11 @@ public class ProvenanceEventDTO { } /** - * Whether or not the input and output content claim is the same. - * - * @return + * @return whether or not the input and output content claim is the same */ + @ApiModelProperty( + value = "Whether the input and output content claim is the same." + ) public Boolean getContentEqual() { return contentEqual; } @@ -398,10 +421,11 @@ public class ProvenanceEventDTO { } /** - * Returns whether or not the output content is still available. - * - * @return + * @return whether or not the output content is still available */ + @ApiModelProperty( + value = "Whether the output content is still available." + ) public Boolean getOutputContentAvailable() { return outputContentAvailable; } @@ -411,11 +435,11 @@ public class ProvenanceEventDTO { } /** - * Returns the Section in which the output Content Claim lives, or - * null if no Content Claim exists. - * - * @return + * @return the Section in which the output Content Claim lives, or null if no Content Claim exists */ + @ApiModelProperty( + value = "The section in which the output content claim lives." + ) public String getOutputContentClaimSection() { return outputContentClaimSection; } @@ -425,11 +449,11 @@ public class ProvenanceEventDTO { } /** - * Returns the Container in which the output Content Claim lives, or - * null if no Content Claim exists. - * - * @return + * @return the Container in which the output Content Claim lives, or null if no Content Claim exists */ + @ApiModelProperty( + value = "The container in which the output content claim lives." + ) public String getOutputContentClaimContainer() { return outputContentClaimContainer; } @@ -439,11 +463,11 @@ public class ProvenanceEventDTO { } /** - * Returns the Identifier of the output Content Claim, or null - * if no Content Claim exists. - * - * @return + * @return the Identifier of the output Content Claim, or null if no Content Claim exists */ + @ApiModelProperty( + value = "The identifier of the output content claim." + ) public String getOutputContentClaimIdentifier() { return outputContentClaimIdentifier; } @@ -453,11 +477,11 @@ public class ProvenanceEventDTO { } /** - * Returns the offset into the the output Content Claim where the FlowFile's - * content begins, or null if no Content Claim exists. - * - * @return + * @return the offset into the the output Content Claim where the FlowFile's content begins, or null if no Content Claim exists */ + @ApiModelProperty( + value = "The offset into the output content claim where the flowfiles content begins." + ) public Long getOutputContentClaimOffset() { return outputContentClaimOffset; } @@ -467,10 +491,11 @@ public class ProvenanceEventDTO { } /** - * Returns the formatted file size of the input content claim. - * - * @return + * @return the formatted file size of the input content claim */ + @ApiModelProperty( + value = "The file size of the output content claim formatted." + ) public String getOutputContentClaimFileSize() { return outputContentClaimFileSize; } @@ -480,10 +505,11 @@ public class ProvenanceEventDTO { } /** - * Returns the number of bytes of the input content claim. - * - * @return + * @return the number of bytes of the input content claim */ + @ApiModelProperty( + value = "The file size of the output content claim in bytes." + ) public Long getOutputContentClaimFileSizeBytes() { return outputContentClaimFileSizeBytes; } @@ -493,10 +519,11 @@ public class ProvenanceEventDTO { } /** - * Returns whether or not the input content is still available. - * - * @return + * @return whether or not the input content is still available */ + @ApiModelProperty( + value = "Whether the input content is still available." + ) public Boolean getInputContentAvailable() { return inputContentAvailable; } @@ -506,11 +533,11 @@ public class ProvenanceEventDTO { } /** - * Returns the Section in which the input Content Claim lives, or - * null if no Content Claim exists. - * - * @return + * @return the Section in which the input Content Claim lives, or null if no Content Claim exists */ + @ApiModelProperty( + value = "The section in which the input content claim lives." + ) public String getInputContentClaimSection() { return inputContentClaimSection; } @@ -520,11 +547,11 @@ public class ProvenanceEventDTO { } /** - * Returns the Container in which the input Content Claim lives, or - * null if no Content Claim exists. - * - * @return + * @return the Container in which the input Content Claim lives, or null if no Content Claim exists */ + @ApiModelProperty( + value = "The container in which the input content claim lives." + ) public String getInputContentClaimContainer() { return inputContentClaimContainer; } @@ -534,11 +561,11 @@ public class ProvenanceEventDTO { } /** - * Returns the Identifier of the input Content Claim, or null - * if no Content Claim exists. - * - * @return + * @return the Identifier of the input Content Claim, or null if no Content Claim exists */ + @ApiModelProperty( + value = "The identifier of the input content claim." + ) public String getInputContentClaimIdentifier() { return inputContentClaimIdentifier; } @@ -548,11 +575,11 @@ public class ProvenanceEventDTO { } /** - * Returns the offset into the the input Content Claim where the FlowFile's - * content begins, or null if no Content Claim exists. - * - * @return + * @return the offset into the the input Content Claim where the FlowFile's content begins, or null if no Content Claim exists */ + @ApiModelProperty( + value = "The offset into the input content claim where the flowfiles content begins." + ) public Long getInputContentClaimOffset() { return inputContentClaimOffset; } @@ -562,10 +589,11 @@ public class ProvenanceEventDTO { } /** - * Returns the formatted file size of the input content claim. - * - * @return + * @return the formatted file size of the input content claim */ + @ApiModelProperty( + value = "The file size of the input content claim formatted." + ) public String getInputContentClaimFileSize() { return inputContentClaimFileSize; } @@ -575,10 +603,11 @@ public class ProvenanceEventDTO { } /** - * Returns the number of bytes of the input content claim. - * - * @return + * @return the number of bytes of the input content claim */ + @ApiModelProperty( + value = "The file size of the intput content claim in bytes." + ) public Long getInputContentClaimFileSizeBytes() { return inputContentClaimFileSizeBytes; } @@ -588,10 +617,11 @@ public class ProvenanceEventDTO { } /** - * Returns whether or not replay is available. - * - * @return + * @return whether or not replay is available */ + @ApiModelProperty( + value = "Whether or not replay is available." + ) public Boolean getReplayAvailable() { return replayAvailable; } @@ -601,10 +631,11 @@ public class ProvenanceEventDTO { } /** - * Returns the explanation as to why replay is unavailable. - * - * @return + * @return the explanation as to why replay is unavailable */ + @ApiModelProperty( + value = "Explanation as to why replay is unavailable." + ) public String getReplayExplanation() { return replayExplanation; } @@ -614,12 +645,13 @@ public class ProvenanceEventDTO { } /** - * Returns identifier of the FlowFile Queue / Connection from which the - * FlowFile was pulled to generate this event, or null if - * either the queue is unknown or the FlowFile was created by this event. - * - * @return + * @return identifier of the FlowFile Queue / Connection from which the FlowFile was pulled to generate this event, or null if either the queue is unknown or the FlowFile was created + * by this event */ + @ApiModelProperty( + value = "The identifier of the queue/connection from which the flowfile was pulled to genereate this event. May be null if the queue/connection is unknown or the " + + "flowfile was generated from this event." + ) public String getSourceConnectionIdentifier() { return sourceConnectionIdentifier; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceOptionsDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceOptionsDTO.java index 7f939b9d15..edd414fa54 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceOptionsDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceOptionsDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.provenance; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.List; import javax.xml.bind.annotation.XmlType; @@ -28,10 +29,11 @@ public class ProvenanceOptionsDTO { private List searchableFields; /** - * The available searchable fields for this NiFi instance. - * - * @return + * @return available searchable fields for this NiFi instance */ + @ApiModelProperty( + value = "The available searchable field for the NiFi." + ) public List getSearchableFields() { return searchableFields; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceRequestDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceRequestDTO.java index e9e54534ed..f38bc99514 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceRequestDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceRequestDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.provenance; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Date; import java.util.Map; @@ -37,10 +38,11 @@ public class ProvenanceRequestDTO { private Integer maxResults; /** - * Returns the search terms to use for this search - * - * @return + * @return the search terms to use for this search */ + @ApiModelProperty( + value = "The search terms used to perform the search." + ) public Map getSearchTerms() { return searchTerms; } @@ -50,11 +52,12 @@ public class ProvenanceRequestDTO { } /** - * The earliest event time to include in the query - * - * @return + * @return earliest event time to include in the query */ @XmlJavaTypeAdapter(DateTimeAdapter.class) + @ApiModelProperty( + value = "The earliest event time to include in the query." + ) public Date getStartDate() { return startDate; } @@ -64,11 +67,12 @@ public class ProvenanceRequestDTO { } /** - * The latest event time to include in the query - * - * @return + * @return latest event time to include in the query */ @XmlJavaTypeAdapter(DateTimeAdapter.class) + @ApiModelProperty( + value = "The latest event time to include in the query." + ) public Date getEndDate() { return endDate; } @@ -78,10 +82,11 @@ public class ProvenanceRequestDTO { } /** - * The minimum file size to include in the query. - * - * @return + * @return minimum file size to include in the query */ + @ApiModelProperty( + value = "The minimum file size to include in the query." + ) public String getMinimumFileSize() { return minimumFileSize; } @@ -91,10 +96,11 @@ public class ProvenanceRequestDTO { } /** - * The maximum file size to include in the query. - * - * @return + * @return maximum file size to include in the query */ + @ApiModelProperty( + value = "The maximum file size to include in the query." + ) public String getMaximumFileSize() { return maximumFileSize; } @@ -104,10 +110,11 @@ public class ProvenanceRequestDTO { } /** - * The number of max results. - * - * @return + * @return number of max results */ + @ApiModelProperty( + value = "The maximum number of results to include." + ) public Integer getMaxResults() { return maxResults; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceResultsDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceResultsDTO.java index d6ea8a00d7..d37452d9ec 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceResultsDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceResultsDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.provenance; +import com.wordnik.swagger.annotations.ApiModelProperty; import org.apache.nifi.web.api.dto.util.DateTimeAdapter; import org.apache.nifi.web.api.dto.util.TimeAdapter; @@ -41,10 +42,11 @@ public class ProvenanceResultsDTO { private Set errors; /** - * Any error messages. - * - * @return + * @return error messages */ + @ApiModelProperty( + value = "Any errors that occurred while performing the provenance request." + ) public Set getErrors() { return errors; } @@ -54,10 +56,11 @@ public class ProvenanceResultsDTO { } /** - * The provenance events that matched the search criteria. - * - * @return + * @return provenance events that matched the search criteria */ + @ApiModelProperty( + value = "The provenance events that matched the search criteria." + ) public List getProvenanceEvents() { return provenanceEvents; } @@ -67,10 +70,11 @@ public class ProvenanceResultsDTO { } /** - * The total number of results formatted. - * - * @return + * @return total number of results formatted */ + @ApiModelProperty( + value = "The total number of results formatted." + ) public String getTotal() { return total; } @@ -80,10 +84,11 @@ public class ProvenanceResultsDTO { } /** - * The total number of results. - * - * @return + * @return total number of results */ + @ApiModelProperty( + value = "The total number of results." + ) public Long getTotalCount() { return totalCount; } @@ -93,11 +98,12 @@ public class ProvenanceResultsDTO { } /** - * When the search was performed. - * - * @return + * @return when the search was performed */ @XmlJavaTypeAdapter(TimeAdapter.class) + @ApiModelProperty( + value = "Then the search was performed." + ) public Date getGenerated() { return generated; } @@ -107,11 +113,12 @@ public class ProvenanceResultsDTO { } /** - * The oldest event available in the provenance repository. - * - * @return + * @return oldest event available in the provenance repository */ @XmlJavaTypeAdapter(DateTimeAdapter.class) + @ApiModelProperty( + value = "The oldest event available in the provenance repository." + ) public Date getOldestEvent() { return oldestEvent; } @@ -121,10 +128,11 @@ public class ProvenanceResultsDTO { } /** - * The time offset on the server thats used for event time. - * - * @return + * @return time offset on the server thats used for event time */ + @ApiModelProperty( + value = "The time offset of the server that's used for event time." + ) public Integer getTimeOffset() { return timeOffset; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceSearchableFieldDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceSearchableFieldDTO.java index af89f97c3f..05a707e337 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceSearchableFieldDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/ProvenanceSearchableFieldDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.provenance; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -30,10 +31,11 @@ public class ProvenanceSearchableFieldDTO { private String type; /** - * The id of this searchable field. - * - * @return + * @return id of this searchable field */ + @ApiModelProperty( + value = "The id of the searchable field." + ) public String getId() { return id; } @@ -43,10 +45,11 @@ public class ProvenanceSearchableFieldDTO { } /** - * The field. - * - * @return + * @return the field */ + @ApiModelProperty( + value = "The searchable field." + ) public String getField() { return field; } @@ -56,10 +59,11 @@ public class ProvenanceSearchableFieldDTO { } /** - * The label for this field. - * - * @return + * @return label for this field */ + @ApiModelProperty( + value = "The label for the searchable field." + ) public String getLabel() { return label; } @@ -69,10 +73,11 @@ public class ProvenanceSearchableFieldDTO { } /** - * The type for this field. - * - * @return + * @return type of this field */ + @ApiModelProperty( + value = "The type of the searchable field." + ) public String getType() { return type; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/LineageDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/LineageDTO.java index 745105ed01..bc68d784eb 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/LineageDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/LineageDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.provenance.lineage; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Date; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; @@ -40,10 +41,11 @@ public class LineageDTO { private LineageResultsDTO results; /** - * The id of this lineage. - * - * @return + * @return id of this lineage */ + @ApiModelProperty( + value = "The id of this lineage query." + ) public String getId() { return id; } @@ -53,10 +55,11 @@ public class LineageDTO { } /** - * The uri for this lineage. - * - * @return + * @return uri for this lineage */ + @ApiModelProperty( + value = "The URI for this lineage query for later retrieval and deletion." + ) public String getUri() { return uri; } @@ -66,10 +69,11 @@ public class LineageDTO { } /** - * The id of the node in the cluster where this lineage originated. - * - * @return + * @return id of the node in the cluster where this lineage originated */ + @ApiModelProperty( + value = "The id of the node where this lineage originated if clustered." + ) public String getClusterNodeId() { return clusterNodeId; } @@ -79,11 +83,12 @@ public class LineageDTO { } /** - * The submission time for this lineage. - * - * @return + * @return submission time for this lineage */ @XmlJavaTypeAdapter(TimestampAdapter.class) + @ApiModelProperty( + value = "When the lineage query was submitted." + ) public Date getSubmissionTime() { return submissionTime; } @@ -93,11 +98,12 @@ public class LineageDTO { } /** - * The expiration of this lineage. - * - * @return + * @return expiration of this lineage */ @XmlJavaTypeAdapter(TimestampAdapter.class) + @ApiModelProperty( + value = "When the lineage query will expire." + ) public Date getExpiration() { return expiration; } @@ -107,10 +113,11 @@ public class LineageDTO { } /** - * Percent completed for this result. - * - * @return + * @return percent completed for this result */ + @ApiModelProperty( + value = "The percent complete for the lineage query." + ) public Integer getPercentCompleted() { return percentCompleted; } @@ -120,10 +127,11 @@ public class LineageDTO { } /** - * Whether or not the request is finished running. - * - * @return + * @return whether or not the request is finished running */ + @ApiModelProperty( + value = "Whether the lineage query has finished." + ) public Boolean getFinished() { return finished; } @@ -133,10 +141,11 @@ public class LineageDTO { } /** - * The lineage request. - * - * @return + * @return the lineage request */ + @ApiModelProperty( + value = "The initial lineage result." + ) public LineageRequestDTO getRequest() { return request; } @@ -146,10 +155,11 @@ public class LineageDTO { } /** - * The results of this lineage. - * - * @return + * @return the results of this lineage */ + @ApiModelProperty( + value = "The results of the lineage query." + ) public LineageResultsDTO getResults() { return results; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/LineageRequestDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/LineageRequestDTO.java index 23cf892cfa..afab6212c2 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/LineageRequestDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/LineageRequestDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.provenance.lineage; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlType; @@ -31,7 +32,6 @@ public class LineageRequestDTO { @XmlType(name = "lineageRequestType") @XmlEnum public enum LineageRequestType { - PARENTS, CHILDREN, FLOWFILE; @@ -43,10 +43,11 @@ public class LineageRequestDTO { private String uuid; /** - * The event id that was used to generate this lineage. - * - * @return + * @return event id that was used to generate this lineage */ + @ApiModelProperty( + value = "" + ) public Long getEventId() { return eventId; } @@ -56,14 +57,14 @@ public class LineageRequestDTO { } /** - * The type of lineage request. Either 'PARENTS', 'CHILDREN', or 'FLOWFILE'. - * PARENTS will return the lineage for the flowfiles that are parents of the - * specified event. CHILDREN will return the lineage of for the flowfiles - * that are children of the specified event. FLOWFILE will return the - * lineage for the specified flowfile. - * - * @return + * @return type of lineage request. Either 'PARENTS', 'CHILDREN', or 'FLOWFILE'. PARENTS will return the lineage for the flowfiles that are parents of the specified event. CHILDREN will return the + * lineage of for the flowfiles that are children of the specified event. FLOWFILE will return the lineage for the specified flowfile. */ + @ApiModelProperty( + value = "The type of lineage request. PARENTS will return the lineage for the flowfiles that are parents of the specified event. CHILDREN will return the lineage " + + "for the flowfiles that are children of the specified event. FLOWFILE will return the lineage for the specified flowfile.", + allowableValues = "PARENTS, CHILDREN, and FLOWFILE" + ) public LineageRequestType getLineageRequestType() { return lineageRequestType; } @@ -73,10 +74,11 @@ public class LineageRequestDTO { } /** - * The uuid that was used to generate this lineage. - * - * @return + * @return uuid that was used to generate this lineage */ + @ApiModelProperty( + value = "The uuid that was used to generate the lineage." + ) public String getUuid() { return uuid; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/LineageResultsDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/LineageResultsDTO.java index 77b6e7ace7..0ac4479ff6 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/LineageResultsDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/LineageResultsDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.provenance.lineage; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.List; import java.util.Set; import javax.xml.bind.annotation.XmlType; @@ -32,10 +33,11 @@ public class LineageResultsDTO { private List links; /** - * Any error messages. - * - * @return + * @return any error messages */ + @ApiModelProperty( + value = "Any errors that occurred while generating the lineage." + ) public Set getErrors() { return errors; } @@ -45,10 +47,11 @@ public class LineageResultsDTO { } /** - * The nodes. - * - * @return + * @return the nodes */ + @ApiModelProperty( + value = "The nodes in the lineage." + ) public List getNodes() { return nodes; } @@ -58,10 +61,11 @@ public class LineageResultsDTO { } /** - * The links. - * - * @return + * @return the links */ + @ApiModelProperty( + value = "The links between the nodes in the lineage." + ) public List getLinks() { return links; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/ProvenanceLinkDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/ProvenanceLinkDTO.java index f3bbcefbed..f91d1247d2 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/ProvenanceLinkDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/ProvenanceLinkDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.provenance.lineage; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Date; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; @@ -34,10 +35,11 @@ public class ProvenanceLinkDTO { private Long millis; /** - * The source node id. - * - * @return + * @return source node id */ + @ApiModelProperty( + value = "The source node id of the link." + ) public String getSourceId() { return sourceId; } @@ -47,10 +49,11 @@ public class ProvenanceLinkDTO { } /** - * The target node id. - * - * @return + * @return target node id */ + @ApiModelProperty( + value = "The target node id of the link." + ) public String getTargetId() { return targetId; } @@ -60,10 +63,11 @@ public class ProvenanceLinkDTO { } /** - * The flowfile uuid that traversed this link. - * - * @return + * @return flowfile uuid that traversed this link */ + @ApiModelProperty( + value = "The flowfile uuid that traversed the link." + ) public String getFlowFileUuid() { return flowFileUuid; } @@ -73,11 +77,12 @@ public class ProvenanceLinkDTO { } /** - * The timestamp of this link (based on the destination). - * - * @return + * @return timestamp of this link (based on the destination) */ @XmlJavaTypeAdapter(TimestampAdapter.class) + @ApiModelProperty( + value = "The timestamp of the link (based on the destination)." + ) public Date getTimestamp() { return timestamp; } @@ -87,10 +92,11 @@ public class ProvenanceLinkDTO { } /** - * The number of millis since epoch. - * - * @return + * @return number of millis since epoch */ + @ApiModelProperty( + value = "The timestamp of this link in milliseconds." + ) public Long getMillis() { return millis; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/ProvenanceNodeDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/ProvenanceNodeDTO.java index c15c598cd0..5e7e329730 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/ProvenanceNodeDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/ProvenanceNodeDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.provenance.lineage; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Date; import java.util.List; @@ -25,8 +26,7 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.apache.nifi.web.api.dto.util.TimestampAdapter; /** - * A node within a provenance lineage. May represent either an event or a - * flowfile. + * A node within a provenance lineage. May represent either an event or a flowfile. */ @XmlType(name = "provenanceNode") public class ProvenanceNodeDTO { @@ -42,10 +42,11 @@ public class ProvenanceNodeDTO { private Date timestamp; /** - * The id of the node. - * - * @return + * @return id of the node */ + @ApiModelProperty( + value = "The id of the node." + ) public String getId() { return id; } @@ -55,10 +56,11 @@ public class ProvenanceNodeDTO { } /** - * The flowfile uuid for this provenance event. - * - * @return + * @return flowfile uuid for this provenance event */ + @ApiModelProperty( + value = "The uuid of the flowfile associated with the provenance event." + ) public String getFlowFileUuid() { return flowFileUuid; } @@ -68,10 +70,11 @@ public class ProvenanceNodeDTO { } /** - * The parent flowfile uuids for this provenance event. - * - * @return + * @return parent flowfile uuids for this provenance event */ + @ApiModelProperty( + value = "The uuid of the parent flowfiles of the provenance event." + ) public List getParentUuids() { return parentUuids; } @@ -81,10 +84,11 @@ public class ProvenanceNodeDTO { } /** - * The child flowfile uuids for this provenance event. - * - * @return + * @return child flowfile uuids for this provenance event */ + @ApiModelProperty( + value = "The uuid of the childrent flowfiles of the provenance event." + ) public List getChildUuids() { return childUuids; } @@ -94,10 +98,11 @@ public class ProvenanceNodeDTO { } /** - * The node identifier that this event/flowfile originated from. - * - * @return + * @return node identifier that this event/flowfile originated from */ + @ApiModelProperty( + value = "The identifier of the node that this event/flowfile originated from." + ) public String getClusterNodeIdentifier() { return clusterNodeIdentifier; } @@ -107,10 +112,12 @@ public class ProvenanceNodeDTO { } /** - * The type of node. - * - * @return + * @return type of node */ + @ApiModelProperty( + value = "The type of the node.", + allowableValues = "FLOWFILE, EVENT" + ) public String getType() { return type; } @@ -120,10 +127,11 @@ public class ProvenanceNodeDTO { } /** - * If this is an event node, this is the type of event. - * - * @return + * @return this is an event node, this is the type of event */ + @ApiModelProperty( + value = "If the type is EVENT, this is the type of event." + ) public String getEventType() { return eventType; } @@ -133,11 +141,12 @@ public class ProvenanceNodeDTO { } /** - * The timestamp of this node. - * - * @return + * @return timestamp of this node */ @XmlJavaTypeAdapter(TimestampAdapter.class) + @ApiModelProperty( + value = "The timestamp of the node formatted." + ) public Date getTimestamp() { return timestamp; } @@ -147,10 +156,11 @@ public class ProvenanceNodeDTO { } /** - * The number of millis since epoch. - * - * @return + * @return number of millis since epoch */ + @ApiModelProperty( + value = "The timestamp of the node in milliseconds." + ) public Long getMillis() { return millis; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/search/ComponentSearchResultDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/search/ComponentSearchResultDTO.java index 83d7a91319..8e9cba56d7 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/search/ComponentSearchResultDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/search/ComponentSearchResultDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.search; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.List; import javax.xml.bind.annotation.XmlType; @@ -31,10 +32,11 @@ public class ComponentSearchResultDTO { private List matches; /** - * The id of the component that matched. - * - * @return + * @return id of the component that matched */ + @ApiModelProperty( + value = "The id of the component that matched the search." + ) public String getId() { return id; } @@ -44,10 +46,11 @@ public class ComponentSearchResultDTO { } /** - * The group id of the component that matched. - * - * @return + * @return group id of the component that matched */ + @ApiModelProperty( + value = "The group id of the component that matched the search." + ) public String getGroupId() { return groupId; } @@ -57,10 +60,11 @@ public class ComponentSearchResultDTO { } /** - * The name of the component that matched. - * - * @return + * @return name of the component that matched */ + @ApiModelProperty( + value = "The name of the component that matched the search." + ) public String getName() { return name; } @@ -70,10 +74,11 @@ public class ComponentSearchResultDTO { } /** - * What matched the search string for this component. - * - * @return + * @return What matched the search string for this component */ + @ApiModelProperty( + value = "What matched the search from the component." + ) public List getMatches() { return matches; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/search/NodeSearchResultDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/search/NodeSearchResultDTO.java index 7c250ee806..554966ecc4 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/search/NodeSearchResultDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/search/NodeSearchResultDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.search; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -28,10 +29,11 @@ public class NodeSearchResultDTO { private String address; /** - * The id of the node that was matched. - * - * @return + * @return id of the node that was matched */ + @ApiModelProperty( + value = "The id of the node that matched the search." + ) public String getId() { return id; } @@ -41,10 +43,11 @@ public class NodeSearchResultDTO { } /** - * The address of the node that was matched. - * - * @return + * @return address of the node that was matched */ + @ApiModelProperty( + value = "The address of the node that matched the search." + ) public String getAddress() { return address; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/search/SearchResultsDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/search/SearchResultsDTO.java index 212d4f2ef3..60e5bddffd 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/search/SearchResultsDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/search/SearchResultsDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.search; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlType; @@ -35,10 +36,11 @@ public class SearchResultsDTO { private List funnelResults = new ArrayList<>(); /** - * The processors that matched the search. - * - * @return + * @return The processors that matched the search */ + @ApiModelProperty( + value = "The processors that matched the search." + ) public List getProcessorResults() { return processorResults; } @@ -48,10 +50,11 @@ public class SearchResultsDTO { } /** - * The connections that matched the search. - * - * @return + * @return connections that matched the search */ + @ApiModelProperty( + value = "The connections that matched the search." + ) public List getConnectionResults() { return connectionResults; } @@ -61,10 +64,11 @@ public class SearchResultsDTO { } /** - * The process group that matched the search. - * - * @return + * @return process group that matched the search */ + @ApiModelProperty( + value = "The process groups that matched the search." + ) public List getProcessGroupResults() { return processGroupResults; } @@ -74,19 +78,21 @@ public class SearchResultsDTO { } /** - * The input ports that matched the search. - * - * @return + * @return input ports that matched the search */ + @ApiModelProperty( + value = "The input ports that matched the search." + ) public List getInputPortResults() { return inputPortResults; } /** - * The output ports that matched the search. - * - * @return + * @return output ports that matched the search */ + @ApiModelProperty( + value = "The output ports that matched the search." + ) public List getOutputPortResults() { return outputPortResults; } @@ -100,10 +106,11 @@ public class SearchResultsDTO { } /** - * The remote process groups that matched the search. - * - * @return + * @return remote process groups that matched the search */ + @ApiModelProperty( + value = "The remote process groups that matched the search." + ) public List getRemoteProcessGroupResults() { return remoteProcessGroupResults; } @@ -113,10 +120,11 @@ public class SearchResultsDTO { } /** - * The funnels that matched the search. - * - * @return + * @return funnels that matched the search */ + @ApiModelProperty( + value = "The funnels that matched the search." + ) public List getFunnelResults() { return funnelResults; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/search/UserGroupSearchResultDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/search/UserGroupSearchResultDTO.java index ab5636d680..ef81b887aa 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/search/UserGroupSearchResultDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/search/UserGroupSearchResultDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.search; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -27,10 +28,11 @@ public class UserGroupSearchResultDTO { private String group; /** - * The name of the group that matched. - * - * @return + * @return name of the group that matched */ + @ApiModelProperty( + value = "The name of the group that matched the search." + ) public String getGroup() { return group; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/search/UserSearchResultDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/search/UserSearchResultDTO.java index 9402eeb0d9..8bed771b47 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/search/UserSearchResultDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/search/UserSearchResultDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.search; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -28,10 +29,11 @@ public class UserSearchResultDTO { private String userDn; /** - * The dn of the user that matched. - * - * @return + * @return dn of the user that matched */ + @ApiModelProperty( + value = "The dn of the user that matched the search." + ) public String getUserDn() { return userDn; } @@ -41,10 +43,11 @@ public class UserSearchResultDTO { } /** - * The username of user that matched. - * - * @return + * @return username of user that matched */ + @ApiModelProperty( + value = "The name of the user that matched the search." + ) public String getUserName() { return userName; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterConnectionStatusDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterConnectionStatusDTO.java index f0e11d6398..34f900fbb7 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterConnectionStatusDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterConnectionStatusDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Collection; import java.util.Date; import javax.xml.bind.annotation.XmlType; @@ -34,11 +35,12 @@ public class ClusterConnectionStatusDTO { private String connectionName; /** - * The time the status were last refreshed. - * - * @return + * @return time the status were last refreshed */ @XmlJavaTypeAdapter(TimeAdapter.class) + @ApiModelProperty( + value = "The time the status was last refreshed." + ) public Date getStatsLastRefreshed() { return statsLastRefreshed; } @@ -48,10 +50,11 @@ public class ClusterConnectionStatusDTO { } /** - * The connection id. - * - * @return + * @return connection id */ + @ApiModelProperty( + value = "The id of the connection." + ) public String getConnectionId() { return connectionId; } @@ -61,10 +64,11 @@ public class ClusterConnectionStatusDTO { } /** - * The connection name. - * - * @return + * @return connection name */ + @ApiModelProperty( + value = "The name of the connection." + ) public String getConnectionName() { return connectionName; } @@ -74,10 +78,11 @@ public class ClusterConnectionStatusDTO { } /** - * Collection of node connection status DTO. - * * @return The collection of node connection status DTO */ + @ApiModelProperty( + value = "The connection status for each node." + ) public Collection getNodeConnectionStatus() { return nodeConnectionStatus; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterPortStatusDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterPortStatusDTO.java index 4d7fa4d611..372bb70e30 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterPortStatusDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterPortStatusDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Collection; import java.util.Date; import javax.xml.bind.annotation.XmlType; @@ -34,11 +35,12 @@ public class ClusterPortStatusDTO { private String portName; /** - * The time the status was last refreshed. - * * @return the time the status were last refreshed */ @XmlJavaTypeAdapter(TimeAdapter.class) + @ApiModelProperty( + value = "The time the status was last refreshed." + ) public Date getStatsLastRefreshed() { return statsLastRefreshed; } @@ -48,10 +50,11 @@ public class ClusterPortStatusDTO { } /** - * The port status from each node in the cluster. - * - * @return + * @return port status from each node in the cluster */ + @ApiModelProperty( + value = "The port status for each node." + ) public Collection getNodePortStatus() { return nodePortStatus; } @@ -61,10 +64,11 @@ public class ClusterPortStatusDTO { } /** - * The port id. - * - * @return + * @return port id */ + @ApiModelProperty( + value = "The id of the port." + ) public String getPortId() { return portId; } @@ -74,10 +78,11 @@ public class ClusterPortStatusDTO { } /** - * The port name. - * - * @return + * @return port name */ + @ApiModelProperty( + value = "The name of the port." + ) public String getPortName() { return portName; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterProcessGroupStatusDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterProcessGroupStatusDTO.java new file mode 100644 index 0000000000..1a4ad63ecc --- /dev/null +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterProcessGroupStatusDTO.java @@ -0,0 +1,102 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.web.api.dto.status; + +import com.wordnik.swagger.annotations.ApiModelProperty; +import java.util.Collection; +import java.util.Date; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import org.apache.nifi.web.api.dto.util.TimeAdapter; + +/** + * DTO for serializing the a process group's status across the cluster. + */ +@XmlType(name = "clusterProcessGroupStatus") +public class ClusterProcessGroupStatusDTO { + + private Collection nodeProcessGroupStatus; + private Date statsLastRefreshed; + private String processGroupId; + private String processGroupName; + + /** + * The time the status were last refreshed. + * + * @return The time the status were last refreshed + */ + @XmlJavaTypeAdapter(TimeAdapter.class) + @ApiModelProperty( + value = "The time when the stats was last refreshed." + ) + public Date getStatsLastRefreshed() { + return statsLastRefreshed; + } + + public void setStatsLastRefreshed(Date statsLastRefreshed) { + this.statsLastRefreshed = statsLastRefreshed; + } + + /** + * The process group id. + * + * @return The process group id + */ + @ApiModelProperty( + value = "The id of the process group." + ) + public String getProcessGroupId() { + return processGroupId; + } + + public void setProcessGroupId(String processGroupId) { + this.processGroupId = processGroupId; + } + + /** + * The process group name. + * + * @return The process group name + */ + @ApiModelProperty( + value = "The name of the process group." + ) + public String getProcessGroupName() { + return processGroupName; + } + + public void setProcessGroupName(String processGroupName) { + this.processGroupName = processGroupName; + } + + /** + * Collection of node process group status DTO. + * + * @return The collection of node process group status DTO + */ + @ApiModelProperty( + value = "The process groups status for each node." + ) + public Collection getNodeProcessGroupStatus() { + return nodeProcessGroupStatus; + } + + public void setNodeProcessGroupStatus(Collection nodeProcessGroupStatus) { + this.nodeProcessGroupStatus = nodeProcessGroupStatus; + } + +} diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterProcessorStatusDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterProcessorStatusDTO.java index b9f45f2b85..faedc5745c 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterProcessorStatusDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterProcessorStatusDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Collection; import java.util.Date; import javax.xml.bind.annotation.XmlType; @@ -36,11 +37,12 @@ public class ClusterProcessorStatusDTO { private String processorRunStatus; /** - * The time the status were last refreshed. - * - * @return + * @return time the status were last refreshed */ @XmlJavaTypeAdapter(TimeAdapter.class) + @ApiModelProperty( + value = "The time when the status was last refreshed." + ) public Date getStatsLastRefreshed() { return statsLastRefreshed; } @@ -50,10 +52,11 @@ public class ClusterProcessorStatusDTO { } /** - * The processor id. - * - * @return + * @return processor id */ + @ApiModelProperty( + value = "The processor id." + ) public String getProcessorId() { return processorId; } @@ -63,10 +66,11 @@ public class ClusterProcessorStatusDTO { } /** - * The processor name. - * - * @return + * @return processor name */ + @ApiModelProperty( + value = "The processor name." + ) public String getProcessorName() { return processorName; } @@ -76,10 +80,11 @@ public class ClusterProcessorStatusDTO { } /** - * The processor type. - * - * @return + * @return processor type */ + @ApiModelProperty( + value = "The processor type." + ) public String getProcessorType() { return processorType; } @@ -89,10 +94,12 @@ public class ClusterProcessorStatusDTO { } /** - * The processor run status. - * - * @return + * @return processor run status */ + @ApiModelProperty( + value = "The processor state.", + allowableValues = "RUNNING, STOPPED, DISABLED, INVALID" + ) public String getProcessorRunStatus() { return processorRunStatus; } @@ -106,6 +113,9 @@ public class ClusterProcessorStatusDTO { * * @return The collection of node processor status DTO */ + @ApiModelProperty( + value = "The processor status for each node." + ) public Collection getNodeProcessorStatus() { return nodeProcessorStatus; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterRemoteProcessGroupStatusDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterRemoteProcessGroupStatusDTO.java index d6b26d414e..5fef96f91f 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterRemoteProcessGroupStatusDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterRemoteProcessGroupStatusDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Collection; import java.util.Date; import javax.xml.bind.annotation.XmlType; @@ -34,11 +35,12 @@ public class ClusterRemoteProcessGroupStatusDTO { private String remoteProcessGroupName; /** - * The time the status was last refreshed. - * * @return the time the status were last refreshed */ @XmlJavaTypeAdapter(TimeAdapter.class) + @ApiModelProperty( + value = "The time when the remote process group status was last refreshed." + ) public Date getStatsLastRefreshed() { return statsLastRefreshed; } @@ -48,10 +50,11 @@ public class ClusterRemoteProcessGroupStatusDTO { } /** - * The remote process group status from each node in the cluster. - * - * @return + * @return remote process group status from each node in the cluster */ + @ApiModelProperty( + value = "The remote process group status from each node in the cluster." + ) public Collection getNodeRemoteProcessGroupStatus() { return nodeRemoteProcessGroupStatus; } @@ -61,10 +64,11 @@ public class ClusterRemoteProcessGroupStatusDTO { } /** - * The remote process group id. - * - * @return + * @return remote process group id */ + @ApiModelProperty( + value = "The id of the remote process group." + ) public String getRemoteProcessGroupId() { return remoteProcessGroupId; } @@ -74,10 +78,11 @@ public class ClusterRemoteProcessGroupStatusDTO { } /** - * The remote process group name. - * - * @return + * @return remote process group name */ + @ApiModelProperty( + value = "The name of the remote process group." + ) public String getRemoteProcessGroupName() { return remoteProcessGroupName; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterStatusDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterStatusDTO.java index d83399174b..73529d06db 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterStatusDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterStatusDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Collection; import javax.xml.bind.annotation.XmlType; @@ -29,10 +30,11 @@ public class ClusterStatusDTO { private Collection nodeStatus; /** - * The collection of the node status DTOs. - * - * @return + * @return collection of the node status DTOs */ + @ApiModelProperty( + value = "The status of each node." + ) public Collection getNodeStatus() { return nodeStatus; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterStatusHistoryDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterStatusHistoryDTO.java index 31a994845d..997e24b593 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterStatusHistoryDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ClusterStatusHistoryDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Collection; import java.util.Date; import javax.xml.bind.annotation.XmlType; @@ -33,11 +34,12 @@ public class ClusterStatusHistoryDTO { private Date generated; /** - * When this status history was generated. - * - * @return + * @return when this status history was generated */ @XmlJavaTypeAdapter(TimeAdapter.class) + @ApiModelProperty( + value = "When the status history was generated." + ) public Date getGenerated() { return generated; } @@ -47,10 +49,11 @@ public class ClusterStatusHistoryDTO { } /** - * The status history from each node in the cluster. - * - * @return + * @return status history from each node in the cluster */ + @ApiModelProperty( + value = "The status history from each node." + ) public Collection getNodeStatusHistory() { return nodeStatusHistory; } @@ -60,10 +63,11 @@ public class ClusterStatusHistoryDTO { } /** - * The status history for this component across the entire cluster. - * - * @return + * @return status history for this component across the entire cluster */ + @ApiModelProperty( + value = "The status history for the entire cluster." + ) public StatusHistoryDTO getClusterStatusHistory() { return clusterStatusHistory; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ConnectionStatusDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ConnectionStatusDTO.java index 387cce5c89..dc17c2181e 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ConnectionStatusDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ConnectionStatusDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -40,10 +41,11 @@ public class ConnectionStatusDTO { /* getters / setters */ /** - * The id for the connection. - * * @return The connection id */ + @ApiModelProperty( + value = "The id of the connection." + ) public String getId() { return id; } @@ -53,10 +55,11 @@ public class ConnectionStatusDTO { } /** - * The ID of the Process Group to which this processor belongs. - * - * @return the ID of the Process Group to which this processor belongs. + * @return the ID of the Process Group to which this connection belongs. */ + @ApiModelProperty( + value = "The id of the process group the connection belongs to." + ) public String getGroupId() { return groupId; } @@ -66,10 +69,11 @@ public class ConnectionStatusDTO { } /** - * The name of this connection. - * - * @return + * @return name of this connection */ + @ApiModelProperty( + value = "The name of the connection." + ) public String getName() { return name; } @@ -79,10 +83,11 @@ public class ConnectionStatusDTO { } /** - * The total count of flow files that are queued. - * - * @return + * @return total count of flow files that are queued */ + @ApiModelProperty( + value = "The number of flowfiles that are queued." + ) public String getQueuedCount() { return queuedCount; } @@ -92,10 +97,11 @@ public class ConnectionStatusDTO { } /** - * The total size of flow files that are queued. - * - * @return + * @return total size of flow files that are queued */ + @ApiModelProperty( + value = "The total size of flowfiles that are queued formatted." + ) public String getQueuedSize() { return queuedSize; } @@ -105,10 +111,11 @@ public class ConnectionStatusDTO { } /** - * The total count and size of flow files that are queued. - * * @return The total count and size of queued flow files */ + @ApiModelProperty( + value = "The total count and size of queued flowfiles formatted." + ) public String getQueued() { return queued; } @@ -118,10 +125,11 @@ public class ConnectionStatusDTO { } /** - * The id of the source of this connection. - * - * @return + * @return id of the source of this connection */ + @ApiModelProperty( + value = "The id of the source of the connection." + ) public String getSourceId() { return sourceId; } @@ -131,10 +139,11 @@ public class ConnectionStatusDTO { } /** - * The name of the source of this connection. - * - * @return + * @return name of the source of this connection */ + @ApiModelProperty( + value = "The name of the source of the connection." + ) public String getSourceName() { return sourceName; } @@ -144,10 +153,11 @@ public class ConnectionStatusDTO { } /** - * The id of the destination of this connection. - * - * @return + * @return id of the destination of this connection */ + @ApiModelProperty( + value = "The id of the destination of the connection." + ) public String getDestinationId() { return destinationId; } @@ -157,10 +167,11 @@ public class ConnectionStatusDTO { } /** - * The name of the destination of this connection. - * - * @return + * @return name of the destination of this connection */ + @ApiModelProperty( + value = "The name of the destination of the connection." + ) public String getDestinationName() { return destinationName; } @@ -170,10 +181,11 @@ public class ConnectionStatusDTO { } /** - * The input for this connection. - * - * @return + * @return input for this connection */ + @ApiModelProperty( + value = "The input count/size for the connection in the last 5 minutes." + ) public String getInput() { return input; } @@ -183,10 +195,11 @@ public class ConnectionStatusDTO { } /** - * The output for this connection. - * - * @return + * @return output for this connection */ + @ApiModelProperty( + value = "The output count/sie for the connection in the last 5 minutes." + ) public String getOutput() { return output; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ControllerStatusDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ControllerStatusDTO.java index 9e063e44b8..7afc7bca94 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ControllerStatusDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ControllerStatusDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.List; import javax.xml.bind.annotation.XmlType; import org.apache.nifi.web.api.dto.BulletinDTO; @@ -45,6 +46,9 @@ public class ControllerStatusDTO { * * @return The active thread count */ + @ApiModelProperty( + value = "The number of active threads in the NiFi." + ) public Integer getActiveThreadCount() { return activeThreadCount; } @@ -54,10 +58,11 @@ public class ControllerStatusDTO { } /** - * The queue for the controller. - * - * @return + * @return queue for the controller */ + @ApiModelProperty( + value = "The number of flowfilew queued in the NiFi." + ) public String getQueued() { return queued; } @@ -67,11 +72,11 @@ public class ControllerStatusDTO { } /** - * Used in clustering, will report the number of nodes connected vs the - * number of nodes in the cluster. - * - * @return + * @return Used in clustering, will report the number of nodes connected vs the number of nodes in the cluster */ + @ApiModelProperty( + value = "When clustered, reports the number of nodes connected vs the number of nodes in the cluster." + ) public String getConnectedNodes() { return connectedNodes; } @@ -81,10 +86,11 @@ public class ControllerStatusDTO { } /** - * System bulletins to be reported to the user. - * - * @return + * @return System bulletins to be reported to the user */ + @ApiModelProperty( + value = "System level bulletins to be reported to the user." + ) public List getBulletins() { return bulletins; } @@ -94,10 +100,11 @@ public class ControllerStatusDTO { } /** - * Whether or not there are pending user requests. - * - * @return + * @return whether or not there are pending user requests */ + @ApiModelProperty( + value = "Whether there are any pending user account requests." + ) public Boolean getHasPendingAccounts() { return hasPendingAccounts; } @@ -107,10 +114,11 @@ public class ControllerStatusDTO { } /** - * The number of running components in this controller. - * - * @return + * @return number of running components in this controller */ + @ApiModelProperty( + value = "The number of running components in the NiFi." + ) public Integer getRunningCount() { return runningCount; } @@ -120,10 +128,11 @@ public class ControllerStatusDTO { } /** - * The number of stopped components in this controller. - * - * @return + * @return number of stopped components in this controller */ + @ApiModelProperty( + value = "The number of stopped components in the NiFi." + ) public Integer getStoppedCount() { return stoppedCount; } @@ -133,10 +142,11 @@ public class ControllerStatusDTO { } /** - * The number of invalid components in this controller. - * - * @return + * @return number of invalid components in this controller */ + @ApiModelProperty( + value = "The number of invalid components in the NiFi." + ) public Integer getInvalidCount() { return invalidCount; } @@ -146,10 +156,11 @@ public class ControllerStatusDTO { } /** - * The number of disabled components in this controller. - * - * @return + * @return number of disabled components in this controller */ + @ApiModelProperty( + value = "The number of disabled components in the NiFi." + ) public Integer getDisabledCount() { return disabledCount; } @@ -159,10 +170,11 @@ public class ControllerStatusDTO { } /** - * The number of active remote ports in this controller. - * - * @return + * @return number of active remote ports in this controller */ + @ApiModelProperty( + value = "The number of active remote ports in the NiFi." + ) public Integer getActiveRemotePortCount() { return activeRemotePortCount; } @@ -172,10 +184,11 @@ public class ControllerStatusDTO { } /** - * The number of inactive remote ports in this controller. - * - * @return + * @return number of inactive remote ports in this controller */ + @ApiModelProperty( + value = "The number of inactive remote ports in the NiFi." + ) public Integer getInactiveRemotePortCount() { return inactiveRemotePortCount; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeConnectionStatusDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeConnectionStatusDTO.java index f7cba448a2..bcc4045c1b 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeConnectionStatusDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeConnectionStatusDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; import org.apache.nifi.web.api.dto.NodeDTO; @@ -29,10 +30,11 @@ public class NodeConnectionStatusDTO { private ConnectionStatusDTO connectionStatus; /** - * The node. - * - * @return + * @return the node */ + @ApiModelProperty( + value = "The node." + ) public NodeDTO getNode() { return node; } @@ -42,10 +44,11 @@ public class NodeConnectionStatusDTO { } /** - * The connection's status. - * - * @return + * @return connection's status */ + @ApiModelProperty( + value = "The connection status from the node." + ) public ConnectionStatusDTO getConnectionStatus() { return connectionStatus; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodePortStatusDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodePortStatusDTO.java index 93d89ac1e2..3b37e9d591 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodePortStatusDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodePortStatusDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; import org.apache.nifi.web.api.dto.NodeDTO; @@ -29,10 +30,11 @@ public class NodePortStatusDTO { private PortStatusDTO portStatus; /** - * The node. - * - * @return + * @return the node */ + @ApiModelProperty( + value = "The node." + ) public NodeDTO getNode() { return node; } @@ -42,10 +44,11 @@ public class NodePortStatusDTO { } /** - * The port's status. - * - * @return + * @return port status */ + @ApiModelProperty( + value = "The port status from the node." + ) public PortStatusDTO getPortStatus() { return portStatus; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeProcessGroupStatusDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeProcessGroupStatusDTO.java new file mode 100644 index 0000000000..96c59faf26 --- /dev/null +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeProcessGroupStatusDTO.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.web.api.dto.status; + +import com.wordnik.swagger.annotations.ApiModelProperty; +import javax.xml.bind.annotation.XmlType; +import org.apache.nifi.web.api.dto.NodeDTO; + +/** + * DTO for serializing the process group status for a particular node. + */ +@XmlType(name = "nodeProcessGroupStatus") +public class NodeProcessGroupStatusDTO { + + private NodeDTO node; + private ProcessGroupStatusDTO processGroupStatus; + + /** + * The node. + * + * @return The node DTO + */ + @ApiModelProperty( + value = "The node." + ) + public NodeDTO getNode() { + return node; + } + + public void setNode(NodeDTO node) { + this.node = node; + } + + /** + * The process group's status. + * + * @return The process group status + */ + @ApiModelProperty( + value = "The process group status from the node." + ) + public ProcessGroupStatusDTO getProcessGroupStatus() { + return processGroupStatus; + } + + public void setProcessGroupStatus(ProcessGroupStatusDTO processGroupStatus) { + this.processGroupStatus = processGroupStatus; + } + +} diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeProcessorStatusDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeProcessorStatusDTO.java index afff4b10f5..8c8f60416b 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeProcessorStatusDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeProcessorStatusDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; import org.apache.nifi.web.api.dto.NodeDTO; @@ -29,10 +30,11 @@ public class NodeProcessorStatusDTO { private ProcessorStatusDTO processorStatus; /** - * The node. - * - * @return + * @return the node */ + @ApiModelProperty( + value = "The node." + ) public NodeDTO getNode() { return node; } @@ -42,10 +44,11 @@ public class NodeProcessorStatusDTO { } /** - * The processor's status. - * - * @return + * @return processor's status */ + @ApiModelProperty( + value = "The processor status from the node." + ) public ProcessorStatusDTO getProcessorStatus() { return processorStatus; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeRemoteProcessGroupStatusDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeRemoteProcessGroupStatusDTO.java index 03923bf35b..512b4c2f91 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeRemoteProcessGroupStatusDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeRemoteProcessGroupStatusDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; import org.apache.nifi.web.api.dto.NodeDTO; @@ -29,10 +30,11 @@ public class NodeRemoteProcessGroupStatusDTO { private RemoteProcessGroupStatusDTO remoteProcessGroupStatus; /** - * The node. - * - * @return + * @return the node */ + @ApiModelProperty( + value = "The node." + ) public NodeDTO getNode() { return node; } @@ -42,10 +44,11 @@ public class NodeRemoteProcessGroupStatusDTO { } /** - * The remote process group's status. - * - * @return + * @return remote process group's status */ + @ApiModelProperty( + value = "The remote process group status from the node." + ) public RemoteProcessGroupStatusDTO getRemoteProcessGroupStatus() { return remoteProcessGroupStatus; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeStatusDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeStatusDTO.java index 03647cd173..3f07f3dc9f 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeStatusDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeStatusDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; import org.apache.nifi.web.api.dto.NodeDTO; @@ -29,10 +30,11 @@ public class NodeStatusDTO { private ProcessGroupStatusDTO controllerStatus; /** - * The node. - * - * @return + * @return the node */ + @ApiModelProperty( + value = "The node." + ) public NodeDTO getNode() { return node; } @@ -42,10 +44,11 @@ public class NodeStatusDTO { } /** - * The controller status. - * - * @return + * @return the controller status */ + @ApiModelProperty( + value = "The controller status for each node." + ) public ProcessGroupStatusDTO getControllerStatus() { return controllerStatus; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeStatusHistoryDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeStatusHistoryDTO.java index c8b05f3e82..5cf9f416eb 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeStatusHistoryDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeStatusHistoryDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; import org.apache.nifi.web.api.dto.NodeDTO; @@ -29,10 +30,11 @@ public class NodeStatusHistoryDTO { private StatusHistoryDTO statusHistory; /** - * The node. - * - * @return + * @return the node */ + @ApiModelProperty( + value = "The node." + ) public NodeDTO getNode() { return node; } @@ -42,10 +44,11 @@ public class NodeStatusHistoryDTO { } /** - * The processor status history. - * - * @return + * @return processor status history */ + @ApiModelProperty( + value = "The processor status for each node." + ) public StatusHistoryDTO getStatusHistory() { return statusHistory; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/PortStatusDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/PortStatusDTO.java index c32efdb750..c1d95d05cd 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/PortStatusDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/PortStatusDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -34,10 +35,11 @@ public class PortStatusDTO extends StatusDTO { private String runStatus; /** - * Whether this port has incoming or outgoing connections to a remote NiFi. - * - * @return + * @return whether this port has incoming or outgoing connections to a remote NiFi */ + @ApiModelProperty( + value = "Whether the port has incoming or outgoing connections to a remote NiFi." + ) public Boolean isTransmitting() { return transmitting; } @@ -47,10 +49,11 @@ public class PortStatusDTO extends StatusDTO { } /** - * The active thread count for this port. - * - * @return + * @return the active thread count for this port */ + @ApiModelProperty( + value = "The active thread count for the port." + ) public Integer getActiveThreadCount() { return activeThreadCount; } @@ -60,10 +63,11 @@ public class PortStatusDTO extends StatusDTO { } /** - * The id of this port. - * - * @return + * @return id of this port */ + @ApiModelProperty( + value = "The id of the port." + ) public String getId() { return id; } @@ -73,10 +77,11 @@ public class PortStatusDTO extends StatusDTO { } /** - * The id of the group this port resides in. - * - * @return + * @return id of the group this port resides in */ + @ApiModelProperty( + value = "The id of the parent process group of the port." + ) public String getGroupId() { return groupId; } @@ -86,10 +91,11 @@ public class PortStatusDTO extends StatusDTO { } /** - * The name of this port. - * - * @return + * @return name of this port */ + @ApiModelProperty( + value = "The name of the port." + ) public String getName() { return name; } @@ -99,10 +105,11 @@ public class PortStatusDTO extends StatusDTO { } /** - * The run status of this port. - * - * @return + * @return run status of this port */ + @ApiModelProperty( + value = "The run status of the port." + ) public String getRunStatus() { return runStatus; } @@ -112,11 +119,11 @@ public class PortStatusDTO extends StatusDTO { } /** - * The total count and size of flow files that have been accepted in the - * last five minutes. - * - * @return The total processed + * @return The total count and size of flow files that have been accepted in the last five minutes */ + @ApiModelProperty( + value = "The count/size of flowfiles that have been accepted in the last 5 minutes." + ) public String getInput() { return input; } @@ -126,11 +133,11 @@ public class PortStatusDTO extends StatusDTO { } /** - * The total count and size of flow files that have been processed in the - * last five minutes. - * - * @return The total output + * @return The total count and size of flow files that have been processed in the last five minutes */ + @ApiModelProperty( + value = "The count/size of flowfiles that have been processed in the last 5 minutes." + ) public String getOutput() { return output; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ProcessGroupStatusDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ProcessGroupStatusDTO.java index 4fa2b641eb..3ebae8fc50 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ProcessGroupStatusDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ProcessGroupStatusDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Collection; import java.util.Date; import javax.xml.bind.annotation.XmlType; @@ -38,10 +39,15 @@ public class ProcessGroupStatusDTO extends StatusDTO { private Collection outputPortStatus; private String input; + private String queuedCount; + private String queuedSize; private String queued; private String read; private String written; private String output; + private String transferred; + private String received; + private String sent; private Integer activeThreadCount; private Date statsLastRefreshed; @@ -50,6 +56,9 @@ public class ProcessGroupStatusDTO extends StatusDTO { * * @return The id for the process group */ + @ApiModelProperty( + value = "The id of the process group." + ) public String getId() { return id; } @@ -59,10 +68,11 @@ public class ProcessGroupStatusDTO extends StatusDTO { } /** - * The name of this process group. - * - * @return + * @return name of this process group */ + @ApiModelProperty( + value = "The name of this process group." + ) public String getName() { return name; } @@ -72,10 +82,11 @@ public class ProcessGroupStatusDTO extends StatusDTO { } /** - * The active thread count for this process group. - * - * @return + * @return active thread count for this process group */ + @ApiModelProperty( + value = "The active thread count for this process group." + ) public Integer getActiveThreadCount() { return activeThreadCount; } @@ -89,6 +100,9 @@ public class ProcessGroupStatusDTO extends StatusDTO { * * @return The status of all connections */ + @ApiModelProperty( + value = "The status of all conenctions in the process group." + ) public Collection getConnectionStatus() { return connectionStatus; } @@ -102,6 +116,9 @@ public class ProcessGroupStatusDTO extends StatusDTO { * * @return The status of all process groups */ + @ApiModelProperty( + value = "The status of all process groups in the process group." + ) public Collection getProcessGroupStatus() { return processGroupStatus; } @@ -115,6 +132,9 @@ public class ProcessGroupStatusDTO extends StatusDTO { * * @return The status of all remote process groups */ + @ApiModelProperty( + value = "The status of all remote process groups in the process group.." + ) public Collection getRemoteProcessGroupStatus() { return remoteProcessGroupStatus; } @@ -128,6 +148,9 @@ public class ProcessGroupStatusDTO extends StatusDTO { * * @return The status of all processors */ + @ApiModelProperty( + value = "The status of all processors in the process group." + ) public Collection getProcessorStatus() { return processorStatus; } @@ -141,6 +164,9 @@ public class ProcessGroupStatusDTO extends StatusDTO { * * @return The status of all input ports */ + @ApiModelProperty( + value = "The status of all input ports in the process group." + ) public Collection getInputPortStatus() { return inputPortStatus; } @@ -154,6 +180,9 @@ public class ProcessGroupStatusDTO extends StatusDTO { * * @return The status of all output ports */ + @ApiModelProperty( + value = "The status of all output ports in the process group." + ) public Collection getOutputPortStatus() { return outputPortStatus; } @@ -167,6 +196,9 @@ public class ProcessGroupStatusDTO extends StatusDTO { * * @return The output stats */ + @ApiModelProperty( + value = "The output count/size for the process group in the last 5 minutes." + ) public String getOutput() { return output; } @@ -175,11 +207,94 @@ public class ProcessGroupStatusDTO extends StatusDTO { this.output = output; } + /** + * The transferred stats for this process group. This represents the count/size of flowfiles transferred to/from queues. + * + * @return The transferred status for this process group + */ + @ApiModelProperty( + value = "The count/size transferred to/frome queues in the process group in the last 5 minutes." + ) + public String getTransferred() { + return transferred; + } + + public void setTransferred(String transferred) { + this.transferred = transferred; + } + + /** + * The received stats for this process group. This represents the count/size of flowfiles received. + * + * @return The received stats for this process group + */ + @ApiModelProperty( + value = "The count/size sent to the process group in the last 5 minutes." + ) + public String getReceived() { + return received; + } + + public void setReceived(String received) { + this.received = received; + } + + /** + * The sent stats for this process group. This represents the count/size of flowfiles sent. + * + * @return The sent stats for this process group + */ + @ApiModelProperty( + value = "The count/size sent from this process group in the last 5 minutes." + ) + public String getSent() { + return sent; + } + + public void setSent(String sent) { + this.sent = sent; + } + + /** + * The queued count for this process group. + * + * @return The queued count for this process group + */ + @ApiModelProperty( + value = "The count that is queued for the process group." + ) + public String getQueuedCount() { + return queuedCount; + } + + public void setQueuedCount(String queuedCount) { + this.queuedCount = queuedCount; + } + + /** + * The queued size for this process group. + * + * @return The queued size for this process group + */ + @ApiModelProperty( + value = "The size that is queued for the process group." + ) + public String getQueuedSize() { + return queuedSize; + } + + public void setQueuedSize(String queuedSize) { + this.queuedSize = queuedSize; + } + /** * The queued stats for this process group. * * @return The queued stats */ + @ApiModelProperty( + value = "The count/size that is queued in the the process group." + ) public String getQueued() { return queued; } @@ -193,6 +308,9 @@ public class ProcessGroupStatusDTO extends StatusDTO { * * @return The read stats */ + @ApiModelProperty( + value = "The number of bytes read in the last 5 minutes." + ) public String getRead() { return read; } @@ -206,6 +324,9 @@ public class ProcessGroupStatusDTO extends StatusDTO { * * @return The written stats */ + @ApiModelProperty( + value = "The number of bytes written in the last 5 minutes." + ) public String getWritten() { return written; } @@ -219,6 +340,9 @@ public class ProcessGroupStatusDTO extends StatusDTO { * * @return The input stats */ + @ApiModelProperty( + value = "The input count/size for the process group in the last 5 minutes." + ) public String getInput() { return input; } @@ -233,6 +357,9 @@ public class ProcessGroupStatusDTO extends StatusDTO { * @return The the status was calculated */ @XmlJavaTypeAdapter(TimeAdapter.class) + @ApiModelProperty( + value = "The time the status for the process group was last refreshed." + ) public Date getStatsLastRefreshed() { return statsLastRefreshed; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ProcessorStatusDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ProcessorStatusDTO.java index 334adad4ed..1899418807 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ProcessorStatusDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ProcessorStatusDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -42,10 +43,11 @@ public class ProcessorStatusDTO extends StatusDTO { /* getters / setters */ /** - * The id for the processor. - * * @return The processor id */ + @ApiModelProperty( + value = "The id of the processor." + ) public String getId() { return id; } @@ -55,10 +57,11 @@ public class ProcessorStatusDTO extends StatusDTO { } /** - * The name of the processor. - * * @return The processor name */ + @ApiModelProperty( + value = "The name of the prcessor." + ) public String getName() { return name; } @@ -68,10 +71,11 @@ public class ProcessorStatusDTO extends StatusDTO { } /** - * The type of the processor. - * * @return The processor type */ + @ApiModelProperty( + value = "The type of the processor." + ) public String getType() { return type; } @@ -81,10 +85,12 @@ public class ProcessorStatusDTO extends StatusDTO { } /** - * The run status of this processor. - * - * @return + * @return run status of this processor */ + @ApiModelProperty( + value = "The state of the processor.", + allowableValues = "RUNNING, STOPPED, DISABLED, INVALID" + ) public String getRunStatus() { return runStatus; } @@ -94,11 +100,11 @@ public class ProcessorStatusDTO extends StatusDTO { } /** - * The total count and size of flow files that have been accepted in the - * last five minutes. - * - * @return The total processed + * @return The total count and size of flow files that have been accepted in the last five minutes */ + @ApiModelProperty( + value = "The count/size of flowfiles that have been accepted in the last 5 minutes." + ) public String getInput() { return input; } @@ -108,10 +114,11 @@ public class ProcessorStatusDTO extends StatusDTO { } /** - * The number of bytes read. - * - * @return + * @return number of bytes read */ + @ApiModelProperty( + value = "The number of bytes read in the last 5 minutes." + ) public String getRead() { return read; } @@ -121,10 +128,11 @@ public class ProcessorStatusDTO extends StatusDTO { } /** - * The number of bytes written. - * - * @return + * @return number of bytes written */ + @ApiModelProperty( + value = "The number of bytes written in the last 5 minutes." + ) public String getWritten() { return written; } @@ -134,10 +142,11 @@ public class ProcessorStatusDTO extends StatusDTO { } /** - * The ID of the Process Group to which this processor belongs. - * * @return the ID of the Process Group to which this processor belongs. */ + @ApiModelProperty( + value = "The id of the parent process group to which the processor belongs." + ) public String getGroupId() { return groupId; } @@ -147,11 +156,11 @@ public class ProcessorStatusDTO extends StatusDTO { } /** - * The total count and size of flow files that have been processed in the - * last five minutes. - * - * @return The total output + * @return The total count and size of flow files that have been processed in the last five minutes */ + @ApiModelProperty( + value = "The count/size of flowfiles that have been processed in the last 5 minutes." + ) public String getOutput() { return output; } @@ -161,10 +170,11 @@ public class ProcessorStatusDTO extends StatusDTO { } /** - * The number of threads currently running for this Processor - * - * @return + * @return number of threads currently running for this Processor */ + @ApiModelProperty( + value = "The number of threads currently executing in the processor." + ) public Integer getActiveThreadCount() { return activeThreadCount; } @@ -174,10 +184,11 @@ public class ProcessorStatusDTO extends StatusDTO { } /** - * The number of task this connectable has had over the last 5 minutes. - * - * @return + * @return number of task this connectable has had over the last 5 minutes */ + @ApiModelProperty( + value = "The total number of task this connectable has completed over the last 5 minutes." + ) public String getTasks() { return tasks; } @@ -187,11 +198,11 @@ public class ProcessorStatusDTO extends StatusDTO { } /** - * The total duration of all tasks for this connectable over the last 5 - * minutes. - * - * @return + * @return total duration of all tasks for this connectable over the last 5 minutes */ + @ApiModelProperty( + value = "The total duration of all tasks for this connectable over the last 5 minutes." + ) public String getTasksDuration() { return tasksDuration; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/RemotePortStatusDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/RemotePortStatusDTO.java index a8fcc9f52d..6778b0dc9b 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/RemotePortStatusDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/RemotePortStatusDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -31,10 +32,11 @@ public class RemotePortStatusDTO { private Boolean exists; /** - * The id of the connection this remote port is connected to. - * - * @return + * @return id of the connection this remote port is connected to */ + @ApiModelProperty( + value = "The id of the conneciton the remote is connected to." + ) public String getConnectionId() { return connectionId; } @@ -44,10 +46,11 @@ public class RemotePortStatusDTO { } /** - * The id of the remote port. - * - * @return + * @return id of the remote port */ + @ApiModelProperty( + value = "The id of the remote port." + ) public String getId() { return id; } @@ -57,10 +60,11 @@ public class RemotePortStatusDTO { } /** - * The name of the remote port. - * - * @return + * @return name of the remote port */ + @ApiModelProperty( + value = "The name of the remote port." + ) public String getName() { return name; } @@ -70,10 +74,11 @@ public class RemotePortStatusDTO { } /** - * Whether or not the remote port exists. - * - * @return + * @return whether or not the remote port exists */ + @ApiModelProperty( + value = "Whether or not the remote port exists." + ) public Boolean getExists() { return exists; } @@ -83,10 +88,11 @@ public class RemotePortStatusDTO { } /** - * Whether or not the remote port is running. - * - * @return + * @return whether or not the remote port is running */ + @ApiModelProperty( + value = "Whether or not the remote port is running." + ) public Boolean getRunning() { return running; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/RemoteProcessGroupStatusDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/RemoteProcessGroupStatusDTO.java index 363d4da39b..f556debef3 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/RemoteProcessGroupStatusDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/RemoteProcessGroupStatusDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.List; import javax.xml.bind.annotation.XmlType; @@ -38,10 +39,11 @@ public class RemoteProcessGroupStatusDTO extends StatusDTO { private String received; /** - * The id for the remote process group. - * * @return The id for the remote process group */ + @ApiModelProperty( + value = "The id of the remote process group." + ) public String getId() { return id; } @@ -51,10 +53,11 @@ public class RemoteProcessGroupStatusDTO extends StatusDTO { } /** - * The id of the group this remote process group is in. - * - * @return + * @return id of the group this remote process group is in */ + @ApiModelProperty( + value = "The id of the parent process group the remote process group resides in." + ) public String getGroupId() { return groupId; } @@ -64,10 +67,11 @@ public class RemoteProcessGroupStatusDTO extends StatusDTO { } /** - * The URI of the target system. - * - * @return + * @return URI of the target system */ + @ApiModelProperty( + value = "The URI of the target system." + ) public String getTargetUri() { return targetUri; } @@ -77,10 +81,11 @@ public class RemoteProcessGroupStatusDTO extends StatusDTO { } /** - * The name of this remote process group. - * - * @return + * @return name of this remote process group */ + @ApiModelProperty( + value = "The name of the remote process group." + ) public String getName() { return name; } @@ -90,10 +95,11 @@ public class RemoteProcessGroupStatusDTO extends StatusDTO { } /** - * The transmission status of this remote process group. - * - * @return + * @return transmission status of this remote process group */ + @ApiModelProperty( + value = "The transmission status of the remote process group." + ) public String getTransmissionStatus() { return transmissionStatus; } @@ -103,10 +109,11 @@ public class RemoteProcessGroupStatusDTO extends StatusDTO { } /** - * The number of active threads. - * - * @return + * @return number of active threads */ + @ApiModelProperty( + value = "The number of active threads for the remote process group." + ) public Integer getActiveThreadCount() { return activeThreadCount; } @@ -116,10 +123,11 @@ public class RemoteProcessGroupStatusDTO extends StatusDTO { } /** - * Returns any remote authorization issues for this remote process group. - * - * @return + * @return any remote authorization issues for this remote process group */ + @ApiModelProperty( + value = "Any remote authorization issues for the remote process group." + ) public List getAuthorizationIssues() { return authorizationIssues; } @@ -129,11 +137,11 @@ public class RemoteProcessGroupStatusDTO extends StatusDTO { } /** - * Formatted description of the amount of data sent to this remote process - * group. - * - * @return + * @return Formatted description of the amount of data sent to this remote process group */ + @ApiModelProperty( + value = "The count/size of the flowfiles sent to the remote process group in the last 5 minutes." + ) public String getSent() { return sent; } @@ -143,11 +151,11 @@ public class RemoteProcessGroupStatusDTO extends StatusDTO { } /** - * Formatted description of the amount of data received from this remote - * process group. - * - * @return + * @return Formatted description of the amount of data received from this remote process group */ + @ApiModelProperty( + value = "The count/size of the flowfiles received from the remote process group in the last 5 minutes." + ) public String getReceived() { return received; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusDTO.java index e4e7a450f9..39b9c06b86 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.List; import javax.xml.bind.annotation.XmlType; import org.apache.nifi.web.api.dto.BulletinDTO; @@ -29,10 +30,11 @@ public abstract class StatusDTO { private List bulletins; /** - * Bulletins for this component. - * - * @return + * @return Bulletins for this component */ + @ApiModelProperty( + value = "The current bulletins for the component." + ) public List getBulletins() { return bulletins; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusDescriptorDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusDescriptorDTO.java index a203e10d61..0a3c41856f 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusDescriptorDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusDescriptorDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -25,7 +26,6 @@ import javax.xml.bind.annotation.XmlType; public class StatusDescriptorDTO { public enum Formatter { - COUNT, DURATION, DATA_SIZE @@ -47,10 +47,11 @@ public class StatusDescriptorDTO { } /** - * The name of this status field. - * - * @return + * @return name of this status field */ + @ApiModelProperty( + value = "The name of the status field." + ) public String getField() { return field; } @@ -60,10 +61,11 @@ public class StatusDescriptorDTO { } /** - * The label of this status field. - * - * @return + * @return label of this status field */ + @ApiModelProperty( + value = "The label for the status field." + ) public String getLabel() { return label; } @@ -73,10 +75,11 @@ public class StatusDescriptorDTO { } /** - * The description of this status field. - * - * @return + * @return description of this status field */ + @ApiModelProperty( + value = "The description of the status field." + ) public String getDescription() { return description; } @@ -86,10 +89,11 @@ public class StatusDescriptorDTO { } /** - * The formatter for this descriptor. - * - * @return + * @return formatter for this descriptor */ + @ApiModelProperty( + value = "The formatter for the status descriptor." + ) public String getFormatter() { return formatter; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusHistoryDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusHistoryDTO.java index 5b97c16d71..c0ef33b115 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusHistoryDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusHistoryDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Date; import java.util.LinkedHashMap; import java.util.List; @@ -37,11 +38,12 @@ public class StatusHistoryDTO { private List statusSnapshots; /** - * When this status history was generated. - * - * @return + * @return when this status history was generated */ @XmlJavaTypeAdapter(TimeAdapter.class) + @ApiModelProperty( + value = "The timestamp when the status history was generated." + ) public Date getGenerated() { return generated; } @@ -51,10 +53,11 @@ public class StatusHistoryDTO { } /** - * The component details for this status history. - * - * @return + * @return The component details for this status history */ + @ApiModelProperty( + value = "The component details for the status history." + ) public LinkedHashMap getDetails() { return details; } @@ -64,10 +67,11 @@ public class StatusHistoryDTO { } /** - * Descriptors for each supported status field. - * - * @return + * @return Descriptors for each supported status field */ + @ApiModelProperty( + value = "The descriptor for each support status field." + ) public List getFieldDescriptors() { return fieldDescriptors; } @@ -77,10 +81,11 @@ public class StatusHistoryDTO { } /** - * The status snapshots. - * - * @return + * @return The status snapshots */ + @ApiModelProperty( + value = "The status snapshots." + ) public List getStatusSnapshots() { return statusSnapshots; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusHistoryDetailDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusHistoryDetailDTO.java index b9d16bba00..e78641e7a4 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusHistoryDetailDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusHistoryDetailDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlType; /** @@ -28,10 +29,11 @@ public class StatusHistoryDetailDTO { private String value; /** - * The label for this status detail. - * - * @return + * @return label for this status detail */ + @ApiModelProperty( + value = "The label for the status detail." + ) public String getLabel() { return label; } @@ -41,10 +43,11 @@ public class StatusHistoryDetailDTO { } /** - * The value for this status detail. - * - * @return + * @return value for this status detail */ + @ApiModelProperty( + value = "The value for the status detail." + ) public String getValue() { return value; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusSnapshotDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusSnapshotDTO.java index cc6894a617..24d801fdcb 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusSnapshotDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusSnapshotDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto.status; +import com.wordnik.swagger.annotations.ApiModelProperty; import java.util.Date; import java.util.Map; import javax.xml.bind.annotation.XmlType; @@ -30,10 +31,11 @@ public class StatusSnapshotDTO { private Map statusMetrics; /** - * The timestamp of this snapshot. - * - * @return + * @return timestamp of this snapshot */ + @ApiModelProperty( + value = "The timestamp of the snapshot." + ) public Date getTimestamp() { return timestamp; } @@ -43,10 +45,11 @@ public class StatusSnapshotDTO { } /** - * The status metrics. - * - * @return + * @return status metrics */ + @ApiModelProperty( + value = "The status metrics." + ) public Map getStatusMetrics() { return statusMetrics; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/AboutEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/AboutEntity.java index 36fc163a04..5cdbe1e53b 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/AboutEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/AboutEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.AboutDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a AboutDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a AboutDTO. */ @XmlRootElement(name = "aboutEntity") public class AboutEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ActionEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ActionEntity.java index 1b2c0b63c8..d52f5fbb4c 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ActionEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ActionEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.action.ActionDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to an ActionDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to an ActionDTO. */ @XmlRootElement(name = "actionEntity") public class ActionEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/AuthorityEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/AuthorityEntity.java index eed1305526..9b023ba302 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/AuthorityEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/AuthorityEntity.java @@ -21,9 +21,7 @@ import java.util.Set; import javax.xml.bind.annotation.XmlRootElement; /** - * A serialized representation of this class can be placed in the entity body of - * a response to the API. This particular entity holds a set of user - * authorities. + * A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a set of user authorities. */ @XmlRootElement(name = "authoritiesEntity") public class AuthorityEntity extends Entity { @@ -32,9 +30,7 @@ public class AuthorityEntity extends Entity { private Set authorities; /** - * The current user id. - * - * @return + * @return current user id */ public String getUserId() { return userId; @@ -45,9 +41,7 @@ public class AuthorityEntity extends Entity { } /** - * The set of authorities that are being serialized. - * - * @return + * @return set of authorities that are being serialized */ public Set getAuthorities() { return authorities; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/BannerEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/BannerEntity.java index 594707a6df..c9a8cd2048 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/BannerEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/BannerEntity.java @@ -21,9 +21,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.BannerDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a BannerDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a BannerDTO. */ @XmlRootElement(name = "bannersEntity") public class BannerEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/BulletinBoardEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/BulletinBoardEntity.java index 4287893ffd..f648d50e88 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/BulletinBoardEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/BulletinBoardEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.BulletinBoardDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a BulletinBoardDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a BulletinBoardDTO. */ @XmlRootElement(name = "bulletinBoardEntity") public class BulletinBoardEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterConnectionStatusEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterConnectionStatusEntity.java index 732a4b7077..f211cc40d7 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterConnectionStatusEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterConnectionStatusEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.status.ClusterConnectionStatusDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a ClusterConnectionStatusDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a ClusterConnectionStatusDTO. */ @XmlRootElement(name = "clusterConnectionStatusEntity") public class ClusterConnectionStatusEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterEntity.java index 8306b0f879..c59ce017f5 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.ClusterDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a ClusterDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a ClusterDTO. */ @XmlRootElement(name = "clusterEntity") public class ClusterEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterPortStatusEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterPortStatusEntity.java index 16a249732b..477b6ec7dc 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterPortStatusEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterPortStatusEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.status.ClusterPortStatusDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a ClusterPortStatusDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a ClusterPortStatusDTO. */ @XmlRootElement(name = "clusterPortStatusEntity") public class ClusterPortStatusEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterProcessGroupStatusEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterProcessGroupStatusEntity.java new file mode 100644 index 0000000000..f8b7e11115 --- /dev/null +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterProcessGroupStatusEntity.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.web.api.entity; + +import javax.xml.bind.annotation.XmlRootElement; +import org.apache.nifi.web.api.dto.status.ClusterProcessGroupStatusDTO; + +/** + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a ClusterProcessGroupStatusDTO. + */ +@XmlRootElement(name = "clusterProcessGroupStatusEntity") +public class ClusterProcessGroupStatusEntity extends Entity { + + private ClusterProcessGroupStatusDTO clusterProcessGroupStatus; + + /** + * The ClusterProcessGroupStatusDTO that is being serialized. + * + * @return The ClusterProcessGroupStatusDTO object + */ + public ClusterProcessGroupStatusDTO getClusterProcessGroupStatus() { + return clusterProcessGroupStatus; + } + + public void setClusterProcessGroupStatus(ClusterProcessGroupStatusDTO clusterProcessGroupStatus) { + this.clusterProcessGroupStatus = clusterProcessGroupStatus; + } + +} diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterProcessorStatusEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterProcessorStatusEntity.java index 68e5c5cac5..2b8220fe88 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterProcessorStatusEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterProcessorStatusEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.status.ClusterProcessorStatusDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a ClusterProcessorStatusDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a ClusterProcessorStatusDTO. */ @XmlRootElement(name = "clusterProcessorStatusEntity") public class ClusterProcessorStatusEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterRemoteProcessGroupStatusEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterRemoteProcessGroupStatusEntity.java index 8a3da7cbc3..66569c55e9 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterRemoteProcessGroupStatusEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterRemoteProcessGroupStatusEntity.java @@ -20,9 +20,8 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.status.ClusterRemoteProcessGroupStatusDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a ClusterRemoteProcessGroupStatusDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a + * ClusterRemoteProcessGroupStatusDTO. */ @XmlRootElement(name = "clusterRemoteProcessGroupStatusEntity") public class ClusterRemoteProcessGroupStatusEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterSearchResultsEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterSearchResultsEntity.java index 546bd8b9f5..48fc01f1df 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterSearchResultsEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterSearchResultsEntity.java @@ -21,9 +21,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.search.NodeSearchResultDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to NodeSearchResultDTOs. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to NodeSearchResultDTOs. */ @XmlRootElement(name = "clusterSearchResultsEntity") public class ClusterSearchResultsEntity { @@ -31,9 +29,7 @@ public class ClusterSearchResultsEntity { private List nodeResults; /** - * The node search results. - * - * @return + * @return node search results */ public List getNodeResults() { return nodeResults; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterStatusEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterStatusEntity.java index d22d432515..84fffb964d 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterStatusEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterStatusEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.status.ClusterStatusDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a ClusterStatusDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a ClusterStatusDTO. */ @XmlRootElement(name = "clusterStatusEntity") public class ClusterStatusEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterStatusHistoryEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterStatusHistoryEntity.java index 9ed69fd807..b13984a2a4 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterStatusHistoryEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ClusterStatusHistoryEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.status.ClusterStatusHistoryDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a ClusterStatusHistoryDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a ClusterStatusHistoryDTO. */ @XmlRootElement(name = "clusterStatusHistoryEntity") public class ClusterStatusHistoryEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ComponentHistoryEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ComponentHistoryEntity.java index ca682110df..a6e705fd26 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ComponentHistoryEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ComponentHistoryEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.ComponentHistoryDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a ComponentHistoryDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a ComponentHistoryDTO. */ @XmlRootElement(name = "componentHistoryEntity") public class ComponentHistoryEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ConnectionEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ConnectionEntity.java index 69ae937e21..b041e51cfc 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ConnectionEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ConnectionEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.ConnectionDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a response to the API. This particular entity holds a reference to a - * ConnectionDTO. + * A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a ConnectionDTO. */ @XmlRootElement(name = "connectionEntity") public class ConnectionEntity extends Entity { @@ -30,9 +28,7 @@ public class ConnectionEntity extends Entity { private ConnectionDTO connection; /** - * The RelationshipDTO that is being serialized. - * - * @return + * @return RelationshipDTO that is being serialized */ public ConnectionDTO getConnection() { return connection; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ConnectionsEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ConnectionsEntity.java index c69c69ae3d..5b2b1b0ed0 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ConnectionsEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ConnectionsEntity.java @@ -22,9 +22,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.ConnectionDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a response to the API. This particular entity holds a reference to a list of - * ConnectionDTOs. + * A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of ConnectionDTOs. */ @XmlRootElement(name = "connectionsEntity") public class ConnectionsEntity extends Entity { @@ -32,9 +30,7 @@ public class ConnectionsEntity extends Entity { private Set connections; /** - * The list of ConnectionDTOs that are being serialized. - * - * @return + * @return list of ConnectionDTOs that are being serialized */ public Set getConnections() { return connections; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerConfigurationEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerConfigurationEntity.java index e13903b267..22c859e51a 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerConfigurationEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerConfigurationEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.ControllerConfigurationDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a ControllerConfigurationDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a ControllerConfigurationDTO. */ @XmlRootElement(name = "controllerConfigurationEntity") public class ControllerConfigurationEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerEntity.java index 62d0409efe..706f538f3a 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.ControllerDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a ControllerDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a ControllerDTO. */ @XmlRootElement(name = "controllerEntity") public class ControllerEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerServiceEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerServiceEntity.java index 44364e712c..8f217b5b28 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerServiceEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerServiceEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.ControllerServiceDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a response to the API. This particular entity holds a reference to a - * controller service. + * A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a controller service. */ @XmlRootElement(name = "controllerServiceEntity") public class ControllerServiceEntity extends Entity { @@ -30,9 +28,7 @@ public class ControllerServiceEntity extends Entity { private ControllerServiceDTO controllerService; /** - * The controller service that is being serialized. - * - * @return + * @return controller service that is being serialized */ public ControllerServiceDTO getControllerService() { return controllerService; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerServiceReferencingComponentsEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerServiceReferencingComponentsEntity.java index 6010f93014..c6be79dd18 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerServiceReferencingComponentsEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerServiceReferencingComponentsEntity.java @@ -21,9 +21,8 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.ControllerServiceReferencingComponentDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a response to the API. This particular entity holds a reference to a list of - * controller services referencing components. + * A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of controller services referencing + * components. */ @XmlRootElement(name = "controllerServiceReferencingComponentsEntity") public class ControllerServiceReferencingComponentsEntity extends Entity { @@ -31,9 +30,7 @@ public class ControllerServiceReferencingComponentsEntity extends Entity { private Set controllerServiceReferencingComponents; /** - * The list of controller service referencing components that are being serialized. - * - * @return + * @return list of controller service referencing components that are being serialized */ public Set getControllerServiceReferencingComponents() { return controllerServiceReferencingComponents; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerServiceTypesEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerServiceTypesEntity.java index dafb8c22af..8b8bae48e4 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerServiceTypesEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerServiceTypesEntity.java @@ -21,9 +21,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.DocumentedTypeDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a response to the API. This particular entity holds a reference to a list of - * controller service types. + * A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of controller service types. */ @XmlRootElement(name = "controllerServiceTypesEntity") public class ControllerServiceTypesEntity extends Entity { @@ -31,9 +29,7 @@ public class ControllerServiceTypesEntity extends Entity { private Set controllerServiceTypes; /** - * The list of controller service types that are being serialized. - * - * @return + * @return list of controller service types that are being serialized */ public Set getControllerServiceTypes() { return controllerServiceTypes; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerServicesEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerServicesEntity.java index 4485b43d15..9c2c366276 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerServicesEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerServicesEntity.java @@ -21,9 +21,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.ControllerServiceDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a response to the API. This particular entity holds a reference to a list of - * controller services. + * A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of controller services. */ @XmlRootElement(name = "controllerServicesEntity") public class ControllerServicesEntity extends Entity { @@ -31,9 +29,7 @@ public class ControllerServicesEntity extends Entity { private Set controllerServices; /** - * The list of controller services that are being serialized. - * - * @return + * @return list of controller services that are being serialized */ public Set getControllerServices() { return controllerServices; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerStatusEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerStatusEntity.java index 94d8aca23f..6183546246 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerStatusEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerStatusEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.status.ControllerStatusDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a ControllerStatusDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a ControllerStatusDTO. */ @XmlRootElement(name = "controllerStatusEntity") public class ControllerStatusEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/CounterEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/CounterEntity.java index 666dc75fea..c84d11eb2e 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/CounterEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/CounterEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.CounterDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a response from the API. This particular entity holds a reference to a - * CounterDTO. + * A serialized representation of this class can be placed in the entity body of a response from the API. This particular entity holds a reference to a CounterDTO. */ @XmlRootElement(name = "counterEntity") public class CounterEntity extends Entity { @@ -30,9 +28,7 @@ public class CounterEntity extends Entity { private CounterDTO counter; /** - * Get the counter. - * - * @return + * @return the counter */ public CounterDTO getCounter() { return counter; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/CountersEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/CountersEntity.java index bee76692fc..dabd5a177f 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/CountersEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/CountersEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.CountersDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a response from the API. This particular entity holds a reference to a - * CountersDTO. + * A serialized representation of this class can be placed in the entity body of a response from the API. This particular entity holds a reference to a CountersDTO. */ @XmlRootElement(name = "countersEntity") public class CountersEntity extends Entity { @@ -30,10 +28,7 @@ public class CountersEntity extends Entity { private CountersDTO counters; /** - * Get the counters which contains all the counter groups and a generation - * date. - * - * @return + * @return the counters which contains all the counter groups and a generation date */ public CountersDTO getCounters() { return counters; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/Entity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/Entity.java index 6abcbf391a..ad3a7dee40 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/Entity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/Entity.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.entity; +import com.wordnik.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.RevisionDTO; @@ -28,10 +29,11 @@ public class Entity { private RevisionDTO revision; /** - * A revision for this request/response. - * - * @return + * @return revision for this request/response */ + @ApiModelProperty( + value = "The revision for this request/response. The revision is required for any mutable flow requests and is included in all responses." + ) public RevisionDTO getRevision() { return revision; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/FlowSnippetEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/FlowSnippetEntity.java index a15cc51de3..bff4a51c83 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/FlowSnippetEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/FlowSnippetEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.FlowSnippetDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a FlowSnippetDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a FlowSnippetDTO. */ @XmlRootElement(name = "flowSnippetEntity") public class FlowSnippetEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/FunnelEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/FunnelEntity.java index 8b43fb8bbd..241ac51439 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/FunnelEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/FunnelEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.FunnelDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a FunnelDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a FunnelDTO. */ @XmlRootElement(name = "funnelEntity") public class FunnelEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/FunnelsEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/FunnelsEntity.java index 2b8cbc88db..34426db42d 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/FunnelsEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/FunnelsEntity.java @@ -22,9 +22,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.FunnelDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a response to the API. This particular entity holds a reference to a list of - * FunnelDTOs. + * A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of FunnelDTOs. */ @XmlRootElement(name = "funnelsEntity") public class FunnelsEntity extends Entity { @@ -32,9 +30,7 @@ public class FunnelsEntity extends Entity { private Set funnels; /** - * The collection of FunnelDTOs that are being serialized. - * - * @return + * @return collection of FunnelDTOs that are being serialized */ public Set getFunnels() { return funnels; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/HistoryEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/HistoryEntity.java index f817cce4bd..72a46561b6 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/HistoryEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/HistoryEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.action.HistoryDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a HistoryDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a HistoryDTO. */ @XmlRootElement(name = "historyEntity") public class HistoryEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/InputPortEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/InputPortEntity.java index 9fec9d8727..f92c47802f 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/InputPortEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/InputPortEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.PortDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a response to the API. This particular entity holds a reference to an input - * PortDTO. + * A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to an input PortDTO. */ @XmlRootElement(name = "inputPortEntity") public class InputPortEntity extends Entity { @@ -30,9 +28,7 @@ public class InputPortEntity extends Entity { private PortDTO inputPort; /** - * The input PortDTO that are being serialized. - * - * @return + * @return input PortDTO that are being serialized */ public PortDTO getInputPort() { return inputPort; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/InputPortsEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/InputPortsEntity.java index 8637596284..93a03e7127 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/InputPortsEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/InputPortsEntity.java @@ -22,9 +22,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.PortDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a response to the API. This particular entity holds a reference to a list of - * input PortDTOs. + * A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of input PortDTOs. */ @XmlRootElement(name = "inputPortsEntity") public class InputPortsEntity extends Entity { @@ -32,9 +30,7 @@ public class InputPortsEntity extends Entity { private Set inputPorts; /** - * The collection of input PortDTOs that are being serialized. - * - * @return + * @return collection of input PortDTOs that are being serialized */ public Set getInputPorts() { return inputPorts; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/LabelEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/LabelEntity.java index 867d781402..535240c194 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/LabelEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/LabelEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.LabelDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a LabelDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a LabelDTO. */ @XmlRootElement(name = "labelEntity") public class LabelEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/LabelsEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/LabelsEntity.java index 063eeafe40..05dab6c371 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/LabelsEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/LabelsEntity.java @@ -22,9 +22,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.LabelDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a response to the API. This particular entity holds a reference to a list of - * LabelDTOs. + * A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of LabelDTOs. */ @XmlRootElement(name = "labelsEntity") public class LabelsEntity extends Entity { @@ -32,9 +30,7 @@ public class LabelsEntity extends Entity { private Set labels; /** - * The collection of LabelDTOs that are being serialized. - * - * @return + * @return collection of LabelDTOs that are being serialized */ public Set getLabels() { return labels; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/LineageEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/LineageEntity.java index 5d443af89b..6bcf039ff4 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/LineageEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/LineageEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.provenance.lineage.LineageDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a LineageDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a LineageDTO. */ @XmlRootElement(name = "lineageEntity") public class LineageEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/NodeEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/NodeEntity.java index ac5b306f16..75c9c4ca08 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/NodeEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/NodeEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.NodeDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a NodeDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a NodeDTO. */ @XmlRootElement(name = "nodeEntity") public class NodeEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/NodeStatusEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/NodeStatusEntity.java index d7471dae67..54ba306ee4 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/NodeStatusEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/NodeStatusEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.status.NodeStatusDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a NodeStatusDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a NodeStatusDTO. */ @XmlRootElement(name = "nodeStatusEntity") public class NodeStatusEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/NodeSystemDiagnosticsEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/NodeSystemDiagnosticsEntity.java index 59eafa16b7..443276c05a 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/NodeSystemDiagnosticsEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/NodeSystemDiagnosticsEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.NodeSystemDiagnosticsDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a NodeSystemDiagnosticsDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a NodeSystemDiagnosticsDTO. */ @XmlRootElement(name = "nodeSystemDiagnosticsEntity") public class NodeSystemDiagnosticsEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/OutputPortEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/OutputPortEntity.java index 07fdab7589..4f40aec66e 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/OutputPortEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/OutputPortEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.PortDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a response to the API. This particular entity holds a reference to an output - * PortDTO. + * A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to an output PortDTO. */ @XmlRootElement(name = "outputPortEntity") public class OutputPortEntity extends Entity { @@ -30,9 +28,7 @@ public class OutputPortEntity extends Entity { private PortDTO outputPort; /** - * The output PortDTO that are being serialized. - * - * @return + * @return output PortDTO that are being serialized */ public PortDTO getOutputPort() { return outputPort; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/OutputPortsEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/OutputPortsEntity.java index 9fa398dadd..e624c52e02 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/OutputPortsEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/OutputPortsEntity.java @@ -22,9 +22,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.PortDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a response to the API. This particular entity holds a reference to a list of - * output PortDTOs. + * A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of output PortDTOs. */ @XmlRootElement(name = "outputPortsEntity") public class OutputPortsEntity extends Entity { @@ -32,9 +30,7 @@ public class OutputPortsEntity extends Entity { private Set outputPorts; /** - * The collection of output PortDTOs that are being serialized. - * - * @return + * @return collection of output PortDTOs that are being serialized */ public Set getOutputPorts() { return outputPorts; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/PrioritizerTypesEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/PrioritizerTypesEntity.java index 2ddddd8887..7f1dfa325a 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/PrioritizerTypesEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/PrioritizerTypesEntity.java @@ -21,9 +21,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.DocumentedTypeDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a response to the API. This particular entity holds a reference to a list of - * prioritizer types. + * A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of prioritizer types. */ @XmlRootElement(name = "prioritizerTypesEntity") public class PrioritizerTypesEntity extends Entity { @@ -31,9 +29,7 @@ public class PrioritizerTypesEntity extends Entity { private Set prioritizerTypes; /** - * The list of prioritizer types that are being serialized. - * - * @return + * @return list of prioritizer types that are being serialized */ public Set getPrioritizerTypes() { return prioritizerTypes; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessGroupEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessGroupEntity.java index c677ef1a24..d1ec034271 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessGroupEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessGroupEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.ProcessGroupDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a ProcessGroupDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a ProcessGroupDTO. */ @XmlRootElement(name = "processGroupEntity") public class ProcessGroupEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessGroupStatusEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessGroupStatusEntity.java index f0a6e0f651..d7d857f3a1 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessGroupStatusEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessGroupStatusEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.status.ProcessGroupStatusDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a ProcessGroupStatusDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a ProcessGroupStatusDTO. */ @XmlRootElement(name = "processGroupStatusEntity") public class ProcessGroupStatusEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessGroupsEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessGroupsEntity.java index 1fdf23f839..7acf650e4a 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessGroupsEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessGroupsEntity.java @@ -21,9 +21,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.ProcessGroupDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a set of ProcessGroupDTOs. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a set of ProcessGroupDTOs. */ @XmlRootElement(name = "processGroupsEntity") public class ProcessGroupsEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessorEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessorEntity.java index 21ad431df4..e03bb85ef3 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessorEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessorEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.ProcessorDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a ProcessorDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a ProcessorDTO. */ @XmlRootElement(name = "processorEntity") public class ProcessorEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessorTypesEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessorTypesEntity.java index 23237fe7e1..17cf7fd226 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessorTypesEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessorTypesEntity.java @@ -21,9 +21,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.DocumentedTypeDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a response to the API. This particular entity holds a reference to a list of - * processor types. + * A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of processor types. */ @XmlRootElement(name = "processorTypesEntity") public class ProcessorTypesEntity extends Entity { @@ -31,9 +29,7 @@ public class ProcessorTypesEntity extends Entity { private Set processorTypes; /** - * The list of processor types that are being serialized. - * - * @return + * @return list of processor types that are being serialized */ public Set getProcessorTypes() { return processorTypes; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessorsEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessorsEntity.java index 4962b38a8c..04db99fb32 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessorsEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessorsEntity.java @@ -22,9 +22,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.ProcessorDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a response to the API. This particular entity holds a reference to a list of - * ProcessorDTOs. + * A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of ProcessorDTOs. */ @XmlRootElement(name = "processorsEntity") public class ProcessorsEntity extends Entity { @@ -32,9 +30,7 @@ public class ProcessorsEntity extends Entity { private Set processors; /** - * The collection of ProcessorDTOs that are being serialized. - * - * @return + * @return collection of ProcessorDTOs that are being serialized */ public Set getProcessors() { return processors; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/PropertyDescriptorEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/PropertyDescriptorEntity.java index 9251b7f220..478952c4af 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/PropertyDescriptorEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/PropertyDescriptorEntity.java @@ -17,13 +17,10 @@ package org.apache.nifi.web.api.entity; import javax.xml.bind.annotation.XmlRootElement; -import org.apache.nifi.web.api.dto.ProcessorDTO; import org.apache.nifi.web.api.dto.PropertyDescriptorDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a PropertyDescriptorDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a PropertyDescriptorDTO. */ @XmlRootElement(name = "propertyDescriptor") public class PropertyDescriptorEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProvenanceEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProvenanceEntity.java index 72a85285fb..c26f9aa2be 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProvenanceEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProvenanceEntity.java @@ -25,9 +25,7 @@ public class ProvenanceEntity extends Entity { private ProvenanceDTO provenance; /** - * The provenance . - * - * @return + * @return provenance */ public ProvenanceDTO getProvenance() { return provenance; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProvenanceEventEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProvenanceEventEntity.java index 0aa0a5528d..0396145cba 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProvenanceEventEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProvenanceEventEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.provenance.ProvenanceEventDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a ProvenanceEventDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a ProvenanceEventDTO. */ @XmlRootElement(name = "provenanceEventEntity") public class ProvenanceEventEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProvenanceOptionsEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProvenanceOptionsEntity.java index 01591cb3a8..e4510d62bc 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProvenanceOptionsEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProvenanceOptionsEntity.java @@ -21,9 +21,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.provenance.ProvenanceOptionsDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a ProvenanceOptionsDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a ProvenanceOptionsDTO. */ @XmlRootElement(name = "provenanceOptionsEntity") public class ProvenanceOptionsEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RemoteProcessGroupEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RemoteProcessGroupEntity.java index 62a84d6abb..ba12f40f3f 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RemoteProcessGroupEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RemoteProcessGroupEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.RemoteProcessGroupDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a RemoteProcessGroupDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a RemoteProcessGroupDTO. */ @XmlRootElement(name = "remoteProcessGroupEntity") public class RemoteProcessGroupEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RemoteProcessGroupPortEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RemoteProcessGroupPortEntity.java index f310b5e5ec..9d5189af5c 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RemoteProcessGroupPortEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RemoteProcessGroupPortEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a RemoteProcessGroupPortDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a RemoteProcessGroupPortDTO. */ @XmlRootElement(name = "remoteProcessGroupPortEntity") public class RemoteProcessGroupPortEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RemoteProcessGroupsEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RemoteProcessGroupsEntity.java index a04c789636..42abf238a7 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RemoteProcessGroupsEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RemoteProcessGroupsEntity.java @@ -22,9 +22,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.RemoteProcessGroupDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a response to the API. This particular entity holds a reference to a list of - * RemoteProcessGroupDTOs. + * A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of RemoteProcessGroupDTOs. */ @XmlRootElement(name = "remoteProcessGroupsEntity") public class RemoteProcessGroupsEntity extends Entity { @@ -32,9 +30,7 @@ public class RemoteProcessGroupsEntity extends Entity { private Set remoteProcessGroups; /** - * The collection of RemoteProcessGroupDTOs that are being serialized. - * - * @return + * @return collection of RemoteProcessGroupDTOs that are being serialized */ public Set getRemoteProcessGroups() { return remoteProcessGroups; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ReportingTaskEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ReportingTaskEntity.java index a372751712..3c07dd74bb 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ReportingTaskEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ReportingTaskEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.ReportingTaskDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a response to the API. This particular entity holds a reference to a - * reporting task. + * A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a reporting task. */ @XmlRootElement(name = "reportingTaskEntity") public class ReportingTaskEntity extends Entity { @@ -30,9 +28,7 @@ public class ReportingTaskEntity extends Entity { private ReportingTaskDTO reportingTask; /** - * The reporting task that is being serialized. - * - * @return + * @return reporting task that is being serialized */ public ReportingTaskDTO getReportingTask() { return reportingTask; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ReportingTaskTypesEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ReportingTaskTypesEntity.java index 4b021efb44..da995319c3 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ReportingTaskTypesEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ReportingTaskTypesEntity.java @@ -21,9 +21,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.DocumentedTypeDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a response to the API. This particular entity holds a reference to a list of - * reporting task types. + * A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of reporting task types. */ @XmlRootElement(name = "reportingTaskTypesEntity") public class ReportingTaskTypesEntity extends Entity { @@ -31,9 +29,7 @@ public class ReportingTaskTypesEntity extends Entity { private Set reportingTaskTypes; /** - * The list of reporting task types that are being serialized. - * - * @return + * @return list of reporting task types that are being serialized */ public Set getReportingTaskTypes() { return reportingTaskTypes; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ReportingTasksEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ReportingTasksEntity.java index 4699d5d3c4..b493594cb4 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ReportingTasksEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ReportingTasksEntity.java @@ -21,9 +21,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.ReportingTaskDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a response to the API. This particular entity holds a reference to a list of - * reporting tasks. + * A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of reporting tasks. */ @XmlRootElement(name = "reportingTasksEntity") public class ReportingTasksEntity extends Entity { @@ -31,9 +29,7 @@ public class ReportingTasksEntity extends Entity { private Set reportingTasks; /** - * The list of reporting tasks that are being serialized. - * - * @return + * @return list of reporting tasks that are being serialized */ public Set getReportingTasks() { return reportingTasks; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/SearchResultsEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/SearchResultsEntity.java index 6b9a88b3ff..43aa3cfa1b 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/SearchResultsEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/SearchResultsEntity.java @@ -20,10 +20,8 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.search.SearchResultsDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to ProcessorSearchResultDTOs, RemoteProcessGroupSearchResultDTOs, - * and ConnectionSearchResultDTOs. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to ProcessorSearchResultDTOs, + * RemoteProcessGroupSearchResultDTOs, and ConnectionSearchResultDTOs. */ @XmlRootElement(name = "searchResultsEntity") public class SearchResultsEntity { @@ -31,9 +29,7 @@ public class SearchResultsEntity { private SearchResultsDTO searchResultsDTO; /** - * The search results. - * - * @return + * @return search results */ public SearchResultsDTO getSearchResultsDTO() { return searchResultsDTO; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/SnippetEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/SnippetEntity.java index a9b05a1cc3..d20e61dfae 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/SnippetEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/SnippetEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.SnippetDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a SnippetDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a SnippetDTO. */ @XmlRootElement(name = "snippetEntity") public class SnippetEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/StatusHistoryEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/StatusHistoryEntity.java index d3c2247d3a..98891ffb25 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/StatusHistoryEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/StatusHistoryEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.status.StatusHistoryDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a StatusHistoryDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a StatusHistoryDTO. */ @XmlRootElement(name = "statusHistoryEntity") public class StatusHistoryEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/SystemDiagnosticsEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/SystemDiagnosticsEntity.java index e7baa1606b..8c8b865569 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/SystemDiagnosticsEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/SystemDiagnosticsEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.SystemDiagnosticsDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a SystemDiagnosticsDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a SystemDiagnosticsDTO. */ @XmlRootElement(name = "systemDiagnosticsEntity") public class SystemDiagnosticsEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/TemplateEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/TemplateEntity.java index 8e9f07a2a8..553d686a27 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/TemplateEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/TemplateEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.TemplateDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a TemplateDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a TemplateDTO. */ @XmlRootElement(name = "templateEntity") public class TemplateEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/TemplatesEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/TemplatesEntity.java index 34000453f2..3a9f46d70b 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/TemplatesEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/TemplatesEntity.java @@ -24,9 +24,7 @@ import org.apache.nifi.web.api.dto.TemplateDTO; import org.apache.nifi.web.api.dto.util.TimeAdapter; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a set of TemplateDTOs. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a set of TemplateDTOs. */ @XmlRootElement(name = "templatesEntity") public class TemplatesEntity extends Entity { @@ -48,9 +46,7 @@ public class TemplatesEntity extends Entity { } /** - * When this content was generated. - * - * @return + * @return When this content was generated */ @XmlJavaTypeAdapter(TimeAdapter.class) public Date getGenerated() { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UserEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UserEntity.java index 963e853e50..71554dd83d 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UserEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UserEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.UserDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a UserDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a UserDTO. */ @XmlRootElement(name = "userEntity") public class UserEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UserGroupEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UserGroupEntity.java index a6542c8f8b..35a88d5fe7 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UserGroupEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UserGroupEntity.java @@ -20,9 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.web.api.dto.UserGroupDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a UserGroupDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a UserGroupDTO. */ @XmlRootElement(name = "userGroupEntity") public class UserGroupEntity extends Entity { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UserSearchResultsEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UserSearchResultsEntity.java index baffe1511c..fcdeee3a20 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UserSearchResultsEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UserSearchResultsEntity.java @@ -22,9 +22,8 @@ import org.apache.nifi.web.api.dto.search.UserGroupSearchResultDTO; import org.apache.nifi.web.api.dto.search.UserSearchResultDTO; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to UserSearchResultDTOs and UserGroupSearchResultDTOs. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to UserSearchResultDTOs and + * UserGroupSearchResultDTOs. */ @XmlRootElement(name = "userSearchResultsEntity") public class UserSearchResultsEntity { @@ -33,9 +32,7 @@ public class UserSearchResultsEntity { private List userGroupResults; /** - * The user search results. - * - * @return + * @return user search results */ public List getUserResults() { return userResults; @@ -46,9 +43,7 @@ public class UserSearchResultsEntity { } /** - * The user group search results. - * - * @return + * @return user group search results */ public List getUserGroupResults() { return userGroupResults; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UsersEntity.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UsersEntity.java index 2d11d1f0cb..4acc7cb534 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UsersEntity.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UsersEntity.java @@ -24,9 +24,7 @@ import org.apache.nifi.web.api.dto.UserDTO; import org.apache.nifi.web.api.dto.util.TimeAdapter; /** - * A serialized representation of this class can be placed in the entity body of - * a request or response to or from the API. This particular entity holds a - * reference to a collection of UserDTO. + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a collection of UserDTO. */ @XmlRootElement(name = "usersEntity") public class UsersEntity extends Entity { @@ -48,9 +46,7 @@ public class UsersEntity extends Entity { } /** - * When this content was generated. - * - * @return + * @return When this content was generated */ @XmlJavaTypeAdapter(TimeAdapter.class) public Date getGenerated() { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/DoesDnExistMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/DoesDnExistMessage.java index 38d0dd861e..54361406f2 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/DoesDnExistMessage.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/DoesDnExistMessage.java @@ -20,7 +20,6 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.cluster.authorization.protocol.message.ProtocolMessage.MessageType; /** - * @author unattributed */ @XmlRootElement(name = "doesDnExistMessage") public class DoesDnExistMessage extends ProtocolMessage { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/GetAuthoritiesMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/GetAuthoritiesMessage.java index 347163f184..50d371d0ac 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/GetAuthoritiesMessage.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/GetAuthoritiesMessage.java @@ -22,7 +22,6 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.authorization.Authority; /** - * @author unattributed */ @XmlRootElement(name = "getAuthoritiesMessage") public class GetAuthoritiesMessage extends ProtocolMessage { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/GetGroupForUserMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/GetGroupForUserMessage.java index 717f2444e2..72a6af59aa 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/GetGroupForUserMessage.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/GetGroupForUserMessage.java @@ -19,7 +19,6 @@ package org.apache.nifi.cluster.authorization.protocol.message; import javax.xml.bind.annotation.XmlRootElement; /** - * @author unattributed */ @XmlRootElement(name = "getGroupForUserMessage") public class GetGroupForUserMessage extends ProtocolMessage { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/ProtocolMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/ProtocolMessage.java index 102142aa60..ddeb69e2c0 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/ProtocolMessage.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/ProtocolMessage.java @@ -17,7 +17,6 @@ package org.apache.nifi.cluster.authorization.protocol.message; /** - * @author unattributed */ public abstract class ProtocolMessage { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/jaxb/JaxbProtocolUtils.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/jaxb/JaxbProtocolUtils.java index 97a1bc7f0b..2a32d849d9 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/jaxb/JaxbProtocolUtils.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/jaxb/JaxbProtocolUtils.java @@ -20,7 +20,6 @@ import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; /** - * @author unattributed */ public final class JaxbProtocolUtils { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/jaxb/ObjectFactory.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/jaxb/ObjectFactory.java index 5cde335919..2e70a1937f 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/jaxb/ObjectFactory.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/src/main/java/org/apache/nifi/cluster/authorization/protocol/message/jaxb/ObjectFactory.java @@ -22,7 +22,6 @@ import org.apache.nifi.cluster.authorization.protocol.message.GetAuthoritiesMess import org.apache.nifi.cluster.authorization.protocol.message.GetGroupForUserMessage; /** - * @author unattributed */ @XmlRegistry public class ObjectFactory { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/DocGenerator.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/DocGenerator.java index 8a53f00ca0..ea033c5ebb 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/DocGenerator.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/DocGenerator.java @@ -54,7 +54,7 @@ public class DocGenerator { * Generates documentation into the work/docs dir specified by * NiFiProperties. * - * @param properties + * @param properties to lookup nifi properties */ public static void generate(final NiFiProperties properties) { @SuppressWarnings("rawtypes") @@ -90,10 +90,10 @@ public class DocGenerator { * @param docsDir the work\docs\components dir to stick component * documentation in * @param componentClass the class to document - * @throws InstantiationException - * @throws IllegalAccessException - * @throws IOException - * @throws InitializationException + * @throws InstantiationException ie + * @throws IllegalAccessException iae + * @throws IOException ioe + * @throws InitializationException ie */ private static void document(final File docsDir, final Class componentClass) throws InstantiationException, IllegalAccessException, IOException, InitializationException { @@ -163,7 +163,7 @@ public class DocGenerator { * Checks to see if a directory to write to has an additionalDetails.html in * it already. * - * @param directory + * @param directory to check * @return true if additionalDetails.html exists, false otherwise. */ private static boolean hasAdditionalInfo(File directory) { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java index 243aaa35ae..d7bad78f75 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; import java.util.List; +import java.util.Set; import javax.xml.stream.FactoryConfigurationError; import javax.xml.stream.XMLOutputFactory; @@ -36,6 +37,7 @@ import org.apache.nifi.components.ConfigurableComponent; import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.controller.ControllerService; import org.apache.nifi.documentation.DocumentationWriter; +import org.apache.nifi.nar.ExtensionManager; /** * Generates HTML documentation for a ConfigurableComponent. This class is used @@ -72,13 +74,11 @@ public class HtmlDocumentationWriter implements DocumentationWriter { /** * Writes the head portion of the HTML documentation. - * - * @param configurableComponent - * the component to describe - * @param xmlStreamWriter - * the stream to write to - * @throws XMLStreamException - * thrown if there was a problem writing to the stream + * + * @param configurableComponent the component to describe + * @param xmlStreamWriter the stream to write to + * @throws XMLStreamException thrown if there was a problem writing to the + * stream */ protected void writeHead(final ConfigurableComponent configurableComponent, final XMLStreamWriter xmlStreamWriter) throws XMLStreamException { @@ -99,9 +99,8 @@ public class HtmlDocumentationWriter implements DocumentationWriter { /** * Gets the class name of the component. - * - * @param configurableComponent - * the component to describe + * + * @param configurableComponent the component to describe * @return the class name of the component */ protected String getTitle(final ConfigurableComponent configurableComponent) { @@ -111,15 +110,13 @@ public class HtmlDocumentationWriter implements DocumentationWriter { /** * Writes the body section of the documentation, this consists of the * component description, the tags, and the PropertyDescriptors. - * - * @param configurableComponent - * the component to describe - * @param xmlStreamWriter - * the stream writer - * @param hasAdditionalDetails - * whether there are additional details present or not - * @throws XMLStreamException - * thrown if there was a problem writing to the XML stream + * + * @param configurableComponent the component to describe + * @param xmlStreamWriter the stream writer + * @param hasAdditionalDetails whether there are additional details present + * or not + * @throws XMLStreamException thrown if there was a problem writing to the + * XML stream */ private void writeBody(final ConfigurableComponent configurableComponent, final XMLStreamWriter xmlStreamWriter, final boolean hasAdditionalDetails) @@ -136,13 +133,10 @@ public class HtmlDocumentationWriter implements DocumentationWriter { /** * Writes the list of components that may be linked from this component. - * - * @param configurableComponent - * the component to describe - * @param xmlStreamWriter - * the stream writer to use - * @throws XMLStreamException - * thrown if there was a problem writing the XML + * + * @param configurableComponent the component to describe + * @param xmlStreamWriter the stream writer to use + * @throws XMLStreamException thrown if there was a problem writing the XML */ private void writeSeeAlso(ConfigurableComponent configurableComponent, XMLStreamWriter xmlStreamWriter) throws XMLStreamException { @@ -156,13 +150,11 @@ public class HtmlDocumentationWriter implements DocumentationWriter { xmlStreamWriter.writeCharacters(", "); } - final String link = "../" + linkedComponent.getCanonicalName() + "/index.html"; - - writeLink(xmlStreamWriter, linkedComponent.getSimpleName(), link); + writeLinkForComponent(xmlStreamWriter, linkedComponent); ++index; } - + for (final String linkedComponent : seeAlso.classNames()) { if (index != 0) { xmlStreamWriter.writeCharacters(", "); @@ -171,7 +163,7 @@ public class HtmlDocumentationWriter implements DocumentationWriter { final String link = "../" + linkedComponent + "/index.html"; final int indexOfLastPeriod = linkedComponent.lastIndexOf(".") + 1; - + writeLink(xmlStreamWriter, linkedComponent.substring(indexOfLastPeriod), link); ++index; @@ -183,26 +175,17 @@ public class HtmlDocumentationWriter implements DocumentationWriter { /** * This method may be overridden by sub classes to write additional * information to the body of the documentation. - * - * @param configurableComponent - * the component to describe - * @param xmlStreamWriter - * the stream writer - * @throws XMLStreamException - * thrown if there was a problem writing to the XML stream + * + * @param configurableComponent the component to describe + * @param xmlStreamWriter the stream writer + * @throws XMLStreamException thrown if there was a problem writing to the + * XML stream */ protected void writeAdditionalBodyInfo(final ConfigurableComponent configurableComponent, final XMLStreamWriter xmlStreamWriter) throws XMLStreamException { } - /** - * Writes the tags attached to a ConfigurableComponent. - * - * @param configurableComponent - * @param xmlStreamWriter - * @throws XMLStreamException - */ private void writeTags(final ConfigurableComponent configurableComponent, final XMLStreamWriter xmlStreamWriter) throws XMLStreamException { final Tags tags = configurableComponent.getClass().getAnnotation(Tags.class); @@ -218,30 +201,27 @@ public class HtmlDocumentationWriter implements DocumentationWriter { } xmlStreamWriter.writeEndElement(); } - + static String join(final String[] toJoin, final String delimiter) { - final StringBuilder sb = new StringBuilder(); - for (int i=0; i < toJoin.length; i++) { - sb.append(toJoin[i]); - if ( i < toJoin.length - 1 ) { - sb.append(delimiter); - } - } - return sb.toString(); + final StringBuilder sb = new StringBuilder(); + for (int i = 0; i < toJoin.length; i++) { + sb.append(toJoin[i]); + if (i < toJoin.length - 1) { + sb.append(delimiter); + } + } + return sb.toString(); } /** * Writes a description of the configurable component. - * - * @param configurableComponent - * the component to describe - * @param xmlStreamWriter - * the stream writer - * @param hasAdditionalDetails - * whether there are additional details available as - * 'additionalDetails.html' - * @throws XMLStreamException - * thrown if there was a problem writing to the XML stream + * + * @param configurableComponent the component to describe + * @param xmlStreamWriter the stream writer + * @param hasAdditionalDetails whether there are additional details + * available as 'additionalDetails.html' + * @throws XMLStreamException thrown if there was a problem writing to the + * XML stream */ protected void writeDescription(final ConfigurableComponent configurableComponent, final XMLStreamWriter xmlStreamWriter, final boolean hasAdditionalDetails) @@ -260,9 +240,8 @@ public class HtmlDocumentationWriter implements DocumentationWriter { /** * Gets a description of the ConfigurableComponent using the * CapabilityDescription annotation. - * - * @param configurableComponent - * the component to describe + * + * @param configurableComponent the component to describe * @return a description of the configurableComponent */ protected String getDescription(final ConfigurableComponent configurableComponent) { @@ -281,13 +260,11 @@ public class HtmlDocumentationWriter implements DocumentationWriter { /** * Writes the PropertyDescriptors out as a table. - * - * @param configurableComponent - * the component to describe - * @param xmlStreamWriter - * the stream writer - * @throws XMLStreamException - * thrown if there was a problem writing to the XML Stream + * + * @param configurableComponent the component to describe + * @param xmlStreamWriter the stream writer + * @throws XMLStreamException thrown if there was a problem writing to the + * XML Stream */ protected void writeProperties(final ConfigurableComponent configurableComponent, final XMLStreamWriter xmlStreamWriter) throws XMLStreamException { @@ -367,13 +344,7 @@ public class HtmlDocumentationWriter implements DocumentationWriter { writeSimpleElement(xmlStreamWriter, "p", "This component has no required or optional properties."); } } - - /** - * Writes a list of the dynamic properties that a processor supports - * @param configurableComponent - * @param xmlStreamWriter - * @throws XMLStreamException - */ + private void writeDynamicProperties(final ConfigurableComponent configurableComponent, final XMLStreamWriter xmlStreamWriter) throws XMLStreamException { @@ -392,7 +363,7 @@ public class HtmlDocumentationWriter implements DocumentationWriter { writeSimpleElement(xmlStreamWriter, "th", "Description"); xmlStreamWriter.writeEndElement(); for (final DynamicProperty dynamicProperty : dynamicProperties) { - xmlStreamWriter.writeStartElement("tr"); + xmlStreamWriter.writeStartElement("tr"); writeSimpleElement(xmlStreamWriter, "td", dynamicProperty.name(), false, "name"); writeSimpleElement(xmlStreamWriter, "td", dynamicProperty.value(), false, "value"); xmlStreamWriter.writeStartElement("td"); @@ -404,17 +375,12 @@ public class HtmlDocumentationWriter implements DocumentationWriter { xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement(); } - + xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement(); } } - /** - * Gets the dynamic properties for a configurable component - * @param configurableComponent - * @return - */ private List getDynamicProperties(ConfigurableComponent configurableComponent) { final List dynamicProperties = new ArrayList<>(); final DynamicProperties dynProps = configurableComponent.getClass().getAnnotation(DynamicProperties.class); @@ -423,22 +389,15 @@ public class HtmlDocumentationWriter implements DocumentationWriter { dynamicProperties.add(dynProp); } } - + final DynamicProperty dynProp = configurableComponent.getClass().getAnnotation(DynamicProperty.class); if (dynProp != null) { dynamicProperties.add(dynProp); } - + return dynamicProperties; } - /** - * Writes an info icon with a description. - * - * @param xmlStreamWriter - * @param description the description of the item - * @throws XMLStreamException - */ private void writeValidValueDescription(XMLStreamWriter xmlStreamWriter, String description) throws XMLStreamException { xmlStreamWriter.writeCharacters(" "); @@ -453,13 +412,11 @@ public class HtmlDocumentationWriter implements DocumentationWriter { /** * Interrogates a PropertyDescriptor to get a list of AllowableValues, if * there are none, nothing is written to the stream. - * - * @param xmlStreamWriter - * the stream writer to use - * @param property - * the property to describe - * @throws XMLStreamException - * thrown if there was a problem writing to the XML Stream + * + * @param xmlStreamWriter the stream writer to use + * @param property the property to describe + * @throws XMLStreamException thrown if there was a problem writing to the + * XML Stream */ protected void writeValidValues(XMLStreamWriter xmlStreamWriter, PropertyDescriptor property) throws XMLStreamException { @@ -477,52 +434,62 @@ public class HtmlDocumentationWriter implements DocumentationWriter { } xmlStreamWriter.writeEndElement(); } else if (property.getControllerServiceDefinition() != null) { - Class controllerServiceClass = property - .getControllerServiceDefinition(); + Class controllerServiceClass = property.getControllerServiceDefinition(); - writeSimpleElement(xmlStreamWriter, "strong", "Controller Service: "); + writeSimpleElement(xmlStreamWriter, "strong", "Controller Service API: "); xmlStreamWriter.writeEmptyElement("br"); xmlStreamWriter.writeCharacters(controllerServiceClass.getSimpleName()); + + final List> implementations = lookupControllerServiceImpls(controllerServiceClass); + xmlStreamWriter.writeEmptyElement("br"); + if (implementations.size() > 0) { + final String title = implementations.size() > 1 ? "Implementations: " : "Implementation:"; + writeSimpleElement(xmlStreamWriter, "strong", title); + for (int i = 0; i < implementations.size(); i++) { + xmlStreamWriter.writeEmptyElement("br"); + writeLinkForComponent(xmlStreamWriter, implementations.get(i)); + } + } else { + xmlStreamWriter.writeCharacters("No implementations found."); + } } } /** * Writes a begin element, then text, then end element for the element of a * users choosing. Example: <p>text</p> - * - * @param writer - * the stream writer to use - * @param elementName - * the name of the element - * @param characters - * the characters to insert into the element - * @param strong - * whether the characters should be strong or not. - * @throws XMLStreamException - * thrown if there was a problem writing to the stream. + * + * @param writer the stream writer to use + * @param elementName the name of the element + * @param characters the characters to insert into the element + * @param strong whether the characters should be strong or not. + * @throws XMLStreamException thrown if there was a problem writing to the + * stream. */ protected final static void writeSimpleElement(final XMLStreamWriter writer, final String elementName, final String characters, boolean strong) throws XMLStreamException { - writeSimpleElement(writer, elementName, characters, strong, null); + writeSimpleElement(writer, elementName, characters, strong, null); } - + /** - * Writes a begin element, an id attribute(if specified), then text, then end element for - * element of the users choosing. Example: <p id="p-id">text</p> - * + * Writes a begin element, an id attribute(if specified), then text, then + * end element for element of the users choosing. Example: <p + * id="p-id">text</p> + * * @param writer the stream writer to use * @param elementName the name of the element * @param characters the text of the element * @param strong whether to bold the text of the element or not - * @param id the id of the element. specifying null will cause no element to be written. - * @throws XMLStreamException + * @param id the id of the element. specifying null will cause no element to + * be written. + * @throws XMLStreamException xse */ protected final static void writeSimpleElement(final XMLStreamWriter writer, final String elementName, final String characters, boolean strong, String id) throws XMLStreamException { - writer.writeStartElement(elementName); - if (id != null) { - writer.writeAttribute("id", id); - } + writer.writeStartElement(elementName); + if (id != null) { + writer.writeAttribute("id", id); + } if (strong) { writer.writeStartElement("strong"); } @@ -536,15 +503,12 @@ public class HtmlDocumentationWriter implements DocumentationWriter { /** * Writes a begin element, then text, then end element for the element of a * users choosing. Example: <p>text</p> - * - * @param writer - * the stream writer to use - * @param elementName - * the name of the element - * @param characters - * the characters to insert into the element - * @throws XMLStreamException - * thrown if there was a problem writing to the stream + * + * @param writer the stream writer to use + * @param elementName the name of the element + * @param characters the characters to insert into the element + * @throws XMLStreamException thrown if there was a problem writing to the + * stream */ protected final static void writeSimpleElement(final XMLStreamWriter writer, final String elementName, final String characters) throws XMLStreamException { @@ -553,15 +517,12 @@ public class HtmlDocumentationWriter implements DocumentationWriter { /** * A helper method to write a link - * - * @param xmlStreamWriter - * the stream to write to - * @param text - * the text of the link - * @param location - * the location of the link - * @throws XMLStreamException - * thrown if there was a problem writing to the stream + * + * @param xmlStreamWriter the stream to write to + * @param text the text of the link + * @param location the location of the link + * @throws XMLStreamException thrown if there was a problem writing to the + * stream */ protected void writeLink(final XMLStreamWriter xmlStreamWriter, final String text, final String location) throws XMLStreamException { @@ -570,4 +531,41 @@ public class HtmlDocumentationWriter implements DocumentationWriter { xmlStreamWriter.writeCharacters(text); xmlStreamWriter.writeEndElement(); } + + /** + * Writes a link to another configurable component + * + * @param xmlStreamWriter the xml stream writer + * @param clazz the configurable component to link to + * @throws XMLStreamException thrown if there is a problem writing the XML + */ + protected void writeLinkForComponent(final XMLStreamWriter xmlStreamWriter, final Class clazz) throws XMLStreamException { + writeLink(xmlStreamWriter, clazz.getSimpleName(), "../" + clazz.getCanonicalName() + "/index.html"); + } + + /** + * Uses the {@link ExtensionManager} to discover any {@link ControllerService} implementations that implement a specific + * ControllerService API. + * + * @param parent the controller service API + * @return a list of controller services that implement the controller service API + */ + private List> lookupControllerServiceImpls( + final Class parent) { + + final List> implementations = new ArrayList<>(); + + // first get all ControllerService implementations + final Set controllerServices = ExtensionManager.getExtensions(ControllerService.class); + + // then iterate over all controller services looking for any that is a child of the parent + // ControllerService API that was passed in as a parameter + for (final Class controllerServiceClass : controllerServices) { + if (parent.isAssignableFrom(controllerServiceClass)) { + implementations.add(controllerServiceClass); + } + } + + return implementations; + } } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlProcessorDocumentationWriter.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlProcessorDocumentationWriter.java index c253a4d8f2..4a15b50426 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlProcessorDocumentationWriter.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlProcessorDocumentationWriter.java @@ -51,13 +51,10 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter { /** * Writes all the attributes that a processor says it reads and writes - * - * @param processor - * the processor to describe - * @param xmlStreamWriter - * the xml stream writer to use - * @throws XMLStreamException - * thrown if there was a problem writing the XML + * + * @param processor the processor to describe + * @param xmlStreamWriter the xml stream writer to use + * @throws XMLStreamException thrown if there was a problem writing the XML */ private void writeAttributeInfo(Processor processor, XMLStreamWriter xmlStreamWriter) throws XMLStreamException { @@ -67,20 +64,18 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter { } private String defaultIfBlank(final String test, final String defaultValue) { - if ( test == null || test.trim().isEmpty() ) { - return defaultValue; - } - return test; + if (test == null || test.trim().isEmpty()) { + return defaultValue; + } + return test; } - + /** * Writes out just the attributes that are being read in a table form. - * - * @param xmlStreamWriter - * the xml stream writer to use - * @param processor - * the processor to describe - * @throws XMLStreamException + * + * @param xmlStreamWriter the xml stream writer to use + * @param processor the processor to describe + * @throws XMLStreamException xse */ private void handleReadsAttributes(XMLStreamWriter xmlStreamWriter, final Processor processor) throws XMLStreamException { @@ -102,7 +97,7 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter { writeSimpleElement(xmlStreamWriter, "td", defaultIfBlank(attribute.description(), "Not Specified")); xmlStreamWriter.writeEndElement(); - + } xmlStreamWriter.writeEndElement(); @@ -113,12 +108,10 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter { /** * Writes out just the attributes that are being written to in a table form. - * - * @param xmlStreamWriter - * the xml stream writer to use - * @param processor - * the processor to describe - * @throws XMLStreamException + * + * @param xmlStreamWriter the xml stream writer to use + * @param processor the processor to describe + * @throws XMLStreamException xse */ private void handleWritesAttributes(XMLStreamWriter xmlStreamWriter, final Processor processor) throws XMLStreamException { @@ -150,9 +143,8 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter { /** * Collects the attributes that a processor is reading from. - * - * @param processor - * the processor to describe + * + * @param processor the processor to describe * @return the list of attributes that processor is reading */ private List getReadsAttributes(Processor processor) { @@ -173,9 +165,8 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter { /** * Collects the attributes that a processor is writing to. - * - * @param processor - * the processor to describe + * + * @param processor the processor to describe * @return the list of attributes the processor is writing */ private List getWritesAttributes(Processor processor) { @@ -196,13 +187,10 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter { /** * Writes a table describing the relations a processor has. - * - * @param processor - * the processor to describe - * @param xmlStreamWriter - * the stream writer to use - * @throws XMLStreamException - * thrown if there was a problem writing the xml + * + * @param processor the processor to describe + * @param xmlStreamWriter the stream writer to use + * @throws XMLStreamException thrown if there was a problem writing the xml */ private void writeRelationships(final Processor processor, final XMLStreamWriter xmlStreamWriter) throws XMLStreamException { @@ -229,15 +217,8 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter { } } - /** - * Writes dynamic relationship information - * - * @param processor - * @param xmlStreamWriter - * @throws XMLStreamException - */ private void writeDynamicRelationships(final Processor processor, final XMLStreamWriter xmlStreamWriter) throws XMLStreamException { - + List dynamicRelationships = getDynamicRelationships(processor); if (dynamicRelationships.size() > 0) { @@ -264,12 +245,12 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter { private List getDynamicRelationships(Processor processor) { List results = new ArrayList<>(); - + DynamicRelationship dynamicRelationships = processor.getClass().getAnnotation(DynamicRelationship.class); if (dynamicRelationships != null) { results.add(dynamicRelationships); } - + return results; } } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedControllerService.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedControllerService.java index c27f3baa51..cd68267d30 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedControllerService.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedControllerService.java @@ -26,32 +26,37 @@ import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.controller.AbstractControllerService; import org.apache.nifi.processor.util.StandardValidators; -@CapabilityDescription("A documented controller service that can help you do things") -@Tags({ "one", "two", "three" }) -public class FullyDocumentedControllerService extends AbstractControllerService { - public static final PropertyDescriptor KEYSTORE = new PropertyDescriptor.Builder().name("Keystore Filename") - .description("The fully-qualified filename of the Keystore").defaultValue(null) - .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR).sensitive(false).build(); - public static final PropertyDescriptor KEYSTORE_TYPE = new PropertyDescriptor.Builder().name("Keystore Type") - .description("The Type of the Keystore").allowableValues("JKS", "PKCS12") - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).defaultValue("JKS").sensitive(false).build(); - public static final PropertyDescriptor KEYSTORE_PASSWORD = new PropertyDescriptor.Builder() - .name("Keystore Password").defaultValue(null).description("The password for the Keystore") - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).sensitive(true).build(); +@CapabilityDescription("A documented controller service that can help you do things") +@Tags({"one", "two", "three"}) +public class FullyDocumentedControllerService extends AbstractControllerService implements SampleService{ - private static final List properties; + public static final PropertyDescriptor KEYSTORE = new PropertyDescriptor.Builder().name("Keystore Filename") + .description("The fully-qualified filename of the Keystore").defaultValue(null) + .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR).sensitive(false).build(); + public static final PropertyDescriptor KEYSTORE_TYPE = new PropertyDescriptor.Builder().name("Keystore Type") + .description("The Type of the Keystore").allowableValues("JKS", "PKCS12") + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).defaultValue("JKS").sensitive(false).build(); + public static final PropertyDescriptor KEYSTORE_PASSWORD = new PropertyDescriptor.Builder() + .name("Keystore Password").defaultValue(null).description("The password for the Keystore") + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).sensitive(true).build(); - static { - List props = new ArrayList<>(); - props.add(KEYSTORE); - props.add(KEYSTORE_PASSWORD); - props.add(KEYSTORE_TYPE); - properties = Collections.unmodifiableList(props); - } + private static final List properties; - @Override - protected List getSupportedPropertyDescriptors() { - return properties; - } + static { + List props = new ArrayList<>(); + props.add(KEYSTORE); + props.add(KEYSTORE_PASSWORD); + props.add(KEYSTORE_TYPE); + properties = Collections.unmodifiableList(props); + } + @Override + protected List getSupportedPropertyDescriptors() { + return properties; + } + + @Override + public void doSomething() { + // TODO Auto-generated method stub + } } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedProcessor.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedProcessor.java index cc59733188..178a144534 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedProcessor.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedProcessor.java @@ -40,82 +40,90 @@ import org.apache.nifi.processor.Relationship; import org.apache.nifi.processor.exception.ProcessException; import org.apache.nifi.processor.util.StandardValidators; -@Tags({ "one", "two", "three" }) +@Tags({"one", "two", "three"}) @CapabilityDescription("This is a processor that is used to test documentation.") -@WritesAttributes({@WritesAttribute(attribute="first", description="this is the first attribute i write"), @WritesAttribute(attribute="second")}) -@ReadsAttribute(attribute = "incoming", description="this specifies the format of the thing") -@SeeAlso(value={FullyDocumentedControllerService.class, FullyDocumentedReportingTask.class}, classNames={"org.apache.nifi.processor.ExampleProcessor"}) -@DynamicProperty(name="Relationship Name", supportsExpressionLanguage=true, value="some XPath", description="Routes FlowFiles to relationships based on XPath") -@DynamicRelationship(name="name from dynamic property", description="all files that match the properties XPath") +@WritesAttributes({ + @WritesAttribute(attribute = "first", description = "this is the first attribute i write"), + @WritesAttribute(attribute = "second")}) +@ReadsAttribute(attribute = "incoming", description = "this specifies the format of the thing") +@SeeAlso(value = {FullyDocumentedControllerService.class, FullyDocumentedReportingTask.class}, classNames = {"org.apache.nifi.processor.ExampleProcessor"}) +@DynamicProperty(name = "Relationship Name", supportsExpressionLanguage = true, value = "some XPath", description = "Routes FlowFiles to relationships based on XPath") +@DynamicRelationship(name = "name from dynamic property", description = "all files that match the properties XPath") public class FullyDocumentedProcessor extends AbstractProcessor { - public static final PropertyDescriptor DIRECTORY = new PropertyDescriptor.Builder().name("Input Directory") - .description("The input directory from which to pull files").required(true) - .addValidator(StandardValidators.createDirectoryExistsValidator(true, false)) - .expressionLanguageSupported(true).build(); + public static final PropertyDescriptor DIRECTORY = new PropertyDescriptor.Builder().name("Input Directory") + .description("The input directory from which to pull files").required(true) + .addValidator(StandardValidators.createDirectoryExistsValidator(true, false)) + .expressionLanguageSupported(true).build(); - public static final PropertyDescriptor RECURSE = new PropertyDescriptor.Builder().name("Recurse Subdirectories") - .description("Indicates whether or not to pull files from subdirectories").required(true) - .allowableValues(new AllowableValue("true", "true", "Should pull from sub directories"), new AllowableValue("false", "false", "Should not pull from sub directories")).defaultValue("true").build(); + public static final PropertyDescriptor RECURSE = new PropertyDescriptor.Builder().name("Recurse Subdirectories") + .description("Indicates whether or not to pull files from subdirectories").required(true) + .allowableValues( + new AllowableValue("true", "true", "Should pull from sub directories"), + new AllowableValue("false", "false", "Should not pull from sub directories") + ).defaultValue("true").build(); - public static final PropertyDescriptor POLLING_INTERVAL = new PropertyDescriptor.Builder().name("Polling Interval") - .description("Indicates how long to wait before performing a directory listing").required(true) - .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR).defaultValue("0 sec").build(); + public static final PropertyDescriptor POLLING_INTERVAL = new PropertyDescriptor.Builder().name("Polling Interval") + .description("Indicates how long to wait before performing a directory listing").required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR).defaultValue("0 sec").build(); - public static final PropertyDescriptor OPTIONAL_PROPERTY = new PropertyDescriptor.Builder() - .name("Optional Property").description("This is a property you can use or not").required(false).build(); - - public static final PropertyDescriptor TYPE_PROPERTY = new PropertyDescriptor.Builder() - .name("Type").description("This is the type of something that you can choose. It has several possible values").allowableValues("yes", "no", "maybe", "possibly", "not likely", "longer option name").required(true).build(); + public static final PropertyDescriptor OPTIONAL_PROPERTY = new PropertyDescriptor.Builder() + .name("Optional Property").description("This is a property you can use or not").required(false).build(); - public static final PropertyDescriptor SERVICE_PROPERTY = new PropertyDescriptor.Builder() - .name("Controller Service").description("This is the controller service to use to do things") - .identifiesControllerService(SampleService.class).required(true).build(); - - public static final Relationship REL_SUCCESS = new Relationship.Builder().name("success") - .description("Successful files").build(); - public static final Relationship REL_FAILURE = new Relationship.Builder().name("failure") - .description("Failing files").build(); + public static final PropertyDescriptor TYPE_PROPERTY = new PropertyDescriptor.Builder() + .name("Type") + .description("This is the type of something that you can choose. It has several possible values") + .allowableValues("yes", "no", "maybe", "possibly", "not likely", "longer option name") + .required(true).build(); - private List properties; - private Set relationships; + public static final PropertyDescriptor SERVICE_PROPERTY = new PropertyDescriptor.Builder() + .name("Controller Service").description("This is the controller service to use to do things") + .identifiesControllerService(SampleService.class).required(true).build(); - @Override - protected void init(ProcessorInitializationContext context) { - final List properties = new ArrayList<>(); - properties.add(DIRECTORY); - properties.add(RECURSE); - properties.add(POLLING_INTERVAL); - properties.add(OPTIONAL_PROPERTY); - properties.add(TYPE_PROPERTY); - properties.add(SERVICE_PROPERTY); - this.properties = Collections.unmodifiableList(properties); + public static final Relationship REL_SUCCESS = new Relationship.Builder().name("success") + .description("Successful files").build(); + public static final Relationship REL_FAILURE = new Relationship.Builder().name("failure") + .description("Failing files").build(); - final Set relationships = new HashSet<>(); - relationships.add(REL_SUCCESS); - relationships.add(REL_FAILURE); - this.relationships = Collections.unmodifiableSet(relationships); - } + private List properties; + private Set relationships; - @Override - protected List getSupportedPropertyDescriptors() { - return properties; - } + @Override + protected void init(ProcessorInitializationContext context) { + final List properties = new ArrayList<>(); + properties.add(DIRECTORY); + properties.add(RECURSE); + properties.add(POLLING_INTERVAL); + properties.add(OPTIONAL_PROPERTY); + properties.add(TYPE_PROPERTY); + properties.add(SERVICE_PROPERTY); + this.properties = Collections.unmodifiableList(properties); - @Override - public Set getRelationships() { - return relationships; - } + final Set relationships = new HashSet<>(); + relationships.add(REL_SUCCESS); + relationships.add(REL_FAILURE); + this.relationships = Collections.unmodifiableSet(relationships); + } - @Override - public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException { + @Override + protected List getSupportedPropertyDescriptors() { + return properties; + } - } + @Override + public Set getRelationships() { + return relationships; + } - @Override - protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName) { - return new PropertyDescriptor.Builder().name(propertyDescriptorName) - .description("This is a property you can use or not").dynamic(true).build(); - } + @Override + public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException { + + } + + @Override + protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName) { + return new PropertyDescriptor.Builder().name(propertyDescriptorName) + .description("This is a property you can use or not").dynamic(true).build(); + } } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedReportingTask.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedReportingTask.java index 275905b1a4..17e446af6c 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedReportingTask.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedReportingTask.java @@ -26,25 +26,25 @@ import org.apache.nifi.reporting.AbstractReportingTask; import org.apache.nifi.reporting.ReportingContext; @CapabilityDescription("A helper reporting task to do...") -@Tags({ "first", "second", "third" }) +@Tags({"first", "second", "third"}) public class FullyDocumentedReportingTask extends AbstractReportingTask { - public static final PropertyDescriptor SHOW_DELTAS = new PropertyDescriptor.Builder() - .name("Show Deltas") - .description( - "Specifies whether or not to show the difference in values between the current status and the previous status") - .required(true).allowableValues("true", "false").defaultValue("true").build(); + public static final PropertyDescriptor SHOW_DELTAS = new PropertyDescriptor.Builder() + .name("Show Deltas") + .description( + "Specifies whether or not to show the difference in values between the current status and the previous status") + .required(true).allowableValues("true", "false").defaultValue("true").build(); - @Override - public final List getSupportedPropertyDescriptors() { - final List descriptors = new ArrayList<>(); - descriptors.add(SHOW_DELTAS); - return descriptors; - } + @Override + public final List getSupportedPropertyDescriptors() { + final List descriptors = new ArrayList<>(); + descriptors.add(SHOW_DELTAS); + return descriptors; + } - @Override - public void onTrigger(ReportingContext context) { - // TODO Auto-generated method stub + @Override + public void onTrigger(ReportingContext context) { + // TODO Auto-generated method stub - } + } } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/NakedProcessor.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/NakedProcessor.java index ee7f315931..e288f0a048 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/NakedProcessor.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/NakedProcessor.java @@ -23,9 +23,9 @@ import org.apache.nifi.processor.exception.ProcessException; public class NakedProcessor extends AbstractProcessor { - @Override - public void onTrigger(ProcessContext arg0, ProcessSession arg1) throws ProcessException { - - } + @Override + public void onTrigger(ProcessContext arg0, ProcessSession arg1) throws ProcessException { + + } } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/SampleService.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/SampleService.java index 6224364f7b..6f84c15f73 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/SampleService.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/SampleService.java @@ -20,6 +20,6 @@ import org.apache.nifi.controller.ControllerService; public interface SampleService extends ControllerService { - public void doSomething(); + public void doSomething(); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/HtmlDocumentationWriterTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/HtmlDocumentationWriterTest.java index 90ff09f19c..e897262d05 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/HtmlDocumentationWriterTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/HtmlDocumentationWriterTest.java @@ -34,68 +34,68 @@ import static org.junit.Assert.assertEquals; public class HtmlDocumentationWriterTest { - @Test - public void testJoin() { - assertEquals("a, b, c", HtmlDocumentationWriter.join(new String[] {"a", "b", "c"}, ", ")); - assertEquals("a, b", HtmlDocumentationWriter.join(new String[] {"a", "b"}, ", ")); - assertEquals("a", HtmlDocumentationWriter.join(new String[] {"a"}, ", ")); - } - - @Test - public void testDocumentControllerService() throws InitializationException, IOException { + @Test + public void testJoin() { + assertEquals("a, b, c", HtmlDocumentationWriter.join(new String[]{"a", "b", "c"}, ", ")); + assertEquals("a, b", HtmlDocumentationWriter.join(new String[]{"a", "b"}, ", ")); + assertEquals("a", HtmlDocumentationWriter.join(new String[]{"a"}, ", ")); + } - ControllerService controllerService = new FullyDocumentedControllerService(); - controllerService.initialize(new MockControllerServiceInitializationContext()); + @Test + public void testDocumentControllerService() throws InitializationException, IOException { - DocumentationWriter writer = new HtmlDocumentationWriter(); + ControllerService controllerService = new FullyDocumentedControllerService(); + controllerService.initialize(new MockControllerServiceInitializationContext()); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); + DocumentationWriter writer = new HtmlDocumentationWriter(); - writer.write(controllerService, baos, false); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); - String results = new String(baos.toByteArray()); - XmlValidator.assertXmlValid(results); + writer.write(controllerService, baos, false); - // description - assertContains(results, "A documented controller service that can help you do things"); + String results = new String(baos.toByteArray()); + XmlValidator.assertXmlValid(results); - // tags - assertContains(results, "one, two, three"); + // description + assertContains(results, "A documented controller service that can help you do things"); - // properties - assertContains(results, "Keystore Filename"); - assertContains(results, "The fully-qualified filename of the Keystore"); - assertContains(results, "Keystore Type"); - assertContains(results, "JKS"); - assertContains(results, "PKCS12"); - assertContains(results, "Sensitive Property: true"); - } + // tags + assertContains(results, "one, two, three"); - @Test - public void testDocumentReportingTask() throws InitializationException, IOException { + // properties + assertContains(results, "Keystore Filename"); + assertContains(results, "The fully-qualified filename of the Keystore"); + assertContains(results, "Keystore Type"); + assertContains(results, "JKS"); + assertContains(results, "PKCS12"); + assertContains(results, "Sensitive Property: true"); + } - ReportingTask reportingTask = new FullyDocumentedReportingTask(); - reportingTask.initialize(new MockReportingInitializationContext()); + @Test + public void testDocumentReportingTask() throws InitializationException, IOException { - DocumentationWriter writer = new HtmlDocumentationWriter(); + ReportingTask reportingTask = new FullyDocumentedReportingTask(); + reportingTask.initialize(new MockReportingInitializationContext()); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); + DocumentationWriter writer = new HtmlDocumentationWriter(); - writer.write(reportingTask, baos, false); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); - String results = new String(baos.toByteArray()); - XmlValidator.assertXmlValid(results); + writer.write(reportingTask, baos, false); - // description - assertContains(results, "A helper reporting task to do..."); + String results = new String(baos.toByteArray()); + XmlValidator.assertXmlValid(results); - // tags - assertContains(results, "first, second, third"); + // description + assertContains(results, "A helper reporting task to do..."); - // properties - assertContains(results, "Show Deltas"); - assertContains(results, "Specifies whether or not to show the difference in values between the current status and the previous status"); - assertContains(results, "true"); - assertContains(results, "false"); - } + // tags + assertContains(results, "first, second, third"); + + // properties + assertContains(results, "Show Deltas"); + assertContains(results, "Specifies whether or not to show the difference in values between the current status and the previous status"); + assertContains(results, "true"); + assertContains(results, "false"); + } } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/ProcessorDocumentationWriterTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/ProcessorDocumentationWriterTest.java index 5306ddf2ee..6016f95300 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/ProcessorDocumentationWriterTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/ProcessorDocumentationWriterTest.java @@ -30,74 +30,73 @@ import org.apache.nifi.documentation.mock.MockProcessorInitializationContext; import org.junit.Test; public class ProcessorDocumentationWriterTest { + + @Test + public void testFullyDocumentedProcessor() throws IOException { + FullyDocumentedProcessor processor = new FullyDocumentedProcessor(); + processor.initialize(new MockProcessorInitializationContext()); - @Test - public void testFullyDocumentedProcessor() throws IOException { - FullyDocumentedProcessor processor = new FullyDocumentedProcessor(); - processor.initialize(new MockProcessorInitializationContext()); + DocumentationWriter writer = new HtmlProcessorDocumentationWriter(); - DocumentationWriter writer = new HtmlProcessorDocumentationWriter(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); + writer.write(processor, baos, false); - writer.write(processor, baos, false); - - String results = new String(baos.toByteArray()); - XmlValidator.assertXmlValid(results); + String results = new String(baos.toByteArray()); + XmlValidator.assertXmlValid(results); - assertContains(results, FullyDocumentedProcessor.DIRECTORY.getDisplayName()); - assertContains(results, FullyDocumentedProcessor.DIRECTORY.getDescription()); - assertContains(results, FullyDocumentedProcessor.OPTIONAL_PROPERTY.getDisplayName()); - assertContains(results, FullyDocumentedProcessor.OPTIONAL_PROPERTY.getDescription()); - assertContains(results, FullyDocumentedProcessor.POLLING_INTERVAL.getDisplayName()); - assertContains(results, FullyDocumentedProcessor.POLLING_INTERVAL.getDescription()); - assertContains(results, FullyDocumentedProcessor.POLLING_INTERVAL.getDefaultValue()); - assertContains(results, FullyDocumentedProcessor.RECURSE.getDisplayName()); - assertContains(results, FullyDocumentedProcessor.RECURSE.getDescription()); + assertContains(results, FullyDocumentedProcessor.DIRECTORY.getDisplayName()); + assertContains(results, FullyDocumentedProcessor.DIRECTORY.getDescription()); + assertContains(results, FullyDocumentedProcessor.OPTIONAL_PROPERTY.getDisplayName()); + assertContains(results, FullyDocumentedProcessor.OPTIONAL_PROPERTY.getDescription()); + assertContains(results, FullyDocumentedProcessor.POLLING_INTERVAL.getDisplayName()); + assertContains(results, FullyDocumentedProcessor.POLLING_INTERVAL.getDescription()); + assertContains(results, FullyDocumentedProcessor.POLLING_INTERVAL.getDefaultValue()); + assertContains(results, FullyDocumentedProcessor.RECURSE.getDisplayName()); + assertContains(results, FullyDocumentedProcessor.RECURSE.getDescription()); - assertContains(results, FullyDocumentedProcessor.REL_SUCCESS.getName()); - assertContains(results, FullyDocumentedProcessor.REL_SUCCESS.getDescription()); - assertContains(results, FullyDocumentedProcessor.REL_FAILURE.getName()); - assertContains(results, FullyDocumentedProcessor.REL_FAILURE.getDescription()); - assertContains(results, "Controller Service: "); - assertContains(results, "SampleService"); + assertContains(results, FullyDocumentedProcessor.REL_SUCCESS.getName()); + assertContains(results, FullyDocumentedProcessor.REL_SUCCESS.getDescription()); + assertContains(results, FullyDocumentedProcessor.REL_FAILURE.getName()); + assertContains(results, FullyDocumentedProcessor.REL_FAILURE.getDescription()); + assertContains(results, "Controller Service API: "); + assertContains(results, "SampleService"); - assertNotContains(results, "iconSecure.png"); - assertContains(results, FullyDocumentedProcessor.class.getAnnotation(CapabilityDescription.class) - .value()); - assertNotContains(results, "This component has no required or optional properties."); - assertNotContains(results, "No description provided."); - assertNotContains(results, "No Tags provided."); - assertNotContains(results, "Additional Details..."); - } + assertNotContains(results, "iconSecure.png"); + assertContains(results, FullyDocumentedProcessor.class.getAnnotation(CapabilityDescription.class) + .value()); + assertNotContains(results, "This component has no required or optional properties."); + assertNotContains(results, "No description provided."); + assertNotContains(results, "No Tags provided."); + assertNotContains(results, "Additional Details..."); + } - @Test - public void testNakedProcessor() throws IOException { - NakedProcessor processor = new NakedProcessor(); - processor.initialize(new MockProcessorInitializationContext()); + @Test + public void testNakedProcessor() throws IOException { + NakedProcessor processor = new NakedProcessor(); + processor.initialize(new MockProcessorInitializationContext()); - DocumentationWriter writer = new HtmlProcessorDocumentationWriter(); + DocumentationWriter writer = new HtmlProcessorDocumentationWriter(); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); - writer.write(processor, baos, false); + writer.write(processor, baos, false); - String results = new String(baos.toByteArray()); - XmlValidator.assertXmlValid(results); - - // no description - assertContains(results, "No description provided."); - - // no tags - assertContains(results, "None."); - - // properties - assertContains(results, "This component has no required or optional properties."); - - // relationships - assertContains(results, "This processor has no relationships."); - + String results = new String(baos.toByteArray()); + XmlValidator.assertXmlValid(results); - } + // no description + assertContains(results, "No description provided."); + + // no tags + assertContains(results, "None."); + + // properties + assertContains(results, "This component has no required or optional properties."); + + // relationships + assertContains(results, "This processor has no relationships."); + + } } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/XmlValidator.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/XmlValidator.java index 6cb7499628..8bddf98bdf 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/XmlValidator.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/XmlValidator.java @@ -28,23 +28,24 @@ import org.xml.sax.SAXException; /** * A helper class to validate xml documents. - * + * * */ public class XmlValidator { - public static void assertXmlValid(String xml) { - try { - DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(xml))); - } catch (SAXException | IOException | ParserConfigurationException e) { - Assert.fail(e.getMessage()); - } - } - public static void assertContains(String original, String subword) { - Assert.assertTrue(original + " did not contain: " + subword, original.contains(subword)); - } + public static void assertXmlValid(String xml) { + try { + DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(xml))); + } catch (SAXException | IOException | ParserConfigurationException e) { + Assert.fail(e.getMessage()); + } + } - public static void assertNotContains(String original, String subword) { - Assert.assertFalse(original + " did contain: " + subword, original.contains(subword)); - } + public static void assertContains(String original, String subword) { + Assert.assertTrue(original + " did not contain: " + subword, original.contains(subword)); + } + + public static void assertNotContains(String original, String subword) { + Assert.assertFalse(original + " did contain: " + subword, original.contains(subword)); + } } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-file-authorization-provider/pom.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-file-authorization-provider/pom.xml index d79b0ca6e9..b5cde8d692 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-file-authorization-provider/pom.xml +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-file-authorization-provider/pom.xml @@ -49,6 +49,14 @@ ${project.build.directory}/generated-sources/jaxb + + org.apache.maven.plugins + maven-checkstyle-plugin + + **/user/generated/*.java + + + diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-file-authorization-provider/src/main/java/org/apache/nifi/authorization/FileAuthorizationProvider.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-file-authorization-provider/src/main/java/org/apache/nifi/authorization/FileAuthorizationProvider.java index 5657369ff8..9c2cad5fdb 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-file-authorization-provider/src/main/java/org/apache/nifi/authorization/FileAuthorizationProvider.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-file-authorization-provider/src/main/java/org/apache/nifi/authorization/FileAuthorizationProvider.java @@ -167,23 +167,10 @@ public class FileAuthorizationProvider implements AuthorityProvider { public void preDestruction() { } - /** - * Determines if this provider has a default role. - * - * @return - */ private boolean hasDefaultRoles() { return !defaultAuthorities.isEmpty(); } - /** - * Determines if the specified dn is known to this authority provider. When - * this provider is configured to have default role(s), all dn are - * considered to exist. - * - * @param dn - * @return True if he dn is known, false otherwise - */ @Override public boolean doesDnExist(String dn) throws AuthorityAccessException { if (hasDefaultRoles()) { @@ -194,21 +181,11 @@ public class FileAuthorizationProvider implements AuthorityProvider { return user != null; } - /** - * Loads the authorities for the specified user. If this provider is - * configured for default user role(s) and a non existent dn is specified, a - * new user will be automatically created with the default role(s). - * - * @param dn - * @return - * @throws UnknownIdentityException - * @throws AuthorityAccessException - */ @Override public synchronized Set getAuthorities(String dn) throws UnknownIdentityException, AuthorityAccessException { final Set authorities = EnumSet.noneOf(Authority.class); - // get the user + // get the user final User user = getUser(dn); // ensure the user was located @@ -234,16 +211,6 @@ public class FileAuthorizationProvider implements AuthorityProvider { return authorities; } - /** - * Adds the specified authorities to the specified user. Regardless of - * whether this provider is configured for a default user role, when a non - * existent dn is specified, an UnknownIdentityException will be thrown. - * - * @param dn - * @param authorities - * @throws UnknownIdentityException - * @throws AuthorityAccessException - */ @Override public synchronized void setAuthorities(String dn, Set authorities) throws UnknownIdentityException, AuthorityAccessException { // get the user @@ -265,12 +232,6 @@ public class FileAuthorizationProvider implements AuthorityProvider { } } - /** - * Adds the specified authorities to the specified user. - * - * @param user - * @param authorities - */ private void setUserAuthorities(final User user, final Set authorities) { // clear the existing rules user.getRole().clear(); @@ -286,15 +247,6 @@ public class FileAuthorizationProvider implements AuthorityProvider { } } - /** - * Adds the specified user. If this provider is configured with default - * role(s) they will be added to the new user. - * - * @param dn - * @param group - * @throws UnknownIdentityException - * @throws AuthorityAccessException - */ @Override public synchronized void addUser(String dn, String group) throws IdentityAlreadyExistsException, AuthorityAccessException { final User user = getUser(dn); @@ -334,13 +286,6 @@ public class FileAuthorizationProvider implements AuthorityProvider { } } - /** - * Gets the users for the specified authority. - * - * @param authority - * @return - * @throws AuthorityAccessException - */ @Override public synchronized Set getUsers(Authority authority) throws AuthorityAccessException { final Set userSet = new HashSet<>(); @@ -354,15 +299,6 @@ public class FileAuthorizationProvider implements AuthorityProvider { return userSet; } - /** - * Removes the specified user. Regardless of whether this provider is - * configured for a default user role, when a non existent dn is specified, - * an UnknownIdentityException will be thrown. - * - * @param dn - * @throws UnknownIdentityException - * @throws AuthorityAccessException - */ @Override public synchronized void revokeUser(String dn) throws UnknownIdentityException, AuthorityAccessException { // get the user @@ -496,24 +432,12 @@ public class FileAuthorizationProvider implements AuthorityProvider { /** * Grants access to download content regardless of FlowFile attributes. - * - * @param dnChain - * @param attributes - * @return - * @throws UnknownIdentityException - * @throws AuthorityAccessException */ @Override public DownloadAuthorization authorizeDownload(List dnChain, Map attributes) throws UnknownIdentityException, AuthorityAccessException { return DownloadAuthorization.approved(); } - /** - * Locates the user with the specified DN. - * - * @param dn - * @return - */ private User getUser(String dn) throws UnknownIdentityException { // ensure the DN was specified if (dn == null) { @@ -532,13 +456,6 @@ public class FileAuthorizationProvider implements AuthorityProvider { return desiredUser; } - /** - * Locates all users that are part of the specified group. - * - * @param group - * @return - * @throws UnknownIdentityException - */ private Collection getUserGroup(String group) throws UnknownIdentityException { // ensure the DN was specified if (group == null) { @@ -559,11 +476,6 @@ public class FileAuthorizationProvider implements AuthorityProvider { return userGroup; } - /** - * Saves the users file. - * - * @throws Exception - */ private void save() throws Exception { final Marshaller marshaller = JAXB_CONTEXT.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-file-authorization-provider/src/test/java/org/apache/nifi/authorization/FileAuthorizationProviderTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-file-authorization-provider/src/test/java/org/apache/nifi/authorization/FileAuthorizationProviderTest.java index d02d4d7919..74285003b4 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-file-authorization-provider/src/test/java/org/apache/nifi/authorization/FileAuthorizationProviderTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-file-authorization-provider/src/test/java/org/apache/nifi/authorization/FileAuthorizationProviderTest.java @@ -23,105 +23,106 @@ import org.apache.nifi.authorization.exception.ProviderCreationException; import org.apache.nifi.util.file.FileUtils; import org.apache.nifi.util.NiFiProperties; import org.junit.After; +import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; -import static org.mockito.Mockito.*; -import static org.junit.Assert.*; import org.junit.Ignore; import org.mockito.Mockito; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; @Ignore public class FileAuthorizationProviderTest { - + private FileAuthorizationProvider provider; - + private File primary; - + private File restore; - + private NiFiProperties mockProperties; - + private AuthorityProviderConfigurationContext mockConfigurationContext; - + @Before public void setup() throws IOException { - + primary = new File("target/primary/users.txt"); restore = new File("target/restore/users.txt"); - + System.out.println("absolute path: " + primary.getAbsolutePath()); - + mockProperties = mock(NiFiProperties.class); when(mockProperties.getRestoreDirectory()).thenReturn(restore.getParentFile()); - + mockConfigurationContext = mock(AuthorityProviderConfigurationContext.class); when(mockConfigurationContext.getProperty(Mockito.eq("Authorized Users File"))).thenReturn(primary.getPath()); - + provider = new FileAuthorizationProvider(); provider.setNiFiProperties(mockProperties); provider.initialize(null); - } - + } + @After public void cleanup() throws Exception { deleteFile(primary); deleteFile(restore); } - + private boolean deleteFile(final File file) { - if(file.isDirectory()) { + if (file.isDirectory()) { FileUtils.deleteFilesInDir(file, null, null, true, true); } return FileUtils.deleteFile(file, null, 10); } - + @Test public void testPostContructionWhenRestoreDoesNotExist() throws Exception { - + byte[] primaryBytes = "".getBytes(); FileOutputStream fos = new FileOutputStream(primary); fos.write(primaryBytes); fos.close(); - + provider.onConfigured(mockConfigurationContext); assertEquals(primary.length(), restore.length()); } - + @Test public void testPostContructionWhenPrimaryDoesNotExist() throws Exception { - + byte[] restoreBytes = "".getBytes(); FileOutputStream fos = new FileOutputStream(restore); fos.write(restoreBytes); fos.close(); - + provider.onConfigured(mockConfigurationContext); assertEquals(restore.length(), primary.length()); - + } - + @Test(expected = ProviderCreationException.class) public void testPostContructionWhenPrimaryDifferentThanRestore() throws Exception { - + byte[] primaryBytes = "".getBytes(); FileOutputStream fos = new FileOutputStream(primary); fos.write(primaryBytes); fos.close(); - + byte[] restoreBytes = "".getBytes(); fos = new FileOutputStream(restore); fos.write(restoreBytes); fos.close(); - + provider.onConfigured(mockConfigurationContext); } - + @Test public void testPostContructionWhenPrimaryAndBackupDoNotExist() throws Exception { - + provider.onConfigured(mockConfigurationContext); assertEquals(0, restore.length()); assertEquals(restore.length(), primary.length()); } - + } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ClusterManagerProtocolSender.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ClusterManagerProtocolSender.java index fa1547ffcb..10653ff58f 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ClusterManagerProtocolSender.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ClusterManagerProtocolSender.java @@ -26,44 +26,48 @@ import org.apache.nifi.reporting.BulletinRepository; /** * An interface for sending protocol messages from the cluster manager to nodes. - * - * @author unattributed + * */ public interface ClusterManagerProtocolSender { - + /** * Sends a "flow request" message to a node. + * * @param msg a message * @return the response - * @throws ProtocolException if communication failed + * @throws ProtocolException if communication failed */ FlowResponseMessage requestFlow(FlowRequestMessage msg) throws ProtocolException; /** * Sends a "reconnection request" message to a node. + * * @param msg a message - * @return + * @return the response * @throws ProtocolException if communication failed */ ReconnectionResponseMessage requestReconnection(ReconnectionRequestMessage msg) throws ProtocolException; - + /** * Sends a "disconnection request" message to a node. + * * @param msg a message * @throws ProtocolException if communication failed */ void disconnect(DisconnectMessage msg) throws ProtocolException; - + /** * Sends an "assign primary role" message to a node. + * * @param msg a message - * @throws ProtocolException if communication failed + * @throws ProtocolException if communication failed */ void assignPrimaryRole(PrimaryRoleAssignmentMessage msg) throws ProtocolException; /** * Sets the {@link BulletinRepository} that can be used to report bulletins - * @param bulletinRepository + * + * @param bulletinRepository repo */ void setBulletinRepository(final BulletinRepository bulletinRepository); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionRequest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionRequest.java index 1b5d007e78..0e27155616 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionRequest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionRequest.java @@ -20,10 +20,9 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.apache.nifi.cluster.protocol.jaxb.message.ConnectionRequestAdapter; /** - * A node's request to connect to the cluster. The request contains a proposed + * A node's request to connect to the cluster. The request contains a proposed * identifier. - * - * @author unattributed + * */ @XmlJavaTypeAdapter(ConnectionRequestAdapter.class) public class ConnectionRequest { @@ -31,7 +30,7 @@ public class ConnectionRequest { private final NodeIdentifier proposedNodeIdentifier; public ConnectionRequest(final NodeIdentifier proposedNodeIdentifier) { - if(proposedNodeIdentifier == null) { + if (proposedNodeIdentifier == null) { throw new IllegalArgumentException("Proposed node identifier may not be null."); } this.proposedNodeIdentifier = proposedNodeIdentifier; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionResponse.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionResponse.java index 7a5ff2b321..4e06926bb9 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionResponse.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionResponse.java @@ -21,13 +21,12 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.apache.nifi.cluster.protocol.jaxb.message.ConnectionResponseAdapter; /** - * The cluster manager's response to a node's connection request. If the manager - * has a current copy of the data flow, then it is returned with a node identifier - * to the node. Otherwise, the manager will provide a "try again in X seconds" - * response to the node in hopes that a current data flow will be available upon - * subsequent requests. - * - * @author unattributed + * The cluster manager's response to a node's connection request. If the manager + * has a current copy of the data flow, then it is returned with a node + * identifier to the node. Otherwise, the manager will provide a "try again in X + * seconds" response to the node in hopes that a current data flow will be + * available upon subsequent requests. + * */ @XmlJavaTypeAdapter(ConnectionResponseAdapter.class) public class ConnectionResponse { @@ -40,14 +39,14 @@ public class ConnectionResponse { private final Integer managerRemoteInputPort; private final Boolean managerRemoteCommsSecure; private final String instanceId; - + private volatile String clusterManagerDN; - - public ConnectionResponse(final NodeIdentifier nodeIdentifier, final StandardDataFlow dataFlow, final boolean primary, - final Integer managerRemoteInputPort, final Boolean managerRemoteCommsSecure, final String instanceId) { - if(nodeIdentifier == null) { + + public ConnectionResponse(final NodeIdentifier nodeIdentifier, final StandardDataFlow dataFlow, final boolean primary, + final Integer managerRemoteInputPort, final Boolean managerRemoteCommsSecure, final String instanceId) { + if (nodeIdentifier == null) { throw new IllegalArgumentException("Node identifier may not be empty or null."); - } else if(dataFlow == null) { + } else if (dataFlow == null) { throw new IllegalArgumentException("DataFlow may not be null."); } this.nodeIdentifier = nodeIdentifier; @@ -59,9 +58,9 @@ public class ConnectionResponse { this.managerRemoteCommsSecure = managerRemoteCommsSecure; this.instanceId = instanceId; } - + public ConnectionResponse(final int tryLaterSeconds) { - if(tryLaterSeconds <= 0) { + if (tryLaterSeconds <= 0) { throw new IllegalArgumentException("Try-Later seconds may not be nonnegative: " + tryLaterSeconds); } this.dataFlow = null; @@ -84,19 +83,19 @@ public class ConnectionResponse { this.managerRemoteCommsSecure = null; this.instanceId = null; } - + public static ConnectionResponse createBlockedByFirewallResponse() { return new ConnectionResponse(); } - + public boolean isPrimary() { return primary; } - + public boolean shouldTryLater() { return tryLaterSeconds > 0; } - + public boolean isBlockedByFirewall() { return blockedByFirewall; } @@ -104,11 +103,11 @@ public class ConnectionResponse { public int getTryLaterSeconds() { return tryLaterSeconds; } - + public StandardDataFlow getDataFlow() { return dataFlow; } - + public NodeIdentifier getNodeIdentifier() { return nodeIdentifier; } @@ -116,23 +115,22 @@ public class ConnectionResponse { public Integer getManagerRemoteInputPort() { return managerRemoteInputPort; } - + public Boolean isManagerRemoteCommsSecure() { return managerRemoteCommsSecure; } - + public String getInstanceId() { return instanceId; } - + public void setClusterManagerDN(final String dn) { this.clusterManagerDN = dn; } - + /** - * Returns the DN of the NCM, if it is available or null otherwise. - * - * @return + * @return the DN of the NCM, if it is available or null + * otherwise */ public String getClusterManagerDN() { return clusterManagerDN; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/Heartbeat.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/Heartbeat.java index 67324a1e2e..80a4ba7746 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/Heartbeat.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/Heartbeat.java @@ -23,44 +23,44 @@ import org.apache.nifi.cluster.protocol.jaxb.message.HeartbeatAdapter; /** * A heartbeat for indicating the status of a node to the cluster. - * @author unattributed + * */ @XmlJavaTypeAdapter(HeartbeatAdapter.class) public class Heartbeat { - + private final NodeIdentifier nodeIdentifier; private final boolean primary; private final boolean connected; private final long createdTimestamp; private final byte[] payload; - + public Heartbeat(final NodeIdentifier nodeIdentifier, final boolean primary, final boolean connected, final byte[] payload) { - if(nodeIdentifier == null) { + if (nodeIdentifier == null) { throw new IllegalArgumentException("Node Identifier may not be null."); - } + } this.nodeIdentifier = nodeIdentifier; this.primary = primary; this.connected = connected; this.payload = payload; this.createdTimestamp = new Date().getTime(); } - + public NodeIdentifier getNodeIdentifier() { return nodeIdentifier; } - + public byte[] getPayload() { return payload; } - + public boolean isPrimary() { return primary; } - + public boolean isConnected() { return connected; } - + @XmlTransient public long getCreatedTimestamp() { return createdTimestamp; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeBulletins.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeBulletins.java index a12052459c..86df10717d 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeBulletins.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeBulletins.java @@ -40,5 +40,5 @@ public class NodeBulletins { public byte[] getPayload() { return payload; } - + } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeIdentifier.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeIdentifier.java index 18931860c9..eff62b9039 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeIdentifier.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeIdentifier.java @@ -19,56 +19,67 @@ package org.apache.nifi.cluster.protocol; import org.apache.commons.lang3.StringUtils; /** - * A node identifier denoting the coordinates of a flow controller that is connected - * to a cluster. Nodes provide an external public API interface and an internal private - * interface for communicating with the cluster. - * - * The external API interface and internal protocol each require an IP or hostname - * as well as a port for communicating. - * + * A node identifier denoting the coordinates of a flow controller that is + * connected to a cluster. Nodes provide an external public API interface and an + * internal private interface for communicating with the cluster. + * + * The external API interface and internal protocol each require an IP or + * hostname as well as a port for communicating. + * * This class overrides hashCode and equals and considers two instances to be * equal if they have the equal IDs. - * - * @author unattributed + * * @Immutable * @Threadsafe */ public class NodeIdentifier { - - /** the unique identifier for the node */ + + /** + * the unique identifier for the node + */ private final String id; - - /** the IP or hostname to use for sending requests to the node's external interface */ + + /** + * the IP or hostname to use for sending requests to the node's external + * interface + */ private final String apiAddress; - - /** the port to use use for sending requests to the node's external interface */ - private final int apiPort; - - /** the IP or hostname to use for sending requests to the node's internal interface */ + + /** + * the port to use use for sending requests to the node's external interface + */ + private final int apiPort; + + /** + * the IP or hostname to use for sending requests to the node's internal + * interface + */ private final String socketAddress; - - /** the port to use use for sending requests to the node's internal interface */ + + /** + * the port to use use for sending requests to the node's internal interface + */ private final int socketPort; - + private final String nodeDn; public NodeIdentifier(final String id, final String apiAddress, final int apiPort, final String socketAddress, final int socketPort) { this(id, apiAddress, apiPort, socketAddress, socketPort, null); } - + public NodeIdentifier(final String id, final String apiAddress, final int apiPort, final String socketAddress, final int socketPort, final String dn) { - - if(StringUtils.isBlank(id)) { + + if (StringUtils.isBlank(id)) { throw new IllegalArgumentException("Node ID may not be empty or null."); - } else if(StringUtils.isBlank(apiAddress)) { + } else if (StringUtils.isBlank(apiAddress)) { throw new IllegalArgumentException("Node API address may not be empty or null."); - } else if(StringUtils.isBlank(socketAddress)) { + } else if (StringUtils.isBlank(socketAddress)) { throw new IllegalArgumentException("Node socket address may not be empty or null."); - } - + } + validatePort(apiPort); validatePort(socketPort); - + this.id = id; this.apiAddress = apiAddress; this.apiPort = apiPort; @@ -80,11 +91,11 @@ public class NodeIdentifier { public String getId() { return id; } - + public String getDN() { return nodeDn; } - + public String getApiAddress() { return apiAddress; } @@ -96,22 +107,22 @@ public class NodeIdentifier { public String getSocketAddress() { return socketAddress; } - + public int getSocketPort() { return socketPort; } - + private void validatePort(final int port) { - if(port < 1 || port > 65535) { + if (port < 1 || port > 65535) { throw new IllegalArgumentException("Port must be inclusively in the range [1, 65535]. Port given: " + port); - } + } } - + /** * Compares the id of two node identifiers for equality. - * + * * @param obj a node identifier - * + * * @return true if the id is equal; false otherwise */ @Override @@ -130,33 +141,33 @@ public class NodeIdentifier { } /** - * Compares API address/port and socket address/port for equality. The - * id is not used for comparison. - * + * Compares API address/port and socket address/port for equality. The id is + * not used for comparison. + * * @param other a node identifier - * + * * @return true if API address/port and socket address/port are equal; false * otherwise */ public boolean logicallyEquals(final NodeIdentifier other) { - if(other == null) { + if (other == null) { return false; } if ((this.apiAddress == null) ? (other.apiAddress != null) : !this.apiAddress.equals(other.apiAddress)) { return false; } - if(this.apiPort != other.apiPort) { + if (this.apiPort != other.apiPort) { return false; } if ((this.socketAddress == null) ? (other.socketAddress != null) : !this.socketAddress.equals(other.socketAddress)) { return false; } - if(this.socketPort != other.socketPort) { + if (this.socketPort != other.socketPort) { return false; } return true; } - + @Override public int hashCode() { int hash = 7; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeProtocolSender.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeProtocolSender.java index 1edcb91840..f3e5df49f0 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeProtocolSender.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeProtocolSender.java @@ -24,50 +24,61 @@ import org.apache.nifi.cluster.protocol.message.NodeBulletinsMessage; import org.apache.nifi.cluster.protocol.message.ReconnectionFailureMessage; /** - * An interface for sending protocol messages from a node to the cluster manager. - * @author unattributed + * An interface for sending protocol messages from a node to the cluster + * manager. + * */ public interface NodeProtocolSender { - + /** * Sends a "connection request" message to the cluster manager. + * * @param msg a message * @return the response - * @throws UnknownServiceAddressException if the cluster manager's address is not known + * @throws UnknownServiceAddressException if the cluster manager's address + * is not known * @throws ProtocolException if communication failed */ ConnectionResponseMessage requestConnection(ConnectionRequestMessage msg) throws ProtocolException, UnknownServiceAddressException; - + /** * Sends a "heartbeat" message to the cluster manager. + * * @param msg a message - * @throws UnknownServiceAddressException if the cluster manager's address is not known + * @throws UnknownServiceAddressException if the cluster manager's address + * is not known * @throws ProtocolException if communication failed */ void heartbeat(HeartbeatMessage msg) throws ProtocolException, UnknownServiceAddressException; - + /** * Sends a bulletins message to the cluster manager. - * @param msg - * @throws ProtocolException - * @throws UnknownServiceAddressException + * + * @param msg a message + * @throws ProtocolException pe + * @throws UnknownServiceAddressException ex */ void sendBulletins(NodeBulletinsMessage msg) throws ProtocolException, UnknownServiceAddressException; - + /** * Sends a failure notification if the controller was unable start. + * * @param msg a message - * @throws UnknownServiceAddressException if the cluster manager's address is not known + * @throws UnknownServiceAddressException if the cluster manager's address + * is not known * @throws ProtocolException if communication failed */ void notifyControllerStartupFailure(ControllerStartupFailureMessage msg) throws ProtocolException, UnknownServiceAddressException; - + /** - * Sends a failure notification if the node was unable to reconnect to the cluster + * Sends a failure notification if the node was unable to reconnect to the + * cluster + * * @param msg a message - * @throws UnknownServiceAddressException if the cluster manager's address is not known + * @throws UnknownServiceAddressException if the cluster manager's address + * is not known * @throws ProtocolException if communication failed */ void notifyReconnectionFailure(ReconnectionFailureMessage msg) throws ProtocolException, UnknownServiceAddressException; - + } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolContext.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolContext.java index b614e7630e..402366084f 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolContext.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolContext.java @@ -17,22 +17,23 @@ package org.apache.nifi.cluster.protocol; /** - * The context for communicating using the internal cluster protocol. - * + * The context for communicating using the internal cluster protocol. + * * @param The type of protocol message. - * - * @author unattributed + * */ public interface ProtocolContext { - + /** * Creates a marshaller for serializing protocol messages. + * * @return a marshaller */ ProtocolMessageMarshaller createMarshaller(); - + /** * Creates an unmarshaller for deserializing protocol messages. + * * @return a unmarshaller */ ProtocolMessageUnmarshaller createUnmarshaller(); diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolException.java index f11ad84aa0..247f73d787 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolException.java @@ -19,21 +19,21 @@ package org.apache.nifi.cluster.protocol; /** * The base exception for problems encountered while communicating within the * cluster. - * @author unattributed + * */ public class ProtocolException extends RuntimeException { - + public ProtocolException() { } - + public ProtocolException(String msg) { super(msg); } - + public ProtocolException(Throwable cause) { super(cause); } - + public ProtocolException(String msg, Throwable cause) { super(msg, cause); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolHandler.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolHandler.java index 6de87db997..b2bace9699 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolHandler.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolHandler.java @@ -20,25 +20,26 @@ import org.apache.nifi.cluster.protocol.message.ProtocolMessage; /** * A handler for processing protocol messages. - * @author unattributed + * */ public interface ProtocolHandler { - + /** * Handles the given protocol message or throws an exception if it cannot - * handle the message. If no response is needed by the protocol, then null + * handle the message. If no response is needed by the protocol, then null * should be returned. - * + * * @param msg a message * @return a response or null, if no response is necessary - * + * * @throws ProtocolException if the message could not be processed */ ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException; - + /** - * @param msg - * @return true if the handler can process the given message; false otherwise + * @param msg a message + * @return true if the handler can process the given message; false + * otherwise */ boolean canHandle(ProtocolMessage msg); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolListener.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolListener.java index 32f0f5ddfe..2f35241141 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolListener.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolListener.java @@ -23,48 +23,53 @@ import org.apache.nifi.reporting.BulletinRepository; /** * Defines the interface for a listener to process protocol messages. - * @author unattributed + * */ public interface ProtocolListener { - + /** - * Starts the instance for listening for messages. Start may only be called + * Starts the instance for listening for messages. Start may only be called * if the instance is not running. - * @throws java.io.IOException + * + * @throws java.io.IOException ex */ void start() throws IOException; - + /** - * Stops the instance from listening for messages. Stop may only be called + * Stops the instance from listening for messages. Stop may only be called * if the instance is running. - * @throws java.io.IOException + * + * @throws java.io.IOException ex */ void stop() throws IOException; - + /** * @return true if the instance is started; false otherwise. */ boolean isRunning(); - + /** * @return the handlers registered with the listener */ Collection getHandlers(); - + /** * Registers a handler with the listener. + * * @param handler a handler */ void addHandler(ProtocolHandler handler); - + /** * Sets the BulletinRepository that can be used to report bulletins - * @param bulletinRepository + * + * @param bulletinRepository repo */ void setBulletinRepository(BulletinRepository bulletinRepository); - + /** * Unregisters the handler with the listener. + * * @param handler a handler * @return true if the handler was removed; false otherwise */ diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageMarshaller.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageMarshaller.java index bb436e0c4e..6fd921ef1f 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageMarshaller.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageMarshaller.java @@ -21,15 +21,15 @@ import java.io.OutputStream; /** * Defines a marshaller for serializing protocol messages. - * + * * @param The type of protocol message. - * - * @author unattributed + * */ public interface ProtocolMessageMarshaller { - + /** * Serializes the given message to the given output stream. + * * @param msg a message * @param os an output stream * @throws IOException if the message could not be serialized to the stream diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageUnmarshaller.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageUnmarshaller.java index c690e7bfe7..e8910bd41c 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageUnmarshaller.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageUnmarshaller.java @@ -21,18 +21,19 @@ import java.io.InputStream; /** * Defines an unmarshaller for deserializing protocol messages. - * + * * @param The type of protocol message. - * - * @author unattributed + * */ public interface ProtocolMessageUnmarshaller { - + /** * Deserializes a message on the given input stream. + * * @param is an input stream - * @return - * @throws IOException if the message could not be deserialized from the stream + * @return deserialized message + * @throws IOException if the message could not be deserialized from the + * stream */ T unmarshal(InputStream is) throws IOException; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/StandardDataFlow.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/StandardDataFlow.java index c2d16fc01b..0f0ed69ba5 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/StandardDataFlow.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/StandardDataFlow.java @@ -25,25 +25,25 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.apache.nifi.cluster.protocol.jaxb.message.DataFlowAdapter; /** - * Represents a dataflow, which includes the raw bytes of the flow.xml and + * Represents a dataflow, which includes the raw bytes of the flow.xml and * whether processors should be started automatically at application startup. */ @XmlJavaTypeAdapter(DataFlowAdapter.class) public class StandardDataFlow implements Serializable, DataFlow { - + private final byte[] flow; private final byte[] templateBytes; private final byte[] snippetBytes; private boolean autoStartProcessors; - + /** - * Constructs an instance. - * + * Constructs an instance. + * * @param flow a valid flow as bytes, which cannot be null * @param templateBytes an XML representation of templates * @param snippetBytes an XML representation of snippets - * + * * @throws NullPointerException if any argument is null */ public StandardDataFlow(final byte[] flow, final byte[] templateBytes, final byte[] snippetBytes) { @@ -51,20 +51,20 @@ public class StandardDataFlow implements Serializable, DataFlow { this.templateBytes = templateBytes; this.snippetBytes = snippetBytes; } - + public StandardDataFlow(final DataFlow toCopy) { this.flow = copy(toCopy.getFlow()); this.templateBytes = copy(toCopy.getTemplates()); this.snippetBytes = copy(toCopy.getSnippets()); this.autoStartProcessors = toCopy.isAutoStartProcessors(); } - + private static byte[] copy(final byte[] bytes) { return bytes == null ? null : Arrays.copyOf(bytes, bytes.length); } - + /** - * @return the raw byte array of the flow + * @return the raw byte array of the flow */ public byte[] getFlow() { return flow; @@ -76,26 +76,26 @@ public class StandardDataFlow implements Serializable, DataFlow { public byte[] getTemplates() { return templateBytes; } - + /** * @return the raw byte array of the snippets */ public byte[] getSnippets() { return snippetBytes; } - + /** - * @return true if processors should be automatically started at application - * startup; false otherwise + * @return true if processors should be automatically started at application + * startup; false otherwise */ public boolean isAutoStartProcessors() { return autoStartProcessors; } - + /** - * + * * Sets the flag to automatically start processors at application startup. - * + * * @param autoStartProcessors true if processors should be automatically * started at application startup; false otherwise */ diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/UnknownServiceAddressException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/UnknownServiceAddressException.java index 41c74eb10b..48d70561ab 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/UnknownServiceAddressException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/UnknownServiceAddressException.java @@ -18,21 +18,21 @@ package org.apache.nifi.cluster.protocol; /** * Represents the exceptional case when a service's address is not known. - * @author unattributed + * */ public class UnknownServiceAddressException extends RuntimeException { - + public UnknownServiceAddressException() { } - + public UnknownServiceAddressException(String msg) { super(msg); } - + public UnknownServiceAddressException(Throwable cause) { super(cause); } - + public UnknownServiceAddressException(String msg, Throwable cause) { super(msg, cause); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImpl.java index ceb3fcbf9e..636a6d354c 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImpl.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImpl.java @@ -43,34 +43,32 @@ import org.apache.nifi.util.FormatUtils; /** * A protocol sender for sending protocol messages from the cluster manager to - * nodes. - * - * Connection-type requests (e.g., reconnection, disconnection) by nature of - * starting/stopping flow controllers take longer than other types of protocol - * messages. Therefore, a handshake timeout may be specified to lengthen the + * nodes. + * + * Connection-type requests (e.g., reconnection, disconnection) by nature of + * starting/stopping flow controllers take longer than other types of protocol + * messages. Therefore, a handshake timeout may be specified to lengthen the * allowable time for communication with the node. - * - * @author unattributed + * */ public class ClusterManagerProtocolSenderImpl implements ClusterManagerProtocolSender { - private final ProtocolContext protocolContext; private final SocketConfiguration socketConfiguration; private int handshakeTimeoutSeconds; private volatile BulletinRepository bulletinRepository; public ClusterManagerProtocolSenderImpl(final SocketConfiguration socketConfiguration, final ProtocolContext protocolContext) { - if(socketConfiguration == null) { + if (socketConfiguration == null) { throw new IllegalArgumentException("Socket configuration may not be null."); - } else if(protocolContext == null) { + } else if (protocolContext == null) { throw new IllegalArgumentException("Protocol Context may not be null."); } this.socketConfiguration = socketConfiguration; this.protocolContext = protocolContext; this.handshakeTimeoutSeconds = -1; // less than zero denotes variable not configured } - + @Override public void setBulletinRepository(final BulletinRepository bulletinRepository) { this.bulletinRepository = bulletinRepository; @@ -78,76 +76,79 @@ public class ClusterManagerProtocolSenderImpl implements ClusterManagerProtocolS /** * Requests the data flow from a node. + * * @param msg a message * @return the message response - * @throws @throws ProtocolException if the message failed to be sent or the response was malformed + * @throws ProtocolException if the message failed to be sent or the + * response was malformed */ @Override public FlowResponseMessage requestFlow(final FlowRequestMessage msg) throws ProtocolException { Socket socket = null; try { - socket = createSocket(msg.getNodeId(), false); - + socket = createSocket(msg.getNodeId(), false); + try { // marshal message to output stream final ProtocolMessageMarshaller marshaller = protocolContext.createMarshaller(); marshaller.marshal(msg, socket.getOutputStream()); - } catch(final IOException ioe) { + } catch (final IOException ioe) { throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe); } - + final ProtocolMessage response; try { // unmarshall response and return final ProtocolMessageUnmarshaller unmarshaller = protocolContext.createUnmarshaller(); response = unmarshaller.unmarshal(socket.getInputStream()); - } catch(final IOException ioe) { + } catch (final IOException ioe) { throw new ProtocolException("Failed unmarshalling '" + MessageType.FLOW_RESPONSE + "' protocol message due to: " + ioe, ioe); - } - - if(MessageType.FLOW_RESPONSE == response.getType()) { + } + + if (MessageType.FLOW_RESPONSE == response.getType()) { return (FlowResponseMessage) response; } else { throw new ProtocolException("Expected message type '" + MessageType.FLOW_RESPONSE + "' but found '" + response.getType() + "'"); } - + } finally { SocketUtils.closeQuietly(socket); } } /** - * Requests a node to reconnect to the cluster. The configured value for + * Requests a node to reconnect to the cluster. The configured value for * handshake timeout is applied to the socket before making the request. + * * @param msg a message * @return the response - * @throws ProtocolException if the message failed to be sent or the response was malformed + * @throws ProtocolException if the message failed to be sent or the + * response was malformed */ @Override public ReconnectionResponseMessage requestReconnection(final ReconnectionRequestMessage msg) throws ProtocolException { Socket socket = null; try { - socket = createSocket(msg.getNodeId(), true); + socket = createSocket(msg.getNodeId(), true); // marshal message to output stream try { final ProtocolMessageMarshaller marshaller = protocolContext.createMarshaller(); marshaller.marshal(msg, socket.getOutputStream()); - } catch(final IOException ioe) { + } catch (final IOException ioe) { throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe); } - - + final ProtocolMessage response; try { // unmarshall response and return final ProtocolMessageUnmarshaller unmarshaller = protocolContext.createUnmarshaller(); response = unmarshaller.unmarshal(socket.getInputStream()); - } catch(final IOException ioe) { + } catch (final IOException ioe) { throw new ProtocolException("Failed unmarshalling '" + MessageType.RECONNECTION_RESPONSE + "' protocol message due to: " + ioe, ioe); - } - - if(MessageType.RECONNECTION_RESPONSE == response.getType()) { + } + + if (MessageType.RECONNECTION_RESPONSE == response.getType()) { return (ReconnectionResponseMessage) response; } else { throw new ProtocolException("Expected message type '" + MessageType.FLOW_RESPONSE + "' but found '" + response.getType() + "'"); @@ -156,10 +157,11 @@ public class ClusterManagerProtocolSenderImpl implements ClusterManagerProtocolS SocketUtils.closeQuietly(socket); } } - + /** - * Requests a node to disconnect from the cluster. The configured value for + * Requests a node to disconnect from the cluster. The configured value for * handshake timeout is applied to the socket before making the request. + * * @param msg a message * @throws ProtocolException if the message failed to be sent */ @@ -167,13 +169,13 @@ public class ClusterManagerProtocolSenderImpl implements ClusterManagerProtocolS public void disconnect(final DisconnectMessage msg) throws ProtocolException { Socket socket = null; try { - socket = createSocket(msg.getNodeId(), true); + socket = createSocket(msg.getNodeId(), true); // marshal message to output stream try { final ProtocolMessageMarshaller marshaller = protocolContext.createMarshaller(); marshaller.marshal(msg, socket.getOutputStream()); - } catch(final IOException ioe) { + } catch (final IOException ioe) { throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe); } } finally { @@ -183,37 +185,36 @@ public class ClusterManagerProtocolSenderImpl implements ClusterManagerProtocolS /** * Assigns the primary role to a node. - * + * * @param msg a message - * + * * @throws ProtocolException if the message failed to be sent */ @Override public void assignPrimaryRole(final PrimaryRoleAssignmentMessage msg) throws ProtocolException { Socket socket = null; try { - socket = createSocket(msg.getNodeId(), true); + socket = createSocket(msg.getNodeId(), true); try { // marshal message to output stream final ProtocolMessageMarshaller marshaller = protocolContext.createMarshaller(); marshaller.marshal(msg, socket.getOutputStream()); - } catch(final IOException ioe) { + } catch (final IOException ioe) { throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe); } } finally { SocketUtils.closeQuietly(socket); } } - - + private void setConnectionHandshakeTimeoutOnSocket(final Socket socket) throws SocketException { // update socket timeout, if handshake timeout was set; otherwise use socket's current timeout - if(handshakeTimeoutSeconds >= 0) { + if (handshakeTimeoutSeconds >= 0) { socket.setSoTimeout(handshakeTimeoutSeconds * 1000); - } + } } - + public SocketConfiguration getSocketConfiguration() { return socketConfiguration; } @@ -227,18 +228,18 @@ public class ClusterManagerProtocolSenderImpl implements ClusterManagerProtocolS } private Socket createSocket(final NodeIdentifier nodeId, final boolean applyHandshakeTimeout) { - return createSocket(nodeId.getSocketAddress(), nodeId.getSocketPort(), applyHandshakeTimeout); + return createSocket(nodeId.getSocketAddress(), nodeId.getSocketPort(), applyHandshakeTimeout); } - + private Socket createSocket(final String host, final int port, final boolean applyHandshakeTimeout) { - try { + try { // create a socket final Socket socket = SocketUtils.createSocket(InetSocketAddress.createUnresolved(host, port), socketConfiguration); - if ( applyHandshakeTimeout ) { - setConnectionHandshakeTimeoutOnSocket(socket); + if (applyHandshakeTimeout) { + setConnectionHandshakeTimeoutOnSocket(socket); } return socket; - } catch(final IOException ioe) { + } catch (final IOException ioe) { throw new ProtocolException("Failed to create socket due to: " + ioe, ioe); } } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderListener.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderListener.java index 933e5fade8..8eb83a4e39 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderListener.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderListener.java @@ -32,21 +32,20 @@ import org.apache.nifi.cluster.protocol.message.ReconnectionResponseMessage; import org.apache.nifi.reporting.BulletinRepository; /** - * A wrapper class for consolidating a protocol sender and listener for the cluster - * manager. - * - * @author unattributed + * A wrapper class for consolidating a protocol sender and listener for the + * cluster manager. + * */ public class ClusterManagerProtocolSenderListener implements ClusterManagerProtocolSender, ProtocolListener { - + private final ClusterManagerProtocolSender sender; - + private final ProtocolListener listener; - + public ClusterManagerProtocolSenderListener(final ClusterManagerProtocolSender sender, final ProtocolListener listener) { - if(sender == null) { + if (sender == null) { throw new IllegalArgumentException("ClusterManagerProtocolSender may not be null."); - } else if(listener == null) { + } else if (listener == null) { throw new IllegalArgumentException("ProtocolListener may not be null."); } this.sender = sender; @@ -55,7 +54,7 @@ public class ClusterManagerProtocolSenderListener implements ClusterManagerProto @Override public void stop() throws IOException { - if(!isRunning()) { + if (!isRunning()) { throw new IllegalStateException("Instance is already stopped."); } listener.stop(); @@ -63,7 +62,7 @@ public class ClusterManagerProtocolSenderListener implements ClusterManagerProto @Override public void start() throws IOException { - if(isRunning()) { + if (isRunning()) { throw new IllegalStateException("Instance is already started."); } listener.start(); @@ -88,13 +87,13 @@ public class ClusterManagerProtocolSenderListener implements ClusterManagerProto public void addHandler(final ProtocolHandler handler) { listener.addHandler(handler); } - + @Override public void setBulletinRepository(final BulletinRepository bulletinRepository) { listener.setBulletinRepository(bulletinRepository); sender.setBulletinRepository(bulletinRepository); } - + @Override public FlowResponseMessage requestFlow(final FlowRequestMessage msg) throws ProtocolException { return sender.requestFlow(msg); @@ -109,10 +108,10 @@ public class ClusterManagerProtocolSenderListener implements ClusterManagerProto public void disconnect(DisconnectMessage msg) throws ProtocolException { sender.disconnect(msg); } - + @Override public void assignPrimaryRole(PrimaryRoleAssignmentMessage msg) throws ProtocolException { sender.assignPrimaryRole(msg); } - + } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscovery.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscovery.java index 24e51e0ee9..f808c83ab7 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscovery.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscovery.java @@ -45,7 +45,6 @@ import org.slf4j.LoggerFactory; * discovery. The instance must be stopped before termination of the JVM to * ensure proper resource clean-up. * - * @author unattributed */ public class ClusterServiceDiscovery implements MulticastServiceDiscovery, ProtocolListener { @@ -60,7 +59,6 @@ public class ClusterServiceDiscovery implements MulticastServiceDiscovery, Proto */ private DiscoverableService service; - public ClusterServiceDiscovery(final String serviceName, final InetSocketAddress multicastAddress, final MulticastConfiguration multicastConfiguration, final ProtocolContext protocolContext) { @@ -162,7 +160,8 @@ public class ClusterServiceDiscovery implements MulticastServiceDiscovery, Proto || broadcastMsg.getPort() != oldService.getServiceAddress().getPort()) { service = new DiscoverableServiceImpl(serviceName, InetSocketAddress.createUnresolved(broadcastMsg.getAddress(), broadcastMsg.getPort())); final InetSocketAddress oldServiceAddress = (oldService == null) ? null : oldService.getServiceAddress(); - logger.info(String.format("Updating cluster service address for '%s' from '%s' to '%s'", serviceName, prettyPrint(oldServiceAddress), prettyPrint(service.getServiceAddress()))); + logger.info(String.format("Updating cluster service address for '%s' from '%s' to '%s'", + serviceName, prettyPrint(oldServiceAddress), prettyPrint(service.getServiceAddress()))); } } return null; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocator.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocator.java index bebfde8b2e..a49847f89d 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocator.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocator.java @@ -27,39 +27,38 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Implements the ServiceLocator interface for locating the socket address - * of a cluster service. Depending on configuration, the address may be located - * using service discovery. If using service discovery, then the service methods - * must be used for starting and stopping discovery. - * - * Service discovery may be used in conjunction with a fixed port. In this case, - * the service discovery will yield the service IP/host while the fixed port will - * be used for the port. - * + * Implements the ServiceLocator interface for locating the socket address of a + * cluster service. Depending on configuration, the address may be located using + * service discovery. If using service discovery, then the service methods must + * be used for starting and stopping discovery. + * + * Service discovery may be used in conjunction with a fixed port. In this case, + * the service discovery will yield the service IP/host while the fixed port + * will be used for the port. + * * Alternatively, the instance may be configured with exact service location, in - * which case, no service discovery occurs and the caller will always receive the - * configured service. - * - * @author unattributed + * which case, no service discovery occurs and the caller will always receive + * the configured service. + * */ public class ClusterServiceLocator implements ServiceDiscovery { - + private static final Logger logger = LoggerFactory.getLogger(ClusterServiceLocator.class); - + private final String serviceName; - + private final ClusterServiceDiscovery serviceDiscovery; - + private final DiscoverableService fixedService; private final int fixedServicePort; - + private final AttemptsConfig attemptsConfig = new AttemptsConfig(); - + private final AtomicBoolean running = new AtomicBoolean(false); - + public ClusterServiceLocator(final ClusterServiceDiscovery serviceDiscovery) { - if(serviceDiscovery == null) { + if (serviceDiscovery == null) { throw new IllegalArgumentException("ClusterServiceDiscovery may not be null."); } this.serviceDiscovery = serviceDiscovery; @@ -67,9 +66,9 @@ public class ClusterServiceLocator implements ServiceDiscovery { this.fixedServicePort = 0; this.serviceName = serviceDiscovery.getServiceName(); } - + public ClusterServiceLocator(final ClusterServiceDiscovery serviceDiscovery, final int fixedServicePort) { - if(serviceDiscovery == null) { + if (serviceDiscovery == null) { throw new IllegalArgumentException("ClusterServiceDiscovery may not be null."); } this.serviceDiscovery = serviceDiscovery; @@ -77,9 +76,9 @@ public class ClusterServiceLocator implements ServiceDiscovery { this.fixedServicePort = fixedServicePort; this.serviceName = serviceDiscovery.getServiceName(); } - + public ClusterServiceLocator(final DiscoverableService fixedService) { - if(fixedService == null) { + if (fixedService == null) { throw new IllegalArgumentException("Service may not be null."); } this.serviceDiscovery = null; @@ -87,30 +86,30 @@ public class ClusterServiceLocator implements ServiceDiscovery { this.fixedServicePort = 0; this.serviceName = fixedService.getServiceName(); } - + @Override public DiscoverableService getService() { - + final int numAttemptsValue; final int secondsBetweenAttempts; - synchronized(this) { + synchronized (this) { numAttemptsValue = attemptsConfig.numAttempts; secondsBetweenAttempts = attemptsConfig.getTimeBetweenAttempts(); } - - // try for a configured amount of attempts to retrieve the service address - for(int i = 0; i < numAttemptsValue; i++) { - if(fixedService != null) { + // try for a configured amount of attempts to retrieve the service address + for (int i = 0; i < numAttemptsValue; i++) { + + if (fixedService != null) { return fixedService; - } else if(serviceDiscovery != null) { - + } else if (serviceDiscovery != null) { + final DiscoverableService discoveredService = serviceDiscovery.getService(); - + // if we received an address - if(discoveredService != null) { + if (discoveredService != null) { // if we were configured with a fixed port, then use the discovered host and fixed port; otherwise use the discovered address - if(fixedServicePort > 0) { + if (fixedServicePort > 0) { // create service using discovered service name and address with fixed service port final InetSocketAddress addr = InetSocketAddress.createUnresolved(discoveredService.getServiceAddress().getHostName(), fixedServicePort); final DiscoverableService result = new DiscoverableServiceImpl(discoveredService.getServiceName(), addr); @@ -120,23 +119,23 @@ public class ClusterServiceLocator implements ServiceDiscovery { } } } - + // could not obtain service address, so sleep a bit try { - logger.debug(String.format("Locating Cluster Service '%s' Attempt: %d of %d failed. Trying again in %d seconds.", - serviceName, (i + 1), numAttemptsValue, secondsBetweenAttempts)); + logger.debug(String.format("Locating Cluster Service '%s' Attempt: %d of %d failed. Trying again in %d seconds.", + serviceName, (i + 1), numAttemptsValue, secondsBetweenAttempts)); Thread.sleep(secondsBetweenAttempts * 1000); - } catch(final InterruptedException ie) { + } catch (final InterruptedException ie) { break; } - + } return null; } public boolean isRunning() { - if(serviceDiscovery != null) { + if (serviceDiscovery != null) { return serviceDiscovery.isRunning(); } else { return running.get(); @@ -144,31 +143,31 @@ public class ClusterServiceLocator implements ServiceDiscovery { } public void start() throws IOException { - - if(isRunning()) { + + if (isRunning()) { throw new IllegalStateException("Instance is already started."); } - - if(serviceDiscovery != null) { + + if (serviceDiscovery != null) { serviceDiscovery.start(); } running.set(true); } public void stop() throws IOException { - - if(isRunning() == false) { + + if (isRunning() == false) { throw new IllegalStateException("Instance is already stopped."); } - - if(serviceDiscovery != null) { + + if (serviceDiscovery != null) { serviceDiscovery.stop(); } running.set(false); } - + public synchronized void setAttemptsConfig(final AttemptsConfig config) { - if(config == null) { + if (config == null) { throw new IllegalArgumentException("Attempts configuration may not be null."); } this.attemptsConfig.numAttempts = config.numAttempts; @@ -183,21 +182,21 @@ public class ClusterServiceLocator implements ServiceDiscovery { config.timeBetweenAttempsUnit = this.attemptsConfig.timeBetweenAttempsUnit; return config; } - + public static class AttemptsConfig { - + private int numAttempts = 1; - + private int timeBetweenAttempts = 1; - + private TimeUnit timeBetweenAttempsUnit = TimeUnit.SECONDS; - + public int getNumAttempts() { return numAttempts; } public void setNumAttempts(int numAttempts) { - if(numAttempts <= 0) { + if (numAttempts <= 0) { throw new IllegalArgumentException("Number of attempts must be positive: " + numAttempts); } this.numAttempts = numAttempts; @@ -208,9 +207,9 @@ public class ClusterServiceLocator implements ServiceDiscovery { } public void setTimeBetweenAttempsUnit(TimeUnit timeBetweenAttempsUnit) { - if(timeBetweenAttempts <= 0) { + if (timeBetweenAttempts <= 0) { throw new IllegalArgumentException("Time between attempts must be positive: " + numAttempts); - } + } this.timeBetweenAttempsUnit = timeBetweenAttempsUnit; } @@ -219,9 +218,9 @@ public class ClusterServiceLocator implements ServiceDiscovery { } public void setTimeBetweenAttempts(int timeBetweenAttempts) { - if(timeBetweenAttempts <= 0) { - throw new IllegalArgumentException("Time between attempts must be positive: " + numAttempts); - } + if (timeBetweenAttempts <= 0) { + throw new IllegalArgumentException("Time between attempts must be positive: " + numAttempts); + } this.timeBetweenAttempts = timeBetweenAttempts; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcaster.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcaster.java index e9e7d5bc60..0bb13d40af 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcaster.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcaster.java @@ -21,7 +21,10 @@ import java.io.IOException; import java.net.DatagramPacket; import java.net.InetSocketAddress; import java.net.MulticastSocket; -import java.util.*; +import java.util.Collections; +import java.util.Set; +import java.util.Timer; +import java.util.TimerTask; import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.TimeUnit; @@ -39,75 +42,75 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Broadcasts services used by the clustering software using multicast communication. - * A configurable delay occurs after broadcasting the collection of services. - * + * Broadcasts services used by the clustering software using multicast + * communication. A configurable delay occurs after broadcasting the collection + * of services. + * * The client caller is responsible for starting and stopping the broadcasting. * The instance must be stopped before termination of the JVM to ensure proper * resource clean-up. - * - * @author unattributed + * */ public class ClusterServicesBroadcaster implements MulticastServicesBroadcaster { - + private static final Logger logger = new NiFiLog(LoggerFactory.getLogger(ClusterServicesBroadcaster.class)); - + private final Set services = new CopyOnWriteArraySet<>(); private final InetSocketAddress multicastAddress; - + private final MulticastConfiguration multicastConfiguration; - + private final ProtocolContext protocolContext; - + private final int broadcastDelayMs; - + private Timer broadcaster; - + private MulticastSocket multicastSocket; - - public ClusterServicesBroadcaster(final InetSocketAddress multicastAddress, - final MulticastConfiguration multicastConfiguration, + + public ClusterServicesBroadcaster(final InetSocketAddress multicastAddress, + final MulticastConfiguration multicastConfiguration, final ProtocolContext protocolContext, final String broadcastDelay) { - - if(multicastAddress == null) { + + if (multicastAddress == null) { throw new IllegalArgumentException("Multicast address may not be null."); - } else if(multicastAddress.getAddress().isMulticastAddress() == false) { + } else if (multicastAddress.getAddress().isMulticastAddress() == false) { throw new IllegalArgumentException("Multicast group address is not a Class D IP address."); - } else if(protocolContext == null) { + } else if (protocolContext == null) { throw new IllegalArgumentException("Protocol Context may not be null."); - } else if(multicastConfiguration == null) { + } else if (multicastConfiguration == null) { throw new IllegalArgumentException("Multicast configuration may not be null."); } - + this.services.addAll(services); this.multicastAddress = multicastAddress; this.multicastConfiguration = multicastConfiguration; this.protocolContext = protocolContext; this.broadcastDelayMs = (int) FormatUtils.getTimeDuration(broadcastDelay, TimeUnit.MILLISECONDS); } - + public void start() throws IOException { - if(isRunning()) { + if (isRunning()) { throw new IllegalStateException("Instance is already started."); } - + // setup socket multicastSocket = MulticastUtils.createMulticastSocket(multicastConfiguration); - + // setup broadcaster broadcaster = new Timer("Cluster Services Broadcaster", /* is daemon */ true); broadcaster.schedule(new TimerTask() { @Override public void run() { - for(final DiscoverableService service : services) { + for (final DiscoverableService service : services) { try { final InetSocketAddress serviceAddress = service.getServiceAddress(); - logger.debug(String.format("Broadcasting Cluster Service '%s' at address %s:%d", - service.getServiceName(), serviceAddress.getHostName(), serviceAddress.getPort())); - + logger.debug(String.format("Broadcasting Cluster Service '%s' at address %s:%d", + service.getServiceName(), serviceAddress.getHostName(), serviceAddress.getPort())); + // create message final ServiceBroadcastMessage msg = new ServiceBroadcastMessage(); msg.setServiceName(service.getServiceName()); @@ -124,37 +127,37 @@ public class ClusterServicesBroadcaster implements MulticastServicesBroadcaster final DatagramPacket packet = new DatagramPacket(packetBytes, packetBytes.length, multicastAddress); multicastSocket.send(packet); - } catch(final Exception ex) { + } catch (final Exception ex) { logger.warn(String.format("Cluster Services Broadcaster failed broadcasting service '%s' due to: %s", service.getServiceName(), ex), ex); } } } }, 0, broadcastDelayMs); } - + public boolean isRunning() { return (broadcaster != null); } - + public void stop() { - - if(isRunning() == false) { + + if (isRunning() == false) { throw new IllegalStateException("Instance is already stopped."); } - + broadcaster.cancel(); broadcaster = null; // close socket MulticastUtils.closeQuietly(multicastSocket); - + } @Override public int getBroadcastDelayMs() { return broadcastDelayMs; } - + @Override public Set getServices() { return Collections.unmodifiableSet(services); @@ -164,16 +167,16 @@ public class ClusterServicesBroadcaster implements MulticastServicesBroadcaster public InetSocketAddress getMulticastAddress() { return multicastAddress; } - + @Override public boolean addService(final DiscoverableService service) { return services.add(service); } - + @Override public boolean removeService(final String serviceName) { - for(final DiscoverableService service : services) { - if(service.getServiceName().equals(serviceName)) { + for (final DiscoverableService service : services) { + if (service.getServiceName().equals(serviceName)) { return services.remove(service); } } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/CopyingInputStream.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/CopyingInputStream.java index 680df65aec..7ac17ab85e 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/CopyingInputStream.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/CopyingInputStream.java @@ -23,6 +23,7 @@ import java.io.InputStream; import java.io.OutputStream; public class CopyingInputStream extends FilterInputStream { + private final ByteArrayOutputStream baos = new ByteArrayOutputStream(); private final int maxBytesToCopy; private final InputStream in; @@ -32,45 +33,45 @@ public class CopyingInputStream extends FilterInputStream { this.maxBytesToCopy = maxBytesToCopy; this.in = in; } - + @Override public int read() throws IOException { final int delegateRead = in.read(); - if ( delegateRead != -1 && getNumberOfBytesCopied() < maxBytesToCopy ) { + if (delegateRead != -1 && getNumberOfBytesCopied() < maxBytesToCopy) { baos.write(delegateRead); } - + return delegateRead; } - + @Override public int read(byte[] b) throws IOException { final int delegateRead = in.read(b); - if ( delegateRead >= 0 ) { + if (delegateRead >= 0) { baos.write(b, 0, Math.min(delegateRead, maxBytesToCopy - getNumberOfBytesCopied())); } - + return delegateRead; } - + @Override public int read(byte[] b, int off, int len) throws IOException { final int delegateRead = in.read(b, off, len); - if ( delegateRead >= 0 ) { + if (delegateRead >= 0) { baos.write(b, off, Math.min(delegateRead, maxBytesToCopy - getNumberOfBytesCopied())); } - + return delegateRead; } - + public byte[] getBytesRead() { return baos.toByteArray(); } - + public void writeBytes(final OutputStream out) throws IOException { baos.writeTo(out); } - + public int getNumberOfBytesCopied() { return baos.size(); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListener.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListener.java index d3764b3d58..8ca51419fa 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListener.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListener.java @@ -45,20 +45,19 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Implements a listener for protocol messages sent over multicast. If a message + * Implements a listener for protocol messages sent over multicast. If a message * is of type MulticastProtocolMessage, then the underlying protocol message is - * passed to the handler. If the receiving handler produces a message response, - * then the message is wrapped with a MulticastProtocolMessage before being - * sent to the originator. - * - * The client caller is responsible for starting and stopping the listener. - * The instance must be stopped before termination of the JVM to ensure proper + * passed to the handler. If the receiving handler produces a message response, + * then the message is wrapped with a MulticastProtocolMessage before being sent + * to the originator. + * + * The client caller is responsible for starting and stopping the listener. The + * instance must be stopped before termination of the JVM to ensure proper * resource clean-up. - * - * @author unattributed + * */ public class MulticastProtocolListener extends MulticastListener implements ProtocolListener { - + private static final Logger logger = new NiFiLog(LoggerFactory.getLogger(MulticastProtocolListener.class)); // immutable members @@ -74,7 +73,7 @@ public class MulticastProtocolListener extends MulticastListener implements Prot final ProtocolContext protocolContext) { super(numThreads, multicastAddress, configuration); - + if (protocolContext == null) { throw new IllegalArgumentException("Protocol Context may not be null."); } @@ -89,21 +88,21 @@ public class MulticastProtocolListener extends MulticastListener implements Prot @Override public void start() throws IOException { - if(super.isRunning()) { + if (super.isRunning()) { throw new IllegalStateException("Instance is already started."); } - + super.start(); - + } @Override public void stop() throws IOException { - if(super.isRunning() == false) { + if (super.isRunning() == false) { throw new IllegalStateException("Instance is already stopped."); } - + // shutdown listener super.stop(); @@ -116,17 +115,17 @@ public class MulticastProtocolListener extends MulticastListener implements Prot @Override public void addHandler(final ProtocolHandler handler) { - if(handler == null) { + if (handler == null) { throw new NullPointerException("Protocol handler may not be null."); } handlers.add(handler); } - + @Override public boolean removeHandler(final ProtocolHandler handler) { return handlers.remove(handler); } - + @Override public void dispatchRequest(final MulticastSocket multicastSocket, final DatagramPacket packet) { @@ -138,10 +137,10 @@ public class MulticastProtocolListener extends MulticastListener implements Prot // unwrap multicast message, if necessary final ProtocolMessage unwrappedRequest; - if(request instanceof MulticastProtocolMessage) { + if (request instanceof MulticastProtocolMessage) { final MulticastProtocolMessage multicastRequest = (MulticastProtocolMessage) request; // don't process a message we sent - if(listenerId.equals(multicastRequest.getId())) { + if (listenerId.equals(multicastRequest.getId())) { return; } else { unwrappedRequest = multicastRequest.getProtocolMessage(); @@ -149,7 +148,7 @@ public class MulticastProtocolListener extends MulticastListener implements Prot } else { unwrappedRequest = request; } - + // dispatch message to handler ProtocolHandler desiredHandler = null; for (final ProtocolHandler handler : getHandlers()) { @@ -164,28 +163,28 @@ public class MulticastProtocolListener extends MulticastListener implements Prot throw new ProtocolException("No handler assigned to handle message type: " + request.getType()); } else { final ProtocolMessage response = desiredHandler.handle(request); - if(response != null) { + if (response != null) { try { - + // wrap with listener id final MulticastProtocolMessage multicastResponse = new MulticastProtocolMessage(listenerId, response); - + // marshal message final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ProtocolMessageMarshaller marshaller = protocolContext.createMarshaller(); marshaller.marshal(multicastResponse, baos); final byte[] responseBytes = baos.toByteArray(); - + final int maxPacketSizeBytes = getMaxPacketSizeBytes(); - if(responseBytes.length > maxPacketSizeBytes) { - logger.warn("Cluster protocol handler '" + desiredHandler.getClass() + - "' produced a multicast response with length greater than configured max packet size '" + maxPacketSizeBytes + "'"); + if (responseBytes.length > maxPacketSizeBytes) { + logger.warn("Cluster protocol handler '" + desiredHandler.getClass() + + "' produced a multicast response with length greater than configured max packet size '" + maxPacketSizeBytes + "'"); } - + // create and send packet - final DatagramPacket responseDatagram = new DatagramPacket(responseBytes, responseBytes.length, getMulticastAddress().getAddress(), getMulticastAddress().getPort()); + final DatagramPacket responseDatagram = new DatagramPacket(responseBytes, responseBytes.length, getMulticastAddress().getAddress(), getMulticastAddress().getPort()); multicastSocket.send(responseDatagram); - + } catch (final IOException ioe) { throw new ProtocolException("Failed marshalling protocol message in response to message type: " + request.getType() + " due to: " + ioe, ioe); } @@ -194,8 +193,8 @@ public class MulticastProtocolListener extends MulticastListener implements Prot } catch (final Throwable t) { logger.warn("Failed processing protocol message due to " + t, t); - - if ( bulletinRepository != null ) { + + if (bulletinRepository != null) { final Bulletin bulletin = BulletinFactory.createBulletin("Clustering", "WARNING", "Failed to process Protocol Message due to " + t.toString()); bulletinRepository.addBulletin(bulletin); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImpl.java index dc86d24ea2..993dea5c0b 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImpl.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImpl.java @@ -41,38 +41,38 @@ import org.apache.nifi.io.socket.SocketUtils; import org.apache.nifi.io.socket.multicast.DiscoverableService; public class NodeProtocolSenderImpl implements NodeProtocolSender { + private final SocketConfiguration socketConfiguration; private final ClusterServiceLocator clusterManagerProtocolServiceLocator; private final ProtocolContext protocolContext; - - public NodeProtocolSenderImpl(final ClusterServiceLocator clusterManagerProtocolServiceLocator, + + public NodeProtocolSenderImpl(final ClusterServiceLocator clusterManagerProtocolServiceLocator, final SocketConfiguration socketConfiguration, final ProtocolContext protocolContext) { - if(clusterManagerProtocolServiceLocator == null) { + if (clusterManagerProtocolServiceLocator == null) { throw new IllegalArgumentException("Protocol Service Locator may not be null."); - } else if(socketConfiguration == null) { + } else if (socketConfiguration == null) { throw new IllegalArgumentException("Socket configuration may not be null."); - } else if(protocolContext == null) { + } else if (protocolContext == null) { throw new IllegalArgumentException("Protocol Context may not be null."); } - + this.clusterManagerProtocolServiceLocator = clusterManagerProtocolServiceLocator; this.socketConfiguration = socketConfiguration; this.protocolContext = protocolContext; } - - + @Override public ConnectionResponseMessage requestConnection(final ConnectionRequestMessage msg) throws ProtocolException, UnknownServiceAddressException { Socket socket = null; try { socket = createSocket(); - + String ncmDn = null; - if ( socket instanceof SSLSocket ) { + if (socket instanceof SSLSocket) { final SSLSocket sslSocket = (SSLSocket) socket; try { final X509Certificate[] certChains = sslSocket.getSession().getPeerCertificateChain(); - if ( certChains != null && certChains.length > 0 ) { + if (certChains != null && certChains.length > 0) { ncmDn = certChains[0].getSubjectDN().getName(); } } catch (final ProtocolException pe) { @@ -81,25 +81,25 @@ public class NodeProtocolSenderImpl implements NodeProtocolSender { throw new ProtocolException(e); } } - + try { // marshal message to output stream final ProtocolMessageMarshaller marshaller = protocolContext.createMarshaller(); marshaller.marshal(msg, socket.getOutputStream()); - } catch(final IOException ioe) { + } catch (final IOException ioe) { throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe); - } - + } + final ProtocolMessage response; try { // unmarshall response and return final ProtocolMessageUnmarshaller unmarshaller = protocolContext.createUnmarshaller(); response = unmarshaller.unmarshal(socket.getInputStream()); - } catch(final IOException ioe) { + } catch (final IOException ioe) { throw new ProtocolException("Failed unmarshalling '" + MessageType.CONNECTION_RESPONSE + "' protocol message due to: " + ioe, ioe); - } - - if(MessageType.CONNECTION_RESPONSE == response.getType()) { + } + + if (MessageType.CONNECTION_RESPONSE == response.getType()) { final ConnectionResponseMessage connectionResponse = (ConnectionResponseMessage) response; connectionResponse.setClusterManagerDN(ncmDn); return connectionResponse; @@ -110,8 +110,7 @@ public class NodeProtocolSenderImpl implements NodeProtocolSender { SocketUtils.closeQuietly(socket); } } - - + @Override public void heartbeat(final HeartbeatMessage msg) throws ProtocolException, UnknownServiceAddressException { sendProtocolMessage(msg); @@ -131,22 +130,22 @@ public class NodeProtocolSenderImpl implements NodeProtocolSender { public void notifyReconnectionFailure(ReconnectionFailureMessage msg) throws ProtocolException, UnknownServiceAddressException { sendProtocolMessage(msg); } - + private Socket createSocket() { // determine the cluster manager's address - final DiscoverableService service = clusterManagerProtocolServiceLocator.getService(); - if(service == null) { + final DiscoverableService service = clusterManagerProtocolServiceLocator.getService(); + if (service == null) { throw new UnknownServiceAddressException("Cluster Manager's service is not known. Verify a cluster manager is running."); } - + try { // create a socket - return SocketUtils.createSocket(service.getServiceAddress(), socketConfiguration); - } catch(final IOException ioe) { + return SocketUtils.createSocket(service.getServiceAddress(), socketConfiguration); + } catch (final IOException ioe) { throw new ProtocolException("Failed to create socket due to: " + ioe, ioe); } } - + private void sendProtocolMessage(final ProtocolMessage msg) { Socket socket = null; try { @@ -156,16 +155,16 @@ public class NodeProtocolSenderImpl implements NodeProtocolSender { // marshal message to output stream final ProtocolMessageMarshaller marshaller = protocolContext.createMarshaller(); marshaller.marshal(msg, socket.getOutputStream()); - } catch(final IOException ioe) { + } catch (final IOException ioe) { throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe); } } finally { SocketUtils.closeQuietly(socket); } } - + public SocketConfiguration getSocketConfiguration() { return socketConfiguration; } - + } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderListener.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderListener.java index 4b359f462f..2992e38e1f 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderListener.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderListener.java @@ -33,14 +33,14 @@ import org.apache.nifi.cluster.protocol.message.ReconnectionFailureMessage; import org.apache.nifi.reporting.BulletinRepository; public class NodeProtocolSenderListener implements NodeProtocolSender, ProtocolListener { - + private final NodeProtocolSender sender; private final ProtocolListener listener; - + public NodeProtocolSenderListener(final NodeProtocolSender sender, final ProtocolListener listener) { - if(sender == null) { + if (sender == null) { throw new IllegalArgumentException("NodeProtocolSender may not be null."); - } else if(listener == null) { + } else if (listener == null) { throw new IllegalArgumentException("ProtocolListener may not be null."); } this.sender = sender; @@ -49,7 +49,7 @@ public class NodeProtocolSenderListener implements NodeProtocolSender, ProtocolL @Override public void stop() throws IOException { - if(!isRunning()) { + if (!isRunning()) { throw new IllegalStateException("Instance is already stopped."); } listener.stop(); @@ -57,7 +57,7 @@ public class NodeProtocolSenderListener implements NodeProtocolSender, ProtocolL @Override public void start() throws IOException { - if(isRunning()) { + if (isRunning()) { throw new IllegalStateException("Instance is already started."); } listener.start(); @@ -92,12 +92,12 @@ public class NodeProtocolSenderListener implements NodeProtocolSender, ProtocolL public ConnectionResponseMessage requestConnection(final ConnectionRequestMessage msg) throws ProtocolException, UnknownServiceAddressException { return sender.requestConnection(msg); } - + @Override public void notifyControllerStartupFailure(final ControllerStartupFailureMessage msg) throws ProtocolException, UnknownServiceAddressException { sender.notifyControllerStartupFailure(msg); } - + @Override public void notifyReconnectionFailure(final ReconnectionFailureMessage msg) throws ProtocolException, UnknownServiceAddressException { sender.notifyReconnectionFailure(msg); diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListener.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListener.java index ca30d9b2a5..d48e0ee9e5 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListener.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListener.java @@ -47,9 +47,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Implements a listener for protocol messages sent over unicast socket. - * - * @author unattributed + * Implements a listener for protocol messages sent over unicast socket. + * */ public class SocketProtocolListener extends SocketListener implements ProtocolListener { @@ -57,7 +56,7 @@ public class SocketProtocolListener extends SocketListener implements ProtocolLi private final ProtocolContext protocolContext; private final Collection handlers = new CopyOnWriteArrayList<>(); private volatile BulletinRepository bulletinRepository; - + public SocketProtocolListener( final int numThreads, final int port, @@ -65,11 +64,11 @@ public class SocketProtocolListener extends SocketListener implements ProtocolLi final ProtocolContext protocolContext) { super(numThreads, port, configuration); - - if(protocolContext == null) { + + if (protocolContext == null) { throw new IllegalArgumentException("Protocol Context may not be null."); } - + this.protocolContext = protocolContext; } @@ -77,24 +76,24 @@ public class SocketProtocolListener extends SocketListener implements ProtocolLi public void setBulletinRepository(final BulletinRepository bulletinRepository) { this.bulletinRepository = bulletinRepository; } - + @Override public void start() throws IOException { - if(super.isRunning()) { + if (super.isRunning()) { throw new IllegalStateException("Instance is already started."); } - + super.start(); } @Override public void stop() throws IOException { - if(super.isRunning() == false) { + if (super.isRunning() == false) { throw new IOException("Instance is already stopped."); } - + super.stop(); } @@ -106,12 +105,12 @@ public class SocketProtocolListener extends SocketListener implements ProtocolLi @Override public void addHandler(final ProtocolHandler handler) { - if(handler == null) { + if (handler == null) { throw new NullPointerException("Protocol handler may not be null."); } handlers.add(handler); } - + @Override public boolean removeHandler(final ProtocolHandler handler) { return handlers.remove(handler); @@ -127,13 +126,13 @@ public class SocketProtocolListener extends SocketListener implements ProtocolLi hostname = socket.getInetAddress().getHostName(); final String requestId = UUID.randomUUID().toString(); logger.info("Received request {} from {}", requestId, hostname); - + String requestorDn = null; - if ( socket instanceof SSLSocket ) { + if (socket instanceof SSLSocket) { final SSLSocket sslSocket = (SSLSocket) socket; try { final X509Certificate[] certChains = sslSocket.getSession().getPeerCertificateChain(); - if ( certChains != null && certChains.length > 0 ) { + if (certChains != null && certChains.length > 0) { requestorDn = certChains[0].getSubjectDN().getName(); } } catch (final ProtocolException pe) { @@ -142,22 +141,22 @@ public class SocketProtocolListener extends SocketListener implements ProtocolLi throw new ProtocolException(e); } } - + // unmarshall message final ProtocolMessageUnmarshaller unmarshaller = protocolContext.createUnmarshaller(); final InputStream inStream = socket.getInputStream(); final CopyingInputStream copyingInputStream = new CopyingInputStream(inStream, maxMsgBuffer); // don't copy more than 1 MB logger.debug("Request {} has a message length of {}", requestId, copyingInputStream.getNumberOfBytesCopied()); - + final ProtocolMessage request; try { request = unmarshaller.unmarshal(copyingInputStream); } finally { receivedMessage = copyingInputStream.getBytesRead(); } - + request.setRequestorDN(requestorDn); - + // dispatch message to handler ProtocolHandler desiredHandler = null; for (final ProtocolHandler handler : getHandlers()) { @@ -172,10 +171,10 @@ public class SocketProtocolListener extends SocketListener implements ProtocolLi throw new ProtocolException("No handler assigned to handle message type: " + request.getType()); } else { final ProtocolMessage response = desiredHandler.handle(request); - if(response != null) { + if (response != null) { try { logger.debug("Sending response for request {}", requestId); - + // marshal message to output stream final ProtocolMessageMarshaller marshaller = protocolContext.createMarshaller(); marshaller.marshal(response, socket.getOutputStream()); @@ -184,19 +183,19 @@ public class SocketProtocolListener extends SocketListener implements ProtocolLi } } } - + stopWatch.stop(); logger.info("Finished processing request {} (type={}, length={} bytes) in {} millis", requestId, request.getType(), receivedMessage.length, stopWatch.getDuration(TimeUnit.MILLISECONDS)); } catch (final IOException e) { logger.warn("Failed processing protocol message from " + hostname + " due to " + e, e); - - if ( bulletinRepository != null ) { + + if (bulletinRepository != null) { final Bulletin bulletin = BulletinFactory.createBulletin("Clustering", "WARNING", String.format("Failed to process protocol message from %s due to: %s", hostname, e.toString())); bulletinRepository.addBulletin(bulletin); } } catch (final ProtocolException e) { logger.warn("Failed processing protocol message from " + hostname + " due to " + e, e); - if ( bulletinRepository != null ) { + if (bulletinRepository != null) { final Bulletin bulletin = BulletinFactory.createBulletin("Clustering", "WARNING", String.format("Failed to process protocol message from %s due to: %s", hostname, e.toString())); bulletinRepository.addBulletin(bulletin); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/JaxbProtocolContext.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/JaxbProtocolContext.java index bc686306c0..4d44b4e86a 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/JaxbProtocolContext.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/JaxbProtocolContext.java @@ -38,28 +38,27 @@ import org.apache.nifi.cluster.protocol.ProtocolMessageUnmarshaller; /** * Implements a context for communicating internally amongst the cluster using * JAXB. - * + * * @param The type of protocol message. * - * @author unattributed */ public class JaxbProtocolContext implements ProtocolContext { private static final int BUF_SIZE = (int) Math.pow(2, 10); // 1k - + /* * A sentinel is used to detect corrupted messages. Relying on the integrity - * of the message size can cause memory issues if the value is corrupted + * of the message size can cause memory issues if the value is corrupted * and equal to a number larger than the memory size. */ private static final byte MESSAGE_PROTOCOL_START_SENTINEL = 0x5A; - + private final JAXBContext jaxbCtx; - + public JaxbProtocolContext(final JAXBContext jaxbCtx) { this.jaxbCtx = jaxbCtx; } - + @Override public ProtocolMessageMarshaller createMarshaller() { return new ProtocolMessageMarshaller() { @@ -78,7 +77,7 @@ public class JaxbProtocolContext implements ProtocolContext { // write message protocol sentinel dos.write(MESSAGE_PROTOCOL_START_SENTINEL); - + // write message size in bytes dos.writeInt(msgBytes.size()); @@ -108,14 +107,14 @@ public class JaxbProtocolContext implements ProtocolContext { // check for the presence of the message protocol sentinel final byte sentinel = (byte) dis.read(); - if ( sentinel == -1 ) { + if (sentinel == -1) { throw new EOFException(); } - if(MESSAGE_PROTOCOL_START_SENTINEL != sentinel) { + if (MESSAGE_PROTOCOL_START_SENTINEL != sentinel) { throw new IOException("Failed reading protocol message due to malformed header"); } - + // read the message size final int msgBytesSize = dis.readInt(); diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionRequest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionRequest.java index d9de24f0b9..85f4a3f730 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionRequest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionRequest.java @@ -20,13 +20,13 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.apache.nifi.cluster.protocol.NodeIdentifier; /** - * @author unattributed */ public class AdaptedConnectionRequest { - + private NodeIdentifier nodeIdentifier; - - public AdaptedConnectionRequest() {} + + public AdaptedConnectionRequest() { + } @XmlJavaTypeAdapter(NodeIdentifierAdapter.class) public NodeIdentifier getNodeIdentifier() { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionResponse.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionResponse.java index c7c783bdc2..60467027db 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionResponse.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionResponse.java @@ -22,10 +22,9 @@ import org.apache.nifi.cluster.protocol.NodeIdentifier; import org.apache.nifi.cluster.protocol.StandardDataFlow; /** - * @author unattributed */ public class AdaptedConnectionResponse { - + private StandardDataFlow dataFlow; private NodeIdentifier nodeIdentifier; private boolean blockedByFirewall; @@ -34,8 +33,9 @@ public class AdaptedConnectionResponse { private Integer managerRemoteInputPort; private Boolean managerRemoteCommsSecure; private String instanceId; - - public AdaptedConnectionResponse() {} + + public AdaptedConnectionResponse() { + } @XmlJavaTypeAdapter(DataFlowAdapter.class) public StandardDataFlow getDataFlow() { @@ -82,27 +82,27 @@ public class AdaptedConnectionResponse { public boolean shouldTryLater() { return tryLaterSeconds > 0; } - + public void setManagerRemoteInputPort(Integer managerRemoteInputPort) { this.managerRemoteInputPort = managerRemoteInputPort; } - + public Integer getManagerRemoteInputPort() { return managerRemoteInputPort; } - + public void setManagerRemoteCommsSecure(Boolean secure) { this.managerRemoteCommsSecure = secure; } - + public Boolean isManagerRemoteCommsSecure() { return managerRemoteCommsSecure; } - + public void setInstanceId(String instanceId) { this.instanceId = instanceId; } - + public String getInstanceId() { return instanceId; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedCounter.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedCounter.java index 89d903bd6a..311a4707e5 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedCounter.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedCounter.java @@ -17,17 +17,17 @@ package org.apache.nifi.cluster.protocol.jaxb.message; /** - * @author unattributed */ public class AdaptedCounter { - + private String groupName; - + private String name; - + private long value; - public AdaptedCounter() {} + public AdaptedCounter() { + } public String getGroupName() { return groupName; @@ -52,5 +52,5 @@ public class AdaptedCounter { public void setValue(long value) { this.value = value; } - + } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedDataFlow.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedDataFlow.java index bb976195c5..683fdf5cc3 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedDataFlow.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedDataFlow.java @@ -17,17 +17,17 @@ package org.apache.nifi.cluster.protocol.jaxb.message; /** - * @author unattributed */ public class AdaptedDataFlow { - + private byte[] flow; private byte[] templates; private byte[] snippets; - + private boolean autoStartProcessors; - - public AdaptedDataFlow() {} + + public AdaptedDataFlow() { + } public byte[] getFlow() { return flow; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedHeartbeat.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedHeartbeat.java index 5b9d9b7619..cec37574f7 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedHeartbeat.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedHeartbeat.java @@ -20,16 +20,16 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.apache.nifi.cluster.protocol.NodeIdentifier; /** - * @author unattributed */ public class AdaptedHeartbeat { - + private NodeIdentifier nodeIdentifier; private byte[] payload; private boolean primary; private boolean connected; - - public AdaptedHeartbeat() {} + + public AdaptedHeartbeat() { + } @XmlJavaTypeAdapter(NodeIdentifierAdapter.class) public NodeIdentifier getNodeIdentifier() { @@ -39,7 +39,7 @@ public class AdaptedHeartbeat { public void setNodeIdentifier(NodeIdentifier nodeIdentifier) { this.nodeIdentifier = nodeIdentifier; } - + public boolean isPrimary() { return primary; } @@ -51,11 +51,11 @@ public class AdaptedHeartbeat { public boolean isConnected() { return connected; } - + public void setConnected(boolean connected) { this.connected = connected; } - + public byte[] getPayload() { return payload; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeBulletins.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeBulletins.java index 98e2438a97..5df8ec718a 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeBulletins.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeBulletins.java @@ -20,15 +20,15 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.apache.nifi.cluster.protocol.NodeIdentifier; /** - * @author unattributed */ public class AdaptedNodeBulletins { - + private NodeIdentifier nodeIdentifier; - + private byte[] payload; - - public AdaptedNodeBulletins() {} + + public AdaptedNodeBulletins() { + } @XmlJavaTypeAdapter(NodeIdentifierAdapter.class) public NodeIdentifier getNodeIdentifier() { @@ -38,7 +38,7 @@ public class AdaptedNodeBulletins { public void setNodeIdentifier(NodeIdentifier nodeIdentifier) { this.nodeIdentifier = nodeIdentifier; } - + public byte[] getPayload() { return payload; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeIdentifier.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeIdentifier.java index 8134ea302a..3bbf7b6fe8 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeIdentifier.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeIdentifier.java @@ -17,21 +17,21 @@ package org.apache.nifi.cluster.protocol.jaxb.message; /** - * @author unattributed */ public class AdaptedNodeIdentifier { - + private String id; - + private String apiAddress; - private int apiPort; + private int apiPort; private String socketAddress; - + private int socketPort; - - public AdaptedNodeIdentifier() {} + + public AdaptedNodeIdentifier() { + } public String getApiAddress() { return apiAddress; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ConnectionRequestAdapter.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ConnectionRequestAdapter.java index 1f91cf1461..21f9770db7 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ConnectionRequestAdapter.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ConnectionRequestAdapter.java @@ -20,14 +20,13 @@ import javax.xml.bind.annotation.adapters.XmlAdapter; import org.apache.nifi.cluster.protocol.ConnectionRequest; /** - * @author unattributed */ public class ConnectionRequestAdapter extends XmlAdapter { @Override public AdaptedConnectionRequest marshal(final ConnectionRequest cr) { final AdaptedConnectionRequest aCr = new AdaptedConnectionRequest(); - if(cr != null) { + if (cr != null) { aCr.setNodeIdentifier(cr.getProposedNodeIdentifier()); } return aCr; @@ -37,5 +36,5 @@ public class ConnectionRequestAdapter extends XmlAdapter { @Override public AdaptedConnectionResponse marshal(final ConnectionResponse cr) { final AdaptedConnectionResponse aCr = new AdaptedConnectionResponse(); - if(cr != null) { + if (cr != null) { aCr.setDataFlow(cr.getDataFlow()); aCr.setNodeIdentifier(cr.getNodeIdentifier()); aCr.setTryLaterSeconds(cr.getTryLaterSeconds()); @@ -42,14 +41,14 @@ public class ConnectionResponseAdapter extends XmlAdapter { @Override public AdaptedDataFlow marshal(final StandardDataFlow df) { - + final AdaptedDataFlow aDf = new AdaptedDataFlow(); - - if(df != null) { + + if (df != null) { aDf.setFlow(df.getFlow()); aDf.setTemplates(df.getTemplates()); aDf.setSnippets(df.getSnippets()); aDf.setAutoStartProcessors(df.isAutoStartProcessors()); } - + return aDf; } @@ -46,5 +45,5 @@ public class DataFlowAdapter extends XmlAdapter { @Override public AdaptedHeartbeat marshal(final Heartbeat hb) { - + final AdaptedHeartbeat aHb = new AdaptedHeartbeat(); - - if(hb != null) { + + if (hb != null) { // set node identifier aHb.setNodeIdentifier(hb.getNodeIdentifier()); // set payload aHb.setPayload(hb.getPayload()); - + // set leader flag aHb.setPrimary(hb.isPrimary()); - + // set connected flag aHb.setConnected(hb.isConnected()); } - + return aHb; } @@ -50,5 +49,5 @@ public class HeartbeatAdapter extends XmlAdapter { public Heartbeat unmarshal(final AdaptedHeartbeat aHb) { return new Heartbeat(aHb.getNodeIdentifier(), aHb.isPrimary(), aHb.isConnected(), aHb.getPayload()); } - + } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/JaxbProtocolUtils.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/JaxbProtocolUtils.java index c3a57f54bc..cbb6747e2a 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/JaxbProtocolUtils.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/JaxbProtocolUtils.java @@ -20,14 +20,13 @@ import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; /** - * @author unattributed */ public final class JaxbProtocolUtils { - + public static final String JAXB_CONTEXT_PATH = ObjectFactory.class.getPackage().getName(); public static final JAXBContext JAXB_CONTEXT = initializeJaxbContext(); - + /** * Load the JAXBContext version. */ @@ -38,5 +37,5 @@ public final class JaxbProtocolUtils { throw new RuntimeException("Unable to create JAXBContext.", e); } } - + } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/NodeBulletinsAdapter.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/NodeBulletinsAdapter.java index 1ae41f78a4..ab3126ccfd 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/NodeBulletinsAdapter.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/NodeBulletinsAdapter.java @@ -20,23 +20,22 @@ import javax.xml.bind.annotation.adapters.XmlAdapter; import org.apache.nifi.cluster.protocol.NodeBulletins; /** - * @author unattributed */ public class NodeBulletinsAdapter extends XmlAdapter { @Override public AdaptedNodeBulletins marshal(final NodeBulletins hb) { - + final AdaptedNodeBulletins adaptedBulletins = new AdaptedNodeBulletins(); - - if(hb != null) { + + if (hb != null) { // set node identifier adaptedBulletins.setNodeIdentifier(hb.getNodeIdentifier()); // set payload adaptedBulletins.setPayload(hb.getPayload()); } - + return adaptedBulletins; } @@ -44,5 +43,5 @@ public class NodeBulletinsAdapter extends XmlAdapter { @Override public AdaptedNodeIdentifier marshal(final NodeIdentifier ni) { - if(ni == null) { + if (ni == null) { return null; } else { final AdaptedNodeIdentifier aNi = new AdaptedNodeIdentifier(); @@ -41,11 +40,11 @@ public class NodeIdentifierAdapter extends XmlAdapternull otherwise. - * - * @return + * @return the DN of the NCM, if it is available or null + * otherwise */ public String getClusterManagerDN() { return clusterManagerDN; @@ -62,5 +59,5 @@ public class ConnectionResponseMessage extends ProtocolMessage { public MessageType getType() { return MessageType.CONNECTION_RESPONSE; } - + } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ControllerStartupFailureMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ControllerStartupFailureMessage.java index ebc1caec0b..3d3bd431c2 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ControllerStartupFailureMessage.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ControllerStartupFailureMessage.java @@ -23,15 +23,15 @@ import org.apache.nifi.cluster.protocol.NodeIdentifier; import org.apache.nifi.cluster.protocol.jaxb.message.NodeIdentifierAdapter; /** - * @author unattributed */ @XmlRootElement(name = "controllerStartupFailureMessage") public class ControllerStartupFailureMessage extends ExceptionMessage { private NodeIdentifier nodeId; - - public ControllerStartupFailureMessage() {} - + + public ControllerStartupFailureMessage() { + } + @Override public MessageType getType() { return MessageType.CONTROLLER_STARTUP_FAILURE; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/DisconnectMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/DisconnectMessage.java index 8aa7a4008b..6da5241b93 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/DisconnectMessage.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/DisconnectMessage.java @@ -22,14 +22,13 @@ import org.apache.nifi.cluster.protocol.NodeIdentifier; import org.apache.nifi.cluster.protocol.jaxb.message.NodeIdentifierAdapter; /** - * @author unattributed */ @XmlRootElement(name = "disconnectionMessage") public class DisconnectMessage extends ProtocolMessage { - + private NodeIdentifier nodeId; private String explanation; - + @XmlJavaTypeAdapter(NodeIdentifierAdapter.class) public NodeIdentifier getNodeId() { return nodeId; @@ -46,10 +45,10 @@ public class DisconnectMessage extends ProtocolMessage { public void setExplanation(String explanation) { this.explanation = explanation; } - + @Override public MessageType getType() { return MessageType.DISCONNECTION_REQUEST; } - + } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ExceptionMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ExceptionMessage.java index 99a6deea9f..65fab0f980 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ExceptionMessage.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ExceptionMessage.java @@ -19,14 +19,14 @@ package org.apache.nifi.cluster.protocol.message; import javax.xml.bind.annotation.XmlRootElement; /** - * @author unattributed */ @XmlRootElement(name = "exceptionMessage") public class ExceptionMessage extends ProtocolMessage { - + private String exceptionMessage; - public ExceptionMessage() {} + public ExceptionMessage() { + } public String getExceptionMessage() { return exceptionMessage; @@ -35,10 +35,10 @@ public class ExceptionMessage extends ProtocolMessage { public void setExceptionMessage(String exceptionMessage) { this.exceptionMessage = exceptionMessage; } - + @Override public MessageType getType() { return MessageType.EXCEPTION; } - + } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowRequestMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowRequestMessage.java index 4a10538bb1..594f6f63e3 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowRequestMessage.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowRequestMessage.java @@ -22,11 +22,10 @@ import org.apache.nifi.cluster.protocol.NodeIdentifier; import org.apache.nifi.cluster.protocol.jaxb.message.NodeIdentifierAdapter; /** - * @author unattributed */ @XmlRootElement(name = "flowRequestMessage") public class FlowRequestMessage extends ProtocolMessage { - + private NodeIdentifier nodeId; @XmlJavaTypeAdapter(NodeIdentifierAdapter.class) @@ -37,10 +36,10 @@ public class FlowRequestMessage extends ProtocolMessage { public void setNodeId(NodeIdentifier nodeId) { this.nodeId = nodeId; } - + @Override public MessageType getType() { return MessageType.FLOW_REQUEST; } - + } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowResponseMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowResponseMessage.java index 0d34dae7ca..3b1610cb0d 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowResponseMessage.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowResponseMessage.java @@ -21,13 +21,12 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.nifi.cluster.protocol.StandardDataFlow; /** - * @author unattributed */ @XmlRootElement(name = "flowResponseMessage") public class FlowResponseMessage extends ProtocolMessage { - + private StandardDataFlow dataFlow; - + @Override public MessageType getType() { return MessageType.FLOW_RESPONSE; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/HeartbeatMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/HeartbeatMessage.java index 0064cb699c..15432b125c 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/HeartbeatMessage.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/HeartbeatMessage.java @@ -20,13 +20,12 @@ import org.apache.nifi.cluster.protocol.Heartbeat; import javax.xml.bind.annotation.XmlRootElement; /** - * @author unattributed */ @XmlRootElement(name = "heartbeatMessage") public class HeartbeatMessage extends ProtocolMessage { - + private Heartbeat heartbeat; - + @Override public MessageType getType() { return MessageType.HEARTBEAT; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/MulticastProtocolMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/MulticastProtocolMessage.java index c6d2d44ed4..e4fa9cb74e 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/MulticastProtocolMessage.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/MulticastProtocolMessage.java @@ -20,28 +20,28 @@ import javax.xml.bind.annotation.XmlRootElement; /** * Wraps a protocol message and an identifier for sending the message by way - * multicast. The identifier is necessary for the sender to identify a message + * multicast. The identifier is necessary for the sender to identify a message * sent by it. - * - * @author unattributed + * */ @XmlRootElement(name = "multicastMessage") public class MulticastProtocolMessage extends ProtocolMessage { - + private ProtocolMessage protocolMessage; - + private String id; - - public MulticastProtocolMessage() {} + + public MulticastProtocolMessage() { + } public MulticastProtocolMessage(final String id, final ProtocolMessage protocolMessage) { this.protocolMessage = protocolMessage; this.id = id; } - + @Override public MessageType getType() { - if(protocolMessage == null) { + if (protocolMessage == null) { return null; } return protocolMessage.getType(); diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/NodeBulletinsMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/NodeBulletinsMessage.java index 9237a924fa..6df3ba4190 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/NodeBulletinsMessage.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/NodeBulletinsMessage.java @@ -20,13 +20,12 @@ import org.apache.nifi.cluster.protocol.NodeBulletins; import javax.xml.bind.annotation.XmlRootElement; /** - * @author unattributed */ @XmlRootElement(name = "nodeBulletinsMessage") public class NodeBulletinsMessage extends ProtocolMessage { - + private NodeBulletins bulletins; - + @Override public MessageType getType() { return MessageType.BULLETINS; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PingMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PingMessage.java index ee38deba70..b6ada4d630 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PingMessage.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PingMessage.java @@ -20,17 +20,17 @@ import java.util.Date; import javax.xml.bind.annotation.XmlRootElement; /** - * @author unattributed */ @XmlRootElement(name = "pingMessage") public class PingMessage extends ProtocolMessage { - + private String id; - + private Date date = new Date(); - public PingMessage() {} - + public PingMessage() { + } + public Date getDate() { return date; } @@ -46,10 +46,10 @@ public class PingMessage extends ProtocolMessage { public void setId(String id) { this.id = id; } - + @Override public MessageType getType() { return MessageType.PING; } - + } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PrimaryRoleAssignmentMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PrimaryRoleAssignmentMessage.java index a289abc977..4b7563a0b5 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PrimaryRoleAssignmentMessage.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PrimaryRoleAssignmentMessage.java @@ -22,7 +22,6 @@ import org.apache.nifi.cluster.protocol.NodeIdentifier; import org.apache.nifi.cluster.protocol.jaxb.message.NodeIdentifierAdapter; /** - * @author unattributed */ @XmlRootElement(name = "primaryRoleAssignmentMessage") public class PrimaryRoleAssignmentMessage extends ProtocolMessage { @@ -30,7 +29,7 @@ public class PrimaryRoleAssignmentMessage extends ProtocolMessage { private NodeIdentifier nodeId; private boolean primary; - + @XmlJavaTypeAdapter(NodeIdentifierAdapter.class) public NodeIdentifier getNodeId() { return nodeId; @@ -47,7 +46,7 @@ public class PrimaryRoleAssignmentMessage extends ProtocolMessage { public void setPrimary(boolean primary) { this.primary = primary; } - + @Override public MessageType getType() { return MessageType.PRIMARY_ROLE; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ProtocolMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ProtocolMessage.java index 6bf2a13237..c6f7ce02e3 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ProtocolMessage.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ProtocolMessage.java @@ -16,13 +16,12 @@ */ package org.apache.nifi.cluster.protocol.message; -/** - * @author unattributed - */ public abstract class ProtocolMessage { + private volatile String requestorDN; - + public static enum MessageType { + BULLETINS, CONNECTION_REQUEST, CONNECTION_RESPONSE, @@ -39,23 +38,24 @@ public abstract class ProtocolMessage { RECONNECTION_RESPONSE, SERVICE_BROADCAST, } - + public abstract MessageType getType(); - + /** * Sets the DN of the entity making the request - * @param dn + * + * @param dn dn of the entity making the request */ public void setRequestorDN(final String dn) { this.requestorDN = dn; } - + /** - * Returns the DN of the entity that made the request, if using a secure socket. Otherwise, returns null - * @return + * @return the DN of the entity that made the request, if using a secure + * socket. Otherwise, returns null */ public String getRequestorDN() { return requestorDN; } - + } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionFailureMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionFailureMessage.java index ba45e281b9..ce62c5ba47 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionFailureMessage.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionFailureMessage.java @@ -24,10 +24,12 @@ import org.apache.nifi.cluster.protocol.jaxb.message.NodeIdentifierAdapter; @XmlRootElement(name = "reconnectionFailureMessage") public class ReconnectionFailureMessage extends ExceptionMessage { + private NodeIdentifier nodeId; - - public ReconnectionFailureMessage() {} - + + public ReconnectionFailureMessage() { + } + @Override public MessageType getType() { return MessageType.RECONNECTION_FAILURE; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionRequestMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionRequestMessage.java index eab3d5d588..bd00346392 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionRequestMessage.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionRequestMessage.java @@ -24,7 +24,6 @@ import org.apache.nifi.cluster.protocol.StandardDataFlow; import org.apache.nifi.cluster.protocol.jaxb.message.NodeIdentifierAdapter; /** - * @author unattributed */ @XmlRootElement(name = "reconnectionRequestMessage") public class ReconnectionRequestMessage extends ProtocolMessage { @@ -35,8 +34,9 @@ public class ReconnectionRequestMessage extends ProtocolMessage { private Integer managerRemoteSiteListeningPort; private Boolean managerRemoteSiteCommsSecure; private String instanceId; - - public ReconnectionRequestMessage() {} + + public ReconnectionRequestMessage() { + } @XmlJavaTypeAdapter(NodeIdentifierAdapter.class) public NodeIdentifier getNodeId() { @@ -62,32 +62,32 @@ public class ReconnectionRequestMessage extends ProtocolMessage { public void setPrimary(boolean primary) { this.primary = primary; } - + @Override public MessageType getType() { return MessageType.RECONNECTION_REQUEST; } - + public void setManagerRemoteSiteListeningPort(final Integer listeningPort) { this.managerRemoteSiteListeningPort = listeningPort; } - + public Integer getManagerRemoteSiteListeningPort() { return managerRemoteSiteListeningPort; } - + public void setManagerRemoteSiteCommsSecure(final Boolean remoteSiteCommsSecure) { this.managerRemoteSiteCommsSecure = remoteSiteCommsSecure; } - + public Boolean isManagerRemoteSiteCommsSecure() { return managerRemoteSiteCommsSecure; } - + public void setInstanceId(final String instanceId) { this.instanceId = instanceId; } - + public String getInstanceId() { return instanceId; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionResponseMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionResponseMessage.java index fd0f921d6e..10ed7f60e1 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionResponseMessage.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionResponseMessage.java @@ -29,4 +29,4 @@ public class ReconnectionResponseMessage extends ProtocolMessage { return MessageType.RECONNECTION_RESPONSE; } -} \ No newline at end of file +} diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ServiceBroadcastMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ServiceBroadcastMessage.java index 92708ba68f..d0b546c955 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ServiceBroadcastMessage.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ServiceBroadcastMessage.java @@ -19,18 +19,18 @@ package org.apache.nifi.cluster.protocol.message; import javax.xml.bind.annotation.XmlRootElement; /** - * @author unattributed */ @XmlRootElement(name = "serviceBroadcastMessage") public class ServiceBroadcastMessage extends ProtocolMessage { private String serviceName; - + private String address; - + private int port; - - public ServiceBroadcastMessage() {} + + public ServiceBroadcastMessage() { + } public String getServiceName() { return serviceName; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/MulticastConfigurationFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/MulticastConfigurationFactoryBean.java index fa201bbc2f..460d3bcfc4 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/MulticastConfigurationFactoryBean.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/MulticastConfigurationFactoryBean.java @@ -24,18 +24,18 @@ import org.apache.nifi.util.NiFiProperties; import org.springframework.beans.factory.FactoryBean; /** - * Factory bean for creating a singleton MulticastConfiguration instance. + * Factory bean for creating a singleton MulticastConfiguration instance. */ public class MulticastConfigurationFactoryBean implements FactoryBean { - + private MulticastConfiguration configuration; private NiFiProperties properties; - + @Override public Object getObject() throws Exception { - if(configuration == null) { + if (configuration == null) { configuration = new MulticastConfiguration(); - + final int timeout = (int) FormatUtils.getTimeDuration(properties.getClusterProtocolSocketTimeout(), TimeUnit.MILLISECONDS); configuration.setSocketTimeout(timeout); configuration.setReuseAddress(true); @@ -53,7 +53,7 @@ public class MulticastConfigurationFactoryBean implements FactoryBean { public boolean isSingleton() { return true; } - + public void setProperties(NiFiProperties properties) { this.properties = properties; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/ServerSocketConfigurationFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/ServerSocketConfigurationFactoryBean.java index 5b5816d6cc..c41aeff599 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/ServerSocketConfigurationFactoryBean.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/ServerSocketConfigurationFactoryBean.java @@ -26,22 +26,23 @@ import org.apache.nifi.util.NiFiProperties; import org.springframework.beans.factory.FactoryBean; /** - * Factory bean for creating a singleton ServerSocketConfiguration instance. + * Factory bean for creating a singleton ServerSocketConfiguration instance. */ public class ServerSocketConfigurationFactoryBean implements FactoryBean { + private ServerSocketConfiguration configuration; private NiFiProperties properties; - + @Override public ServerSocketConfiguration getObject() throws Exception { - if(configuration == null) { + if (configuration == null) { configuration = new ServerSocketConfiguration(); configuration.setNeedClientAuth(properties.getNeedClientAuth()); - + final int timeout = (int) FormatUtils.getTimeDuration(properties.getClusterProtocolSocketTimeout(), TimeUnit.MILLISECONDS); configuration.setSocketTimeout(timeout); configuration.setReuseAddress(true); - if(Boolean.valueOf(properties.getProperty(NiFiProperties.CLUSTER_PROTOCOL_IS_SECURE))) { + if (Boolean.valueOf(properties.getProperty(NiFiProperties.CLUSTER_PROTOCOL_IS_SECURE))) { configuration.setSSLContextFactory(new SSLContextFactory(properties)); } } @@ -58,7 +59,7 @@ public class ServerSocketConfigurationFactoryBean implements FactoryBean { - + private SocketConfiguration configuration; - + private NiFiProperties properties; - + @Override public SocketConfiguration getObject() throws Exception { - if(configuration == null) { + if (configuration == null) { configuration = new SocketConfiguration(); - + final int timeout = (int) FormatUtils.getTimeDuration(properties.getClusterProtocolSocketTimeout(), TimeUnit.MILLISECONDS); configuration.setSocketTimeout(timeout); configuration.setReuseAddress(true); - if(Boolean.valueOf(properties.getProperty(NiFiProperties.CLUSTER_PROTOCOL_IS_SECURE))) { + if (Boolean.valueOf(properties.getProperty(NiFiProperties.CLUSTER_PROTOCOL_IS_SECURE))) { configuration.setSSLContextFactory(new SSLContextFactory(properties)); } } @@ -59,7 +59,7 @@ public class SocketConfigurationFactoryBean implements FactoryBean() { @Override @@ -124,11 +122,12 @@ public class ClusterManagerProtocolSenderImplTest { } }); FlowRequestMessage request = new FlowRequestMessage(); - request.setNodeId(new NodeIdentifier("id", "api-address", 1, address.getHostAddress(), port)); + request.setNodeId(new NodeIdentifier("id", "api-address", 1, "localhost", port)); try { sender.requestFlow(request); fail("failed to throw exception"); - } catch(ProtocolException pe) {} + } catch (ProtocolException pe) { + } } - + } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscoveryTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscoveryTest.java index e3703e2316..90817b2b85 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscoveryTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscoveryTest.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.cluster.protocol.impl; -import org.apache.nifi.cluster.protocol.impl.ClusterServiceDiscovery; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.net.DatagramPacket; @@ -32,69 +31,69 @@ import org.apache.nifi.cluster.protocol.message.ServiceBroadcastMessage; import org.apache.nifi.io.socket.multicast.MulticastConfiguration; import org.apache.nifi.io.socket.multicast.MulticastUtils; import org.junit.After; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; /** - * @author unattributed */ public class ClusterServiceDiscoveryTest { - + private ClusterServiceDiscovery discovery; - + private String serviceName; - + private MulticastSocket socket; - + private InetSocketAddress multicastAddress; - + private MulticastConfiguration configuration; - + private ProtocolContext protocolContext; - + @Before public void setup() throws Exception { serviceName = "some-service"; multicastAddress = new InetSocketAddress("225.1.1.1", 22222); configuration = new MulticastConfiguration(); - + protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT); - + discovery = new ClusterServiceDiscovery(serviceName, multicastAddress, configuration, protocolContext); discovery.start(); socket = MulticastUtils.createMulticastSocket(multicastAddress.getPort(), configuration); } - + @After public void teardown() throws IOException { try { - if(discovery.isRunning()) { + if (discovery.isRunning()) { discovery.stop(); } } finally { MulticastUtils.closeQuietly(socket); } } - + @Ignore("Test needs to be fixed. Requires an active network connection") @Test public void testGetAddressOnStartup() { assertNull(discovery.getService()); - } - + } + @Ignore("This test has an NPE after ignoring another...perhaps has a bad inter-test dependency") @Test public void testGetAddressAfterBroadcast() throws Exception { - + ServiceBroadcastMessage msg = new ServiceBroadcastMessage(); msg.setServiceName("some-service"); msg.setAddress("3.3.3.3"); msg.setPort(1234); - + // marshal message to output stream ProtocolMessageMarshaller marshaller = protocolContext.createMarshaller(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -102,22 +101,22 @@ public class ClusterServiceDiscoveryTest { byte[] requestPacketBytes = baos.toByteArray(); DatagramPacket packet = new DatagramPacket(requestPacketBytes, requestPacketBytes.length, multicastAddress); socket.send(packet); - + Thread.sleep(250); - + InetSocketAddress updatedAddress = discovery.getService().getServiceAddress(); assertEquals("some-service", discovery.getServiceName()); assertEquals("3.3.3.3", updatedAddress.getHostName()); assertEquals(1234, updatedAddress.getPort()); - + } - + @Ignore("Test needs to be fixed. Requires an active network connection") @Test public void testBadBroadcastMessage() throws Exception { - + ProtocolMessage msg = new PingMessage(); - + // marshal message to output stream ProtocolMessageMarshaller marshaller = protocolContext.createMarshaller(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -125,11 +124,11 @@ public class ClusterServiceDiscoveryTest { byte[] requestPacketBytes = baos.toByteArray(); DatagramPacket packet = new DatagramPacket(requestPacketBytes, requestPacketBytes.length, multicastAddress); socket.send(packet); - + Thread.sleep(250); - + assertNull(discovery.getService()); - + } - + } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocatorTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocatorTest.java index b1c156b506..ea4015044d 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocatorTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocatorTest.java @@ -16,104 +16,104 @@ */ package org.apache.nifi.cluster.protocol.impl; -import org.apache.nifi.cluster.protocol.impl.ClusterServiceLocator; -import org.apache.nifi.cluster.protocol.impl.ClusterServiceDiscovery; import java.net.InetSocketAddress; import java.util.concurrent.TimeUnit; import org.apache.nifi.io.socket.multicast.DiscoverableService; import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import org.junit.Before; import org.junit.Test; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; import org.mockito.stubbing.OngoingStubbing; public class ClusterServiceLocatorTest { - + private ClusterServiceDiscovery mockServiceDiscovery; - + private int fixedPort; - + private DiscoverableService fixedService; - + private ClusterServiceLocator serviceDiscoveryLocator; - + private ClusterServiceLocator serviceDiscoveryFixedPortLocator; - + private ClusterServiceLocator fixedServiceLocator; - + @Before public void setup() throws Exception { - + fixedPort = 1; mockServiceDiscovery = mock(ClusterServiceDiscovery.class); fixedService = new DiscoverableServiceImpl("some-service", InetSocketAddress.createUnresolved("some-host", 20)); - + serviceDiscoveryLocator = new ClusterServiceLocator(mockServiceDiscovery); serviceDiscoveryFixedPortLocator = new ClusterServiceLocator(mockServiceDiscovery, fixedPort); fixedServiceLocator = new ClusterServiceLocator(fixedService); - + } - + @Test public void getServiceWhenServiceDiscoveryNotStarted() { assertNull(serviceDiscoveryLocator.getService()); } - + @Test public void getServiceWhenServiceDiscoveryFixedPortNotStarted() { assertNull(serviceDiscoveryLocator.getService()); } - + @Test public void getServiceWhenFixedServiceNotStarted() { assertEquals(fixedService, fixedServiceLocator.getService()); } - + @Test public void getServiceNotOnFirstAttempt() { - + ClusterServiceLocator.AttemptsConfig config = new ClusterServiceLocator.AttemptsConfig(); config.setNumAttempts(2); config.setTimeBetweenAttempsUnit(TimeUnit.SECONDS); config.setTimeBetweenAttempts(1); - + serviceDiscoveryLocator.setAttemptsConfig(config); - + OngoingStubbing stubbing = null; - for(int i = 0; i < config.getNumAttempts() - 1; i++) { - if(stubbing == null) { + for (int i = 0; i < config.getNumAttempts() - 1; i++) { + if (stubbing == null) { stubbing = when(mockServiceDiscovery.getService()).thenReturn(null); } else { stubbing.thenReturn(null); } } stubbing.thenReturn(fixedService); - + assertEquals(fixedService, serviceDiscoveryLocator.getService()); - + } - + @Test public void getServiceNotOnFirstAttemptWithFixedPort() { - + ClusterServiceLocator.AttemptsConfig config = new ClusterServiceLocator.AttemptsConfig(); config.setNumAttempts(2); config.setTimeBetweenAttempsUnit(TimeUnit.SECONDS); config.setTimeBetweenAttempts(1); - + serviceDiscoveryFixedPortLocator.setAttemptsConfig(config); - + OngoingStubbing stubbing = null; - for(int i = 0; i < config.getNumAttempts() - 1; i++) { - if(stubbing == null) { + for (int i = 0; i < config.getNumAttempts() - 1; i++) { + if (stubbing == null) { stubbing = when(mockServiceDiscovery.getService()).thenReturn(null); } else { stubbing.thenReturn(null); } } stubbing.thenReturn(fixedService); - + InetSocketAddress resultAddress = InetSocketAddress.createUnresolved(fixedService.getServiceAddress().getHostName(), fixedPort); DiscoverableService resultService = new DiscoverableServiceImpl(fixedService.getServiceName(), resultAddress); assertEquals(resultService, serviceDiscoveryFixedPortLocator.getService()); diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcasterTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcasterTest.java index ec1f26d2be..24dd17dee5 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcasterTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcasterTest.java @@ -16,8 +16,6 @@ */ package org.apache.nifi.cluster.protocol.impl; -import org.apache.nifi.cluster.protocol.impl.ClusterServicesBroadcaster; -import org.apache.nifi.cluster.protocol.impl.MulticastProtocolListener; import java.net.InetSocketAddress; import org.apache.nifi.cluster.protocol.ProtocolContext; import org.apache.nifi.cluster.protocol.ProtocolException; @@ -30,77 +28,77 @@ import org.apache.nifi.io.socket.multicast.DiscoverableService; import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl; import org.apache.nifi.io.socket.multicast.MulticastConfiguration; import org.junit.After; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; /** - * @author unattributed */ public class ClusterServicesBroadcasterTest { - + private ClusterServicesBroadcaster broadcaster; - + private MulticastProtocolListener listener; - + private DummyProtocolHandler handler; - + private InetSocketAddress multicastAddress; - + private DiscoverableService broadcastedService; private ProtocolContext protocolContext; - + private MulticastConfiguration configuration; - + @Before public void setup() throws Exception { broadcastedService = new DiscoverableServiceImpl("some-service", new InetSocketAddress("localhost", 11111)); - + multicastAddress = new InetSocketAddress("225.1.1.1", 22222); - + configuration = new MulticastConfiguration(); - + protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT); - + broadcaster = new ClusterServicesBroadcaster(multicastAddress, configuration, protocolContext, "500 ms"); broadcaster.addService(broadcastedService); - + handler = new DummyProtocolHandler(); listener = new MulticastProtocolListener(5, multicastAddress, configuration, protocolContext); listener.addHandler(handler); } - + @After public void teardown() { - - if(broadcaster.isRunning()) { + + if (broadcaster.isRunning()) { broadcaster.stop(); } - + try { - if(listener.isRunning()) { + if (listener.isRunning()) { listener.stop(); } - } catch(Exception ex) { + } catch (Exception ex) { ex.printStackTrace(System.out); } - + } - + @Ignore("fails needs to be fixed") @Test public void testBroadcastReceived() throws Exception { - + broadcaster.start(); listener.start(); - + Thread.sleep(1000); - + listener.stop(); - + assertNotNull(handler.getProtocolMessage()); assertEquals(ProtocolMessage.MessageType.SERVICE_BROADCAST, handler.getProtocolMessage().getType()); final ServiceBroadcastMessage msg = (ServiceBroadcastMessage) handler.getProtocolMessage(); @@ -108,11 +106,11 @@ public class ClusterServicesBroadcasterTest { assertEquals(broadcastedService.getServiceAddress().getHostName(), msg.getAddress()); assertEquals(broadcastedService.getServiceAddress().getPort(), msg.getPort()); } - + private class DummyProtocolHandler implements ProtocolHandler { private ProtocolMessage protocolMessage; - + @Override public boolean canHandle(ProtocolMessage msg) { return true; @@ -123,11 +121,11 @@ public class ClusterServicesBroadcasterTest { this.protocolMessage = msg; return null; } - + public ProtocolMessage getProtocolMessage() { return protocolMessage; } - + } - + } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListenerTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListenerTest.java index 4233d88d70..690d416d28 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListenerTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListenerTest.java @@ -35,69 +35,66 @@ import org.apache.nifi.cluster.protocol.message.ProtocolMessage; import org.apache.nifi.io.socket.multicast.MulticastConfiguration; import org.apache.nifi.io.socket.multicast.MulticastUtils; import org.junit.After; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -/** - * @author unattributed - */ public class MulticastProtocolListenerTest { - + private MulticastProtocolListener listener; - + private MulticastSocket socket; - + private InetSocketAddress address; - + private MulticastConfiguration configuration; - + private ProtocolContext protocolContext; - + @Before public void setup() throws Exception { address = new InetSocketAddress("226.1.1.1", 60000); configuration = new MulticastConfiguration(); - + protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT); - + listener = new MulticastProtocolListener(5, address, configuration, protocolContext); listener.start(); socket = MulticastUtils.createMulticastSocket(address.getPort(), configuration); } - + @After public void teardown() throws IOException { try { - if(listener.isRunning()) { + if (listener.isRunning()) { listener.stop(); } } finally { MulticastUtils.closeQuietly(socket); } } - + @Ignore("Test needs to be reworked. Fails if on a system without actiev network connection") @Test public void testBadRequest() throws Exception { DelayedProtocolHandler handler = new DelayedProtocolHandler(0); listener.addHandler(handler); - DatagramPacket packet = new DatagramPacket(new byte[] {5}, 1, address); + DatagramPacket packet = new DatagramPacket(new byte[]{5}, 1, address); socket.send(packet); Thread.sleep(250); assertEquals(0, handler.getMessages().size()); } - + @Ignore("this test works sometimes and fails others - needs work to be reliable") @Test public void testRequest() throws Exception { ReflexiveProtocolHandler handler = new ReflexiveProtocolHandler(); listener.addHandler(handler); - + ProtocolMessage msg = new PingMessage(); MulticastProtocolMessage multicastMsg = new MulticastProtocolMessage("some-id", msg); @@ -112,13 +109,13 @@ public class MulticastProtocolListenerTest { Thread.sleep(250); assertEquals(1, handler.getMessages().size()); assertEquals(msg.getType(), handler.getMessages().get(0).getType()); - + } - + private class ReflexiveProtocolHandler implements ProtocolHandler { - + private List messages = new ArrayList<>(); - + @Override public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException { messages.add(msg); @@ -129,30 +126,30 @@ public class MulticastProtocolListenerTest { public boolean canHandle(ProtocolMessage msg) { return true; } - + public List getMessages() { return messages; } - + } private class DelayedProtocolHandler implements ProtocolHandler { - + private int delay = 0; - + private List messages = new ArrayList<>(); - + public DelayedProtocolHandler(int delay) { this.delay = delay; } - + @Override public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException { try { messages.add(msg); Thread.sleep(delay); return null; - } catch(final InterruptedException ie) { + } catch (final InterruptedException ie) { throw new ProtocolException(ie); } @@ -162,10 +159,10 @@ public class MulticastProtocolListenerTest { public boolean canHandle(ProtocolMessage msg) { return true; } - + public List getMessages() { return messages; } - + } } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImplTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImplTest.java index 1c5ba9e26a..19834ae3a0 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImplTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImplTest.java @@ -16,9 +16,6 @@ */ package org.apache.nifi.cluster.protocol.impl; -import org.apache.nifi.cluster.protocol.impl.ClusterServiceLocator; -import org.apache.nifi.cluster.protocol.impl.SocketProtocolListener; -import org.apache.nifi.cluster.protocol.impl.NodeProtocolSenderImpl; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; import static org.mockito.Matchers.any; @@ -58,104 +55,102 @@ import org.junit.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -/** - * @author unattributed - */ @Ignore("Randomly tests... probably timing-specific") public class NodeProtocolSenderImplTest { - + private SocketProtocolListener listener; - + private NodeProtocolSenderImpl sender; - + private DiscoverableService service; - + private ServerSocketConfiguration serverSocketConfiguration; - + private ClusterServiceLocator mockServiceLocator; - + private ProtocolHandler mockHandler; - + private NodeIdentifier nodeIdentifier; - + @Before public void setup() throws IOException { - + serverSocketConfiguration = new ServerSocketConfiguration(); mockServiceLocator = mock(ClusterServiceLocator.class); mockHandler = mock(ProtocolHandler.class); - + nodeIdentifier = new NodeIdentifier("1", "localhost", 1234, "localhost", 5678); - + ProtocolContext protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT); - + listener = new SocketProtocolListener(5, 0, serverSocketConfiguration, protocolContext); listener.setShutdownListenerSeconds(3); listener.addHandler(mockHandler); listener.start(); - + service = new DiscoverableServiceImpl("some-service", new InetSocketAddress("localhost", listener.getPort())); - + SocketConfiguration socketConfiguration = new SocketConfiguration(); socketConfiguration.setReuseAddress(true); sender = new NodeProtocolSenderImpl(mockServiceLocator, socketConfiguration, protocolContext); } - + @After public void teardown() throws IOException { - if(listener.isRunning()) { + if (listener.isRunning()) { listener.stop(); } } - + @Test public void testConnect() throws Exception { - + when(mockServiceLocator.getService()).thenReturn(service); when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE); ConnectionResponseMessage mockMessage = new ConnectionResponseMessage(); - mockMessage.setConnectionResponse(new ConnectionResponse(nodeIdentifier, new StandardDataFlow("flow".getBytes("UTF-8"), new byte[0], new byte[0]), false, null, null, UUID.randomUUID().toString())); + mockMessage.setConnectionResponse(new ConnectionResponse(nodeIdentifier, + new StandardDataFlow("flow".getBytes("UTF-8"), new byte[0], new byte[0]), false, null, null, UUID.randomUUID().toString())); when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(mockMessage); - + ConnectionRequestMessage request = new ConnectionRequestMessage(); request.setConnectionRequest(new ConnectionRequest(nodeIdentifier)); ConnectionResponseMessage response = sender.requestConnection(request); assertNotNull(response); } - + @Test(expected = UnknownServiceAddressException.class) public void testConnectNoClusterManagerAddress() throws Exception { - + when(mockServiceLocator.getService()).thenReturn(null); when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE); when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new ConnectionResponseMessage()); - + ConnectionRequestMessage request = new ConnectionRequestMessage(); request.setConnectionRequest(new ConnectionRequest(nodeIdentifier)); sender.requestConnection(request); fail("failed to throw exception"); } - + @Test(expected = ProtocolException.class) public void testConnectBadResponse() throws Exception { - + when(mockServiceLocator.getService()).thenReturn(service); when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE); when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new PingMessage()); - + ConnectionRequestMessage request = new ConnectionRequestMessage(); request.setConnectionRequest(new ConnectionRequest(nodeIdentifier)); - + sender.requestConnection(request); fail("failed to throw exception"); - + } - + @Test(expected = ProtocolException.class) public void testConnectDelayedResponse() throws Exception { - + final int time = 250; sender.getSocketConfiguration().setSocketTimeout(time); when(mockServiceLocator.getService()).thenReturn(service); @@ -172,28 +167,28 @@ public class NodeProtocolSenderImplTest { sender.requestConnection(request); fail("failed to throw exception"); - + } - + @Test public void testHeartbeat() throws Exception { - + when(mockServiceLocator.getService()).thenReturn(service); when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE); when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(null); - + HeartbeatMessage hb = new HeartbeatMessage(); - hb.setHeartbeat(new Heartbeat(new NodeIdentifier("id", "localhost", 3, "localhost", 4), false, false, new byte[] {1, 2, 3})); + hb.setHeartbeat(new Heartbeat(new NodeIdentifier("id", "localhost", 3, "localhost", 4), false, false, new byte[]{1, 2, 3})); sender.heartbeat(hb); } - + @Test public void testNotifyControllerStartupFailure() throws Exception { - + when(mockServiceLocator.getService()).thenReturn(service); when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE); when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(null); - + ControllerStartupFailureMessage msg = new ControllerStartupFailureMessage(); msg.setNodeId(new NodeIdentifier("some-id", "some-addr", 1, "some-addr", 1)); msg.setExceptionMessage("some exception"); diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListenerTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListenerTest.java similarity index 94% rename from nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListenerTest.java rename to nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListenerTest.java index 92a7d2a943..cac5bf2370 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListenerTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListenerTest.java @@ -27,18 +27,18 @@ import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext; import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils; import org.apache.nifi.cluster.protocol.message.PingMessage; import org.apache.nifi.cluster.protocol.message.ProtocolMessage; -import org.apache.nifi.cluster.protocol.testutils.DelayedProtocolHandler; -import org.apache.nifi.cluster.protocol.testutils.ReflexiveProtocolHandler; +import org.apache.nifi.cluster.protocol.impl.testutils.DelayedProtocolHandler; +import org.apache.nifi.cluster.protocol.impl.testutils.ReflexiveProtocolHandler; import org.apache.nifi.io.socket.ServerSocketConfiguration; import org.apache.nifi.io.socket.SocketConfiguration; import org.apache.nifi.io.socket.SocketUtils; import org.junit.After; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; import org.junit.Before; import org.junit.Test; /** - * @author unattributed */ public class SocketProtocolListenerTest { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/DelayedProtocolHandler.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/DelayedProtocolHandler.java index 07ee83ad75..d6d83ef7ef 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/DelayedProtocolHandler.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/DelayedProtocolHandler.java @@ -23,7 +23,6 @@ import org.apache.nifi.cluster.protocol.ProtocolHandler; import org.apache.nifi.cluster.protocol.message.ProtocolMessage; /** - * @author unattributed */ public class DelayedProtocolHandler implements ProtocolHandler { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/ReflexiveProtocolHandler.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/ReflexiveProtocolHandler.java index 4e3b9322ec..ccf2c4c837 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/ReflexiveProtocolHandler.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/ReflexiveProtocolHandler.java @@ -23,12 +23,11 @@ import org.apache.nifi.cluster.protocol.ProtocolHandler; import org.apache.nifi.cluster.protocol.message.ProtocolMessage; /** - * @author unattributed */ public class ReflexiveProtocolHandler implements ProtocolHandler { - + private List messages = new ArrayList<>(); - + @Override public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException { messages.add(msg); @@ -43,5 +42,5 @@ public class ReflexiveProtocolHandler implements ProtocolHandler { public List getMessages() { return messages; } - + } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContext.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContext.java index 44fb25ad97..8c3e41b15e 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContext.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContext.java @@ -22,38 +22,44 @@ import org.apache.nifi.action.Action; import org.apache.nifi.web.Revision; /** - * Contains contextual information about clustering that may be serialized + * Contains contextual information about clustering that may be serialized * between manager and node when communicating over HTTP. */ public interface ClusterContext extends Serializable { - + /** - * Returns a list of auditable actions. The list is modifiable - * and will never be null. + * Returns a list of auditable actions. The list is modifiable and will + * never be null. + * * @return a collection of actions */ List getActions(); - + Revision getRevision(); - + void setRevision(Revision revision); - + /** - * @return true if the request was sent by the cluster manager; false otherwise + * @return true if the request was sent by the cluster manager; false + * otherwise */ boolean isRequestSentByClusterManager(); - + /** * Sets the flag to indicate if a request was sent by the cluster manager. - * @param flag true if the request was sent by the cluster manager; false otherwise + * + * @param flag true if the request was sent by the cluster manager; false + * otherwise */ void setRequestSentByClusterManager(boolean flag); - + /** - * Gets an id generation seed. This is used to ensure that nodes are able to generate the - * same id across the cluster. This is usually handled by the cluster manager creating the - * id, however for some actions (snippets, templates, etc) this is not possible. - * @return + * Gets an id generation seed. This is used to ensure that nodes are able to + * generate the same id across the cluster. This is usually handled by the + * cluster manager creating the id, however for some actions (snippets, + * templates, etc) this is not possible. + * + * @return generated id seed */ String getIdGenerationSeed(); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextImpl.java index 06907d2427..43e7c2dbbe 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextImpl.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextImpl.java @@ -29,13 +29,13 @@ import org.apache.nifi.web.Revision; public class ClusterContextImpl implements ClusterContext, Serializable { private final List actions = new ArrayList<>(); - + private Revision revision; - + private boolean requestSentByClusterManager; - + private final String idGenerationSeed = UUID.randomUUID().toString(); - + @Override public List getActions() { return actions; @@ -55,7 +55,7 @@ public class ClusterContextImpl implements ClusterContext, Serializable { public boolean isRequestSentByClusterManager() { return requestSentByClusterManager; } - + @Override public void setRequestSentByClusterManager(boolean requestSentByClusterManager) { this.requestSentByClusterManager = requestSentByClusterManager; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextThreadLocal.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextThreadLocal.java index c8c7206947..79900fb051 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextThreadLocal.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextThreadLocal.java @@ -20,23 +20,23 @@ package org.apache.nifi.cluster.context; * Manages a cluster context on a threadlocal. */ public class ClusterContextThreadLocal { - + private static final ThreadLocal contextHolder = new ThreadLocal<>(); - + public static void removeContext() { contextHolder.remove(); } - + public static ClusterContext createEmptyContext() { return new ClusterContextImpl(); } - + public static ClusterContext getContext() { return contextHolder.get(); } - + public static void setContext(final ClusterContext context) { contextHolder.set(context); } - + } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/Event.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/Event.java index 6bc5d6cc35..510579f436 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/Event.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/Event.java @@ -20,10 +20,8 @@ import java.util.Date; import org.apache.commons.lang3.StringUtils; /** - * Events describe the occurrence of something noteworthy. They record the - * event's source, a timestamp, a description, and a category. + * Events describe the occurrence of something noteworthy. They record the event's source, a timestamp, a description, and a category. * - * @author unattributed * * @Immutable */ @@ -45,8 +43,7 @@ public class Event { private final String message; /** - * Creates an event with the current time as the timestamp and a category of - * "INFO". + * Creates an event with the current time as the timestamp and a category of "INFO". * * @param source the source * @param message the description diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/EventManager.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/EventManager.java index f9dfb00fe1..8411e5b8ef 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/EventManager.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/EventManager.java @@ -19,11 +19,9 @@ package org.apache.nifi.cluster.event; import java.util.List; /** - * Manages an ordered list of events. The event history size dictates the total - * number of events to manage for a given source at a given time. When the size - * is exceeded, the oldest event for that source is evicted. + * Manages an ordered list of events. The event history size dictates the total number of events to manage for a given source at a given time. When the size is exceeded, the oldest event for that + * source is evicted. * - * @author unattributed */ public interface EventManager { @@ -35,8 +33,7 @@ public interface EventManager { void addEvent(Event event); /** - * Returns a list of events for a given source sorted by the event's - * timestamp where the most recent event is first in the list. + * Returns a list of events for a given source sorted by the event's timestamp where the most recent event is first in the list. * * @param eventSource the source * diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/impl/EventManagerImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/impl/EventManagerImpl.java index 7fadc78ffa..c9cd6a5ee4 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/impl/EventManagerImpl.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/impl/EventManagerImpl.java @@ -31,13 +31,11 @@ import org.apache.nifi.cluster.event.EventManager; /** * Implements the EventManager. * - * @author unattributed */ public class EventManagerImpl implements EventManager { /** - * associates the source ID with an ordered queue of events, ordered by most - * recent event + * associates the source ID with an ordered queue of events, ordered by most recent event */ private final Map> eventsMap = new HashMap<>(); @@ -49,8 +47,7 @@ public class EventManagerImpl implements EventManager { /** * Creates an instance. * - * @param eventHistorySize the number of events to manage for a given - * source. Value must be positive. + * @param eventHistorySize the number of events to manage for a given source. Value must be positive. */ public EventManagerImpl(final int eventHistorySize) { if (eventHistorySize <= 0) { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/firewall/ClusterNodeFirewall.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/firewall/ClusterNodeFirewall.java index 2e3d2784d7..b6713d1b06 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/firewall/ClusterNodeFirewall.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/firewall/ClusterNodeFirewall.java @@ -17,18 +17,17 @@ package org.apache.nifi.cluster.firewall; /** - * Defines the interface for restricting external client connections to a set of - * hosts or IPs. + * Defines the interface for restricting external client connections to a set of hosts or IPs. */ public interface ClusterNodeFirewall { /** - * Returns true if the given host or IP is permissible through the firewall; - * false otherwise. + * Returns true if the given host or IP is permissible through the firewall; false otherwise. * * If an IP is given, then it must be formatted in dotted decimal notation. - * @param hostOrIp - * @return + * + * @param hostOrIp host + * @return true if permissible */ boolean isPermissible(String hostOrIp); diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewall.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewall.java index 916ec14655..8ba33c5332 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewall.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewall.java @@ -16,10 +16,14 @@ */ package org.apache.nifi.cluster.firewall.impl; -import java.io.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; import java.net.InetAddress; import java.net.UnknownHostException; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; import org.apache.commons.net.util.SubnetUtils; import org.apache.nifi.cluster.firewall.ClusterNodeFirewall; import org.apache.nifi.util.file.FileUtils; @@ -28,11 +32,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * A file-based implementation of the ClusterFirewall interface. The class is - * configured with a file. If the file is empty, then everything is permissible. - * Otherwise, the file should contain hostnames or IPs formatted as dotted - * decimals with an optional CIDR suffix. Each entry must be separated by a - * newline. An example configuration is given below: + * A file-based implementation of the ClusterFirewall interface. The class is configured with a file. If the file is empty, then everything is permissible. Otherwise, the file should contain hostnames + * or IPs formatted as dotted decimals with an optional CIDR suffix. Each entry must be separated by a newline. An example configuration is given below: * * * # hash character is a comment delimiter @@ -42,12 +43,9 @@ import org.slf4j.LoggerFactory; * 9.10.11.12/13 # a smaller range of CIDR IPs * * - * This class allows for synchronization with an optionally configured restore - * directory. If configured, then at startup, if the either the config file or - * the restore directory's copy is missing, then the configuration file will be - * copied to the appropriate location. If both restore directory contains a copy - * that is different in content to configuration file, then an exception is - * thrown at construction time. + * This class allows for synchronization with an optionally configured restore directory. If configured, then at startup, if the either the config file or the restore directory's copy is missing, then + * the configuration file will be copied to the appropriate location. If both restore directory contains a copy that is different in content to configuration file, then an exception is thrown at + * construction time. */ public class FileBasedClusterNodeFirewall implements ClusterNodeFirewall { @@ -103,7 +101,7 @@ public class FileBasedClusterNodeFirewall implements ClusterNodeFirewall { try { ip = InetAddress.getByName(hostOrIp).getHostAddress(); } catch (final UnknownHostException uhe) { - logger.warn("Blocking unknown host: " + hostOrIp, uhe); + logger.warn("Blocking unknown host '{}'", hostOrIp, uhe); return false; } @@ -115,9 +113,11 @@ public class FileBasedClusterNodeFirewall implements ClusterNodeFirewall { } // no match + logger.debug("Blocking host '{}' because it does not match our allowed list.", hostOrIp); return false; } catch (final IllegalArgumentException iae) { + logger.debug("Blocking requested host, '{}', because it is malformed.", hostOrIp, iae); return false; } } @@ -168,30 +168,30 @@ public class FileBasedClusterNodeFirewall implements ClusterNodeFirewall { if (ipOrHostLine.contains("/")) { ipCidr = ipOrHostLine; } else if (ipOrHostLine.contains("\\")) { - logger.warn("CIDR IP notation uses forward slashes '/'. Replacing backslash '\\' with forward slash'/' for '" + ipOrHostLine + "'"); + logger.warn("CIDR IP notation uses forward slashes '/'. Replacing backslash '\\' with forward slash'/' for '{}'", ipOrHostLine); ipCidr = ipOrHostLine.replace("\\", "/"); } else { try { ipCidr = InetAddress.getByName(ipOrHostLine).getHostAddress(); if (!ipOrHostLine.equals(ipCidr)) { - logger.debug(String.format("Resolved host '%s' to ip '%s'", ipOrHostLine, ipCidr)); + logger.debug("Resolved host '{}' to ip '{}'", ipOrHostLine, ipCidr); } ipCidr += "/32"; - logger.debug("Adding CIDR to exact IP: " + ipCidr); + logger.debug("Adding CIDR to exact IP: '{}'", ipCidr); } catch (final UnknownHostException uhe) { - logger.warn("Firewall is skipping unknown host address: " + ipOrHostLine); + logger.warn("Firewall is skipping unknown host address: '{}'", ipOrHostLine); continue; } } try { - logger.debug("Adding CIDR IP to firewall: " + ipCidr); + logger.debug("Adding CIDR IP to firewall: '{}'", ipCidr); final SubnetUtils subnetUtils = new SubnetUtils(ipCidr); subnetUtils.setInclusiveHostCount(true); subnetInfos.add(subnetUtils.getInfo()); totalIpsAdded++; } catch (final IllegalArgumentException iae) { - logger.warn("Firewall is skipping invalid CIDR address: " + ipOrHostLine); + logger.warn("Firewall is skipping invalid CIDR address: '{}'", ipOrHostLine); } } @@ -199,7 +199,7 @@ public class FileBasedClusterNodeFirewall implements ClusterNodeFirewall { if (totalIpsAdded == 0) { logger.info("No IPs added to firewall. Firewall will accept all requests."); } else { - logger.info(String.format("Added %d IP(s) to firewall. Only requests originating from the configured IPs will be accepted.", totalIpsAdded)); + logger.info("Added {} IP(s) to firewall. Only requests originating from the configured IPs will be accepted.", totalIpsAdded); } } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/ClusterDataFlow.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/ClusterDataFlow.java index c17b429518..a5e78bfdca 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/ClusterDataFlow.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/ClusterDataFlow.java @@ -22,7 +22,6 @@ import org.apache.nifi.cluster.protocol.StandardDataFlow; /** * A dataflow with additional information about the cluster. * - * @author unattributed */ public class ClusterDataFlow { @@ -39,13 +38,13 @@ public class ClusterDataFlow { } public byte[] getControllerServices() { - return controllerServices; + return controllerServices; } - + public byte[] getReportingTasks() { - return reportingTasks; + return reportingTasks; } - + public NodeIdentifier getPrimaryNodeId() { return primaryNodeId; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DaoException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DaoException.java index 6ff15a7c31..aed86c91ec 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DaoException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DaoException.java @@ -19,7 +19,6 @@ package org.apache.nifi.cluster.flow; /** * A base exception for data access exceptions. * - * @author unattributed */ public class DaoException extends RuntimeException { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowDao.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowDao.java index a2737045d2..861095f142 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowDao.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowDao.java @@ -19,7 +19,6 @@ package org.apache.nifi.cluster.flow; /** * A data access object for loading and saving the flow managed by the cluster. * - * @author unattributed */ public interface DataFlowDao { @@ -36,14 +35,13 @@ public interface DataFlowDao { * Saves the cluster's dataflow. * * - * @param dataFlow + * @param dataFlow flow * @throws DaoException if the dataflow was unable to be saved */ void saveDataFlow(ClusterDataFlow dataFlow) throws DaoException; /** - * Sets the state of the dataflow. If the dataflow does not exist, then an - * exception is thrown. + * Sets the state of the dataflow. If the dataflow does not exist, then an exception is thrown. * * @param flowState the state of the dataflow * diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowManagementService.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowManagementService.java index 082d65e512..8a2af5430f 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowManagementService.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowManagementService.java @@ -21,23 +21,17 @@ import java.util.Set; import org.apache.nifi.cluster.protocol.NodeIdentifier; /** - * A service for managing the cluster's flow. The service will attempt to keep - * the cluster's dataflow current while respecting the value of the configured - * retrieval delay. + * A service for managing the cluster's flow. The service will attempt to keep the cluster's dataflow current while respecting the value of the configured retrieval delay. * - * The eligible retrieval time is reset with the configured delay every time the - * flow state is set to STALE. If the state is set to UNKNOWN or CURRENT, then - * the flow will not be retrieved. + * The eligible retrieval time is reset with the configured delay every time the flow state is set to STALE. If the state is set to UNKNOWN or CURRENT, then the flow will not be retrieved. * * Clients must call start() and stop() to initialize and stop the instance. * - * @author unattributed */ public interface DataFlowManagementService { /** - * Starts the instance. Start may only be called if the instance is not - * running. + * Starts the instance. Start may only be called if the instance is not running. */ void start(); @@ -69,20 +63,20 @@ public interface DataFlowManagementService { /** * Updates the dataflow with the given serialized form of the Controller Services that are to exist on the NCM. - * - * @param serializedControllerServices - * @throws DaoException + * + * @param serializedControllerServices services + * @throws DaoException ex */ void updateControllerServices(byte[] serializedControllerServices) throws DaoException; - + /** * Updates the dataflow with the given serialized form of Reporting Tasks that are to exist on the NCM. - * - * @param serviceNodes - * @throws DaoException + * + * @param serializedReportingTasks tasks + * @throws DaoException ex */ void updateReportingTasks(byte[] serializedReportingTasks) throws DaoException; - + /** * Sets the state of the flow. * @@ -110,11 +104,9 @@ public interface DataFlowManagementService { void setNodeIds(Set nodeIds); /** - * Returns the set of node identifiers the service is using to retrieve the - * flow. + * Returns the set of node identifiers the service is using to retrieve the flow. * - * @return the set of node identifiers the service is using to retrieve the - * flow. + * @return the set of node identifiers the service is using to retrieve the flow. */ Set getNodeIds(); diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/PersistedFlowState.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/PersistedFlowState.java index b3afc6ee6f..166632ca92 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/PersistedFlowState.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/PersistedFlowState.java @@ -27,7 +27,6 @@ package org.apache.nifi.cluster.flow; * * * - * @author unattributed */ public enum PersistedFlowState { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/StaleFlowException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/StaleFlowException.java index ce5a08b50c..0318e7b1f1 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/StaleFlowException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/StaleFlowException.java @@ -17,10 +17,8 @@ package org.apache.nifi.cluster.flow; /** - * Represents the exceptional case when a caller is requesting the current flow, - * but a current flow is not available. + * Represents the exceptional case when a caller is requesting the current flow, but a current flow is not available. * - * @author unattributed */ public class StaleFlowException extends RuntimeException { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowDaoImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowDaoImpl.java index dd9d2a3c6f..5554247632 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowDaoImpl.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowDaoImpl.java @@ -67,36 +67,23 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; /** - * Implements the FlowDao interface. The implementation tracks the state of the - * dataflow by annotating the filename of the flow state file. Specifically, the - * implementation correlates PersistedFlowState states to filename extensions. - * The correlation is as follows: + * Implements the FlowDao interface. The implementation tracks the state of the dataflow by annotating the filename of the flow state file. Specifically, the implementation correlates + * PersistedFlowState states to filename extensions. The correlation is as follows: *
      *
    • CURRENT maps to flow.xml
    • *
    • STALE maps to flow.xml.stale
    • *
    • UNKNOWN maps to flow.xml.unknown
    • *
    - * Whenever the flow state changes, the flow state file's name is updated to - * denote its state. + * Whenever the flow state changes, the flow state file's name is updated to denote its state. * - * The implementation also provides for a restore directory that may be - * configured for higher availability. At instance creation, if the primary or - * restore directories have multiple flow state files, an exception is thrown. - * If the primary directory has a current flow state file, but the restore - * directory does not, then the primary flow state file is copied to the restore - * directory. If the restore directory has a current flow state file, but the - * primary directory does not, then the restore flow state file is copied to the - * primary directory. If both the primary and restore directories have a current - * flow state file and the files are different, then an exception is thrown. + * The implementation also provides for a restore directory that may be configured for higher availability. At instance creation, if the primary or restore directories have multiple flow state files, + * an exception is thrown. If the primary directory has a current flow state file, but the restore directory does not, then the primary flow state file is copied to the restore directory. If the + * restore directory has a current flow state file, but the primary directory does not, then the restore flow state file is copied to the primary directory. If both the primary and restore directories + * have a current flow state file and the files are different, then an exception is thrown. * - * When the flow state file is saved, it is always saved first to the restore - * directory followed by a save to the primary directory. When the flow state - * file is loaded, a check is made to verify that the primary and restore flow - * state files are both current. If either is not current, then an exception is - * thrown. The primary flow state file is always read when the load method is - * called. + * When the flow state file is saved, it is always saved first to the restore directory followed by a save to the primary directory. When the flow state file is loaded, a check is made to verify that + * the primary and restore flow state files are both current. If either is not current, then an exception is thrown. The primary flow state file is always read when the load method is called. * - * @author unattributed */ public class DataFlowDaoImpl implements DataFlowDao { @@ -187,36 +174,35 @@ public class DataFlowDaoImpl implements DataFlowDao { throw new DaoException(ex); } } - - + private void syncWithRestore(final File primaryFile, final File restoreFile) throws IOException { try (final FileInputStream primaryFis = new FileInputStream(primaryFile); - final TarArchiveInputStream primaryIn = new TarArchiveInputStream(primaryFis); - final FileInputStream restoreFis = new FileInputStream(restoreFile); - final TarArchiveInputStream restoreIn = new TarArchiveInputStream(restoreFis)) { - + final TarArchiveInputStream primaryIn = new TarArchiveInputStream(primaryFis); + final FileInputStream restoreFis = new FileInputStream(restoreFile); + final TarArchiveInputStream restoreIn = new TarArchiveInputStream(restoreFis)) { + final ArchiveEntry primaryEntry = primaryIn.getNextEntry(); final ArchiveEntry restoreEntry = restoreIn.getNextEntry(); - if ( primaryEntry == null && restoreEntry == null ) { + if (primaryEntry == null && restoreEntry == null) { return; } - if ( (primaryEntry == null && restoreEntry != null) || (primaryEntry != null && restoreEntry == null) ) { + if ((primaryEntry == null && restoreEntry != null) || (primaryEntry != null && restoreEntry == null)) { throw new IllegalStateException(String.format("Primary file '%s' is different than restore file '%s'", primaryFile.getAbsoluteFile(), restoreFile.getAbsolutePath())); } - + final byte[] primaryMd5 = calculateMd5(primaryIn); final byte[] restoreMd5 = calculateMd5(restoreIn); - - if ( !Arrays.equals(primaryMd5, restoreMd5) ) { + + if (!Arrays.equals(primaryMd5, restoreMd5)) { throw new IllegalStateException(String.format("Primary file '%s' is different than restore file '%s'", primaryFile.getAbsoluteFile(), restoreFile.getAbsolutePath())); } } } - + private byte[] calculateMd5(final InputStream in) throws IOException { final MessageDigest digest; try { @@ -224,7 +210,7 @@ public class DataFlowDaoImpl implements DataFlowDao { } catch (final NoSuchAlgorithmException nsae) { throw new IOException(nsae); } - + int len; final byte[] buffer = new byte[8192]; while ((len = in.read(buffer)) > -1) { @@ -257,12 +243,14 @@ public class DataFlowDaoImpl implements DataFlowDao { if (primaryStateFile == null) { writeDataFlow(createNewFlowStateFile(restoreDirectory), dataFlow); } else { - throw new DaoException(String.format("Unable to save dataflow because dataflow state file in primary directory '%s' exists, but it does not exist in the restore directory '%s'", + throw new DaoException(String.format("Unable to save dataflow because dataflow state file in primary directory " + + "'%s' exists, but it does not exist in the restore directory '%s'", primaryDirectory.getAbsolutePath(), restoreDirectory.getAbsolutePath())); } } else { if (primaryStateFile == null) { - throw new DaoException(String.format("Unable to save dataflow because dataflow state file in restore directory '%s' exists, but it does not exist in the primary directory '%s'", + throw new DaoException(String.format("Unable to save dataflow because dataflow state file in restore directory " + + "'%s' exists, but it does not exist in the primary directory '%s'", restoreDirectory.getAbsolutePath(), primaryDirectory.getAbsolutePath())); } else { final PersistedFlowState primaryFlowState = getPersistedFlowState(primaryStateFile); @@ -270,14 +258,15 @@ public class DataFlowDaoImpl implements DataFlowDao { if (primaryFlowState == restoreFlowState) { writeDataFlow(restoreStateFile, dataFlow); } else { - throw new DaoException(String.format("Unable to save dataflow because state file in primary directory '%s' has state '%s', but the state file in the restore directory '%s' has state '%s'", + throw new DaoException(String.format("Unable to save dataflow because state file in primary directory " + + "'%s' has state '%s', but the state file in the restore directory '%s' has state '%s'", primaryDirectory.getAbsolutePath(), primaryFlowState, restoreDirectory.getAbsolutePath(), restoreFlowState)); } } } } - // write dataflow to primary + // write dataflow to primary if (primaryStateFile == null) { writeDataFlow(createNewFlowStateFile(primaryDirectory), dataFlow); } else { @@ -477,7 +466,7 @@ public class DataFlowDaoImpl implements DataFlowDao { byte[] clusterInfoBytes = new byte[0]; byte[] controllerServiceBytes = new byte[0]; byte[] reportingTaskBytes = new byte[0]; - + try (final InputStream inStream = new FileInputStream(file); final TarArchiveInputStream tarIn = new TarArchiveInputStream(new BufferedInputStream(inStream))) { TarArchiveEntry tarEntry; @@ -500,13 +489,13 @@ public class DataFlowDaoImpl implements DataFlowDao { StreamUtils.fillBuffer(tarIn, clusterInfoBytes, true); break; case CONTROLLER_SERVICES_FILENAME: - controllerServiceBytes = new byte[(int) tarEntry.getSize()]; - StreamUtils.fillBuffer(tarIn, controllerServiceBytes, true); - break; + controllerServiceBytes = new byte[(int) tarEntry.getSize()]; + StreamUtils.fillBuffer(tarIn, controllerServiceBytes, true); + break; case REPORTING_TASKS_FILENAME: - reportingTaskBytes = new byte[(int) tarEntry.getSize()]; - StreamUtils.fillBuffer(tarIn, reportingTaskBytes, true); - break; + reportingTaskBytes = new byte[(int) tarEntry.getSize()]; + StreamUtils.fillBuffer(tarIn, reportingTaskBytes, true); + break; default: throw new DaoException("Found Unexpected file in dataflow configuration: " + tarEntry.getName()); } @@ -559,7 +548,7 @@ public class DataFlowDaoImpl implements DataFlowDao { final TarArchiveOutputStream tarOut = new TarArchiveOutputStream(new BufferedOutputStream(fos))) { final DataFlow dataFlow = clusterDataFlow.getDataFlow(); - if ( dataFlow == null ) { + if (dataFlow == null) { writeTarEntry(tarOut, FLOW_XML_FILENAME, getEmptyFlowBytes()); writeTarEntry(tarOut, TEMPLATES_FILENAME, new byte[0]); writeTarEntry(tarOut, SNIPPETS_FILENAME, new byte[0]); diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImpl.java index 1bb8ca3c92..22450dab14 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImpl.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImpl.java @@ -45,31 +45,23 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Implements FlowManagementService interface. The service tries to keep the - * cluster's flow current with regards to the available nodes. + * Implements FlowManagementService interface. The service tries to keep the cluster's flow current with regards to the available nodes. * - * The instance may be configured with a retrieval delay, which will reduce the - * number of retrievals performed by the service at the expense of increasing - * the chances that the service will not be able to provide a current flow to - * the caller. + * The instance may be configured with a retrieval delay, which will reduce the number of retrievals performed by the service at the expense of increasing the chances that the service will not be able + * to provide a current flow to the caller. * - * By default, the service will try to update the flow as quickly as possible. - * Configuring a delay enables a less aggressive retrieval strategy. - * Specifically, the eligible retrieval time is reset every time the flow state - * is set to STALE. If the state is set to UNKNOWN or CURRENT, then the flow - * will not be retrieved. + * By default, the service will try to update the flow as quickly as possible. Configuring a delay enables a less aggressive retrieval strategy. Specifically, the eligible retrieval time is reset + * every time the flow state is set to STALE. If the state is set to UNKNOWN or CURRENT, then the flow will not be retrieved. * - * @author unattributed */ public class DataFlowManagementServiceImpl implements DataFlowManagementService { /* - * Developer Note: - * + * Developer Note: + * * This class maintains an ExecutorService and a Runnable. * Although the class is not externally threadsafe, its internals are protected to * accommodate multithread access between the ExecutorServer and the Runnable. - * */ private static final Logger logger = new NiFiLog(LoggerFactory.getLogger(DataFlowManagementServiceImpl.class)); @@ -170,13 +162,12 @@ public class DataFlowManagementServiceImpl implements DataFlowManagementService resourceLock.unlock("updatePrimaryNode"); } } - - + @Override public void updateControllerServices(final byte[] controllerServiceBytes) throws DaoException { - resourceLock.lock(); - try { - final ClusterDataFlow existingClusterDataFlow = flowDao.loadDataFlow(); + resourceLock.lock(); + try { + final ClusterDataFlow existingClusterDataFlow = flowDao.loadDataFlow(); final StandardDataFlow dataFlow; final byte[] reportingTaskBytes; @@ -192,16 +183,16 @@ public class DataFlowManagementServiceImpl implements DataFlowManagementService } flowDao.saveDataFlow(new ClusterDataFlow(dataFlow, nodeId, controllerServiceBytes, reportingTaskBytes)); - } finally { - resourceLock.unlock("updateControllerServices"); - } + } finally { + resourceLock.unlock("updateControllerServices"); + } } - + @Override public void updateReportingTasks(final byte[] reportingTaskBytes) throws DaoException { - resourceLock.lock(); - try { - final ClusterDataFlow existingClusterDataFlow = flowDao.loadDataFlow(); + resourceLock.lock(); + try { + final ClusterDataFlow existingClusterDataFlow = flowDao.loadDataFlow(); final StandardDataFlow dataFlow; final byte[] controllerServiceBytes; @@ -217,9 +208,9 @@ public class DataFlowManagementServiceImpl implements DataFlowManagementService } flowDao.saveDataFlow(new ClusterDataFlow(dataFlow, nodeId, controllerServiceBytes, reportingTaskBytes)); - } finally { - resourceLock.unlock("updateControllerServices"); - } + } finally { + resourceLock.unlock("updateControllerServices"); + } } @Override @@ -300,8 +291,7 @@ public class DataFlowManagementServiceImpl implements DataFlowManagementService } /** - * A timer task for issuing FlowRequestMessage messages to nodes to retrieve - * an updated flow. + * A timer task for issuing FlowRequestMessage messages to nodes to retrieve an updated flow. */ private class FlowRetrieverTimerTask extends TimerTask { @@ -361,8 +351,8 @@ public class DataFlowManagementServiceImpl implements DataFlowManagementService if (existingClusterDataFlow == null) { currentClusterDataFlow = new ClusterDataFlow(dataFlow, null, new byte[0], new byte[0]); } else { - currentClusterDataFlow = new ClusterDataFlow(dataFlow, existingClusterDataFlow.getPrimaryNodeId(), - existingClusterDataFlow.getControllerServices(), existingClusterDataFlow.getReportingTasks()); + currentClusterDataFlow = new ClusterDataFlow(dataFlow, existingClusterDataFlow.getPrimaryNodeId(), + existingClusterDataFlow.getControllerServices(), existingClusterDataFlow.getReportingTasks()); } flowDao.saveDataFlow(currentClusterDataFlow); flowDao.setPersistedFlowState(PersistedFlowState.CURRENT); diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/ClusterManager.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/ClusterManager.java index 3a1dfb2195..336d675caf 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/ClusterManager.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/ClusterManager.java @@ -39,26 +39,16 @@ import org.apache.nifi.remote.cluster.NodeInformant; import org.apache.nifi.reporting.BulletinRepository; /** - * Defines the interface for a ClusterManager. The cluster manager is a - * threadsafe centralized manager for a cluster. Members of a cluster are nodes. - * A member becomes a node by issuing a connection request to the manager. The - * manager maintains the set of nodes. Nodes may be disconnected, reconnected, - * and deleted. + * Defines the interface for a ClusterManager. The cluster manager is a threadsafe centralized manager for a cluster. Members of a cluster are nodes. A member becomes a node by issuing a connection + * request to the manager. The manager maintains the set of nodes. Nodes may be disconnected, reconnected, and deleted. * - * Nodes are responsible for sending heartbeats to the manager to indicate their - * liveliness. A manager may disconnect a node if it does not receive a - * heartbeat within a configurable time period. A cluster manager instance may - * be configured with how often to monitor received heartbeats - * (getHeartbeatMonitoringIntervalSeconds()) and the maximum time that may - * elapse between node heartbeats before disconnecting the node - * (getMaxHeartbeatGapSeconds()). + * Nodes are responsible for sending heartbeats to the manager to indicate their liveliness. A manager may disconnect a node if it does not receive a heartbeat within a configurable time period. A + * cluster manager instance may be configured with how often to monitor received heartbeats (getHeartbeatMonitoringIntervalSeconds()) and the maximum time that may elapse between node heartbeats + * before disconnecting the node (getMaxHeartbeatGapSeconds()). * - * Since only a single node may execute isolated processors, the cluster manager - * maintains the notion of a primary node. The primary node is chosen at cluster - * startup and retains the role until a user requests a different node to be the - * primary node. + * Since only a single node may execute isolated processors, the cluster manager maintains the notion of a primary node. The primary node is chosen at cluster startup and retains the role until a user + * requests a different node to be the primary node. * - * @author unattributed */ public interface ClusterManager extends NodeInformant { @@ -77,30 +67,25 @@ public interface ClusterManager extends NodeInformant { Set getNodes(Status... statuses); /** - * @param nodeId - * @return returns the node with the given identifier or null if node does - * not exist + * @param nodeId node identifier + * @return returns the node with the given identifier or null if node does not exist */ Node getNode(String nodeId); /** - * @param statuses + * @param statuses statuses * @return the set of node identifiers with the given node status */ Set getNodeIds(Status... statuses); /** - * Deletes the node with the given node identifier. If the given node is the - * primary node, then a subsequent request may be made to the manager to set - * a new primary node. + * Deletes the node with the given node identifier. If the given node is the primary node, then a subsequent request may be made to the manager to set a new primary node. * * @param nodeId the node identifier - * @param userDn the Distinguished Name of the user requesting the node be - * deleted from the cluster + * @param userDn the Distinguished Name of the user requesting the node be deleted from the cluster * * @throws UnknownNodeException if the node does not exist - * @throws IllegalNodeDeletionException if the node is not in a disconnected - * state + * @throws IllegalNodeDeletionException if the node is not in a disconnected state */ void deleteNode(String nodeId, String userDn) throws UnknownNodeException, IllegalNodeDeletionException; @@ -114,14 +99,11 @@ public interface ClusterManager extends NodeInformant { ConnectionResponse requestConnection(ConnectionRequest request); /** - * Services reconnection requests for a given node. If the node indicates - * reconnection failure, then the node will be set to disconnected. - * Otherwise, a reconnection request will be sent to the node, initiating - * the connection handshake. + * Services reconnection requests for a given node. If the node indicates reconnection failure, then the node will be set to disconnected. Otherwise, a reconnection request will be sent to the + * node, initiating the connection handshake. * * @param nodeId a node identifier - * @param userDn the Distinguished Name of the user requesting the - * reconnection + * @param userDn the Distinguished Name of the user requesting the reconnection * * @throws UnknownNodeException if the node does not exist * @throws IllegalNodeReconnectionException if the node is not disconnected @@ -132,13 +114,10 @@ public interface ClusterManager extends NodeInformant { * Requests the node with the given identifier be disconnected. * * @param nodeId the node identifier - * @param userDn the Distinguished Name of the user requesting the - * disconnection + * @param userDn the Distinguished Name of the user requesting the disconnection * * @throws UnknownNodeException if the node does not exist - * @throws IllegalNodeDisconnectionException if the node cannot be - * disconnected due to the cluster's state (e.g., node is last connected - * node or node is primary) + * @throws IllegalNodeDisconnectionException if the node cannot be disconnected due to the cluster's state (e.g., node is last connected node or node is primary) * @throws UnknownNodeException if the node does not exist * @throws IllegalNodeDisconnectionException if the node is not disconnected * @throws NodeDisconnectionException if the disconnection failed @@ -146,50 +125,37 @@ public interface ClusterManager extends NodeInformant { void requestDisconnection(String nodeId, String userDn) throws UnknownNodeException, IllegalNodeDisconnectionException, NodeDisconnectionException; /** - * @return the time in seconds to wait between successive executions of - * heartbeat monitoring + * @return the time in seconds to wait between successive executions of heartbeat monitoring */ int getHeartbeatMonitoringIntervalSeconds(); /** - * @return the maximum time in seconds that is allowed between successive - * heartbeats of a node before disconnecting the node + * @return the maximum time in seconds that is allowed between successive heartbeats of a node before disconnecting the node */ int getMaxHeartbeatGapSeconds(); /** - * Returns a list of node events for the node with the given identifier. The - * events will be returned in order of most recent to least recent according - * to the creation date of the event. + * Returns a list of node events for the node with the given identifier. The events will be returned in order of most recent to least recent according to the creation date of the event. * * @param nodeId the node identifier * - * @return the list of events or an empty list if no node exists with the - * given identifier + * @return the list of events or an empty list if no node exists with the given identifier */ List getNodeEvents(final String nodeId); /** - * Revokes the primary role from the current primary node and assigns the - * primary role to given given node ID. + * Revokes the primary role from the current primary node and assigns the primary role to given given node ID. * - * If role revocation fails, then the current primary node is set to - * disconnected while retaining the primary role and no role assignment is - * performed. + * If role revocation fails, then the current primary node is set to disconnected while retaining the primary role and no role assignment is performed. * - * If role assignment fails, then the given node is set to disconnected and - * is given the primary role. + * If role assignment fails, then the given node is set to disconnected and is given the primary role. * * @param nodeId the node identifier - * @param userDn the Distinguished Name of the user requesting that the - * Primary Node be assigned + * @param userDn the Distinguished Name of the user requesting that the Primary Node be assigned * - * @throws UnknownNodeException if the node with the given identifier does - * not exist - * @throws IneligiblePrimaryNodeException if the node with the given - * identifier is not eligible to be the primary node - * @throws PrimaryRoleAssignmentException if the cluster was unable to - * change the primary role to the requested node + * @throws UnknownNodeException if the node with the given identifier does not exist + * @throws IneligiblePrimaryNodeException if the node with the given identifier is not eligible to be the primary node + * @throws PrimaryRoleAssignmentException if the cluster was unable to change the primary role to the requested node */ void setPrimaryNode(String nodeId, String userDn) throws UnknownNodeException, IneligiblePrimaryNodeException, PrimaryRoleAssignmentException; @@ -199,27 +165,18 @@ public interface ClusterManager extends NodeInformant { Node getPrimaryNode(); /** - * Returns the bulletin repository. - * - * @return + * @return the bulletin repository */ BulletinRepository getBulletinRepository(); /** - * Returns a {@link ProcessGroupStatus} that represents the status of all - * nodes with the given {@link Status}es for the given ProcessGroup id, or - * null if no nodes exist with the given statuses - * - * @param groupId - * @return + * @param groupId groupId + * @return a {@link ProcessGroupStatus} that represents the status of all nodes with the given {@link Status}es for the given ProcessGroup id, or null if no nodes exist with the given statuses */ ProcessGroupStatus getProcessGroupStatus(String groupId); /** - * Returns a merged representation of the System Diagnostics for all nodes - * in the cluster - * - * @return + * @return a merged representation of the System Diagnostics for all nodes in the cluster */ SystemDiagnostics getSystemDiagnostics(); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpClusterManager.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpClusterManager.java index 2cf5812631..5a15b4b8b2 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpClusterManager.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpClusterManager.java @@ -30,73 +30,52 @@ import java.util.Map; import java.util.Set; /** - * Extends the ClusterManager interface to define how requests issued to the - * cluster manager are federated to the nodes. Specifically, the HTTP protocol - * is used for communicating requests to the cluster manager and to the nodes. + * Extends the ClusterManager interface to define how requests issued to the cluster manager are federated to the nodes. Specifically, the HTTP protocol is used for communicating requests to the + * cluster manager and to the nodes. * - * @author unattributed */ public interface HttpClusterManager extends ClusterManager { /** - * Federates the HTTP request to all connected nodes in the cluster. The - * given URI's host and port will not be used and instead will be adjusted - * for each node's host and port. The node URIs are guaranteed to be - * constructed before issuing any requests, so if a UriConstructionException - * is thrown, then it is guaranteed that no request was issued. + * Federates the HTTP request to all connected nodes in the cluster. The given URI's host and port will not be used and instead will be adjusted for each node's host and port. The node URIs are + * guaranteed to be constructed before issuing any requests, so if a UriConstructionException is thrown, then it is guaranteed that no request was issued. * * @param method the HTTP method (e.g., GET, POST, PUT, DELETE, HEAD) - * @param uri the base request URI (up to, but not including, the query - * string) + * @param uri the base request URI (up to, but not including, the query string) * @param parameters the request parameters * @param headers the request headers * * @return the client response * - * @throws NoConnectedNodesException if no nodes are connected as results of - * the request + * @throws NoConnectedNodesException if no nodes are connected as results of the request * @throws NoResponseFromNodesException if no response could be obtained - * @throws UriConstructionException if there was an issue constructing the - * URIs tailored for each individual node - * @throws ConnectingNodeMutableRequestException if the request was a PUT, - * POST, DELETE and a node is connecting to the cluster - * @throws DisconnectedNodeMutableRequestException if the request was a PUT, - * POST, DELETE and a node is disconnected from the cluster - * @throws SafeModeMutableRequestException if the request was a PUT, POST, - * DELETE and a the cluster is in safe mode + * @throws UriConstructionException if there was an issue constructing the URIs tailored for each individual node + * @throws ConnectingNodeMutableRequestException if the request was a PUT, POST, DELETE and a node is connecting to the cluster + * @throws DisconnectedNodeMutableRequestException if the request was a PUT, POST, DELETE and a node is disconnected from the cluster + * @throws SafeModeMutableRequestException if the request was a PUT, POST, DELETE and a the cluster is in safe mode */ NodeResponse applyRequest(String method, URI uri, Map> parameters, Map headers) throws NoConnectedNodesException, NoResponseFromNodesException, UriConstructionException, ConnectingNodeMutableRequestException, DisconnectedNodeMutableRequestException, SafeModeMutableRequestException; /** - * Federates the HTTP request to the nodes specified. The given URI's host - * and port will not be used and instead will be adjusted for each node's - * host and port. The node URIs are guaranteed to be constructed before - * issuing any requests, so if a UriConstructionException is thrown, then it - * is guaranteed that no request was issued. + * Federates the HTTP request to the nodes specified. The given URI's host and port will not be used and instead will be adjusted for each node's host and port. The node URIs are guaranteed to be + * constructed before issuing any requests, so if a UriConstructionException is thrown, then it is guaranteed that no request was issued. * * @param method the HTTP method (e.g., GET, POST, PUT, DELETE, HEAD) - * @param uri the base request URI (up to, but not including, the query - * string) + * @param uri the base request URI (up to, but not including, the query string) * @param parameters the request parameters * @param headers the request headers - * @param nodeIdentifiers the NodeIdentifier for each node that the request - * should be replaced to + * @param nodeIdentifiers the NodeIdentifier for each node that the request should be replaced to * * @return the client response * - * @throws NoConnectedNodesException if no nodes are connected as results of - * the request + * @throws NoConnectedNodesException if no nodes are connected as results of the request * @throws NoResponseFromNodesException if no response could be obtained - * @throws UriConstructionException if there was an issue constructing the - * URIs tailored for each individual node - * @throws ConnectingNodeMutableRequestException if the request was a PUT, - * POST, DELETE and a node is connecting to the cluster - * @throws DisconnectedNodeMutableRequestException if the request was a PUT, - * POST, DELETE and a node is disconnected from the cluster - * @throws SafeModeMutableRequestException if the request was a PUT, POST, - * DELETE and a the cluster is in safe mode + * @throws UriConstructionException if there was an issue constructing the URIs tailored for each individual node + * @throws ConnectingNodeMutableRequestException if the request was a PUT, POST, DELETE and a node is connecting to the cluster + * @throws DisconnectedNodeMutableRequestException if the request was a PUT, POST, DELETE and a node is disconnected from the cluster + * @throws SafeModeMutableRequestException if the request was a PUT, POST, DELETE and a the cluster is in safe mode */ NodeResponse applyRequest(String method, URI uri, Map> parameters, Map headers, Set nodeIdentifiers) @@ -104,64 +83,45 @@ public interface HttpClusterManager extends ClusterManager { DisconnectedNodeMutableRequestException, SafeModeMutableRequestException; /** - * Federates the HTTP request to all connected nodes in the cluster. The - * given URI's host and port will not be used and instead will be adjusted - * for each node's host and port. The node URIs are guaranteed to be - * constructed before issuing any requests, so if a UriConstructionException - * is thrown, then it is guaranteed that no request was issued. + * Federates the HTTP request to all connected nodes in the cluster. The given URI's host and port will not be used and instead will be adjusted for each node's host and port. The node URIs are + * guaranteed to be constructed before issuing any requests, so if a UriConstructionException is thrown, then it is guaranteed that no request was issued. * * @param method the HTTP method (e.g., GET, POST, PUT, DELETE, HEAD) - * @param uri the base request URI (up to, but not including, the query - * string) + * @param uri the base request URI (up to, but not including, the query string) * @param entity the HTTP request entity * @param headers the request headers * * @return the client response * - * @throws NoConnectedNodesException if no nodes are connected as results of - * the request + * @throws NoConnectedNodesException if no nodes are connected as results of the request * @throws NoResponseFromNodesException if no response could be obtained - * @throws UriConstructionException if there was an issue constructing the - * URIs tailored for each individual node - * @throws ConnectingNodeMutableRequestException if the request was a PUT, - * POST, DELETE and a node is connecting to the cluster - * @throws DisconnectedNodeMutableRequestException if the request was a PUT, - * POST, DELETE and a node is disconnected from the cluster - * @throws SafeModeMutableRequestException if the request was a PUT, POST, - * DELETE and a the cluster is in safe mode + * @throws UriConstructionException if there was an issue constructing the URIs tailored for each individual node + * @throws ConnectingNodeMutableRequestException if the request was a PUT, POST, DELETE and a node is connecting to the cluster + * @throws DisconnectedNodeMutableRequestException if the request was a PUT, POST, DELETE and a node is disconnected from the cluster + * @throws SafeModeMutableRequestException if the request was a PUT, POST, DELETE and a the cluster is in safe mode */ NodeResponse applyRequest(String method, URI uri, Object entity, Map headers) throws NoConnectedNodesException, NoResponseFromNodesException, UriConstructionException, ConnectingNodeMutableRequestException, DisconnectedNodeMutableRequestException, SafeModeMutableRequestException; /** - * Federates the HTTP request to the nodes specified. The given URI's host - * and port will not be used and instead will be adjusted for each node's - * host and port. The node URIs are guaranteed to be constructed before - * issuing any requests, so if a UriConstructionException is thrown, then it - * is guaranteed that no request was issued. + * Federates the HTTP request to the nodes specified. The given URI's host and port will not be used and instead will be adjusted for each node's host and port. The node URIs are guaranteed to be + * constructed before issuing any requests, so if a UriConstructionException is thrown, then it is guaranteed that no request was issued. * * @param method the HTTP method (e.g., GET, POST, PUT, DELETE, HEAD) - * @param uri the base request URI (up to, but not including, the query - * string) + * @param uri the base request URI (up to, but not including, the query string) * @param entity the HTTP request entity * @param headers the request headers - * @param nodeIdentifiers the NodeIdentifier for each node that the request - * should be replaced to + * @param nodeIdentifiers the NodeIdentifier for each node that the request should be replaced to * * @return the client response * - * @throws NoConnectedNodesException if no nodes are connected as results of - * the request + * @throws NoConnectedNodesException if no nodes are connected as results of the request * @throws NoResponseFromNodesException if no response could be obtained - * @throws UriConstructionException if there was an issue constructing the - * URIs tailored for each individual node - * @throws ConnectingNodeMutableRequestException if the request was a PUT, - * POST, DELETE and a node is connecting to the cluster - * @throws DisconnectedNodeMutableRequestException if the request was a PUT, - * POST, DELETE and a node is disconnected from the cluster - * @throws SafeModeMutableRequestException if the request was a PUT, POST, - * DELETE and a the cluster is in safe mode + * @throws UriConstructionException if there was an issue constructing the URIs tailored for each individual node + * @throws ConnectingNodeMutableRequestException if the request was a PUT, POST, DELETE and a node is connecting to the cluster + * @throws DisconnectedNodeMutableRequestException if the request was a PUT, POST, DELETE and a node is disconnected from the cluster + * @throws SafeModeMutableRequestException if the request was a PUT, POST, DELETE and a the cluster is in safe mode */ NodeResponse applyRequest(String method, URI uri, Object entity, Map headers, Set nodeIdentifiers) throws NoConnectedNodesException, NoResponseFromNodesException, UriConstructionException, ConnectingNodeMutableRequestException, diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpRequestReplicator.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpRequestReplicator.java index fb57622ddf..470c6ba4c9 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpRequestReplicator.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpRequestReplicator.java @@ -24,25 +24,20 @@ import java.util.Set; import org.apache.nifi.cluster.protocol.NodeIdentifier; /** - * A service for managing the replication of requests to nodes. It is up to the - * implementing class to decide if requests are sent concurrently or serially. + * A service for managing the replication of requests to nodes. It is up to the implementing class to decide if requests are sent concurrently or serially. * - * Clients must call start() and stop() to initialize and shutdown the instance. - * The instance must be started before issuing any replication requests. + * Clients must call start() and stop() to initialize and shutdown the instance. The instance must be started before issuing any replication requests. * - * @author unattributed */ public interface HttpRequestReplicator { /** - * Starts the instance for replicating requests. Start may only be called if - * the instance is not running. + * Starts the instance for replicating requests. Start may only be called if the instance is not running. */ void start(); /** - * Stops the instance from replicating requests. Stop may only be called if - * the instance is running. + * Stops the instance from replicating requests. Stop may only be called if the instance is running. */ void stop(); @@ -52,47 +47,36 @@ public interface HttpRequestReplicator { boolean isRunning(); /** - * Requests are sent to each node in the cluster. If the request results in - * an exception, then the NodeResourceResponse will contain the exception. + * Requests are sent to each node in the cluster. If the request results in an exception, then the NodeResourceResponse will contain the exception. * - * HTTP DELETE and OPTIONS methods must supply an empty parameters map or - * else and IllegalArgumentException is thrown. + * HTTP DELETE and OPTIONS methods must supply an empty parameters map or else and IllegalArgumentException is thrown. * * @param nodeIds the node identifiers - * @param method the HTTP method (e.g., GET, POST, PUT, DELETE, HEAD, - * OPTIONS) - * @param uri the base request URI (up to, but not including, the query - * string) + * @param method the HTTP method (e.g., GET, POST, PUT, DELETE, HEAD, OPTIONS) + * @param uri the base request URI (up to, but not including, the query string) * @param parameters any request parameters * @param headers any HTTP headers * * @return the set of node responses * - * @throws UriConstructionException if a request for a node failed to be - * constructed from the given prototype URI. If thrown, it is guaranteed - * that no request was sent. + * @throws UriConstructionException if a request for a node failed to be constructed from the given prototype URI. If thrown, it is guaranteed that no request was sent. */ Set replicate(Set nodeIds, String method, URI uri, Map> parameters, Map headers) throws UriConstructionException; /** - * Requests are sent to each node in the cluster. If the request results in - * an exception, then the NodeResourceResponse will contain the exception. + * Requests are sent to each node in the cluster. If the request results in an exception, then the NodeResourceResponse will contain the exception. * - * HTTP DELETE, GET, HEAD, and OPTIONS methods will throw an - * IllegalArgumentException if used. + * HTTP DELETE, GET, HEAD, and OPTIONS methods will throw an IllegalArgumentException if used. * * @param nodeIds the node identifiers * @param method the HTTP method (e.g., POST, PUT) - * @param uri the base request URI (up to, but not including, the query - * string) + * @param uri the base request URI (up to, but not including, the query string) * @param entity an entity * @param headers any HTTP headers * * @return the set of node responses * - * @throws UriConstructionException if a request for a node failed to be - * constructed from the given prototype URI. If thrown, it is guaranteed - * that no request was sent. + * @throws UriConstructionException if a request for a node failed to be constructed from the given prototype URI. If thrown, it is guaranteed that no request was sent. */ Set replicate(Set nodeIds, String method, URI uri, Object entity, Map headers) throws UriConstructionException; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpResponseMapper.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpResponseMapper.java index 843a6667db..fda9ecf331 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpResponseMapper.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpResponseMapper.java @@ -24,13 +24,11 @@ import org.apache.nifi.cluster.node.Node.Status; /** * Maps a HTTP response to a node status. * - * @author unattributed */ public interface HttpResponseMapper { /** - * Maps a HTTP response to a node response and the corresponding node - * status. + * Maps a HTTP response to a node response and the corresponding node status. * * @param requestURI the original request URI * @param nodeResponses a set of node resource responses diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/NodeResponse.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/NodeResponse.java index 8bc73abb9d..2789f78369 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/NodeResponse.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/NodeResponse.java @@ -40,25 +40,16 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Encapsulates a node's response in regards to receiving a external API - * request. + * Encapsulates a node's response in regards to receiving a external API request. * - * Both the ClientResponse and (server) Response may be obtained from this - * instance. The ClientResponse is stored as it is received from the node. This - * includes the entity input stream. The Response is constructed on demand when - * mapping a ClientResponse to the Response. The ClientResponse to Response - * mapping includes copying the ClientResponse's input stream to the Response. - * Therefore, the getResponse() method should not be called more than once. - * Furthermore, the method should not be called if the caller has already read - * the ClientResponse's input stream. + * Both the ClientResponse and (server) Response may be obtained from this instance. The ClientResponse is stored as it is received from the node. This includes the entity input stream. The Response + * is constructed on demand when mapping a ClientResponse to the Response. The ClientResponse to Response mapping includes copying the ClientResponse's input stream to the Response. Therefore, the + * getResponse() method should not be called more than once. Furthermore, the method should not be called if the caller has already read the ClientResponse's input stream. * - * If a ClientResponse was unable to be created, then a NodeResponse will store - * the Throwable, which may be obtained by calling getThrowable(). + * If a ClientResponse was unable to be created, then a NodeResponse will store the Throwable, which may be obtained by calling getThrowable(). * - * This class overrides hashCode and equals and considers two instances to be - * equal if they have the equal NodeIdentifiers. + * This class overrides hashCode and equals and considers two instances to be equal if they have the equal NodeIdentifiers. * - * @author unattributed */ public class NodeResponse { @@ -145,14 +136,14 @@ public class NodeResponse { public int getStatus() { if (hasThrowable()) { /* - * since there is a throwable, there is no client input stream to + * since there is a throwable, there is no client input stream to * worry about maintaining, so we can call getResponse() method */ return getResponse().getStatus(); } else { /* * use client response's status instead of calling getResponse().getStatus() - * so that we don't read the client's input stream as part of creating + * so that we don't read the client's input stream as part of creating * the response in the getResponse() method */ return clientResponse.getStatus(); @@ -160,9 +151,7 @@ public class NodeResponse { } /** - * Returns true if the response status is 2xx, false otherwise. - * - * @return + * @return true if the response status is 2xx, false otherwise. */ public boolean is2xx() { final int statusCode = getStatus(); @@ -170,9 +159,7 @@ public class NodeResponse { } /** - * Returns true if the response status is 5xx, false otherwise. - * - * @return + * @return true if the response status is 5xx, false otherwise. */ public boolean is5xx() { final int statusCode = getStatus(); @@ -180,8 +167,7 @@ public class NodeResponse { } /** - * Returns null if hasThrowable() is true; otherwise the client's response - * is returned. + * Returns null if hasThrowable() is true; otherwise the client's response is returned. * * The ClientResponse's input stream can only be read once. * @@ -192,24 +178,18 @@ public class NodeResponse { } /** - * If this node response has been merged returns the updated entity, - * otherwise null. Also returns null if hasThrowable() is true. The - * intent of this method is to support getting the response entity - * when it was already consumed during the merge operation. In this - * case the client response rom getClientResponse() will not support - * a getEntity(...) or getEntityInputStream() call. - * - * @return + * If this node response has been merged returns the updated entity, otherwise null. Also returns null if hasThrowable() is true. The intent of this method is to support getting the response + * entity when it was already consumed during the merge operation. In this case the client response rom getClientResponse() will not support a getEntity(...) or getEntityInputStream() call. + * + * @return If this node response has been merged returns the updated entity, otherwise null. Also returns null if hasThrowable() is true */ public Entity getUpdatedEntity() { return updatedEntity; } - + /** - * Creates a Response by mapping the ClientResponse values to it. Since the - * ClientResponse's input stream can only be read once, this method should - * only be called once. Furthermore, the caller should not have already read - * the ClientResponse's input stream. + * Creates a Response by mapping the ClientResponse values to it. Since the ClientResponse's input stream can only be read once, this method should only be called once. Furthermore, the caller + * should not have already read the ClientResponse's input stream. * * @return the response */ @@ -232,11 +212,9 @@ public class NodeResponse { } /** - * Returns true if a throwable was thrown and a response was not able to be - * created; false otherwise. + * Returns true if a throwable was thrown and a response was not able to be created; false otherwise. * - * @return true if a throwable was thrown and a response was not able to be - * created; false otherwise + * @return true if a throwable was thrown and a response was not able to be created; false otherwise */ public boolean hasThrowable() { return getThrowable() != null; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ClusterException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ClusterException.java index 3bf9752cc1..e93acca710 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ClusterException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ClusterException.java @@ -19,7 +19,6 @@ package org.apache.nifi.cluster.manager.exception; /** * The base exception class for cluster related exceptions. * - * @author unattributed */ public class ClusterException extends RuntimeException { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ConnectingNodeMutableRequestException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ConnectingNodeMutableRequestException.java index 365b5f0b48..a698b0f62b 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ConnectingNodeMutableRequestException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ConnectingNodeMutableRequestException.java @@ -17,10 +17,8 @@ package org.apache.nifi.cluster.manager.exception; /** - * Represents the exceptional case when a HTTP request that may change a node's - * dataflow is to be replicated while a node is connecting to the cluster. + * Represents the exceptional case when a HTTP request that may change a node's dataflow is to be replicated while a node is connecting to the cluster. * - * @author unattributed */ public class ConnectingNodeMutableRequestException extends MutableRequestException { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/DisconnectedNodeMutableRequestException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/DisconnectedNodeMutableRequestException.java index 412a555e32..53740194c5 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/DisconnectedNodeMutableRequestException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/DisconnectedNodeMutableRequestException.java @@ -17,10 +17,8 @@ package org.apache.nifi.cluster.manager.exception; /** - * Represents the exceptional case when a HTTP request that may change a node's - * dataflow is to be replicated while one or more nodes are disconnected. + * Represents the exceptional case when a HTTP request that may change a node's dataflow is to be replicated while one or more nodes are disconnected. * - * @author unattributed */ public class DisconnectedNodeMutableRequestException extends MutableRequestException { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalClusterStateException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalClusterStateException.java index 6c4e67087f..e10e9c399b 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalClusterStateException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalClusterStateException.java @@ -17,10 +17,8 @@ package org.apache.nifi.cluster.manager.exception; /** - * Signals that an operation to be performed on a cluster has been invoked at an - * illegal or inappropriate time. + * Signals that an operation to be performed on a cluster has been invoked at an illegal or inappropriate time. * - * @author unattributed */ public class IllegalClusterStateException extends ClusterException { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDeletionException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDeletionException.java index adef62a823..b4eed3db68 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDeletionException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDeletionException.java @@ -17,10 +17,8 @@ package org.apache.nifi.cluster.manager.exception; /** - * Represents the exceptional case when a deletion request is issued to a node - * that cannot be deleted (e.g., the node is not disconnected). + * Represents the exceptional case when a deletion request is issued to a node that cannot be deleted (e.g., the node is not disconnected). * - * @author unattributed */ public class IllegalNodeDeletionException extends IllegalClusterStateException { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDisconnectionException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDisconnectionException.java index 7e61b24f76..1199ef7a9b 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDisconnectionException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDisconnectionException.java @@ -17,11 +17,8 @@ package org.apache.nifi.cluster.manager.exception; /** - * Represents the exceptional case when a disconnection request is issued to a - * node that cannot be disconnected (e.g., last node in cluster, node is primary - * node). + * Represents the exceptional case when a disconnection request is issued to a node that cannot be disconnected (e.g., last node in cluster, node is primary node). * - * @author unattributed */ public class IllegalNodeDisconnectionException extends IllegalClusterStateException { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeReconnectionException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeReconnectionException.java index 96c76bcb35..3f7129677a 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeReconnectionException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeReconnectionException.java @@ -17,10 +17,8 @@ package org.apache.nifi.cluster.manager.exception; /** - * Represents the exceptional case when a reconnection request is issued to a - * node that cannot be reconnected (e.g., the node is not disconnected). + * Represents the exceptional case when a reconnection request is issued to a node that cannot be reconnected (e.g., the node is not disconnected). * - * @author unattributed */ public class IllegalNodeReconnectionException extends IllegalClusterStateException { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IneligiblePrimaryNodeException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IneligiblePrimaryNodeException.java index 4b0097a4b8..26b22f8cda 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IneligiblePrimaryNodeException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IneligiblePrimaryNodeException.java @@ -17,10 +17,8 @@ package org.apache.nifi.cluster.manager.exception; /** - * Represents the exceptional case when the primary role cannot be assigned to a - * node because the node is ineligible for the role. + * Represents the exceptional case when the primary role cannot be assigned to a node because the node is ineligible for the role. * - * @author unattributed */ public class IneligiblePrimaryNodeException extends IllegalClusterStateException { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/MutableRequestException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/MutableRequestException.java index d1605874ba..a78f34cea5 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/MutableRequestException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/MutableRequestException.java @@ -17,11 +17,9 @@ package org.apache.nifi.cluster.manager.exception; /** - * Represents the exceptional case when a HTTP request that may change a node's - * state is to be replicated while the cluster or connected nodes are unable to - * change their state (e.g., a new node is connecting to the cluster). + * Represents the exceptional case when a HTTP request that may change a node's state is to be replicated while the cluster or connected nodes are unable to change their state (e.g., a new node is + * connecting to the cluster). * - * @author unattributed */ public class MutableRequestException extends IllegalClusterStateException { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoConnectedNodesException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoConnectedNodesException.java index 8d704b968d..7a828e3f0b 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoConnectedNodesException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoConnectedNodesException.java @@ -17,10 +17,8 @@ package org.apache.nifi.cluster.manager.exception; /** - * Represents the exceptional case when the cluster is unable to service a - * request because no nodes are connected. + * Represents the exceptional case when the cluster is unable to service a request because no nodes are connected. * - * @author unattributed */ public class NoConnectedNodesException extends ClusterException { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoResponseFromNodesException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoResponseFromNodesException.java index 9e17a232dc..9616ad3ca6 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoResponseFromNodesException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoResponseFromNodesException.java @@ -17,11 +17,9 @@ package org.apache.nifi.cluster.manager.exception; /** - * Represents the exceptional case when the cluster is unable to service a - * request because no nodes returned a response. When the given request is not - * mutable the nodes are left in their previous state. + * Represents the exceptional case when the cluster is unable to service a request because no nodes returned a response. When the given request is not mutable the nodes are left in their previous + * state. * - * @author unattributed */ public class NoResponseFromNodesException extends ClusterException { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeDisconnectionException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeDisconnectionException.java index 3bd2f4b93f..2f59eed08d 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeDisconnectionException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeDisconnectionException.java @@ -17,10 +17,8 @@ package org.apache.nifi.cluster.manager.exception; /** - * Represents the exceptional case when a disconnection request to a node - * failed. + * Represents the exceptional case when a disconnection request to a node failed. * - * @author unattributed */ public class NodeDisconnectionException extends ClusterException { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeReconnectionException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeReconnectionException.java index 8c40cef283..be3edf4572 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeReconnectionException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeReconnectionException.java @@ -19,7 +19,6 @@ package org.apache.nifi.cluster.manager.exception; /** * Represents the exceptional case when a reconnection request to a node failed. * - * @author unattributed */ public class NodeReconnectionException extends ClusterException { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/PrimaryRoleAssignmentException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/PrimaryRoleAssignmentException.java index 403f7a5ce1..57503826b0 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/PrimaryRoleAssignmentException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/PrimaryRoleAssignmentException.java @@ -17,10 +17,8 @@ package org.apache.nifi.cluster.manager.exception; /** - * Represents the exceptional case when the cluster is unable to update the - * primary role of a node. + * Represents the exceptional case when the cluster is unable to update the primary role of a node. * - * @author unattributed */ public class PrimaryRoleAssignmentException extends IllegalClusterStateException { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/SafeModeMutableRequestException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/SafeModeMutableRequestException.java index f544f26908..05d24359a8 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/SafeModeMutableRequestException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/SafeModeMutableRequestException.java @@ -17,10 +17,8 @@ package org.apache.nifi.cluster.manager.exception; /** - * Represents the exceptional case when a HTTP request that may change a node's - * dataflow is to be replicated while the cluster is in safe mode. + * Represents the exceptional case when a HTTP request that may change a node's dataflow is to be replicated while the cluster is in safe mode. * - * @author unattributed */ public class SafeModeMutableRequestException extends MutableRequestException { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UnknownNodeException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UnknownNodeException.java index 914bb56a84..2d43e8a265 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UnknownNodeException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UnknownNodeException.java @@ -17,10 +17,8 @@ package org.apache.nifi.cluster.manager.exception; /** - * Represents the exceptional case when a request is made for a node that does - * not exist. + * Represents the exceptional case when a request is made for a node that does not exist. * - * @author unattributed */ public class UnknownNodeException extends ClusterException { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UriConstructionException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UriConstructionException.java index 773d7b58f2..325ffa0b98 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UriConstructionException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UriConstructionException.java @@ -17,11 +17,8 @@ package org.apache.nifi.cluster.manager.exception; /** - * Represents the exceptional case when a URI cannot be constructed from the - * given information. This exception is similar to Java's URISyntaxException - * except that it extends RuntimeException. + * Represents the exceptional case when a URI cannot be constructed from the given information. This exception is similar to Java's URISyntaxException except that it extends RuntimeException. * - * @author unattributed */ public class UriConstructionException extends RuntimeException { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImpl.java index 81bb7a75d4..32181e38a8 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImpl.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImpl.java @@ -59,21 +59,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * An implementation of the HttpRequestReplicator interface. This - * implementation parallelizes the node HTTP requests using the given - * ExecutorService instance. Individual requests may have - * connection and read timeouts set, which may be set during instance - * construction. Otherwise, the default is not to timeout. + * An implementation of the HttpRequestReplicator interface. This implementation parallelizes the node HTTP requests using the given ExecutorService instance. Individual + * requests may have connection and read timeouts set, which may be set during instance construction. Otherwise, the default is not to timeout. * - * If a node protocol scheme is provided during construction, then all requests - * will be replicated using the given scheme. If null is provided as the scheme - * (the default), then the requests will be replicated using the scheme of the - * original URI. + * If a node protocol scheme is provided during construction, then all requests will be replicated using the given scheme. If null is provided as the scheme (the default), then the requests will be + * replicated using the scheme of the original URI. * - * Clients must call start() and stop() to initialize and shutdown the instance. - * The instance must be started before issuing any replication requests. + * Clients must call start() and stop() to initialize and shutdown the instance. The instance must be started before issuing any replication requests. * - * @author unattributed */ public class HttpRequestReplicatorImpl implements HttpRequestReplicator { @@ -97,11 +90,9 @@ public class HttpRequestReplicatorImpl implements HttpRequestReplicator { private String nodeProtocolScheme = null; /** - * Creates an instance. The connection timeout and read timeout will be - * infinite. + * Creates an instance. The connection timeout and read timeout will be infinite. * - * @param numThreads the number of threads to use when parallelizing - * requests + * @param numThreads the number of threads to use when parallelizing requests * @param client a client for making requests */ public HttpRequestReplicatorImpl(final int numThreads, final Client client) { @@ -111,12 +102,10 @@ public class HttpRequestReplicatorImpl implements HttpRequestReplicator { /** * Creates an instance. * - * @param numThreads the number of threads to use when parallelizing - * requests + * @param numThreads the number of threads to use when parallelizing requests * @param client a client for making requests - * @param connectionTimeoutMs the connection timeout specified in - * milliseconds - * @param readTimeoutMs the read timeout specified in milliseconds + * @param connectionTimeout the connection timeout specified in milliseconds + * @param readTimeout the read timeout specified in milliseconds */ public HttpRequestReplicatorImpl(final int numThreads, final Client client, final String connectionTimeout, final String readTimeout) { @@ -178,9 +167,7 @@ public class HttpRequestReplicatorImpl implements HttpRequestReplicator { /** * Sets the protocol scheme to use when issuing requests to nodes. * - * @param nodeProtocolScheme the scheme. Valid values are "http", "https", - * or null. If null is specified, then the scheme of the originating request - * is used when replicating that request. + * @param nodeProtocolScheme the scheme. Valid values are "http", "https", or null. If null is specified, then the scheme of the originating request is used when replicating that request. */ public synchronized void setNodeProtocolScheme(final String nodeProtocolScheme) { if (StringUtils.isNotBlank(nodeProtocolScheme)) { @@ -368,9 +355,7 @@ public class HttpRequestReplicatorImpl implements HttpRequestReplicator { } /** - * Wraps a future node response with info from originating request. This - * coupling allows for futures that encountered exceptions to be linked back - * to the failing node and better reported. + * Wraps a future node response with info from originating request. This coupling allows for futures that encountered exceptions to be linked back to the failing node and better reported. */ private class NodeHttpRequestFutureWrapper { @@ -417,8 +402,7 @@ public class HttpRequestReplicatorImpl implements HttpRequestReplicator { } /** - * A Callable for making an HTTP request to a single node and returning its - * response. + * A Callable for making an HTTP request to a single node and returning its response. */ private class NodeHttpRequestCallable implements Callable { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImpl.java index afade7edce..c11df0591b 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImpl.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImpl.java @@ -33,14 +33,10 @@ import org.slf4j.LoggerFactory; * * The algorithm is as follows. * - * If any HTTP responses were 2XX, then disconnect non-2XX responses. This is - * because 2XX may have changed a node's flow. + * If any HTTP responses were 2XX, then disconnect non-2XX responses. This is because 2XX may have changed a node's flow. * - * If no 2XX responses were received, then the node's flow has not changed. - * Instead of disconnecting everything, we only disconnect the nodes with - * internal errors, i.e., 5XX responses. + * If no 2XX responses were received, then the node's flow has not changed. Instead of disconnecting everything, we only disconnect the nodes with internal errors, i.e., 5XX responses. * - * @author unattributed */ public class HttpResponseMapperImpl implements HttpResponseMapper { @@ -60,7 +56,7 @@ public class HttpResponseMapperImpl implements HttpResponseMapper { } } - // determine the status of each node + // determine the status of each node for (final NodeResponse nodeResponse : nodeResponses) { final Node.Status status; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java index db6421ecd3..24204a46e5 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java @@ -232,22 +232,15 @@ import org.apache.nifi.web.api.entity.ReportingTaskEntity; import org.apache.nifi.web.api.entity.ReportingTasksEntity; /** - * Provides a cluster manager implementation. The manager federates incoming - * HTTP client requests to the nodes' external API using the HTTP protocol. The - * manager also communicates with nodes using the nodes' internal socket - * protocol. + * Provides a cluster manager implementation. The manager federates incoming HTTP client requests to the nodes' external API using the HTTP protocol. The manager also communicates with nodes using the + * nodes' internal socket protocol. * - * The manager's socket address may broadcasted using multicast if a - * MulticastServiceBroadcaster instance is set on this instance. The manager - * instance must be started after setting the broadcaster. + * The manager's socket address may broadcasted using multicast if a MulticastServiceBroadcaster instance is set on this instance. The manager instance must be started after setting the broadcaster. * - * The manager may be configured with an EventManager for recording noteworthy - * lifecycle events (e.g., first heartbeat received, node status change). + * The manager may be configured with an EventManager for recording noteworthy lifecycle events (e.g., first heartbeat received, node status change). * - * The start() and stop() methods must be called to initialize and stop the - * instance. + * The start() and stop() methods must be called to initialize and stop the instance. * - * @author unattributed */ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, ControllerServiceProvider, ReportingTaskProvider { @@ -258,47 +251,38 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C private static final Logger heartbeatLogger = new NiFiLog(LoggerFactory.getLogger("org.apache.nifi.cluster.heartbeat")); /** - * The HTTP header to store a cluster context. An example of what may be - * stored in the context is a node's auditable actions in response to a - * cluster request. The cluster context is serialized using Java's - * serialization mechanism and hex encoded. + * The HTTP header to store a cluster context. An example of what may be stored in the context is a node's auditable actions in response to a cluster request. The cluster context is serialized + * using Java's serialization mechanism and hex encoded. */ public static final String CLUSTER_CONTEXT_HTTP_HEADER = "X-ClusterContext"; /** - * HTTP Header that stores a unique ID for each request that is replicated - * to the nodes. This is used for logging purposes so that request - * information, such as timing, can be correlated between the NCM and the - * nodes + * HTTP Header that stores a unique ID for each request that is replicated to the nodes. This is used for logging purposes so that request information, such as timing, can be correlated between + * the NCM and the nodes */ public static final String REQUEST_ID_HEADER = "X-RequestID"; /** - * The HTTP header that the NCM specifies to ask a node if they are able to - * process a given request. The value is always 150-NodeContinue. The node - * will respond with 150 CONTINUE if it is able to process the request, 417 - * EXPECTATION_FAILED otherwise. + * The HTTP header that the NCM specifies to ask a node if they are able to process a given request. The value is always 150-NodeContinue. The node will respond with 150 CONTINUE if it is able to + * process the request, 417 EXPECTATION_FAILED otherwise. */ public static final String NCM_EXPECTS_HTTP_HEADER = "X-NcmExpects"; public static final int NODE_CONTINUE_STATUS_CODE = 150; /** - * The HTTP header that the NCM specifies to indicate that a node should - * invalidate the specified user group. This is done to ensure that user - * cache is not stale when an administrator modifies a group through the UI. + * The HTTP header that the NCM specifies to indicate that a node should invalidate the specified user group. This is done to ensure that user cache is not stale when an administrator modifies a + * group through the UI. */ public static final String CLUSTER_INVALIDATE_USER_GROUP_HEADER = "X-ClusterInvalidateUserGroup"; /** - * The HTTP header that the NCM specifies to indicate that a node should - * invalidate the specified user. This is done to ensure that user cache is - * not stale when an administrator modifies a user through the UI. + * The HTTP header that the NCM specifies to indicate that a node should invalidate the specified user. This is done to ensure that user cache is not stale when an administrator modifies a user + * through the UI. */ public static final String CLUSTER_INVALIDATE_USER_HEADER = "X-ClusterInvalidateUser"; /** - * The default number of seconds to respond to a connecting node if the - * manager cannot provide it with a current data flow. + * The default number of seconds to respond to a connecting node if the manager cannot provide it with a current data flow. */ private static final int DEFAULT_CONNECTION_REQUEST_TRY_AGAIN_SECONDS = 5; @@ -318,13 +302,13 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C public static final String PROVENANCE_URI = "/nifi-api/controller/provenance"; public static final Pattern PROVENANCE_QUERY_URI = Pattern.compile("/nifi-api/controller/provenance/[a-f0-9\\-]{36}"); public static final Pattern PROVENANCE_EVENT_URI = Pattern.compile("/nifi-api/controller/provenance/events/[0-9]+"); - + public static final String CONTROLLER_SERVICES_URI = "/nifi-api/controller/controller-services/node"; public static final Pattern CONTROLLER_SERVICE_URI_PATTERN = Pattern.compile("/nifi-api/controller/controller-services/node/[a-f0-9\\-]{36}"); public static final Pattern CONTROLLER_SERVICE_REFERENCES_URI_PATTERN = Pattern.compile("/nifi-api/controller/controller-services/node/[a-f0-9\\-]{36}/references"); public static final String REPORTING_TASKS_URI = "/nifi-api/controller/reporting-tasks/node"; public static final Pattern REPORTING_TASK_URI_PATTERN = Pattern.compile("/nifi-api/controller/reporting-tasks/node/[a-f0-9\\-]{36}"); - + private final NiFiProperties properties; private final HttpRequestReplicator httpRequestReplicator; private final HttpResponseMapper httpResponseMapper; @@ -399,6 +383,40 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } componentStatusSnapshotMillis = snapshotMillis; + Executors.newSingleThreadScheduledExecutor().scheduleWithFixedDelay(new Runnable() { + @Override + public void run() { + readLock.lock(); + try { + for (final Node node : nodes) { + if (Status.CONNECTED.equals(node.getStatus())) { + ComponentStatusRepository statusRepository = componentMetricsRepositoryMap.get(node.getNodeId()); + if (statusRepository == null) { + statusRepository = createComponentStatusRepository(); + componentMetricsRepositoryMap.put(node.getNodeId(), statusRepository); + } + + // ensure this node has a payload + if (node.getHeartbeat() != null && node.getHeartbeatPayload() != null) { + // if nothing has been captured or the current heartbeat is newer, capture it - comparing the heatbeat created timestamp + // is safe since its marked as XmlTransient so we're assured that its based off the same clock that created the last capture date + if (statusRepository.getLastCaptureDate() == null || node.getHeartbeat().getCreatedTimestamp() > statusRepository.getLastCaptureDate().getTime()) { + statusRepository.capture(node.getHeartbeatPayload().getProcessGroupStatus()); + } + } + } + } + } catch (final Throwable t) { + logger.warn("Unable to capture component metrics from Node heartbeats: " + t); + if (logger.isDebugEnabled()) { + logger.warn("", t); + } + } finally { + readLock.unlock("capture component metrics from node heartbeats"); + } + } + }, componentStatusSnapshotMillis, componentStatusSnapshotMillis, TimeUnit.MILLISECONDS); + remoteInputPort = properties.getRemoteInputPort(); if (remoteInputPort == null) { remoteSiteListener = null; @@ -427,14 +445,14 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C public void heartbeat() { } }, this, encryptor); - + // When we construct the scheduling agents, we can pass null for a lot of the arguments because we are only // going to be scheduling Reporting Tasks. Otherwise, it would not be okay. processScheduler.setSchedulingAgent(SchedulingStrategy.TIMER_DRIVEN, new TimerDrivenSchedulingAgent(null, reportingTaskEngine, null, encryptor)); processScheduler.setSchedulingAgent(SchedulingStrategy.CRON_DRIVEN, new QuartzSchedulingAgent(null, reportingTaskEngine, null, encryptor)); processScheduler.setMaxThreadCount(SchedulingStrategy.TIMER_DRIVEN, 10); processScheduler.setMaxThreadCount(SchedulingStrategy.CRON_DRIVEN, 10); - + controllerServiceProvider = new StandardControllerServiceProvider(processScheduler, bulletinRepository); } @@ -479,10 +497,10 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } final byte[] serializedServices = clusterDataFlow.getControllerServices(); - if ( serializedServices != null && serializedServices.length > 0 ) { - ControllerServiceLoader.loadControllerServices(this, new ByteArrayInputStream(serializedServices), encryptor, bulletinRepository, properties.getAutoResumeState()); + if (serializedServices != null && serializedServices.length > 0) { + ControllerServiceLoader.loadControllerServices(this, new ByteArrayInputStream(serializedServices), encryptor, bulletinRepository, properties.getAutoResumeState()); } - + // start multicast broadcasting service, if configured if (servicesBroadcaster != null) { servicesBroadcaster.start(); @@ -493,8 +511,8 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C // Load and start running Reporting Tasks final byte[] serializedReportingTasks = clusterDataFlow.getReportingTasks(); - if ( serializedReportingTasks != null && serializedReportingTasks.length > 0 ) { - loadReportingTasks(serializedReportingTasks); + if (serializedReportingTasks != null && serializedReportingTasks.length > 0) { + loadReportingTasks(serializedReportingTasks); } } catch (final IOException ioe) { logger.warn("Failed to initialize cluster services due to: " + ioe, ioe); @@ -558,10 +576,10 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C servicesBroadcaster.stop(); } - if ( processScheduler != null ) { + if (processScheduler != null) { processScheduler.shutdown(); } - + if (encounteredException) { throw new IOException("Failed to shutdown Cluster Manager because one or more cluster services failed to shutdown. Check the logs for details."); } @@ -633,14 +651,10 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } /** - * Services connection requests. If the data flow management service is - * unable to provide a current copy of the data flow, then the returned - * connection response will indicate the node should try later. Otherwise, - * the connection response will contain the the flow and the node - * identifier. + * Services connection requests. If the data flow management service is unable to provide a current copy of the data flow, then the returned connection response will indicate the node should try + * later. Otherwise, the connection response will contain the the flow and the node identifier. * - * If this instance is configured with a firewall and the request is - * blocked, then the response will not contain a node identifier. + * If this instance is configured with a firewall and the request is blocked, then the response will not contain a node identifier. * * @param request a connection request * @@ -720,14 +734,14 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } /* - * The manager does not have a current copy of the data flow, - * so it will instruct the node to try connecting at a later - * time. Meanwhile, the flow will be locked down from user + * The manager does not have a current copy of the data flow, + * so it will instruct the node to try connecting at a later + * time. Meanwhile, the flow will be locked down from user * changes because the node is marked as connecting. */ /* - * Create try-later response based on flow retrieval delay to give + * Create try-later response based on flow retrieval delay to give * the flow management service a chance to retrieve a curren flow */ final int tryAgainSeconds; @@ -749,20 +763,14 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } /** - * Services reconnection requests for a given node. If the node indicates - * reconnection failure, then the node will be set to disconnected and if - * the node has primary role, then the role will be revoked. Otherwise, a - * reconnection request will be sent to the node, initiating the connection - * handshake. + * Services reconnection requests for a given node. If the node indicates reconnection failure, then the node will be set to disconnected and if the node has primary role, then the role will be + * revoked. Otherwise, a reconnection request will be sent to the node, initiating the connection handshake. * * @param nodeId a node identifier * * @throws UnknownNodeException if the node does not exist - * @throws IllegalNodeReconnectionException if the node cannot be - * reconnected because the node is not disconnected - * @throws NodeReconnectionException if the reconnection message failed to - * be sent or the cluster could not provide a current data flow for the - * reconnection request + * @throws IllegalNodeReconnectionException if the node cannot be reconnected because the node is not disconnected + * @throws NodeReconnectionException if the reconnection message failed to be sent or the cluster could not provide a current data flow for the reconnection request */ @Override public void requestReconnection(final String nodeId, final String userDn) throws UnknownNodeException, IllegalNodeReconnectionException { @@ -946,7 +954,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C final String scheduleStateValue = DomUtils.getChild(taskElement, "scheduledState").getTextContent().trim(); final ScheduledState scheduledState = ScheduledState.valueOf(scheduleStateValue); - + // Reporting Task Properties for (final Element property : DomUtils.getChildElementsByTagName(taskElement, "property")) { final String name = DomUtils.getChildText(property, "name"); @@ -969,21 +977,21 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C final ReportingTask reportingTask = reportingTaskNode.getReportingTask(); final ComponentLog componentLog = new SimpleProcessLogger(taskId, reportingTask); - final ReportingInitializationContext config = new StandardReportingInitializationContext(taskId, taskName, + final ReportingInitializationContext config = new StandardReportingInitializationContext(taskId, taskName, schedulingStrategy, taskSchedulingPeriod, componentLog, this); reportingTask.initialize(config); final String annotationData = DomUtils.getChildText(taskElement, "annotationData"); - if ( annotationData != null ) { + if (annotationData != null) { reportingTaskNode.setAnnotationData(annotationData.trim()); } - + final Map resolvedProps; try (final NarCloseable narCloseable = NarCloseable.withNarLoader()) { resolvedProps = new HashMap<>(); for (final Map.Entry entry : properties.entrySet()) { final PropertyDescriptor descriptor = reportingTask.getPropertyDescriptor(entry.getKey()); - if ( entry.getValue() == null ) { + if (entry.getValue() == null) { resolvedProps.put(descriptor, descriptor.getDefaultValue()); } else { resolvedProps.put(descriptor, entry.getValue()); @@ -992,24 +1000,24 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } for (final Map.Entry entry : resolvedProps.entrySet()) { - if ( entry.getValue() != null ) { + if (entry.getValue() != null) { reportingTaskNode.setProperty(entry.getKey().getName(), entry.getValue()); } } - + final String comments = DomUtils.getChildText(taskElement, "comment"); - if ( comments != null ) { + if (comments != null) { reportingTaskNode.setComments(comments); } reportingTaskNode.setScheduledState(scheduledState); - if ( ScheduledState.RUNNING.equals(scheduledState) ) { - if ( reportingTaskNode.isValid() ) { + if (ScheduledState.RUNNING.equals(scheduledState)) { + if (reportingTaskNode.isValid()) { try { processScheduler.schedule(reportingTaskNode); } catch (final Exception e) { logger.error("Failed to start {} due to {}", reportingTaskNode, e); - if ( logger.isDebugEnabled() ) { + if (logger.isDebugEnabled()) { logger.error("", e); } } @@ -1017,8 +1025,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C logger.error("Failed to start {} because it is invalid due to {}", reportingTaskNode, reportingTaskNode.getValidationErrors()); } } - - + tasks.put(reportingTaskNode.getIdentifier(), reportingTaskNode); } } catch (final SAXException | ParserConfigurationException | IOException | DOMException | NumberFormatException | InitializationException t) { @@ -1031,7 +1038,6 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C return tasks; } - @Override public ReportingTaskNode createReportingTask(final String type, final String id, final boolean firstTimeAdded) throws ReportingTaskInstantiationException { if (type == null) { @@ -1064,16 +1070,16 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C final ReportingTaskNode taskNode = new ClusteredReportingTaskNode(task, id, processScheduler, new ClusteredEventAccess(this), bulletinRepository, controllerServiceProvider, validationContextFactory); taskNode.setName(task.getClass().getSimpleName()); - + reportingTasks.put(id, taskNode); - if ( firstTimeAdded ) { + if (firstTimeAdded) { try (final NarCloseable x = NarCloseable.withNarLoader()) { ReflectionUtils.invokeMethodsWithAnnotation(OnAdded.class, task); } catch (final Exception e) { throw new ComponentLifeCycleException("Failed to invoke On-Added Lifecycle methods of " + task, e); } } - + return taskNode; } @@ -1131,11 +1137,8 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C * @param userDn the DN of the user requesting the disconnection * * @throws UnknownNodeException if the node does not exist - * @throws IllegalNodeDisconnectionException if the node cannot be - * disconnected due to the cluster's state (e.g., node is last connected - * node or node is primary) - * @throws NodeDisconnectionException if the disconnection message fails to - * be sent. + * @throws IllegalNodeDisconnectionException if the node cannot be disconnected due to the cluster's state (e.g., node is last connected node or node is primary) + * @throws NodeDisconnectionException if the disconnection message fails to be sent. */ @Override public void requestDisconnection(final String nodeId, final String userDn) throws UnknownNodeException, IllegalNodeDisconnectionException, NodeDisconnectionException { @@ -1153,8 +1156,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } /** - * Requests a disconnection to the node with the given node ID, but any - * exception thrown is suppressed. + * Requests a disconnection to the node with the given node ID, but any exception thrown is suppressed. * * @param nodeId the node ID */ @@ -1165,28 +1167,19 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } /** - * Issues a disconnection message to the node identified by the given node - * ID. If the node is not known, then a UnknownNodeException is thrown. If - * the node cannot be disconnected due to the cluster's state and - * ignoreLastNodeCheck is false, then a IllegalNodeDisconnectionException is - * thrown. Otherwise, a disconnection message is issued to the node. + * Issues a disconnection message to the node identified by the given node ID. If the node is not known, then a UnknownNodeException is thrown. If the node cannot be disconnected due to the + * cluster's state and ignoreLastNodeCheck is false, then a IllegalNodeDisconnectionException is thrown. Otherwise, a disconnection message is issued to the node. * - * Whether the disconnection message is successfully sent to the node, the - * node is marked as disconnected and if the node is the primary node, then - * the primary role is revoked. + * Whether the disconnection message is successfully sent to the node, the node is marked as disconnected and if the node is the primary node, then the primary role is revoked. * * @param nodeId the ID of the node - * @param ignoreNodeChecks if false, checks will be made to ensure the - * cluster supports the node's disconnection (e.g., the node is not the last - * connected node in the cluster; the node is not the primary); otherwise, - * the request is made regardless of the cluster state + * @param ignoreNodeChecks if false, checks will be made to ensure the cluster supports the node's disconnection (e.g., the node is not the last connected node in the cluster; the node is not the + * primary); otherwise, the request is made regardless of the cluster state * @param explanation * - * @throws IllegalNodeDisconnectionException if the node cannot be - * disconnected due to the cluster's state (e.g., node is last connected - * node or node is primary). Not thrown if ignoreNodeChecks is true. - * @throws NodeDisconnectionException if the disconnection message fails to - * be sent. + * @throws IllegalNodeDisconnectionException if the node cannot be disconnected due to the cluster's state (e.g., node is last connected node or node is primary). Not thrown if ignoreNodeChecks is + * true. + * @throws NodeDisconnectionException if the disconnection message fails to be sent. */ private void requestDisconnection(final NodeIdentifier nodeId, final boolean ignoreNodeChecks, final String explanation) throws IllegalNodeDisconnectionException, NodeDisconnectionException { @@ -1244,8 +1237,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } /** - * Messages the node to have the primary role. If the messaging fails, then - * the node is marked as disconnected. + * Messages the node to have the primary role. If the messaging fails, then the node is marked as disconnected. * * @param nodeId the node ID to assign primary role * @@ -1260,7 +1252,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C msg.setPrimary(true); logger.info("Attempting to assign primary role to node: " + nodeId); - // message + // message senderListener.assignPrimaryRole(msg); logger.info("Assigned primary role to node: " + nodeId); @@ -1289,11 +1281,9 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } /** - * Messages the node with the given node ID to no longer have the primary - * role. If the messaging fails, then the node is marked as disconnected. + * Messages the node with the given node ID to no longer have the primary role. If the messaging fails, then the node is marked as disconnected. * - * @return true if the primary role was revoked from the node; false - * otherwise + * @return true if the primary role was revoked from the node; false otherwise */ private boolean revokePrimaryRole(final NodeIdentifier nodeId) { writeLock.lock(); @@ -1350,8 +1340,10 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C final Node node = getRawNode(msg.getNodeId().getId()); if (node != null) { node.setStatus(Status.DISCONNECTED); - addEvent(msg.getNodeId(), "Node could not join cluster because it failed to start up properly. Setting node to Disconnected. Node reported the following error: " + msg.getExceptionMessage()); - addBulletin(node, Severity.ERROR, "Node could not join cluster because it failed to start up properly. Setting node to Disconnected. Node reported the following error: " + msg.getExceptionMessage()); + addEvent(msg.getNodeId(), "Node could not join cluster because it failed to start up properly. Setting node to Disconnected. Node reported " + + "the following error: " + msg.getExceptionMessage()); + addBulletin(node, Severity.ERROR, "Node could not join cluster because it failed to start up properly. Setting node to Disconnected. Node " + + "reported the following error: " + msg.getExceptionMessage()); } } finally { writeLock.unlock("handleControllerStartupFailure"); @@ -1372,18 +1364,10 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C writeLock.unlock("handleControllerStartupFailure"); } } - - /** - * Adds an instance of a specified controller service. - * - * @param type - * @param id - * @param properties - * @return - */ + @Override public ControllerServiceNode createControllerService(final String type, final String id, final boolean firstTimeAdded) { - return controllerServiceProvider.createControllerService(type, id, firstTimeAdded); + return controllerServiceProvider.createControllerService(type, id, firstTimeAdded); } @Override @@ -1410,82 +1394,80 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C public boolean isControllerServiceEnabling(final String serviceIdentifier) { return controllerServiceProvider.isControllerServiceEnabling(serviceIdentifier); } - + @Override public String getControllerServiceName(final String serviceIdentifier) { - return controllerServiceProvider.getControllerServiceName(serviceIdentifier); + return controllerServiceProvider.getControllerServiceName(serviceIdentifier); } @Override public void removeControllerService(final ControllerServiceNode serviceNode) { controllerServiceProvider.removeControllerService(serviceNode); } - @Override public void enableControllerService(final ControllerServiceNode serviceNode) { controllerServiceProvider.enableControllerService(serviceNode); } - + @Override public void enableControllerServices(final Collection serviceNodes) { controllerServiceProvider.enableControllerServices(serviceNodes); } - + @Override public void disableControllerService(final ControllerServiceNode serviceNode) { controllerServiceProvider.disableControllerService(serviceNode); } - + @Override public Set getAllControllerServices() { - return controllerServiceProvider.getAllControllerServices(); + return controllerServiceProvider.getAllControllerServices(); } - - + @Override public void disableReferencingServices(final ControllerServiceNode serviceNode) { controllerServiceProvider.disableReferencingServices(serviceNode); } - + @Override public void enableReferencingServices(final ControllerServiceNode serviceNode) { controllerServiceProvider.enableReferencingServices(serviceNode); } - + @Override public void scheduleReferencingComponents(final ControllerServiceNode serviceNode) { controllerServiceProvider.scheduleReferencingComponents(serviceNode); } - + @Override public void unscheduleReferencingComponents(final ControllerServiceNode serviceNode) { controllerServiceProvider.unscheduleReferencingComponents(serviceNode); } - + @Override public void verifyCanEnableReferencingServices(final ControllerServiceNode serviceNode) { controllerServiceProvider.verifyCanEnableReferencingServices(serviceNode); } - + @Override public void verifyCanScheduleReferencingComponents(final ControllerServiceNode serviceNode) { controllerServiceProvider.verifyCanScheduleReferencingComponents(serviceNode); } - + @Override public void verifyCanDisableReferencingServices(final ControllerServiceNode serviceNode) { controllerServiceProvider.verifyCanDisableReferencingServices(serviceNode); } - + @Override public void verifyCanStopReferencingComponents(final ControllerServiceNode serviceNode) { controllerServiceProvider.verifyCanStopReferencingComponents(serviceNode); } - + private byte[] serialize(final Document doc) throws TransformerException { - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - final DOMSource domSource = new DOMSource(doc); + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final DOMSource domSource = new DOMSource(doc); final StreamResult streamResult = new StreamResult(baos); // configure the transformer and convert the DOM @@ -1498,91 +1480,89 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C transformer.transform(domSource, streamResult); return baos.toByteArray(); } - + private byte[] serializeControllerServices() throws ParserConfigurationException, TransformerException { - final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); final DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); final Document document = docBuilder.newDocument(); - final Element rootElement = document.createElement("controllerServices"); - document.appendChild(rootElement); - - for ( final ControllerServiceNode serviceNode : getAllControllerServices() ) { - StandardFlowSerializer.addControllerService(rootElement, serviceNode, encryptor); - } - - return serialize(document); + final Element rootElement = document.createElement("controllerServices"); + document.appendChild(rootElement); + + for (final ControllerServiceNode serviceNode : getAllControllerServices()) { + StandardFlowSerializer.addControllerService(rootElement, serviceNode, encryptor); + } + + return serialize(document); } - + private byte[] serializeReportingTasks() throws ParserConfigurationException, TransformerException { - final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); final DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); final Document document = docBuilder.newDocument(); - final Element rootElement = document.createElement("reportingTasks"); - document.appendChild(rootElement); - - for ( final ReportingTaskNode taskNode : getAllReportingTasks() ) { - StandardFlowSerializer.addReportingTask(rootElement, taskNode, encryptor); - } - - return serialize(document); + final Element rootElement = document.createElement("reportingTasks"); + document.appendChild(rootElement); + + for (final ReportingTaskNode taskNode : getAllReportingTasks()) { + StandardFlowSerializer.addReportingTask(rootElement, taskNode, encryptor); + } + + return serialize(document); } - - + public void saveControllerServices() { - try { - dataFlowManagementService.updateControllerServices(serializeControllerServices()); - } catch (final Exception e) { - logger.error("Failed to save changes to NCM's Controller Services; changes may be lost on restart due to " + e); - if ( logger.isDebugEnabled() ) { - logger.error("", e); - } - - getBulletinRepository().addBulletin(BulletinFactory.createBulletin("Controller Services", Severity.ERROR.name(), - "Failed to save changes to NCM's Controller Services; changes may be lost on restart. See logs for more details.")); - } + try { + dataFlowManagementService.updateControllerServices(serializeControllerServices()); + } catch (final Exception e) { + logger.error("Failed to save changes to NCM's Controller Services; changes may be lost on restart due to " + e); + if (logger.isDebugEnabled()) { + logger.error("", e); + } + + getBulletinRepository().addBulletin(BulletinFactory.createBulletin("Controller Services", Severity.ERROR.name(), + "Failed to save changes to NCM's Controller Services; changes may be lost on restart. See logs for more details.")); + } } - + public void saveReportingTasks() { - try { - dataFlowManagementService.updateReportingTasks(serializeReportingTasks()); - } catch (final Exception e) { - logger.error("Failed to save changes to NCM's Reporting Tasks; changes may be lost on restart due to " + e); - if ( logger.isDebugEnabled() ) { - logger.error("", e); - } - - getBulletinRepository().addBulletin(BulletinFactory.createBulletin("Reporting Tasks", Severity.ERROR.name(), - "Failed to save changes to NCM's Reporting Tasks; changes may be lost on restart. See logs for more details.")); - } + try { + dataFlowManagementService.updateReportingTasks(serializeReportingTasks()); + } catch (final Exception e) { + logger.error("Failed to save changes to NCM's Reporting Tasks; changes may be lost on restart due to " + e); + if (logger.isDebugEnabled()) { + logger.error("", e); + } + + getBulletinRepository().addBulletin(BulletinFactory.createBulletin("Reporting Tasks", Severity.ERROR.name(), + "Failed to save changes to NCM's Reporting Tasks; changes may be lost on restart. See logs for more details.")); + } } @Override public Set getAllReportingTasks() { - readLock.lock(); - try { - return new HashSet<>(reportingTasks.values()); - } finally { - readLock.unlock("getReportingTasks"); - } + readLock.lock(); + try { + return new HashSet<>(reportingTasks.values()); + } finally { + readLock.unlock("getReportingTasks"); + } } @Override public ReportingTaskNode getReportingTaskNode(final String taskId) { - readLock.lock(); - try { - return reportingTasks.get(taskId); - } finally { - readLock.unlock("getReportingTaskNode"); - } + readLock.lock(); + try { + return reportingTasks.get(taskId); + } finally { + readLock.unlock("getReportingTaskNode"); + } } @Override public void startReportingTask(final ReportingTaskNode reportingTaskNode) { reportingTaskNode.verifyCanStart(); - processScheduler.schedule(reportingTaskNode); + processScheduler.schedule(reportingTaskNode); } - @Override public void stopReportingTask(final ReportingTaskNode reportingTaskNode) { reportingTaskNode.verifyCanStop(); @@ -1591,56 +1571,54 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C @Override public void removeReportingTask(final ReportingTaskNode reportingTaskNode) { - writeLock.lock(); - try { - final ReportingTaskNode existing = reportingTasks.get(reportingTaskNode.getIdentifier()); - if ( existing == null || existing != reportingTaskNode ) { - throw new IllegalStateException("Reporting Task " + reportingTaskNode + " does not exist in this Flow"); - } - - reportingTaskNode.verifyCanDelete(); - - try (final NarCloseable x = NarCloseable.withNarLoader()) { - ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnRemoved.class, reportingTaskNode.getReportingTask(), reportingTaskNode.getConfigurationContext()); - } - - for ( final Map.Entry entry : reportingTaskNode.getProperties().entrySet() ) { - final PropertyDescriptor descriptor = entry.getKey(); - if (descriptor.getControllerServiceDefinition() != null ) { - final String value = entry.getValue() == null ? descriptor.getDefaultValue() : entry.getValue(); - if ( value != null ) { - final ControllerServiceNode serviceNode = controllerServiceProvider.getControllerServiceNode(value); - if ( serviceNode != null ) { - serviceNode.removeReference(reportingTaskNode); - } - } - } - } - - reportingTasks.remove(reportingTaskNode.getIdentifier()); - } finally { - writeLock.unlock("removeReportingTask"); - } + writeLock.lock(); + try { + final ReportingTaskNode existing = reportingTasks.get(reportingTaskNode.getIdentifier()); + if (existing == null || existing != reportingTaskNode) { + throw new IllegalStateException("Reporting Task " + reportingTaskNode + " does not exist in this Flow"); + } + + reportingTaskNode.verifyCanDelete(); + + try (final NarCloseable x = NarCloseable.withNarLoader()) { + ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnRemoved.class, reportingTaskNode.getReportingTask(), reportingTaskNode.getConfigurationContext()); + } + + for (final Map.Entry entry : reportingTaskNode.getProperties().entrySet()) { + final PropertyDescriptor descriptor = entry.getKey(); + if (descriptor.getControllerServiceDefinition() != null) { + final String value = entry.getValue() == null ? descriptor.getDefaultValue() : entry.getValue(); + if (value != null) { + final ControllerServiceNode serviceNode = controllerServiceProvider.getControllerServiceNode(value); + if (serviceNode != null) { + serviceNode.removeReference(reportingTaskNode); + } + } + } + } + + reportingTasks.remove(reportingTaskNode.getIdentifier()); + } finally { + writeLock.unlock("removeReportingTask"); + } } - - + @Override public void disableReportingTask(final ReportingTaskNode reportingTask) { reportingTask.verifyCanDisable(); processScheduler.disableReportingTask(reportingTask); } - + @Override public void enableReportingTask(final ReportingTaskNode reportingTask) { reportingTask.verifyCanEnable(); processScheduler.enableReportingTask(reportingTask); } - - + /** * Handle a bulletins message. * - * @param bulletins + * @param bulletins bulletins */ public void handleBulletins(final NodeBulletins bulletins) { final NodeIdentifier nodeIdentifier = bulletins.getNodeIdentifier(); @@ -1655,15 +1633,9 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } /** - * Handles a node's heartbeat. If this heartbeat is a node's first heartbeat - * since its connection request, then the manager will mark the node as - * connected. If the node was previously disconnected due to a lack of - * heartbeat, then a reconnection request is issued. If the node was - * disconnected for other reasons, then a disconnection request is issued. - * If this instance is configured with a firewall and the heartbeat is - * blocked, then a disconnection request is issued. - * - * @param heartbeat + * Handles a node's heartbeat. If this heartbeat is a node's first heartbeat since its connection request, then the manager will mark the node as connected. If the node was previously disconnected + * due to a lack of heartbeat, then a reconnection request is issued. If the node was disconnected for other reasons, then a disconnection request is issued. If this instance is configured with a + * firewall and the heartbeat is blocked, then a disconnection request is issued. */ @Override public void handleHeartbeat(final Heartbeat heartbeat) { @@ -1677,9 +1649,8 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C /* * Processing a heartbeat requires a write lock, which may take a while * to obtain. Only the last heartbeat is necessary to process per node. - * Futhermore, since many could pile up, heartbeats are processed in + * Futhermore, since many could pile up, heartbeats are processed in * bulk. - * * The below queue stores the pending heartbeats. */ pendingHeartbeats.add(heartbeat); @@ -1756,7 +1727,8 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } else if (heartbeatIndicatesNotYetConnected) { if (Status.CONNECTED == node.getStatus()) { // record event - addEvent(node.getNodeId(), "Received heartbeat from node that thinks it is not yet part of the cluster, though the Manager thought it was. Marking as Disconnected and issuing reconnection request."); + addEvent(node.getNodeId(), "Received heartbeat from node that thinks it is not yet part of the cluster, though the Manager thought it " + + "was. Marking as Disconnected and issuing reconnection request."); // record heartbeat node.setHeartbeat(null); @@ -1815,23 +1787,10 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C // record heartbeat node.setHeartbeat(mostRecentHeartbeat); - - ComponentStatusRepository statusRepository = componentMetricsRepositoryMap.get(node.getNodeId()); - if (statusRepository == null) { - statusRepository = createComponentStatusRepository(); - componentMetricsRepositoryMap.put(node.getNodeId(), statusRepository); - } - - // If it's been a while since we've captured, capture this metric. - final Date lastCaptureDate = statusRepository.getLastCaptureDate(); - final long millisSinceLastCapture = (lastCaptureDate == null) ? Long.MAX_VALUE : (System.currentTimeMillis() - lastCaptureDate.getTime()); - - if (millisSinceLastCapture > componentStatusSnapshotMillis) { - statusRepository.capture(node.getHeartbeatPayload().getProcessGroupStatus()); - } } } catch (final Exception e) { - logger.error("Failed to process heartbeat from {}:{} due to {}", mostRecentHeartbeat.getNodeIdentifier().getApiAddress(), mostRecentHeartbeat.getNodeIdentifier().getApiPort(), e.toString()); + logger.error("Failed to process heartbeat from {}:{} due to {}", + mostRecentHeartbeat.getNodeIdentifier().getApiAddress(), mostRecentHeartbeat.getNodeIdentifier().getApiPort(), e.toString()); if (logger.isDebugEnabled()) { logger.error("", e); } @@ -2031,13 +1990,15 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C @Override public NodeResponse applyRequest(final String method, final URI uri, final Map> parameters, final Map headers) - throws NoConnectedNodesException, NoResponseFromNodesException, UriConstructionException, ConnectingNodeMutableRequestException, DisconnectedNodeMutableRequestException, SafeModeMutableRequestException { + throws NoConnectedNodesException, NoResponseFromNodesException, UriConstructionException, + ConnectingNodeMutableRequestException, DisconnectedNodeMutableRequestException, SafeModeMutableRequestException { return applyRequest(method, uri, parameters, headers, getNodeIds(Status.CONNECTED)); } @Override public NodeResponse applyRequest(final String method, final URI uri, final Map> parameters, final Map headers, final Set nodeIdentifiers) - throws NoConnectedNodesException, NoResponseFromNodesException, UriConstructionException, ConnectingNodeMutableRequestException, DisconnectedNodeMutableRequestException, SafeModeMutableRequestException { + throws NoConnectedNodesException, NoResponseFromNodesException, UriConstructionException, + ConnectingNodeMutableRequestException, DisconnectedNodeMutableRequestException, SafeModeMutableRequestException { final boolean mutableRequest = canChangeNodeState(method, uri); final ClusterManagerLock lock = mutableRequest ? writeLock : readLock; @@ -2073,13 +2034,15 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C @Override public NodeResponse applyRequest(final String method, final URI uri, final Object entity, final Map headers) - throws NoConnectedNodesException, NoResponseFromNodesException, UriConstructionException, ConnectingNodeMutableRequestException, DisconnectedNodeMutableRequestException, SafeModeMutableRequestException { + throws NoConnectedNodesException, NoResponseFromNodesException, UriConstructionException, + ConnectingNodeMutableRequestException, DisconnectedNodeMutableRequestException, SafeModeMutableRequestException { return applyRequest(method, uri, entity, headers, getNodeIds(Status.CONNECTED)); } @Override public NodeResponse applyRequest(final String method, final URI uri, final Object entity, final Map headers, final Set nodeIdentifiers) - throws NoConnectedNodesException, NoResponseFromNodesException, UriConstructionException, ConnectingNodeMutableRequestException, DisconnectedNodeMutableRequestException, SafeModeMutableRequestException { + throws NoConnectedNodesException, NoResponseFromNodesException, UriConstructionException, + ConnectingNodeMutableRequestException, DisconnectedNodeMutableRequestException, SafeModeMutableRequestException { final boolean mutableRequest = canChangeNodeState(method, uri); final ClusterManagerLock lock = mutableRequest ? writeLock : readLock; @@ -2258,7 +2221,9 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } // requires write lock to already be acquired unless method cannot change node state - private NodeResponse federateRequest(final String method, final URI uri, final Map> parameters, final Object entity, final Map headers, final Set nodeIds) throws UriConstructionException { + private NodeResponse federateRequest( + final String method, final URI uri, final Map> parameters, final Object entity, final Map headers, final Set nodeIds) + throws UriConstructionException { // ensure some nodes are connected if (nodeIds.isEmpty()) { throw new NoConnectedNodesException("Cannot apply " + method + " request to " + uri + " because there are currently no connected Nodes"); @@ -2336,7 +2301,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C // merge the response final NodeResponse clientResponse = mergeResponses(uri, method, nodeResponses, mutableRequest); holder.set(clientResponse); - + // if we have a response get the updated cluster context for auditing and revision updating Revision updatedRevision = null; if (mutableRequest && clientResponse != null) { @@ -2367,18 +2332,18 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C logger.warn("Classpath issue detected because failed to deserialize cluster context from node response due to: " + cnfe, cnfe); } } - + return updatedRevision; } }; - + // federate the request and lock on the revision if (mutableRequest) { optimisticLockingManager.setRevision(federateRequest); } else { federateRequest.execute(optimisticLockingManager.getLastModification().getRevision()); } - + return holder.get(); } @@ -2387,7 +2352,8 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } private static boolean isProcessorEndpoint(final URI uri, final String method) { - if (("GET".equalsIgnoreCase(method) || "PUT".equalsIgnoreCase(method)) && (PROCESSOR_URI_PATTERN.matcher(uri.getPath()).matches() || CLUSTER_PROCESSOR_URI_PATTERN.matcher(uri.getPath()).matches()) ) { + if (("GET".equalsIgnoreCase(method) || "PUT".equalsIgnoreCase(method)) + && (PROCESSOR_URI_PATTERN.matcher(uri.getPath()).matches() || CLUSTER_PROCESSOR_URI_PATTERN.matcher(uri.getPath()).matches())) { return true; } else if ("POST".equalsIgnoreCase(method) && PROCESSORS_URI_PATTERN.matcher(uri.getPath()).matches()) { return true; @@ -2434,11 +2400,11 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C private static boolean isProvenanceEventEndpoint(final URI uri, final String method) { return "GET".equalsIgnoreCase(method) && PROVENANCE_EVENT_URI.matcher(uri.getPath()).matches(); } - + private static boolean isControllerServicesEndpoint(final URI uri, final String method) { return "GET".equalsIgnoreCase(method) && CONTROLLER_SERVICES_URI.equals(uri.getPath()); } - + private static boolean isControllerServiceEndpoint(final URI uri, final String method) { if (("GET".equalsIgnoreCase(method) || "PUT".equalsIgnoreCase(method)) && CONTROLLER_SERVICE_URI_PATTERN.matcher(uri.getPath()).matches()) { return true; @@ -2448,19 +2414,19 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C return false; } - + private static boolean isControllerServiceReferenceEndpoint(final URI uri, final String method) { if (("GET".equalsIgnoreCase(method) || "PUT".equalsIgnoreCase(method)) && CONTROLLER_SERVICE_REFERENCES_URI_PATTERN.matcher(uri.getPath()).matches()) { return true; } - + return false; } - + private static boolean isReportingTasksEndpoint(final URI uri, final String method) { return "GET".equalsIgnoreCase(method) && REPORTING_TASKS_URI.equals(uri.getPath()); } - + private static boolean isReportingTaskEndpoint(final URI uri, final String method) { if (("GET".equalsIgnoreCase(method) || "PUT".equalsIgnoreCase(method)) && REPORTING_TASK_URI_PATTERN.matcher(uri.getPath()).matches()) { return true; @@ -2661,15 +2627,16 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C remoteProcessGroup.setAuthorizationIssues(mergedAuthorizationIssues); } } - - private void mergeControllerServiceReferences(final Set referencingComponents, final Map> referencingComponentMap) { + + private void mergeControllerServiceReferences( + final Set referencingComponents, final Map> referencingComponentMap) { final Map activeThreadCounts = new HashMap<>(); final Map states = new HashMap<>(); for (final Map.Entry> nodeEntry : referencingComponentMap.entrySet()) { final Set nodeReferencingComponents = nodeEntry.getValue(); // go through all the nodes referencing components - if ( nodeReferencingComponents != null ) { + if (nodeReferencingComponents != null) { for (final ControllerServiceReferencingComponentDTO nodeReferencingComponent : nodeReferencingComponents) { // handle active thread counts if (nodeReferencingComponent.getActiveThreadCount() != null && nodeReferencingComponent.getActiveThreadCount() > 0) { @@ -2680,7 +2647,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C activeThreadCounts.put(nodeReferencingComponent.getId(), nodeReferencingComponent.getActiveThreadCount() + current); } } - + // handle controller service state final String state = states.get(nodeReferencingComponent.getId()); if (state == null) { @@ -2692,7 +2659,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } } } - } + } // go through each referencing components for (final ControllerServiceReferencingComponentDTO referencingComponent : referencingComponents) { @@ -2700,24 +2667,24 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C if (activeThreadCount != null) { referencingComponent.setActiveThreadCount(activeThreadCount); } - + final String state = states.get(referencingComponent.getId()); if (state != null) { referencingComponent.setState(state); } } } - + private void mergeControllerService(final ControllerServiceDTO controllerService, final Map controllerServiceMap) { final Map> validationErrorMap = new HashMap<>(); final Set referencingComponents = controllerService.getReferencingComponents(); final Map> nodeReferencingComponentsMap = new HashMap<>(); - + String state = null; for (final Map.Entry nodeEntry : controllerServiceMap.entrySet()) { final NodeIdentifier nodeId = nodeEntry.getKey(); final ControllerServiceDTO nodeControllerService = nodeEntry.getValue(); - + if (state == null) { if (ControllerServiceState.DISABLING.name().equals(nodeControllerService.getState())) { state = ControllerServiceState.DISABLING.name(); @@ -2725,27 +2692,27 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C state = ControllerServiceState.ENABLING.name(); } } - + for (final ControllerServiceReferencingComponentDTO nodeReferencingComponents : nodeControllerService.getReferencingComponents()) { nodeReferencingComponentsMap.put(nodeId, nodeReferencingComponents.getReferencingComponents()); } - + // merge the validation errors mergeValidationErrors(validationErrorMap, nodeId, nodeControllerService.getValidationErrors()); } - + // merge the referencing components mergeControllerServiceReferences(referencingComponents, nodeReferencingComponentsMap); - + // store the 'transition' state is applicable if (state != null) { controllerService.setState(state); } - + // set the merged the validation errors controllerService.setValidationErrors(normalizedMergedValidationErrors(validationErrorMap, controllerServiceMap.size())); } - + private void mergeReportingTask(final ReportingTaskDTO reportingTask, final Map reportingTaskMap) { final Map> validationErrorMap = new HashMap<>(); @@ -2757,24 +2724,24 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C if (nodeReportingTask.getActiveThreadCount() != null) { activeThreadCount += nodeReportingTask.getActiveThreadCount(); } - + // merge the validation errors mergeValidationErrors(validationErrorMap, nodeId, nodeReportingTask.getValidationErrors()); } // set the merged active thread counts reportingTask.setActiveThreadCount(activeThreadCount); - + // set the merged the validation errors reportingTask.setValidationErrors(normalizedMergedValidationErrors(validationErrorMap, reportingTaskMap.size())); } /** * Merges the validation errors into the specified map, recording the corresponding node identifier. - * - * @param validationErrorMap - * @param nodeId - * @param nodeValidationErrors + * + * @param validationErrorMap map + * @param nodeId id + * @param nodeValidationErrors errors */ public void mergeValidationErrors(final Map> validationErrorMap, final NodeIdentifier nodeId, final Collection nodeValidationErrors) { if (nodeValidationErrors != null) { @@ -2788,13 +2755,13 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } } } - + /** * Normalizes the validation errors by prepending the corresponding nodes when the error does not exist across all nodes. - * - * @param validationErrorMap - * @param totalNodes - * @return + * + * @param validationErrorMap map + * @param totalNodes total + * @return normalized errors */ public Set normalizedMergedValidationErrors(final Map> validationErrorMap, int totalNodes) { final Set normalizedValidationErrors = new HashSet<>(); @@ -2812,7 +2779,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } return normalizedValidationErrors; } - + // requires write lock to be already acquired unless request is not mutable private NodeResponse mergeResponses(final URI uri, final String method, final Set nodeResponses, final boolean mutableRequest) { // holds the one response of all the node responses to return to the client @@ -2848,7 +2815,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C final boolean hasClientResponse = clientResponse != null; final boolean hasSuccessfulClientResponse = hasClientResponse && clientResponse.is2xx(); - // drain the responses from the socket for those responses not being sent to the client + // drain the responses from the socket for those responses not being sent to the client final Set nodeResponsesToDrain = new HashSet<>(updatedNodesMap.values()); nodeResponsesToDrain.remove(clientResponse); @@ -3105,7 +3072,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } else if (hasSuccessfulClientResponse && isControllerServiceEndpoint(uri, method)) { final ControllerServiceEntity responseEntity = clientResponse.getClientResponse().getEntity(ControllerServiceEntity.class); final ControllerServiceDTO controllerService = responseEntity.getControllerService(); - + final Map resultsMap = new HashMap<>(); for (final NodeResponse nodeResponse : updatedNodesMap.values()) { if (problematicNodeResponses.contains(nodeResponse)) { @@ -3118,12 +3085,12 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C resultsMap.put(nodeResponse.getNodeId(), nodeControllerService); } mergeControllerService(controllerService, resultsMap); - + clientResponse = new NodeResponse(clientResponse, responseEntity); } else if (hasSuccessfulClientResponse && isControllerServicesEndpoint(uri, method)) { final ControllerServicesEntity responseEntity = clientResponse.getClientResponse().getEntity(ControllerServicesEntity.class); final Set controllerServices = responseEntity.getControllerServices(); - + final Map> controllerServiceMap = new HashMap<>(); for (final NodeResponse nodeResponse : updatedNodesMap.values()) { if (problematicNodeResponses.contains(nodeResponse)) { @@ -3156,25 +3123,26 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } else if (hasSuccessfulClientResponse && isControllerServiceReferenceEndpoint(uri, method)) { final ControllerServiceReferencingComponentsEntity responseEntity = clientResponse.getClientResponse().getEntity(ControllerServiceReferencingComponentsEntity.class); final Set referencingComponents = responseEntity.getControllerServiceReferencingComponents(); - + final Map> resultsMap = new HashMap<>(); for (final NodeResponse nodeResponse : updatedNodesMap.values()) { if (problematicNodeResponses.contains(nodeResponse)) { continue; } - final ControllerServiceReferencingComponentsEntity nodeResponseEntity = (nodeResponse == clientResponse) ? responseEntity : nodeResponse.getClientResponse().getEntity(ControllerServiceReferencingComponentsEntity.class); + final ControllerServiceReferencingComponentsEntity nodeResponseEntity = + (nodeResponse == clientResponse) ? responseEntity : nodeResponse.getClientResponse().getEntity(ControllerServiceReferencingComponentsEntity.class); final Set nodeReferencingComponents = nodeResponseEntity.getControllerServiceReferencingComponents(); resultsMap.put(nodeResponse.getNodeId(), nodeReferencingComponents); } mergeControllerServiceReferences(referencingComponents, resultsMap); - + clientResponse = new NodeResponse(clientResponse, responseEntity); } else if (hasSuccessfulClientResponse && isReportingTaskEndpoint(uri, method)) { final ReportingTaskEntity responseEntity = clientResponse.getClientResponse().getEntity(ReportingTaskEntity.class); final ReportingTaskDTO reportingTask = responseEntity.getReportingTask(); - + final Map resultsMap = new HashMap<>(); for (final NodeResponse nodeResponse : updatedNodesMap.values()) { if (problematicNodeResponses.contains(nodeResponse)) { @@ -3187,12 +3155,12 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C resultsMap.put(nodeResponse.getNodeId(), nodeReportingTask); } mergeReportingTask(reportingTask, resultsMap); - + clientResponse = new NodeResponse(clientResponse, responseEntity); } else if (hasSuccessfulClientResponse && isReportingTasksEndpoint(uri, method)) { final ReportingTasksEntity responseEntity = clientResponse.getClientResponse().getEntity(ReportingTasksEntity.class); final Set reportingTaskSet = responseEntity.getReportingTasks(); - + final Map> reportingTaskMap = new HashMap<>(); for (final NodeResponse nodeResponse : updatedNodesMap.values()) { if (problematicNodeResponses.contains(nodeResponse)) { @@ -3229,9 +3197,9 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } /* - * Nodes that encountered issues handling the request are marked as - * disconnected for mutable requests (e.g., post, put, delete). For - * other requests (e.g., get, head), the nodes remain in their current + * Nodes that encountered issues handling the request are marked as + * disconnected for mutable requests (e.g., post, put, delete). For + * other requests (e.g., get, head), the nodes remain in their current * state even if they had problems handling the request. */ if (mutableRequest) { @@ -3246,7 +3214,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C // mark flow as stale since this request could have changed the flow notifyDataFlowManagmentServiceOfFlowStateChange(PersistedFlowState.STALE); - // disconnect problematic nodes + // disconnect problematic nodes if (!problematicNodeResponses.isEmpty()) { if (problematicNodeResponses.size() < nodeResponses.size()) { logger.warn(String.format("One or more nodes failed to process URI '%s'. Requesting each node to disconnect from cluster.", uri)); @@ -3261,8 +3229,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } /** - * Drains the node responses off of the socket to ensure that the socket is - * appropriately cleaned-up. + * Drains the node responses off of the socket to ensure that the socket is appropriately cleaned-up. * * @param nodeResponses the collection of node responses */ @@ -3299,11 +3266,8 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } /** - * A helper method to disconnect nodes that returned unsuccessful HTTP - * responses because of a replicated request. Disconnection requests are - * sent concurrently. + * A helper method to disconnect nodes that returned unsuccessful HTTP responses because of a replicated request. Disconnection requests are sent concurrently. * - * @param nodeResponses */ private void disconnectNodes(final Set nodeResponses, final String explanation) { // return fast if nothing to do @@ -3349,14 +3313,11 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } /** - * Returns false if an internal protocol message was received by a node - * listed in the firewall. If no firewall is configured, then false is - * always returned. + * Returns false if an internal protocol message was received by a node listed in the firewall. If no firewall is configured, then false is always returned. * * @param ip the IP of the remote machine * - * @return false if the IP is listed in the firewall or if the firewall is - * not configured; true otherwise + * @return false if the IP is listed in the firewall or if the firewall is not configured; true otherwise */ private boolean isBlockedByFirewall(final String ip) { if (isFirewallConfigured()) { @@ -3403,10 +3364,8 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } /** - * Resolves a proposed node identifier to a node identifier that the manager - * approves. If the proposed node identifier conflicts with an existing node - * identifier, then an approved node identifier is generated and returned to - * the caller. + * Resolves a proposed node identifier to a node identifier that the manager approves. If the proposed node identifier conflicts with an existing node identifier, then an approved node identifier + * is generated and returned to the caller. * * @param proposedNodeId a proposed identifier * @@ -3565,11 +3524,8 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } /** - * This timer task simply processes any pending heartbeats. This timer task - * is not strictly needed, as HeartbeatMonitoringTimerTask will do this. - * However, this task is scheduled much more frequently and by processing - * the heartbeats more frequently, the stats that we report have less of a - * delay. + * This timer task simply processes any pending heartbeats. This timer task is not strictly needed, as HeartbeatMonitoringTimerTask will do this. However, this task is scheduled much more + * frequently and by processing the heartbeats more frequently, the stats that we report have less of a delay. */ private class ProcessPendingHeartbeatsTask extends TimerTask { @@ -3585,13 +3541,9 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } /** - * A timer task to detect nodes that have not sent a heartbeat in a while. - * The "problem" nodes are marked as disconnected due to lack of heartbeat - * by the task. No disconnection request is sent to the node. This is - * because either the node is not functioning in which case sending the - * request is futile or the node is running a bit slow. In the latter case, - * we'll wait for the next heartbeat and send a reconnection request when we - * process the heartbeat in the heartbeatHandler() method. + * A timer task to detect nodes that have not sent a heartbeat in a while. The "problem" nodes are marked as disconnected due to lack of heartbeat by the task. No disconnection request is sent to + * the node. This is because either the node is not functioning in which case sending the request is futile or the node is running a bit slow. In the latter case, we'll wait for the next heartbeat + * and send a reconnection request when we process the heartbeat in the heartbeatHandler() method. */ private class HeartbeatMonitoringTimerTask extends TimerTask { @@ -3883,11 +3835,11 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C // Aggregate the snapshots final List aggregatedSnapshotDtos = new ArrayList<>(); for (final Map.Entry> entry : snapshotsToAggregate.entrySet()) { - final StatusSnapshotDTO dto = new StatusSnapshotDTO(); - dto.setTimestamp(entry.getKey()); - final List snapshots = entry.getValue(); final StatusSnapshot reducedSnapshot = snapshots.get(0).getValueReducer().reduce(snapshots); + + final StatusSnapshotDTO dto = new StatusSnapshotDTO(); + dto.setTimestamp(reducedSnapshot.getTimestamp()); dto.setStatusMetrics(StatusHistoryUtil.createStatusSnapshotDto(reducedSnapshot).getStatusMetrics()); aggregatedSnapshotDtos.add(dto); diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/node/Node.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/node/Node.java index 84565da137..95da615092 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/node/Node.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/node/Node.java @@ -27,15 +27,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Represents a connected flow controller. Nodes always have an immutable - * identifier and a status. The status may be changed, but never null. + * Represents a connected flow controller. Nodes always have an immutable identifier and a status. The status may be changed, but never null. * * A Node may be cloned, but the cloning is a shallow copy of the instance. * - * This class overrides hashCode and equals and considers two instances to be - * equal if they have the equal NodeIdentifiers. + * This class overrides hashCode and equals and considers two instances to be equal if they have the equal NodeIdentifiers. * - * @author unattributed */ public class Node implements Cloneable, Comparable { @@ -44,19 +41,12 @@ public class Node implements Cloneable, Comparable { /** * The semantics of a Node status are as follows: *
      - *
    • CONNECTED -- a flow controller that is connected to the cluster. A - * connecting node transitions to connected after the cluster receives the - * flow controller's first heartbeat. A connected node can transition to - * disconnecting.
    • - *
    • CONNECTING -- a flow controller has issued a connection request to - * the cluster, but has not yet sent a heartbeat. A connecting node can - * transition to disconnecting or connected. The cluster will not accept any - * external requests to change the flow while any node is connecting.
    • - *
    • DISCONNECTED -- a flow controller that is not connected to the - * cluster. A disconnected node can transition to connecting.
    • - *
    • DISCONNECTING -- a flow controller that is in the process of - * disconnecting from the cluster. A disconnecting node will always - * transition to disconnected.
    • + *
    • CONNECTED -- a flow controller that is connected to the cluster. A connecting node transitions to connected after the cluster receives the flow controller's first heartbeat. A connected + * node can transition to disconnecting.
    • + *
    • CONNECTING -- a flow controller has issued a connection request to the cluster, but has not yet sent a heartbeat. A connecting node can transition to disconnecting or connected. The cluster + * will not accept any external requests to change the flow while any node is connecting.
    • + *
    • DISCONNECTED -- a flow controller that is not connected to the cluster. A disconnected node can transition to connecting.
    • + *
    • DISCONNECTING -- a flow controller that is in the process of disconnecting from the cluster. A disconnecting node will always transition to disconnected.
    • *
    */ public static enum Status { @@ -93,8 +83,7 @@ public class Node implements Cloneable, Comparable { private AtomicLong connectionRequestedTimestamp = new AtomicLong(0L); /** - * a flag to indicate this node was disconnected because of a lack of - * heartbeat + * a flag to indicate this node was disconnected because of a lack of heartbeat */ private boolean heartbeatDisconnection; @@ -156,31 +145,27 @@ public class Node implements Cloneable, Comparable { } /** - * Sets the time when the connection request for this node was last - * received. + * Sets the time when the connection request for this node was last received. * * This method is thread-safe and may be called without obtaining any lock. * - * @param connectionRequestedTimestamp + * @param connectionRequestedTimestamp timestamp */ public void setConnectionRequestedTimestamp(long connectionRequestedTimestamp) { this.connectionRequestedTimestamp.set(connectionRequestedTimestamp); } /** - * Returns true if the node was disconnected due to lack of heartbeat; false - * otherwise. + * Returns true if the node was disconnected due to lack of heartbeat; false otherwise. * - * @return true if the node was disconnected due to lack of heartbeat; false - * otherwise. + * @return true if the node was disconnected due to lack of heartbeat; false otherwise. */ public boolean isHeartbeatDisconnection() { return heartbeatDisconnection; } /** - * Sets the status to disconnected and flags the node as being disconnected - * by lack of heartbeat. + * Sets the status to disconnected and flags the node as being disconnected by lack of heartbeat. */ public void setHeartbeatDisconnection() { setStatus(Status.DISCONNECTED); diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/spring/ClusterManagerProtocolServiceLocatorFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/spring/ClusterManagerProtocolServiceLocatorFactoryBean.java index e26d196561..2136dad1a0 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/spring/ClusterManagerProtocolServiceLocatorFactoryBean.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/spring/ClusterManagerProtocolServiceLocatorFactoryBean.java @@ -33,12 +33,10 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; /** - * Factory bean for creating a singleton ClusterManagerProtocolServiceLocator - * instance. If the application is configured to act as the cluster manager, - * then null is always returned as the created instance. + * Factory bean for creating a singleton ClusterManagerProtocolServiceLocator instance. If the application is configured to act as the cluster manager, then null is always returned as the created + * instance. * - * The cluster manager protocol service represents the socket endpoint for - * sending internal socket messages to the cluster manager. + * The cluster manager protocol service represents the socket endpoint for sending internal socket messages to the cluster manager. */ public class ClusterManagerProtocolServiceLocatorFactoryBean implements FactoryBean, ApplicationContextAware, DisposableBean { @@ -51,7 +49,7 @@ public class ClusterManagerProtocolServiceLocatorFactoryBean implements FactoryB @Override public Object getObject() throws Exception { /* - * If configured for the cluster manager, then the service locator is never used. + * If configured for the cluster manager, then the service locator is never used. */ if (properties.isClusterManager()) { return null; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/spring/WebClusterManagerFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/spring/WebClusterManagerFactoryBean.java index d3cff3b26f..2b3bff96b8 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/spring/WebClusterManagerFactoryBean.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/spring/WebClusterManagerFactoryBean.java @@ -36,9 +36,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; /** - * Factory bean for creating a singleton WebClusterManager instance. If the - * application is not configured to act as the cluster manager, then null is - * always returned as the created instance. + * Factory bean for creating a singleton WebClusterManager instance. If the application is not configured to act as the cluster manager, then null is always returned as the created instance. */ public class WebClusterManagerFactoryBean implements FactoryBean, ApplicationContextAware { @@ -49,7 +47,7 @@ public class WebClusterManagerFactoryBean implements FactoryBean, ApplicationCon private NiFiProperties properties; private StringEncryptor encryptor; - + private OptimisticLockingManager optimisticLockingManager; @Override @@ -58,8 +56,8 @@ public class WebClusterManagerFactoryBean implements FactoryBean, ApplicationCon throw new IllegalStateException("Application may be configured as a cluster manager or a node, but not both."); } else if (!properties.isClusterManager()) { /* - * If not configured for the cluster manager, then the cluster manager is never used. - * null is returned so that we don't instantiate a thread pool or other resources. + * If not configured for the cluster manager, then the cluster manager is never used. + * null is returned so that we don't instantiate a thread pool or other resources. */ return null; } else if (clusterManager == null) { @@ -127,7 +125,7 @@ public class WebClusterManagerFactoryBean implements FactoryBean, ApplicationCon public void setEncryptor(final StringEncryptor encryptor) { this.encryptor = encryptor; } - + public void setOptimisticLockingManager(OptimisticLockingManager optimisticLockingManager) { this.optimisticLockingManager = optimisticLockingManager; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/event/impl/EventManagerImplTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/event/impl/EventManagerImplTest.java index 09ea44b383..e823d274b7 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/event/impl/EventManagerImplTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/event/impl/EventManagerImplTest.java @@ -16,18 +16,18 @@ */ package org.apache.nifi.cluster.event.impl; -import org.apache.nifi.cluster.event.impl.EventManagerImpl; import java.util.Arrays; import java.util.Collections; import java.util.List; import org.apache.nifi.cluster.event.Event; import org.apache.nifi.cluster.event.Event.Category; import org.apache.nifi.cluster.event.EventManager; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import org.junit.Test; -import static org.junit.Assert.*; /** - * @author unattributed */ public class EventManagerImplTest { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewallTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewallTest.java index e5db7cac69..b5f76fb0d6 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewallTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewallTest.java @@ -17,12 +17,17 @@ package org.apache.nifi.cluster.firewall.impl; import java.io.File; -import java.io.IOException; -import org.apache.nifi.util.file.FileUtils; -import org.junit.After; +import java.net.InetAddress; +import java.net.UnknownHostException; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assume.assumeTrue; import org.junit.Before; -import static org.junit.Assert.*; +import org.junit.BeforeClass; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TemporaryFolder; public class FileBasedClusterNodeFirewallTest { @@ -36,21 +41,54 @@ public class FileBasedClusterNodeFirewallTest { private File restoreDirectory; + @Rule + public final TemporaryFolder temp = new TemporaryFolder(); + + private static final String NONEXISTENT_HOSTNAME = "abc"; + + private static boolean badHostsDoNotResolve = false; + + /** + * We have tests that rely on known bad host/ip parameters; make sure DNS doesn't resolve them. + * This can be a problem i.e. on residential ISPs in the USA because the provider will often + * wildcard match all possible DNS names in an attempt to serve advertising. + */ + @BeforeClass + public static void ensureBadHostsDoNotWork() { + final InetAddress ip; + try { + ip = InetAddress.getByName(NONEXISTENT_HOSTNAME); + } catch (final UnknownHostException uhe) { + badHostsDoNotResolve = true; + } + } + @Before public void setup() throws Exception { - ipsConfig = new File("src/test/resources/org/apache/nifi/cluster/firewall/impl/ips.txt"); - emptyConfig = new File("src/test/resources/org/apache/nifi/cluster/firewall/impl/empty.txt"); + ipsConfig = new File(getClass().getResource("/org/apache/nifi/cluster/firewall/impl/ips.txt").toURI()); + emptyConfig = new File(getClass().getResource("/org/apache/nifi/cluster/firewall/impl/empty.txt").toURI()); - restoreDirectory = new File(System.getProperty("java.io.tmpdir") + "/firewall_restore"); + restoreDirectory = temp.newFolder("firewall_restore"); ipsFirewall = new FileBasedClusterNodeFirewall(ipsConfig, restoreDirectory); acceptAllFirewall = new FileBasedClusterNodeFirewall(emptyConfig); } - @After - public void teardown() throws IOException { - deleteFile(restoreDirectory); + /** + * We have two garbage lines in our test config file, ensure they didn't get turned into hosts. + */ + @Test + public void ensureBadDataWasIgnored() { + assumeTrue(badHostsDoNotResolve); + assertFalse("firewall treated our malformed data as a host. If " + + "`host \"bad data should be skipped\"` works locally, this test should have been " + + "skipped.", + ipsFirewall.isPermissible("bad data should be skipped")); + assertFalse("firewall treated our malformed data as a host. If " + + "`host \"more bad data\"` works locally, this test should have been " + + "skipped.", + ipsFirewall.isPermissible("more bad data")); } @Test @@ -75,7 +113,10 @@ public class FileBasedClusterNodeFirewallTest { @Test public void testIsPermissibleWithMalformedData() { - assertFalse(ipsFirewall.isPermissible("abc")); + assumeTrue(badHostsDoNotResolve); + assertFalse("firewall allowed host '" + NONEXISTENT_HOSTNAME + "' rather than rejecting as malformed. If `host " + NONEXISTENT_HOSTNAME + "` " + + "works locally, this test should have been skipped.", + ipsFirewall.isPermissible(NONEXISTENT_HOSTNAME)); } @Test @@ -85,14 +126,10 @@ public class FileBasedClusterNodeFirewallTest { @Test public void testIsPermissibleWithEmptyConfigWithMalformedData() { - assertTrue(acceptAllFirewall.isPermissible("abc")); - } - - private boolean deleteFile(final File file) { - if (file.isDirectory()) { - FileUtils.deleteFilesInDir(file, null, null, true, true); - } - return FileUtils.deleteFile(file, null, 10); + assumeTrue(badHostsDoNotResolve); + assertTrue("firewall did not allow malformed host '" + NONEXISTENT_HOSTNAME + "' under permissive configs. If " + + "`host " + NONEXISTENT_HOSTNAME + "` works locally, this test should have been skipped.", + acceptAllFirewall.isPermissible(NONEXISTENT_HOSTNAME)); } } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImplTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImplTest.java index f9ba016e3a..3d00d3be4b 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImplTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImplTest.java @@ -56,7 +56,6 @@ import org.w3c.dom.Element; import org.xml.sax.SAXException; /** - * @author unattributed */ public class DataFlowManagementServiceImplTest { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImplTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImplTest.java index 0c65aba218..b02eac0917 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImplTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImplTest.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.cluster.manager.impl; -import org.apache.nifi.cluster.manager.impl.HttpRequestReplicatorImpl; import javax.ws.rs.core.Response; import javax.xml.bind.annotation.XmlRootElement; import javax.ws.rs.HttpMethod; @@ -43,10 +42,11 @@ import org.junit.Before; import org.junit.Test; import org.apache.nifi.cluster.manager.testutils.HttpResponseAction; import org.apache.nifi.cluster.protocol.NodeIdentifier; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; /** - * @author unattributed */ public class HttpRequestReplicatorImplTest { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImplTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImplTest.java index d45a4d1d15..ebea63a300 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImplTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImplTest.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.cluster.manager.impl; -import org.apache.nifi.cluster.manager.impl.HttpResponseMapperImpl; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.core.util.MultivaluedMapImpl; import java.io.ByteArrayInputStream; @@ -29,13 +28,13 @@ import org.apache.nifi.cluster.manager.NodeResponse; import org.apache.nifi.cluster.node.Node; import org.apache.nifi.cluster.node.Node.Status; import org.apache.nifi.cluster.protocol.NodeIdentifier; +import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; /** - * @author unattributed */ public class HttpResponseMapperImplTest { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpRequest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpRequest.java index 35380ddb57..4c3eeeebe1 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpRequest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpRequest.java @@ -30,10 +30,8 @@ import javax.ws.rs.core.MediaType; import org.apache.commons.lang3.StringUtils; /** - * Encapsulates an HTTP request. The toString method returns the - * specification-compliant request. + * Encapsulates an HTTP request. The toString method returns the specification-compliant request. * - * @author unattributed */ public class HttpRequest { @@ -97,9 +95,7 @@ public class HttpRequest { } /** - * A builder for constructing basic HTTP requests. It handles only enough of - * the HTTP specification to support basic unit testing, and it should not - * be used otherwise. + * A builder for constructing basic HTTP requests. It handles only enough of the HTTP specification to support basic unit testing, and it should not be used otherwise. */ public static class HttpRequestBuilder { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponse.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponse.java index 3aa29318a3..7ae48061a9 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponse.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponse.java @@ -22,10 +22,8 @@ import java.util.Map; import javax.ws.rs.core.Response.Status; /** - * Encapsulates an HTTP response. The toString method returns the - * specification-compliant response. + * Encapsulates an HTTP response. The toString method returns the specification-compliant response. * - * @author unattributed */ public class HttpResponse { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponseAction.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponseAction.java index 28615d0348..a2899cfe6e 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponseAction.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponseAction.java @@ -17,13 +17,10 @@ package org.apache.nifi.cluster.manager.testutils; /** - * Wraps a HttpResponse with a time-delay. When the action is applied, the - * currently executing thread sleeps for the given delay before returning the - * response to the caller. + * Wraps a HttpResponse with a time-delay. When the action is applied, the currently executing thread sleeps for the given delay before returning the response to the caller. * * This class is good for simulating network latency. * - * @author unattributed */ public class HttpResponseAction { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpServer.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpServer.java index f17a66c3eb..3621475a65 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpServer.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpServer.java @@ -37,10 +37,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * A simple HTTP web server that allows clients to register canned-responses to - * respond to received requests. + * A simple HTTP web server that allows clients to register canned-responses to respond to received requests. * - * @author unattributed */ public class HttpServer { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImplTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImplTest.java deleted file mode 100644 index 96943c2462..0000000000 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImplTest.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.cluster.protocol.impl; - -import java.io.IOException; -import java.net.InetAddress; -import org.apache.nifi.cluster.protocol.NodeIdentifier; -import org.apache.nifi.cluster.protocol.ProtocolContext; -import org.apache.nifi.cluster.protocol.ProtocolException; -import org.apache.nifi.cluster.protocol.ProtocolHandler; -import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext; -import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils; -import org.apache.nifi.cluster.protocol.message.FlowRequestMessage; -import org.apache.nifi.cluster.protocol.message.FlowResponseMessage; -import org.apache.nifi.cluster.protocol.message.PingMessage; -import org.apache.nifi.cluster.protocol.message.ProtocolMessage; -import org.apache.nifi.io.socket.ServerSocketConfiguration; -import org.apache.nifi.io.socket.SocketConfiguration; -import org.junit.After; -import static org.junit.Assert.*; -import org.junit.Before; -import org.junit.Test; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.*; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - -/** - * @author unattributed - */ -public class ClusterManagerProtocolSenderImplTest { - - private InetAddress address; - - private int port; - - private SocketProtocolListener listener; - - private ClusterManagerProtocolSenderImpl sender; - - private ProtocolHandler mockHandler; - - @Before - public void setup() throws IOException { - - address = InetAddress.getLocalHost(); - ServerSocketConfiguration serverSocketConfiguration = new ServerSocketConfiguration(); - - mockHandler = mock(ProtocolHandler.class); - - ProtocolContext protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT); - - listener = new SocketProtocolListener(5, 0, serverSocketConfiguration, protocolContext); - listener.addHandler(mockHandler); - listener.start(); - - port = listener.getPort(); - - SocketConfiguration socketConfiguration = new SocketConfiguration(); - sender = new ClusterManagerProtocolSenderImpl(socketConfiguration, protocolContext); - } - - @After - public void teardown() throws IOException { - if (listener.isRunning()) { - listener.stop(); - } - } - - @Test - public void testRequestFlow() throws Exception { - - when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE); - when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new FlowResponseMessage()); - FlowRequestMessage request = new FlowRequestMessage(); - request.setNodeId(new NodeIdentifier("id", "api-address", 1, address.getHostAddress(), port)); - FlowResponseMessage response = sender.requestFlow(request); - assertNotNull(response); - } - - @Test - public void testRequestFlowWithBadResponseMessage() throws Exception { - - when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE); - when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new PingMessage()); - FlowRequestMessage request = new FlowRequestMessage(); - request.setNodeId(new NodeIdentifier("id", "api-address", 1, address.getHostAddress(), port)); - try { - sender.requestFlow(request); - fail("failed to throw exception"); - } catch (ProtocolException pe) { - } - - } - - @Test - public void testRequestFlowDelayedResponse() throws Exception { - - final int time = 250; - sender.getSocketConfiguration().setSocketTimeout(time); - - when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE); - when(mockHandler.handle(any(ProtocolMessage.class))).thenAnswer(new Answer() { - @Override - public FlowResponseMessage answer(InvocationOnMock invocation) throws Throwable { - Thread.sleep(time * 3); - return new FlowResponseMessage(); - } - }); - FlowRequestMessage request = new FlowRequestMessage(); - request.setNodeId(new NodeIdentifier("id", "api-address", 1, address.getHostAddress(), port)); - try { - sender.requestFlow(request); - fail("failed to throw exception"); - } catch (ProtocolException pe) { - } - } - -} diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocatorTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocatorTest.java deleted file mode 100644 index 4a6957105e..0000000000 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocatorTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.cluster.protocol.impl; - -import java.net.InetSocketAddress; -import java.util.concurrent.TimeUnit; -import org.apache.nifi.io.socket.multicast.DiscoverableService; -import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl; -import static org.junit.Assert.*; -import org.junit.Before; -import org.junit.Test; -import static org.mockito.Mockito.*; -import org.mockito.stubbing.OngoingStubbing; - -public class ClusterServiceLocatorTest { - - private ClusterServiceDiscovery mockServiceDiscovery; - - private int fixedPort; - - private DiscoverableService fixedService; - - private ClusterServiceLocator serviceDiscoveryLocator; - - private ClusterServiceLocator serviceDiscoveryFixedPortLocator; - - private ClusterServiceLocator fixedServiceLocator; - - @Before - public void setup() throws Exception { - - fixedPort = 1; - mockServiceDiscovery = mock(ClusterServiceDiscovery.class); - fixedService = new DiscoverableServiceImpl("some-service", InetSocketAddress.createUnresolved("some-host", 20)); - - serviceDiscoveryLocator = new ClusterServiceLocator(mockServiceDiscovery); - serviceDiscoveryFixedPortLocator = new ClusterServiceLocator(mockServiceDiscovery, fixedPort); - fixedServiceLocator = new ClusterServiceLocator(fixedService); - - } - - @Test - public void getServiceWhenServiceDiscoveryNotStarted() { - assertNull(serviceDiscoveryLocator.getService()); - } - - @Test - public void getServiceWhenServiceDiscoveryFixedPortNotStarted() { - assertNull(serviceDiscoveryLocator.getService()); - } - - @Test - public void getServiceWhenFixedServiceNotStarted() { - assertEquals(fixedService, fixedServiceLocator.getService()); - } - - @Test - public void getServiceNotOnFirstAttempt() { - - ClusterServiceLocator.AttemptsConfig config = new ClusterServiceLocator.AttemptsConfig(); - config.setNumAttempts(2); - config.setTimeBetweenAttempsUnit(TimeUnit.SECONDS); - config.setTimeBetweenAttempts(1); - - serviceDiscoveryLocator.setAttemptsConfig(config); - - OngoingStubbing stubbing = null; - for (int i = 0; i < config.getNumAttempts() - 1; i++) { - if (stubbing == null) { - stubbing = when(mockServiceDiscovery.getService()).thenReturn(null); - } else { - stubbing.thenReturn(null); - } - } - stubbing.thenReturn(fixedService); - - assertEquals(fixedService, serviceDiscoveryLocator.getService()); - - } - - @Test - public void getServiceNotOnFirstAttemptWithFixedPort() { - - ClusterServiceLocator.AttemptsConfig config = new ClusterServiceLocator.AttemptsConfig(); - config.setNumAttempts(2); - config.setTimeBetweenAttempsUnit(TimeUnit.SECONDS); - config.setTimeBetweenAttempts(1); - - serviceDiscoveryFixedPortLocator.setAttemptsConfig(config); - - OngoingStubbing stubbing = null; - for (int i = 0; i < config.getNumAttempts() - 1; i++) { - if (stubbing == null) { - stubbing = when(mockServiceDiscovery.getService()).thenReturn(null); - } else { - stubbing.thenReturn(null); - } - } - stubbing.thenReturn(fixedService); - - InetSocketAddress resultAddress = InetSocketAddress.createUnresolved(fixedService.getServiceAddress().getHostName(), fixedPort); - DiscoverableService resultService = new DiscoverableServiceImpl(fixedService.getServiceName(), resultAddress); - assertEquals(resultService, serviceDiscoveryFixedPortLocator.getService()); - } -} diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcasterTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcasterTest.java deleted file mode 100644 index 4d85d1a130..0000000000 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcasterTest.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.cluster.protocol.impl; - -import java.net.InetSocketAddress; -import org.apache.nifi.cluster.protocol.ProtocolContext; -import org.apache.nifi.cluster.protocol.ProtocolException; -import org.apache.nifi.cluster.protocol.ProtocolHandler; -import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext; -import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils; -import org.apache.nifi.cluster.protocol.message.ProtocolMessage; -import org.apache.nifi.cluster.protocol.message.ServiceBroadcastMessage; -import org.apache.nifi.io.socket.multicast.DiscoverableService; -import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl; -import org.apache.nifi.io.socket.multicast.MulticastConfiguration; -import org.junit.After; -import static org.junit.Assert.*; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -/** - * @author unattributed - */ -public class ClusterServicesBroadcasterTest { - - private ClusterServicesBroadcaster broadcaster; - - private MulticastProtocolListener listener; - - private DummyProtocolHandler handler; - - private InetSocketAddress multicastAddress; - - private DiscoverableService broadcastedService; - - private ProtocolContext protocolContext; - - private MulticastConfiguration configuration; - - @Before - public void setup() throws Exception { - - broadcastedService = new DiscoverableServiceImpl("some-service", new InetSocketAddress("localhost", 11111)); - - multicastAddress = new InetSocketAddress("225.1.1.1", 22222); - - configuration = new MulticastConfiguration(); - - protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT); - - broadcaster = new ClusterServicesBroadcaster(multicastAddress, configuration, protocolContext, "500 ms"); - broadcaster.addService(broadcastedService); - - handler = new DummyProtocolHandler(); - listener = new MulticastProtocolListener(5, multicastAddress, configuration, protocolContext); - listener.addHandler(handler); - } - - @After - public void teardown() { - - if (broadcaster.isRunning()) { - broadcaster.stop(); - } - - try { - if (listener.isRunning()) { - listener.stop(); - } - } catch (Exception ex) { - ex.printStackTrace(System.out); - } - - } - - @Test - @Ignore - public void testBroadcastReceived() throws Exception { - - broadcaster.start(); - listener.start(); - - Thread.sleep(1000); - - listener.stop(); - - assertNotNull(handler.getProtocolMessage()); - assertEquals(ProtocolMessage.MessageType.SERVICE_BROADCAST, handler.getProtocolMessage().getType()); - final ServiceBroadcastMessage msg = (ServiceBroadcastMessage) handler.getProtocolMessage(); - assertEquals(broadcastedService.getServiceName(), msg.getServiceName()); - assertEquals(broadcastedService.getServiceAddress().getHostName(), msg.getAddress()); - assertEquals(broadcastedService.getServiceAddress().getPort(), msg.getPort()); - } - - private class DummyProtocolHandler implements ProtocolHandler { - - private ProtocolMessage protocolMessage; - - @Override - public boolean canHandle(ProtocolMessage msg) { - return true; - } - - @Override - public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException { - this.protocolMessage = msg; - return null; - } - - public ProtocolMessage getProtocolMessage() { - return protocolMessage; - } - - } - -} diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListenerTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListenerTest.java deleted file mode 100644 index 6c79b9073d..0000000000 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListenerTest.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.cluster.protocol.impl; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.net.DatagramPacket; -import java.net.InetSocketAddress; -import java.net.MulticastSocket; -import java.util.ArrayList; -import java.util.List; -import org.apache.nifi.cluster.protocol.ProtocolContext; -import org.apache.nifi.cluster.protocol.ProtocolException; -import org.apache.nifi.cluster.protocol.ProtocolHandler; -import org.apache.nifi.cluster.protocol.ProtocolMessageMarshaller; -import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext; -import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils; -import org.apache.nifi.cluster.protocol.message.MulticastProtocolMessage; -import org.apache.nifi.cluster.protocol.message.PingMessage; -import org.apache.nifi.cluster.protocol.message.ProtocolMessage; -import org.apache.nifi.io.socket.multicast.MulticastConfiguration; -import org.apache.nifi.io.socket.multicast.MulticastUtils; -import org.junit.After; -import static org.junit.Assert.*; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -/** - * @author unattributed - */ -public class MulticastProtocolListenerTest { - - private MulticastProtocolListener listener; - - private MulticastSocket socket; - - private InetSocketAddress address; - - private MulticastConfiguration configuration; - - private ProtocolContext protocolContext; - - @Before - public void setup() throws Exception { - - address = new InetSocketAddress("226.1.1.1", 60000); - configuration = new MulticastConfiguration(); - - protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT); - - listener = new MulticastProtocolListener(5, address, configuration, protocolContext); - listener.start(); - - socket = MulticastUtils.createMulticastSocket(address.getPort(), configuration); - } - - @After - public void teardown() throws IOException { - try { - if (listener.isRunning()) { - listener.stop(); - } - } finally { - MulticastUtils.closeQuietly(socket); - } - } - - @Ignore("This test must be reworked. Requires an active network connection") - @Test - public void testBadRequest() throws Exception { - DelayedProtocolHandler handler = new DelayedProtocolHandler(0); - listener.addHandler(handler); - DatagramPacket packet = new DatagramPacket(new byte[]{5}, 1, address); - socket.send(packet); - Thread.sleep(250); - assertEquals(0, handler.getMessages().size()); - } - - @Test - @Ignore - public void testRequest() throws Exception { - - ReflexiveProtocolHandler handler = new ReflexiveProtocolHandler(); - listener.addHandler(handler); - - ProtocolMessage msg = new PingMessage(); - MulticastProtocolMessage multicastMsg = new MulticastProtocolMessage("some-id", msg); - - // marshal message to output stream - ProtocolMessageMarshaller marshaller = protocolContext.createMarshaller(); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - marshaller.marshal(multicastMsg, baos); - byte[] requestPacketBytes = baos.toByteArray(); - DatagramPacket packet = new DatagramPacket(requestPacketBytes, requestPacketBytes.length, address); - socket.send(packet); - - Thread.sleep(250); - assertEquals(1, handler.getMessages().size()); - assertEquals(msg.getType(), handler.getMessages().get(0).getType()); - - } - - private class ReflexiveProtocolHandler implements ProtocolHandler { - - private List messages = new ArrayList<>(); - - @Override - public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException { - messages.add(msg); - return msg; - } - - @Override - public boolean canHandle(ProtocolMessage msg) { - return true; - } - - public List getMessages() { - return messages; - } - - } - - private class DelayedProtocolHandler implements ProtocolHandler { - - private int delay = 0; - - private List messages = new ArrayList<>(); - - public DelayedProtocolHandler(int delay) { - this.delay = delay; - } - - @Override - public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException { - try { - messages.add(msg); - Thread.sleep(delay); - return null; - } catch (final InterruptedException ie) { - throw new ProtocolException(ie); - } - - } - - @Override - public boolean canHandle(ProtocolMessage msg) { - return true; - } - - public List getMessages() { - return messages; - } - - } -} diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImplTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImplTest.java deleted file mode 100644 index 7c62d2f984..0000000000 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImplTest.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.cluster.protocol.impl; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.io.IOException; -import java.net.InetSocketAddress; -import java.util.UUID; - -import org.apache.nifi.cluster.HeartbeatPayload; -import org.apache.nifi.cluster.protocol.ConnectionRequest; -import org.apache.nifi.cluster.protocol.ConnectionResponse; -import org.apache.nifi.cluster.protocol.Heartbeat; -import org.apache.nifi.cluster.protocol.NodeIdentifier; -import org.apache.nifi.cluster.protocol.ProtocolContext; -import org.apache.nifi.cluster.protocol.ProtocolException; -import org.apache.nifi.cluster.protocol.ProtocolHandler; -import org.apache.nifi.cluster.protocol.StandardDataFlow; -import org.apache.nifi.cluster.protocol.UnknownServiceAddressException; -import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext; -import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils; -import org.apache.nifi.cluster.protocol.message.ConnectionRequestMessage; -import org.apache.nifi.cluster.protocol.message.ConnectionResponseMessage; -import org.apache.nifi.cluster.protocol.message.ControllerStartupFailureMessage; -import org.apache.nifi.cluster.protocol.message.HeartbeatMessage; -import org.apache.nifi.cluster.protocol.message.PingMessage; -import org.apache.nifi.cluster.protocol.message.ProtocolMessage; -import org.apache.nifi.io.socket.ServerSocketConfiguration; -import org.apache.nifi.io.socket.SocketConfiguration; -import org.apache.nifi.io.socket.multicast.DiscoverableService; -import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - -/** - * @author unattributed - */ -public class NodeProtocolSenderImplTest { - - private SocketProtocolListener listener; - - private NodeProtocolSenderImpl sender; - - private DiscoverableService service; - - private ServerSocketConfiguration serverSocketConfiguration; - - private ClusterServiceLocator mockServiceLocator; - - private ProtocolHandler mockHandler; - - private NodeIdentifier nodeIdentifier; - - @Before - public void setup() throws IOException { - - serverSocketConfiguration = new ServerSocketConfiguration(); - - mockServiceLocator = mock(ClusterServiceLocator.class); - mockHandler = mock(ProtocolHandler.class); - - nodeIdentifier = new NodeIdentifier("1", "localhost", 1234, "localhost", 5678); - - ProtocolContext protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT); - - listener = new SocketProtocolListener(5, 0, serverSocketConfiguration, protocolContext); - listener.setShutdownListenerSeconds(3); - listener.addHandler(mockHandler); - listener.start(); - - service = new DiscoverableServiceImpl("some-service", new InetSocketAddress("localhost", listener.getPort())); - - SocketConfiguration socketConfiguration = new SocketConfiguration(); - socketConfiguration.setReuseAddress(true); - sender = new NodeProtocolSenderImpl(mockServiceLocator, socketConfiguration, protocolContext); - } - - @After - public void teardown() throws IOException { - if (listener.isRunning()) { - listener.stop(); - } - } - - @Test - public void testConnect() throws Exception { - - when(mockServiceLocator.getService()).thenReturn(service); - when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE); - ConnectionResponseMessage mockMessage = new ConnectionResponseMessage(); - mockMessage.setConnectionResponse(new ConnectionResponse(nodeIdentifier, new StandardDataFlow("flow".getBytes("UTF-8"), new byte[0], new byte[0]), false, null, null, UUID.randomUUID().toString())); - when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(mockMessage); - - ConnectionRequestMessage request = new ConnectionRequestMessage(); - request.setConnectionRequest(new ConnectionRequest(nodeIdentifier)); - ConnectionResponseMessage response = sender.requestConnection(request); - assertNotNull(response); - } - - @Test(expected = UnknownServiceAddressException.class) - public void testConnectNoClusterManagerAddress() throws Exception { - - when(mockServiceLocator.getService()).thenReturn(null); - when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE); - when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new ConnectionResponseMessage()); - - ConnectionRequestMessage request = new ConnectionRequestMessage(); - request.setConnectionRequest(new ConnectionRequest(nodeIdentifier)); - - sender.requestConnection(request); - fail("failed to throw exception"); - } - - @Test(expected = ProtocolException.class) - public void testConnectBadResponse() throws Exception { - - when(mockServiceLocator.getService()).thenReturn(service); - when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE); - when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new PingMessage()); - - ConnectionRequestMessage request = new ConnectionRequestMessage(); - request.setConnectionRequest(new ConnectionRequest(nodeIdentifier)); - - sender.requestConnection(request); - fail("failed to throw exception"); - - } - - @Test(expected = ProtocolException.class) - public void testConnectDelayedResponse() throws Exception { - - final int time = 250; - sender.getSocketConfiguration().setSocketTimeout(time); - when(mockServiceLocator.getService()).thenReturn(service); - when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE); - when(mockHandler.handle(any(ProtocolMessage.class))).thenAnswer(new Answer() { - @Override - public ConnectionResponseMessage answer(InvocationOnMock invocation) throws Throwable { - Thread.sleep(time * 3); - return new ConnectionResponseMessage(); - } - }); - ConnectionRequestMessage request = new ConnectionRequestMessage(); - request.setConnectionRequest(new ConnectionRequest(nodeIdentifier)); - - sender.requestConnection(request); - fail("failed to throw exception"); - - } - - @Test - public void testHeartbeat() throws Exception { - - when(mockServiceLocator.getService()).thenReturn(service); - when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE); - when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(null); - - HeartbeatMessage msg = new HeartbeatMessage(); - HeartbeatPayload hbPayload = new HeartbeatPayload(); - Heartbeat hb = new Heartbeat(new NodeIdentifier("id", "localhost", 3, "localhost", 4), false, false, hbPayload.marshal()); - msg.setHeartbeat(hb); - sender.heartbeat(msg); - } - - @Test - public void testNotifyControllerStartupFailure() throws Exception { - - when(mockServiceLocator.getService()).thenReturn(service); - when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE); - when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(null); - - ControllerStartupFailureMessage msg = new ControllerStartupFailureMessage(); - msg.setNodeId(new NodeIdentifier("some-id", "some-addr", 1, "some-addr", 1)); - msg.setExceptionMessage("some exception"); - sender.notifyControllerStartupFailure(msg); - } - -} diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/testutils/DelayedProtocolHandler.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/testutils/DelayedProtocolHandler.java deleted file mode 100644 index 2f16777fae..0000000000 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/testutils/DelayedProtocolHandler.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.cluster.protocol.testutils; - -import java.util.ArrayList; -import java.util.List; -import org.apache.nifi.cluster.protocol.ProtocolException; -import org.apache.nifi.cluster.protocol.ProtocolHandler; -import org.apache.nifi.cluster.protocol.message.ProtocolMessage; - -/** - * @author unattributed - */ -public class DelayedProtocolHandler implements ProtocolHandler { - - private int delay = 0; - private List messages = new ArrayList<>(); - - public DelayedProtocolHandler(int delay) { - this.delay = delay; - } - - @Override - public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException { - try { - messages.add(msg); - Thread.sleep(delay); - return null; - } catch (final InterruptedException ie) { - throw new ProtocolException(ie); - } - - } - - @Override - public boolean canHandle(ProtocolMessage msg) { - return true; - } - - public List getMessages() { - return messages; - } -} diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/pom.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/pom.xml index 7b28bbeaaa..63c07c00bd 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/pom.xml +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/pom.xml @@ -43,8 +43,8 @@ nifi-api - org.apache.nifi - nifi-site-to-site-client + org.apache.nifi + nifi-site-to-site-client org.apache.commons diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/connectable/Connectable.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/connectable/Connectable.java index 3d5c75da7d..7c4009231d 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/connectable/Connectable.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/connectable/Connectable.java @@ -46,7 +46,7 @@ public interface Connectable extends Triggerable { /** * Returns the ProcessorRelationship whose name is given * - * @param relationshipName + * @param relationshipName name * @return a ProcessorRelationship whose name is given, or null * if none exists */ @@ -69,7 +69,7 @@ public interface Connectable extends Triggerable { /** * - * @param connection + * @param connection to remove * @throws IllegalStateException if the given Connection is not registered * to this. */ @@ -79,8 +79,8 @@ public interface Connectable extends Triggerable { * Updates any internal state that depends on the given connection. The * given connection will share the same ID as the old connection. * - * @param newConnection - * @throws IllegalStateException + * @param newConnection new connection + * @throws IllegalStateException ise */ void updateConnection(Connection newConnection) throws IllegalStateException; @@ -98,7 +98,7 @@ public interface Connectable extends Triggerable { Set getConnections(); /** - * @param relationship + * @param relationship to get connections for * @return a Set of all Connections that contain * the given relationship for which this Connectable is the * source @@ -106,16 +106,14 @@ public interface Connectable extends Triggerable { Set getConnections(Relationship relationship); /** - * Returns the position on the graph where this Connectable is located - * - * @return + * @return the position on the graph where this Connectable is located */ Position getPosition(); /** * Updates this component's position on the graph * - * @param position + * @param position new position */ void setPosition(Position position); @@ -127,7 +125,8 @@ public interface Connectable extends Triggerable { /** * Sets the name of this Connectable so that its name will be visible on the * UI - * @param name + * + * @param name new name */ void setName(String name); @@ -138,31 +137,28 @@ public interface Connectable extends Triggerable { /** * Sets the comments of this Connectable. - * @param comments + * + * @param comments of this Connectable */ void setComments(String comments); /** - * If true, + * @return If true, * {@link #onTrigger(nifi.processor.ProcessContext, nifi.processor.ProcessSessionFactory)} * should be called even when this Connectable has no FlowFiles queued for * processing - * - * @return */ boolean isTriggerWhenEmpty(); /** - * Returns the ProcessGroup to which this Connectable belongs - * - * @return + * @return the ProcessGroup to which this Connectable belongs */ ProcessGroup getProcessGroup(); /** * Sets the new ProcessGroup to which this Connectable belongs * - * @param group + * @param group new group */ void setProcessGroup(ProcessGroup group); @@ -177,15 +173,13 @@ public interface Connectable extends Triggerable { boolean isAutoTerminated(Relationship relationship); /** - * Indicates whether flow file content made by this connectable must be - * persisted - * - * @return + * @return Indicates whether flow file content made by this connectable must + * be persisted */ boolean isLossTolerant(); /** - * @param lossTolerant + * @param lossTolerant true if it is */ void setLossTolerant(boolean lossTolerant); @@ -195,41 +189,33 @@ public interface Connectable extends Triggerable { ConnectableType getConnectableType(); /** - * Returns the any validation errors for this connectable. - * - * @return + * @return any validation errors for this connectable */ Collection getValidationErrors(); /** - * Returns the amount of time for which a FlowFile should be penalized when + * @param timeUnit unit over which to interpret the duration + * @return the amount of time for which a FlowFile should be penalized when * {@link ProcessSession#penalize(nifi.flowfile.FlowFile)} is called - * - * @param timeUnit - * @return */ long getPenalizationPeriod(final TimeUnit timeUnit); /** - * Returns a string representation for which a FlowFile should be penalized + * @return a string representation for which a FlowFile should be penalized * when {@link ProcessSession#penalize(nifi.flowfile.FlowFile)} is called - * - * @return */ String getPenalizationPeriod(); /** * @param timeUnit determines the unit of time to represent the yield * period. - * @return + * @return yield period */ long getYieldPeriod(TimeUnit timeUnit); /** - * returns the string representation for this Connectable's configured yield + * @return the string representation for this Connectable's configured yield * period - * - * @return */ String getYieldPeriod(); @@ -238,14 +224,15 @@ public interface Connectable extends Triggerable { * scheduled when the processor calls * {@link nifi.processor.ProcessContext#yield() ProcessContext.yield()} * - * @param yieldPeriod + * @param yieldPeriod new yield period */ void setYieldPeriod(String yieldPeriod); /** * Updates the amount of time that this Connectable will penalize FlowFiles * when {@link ProcessSession#penalize(nifi.flowfile.FlowFile)} is called - * @param penalizationPeriod + * + * @param penalizationPeriod new period */ void setPenalizationPeriod(String penalizationPeriod); @@ -258,18 +245,14 @@ public interface Connectable extends Triggerable { void yield(); /** - * Returns the time in milliseconds since Epoch at which this Connectable + * @return the time in milliseconds since Epoch at which this Connectable * should no longer yield its threads - * - * @return */ long getYieldExpiration(); /** - * Specifies whether or not this component is considered side-effect free, - * with respect to external systems. - * - * @return + * @return Specifies whether or not this component is considered side-effect free, + * with respect to external systems */ boolean isSideEffectFree(); diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/AbstractConfiguredComponent.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/AbstractConfiguredComponent.java index c44161fac8..978c612fbb 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/AbstractConfiguredComponent.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/AbstractConfiguredComponent.java @@ -150,16 +150,16 @@ public abstract class AbstractConfiguredComponent implements ConfigurableCompone final PropertyDescriptor descriptor = component.getPropertyDescriptor(name); String value = null; if (!descriptor.isRequired() && (value = properties.remove(descriptor)) != null) { - - if ( descriptor.getControllerServiceDefinition() != null ) { - if (value != null) { + + if (descriptor.getControllerServiceDefinition() != null) { + if (value != null) { final ControllerServiceNode oldNode = serviceProvider.getControllerServiceNode(value); if (oldNode != null) { oldNode.removeReference(this); } } - } - + } + component.onPropertyModified(descriptor, value, null); return true; } @@ -261,12 +261,11 @@ public abstract class AbstractConfiguredComponent implements ConfigurableCompone return true; } - @Override public Collection getValidationErrors() { return getValidationErrors(Collections.emptySet()); } - + public Collection getValidationErrors(final Set serviceIdentifiersNotToValidate) { final List results = new ArrayList<>(); lock.lock(); diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/AbstractPort.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/AbstractPort.java index e1d2dd4e65..50ba12a6df 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/AbstractPort.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/AbstractPort.java @@ -294,8 +294,8 @@ public abstract class AbstractPort implements Port { * Verify that removing this connection will not prevent this Port from * still being connected via each relationship * - * @param connection - * @return + * @param connection to test for removal + * @return true if can be removed */ private boolean canConnectionBeRemoved(final Connection connection) { final Connectable source = connection.getSource(); @@ -368,11 +368,6 @@ public abstract class AbstractPort implements Port { } } - /** - * Indicates whether or not this Port is valid. - * - * @return - */ @Override public abstract boolean isValid(); @@ -399,18 +394,11 @@ public abstract class AbstractPort implements Port { concurrentTaskCount.set(taskCount); } - /** - * @return the number of tasks that may execute concurrently for this - * processor - */ @Override public int getMaxConcurrentTasks() { return concurrentTaskCount.get(); } - /** - * - */ @Override public void shutdown() { scheduledState.set(ScheduledState.STOPPED); @@ -450,13 +438,6 @@ public abstract class AbstractPort implements Port { return type; } - /** - * Updates the amount of time that this processor should avoid being - * scheduled when the processor calls - * {@link nifi.processor.ProcessContext#yield() ProcessContext.yield()} - * - * @param yieldPeriod - */ @Override public void setYieldPeriod(final String yieldPeriod) { final long yieldMillis = FormatUtils.getTimeDuration(requireNonNull(yieldPeriod), TimeUnit.MILLISECONDS); @@ -466,9 +447,6 @@ public abstract class AbstractPort implements Port { this.yieldPeriod.set(yieldPeriod); } - /** - * @param schedulingPeriod - */ @Override public void setScheduldingPeriod(final String schedulingPeriod) { final long schedulingNanos = FormatUtils.getTimeDuration(requireNonNull(schedulingPeriod), TimeUnit.NANOSECONDS); @@ -490,12 +468,6 @@ public abstract class AbstractPort implements Port { return penalizationPeriod.get(); } - /** - * Causes the processor not to be scheduled for some period of time. This - * duration can be obtained and set via the - * {@link #getYieldPeriod(TimeUnit)} and - * {@link #setYieldPeriod(long, TimeUnit)} methods. - */ @Override public void yield() { final long yieldMillis = getYieldPeriod(TimeUnit.MILLISECONDS); diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ConfiguredComponent.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ConfiguredComponent.java index 5b95524bc6..8b2794d6bd 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ConfiguredComponent.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ConfiguredComponent.java @@ -55,9 +55,7 @@ public interface ConfiguredComponent { boolean isValid(); /** - * Returns the any validation errors for this connectable. - * - * @return + * @return the any validation errors for this connectable */ Collection getValidationErrors(); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ContentAvailability.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ContentAvailability.java index eee878e04c..f91fe8f257 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ContentAvailability.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ContentAvailability.java @@ -23,43 +23,33 @@ package org.apache.nifi.controller; public interface ContentAvailability { /** - * Returns a boolean indicating whether or not the Input content is + * @return a boolean indicating whether or not the Input content is * available - * - * @return */ boolean isInputAvailable(); /** - * Returns a boolean indicating whether or not the Output content is + * @return a boolean indicating whether or not the Output content is * available - * - * @return */ boolean isOutputAvailable(); /** - * Returns true if the Input content is the same as the Output + * @return true if the Input content is the same as the Output * content - * - * @return */ boolean isContentSame(); /** - * Returns a boolean indicating whether or not the content is replayable. If + * @return a boolean indicating whether or not the content is replayable. If * this returns false, the reason that replay is not available - * can be determined by calling {@link #getReasonNotReplayable()}. - * - * @return + * can be determined by calling {@link #getReasonNotReplayable()} */ boolean isReplayable(); /** - * Returns the reason that the content cannot be replayed, or - * null if the content can be replayed. - * - * @return + * @return the reason that the content cannot be replayed, or + * null if the content can be replayed */ String getReasonNotReplayable(); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ProcessScheduler.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ProcessScheduler.java index c3b6613238..ee8d9b4fdd 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ProcessScheduler.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ProcessScheduler.java @@ -35,7 +35,7 @@ public interface ProcessScheduler { * are annotated with the {@link OnScheduled} annotation. If the Processor * is already scheduled to run, does nothing. * - * @param procNode + * @param procNode to start * @throws IllegalStateException if the Processor is disabled */ void startProcessor(ProcessorNode procNode); @@ -46,7 +46,8 @@ public interface ProcessScheduler { * are annotated with the {@link OnUnscheduled} annotation. This does not * interrupt any threads that are currently running within the given * Processor. If the Processor is not scheduled to run, does nothing. - * @param procNode + * + * @param procNode to stop */ void stopProcessor(ProcessorNode procNode); @@ -54,7 +55,7 @@ public interface ProcessScheduler { * Starts scheduling the given Port to run. If the Port is already scheduled * to run, does nothing. * - * @param port + * @param port to start * * @throws IllegalStateException if the Port is disabled */ @@ -66,7 +67,7 @@ public interface ProcessScheduler { * interrupt any threads that are currently running within the given Port. * If the Port is not scheduled to run, does nothing. * - * @param port + * @param port to stop */ void stopPort(Port port); @@ -74,7 +75,7 @@ public interface ProcessScheduler { * Starts scheduling the given Funnel to run. If the funnel is already * scheduled to run, does nothing. * - * @param funnel + * @param funnel to start * * @throws IllegalStateException if the Funnel is disabled */ @@ -85,7 +86,7 @@ public interface ProcessScheduler { * threads that are currently running within the given funnel. If the funnel * is not scheduled to run, does nothing. * - * @param funnel + * @param funnel to stop */ void stopFunnel(Funnel funnel); @@ -102,27 +103,23 @@ public interface ProcessScheduler { void disableProcessor(ProcessorNode procNode); /** - * Returns the number of threads currently active for the given - * Connectable. - * - * @param scheduled - * @return + * @param scheduled scheduled component + * @return the number of threads currently active for the given + * Connectable */ int getActiveThreadCount(Object scheduled); /** - * Returns a boolean indicating whether or not the given object is scheduled + * @param scheduled component to test + * @return a boolean indicating whether or not the given object is scheduled * to run - * - * @param scheduled - * @return */ boolean isScheduled(Object scheduled); /** * Registers a relevant event for an Event-Driven worker * - * @param worker + * @param worker to register */ void registerEvent(Connectable worker); @@ -130,8 +127,8 @@ public interface ProcessScheduler { * Notifies the ProcessScheduler of how many threads are available to use * for the given {@link SchedulingStrategy} * - * @param strategy - * @param maxThreadCount + * @param strategy scheduling strategy + * @param maxThreadCount max threads */ void setMaxThreadCount(SchedulingStrategy strategy, int maxThreadCount); @@ -139,31 +136,36 @@ public interface ProcessScheduler { * Notifies the Scheduler that it should stop scheduling the given component * until its yield duration has expired * - * @param procNode + * @param procNode processor */ void yield(ProcessorNode procNode); - + /** * Stops scheduling the given Reporting Task to run - * @param taskNode + * + * @param taskNode to unschedule */ void unschedule(ReportingTaskNode taskNode); - + /** * Begins scheduling the given Reporting Task to run - * @param taskNode + * + * @param taskNode to schedule */ void schedule(ReportingTaskNode taskNode); - + /** - * Enables the Controller Service so that it can be used by Reporting Tasks and Processors - * @param service + * Enables the Controller Service so that it can be used by Reporting Tasks + * and Processors + * + * @param service to enable */ void enableControllerService(ControllerServiceNode service); - + /** * Disables the Controller Service so that it can be updated - * @param service + * + * @param service to disable */ void disableControllerService(ControllerServiceNode service); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ProcessorNode.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ProcessorNode.java index 3189edd782..66967baf2b 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ProcessorNode.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ProcessorNode.java @@ -79,18 +79,20 @@ public abstract class ProcessorNode extends AbstractConfiguredComponent implemen public abstract void setStyle(Map style); /** - * Returns the number of threads (concurrent tasks) currently being used by this Processor - * @return + * @return the number of threads (concurrent tasks) currently being used by + * this Processor */ public abstract int getActiveThreadCount(); - + /** * Verifies that this Processor can be started if the provided set of - * services are enabled. This is introduced because we need to verify that all components - * can be started before starting any of them. In order to do that, we need to know that this - * component can be started if the given services are enabled, as we will then enable the given - * services before starting this component. - * @param ignoredReferences + * services are enabled. This is introduced because we need to verify that + * all components can be started before starting any of them. In order to do + * that, we need to know that this component can be started if the given + * services are enabled, as we will then enable the given services before + * starting this component. + * + * @param ignoredReferences to ignore */ public abstract void verifyCanStart(Set ignoredReferences); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ReportingTaskNode.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ReportingTaskNode.java index c932f30058..c2adf01057 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ReportingTaskNode.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ReportingTaskNode.java @@ -40,7 +40,8 @@ public interface ReportingTaskNode extends ConfiguredComponent { /** * Updates how often the ReportingTask should be triggered to run - * @param schedulingPeriod + * + * @param schedulingPeriod new period */ void setScheduldingPeriod(String schedulingPeriod); @@ -53,43 +54,48 @@ public interface ReportingTaskNode extends ConfiguredComponent { boolean isRunning(); /** - * Returns the number of threads (concurrent tasks) currently being used by this ReportingTask - * @return + * @return the number of threads (concurrent tasks) currently being used by + * this ReportingTask */ int getActiveThreadCount(); - + /** - * Indicates the {@link ScheduledState} of this ReportingTask. A - * value of stopped does NOT indicate that the ReportingTask has - * no active threads, only that it is not currently scheduled to be given - * any more threads. To determine whether or not the + * @return Indicates the {@link ScheduledState} of this ReportingTask. + * A value of stopped does NOT indicate that the ReportingTask + * has no active threads, only that it is not currently scheduled to be + * given any more threads. To determine whether or not the * ReportingTask has any active threads, see - * {@link ProcessScheduler#getActiveThreadCount(ReportingTask)}. - * - * @return + * {@link ProcessScheduler#getActiveThreadCount(ReportingTask)} */ ScheduledState getScheduledState(); - + void setScheduledState(ScheduledState state); - + String getComments(); - + void setComments(String comment); - + /** * Verifies that this Reporting Task can be enabled if the provided set of - * services are enabled. This is introduced because we need to verify that all components - * can be started before starting any of them. In order to do that, we need to know that this - * component can be started if the given services are enabled, as we will then enable the given - * services before starting this component. - * @param ignoredReferences + * services are enabled. This is introduced because we need to verify that + * all components can be started before starting any of them. In order to do + * that, we need to know that this component can be started if the given + * services are enabled, as we will then enable the given services before + * starting this component. + * + * @param ignoredReferences to ignore */ void verifyCanStart(Set ignoredReferences); - + void verifyCanStart(); + void verifyCanStop(); + void verifyCanDisable(); + void verifyCanEnable(); + void verifyCanDelete(); + void verifyCanUpdate(); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/StandardFlowFileQueue.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/StandardFlowFileQueue.java index 59d230881f..075f2cf5f3 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/StandardFlowFileQueue.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/StandardFlowFileQueue.java @@ -56,7 +56,6 @@ import org.slf4j.LoggerFactory; * A FlowFileQueue is used to queue FlowFile objects that are awaiting further * processing. Must be thread safe. * - * @author none */ public final class StandardFlowFileQueue implements FlowFileQueue { @@ -212,7 +211,7 @@ public final class StandardFlowFileQueue implements FlowFileQueue { /** * MUST be called with lock held * - * @return + * @return size of queue */ private QueueSize getQueueSize() { final QueueSize unacknowledged = unacknowledgedSizeRef.get(); @@ -350,7 +349,7 @@ public final class StandardFlowFileQueue implements FlowFileQueue { /** * MUST be called with either the read or write lock held * - * @return + * @return true if full */ private boolean determineIfFull() { final long maxSize = maximumQueueObjectCount; @@ -1011,7 +1010,7 @@ public final class StandardFlowFileQueue implements FlowFileQueue { if (record == null || record.isPenalized()) { // not enough unpenalized records to pull. Put all records back and return activeQueue.addAll(buffer); - if ( record != null ) { + if (record != null) { activeQueue.add(record); } return; diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/StandardFunnel.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/StandardFunnel.java index 3bdfd2026f..0effbaf297 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/StandardFunnel.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/StandardFunnel.java @@ -263,7 +263,7 @@ public class StandardFunnel implements Funnel { /** * Throws {@link UnsupportedOperationException} * - * @param name + * @param name new name */ @Override public void setName(final String name) { @@ -403,7 +403,7 @@ public class StandardFunnel implements Funnel { * scheduled when the processor calls * {@link nifi.processor.ProcessContext#yield() ProcessContext.yield()} * - * @param yieldPeriod + * @param yieldPeriod new period */ @Override public void setYieldPeriod(final String yieldPeriod) { @@ -414,9 +414,6 @@ public class StandardFunnel implements Funnel { this.yieldPeriod.set(yieldPeriod); } - /** - * @param schedulingPeriod - */ @Override public void setScheduldingPeriod(final String schedulingPeriod) { final long schedulingNanos = FormatUtils.getTimeDuration(requireNonNull(schedulingPeriod), TimeUnit.NANOSECONDS); diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ValidationContextFactory.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ValidationContextFactory.java index 09479d570b..a7118d4678 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ValidationContextFactory.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ValidationContextFactory.java @@ -25,7 +25,7 @@ import org.apache.nifi.components.ValidationContext; public interface ValidationContextFactory { ValidationContext newValidationContext(Map properties, String annotationData); - + ValidationContext newValidationContext(Set serviceIdentifiersToNotValidate, Map properties, String annotationData); - + } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/exception/ControllerServiceAlreadyExistsException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/exception/ControllerServiceAlreadyExistsException.java index 0ff68b035b..327be36760 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/exception/ControllerServiceAlreadyExistsException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/exception/ControllerServiceAlreadyExistsException.java @@ -20,10 +20,6 @@ public class ControllerServiceAlreadyExistsException extends RuntimeException { private static final long serialVersionUID = -544424320587059277L; - /** - * Constructs a default exception - * @param id - */ public ControllerServiceAlreadyExistsException(final String id) { super("A Controller Service already exists with ID " + id); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/exception/ControllerServiceInstantiationException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/exception/ControllerServiceInstantiationException.java index 18cfcda659..f2118d7b76 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/exception/ControllerServiceInstantiationException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/exception/ControllerServiceInstantiationException.java @@ -20,31 +20,18 @@ public class ControllerServiceInstantiationException extends RuntimeException { private static final long serialVersionUID = -544424320587059277L; - /** - * Constructs a default exception - */ public ControllerServiceInstantiationException() { super(); } - /** - * @param message - */ public ControllerServiceInstantiationException(String message) { super(message); } - /** - * @param cause - */ public ControllerServiceInstantiationException(Throwable cause) { super(cause); } - /** - * @param message - * @param cause - */ public ControllerServiceInstantiationException(String message, Throwable cause) { super(message, cause); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/reporting/ReportingTaskProvider.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/reporting/ReportingTaskProvider.java index bb6f3f7086..9f167985fe 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/reporting/ReportingTaskProvider.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/reporting/ReportingTaskProvider.java @@ -20,84 +20,92 @@ import java.util.Set; import org.apache.nifi.controller.ReportingTaskNode; /** - * A ReportingTaskProvider is responsible for providing management of, and access to, Reporting Tasks + * A ReportingTaskProvider is responsible for providing management of, and + * access to, Reporting Tasks */ public interface ReportingTaskProvider { /** * Creates a new instance of a reporting task - * - * @param type the type (fully qualified class name) of the reporting task to instantiate + * + * @param type the type (fully qualified class name) of the reporting task + * to instantiate * @param id the identifier for the Reporting Task - * @param firstTimeAdded whether or not this is the first time that the reporting task is being added - * to the flow. I.e., this will be true only when the user adds the reporting task to the flow, not when - * the flow is being restored after a restart of the software - * + * @param firstTimeAdded whether or not this is the first time that the + * reporting task is being added to the flow. I.e., this will be true only + * when the user adds the reporting task to the flow, not when the flow is + * being restored after a restart of the software + * * @return the ReportingTaskNode that is used to manage the reporting task - * - * @throws ReportingTaskInstantiationException if unable to create the Reporting Task + * + * @throws ReportingTaskInstantiationException if unable to create the + * Reporting Task */ ReportingTaskNode createReportingTask(String type, String id, boolean firstTimeAdded) throws ReportingTaskInstantiationException; - + /** - * Returns the reporting task that has the given identifier, or null if no reporting task - * exists with that ID. - * - * @param identifier - * @return + * @param identifier of node + * @return the reporting task that has the given identifier, or + * null if no reporting task exists with that ID */ ReportingTaskNode getReportingTaskNode(String identifier); - + /** - * Returns a Set of all Reporting Tasks that exist for this service provider. - * @return + * @return a Set of all Reporting Tasks that exist for this service + * provider */ Set getAllReportingTasks(); - + /** * Removes the given reporting task from the flow - * + * * @param reportingTask - * - * @throws IllegalStateException if the reporting task cannot be removed because it is not stopped, or - * if the reporting task is not known in the flow + * + * @throws IllegalStateException if the reporting task cannot be removed + * because it is not stopped, or if the reporting task is not known in the + * flow */ void removeReportingTask(ReportingTaskNode reportingTask); - + /** - * Begins scheduling the reporting task to run and invokes appropriate lifecycle methods + * Begins scheduling the reporting task to run and invokes appropriate + * lifecycle methods + * * @param reportingTask - * - * @throws IllegalStateException if the ReportingTask's state is not STOPPED, or if the Reporting Task has active - * threads, or if the ReportingTask is not valid + * + * @throws IllegalStateException if the ReportingTask's state is not + * STOPPED, or if the Reporting Task has active threads, or if the + * ReportingTask is not valid */ void startReportingTask(ReportingTaskNode reportingTask); - + /** - * Stops scheduling the reporting task to run and invokes appropriate lifecycle methods + * Stops scheduling the reporting task to run and invokes appropriate + * lifecycle methods + * * @param reportingTask - * + * * @throws IllegalStateException if the ReportingTask's state is not RUNNING */ void stopReportingTask(ReportingTaskNode reportingTask); - - + /** * Enables the reporting task to be scheduled to run + * * @param reportingTask - * - * @throws IllegalStateException if the ReportingTask's state is not DISABLED + * + * @throws IllegalStateException if the ReportingTask's state is not + * DISABLED */ void enableReportingTask(ReportingTaskNode reportingTask); - - + /** * Disables the ability to schedul the reporting task to run - * + * * @param reportingTask - * - * @throws IllegalStateException if the ReportingTask's state is not STOPPED, or if the Reporting Task has active - * threads + * + * @throws IllegalStateException if the ReportingTask's state is not + * STOPPED, or if the Reporting Task has active threads */ void disableReportingTask(ReportingTaskNode reportingTask); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/repository/ContentNotFoundException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/repository/ContentNotFoundException.java index 6ce7ba6923..5aeb5c5753 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/repository/ContentNotFoundException.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/repository/ContentNotFoundException.java @@ -20,7 +20,6 @@ import org.apache.nifi.controller.repository.claim.ContentClaim; /** * - * @author none */ public class ContentNotFoundException extends RuntimeException { diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/repository/FlowFileEventRepository.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/repository/FlowFileEventRepository.java index 2eb3caf760..560dc058b5 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/repository/FlowFileEventRepository.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/repository/FlowFileEventRepository.java @@ -19,24 +19,19 @@ package org.apache.nifi.controller.repository; import java.io.Closeable; import java.io.IOException; -/** - * - * @author none - */ public interface FlowFileEventRepository extends Closeable { /** * Updates the repository to include a new FlowFile processing event * - * @param event - * @throws java.io.IOException + * @param event new event + * @throws java.io.IOException ioe */ void updateRepository(FlowFileEvent event) throws IOException; /** - * Returns a report of processing activity since the given time - * @param sinceEpochMillis - * @return + * @param sinceEpochMillis age of report + * @return a report of processing activity since the given time */ RepositoryStatusReport reportTransferEvents(long sinceEpochMillis); @@ -44,7 +39,7 @@ public interface FlowFileEventRepository extends Closeable { * Causes any flow file events of the given entry age in epoch milliseconds * or older to be purged from the repository * - * @param cutoffEpochMilliseconds + * @param cutoffEpochMilliseconds cutoff */ void purgeTransferEvents(long cutoffEpochMilliseconds); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceNode.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceNode.java index 50bf469e77..10933dbc34 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceNode.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceNode.java @@ -24,45 +24,52 @@ import org.apache.nifi.controller.ControllerService; public interface ControllerServiceNode extends ConfiguredComponent { ControllerService getProxiedControllerService(); - + ControllerService getControllerServiceImplementation(); ControllerServiceState getState(); + void setState(ControllerServiceState state); - + ControllerServiceReference getReferences(); void addReference(ConfiguredComponent referringComponent); void removeReference(ConfiguredComponent referringComponent); - + void setComments(String comment); + String getComments(); - + void verifyCanEnable(); + void verifyCanDisable(); - + /** - * Verifies that this Controller Service can be disabled if the provided set of - * services are also disabled. This is introduced because we can have an instance - * where A references B, which references C, which references A and we want - * to disable service C. In this case, the cycle needs to not cause us to fail, - * so we want to verify that C can be disabled if A and B also are. - * - * @param ignoredReferences + * Verifies that this Controller Service can be disabled if the provided set + * of services are also disabled. This is introduced because we can have an + * instance where A references B, which references C, which references A and + * we want to disable service C. In this case, the cycle needs to not cause + * us to fail, so we want to verify that C can be disabled if A and B also + * are. + * + * @param ignoredReferences references to ignore */ void verifyCanDisable(Set ignoredReferences); - + /** - * Verifies that this Controller Service can be enabled if the provided set of - * services are also enabled. This is introduced because we can have an instance where - * A reference B, which references C, which references A and we want to enable - * Service A. In this case, the cycle needs to not cause us to fail, so we want to verify - * that A can be enabled if A and B also are. - * @param ignoredReferences + * Verifies that this Controller Service can be enabled if the provided set + * of services are also enabled. This is introduced because we can have an + * instance where A reference B, which references C, which references A and + * we want to enable Service A. In this case, the cycle needs to not cause + * us to fail, so we want to verify that A can be enabled if A and B also + * are. + * + * @param ignoredReferences to ignore */ void verifyCanEnable(Set ignoredReferences); - + void verifyCanDelete(); + void verifyCanUpdate(); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceProvider.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceProvider.java index 1901fb6521..a600699a95 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceProvider.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceProvider.java @@ -28,123 +28,149 @@ import org.apache.nifi.controller.ControllerServiceLookup; public interface ControllerServiceProvider extends ControllerServiceLookup { /** - * Creates a new Controller Service of the specified type and assigns it the given id. If firstTimeadded - * is true, calls any methods that are annotated with {@link OnAdded} + * Creates a new Controller Service of the specified type and assigns it the + * given id. If firstTimeadded is true, calls any methods that + * are annotated with {@link OnAdded} * - * @param type - * @param id - * @param firstTimeAdded - * @return + * @param type of service + * @param id of service + * @param firstTimeAdded for service + * @return the service node */ ControllerServiceNode createControllerService(String type, String id, boolean firstTimeAdded); /** - * Gets the controller service node for the specified identifier. Returns + * @param id of the service + * @return the controller service node for the specified identifier. Returns * null if the identifier does not match a known service - * - * @param id - * @return */ ControllerServiceNode getControllerServiceNode(String id); - + /** - * Removes the given Controller Service from the flow. This will call all appropriate methods - * that have the @OnRemoved annotation. - * + * Removes the given Controller Service from the flow. This will call all + * appropriate methods that have the @OnRemoved annotation. + * * @param serviceNode the controller service to remove - * - * @throws IllegalStateException if the controller service is not disabled or is not a part of this flow + * + * @throws IllegalStateException if the controller service is not disabled + * or is not a part of this flow */ void removeControllerService(ControllerServiceNode serviceNode); - + /** - * Enables the given controller service that it can be used by other components - * @param serviceNode + * Enables the given controller service that it can be used by other + * components + * + * @param serviceNode the service node */ void enableControllerService(ControllerServiceNode serviceNode); - + /** - * Enables the collection of services. If a service in this collection depends on another service, - * the service being depended on must either already be enabled or must be in the collection as well. - * @param serviceNodes + * Enables the collection of services. If a service in this collection + * depends on another service, the service being depended on must either + * already be enabled or must be in the collection as well. + * + * @param serviceNodes the nodes */ void enableControllerServices(Collection serviceNodes); - + /** - * Disables the given controller service so that it cannot be used by other components. This allows - * configuration to be updated or allows service to be removed. - * @param serviceNode + * Disables the given controller service so that it cannot be used by other + * components. This allows configuration to be updated or allows service to + * be removed. + * + * @param serviceNode the node */ void disableControllerService(ControllerServiceNode serviceNode); - + /** - * Returns a Set of all Controller Services that exist for this service provider. - * @return + * @return a Set of all Controller Services that exist for this service + * provider */ Set getAllControllerServices(); - + /** - * Verifies that all running Processors and Reporting Tasks referencing the Controller Service (or a service - * that depends on the provided service) can be stopped. - * @param serviceNode - * - * @throws IllegalStateException if any referencing component cannot be stopped + * Verifies that all running Processors and Reporting Tasks referencing the + * Controller Service (or a service that depends on the provided service) + * can be stopped. + * + * @param serviceNode the node + * + * @throws IllegalStateException if any referencing component cannot be + * stopped */ void verifyCanStopReferencingComponents(ControllerServiceNode serviceNode); - + /** - * Recursively unschedules all schedulable components (Processors and Reporting Tasks) that reference the given - * Controller Service. For any Controller services that reference this one, its schedulable referencing components will also - * be unscheduled. - * @param serviceNode + * Recursively unschedules all schedulable components (Processors and + * Reporting Tasks) that reference the given Controller Service. For any + * Controller services that reference this one, its schedulable referencing + * components will also be unscheduled. + * + * @param serviceNode the node */ void unscheduleReferencingComponents(ControllerServiceNode serviceNode); - + /** - * Verifies that all Controller Services referencing the provided Controller Service can be disabled. - * @param serviceNode - * - * @throws IllegalStateException if any referencing service cannot be disabled + * Verifies that all Controller Services referencing the provided Controller + * Service can be disabled. + * + * @param serviceNode the node + * + * @throws IllegalStateException if any referencing service cannot be + * disabled */ void verifyCanDisableReferencingServices(ControllerServiceNode serviceNode); - + /** - * Disables any Controller Service that references the provided Controller Service. This action is performed recursively - * so that if service A references B and B references C, disabling references for C will first disable A, then B. - * @param serviceNode + * Disables any Controller Service that references the provided Controller + * Service. This action is performed recursively so that if service A + * references B and B references C, disabling references for C will first + * disable A, then B. + * + * @param serviceNode the node */ void disableReferencingServices(ControllerServiceNode serviceNode); - + /** - * Verifies that all Controller Services referencing the provided ControllerService can be enabled. - * @param serviceNode - * - * @throws IllegalStateException if any referencing component cannot be enabled + * Verifies that all Controller Services referencing the provided + * ControllerService can be enabled. + * + * @param serviceNode the node + * + * @throws IllegalStateException if any referencing component cannot be + * enabled */ void verifyCanEnableReferencingServices(ControllerServiceNode serviceNode); - - + /** - * Enables all Controller Services that are referencing the given service. If Service A references Service B and Service - * B references serviceNode, Service A and B will both be enabled. - * @param serviceNode + * Enables all Controller Services that are referencing the given service. + * If Service A references Service B and Service B references serviceNode, + * Service A and B will both be enabled. + * + * @param serviceNode the node */ void enableReferencingServices(ControllerServiceNode serviceNode); - + /** - * Verifies that all enabled Processors referencing the ControllerService (or a service that depends on - * the provided service) can be scheduled to run. - * @param serviceNode - * - * @throws IllegalStateException if any referencing component cannot be scheduled + * Verifies that all enabled Processors referencing the ControllerService + * (or a service that depends on the provided service) can be scheduled to + * run. + * + * @param serviceNode the node + * + * @throws IllegalStateException if any referencing component cannot be + * scheduled */ void verifyCanScheduleReferencingComponents(ControllerServiceNode serviceNode); - + /** - * Schedules any schedulable component (Processor, ReportingTask) that is referencing the given Controller Service - * to run. This is performed recursively, so if a Processor is referencing Service A, which is referencing serviceNode, - * then the Processor will also be started. - * @param serviceNode + * Schedules any schedulable component (Processor, ReportingTask) that is + * referencing the given Controller Service to run. This is performed + * recursively, so if a Processor is referencing Service A, which is + * referencing serviceNode, then the Processor will also be started. + * + * @param serviceNode the node */ void scheduleReferencingComponents(ControllerServiceNode serviceNode); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceReference.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceReference.java index 67ffb6cb44..df18c62e56 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceReference.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceReference.java @@ -26,26 +26,21 @@ import org.apache.nifi.controller.ConfiguredComponent; public interface ControllerServiceReference { /** - * Returns the component that is being referenced - * - * @return + * @return the component that is being referenced */ ControllerServiceNode getReferencedComponent(); /** - * Returns a {@link Set} of all components that are referencing this + * @return a {@link Set} of all components that are referencing this * Controller Service - * - * @return */ Set getReferencingComponents(); /** - * Returns a {@link Set} of all Processors, Reporting Tasks, and Controller Services that are - * referencing the Controller Service and are running (in the case of Processors and Reporting Tasks) - * or enabled (in the case of Controller Services) - * - * @return + * @return a {@link Set} of all Processors, Reporting Tasks, and Controller + * Services that are referencing the Controller Service and are running (in + * the case of Processors and Reporting Tasks) or enabled (in the case of + * Controller Services) */ Set getActiveReferences(); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceState.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceState.java index 2ed8fd9316..63840e731b 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceState.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceState.java @@ -16,30 +16,28 @@ */ package org.apache.nifi.controller.service; - /** * Represents the valid states for a Controller Service. */ public enum ControllerServiceState { + /** * Controller Service is disabled and cannot be used. */ DISABLED, - /** - * Controller Service has been disabled but has not yet finished its lifecycle - * methods. + * Controller Service has been disabled but has not yet finished its + * lifecycle methods. */ DISABLING, - /** - * Controller Service has been enabled but has not yet finished its lifecycle methods. + * Controller Service has been enabled but has not yet finished its + * lifecycle methods. */ ENABLING, - /** - * Controller Service has been enabled and has finished its lifecycle methods. The Controller SErvice - * is ready to be used. + * Controller Service has been enabled and has finished its lifecycle + * methods. The Controller SErvice is ready to be used. */ ENABLED; } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/groups/ProcessGroup.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/groups/ProcessGroup.java index b898638bf6..a9cfb58599 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/groups/ProcessGroup.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/groups/ProcessGroup.java @@ -51,7 +51,7 @@ public interface ProcessGroup { /** * Updates the ProcessGroup to point to a new parent * - * @param group + * @param group new parent group */ void setParent(ProcessGroup group); @@ -68,19 +68,18 @@ public interface ProcessGroup { /** * Updates the name of this ProcessGroup. * - * @param name + * @param name new name */ void setName(String name); /** * Updates the position of where this ProcessGroup is located in the graph + * @param position new position */ void setPosition(Position position); /** - * Returns the position of where this ProcessGroup is located in the graph - * - * @return + * @return the position of where this ProcessGroup is located in the graph */ Position getPosition(); @@ -93,14 +92,12 @@ public interface ProcessGroup { /** * Updates the comments for this ProcessGroup * - * @param comments + * @param comments new comments */ void setComments(String comments); /** - * Returns the counts for this ProcessGroup - * - * @return + * @return the counts for this ProcessGroup */ ProcessGroupCounts getCounts(); @@ -129,18 +126,17 @@ public interface ProcessGroup { /** * Enables the given Input Port * - * @param port + * @param port to enable */ void enableInputPort(Port port); /** * Enables the given Output Port * - * @param port + * @param port to enable */ void enableOutputPort(Port port); - /** * Starts the given Processor * @@ -153,46 +149,45 @@ public interface ProcessGroup { /** * Starts the given Input Port * - * @param port + * @param port to start */ void startInputPort(Port port); /** * Starts the given Output Port * - * @param port + * @param port to start */ void startOutputPort(Port port); /** * Starts the given Funnel * - * @param funnel + * @param funnel to start */ void startFunnel(Funnel funnel); /** * Stops the given Processor * - * @param processor + * @param processor to stop */ void stopProcessor(ProcessorNode processor); /** * Stops the given Port * - * @param processor + * @param port to stop */ void stopInputPort(Port port); /** * Stops the given Port * - * @param processor + * @param port to stop */ void stopOutputPort(Port port); - /** * Disables the given Processor * @@ -205,18 +200,17 @@ public interface ProcessGroup { /** * Disables the given Input Port * - * @param port + * @param port to disable */ void disableInputPort(Port port); /** * Disables the given Output Port * - * @param port + * @param port to disable */ void disableOutputPort(Port port); - /** * Indicates that the Flow is being shutdown; allows cleanup of resources * associated with processors, etc. @@ -224,10 +218,8 @@ public interface ProcessGroup { void shutdown(); /** - * Returns a boolean indicating whether or not this ProcessGroup is the root + * @return a boolean indicating whether or not this ProcessGroup is the root * group - * - * @return */ boolean isRootGroup(); @@ -236,7 +228,7 @@ public interface ProcessGroup { * external sources to {@link Processor}s and other {@link Port}s within * this ProcessGroup. * - * @param port + * @param port to add */ void addInputPort(Port port); @@ -297,7 +289,7 @@ public interface ProcessGroup { /** * Adds a reference to a ProgressGroup as a child of this. * - * @return the newly created reference + * @param group to add */ void addProcessGroup(ProcessGroup group); @@ -305,8 +297,8 @@ public interface ProcessGroup { * Returns the ProcessGroup whose parent is this and whose id * is given * - * @param id - * @return + * @param id identifier of group to get + * @return child group */ ProcessGroup getProcessGroup(String id); @@ -363,12 +355,10 @@ public interface ProcessGroup { ProcessorNode getProcessor(String id); /** - * Returns the Connectable with the given ID, or + * @param id the ID of the Connectable + * @return the Connectable with the given ID, or * null if the Connectable is not a member of the * group - * - * @param id the ID of the Connectable - * @return */ Connectable getConnectable(String id); @@ -377,7 +367,7 @@ public interface ProcessGroup { * the Source and Destination of the Connection that the Connection has been * established. * - * @param connection + * @param connection to add * @throws NullPointerException if the connection is null * @throws IllegalStateException if the source or destination of the * connection is not a member of this ProcessGroup or if a connection @@ -388,7 +378,7 @@ public interface ProcessGroup { /** * Removes the connection from this ProcessGroup. * - * @param connection + * @param connection to remove * @throws IllegalStateException if connection is not contained * within this. */ @@ -404,35 +394,32 @@ public interface ProcessGroup { * this method does not notify either, as both the Source and Destination * should already be aware of the Connection. * - * @param connection + * @param connection to inherit */ void inheritConnection(Connection connection); /** + * @param id identifier of connection * @return the Connection with the given ID, or null if the * connection does not exist. */ Connection getConnection(String id); /** - * Returns the {@link Set} of all {@link Connection}s contained within this. - * - * @return + * @return the {@link Set} of all {@link Connection}s contained within this */ Set getConnections(); /** - * Returns a List of all Connections contains within this ProcessGroup and - * any child ProcessGroups. - * - * @return + * @return a List of all Connections contains within this ProcessGroup and + * any child ProcessGroups */ List findAllConnections(); /** * Adds the given RemoteProcessGroup to this ProcessGroup * - * @param remoteGroup + * @param remoteGroup group to add * * @throws NullPointerException if the given argument is null */ @@ -441,7 +428,7 @@ public interface ProcessGroup { /** * Removes the given RemoteProcessGroup from this ProcessGroup * - * @param remoteGroup + * @param remoteGroup group to remove * @throws NullPointerException if the argument is null * @throws IllegalStateException if the given argument does not belong to * this ProcessGroup @@ -449,21 +436,17 @@ public interface ProcessGroup { void removeRemoteProcessGroup(RemoteProcessGroup remoteGroup); /** - * Returns the RemoteProcessGroup that is the child of this ProcessGroup and + * @param id identifier of group to find + * @return the RemoteProcessGroup that is the child of this ProcessGroup and * has the given ID. If no RemoteProcessGroup can be found with the given - * ID, returns null. - * - * @param id - * @return + * ID, returns null */ RemoteProcessGroup getRemoteProcessGroup(String id); /** - * Returns a set of all RemoteProcessGroups that belong to this + * @return a set of all RemoteProcessGroups that belong to this * ProcessGroup. If no RemoteProcessGroup's have been added to this - * ProcessGroup, will return an empty Set. - * - * @return + * ProcessGroup, will return an empty Set */ Set getRemoteProcessGroups(); @@ -471,7 +454,6 @@ public interface ProcessGroup { * Adds the given Label to this ProcessGroup * * @param label the label to add - * @return * * @throws NullPointerException if the argument is null */ @@ -488,155 +470,129 @@ public interface ProcessGroup { void removeLabel(Label label); /** - * Returns a set of all Labels that belong to this ProcessGroup. If no - * Labels belong to this ProcessGroup, returns an empty Set. - * - * @return + * @return a set of all Labels that belong to this ProcessGroup. If no + * Labels belong to this ProcessGroup, returns an empty Set */ Set