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.
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 @@
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
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 @@
_minAge = 0;
_maxAge = 0;
_minSize = 0;
- _maxSize = 0;;
+ _maxSize = 0;
_ignoreHiddenFile = true;
_pollInterval = 0;
_batchSize = 10;
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 @@
_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 @@
// 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 @@
// 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 @@
} // 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);