You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ph...@apache.org on 2019/04/22 11:24:45 UTC
[nifi-minifi-cpp] branch master updated: MINIFICPP-804 - C API
Python examples are broken
This is an automated email from the ASF dual-hosted git repository.
phrocker pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
The following commit(s) were added to refs/heads/master by this push:
new 9d378e9 MINIFICPP-804 - C API Python examples are broken
9d378e9 is described below
commit 9d378e978c93a0df08ffd65be1168abdbf113b9f
Author: Arpad Boda <ab...@hortonworks.com>
AuthorDate: Wed Apr 17 15:44:11 2019 +0200
MINIFICPP-804 - C API Python examples are broken
Closes #537.
Signed-off-by: Marc Parisi <ph...@apache.org>
---
nanofi/include/api/nanofi.h | 2 +-
python/getFile.py | 6 ++++--
python/minifi/__init__.py | 10 ++++++----
3 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/nanofi/include/api/nanofi.h b/nanofi/include/api/nanofi.h
index c014030..04e5712 100644
--- a/nanofi/include/api/nanofi.h
+++ b/nanofi/include/api/nanofi.h
@@ -262,7 +262,7 @@ flow_file_record *invoke_file(standalone_processor* proc, const char* path);
**/
flow_file_record *invoke_chunk(standalone_processor *proc, uint8_t *buf, uint64_t size);
-int transfer(processor_session* session, flow *flow, const char *rel);
+DEPRECATED int transfer(processor_session* session, flow *flow, const char *rel);
/**
* Creates a flow file record based on a file
diff --git a/python/getFile.py b/python/getFile.py
index fd3e335..c8aff98 100644
--- a/python/getFile.py
+++ b/python/getFile.py
@@ -36,7 +36,9 @@ class GetFilePrinterProcessor(PyProcessor):
if not flow_file.add_attribute("python_test","value2"):
print("Cannot add the same attribute twice!")
print ("original file name: " + flow_file.get_attribute("filename"))
- self.transfer(session, flow_file, "success")
+ target_relationship = "success"
+ if not self.transfer(session, flow_file, target_relationship):
+ print("transfer to relationship " + target_relationship + " failed")
return CALLBACK(onTrigger)
@@ -67,7 +69,7 @@ processor.set_property("Keep Source File", "true")
current_module = sys.modules[__name__]
-processor = minifi.create_python_processor(current_module,"GetFilePrinterProcessor")
+processor = minifi.create_python_processor(current_module, "GetFilePrinterProcessor")
ff = minifi.get_next_flowfile()
if ff:
diff --git a/python/minifi/__init__.py b/python/minifi/__init__.py
index b6de1d6..4632347 100644
--- a/python/minifi/__init__.py
+++ b/python/minifi/__init__.py
@@ -60,7 +60,7 @@ class Processor(object):
self._minifi = minifi
def set_property(self, name, value):
- self._minifi.set_property( self._proc, name.encode("UTF-8"), value.encode("UTF-8"))
+ return self._minifi.set_property( self._proc, name.encode("UTF-8"), value.encode("UTF-8")) == 0
class PyProcessor(object):
def __init__(self, minifi, flow):
@@ -79,7 +79,7 @@ class PyProcessor(object):
return None
def transfer(self, session, ff, rel):
- self._minifi.transfer(session, self._flow, rel.encode("UTF-8"))
+ return self._minifi.transfer_to_relationship(ff.get_instance(), session, rel.encode("UTF-8")) == 0
@abstractmethod
def _onTriggerCallback(self):
@@ -120,8 +120,7 @@ class FlowFile(object):
def add_attribute(self, name, value):
vallen = len(value)
- ret = self._minifi.add_attribute(self._ff, name.encode("UTF-8"), value.encode("UTF-8"), vallen)
- return True if ret == 0 else False
+ return self._minifi.add_attribute(self._ff, name.encode("UTF-8"), value.encode("UTF-8"), vallen) == 0
def update_attribute(self, name, value):
vallen = len(value)
@@ -167,6 +166,9 @@ class MiNiFi(object):
""" transfer ff """
self._minifi.transfer.argtypes = [ctypes.POINTER(CProcessSession), ctypes.POINTER(CFlow) , ctypes.c_char_p ]
self._minifi.transfer.restype = ctypes.c_int
+ """ transfer ff to relationship """
+ self._minifi.transfer_to_relationship.argtypes = [ctypes.POINTER(CFlowFile), ctypes.POINTER(CProcessSession), ctypes.c_char_p ]
+ self._minifi.transfer_to_relationship.restype = ctypes.c_int
""" add attribute to ff """
self._minifi.add_attribute.argtypes = [ctypes.POINTER(CFlowFile), ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int ]
self._minifi.add_attribute.restype = ctypes.c_int