-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Spring boot4 #460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Spring boot4 #460
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fb9c350
Add RoutableProxyChannelSelector and allow Interceptors to be configu…
rgoers 5ca1c95
Enhancements for Spring Boot
rgoers d6de49d
Add relative path
rgoers 2c16a6c
Drop LGPL spotbugs-annotations in favor of internal annotation
ppkarwasz 8379469
Apply suggestions from code review
ppkarwasz 4c658dc
Fix formatting
rgoers bc1d393
Fix potential NPE
rgoers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
flume-ng-configuration/src/main/java/org/apache/flume/conf/internal/SuppressFBWarnings.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * 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.conf.internal; | ||
|
|
||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
|
|
||
| /** | ||
| * Used to suppress SpotBugs warnings in Flume artifacts. | ||
| * | ||
| * <p>SpotBugs recognizes any annotation whose simple name is {@code SuppressFBWarnings}, so this | ||
| * type lets us drop the dependency on the LGPL-licensed {@code spotbugs-annotations} artifact.</p> | ||
| * | ||
| * <p>This type is not exported via JPMS. Do <strong>not</strong> use in third-party modules.</p> | ||
| */ | ||
| @Retention(RetentionPolicy.CLASS) | ||
| @Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.PARAMETER}) | ||
| public @interface SuppressFBWarnings { | ||
|
|
||
| /** The set of SpotBugs warnings to suppress. */ | ||
| String[] value() default {}; | ||
| } |
22 changes: 22 additions & 0 deletions
22
flume-ng-configuration/src/main/java/org/apache/flume/conf/internal/package-info.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
| /** | ||
| * Contains types used only by Flume modules. | ||
| * | ||
| * <p>These types are not exported via JPMS and are not available to third-party modules.</p> | ||
| */ | ||
| package org.apache.flume.conf.internal; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
flume-ng-core/src/main/java/org/apache/flume/channel/RoutableProxyChannelSelector.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to you under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.flume.channel; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.HashMap; | ||
| import java.util.HashSet; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
| import org.apache.commons.lang3.StringUtils; | ||
| import org.apache.flume.Channel; | ||
| import org.apache.flume.ChannelSelector; | ||
| import org.apache.flume.Context; | ||
| import org.apache.flume.Event; | ||
| import org.apache.flume.conf.Configurables; | ||
| import org.apache.logging.log4j.LogManager; | ||
| import org.apache.logging.log4j.Logger; | ||
|
|
||
| public class RoutableProxyChannelSelector extends LoadBalancingChannelSelector { | ||
| private static final Logger LOGGER = LogManager.getLogger(RoutableProxyChannelSelector.class); | ||
| private static final String HEADER_NAME = "headerName"; | ||
| private static final String SELECTOR = ".selector."; | ||
| private static final String CHANNELS = "channels"; | ||
| private static final String DEFAULT = "default"; | ||
| private static final String TYPE = "type"; | ||
|
|
||
| private final Map<String, ChannelSelector> selectorMap = new HashMap<>(); | ||
| private ChannelSelector defaultSelector; | ||
| private String headerName; | ||
|
|
||
| public void addSelector(String headerName, ChannelSelector selector) { | ||
| selectorMap.put(headerName, selector); | ||
| } | ||
|
|
||
| public void setDefaultSelector(ChannelSelector defaultSelector) { | ||
| this.defaultSelector = defaultSelector; | ||
| } | ||
|
|
||
| public ChannelSelector getDefaultSelector() { | ||
| return defaultSelector; | ||
| } | ||
|
|
||
| @Override | ||
| public void configure(Context context) { | ||
| Configurables.ensureRequiredNonNull(context, HEADER_NAME); | ||
| List<Channel> allChannels = getAllChannels(); | ||
| for (Map.Entry<String, String> entry : context.getParameters().entrySet()) { | ||
| if (entry.getKey().equals(HEADER_NAME)) { | ||
| this.headerName = entry.getValue(); | ||
| } else if (!entry.getKey().equals(TYPE)) { | ||
| String key = StringUtils.substringBefore(entry.getKey(), "."); | ||
| Map<String, String> map = context.getSubProperties(key + SELECTOR); | ||
| if (map != null) { | ||
| String channelNames = getRequiredNonNull(map, CHANNELS, key); | ||
| Set<String> channelSet = new HashSet<>(Arrays.asList(channelNames.split("\\s+"))); | ||
| List<Channel> channels = new ArrayList<>(channelSet.size()); | ||
| for (String channelName : channelSet) { | ||
| for (Channel channel : allChannels) { | ||
| if (channelName.equals(channel.getName())) { | ||
| channels.add(channel); | ||
| } | ||
| } | ||
| } | ||
| ChannelSelector selector = ChannelSelectorFactory.create(channels, map); | ||
| if (DEFAULT.equals(key)) { | ||
| defaultSelector = selector; | ||
| } else { | ||
| selectorMap.put(key, selector); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| if (headerName == null) { | ||
| throw new IllegalArgumentException("No header name specified for RoutableProxy"); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public List<Channel> getRequiredChannels(Event event) { | ||
| ChannelSelector selector = getSelector(event); | ||
| if (selector != null) { | ||
| return selector.getRequiredChannels(event); | ||
| } | ||
| return new ArrayList<>(); | ||
| } | ||
|
|
||
| @Override | ||
| public List<Channel> getOptionalChannels(Event event) { | ||
| ChannelSelector selector = getSelector(event); | ||
| if (selector != null) { | ||
| return selector.getOptionalChannels(event); | ||
| } | ||
| return new ArrayList<>(); | ||
| } | ||
|
|
||
| private ChannelSelector getSelector(Event event) { | ||
| ChannelSelector channelSelector = selectorMap.get(event.getHeaders().get(headerName)); | ||
| if (channelSelector == null) { | ||
| channelSelector = defaultSelector; | ||
| } | ||
| return channelSelector; | ||
| } | ||
|
|
||
| private String getRequiredNonNull(Map<String, String> map, String keyName, String prefix) { | ||
| String value = map.get(keyName); | ||
| if (value == null) { | ||
| throw new IllegalArgumentException(String.format("Missing key %s in %s", keyName, prefix)); | ||
| } | ||
| return value; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.