You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by al...@apache.org on 2016/08/27 02:49:41 UTC

nifi-minifi-cpp git commit: MINIFI-84 Performing explicit checking on values of processor Properties YAML. An empty value is treated as a YAML node in lieu of being null and would lead to conversion errors.

Repository: nifi-minifi-cpp
Updated Branches:
  refs/heads/master 8f853c94d -> ce3d3e498


MINIFI-84 Performing explicit checking on values of processor Properties YAML. An empty value is treated as a YAML node in lieu of being null and would lead to conversion errors.

This closes #7.


Project: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/commit/ce3d3e49
Tree: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/tree/ce3d3e49
Diff: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/diff/ce3d3e49

Branch: refs/heads/master
Commit: ce3d3e49892554e512fe0f68f99c5d413c8d5535
Parents: 8f853c9
Author: Aldrin Piri <al...@apache.org>
Authored: Tue Aug 23 12:31:49 2016 -0400
Committer: Aldrin Piri <al...@apache.org>
Committed: Fri Aug 26 22:08:04 2016 -0400

----------------------------------------------------------------------
 inc/FlowController.h   |  2 ++
 inc/GetFile.h          |  2 +-
 src/FlowController.cpp | 52 +++++++++++++++++++--------------------------
 3 files changed, 25 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/ce3d3e49/inc/FlowController.h
----------------------------------------------------------------------
diff --git a/inc/FlowController.h b/inc/FlowController.h
index 13f7dff..0698c65 100644
--- a/inc/FlowController.h
+++ b/inc/FlowController.h
@@ -234,6 +234,8 @@ private:
 	void parseConnectionYaml(YAML::Node *node, ProcessGroup *parent);
 	//! Process Remote Process Group YAML
 	void parseRemoteProcessGroupYaml(YAML::Node *node, ProcessGroup *parent);
+	//! Parse Properties Node YAML for a processor
+	void parsePropertiesNodeYaml(YAML::Node *propertiesNode, Processor *processor);
 
 	// Prevent default copy constructor and assignment operation
 	// Only support pass by reference or pointer

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/ce3d3e49/inc/GetFile.h
----------------------------------------------------------------------
diff --git a/inc/GetFile.h b/inc/GetFile.h
index 333813d..7ba6af4 100644
--- a/inc/GetFile.h
+++ b/inc/GetFile.h
@@ -42,7 +42,7 @@ public:
 		_minAge = 0;
 		_maxAge = 0;
 		_minSize = 0;
-		_maxSize = 0;;
+		_maxSize = 0;
 		_ignoreHiddenFile = true;
 		_pollInterval = 0;
 		_batchSize = 10;

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/ce3d3e49/src/FlowController.cpp
----------------------------------------------------------------------
diff --git a/src/FlowController.cpp b/src/FlowController.cpp
index b176a12..8ac76fb 100644
--- a/src/FlowController.cpp
+++ b/src/FlowController.cpp
@@ -88,6 +88,7 @@ FlowController::FlowController(std::string name)
 	_logger->log_info("FlowController NiFi Configuration file %s", pathString.c_str());
 
 	// Create repos for flow record and provenance
+
 	_logger->log_info("FlowController %s created", _name.c_str());
 }
 
@@ -465,22 +466,7 @@ void FlowController::parseProcessorNodeYaml(YAML::Node processorsNode, ProcessGr
 
 				// handle processor properties
 				YAML::Node propertiesNode = procNode["Properties"];
-				std::vector<Property> properties;
-
-				if (propertiesNode.IsMap() && !propertiesNode.IsNull() && propertiesNode.size() > 0) {
-					std::map<std::string, std::string> propertiesMap = propertiesNode.as<
-							std::map<std::string, std::string>>();
-					for (std::map<std::string, std::string>::iterator propsIter = propertiesMap.begin();
-							propsIter != propertiesMap.end(); propsIter++) {
-						std::string propertyName = propsIter->first;
-						std::string propertyValue = propsIter->second;
-						if (!processor->setProperty(propertyName, propertyValue)) {
-							_logger->log_warn(
-									"Received property %s with value %s but is not one of the properties for %s",
-									propertyName.c_str(), propertyValue.c_str(), procCfg.name.c_str());
-						}
-					}
-				}
+				parsePropertiesNodeYaml(&propertiesNode, processor);
 
 				// Take care of scheduling
 				TimeUnit unit;
@@ -835,20 +821,8 @@ void FlowController::parsePortYaml(YAML::Node *portNode, ProcessGroup *parent, T
 	// handle port properties
 	YAML::Node nodeVal = portNode->as<YAML::Node>();
 	YAML::Node propertiesNode = nodeVal["Properties"];
-	std::vector<Property> properties;
-
-	if (propertiesNode.IsMap() && !propertiesNode.IsNull() && propertiesNode.size() > 0) {
-		std::map<std::string, std::string> propertiesMap = propertiesNode.as<std::map<std::string, std::string>>();
-		for (std::map<std::string, std::string>::iterator propsIter = propertiesMap.begin();
-				propsIter != propertiesMap.end(); propsIter++) {
-			std::string propertyName = propsIter->first;
-			std::string propertyValue = propsIter->second;
-			if (!processor->setProperty(propertyName, propertyValue)) {
-				_logger->log_warn("Received property %s with value %s but is not one of the properties for %s",
-						propertyName.c_str(), propertyValue.c_str(), nameStr.c_str());
-			}
-		}
-	}
+
+	parsePropertiesNodeYaml(&propertiesNode, processor);
 
 	// add processor to parent
 	parent->addProcessor(processor);
@@ -1095,6 +1069,24 @@ void FlowController::parseProcessorNode(xmlDoc *doc, xmlNode *processorNode, Pro
 	} // while node
 }
 
+void FlowController::parsePropertiesNodeYaml(YAML::Node *propertiesNode, Processor *processor)
+{
+    // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
+    for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter)
+    {
+        std::string propertyName = propsIter->first.as<std::string>();
+        YAML::Node propertyValueNode = propsIter->second;
+        if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined())
+        {
+            std::string rawValueString = propertyValueNode.as<std::string>();
+            if (!processor->setProperty(propertyName, rawValueString))
+            {
+                _logger->log_warn("Received property %s with value %s but is not one of the properties for %s", propertyName.c_str(), rawValueString.c_str(), processor->getName().c_str());
+            }
+        }
+    }
+}
+
 void FlowController::load(ConfigFormat configFormat) {
 	if (_running) {
 		stop(true);