[50/51] [abbrv] [partial] nifi-minifi-cpp git commit: MINIFI-68 Adding yaml-cpp source and updating LICENSE to reflect its inclusion.
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/4dd46e29/src/FlowController.cpp -- diff --git a/src/FlowController.cpp b/src/FlowController.cpp index 7f4061e..f53146e 100644 --- a/src/FlowController.cpp +++ b/src/FlowController.cpp @@ -37,7 +37,7 @@ FlowController::FlowController(std::string name) uuid_generate(_uuid); // Setup the default values - _xmlFileName = DEFAULT_FLOW_XML_FILE_NAME; + _configurationFileName = DEFAULT_FLOW_XML_FILE_NAME; _maxEventDrivenThreads = DEFAULT_MAX_EVENT_DRIVEN_THREAD; _maxTimerDrivenThreads = DEFAULT_MAX_TIMER_DRIVEN_THREAD; _running = false; @@ -48,8 +48,8 @@ FlowController::FlowController(std::string name) // NiFi config properties _configure = Configure::getConfigure(); - _configure->get(Configure::nifi_flow_configuration_file, _xmlFileName); - _logger->log_info("FlowController NiFi XML file %s", _xmlFileName.c_str()); + _configure->get(Configure::nifi_flow_configuration_file, _configurationFileName); + _logger->log_info("FlowController NiFi XML file %s", _configurationFileName.c_str()); // Create repos for flow record and provenance _logger->log_info("FlowController %s created", _name.c_str()); @@ -110,17 +110,17 @@ void FlowController::reload(std::string xmlFile) _logger->log_info("Starting to reload Flow Controller with xml %s", xmlFile.c_str()); stop(true); unload(); - std::string oldxmlFile = this->_xmlFileName; - this->_xmlFileName = xmlFile; - load(); + std::string oldxmlFile = this->_configurationFileName; + this->_configurationFileName = xmlFile; + load(ConfigFormat::XML); start(); if (!this->_root) { - this->_xmlFileName = oldxmlFile; + this->_configurationFileName = oldxmlFile; _logger->log_info("Rollback Flow Controller to xml %s", oldxmlFile.c_str()); stop(true); unload(); - load(); + load(ConfigFormat::XML); start(); } } @@ -197,60 +197,45 @@ void FlowController::parseConnection(xmlDoc *doc, xmlNode *node, ProcessGroup *p if (xmlStrcmp(currentNode->name, BAD_CAST "id") == 0) { char *id = (char *) xmlNodeGetContent(currentNode); - if (id) - { + if (id) { _logger->log_debug("parseConnection: id => [%s]", id); uuid_parse(id, uuid); xmlFree(id); } - } - else if (xmlStrcmp(currentNode->name, BAD_CAST "name") == 0) - { + } else if (xmlStrcmp(currentNode->name, BAD_CAST "name") == 0) { char *name = (char *) xmlNodeGetContent(currentNode); - if (name) - { + if (name) { _logger->log_debug("parseConnection: name => [%s]", name); connection = this->createConnection(name, uuid); - if (connection == NULL) - { + if (connection == NULL) { xmlFree(name); return; } xmlFree(name); } - } - else if (xmlStrcmp(currentNode->name, BAD_CAST "sourceId") == 0) - { + } else if (xmlStrcmp(currentNode->name, BAD_CAST "sourceId") == 0) { char *id = (char *) xmlNodeGetContent(currentNode); - if (id) - { + if (id) { _logger->log_debug("parseConnection: sourceId => [%s]", id); uuid_parse(id, uuid); xmlFree(id); if (connection) connection->setSourceProcessorUUID(uuid); } - } - else if (xmlStrcmp(currentNode->name, BAD_CAST "destinationId") == 0) - { + } else if (xmlStrcmp(currentNode->name, BAD_CAST "destinationId") == 0) {
[50/51] [abbrv] [partial] nifi-minifi-cpp git commit: MINIFI-68 Adding yaml-cpp source and updating LICENSE to reflect its inclusion.
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/cf813d4d/src/FlowController.cpp -- diff --git a/src/FlowController.cpp b/src/FlowController.cpp index b18953e..2684b04 100644 --- a/src/FlowController.cpp +++ b/src/FlowController.cpp @@ -27,17 +27,17 @@ #include #include #include +#include #include "FlowController.h" #include "ProcessContext.h" -FlowController::FlowController(std::string name) -: _name(name) -{ +FlowController::FlowController(std::string name) : + _name(name) { uuid_generate(_uuid); // Setup the default values - _xmlFileName = DEFAULT_FLOW_XML_FILE_NAME; + _configurationFileName = DEFAULT_FLOW_XML_FILE_NAME; _maxEventDrivenThreads = DEFAULT_MAX_EVENT_DRIVEN_THREAD; _maxTimerDrivenThreads = DEFAULT_MAX_TIMER_DRIVEN_THREAD; _running = false; @@ -48,34 +48,29 @@ FlowController::FlowController(std::string name) // NiFi config properties _configure = Configure::getConfigure(); - _configure->get(Configure::nifi_flow_configuration_file, _xmlFileName); - _logger->log_info("FlowController NiFi XML file %s", _xmlFileName.c_str()); + _configure->get(Configure::nifi_flow_configuration_file, _configurationFileName); + _logger->log_info("FlowController NiFi XML file %s", _configurationFileName.c_str()); // Create repos for flow record and provenance _logger->log_info("FlowController %s created", _name.c_str()); } -FlowController::~FlowController() -{ +FlowController::~FlowController() { stop(true); unload(); delete _protocol; } -bool FlowController::isRunning() -{ +bool FlowController::isRunning() { return (_running); } -bool FlowController::isInitialized() -{ +bool FlowController::isInitialized() { return (_initialized); } -void FlowController::stop(bool force) -{ - if (_running) - { +void FlowController::stop(bool force) { + if (_running) { _logger->log_info("Stop Flow Controller"); this->_timerScheduler.stop(); // Wait for sometime for thread stop @@ -86,14 +81,11 @@ void FlowController::stop(bool force) } } -void FlowController::unload() -{ - if (_running) - { +void FlowController::unload() { + if (_running) { stop(true); } - if (_initialized) - { + if (_initialized) { _logger->log_info("Unload Flow Controller"); if (_root) delete _root; @@ -105,43 +97,34 @@ void FlowController::unload() return; } -void FlowController::reload(std::string xmlFile) -{ +void FlowController::reload(std::string xmlFile) { _logger->log_info("Starting to reload Flow Controller with xml %s", xmlFile.c_str()); stop(true); unload(); - std::string oldxmlFile = this->_xmlFileName; - this->_xmlFileName = xmlFile; - load(); + std::string oldxmlFile = this->_configurationFileName; + this->_configurationFileName = xmlFile; + load(ConfigFormat::XML); start(); - if (!this->_root) - { - this->_xmlFileName = oldxmlFile; + if (!this->_root) { + this->_configurationFileName = oldxmlFile; _logger->log_info("Rollback Flow Controller to xml %s", oldxmlFile.c_str()); stop(true); unload(); - load(); + load(ConfigFormat::XML); start(); } } -Processor *FlowController::createProcessor(std::string name, uuid_t uuid) -{ +Processor *FlowController::createProcessor(std::string name, uuid_t uuid) { Processor *processor = NULL; - if (name == GenerateFlowFile::ProcessorName) - { + _logger->log_trace("Received request to create a processor for name %s", name.c_str()); + if (name == GenerateFlowFile::ProcessorName) { processor = new GenerateFlowFile(name, uuid); - } - else if (name == LogAttribute::ProcessorName) - { + } else if (name == LogAttribute::ProcessorName) { processor = new LogAttribute(name, uuid); - } - else if (name == RealTimeDataCollector::ProcessorName) - { + } else if (name == RealTimeDataCollector::ProcessorName) { processor = new RealTimeDataCollector(name, uuid); - } - else - { + } else { _logger->log_error("No Processor defined for %s", name.c_str()); return NULL; } @@ -152,29 +135,24 @@ Processor *FlowController::createProcessor(std::string name, uuid_t uuid) return processor; } -ProcessGroup *FlowController::createRootProcessGroup(std::string name, uuid_t uuid) -{ +ProcessGroup *FlowController::createRootProcessGroup(std::string name, uuid_t uui