mirror of https://github.com/apache/nifi.git
Merge branch 'NIFI-735' into develop
This commit is contained in:
commit
9fa03b4324
|
@ -20,7 +20,7 @@ import org.apache.nifi.components.ConfigurableComponent;
|
||||||
import org.apache.nifi.reporting.InitializationException;
|
import org.apache.nifi.reporting.InitializationException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface for initializing a ConfigurableComponent. It is up to the
|
* An interface for initializing and tearing down a ConfigurableComponent. It is up to the
|
||||||
* implementer to call "init" so that you can call
|
* implementer to call "init" so that you can call
|
||||||
* ConfigurableComponent.getPropertyDescriptors()
|
* ConfigurableComponent.getPropertyDescriptors()
|
||||||
*
|
*
|
||||||
|
@ -35,4 +35,11 @@ public interface ConfigurableComponentInitializer {
|
||||||
* @throws InitializationException if the component could not be initialized
|
* @throws InitializationException if the component could not be initialized
|
||||||
*/
|
*/
|
||||||
void initialize(ConfigurableComponent component) throws InitializationException;
|
void initialize(ConfigurableComponent component) throws InitializationException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls the lifecycle methods that should be called when a flow is shutdown.
|
||||||
|
*
|
||||||
|
* @param component the component to initialize
|
||||||
|
*/
|
||||||
|
void teardown(ConfigurableComponent component);
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,6 +114,8 @@ public class DocGenerator {
|
||||||
try (final OutputStream output = new BufferedOutputStream(new FileOutputStream(baseDocumenationFile))) {
|
try (final OutputStream output = new BufferedOutputStream(new FileOutputStream(baseDocumenationFile))) {
|
||||||
writer.write(component, output, hasAdditionalInfo(directory));
|
writer.write(component, output, hasAdditionalInfo(directory));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initializer.teardown(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.documentation.init;
|
package org.apache.nifi.documentation.init;
|
||||||
|
|
||||||
import org.apache.nifi.annotation.lifecycle.OnRemoved;
|
|
||||||
import org.apache.nifi.annotation.lifecycle.OnShutdown;
|
import org.apache.nifi.annotation.lifecycle.OnShutdown;
|
||||||
import org.apache.nifi.components.ConfigurableComponent;
|
import org.apache.nifi.components.ConfigurableComponent;
|
||||||
import org.apache.nifi.controller.ControllerService;
|
import org.apache.nifi.controller.ControllerService;
|
||||||
|
@ -42,11 +41,17 @@ public class ControllerServiceInitializer implements ConfigurableComponentInitia
|
||||||
|
|
||||||
try (NarCloseable narCloseable = NarCloseable.withNarLoader()) {
|
try (NarCloseable narCloseable = NarCloseable.withNarLoader()) {
|
||||||
controllerService.initialize(new MockControllerServiceInitializationContext());
|
controllerService.initialize(new MockControllerServiceInitializationContext());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void teardown(ConfigurableComponent component) {
|
||||||
|
try (NarCloseable narCloseable = NarCloseable.withNarLoader()) {
|
||||||
|
ControllerService controllerService = (ControllerService) component;
|
||||||
|
|
||||||
final ProcessorLog logger = new MockProcessorLogger();
|
final ProcessorLog logger = new MockProcessorLogger();
|
||||||
final MockConfigurationContext context = new MockConfigurationContext();
|
final MockConfigurationContext context = new MockConfigurationContext();
|
||||||
ReflectionUtils.quietlyInvokeMethodsWithAnnotations(OnRemoved.class, null, controllerService, logger, context);
|
ReflectionUtils.quietlyInvokeMethodsWithAnnotations(OnShutdown.class, org.apache.nifi.processor.annotation.OnShutdown.class, controllerService, logger, context);
|
||||||
ReflectionUtils.quietlyInvokeMethodsWithAnnotations(OnShutdown.class, null, controllerService, logger, context);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.documentation.init;
|
package org.apache.nifi.documentation.init;
|
||||||
|
|
||||||
import org.apache.nifi.annotation.lifecycle.OnRemoved;
|
|
||||||
import org.apache.nifi.annotation.lifecycle.OnShutdown;
|
import org.apache.nifi.annotation.lifecycle.OnShutdown;
|
||||||
import org.apache.nifi.components.ConfigurableComponent;
|
import org.apache.nifi.components.ConfigurableComponent;
|
||||||
import org.apache.nifi.documentation.ConfigurableComponentInitializer;
|
import org.apache.nifi.documentation.ConfigurableComponentInitializer;
|
||||||
|
@ -40,11 +39,17 @@ public class ProcessorInitializer implements ConfigurableComponentInitializer {
|
||||||
Processor processor = (Processor) component;
|
Processor processor = (Processor) component;
|
||||||
try (NarCloseable narCloseable = NarCloseable.withNarLoader()) {
|
try (NarCloseable narCloseable = NarCloseable.withNarLoader()) {
|
||||||
processor.initialize(new MockProcessorInitializationContext());
|
processor.initialize(new MockProcessorInitializationContext());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void teardown(ConfigurableComponent component) {
|
||||||
|
Processor processor = (Processor) component;
|
||||||
|
try (NarCloseable narCloseable = NarCloseable.withNarLoader()) {
|
||||||
|
|
||||||
final ProcessorLog logger = new MockProcessorLogger();
|
final ProcessorLog logger = new MockProcessorLogger();
|
||||||
final MockProcessContext context = new MockProcessContext();
|
final MockProcessContext context = new MockProcessContext();
|
||||||
ReflectionUtils.quietlyInvokeMethodsWithAnnotations(OnRemoved.class, null, processor, logger, context);
|
ReflectionUtils.quietlyInvokeMethodsWithAnnotations(OnShutdown.class, org.apache.nifi.processor.annotation.OnShutdown.class, processor, logger, context);
|
||||||
ReflectionUtils.quietlyInvokeMethodsWithAnnotations(OnShutdown.class, null, processor, logger, context);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.documentation.init;
|
package org.apache.nifi.documentation.init;
|
||||||
|
|
||||||
import org.apache.nifi.annotation.lifecycle.OnRemoved;
|
|
||||||
import org.apache.nifi.annotation.lifecycle.OnShutdown;
|
import org.apache.nifi.annotation.lifecycle.OnShutdown;
|
||||||
import org.apache.nifi.components.ConfigurableComponent;
|
import org.apache.nifi.components.ConfigurableComponent;
|
||||||
import org.apache.nifi.documentation.ConfigurableComponentInitializer;
|
import org.apache.nifi.documentation.ConfigurableComponentInitializer;
|
||||||
|
@ -40,10 +39,16 @@ public class ReportingTaskingInitializer implements ConfigurableComponentInitial
|
||||||
ReportingTask reportingTask = (ReportingTask) component;
|
ReportingTask reportingTask = (ReportingTask) component;
|
||||||
try (NarCloseable narCloseable = NarCloseable.withNarLoader()) {
|
try (NarCloseable narCloseable = NarCloseable.withNarLoader()) {
|
||||||
reportingTask.initialize(new MockReportingInitializationContext());
|
reportingTask.initialize(new MockReportingInitializationContext());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void teardown(ConfigurableComponent component) {
|
||||||
|
ReportingTask reportingTask = (ReportingTask) component;
|
||||||
|
try (NarCloseable narCloseable = NarCloseable.withNarLoader()) {
|
||||||
|
|
||||||
final MockConfigurationContext context = new MockConfigurationContext();
|
final MockConfigurationContext context = new MockConfigurationContext();
|
||||||
ReflectionUtils.quietlyInvokeMethodsWithAnnotations(OnRemoved.class, null, reportingTask, new MockProcessorLogger(), context);
|
ReflectionUtils.quietlyInvokeMethodsWithAnnotations(OnShutdown.class, org.apache.nifi.processor.annotation.OnShutdown.class, reportingTask, new MockProcessorLogger(), context);
|
||||||
ReflectionUtils.quietlyInvokeMethodsWithAnnotations(OnShutdown.class, null, reportingTask, new MockProcessorLogger(), context);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ public class HtmlDocumentationWriterTest {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
|
||||||
writer.write(controllerService, baos, false);
|
writer.write(controllerService, baos, false);
|
||||||
|
initializer.teardown(controllerService);
|
||||||
|
|
||||||
String results = new String(baos.toByteArray());
|
String results = new String(baos.toByteArray());
|
||||||
XmlValidator.assertXmlValid(results);
|
XmlValidator.assertXmlValid(results);
|
||||||
|
@ -77,8 +78,8 @@ public class HtmlDocumentationWriterTest {
|
||||||
assertContains(results, "Sensitive Property: true");
|
assertContains(results, "Sensitive Property: true");
|
||||||
|
|
||||||
// verify the right OnRemoved and OnShutdown methods were called
|
// verify the right OnRemoved and OnShutdown methods were called
|
||||||
Assert.assertEquals(1, controllerService.getOnRemovedArgs());
|
Assert.assertEquals(0, controllerService.getOnRemovedArgs());
|
||||||
Assert.assertEquals(1, controllerService.getOnRemovedNoArgs());
|
Assert.assertEquals(0, controllerService.getOnRemovedNoArgs());
|
||||||
|
|
||||||
Assert.assertEquals(1, controllerService.getOnShutdownArgs());
|
Assert.assertEquals(1, controllerService.getOnShutdownArgs());
|
||||||
Assert.assertEquals(1, controllerService.getOnShutdownNoArgs());
|
Assert.assertEquals(1, controllerService.getOnShutdownNoArgs());
|
||||||
|
@ -96,6 +97,7 @@ public class HtmlDocumentationWriterTest {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
|
||||||
writer.write(reportingTask, baos, false);
|
writer.write(reportingTask, baos, false);
|
||||||
|
initializer.teardown(reportingTask);
|
||||||
|
|
||||||
String results = new String(baos.toByteArray());
|
String results = new String(baos.toByteArray());
|
||||||
XmlValidator.assertXmlValid(results);
|
XmlValidator.assertXmlValid(results);
|
||||||
|
@ -113,8 +115,8 @@ public class HtmlDocumentationWriterTest {
|
||||||
assertContains(results, "false");
|
assertContains(results, "false");
|
||||||
|
|
||||||
// verify the right OnRemoved and OnShutdown methods were called
|
// verify the right OnRemoved and OnShutdown methods were called
|
||||||
Assert.assertEquals(1, reportingTask.getOnRemovedArgs());
|
Assert.assertEquals(0, reportingTask.getOnRemovedArgs());
|
||||||
Assert.assertEquals(1, reportingTask.getOnRemovedNoArgs());
|
Assert.assertEquals(0, reportingTask.getOnRemovedNoArgs());
|
||||||
|
|
||||||
Assert.assertEquals(1, reportingTask.getOnShutdownArgs());
|
Assert.assertEquals(1, reportingTask.getOnShutdownArgs());
|
||||||
Assert.assertEquals(1, reportingTask.getOnShutdownNoArgs());
|
Assert.assertEquals(1, reportingTask.getOnShutdownNoArgs());
|
||||||
|
|
|
@ -44,6 +44,7 @@ public class ProcessorDocumentationWriterTest {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
|
||||||
writer.write(processor, baos, false);
|
writer.write(processor, baos, false);
|
||||||
|
initializer.teardown(processor);
|
||||||
|
|
||||||
String results = new String(baos.toByteArray());
|
String results = new String(baos.toByteArray());
|
||||||
XmlValidator.assertXmlValid(results);
|
XmlValidator.assertXmlValid(results);
|
||||||
|
@ -74,8 +75,8 @@ public class ProcessorDocumentationWriterTest {
|
||||||
assertNotContains(results, "Additional Details...");
|
assertNotContains(results, "Additional Details...");
|
||||||
|
|
||||||
// verify the right OnRemoved and OnShutdown methods were called
|
// verify the right OnRemoved and OnShutdown methods were called
|
||||||
Assert.assertEquals(1, processor.getOnRemovedArgs());
|
Assert.assertEquals(0, processor.getOnRemovedArgs());
|
||||||
Assert.assertEquals(1, processor.getOnRemovedNoArgs());
|
Assert.assertEquals(0, processor.getOnRemovedNoArgs());
|
||||||
|
|
||||||
Assert.assertEquals(1, processor.getOnShutdownArgs());
|
Assert.assertEquals(1, processor.getOnShutdownArgs());
|
||||||
Assert.assertEquals(1, processor.getOnShutdownNoArgs());
|
Assert.assertEquals(1, processor.getOnShutdownNoArgs());
|
||||||
|
@ -92,6 +93,7 @@ public class ProcessorDocumentationWriterTest {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
|
||||||
writer.write(processor, baos, false);
|
writer.write(processor, baos, false);
|
||||||
|
initializer.teardown(processor);
|
||||||
|
|
||||||
String results = new String(baos.toByteArray());
|
String results = new String(baos.toByteArray());
|
||||||
XmlValidator.assertXmlValid(results);
|
XmlValidator.assertXmlValid(results);
|
||||||
|
@ -121,6 +123,7 @@ public class ProcessorDocumentationWriterTest {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
|
||||||
writer.write(processor, baos, false);
|
writer.write(processor, baos, false);
|
||||||
|
initializer.teardown(processor);
|
||||||
|
|
||||||
String results = new String(baos.toByteArray());
|
String results = new String(baos.toByteArray());
|
||||||
XmlValidator.assertXmlValid(results);
|
XmlValidator.assertXmlValid(results);
|
||||||
|
|
Loading…
Reference in New Issue