This is an automated email from the ASF dual-hosted git repository. ppkarwasz pushed a commit to branch fix/spotless in repository https://gitbox.apache.org/repos/asf/logging-flume-spring-boot.git
commit 73411dbad29981983a1fd13c48eef789aa9c3b3e Author: Spotless <[email protected]> AuthorDate: Thu Jul 2 18:57:35 2026 +0200 Apply spotless formatting This applies Spotless formatting before reviewing #4. --- .asf.yaml | 4 +- flume-spring-boot/pom.xml | 44 +++--- .../apache/flume/spring/boot/FlumeApplication.java | 19 ++- .../boot/config/AbstractFlumeConfiguration.java | 165 ++++++++++---------- .../spring/boot/config/SpringConfiguration.java | 51 +++--- .../boot/controller/FlumeMetricsController.java | 33 ++-- .../flume/spring/boot/runner/SpringFlume.java | 62 ++++---- .../apache/flume/spring/app/TestSpringFlume.java | 50 +++--- .../apache/flume/spring/app/config/AppConfig.java | 76 +++++---- .../src/test/resources/application.yml | 16 ++ flume-spring-boot/src/test/resources/bootstrap.yml | 18 ++- .../src/test/resources/log4j2-test.xml | 33 ++-- pom.xml | 172 ++++++++++----------- 13 files changed, 378 insertions(+), 365 deletions(-) diff --git a/.asf.yaml b/.asf.yaml index 6f32cad..b937bd2 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -1,7 +1,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 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 # @@ -12,6 +13,7 @@ # 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 diff --git a/flume-spring-boot/pom.xml b/flume-spring-boot/pom.xml index 4601e12..b85e5e9 100644 --- a/flume-spring-boot/pom.xml +++ b/flume-spring-boot/pom.xml @@ -1,30 +1,28 @@ <?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"> + ~ 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> - <artifactId>flume-spring-boot-parent</artifactId> <groupId>org.apache.flume</groupId> + <artifactId>flume-spring-boot-parent</artifactId> <version>2.1.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> - <modelVersion>4.0.0</modelVersion> <artifactId>flume-spring-boot</artifactId> <name>Flume Spring Boot Support</name> @@ -129,8 +127,6 @@ limitations under the License. <scope>test</scope> </dependency> </dependencies> - <build> - - </build> + <build /> -</project> \ No newline at end of file +</project> 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 index d4a5146..c38c911 100644 --- 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 @@ -1,31 +1,30 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * 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 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 + * 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. + * 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. + * The application to run. */ @SpringBootApplication public class FlumeApplication { - public static void main(String[] args) { - SpringApplication.run(FlumeApplication.class, args); - } + 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 index 641aacc..57a567f 100644 --- 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 @@ -1,21 +1,24 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * 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 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 + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.flume.spring.boot.config; +import java.util.Arrays; +import java.util.List; +import java.util.Map; import org.apache.flume.Channel; import org.apache.flume.ChannelSelector; import org.apache.flume.Context; @@ -28,87 +31,81 @@ 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; - /** * The primarily provides helper methods to create and configure the various Flume components. * The do not have to be used. */ 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); + 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; } - 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); + 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)); + ChannelProcessor channelProcessor = new ChannelProcessor(selector); + source.setChannelProcessor(new ChannelProcessor(selector)); + return SourceRunner.forSource(source); } - source.setName(name); - Configurables.configure(source, createContext(params)); - ChannelProcessor channelProcessor = new ChannelProcessor(selector); - 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); + 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); } - processor.setSinks(sinks); - Configurables.configure(processor, createContext(params)); - return processor; - } + 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 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); + 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; } - sink.setName(name); - Configurables.configure(sink, createContext(params)); - sink.setChannel(channel); - return sink; - } - protected ChannelSelector createChannelSelector(Class<? extends ChannelSelector> clazz, - List<Channel> channels, Map<String, String> params) { + protected ChannelSelector createChannelSelector( + Class<? extends ChannelSelector> clazz, List<Channel> channels, Map<String, String> params) { ChannelSelector selector; try { selector = clazz.newInstance(); @@ -120,19 +117,19 @@ public abstract class AbstractFlumeConfiguration { 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); - } + /** + * 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(); - } + 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 index 6ceedfc..4c3991a 100644 --- 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 @@ -1,21 +1,22 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * 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 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 + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.flume.spring.boot.config; +import java.util.Map; import org.apache.flume.Channel; import org.apache.flume.SinkRunner; import org.apache.flume.SourceRunner; @@ -25,8 +26,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import java.util.Map; - /** * This is the heart of a Flume application. Use your custom Java configuration * file to define the Channels, SinkRunners, and SourceRunners as beans. @@ -38,27 +37,27 @@ import java.util.Map; @Configuration public class SpringConfiguration { - @Autowired - public Map<String, Channel> channels; + @Autowired + public Map<String, Channel> channels; - @Autowired - public Map<String, SinkRunner> sinkRunners; + @Autowired + public Map<String, SinkRunner> sinkRunners; - @Autowired - public Map<String, SourceRunner> sourceRunners; + @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()); + @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; } - 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 index 3f4642c..2391868 100644 --- 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 @@ -1,32 +1,30 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * 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 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 + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.flume.spring.boot.controller; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; 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. */ @@ -34,15 +32,14 @@ import com.google.gson.reflect.TypeToken; @ConditionalOnProperty(prefix = "flume", name = "metrics", havingValue = "http") public class FlumeMetricsController { - private final Type mapType = new MapTypeToken().getType(); - private final Gson gson = new Gson(); + 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); - } + @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>>> { - } + 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 index 2cc312c..3291f26 100644 --- 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 @@ -1,59 +1,55 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * 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 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 + * 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. + * 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 jakarta.annotation.PostConstruct; +import jakarta.annotation.PreDestroy; +import java.util.List; 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 jakarta.annotation.PostConstruct; -import jakarta.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(); - } - - + 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 index c2f1510..824e988 100644 --- 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 @@ -1,32 +1,31 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * 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 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 + * 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. + * 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.resttestclient.TestRestTemplate; import org.springframework.boot.resttestclient.autoconfigure.AutoConfigureTestRestTemplate; +import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -36,28 +35,29 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; * */ @ExtendWith(SpringExtension.class) -@SpringBootTest(classes = {FlumeApplication.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@SpringBootTest( + classes = {FlumeApplication.class}, + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @AutoConfigureTestRestTemplate public class TestSpringFlume { - @LocalServerPort - private int port; + @LocalServerPort + private int port; - @Autowired - private TestRestTemplate restTemplate; + @Autowired + private TestRestTemplate restTemplate; - @Autowired - MaterializedConfiguration configuration; + @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); - } + @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 index a80657d..70fafe7 100644 --- 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 @@ -1,21 +1,23 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * 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 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 + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.flume.spring.app.config; +import java.util.HashMap; +import java.util.Map; import org.apache.flume.Channel; import org.apache.flume.ChannelSelector; import org.apache.flume.Context; @@ -34,48 +36,44 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; -import java.util.HashMap; -import java.util.Map; - /** * */ @AutoConfiguration -@ComponentScan(basePackages="org.apache.flume.spring.app") +@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.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 + @ConfigurationProperties(prefix = "flume.channels.channel1") + public Map<String, String> channel1Properties() { + return new HashMap<>(); + } - @Bean - public Channel memoryChannel(@Qualifier("channel1Properties")Map<String, String> channel1Properties) { - return configureChannel("channel1", MemoryChannel.class, channel1Properties); - } + @Bean + public Channel memoryChannel(@Qualifier("channel1Properties") Map<String, String> channel1Properties) { + return configureChannel("channel1", MemoryChannel.class, channel1Properties); + } - @Bean - public SourceRunner seqSource(Channel memoryChannel, @Qualifier("source1Properties")Map<String, String> source1Properties) { - ChannelSelector selector = new ReplicatingChannelSelector(); - selector.setChannels(listOf(memoryChannel)); - SourceRunner runner = configureSource("source1", SequenceGeneratorSource.class, selector, - source1Properties); - Context context = source1Properties != null ? new Context(source1Properties) : new Context(); - runner.getSource().getChannelProcessor().configure(context); - return runner; - } + @Bean + public SourceRunner seqSource( + Channel memoryChannel, @Qualifier("source1Properties") Map<String, String> source1Properties) { + ChannelSelector selector = new ReplicatingChannelSelector(); + selector.setChannels(listOf(memoryChannel)); + SourceRunner runner = configureSource("source1", SequenceGeneratorSource.class, selector, source1Properties); + Context context = source1Properties != null ? new Context(source1Properties) : new Context(); + runner.getSource().getChannelProcessor().configure(context); + return runner; + } - @Bean - public SinkRunner nullSink(Channel memoryChannel) { - Sink sink = configureSink("null", NullSink.class, memoryChannel,null); - return createSinkRunner(configureSinkProcessor(null, DefaultSinkProcessor.class, - listOf(sink))); - } + @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/application.yml b/flume-spring-boot/src/test/resources/application.yml index 7b52309..b8baaa6 100644 --- a/flume-spring-boot/src/test/resources/application.yml +++ b/flume-spring-boot/src/test/resources/application.yml @@ -1,3 +1,19 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to you under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# spring: application: name: flume-test diff --git a/flume-spring-boot/src/test/resources/bootstrap.yml b/flume-spring-boot/src/test/resources/bootstrap.yml index e290590..d6d8441 100644 --- a/flume-spring-boot/src/test/resources/bootstrap.yml +++ b/flume-spring-boot/src/test/resources/bootstrap.yml @@ -1,3 +1,19 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to you under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# flume: app: - packages: "org.apache.flume.spring.boot.app" \ No newline at end of file + packages: "org.apache.flume.spring.boot.app" diff --git a/flume-spring-boot/src/test/resources/log4j2-test.xml b/flume-spring-boot/src/test/resources/log4j2-test.xml index 5baa09d..eb4c2eb 100644 --- a/flume-spring-boot/src/test/resources/log4j2-test.xml +++ b/flume-spring-boot/src/test/resources/log4j2-test.xml @@ -1,21 +1,20 @@ <?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. - ---> + ~ 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"> @@ -28,4 +27,4 @@ <AppenderRef ref="Console" /> </Root> </Loggers> -</Configuration> \ No newline at end of file +</Configuration> diff --git a/pom.xml b/pom.xml index 68947de..f57611e 100644 --- a/pom.xml +++ b/pom.xml @@ -1,23 +1,21 @@ <?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"> + ~ 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> @@ -29,9 +27,70 @@ limitations under the License. <groupId>org.apache.flume</groupId> <artifactId>flume-spring-boot-parent</artifactId> - <name>Flume Spring Boot Parent</name> <version>2.1.0-SNAPSHOT</version> <packaging>pom</packaging> + <name>Flume Spring Boot Parent</name> + + <inceptionYear>2022</inceptionYear> + + <organization> + <name>Apache Software Foundation</name> + <url>http://www.apache.org</url> + </organization> + + <licenses> + <license> + <name>The Apache Software License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> + </license> + </licenses> + + <developers> + <developer> + <id>rgoers</id> + <name>Ralph Goers</name> + <email>[email protected]</email> + <organization>Nextiva</organization> + </developer> + </developers> + + <mailingLists> + <mailingList> + <name>Flume User List</name> + <subscribe>[email protected]</subscribe> + <unsubscribe>[email protected]</unsubscribe> + <post>[email protected]</post> + <archive>http://mail-archives.apache.org/mod_mbox/flume-user/</archive> + </mailingList> + <mailingList> + <name>Flume Developer List</name> + <subscribe>[email protected]</subscribe> + <unsubscribe>[email protected]</unsubscribe> + <post>[email protected]</post> + <archive>http://mail-archives.apache.org/mod_mbox/flume-dev/</archive> + </mailingList> + <mailingList> + <name>Flume Commits</name> + <subscribe>[email protected]</subscribe> + <unsubscribe>[email protected]</unsubscribe> + <post>[email protected]</post> + <archive>http://mail-archives.apache.org/mod_mbox/flume-commits/</archive> + </mailingList> + </mailingLists> + <modules> + <module>flume-spring-boot</module> + </modules> + + <scm> + <connection>https://gitbox.apache.org/repos/asf/flume-spring-boot.git</connection> + <developerConnection>https://gitbox.apache.org/repos/asf/flume-spring-boot.git</developerConnection> + <url>https://gitbox.apache.org/repos/asf/flume-spring-boot.git</url> + </scm> + + <issueManagement> + <system>JIRA</system> + <url>https://issues.apache.org/jira/browse/FLUME</url> + </issueManagement> <properties> <ReleaseVersion>2.1.0</ReleaseVersion> @@ -54,8 +113,8 @@ limitations under the License. <groupId>org.apache.flume</groupId> <artifactId>flume-dependencies</artifactId> <version>${flume.version}</version> - <scope>import</scope> <type>pom</type> + <scope>import</scope> </dependency> <!-- Override the versions in this repo --> <dependency> @@ -72,67 +131,6 @@ limitations under the License. </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>Nextiva</organization> - </developer> - </developers> - - <organization> - <name>Apache Software Foundation</name> - <url>http://www.apache.org</url> - </organization> - <modules> - <module>flume-spring-boot</module> - </modules> <build> <plugins> <plugin> @@ -173,10 +171,10 @@ limitations under the License. <executions> <execution> <id>verify.rat</id> - <phase>verify</phase> <goals> <goal>check</goal> </goals> + <phase>verify</phase> </execution> </executions> </plugin> @@ -197,10 +195,10 @@ limitations under the License. <version>${mvn-gpg-plugin.version}</version> <executions> <execution> - <phase>verify</phase> <goals> <goal>sign</goal> </goals> + <phase>verify</phase> <configuration> <keyname>${SigningUserName}</keyname> </configuration> @@ -211,18 +209,18 @@ limitations under the License. <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>${mvn-javadoc-plugin.version}</version> + <configuration> + <additionalparam>-Xdoclint:none</additionalparam> + </configuration> <executions> <execution> <id>javadoc-jar</id> - <phase>package</phase> <goals> <goal>aggregate-jar</goal> </goals> + <phase>package</phase> </execution> </executions> - <configuration> - <additionalparam>-Xdoclint:none</additionalparam> - </configuration> </plugin> </plugins> </build>
