public static ChannelSelector create(List<Channel> channels, Map<String, String> config) { ChannelSelector selector = getSelectorForType(config.get( BasicConfigurationConstants.CONFIG_TYPE)); selector.setChannels(channels); Context context = new Context(); context.putAll(config); Configurables.configure(selector, context); return selector; }
@Override public void configure(Context context) { Configurables.ensureRequiredNonNull( context, CONFIG_PORT); port = context.getInteger(CONFIG_PORT); host = context.getString(CONFIG_HOST); remoteHostHeader = context.getString(REMOTE_ADDRESS_HEADER); }
Configurables.configure(group, groupConf); sinkRunnerMap.put(comp.getComponentName(), new SinkRunner(group.getProcessor())); sinkMap.add(entry.getValue()); pr.setSinks(sinkMap); Configurables.configure(pr, new Context()); sinkRunnerMap.put(entry.getKey(), new SinkRunner(pr)); } catch (Exception e) {
@Override public void configure(Context context) { String hostKey = NetcatSourceConfigurationConstants.CONFIG_HOSTNAME; String portKey = NetcatSourceConfigurationConstants.CONFIG_PORT; String ackEventKey = NetcatSourceConfigurationConstants.CONFIG_ACKEVENT; Configurables.ensureRequiredNonNull(context, hostKey, portKey); hostName = context.getString(hostKey); port = context.getInteger(portKey); ackEveryEvent = context.getBoolean(ackEventKey, true); maxLineLength = context.getInteger( NetcatSourceConfigurationConstants.CONFIG_MAX_LINE_LENGTH, NetcatSourceConfigurationConstants.DEFAULT_MAX_LINE_LENGTH); sourceEncoding = context.getString( NetcatSourceConfigurationConstants.CONFIG_SOURCE_ENCODING, NetcatSourceConfigurationConstants.DEFAULT_ENCODING ); }
public static ChannelSelector create(List<Channel> channels, ChannelSelectorConfiguration conf) { String type = ChannelSelectorType.REPLICATING.toString(); if (conf != null) { type = conf.getType(); } ChannelSelector selector = getSelectorForType(type); selector.setChannels(channels); Configurables.configure(selector, conf); return selector; }
@Override public void configure(Context context) { configureSsl(context); Configurables.ensureRequiredNonNull(context, PORT_KEY, BIND_KEY);
comp.getComponentName(), comp.getType()); try { Configurables.configure(channel, comp); channelComponentMap.put(comp.getComponentName(), new ChannelComponent(channel)); context.getString(BasicConfigurationConstants.CONFIG_TYPE)); try { Configurables.configure(channel, context); channelComponentMap.put(chName, new ChannelComponent(channel)); LOGGER.info("Created channel " + chName);
@Override public void configure(Context context) { Configurables.ensureRequiredNonNull( context, SyslogSourceConfigurationConstants.CONFIG_PORT); port = context.getInteger(SyslogSourceConfigurationConstants.CONFIG_PORT); host = context.getString(SyslogSourceConfigurationConstants.CONFIG_HOST); formaterProp = context.getSubProperties( SyslogSourceConfigurationConstants.CONFIG_FORMAT_PREFIX); keepFields = SyslogUtils.chooseFieldsToKeep( context.getString( SyslogSourceConfigurationConstants.CONFIG_KEEP_FIELDS, SyslogSourceConfigurationConstants.DEFAULT_KEEP_FIELDS)); clientIPHeader = context.getString(SyslogSourceConfigurationConstants.CONFIG_CLIENT_IP_HEADER); clientHostnameHeader = context.getString(SyslogSourceConfigurationConstants.CONFIG_CLIENT_HOSTNAME_HEADER); if (sourceCounter == null) { sourceCounter = new SourceCounter(getName()); } }
Configurables.configure(processor, context); return processor;
@Override public void configure(Context context) { configureSsl(context); Configurables.ensureRequiredNonNull(context, SyslogSourceConfigurationConstants.CONFIG_PORT); port = context.getInteger(SyslogSourceConfigurationConstants.CONFIG_PORT); host = context.getString(SyslogSourceConfigurationConstants.CONFIG_HOST); eventSize = context.getInteger("eventSize", SyslogUtils.DEFAULT_SIZE); formaterProp = context.getSubProperties( SyslogSourceConfigurationConstants.CONFIG_FORMAT_PREFIX); keepFields = SyslogUtils.chooseFieldsToKeep( context.getString( SyslogSourceConfigurationConstants.CONFIG_KEEP_FIELDS, SyslogSourceConfigurationConstants.DEFAULT_KEEP_FIELDS)); clientIPHeader = context.getString(SyslogSourceConfigurationConstants.CONFIG_CLIENT_IP_HEADER); clientHostnameHeader = context.getString(SyslogSourceConfigurationConstants.CONFIG_CLIENT_HOSTNAME_HEADER); if (sourceCounter == null) { sourceCounter = new SourceCounter(getName()); } }
Sink sink = sinkFactory.create(comp.getComponentName(), comp.getType()); try { Configurables.configure(sink, config); ChannelComponent channelComponent = channelComponentMap.get(config.getChannel()); if (channelComponent == null) { BasicConfigurationConstants.CONFIG_TYPE)); try { Configurables.configure(sink, context); ChannelComponent channelComponent = channelComponentMap.get(
@Override public void configure(Context context) { Configurables.ensureRequiredNonNull( context, CONFIG_PORT); port = context.getInteger(CONFIG_PORT); host = context.getString(CONFIG_HOST); remoteHostHeader = context.getString(REMOTE_ADDRESS_HEADER); }
@SuppressWarnings("unchecked") public static SinkProcessor getProcessor(ComponentConfiguration conf, List<Sink> sinks) { String typeStr = conf.getType(); SinkProcessor processor; SinkProcessorType type = SinkProcessorType.DEFAULT; try { type = SinkProcessorType.valueOf(typeStr.toUpperCase(Locale.ENGLISH)); } catch (Exception ex) { logger.warn("Sink type {} does not exist, using default", typeStr); } Class<? extends SinkProcessor> processorClass = null; try { processorClass = (Class<? extends SinkProcessor>) Class.forName(type .getSinkProcessorClassName()); } catch (Exception ex) { throw new FlumeException("Unable to load sink processor type: " + typeStr + ", class: " + type.getSinkProcessorClassName(), ex); } try { processor = processorClass.newInstance(); } catch (Exception e) { throw new FlumeException("Unable to create processor, type: " + typeStr + ", class: " + type.getSinkProcessorClassName(), e); } processor.setSinks(sinks); Configurables.configure(processor, conf); return processor; }
comp.getType()); try { Configurables.configure(source, config); Set<String> channelNames = config.getChannels(); List<Channel> sourceChannels = Configurables.configure(channelProcessor, config); context.getString(BasicConfigurationConstants.CONFIG_TYPE)); try { Configurables.configure(source, context); String[] channelNames = context.getString( BasicConfigurationConstants.CONFIG_CHANNELS).split("\\s+"); Configurables.configure(channelProcessor, context); source.setChannelProcessor(channelProcessor); sourceRunnerMap.put(sourceName,
String.format("Class %s is not a subclass of JMSMessageConverter", clazz.getName())); converter = (JMSMessageConverter)clazz.newInstance(); boolean configured = Configurables.configure(converter, converterContext); if (logger.isDebugEnabled()) { logger.debug(String.format("Attempted configuration of %s, result = %s",
/** * Tests that sub-properties (kafka.producer.*) apply correctly across multiple invocations * of configure() (fix for FLUME-2857). */ @Test public void testDefaultSettingsOnReConfigure() { String sampleProducerProp = "compression.type"; String sampleProducerVal = "snappy"; Context context = prepareDefaultContext(); context.put(KafkaSinkConstants.KAFKA_PRODUCER_PREFIX + sampleProducerProp, sampleProducerVal); KafkaSink kafkaSink = new KafkaSink(); Configurables.configure(kafkaSink, context); Assert.assertEquals(sampleProducerVal, kafkaSink.getKafkaProps().getProperty(sampleProducerProp)); context = prepareDefaultContext(); Configurables.configure(kafkaSink, context); Assert.assertNull(kafkaSink.getKafkaProps().getProperty(sampleProducerProp)); }
private Sink.Status prepareAndSend(Context context, String msg) throws EventDeliveryException { Sink kafkaSink = new KafkaSink(); Configurables.configure(kafkaSink, context); Channel memoryChannel = new MemoryChannel(); Configurables.configure(memoryChannel, context); kafkaSink.setChannel(memoryChannel); kafkaSink.start(); Transaction tx = memoryChannel.getTransaction(); tx.begin(); Event event = EventBuilder.withBody(msg.getBytes()); memoryChannel.put(event); tx.commit(); tx.close(); return kafkaSink.process(); }
@Test public void testTopicAndKeyFromHeader() { Sink kafkaSink = new KafkaSink(); Context context = prepareDefaultContext(); Configurables.configure(kafkaSink, context); Channel memoryChannel = new MemoryChannel(); Configurables.configure(memoryChannel, context); kafkaSink.setChannel(memoryChannel); kafkaSink.start(); String msg = "test-topic-and-key-from-header"; Map<String, String> headers = new HashMap<String, String>(); headers.put("topic", TestConstants.CUSTOM_TOPIC); headers.put("key", TestConstants.CUSTOM_KEY); Transaction tx = memoryChannel.getTransaction(); tx.begin(); Event event = EventBuilder.withBody(msg.getBytes(), headers); memoryChannel.put(event); tx.commit(); tx.close(); try { Sink.Status status = kafkaSink.process(); if (status == Sink.Status.BACKOFF) { fail("Error Occurred"); } } catch (EventDeliveryException ex) { // ignore } checkMessageArrived(msg, TestConstants.CUSTOM_TOPIC); }