Review Board 1.7.22


FLUME-1768. Multiplexing channel selector should allow optional-only channels

Review Request #8387 - Created Dec. 6, 2012 and submitted

Hari Shreedharan
FLUME-1768
Reviewers
Flume
flume-git
Added support for an optional channels only configuration.
Added 2 unit tests to test various sets of configs.
flume-ng-core/src/main/java/org/apache/flume/channel/MultiplexingChannelSelector.java
Revision 866d9dc New Change
[20] 91 lines
[+20] [+] public void configure(Context context) {
92
    }
92
    }
93

    
   
93

   
94
    defaultChannels = getChannelListFromNames(
94
    defaultChannels = getChannelListFromNames(
95
        context.getString(CONFIG_DEFAULT_CHANNEL), channelNameMap);
95
        context.getString(CONFIG_DEFAULT_CHANNEL), channelNameMap);
96

    
   
96

   
97
    if(defaultChannels.isEmpty()){

   
98
      throw new FlumeException("Default channel list empty");

   
99
    }

   
100

    
   

   
101
    Map<String, String> mapConfig =
97
    Map<String, String> mapConfig =
102
        context.getSubProperties(CONFIG_PREFIX_MAPPING);
98
        context.getSubProperties(CONFIG_PREFIX_MAPPING);
103

    
   
99

   
104
    channelMapping = new HashMap<String, List<Channel>>();
100
    channelMapping = new HashMap<String, List<Channel>>();
105

    
   
101

   
[+20] [20] 49 lines
[+20] public void configure(Context context) {
155
  //Given a list of channel names as space delimited string,
151
  //Given a list of channel names as space delimited string,
156
  //returns list of channels.
152
  //returns list of channels.
157
  private List<Channel> getChannelListFromNames(String channels,
153
  private List<Channel> getChannelListFromNames(String channels,
158
      Map<String, Channel> channelNameMap){
154
      Map<String, Channel> channelNameMap){
159
    List<Channel> configuredChannels = new ArrayList<Channel>();
155
    List<Channel> configuredChannels = new ArrayList<Channel>();

    
   
156
    if(channels == null || channels.isEmpty()) {

    
   
157
      return configuredChannels;

    
   
158
    }
160
    String[] chNames = channels.split(" ");
159
    String[] chNames = channels.split(" ");
161
    for (String name : chNames) {
160
    for (String name : chNames) {
162
      Channel ch = channelNameMap.get(name);
161
      Channel ch = channelNameMap.get(name);
163
      if (ch != null) {
162
      if (ch != null) {
164
        configuredChannels.add(ch);
163
        configuredChannels.add(ch);
[+20] [20] 9 lines
flume-ng-core/src/test/java/org/apache/flume/channel/TestMultiplexingChannelSelector.java
Revision 9dff5bb New Change
 
flume-ng-doc/sphinx/FlumeUserGuide.rst
Revision f8528bb New Change
 
  1. flume-ng-core/src/main/java/org/apache/flume/channel/MultiplexingChannelSelector.java: Loading...
  2. flume-ng-core/src/test/java/org/apache/flume/channel/TestMultiplexingChannelSelector.java: Loading...
  3. flume-ng-doc/sphinx/FlumeUserGuide.rst: Loading...