This is an automated email from the ASF dual-hosted git repository. rgoers pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/flume-spring-boot.git
commit 1bd82e4cc5f844d2a95327be85448314d7e96e6f Author: Ralph Goers <[email protected]> AuthorDate: Thu Mar 16 14:03:23 2023 -0700 Initial commit. Fix #1 to require a spring.factories that declares a configuration with a ComponentScan --- .asf.yaml | 40 ++++ CHANGELOG | 7 + LICENSE.txt | 245 +++++++++++++++++++++ NOTICE.txt | 3 + README.md | 59 +++++ RELEASE-NOTES.txt | 33 +++ checkstyle-header.txt | 16 ++ findbugs-exclude-filter.xml | 31 +++ flume-spring-boot-dist/pom.xml | 153 +++++++++++++ flume-spring-boot-dist/src/assembly/bin.xml | 50 +++++ flume-spring-boot-dist/src/assembly/src.xml | 45 ++++ flume-spring-boot/pom.xml | 94 ++++++++ .../apache/flume/spring/boot/FlumeApplication.java | 31 +++ .../boot/config/AbstractFlumeConfiguration.java | 135 ++++++++++++ .../spring/boot/config/SpringConfiguration.java | 59 +++++ .../boot/controller/FlumeMetricsController.java | 48 ++++ .../flume/spring/boot/runner/SpringFlume.java | 59 +++++ .../apache/flume/spring/app/TestSpringFlume.java | 61 +++++ .../apache/flume/spring/app/config/AppConfig.java | 76 +++++++ .../src/test/resources/META-INF/spring.factories | 16 ++ .../src/test/resources/application.yml | 15 ++ flume-spring-boot/src/test/resources/bootstrap.yml | 3 + .../src/test/resources/log4j2-test.xml | 31 +++ pom.xml | 195 ++++++++++++++++ 24 files changed, 1505 insertions(+) diff --git a/.asf.yaml b/.asf.yaml new file mode 100644 index 0000000..cbbf927 --- /dev/null +++ b/.asf.yaml @@ -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. + +# `.asf.yaml` is a branch-specific YAML configuration file for Git repositories to control features such as notifications, GitHub settings, etc. +# See its documentation for details: https://cwiki.apache.org/confluence/display/INFRA/Git+-+.asf.yaml+features + +notifications: + # GitHub already provides notifications for PRs and issues. + # Please don't duplicate that noise here! + commits: [email protected] + jira_options: link label +github: + description: "Apache Flume is a distributed, reliable, and available service for efficiently collecting, aggregating, and moving large amounts of log-like data" + homepage: https://logging.apache.org/flume/ + features: + issues: true + del_branch_on_merge: true + autolink_jira: + - FLUME + labels: + - apache + - api + - java + - jvm + - library + - flume + protected_branches: + trunk: {} diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..b71703f --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,7 @@ +Release Notes - Flume Spring Boot - Version 2.0.0 + +** Bug + * [#1] - Require Applications to define a configuration class containing the appropriate ComponentScan declaration in spring.factories. + + + diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..9fa7156 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,245 @@ + + 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. + +==== + +The following files are included under the 2-Clause BSD License + +flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/solr/collection1/conf/lang/stopwords_ar.txt +flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/solr/collection1/conf/lang/stopwords_bg.txt +flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/solr/collection1/conf/lang/stopwords_da.txt +flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/solr/collection1/conf/lang/stopwords_de.txt +flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/solr/collection1/conf/lang/stopwords_es.txt +flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/solr/collection1/conf/lang/stopwords_fa.txt +flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/solr/collection1/conf/lang/stopwords_fi.txt +flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/solr/collection1/conf/lang/stopwords_fr.txt +flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/solr/collection1/conf/lang/stopwords_hi.txt +flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/solr/collection1/conf/lang/stopwords_hu.txt +flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/solr/collection1/conf/lang/stopwords_it.txt +flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/solr/collection1/conf/lang/stopwords_nl.txt +flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/solr/collection1/conf/lang/stopwords_no.txt +flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/solr/collection1/conf/lang/stopwords_pt.txt +flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/solr/collection1/conf/lang/stopwords_ro.txt +flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/solr/collection1/conf/lang/stopwords_ru.txt +flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/solr/collection1/conf/lang/stopwords_sv.txt + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY 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. diff --git a/NOTICE.txt b/NOTICE.txt new file mode 100644 index 0000000..33c6200 --- /dev/null +++ b/NOTICE.txt @@ -0,0 +1,3 @@ +Apache Flume Spring Boot +Copyright 2022-2023 The Apache Software Foundation + diff --git a/README.md b/README.md new file mode 100644 index 0000000..26a4e14 --- /dev/null +++ b/README.md @@ -0,0 +1,59 @@ +<!-- +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. +--> + +# Welcome to Apache Flume Spring Boot! + +Apache Flume is a distributed, reliable, and available service for efficiently +collecting, aggregating, and moving large amounts of log-like data. It has a simple +and flexible architecture based on streaming data flows. It is robust and fault +tolerant with tunable reliability mechanisms and many failover and recovery +mechanisms. The system is centrally managed and allows for intelligent dynamic +management. It uses a simple extensible data model that allows for online +analytic application. + +The Apache Flume Spring Boot module provides the minimal framework required to allow +Apache Flume to be created and configured as a "normal" Spring Boot applications. + +Apache Flume Spring Boot is open-sourced under the Apache Software Foundation License v2.0. + +## Documentation + +Documentation is included in the binary distribution under the docs directory. +In source form, it can be found in the flume-ng-doc directory. + +The Flume 1.x guide and FAQ are available here: + +* https://cwiki.apache.org/FLUME +* https://cwiki.apache.org/confluence/display/FLUME/Getting+Started + +## Contact us! + +* Mailing lists: https://cwiki.apache.org/confluence/display/FLUME/Mailing+Lists +* Slack channel #flume on https://the-asf.slack.com/ + +Bug and Issue tracker. + +* https://github.com/apache/flume-spring-boot/issues + +## Compiling Flume Spring Boot + +Compiling Flume Spring Boot requires the following tools: + +* Oracle Java JDK 11 +* Apache Maven 3.x diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt new file mode 100644 index 0000000..82feabe --- /dev/null +++ b/RELEASE-NOTES.txt @@ -0,0 +1,33 @@ +Apache Flume Spring Boot 2.0.0 + +CONTENTS +1. What is Apache Flume Spring Boot +2. Major changes in this Release +3. How to Get Involved +4. How to Report Issues + +1. What is Apache Flume Spring Boot +Flume is a distributed, reliable, and available service for +efficiently collecting, aggregating, and moving large amounts of event +data. Flume Spring Boot allows Flume to be packaged and configured as a +"nomral" Spring boot application. + +2. Major changes in this Release +For a detailed list of changes, please see the CHANGELOG file included +in this distribution. + +Apache Flume Spring Boot 2.0.0 modifies how application configuration is +wired into Spring. Prior releases used a mechanism that prevented Spring Cloud +from iniitializing properly. Applications should now add a declaration for +org.springframework.boot.autoconfigure.EnableAutoConfiguration to META-INF/spring.properties +that references a configuration class that contains a @ComponentScan annotation. + +4. How to Get Involved +The Apache Flume project really needs and appreciates any contributions, +including documentation help, source code and feedback. If you are interested +in contributing, please visit: +https://cwiki.apache.org/confluence/display/FLUME/How+to+Contribute + +5. How to Report Issues +The Apache Flume Spring Boot project uses GitHub issues for issue tracking. Please see +https://github.com/apache/flume-spring-boot/issues diff --git a/checkstyle-header.txt b/checkstyle-header.txt new file mode 100644 index 0000000..4f33236 --- /dev/null +++ b/checkstyle-header.txt @@ -0,0 +1,16 @@ +/* + * 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. + */ diff --git a/findbugs-exclude-filter.xml b/findbugs-exclude-filter.xml new file mode 100644 index 0000000..327be31 --- /dev/null +++ b/findbugs-exclude-filter.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!-- + 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. +--> + +<!-- ===================================================================== --> +<!-- $Id: findbugs-exclude-filter.xml 773234 2009-05-09 15:27:59Z rgoers $ --> +<!-- ===================================================================== --> +<FindBugsFilter> + <!-- Enable only high priority warnings --> + <Match> + <Priority value="2"/> + </Match> + + <Match> + <Priority value="3"/> + </Match> +</FindBugsFilter> diff --git a/flume-spring-boot-dist/pom.xml b/flume-spring-boot-dist/pom.xml new file mode 100644 index 0000000..e6c2f51 --- /dev/null +++ b/flume-spring-boot-dist/pom.xml @@ -0,0 +1,153 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.flume</groupId> + <artifactId>flume-spring-boot-parent</artifactId> + <version>2.0.0-SNAPSHOT</version> + </parent> + + <artifactId>flume-spring-boot-dist</artifactId> + <name>Flume Spring Boot Distribution</name> + <packaging>pom</packaging> + + <properties> + <maven.deploy.skip>true</maven.deploy.skip> + <maven.install.skip>true</maven.install.skip> + <maven.test.skip>true</maven.test.skip> + <spotless.check.skip>true</spotless.check.skip> + </properties> + <dependencies> + <dependency> + <groupId>org.apache.flume</groupId> + <artifactId>flume-spring-boot</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <!-- calculate checksums of source release for Apache dist area --> + <plugin> + <groupId>net.nicoulaj.maven.plugins</groupId> + <artifactId>checksum-maven-plugin</artifactId> + <version>${checksum-maven-plugin.version}</version> + <executions> + <execution> + <id>calculate-checksums</id> + <goals> + <goal>files</goal> + </goals> + <!-- execute prior to maven-gpg-plugin:sign due to https://github.com/nicoulaj/checksum-maven-plugin/issues/112 --> + <phase>post-integration-test</phase> + <configuration> + <algorithms> + <algorithm>SHA-512</algorithm> + </algorithms> + <!-- https://maven.apache.org/apache-resource-bundles/#source-release-assembly-descriptor --> + <fileSets> + <fileSet> + <directory>${project.build.directory}</directory> + <includes> + <include>apache-flume-spring-boot-${project.version}-src.zip</include> + <include>apache-flume-spring-boot-${project.version}-src.tar.gz</include> + <include>apache-flume-spring-boot-${project.version}-bin.zip</include> + <include>apache-flume-spring-boot-${project.version}-bin.tar.gz</include> + </includes> + </fileSet> + </fileSets> + <csvSummary>false</csvSummary> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + <executions> + <execution> + <phase>post-integration-test</phase> + <configuration> + <target> + <property name="spaces" value=" " /> + <concat destfile="${project.build.directory}/apache-flume-spring-boot-${project.version}-src.zip.sha512" append="yes">${spaces}apache-flume-spring-boot-${project.version}-src.zip</concat> + <concat destfile="${project.build.directory}/apache-flume-spring-boot-${project.version}-src.tar.gz.sha512" append="yes">${spaces}apache-flume-spring-boot-${project.version}-src.tar.gz</concat> + <concat destfile="${project.build.directory}/apache-flume-spring-boot-${project.version}-bin.zip.sha512" append="yes">${spaces}apache-flume-spring-boot-${project.version}-bin.zip</concat> + <concat destfile="${project.build.directory}/apache-flume-spring-boot-${project.version}-bin.tar.gz.sha512" append="yes">${spaces}apache-flume-spring-boot-${project.version}-bin.tar.gz</concat> + </target> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <executions> + <execution> + <id>source-release-assembly</id> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <finalName>apache-flume-spring-boot-${project.version}</finalName> + <descriptors> + <descriptor>src/assembly/src.xml</descriptor> + </descriptors> + <tarLongFileMode>gnu</tarLongFileMode> + </configuration> + </execution> + <execution> + <id>binary</id> + <configuration> + <finalName>apache-flume-spring-boot-${project.version}</finalName> + <descriptors> + <descriptor>src/assembly/bin.xml</descriptor> + </descriptors> + <tarLongFileMode>gnu</tarLongFileMode> + </configuration> + <goals> + <goal>single</goal> + </goals> + <phase>package</phase> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-gpg-plugin</artifactId> + <executions> + <execution> + <id>sign-release-artifacts</id> + <goals> + <goal>sign</goal> + </goals> + <configuration> + <keyname>${SigningUserName}</keyname> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + +</project> diff --git a/flume-spring-boot-dist/src/assembly/bin.xml b/flume-spring-boot-dist/src/assembly/bin.xml new file mode 100644 index 0000000..1816822 --- /dev/null +++ b/flume-spring-boot-dist/src/assembly/bin.xml @@ -0,0 +1,50 @@ +<!-- + 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. +--> +<assembly> + <id>bin</id> + <formats> + <format>tar.gz</format> + <format>zip</format> + </formats> + <baseDirectory>apache-flume-spring-boot-${project.version}-bin</baseDirectory> + <includeSiteDirectory>false</includeSiteDirectory> + <moduleSets> + <moduleSet> + <useAllReactorProjects>true</useAllReactorProjects> + </moduleSet> + </moduleSets> + <dependencySets> + <dependencySet> + <includes> + <include>org.apache.flume:flume-spring-boot</include> + </includes> + <outputDirectory></outputDirectory> + <unpack>false</unpack> + </dependencySet> + </dependencySets> + + <fileSets> + <fileSet> + <directory>../</directory> + <includes> + <include>LICENSE.txt</include> + <include>NOTICE.txt</include> + <include>RELEASE-NOTES.txt</include> + </includes> + </fileSet> + </fileSets> +</assembly> diff --git a/flume-spring-boot-dist/src/assembly/src.xml b/flume-spring-boot-dist/src/assembly/src.xml new file mode 100644 index 0000000..fb768c5 --- /dev/null +++ b/flume-spring-boot-dist/src/assembly/src.xml @@ -0,0 +1,45 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- + 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. +--> + +<assembly> + <id>src</id> + <formats> + <format>zip</format> + <format>tar.gz</format> + </formats> + <baseDirectory>apache-flume-spring-boot-${project.version}-src</baseDirectory> + <fileSets> + <fileSet> + <directory>../</directory> + + <excludes> + <exclude>**/target/**</exclude> + <exclude>**/.classpath</exclude> + <exclude>**/.project</exclude> + <exclude>**/.idea/**</exclude> + <exclude>**/*.iml</exclude> + <exclude>**/.settings/**</exclude> + <exclude>lib/**</exclude> + <exclude>**/.DS_Store</exclude> + <exclude>./mvn/wrapper/maven-wrapper.jar</exclude> + </excludes> + </fileSet> + </fileSets> +</assembly> diff --git a/flume-spring-boot/pom.xml b/flume-spring-boot/pom.xml new file mode 100644 index 0000000..0bb3c8a --- /dev/null +++ b/flume-spring-boot/pom.xml @@ -0,0 +1,94 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>flume-spring-boot-parent</artifactId> + <groupId>org.apache.flume</groupId> + <version>2.0.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>flume-spring-boot</artifactId> + <name>Flume Spring Boot Support</name> + + <properties> + <module.name>org.apache.flume.spring.boot</module.name> + <spring-boot.version>2.7.5</spring-boot.version> + </properties> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-dependencies</artifactId> + <version>${spring-boot.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.apache.flume</groupId> + <artifactId>flume-ng-configuration</artifactId> + </dependency> + <dependency> + <groupId>org.apache.flume</groupId> + <artifactId>flume-ng-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.flume</groupId> + <artifactId>flume-ng-node</artifactId> + </dependency> + <!-- Spring Boot dependencies --> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-actuator</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter</artifactId> + <exclusions> + <exclusion> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <!-- log dependencies --> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-log4j2</artifactId> + </dependency> + </dependencies> + <build> + + </build> + +</project> \ No newline at end of file diff --git a/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/FlumeApplication.java b/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/FlumeApplication.java new file mode 100644 index 0000000..d4a5146 --- /dev/null +++ b/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/FlumeApplication.java @@ -0,0 +1,31 @@ +/* + * 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.flume.spring.boot; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The application to run. + */ +@SpringBootApplication +public class FlumeApplication { + public static void main(String[] args) { + SpringApplication.run(FlumeApplication.class, args); + } +} diff --git a/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/config/AbstractFlumeConfiguration.java b/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/config/AbstractFlumeConfiguration.java new file mode 100644 index 0000000..79db452 --- /dev/null +++ b/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/config/AbstractFlumeConfiguration.java @@ -0,0 +1,135 @@ +/* + * 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.flume.spring.boot.config; + +import org.apache.flume.Channel; +import org.apache.flume.ChannelSelector; +import org.apache.flume.Context; +import org.apache.flume.FlumeException; +import org.apache.flume.Sink; +import org.apache.flume.SinkProcessor; +import org.apache.flume.SinkRunner; +import org.apache.flume.Source; +import org.apache.flume.SourceRunner; +import org.apache.flume.channel.ChannelProcessor; +import org.apache.flume.conf.Configurables; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * + */ +public abstract class AbstractFlumeConfiguration { + + protected <T extends Channel> T configureChannel(final String name, final Class<T> clazz, + final Map<String, String> params) { + T channel; + try { + channel = clazz.newInstance(); + } catch (Exception ex) { + throw new FlumeException("Unable to create channel " + name, ex); + } + channel.setName(name); + Configurables.configure(channel, createContext(params)); + return channel; + } + + protected <T extends Source> SourceRunner configureSource(final String name, final Class<T> clazz, + final ChannelSelector selector, final Map<String, String> params) { + T source; + try { + source = clazz.newInstance(); + } catch (Exception ex) { + throw new FlumeException("Unable to create source " + name, ex); + } + source.setName(name); + Configurables.configure(source, createContext(params)); + source.setChannelProcessor(new ChannelProcessor(selector)); + return SourceRunner.forSource(source); + } + + protected <T extends Source> SourceRunner configureSource(final T source, + final ChannelSelector selector, final Map<String, String> params) { + source.setChannelProcessor(new ChannelProcessor(selector)); + return SourceRunner.forSource(source); + } + + protected <T extends SinkProcessor> T configureSinkProcessor(final Map<String, String> params, + final Class<T> clazz, final List<Sink> sinks) { + T processor; + try { + processor = clazz.newInstance(); + } catch (Exception ex) { + throw new FlumeException("Unable to create SinkProcessor of type: " + clazz.getName(), ex); + } + processor.setSinks(sinks); + Configurables.configure(processor, createContext(params)); + return processor; + } + + + protected SinkRunner createSinkRunner(SinkProcessor sinkProcessor) { + SinkRunner runner = new SinkRunner(sinkProcessor); + runner.setSink(sinkProcessor); + return runner; + } + + protected <T extends Sink> Sink configureSink(final String name, final Class<T> sinkClazz, + final Channel channel, + final Map<String, String> params) { + T sink; + try { + sink = sinkClazz.newInstance(); + } catch (Exception ex) { + throw new FlumeException("Unable to create sink " + name, ex); + } + sink.setName(name); + Configurables.configure(sink, createContext(params)); + sink.setChannel(channel); + return sink; + } + + protected ChannelSelector createChannelSelector(Class<? extends ChannelSelector> clazz, + Map<String, String> params) { + ChannelSelector selector; + try { + selector = clazz.newInstance(); + } catch (Exception ex) { + throw new FlumeException("Unable to create channel selector " + clazz.getName(), ex); + } + Configurables.configure(selector, createContext(params)); + return selector; + } + + /** + * Creates a List from a Varargs array. + * + * @param items The items to add to the list. + * @param <T> The type of objects in the List. + * @return a List containing the supplied items. + */ + @SafeVarargs + protected final <T> List<T> listOf(T... items) { + return Arrays.asList(items); + } + + private static Context createContext(Map<String, String> map) { + return map != null ? new Context(map) : new Context(); + } +} diff --git a/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/config/SpringConfiguration.java b/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/config/SpringConfiguration.java new file mode 100644 index 0000000..eac9a76 --- /dev/null +++ b/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/config/SpringConfiguration.java @@ -0,0 +1,59 @@ +/* + * 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.flume.spring.boot.config; + +import org.apache.flume.Channel; +import org.apache.flume.SinkRunner; +import org.apache.flume.SourceRunner; +import org.apache.flume.node.MaterializedConfiguration; +import org.apache.flume.node.SimpleMaterializedConfiguration; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.Map; + +/** + * + */ +@Configuration +public class SpringConfiguration { + + @Autowired + public Map<String, Channel> channels; + + @Autowired + public Map<String, SinkRunner> sinkRunners; + + @Autowired + public Map<String, SourceRunner> sourceRunners; + + @Bean + public MaterializedConfiguration configuration() { + MaterializedConfiguration config = new SimpleMaterializedConfiguration(); + for (Map.Entry<String, Channel> entry : channels.entrySet()) { + config.addChannel(entry.getKey(), entry.getValue()); + } + for (Map.Entry<String, SinkRunner> entry : sinkRunners.entrySet()) { + config.addSinkRunner(entry.getKey(), entry.getValue()); + } + for (Map.Entry<String, SourceRunner> entry : sourceRunners.entrySet()) { + config.addSourceRunner(entry.getKey(), entry.getValue()); + } + return config; + } +} diff --git a/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/controller/FlumeMetricsController.java b/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/controller/FlumeMetricsController.java new file mode 100644 index 0000000..3f4642c --- /dev/null +++ b/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/controller/FlumeMetricsController.java @@ -0,0 +1,48 @@ +/* + * 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.flume.spring.boot.controller; + +import java.lang.reflect.Type; +import java.util.Map; + +import org.apache.flume.instrumentation.util.JMXPollUtil; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; + +/** + * Retrieves Flume Metrics. + */ +@RestController +@ConditionalOnProperty(prefix = "flume", name = "metrics", havingValue = "http") +public class FlumeMetricsController { + + private final Type mapType = new MapTypeToken().getType(); + private final Gson gson = new Gson(); + + @GetMapping(value = "/metrics", produces = "application/json;charset=utf-8") + public String metrics() { + Map<String, Map<String, String>> metricsMap = JMXPollUtil.getAllMBeans(); + return gson.toJson(metricsMap, mapType); + } + + private static class MapTypeToken extends TypeToken<Map<String, Map<String, String>>> { + } +} diff --git a/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/runner/SpringFlume.java b/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/runner/SpringFlume.java new file mode 100644 index 0000000..2ddecad --- /dev/null +++ b/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/runner/SpringFlume.java @@ -0,0 +1,59 @@ +/* + * 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.flume.spring.boot.runner; + +import com.google.common.collect.Lists; +import org.apache.flume.lifecycle.LifecycleAware; +import org.apache.flume.node.Application; +import org.apache.flume.node.MaterializedConfiguration; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import java.util.List; + +/** + * + */ +@Component +public class SpringFlume { + private MaterializedConfiguration materializedConfiguration; + + private final Application application; + + @Autowired + public SpringFlume(MaterializedConfiguration configuration) { + this.materializedConfiguration = configuration; + List<LifecycleAware> components = Lists.newArrayList(); + application = new Application(components); + } + + @PostConstruct + public void startUp() { + application.start(); + application.handleConfigurationEvent(materializedConfiguration); + } + + @PreDestroy + public void shutdown() { + application.stop(); + } + + +} diff --git a/flume-spring-boot/src/test/java/org/apache/flume/spring/app/TestSpringFlume.java b/flume-spring-boot/src/test/java/org/apache/flume/spring/app/TestSpringFlume.java new file mode 100644 index 0000000..b30af88 --- /dev/null +++ b/flume-spring-boot/src/test/java/org/apache/flume/spring/app/TestSpringFlume.java @@ -0,0 +1,61 @@ +/* + * 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.flume.spring.app; + +import java.net.URI; + +import org.apache.flume.node.MaterializedConfiguration; +import org.apache.flume.spring.boot.FlumeApplication; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +/** + * + */ +@ExtendWith(SpringExtension.class) +@SpringBootTest(classes = {FlumeApplication.class}, + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class TestSpringFlume { + + @LocalServerPort + private int port; + + @Autowired + private TestRestTemplate restTemplate; + + @Autowired + MaterializedConfiguration configuration; + + @Test + public void contextLoads() { + Assertions.assertThat(configuration).isNotNull(); + Assertions.assertThat(configuration.getSinkRunners()).isNotNull(); + Assertions.assertThat(configuration.getSinkRunners().size()).isEqualTo(1); + String uri = "http://localhost:" + port + "/metrics"; + ResponseEntity<String> response = restTemplate.getForEntity(URI.create(uri), String.class); + Assertions.assertThat(response).isNotNull(); + Assertions.assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); + } +} diff --git a/flume-spring-boot/src/test/java/org/apache/flume/spring/app/config/AppConfig.java b/flume-spring-boot/src/test/java/org/apache/flume/spring/app/config/AppConfig.java new file mode 100644 index 0000000..0f1bc2b --- /dev/null +++ b/flume-spring-boot/src/test/java/org/apache/flume/spring/app/config/AppConfig.java @@ -0,0 +1,76 @@ +/* + * 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.flume.spring.app.config; + +import org.apache.flume.Channel; +import org.apache.flume.ChannelSelector; +import org.apache.flume.Sink; +import org.apache.flume.SinkRunner; +import org.apache.flume.SourceRunner; +import org.apache.flume.channel.MemoryChannel; +import org.apache.flume.channel.ReplicatingChannelSelector; +import org.apache.flume.sink.DefaultSinkProcessor; +import org.apache.flume.sink.NullSink; +import org.apache.flume.source.SequenceGeneratorSource; +import org.apache.flume.spring.boot.config.AbstractFlumeConfiguration; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +import java.util.HashMap; +import java.util.Map; + +/** + * + */ +@Configuration +@ComponentScan(basePackages="org.apache.flume.spring.app") +public class AppConfig extends AbstractFlumeConfiguration { + + @Bean + @ConfigurationProperties(prefix = "flume.sources.source1") + public Map<String, String> source1Properties() { + return new HashMap<>(); + } + + @Bean + @ConfigurationProperties(prefix = "flume.channels.channel1") + public Map<String, String> channel1Properties() { + return new HashMap<>(); + } + + @Bean + public Channel memoryChannel(Map<String, String> channel1Properties) { + return configureChannel("channel1", MemoryChannel.class, channel1Properties); + } + + @Bean + public SourceRunner seqSource(Channel memoryChannel, Map<String, String> source1Properties) { + ChannelSelector selector = new ReplicatingChannelSelector(); + selector.setChannels(listOf(memoryChannel)); + return configureSource("source1", SequenceGeneratorSource.class, selector, + source1Properties); + } + + @Bean + public SinkRunner nullSink(Channel memoryChannel) { + Sink sink = configureSink("null", NullSink.class, memoryChannel,null); + return createSinkRunner(configureSinkProcessor(null, DefaultSinkProcessor.class, + listOf(sink))); + } +} diff --git a/flume-spring-boot/src/test/resources/META-INF/spring.factories b/flume-spring-boot/src/test/resources/META-INF/spring.factories new file mode 100644 index 0000000..10241f5 --- /dev/null +++ b/flume-spring-boot/src/test/resources/META-INF/spring.factories @@ -0,0 +1,16 @@ +# 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.springframework.boot.autoconfigure.EnableAutoConfiguration=org.apache.flume.spring.app.config.AppConfig \ No newline at end of file diff --git a/flume-spring-boot/src/test/resources/application.yml b/flume-spring-boot/src/test/resources/application.yml new file mode 100644 index 0000000..7b52309 --- /dev/null +++ b/flume-spring-boot/src/test/resources/application.yml @@ -0,0 +1,15 @@ +spring: + application: + name: flume-test + +server: + port: 41414 + +flume: + metrics: http + sources: + source1: + totalEvents: 10000 + channels: + channel1: + capacity: 10000 diff --git a/flume-spring-boot/src/test/resources/bootstrap.yml b/flume-spring-boot/src/test/resources/bootstrap.yml new file mode 100644 index 0000000..e290590 --- /dev/null +++ b/flume-spring-boot/src/test/resources/bootstrap.yml @@ -0,0 +1,3 @@ +flume: + app: + packages: "org.apache.flume.spring.boot.app" \ No newline at end of file diff --git a/flume-spring-boot/src/test/resources/log4j2-test.xml b/flume-spring-boot/src/test/resources/log4j2-test.xml new file mode 100644 index 0000000..a98e448 --- /dev/null +++ b/flume-spring-boot/src/test/resources/log4j2-test.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. + +--> +<Configuration status="ERROR"> + <Appenders> + <Console name="Console" target="SYSTEM_OUT"> + <PatternLayout pattern="%d [%t] %-5level: %msg%n%throwable" /> + </Console> + </Appenders> + <Loggers> + <Logger name="org.apache.flume" level="INFO" /> + <Root level="INFO"> + <AppenderRef ref="Console" /> + </Root> + </Loggers> +</Configuration> \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..51bc85b --- /dev/null +++ b/pom.xml @@ -0,0 +1,195 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache</groupId> + <artifactId>apache</artifactId> + <version>29</version> + </parent> + + <groupId>org.apache.flume</groupId> + <artifactId>flume-spring-boot-parent</artifactId> + <name>Flume Spring Boot Parent</name> + <version>2.0.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <properties> + <ReleaseVersion>2.0.0</ReleaseVersion> + <ReleaseManager>Ralph Goers</ReleaseManager> + <ReleaseKey>B3D8E1BA</ReleaseKey> + <SigningUserName>[email protected]</SigningUserName> + <checksum-maven-plugin.version>1.11</checksum-maven-plugin.version> + <findsecbugs-plugin.version>1.12.0</findsecbugs-plugin.version> + <flume.version>1.11.0</flume.version> + <log4j.version>2.20.0</log4j.version> + <maven.compiler.source>11</maven.compiler.source> + <maven.compiler.target>11</maven.compiler.target> + <module.name>org.apache.flume.spring.boot</module.name> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <slf4j.version>1.7.32</slf4j.version> + <spotbugs-maven-plugin.version>4.7.2.1</spotbugs-maven-plugin.version> + <spotless-maven-plugin.version>2.27.2</spotless-maven-plugin.version> + <spring-boot.version>2.7.5</spring-boot.version> + </properties> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.flume</groupId> + <artifactId>flume-spring-boot</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-dependencies</artifactId> + <version>${spring-boot.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + <dependency> + <groupId>org.apache.flume</groupId> + <artifactId>flume-ng-configuration</artifactId> + <version>${flume.version}</version> + </dependency> + <dependency> + <groupId>org.apache.flume</groupId> + <artifactId>flume-ng-core</artifactId> + <version>${flume.version}</version> + </dependency> + <dependency> + <groupId>org.apache.flume</groupId> + <artifactId>flume-ng-node</artifactId> + <version>${flume.version}</version> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + <version>${log4j.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <version>${log4j.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j-impl</artifactId> + <version>${log4j.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-1.2-api</artifactId> + <version>${log4j.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-jcl</artifactId> + <version>${log4j.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-jul</artifactId> + <version>${log4j.version}</version> + </dependency> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>${slf4j.version}</version> + </dependency> + </dependencies> + </dependencyManagement> + + <inceptionYear>2022</inceptionYear> + + <issueManagement> + <system>JIRA</system> + <url>https://issues.apache.org/jira/browse/FLUME</url> + </issueManagement> + + <licenses> + <license> + <name>The Apache Software License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> + </license> + </licenses> + + <mailingLists> + <mailingList> + <archive>http://mail-archives.apache.org/mod_mbox/flume-user/</archive> + <name>Flume User List</name> + <post>[email protected]</post> + <subscribe>[email protected]</subscribe> + <unsubscribe>[email protected]</unsubscribe> + </mailingList> + <mailingList> + <archive>http://mail-archives.apache.org/mod_mbox/flume-dev/</archive> + <name>Flume Developer List</name> + <post>[email protected]</post> + <subscribe>[email protected]</subscribe> + <unsubscribe>[email protected]</unsubscribe> + </mailingList> + <mailingList> + <archive>http://mail-archives.apache.org/mod_mbox/flume-commits/</archive> + <name>Flume Commits</name> + <post>[email protected]</post> + <subscribe>[email protected]</subscribe> + <unsubscribe>[email protected]</unsubscribe> + </mailingList> + </mailingLists> + + <scm> + <url>https://gitbox.apache.org/repos/asf/flume-spring-boot.git</url> + <developerConnection>https://gitbox.apache.org/repos/asf/flume-spring-boot.git</developerConnection> + <connection>https://gitbox.apache.org/repos/asf/flume-spring-boot.git</connection> + </scm> + + <developers> + <developer> + <name>Ralph Goers</name> + <id>rgoers</id> + <email>[email protected]</email> + <organization>Intuit</organization> + </developer> + </developers> + + <organization> + <name>Apache Software Foundation</name> + <url>http://www.apache.org</url> + </organization> + <modules> + <module>flume-spring-boot</module> + </modules> + <profiles> + <profile> + <id>release</id> + <modules> + <module>flume-spring-boot-dist</module> + </modules> + </profile> + </profiles> + +</project>
