[GitHub] nifi-minifi-cpp pull request #268: MINIFICPP-397 Added implementation of Rou...
Github user asfgit closed the pull request at: https://github.com/apache/nifi-minifi-cpp/pull/268 ---
[GitHub] nifi-minifi-cpp pull request #268: MINIFICPP-397 Added implementation of Rou...
Github user minifirocks commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/268#discussion_r171389409 --- Diff: libminifi/src/processors/RouteOnAttribute.cpp --- @@ -0,0 +1,107 @@ +/** + * @file RouteOnAttribute.cpp + * RouteOnAttribute class implementation + * + * 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 "processors/RouteOnAttribute.h" + +#include +#include +#include + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace processors { + +core::Relationship RouteOnAttribute::Unmatched( +"unmatched", +"Files which do not match any expression are routed here"); +core::Relationship RouteOnAttribute::Failure( +"failure", +"Failed files are transferred to failure"); + +void RouteOnAttribute::initialize() { + std::set properties; + setSupportedProperties(properties); +} + +void RouteOnAttribute::onDynamicPropertyModified(const core::Property &orig_property, + const core::Property &new_property) { + + // Update the routing table when routes are added via dynamic properties. + route_properties_[new_property.getName()] = new_property; + + std::set relationships; + + for (const auto &route : route_properties_) { +core::Relationship route_rel{route.first, "Dynamic route"}; +route_rels_[route.first] = route_rel; +relationships.insert(route_rel); +logger_->log_info("RouteOnAttribute registered route '%s' with expression '%s'", + route.first, + route.second.getValue()); + } + + relationships.insert(Unmatched); + relationships.insert(Failure); + setSupportedRelationships(relationships); --- End diff -- OK. ---
[GitHub] nifi-minifi-cpp pull request #268: MINIFICPP-397 Added implementation of Rou...
Github user achristianson commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/268#discussion_r171338847 --- Diff: libminifi/src/processors/RouteOnAttribute.cpp --- @@ -0,0 +1,107 @@ +/** + * @file RouteOnAttribute.cpp + * RouteOnAttribute class implementation + * + * 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 "processors/RouteOnAttribute.h" + +#include +#include +#include + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace processors { + +core::Relationship RouteOnAttribute::Unmatched( +"unmatched", +"Files which do not match any expression are routed here"); +core::Relationship RouteOnAttribute::Failure( +"failure", +"Failed files are transferred to failure"); + +void RouteOnAttribute::initialize() { + std::set properties; + setSupportedProperties(properties); +} + +void RouteOnAttribute::onDynamicPropertyModified(const core::Property &orig_property, + const core::Property &new_property) { + + // Update the routing table when routes are added via dynamic properties. + route_properties_[new_property.getName()] = new_property; + + std::set relationships; + + for (const auto &route : route_properties_) { +core::Relationship route_rel{route.first, "Dynamic route"}; +route_rels_[route.first] = route_rel; +relationships.insert(route_rel); +logger_->log_info("RouteOnAttribute registered route '%s' with expression '%s'", + route.first, + route.second.getValue()); + } + + relationships.insert(Unmatched); + relationships.insert(Failure); + setSupportedRelationships(relationships); --- End diff -- Since we don't support changing of relationships if isRunning() is true, a call to update properties/relationships will not go through and the failure will be logged. I think that's the behavior we want. ---
[GitHub] nifi-minifi-cpp pull request #268: MINIFICPP-397 Added implementation of Rou...
Github user minifirocks commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/268#discussion_r171293683 --- Diff: libminifi/src/processors/RouteOnAttribute.cpp --- @@ -0,0 +1,107 @@ +/** + * @file RouteOnAttribute.cpp + * RouteOnAttribute class implementation + * + * 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 "processors/RouteOnAttribute.h" + +#include +#include +#include + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace processors { + +core::Relationship RouteOnAttribute::Unmatched( +"unmatched", +"Files which do not match any expression are routed here"); +core::Relationship RouteOnAttribute::Failure( +"failure", +"Failed files are transferred to failure"); + +void RouteOnAttribute::initialize() { + std::set properties; + setSupportedProperties(properties); +} + +void RouteOnAttribute::onDynamicPropertyModified(const core::Property &orig_property, + const core::Property &new_property) { + + // Update the routing table when routes are added via dynamic properties. + route_properties_[new_property.getName()] = new_property; + + std::set relationships; + + for (const auto &route : route_properties_) { +core::Relationship route_rel{route.first, "Dynamic route"}; +route_rels_[route.first] = route_rel; +relationships.insert(route_rel); +logger_->log_info("RouteOnAttribute registered route '%s' with expression '%s'", + route.first, + route.second.getValue()); + } + + relationships.insert(Unmatched); + relationships.insert(Failure); + setSupportedRelationships(relationships); --- End diff -- bool Connectable::setSupportedRelationships(std::set relationships) { if (isRunning()) { logger_->log_warn("Can not set processor supported relationship while the process %s is running", name_); return false; } what if we do the onDynamicPropertyModified while the processor is running ---
[GitHub] nifi-minifi-cpp pull request #268: MINIFICPP-397 Added implementation of Rou...
GitHub user achristianson opened a pull request: https://github.com/apache/nifi-minifi-cpp/pull/268 MINIFICPP-397 Added implementation of RouteOnAttribute Thank you for submitting a contribution to Apache NiFi - MiNiFi C++. In order to streamline the review of the contribution we ask you to ensure the following steps have been taken: ### For all changes: - [x] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? - [x] Does your PR title start with MINIFI- where is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. - [x] Has your PR been rebased against the latest commit within the target branch (typically master)? - [x] Is your initial contribution a single, squashed commit? ### For code changes: - [x] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? - [x] If applicable, have you updated the LICENSE file? - [x] If applicable, have you updated the NOTICE file? ### For documentation related changes: - [x] Have you ensured that format looks appropriate for the output in which it is rendered? ### Note: Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible. You can merge this pull request into a Git repository by running: $ git pull https://github.com/achristianson/nifi-minifi-cpp MINIFICPP-397 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi-minifi-cpp/pull/268.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #268 commit 8328f8e386e6a32253c0fc19c9769aad90d95281 Author: Andrew I. Christianson Date: 2018-02-20T16:22:18Z MINIFICPP-397 Added implementation of RouteOnAttribute ---