From 2587ae4de02118704277131a8bc0e40b953ffa49 Mon Sep 17 00:00:00 2001 From: Andre F de Miranda Date: Fri, 17 Feb 2017 01:06:17 +1100 Subject: [PATCH 1/3] NIFI-329 - Introduce IRC Client Services and IRC processors - TLS implementation --- nifi-assembly/LICENSE | 50 ++++ nifi-assembly/NOTICE | 2 + .../nifi-irc-client-service-api-nar/pom.xml | 46 +++ .../src/main/resources/META-INF/LICENSE | 231 ++++++++++++++ .../src/main/resources/META-INF/NOTICE | 0 .../nifi-irc-client-service-api/pom.xml | 54 ++++ .../org/apache/nifi/irc/IRCClientService.java | 40 +++ .../nifi-irc-client-service-nar/pom.xml | 47 +++ .../src/main/resources/META-INF/LICENSE | 282 ++++++++++++++++++ .../src/main/resources/META-INF/NOTICE | 264 ++++++++++++++++ .../nifi-irc-client-service/pom.xml | 74 +++++ .../nifi/irc/StandardIRCClientService.java | 233 +++++++++++++++ .../irc/handlers/ServiceEventHandler.java | 65 ++++ ...g.apache.nifi.controller.ControllerService | 15 + .../nifi-irc-processors-nar/pom.xml | 41 +++ .../src/main/resources/META-INF/LICENSE | 228 ++++++++++++++ .../src/main/resources/META-INF/NOTICE | 0 .../nifi-irc-processors/pom.xml | 65 ++++ .../processors/irc/AbstractIRCProcessor.java | 94 ++++++ .../nifi/processors/irc/ConsumeIRC.java | 108 +++++++ .../nifi/processors/irc/PublishIRC.java | 139 +++++++++ .../irc/handlers/ConsumerEventHandler.java | 127 ++++++++ .../processors/irc/handlers/EventHandler.java | 46 +++ .../irc/handlers/PublisherEventHandler.java | 37 +++ .../org.apache.nifi.processor.Processor | 17 ++ .../processors/irc/TestIRCProcessors.java | 179 +++++++++++ .../src/test/resources/localhost-ks.jks | Bin 0 -> 3512 bytes .../src/test/resources/localhost-ts.jks | Bin 0 -> 1816 bytes nifi-nar-bundles/nifi-irc-bundle/pom.xml | 39 +++ nifi-nar-bundles/pom.xml | 1 + 30 files changed, 2524 insertions(+) create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-api-nar/pom.xml create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-api-nar/src/main/resources/META-INF/LICENSE create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-api-nar/src/main/resources/META-INF/NOTICE create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-api/pom.xml create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-api/src/main/java/org/apache/nifi/irc/IRCClientService.java create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-nar/pom.xml create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-nar/src/main/resources/META-INF/LICENSE create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-nar/src/main/resources/META-INF/NOTICE create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service/pom.xml create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service/src/main/java/org/apache/nifi/irc/StandardIRCClientService.java create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service/src/main/java/org/apache/nifi/irc/handlers/ServiceEventHandler.java create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors-nar/pom.xml create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors-nar/src/main/resources/META-INF/LICENSE create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors-nar/src/main/resources/META-INF/NOTICE create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/pom.xml create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/AbstractIRCProcessor.java create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/ConsumeIRC.java create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/PublishIRC.java create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/handlers/ConsumerEventHandler.java create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/handlers/EventHandler.java create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/handlers/PublisherEventHandler.java create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor create mode 100644 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/test/java/org/apache/nifi/processors/irc/TestIRCProcessors.java create mode 100755 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/test/resources/localhost-ks.jks create mode 100755 nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/test/resources/localhost-ts.jks create mode 100644 nifi-nar-bundles/nifi-irc-bundle/pom.xml diff --git a/nifi-assembly/LICENSE b/nifi-assembly/LICENSE index 0c23ee7085ba..dbcb203d29b3 100644 --- a/nifi-assembly/LICENSE +++ b/nifi-assembly/LICENSE @@ -1969,3 +1969,53 @@ available under an MIT style license. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + The binary distribution of this product bundles 'Kitteh IRC Client Library' + under an MIT style license. + + * Copyright (C) 2013-2017 Matt Baxter http://kitteh.org + + 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 'mbassador' + under an MIT style license. + + * Copyright (c) 2012 Benjamin Diedrichsen + + 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-assembly/NOTICE b/nifi-assembly/NOTICE index 0873c21b73de..16abb3c5ad12 100644 --- a/nifi-assembly/NOTICE +++ b/nifi-assembly/NOTICE @@ -1364,6 +1364,8 @@ The following binary components are provided under the MIT License. See project (MIT License) EWS Java API (com.microsoft.ews-java-api:ews-java-api:2.0 - https://github.com/OfficeDev/ews-java-api) (MIT License) libffi (libffi-3.2.1 - http://sourceware.org/libffi/) + (MIT License) Kitteh IRC Client Library (kitteh client-lib 3.0.3 - http://kicl.kitteh.org/) + (MIT License) 'mbassador' (mbassador 1.2.4 - https://github.com/bennidi/mbassador) ***************** Mozilla Public License v2.0 diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-api-nar/pom.xml b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-api-nar/pom.xml new file mode 100644 index 000000000000..e9df35f35325 --- /dev/null +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-api-nar/pom.xml @@ -0,0 +1,46 @@ + + + + 4.0.0 + + + org.apache.nifi + nifi-irc-bundle + 1.3.0-SNAPSHOT + + + nifi-irc-client-service-api-nar + 1.3.0-SNAPSHOT + nar + + true + true + + + + + org.apache.nifi + nifi-standard-services-api-nar + nar + + + org.apache.nifi + nifi-irc-client-service-api + 1.3.0-SNAPSHOT + + + + diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-api-nar/src/main/resources/META-INF/LICENSE b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-api-nar/src/main/resources/META-INF/LICENSE new file mode 100644 index 000000000000..4dd5f3cbda8f --- /dev/null +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-api-nar/src/main/resources/META-INF/LICENSE @@ -0,0 +1,231 @@ + + 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. + +APACHE NIFI SUBCOMPONENTS: + +The nifi-irc-client-service-api contains subcomponents with separate copyright +notices and license terms. Your use of the source code for the these +subcomponents is subject to the terms and conditions of the following +licenses. + + * Copyright (C) 2013-2017 Matt Baxter http://kitteh.org + + 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-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-api-nar/src/main/resources/META-INF/NOTICE b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-api-nar/src/main/resources/META-INF/NOTICE new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-api/pom.xml b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-api/pom.xml new file mode 100644 index 000000000000..6641aef3cee6 --- /dev/null +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-api/pom.xml @@ -0,0 +1,54 @@ + + + + 4.0.0 + + + org.apache.nifi + nifi-irc-bundle + 1.3.0-SNAPSHOT + + + nifi-irc-client-service-api + jar + + + + org.apache.nifi + nifi-api + provided + + + org.kitteh.irc + client-lib + 3.0.1 + + + net.engio + mbassador + + + io.netty + netty-codec + + + io.netty + netty-handler + + + + + diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-api/src/main/java/org/apache/nifi/irc/IRCClientService.java b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-api/src/main/java/org/apache/nifi/irc/IRCClientService.java new file mode 100644 index 000000000000..03a97d130ddd --- /dev/null +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-api/src/main/java/org/apache/nifi/irc/IRCClientService.java @@ -0,0 +1,40 @@ +/* + * 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.irc; + +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.controller.ControllerService; +import org.apache.nifi.processor.exception.ProcessException; +import org.kitteh.irc.client.library.Client; + +import java.util.concurrent.atomic.AtomicBoolean; + +@Tags({"example"}) +@CapabilityDescription("Example Service API.") +public interface IRCClientService extends ControllerService { + + // public void execute() throws ProcessException; + + public void joinChannel(String channel) throws ProcessException; + + public Client getClient() throws ProcessException; + + public AtomicBoolean getIsConnected() throws ProcessException; + + public int setAndGetDelay(int i); +} diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-nar/pom.xml b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-nar/pom.xml new file mode 100644 index 000000000000..8ee7e064371a --- /dev/null +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-nar/pom.xml @@ -0,0 +1,47 @@ + + + + 4.0.0 + + + org.apache.nifi + nifi-irc-bundle + 1.3.0-SNAPSHOT + + + nifi-irc-client-service-nar + 1.3.0-SNAPSHOT + nar + + true + true + + + + + org.apache.nifi + nifi-irc-client-service-api-nar + 1.3.0-SNAPSHOT + nar + + + org.apache.nifi + nifi-irc-client-service + 1.3.0-SNAPSHOT + + + + diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-nar/src/main/resources/META-INF/LICENSE b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-nar/src/main/resources/META-INF/LICENSE new file mode 100644 index 000000000000..1ef75bbd96a9 --- /dev/null +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-nar/src/main/resources/META-INF/LICENSE @@ -0,0 +1,282 @@ + + 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. + +APACHE NIFI SUBCOMPONENTS: + +The Apache NiFi project contains subcomponents with separate copyright +notices and license terms. Your use of the source code for the these +subcomponents is subject to the terms and conditions of the following +licenses. + +The binary distribution of this product bundles 'Bouncy Castle JDK 1.5 Provider' + under an MIT style license. + + Copyright (c) 2000 - 2015 The Legion of the Bouncy Castle Inc. (http://www.bouncycastle.org) + + 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 'Kitteh IRC Client Library' + under an MIT style license. + + * Copyright (C) 2013-2017 Matt Baxter http://kitteh.org + + 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 'mbassador' + under an MIT style license. + + * Copyright (c) 2012 Benjamin Diedrichsen + + 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-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-nar/src/main/resources/META-INF/NOTICE b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-nar/src/main/resources/META-INF/NOTICE new file mode 100644 index 000000000000..55f2915a7d45 --- /dev/null +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-nar/src/main/resources/META-INF/NOTICE @@ -0,0 +1,264 @@ +nifi-irc-client-service-nar +Copyright 2015-2017 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + +****************** +MIT License +****************** +The following binary components are provided under the MIT License + + (MIT License) Kitteh IRC Client Library + The following NOTICE information applies: + + See the LICENSE file for the Kitteh IRC Client Library copyright and license. + + This project, when built, includes the MBassador event bus and Netty framework. + + + + The license for MBassador's files, located (in the binary) in the folder org/kitteh/irc/lib/net/engio/mbassy/ is as follows: + ----------------------- + MIT License + + Copyright (c) 2012 Benjamin Diedrichsen + + 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 license for the Netty framework, located (in the binary) in the folder org/kitteh/irc/lib/io/netty/ is as follows: + ----------------------- + Copyright 2011 The Netty Project + + The Netty Project 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. + ----------------------- + + The Netty framework additionally includes other projects with their own licenses. These licenses can be found at https://github.com/netty/netty/tree/4.0/license + + For your convenience, the full text of the Apache License, version 2.0: + + + + + 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. diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service/pom.xml b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service/pom.xml new file mode 100644 index 000000000000..fa9e844cffa1 --- /dev/null +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service/pom.xml @@ -0,0 +1,74 @@ + + + + 4.0.0 + + + org.apache.nifi + nifi-irc-bundle + 1.3.0-SNAPSHOT + + + nifi-irc-client-service + jar + + + + org.apache.nifi + nifi-irc-client-service-api + 1.3.0-SNAPSHOT + + + org.apache.nifi + nifi-api + provided + + + org.apache.nifi + nifi-utils + + + org.apache.nifi + nifi-security-utils + + + org.apache.nifi + nifi-ssl-context-service-api + compile + + + org.kitteh.irc + client-lib + 3.0.3 + + + org.apache.nifi + nifi-mock + test + + + org.slf4j + slf4j-simple + test + + + junit + junit + test + + + + diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service/src/main/java/org/apache/nifi/irc/StandardIRCClientService.java b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service/src/main/java/org/apache/nifi/irc/StandardIRCClientService.java new file mode 100644 index 000000000000..1d3d8b992185 --- /dev/null +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service/src/main/java/org/apache/nifi/irc/StandardIRCClientService.java @@ -0,0 +1,233 @@ +/* + * 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.irc; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; +import java.security.cert.CertificateException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnDisabled; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.irc.handlers.ServiceEventHandler; +import org.apache.nifi.logging.ComponentLog; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.ssl.SSLContextService; +import org.apache.nifi.security.util.KeyStoreUtils; +import org.apache.nifi.util.StringUtils; +import org.kitteh.irc.client.library.Client; +import org.kitteh.irc.client.library.feature.sending.SingleDelaySender; + + +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManagerFactory; + +@Tags({ "irc"}) +@CapabilityDescription("IRC client controller.") +public class StandardIRCClientService extends AbstractControllerService implements IRCClientService { + + public static final PropertyDescriptor IRC_SERVER = new PropertyDescriptor + .Builder().name("IRC_SERVER") + .displayName("IRC Server") + .description("The IRC server you want to connect to") + .required(true) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + public static final PropertyDescriptor IRC_SERVER_PORT = new PropertyDescriptor + .Builder().name("IRC_SERVER_PORT") + .displayName("IRC Server Port") + .description("The IRC server port you want to connect to") + .required(true) + .defaultValue("6667") + .addValidator(StandardValidators.PORT_VALIDATOR) + .build(); + public static final PropertyDescriptor SSL_CONTEXT_SERVICE = new PropertyDescriptor.Builder() + .name("SSL_CONTEXT_SERVICE") + .displayName("SSL Context Service") + .description("The Controller Service to use in order to obtain an SSL Context. If this property is set, " + + "IRC connection will be established over a secure connection.") + .required(false) + .identifiesControllerService(SSLContextService.class) + .build(); + public static final PropertyDescriptor IRC_NICK = new PropertyDescriptor + .Builder().name("IRC_NICK") + .displayName("Nickname") + .description("The Nickname to use when connecting to the IRC server") + .required(true) + .defaultValue("NiFi") + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + public static final PropertyDescriptor IRC_SERVER_PASSWORD = new PropertyDescriptor + .Builder().name("IRC_SERVER_PASSWORD") + .displayName("Password") + .description("The password to be user for authentication") + .required(false) + .sensitive(true) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + + private static final List properties; + private Client ircClient; + private ComponentLog logger; + protected AtomicBoolean connectionStatus = new AtomicBoolean(false); + + protected String clientIdentification; + private static final Set requestedChannels = new HashSet<>(); + + + static { + final List props = new ArrayList<>(); + props.add(IRC_SERVER); + props.add(IRC_SERVER_PORT); + props.add(IRC_NICK); + props.add(IRC_SERVER_PASSWORD); + props.add(SSL_CONTEXT_SERVICE); + properties = Collections.unmodifiableList(props); + } + + // Initialize MESSAGE_DELAY using KICL's default + private AtomicInteger MESSAGE_DELAY = new AtomicInteger(SingleDelaySender.DEFAULT_MESSAGE_DELAY); + + @Override + protected List getSupportedPropertyDescriptors() { + return properties; + } + + /** + * @param context + * the configuration context + * @throws InitializationException + * if unable to create a database connection + */ + @OnEnabled + public void onEnabled(final ConfigurationContext context) throws InitializationException { + clientIdentification = this.getIdentifier(); + + this.logger = this.getLogger(); + + Client.Builder clientSkeleton = Client + .builder() + .serverHost(context.getProperty(IRC_SERVER).getValue()) + .serverPort(context.getProperty(IRC_SERVER_PORT).asInteger()) + .nick(context.getProperty(IRC_NICK).getValue()) + .user("nifi") + .realName(String.join(" - ", new String[] { this.getClass().getSimpleName(), this.clientIdentification })); + + // Setup Security + final SSLContextService sslContextService = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class); + + if (sslContextService == null) { + // Disabled... + clientSkeleton.secure(false); + } else { + // Enabled + clientSkeleton.secure(true); + SSLContext sslContext; + TrustManagerFactory tmf; + + // Is key configured? If yes, populate and let it go... + if (sslContextService.isKeyStoreConfigured()) { + final String keyPassword = sslContextService.getKeyPassword(); + final String keyFile = sslContextService.getKeyStoreFile(); + + if (!StringUtils.isEmpty(keyPassword) && !StringUtils.isEmpty(keyFile) ) { + clientSkeleton.secureKeyPassword(keyPassword); + clientSkeleton.secureKey(new File(keyFile)); + sslContext = sslContextService.createSSLContext(SSLContextService.ClientAuth.REQUIRED); + } else { + sslContext = sslContextService.createSSLContext(SSLContextService.ClientAuth.NONE); + } + + try { + Provider tlsProvider = sslContext.getProvider(); + + final KeyStore trustStore = KeyStoreUtils.getTrustStore(sslContextService.getTrustStoreType()); + try (final InputStream trustStoreStream = new FileInputStream(new File(sslContextService.getTrustStoreFile()))) { + trustStore.load(trustStoreStream, sslContextService.getTrustStorePassword().toCharArray()); + } + + tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + tmf.init(trustStore); + + clientSkeleton.secureTrustManagerFactory(tmf); + } catch (NoSuchAlgorithmException | CertificateException | KeyStoreException | IOException e) { + logger.error("Failed to initialize secure IRC service due to {}", new Object[]{e.getMessage()}, e); + } + + } + } + this.ircClient = clientSkeleton.build(); + + // Setup the Server Handlers + ServiceEventHandler serviceEventHandler = new ServiceEventHandler(connectionStatus, requestedChannels, getLogger()); + ircClient.getEventManager().registerEventListener(serviceEventHandler); + } + + @OnDisabled + public void shutdown() { + this.ircClient.shutdown(clientIdentification + " - is going to rest a bit..."); + while (this.connectionStatus.get()) { + // Wait for the disconnection + } + } + + @Override + public void joinChannel(String channel) throws ProcessException { + this.requestedChannels.add(channel); + this.getClient().addChannel(channel); + } + + @Override + public Client getClient() throws ProcessException { + return this.ircClient; + } + + @Override + public AtomicBoolean getIsConnected() throws ProcessException { + return this.connectionStatus; + } + + @Override + public int setAndGetDelay(int delay) { + synchronized (this.MESSAGE_DELAY) { + this.MESSAGE_DELAY.getAndSet(delay); + this.ircClient.setMessageSendingQueueSupplier(SingleDelaySender.getSupplier(this.MESSAGE_DELAY.get())); + return this.MESSAGE_DELAY.get(); + } + } + + +} diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service/src/main/java/org/apache/nifi/irc/handlers/ServiceEventHandler.java b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service/src/main/java/org/apache/nifi/irc/handlers/ServiceEventHandler.java new file mode 100644 index 000000000000..d7448fbb32a9 --- /dev/null +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service/src/main/java/org/apache/nifi/irc/handlers/ServiceEventHandler.java @@ -0,0 +1,65 @@ +/* + * 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.irc.handlers; + +import net.engio.mbassy.listener.Handler; +import org.apache.nifi.logging.ComponentLog; +import org.kitteh.irc.client.library.event.client.ClientConnectedEvent; +import org.kitteh.irc.client.library.event.client.ClientConnectionClosedEvent; + +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; + + +public class ServiceEventHandler { + private final Set requestedChannels; + private final ComponentLog logger; + private final AtomicBoolean connectionStatus; + + public ServiceEventHandler(AtomicBoolean connectionStatus, Set requestedChannels, ComponentLog logger) { + this.requestedChannels = requestedChannels; + this.logger = logger; + this.connectionStatus = connectionStatus; + } + + @Handler + protected void onConnect(ClientConnectedEvent event) { + connectionStatus.set(true); + logger.info("Successfully connected to: " + event.getServerInfo().getAddress().get()); + // If not inside all the desired channel, try to join + if (!event.getClient().getChannels().contains(requestedChannels) || event.getClient().getChannels().isEmpty()) { + // chop the already joined channels + Set pendingChannels = new HashSet<>(requestedChannels); + pendingChannels.removeAll(event.getClient().getChannels()); + pendingChannels.forEach(pendingChannel -> event.getClient().addChannel(pendingChannel)); + } + } + + @Handler + protected void onDisconnect(ClientConnectionClosedEvent event) { + connectionStatus.set(false); + // isReconnecting is used to KICL to state if re-connection is being attempted + // e.g. connection dropped but client is trying to reconnect + if (event.isReconnecting()) { + logger.warn("Connection to IRC server dropped! Attempting to reconnect"); + } else { + // This in theory should only be invoked during shutdown + logger.info("Successfully disconnected from: " + event.getClient().getServerInfo().getAddress().get()); + } + } +} diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService new file mode 100644 index 000000000000..45d825c449c4 --- /dev/null +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService @@ -0,0 +1,15 @@ +# 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. +org.apache.nifi.irc.StandardIRCClientService \ No newline at end of file diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors-nar/pom.xml b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors-nar/pom.xml new file mode 100644 index 000000000000..d5c0646e8546 --- /dev/null +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors-nar/pom.xml @@ -0,0 +1,41 @@ + + + + 4.0.0 + + + org.apache.nifi + nifi-irc-bundle + 1.3.0-SNAPSHOT + + + nifi-irc-processors-nar + 1.3.0-SNAPSHOT + nar + + true + true + + + + + org.apache.nifi + nifi-irc-processors + 1.3.0-SNAPSHOT + + + + diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors-nar/src/main/resources/META-INF/LICENSE b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors-nar/src/main/resources/META-INF/LICENSE new file mode 100644 index 000000000000..6e4070987974 --- /dev/null +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors-nar/src/main/resources/META-INF/LICENSE @@ -0,0 +1,228 @@ + + 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. + + nifi-irc-processor includes subcomponents with separate copyright notices and + license terms. Your use of these subcomponents is subject to the terms + and conditions of the following licenses: + + * Copyright (C) 2013-2017 Matt Baxter http://kitteh.org + + 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-nar-bundles/nifi-irc-bundle/nifi-irc-processors-nar/src/main/resources/META-INF/NOTICE b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors-nar/src/main/resources/META-INF/NOTICE new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/pom.xml b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/pom.xml new file mode 100644 index 000000000000..87b2362a3dc3 --- /dev/null +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + + + org.apache.nifi + nifi-irc-bundle + 1.3.0-SNAPSHOT + + + nifi-irc-processors + jar + + + org.apache.nifi + nifi-api + + + org.apache.nifi + nifi-irc-client-service + 1.3.0-SNAPSHOT + provided + + + org.apache.nifi + nifi-ssl-context-service-api + provided + + + org.apache.nifi + nifi-mock + test + + + org.slf4j + slf4j-simple + test + + + junit + junit + 4.11 + test + + + org.apache.nifi + nifi-ssl-context-service + test + + + \ No newline at end of file diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/AbstractIRCProcessor.java b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/AbstractIRCProcessor.java new file mode 100644 index 000000000000..ff17b959a484 --- /dev/null +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/AbstractIRCProcessor.java @@ -0,0 +1,94 @@ +/* + * 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.irc; + +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.ControllerService; +import org.apache.nifi.irc.IRCClientService; +import org.apache.nifi.irc.StandardIRCClientService; +import org.apache.nifi.processor.AbstractSessionFactoryProcessor; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSessionFactory; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.processors.irc.handlers.EventHandler; +import org.kitteh.irc.client.library.Client; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +abstract class AbstractIRCProcessor extends AbstractSessionFactoryProcessor { + public static PropertyDescriptor IRC_CLIENT_SERVICE = new PropertyDescriptor.Builder() + .name("IRC_CLIENT_SERVICE") + .displayName("IRC Client Service") + .description("The IRC Client Service to use with this client") + .identifiesControllerService(StandardIRCClientService.class) + .required(true) + .build(); + public static PropertyDescriptor IRC_CHANNEL = new PropertyDescriptor.Builder() + .name("IRC_CHANNEL") + .displayName("IRC Channel") + .description("The IRC channel this processor will consume data from") + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .required(true) + .build(); + + + public static final Relationship REL_SUCCESS = new Relationship.Builder() + .name("success") + .description("Any FlowFile that is successfully captured will be passed to this Relationship.") + .build(); + + protected volatile IRCClientService ircClientService; + protected volatile Client client = null; + + @Override + public Set getRelationships() { + final Set relationships = new HashSet<>(); + relationships.add(REL_SUCCESS); + return relationships; + } + + @Override + protected List getSupportedPropertyDescriptors() { + List propDescs = new ArrayList<>(); + propDescs.add(IRC_CLIENT_SERVICE); + propDescs.add(IRC_CHANNEL); + return propDescs; + } + + @OnScheduled + public void onScheduled(ProcessContext context) { + String IRCServiceId = context.getProperty(IRC_CLIENT_SERVICE).getValue();; + ControllerService controllerService = context.getControllerServiceLookup().getControllerService(IRCServiceId); + + ircClientService = (IRCClientService) controllerService; + } + + protected Client setupClient(final ProcessContext context, final ProcessSessionFactory sessionFactory, IRCClientService ircClientService, EventHandler eventHandler) { + ircClientService.getClient().getEventManager().registerEventListener(eventHandler); + return ircClientService.getClient(); + } + + protected void clearSetup(Client client, EventHandler eventHandler) { + client.getEventManager().unregisterEventListener(eventHandler); + } + +} \ No newline at end of file diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/ConsumeIRC.java b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/ConsumeIRC.java new file mode 100644 index 000000000000..8a8cc865f36f --- /dev/null +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/ConsumeIRC.java @@ -0,0 +1,108 @@ +/* + * 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.irc; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.TriggerSerially; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnStopped; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSessionFactory; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.processors.irc.handlers.ConsumerEventHandler; + +@Tags({"consume", "irc"}) +@TriggerSerially +@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN) +@CapabilityDescription("This processor implements a IRC client allowing nifi to listen for predifined IRC channel" + + "and convert all received messages into flowfiles." + + "Due to the nature of IRC no delivery guarantees are offered. USE WITH CARE") + +@WritesAttributes({ + @WritesAttribute(attribute = "irc.sender", description = "The IRC nickname source user of the message"), + @WritesAttribute(attribute = "irc.channel", description = "The channel from where the message was received "), + @WritesAttribute(attribute = "irc.server", description = "The values IRC channel where the message was received from")}) +public class ConsumeIRC extends AbstractIRCProcessor { + public static PropertyDescriptor IRC_PROCESS_PRIV_MESSAGES = new PropertyDescriptor.Builder() + .name("IRC_PROCESS_PRIV_MESSAGES") + .displayName("Process Private Message") + .description("Defines if the processor should discard private messages or to process them as FlowFiles.") + .allowableValues("true", "false") + .defaultValue("false") + .addValidator(StandardValidators.BOOLEAN_VALIDATOR) + .required(true) + .build(); + + public static PropertyDescriptor IRC_STRIP_FORMATTING = new PropertyDescriptor.Builder() + .name("IRC_STRIP_FORMATTING") + .displayName("Strip message formatting") + .description("Defines if the processor should strip message formatting when writing content to FlowFile") + .allowableValues("true", "false") + .defaultValue("false") + .addValidator(StandardValidators.BOOLEAN_VALIDATOR) + .required(true) + .build(); + + private volatile ConsumerEventHandler eventHandler; + + @Override + protected List getSupportedPropertyDescriptors() { + List propDescs = new ArrayList<>(); + propDescs.add(IRC_CLIENT_SERVICE); + propDescs.add(IRC_CHANNEL); + propDescs.add(IRC_PROCESS_PRIV_MESSAGES); + propDescs.add(IRC_STRIP_FORMATTING); + return propDescs; + } + + @OnStopped + public void onUnscheduled(ProcessContext context) { + clearSetup(client, eventHandler); + this.client = null; + } + + @Override + public void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory ) throws ProcessException { + if (client == null) { + // Initialise client + // Initialise the handler that will be provided to the setupClient super method + this.eventHandler = new ConsumerEventHandler(context, sessionFactory, getLogger()); + // initialize the client + this.client = setupClient(context, sessionFactory, ircClientService, eventHandler); + } + + // Verify if should join the channel + if (!this.client.getChannels().contains(context.getProperty(IRC_CHANNEL).getValue())) { + ircClientService.joinChannel(context.getProperty(IRC_CHANNEL).getValue()); + } + + + if (ircClientService.getIsConnected().get()) { + } + // Let KICL take care of the session. + context.yield(); + } + +} diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/PublishIRC.java b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/PublishIRC.java new file mode 100644 index 000000000000..1b36ef8b12b4 --- /dev/null +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/PublishIRC.java @@ -0,0 +1,139 @@ +/* + * 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.irc; + +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.TriggerSerially; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnStopped; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.ProcessSessionFactory; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.io.InputStreamCallback; +import org.apache.nifi.processors.irc.handlers.PublisherEventHandler; +import org.apache.nifi.stream.io.StreamUtils; +import org.apache.nifi.util.StopWatch; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.concurrent.TimeUnit; + +@Tags({"publish", "irc"}) +@TriggerSerially +@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN) + +@CapabilityDescription("This processor implements a IRC client allowing nifi to publish flowfile contents into a " + + "predefined IRC channel. " + "\n" + + "IMPORTANT NOTE: Due to the nature of the IRC protocol, no delivery guarantees are offered. USE WITH CARE") + +@WritesAttributes({ + @WritesAttribute(attribute = "irc.sender", description = "The IRC nickname source user of the message"), + @WritesAttribute(attribute = "irc.channel", description = "The channel from where the message was received "), + @WritesAttribute(attribute = "irc.server", description = "The values IRC channel where the message was received from")}) +public class PublishIRC extends AbstractIRCProcessor { + + private volatile PublisherEventHandler eventHandler; + + @OnStopped + public void onUnscheduled(ProcessContext context) { + clearSetup(client, eventHandler); + client = null; + } + + @Override + public void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException { + ProcessSession session = sessionFactory.createSession(); + + + + if (client == null) { + // Initialise the handler that will be provided to the setupClient super method + this.eventHandler = new PublisherEventHandler(context, sessionFactory, getLogger()); + this.client = ircClientService.getClient(); + this.client.getEventManager().registerEventListener(this.eventHandler); + } + + if (ircClientService.getIsConnected().get()) { + FlowFile flowFile = session.get(); + if (flowFile == null) { + return; + } + + final StopWatch watch = new StopWatch(); + watch.start(); + + // ensure queue is set to no delay + ircClientService.setAndGetDelay(0); + + final String targetChannel = context.getProperty(IRC_CHANNEL).getValue(); + // Verify if should join the channel + if (!ircClientService.getClient().getChannels().contains(targetChannel)) { + ircClientService.joinChannel(targetChannel); + } + + + // Do the FlowFile magic + if (client.getChannel(targetChannel).isPresent()) { + client.sendMessage(targetChannel, readContent(session, flowFile).toString()); + session.transfer(flowFile, REL_SUCCESS); + watch.stop(); + session.getProvenanceReporter().send(flowFile, "irc://" + .concat(client.getServerInfo().getAddress().get()) + .concat("/") + // Device if append channel to URI or not + .concat(targetChannel.concat("/")), + watch.getDuration(TimeUnit.MILLISECONDS) + ); + } else { + // The client seems to be waiting for join command to complete, rollback for now + session.rollback(false); + } + // Commit no matter what + session.commit(); + } + context.yield(); + } + + /** + * Helper method to read the FlowFile content stream into a ByteArrayOutputStream object. + * + * @param session + * - the current process session. + * @param flowFile + * - the FlowFile to read the content from. + * + * @return ByteArrayOutputStream object containing the FlowFile content. + */ + protected ByteArrayOutputStream readContent(final ProcessSession session, final FlowFile flowFile) { + final ByteArrayOutputStream baos = new ByteArrayOutputStream((int) flowFile.getSize() + 1); + session.read(flowFile, new InputStreamCallback() { + @Override + public void process(final InputStream in) throws IOException { + StreamUtils.copy(in, baos); + } + }); + + return baos; + } + +} diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/handlers/ConsumerEventHandler.java b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/handlers/ConsumerEventHandler.java new file mode 100644 index 000000000000..1311df08a5bf --- /dev/null +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/handlers/ConsumerEventHandler.java @@ -0,0 +1,127 @@ +/* + * 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.irc.handlers; + +import net.engio.mbassy.listener.Handler; +import net.engio.mbassy.listener.Invoke; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.logging.ComponentLog; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.ProcessSessionFactory; +import org.apache.nifi.processor.exception.FlowFileAccessException; +import org.apache.nifi.processor.io.OutputStreamCallback; +import org.apache.nifi.processors.irc.ConsumeIRC; +import org.apache.nifi.util.StopWatch; +import org.kitteh.irc.client.library.event.channel.ChannelMessageEvent; +import org.kitteh.irc.client.library.event.helper.MessageEvent; +import org.kitteh.irc.client.library.event.user.PrivateMessageEvent; +import org.kitteh.irc.client.library.util.Format; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; + + +public class ConsumerEventHandler extends EventHandler { + + public ConsumerEventHandler(ProcessContext context, ProcessSessionFactory sessionFactory, ComponentLog logger) { + super(context, sessionFactory, logger); + } + + @Handler(delivery = Invoke.Asynchronously) + protected void onPrivateMessageReceived(PrivateMessageEvent event) { + logger.info("Received private message '{}' from {} while waiting for messages on {} ", + new Object[] {event.getMessage(), event.getActor().getName(), context.getProperty(ConsumeIRC.IRC_CHANNEL).getValue()}); + if (context.getProperty(ConsumeIRC.IRC_PROCESS_PRIV_MESSAGES).asBoolean()) { + turnEventIntoFlowFile(event); + } else { + event.sendReply(String.format("Hi %s. Thank you for your message but I am not looking to chat with strangers.", + String.valueOf(event.getActor().getNick()))); + } + } + + @Handler(delivery = Invoke.Asynchronously) + protected void onChannelMessageReceived(ChannelMessageEvent event) { + // verify if the message was sent to the channel the processor is consuming + if (event.getChannel().getName().equals(context.getProperty(ConsumeIRC.IRC_CHANNEL).getValue())) { + + logger.info("Received message '{}' on channel {} while waiting for messages on {} ", + new Object[]{event.getMessage(), event.getChannel().getName(), context.getProperty(ConsumeIRC.IRC_CHANNEL).getValue()}); + turnEventIntoFlowFile(event); + } + } + + private void turnEventIntoFlowFile(final MessageEvent messageEvent) { + final ProcessSession processSession = sessionFactory.createSession(); + final StopWatch watch = new StopWatch(); + watch.start(); + try { + FlowFile flowFile = processSession.create(); + + + flowFile = processSession.write(flowFile, new OutputStreamCallback() { + @Override + public void process(OutputStream out) throws IOException { + if (context.getProperty(ConsumeIRC.IRC_STRIP_FORMATTING).asBoolean()) { + out.write(Format.stripAll(messageEvent.getMessage()).getBytes()); + } else { + out.write(messageEvent.getMessage().getBytes()); + } + } + }); + + final Map attributes = new HashMap<>(); + + + // Extract metadata and add as attributes of a channel message via casting + if (messageEvent instanceof ChannelMessageEvent) { + attributes.put("irc.sender", ((ChannelMessageEvent) messageEvent).getActor().getName()); + attributes.put("irc.channel", ((ChannelMessageEvent) messageEvent).getChannel().getName()); + } + // Private messages lack channels + if (messageEvent instanceof PrivateMessageEvent) { + attributes.put("irc.sender", ((PrivateMessageEvent) messageEvent).getActor().getName()); + } + + // But all come from servers + attributes.put("irc.server", messageEvent.getClient().getServerInfo().getAddress().get()); + flowFile = processSession.putAllAttributes(flowFile, attributes); + + watch.stop(); + processSession.getProvenanceReporter() + .receive(flowFile, "irc://" + .concat(messageEvent.getClient().getServerInfo().getAddress().get()) + .concat("/") + // Device if append channel to URI or not + .concat((messageEvent instanceof ChannelMessageEvent) ? ((ChannelMessageEvent) messageEvent).getChannel().getName().concat("/") : ""), + watch.getDuration(TimeUnit.MILLISECONDS) + ); + + processSession.transfer(flowFile, ConsumeIRC.REL_SUCCESS); + processSession.commit(); + } catch (FlowFileAccessException | IllegalStateException ex) { + logger.error("Unable to fully process input due to " + ex.getMessage(), ex); + throw ex; + } finally { + processSession.rollback(); + } + } +} + diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/handlers/EventHandler.java b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/handlers/EventHandler.java new file mode 100644 index 000000000000..8a7730adb453 --- /dev/null +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/handlers/EventHandler.java @@ -0,0 +1,46 @@ +/* + * 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.irc.handlers; + +import net.engio.mbassy.listener.Handler; +import net.engio.mbassy.listener.Invoke; +import org.apache.nifi.logging.ComponentLog; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSessionFactory; +import org.apache.nifi.processors.irc.ConsumeIRC; +import org.kitteh.irc.client.library.event.channel.RequestedChannelJoinCompleteEvent; + +// Class to generalize the Consumer and Publisher event Handlers +public abstract class EventHandler { + protected final ProcessSessionFactory sessionFactory; + protected final ComponentLog logger; + protected final ProcessContext context; + + public EventHandler(ProcessContext context, ProcessSessionFactory sessionFactory, ComponentLog logger) { + this.sessionFactory = sessionFactory; + this.logger = logger; + this.context = context; + } + + // While the join logic happens at the client service, the "onJoin" handlers are managed by the processors. + @Handler(delivery = Invoke.Asynchronously) + protected void onJoinComplete(RequestedChannelJoinCompleteEvent event) { + if (event.getChannel().getName().equals(context.getProperty(ConsumeIRC.IRC_CHANNEL).getValue())) { + logger.info("Joined channel {} ", new Object[] {event.getAffectedChannel().get().getName()}); + } + } +} diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/handlers/PublisherEventHandler.java b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/handlers/PublisherEventHandler.java new file mode 100644 index 000000000000..a4c54a56a221 --- /dev/null +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/handlers/PublisherEventHandler.java @@ -0,0 +1,37 @@ +/* + * 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.irc.handlers; + +import net.engio.mbassy.listener.Handler; +import org.apache.nifi.logging.ComponentLog; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSessionFactory; +import org.kitteh.irc.client.library.event.helper.ClientEvent; + + +public class PublisherEventHandler extends EventHandler { + public PublisherEventHandler(ProcessContext context, ProcessSessionFactory sessionFactory, ComponentLog logger) { + super(context, sessionFactory, logger); + } + + @Handler + public void handleAll(ClientEvent event) { + final String className = event.getClass().getSimpleName(); + } + +} + diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor new file mode 100644 index 000000000000..4ed28df5c541 --- /dev/null +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor @@ -0,0 +1,17 @@ +r +# 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. +org.apache.nifi.processors.irc.ConsumeIRC +org.apache.nifi.processors.irc.PublishIRC \ No newline at end of file diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/test/java/org/apache/nifi/processors/irc/TestIRCProcessors.java b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/test/java/org/apache/nifi/processors/irc/TestIRCProcessors.java new file mode 100644 index 000000000000..e5f6e3c4777e --- /dev/null +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/test/java/org/apache/nifi/processors/irc/TestIRCProcessors.java @@ -0,0 +1,179 @@ +/* + * 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.irc; + +import org.apache.nifi.irc.IRCClientService; +import org.apache.nifi.irc.StandardIRCClientService; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.ssl.SSLContextService; +import org.apache.nifi.ssl.StandardSSLContextService; +import org.apache.nifi.util.MockFlowFile; +import org.apache.nifi.util.TestRunner; +import org.apache.nifi.util.TestRunners; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + +import java.util.LinkedList; +import java.util.List; + +public class TestIRCProcessors { + + + @Before + public void init() { + + } + + @Ignore("Test requires network connectivity to an IRC server and left just for illustration purposes") + @Test(timeout = 1200000L) + public void testConsumeIRC() throws InitializationException, InterruptedException { + // Setup the basics + IRCClientService ircClientService = new StandardIRCClientService(); + + + // Setup first runner + final TestRunner runner = TestRunners.newTestRunner(ConsumeIRC.class); + runner.addControllerService("test", ircClientService); + runner.setProperty(ircClientService, StandardIRCClientService.IRC_SERVER, "dev.lab"); + runner.setProperty(ircClientService, StandardIRCClientService.IRC_SERVER_PORT, "6667"); + runner.setProperty(ircClientService, StandardIRCClientService.IRC_NICK, "NiFi"); + runner.setProperty(ConsumeIRC.IRC_CLIENT_SERVICE, ircClientService.getIdentifier()); + runner.setProperty(ConsumeIRC.IRC_CHANNEL, "#nifi_"); + + runner.enableControllerService(ircClientService); + + // Start the processor... and iterate once but let it run + runner.run(1, false); + + + + List results = new LinkedList<>(); + + // loop waiting for content + while (results.size() == 0) { + results.addAll(runner.getFlowFilesForRelationship(ConsumeIRC.REL_SUCCESS)); + } + Assert.assertTrue(results.size() >= 1); + MockFlowFile response = results.get(0); + response.assertContentEquals("..."); + + runner.disableControllerService(ircClientService); + } + + @Ignore("Test requires network connectivity to an IRC server and left just for illustration purposes") + @Test(timeout = 1200000L) + public void testPublishIRC() throws InitializationException, InterruptedException { + // Setup the basics + IRCClientService ircClientService = new StandardIRCClientService(); + + // Setup first runner + final TestRunner runner = TestRunners.newTestRunner(PublishIRC.class); + runner.addControllerService("test", ircClientService); + runner.setProperty(ircClientService, StandardIRCClientService.IRC_SERVER, "dev.lab"); + runner.setProperty(ircClientService, StandardIRCClientService.IRC_SERVER_PORT, "6667"); + runner.setProperty(ircClientService, StandardIRCClientService.IRC_NICK, "NiFi"); + + runner.setProperty(PublishIRC.IRC_CLIENT_SERVICE, ircClientService.getIdentifier()); + runner.setProperty(PublishIRC.IRC_CHANNEL, "#nifi_"); + + runner.enableControllerService(ircClientService); + + // Start the processor... and iterate once but let it run + runner.run(1, false); + + List results = new LinkedList<>(); + + while (!ircClientService.getIsConnected().get()) { + // wait for connection + } + + runner.enqueue("test test test chocolate!"); + + // Run a few times hoping all client setup will be complete by the end of the last iteration + runner.run(20, false); + + // loop waiting for content + while (results.size() == 0) { + results.addAll(runner.getFlowFilesForRelationship(ConsumeIRC.REL_SUCCESS)); + } + Assert.assertTrue(results.size() >= 1); + + runner.disableControllerService(ircClientService); + } + + @Ignore("Test requires network connectivity to an IRC server and left just for illustration purposes") + @Test(timeout = 1200000L) + public void testPublishIRCWithTLS() throws InitializationException, InterruptedException { + // Setup the basics + IRCClientService ircClientService = new StandardIRCClientService(); + SSLContextService sslContextService = new StandardSSLContextService(); + + + // Setup first runner + final TestRunner runner = TestRunners.newTestRunner(PublishIRC.class); + + runner.addControllerService("test", ircClientService); + runner.setProperty(ircClientService, StandardIRCClientService.SSL_CONTEXT_SERVICE, "ssl-test"); + runner.setProperty(ircClientService, StandardIRCClientService.IRC_SERVER, "dev.lab"); + runner.setProperty(ircClientService, StandardIRCClientService.IRC_SERVER_PORT, "6697"); + runner.setProperty(ircClientService, StandardIRCClientService.IRC_NICK, "NiFi"); + // Set up the SSL context + runner.addControllerService("ssl-test", sslContextService); + runner.setProperty(sslContextService, StandardSSLContextService.TRUSTSTORE, "src/test/resources/localhost-ts.jks"); + runner.setProperty(sslContextService, StandardSSLContextService.TRUSTSTORE_PASSWORD, "localtest"); + runner.setProperty(sslContextService, StandardSSLContextService.TRUSTSTORE_TYPE, "JKS"); + runner.setProperty(sslContextService, StandardSSLContextService.KEYSTORE, "src/test/resources/localhost-ks.jks"); + runner.setProperty(sslContextService, StandardSSLContextService.KEYSTORE_PASSWORD, "localtest"); + runner.setProperty(sslContextService, StandardSSLContextService.KEYSTORE_TYPE, "JKS"); + + + + runner.setProperty(PublishIRC.IRC_CLIENT_SERVICE, ircClientService.getIdentifier()); + runner.setProperty(PublishIRC.IRC_CHANNEL, "#nifi_"); + + // Enable the SSL service followed by the IRC service + runner.enableControllerService(sslContextService); + runner.enableControllerService(ircClientService); + + // Start the processor... and iterate once but let it run + runner.run(1, false); + + List results = new LinkedList<>(); + + while (!ircClientService.getIsConnected().get()) { + // wait for connection + } + + runner.enqueue("test test test chocolate!"); + + // Run a few times hoping all client setup will be complete by the end of the last iteration + runner.run(20, false); + + // loop waiting for content + while (results.size() == 0) { + results.addAll(runner.getFlowFilesForRelationship(ConsumeIRC.REL_SUCCESS)); + } + Assert.assertTrue(results.size() >= 1); + + runner.disableControllerService(ircClientService); + } + + + +} diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/test/resources/localhost-ks.jks b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/test/resources/localhost-ks.jks new file mode 100755 index 0000000000000000000000000000000000000000..df36197d92ab8e9870f42666d74c47646fd56f26 GIT binary patch literal 3512 zcmchZXH*l&7RQqiLLfv+Xd3T`p&Iir~-L#Y=#ud?{E1Ldil!ycf^TKF)2%4dD_ z&CRl2juv-w;hX`>r;n!ME0*eJZQo{liYbqFr%&s4KWji3-S|{|Q#z3Bi!_n-HQIvn z)_yhbW3OmoReGZ$;mdsOy)j4ml{e?MpM3BXEZ&%y>@=UK++W7rcU+QDvQxbsYBP>C ziqWW_4}oMI2<5S^ml11u$vzs(Bz1QY%@RE`7dI!_J9pQZTH;ai+~*FZ-!&0FO}AsY zOxhC^^;ctKwcW!%@WtyMsu@6xd3zdv(I!8(v5$IseOUHF#yBeb=(KkBD?D*{)a_{6 zy11;ZtH1s5w8!+ewZvnrkKmE%X*#>Ul%b`b!V6_&L1)$_<6^i6k7Bh$Cbm8X7HN40 zS#G)q)jhM1yqIk|ug4$}yr>lNM^7CDi=S{rQqn53pE8J!Vk=?&Q_pATc&ICwBQ zS(^FTsqy1f=9leGJUj=gReI>!b5N4p{xQ7Yh?)gcpugwPJJKnkHLG#|+$oVkg4yV1aO1A$e7 zaQjo^Q#=uo%^bn4wLVp1-Lpy>m3Om-GmM2@#_FNth9W;Io4*MtEVVL^kgC7SFA-we z#qVjp#>O>$RucpY72eI-)`&+06CPE;lJYi4}@3m`# zJ_AU}qlHP&l8^Sxdy9$-4gOUb4UL4637oYGzAr%oZTy>dW-CT`%o3B(duSJ1(e{$Y zM<9UyvWx;+833RQMN{a4(G-wlHXR5E0)ZV>5?#@72%}__LDViB2!zoC&;$$&%?P2h z0z(iWD~mq^C<3ITh2caaj#n5E%ofhx0nUQPL~nPTGlqqB22Ex{K(u_Eac+1F2b%p@ zfFWRi2!bZ=dhQr@H0!ZShxiYx(fr(S%o#KWt$@YIDPiPok3$Sr4*fIyhqIvoh5uR( z+G9aS0kQzl6d)6b0t5omn(X@$hGj=yE`{&~S2Gtia5Gn?EL_(yG|G+K@=fp0D^(rz zxT1R64#p$fx05POs#deg9+l!c8gwhEor|BbmTA)uRlj-gz6)6_cB&4*Tc-M`bK9>c z*H4msFu-a#7iT^GkUgZvxqIcr(X*;=?XWBEh_4N)!@=`Ah5M!kt4cNNSPATwH?AXC zdENd&XqoAr2Dq}BQ6Gnc3D~XB-xhZWLe^fld)&QlbH&rFP$(?%sxBMiB_=cw?r7CH@9Dd8TnkYHTi)yt>lPMf~Qh{TVz-%zd}mpoX@Lx z7dHOF@cCta&Y}DYj>8M>y0uqvg+{1>9qQK_{DUz^17>%6baZre>Zg9-*JTh{JeEgE(Xc$3KCdGsnB0X~&288Q1yu50`xi`1$u zxw%0F{zoTzg?QpaXg#S%Pc}TD&G9sE#r*FN1sL2ia!PT<-siU_xsUiWo{_zcpd9U!Ni)~G zLi}%abS2t*$1jmQ&rh~)%FTUKeNh{2;~_;7Z1a$&S<~zN0o(9-C8gCXFPUtQaEi(Ok}L|C$~05J}GOTeZ2`>N!9w z|5?&Yv(xUn4w}Md-)+>Xm-idnwqK!l-ep)3M#!opq&#uM)v4O^f$5XSSy^-7P*&lV zi*Bv9WLRzp8QFh_Sp$75|b~$}d%! zADHN!cN?}Zq;Pfp`_&u3UsSsuum4tHmJnSKKJnFdCJT}j<9dY@Y9;CdG*Uh6JugW| zjszU%k%LnRdK;+FkhCS;r3tV3Qu-?q>U@4Gz20FckyBYJ$a2l5D|g6nnw|8he9Zuw zE>xvKu;5sW8RFB^dtl3__u=TrP;92~^c`S>V6o8(>LDq#2#WbkDhztv-Y+KRxxc_( z9-Ig8g=a}sc!GElV)j`DAZZobG^EycOweBae{tMx(CCHt3QRem*{+4B%V0XzUy$!_ zUZ;}$4v!kJ?fiOsh zU6?00F|Q<1!8boIGdazbS85=;kbaqV>qY`p(FtRc*H!<=v7&I|*F*PwV zGR!y-b78_&{p;J_RLYcZ=UKH^oM-d2R~63QK8sqv6wbQ1c%Aj-tT=16Xl@Dp3*V;e zHf*;EU2s!d?EmGAwL4$*KMm76>RxSI^Y_{r+12XOyBVZ5SkF88wdmZUBCW>1mjpsy z^o8A>D^$57@$5Uk|7*7VJjNZDDg1En^sD7BzpeZg;PKvK$44Vgqc3^M$IC50#>}kV z5b(o}W%EH!_vB=5`RI47^%}8dvO6oHmz@0=8J8WnQn7ZTq?gtGwUN*b>^*j51vd`gXZ}Tj=d=! zZ5Q2p8)B?EgtP6!|DK($dm-WAwXXk9U+SN8m>b$H+55Tn^-f3Qi)|}kFy(38X`WLz zb3tscaO}@TH^6nkgPpdLY>Z2bWWLj})^PvwNNvp0VmYkR- zC$rcPs*X#TBPg{vHL)l;!%)D052TJ;m^~!5xFj<#9cRWgF)#(@MiUbYLkm#GG%*0? zP$-w~?rCD&0nCOvupnUsa^#sB8yWuA2RF)=3TX!2_nM>k=E?JKg4=^^-n%dyma}iz z7O0l#8tb4G_&d_JH{#d+qhEI!d^66fYKrV z-7ByE+kQ;?hjsY#V=I=4^0WMI{&xAO++ilu5aB4XiALW_Kd;kHysq{BlM=J!+>0KJ z$C*SKrY8jSiz;)U*)(Zq)1ucc+#e!jzJi?g{o#VvYqM?do!+xL#%xFU&dMq4cmJ|_ z)$}vmhufCDDLpVUyl>Z)NdISr>;jDqTRg=Im0$R1hzV~$&uP?iV%b9*v8wKnnqG|u zi`U6%Z(de9F>i4__b)}$q>sOosu)$Q&n)@4Z$;pQ&K1q~A4WZ$&o-$$Ev}(DR5gXs z$NJxSPc7!gRtAte7ABjPohmimJL!w=83*1S57xEkb0m5`p0y|T%0y91?Xr*$k!KcN z@qQxIFmK}r4~|)iTkLXzMLu+2k#TdI871R( + + + 4.0.0 + + + org.apache.nifi + nifi-nar-bundles + 1.3.0-SNAPSHOT + + + org.apache.nifi + nifi-irc-bundle + 1.3.0-SNAPSHOT + pom + + + nifi-irc-client-service-api + nifi-irc-client-service-api-nar + nifi-irc-client-service + nifi-irc-client-service-nar + nifi-irc-processors + nifi-irc-processors-nar + + + diff --git a/nifi-nar-bundles/pom.xml b/nifi-nar-bundles/pom.xml index a2887b8385da..2ed528af6f5d 100755 --- a/nifi-nar-bundles/pom.xml +++ b/nifi-nar-bundles/pom.xml @@ -72,6 +72,7 @@ nifi-windows-event-log-bundle nifi-ignite-bundle nifi-email-bundle + nifi-irc-bundle nifi-ranger-bundle nifi-websocket-bundle nifi-tcp-bundle From 09d3b18485505354a8f0231ab911f5c25785c75e Mon Sep 17 00:00:00 2001 From: Tony Kurc Date: Tue, 30 May 2017 23:39:50 -0400 Subject: [PATCH 2/3] NIFI-329 - Fixes issues identified during PR --- nifi-assembly/pom.xml | 15 +++++++++++++++ .../nifi-irc-client-service-api/pom.xml | 16 +--------------- .../nifi-irc-processors-nar/pom.xml | 5 +++++ .../processors/irc/AbstractIRCProcessor.java | 3 +-- .../apache/nifi/processors/irc/PublishIRC.java | 2 +- .../org.apache.nifi.processor.Processor | 1 - pom.xml | 18 ++++++++++++++++++ 7 files changed, 41 insertions(+), 19 deletions(-) diff --git a/nifi-assembly/pom.xml b/nifi-assembly/pom.xml index 5c7bff77ded2..04f5d88e94be 100755 --- a/nifi-assembly/pom.xml +++ b/nifi-assembly/pom.xml @@ -476,6 +476,21 @@ nifi-hwx-schema-registry-nar nar + + org.apache.nifi + nifi-irc-client-service-api-nar + nar + + + org.apache.nifi + nifi-irc-client-service-nar + nar + + + org.apache.nifi + nifi-irc-processors-nar + nar + diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-api/pom.xml b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-api/pom.xml index 6641aef3cee6..b9bcbd69dd19 100644 --- a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-api/pom.xml +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service-api/pom.xml @@ -34,21 +34,7 @@ org.kitteh.irc client-lib - 3.0.1 - - - net.engio - mbassador - - - io.netty - netty-codec - - - io.netty - netty-handler - - + 3.0.3 diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors-nar/pom.xml b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors-nar/pom.xml index d5c0646e8546..bc9894b41d77 100644 --- a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors-nar/pom.xml +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors-nar/pom.xml @@ -36,6 +36,11 @@ nifi-irc-processors 1.3.0-SNAPSHOT + + org.apache.nifi + nifi-irc-client-service-api-nar + nar + diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/AbstractIRCProcessor.java b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/AbstractIRCProcessor.java index ff17b959a484..5d45f47332e9 100644 --- a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/AbstractIRCProcessor.java +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/AbstractIRCProcessor.java @@ -20,7 +20,6 @@ import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.controller.ControllerService; import org.apache.nifi.irc.IRCClientService; -import org.apache.nifi.irc.StandardIRCClientService; import org.apache.nifi.processor.AbstractSessionFactoryProcessor; import org.apache.nifi.processor.ProcessContext; import org.apache.nifi.processor.ProcessSessionFactory; @@ -39,7 +38,7 @@ abstract class AbstractIRCProcessor extends AbstractSessionFactoryProcessor { .name("IRC_CLIENT_SERVICE") .displayName("IRC Client Service") .description("The IRC Client Service to use with this client") - .identifiesControllerService(StandardIRCClientService.class) + .identifiesControllerService(IRCClientService.class) .required(true) .build(); public static PropertyDescriptor IRC_CHANNEL = new PropertyDescriptor.Builder() diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/PublishIRC.java b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/PublishIRC.java index 1b36ef8b12b4..6888340e4b2f 100644 --- a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/PublishIRC.java +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/java/org/apache/nifi/processors/irc/PublishIRC.java @@ -40,7 +40,7 @@ @Tags({"publish", "irc"}) @TriggerSerially -@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) @CapabilityDescription("This processor implements a IRC client allowing nifi to publish flowfile contents into a " + "predefined IRC channel. " + "\n" + diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor index 4ed28df5c541..265664241aed 100644 --- a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-processors/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor @@ -1,4 +1,3 @@ -r # 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. diff --git a/pom.xml b/pom.xml index 8794abd6e154..59b011e1e8e8 100644 --- a/pom.xml +++ b/pom.xml @@ -1427,6 +1427,24 @@ 1.3.0-SNAPSHOT nar + + org.apache.nifi + nifi-irc-client-service-api-nar + 1.3.0-SNAPSHOT + nar + + + org.apache.nifi + nifi-irc-client-service-nar + 1.3.0-SNAPSHOT + nar + + + org.apache.nifi + nifi-irc-processors-nar + 1.3.0-SNAPSHOT + nar + org.apache.nifi nifi-parquet-nar From d7c1c52ce0002b324169e2337924fe625846c599 Mon Sep 17 00:00:00 2001 From: Andre F de Miranda Date: Thu, 1 Jun 2017 19:50:01 +1000 Subject: [PATCH 3/3] NIFI-329 - Addresses PR feedback --- nifi-assembly/NOTICE | 11 --------- .../nifi/irc/StandardIRCClientService.java | 23 ++++++++++++++++--- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/nifi-assembly/NOTICE b/nifi-assembly/NOTICE index 16abb3c5ad12..47edb40562c0 100644 --- a/nifi-assembly/NOTICE +++ b/nifi-assembly/NOTICE @@ -1356,17 +1356,6 @@ The following binary components are provided under the Eclipse Public License 1. (EPL 1.0) JaCoCo Java Code Coverage Library ( org.jacoco ) http://www.eclemma.org/jacoco (EPLv1.0) Clojure (org.clojure:clojure:1.8.0 - http://clojure.org) -************************ -The MIT License -************************ - -The following binary components are provided under the MIT License. See project link for details. - - (MIT License) EWS Java API (com.microsoft.ews-java-api:ews-java-api:2.0 - https://github.com/OfficeDev/ews-java-api) - (MIT License) libffi (libffi-3.2.1 - http://sourceware.org/libffi/) - (MIT License) Kitteh IRC Client Library (kitteh client-lib 3.0.3 - http://kicl.kitteh.org/) - (MIT License) 'mbassador' (mbassador 1.2.4 - https://github.com/bennidi/mbassador) - ***************** Mozilla Public License v2.0 ***************** diff --git a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service/src/main/java/org/apache/nifi/irc/StandardIRCClientService.java b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service/src/main/java/org/apache/nifi/irc/StandardIRCClientService.java index 1d3d8b992185..36012d4cb52b 100644 --- a/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service/src/main/java/org/apache/nifi/irc/StandardIRCClientService.java +++ b/nifi-nar-bundles/nifi-irc-bundle/nifi-irc-client-service/src/main/java/org/apache/nifi/irc/StandardIRCClientService.java @@ -30,6 +30,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; @@ -47,6 +48,7 @@ import org.apache.nifi.reporting.InitializationException; import org.apache.nifi.ssl.SSLContextService; import org.apache.nifi.security.util.KeyStoreUtils; +import org.apache.nifi.util.StopWatch; import org.apache.nifi.util.StringUtils; import org.kitteh.irc.client.library.Client; import org.kitteh.irc.client.library.feature.sending.SingleDelaySender; @@ -74,6 +76,14 @@ public class StandardIRCClientService extends AbstractControllerService implemen .defaultValue("6667") .addValidator(StandardValidators.PORT_VALIDATOR) .build(); + public static final PropertyDescriptor IRC_TIMEOUT = new PropertyDescriptor + .Builder().name("IRC_TIMEOUT") + .displayName("IRC Timeout") + .description("The amount of time to wait for certain actions to complete before timing-out") + .required(true) + .defaultValue("5 sec") + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .build(); public static final PropertyDescriptor SSL_CONTEXT_SERVICE = new PropertyDescriptor.Builder() .name("SSL_CONTEXT_SERVICE") .displayName("SSL Context Service") @@ -107,11 +117,11 @@ public class StandardIRCClientService extends AbstractControllerService implemen protected String clientIdentification; private static final Set requestedChannels = new HashSet<>(); - static { final List props = new ArrayList<>(); props.add(IRC_SERVER); props.add(IRC_SERVER_PORT); + props.add(IRC_TIMEOUT); props.add(IRC_NICK); props.add(IRC_SERVER_PASSWORD); props.add(SSL_CONTEXT_SERVICE); @@ -130,7 +140,7 @@ protected List getSupportedPropertyDescriptors() { * @param context * the configuration context * @throws InitializationException - * if unable to create a database connection + * if unable to create an IRC connection */ @OnEnabled public void onEnabled(final ConfigurationContext context) throws InitializationException { @@ -198,10 +208,17 @@ public void onEnabled(final ConfigurationContext context) throws InitializationE @OnDisabled public void shutdown() { + Long timeOut = getConfigurationContext().getProperty(IRC_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS); + final StopWatch stopWatch = new StopWatch(); + + stopWatch.start(); + this.ircClient.shutdown(clientIdentification + " - is going to rest a bit..."); - while (this.connectionStatus.get()) { + while (this.connectionStatus.get() || ( stopWatch.getElapsed(TimeUnit.MILLISECONDS) <= timeOut ) ) { // Wait for the disconnection } + stopWatch.stop(); + logger.info("Disconnected from server after {} milliseconds", new Object[]{stopWatch.getDuration(TimeUnit.MILLISECONDS)}); } @Override