diff --git a/PROCESSORS.md b/PROCESSORS.md
index 97ade1f37a..b1ea31cb31 100644
--- a/PROCESSORS.md
+++ b/PROCESSORS.md
@@ -22,7 +22,6 @@ limitations under the License.
- [BinFiles](#BinFiles)
- [CaptureRTSPFrame](#CaptureRTSPFrame)
- [CollectKubernetesPodMetrics](#CollectKubernetesPodMetrics)
-- [CollectorInitiatedSubscription](#CollectorInitiatedSubscription)
- [CompressContent](#CompressContent)
- [ConsumeJournald](#ConsumeJournald)
- [ConsumeKafka](#ConsumeKafka)
@@ -286,39 +285,6 @@ In the list below, the names of required properties appear in bold. Any other pr
| success | All flow files produced are routed to Success. |
-## CollectorInitiatedSubscription
-
-### Description
-
-Windows Event Log Subscribe Callback to receive FlowFiles from Events on Windows.
-
-### Properties
-
-In the list below, the names of required properties appear in bold. Any other properties (not in bold) are considered optional. The table also indicates any default values, and whether a property supports the NiFi Expression Language.
-
-| Name | Default Value | Allowable Values | Description |
-|------------------------------------|-----------------|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| **Subscription Name** | | | The name of the subscription. The value provided for this parameter should be unique within the computer's scope.
**Supports Expression Language: true** |
-| **Subscription Description** | | | A description of the subscription.
**Supports Expression Language: true** |
-| **Source Address** | | | The IP address or fully qualified domain name (FQDN) of the local or remote computer (event source) from which the events are collected.
**Supports Expression Language: true** |
-| **Source User Name** | | | The user name, which is used by the remote computer (event source) to authenticate the user.
**Supports Expression Language: true** |
-| **Source Password** | | | The password, which is used by the remote computer (event source) to authenticate the user.
**Sensitive Property: true**
**Supports Expression Language: true** |
-| **Source Channels** | | | The Windows Event Log Channels (on domain computer(s)) from which events are transferred.
**Supports Expression Language: true** |
-| **Max Delivery Items** | 1000 | | Determines the maximum number of items that will forwarded from an event source for each request. |
-| **Delivery MaxLatency Time** | 10 min | | How long, in milliseconds, the event source should wait before sending events. |
-| **Heartbeat Interval** | 10 min | | Time interval, in milliseconds, which is observed between the sent heartbeat messages. The event collector uses this property to determine the interval between queries to the event source. |
-| **Channel** | ForwardedEvents | | The Windows Event Log Channel (on local machine) to which events are transferred.
**Supports Expression Language: true** |
-| **Query** | * | | XPath Query to filter events. (See https://msdn.microsoft.com/en-us/library/windows/desktop/dd996910(v=vs.85).aspx for examples.)
**Supports Expression Language: true** |
-| **Max Buffer Size** | 1 MB | | The individual Event Log XMLs are rendered to a buffer. This specifies the maximum size in bytes that the buffer will be allowed to grow to. (Limiting the maximum size of an individual Event XML.) |
-| **Inactive Duration To Reconnect** | 10 min | | If no new event logs are processed for the specified time period, this processor will try reconnecting to recover from a state where any further messages cannot be consumed. Such situation can happen if Windows Event Log service is restarted, or ERROR_EVT_QUERY_RESULT_STALE (15011) is returned. Setting no duration, e.g. '0 ms' disables auto-reconnection. |
-
-### Relationships
-
-| Name | Description |
-|---------|------------------------------------------------|
-| success | Relationship for successfully consumed events. |
-
-
## CompressContent
### Description
diff --git a/README.md b/README.md
index 0fc786fe1a..f325315e09 100644
--- a/README.md
+++ b/README.md
@@ -94,7 +94,7 @@ The next table outlines CMAKE flags that correspond with MiNiFi extensions. Exte
| SQL | [ExecuteSQL](PROCESSORS.md#executesql)
[PutSQL](PROCESSORS.md#putsql)
[QueryDatabaseTable](PROCESSORS.md#querydatabasetable)
| -DENABLE_SQL=ON |
| Splunk | [PutSplunkHTTP](PROCESSORS.md#putsplunkhttp)
[QuerySplunkIndexingStatus](PROCESSORS.md#querysplunkindexingstatus) | -DENABLE_SPLUNK=ON |
| Systemd (Linux) | [ConsumeJournald](PROCESSORS.md#consumejournald) | -DENABLE_SYSTEMD=ON |
-| Windows Event Log (Windows) | [CollectorInitiatedSubscription](PROCESSORS.md#collectorinitiatedsubscription)
[ConsumeWindowsEventLog](PROCESSORS.md#consumewindowseventlog)
[TailEventLog](PROCESSORS.md#taileventlog) | -DENABLE_WEL=ON |
+| Windows Event Log (Windows) | [ConsumeWindowsEventLog](PROCESSORS.md#consumewindowseventlog)
[TailEventLog](PROCESSORS.md#taileventlog) | -DENABLE_WEL=ON |
Please see our [Python guide](extensions/python/PYTHON.md) on how to write Python processors and use them within MiNiFi C++.
diff --git a/extensions/lua/LuaProcessSession.cpp b/extensions/lua/LuaProcessSession.cpp
index daaa997314..3a7f3a48dd 100644
--- a/extensions/lua/LuaProcessSession.cpp
+++ b/extensions/lua/LuaProcessSession.cpp
@@ -22,16 +22,12 @@
namespace org::apache::nifi::minifi::extensions::lua {
-LuaProcessSession::LuaProcessSession(std::shared_ptr session)
- : session_(std::move(session)) {
+LuaProcessSession::LuaProcessSession(core::ProcessSession& session)
+ : session_(session) {
}
std::shared_ptr LuaProcessSession::get() {
- if (!session_) {
- throw std::runtime_error("Access of ProcessSession after it has been released");
- }
-
- auto flow_file = session_->get();
+ auto flow_file = session_.get();
if (flow_file == nullptr) {
return nullptr;
@@ -43,34 +39,26 @@ std::shared_ptr LuaProcessSession::get() {
return result;
}
-void LuaProcessSession::transfer(const std::shared_ptr &script_flow_file,
+void LuaProcessSession::transfer(const std::shared_ptr& script_flow_file,
const core::Relationship& relationship) {
- if (!session_) {
- throw std::runtime_error("Access of ProcessSession after it has been released");
- }
-
- auto flow_file = script_flow_file->getFlowFile();
+ const auto flow_file = script_flow_file->getFlowFile();
if (!flow_file) {
throw std::runtime_error("Access of FlowFile after it has been released");
}
- session_->transfer(flow_file, relationship);
+ session_.transfer(flow_file, relationship);
}
void LuaProcessSession::read(const std::shared_ptr &script_flow_file,
sol::table input_stream_callback) {
- if (!session_) {
- throw std::runtime_error("Access of ProcessSession after it has been released");
- }
-
- auto flow_file = script_flow_file->getFlowFile();
+ const auto flow_file = script_flow_file->getFlowFile();
if (!flow_file) {
throw std::runtime_error("Access of FlowFile after it has been released");
}
- session_->read(flow_file, [&input_stream_callback](const std::shared_ptr& input_stream) -> int64_t {
+ session_.read(flow_file, [&input_stream_callback](const std::shared_ptr& input_stream) -> int64_t {
sol::function callback = input_stream_callback["process"];
return callback(input_stream_callback, std::make_shared(input_stream));
});
@@ -78,43 +66,31 @@ void LuaProcessSession::read(const std::shared_ptr &script_fl
void LuaProcessSession::write(const std::shared_ptr &script_flow_file,
sol::table output_stream_callback) {
- if (!session_) {
- throw std::runtime_error("Access of ProcessSession after it has been released");
- }
-
auto flow_file = script_flow_file->getFlowFile();
if (!flow_file) {
throw std::runtime_error("Access of FlowFile after it has been released");
}
- session_->write(flow_file, [&output_stream_callback](const std::shared_ptr& output_stream) -> int64_t {
+ session_.write(flow_file, [&output_stream_callback](const std::shared_ptr& output_stream) -> int64_t {
sol::function callback = output_stream_callback["process"];
return callback(output_stream_callback, std::make_shared(output_stream));
});
}
std::shared_ptr LuaProcessSession::create() {
- if (!session_) {
- throw std::runtime_error("Access of ProcessSession after it has been released");
- }
-
- auto result = std::make_shared(session_->create());
+ auto result = std::make_shared(session_.create());
flow_files_.push_back(result);
return result;
}
std::shared_ptr LuaProcessSession::create(const std::shared_ptr &flow_file) {
- if (!session_) {
- throw std::runtime_error("Access of ProcessSession after it has been released");
- }
-
std::shared_ptr result;
if (flow_file == nullptr) {
- result = std::make_shared(session_->create());
+ result = std::make_shared(session_.create());
} else {
- result = std::make_shared(session_->create(flow_file->getFlowFile().get()));
+ result = std::make_shared(session_.create(flow_file->getFlowFile().get()));
}
flow_files_.push_back(result);
@@ -127,22 +103,16 @@ void LuaProcessSession::releaseCoreResources() {
flow_file->releaseFlowFile();
}
}
-
- session_.reset();
}
void LuaProcessSession::remove(const std::shared_ptr& script_flow_file) {
- if (!session_) {
- throw std::runtime_error("Access of ProcessSession after it has been released");
- }
-
auto flow_file = script_flow_file->getFlowFile();
if (!flow_file) {
throw std::runtime_error("Access of FlowFile after it has been released");
}
- session_->remove(flow_file);
+ session_.remove(flow_file);
}
} // namespace org::apache::nifi::minifi::extensions::lua
diff --git a/extensions/lua/LuaProcessSession.h b/extensions/lua/LuaProcessSession.h
index de5508890d..bebd13f68e 100644
--- a/extensions/lua/LuaProcessSession.h
+++ b/extensions/lua/LuaProcessSession.h
@@ -31,15 +31,15 @@ namespace org::apache::nifi::minifi::extensions::lua {
class LuaProcessSession {
public:
- explicit LuaProcessSession(std::shared_ptr session);
+ explicit LuaProcessSession(core::ProcessSession& session);
std::shared_ptr get();
std::shared_ptr create();
- std::shared_ptr create(const std::shared_ptr &flow_file);
- void transfer(const std::shared_ptr &flow_file, const core::Relationship& relationship);
- void read(const std::shared_ptr &script_flow_file, sol::table input_stream_callback);
- void write(const std::shared_ptr &flow_file, sol::table output_stream_callback);
- void remove(const std::shared_ptr& flow_file);
+ std::shared_ptr create(const std::shared_ptr& script_flow_file);
+ void transfer(const std::shared_ptr& script_flow_file, const core::Relationship& relationship);
+ void read(const std::shared_ptr& script_flow_file, sol::table input_stream_callback);
+ void write(const std::shared_ptr& script_flow_file, sol::table output_stream_callback);
+ void remove(const std::shared_ptr& script_flow_file);
/**
* Sometimes we want to release shared pointers to core resources when
@@ -53,7 +53,7 @@ class LuaProcessSession {
private:
std::vector> flow_files_;
- std::shared_ptr session_;
+ core::ProcessSession& session_;
};
} // namespace org::apache::nifi::minifi::extensions::lua
diff --git a/extensions/lua/LuaScriptEngine.cpp b/extensions/lua/LuaScriptEngine.cpp
index 0981a9edc4..0806b7f773 100644
--- a/extensions/lua/LuaScriptEngine.cpp
+++ b/extensions/lua/LuaScriptEngine.cpp
@@ -131,7 +131,6 @@ class TriggerSession {
TriggerSession& operator=(const TriggerSession&) = delete;
~TriggerSession() {
- script_context_->releaseProcessContext();
lua_session_->releaseCoreResources();
}
@@ -141,7 +140,7 @@ class TriggerSession {
};
} // namespace
-void LuaScriptEngine::onTrigger(const std::shared_ptr& context, const std::shared_ptr& session) {
+void LuaScriptEngine::onTrigger(core::ProcessContext& context, core::ProcessSession& session) {
auto script_context = std::make_shared(context, lua_);
auto lua_session = std::make_shared(session);
TriggerSession trigger_session(script_context, lua_session);
diff --git a/extensions/lua/LuaScriptEngine.h b/extensions/lua/LuaScriptEngine.h
index 4dcc6d2cde..f5ddf12ade 100644
--- a/extensions/lua/LuaScriptEngine.h
+++ b/extensions/lua/LuaScriptEngine.h
@@ -41,7 +41,7 @@ class LuaScriptEngine {
void eval(const std::string& script);
void evalFile(const std::filesystem::path& file_name);
- void onTrigger(const std::shared_ptr& context, const std::shared_ptr& session);
+ void onTrigger(core::ProcessContext& context, core::ProcessSession& session);
void initialize(const core::Relationship& success, const core::Relationship& failure, const std::shared_ptr& logger);
void setModulePaths(std::vector module_paths) {
diff --git a/extensions/lua/LuaScriptExecutor.cpp b/extensions/lua/LuaScriptExecutor.cpp
index 22a40e391a..665d98d988 100644
--- a/extensions/lua/LuaScriptExecutor.cpp
+++ b/extensions/lua/LuaScriptExecutor.cpp
@@ -26,8 +26,8 @@ namespace org::apache::nifi::minifi::extensions::lua {
LuaScriptExecutor::LuaScriptExecutor(std::string_view name, const utils::Identifier& uuid) : script::ScriptExecutor(name, uuid) {}
-void LuaScriptExecutor::onTrigger(const std::shared_ptr& context, const std::shared_ptr& session) {
- auto lua_script_engine = lua_script_engine_queue_->getResource();
+void LuaScriptExecutor::onTrigger(core::ProcessContext& context, core::ProcessSession& session) {
+ const auto lua_script_engine = lua_script_engine_queue_->getResource();
gsl_Expects(std::holds_alternative(script_to_run_) || std::holds_alternative(script_to_run_));
if (module_directory_) {
diff --git a/extensions/lua/LuaScriptExecutor.h b/extensions/lua/LuaScriptExecutor.h
index d001058c27..3137ed9123 100644
--- a/extensions/lua/LuaScriptExecutor.h
+++ b/extensions/lua/LuaScriptExecutor.h
@@ -21,7 +21,6 @@
#include
#include
#include
-#include
#include "../script/ScriptExecutor.h"
#include "LuaScriptEngine.h"
#include "utils/ResourceQueue.h"
@@ -32,7 +31,7 @@ class LuaScriptExecutor : public script::ScriptExecutor {
public:
explicit LuaScriptExecutor(std::string_view name, const utils::Identifier& uuid = {});
- void onTrigger(const std::shared_ptr& context, const std::shared_ptr& session) override;
+ void onTrigger(core::ProcessContext& context, core::ProcessSession& session) override;
void initialize(std::filesystem::path script_file,
std::string script_body,
std::optional module_directory,
diff --git a/extensions/lua/LuaScriptProcessContext.cpp b/extensions/lua/LuaScriptProcessContext.cpp
index 38a1775c3b..14c7a5ec8a 100644
--- a/extensions/lua/LuaScriptProcessContext.cpp
+++ b/extensions/lua/LuaScriptProcessContext.cpp
@@ -24,22 +24,19 @@
namespace org::apache::nifi::minifi::extensions::lua {
-LuaScriptProcessContext::LuaScriptProcessContext(std::shared_ptr context, sol::state& sol_state)
- : context_(std::move(context)), sol_state_(sol_state) {
+LuaScriptProcessContext::LuaScriptProcessContext(core::ProcessContext& context, sol::state& sol_state)
+ : context_(context), sol_state_(sol_state) {
}
std::string LuaScriptProcessContext::getProperty(const std::string &name) {
std::string value;
- context_->getProperty(name, value);
+ context_.getProperty(name, value);
return value;
}
-void LuaScriptProcessContext::releaseProcessContext() {
- context_.reset();
-}
LuaScriptStateManager LuaScriptProcessContext::getStateManager() {
- return LuaScriptStateManager(context_->getStateManager(), sol_state_);
+ return LuaScriptStateManager(context_.getStateManager(), sol_state_);
}
} // namespace org::apache::nifi::minifi::extensions::lua
diff --git a/extensions/lua/LuaScriptProcessContext.h b/extensions/lua/LuaScriptProcessContext.h
index c5eeb1974d..98fa3c9491 100644
--- a/extensions/lua/LuaScriptProcessContext.h
+++ b/extensions/lua/LuaScriptProcessContext.h
@@ -28,15 +28,14 @@ namespace org::apache::nifi::minifi::extensions::lua {
class LuaScriptProcessContext {
public:
- explicit LuaScriptProcessContext(std::shared_ptr context, sol::state& sol_state);
+ explicit LuaScriptProcessContext(core::ProcessContext& context, sol::state& sol_state);
std::string getProperty(const std::string &name);
- void releaseProcessContext();
LuaScriptStateManager getStateManager();
private:
- std::shared_ptr context_;
+ core::ProcessContext& context_;
sol::state& sol_state_;
};
diff --git a/extensions/python/ExecutePythonProcessor.cpp b/extensions/python/ExecutePythonProcessor.cpp
index e3b0a3a14e..115760e40b 100644
--- a/extensions/python/ExecutePythonProcessor.cpp
+++ b/extensions/python/ExecutePythonProcessor.cpp
@@ -75,7 +75,7 @@ void ExecutePythonProcessor::initalizeThroughScriptEngine() {
}
}
-void ExecutePythonProcessor::onScheduleSharedPtr(const std::shared_ptr &context, const std::shared_ptr& /*sessionFactory*/) {
+void ExecutePythonProcessor::onSchedule(core::ProcessContext& context, core::ProcessSessionFactory& /*sessionFactory*/) {
addAutoTerminatedRelationship(Original);
if (!processor_initialized_) {
loadScript();
@@ -95,7 +95,7 @@ void ExecutePythonProcessor::onScheduleSharedPtr(const std::shared_ptr &context, const std::shared_ptr &session) {
+void ExecutePythonProcessor::onTrigger(core::ProcessContext& context, core::ProcessSession& session) {
reloadScriptIfUsingScriptFileProperty();
if (script_to_exec_.empty()) {
throw std::runtime_error("Neither Script Body nor Script File is available to execute");
diff --git a/extensions/python/ExecutePythonProcessor.h b/extensions/python/ExecutePythonProcessor.h
index c13e85bcef..59b5613271 100644
--- a/extensions/python/ExecutePythonProcessor.h
+++ b/extensions/python/ExecutePythonProcessor.h
@@ -88,8 +88,8 @@ class ExecutePythonProcessor : public core::Processor {
ADD_COMMON_VIRTUAL_FUNCTIONS_FOR_PROCESSORS
void initialize() override;
- void onScheduleSharedPtr(const std::shared_ptr &context, const std::shared_ptr &sessionFactory) override;
- void onTriggerSharedPtr(const std::shared_ptr &context, const std::shared_ptr &session) override;
+ void onSchedule(core::ProcessContext& context, core::ProcessSessionFactory&) override;
+ void onTrigger(core::ProcessContext& context, core::ProcessSession& session) override;
void setSupportsDynamicProperties() {
python_dynamic_ = true;
diff --git a/extensions/python/PythonScriptEngine.cpp b/extensions/python/PythonScriptEngine.cpp
index ccf6156934..10893c195b 100644
--- a/extensions/python/PythonScriptEngine.cpp
+++ b/extensions/python/PythonScriptEngine.cpp
@@ -90,20 +90,20 @@ void PythonScriptEngine::describe(core::Processor* proc) {
}
}
-void PythonScriptEngine::onSchedule(const std::shared_ptr &context) {
+void PythonScriptEngine::onSchedule(core::ProcessContext& context) {
if (processor_instance_.get() != nullptr) {
- callProcessorObjectMethod("onSchedule", std::weak_ptr(context));
+ callProcessorObjectMethod("onSchedule", &context);
} else {
- call("onSchedule", std::weak_ptr(context));
+ call("onSchedule", &context);
}
}
-void PythonScriptEngine::onTrigger(const std::shared_ptr &context, const std::shared_ptr &session) {
+void PythonScriptEngine::onTrigger(core::ProcessContext& context, core::ProcessSession& session) {
auto py_session = std::make_shared(session);
if (processor_instance_.get() != nullptr) {
- callProcessorObjectMethod("onTrigger", std::weak_ptr(context), std::weak_ptr(py_session));
+ callProcessorObjectMethod("onTrigger", &context, std::weak_ptr(py_session));
} else {
- call("onTrigger", std::weak_ptr(context), std::weak_ptr(py_session));
+ call("onTrigger", &context, std::weak_ptr(py_session));
}
}
diff --git a/extensions/python/PythonScriptEngine.h b/extensions/python/PythonScriptEngine.h
index b11c7fa649..dd02485166 100644
--- a/extensions/python/PythonScriptEngine.h
+++ b/extensions/python/PythonScriptEngine.h
@@ -149,8 +149,8 @@ class PythonScriptEngine {
void onInitialize(core::Processor* proc);
void describe(core::Processor* proc);
- void onSchedule(const std::shared_ptr& context);
- void onTrigger(const std::shared_ptr& context, const std::shared_ptr& session);
+ void onSchedule(core::ProcessContext& context);
+ void onTrigger(core::ProcessContext& context, core::ProcessSession& session);
void initialize(const core::Relationship& success, const core::Relationship& failure, const core::Relationship& original, const std::shared_ptr& logger);
void initializeProcessorObject(const std::string& python_class_name);
std::vector getCustomPythonRelationships();
diff --git a/extensions/python/PythonScriptExecutor.cpp b/extensions/python/PythonScriptExecutor.cpp
index 7bf14bc5d4..1dbe57ecb6 100644
--- a/extensions/python/PythonScriptExecutor.cpp
+++ b/extensions/python/PythonScriptExecutor.cpp
@@ -27,10 +27,10 @@
namespace org::apache::nifi::minifi::extensions::python {
-PythonScriptExecutor::PythonScriptExecutor(std::string_view name, const utils::Identifier& uuid) : script::ScriptExecutor(name, uuid) {}
+PythonScriptExecutor::PythonScriptExecutor(const std::string_view name, const utils::Identifier& uuid) : script::ScriptExecutor(name, uuid) {}
-void PythonScriptExecutor::onTrigger(const std::shared_ptr& context, const std::shared_ptr& session) {
+void PythonScriptExecutor::onTrigger(core::ProcessContext& context, core::ProcessSession& session) {
gsl_Expects(python_script_engine_);
gsl_Expects(std::holds_alternative(script_to_run_) || std::holds_alternative(script_to_run_));
diff --git a/extensions/python/PythonScriptExecutor.h b/extensions/python/PythonScriptExecutor.h
index 69fc96d00b..80bf7096f1 100644
--- a/extensions/python/PythonScriptExecutor.h
+++ b/extensions/python/PythonScriptExecutor.h
@@ -29,7 +29,7 @@ class PythonScriptExecutor : public script::ScriptExecutor {
public:
explicit PythonScriptExecutor(std::string_view name, const utils::Identifier& uuid = {});
- void onTrigger(const std::shared_ptr &context, const std::shared_ptr &session) override;
+ void onTrigger(core::ProcessContext& context, core::ProcessSession& session) override;
void initialize(std::filesystem::path script_file,
std::string script_body,
std::optional module_directory,
diff --git a/extensions/python/types/PyProcessContext.cpp b/extensions/python/types/PyProcessContext.cpp
index 540a74c48e..5dd9628ff7 100644
--- a/extensions/python/types/PyProcessContext.cpp
+++ b/extensions/python/types/PyProcessContext.cpp
@@ -65,7 +65,7 @@ int PyProcessContext::init(PyProcessContext* self, PyObject* args, PyObject*) {
}
PyObject* PyProcessContext::getProperty(PyProcessContext* self, PyObject* args) {
- auto context = self->process_context_.lock();
+ auto context = self->process_context_;
if (!context) {
PyErr_SetString(PyExc_AttributeError, "tried reading process context outside 'on_trigger'");
return nullptr;
@@ -100,7 +100,7 @@ PyObject* PyProcessContext::getProperty(PyProcessContext* self, PyObject* args)
}
PyObject* PyProcessContext::getStateManager(PyProcessContext* self, PyObject*) {
- auto context = self->process_context_.lock();
+ auto context = self->process_context_;
if (!context) {
PyErr_SetString(PyExc_AttributeError, "tried reading process context outside 'on_trigger'");
return nullptr;
@@ -110,7 +110,7 @@ PyObject* PyProcessContext::getStateManager(PyProcessContext* self, PyObject*) {
}
PyObject* PyProcessContext::getControllerService(PyProcessContext* self, PyObject* args) {
- auto context = self->process_context_.lock();
+ auto context = self->process_context_;
if (!context) {
PyErr_SetString(PyExc_AttributeError, "tried reading process context outside 'on_trigger'");
return nullptr;
@@ -134,7 +134,7 @@ PyObject* PyProcessContext::getControllerService(PyProcessContext* self, PyObjec
}
PyObject* PyProcessContext::getName(PyProcessContext* self, PyObject*) {
- auto context = self->process_context_.lock();
+ auto context = self->process_context_;
if (!context) {
PyErr_SetString(PyExc_AttributeError, "tried reading process context outside 'on_trigger'");
return nullptr;
@@ -144,7 +144,7 @@ PyObject* PyProcessContext::getName(PyProcessContext* self, PyObject*) {
}
PyObject* PyProcessContext::getProperties(PyProcessContext* self, PyObject*) {
- auto context = self->process_context_.lock();
+ auto context = self->process_context_;
if (!context) {
PyErr_SetString(PyExc_AttributeError, "tried reading process context outside 'on_trigger'");
return nullptr;
diff --git a/extensions/python/types/PyProcessContext.h b/extensions/python/types/PyProcessContext.h
index 26aba677d0..00c6a04e69 100644
--- a/extensions/python/types/PyProcessContext.h
+++ b/extensions/python/types/PyProcessContext.h
@@ -26,7 +26,7 @@ namespace org::apache::nifi::minifi::extensions::python {
struct PyProcessContext {
PyProcessContext() {}
- using HeldType = std::weak_ptr;
+ using HeldType = core::ProcessContext*;
static constexpr const char* HeldTypeName = "PyProcessContext::HeldType";
PyObject_HEAD
diff --git a/extensions/python/types/PyProcessSession.cpp b/extensions/python/types/PyProcessSession.cpp
index 876c68bf75..00b9bf8a5b 100644
--- a/extensions/python/types/PyProcessSession.cpp
+++ b/extensions/python/types/PyProcessSession.cpp
@@ -29,15 +29,11 @@ namespace org::apache::nifi::minifi::extensions::python {
namespace core = org::apache::nifi::minifi::core;
-PyProcessSession::PyProcessSession(std::shared_ptr session)
- : session_(std::move(session)) {
+PyProcessSession::PyProcessSession(core::ProcessSession& session)
+ : session_(gsl::make_not_null(&session)) {
}
std::shared_ptr PyProcessSession::get() {
- if (!session_) {
- throw std::runtime_error("Access of ProcessSession after it has been released");
- }
-
auto flow_file = session_->get();
if (flow_file == nullptr) {
@@ -51,10 +47,6 @@ std::shared_ptr PyProcessSession::get() {
void PyProcessSession::transfer(const std::shared_ptr& flow_file,
const core::Relationship& relationship) {
- if (!session_) {
- throw std::runtime_error("Access of ProcessSession after it has been released");
- }
-
if (!flow_file) {
throw std::runtime_error("Access of FlowFile after it has been released");
}
@@ -63,10 +55,6 @@ void PyProcessSession::transfer(const std::shared_ptr& flow_file
}
void PyProcessSession::transferToCustomRelationship(const std::shared_ptr& flow_file, const std::string& relationship_name) {
- if (!session_) {
- throw std::runtime_error("Access of ProcessSession after it has been released");
- }
-
if (!flow_file) {
throw std::runtime_error("Access of FlowFile after it has been released");
}
@@ -75,10 +63,6 @@ void PyProcessSession::transferToCustomRelationship(const std::shared_ptr& flow_file, BorrowedObject input_stream_callback) {
- if (!session_) {
- throw std::runtime_error("Access of ProcessSession after it has been released");
- }
-
if (!flow_file) {
throw std::runtime_error("Access of FlowFile after it has been released");
}
@@ -89,10 +73,6 @@ void PyProcessSession::read(const std::shared_ptr& flow_file, Bo
}
void PyProcessSession::write(const std::shared_ptr& flow_file, BorrowedObject output_stream_callback) {
- if (!session_) {
- throw std::runtime_error("Access of ProcessSession after it has been released");
- }
-
if (!flow_file) {
throw std::runtime_error("Access of FlowFile after it has been released");
}
@@ -103,10 +83,6 @@ void PyProcessSession::write(const std::shared_ptr& flow_file, B
}
std::shared_ptr PyProcessSession::create(const std::shared_ptr& flow_file) {
- if (!session_) {
- throw std::runtime_error("Access of ProcessSession after it has been released");
- }
-
auto result = session_->create(flow_file.get());
flow_files_.push_back(result);
@@ -114,10 +90,6 @@ std::shared_ptr PyProcessSession::create(const std::shared_ptr PyProcessSession::clone(const std::shared_ptr& flow_file) {
- if (!session_) {
- throw std::runtime_error("Access of ProcessSession after it has been released");
- }
-
if (!flow_file) {
throw std::runtime_error("Flow file to clone is nullptr");
}
@@ -129,19 +101,11 @@ std::shared_ptr PyProcessSession::clone(const std::shared_ptr& flow_file) {
- if (!session_) {
- throw std::runtime_error("Access of ProcessSession after it has been released");
- }
-
session_->remove(flow_file);
flow_files_.erase(ranges::remove_if(flow_files_, [&flow_file](const auto& ff)-> bool { return ff == flow_file; }), flow_files_.end());
}
std::string PyProcessSession::getContentsAsString(const std::shared_ptr& flow_file) {
- if (!session_) {
- throw std::runtime_error("Access of ProcessSession after it has been released");
- }
-
if (!flow_file) {
throw std::runtime_error("Access of FlowFile after it has been released");
}
@@ -155,10 +119,6 @@ std::string PyProcessSession::getContentsAsString(const std::shared_ptr& flow_file, std::string_view key, const std::string& value) {
- if (!session_) {
- throw std::runtime_error("Access of ProcessSession after it has been released");
- }
-
session_->putAttribute(*flow_file, key, value);
}
diff --git a/extensions/python/types/PyProcessSession.h b/extensions/python/types/PyProcessSession.h
index a78bb91078..1a88966793 100644
--- a/extensions/python/types/PyProcessSession.h
+++ b/extensions/python/types/PyProcessSession.h
@@ -27,7 +27,7 @@ namespace org::apache::nifi::minifi::extensions::python {
class PyProcessSession {
public:
- explicit PyProcessSession(std::shared_ptr session);
+ explicit PyProcessSession(core::ProcessSession& session);
std::shared_ptr get();
std::shared_ptr create(const std::shared_ptr& flow_file = nullptr);
@@ -42,7 +42,7 @@ class PyProcessSession {
private:
std::vector> flow_files_;
- std::shared_ptr session_;
+ gsl::not_null session_;
};
struct PyProcessSessionObject {
diff --git a/extensions/script/ExecuteScript.cpp b/extensions/script/ExecuteScript.cpp
index 8e1080027f..7b9fd16588 100644
--- a/extensions/script/ExecuteScript.cpp
+++ b/extensions/script/ExecuteScript.cpp
@@ -74,7 +74,7 @@ void ExecuteScript::onSchedule(core::ProcessContext& context, core::ProcessSessi
script_executor_->initialize(std::move(script_file), std::move(script_body), std::move(module_directory), getMaxConcurrentTasks(), Success, Failure, Original, logger_);
}
-void ExecuteScript::onTriggerSharedPtr(const std::shared_ptr& context, const std::shared_ptr& session) {
+void ExecuteScript::onTrigger(core::ProcessContext& context, core::ProcessSession& session) {
gsl_Expects(script_executor_);
script_executor_->onTrigger(context, session);
}
diff --git a/extensions/script/ExecuteScript.h b/extensions/script/ExecuteScript.h
index e5ef777398..56378e280c 100644
--- a/extensions/script/ExecuteScript.h
+++ b/extensions/script/ExecuteScript.h
@@ -93,7 +93,7 @@ class ExecuteScript : public core::Processor {
void initialize() override;
void onSchedule(core::ProcessContext& context, core::ProcessSessionFactory& session_factory) override;
- void onTriggerSharedPtr(const std::shared_ptr &context, const std::shared_ptr &session) override;
+ void onTrigger(core::ProcessContext& context, core::ProcessSession& session) override;
private:
std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_);
diff --git a/extensions/script/ScriptExecutor.h b/extensions/script/ScriptExecutor.h
index 49f82b4bf0..b685993b70 100644
--- a/extensions/script/ScriptExecutor.h
+++ b/extensions/script/ScriptExecutor.h
@@ -17,8 +17,6 @@
#pragma once
-#include
-#include
#include
#include
@@ -30,9 +28,9 @@ namespace org::apache::nifi::minifi::extensions::script {
class ScriptExecutor : public minifi::core::CoreComponent {
public:
- ScriptExecutor(std::string_view name, const utils::Identifier& uuid) : core::CoreComponent(name, uuid) {}
+ ScriptExecutor(const std::string_view name, const utils::Identifier& uuid) : core::CoreComponent(name, uuid) {}
- virtual void onTrigger(const std::shared_ptr &context, const std::shared_ptr &session) = 0;
+ virtual void onTrigger(core::ProcessContext& context, core::ProcessSession& session) = 0;
virtual void initialize(std::filesystem::path script_file,
std::string script_body,
std::optional module_directory,
diff --git a/extensions/windows-event-log/CollectorInitiatedSubscription.cpp b/extensions/windows-event-log/CollectorInitiatedSubscription.cpp
deleted file mode 100644
index b699b0af5d..0000000000
--- a/extensions/windows-event-log/CollectorInitiatedSubscription.cpp
+++ /dev/null
@@ -1,572 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "CollectorInitiatedSubscription.h"
-
-#include
-#include
-#include