protected SinkProcessorConfiguration(String componentName) { super(componentName); setType("default"); }
private SinkProcessorType getKnownSinkProcessor(String type) { SinkProcessorType[] values = SinkProcessorType.values(); for (SinkProcessorType value : values) { if (value.toString().equalsIgnoreCase(type)) return value; String sinkProcessClassName = value.getClassName(); if (sinkProcessClassName != null && sinkProcessClassName.equalsIgnoreCase(type)) { return value; } } return null; } }
@Override public void configure(ComponentConfiguration conf) { this.conf = (SinkGroupConfiguration) conf; processor = SinkProcessorFactory.getProcessor(this.conf.getProcessorContext(), sinks); } }
@Override public void configure(Context context) throws ConfigurationException { super.configure(context); sinks = Arrays.asList(context.getString( BasicConfigurationConstants.CONFIG_SINKS).split("\\s+")); Map<String, String> params = context.getSubProperties( BasicConfigurationConstants.CONFIG_SINK_PROCESSOR_PREFIX); processorContext = new Context(); processorContext.putAll(params); SinkProcessorType spType = getKnownSinkProcessor(processorContext.getString( BasicConfigurationConstants.CONFIG_TYPE)); if (spType != null) { processorConf = (SinkProcessorConfiguration) ComponentConfigurationFactory.create( this.getComponentName() + "-processor", spType.toString(), ComponentType.SINK_PROCESSOR); if (processorConf != null) { processorConf.setSinks(new HashSet<String>(sinks)); processorConf.configure(processorContext); } } setConfigured(); }
.getConfiguration(name); case SINK: return SinkConfigurationType.valueOf(type.toUpperCase(Locale.ENGLISH)) .getConfiguration(name); case CHANNEL: return ChannelConfigurationType.valueOf(type.toUpperCase(Locale.ENGLISH)) .getConfiguration(name); case SINK_PROCESSOR: return SinkProcessorConfigurationType.valueOf(type.toUpperCase(Locale.ENGLISH)) .getConfiguration(name); case CHANNELSELECTOR: return ChannelSelectorConfigurationType.valueOf(type.toUpperCase(Locale.ENGLISH)) .getConfiguration(name); case SINKGROUP: return new SinkGroupConfiguration(name); default: throw new ConfigurationException(
config = sinkType.toString().toUpperCase(Locale.ENGLISH); configSpecified = true; sinkName, config, ComponentType.SINK); if (sinkConf != null) { sinkConf.configure(sinkContext); if (!channelSet.contains(sinkConf.getChannel())) { throw new ConfigurationException("Channel " + sinkConf.getChannel() + " not in active set."); if ((configSpecified && sinkConf.isNotFoundConfigClass()) || !configSpecified) { newContextMap.put(sinkName, sinkContext); sinkConfigMap.put(sinkName, sinkConf); if (sinkConf != null) errorList.addAll(sinkConf.getErrors()); } catch (ConfigurationException e) { iter.remove(); if (sinkConf != null) errorList.addAll(sinkConf.getErrors()); LOGGER.warn( "Could not configure sink {} due to: {}",
@Override public void configure(Context context) { conf = new SinkGroupConfiguration("sinkgrp"); try { conf.configure(context); } catch (ConfigurationException e) { throw new FlumeException("Invalid Configuration!", e); } configure(conf); }
sinkgroupName, "sinkgroup", ComponentType.SINKGROUP); conf.configure(context); Set<String> groupSinks = validGroupSinks(sinkSet, usedSinks, conf); if (conf != null) errorList.addAll(conf.getErrors()); if (groupSinks != null && !groupSinks.isEmpty()) { List<String> sinkArray = new ArrayList<String>(); sinkArray.addAll(groupSinks); conf.setSinks(sinkArray); sinkgroupConfigMap.put(sinkgroupName, conf); } else { addError(sinkgroupName, CONFIG_ERROR, ERROR); if (conf != null) errorList.addAll(conf.getErrors()); throw new ConfigurationException( "No available sinks for sinkgroup: " + sinkgroupName
@SuppressWarnings("unchecked") @Override public Class<? extends Sink> getClass(String type) throws FlumeException { String sinkClassName = type; SinkType sinkType = SinkType.OTHER; try { sinkType = SinkType.valueOf(type.toUpperCase(Locale.ENGLISH)); } catch (IllegalArgumentException ex) { logger.debug("Sink type {} is a custom type", type); } if (!sinkType.equals(SinkType.OTHER)) { sinkClassName = sinkType.getSinkClassName(); } try { return (Class<? extends Sink>) Class.forName(sinkClassName); } catch (Exception ex) { throw new FlumeException("Unable to load sink type: " + type + ", class: " + sinkClassName, ex); } } }
SinkGroupConfiguration groupConf) { Set<String> groupSinks = Collections.synchronizedSet(new HashSet<String>(groupConf.getSinks())); "Agent configuration for '{}' sinkgroup '{}' sink '{}' in use by another group: " + "'{}', sink not added", new Object[]{agentName, groupConf.getComponentName(), curSink, usedSinks.get(curSink)} ); addError(groupConf.getComponentName(), PROPERTY_PART_OF_ANOTHER_GROUP, ERROR); sinkIt.remove(); continue; LOGGER.warn("Agent configuration for '{}' sinkgroup '{}' sink not found: '{}', " + " sink not added", new Object[]{agentName, groupConf.getComponentName(), curSink} ); addError(curSink, INVALID_PROPERTY, ERROR); continue; } else { usedSinks.put(curSink, groupConf.getComponentName());
String processorClassName = typeStr; try { type = SinkProcessorType.valueOf(typeStr.toUpperCase(Locale.ENGLISH)); } catch (Exception ex) { logger.warn("Sink Processor type {} is a custom type", typeStr); if (!type.equals(SinkProcessorType.OTHER)) { processorClassName = type.getSinkProcessorClassName(); } catch (Exception ex) { throw new FlumeException("Unable to load sink processor type: " + typeStr + ", class: " + type.getSinkProcessorClassName(), ex);
@SuppressWarnings("unchecked") public SinkConfiguration getConfiguration(String name) throws ConfigurationException { if (this == OTHER) { return new SinkConfiguration(name); } Class<? extends SinkConfiguration> clazz; SinkConfiguration instance = null; try { if (sinkConfigurationName != null) { clazz = (Class<? extends SinkConfiguration>) Class .forName(sinkConfigurationName); instance = clazz.getConstructor(String.class).newInstance(name); } else { return new SinkConfiguration(name); } } catch (ClassNotFoundException e) { // Could not find the configuration stub, do basic validation instance = new SinkConfiguration(name); // Let the caller know that this was created because of this exception. instance.setNotFoundConfigClass(); } catch (Exception e) { throw new ConfigurationException("Couldn't create configuration", e); } return instance; }
@SuppressWarnings("unchecked") public SinkProcessorConfiguration getConfiguration(String name) throws ConfigurationException { Class<? extends SinkProcessorConfiguration> clazz; SinkProcessorConfiguration instance = null; try { if (processorClassName != null) { clazz = (Class<? extends SinkProcessorConfiguration>) Class .forName(processorClassName); instance = clazz.getConstructor(String.class).newInstance(name); } else { return new SinkProcessorConfiguration(name); } } catch (ClassNotFoundException e) { // Could not find the configuration stub, do basic validation instance = new SinkProcessorConfiguration(name); // Let the caller know that this was created because of this exception. instance.setNotFoundConfigClass(); } catch (Exception e) { throw new ConfigurationException( "Could not instantiate configuration!", e); } return instance; } }
@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; }
SinkGroupConfiguration groupConf = (SinkGroupConfiguration) comp; List<Sink> groupSinks = new ArrayList<Sink>(); for (String sink : groupConf.getSinks()) { Sink s = sinks.remove(sink); if (s == null) {
try { Configurables.configure(sink, config); ChannelComponent channelComponent = channelComponentMap.get(config.getChannel()); if (channelComponent == null) { String msg = String.format("Sink %s is not connected to a " +
public SinkGroupConfiguration(String name) { super(name); setType(ComponentType.SINKGROUP.getComponentType()); }
private SinkType getKnownSink(String type) { return getKnownComponent(type, SinkType.values()); }
public void configure(Context context) throws ConfigurationException { super.configure(context); this.channel = context.getString("channel"); if (this.channel == null || this.channel.isEmpty()) { errors .add(new FlumeConfigurationError(componentName, "channel", FlumeConfigurationErrorType.PROPERTY_VALUE_NULL, ErrorOrWarning.ERROR)); throw new ConfigurationException("No channel configured for sink: " + this.getComponentName()); } }
protected SinkProcessorConfiguration(String componentName) { super(componentName); setType("default"); }