arpadboda commented on a change in pull request #613: Minificpp 927 Nanofi 
tailfile delimited processor
URL: https://github.com/apache/nifi-minifi-cpp/pull/613#discussion_r325134041
 
 

 ##########
 File path: nanofi/ecu/tailfile_delimited.c
 ##########
 @@ -0,0 +1,76 @@
+/*
+ * 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 "api/ecu.h"
+#include "core/flowfiles.h"
+#include <unistd.h>
+#include <errno.h>
+#include <limits.h>
+#include <signal.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+int main(int argc, char** argv) {
+
+    if (argc < 7) {
+        printf("Error: must run ./tailfile_delimited <file> <interval> 
<delimiter> <hostname> <tcp port number> <nifi port uuid>\n");
+        exit(1);
+    }
+
+    tailfile_input_params input_params = init_logaggregate_input(argv);
+
+    uint64_t intrvl = 0;
+    uint64_t port_num = 0;
+    if (validate_input_params(&input_params, &intrvl, &port_num) < 0) {
+        return 1;
+    }
+
+    setup_signal_action();
+    nifi_proc_params params = setup_nifi_processor(&input_params, 
"TailFileDelimited", on_trigger_tailfiledelimited);
+
+    set_standalone_property(params.processor, "file_path", input_params.file);
+    set_standalone_property(params.processor, "delimiter", 
input_params.delimiter);
+
+    struct CRawSiteToSiteClient * client = createClient(input_params.instance, 
port_num, input_params.nifi_port_uuid);
+
+    char uuid_str[37];
+    get_proc_uuid_from_processor(params.processor, uuid_str);
+
+    while (!stopped) {
+        flow_file_record * new_ff = invoke(params.processor);
+        struct processor_params * pp = NULL;
+        HASH_FIND_STR(procparams, uuid_str, pp);
+        if (pp) {
+            transmit_payload(client, pp->ff_list, 1);
+            delete_completed_flow_files_from_proc(uuid_str);
 
 Review comment:
   According to valgrind we leak really a **lot** here:
   
   ```
   ==19410== 26,335 (2,640 direct, 23,695 indirect) bytes in 55 blocks are 
definitely lost in loss record 114 of 114
   ==19410==    at 0x4C3017F: operator new(unsigned long) (in 
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   ==19410==    by 0x2BE628: create_ff_object_nc (nanofi.cpp:272)
   ==19410==    by 0x2C3543: generate_flow (nanofi.cpp:277)
   ==19410==    by 0x2BD825: on_trigger_tailfiledelimited (ecu.c:503)
   ==19410==    by 0x2EBAC1: operator() (std_function.h:706)
   ==19410==    by 0x2EBAC1: 
org::apache::nifi::minifi::processors::CallbackProcessor::onTrigger(org::apache::nifi::minifi::core::ProcessContext*,
 org::apache::nifi::minifi::core::ProcessSession*) (CallbackProcessor.cpp:44)
   ==19410==    by 0x2F21CE: ExecutionPlan::runNextProcessor(std::function<void 
(std::shared_ptr<org::apache::nifi::minifi::core::ProcessContext>, 
std::shared_ptr<org::apache::nifi::minifi::core::ProcessSession>)>, 
std::shared_ptr<flowfile_input_params>) (Plan.cpp:183)
   ==19410==    by 0x2C22E9: invoke_ff (nanofi.cpp:705)
   ==19410==    by 0x2A72F4: main (tailfile_delimited.c:56)
   ```
   
   Could you investigate this before mering? 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to