com.netflix.suro.SuroPlugin Maven / Gradle / Ivy
The newest version!
package com.netflix.suro;
import com.google.inject.AbstractModule;
import com.google.inject.multibindings.Multibinder;
import com.netflix.suro.input.RecordParser;
import com.netflix.suro.input.SuroInput;
import com.netflix.suro.routing.Filter;
import com.netflix.suro.sink.Sink;
import com.netflix.suro.sink.notice.Notice;
import com.netflix.suro.sink.remotefile.RemotePrefixFormatter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Guice based suro plugin with convenience methods for adding pluggable components
* using Guice's MapBinder.
*
* @author elandau
*
*/
public abstract class SuroPlugin extends AbstractModule {
protected static final Logger LOG = LoggerFactory.getLogger(SuroPlugin.class);
/**
* Add a sink implementation to Suro. typeName is the expected value of the
* 'type' field of a JSON configuration.
*
* @param typeName
* @param sinkClass
*/
public void addSinkType(String typeName, Class sinkClass) {
LOG.info("Adding sinkType: " + typeName + " -> " + sinkClass.getCanonicalName());
Multibinder bindings
= Multibinder.newSetBinder(binder(), TypeHolder.class);
bindings.addBinding().toInstance(new TypeHolder(typeName, sinkClass));
}
public void addInputType(String typeName, Class inputClass) {
LOG.info("Adding inputType: " + typeName + " -> " + inputClass.getCanonicalName());
Multibinder bindings
= Multibinder.newSetBinder(binder(), TypeHolder.class);
bindings.addBinding().toInstance(new TypeHolder(typeName, inputClass));
}
public void addRecordParserType(String typeName, Class recordParserClass) {
LOG.info("Adding recordParser: " + typeName + " -> " + recordParserClass.getCanonicalName());
Multibinder bindings
= Multibinder.newSetBinder(binder(), TypeHolder.class);
bindings.addBinding().toInstance(new TypeHolder(typeName, recordParserClass));
}
public void addRemotePrefixFormatterType(String typeName, Class remotePrefixFormatterClass) {
LOG.info("Adding remotePrefixFormatterType: " + typeName + " -> " + remotePrefixFormatterClass.getCanonicalName());
Multibinder bindings
= Multibinder.newSetBinder(binder(), TypeHolder.class);
bindings.addBinding().toInstance(new TypeHolder(typeName, remotePrefixFormatterClass));
}
public void addNoticeType(String typeName, Class noticeClass) {
LOG.info("Adding notice: " + typeName + "->" + noticeClass.getCanonicalName());
Multibinder bindings
= Multibinder.newSetBinder(binder(), TypeHolder.class);
bindings.addBinding().toInstance(new TypeHolder(typeName, noticeClass));
}
public void addFilterType(String typeName, Class filterClass) {
LOG.info("Adding filterType: " + typeName + "->" + filterClass.getCanonicalName());
Multibinder bindings
= Multibinder.newSetBinder(binder(), TypeHolder.class);
bindings.addBinding().toInstance(new TypeHolder(typeName, filterClass));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy