diff --git a/nifi-nar-maven-plugin/pom.xml b/nifi-nar-maven-plugin/pom.xml index 7ba2d7c002..46dd33319d 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 @@ -163,24 +43,9 @@ - - 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 @@ -201,20 +66,9 @@ - - org.apache.rat - apache-rat-plugin - - - nb-configuration.xml - nbactions.xml - DEPENDENCIES - - - - + - + org.apache.maven maven-plugin-api @@ -240,27 +94,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..a7dd1ede34 --- /dev/null +++ b/nifi-parent/README.md @@ -0,0 +1,65 @@ + +# Apache NiFi Parent + +Apache NiFi Parent provides a nice aggregation of shared concerns for all NiFi Poms to follow + +## Table of Contents + +- [Getting Started](#getting-started) +- [License](#license) +- [Disclaimer](#disclaimer) + +## Getting Started + +- Build the nifi-parent module. Then you can go to the 'nifi-nar-maven-plugin' +directory and follow its instructions and finally the 'nifi' directory. Building +the nifi-parent and nifi-nar-maven-plugin should be rarely necessary as these +will be released infrequently by comparison to the 'nifi' tree. + +## 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..2e888c51e9 --- /dev/null +++ b/nifi-parent/pom.xml @@ -0,0 +1,396 @@ + + + + 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.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 + **/HelpMojo.java,**/generated-sources + + + + org.apache.rat + apache-rat-plugin + + + nb-configuration.xml + nbactions.xml + DEPENDENCIES + + + + + + org.apache.maven.doxia + doxia-core + 1.6 + + + xerces + xercesImpl + + + + + + + check-licenses + + check + + + + + + + + + checkstyle + + false + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + check-style + + check + + + + + + + + + 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/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/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..bd1e07d69a 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,18 +24,17 @@ 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 */ 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..f2f100bca6 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,11 +24,10 @@ 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 */ 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..8f4da55708 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,11 +25,10 @@ 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 */ 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..0506c089ba 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,13 +24,13 @@ 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 */ 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..0bdbbc6023 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,10 +24,11 @@ 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 */ 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..b82533552a 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,24 +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 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..120b6521ed 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,23 +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 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..f5250eaf0c 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,32 +25,38 @@ 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 */ 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..dd47a31dbb 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,21 +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 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..c2f25335f4 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,14 +46,15 @@ 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. + * 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. + * 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 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/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/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..2736044708 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 @@ -119,8 +119,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 +130,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 +143,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 +156,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/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..2aa90cc700 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 @@ -31,8 +31,9 @@ import java.lang.annotation.Target; * {@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/claim/ContentClaim.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/repository/claim/ContentClaim.java index e321217fd3..11a1620ac8 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 @@ -45,11 +45,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/ProcessGroupStatus.java b/nifi/nifi-api/src/main/java/org/apache/nifi/controller/status/ProcessGroupStatus.java index dba3a19b17..45acf8e206 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 @@ -43,6 +43,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 +229,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 +266,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 +337,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 +406,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 +463,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 +492,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 +522,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/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/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..fcb04ea510 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 @@ -54,7 +54,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/annotation/CapabilityDescription.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/annotation/CapabilityDescription.java index fad1ebb90d..8ca8290010 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 @@ -28,7 +28,8 @@ import java.lang.annotation.Target; * 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..53f1d72a3e 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 @@ -39,8 +39,8 @@ import java.lang.annotation.Target; *

    * * @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..1c2b709099 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 @@ -32,7 +32,8 @@ import java.lang.annotation.Target; * 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..239a449970 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 @@ -33,7 +33,8 @@ import java.lang.annotation.Target; * 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..3a716e630c 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 @@ -35,8 +35,9 @@ import java.lang.annotation.Target; * 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..22ecc0b0ff 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 @@ -29,7 +29,8 @@ import java.lang.annotation.Target; * 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..223868ec3b 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 @@ -46,7 +46,8 @@ import java.lang.annotation.Target; *

    * * @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..a2314355b0 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 @@ -37,7 +37,8 @@ import java.lang.annotation.Target; * 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..99980c563e 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 @@ -36,7 +36,8 @@ import java.lang.annotation.Target; * 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..7335a55e2d 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 @@ -41,7 +41,8 @@ import java.lang.annotation.Target; * 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..52c1079681 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 @@ -30,8 +30,9 @@ import java.lang.annotation.Target; * 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..8e8e5df1ce 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 @@ -30,7 +30,9 @@ import java.lang.annotation.Target; * 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..f27b111714 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 @@ -32,7 +32,8 @@ import java.lang.annotation.Target; * 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/io/InputStreamCallback.java b/nifi/nifi-api/src/main/java/org/apache/nifi/processor/io/InputStreamCallback.java index e227156d65..e850684832 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 @@ -30,8 +30,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..e37c37688b 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 @@ -31,8 +31,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..6fcdcaf51b 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 @@ -37,12 +37,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..73780db347 100644 --- a/nifi/nifi-assembly/NOTICE +++ b/nifi/nifi-assembly/NOTICE @@ -511,44 +511,31 @@ 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 - The following NOTICE information applies: - Google HTTP Client Library for Java - - This is free software, licensed under the Apache License, Version 2.0. - (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 diff --git a/nifi/nifi-assembly/pom.xml b/nifi/nifi-assembly/pom.xml index 260614cf88..0cc076a6a4 100644 --- a/nifi/nifi-assembly/pom.xml +++ b/nifi/nifi-assembly/pom.xml @@ -1,489 +1,490 @@ +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. --> - 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 - + 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 - - + + 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 + + +>>>>>>> upstream/develop - - - 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-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..d3796b5c9f 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,104 @@ 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); - 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 +380,577 @@ 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 ) { + 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"); } - + 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(); - + 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"); } } - - 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(); - 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(); - 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-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-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..4e3a502ede 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 @@ -360,7 +360,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); @@ -383,7 +383,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); @@ -414,7 +414,7 @@ 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); @@ -425,7 +425,7 @@ 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); @@ -504,7 +504,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)); } @@ -551,7 +551,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); @@ -829,7 +829,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<>(); 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/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..aae87609f2 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 @@ -60,12 +60,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 +113,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 +149,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..36d8bac8d4 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 ) { + 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/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/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/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/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/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..447d7013d4 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 @@ -78,7 +78,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-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..b0f40481d6 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,50 @@ 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. + * 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. + * 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..a05ea9de65 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 @@ -29,7 +29,7 @@ public interface VersionNegotiator { * Sets the version of this resource to the specified version. Only the * lower byte of the version is relevant. * - * @param version + * @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 @@ -47,8 +47,8 @@ public interface VersionNegotiator { * 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); @@ -56,8 +56,8 @@ public interface VersionNegotiator { * 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/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..311c84c531 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 @@ -61,7 +61,7 @@ public class CompressionOutputStream extends OutputStream { * 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..e613155183 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 @@ -42,7 +42,7 @@ public class BufferStateManager { * 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..19179bcdf1 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(); 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..bbc5cee49c 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 @@ -98,8 +98,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; @@ -170,8 +169,7 @@ public class ByteArrayOutputStream extends OutputStream { * @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); } 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..3e3e3fe96d 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 @@ -39,8 +39,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/LeakyBucketStreamThrottler.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/LeakyBucketStreamThrottler.java index ae075b5e30..ac6322d202 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) { 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..7d6d8d1db3 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,71 @@ 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/StreamUtils.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/StreamUtils.java index 8e3d606273..101a546287 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 @@ -44,10 +44,10 @@ public class StreamUtils { * 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]; @@ -68,9 +68,9 @@ public class StreamUtils { * 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); @@ -82,12 +82,12 @@ public class StreamUtils { * throws an EOFException if ensureCapacity is true and * otherwise returns the number of bytes copied * - * @param source - * @param destination + * @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 - * @throws IOException + * @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; @@ -114,19 +114,19 @@ public class StreamUtils { * 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)); } @@ -157,12 +157,12 @@ public class StreamUtils { * 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 +171,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 +220,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/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..b7a663c196 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,25 @@ 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/NaiveSearchRingBuffer.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/NaiveSearchRingBuffer.java index 85bfd96e67..b7831de789 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 @@ -60,12 +60,10 @@ public class NaiveSearchRingBuffer { } /** - * Returns the contents of the internal buffer, which represents the last X + * @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 - * - * @return */ public byte[] getBufferContents() { final int contentLength = Math.min(lookingFor.length, bufferSize); @@ -78,20 +76,16 @@ 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 + * @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 - * - * @return */ public boolean isFilled() { return bufferSize >= buffer.length; @@ -110,7 +104,7 @@ public class NaiveSearchRingBuffer { * Add the given byte to the buffer and notify whether or not the byte * completes the desired byte sequence. * - * @param data + * @param data the data to add to the buffer * @return true if this byte completes the byte sequence, * false otherwise. */ 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..b46bae58af 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 { @@ -46,8 +45,8 @@ public class RingBuffer { * 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 +134,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; @@ -209,7 +208,7 @@ public class RingBuffer { * 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); @@ -222,7 +221,7 @@ public class RingBuffer { * 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 the evaluator * @param iterationDirection the order in which to iterate over the elements * in the RingBuffer */ @@ -270,7 +269,7 @@ 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 * - * @param + * @param the type to evaluate */ public static interface ForEachEvaluator { @@ -278,8 +277,8 @@ public class RingBuffer { * 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..bc8ab75466 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,8 +55,8 @@ 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()} @@ -71,8 +71,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..73c8aa05e1 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; @@ -53,7 +52,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 +65,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) { @@ -98,9 +97,10 @@ 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 * - * @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); @@ -110,8 +110,8 @@ 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 * - * @param file - * @param logger + * @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 @@ -192,9 +192,9 @@ public class FileUtils { * 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); @@ -205,10 +205,10 @@ public class FileUtils { * 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); @@ -219,10 +219,10 @@ public class FileUtils { * 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 + * @param recurse whether to recurse subdirectories or not * @param deleteEmptyDirectories default is false; if true will delete * directories found that are empty */ @@ -248,9 +248,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) { @@ -352,8 +352,8 @@ public class FileUtils { * 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 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 @@ -369,11 +369,12 @@ public class FileUtils { * indicating the problem. * @return long number of bytes copied * @throws FileNotFoundException if the source file could not be found - * @throws IOException + * @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; @@ -436,16 +437,16 @@ public class FileUtils { * 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 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 + * @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 IOException if unable to read or write to file * @throws SecurityException if a security manager denies the needed file * operations */ 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..270d4d7cb3 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 @@ -61,8 +61,8 @@ public class SynchronousFileWatcher { * 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..f93902faf5 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 @@ -26,8 +26,6 @@ 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. * - * @author - * @param */ public interface Search { @@ -35,7 +33,7 @@ public interface Search { * 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); @@ -43,7 +41,7 @@ public interface Search { * Searches the given input stream for matches between the already specified * dictionary and the contents scanned. * - * @param haystack + * @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 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..a1d361e984 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,8 +32,8 @@ 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); @@ -46,9 +44,9 @@ public class SearchTerm { * 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 +82,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/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-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-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/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/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..a71484ee33 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 @@ -34,9 +34,7 @@ public class BulletinBoardDTO { private Date generated; /** - * The bulletins to populate in the bulletin board. - * - * @return + * @return bulletins to populate in the bulletin board */ public List getBulletins() { return bulletins; @@ -47,9 +45,7 @@ public class BulletinBoardDTO { } /** - * When this bulletin board was generated. - * - * @return + * @return when this bulletin board 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/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..239e7102f8 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 @@ -40,9 +40,7 @@ public class BulletinDTO { private Date timestamp; /** - * The id of this message. - * - * @return + * @return id of this message */ public Long getId() { return id; @@ -53,10 +51,8 @@ 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 */ public String getNodeAddress() { return nodeAddress; @@ -67,9 +63,7 @@ public class BulletinDTO { } /** - * The group id of the source component. - * - * @return + * @return group id of the source component */ public String getGroupId() { return groupId; @@ -80,9 +74,7 @@ public class BulletinDTO { } /** - * The category of this message. - * - * @return + * @return category of this message */ public String getCategory() { return category; @@ -93,9 +85,7 @@ public class BulletinDTO { } /** - * The actual message. - * - * @return + * @return actual message */ public String getMessage() { return message; @@ -106,9 +96,7 @@ public class BulletinDTO { } /** - * The id of the source of this message. - * - * @return + * @return id of the source of this message */ public String getSourceId() { return sourceId; @@ -119,9 +107,7 @@ public class BulletinDTO { } /** - * The name of the source of this message. - * - * @return + * @return name of the source of this message */ public String getSourceName() { return sourceName; @@ -132,9 +118,7 @@ public class BulletinDTO { } /** - * The level of this bulletin. - * - * @return + * @return level of this bulletin */ public String getLevel() { return level; @@ -145,9 +129,7 @@ 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) public Date getTimestamp() { 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..cf4146dce6 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 @@ -33,9 +33,7 @@ public class BulletinQueryDTO { private Integer limit; /** - * Include bulletins after this id. - * - * @return + * @return Include bulletins after this id */ public Long getAfter() { return after; @@ -46,9 +44,7 @@ public class BulletinQueryDTO { } /** - * Include bulletin within this group. Supports a regular expression. - * - * @return + * @return Include bulletin within this group. Supports a regular expression */ public String getGroupId() { return groupId; @@ -59,9 +55,7 @@ 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 */ public String getMessage() { return message; @@ -72,9 +66,7 @@ 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 */ public String getName() { return name; @@ -85,9 +77,7 @@ 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 */ public String getSourceId() { return sourceId; @@ -98,9 +88,7 @@ public class BulletinQueryDTO { } /** - * The maximum number of bulletins to return. - * - * @return + * @return 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..161e788cfc 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 @@ -33,9 +33,7 @@ public class ClusterDTO { private Date generated; /** - * The collection of the node DTOs. - * - * @return + * @return collection of the node DTOs */ public Collection getNodes() { return nodes; @@ -46,9 +44,7 @@ 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) 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/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..2345b0801c 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 @@ -29,9 +29,7 @@ public class ComponentHistoryDTO { private Map propertyHistory; /** - * The component id. - * - * @return + * @return component id */ public String getComponentId() { return componentId; @@ -42,9 +40,7 @@ public class ComponentHistoryDTO { } /** - * The history for this components properties. - * - * @return + * @return history for this components properties */ 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..199c73ea93 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 @@ -34,9 +34,7 @@ public class ConnectableDTO { private String comments; /** - * The id of this connectable component. - * - * @return + * @return id of this connectable component */ public String getId() { return id; @@ -47,9 +45,7 @@ public class ConnectableDTO { } /** - * The type of this connectable component. - * - * @return + * @return type of this connectable component */ public String getType() { return type; @@ -60,9 +56,7 @@ 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 */ public String getGroupId() { return groupId; @@ -73,9 +67,7 @@ public class ConnectableDTO { } /** - * The name of this connectable component. - * - * @return + * @return name of this connectable component */ public String getName() { return name; @@ -86,9 +78,7 @@ public class ConnectableDTO { } /** - * Used to reflect the current state of this Connectable. - * - * @return + * @return Used to reflect the current state of this Connectable */ public Boolean isRunning() { return running; @@ -99,10 +89,8 @@ 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 */ public Boolean getExists() { return exists; @@ -113,10 +101,8 @@ 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 */ public Boolean getTransmitting() { return transmitting; @@ -127,9 +113,7 @@ public class ConnectableDTO { } /** - * The comments from this Connectable. - * - * @return + * @return The comments from this Connectable */ 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..1bd382e5d0 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 @@ -67,9 +67,7 @@ public class ConnectionDTO extends NiFiComponentDTO { } /** - * The name of the connection. - * - * @return + * @return name of the connection */ public String getName() { return name; @@ -80,9 +78,7 @@ public class ConnectionDTO extends NiFiComponentDTO { } /** - * The position of the bend points on this connection. - * - * @return + * @return position of the bend points on this connection */ public List getBends() { return bends; @@ -93,10 +89,8 @@ 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 */ public Integer getLabelIndex() { return labelIndex; @@ -107,9 +101,7 @@ public class ConnectionDTO extends NiFiComponentDTO { } /** - * The z index for this connection. - * - * @return + * @return z index for this connection */ public Long getzIndex() { return zIndex; @@ -133,10 +125,8 @@ 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 */ public Set getAvailableRelationships() { return availableRelationships; 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..8e09fe7b4e 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 @@ -42,9 +42,7 @@ 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 */ public Integer getMaxTimerDrivenThreadCount() { return maxTimerDrivenThreadCount; @@ -55,9 +53,7 @@ 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 */ public Integer getMaxEventDrivenThreadCount() { return maxEventDrivenThreadCount; @@ -68,9 +64,7 @@ public class ControllerConfigurationDTO { } /** - * The name of this NiFi. - * - * @return The name + * @return name of this NiFi */ public String getName() { return name; @@ -81,9 +75,7 @@ public class ControllerConfigurationDTO { } /** - * The comments for this NiFi. - * - * @return + * @return comments for this NiFi */ public String getComments() { return comments; @@ -94,10 +86,8 @@ 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 */ public Long getAutoRefreshIntervalSeconds() { return autoRefreshIntervalSeconds; @@ -108,10 +98,8 @@ 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 */ public Boolean isSiteToSiteSecure() { return siteToSiteSecure; @@ -122,9 +110,7 @@ public class ControllerConfigurationDTO { } /** - * The current time on the server. - * - * @return + * @return current time on the server */ @XmlJavaTypeAdapter(TimeAdapter.class) public Date getCurrentTime() { @@ -136,9 +122,7 @@ public class ControllerConfigurationDTO { } /** - * The time offset of the server. - * - * @return + * @return time offset of the server */ public Integer getTimeOffset() { return timeOffset; @@ -149,9 +133,7 @@ public class ControllerConfigurationDTO { } /** - * Returns the URL for the content viewer if configured. - * - * @return + * @return the URL for the content viewer if configured */ public String getContentViewerUrl() { return contentViewerUrl; @@ -162,9 +144,7 @@ public class ControllerConfigurationDTO { } /** - * The URI for this NiFi controller. - * - * @return + * @return URI for this NiFi controller */ 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..c5ee057cd4 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 @@ -48,9 +48,7 @@ public class ControllerDTO { private Set outputPorts; /** - * The id of this NiFi controller. - * - * @return + * @return id of this NiFi controller */ public String getId() { return id; @@ -74,9 +72,7 @@ public class ControllerDTO { } /** - * The comments of this NiFi controller. - * - * @return + * @return comments of this NiFi controller */ public String getComments() { return comments; @@ -87,9 +83,7 @@ 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 */ public Set getInputPorts() { return inputPorts; @@ -100,9 +94,7 @@ 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 */ public Set getOutputPorts() { return outputPorts; @@ -113,10 +105,8 @@ public class ControllerDTO { } /** - * The Instance ID of the cluster, if this node is connected to a Cluster + * @return Instance ID of the cluster, if this node is connected to a Cluster * Manager, or of this individual instance of in standalone mode - * - * @return */ public String getInstanceId() { return instanceId; @@ -143,10 +133,8 @@ public class ControllerDTO { } /** - * Indicates whether or not Site-to-Site communications with this instance + * @return Indicates whether or not Site-to-Site communications with this instance * is secure (2-way authentication) - * - * @return */ public Boolean isSiteToSiteSecure() { return siteToSiteSecure; @@ -157,9 +145,7 @@ public class ControllerDTO { } /** - * The number of running components in this process group. - * - * @return + * @return number of running components in this process group */ public Integer getRunningCount() { return runningCount; @@ -170,9 +156,7 @@ public class ControllerDTO { } /** - * The number of stopped components in this process group. - * - * @return + * @return number of stopped components in this process group */ public Integer getStoppedCount() { return stoppedCount; @@ -183,9 +167,7 @@ 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 */ public Integer getActiveRemotePortCount() { return activeRemotePortCount; @@ -196,9 +178,7 @@ 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 */ public Integer getInactiveRemotePortCount() { return inactiveRemotePortCount; @@ -209,9 +189,7 @@ public class ControllerDTO { } /** - * The number of input ports contained in this process group. - * - * @return + * @return number of input ports contained in this process group */ public Integer getInputPortCount() { return inputPortCount; @@ -222,9 +200,7 @@ public class ControllerDTO { } /** - * The number of invalid components in this process group. - * - * @return + * @return number of invalid components in this process group */ public Integer getInvalidCount() { return invalidCount; @@ -235,9 +211,7 @@ public class ControllerDTO { } /** - * The number of disabled components in this process group. - * - * @return + * @return number of disabled components in this process group */ public Integer getDisabledCount() { return disabledCount; @@ -248,9 +222,7 @@ public class ControllerDTO { } /** - * The number of output ports in this process group. - * - * @return + * @return number of output ports in this process group */ 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..02ba2e23b7 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 @@ -32,21 +32,19 @@ 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 */ public String getName() { return name; @@ -57,9 +55,7 @@ public class ControllerServiceDTO extends NiFiComponentDTO { } /** - * The controller service type. - * - * @return + * @return the controller service type */ public String getType() { return type; @@ -68,24 +64,20 @@ 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 */ 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 */ public String getAvailability() { return availability; @@ -96,8 +88,8 @@ 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 */ public String getState() { return state; @@ -108,9 +100,7 @@ public class ControllerServiceDTO extends NiFiComponentDTO { } /** - * The controller service properties. - * - * @return + * @return controller service properties */ public Map getProperties() { return properties; @@ -121,9 +111,7 @@ public class ControllerServiceDTO extends NiFiComponentDTO { } /** - * The descriptors for the controller service properties. - * - * @return + * @return descriptors for the controller service properties */ public Map getDescriptors() { return descriptors; @@ -134,10 +122,8 @@ 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 */ public String getCustomUiUrl() { return customUiUrl; @@ -148,9 +134,7 @@ public class ControllerServiceDTO extends NiFiComponentDTO { } /** - * The annotation data for this controller service. - * - * @return + * @return annotation data for this controller service */ public String getAnnotationData() { return annotationData; @@ -161,9 +145,7 @@ public class ControllerServiceDTO extends NiFiComponentDTO { } /** - * All components referencing this controller service. - * - * @return + * @return all components referencing this controller service */ public Set getReferencingComponents() { return referencingComponents; @@ -174,9 +156,9 @@ 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 */ 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..4b557e1ca7 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 @@ -28,6 +28,7 @@ import javax.xml.bind.annotation.XmlType; */ @XmlType(name = "controllerServiceReferencingComponent") public class ControllerServiceReferencingComponentDTO { + private String groupId; private String id; private String name; @@ -36,20 +37,18 @@ 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 */ public String getGroupId() { return groupId; @@ -60,9 +59,7 @@ public class ControllerServiceReferencingComponentDTO { } /** - * The id for this component referencing a controller service. - * - * @return + * @return id for this component referencing a controller service */ public String getId() { return id; @@ -73,9 +70,7 @@ public class ControllerServiceReferencingComponentDTO { } /** - * The name for this component referencing a controller service. - * - * @return + * @return name for this component referencing a controller service */ public String getName() { return name; @@ -86,9 +81,7 @@ public class ControllerServiceReferencingComponentDTO { } /** - * The type for this component referencing a controller service. - * - * @return + * @return type for this component referencing a controller service */ public String getType() { return type; @@ -99,10 +92,8 @@ 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 */ public String getState() { return state; @@ -113,8 +104,8 @@ public class ControllerServiceReferencingComponentDTO { } /** - * The type of reference this is (Processor, ControllerService, or ReportingTask). - * @return + * @return type of reference this is (Processor, ControllerService, or + * ReportingTask) */ public String getReferenceType() { return referenceType; @@ -125,9 +116,7 @@ public class ControllerServiceReferencingComponentDTO { } /** - * The component properties. - * - * @return + * @return component properties */ public Map getProperties() { return properties; @@ -138,9 +127,7 @@ public class ControllerServiceReferencingComponentDTO { } /** - * The descriptors for the components properties. - * - * @return + * @return descriptors for the components properties */ public Map getDescriptors() { return descriptors; @@ -149,11 +136,9 @@ 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 */ public Collection getValidationErrors() { return validationErrors; @@ -162,11 +147,9 @@ 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 */ public Integer getActiveThreadCount() { return activeThreadCount; @@ -177,10 +160,8 @@ 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 */ public Set getReferencingComponents() { return referencingComponents; @@ -191,10 +172,8 @@ 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 */ public Boolean getReferenceCycle() { return referenceCycle; @@ -204,4 +183,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..2df4dd4612 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 @@ -32,9 +32,7 @@ public class CounterDTO { private String value; /** - * The context of the counter. - * - * @return + * @return context of the counter */ public String getContext() { return context; @@ -45,9 +43,7 @@ public class CounterDTO { } /** - * The id of the counter. - * - * @return + * @return id of the counter */ public String getId() { return id; @@ -58,9 +54,7 @@ public class CounterDTO { } /** - * The name of the counter - * - * @return + * @return name of the counter */ public String getName() { return name; @@ -71,9 +65,7 @@ public class CounterDTO { } /** - * The value for the counter - * - * @return + * @return value for the counter */ 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/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..d9f45e398e 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 @@ -33,9 +33,7 @@ public class CountersDTO { private Collection counters; /** - * Gets the collection of counters. - * - * @return + * @return the collection of counters */ public Collection getCounters() { return counters; @@ -46,9 +44,7 @@ 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) 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/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..2241d625d2 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 @@ -30,9 +30,7 @@ public class DocumentedTypeDTO { private Set tags; /** - * An optional description of the corresponding type. - * - * @return + * @return An optional description of the corresponding type */ public String getDescription() { return description; @@ -43,9 +41,7 @@ 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 */ public String getType() { return type; @@ -56,9 +52,7 @@ public class DocumentedTypeDTO { } /** - * The tags associated with this type. - * - * @return + * @return 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..5aec78feaf 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 @@ -35,11 +35,9 @@ 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 */ public Set getConnections() { return connections; @@ -50,9 +48,7 @@ public class FlowSnippetDTO { } /** - * The input ports in this flow snippet. - * - * @return + * @return input ports in this flow snippet */ public Set getInputPorts() { return inputPorts; @@ -63,9 +59,7 @@ public class FlowSnippetDTO { } /** - * The labels in this flow snippet. - * - * @return + * @return labels in this flow snippet */ public Set getLabels() { return labels; @@ -76,9 +70,7 @@ public class FlowSnippetDTO { } /** - * The funnels in this flow snippet. - * - * @return + * @return funnels in this flow snippet */ public Set getFunnels() { return funnels; @@ -89,9 +81,7 @@ public class FlowSnippetDTO { } /** - * The output ports in this flow snippet. - * - * @return + * @return output ports in this flow snippet */ public Set getOutputPorts() { return outputPorts; @@ -102,9 +92,7 @@ public class FlowSnippetDTO { } /** - * The process groups in this flow snippet. - * - * @return + * @return process groups in this flow snippet */ public Set getProcessGroups() { return processGroups; @@ -115,9 +103,7 @@ public class FlowSnippetDTO { } /** - * The processors in this flow group. - * - * @return + * @return processors in this flow group */ public Set getProcessors() { return processors; @@ -128,9 +114,7 @@ public class FlowSnippetDTO { } /** - * The remote process groups in this flow snippet. - * - * @return + * @return remote process groups in this flow snippet */ public Set getRemoteProcessGroups() { return remoteProcessGroups; @@ -141,8 +125,7 @@ public class FlowSnippetDTO { } /** - * Returns the Controller Services in this flow snippet - * @return + * @return 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..9339a07624 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 @@ -34,7 +34,7 @@ public class LabelDTO extends NiFiComponentDTO { // font-size = 12px // color = #eee - private Map style = Collections.emptyMap(); + private Map style; public LabelDTO() { } @@ -53,9 +53,7 @@ public class LabelDTO extends NiFiComponentDTO { } /** - * The style for this label. - * - * @return + * @return style for this label */ public Map getStyle() { return style; @@ -66,9 +64,7 @@ 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 */ public Double getHeight() { return height; @@ -79,9 +75,7 @@ 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 */ 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..1ed0676efd 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 @@ -55,9 +55,8 @@ 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 */ public String getParentGroupId() { return parentGroupId; 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..6aae62f982 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 @@ -41,9 +41,7 @@ public class NodeDTO { private Date nodeStartTime; /** - * The node's last heartbeat timestamp. - * - * @return + * @return node's last heartbeat timestamp */ @XmlJavaTypeAdapter(DateTimeAdapter.class) public Date getHeartbeat() { @@ -55,9 +53,7 @@ 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) public Date getConnectionRequested() { @@ -82,9 +78,7 @@ public class NodeDTO { } /** - * The queue for the controller. - * - * @return + * @return queue for the controller */ public String getQueued() { return queued; @@ -95,9 +89,7 @@ public class NodeDTO { } /** - * The node's host/IP address. - * - * @return + * @return node's host/IP address */ public String getAddress() { return address; @@ -108,9 +100,7 @@ public class NodeDTO { } /** - * The node ID. - * - * @return + * @return node ID */ public String getNodeId() { return nodeId; @@ -121,9 +111,7 @@ public class NodeDTO { } /** - * The port the node is listening for API requests. - * - * @return + * @return port the node is listening for API requests */ public Integer getApiPort() { return apiPort; @@ -134,9 +122,7 @@ public class NodeDTO { } /** - * The node's status. - * - * @return + * @return node's status */ public String getStatus() { return status; @@ -147,9 +133,7 @@ public class NodeDTO { } /** - * The node's events. - * - * @return + * @return node's events */ public List getEvents() { return events; @@ -160,9 +144,7 @@ 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 */ public Boolean isPrimary() { return primary; @@ -173,9 +155,7 @@ 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) public Date getNodeStartTime() { 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..7d8273fdbe 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 @@ -32,9 +32,7 @@ public class NodeEventDTO { private String message; /** - * The category of the node event. - * - * @return + * @return category of the node event */ public String getCategory() { return category; @@ -45,9 +43,7 @@ public class NodeEventDTO { } /** - * The message of the node event. - * - * @return + * @return message of the node event */ public String getMessage() { return message; @@ -58,9 +54,7 @@ public class NodeEventDTO { } /** - * The timestamp of the node event. - * - * @return + * @return timestamp of the node event */ @XmlJavaTypeAdapter(DateTimeAdapter.class) public Date getTimestamp() { 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..f7aff7961d 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 @@ -28,9 +28,7 @@ public class NodeSystemDiagnosticsDTO { private SystemDiagnosticsDTO systemDiagnostics; /** - * The node. - * - * @return + * @return the node */ public NodeDTO getNode() { return node; @@ -41,9 +39,7 @@ public class NodeSystemDiagnosticsDTO { } /** - * The system diagnostics. - * - * @return + * @return the system diagnostics */ 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..464beafb63 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 @@ -38,9 +38,7 @@ public class PortDTO extends NiFiComponentDTO { private Collection validationErrors; /** - * The name of this port. - * - * @return + * @return name of this port */ public String getName() { return name; @@ -51,10 +49,8 @@ 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' */ public String getState() { return state; @@ -67,7 +63,7 @@ public class PortDTO extends NiFiComponentDTO { /** * The type of port. Possible values are 'INPUT_PORT' or 'OUTPUT_PORT'. * - * @return + * @return The type of port */ public String getType() { return type; @@ -78,9 +74,7 @@ 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 */ public Integer getConcurrentlySchedulableTaskCount() { return concurrentlySchedulableTaskCount; @@ -91,9 +85,7 @@ public class PortDTO extends NiFiComponentDTO { } /** - * The comments for this port. - * - * @return + * @return comments for this port */ public String getComments() { return comments; @@ -104,10 +96,8 @@ 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 */ public Boolean isTransmitting() { return transmitting; @@ -118,9 +108,7 @@ public class PortDTO extends NiFiComponentDTO { } /** - * Groups that are allowed to access this port. - * - * @return + * @return groups that are allowed to access this port */ public Set getGroupAccessControl() { return groupAccessControl; @@ -131,9 +119,7 @@ public class PortDTO extends NiFiComponentDTO { } /** - * Users that are allowed to access this port. - * - * @return + * @return users that are allowed to access this port */ public Set getUserAccessControl() { return userAccessControl; 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..5b0f3864f0 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 @@ -37,9 +37,7 @@ public class PositionDTO { /* getters / setters */ /** - * The x coordinate. - * - * @return + * @return the x coordinate */ public Double getX() { return x; @@ -50,9 +48,7 @@ public class PositionDTO { } /** - * The y coordinate. - * - * @return + * @return 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..458a2b390b 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 @@ -32,9 +32,7 @@ public class PreviousValueDTO { private String userName; /** - * The previous value. - * - * @return + * @return previous value */ public String getPreviousValue() { return previousValue; @@ -45,9 +43,7 @@ public class PreviousValueDTO { } /** - * When it was modified. - * - * @return + * @return when it was modified */ @XmlJavaTypeAdapter(DateTimeAdapter.class) public Date getTimestamp() { @@ -59,9 +55,7 @@ public class PreviousValueDTO { } /** - * The user who changed the previous value. - * - * @return + * @return 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..870c32ad63 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 @@ -73,9 +73,7 @@ public class ProcessGroupDTO extends NiFiComponentDTO { } /** - * The comments for this process group. - * - * @return + * @return comments for this process group */ public String getComments() { return comments; @@ -86,10 +84,8 @@ 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 */ public FlowSnippetDTO getContents() { return contents; @@ -100,9 +96,7 @@ 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 */ public Integer getInputPortCount() { return inputPortCount; @@ -113,9 +107,7 @@ public class ProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of invalid components in this process group. - * - * @return + * @return number of invalid components in this process group */ public Integer getInvalidCount() { return invalidCount; @@ -126,9 +118,7 @@ public class ProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of output ports in this process group. - * - * @return + * @return number of output ports in this process group */ public Integer getOutputPortCount() { return outputPortCount; @@ -139,9 +129,7 @@ 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 */ public Boolean isRunning() { return running; @@ -152,9 +140,7 @@ public class ProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of running component in this process group. - * - * @return + * @return number of running component in this process group */ public Integer getRunningCount() { return runningCount; @@ -165,9 +151,7 @@ public class ProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of stopped components in this process group. - * - * @return + * @return number of stopped components in this process group */ public Integer getStoppedCount() { return stoppedCount; @@ -178,9 +162,7 @@ public class ProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of disabled components in this process group. - * - * @return + * @return number of disabled components in this process group */ public Integer getDisabledCount() { return disabledCount; @@ -191,9 +173,7 @@ 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 */ public Integer getActiveRemotePortCount() { return activeRemotePortCount; @@ -204,9 +184,7 @@ 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 */ 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..b507033b68 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 @@ -54,8 +54,8 @@ 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 */ @@ -71,7 +71,7 @@ public class ProcessorConfigDTO { * Indicates whether the processor should be scheduled to run in * event-driven mode or timer-driven mode * - * @return + * @return scheduling strategy */ public String getSchedulingStrategy() { return schedulingStrategy; @@ -82,10 +82,7 @@ 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 flow file */ public String getPenaltyDuration() { return penaltyDuration; @@ -96,10 +93,8 @@ public class ProcessorConfigDTO { } /** - * When yielding, this amount of time must elaspe before this processor is - * scheduled again. - * - * @return + * @return amount of time must elaspe before this processor is + * scheduled again when yielding */ public String getYieldDuration() { return yieldDuration; @@ -110,9 +105,7 @@ public class ProcessorConfigDTO { } /** - * The level at this this processor will report bulletins. - * - * @return + * @return the level at this this processor will report bulletins */ public String getBulletinLevel() { return bulletinLevel; @@ -127,7 +120,7 @@ public class ProcessorConfigDTO { * 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 */ public Integer getConcurrentlySchedulableTaskCount() { return concurrentlySchedulableTaskCount; @@ -138,9 +131,7 @@ public class ProcessorConfigDTO { } /** - * Whether or not this Processor is Loss Tolerant - * - * @return + * @return whether or not this Processor is Loss Tolerant */ public Boolean isLossTolerant() { return lossTolerant; @@ -151,9 +142,7 @@ public class ProcessorConfigDTO { } /** - * The comments for this processor. - * - * @return The comments + * @return the comments */ public String getComments() { return comments; @@ -181,9 +170,7 @@ public class ProcessorConfigDTO { } /** - * The descriptors for this processor's properties. - * - * @return + * @return descriptors for this processor's properties */ public Map getDescriptors() { return descriptors; @@ -207,10 +194,8 @@ 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. */ public String getCustomUiUrl() { return customUiUrl; @@ -221,10 +206,8 @@ public class ProcessorConfigDTO { } /** - * The names of all processor relationships that cause a flow file to be + * @return the names of all processor relationships that cause a flow file to be * terminated if the relationship is not connected to anything - * - * @return */ public Set getAutoTerminatedRelationships() { return autoTerminatedRelationships; @@ -235,10 +218,8 @@ public class ProcessorConfigDTO { } /** - * Maps default values for concurrent tasks for each applicable scheduling + * @return maps default values for concurrent tasks for each applicable scheduling * strategy. - * - * @return */ public Map getDefaultConcurrentTasks() { return defaultConcurrentTasks; @@ -249,9 +230,7 @@ public class ProcessorConfigDTO { } /** - * The run duration in milliseconds. - * - * @return + * @return run duration in milliseconds */ public Long getRunDurationMillis() { return runDurationMillis; @@ -262,10 +241,8 @@ 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 */ 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..cda26cdc40 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 @@ -71,10 +71,8 @@ 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' */ public String getState() { return state; @@ -85,9 +83,7 @@ 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) */ public Map getStyle() { return style; @@ -98,9 +94,7 @@ public class ProcessorDTO extends NiFiComponentDTO { } /** - * Whether this processor supports parallel processing. - * - * @return + * @return whether this processor supports parallel processing */ public Boolean getSupportsParallelProcessing() { return supportsParallelProcessing; @@ -111,9 +105,7 @@ public class ProcessorDTO extends NiFiComponentDTO { } /** - * Whether this processor supports event driven scheduling. - * - * @return + * @return whether this processor supports event driven scheduling */ public Boolean getSupportsEventDriven() { return supportsEventDriven; @@ -166,9 +158,7 @@ public class ProcessorDTO extends NiFiComponentDTO { } /** - * Gets the description for this processor. - * - * @return + * @return the description for this 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..af3de2b91a 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 @@ -37,10 +37,8 @@ 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 */ public List getAllowableValues() { return allowableValues; @@ -51,9 +49,7 @@ public class PropertyDescriptorDTO { } /** - * The default value for this property. - * - * @return + * @return default value for this property */ public String getDefaultValue() { return defaultValue; @@ -64,11 +60,9 @@ public class PropertyDescriptorDTO { } /** - * And explanation of the meaning of the given property. This + * @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. - * - * @return + * mechanism of documenting intent */ public String getDescription() { return description; @@ -79,9 +73,7 @@ public class PropertyDescriptorDTO { } /** - * The property name. - * - * @return + * @return property name */ public String getName() { return name; @@ -92,9 +84,7 @@ public class PropertyDescriptorDTO { } /** - * The human-readable name to display to users. - * - * @return + * @return human-readable name to display to users */ public String getDisplayName() { return displayName; @@ -105,9 +95,7 @@ public class PropertyDescriptorDTO { } /** - * Determines whether the property is required for this processor. - * - * @return + * @return whether the property is required for this processor */ public boolean isRequired() { return required; @@ -118,10 +106,8 @@ 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 */ public boolean isSensitive() { return sensitive; @@ -132,9 +118,7 @@ public class PropertyDescriptorDTO { } /** - * Indicates whether this property is dynamic. - * - * @return + * @return indicates whether this property is dynamic */ public boolean isDynamic() { return dynamic; @@ -145,9 +129,8 @@ public class PropertyDescriptorDTO { } /** - * Specifies whether or not this property support expression language. - * - * @return + * @return specifies whether or not this property support expression + * language */ public boolean getSupportsEl() { return supportsEl; @@ -158,10 +141,8 @@ 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 */ public String getIdentifiesControllerService() { return identifiesControllerService; @@ -170,7 +151,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,10 +163,8 @@ public class PropertyDescriptorDTO { private String description; /** - * Returns the human-readable value that is allowed for this + * @return the human-readable value that is allowed for this * PropertyDescriptor - * - * @return */ public String getDisplayName() { return displayName; @@ -196,9 +175,7 @@ public class PropertyDescriptorDTO { } /** - * Returns the value for this allowable value. - * - * @return + * @return the value for this allowable value */ public String getValue() { return value; @@ -209,10 +186,8 @@ public class PropertyDescriptorDTO { } /** - * Returns a description of this Allowable Value, or null + * @return a description of this Allowable Value, or null * if no description is given - * - * @return */ 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..5dc5b99c19 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 @@ -28,9 +28,7 @@ public class PropertyHistoryDTO { private List previousValues; /** - * The previous values. - * - * @return + * @return previous values */ 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..a9fbfc6e66 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 @@ -29,9 +29,7 @@ public class RelationshipDTO { private Boolean autoTerminate; /** - * The relationship name. - * - * @return + * @return the relationship name */ public String getName() { return name; @@ -42,9 +40,7 @@ public class RelationshipDTO { } /** - * The relationship description. - * - * @return + * @return the relationship description */ public String getDescription() { return description; @@ -55,9 +51,7 @@ public class RelationshipDTO { } /** - * Whether or not this relationship is auto terminated. - * - * @return + * @return true if relationship is auto terminated;false otherwise */ 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..3645eb8ade 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 @@ -29,9 +29,7 @@ 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 */ public Set getInputPorts() { return inputPorts; @@ -42,9 +40,7 @@ public class RemoteProcessGroupContentsDTO { } /** - * The Controller Output Ports from which data can be retrieved - * - * @return + * @return Controller 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..22bbee0d94 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 @@ -67,18 +67,14 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * The target uri of this remote process group. - * - * @return + * @return target uri of this 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 */ public void setName(final String name) { this.name = name; @@ -89,9 +85,7 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * Comments for this remote process group. - * - * @return + * @return Comments for this remote process group */ public String getComments() { return comments; @@ -102,9 +96,7 @@ 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 */ public List getAuthorizationIssues() { return authorizationIssues; @@ -115,9 +107,7 @@ 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 */ public Boolean isTransmitting() { return transmitting; @@ -128,9 +118,7 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * Whether or not the target is running securely. - * - * @return + * @return whether or not the target is running securely */ public Boolean isTargetSecure() { return targetSecure; @@ -141,10 +129,8 @@ 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 */ public String getCommunicationsTimeout() { return communicationsTimeout; @@ -155,10 +141,8 @@ 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 elaspe before this remote process + * group is scheduled again */ public String getYieldDuration() { return yieldDuration; @@ -169,9 +153,7 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of active remote input ports. - * - * @return + * @return number of active remote input ports */ public Integer getActiveRemoteInputPortCount() { return activeRemoteInputPortCount; @@ -182,9 +164,7 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of inactive remote input ports. - * - * @return + * @return number of inactive remote input ports */ public Integer getInactiveRemoteInputPortCount() { return inactiveRemoteInputPortCount; @@ -195,9 +175,7 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of active remote output ports. - * - * @return + * @return number of active remote output ports */ public Integer getActiveRemoteOutputPortCount() { return activeRemoteOutputPortCount; @@ -208,9 +186,7 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of inactive remote output ports. - * - * @return + * @return number of inactive remote output ports */ public Integer getInactiveRemoteOutputPortCount() { return inactiveRemoteOutputPortCount; @@ -221,10 +197,8 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of Remote Input Ports currently available in the remote NiFi + * @return number of Remote Input Ports currently available in the remote NiFi * instance - * - * @return */ public Integer getInputPortCount() { return inputPortCount; @@ -235,10 +209,8 @@ public class RemoteProcessGroupDTO extends NiFiComponentDTO { } /** - * The number of Remote Output Ports currently available in the remote NiFi + * @return number of Remote Output Ports currently available in the remote NiFi * instance - * - * @return */ public Integer getOutputPortCount() { return outputPortCount; @@ -249,10 +221,8 @@ 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 */ public RemoteProcessGroupContentsDTO getContents() { return contents; @@ -263,9 +233,7 @@ 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) public Date getFlowRefreshed() { 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..71d0f661d7 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 @@ -36,9 +36,7 @@ public class RemoteProcessGroupPortDTO { private Boolean connected; /** - * The comments as configured in the target port. - * - * @return + * @return comments as configured in the target port */ public String getComments() { return comments; @@ -49,10 +47,8 @@ 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 */ public Integer getConcurrentlySchedulableTaskCount() { return concurrentlySchedulableTaskCount; @@ -63,9 +59,7 @@ public class RemoteProcessGroupPortDTO { } /** - * The id of the target port. - * - * @return + * @return id of the target port */ public String getId() { return id; @@ -76,9 +70,7 @@ 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 */ public String getGroupId() { return groupId; @@ -89,9 +81,7 @@ public class RemoteProcessGroupPortDTO { } /** - * The name of the target port. - * - * @return + * @return name of the target port */ public String getName() { return name; @@ -102,9 +92,7 @@ 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 */ public Boolean isTransmitting() { return transmitting; @@ -115,9 +103,7 @@ 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 */ public Boolean getUseCompression() { return useCompression; @@ -128,9 +114,7 @@ public class RemoteProcessGroupPortDTO { } /** - * Whether or not the target port exists. - * - * @return + * @return whether or not the target port exists */ public Boolean getExists() { return exists; @@ -141,9 +125,7 @@ public class RemoteProcessGroupPortDTO { } /** - * Whether or not the target port is running. - * - * @return + * @return whether or not the target port is running */ public Boolean isTargetRunning() { return targetRunning; @@ -154,9 +136,7 @@ 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 */ 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..6b6558ae4a 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 @@ -22,147 +22,138 @@ import java.util.Map; import javax.xml.bind.annotation.XmlType; /** - * Component that is capable of reporting internal NiFi state to an external service + * Component that is capable of reporting internal NiFi state to an external + * service */ @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; - } + 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 + */ + 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 + */ + 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; - } + 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 + */ + 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 + */ + public String getSchedulingStrategy() { + return schedulingStrategy; + } + + public void setSchedulingStrategy(String schedulingStrategy) { + this.schedulingStrategy = schedulingStrategy; + } + + /** + * @return Where this service is available. Possible values are + * CLUSTER_MANAGER_ONLY, NODE_ONLY, BOTH + */ + public String getAvailability() { + return availability; + } + + public void setAvailability(String availability) { + this.availability = availability; + } + + /** + * @return reporting task's properties + */ + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties = properties; + } + + /** + * @return Map of property name to descriptor + */ + 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 */ public String getCustomUiUrl() { return customUiUrl; @@ -172,22 +163,21 @@ 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 + */ + 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 */ @@ -200,9 +190,7 @@ public class ReportingTaskDTO extends NiFiComponentDTO { } /** - * The default scheduling period for the different scheduling strategies. - * - * @return + * @return default scheduling period for the different scheduling strategies */ public Map getDefaultSchedulingPeriod() { return defaultSchedulingPeriod; @@ -213,9 +201,7 @@ public class ReportingTaskDTO extends NiFiComponentDTO { } /** - * The number of active threads for this reporting task. - * - * @return + * @return number of active threads for this 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..7a60c6edd2 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 @@ -29,7 +29,6 @@ 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 @@ -63,9 +62,7 @@ public class RevisionDTO { } /** - * The user that last modified the flow. - * - * @return + * @return 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..8e2c21501b 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 @@ -44,9 +44,7 @@ public class SnippetDTO { private FlowSnippetDTO contents; /** - * The id of this snippet. - * - * @return + * @return id of this snippet */ public String getId() { return id; @@ -57,9 +55,7 @@ public class SnippetDTO { } /** - * The uri of this snippet. - * - * @return + * @return uri of this snippet */ public String getUri() { return uri; @@ -70,9 +66,7 @@ public class SnippetDTO { } /** - * The group id for the components in this snippet. - * - * @return + * @return group id for the components in this snippet */ public String getParentGroupId() { return parentGroupId; @@ -83,9 +77,7 @@ 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 */ public Boolean isLinked() { return linked; @@ -96,12 +88,10 @@ public class SnippetDTO { } /** - * The ids of the connections in this snippet. These ids will be populated + * @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). - * - * @return + * (these ids are ignored during update requests) */ public Set getConnections() { return connections; @@ -112,12 +102,10 @@ public class SnippetDTO { } /** - * The ids of the funnels in this snippet. These ids will be populated + * @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). - * - * @param funnels + * (these ids are ignored during update requests) */ public Set getFunnels() { return funnels; @@ -128,12 +116,10 @@ public class SnippetDTO { } /** - * The ids of the input port in this snippet. These ids will be populated + * @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). - * - * @return + * (these ids are ignored during update requests) */ public Set getInputPorts() { return inputPorts; @@ -144,12 +130,10 @@ public class SnippetDTO { } /** - * The ids of the labels in this snippet. These ids will be populated within + * @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). - * - * @return + * ids are ignored during update requests) */ public Set getLabels() { return labels; @@ -160,12 +144,10 @@ public class SnippetDTO { } /** - * The ids of the output ports in this snippet. These ids will be populated + * @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). - * - * @return + * (these ids are ignored during update requests) */ public Set getOutputPorts() { return outputPorts; @@ -176,12 +158,10 @@ public class SnippetDTO { } /** - * The ids of the process groups in this snippet. These ids will be + * @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). - * - * @return + * modified (these ids are ignored during update requests) */ public Set getProcessGroups() { return processGroups; @@ -192,12 +172,10 @@ public class SnippetDTO { } /** - * The ids of the processors in this snippet. These ids will be populated + * @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). - * - * @return + * (these ids are ignored during update requests) */ public Set getProcessors() { return processors; @@ -208,12 +186,10 @@ public class SnippetDTO { } /** - * The ids of the remote process groups in this snippet. These ids will be + * @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). - * - * @return + * modified (these ids are ignored during update requests) */ public Set getRemoteProcessGroups() { return remoteProcessGroups; @@ -224,9 +200,7 @@ public class SnippetDTO { } /** - * The contents of the configuration for this snippet. - * - * @return + * @return the contents of the configuration for this 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..f39cbafffd 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 @@ -54,9 +54,7 @@ public class SystemDiagnosticsDTO { /* getters / setters */ /** - * The number of available processors, if supported. - * - * @return + * @return number of available processors, if supported */ public Integer getAvailableProcessors() { return availableProcessors; @@ -67,9 +65,7 @@ public class SystemDiagnosticsDTO { } /** - * The number of daemon threads. - * - * @return + * @return number of daemon threads */ public Integer getDaemonThreads() { return daemonThreads; @@ -80,9 +76,7 @@ public class SystemDiagnosticsDTO { } /** - * The amount of free heap. - * - * @return + * @return amount of free heap */ public String getFreeHeap() { return freeHeap; @@ -93,9 +87,7 @@ public class SystemDiagnosticsDTO { } /** - * The amount of free non-heap. - * - * @return + * @return amount of free non-heap */ public String getFreeNonHeap() { return freeNonHeap; @@ -106,9 +98,7 @@ public class SystemDiagnosticsDTO { } /** - * The max size of the heap. - * - * @return + * @return max size of the heap */ public String getMaxHeap() { return maxHeap; @@ -119,9 +109,7 @@ public class SystemDiagnosticsDTO { } /** - * The max size of the non-heap. - * - * @return + * @return max size of the non-heap */ public String getMaxNonHeap() { return maxNonHeap; @@ -132,9 +120,7 @@ public class SystemDiagnosticsDTO { } /** - * The processor load average, if supported. - * - * @return + * @return processor load average, if supported */ public Double getProcessorLoadAverage() { return processorLoadAverage; @@ -145,9 +131,7 @@ public class SystemDiagnosticsDTO { } /** - * The total size of the heap. - * - * @return + * @return total size of the heap */ public String getTotalHeap() { return totalHeap; @@ -158,9 +142,7 @@ public class SystemDiagnosticsDTO { } /** - * The total size of non-heap. - * - * @return + * @return total size of non-heap */ public String getTotalNonHeap() { return totalNonHeap; @@ -171,9 +153,7 @@ public class SystemDiagnosticsDTO { } /** - * The total number of threads. - * - * @return + * @return total number of threads */ public Integer getTotalThreads() { return totalThreads; @@ -184,9 +164,7 @@ public class SystemDiagnosticsDTO { } /** - * The amount of used heap. - * - * @return + * @return amount of used heap */ public String getUsedHeap() { return usedHeap; @@ -197,9 +175,7 @@ public class SystemDiagnosticsDTO { } /** - * The amount of used non-heap. - * - * @return + * @return amount of used non-heap */ public String getUsedNonHeap() { return usedNonHeap; @@ -210,9 +186,7 @@ public class SystemDiagnosticsDTO { } /** - * The heap utilization. - * - * @return + * @return heap utilization */ public String getHeapUtilization() { return heapUtilization; @@ -223,9 +197,7 @@ public class SystemDiagnosticsDTO { } /** - * The non-heap utilization. - * - * @return + * @return non-heap utilization */ public String getNonHeapUtilization() { return nonHeapUtilization; @@ -236,9 +208,7 @@ public class SystemDiagnosticsDTO { } /** - * The content repository storage usage. - * - * @return + * @return content repository storage usage */ public Set getContentRepositoryStorageUsage() { return contentRepositoryStorageUsage; @@ -249,9 +219,7 @@ public class SystemDiagnosticsDTO { } /** - * The flowfile repository storage usage. - * - * @return + * @return flowfile repository storage usage */ public StorageUsageDTO getFlowFileRepositoryStorageUsage() { return flowFileRepositoryStorageUsage; @@ -262,9 +230,7 @@ public class SystemDiagnosticsDTO { } /** - * Garbage collection details. - * - * @return + * @return Garbage collection details */ public Set getGarbageCollection() { return garbageCollection; @@ -275,9 +241,7 @@ public class SystemDiagnosticsDTO { } /** - * When these diagnostics were generated. - * - * @return + * @return When these diagnostics were generated */ @XmlJavaTypeAdapter(TimeAdapter.class) public Date getStatsLastRefreshed() { @@ -304,9 +268,7 @@ public class SystemDiagnosticsDTO { private String utilization; /** - * The identifier for this storage location. - * - * @return + * @return identifier for this storage location */ public String getIdentifier() { return identifier; @@ -317,9 +279,7 @@ public class SystemDiagnosticsDTO { } /** - * The amount of free space. - * - * @return + * @return amount of free space */ public String getFreeSpace() { return freeSpace; @@ -330,9 +290,7 @@ public class SystemDiagnosticsDTO { } /** - * The amount of total space. - * - * @param freeSpace + * @return freeSpace amount of total space */ public String getTotalSpace() { return totalSpace; @@ -343,9 +301,7 @@ public class SystemDiagnosticsDTO { } /** - * The amount of used space. - * - * @return + * @return amount of used space */ public String getUsedSpace() { return usedSpace; @@ -356,9 +312,7 @@ public class SystemDiagnosticsDTO { } /** - * The utilization of this storage location. - * - * @return + * @return utilization of this storage location */ public String getUtilization() { return utilization; @@ -369,9 +323,7 @@ public class SystemDiagnosticsDTO { } /** - * The number of bytes of free space. - * - * @return + * @return number of bytes of free space */ public Long getFreeSpaceBytes() { return freeSpaceBytes; @@ -382,9 +334,7 @@ public class SystemDiagnosticsDTO { } /** - * The number of bytes of total space. - * - * @return + * @return number of bytes of total space */ public Long getTotalSpaceBytes() { return totalSpaceBytes; @@ -395,9 +345,7 @@ public class SystemDiagnosticsDTO { } /** - * The number of bytes of used space. - * - * @return + * @return number of bytes of used space */ public Long getUsedSpaceBytes() { return usedSpaceBytes; @@ -419,9 +367,7 @@ public class SystemDiagnosticsDTO { private String collectionTime; /** - * The name of the garbage collector. - * - * @return + * @return name of the garbage collector */ public String getName() { return name; @@ -436,18 +382,14 @@ public class SystemDiagnosticsDTO { } /** - * 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 */ 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..635e3e81cb 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 @@ -37,9 +37,7 @@ public class TemplateDTO { private FlowSnippetDTO snippet; /** - * The id for this template. - * - * @return + * @return id for this template */ public String getId() { return id; @@ -50,9 +48,7 @@ public class TemplateDTO { } /** - * The uri for this template. - * - * @return + * @return uri for this template */ public String getUri() { return uri; @@ -63,9 +59,7 @@ public class TemplateDTO { } /** - * The name of this template. - * - * @return + * @return name of this template */ public String getName() { return name; @@ -76,9 +70,7 @@ public class TemplateDTO { } /** - * The description of this template. - * - * @return + * @return description of this template */ public String getDescription() { return description; @@ -89,9 +81,7 @@ public class TemplateDTO { } /** - * The timestamp when this template was created. - * - * @return + * @return timestamp when this template was created */ @XmlJavaTypeAdapter(DateTimeAdapter.class) public Date getTimestamp() { @@ -103,9 +93,7 @@ public class TemplateDTO { } /** - * The snippet in this template. - * - * @return + * @return snippet in this 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..c62f99c2e9 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 @@ -41,9 +41,7 @@ public class UserDTO { private Set authorities; /** - * The user id. - * - * @return + * @return user id */ public String getId() { return id; @@ -54,9 +52,7 @@ public class UserDTO { } /** - * The users authorities. - * - * @return + * @return users authorities */ public Set getAuthorities() { return authorities; @@ -67,9 +63,7 @@ public class UserDTO { } /** - * The creation time for this users account. - * - * @return + * @return creation time for this users account */ @XmlJavaTypeAdapter(DateTimeAdapter.class) public Date getCreation() { @@ -81,9 +75,7 @@ public class UserDTO { } /** - * The users DN. - * - * @return + * @return users DN */ public String getDn() { return dn; @@ -94,10 +86,8 @@ 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 */ public String getUserName() { return userName; @@ -108,9 +98,7 @@ public class UserDTO { } /** - * The user group. - * - * @return + * @return user group */ public String getUserGroup() { return userGroup; @@ -121,9 +109,7 @@ public class UserDTO { } /** - * The users account justification. - * - * @return + * @return users account justification */ public String getJustification() { return justification; @@ -134,9 +120,7 @@ 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) public Date getLastAccessed() { @@ -148,9 +132,7 @@ 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) public Date getLastVerified() { @@ -162,9 +144,7 @@ public class UserDTO { } /** - * The status of the users account. - * - * @return + * @return status of the users account */ 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..6c4d224e61 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 @@ -31,9 +31,7 @@ public class UserGroupDTO { private String status; /** - * The user group. - * - * @return + * @return user group */ public String getGroup() { return group; @@ -44,9 +42,7 @@ public class UserGroupDTO { } /** - * The users in this group. - * - * @return + * @return users in this group */ public Set getUserIds() { return userIds; @@ -57,9 +53,7 @@ public class UserGroupDTO { } /** - * The status of the users account. - * - * @return + * @return status of the users account */ public String getStatus() { return status; @@ -70,9 +64,7 @@ public class UserGroupDTO { } /** - * The users authorities. - * - * @return + * @return users authorities */ 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..357dd0fa6b 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 @@ -43,9 +43,7 @@ public class ActionDTO { private ActionDetailsDTO actionDetails; /** - * The action id. - * - * @return + * @return action id */ public Integer getId() { return id; @@ -56,9 +54,7 @@ public class ActionDTO { } /** - * The user dn who perform this action. - * - * @return + * @return user dn who perform this action */ public String getUserDn() { return userDn; @@ -69,9 +65,7 @@ public class ActionDTO { } /** - * The user name who perform this action. - * - * @return + * @return user name who perform this action */ public String getUserName() { return userName; @@ -82,9 +76,7 @@ public class ActionDTO { } /** - * This action's timestamp. - * - * @return + * @return action's timestamp */ @XmlJavaTypeAdapter(DateTimeAdapter.class) public Date getTimestamp() { @@ -96,9 +88,7 @@ public class ActionDTO { } /** - * The id of the source component of this action. - * - * @return + * @return id of the source component of this action */ public String getSourceId() { return sourceId; @@ -109,9 +99,7 @@ public class ActionDTO { } /** - * The name of the source component of this action. - * - * @return + * @return name of the source component of this action */ public String getSourceName() { return sourceName; @@ -122,9 +110,7 @@ public class ActionDTO { } /** - * The type of the source component of this action. - * - * @return + * @return type of the source component of this action */ public String getSourceType() { return sourceType; @@ -135,9 +121,7 @@ public class ActionDTO { } /** - * The component details (if any) for this action. - * - * @return + * @return component details (if any) for this action */ public ComponentDetailsDTO getComponentDetails() { return componentDetails; @@ -148,9 +132,7 @@ public class ActionDTO { } /** - * The operation being performed in this action. - * - * @return + * @return operation being performed in this action */ public String getOperation() { return operation; @@ -161,9 +143,7 @@ public class ActionDTO { } /** - * The action details (if any) for this action. - * - * @return + * @return action details (if any) for this 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..36a5e47202 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 @@ -33,9 +33,7 @@ public class HistoryDTO { private Collection actions; /** - * The total number of actions. - * - * @return + * @return total number of actions */ public Integer getTotal() { return total; @@ -46,9 +44,7 @@ public class HistoryDTO { } /** - * Timestamp when these records were returned. - * - * @return + * @return timestamp when these records were returned */ @XmlJavaTypeAdapter(TimeAdapter.class) public Date getLastRefreshed() { @@ -60,9 +56,7 @@ public class HistoryDTO { } /** - * The actions for this range. - * - * @return + * @return actions for this range */ 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..48a1321be8 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 @@ -37,9 +37,7 @@ public class HistoryQueryDTO { private String sortOrder; /** - * The user name. - * - * @return + * @return user name */ public String getUserName() { return userName; @@ -50,9 +48,7 @@ public class HistoryQueryDTO { } /** - * The source component id. - * - * @return + * @return source component id */ public String getSourceId() { return sourceId; @@ -63,9 +59,7 @@ public class HistoryQueryDTO { } /** - * The start date. - * - * @return + * @return start date */ @XmlJavaTypeAdapter(DateTimeAdapter.class) public Date getStartDate() { @@ -77,9 +71,7 @@ public class HistoryQueryDTO { } /** - * The end date. - * - * @return + * @return end date */ @XmlJavaTypeAdapter(DateTimeAdapter.class) public Date getEndDate() { @@ -91,9 +83,7 @@ public class HistoryQueryDTO { } /** - * The offset. - * - * @return + * @return offset */ public Integer getOffset() { return offset; @@ -104,9 +94,7 @@ public class HistoryQueryDTO { } /** - * The desired row count. - * - * @return + * @return desired row count */ public Integer getCount() { return count; @@ -117,9 +105,7 @@ public class HistoryQueryDTO { } /** - * The desired sort column. - * - * @return + * @return desired sort column */ public String getSortColumn() { return sortColumn; @@ -130,9 +116,7 @@ public class HistoryQueryDTO { } /** - * The desired sort order. - * - * @return + * @return desired 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..90eb5f05e6 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 @@ -27,9 +27,7 @@ public class ExtensionDetailsDTO extends ComponentDetailsDTO { private String type; /** - * The extension type. - * - * @return + * @return extension type */ 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..a696a25bed 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 @@ -27,9 +27,7 @@ public class RemoteProcessGroupDetailsDTO extends ComponentDetailsDTO { private String uri; /** - * The URI of the remote process group. - * - * @return + * @return URI 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..223994625b 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 @@ -29,9 +29,7 @@ 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 */ public String getName() { return name; @@ -42,9 +40,7 @@ public class ConfigureDetailsDTO extends ActionDetailsDTO { } /** - * The previous value. - * - * @return + * @return previous value */ public String getPreviousValue() { return previousValue; @@ -55,9 +51,7 @@ public class ConfigureDetailsDTO extends ActionDetailsDTO { } /** - * The new value. - * - * @return + * @return 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..a6d5d99dfc 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 @@ -33,9 +33,7 @@ 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 */ public String getSourceId() { return sourceId; @@ -46,9 +44,7 @@ public class ConnectDetailsDTO extends ActionDetailsDTO { } /** - * The name of the source of the connection. - * - * @return + * @return name of the source of the connection */ public String getSourceName() { return sourceName; @@ -59,9 +55,7 @@ public class ConnectDetailsDTO extends ActionDetailsDTO { } /** - * The type of the source of the connection. - * - * @return + * @return type of the source of the connection */ public String getSourceType() { return sourceType; @@ -72,9 +66,7 @@ public class ConnectDetailsDTO extends ActionDetailsDTO { } /** - * The name of the relationship that was connected. - * - * @return + * @return name of the relationship that was connected */ public String getRelationship() { return relationship; @@ -85,9 +77,7 @@ public class ConnectDetailsDTO extends ActionDetailsDTO { } /** - * The id of the destination of the connection. - * - * @return + * @return id of the destination of the connection */ public String getDestinationId() { return destinationId; @@ -98,9 +88,7 @@ public class ConnectDetailsDTO extends ActionDetailsDTO { } /** - * The name of the destination of the connection. - * - * @return + * @return name of the destination of the connection */ public String getDestinationName() { return destinationName; @@ -111,9 +99,7 @@ public class ConnectDetailsDTO extends ActionDetailsDTO { } /** - * The type of the destination of the connection. - * - * @return + * @return 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..a7f7cf8537 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 @@ -30,9 +30,7 @@ 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 */ public String getPreviousGroupId() { return previousGroupId; @@ -43,9 +41,7 @@ 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 */ public String getPreviousGroup() { return previousGroup; @@ -56,9 +52,7 @@ public class MoveDetailsDTO extends ActionDetailsDTO { } /** - * The id of the group the components belong to. - * - * @return + * @return id of the group the components belong to */ public String getGroupId() { return groupId; @@ -69,9 +63,7 @@ public class MoveDetailsDTO extends ActionDetailsDTO { } /** - * The name of the group the components belong to. - * - * @return + * @return 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..6d5b02f40c 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 @@ -30,9 +30,7 @@ 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) public Date getEndDate() { 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..a9db5d0eaa 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 @@ -29,9 +29,7 @@ public class AttributeDTO { private String previousValue; /** - * The attribute name. - * - * @return + * @return attribute name */ public String getName() { return name; @@ -42,9 +40,7 @@ public class AttributeDTO { } /** - * The attribute value. - * - * @return + * @return attribute value */ public String getValue() { return value; @@ -55,9 +51,7 @@ public class AttributeDTO { } /** - * The value of this attribute before the event took place. - * - * @return + * @return value of this 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..333570e9fa 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 @@ -44,9 +44,7 @@ public class ProvenanceDTO { private ProvenanceResultsDTO results; /** - * The id of this provenance query. - * - * @return + * @return id of this provenance query */ public String getId() { return id; @@ -57,9 +55,7 @@ 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 */ public String getUri() { return uri; @@ -70,9 +66,7 @@ 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 */ public String getClusterNodeId() { return clusterNodeId; @@ -83,9 +77,7 @@ public class ProvenanceDTO { } /** - * The time the query was submitted. - * - * @return + * @return time the query was submitted */ @XmlJavaTypeAdapter(TimestampAdapter.class) public Date getSubmissionTime() { @@ -97,9 +89,7 @@ public class ProvenanceDTO { } /** - * The expiration time of the query results. - * - * @return + * @return expiration time of the query results */ @XmlJavaTypeAdapter(TimestampAdapter.class) public Date getExpiration() { @@ -111,9 +101,7 @@ public class ProvenanceDTO { } /** - * The percent completed. - * - * @return + * @return percent completed */ public Integer getPercentCompleted() { return percentCompleted; @@ -124,9 +112,7 @@ public class ProvenanceDTO { } /** - * Whether the query has finished. - * - * @return + * @return whether the query has finished */ public Boolean isFinished() { return finished; @@ -137,9 +123,7 @@ public class ProvenanceDTO { } /** - * The provenance request. - * - * @return + * @return provenance request */ public ProvenanceRequestDTO getRequest() { return request; @@ -150,9 +134,7 @@ public class ProvenanceDTO { } /** - * The results of this query. - * - * @return + * @return results of this query */ 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..883fce8392 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 @@ -83,9 +83,7 @@ public class ProvenanceEventDTO { private String sourceConnectionIdentifier; /** - * The event uuid. - * - * @return + * @return event uuid */ public String getId() { return id; @@ -96,9 +94,7 @@ public class ProvenanceEventDTO { } /** - * The event id. - * - * @return + * @return event id */ public Long getEventId() { return eventId; @@ -109,9 +105,7 @@ public class ProvenanceEventDTO { } /** - * The time the event occurred. - * - * @return + * @return time the event occurred */ @XmlJavaTypeAdapter(TimestampAdapter.class) public Date getEventTime() { @@ -123,9 +117,7 @@ public class ProvenanceEventDTO { } /** - * The UUID of the FlowFile for this event. - * - * @return + * @return UUID of the FlowFile for this event */ public String getFlowFileUuid() { return flowFileUuid; @@ -136,9 +128,7 @@ public class ProvenanceEventDTO { } /** - * The size of the FlowFile for this event. - * - * @return + * @return size of the FlowFile for this event */ public String getFileSize() { return fileSize; @@ -149,9 +139,7 @@ public class ProvenanceEventDTO { } /** - * The size of the FlowFile in bytes for this event. - * - * @return + * @return size of the FlowFile in bytes for this event */ public Long getFileSizeBytes() { return fileSizeBytes; @@ -162,9 +150,7 @@ public class ProvenanceEventDTO { } /** - * The type of this event. - * - * @return + * @return type of this event */ public String getEventType() { return eventType; @@ -175,9 +161,7 @@ public class ProvenanceEventDTO { } /** - * The attributes for the FlowFile for this event. - * - * @return + * @return attributes for the FlowFile for this event */ public Collection getAttributes() { return attributes; @@ -188,10 +172,8 @@ 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 */ public String getGroupId() { return groupId; @@ -202,9 +184,7 @@ public class ProvenanceEventDTO { } /** - * The id of the component that generated this event. - * - * @return + * @return id of the component that generated this event */ public String getComponentId() { return componentId; @@ -215,9 +195,7 @@ public class ProvenanceEventDTO { } /** - * The name of the component that generated this event. - * - * @return + * @return name of the component that generated this event */ public String getComponentName() { return componentName; @@ -228,9 +206,7 @@ public class ProvenanceEventDTO { } /** - * The type of the component that generated this event. - * - * @return + * @return type of the component that generated this event */ public String getComponentType() { return componentType; @@ -241,9 +217,7 @@ 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 */ public String getTransitUri() { return transitUri; @@ -254,9 +228,7 @@ public class ProvenanceEventDTO { } /** - * The alternate identifier URI for the FlowFile for this event. - * - * @return + * @return alternate identifier URI for the FlowFile for this event */ public String getAlternateIdentifierUri() { return alternateIdentifierUri; @@ -267,9 +239,7 @@ public class ProvenanceEventDTO { } /** - * The identifier of the node where this event originated. - * - * @return + * @return identifier of the node where this event originated */ public String getClusterNodeId() { return clusterNodeId; @@ -280,9 +250,7 @@ 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 */ public String getClusterNodeAddress() { return clusterNodeAddress; @@ -293,9 +261,7 @@ public class ProvenanceEventDTO { } /** - * The parent uuids for this event. - * - * @return + * @return parent uuids for this event */ public List getParentUuids() { return parentUuids; @@ -306,9 +272,7 @@ public class ProvenanceEventDTO { } /** - * The child uuids for this event. - * - * @return + * @return child uuids for this event */ public List getChildUuids() { return childUuids; @@ -319,9 +283,7 @@ public class ProvenanceEventDTO { } /** - * The duration of the event, in milliseconds. - * - * @return + * @return duration of the event, in milliseconds */ public Long getEventDuration() { return eventDuration; @@ -332,9 +294,7 @@ public class ProvenanceEventDTO { } /** - * The duration since the lineage began, in milliseconds. - * - * @return + * @return duration since the lineage began, in milliseconds */ public Long getLineageDuration() { return lineageDuration; @@ -345,9 +305,7 @@ public class ProvenanceEventDTO { } /** - * The source system FlowFile id. - * - * @return + * @return source system FlowFile id */ public String getSourceSystemFlowFileId() { return sourceSystemFlowFileId; @@ -358,10 +316,8 @@ 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 */ public String getRelationship() { return relationship; @@ -372,9 +328,7 @@ public class ProvenanceEventDTO { } /** - * The event details. - * - * @return + * @return event details */ public String getDetails() { return details; @@ -385,9 +339,7 @@ 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 */ public Boolean getContentEqual() { return contentEqual; @@ -398,9 +350,7 @@ public class ProvenanceEventDTO { } /** - * Returns whether or not the output content is still available. - * - * @return + * @return whether or not the output content is still available */ public Boolean getOutputContentAvailable() { return outputContentAvailable; @@ -411,10 +361,8 @@ 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 */ public String getOutputContentClaimSection() { return outputContentClaimSection; @@ -425,10 +373,8 @@ 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 */ public String getOutputContentClaimContainer() { return outputContentClaimContainer; @@ -439,10 +385,8 @@ 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 */ public String getOutputContentClaimIdentifier() { return outputContentClaimIdentifier; @@ -453,10 +397,8 @@ 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 */ public Long getOutputContentClaimOffset() { return outputContentClaimOffset; @@ -467,9 +409,7 @@ public class ProvenanceEventDTO { } /** - * Returns the formatted file size of the input content claim. - * - * @return + * @return the formatted file size of the input content claim */ public String getOutputContentClaimFileSize() { return outputContentClaimFileSize; @@ -480,9 +420,7 @@ public class ProvenanceEventDTO { } /** - * Returns the number of bytes of the input content claim. - * - * @return + * @return the number of bytes of the input content claim */ public Long getOutputContentClaimFileSizeBytes() { return outputContentClaimFileSizeBytes; @@ -493,9 +431,7 @@ public class ProvenanceEventDTO { } /** - * Returns whether or not the input content is still available. - * - * @return + * @return whether or not the input content is still available */ public Boolean getInputContentAvailable() { return inputContentAvailable; @@ -506,10 +442,8 @@ 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 */ public String getInputContentClaimSection() { return inputContentClaimSection; @@ -520,10 +454,8 @@ 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 */ public String getInputContentClaimContainer() { return inputContentClaimContainer; @@ -534,10 +466,8 @@ 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 */ public String getInputContentClaimIdentifier() { return inputContentClaimIdentifier; @@ -548,10 +478,8 @@ 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 */ public Long getInputContentClaimOffset() { return inputContentClaimOffset; @@ -562,9 +490,7 @@ public class ProvenanceEventDTO { } /** - * Returns the formatted file size of the input content claim. - * - * @return + * @return the formatted file size of the input content claim */ public String getInputContentClaimFileSize() { return inputContentClaimFileSize; @@ -575,9 +501,7 @@ public class ProvenanceEventDTO { } /** - * Returns the number of bytes of the input content claim. - * - * @return + * @return the number of bytes of the input content claim */ public Long getInputContentClaimFileSizeBytes() { return inputContentClaimFileSizeBytes; @@ -588,9 +512,7 @@ public class ProvenanceEventDTO { } /** - * Returns whether or not replay is available. - * - * @return + * @return whether or not replay is available */ public Boolean getReplayAvailable() { return replayAvailable; @@ -601,9 +523,7 @@ public class ProvenanceEventDTO { } /** - * Returns the explanation as to why replay is unavailable. - * - * @return + * @return the explanation as to why replay is unavailable */ public String getReplayExplanation() { return replayExplanation; @@ -614,11 +534,9 @@ public class ProvenanceEventDTO { } /** - * Returns identifier of the FlowFile Queue / Connection from which the + * @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. - * - * @return + * either the queue is unknown or the FlowFile was created by 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..2c7f4675c4 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 @@ -28,9 +28,7 @@ public class ProvenanceOptionsDTO { private List searchableFields; /** - * The available searchable fields for this NiFi instance. - * - * @return + * @return available searchable fields for this NiFi instance */ 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..bc239eee39 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 @@ -37,9 +37,7 @@ 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 */ public Map getSearchTerms() { return searchTerms; @@ -50,9 +48,7 @@ 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) public Date getStartDate() { @@ -64,9 +60,7 @@ 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) public Date getEndDate() { @@ -78,9 +72,7 @@ public class ProvenanceRequestDTO { } /** - * The minimum file size to include in the query. - * - * @return + * @return minimum file size to include in the query */ public String getMinimumFileSize() { return minimumFileSize; @@ -91,9 +83,7 @@ public class ProvenanceRequestDTO { } /** - * The maximum file size to include in the query. - * - * @return + * @return maximum file size to include in the query */ public String getMaximumFileSize() { return maximumFileSize; @@ -104,9 +94,7 @@ public class ProvenanceRequestDTO { } /** - * The number of max results. - * - * @return + * @return number of max results */ 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..6d2f64d317 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 @@ -41,9 +41,7 @@ public class ProvenanceResultsDTO { private Set errors; /** - * Any error messages. - * - * @return + * @return error messages */ public Set getErrors() { return errors; @@ -54,9 +52,7 @@ public class ProvenanceResultsDTO { } /** - * The provenance events that matched the search criteria. - * - * @return + * @return provenance events that matched the search criteria */ public List getProvenanceEvents() { return provenanceEvents; @@ -67,9 +63,7 @@ public class ProvenanceResultsDTO { } /** - * The total number of results formatted. - * - * @return + * @return total number of results formatted */ public String getTotal() { return total; @@ -80,9 +74,7 @@ public class ProvenanceResultsDTO { } /** - * The total number of results. - * - * @return + * @return total number of results */ public Long getTotalCount() { return totalCount; @@ -93,9 +85,7 @@ public class ProvenanceResultsDTO { } /** - * When the search was performed. - * - * @return + * @return when the search was performed */ @XmlJavaTypeAdapter(TimeAdapter.class) public Date getGenerated() { @@ -107,9 +97,7 @@ public class ProvenanceResultsDTO { } /** - * The oldest event available in the provenance repository. - * - * @return + * @return oldest event available in the provenance repository */ @XmlJavaTypeAdapter(DateTimeAdapter.class) public Date getOldestEvent() { @@ -121,9 +109,7 @@ 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 */ 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..97300f6e85 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 @@ -30,9 +30,7 @@ public class ProvenanceSearchableFieldDTO { private String type; /** - * The id of this searchable field. - * - * @return + * @return id of this searchable field */ public String getId() { return id; @@ -43,9 +41,7 @@ public class ProvenanceSearchableFieldDTO { } /** - * The field. - * - * @return + * @return the field */ public String getField() { return field; @@ -56,9 +52,7 @@ public class ProvenanceSearchableFieldDTO { } /** - * The label for this field. - * - * @return + * @return label for this field */ public String getLabel() { return label; @@ -69,9 +63,7 @@ public class ProvenanceSearchableFieldDTO { } /** - * The type for this field. - * - * @return + * @return type of this 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..0ef8aab25d 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 @@ -40,9 +40,7 @@ public class LineageDTO { private LineageResultsDTO results; /** - * The id of this lineage. - * - * @return + * @return id of this lineage */ public String getId() { return id; @@ -53,9 +51,7 @@ public class LineageDTO { } /** - * The uri for this lineage. - * - * @return + * @return uri for this lineage */ public String getUri() { return uri; @@ -66,9 +62,7 @@ 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 */ public String getClusterNodeId() { return clusterNodeId; @@ -79,9 +73,7 @@ public class LineageDTO { } /** - * The submission time for this lineage. - * - * @return + * @return submission time for this lineage */ @XmlJavaTypeAdapter(TimestampAdapter.class) public Date getSubmissionTime() { @@ -93,9 +85,7 @@ public class LineageDTO { } /** - * The expiration of this lineage. - * - * @return + * @return expiration of this lineage */ @XmlJavaTypeAdapter(TimestampAdapter.class) public Date getExpiration() { @@ -107,9 +97,7 @@ public class LineageDTO { } /** - * Percent completed for this result. - * - * @return + * @return percent completed for this result */ public Integer getPercentCompleted() { return percentCompleted; @@ -120,9 +108,7 @@ public class LineageDTO { } /** - * Whether or not the request is finished running. - * - * @return + * @return whether or not the request is finished running */ public Boolean getFinished() { return finished; @@ -133,9 +119,7 @@ public class LineageDTO { } /** - * The lineage request. - * - * @return + * @return the lineage request */ public LineageRequestDTO getRequest() { return request; @@ -146,9 +130,7 @@ public class LineageDTO { } /** - * The results of this lineage. - * - * @return + * @return the results of this lineage */ 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..afcea3f062 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 @@ -43,9 +43,7 @@ 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 */ public Long getEventId() { return eventId; @@ -56,13 +54,11 @@ public class LineageRequestDTO { } /** - * The type of lineage request. Either 'PARENTS', 'CHILDREN', or 'FLOWFILE'. + * @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. - * - * @return */ public LineageRequestType getLineageRequestType() { return lineageRequestType; @@ -73,9 +69,7 @@ public class LineageRequestDTO { } /** - * The uuid that was used to generate this lineage. - * - * @return + * @return uuid that was used to generate this 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..8876e9e78e 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 @@ -32,9 +32,7 @@ public class LineageResultsDTO { private List links; /** - * Any error messages. - * - * @return + * @return any error messages */ public Set getErrors() { return errors; @@ -45,9 +43,7 @@ public class LineageResultsDTO { } /** - * The nodes. - * - * @return + * @return the nodes */ public List getNodes() { return nodes; @@ -58,9 +54,7 @@ public class LineageResultsDTO { } /** - * The links. - * - * @return + * @return the links */ 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..d002626afa 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 @@ -34,9 +34,7 @@ public class ProvenanceLinkDTO { private Long millis; /** - * The source node id. - * - * @return + * @return source node id */ public String getSourceId() { return sourceId; @@ -47,9 +45,7 @@ public class ProvenanceLinkDTO { } /** - * The target node id. - * - * @return + * @return target node id */ public String getTargetId() { return targetId; @@ -60,9 +56,7 @@ public class ProvenanceLinkDTO { } /** - * The flowfile uuid that traversed this link. - * - * @return + * @return flowfile uuid that traversed this link */ public String getFlowFileUuid() { return flowFileUuid; @@ -73,9 +67,7 @@ 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) public Date getTimestamp() { @@ -87,9 +79,7 @@ public class ProvenanceLinkDTO { } /** - * The number of millis since epoch. - * - * @return + * @return number of millis since epoch */ 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..4a7ed9c394 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 @@ -42,9 +42,7 @@ public class ProvenanceNodeDTO { private Date timestamp; /** - * The id of the node. - * - * @return + * @return id of the node */ public String getId() { return id; @@ -55,9 +53,7 @@ public class ProvenanceNodeDTO { } /** - * The flowfile uuid for this provenance event. - * - * @return + * @return flowfile uuid for this provenance event */ public String getFlowFileUuid() { return flowFileUuid; @@ -68,9 +64,7 @@ public class ProvenanceNodeDTO { } /** - * The parent flowfile uuids for this provenance event. - * - * @return + * @return parent flowfile uuids for this provenance event */ public List getParentUuids() { return parentUuids; @@ -81,9 +75,7 @@ public class ProvenanceNodeDTO { } /** - * The child flowfile uuids for this provenance event. - * - * @return + * @return child flowfile uuids for this provenance event */ public List getChildUuids() { return childUuids; @@ -94,9 +86,7 @@ public class ProvenanceNodeDTO { } /** - * The node identifier that this event/flowfile originated from. - * - * @return + * @return node identifier that this event/flowfile originated from */ public String getClusterNodeIdentifier() { return clusterNodeIdentifier; @@ -107,9 +97,7 @@ public class ProvenanceNodeDTO { } /** - * The type of node. - * - * @return + * @return type of node */ public String getType() { return type; @@ -120,9 +108,7 @@ 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 */ public String getEventType() { return eventType; @@ -133,9 +119,7 @@ public class ProvenanceNodeDTO { } /** - * The timestamp of this node. - * - * @return + * @return timestamp of this node */ @XmlJavaTypeAdapter(TimestampAdapter.class) public Date getTimestamp() { @@ -147,9 +131,7 @@ public class ProvenanceNodeDTO { } /** - * The number of millis since epoch. - * - * @return + * @return number of millis since epoch */ 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..01965f97c2 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 @@ -31,9 +31,7 @@ public class ComponentSearchResultDTO { private List matches; /** - * The id of the component that matched. - * - * @return + * @return id of the component that matched */ public String getId() { return id; @@ -44,9 +42,7 @@ public class ComponentSearchResultDTO { } /** - * The group id of the component that matched. - * - * @return + * @return group id of the component that matched */ public String getGroupId() { return groupId; @@ -57,9 +53,7 @@ public class ComponentSearchResultDTO { } /** - * The name of the component that matched. - * - * @return + * @return name of the component that matched */ public String getName() { return name; @@ -70,9 +64,7 @@ public class ComponentSearchResultDTO { } /** - * What matched the search string for this component. - * - * @return + * @return What matched the search string for this 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..ab78d069d0 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 @@ -28,9 +28,7 @@ public class NodeSearchResultDTO { private String address; /** - * The id of the node that was matched. - * - * @return + * @return id of the node that was matched */ public String getId() { return id; @@ -41,9 +39,7 @@ public class NodeSearchResultDTO { } /** - * The address of the node that was matched. - * - * @return + * @return address of the node that was matched */ 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..0319916dbb 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 @@ -35,9 +35,7 @@ public class SearchResultsDTO { private List funnelResults = new ArrayList<>(); /** - * The processors that matched the search. - * - * @return + * @return The processors that matched the search */ public List getProcessorResults() { return processorResults; @@ -48,9 +46,7 @@ public class SearchResultsDTO { } /** - * The connections that matched the search. - * - * @return + * @return connections that matched the search */ public List getConnectionResults() { return connectionResults; @@ -61,9 +57,7 @@ public class SearchResultsDTO { } /** - * The process group that matched the search. - * - * @return + * @return process group that matched the search */ public List getProcessGroupResults() { return processGroupResults; @@ -74,18 +68,14 @@ public class SearchResultsDTO { } /** - * The input ports that matched the search. - * - * @return + * @return 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 */ public List getOutputPortResults() { return outputPortResults; @@ -100,9 +90,7 @@ public class SearchResultsDTO { } /** - * The remote process groups that matched the search. - * - * @return + * @return remote process groups that matched the search */ public List getRemoteProcessGroupResults() { return remoteProcessGroupResults; @@ -113,9 +101,7 @@ public class SearchResultsDTO { } /** - * The funnels that matched the search. - * - * @return + * @return 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..863ba3a93c 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 @@ -27,9 +27,7 @@ public class UserGroupSearchResultDTO { private String group; /** - * The name of the group that matched. - * - * @return + * @return name of the group that matched */ 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..b68ab0f43c 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 @@ -28,9 +28,7 @@ public class UserSearchResultDTO { private String userDn; /** - * The dn of the user that matched. - * - * @return + * @return dn of the user that matched */ public String getUserDn() { return userDn; @@ -41,9 +39,7 @@ public class UserSearchResultDTO { } /** - * The username of user that matched. - * - * @return + * @return username of user that matched */ 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..248729ebe5 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 @@ -34,9 +34,7 @@ public class ClusterConnectionStatusDTO { private String connectionName; /** - * The time the status were last refreshed. - * - * @return + * @return time the status were last refreshed */ @XmlJavaTypeAdapter(TimeAdapter.class) public Date getStatsLastRefreshed() { @@ -48,9 +46,7 @@ public class ClusterConnectionStatusDTO { } /** - * The connection id. - * - * @return + * @return connection id */ public String getConnectionId() { return connectionId; @@ -61,9 +57,7 @@ public class ClusterConnectionStatusDTO { } /** - * The connection name. - * - * @return + * @return connection name */ public String getConnectionName() { return connectionName; @@ -74,8 +68,6 @@ public class ClusterConnectionStatusDTO { } /** - * Collection of node connection status DTO. - * * @return The collection of node connection status DTO */ public Collection getNodeConnectionStatus() { 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..ca4ef07b31 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 @@ -34,8 +34,6 @@ public class ClusterPortStatusDTO { private String portName; /** - * The time the status was last refreshed. - * * @return the time the status were last refreshed */ @XmlJavaTypeAdapter(TimeAdapter.class) @@ -48,9 +46,7 @@ public class ClusterPortStatusDTO { } /** - * The port status from each node in the cluster. - * - * @return + * @return port status from each node in the cluster */ public Collection getNodePortStatus() { return nodePortStatus; @@ -61,9 +57,7 @@ public class ClusterPortStatusDTO { } /** - * The port id. - * - * @return + * @return port id */ public String getPortId() { return portId; @@ -74,9 +68,7 @@ public class ClusterPortStatusDTO { } /** - * The port name. - * - * @return + * @return port name */ 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..08d76a5116 --- /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,89 @@ +/* + * 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 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) + public Date getStatsLastRefreshed() { + return statsLastRefreshed; + } + + public void setStatsLastRefreshed(Date statsLastRefreshed) { + this.statsLastRefreshed = statsLastRefreshed; + } + + /** + * The process group id. + * + * @return The process group id + */ + public String getProcessGroupId() { + return processGroupId; + } + + public void setProcessGroupId(String processGroupId) { + this.processGroupId = processGroupId; + } + + /** + * The process group name. + * + * @return The process group name + */ + 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 + */ + 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..8d78b1f5a0 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 @@ -36,9 +36,7 @@ public class ClusterProcessorStatusDTO { private String processorRunStatus; /** - * The time the status were last refreshed. - * - * @return + * @return time the status were last refreshed */ @XmlJavaTypeAdapter(TimeAdapter.class) public Date getStatsLastRefreshed() { @@ -50,9 +48,7 @@ public class ClusterProcessorStatusDTO { } /** - * The processor id. - * - * @return + * @return processor id */ public String getProcessorId() { return processorId; @@ -63,9 +59,7 @@ public class ClusterProcessorStatusDTO { } /** - * The processor name. - * - * @return + * @return processor name */ public String getProcessorName() { return processorName; @@ -76,9 +70,7 @@ public class ClusterProcessorStatusDTO { } /** - * The processor type. - * - * @return + * @return processor type */ public String getProcessorType() { return processorType; @@ -89,9 +81,7 @@ public class ClusterProcessorStatusDTO { } /** - * The processor run status. - * - * @return + * @return processor run status */ public String getProcessorRunStatus() { return processorRunStatus; 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..027bf4f320 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 @@ -34,8 +34,6 @@ public class ClusterRemoteProcessGroupStatusDTO { private String remoteProcessGroupName; /** - * The time the status was last refreshed. - * * @return the time the status were last refreshed */ @XmlJavaTypeAdapter(TimeAdapter.class) @@ -48,9 +46,7 @@ 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 */ public Collection getNodeRemoteProcessGroupStatus() { return nodeRemoteProcessGroupStatus; @@ -61,9 +57,7 @@ public class ClusterRemoteProcessGroupStatusDTO { } /** - * The remote process group id. - * - * @return + * @return remote process group id */ public String getRemoteProcessGroupId() { return remoteProcessGroupId; @@ -74,9 +68,7 @@ public class ClusterRemoteProcessGroupStatusDTO { } /** - * The remote process group name. - * - * @return + * @return remote process group name */ 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..e170c8b218 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 @@ -29,9 +29,7 @@ public class ClusterStatusDTO { private Collection nodeStatus; /** - * The collection of the node status DTOs. - * - * @return + * @return collection of the node status DTOs */ 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..a22c872778 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 @@ -33,9 +33,7 @@ public class ClusterStatusHistoryDTO { private Date generated; /** - * When this status history was generated. - * - * @return + * @return when this status history was generated */ @XmlJavaTypeAdapter(TimeAdapter.class) public Date getGenerated() { @@ -47,9 +45,7 @@ public class ClusterStatusHistoryDTO { } /** - * The status history from each node in the cluster. - * - * @return + * @return status history from each node in the cluster */ public Collection getNodeStatusHistory() { return nodeStatusHistory; @@ -60,9 +56,7 @@ public class ClusterStatusHistoryDTO { } /** - * The status history for this component across the entire cluster. - * - * @return + * @return status history for this component across 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..2abc6ff7a4 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 @@ -40,8 +40,6 @@ public class ConnectionStatusDTO { /* getters / setters */ /** - * The id for the connection. - * * @return The connection id */ public String getId() { @@ -53,8 +51,6 @@ 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. */ public String getGroupId() { @@ -66,9 +62,7 @@ public class ConnectionStatusDTO { } /** - * The name of this connection. - * - * @return + * @return name of this connection */ public String getName() { return name; @@ -79,9 +73,7 @@ public class ConnectionStatusDTO { } /** - * The total count of flow files that are queued. - * - * @return + * @return total count of flow files that are queued */ public String getQueuedCount() { return queuedCount; @@ -92,9 +84,7 @@ public class ConnectionStatusDTO { } /** - * The total size of flow files that are queued. - * - * @return + * @return total size of flow files that are queued */ public String getQueuedSize() { return queuedSize; @@ -105,8 +95,6 @@ public class ConnectionStatusDTO { } /** - * The total count and size of flow files that are queued. - * * @return The total count and size of queued flow files */ public String getQueued() { @@ -118,9 +106,7 @@ public class ConnectionStatusDTO { } /** - * The id of the source of this connection. - * - * @return + * @return id of the source of this connection */ public String getSourceId() { return sourceId; @@ -131,9 +117,7 @@ public class ConnectionStatusDTO { } /** - * The name of the source of this connection. - * - * @return + * @return name of the source of this connection */ public String getSourceName() { return sourceName; @@ -144,9 +128,7 @@ public class ConnectionStatusDTO { } /** - * The id of the destination of this connection. - * - * @return + * @return id of the destination of this connection */ public String getDestinationId() { return destinationId; @@ -157,9 +139,7 @@ public class ConnectionStatusDTO { } /** - * The name of the destination of this connection. - * - * @return + * @return name of the destination of this connection */ public String getDestinationName() { return destinationName; @@ -170,9 +150,7 @@ public class ConnectionStatusDTO { } /** - * The input for this connection. - * - * @return + * @return input for this connection */ public String getInput() { return input; @@ -183,9 +161,7 @@ public class ConnectionStatusDTO { } /** - * The output for this connection. - * - * @return + * @return output for this connection */ 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..adfee2ad6c 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 @@ -54,9 +54,7 @@ public class ControllerStatusDTO { } /** - * The queue for the controller. - * - * @return + * @return queue for the controller */ public String getQueued() { return queued; @@ -67,10 +65,8 @@ 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 */ public String getConnectedNodes() { return connectedNodes; @@ -81,9 +77,7 @@ public class ControllerStatusDTO { } /** - * System bulletins to be reported to the user. - * - * @return + * @return System bulletins to be reported to the user */ public List getBulletins() { return bulletins; @@ -94,9 +88,7 @@ public class ControllerStatusDTO { } /** - * Whether or not there are pending user requests. - * - * @return + * @return whether or not there are pending user requests */ public Boolean getHasPendingAccounts() { return hasPendingAccounts; @@ -107,9 +99,7 @@ public class ControllerStatusDTO { } /** - * The number of running components in this controller. - * - * @return + * @return number of running components in this controller */ public Integer getRunningCount() { return runningCount; @@ -120,9 +110,7 @@ public class ControllerStatusDTO { } /** - * The number of stopped components in this controller. - * - * @return + * @return number of stopped components in this controller */ public Integer getStoppedCount() { return stoppedCount; @@ -133,9 +121,7 @@ public class ControllerStatusDTO { } /** - * The number of invalid components in this controller. - * - * @return + * @return number of invalid components in this controller */ public Integer getInvalidCount() { return invalidCount; @@ -146,9 +132,7 @@ public class ControllerStatusDTO { } /** - * The number of disabled components in this controller. - * - * @return + * @return number of disabled components in this controller */ public Integer getDisabledCount() { return disabledCount; @@ -159,9 +143,7 @@ public class ControllerStatusDTO { } /** - * The number of active remote ports in this controller. - * - * @return + * @return number of active remote ports in this controller */ public Integer getActiveRemotePortCount() { return activeRemotePortCount; @@ -172,9 +154,7 @@ public class ControllerStatusDTO { } /** - * The number of inactive remote ports in this controller. - * - * @return + * @return number of inactive remote ports in this controller */ 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..39fb5ce3eb 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 @@ -29,9 +29,7 @@ public class NodeConnectionStatusDTO { private ConnectionStatusDTO connectionStatus; /** - * The node. - * - * @return + * @return the node */ public NodeDTO getNode() { return node; @@ -42,9 +40,7 @@ public class NodeConnectionStatusDTO { } /** - * The connection's status. - * - * @return + * @return connection's status */ 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..91a6d01aa4 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 @@ -29,9 +29,7 @@ public class NodePortStatusDTO { private PortStatusDTO portStatus; /** - * The node. - * - * @return + * @return the node */ public NodeDTO getNode() { return node; @@ -42,9 +40,7 @@ public class NodePortStatusDTO { } /** - * The port's status. - * - * @return + * @return port status */ 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..5f965b2903 --- /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,57 @@ +/* + * 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 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 + */ + public NodeDTO getNode() { + return node; + } + + public void setNode(NodeDTO node) { + this.node = node; + } + + /** + * The process group's status. + * + * @return The process group status + */ + 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..86d13d5d85 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 @@ -29,9 +29,7 @@ public class NodeProcessorStatusDTO { private ProcessorStatusDTO processorStatus; /** - * The node. - * - * @return + * @return the node */ public NodeDTO getNode() { return node; @@ -42,9 +40,7 @@ public class NodeProcessorStatusDTO { } /** - * The processor's status. - * - * @return + * @return processor's status */ 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..12a0ca0076 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 @@ -29,9 +29,7 @@ public class NodeRemoteProcessGroupStatusDTO { private RemoteProcessGroupStatusDTO remoteProcessGroupStatus; /** - * The node. - * - * @return + * @return the node */ public NodeDTO getNode() { return node; @@ -42,9 +40,7 @@ public class NodeRemoteProcessGroupStatusDTO { } /** - * The remote process group's status. - * - * @return + * @return remote process group's status */ 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..b770015065 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 @@ -29,9 +29,7 @@ public class NodeStatusDTO { private ProcessGroupStatusDTO controllerStatus; /** - * The node. - * - * @return + * @return the node */ public NodeDTO getNode() { return node; @@ -42,9 +40,7 @@ public class NodeStatusDTO { } /** - * The controller status. - * - * @return + * @return the controller status */ 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..9a7cb1677d 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 @@ -29,9 +29,7 @@ public class NodeStatusHistoryDTO { private StatusHistoryDTO statusHistory; /** - * The node. - * - * @return + * @return the node */ public NodeDTO getNode() { return node; @@ -42,9 +40,7 @@ public class NodeStatusHistoryDTO { } /** - * The processor status history. - * - * @return + * @return processor status history */ 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..db03146758 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 @@ -34,9 +34,7 @@ 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 */ public Boolean isTransmitting() { return transmitting; @@ -47,9 +45,7 @@ public class PortStatusDTO extends StatusDTO { } /** - * The active thread count for this port. - * - * @return + * @return the active thread count for this port */ public Integer getActiveThreadCount() { return activeThreadCount; @@ -60,9 +56,7 @@ public class PortStatusDTO extends StatusDTO { } /** - * The id of this port. - * - * @return + * @return id of this port */ public String getId() { return id; @@ -73,9 +67,7 @@ public class PortStatusDTO extends StatusDTO { } /** - * The id of the group this port resides in. - * - * @return + * @return id of the group this port resides in */ public String getGroupId() { return groupId; @@ -86,9 +78,7 @@ public class PortStatusDTO extends StatusDTO { } /** - * The name of this port. - * - * @return + * @return name of this port */ public String getName() { return name; @@ -99,9 +89,7 @@ public class PortStatusDTO extends StatusDTO { } /** - * The run status of this port. - * - * @return + * @return run status of this port */ public String getRunStatus() { return runStatus; @@ -112,10 +100,8 @@ 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 */ public String getInput() { return input; @@ -126,10 +112,8 @@ 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 */ 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..7ad24a94c3 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 @@ -38,10 +38,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; @@ -59,9 +64,7 @@ public class ProcessGroupStatusDTO extends StatusDTO { } /** - * The name of this process group. - * - * @return + * @return name of this process group */ public String getName() { return name; @@ -72,9 +75,7 @@ public class ProcessGroupStatusDTO extends StatusDTO { } /** - * The active thread count for this process group. - * - * @return + * @return active thread count for this process group */ public Integer getActiveThreadCount() { return activeThreadCount; @@ -175,6 +176,74 @@ 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 + */ + 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 + */ + 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 + */ + 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 + */ + 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 + */ + public String getQueuedSize() { + return queuedSize; + } + + public void setQueuedSize(String queuedSize) { + this.queuedSize = queuedSize; + } + /** * The queued stats for this process 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/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..18539bed53 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 @@ -42,8 +42,6 @@ public class ProcessorStatusDTO extends StatusDTO { /* getters / setters */ /** - * The id for the processor. - * * @return The processor id */ public String getId() { @@ -55,8 +53,6 @@ public class ProcessorStatusDTO extends StatusDTO { } /** - * The name of the processor. - * * @return The processor name */ public String getName() { @@ -68,8 +64,6 @@ public class ProcessorStatusDTO extends StatusDTO { } /** - * The type of the processor. - * * @return The processor type */ public String getType() { @@ -81,9 +75,7 @@ public class ProcessorStatusDTO extends StatusDTO { } /** - * The run status of this processor. - * - * @return + * @return run status of this processor */ public String getRunStatus() { return runStatus; @@ -94,10 +86,8 @@ 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 */ public String getInput() { return input; @@ -108,9 +98,7 @@ public class ProcessorStatusDTO extends StatusDTO { } /** - * The number of bytes read. - * - * @return + * @return number of bytes read */ public String getRead() { return read; @@ -121,9 +109,7 @@ public class ProcessorStatusDTO extends StatusDTO { } /** - * The number of bytes written. - * - * @return + * @return number of bytes written */ public String getWritten() { return written; @@ -134,8 +120,6 @@ 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. */ public String getGroupId() { @@ -147,10 +131,8 @@ 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 */ public String getOutput() { return output; @@ -161,9 +143,7 @@ public class ProcessorStatusDTO extends StatusDTO { } /** - * The number of threads currently running for this Processor - * - * @return + * @return number of threads currently running for this Processor */ public Integer getActiveThreadCount() { return activeThreadCount; @@ -174,9 +154,7 @@ 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 */ public String getTasks() { return tasks; @@ -187,10 +165,8 @@ 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 */ 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..58f616190d 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 @@ -31,9 +31,7 @@ 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 */ public String getConnectionId() { return connectionId; @@ -44,9 +42,7 @@ public class RemotePortStatusDTO { } /** - * The id of the remote port. - * - * @return + * @return id of the remote port */ public String getId() { return id; @@ -57,9 +53,7 @@ public class RemotePortStatusDTO { } /** - * The name of the remote port. - * - * @return + * @return name of the remote port */ public String getName() { return name; @@ -70,9 +64,7 @@ public class RemotePortStatusDTO { } /** - * Whether or not the remote port exists. - * - * @return + * @return whether or not the remote port exists */ public Boolean getExists() { return exists; @@ -83,9 +75,7 @@ public class RemotePortStatusDTO { } /** - * Whether or not the remote port is running. - * - * @return + * @return 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..68aa5d6c47 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 @@ -38,8 +38,6 @@ public class RemoteProcessGroupStatusDTO extends StatusDTO { private String received; /** - * The id for the remote process group. - * * @return The id for the remote process group */ public String getId() { @@ -51,9 +49,7 @@ 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 */ public String getGroupId() { return groupId; @@ -64,9 +60,7 @@ public class RemoteProcessGroupStatusDTO extends StatusDTO { } /** - * The URI of the target system. - * - * @return + * @return URI of the target system */ public String getTargetUri() { return targetUri; @@ -77,9 +71,7 @@ public class RemoteProcessGroupStatusDTO extends StatusDTO { } /** - * The name of this remote process group. - * - * @return + * @return name of this remote process group */ public String getName() { return name; @@ -90,9 +82,7 @@ public class RemoteProcessGroupStatusDTO extends StatusDTO { } /** - * The transmission status of this remote process group. - * - * @return + * @return transmission status of this remote process group */ public String getTransmissionStatus() { return transmissionStatus; @@ -103,9 +93,7 @@ public class RemoteProcessGroupStatusDTO extends StatusDTO { } /** - * The number of active threads. - * - * @return + * @return number of active threads */ public Integer getActiveThreadCount() { return activeThreadCount; @@ -116,9 +104,7 @@ 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 */ public List getAuthorizationIssues() { return authorizationIssues; @@ -129,10 +115,8 @@ 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 */ public String getSent() { return sent; @@ -143,10 +127,8 @@ 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 */ 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..e922b70727 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 @@ -29,9 +29,7 @@ public abstract class StatusDTO { private List bulletins; /** - * Bulletins for this component. - * - * @return + * @return Bulletins for this 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..65823d566c 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 @@ -47,9 +47,7 @@ public class StatusDescriptorDTO { } /** - * The name of this status field. - * - * @return + * @return name of this status field */ public String getField() { return field; @@ -60,9 +58,7 @@ public class StatusDescriptorDTO { } /** - * The label of this status field. - * - * @return + * @return label of this status field */ public String getLabel() { return label; @@ -73,9 +69,7 @@ public class StatusDescriptorDTO { } /** - * The description of this status field. - * - * @return + * @return description of this status field */ public String getDescription() { return description; @@ -86,9 +80,7 @@ public class StatusDescriptorDTO { } /** - * The formatter for this descriptor. - * - * @return + * @return formatter for this 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..a996365d19 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 @@ -37,9 +37,7 @@ public class StatusHistoryDTO { private List statusSnapshots; /** - * When this status history was generated. - * - * @return + * @return when this status history was generated */ @XmlJavaTypeAdapter(TimeAdapter.class) public Date getGenerated() { @@ -51,9 +49,7 @@ public class StatusHistoryDTO { } /** - * The component details for this status history. - * - * @return + * @return The component details for this status history */ public LinkedHashMap getDetails() { return details; @@ -64,9 +60,7 @@ public class StatusHistoryDTO { } /** - * Descriptors for each supported status field. - * - * @return + * @return Descriptors for each supported status field */ public List getFieldDescriptors() { return fieldDescriptors; @@ -77,9 +71,7 @@ public class StatusHistoryDTO { } /** - * The status snapshots. - * - * @return + * @return 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..4ebb5e35f0 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 @@ -28,9 +28,7 @@ public class StatusHistoryDetailDTO { private String value; /** - * The label for this status detail. - * - * @return + * @return label for this status detail */ public String getLabel() { return label; @@ -41,9 +39,7 @@ public class StatusHistoryDetailDTO { } /** - * The value for this status detail. - * - * @return + * @return value for this 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..b39fd607ba 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 @@ -30,9 +30,7 @@ public class StatusSnapshotDTO { private Map statusMetrics; /** - * The timestamp of this snapshot. - * - * @return + * @return timestamp of this snapshot */ public Date getTimestamp() { return timestamp; @@ -43,9 +41,7 @@ public class StatusSnapshotDTO { } /** - * The status metrics. - * - * @return + * @return 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/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..103a93751a 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 @@ -32,9 +32,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 +43,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/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..cddb21ab43 --- /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,45 @@ +/* + * 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/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..ad1c1a5557 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 @@ -31,9 +31,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/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..2791bfaa9b 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 @@ -30,9 +30,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..7988d120d8 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 @@ -32,9 +32,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/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..65c38a979d 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 @@ -21,7 +21,7 @@ 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 + * a response to the API. This particular entity holds a reference to a * controller service. */ @XmlRootElement(name = "controllerServiceEntity") @@ -30,9 +30,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..69999274ef 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 @@ -31,9 +31,8 @@ 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..580a76e4ce 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 @@ -31,9 +31,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..cda93c4ef5 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 @@ -31,9 +31,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/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..ef329b8293 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 @@ -30,9 +30,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..c1991a1dc0 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 @@ -30,10 +30,8 @@ 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..e2bb3e70ef 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 @@ -28,9 +28,7 @@ public class Entity { private RevisionDTO revision; /** - * A revision for this request/response. - * - * @return + * @return revision for this request/response */ 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/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..4586c9d50f 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 @@ -32,9 +32,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/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..dc497b5eb1 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 @@ -30,9 +30,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..a112fdd054 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 @@ -32,9 +32,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/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..d4b9681b3a 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 @@ -32,9 +32,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/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..7c5145ede8 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 @@ -30,9 +30,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..01271905f2 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 @@ -32,9 +32,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..2e3f545b62 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 @@ -31,9 +31,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/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..fa584ce25f 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 @@ -31,9 +31,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..201f5aae22 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 @@ -32,9 +32,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..87ca4a3932 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,7 +17,6 @@ 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; /** 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/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..a94b42f83b 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 @@ -32,9 +32,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..2177564ff7 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 @@ -21,7 +21,7 @@ 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 + * a response to the API. This particular entity holds a reference to a * reporting task. */ @XmlRootElement(name = "reportingTaskEntity") @@ -30,9 +30,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..c527ec72f0 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 @@ -31,9 +31,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..4f7be11c71 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 @@ -31,9 +31,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..01e6918874 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 @@ -31,9 +31,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/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..3ff5bc6d89 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 @@ -48,9 +48,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/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..eece172b5f 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 @@ -33,9 +33,7 @@ public class UserSearchResultsEntity { private List userGroupResults; /** - * The user search results. - * - * @return + * @return user search results */ public List getUserResults() { return userResults; @@ -46,9 +44,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..180b6505c4 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 @@ -48,9 +48,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-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..a86a416480 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 @@ -72,13 +72,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 +97,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 +108,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 +131,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 { @@ -162,7 +154,7 @@ public class HtmlDocumentationWriter implements DocumentationWriter { ++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 { @@ -489,40 +446,38 @@ 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 - * @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 +491,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 +505,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 { 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..4320c6eecf 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 @@ -27,31 +27,32 @@ 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" }) +@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(); - 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; + } } 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..c6ed9fb9ef 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 @@ -31,73 +31,72 @@ 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); - - String results = new String(baos.toByteArray()); - XmlValidator.assertXmlValid(results); + writer.write(processor, baos, false); - 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()); + String results = new String(baos.toByteArray()); + XmlValidator.assertXmlValid(results); - 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.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()); - 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..."); - } + 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"); - @Test - public void testNakedProcessor() throws IOException { - NakedProcessor processor = new NakedProcessor(); - processor.initialize(new MockProcessorInitializationContext()); + 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..."); + } - DocumentationWriter writer = new HtmlProcessorDocumentationWriter(); + @Test + public void testNakedProcessor() throws IOException { + NakedProcessor processor = new NakedProcessor(); + processor.initialize(new MockProcessorInitializationContext()); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); + DocumentationWriter writer = new HtmlProcessorDocumentationWriter(); - writer.write(processor, baos, false); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); - 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."); - + 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."); + + } } 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-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..63d1aa7591 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,9 +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) @@ -31,7 +31,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..04fb3f0029 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,45 @@ 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..4b10be6099 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,68 @@ 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 +92,11 @@ public class NodeIdentifier { public String getId() { return id; } - + public String getDN() { return nodeDn; } - + public String getApiAddress() { return apiAddress; } @@ -96,22 +108,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 +142,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..11a391276f 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,24 @@ 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..b6c373722b 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,22 @@ 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..4e43d4d495 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,16 @@ 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..dc22ba03d8 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,22 @@ 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..2837f1a41a 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,21 @@ 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. - * + * A wrapper class for consolidating a protocol sender and listener for the + * cluster manager. + * * @author unattributed */ 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 +55,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 +63,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 +88,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 +109,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..64ca7fa23b 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,39 @@ 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. - * + * which case, no service discovery occurs and the caller will always receive + * the configured service. + * * @author unattributed */ 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 +67,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 +77,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 +87,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 +120,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 +144,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 +183,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 +208,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 +219,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..34587606a9 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,76 @@ 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 +128,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 +168,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..90f91247cf 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,20 @@ 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 +74,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 +89,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 +116,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 +138,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 +149,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 +164,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 +194,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..172f4592ab 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,8 +47,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Implements a listener for protocol messages sent over unicast socket. - * + * Implements a listener for protocol messages sent over unicast socket. + * * @author unattributed */ public class SocketProtocolListener extends SocketListener implements ProtocolListener { @@ -57,7 +57,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 +65,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 +77,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 +106,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 +127,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 +142,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 +172,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 +184,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..c81c7e0213 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 @@ -23,10 +23,11 @@ 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..6c8b49d912 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 @@ -25,7 +25,7 @@ import org.apache.nifi.cluster.protocol.StandardDataFlow; * @author unattributed */ public class AdaptedConnectionResponse { - + private StandardDataFlow dataFlow; private NodeIdentifier nodeIdentifier; private boolean blockedByFirewall; @@ -34,8 +34,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 +83,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..72d716c00b 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 @@ -20,14 +20,15 @@ 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 +53,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..571d846ee7 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 @@ -20,14 +20,15 @@ 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..81714f53e8 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 @@ -23,13 +23,14 @@ 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 +40,7 @@ public class AdaptedHeartbeat { public void setNodeIdentifier(NodeIdentifier nodeIdentifier) { this.nodeIdentifier = nodeIdentifier; } - + public boolean isPrimary() { return primary; } @@ -51,11 +52,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..d9f3577ed5 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 @@ -23,12 +23,13 @@ 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 +39,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..8d0eddd44b 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 @@ -20,18 +20,19 @@ 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..37256a37bc 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 @@ -27,7 +27,7 @@ public class ConnectionRequestAdapter 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 +50,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..565882ded4 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 @@ -23,11 +23,11 @@ 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 +38,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..859d8b7378 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 @@ -26,17 +26,17 @@ public class NodeBulletinsAdapter 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..4ac92759cc 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 @@ -29,9 +29,10 @@ import org.apache.nifi.cluster.protocol.jaxb.message.NodeIdentifierAdapter; 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..7665274fe0 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 @@ -26,10 +26,10 @@ import org.apache.nifi.cluster.protocol.jaxb.message.NodeIdentifierAdapter; */ @XmlRootElement(name = "disconnectionMessage") public class DisconnectMessage extends ProtocolMessage { - + private NodeIdentifier nodeId; private String explanation; - + @XmlJavaTypeAdapter(NodeIdentifierAdapter.class) public NodeIdentifier getNodeId() { return nodeId; @@ -46,10 +46,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..dbc7bc15c5 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 @@ -23,10 +23,11 @@ import javax.xml.bind.annotation.XmlRootElement; */ @XmlRootElement(name = "exceptionMessage") public class ExceptionMessage extends ProtocolMessage { - + private String exceptionMessage; - public ExceptionMessage() {} + public ExceptionMessage() { + } public String getExceptionMessage() { return exceptionMessage; @@ -35,10 +36,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..f72e270e63 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 @@ -26,7 +26,7 @@ import org.apache.nifi.cluster.protocol.jaxb.message.NodeIdentifierAdapter; */ @XmlRootElement(name = "flowRequestMessage") public class FlowRequestMessage extends ProtocolMessage { - + private NodeIdentifier nodeId; @XmlJavaTypeAdapter(NodeIdentifierAdapter.class) @@ -37,10 +37,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..cc0538c4e8 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 @@ -25,9 +25,9 @@ import org.apache.nifi.cluster.protocol.StandardDataFlow; */ @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..05f40ac260 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 @@ -24,9 +24,9 @@ import javax.xml.bind.annotation.XmlRootElement; */ @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..83c284c76d 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,29 @@ 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..45e4dba0bc 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 @@ -24,9 +24,9 @@ import javax.xml.bind.annotation.XmlRootElement; */ @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..c9cb39fa21 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 @@ -24,13 +24,14 @@ import javax.xml.bind.annotation.XmlRootElement; */ @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 +47,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..db11f92847 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 @@ -30,7 +30,7 @@ public class PrimaryRoleAssignmentMessage extends ProtocolMessage { private NodeIdentifier nodeId; private boolean primary; - + @XmlJavaTypeAdapter(NodeIdentifierAdapter.class) public NodeIdentifier getNodeId() { return nodeId; @@ -47,7 +47,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..6d67d212b0 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 @@ -35,8 +35,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 +63,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..113b719678 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 @@ -25,12 +25,13 @@ import javax.xml.bind.annotation.XmlRootElement; 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 @@ -128,7 +129,8 @@ public class ClusterManagerProtocolSenderImplTest { 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..8df6dcb1d6 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,7 +31,8 @@ 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; @@ -41,60 +41,60 @@ 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 +102,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 +125,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..5e98397928 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,7 +28,8 @@ 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; @@ -39,68 +38,68 @@ 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 +107,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 +122,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-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..803797bd2a 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 @@ -26,9 +26,9 @@ 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 +43,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/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..08d21a5660 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 @@ -27,8 +27,9 @@ public interface ClusterNodeFirewall { * 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..521962918d 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; 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..2803d4ccd1 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 @@ -39,13 +39,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/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..9ee5aa80fb 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 @@ -36,7 +36,7 @@ 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; 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..f3545075ab 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 @@ -31,7 +31,6 @@ import org.apache.nifi.cluster.protocol.NodeIdentifier; * * Clients must call start() and stop() to initialize and stop the instance. * - * @author unattributed */ public interface DataFlowManagementService { @@ -68,21 +67,23 @@ public interface DataFlowManagementService { void updatePrimaryNode(NodeIdentifier nodeId) throws DaoException; /** - * Updates the dataflow with the given serialized form of the Controller Services that are to exist on the NCM. - * - * @param serializedControllerServices - * @throws DaoException + * Updates the dataflow with the given serialized form of the Controller + * Services that are to exist on the NCM. + * + * @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 + * Updates the dataflow with the given serialized form of Reporting Tasks + * that are to exist on the NCM. + * + * @param serializedReportingTasks tasks + * @throws DaoException ex */ void updateReportingTasks(byte[] serializedReportingTasks) throws DaoException; - + /** * Sets the state of the flow. * 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..e2690f759e 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 @@ -187,36 +187,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 +223,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 +256,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 +271,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 +479,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 +502,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 +561,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..4fa6504fa2 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 @@ -64,12 +64,11 @@ import org.slf4j.LoggerFactory; 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 +169,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 +190,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 +215,9 @@ public class DataFlowManagementServiceImpl implements DataFlowManagementService } flowDao.saveDataFlow(new ClusterDataFlow(dataFlow, nodeId, controllerServiceBytes, reportingTaskBytes)); - } finally { - resourceLock.unlock("updateControllerServices"); - } + } finally { + resourceLock.unlock("updateControllerServices"); + } } @Override @@ -361,8 +359,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..be52e0f106 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 @@ -77,14 +77,14 @@ public interface ClusterManager extends NodeInformant { Set getNodes(Status... statuses); /** - * @param nodeId + * @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); @@ -199,9 +199,7 @@ public interface ClusterManager extends NodeInformant { Node getPrimaryNode(); /** - * Returns the bulletin repository. - * - * @return + * @return the bulletin repository */ BulletinRepository getBulletinRepository(); 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..958d60069b 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 @@ -192,19 +192,19 @@ 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 */ 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 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..2cf026a591 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 @@ -318,13 +318,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; @@ -398,6 +398,40 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C snapshotMillis = FormatUtils.getTimeDuration(NiFiProperties.DEFAULT_COMPONENT_STATUS_SNAPSHOT_FREQUENCY, TimeUnit.MILLISECONDS); } 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) { @@ -427,14 +461,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 +513,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 +527,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 +592,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."); } @@ -946,7 +980,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 +1003,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 +1026,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 +1051,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 +1064,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 +1096,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; } @@ -1372,7 +1404,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C writeLock.unlock("handleControllerStartupFailure"); } } - + /** * Adds an instance of a specified controller service. * @@ -1383,7 +1415,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C */ @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 +1442,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 +1528,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,52 +1619,50 @@ 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. * @@ -1815,20 +1841,6 @@ 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()); @@ -2336,7 +2348,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 +2379,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 +2399,7 @@ 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 +2446,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 +2460,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,7 +2673,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C remoteProcessGroup.setAuthorizationIssues(mergedAuthorizationIssues); } } - + private void mergeControllerServiceReferences(final Set referencingComponents, final Map> referencingComponentMap) { final Map activeThreadCounts = new HashMap<>(); final Map states = new HashMap<>(); @@ -2669,7 +2681,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C 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 +2692,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 +2704,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } } } - } + } // go through each referencing components for (final ControllerServiceReferencingComponentDTO referencingComponent : referencingComponents) { @@ -2700,24 +2712,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 +2737,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 +2769,25 @@ 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. - * + * Merges the validation errors into the specified map, recording the + * corresponding node identifier. + * * @param validationErrorMap * @param nodeId - * @param nodeValidationErrors + * @param nodeValidationErrors */ public void mergeValidationErrors(final Map> validationErrorMap, final NodeIdentifier nodeId, final Collection nodeValidationErrors) { if (nodeValidationErrors != null) { @@ -2788,13 +2801,14 @@ 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. - * + * Normalizes the validation errors by prepending the corresponding nodes + * when the error does not exist across all nodes. + * * @param validationErrorMap * @param totalNodes - * @return + * @return */ public Set normalizedMergedValidationErrors(final Map> validationErrorMap, int totalNodes) { final Set normalizedValidationErrors = new HashSet<>(); @@ -2812,7 +2826,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 @@ -3105,7 +3119,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 +3132,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,7 +3170,7 @@ 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)) { @@ -3169,12 +3183,12 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C 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 +3201,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)) { @@ -3883,11 +3897,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..1b128f729d 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 @@ -161,7 +161,7 @@ public class Node implements Cloneable, Comparable { * * 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); 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..c369a7f44a 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 @@ -51,7 +51,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..7bcb2033c8 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 @@ -49,7 +49,7 @@ public class WebClusterManagerFactoryBean implements FactoryBean, ApplicationCon private NiFiProperties properties; private StringEncryptor encryptor; - + private OptimisticLockingManager optimisticLockingManager; @Override @@ -58,8 +58,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 +127,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-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..572f8d69b8 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 @@ -212,7 +212,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 +350,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 +1011,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/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