Review Board 1.7.22


FLUME-1769.Replicating channel selector should support optional channels

Review Request #8413 - Created Dec. 7, 2012 and submitted

Hari Shreedharan
FLUME-1769
Reviewers
Flume
flume-git
Replicating channel selector should support optional channels
Added unit tests to handle this case
flume-ng-core/src/main/java/org/apache/flume/channel/AbstractChannelSelector.java
Revision 939257d New Change
[20] 15 lines
[+20]
16
 * specific language governing permissions and limitations
16
 * specific language governing permissions and limitations
17
 * under the License.
17
 * under the License.
18
 */
18
 */
19
package org.apache.flume.channel;
19
package org.apache.flume.channel;
20

    
   
20

   

    
   
21
import java.util.ArrayList;

    
   
22
import java.util.HashMap;
21
import java.util.List;
23
import java.util.List;

    
   
24
import java.util.Map;
22

    
   
25

   
23
import org.apache.flume.Channel;
26
import org.apache.flume.Channel;
24
import org.apache.flume.ChannelSelector;
27
import org.apache.flume.ChannelSelector;

    
   
28
import org.apache.flume.FlumeException;
25

    
   
29

   
26
public abstract class AbstractChannelSelector implements ChannelSelector {
30
public abstract class AbstractChannelSelector implements ChannelSelector {
27

    
   
31

   
28
  private List<Channel> channels;
32
  private List<Channel> channels;
29
  private String name;
33
  private String name;
[+20] [20] 16 lines
[+20] [+] public synchronized void setName(String name) {
46
  @Override
50
  @Override
47
  public synchronized String getName() {
51
  public synchronized String getName() {
48
    return name;
52
    return name;
49
  }
53
  }
50

    
   
54

   

    
   
55
  /**

    
   
56
   *

    
   
57
   * @return A map of name to channel instance.

    
   
58
   */

    
   
59

   

    
   
60
  protected Map<String, Channel> getChannelNameMap() {

    
   
61
    Map<String, Channel> channelNameMap = new HashMap<String, Channel>();

    
   
62
    for (Channel ch : getAllChannels()) {

    
   
63
      channelNameMap.put(ch.getName(), ch);

    
   
64
    }

    
   
65
    return channelNameMap;

    
   
66
  }

    
   
67

   

    
   
68
  /**

    
   
69
   * Given a list of channel names as space delimited string,

    
   
70
   * returns list of channels.

    
   
71
   * @return List of {@linkplain Channel}s represented by the names.

    
   
72
   */

    
   
73
  protected List<Channel> getChannelListFromNames(String channels,

    
   
74
          Map<String, Channel> channelNameMap) {

    
   
75
    List<Channel> configuredChannels = new ArrayList<Channel>();

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

    
   
77
      return configuredChannels;

    
   
78
    }

    
   
79
    String[] chNames = channels.split(" ");

    
   
80
    for (String name : chNames) {

    
   
81
      Channel ch = channelNameMap.get(name);

    
   
82
      if (ch != null) {

    
   
83
        configuredChannels.add(ch);

    
   
84
      } else {

    
   
85
        throw new FlumeException("Selector channel not found: "

    
   
86
                + name);

    
   
87
      }

    
   
88
    }

    
   
89
    return configuredChannels;

    
   
90
  }

    
   
91

   
51
}
92
}
flume-ng-core/src/main/java/org/apache/flume/channel/MultiplexingChannelSelector.java
Revision 54e4b20 New Change
 
flume-ng-core/src/main/java/org/apache/flume/channel/ReplicatingChannelSelector.java
Revision 8f22746 New Change
 
flume-ng-core/src/test/java/org/apache/flume/channel/TestReplicatingChannelSelector.java
Revision e671364 New Change
 
flume-ng-doc/sphinx/FlumeUserGuide.rst
Revision 70cb285 New Change
 
  1. flume-ng-core/src/main/java/org/apache/flume/channel/AbstractChannelSelector.java: Loading...
  2. flume-ng-core/src/main/java/org/apache/flume/channel/MultiplexingChannelSelector.java: Loading...
  3. flume-ng-core/src/main/java/org/apache/flume/channel/ReplicatingChannelSelector.java: Loading...
  4. flume-ng-core/src/test/java/org/apache/flume/channel/TestReplicatingChannelSelector.java: Loading...
  5. flume-ng-doc/sphinx/FlumeUserGuide.rst: Loading...