martinzink commented on a change in pull request #1188:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1188#discussion_r731091666
##########
File path: extensions/standard-processors/processors/DefragmentText.cpp
##########
@@ -26,38 +26,38 @@
namespace org::apache::nifi::minifi::processors {
-const core::Relationship DefragTextFlowFiles::Success("success", "Flowfiles
that have no fragmented messages in them");
-const core::Relationship DefragTextFlowFiles::Failure("failure", "Flowfiles
that failed the defragmentation process");
-const core::Relationship DefragTextFlowFiles::Self("__self__", "Marks the
FlowFile to be owned by this processor");
+const core::Relationship DefragmentText::Success("success", "Flowfiles that
have no fragmented messages in them");
+const core::Relationship DefragmentText::Failure("failure", "Flowfiles that
failed the defragmentation process");
+const core::Relationship DefragmentText::Self("__self__", "Marks the FlowFile
to be owned by this processor");
-const core::Property DefragTextFlowFiles::Pattern(
+const core::Property DefragmentText::Pattern(
core::PropertyBuilder::createProperty("Pattern")
->withDescription("A regular expression to match at the start or end
of messages.")
->withDefaultValue("")->isRequired(true)->build());
-const core::Property DefragTextFlowFiles::PatternLoc(
+const core::Property DefragmentText::PatternLoc(
core::PropertyBuilder::createProperty("Pattern
Location")->withDescription("Where to look for the pattern.")
->withAllowableValues(PatternLocation::values())
->withDefaultValue(toString(PatternLocation::START_OF_MESSAGE))->build());
-const core::Property DefragTextFlowFiles::MaxBufferSize(
+const core::Property DefragmentText::MaxBufferSize(
core::PropertyBuilder::createProperty("Max Buffer Size")
->withDescription("The maximum buffer size, if the buffer exceeds
this, it will be transferred to failure. Expected format is <size> <data unit>")
->withType(core::StandardValidators::get().DATA_SIZE_VALIDATOR)->build());
-const core::Property DefragTextFlowFiles::MaxBufferAge(
+const core::Property DefragmentText::MaxBufferAge(
core::PropertyBuilder::createProperty("Max Buffer Age")->
withDescription("The maximum age of a buffer after which the buffer
will be transferred to failure. Expected format is <duration> <time
unit>")->build());
-void DefragTextFlowFiles::initialize() {
+void DefragmentText::initialize() {
std::lock_guard<std::mutex> defrag_lock(defrag_mutex_);
setSupportedRelationships({Success, Failure});
setSupportedProperties({Pattern, PatternLoc, MaxBufferAge, MaxBufferSize});
}
-void DefragTextFlowFiles::onSchedule(core::ProcessContext* context,
core::ProcessSessionFactory*) {
+void DefragmentText::onSchedule(core::ProcessContext* context,
core::ProcessSessionFactory*) {
gsl_Expects(context);
std::lock_guard<std::mutex> defrag_lock(defrag_mutex_);
Review comment:
Since these functions are on the public interface, I felt that they
should be defended againts multithreaded usage (onSchedule especially since it
writes the class members, while onTrigger uses these)
But since it is not the case in other processors, I removed them to be more
readable.
https://github.com/apache/nifi-minifi-cpp/commit/ed5c9672a4d451cea91998ea9a72dda78121ef02
This was also discussed in a previous PR
https://github.com/apache/nifi-minifi-cpp/pull/1178#discussion_r719358796
##########
File path: PROCESSORS.md
##########
@@ -295,6 +296,30 @@ In the list below, the names of required properties appear
in bold. Any other pr
| - | - |
|success|FlowFiles that are sent successfully to the destination are
transferred to this relationship|
+## DefragmentText
+
+### Description
+
+DefragmentText splits and merges incoming flowfiles so cohesive messages are
not split between them
+### 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 |
+| - | - | - | - |
+|**Pattern**|||A regular expression to match at the start or end of messages.|
+|Pattern Location|||Where to look for the pattern.|
Review comment:
good catch changed it in
https://github.com/apache/nifi-minifi-cpp/commit/ed5c9672a4d451cea91998ea9a72dda78121ef02
##########
File path: extensions/standard-processors/processors/DefragmentText.cpp
##########
@@ -0,0 +1,347 @@
+/**
+ * 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 "DefragmentText.h"
+
+#include <vector>
+
+#include "core/Resource.h"
+#include "serialization/PayloadSerializer.h"
+#include "TextFragmentUtils.h"
+#include "utils/gsl.h"
+
+namespace org::apache::nifi::minifi::processors {
+
+const core::Relationship DefragmentText::Success("success", "Flowfiles that
have no fragmented messages in them");
+const core::Relationship DefragmentText::Failure("failure", "Flowfiles that
failed the defragmentation process");
+const core::Relationship DefragmentText::Self("__self__", "Marks the FlowFile
to be owned by this processor");
+
+const core::Property DefragmentText::Pattern(
+ core::PropertyBuilder::createProperty("Pattern")
+ ->withDescription("A regular expression to match at the start or end
of messages.")
+ ->withDefaultValue("")->isRequired(true)->build());
Review comment:
Agree, removed the default and now we throw in case it is not specified
or an empty string
https://github.com/apache/nifi-minifi-cpp/commit/ed5c9672a4d451cea91998ea9a72dda78121ef02
##########
File path: extensions/standard-processors/processors/DefragmentText.cpp
##########
@@ -0,0 +1,347 @@
+/**
+ * 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 "DefragmentText.h"
+
+#include <vector>
+
+#include "core/Resource.h"
+#include "serialization/PayloadSerializer.h"
+#include "TextFragmentUtils.h"
+#include "utils/gsl.h"
+
+namespace org::apache::nifi::minifi::processors {
+
+const core::Relationship DefragmentText::Success("success", "Flowfiles that
have no fragmented messages in them");
+const core::Relationship DefragmentText::Failure("failure", "Flowfiles that
failed the defragmentation process");
+const core::Relationship DefragmentText::Self("__self__", "Marks the FlowFile
to be owned by this processor");
+
+const core::Property DefragmentText::Pattern(
+ core::PropertyBuilder::createProperty("Pattern")
+ ->withDescription("A regular expression to match at the start or end
of messages.")
+ ->withDefaultValue("")->isRequired(true)->build());
+
+const core::Property DefragmentText::PatternLoc(
+ core::PropertyBuilder::createProperty("Pattern
Location")->withDescription("Where to look for the pattern.")
+ ->withAllowableValues(PatternLocation::values())
+
->withDefaultValue(toString(PatternLocation::START_OF_MESSAGE))->build());
+
+
+const core::Property DefragmentText::MaxBufferSize(
+ core::PropertyBuilder::createProperty("Max Buffer Size")
+ ->withDescription("The maximum buffer size, if the buffer exceeds
this, it will be transferred to failure. Expected format is <size> <data unit>")
+
->withType(core::StandardValidators::get().DATA_SIZE_VALIDATOR)->build());
+
+const core::Property DefragmentText::MaxBufferAge(
+ core::PropertyBuilder::createProperty("Max Buffer Age")->
+ withDescription("The maximum age of a buffer after which the buffer
will be transferred to failure. Expected format is <duration> <time
unit>")->build());
+
+void DefragmentText::initialize() {
+ std::lock_guard<std::mutex> defrag_lock(defrag_mutex_);
+
+ setSupportedRelationships({Success, Failure});
+ setSupportedProperties({Pattern, PatternLoc, MaxBufferAge, MaxBufferSize});
+}
+
+void DefragmentText::onSchedule(core::ProcessContext* context,
core::ProcessSessionFactory*) {
+ gsl_Expects(context);
+ std::lock_guard<std::mutex> defrag_lock(defrag_mutex_);
+
+ std::string max_buffer_age_str;
+ if (context->getProperty(MaxBufferAge.getName(), max_buffer_age_str)) {
+ core::TimeUnit unit;
+ uint64_t max_buffer_age;
+ if (core::Property::StringToTime(max_buffer_age_str, max_buffer_age, unit)
&& core::Property::ConvertTimeUnitToMS(max_buffer_age, unit, max_buffer_age)) {
+ buffer_.setMaxAge(max_buffer_age);
+ logger_->log_trace("The Buffer maximum age is configured to be %d ms",
max_buffer_age);
Review comment:
changed it in
https://github.com/apache/nifi-minifi-cpp/pull/1188/commits/ed5c9672a4d451cea91998ea9a72dda78121ef02
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]