private static ChannelSelector getSelectorForType(String type) { if (type == null || type.trim().length() == 0) { return new ReplicatingChannelSelector(); } String selectorClassName = type; ChannelSelectorType selectorType = ChannelSelectorType.OTHER; try { selectorType = ChannelSelectorType.valueOf(type.toUpperCase(Locale.ENGLISH)); } catch (IllegalArgumentException ex) { LOGGER.debug("Selector type {} is a custom type", type); } if (!selectorType.equals(ChannelSelectorType.OTHER)) { selectorClassName = selectorType.getChannelSelectorClassName(); } ChannelSelector selector = null; try { @SuppressWarnings("unchecked") Class<? extends ChannelSelector> selectorClass = (Class<? extends ChannelSelector>) Class.forName(selectorClassName); selector = selectorClass.newInstance(); } catch (Exception ex) { throw new FlumeException("Unable to load selector type: " + type + ", class: " + selectorClassName, ex); } return selector; }
@Override public void configure(Context context) { String optionalList = context.getString(CONFIG_OPTIONAL); requiredChannels = new ArrayList<Channel>(getAllChannels()); Map<String, Channel> channelNameMap = getChannelNameMap(); if (optionalList != null && !optionalList.isEmpty()) { for (String optional : optionalList.split("\\s+")) { Channel optionalChannel = channelNameMap.get(optional); requiredChannels.remove(optionalChannel); if (!optionalChannels.contains(optionalChannel)) { optionalChannels.add(optionalChannel); } } } } }
@Override public List<Channel> getRequiredChannels(Event event) { /* * Seems like there are lot of components within flume that do not call * configure method. It is conceiveable that custom component tests too * do that. So in that case, revert to old behavior. */ if (requiredChannels == null) { return getAllChannels(); } return requiredChannels; }
@Override public List<Channel> getRequiredChannels(Event event) { /* * Seems like there are lot of components within flume that do not call * configure method. It is conceiveable that custom component tests too * do that. So in that case, revert to old behavior. */ if (requiredChannels == null) { return getAllChannels(); } return requiredChannels; }
private static ChannelSelector getSelectorForType(String type) { if (type == null || type.trim().length() == 0) { return new ReplicatingChannelSelector(); } String selectorClassName = type; ChannelSelectorType selectorType = ChannelSelectorType.OTHER; try { selectorType = ChannelSelectorType.valueOf(type.toUpperCase(Locale.ENGLISH)); } catch (IllegalArgumentException ex) { LOGGER.debug("Selector type {} is a custom type", type); } if (!selectorType.equals(ChannelSelectorType.OTHER)) { selectorClassName = selectorType.getChannelSelectorClassName(); } ChannelSelector selector = null; try { @SuppressWarnings("unchecked") Class<? extends ChannelSelector> selectorClass = (Class<? extends ChannelSelector>) Class.forName(selectorClassName); selector = selectorClass.newInstance(); } catch (Exception ex) { throw new FlumeException("Unable to load selector type: " + type + ", class: " + selectorClassName, ex); } return selector; }
@Override public void configure(Context context) { String optionalList = context.getString(CONFIG_OPTIONAL); requiredChannels = new ArrayList<Channel>(getAllChannels()); Map<String, Channel> channelNameMap = getChannelNameMap(); if (optionalList != null && !optionalList.isEmpty()) { for (String optional : optionalList.split("\\s+")) { Channel optionalChannel = channelNameMap.get(optional); requiredChannels.remove(optionalChannel); if (!optionalChannels.contains(optionalChannel)) { optionalChannels.add(optionalChannel); } } } } }
@Before public void setUp() throws Exception { eventSource = new AvroSource(); channel = new MemoryChannel(); Configurables.configure(channel, new Context()); avroLogger = (Logger) LogManager.getLogger("avrologger"); /* * Clear out all other appenders associated with this logger to ensure * we're only hitting the Avro appender. */ removeAppenders(avroLogger); final Context context = new Context(); testPort = String.valueOf(AvailablePortFinder.getNextAvailable()); context.put("port", testPort); context.put("bind", "0.0.0.0"); Configurables.configure(eventSource, context); final List<Channel> channels = new ArrayList<>(); channels.add(channel); final ChannelSelector cs = new ReplicatingChannelSelector(); cs.setChannels(channels); eventSource.setChannelProcessor(new ChannelProcessor(cs)); eventSource.start(); Assert.assertTrue("Reached start or error", LifecycleController .waitForOneOf(eventSource, LifecycleState.START_OR_ERROR)); Assert.assertEquals("Server is started", LifecycleState.START, eventSource.getLifecycleState()); }