addProcessor -> registerProcessor
This commit is contained in:
parent
18aabd67c8
commit
2803ae09dc
|
@ -49,7 +49,7 @@ public class IngestModule extends AbstractModule {
|
||||||
/**
|
/**
|
||||||
* Adds a processor factory under a specific type name.
|
* Adds a processor factory under a specific type name.
|
||||||
*/
|
*/
|
||||||
public void addProcessor(String type, BiFunction<Environment, TemplateService, Processor.Factory<?>> processorFactoryProvider) {
|
public void registerProcessor(String type, BiFunction<Environment, TemplateService, Processor.Factory<?>> processorFactoryProvider) {
|
||||||
processorsRegistry.addProcessor(type, processorFactoryProvider);
|
processorsRegistry.registerProcessor(type, processorFactoryProvider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class ProcessorsRegistry {
|
||||||
/**
|
/**
|
||||||
* Adds a processor factory under a specific name.
|
* Adds a processor factory under a specific name.
|
||||||
*/
|
*/
|
||||||
public void addProcessor(String name, BiFunction<Environment, TemplateService, Processor.Factory<?>> processorFactoryProvider) {
|
public void registerProcessor(String name, BiFunction<Environment, TemplateService, Processor.Factory<?>> processorFactoryProvider) {
|
||||||
BiFunction<Environment, TemplateService, Processor.Factory<?>> provider = processorFactoryProviders.putIfAbsent(name, processorFactoryProvider);
|
BiFunction<Environment, TemplateService, Processor.Factory<?>> provider = processorFactoryProviders.putIfAbsent(name, processorFactoryProvider);
|
||||||
if (provider != null) {
|
if (provider != null) {
|
||||||
throw new IllegalArgumentException("Processor factory already registered for name [" + name + "]");
|
throw new IllegalArgumentException("Processor factory already registered for name [" + name + "]");
|
||||||
|
|
|
@ -240,7 +240,7 @@ public class IngestClientIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onModule(IngestModule ingestModule) {
|
public void onModule(IngestModule ingestModule) {
|
||||||
ingestModule.addProcessor("test", (environment, templateService) -> config ->
|
ingestModule.registerProcessor("test", (environment, templateService) -> config ->
|
||||||
new TestProcessor("test", ingestDocument -> {
|
new TestProcessor("test", ingestDocument -> {
|
||||||
ingestDocument.setFieldValue("processed", true);
|
ingestDocument.setFieldValue("processed", true);
|
||||||
if (ingestDocument.getFieldValue("fail", Boolean.class)) {
|
if (ingestDocument.getFieldValue("fail", Boolean.class)) {
|
||||||
|
|
|
@ -35,12 +35,12 @@ public class ProcessorsRegistryTests extends ESTestCase {
|
||||||
public void testAddProcessor() {
|
public void testAddProcessor() {
|
||||||
ProcessorsRegistry processorsRegistry = new ProcessorsRegistry();
|
ProcessorsRegistry processorsRegistry = new ProcessorsRegistry();
|
||||||
TestProcessor.Factory factory1 = new TestProcessor.Factory();
|
TestProcessor.Factory factory1 = new TestProcessor.Factory();
|
||||||
processorsRegistry.addProcessor("1", (environment, templateService) -> factory1);
|
processorsRegistry.registerProcessor("1", (environment, templateService) -> factory1);
|
||||||
TestProcessor.Factory factory2 = new TestProcessor.Factory();
|
TestProcessor.Factory factory2 = new TestProcessor.Factory();
|
||||||
processorsRegistry.addProcessor("2", (environment, templateService) -> factory2);
|
processorsRegistry.registerProcessor("2", (environment, templateService) -> factory2);
|
||||||
TestProcessor.Factory factory3 = new TestProcessor.Factory();
|
TestProcessor.Factory factory3 = new TestProcessor.Factory();
|
||||||
try {
|
try {
|
||||||
processorsRegistry.addProcessor("1", (environment, templateService) -> factory3);
|
processorsRegistry.registerProcessor("1", (environment, templateService) -> factory3);
|
||||||
fail("addProcessor should have failed");
|
fail("addProcessor should have failed");
|
||||||
} catch(IllegalArgumentException e) {
|
} catch(IllegalArgumentException e) {
|
||||||
assertThat(e.getMessage(), equalTo("Processor factory already registered for name [1]"));
|
assertThat(e.getMessage(), equalTo("Processor factory already registered for name [1]"));
|
||||||
|
|
|
@ -59,20 +59,20 @@ public class IngestPlugin extends Plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onModule(IngestModule ingestModule) {
|
public void onModule(IngestModule ingestModule) {
|
||||||
ingestModule.addProcessor(GeoIpProcessor.TYPE, (environment, templateService) -> new GeoIpProcessor.Factory(environment.configFile()));
|
ingestModule.registerProcessor(GeoIpProcessor.TYPE, (environment, templateService) -> new GeoIpProcessor.Factory(environment.configFile()));
|
||||||
ingestModule.addProcessor(GrokProcessor.TYPE, (environment, templateService) -> new GrokProcessor.Factory(environment.configFile()));
|
ingestModule.registerProcessor(GrokProcessor.TYPE, (environment, templateService) -> new GrokProcessor.Factory(environment.configFile()));
|
||||||
ingestModule.addProcessor(DateProcessor.TYPE, (environment, templateService) -> new DateProcessor.Factory());
|
ingestModule.registerProcessor(DateProcessor.TYPE, (environment, templateService) -> new DateProcessor.Factory());
|
||||||
ingestModule.addProcessor(SetProcessor.TYPE, (environment, templateService) -> new SetProcessor.Factory(templateService));
|
ingestModule.registerProcessor(SetProcessor.TYPE, (environment, templateService) -> new SetProcessor.Factory(templateService));
|
||||||
ingestModule.addProcessor(AppendProcessor.TYPE, (environment, templateService) -> new AppendProcessor.Factory(templateService));
|
ingestModule.registerProcessor(AppendProcessor.TYPE, (environment, templateService) -> new AppendProcessor.Factory(templateService));
|
||||||
ingestModule.addProcessor(RenameProcessor.TYPE, (environment, templateService) -> new RenameProcessor.Factory());
|
ingestModule.registerProcessor(RenameProcessor.TYPE, (environment, templateService) -> new RenameProcessor.Factory());
|
||||||
ingestModule.addProcessor(RemoveProcessor.TYPE, (environment, templateService) -> new RemoveProcessor.Factory(templateService));
|
ingestModule.registerProcessor(RemoveProcessor.TYPE, (environment, templateService) -> new RemoveProcessor.Factory(templateService));
|
||||||
ingestModule.addProcessor(SplitProcessor.TYPE, (environment, templateService) -> new SplitProcessor.Factory());
|
ingestModule.registerProcessor(SplitProcessor.TYPE, (environment, templateService) -> new SplitProcessor.Factory());
|
||||||
ingestModule.addProcessor(JoinProcessor.TYPE, (environment, templateService) -> new JoinProcessor.Factory());
|
ingestModule.registerProcessor(JoinProcessor.TYPE, (environment, templateService) -> new JoinProcessor.Factory());
|
||||||
ingestModule.addProcessor(UppercaseProcessor.TYPE, (environment, templateService) -> new UppercaseProcessor.Factory());
|
ingestModule.registerProcessor(UppercaseProcessor.TYPE, (environment, templateService) -> new UppercaseProcessor.Factory());
|
||||||
ingestModule.addProcessor(LowercaseProcessor.TYPE, (environment, templateService) -> new LowercaseProcessor.Factory());
|
ingestModule.registerProcessor(LowercaseProcessor.TYPE, (environment, templateService) -> new LowercaseProcessor.Factory());
|
||||||
ingestModule.addProcessor(TrimProcessor.TYPE, (environment, templateService) -> new TrimProcessor.Factory());
|
ingestModule.registerProcessor(TrimProcessor.TYPE, (environment, templateService) -> new TrimProcessor.Factory());
|
||||||
ingestModule.addProcessor(ConvertProcessor.TYPE, (environment, templateService) -> new ConvertProcessor.Factory());
|
ingestModule.registerProcessor(ConvertProcessor.TYPE, (environment, templateService) -> new ConvertProcessor.Factory());
|
||||||
ingestModule.addProcessor(GsubProcessor.TYPE, (environment, templateService) -> new GsubProcessor.Factory());
|
ingestModule.registerProcessor(GsubProcessor.TYPE, (environment, templateService) -> new GsubProcessor.Factory());
|
||||||
ingestModule.addProcessor(FailProcessor.TYPE, (environment, templateService) -> new FailProcessor.Factory(templateService));
|
ingestModule.registerProcessor(FailProcessor.TYPE, (environment, templateService) -> new FailProcessor.Factory(templateService));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue