Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.3.0
-
None
Description
Class org.apache.nifi.NiFi was not designed with extensibility or programmatic access in mind.
This class is the entry point of the engine, however, the current implementation does not allow
a potential caller (e.g. an integration test harness) to bootstrap the engine and then shut it down properly:
The main method org.apache.nifi.NiFi#main simply logs any exception, which is fine
when started from the command line, however prevents programmatic usage and
detecting error conditions (Exceptions) that would be essential to programatically access
it from an integration test.
The constructor org.apache.nifi.NiFi#NiFi registers an UncaughtExceptionHandler,
a JVM Shutdown Hook and changes logging framework settings.
Please change this behaviour:
Expose two methods, one of which accepts the command line argument one would pass
to the NiFi process and another one, which allows the NiFiProperties object to be passed.
This method should return the NiFi object instance for further programmatic access.
The logic used to register UncaughtExceptionHandler, a JVM Shutdown Hook and
changing logging framework settings should be extracted to a protected instance
method so that a client can override their behaviour with a NO-OP.
A second class called e.g. org.apache.nifi.EmbeddedNiFi could be introduced as
a base class for this use-case, where the engine is started through the Java API.
*Please note these changes are baby-steps towards the implementation of a
NiFi integration test harness.*