MCPcopy Create free account
hub / github.com/apache/nifi-minifi-cpp / initialize

Method initialize

extensions/script/python/ExecutePythonProcessor.cpp:55–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53core::Relationship ExecutePythonProcessor::Failure("failure", "Script failures");
54
55void ExecutePythonProcessor::initialize() {
56 // initialization requires that we do a little leg work prior to onSchedule
57 // so that we can provide manifest our processor identity
58 if (getProperties().empty()) {
59 setSupportedProperties({
60 ScriptFile,
61 ScriptBody,
62 ModuleDirectory
63 });
64 setAcceptAllProperties();
65 setSupportedRelationships({
66 Success,
67 Failure
68 });
69 valid_init_ = false;
70 return;
71 }
72
73 python_logger_ = logging::LoggerFactory<ExecutePythonProcessor>::getAliasedLogger(getName());
74
75 getProperty(ModuleDirectory.getName(), module_directory_);
76
77 valid_init_ = false;
78 appendPathForImportModules();
79 loadScript();
80 try {
81 if (script_to_exec_.size()) {
82 std::shared_ptr<python::PythonScriptEngine> engine = getScriptEngine();
83 engine->eval(script_to_exec_);
84 auto shared_this = shared_from_this();
85 engine->describe(shared_this);
86 engine->onInitialize(shared_this);
87 handleEngineNoLongerInUse(std::move(engine));
88 valid_init_ = true;
89 }
90 }
91 catch (const std::exception& exception) {
92 logger_->log_error("Caught Exception: %s", exception.what());
93 std::rethrow_exception(std::current_exception());
94 }
95 catch (...) {
96 logger_->log_error("Caught Exception");
97 std::rethrow_exception(std::current_exception());
98 }
99}
100
101void ExecutePythonProcessor::onSchedule(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSessionFactory>& /*sessionFactory*/) {
102 if (!valid_init_) {

Callers

nothing calls this directly

Calls 8

describeMethod · 0.80
onInitializeMethod · 0.80
log_errorMethod · 0.80
emptyMethod · 0.45
getNameMethod · 0.45
sizeMethod · 0.45
evalMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected