[GitHub] nifi-minifi-cpp pull request #460: MINIFICPP-479: Add processor property des...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/460#discussion_r241199779 --- Diff: libminifi/include/core/state/Value.h --- @@ -74,94 +157,215 @@ class BoolValue : public Value { explicit BoolValue(bool value) : Value(value ? "true" : "false"), value(value) { +setTypeId(); + } + explicit BoolValue(const std::string ) + : Value(strvalue) { +bool l; +std::istringstream(strvalue) >> std::boolalpha >> l; +value = l; // avoid warnings } - bool getValue() { + + bool getValue() const { return value; } protected: + + virtual bool getValue(int ) { +if (ref == 1) { + ref = true; + return true; +} else if (ref == 0) { + ref = false; + return true; +} else { + return false; +} + } + + virtual bool getValue(int64_t ) { +if (ref == 1) { + ref = true; + return true; +} else if (ref == 0) { + ref = false; + return true; +} else { + return false; +} + } + + virtual bool getValue(uint64_t ) { +if (ref == 1) { + ref = true; + return true; +} else if (ref == 0) { + ref = false; + return true; +} else { + return false; +} + } + + virtual bool getValue(bool ) { +ref = value; +return true; + } + bool value; }; -class Int64Value : public Value { +class UInt64Value : public Value { public: - explicit Int64Value(uint64_t value) + explicit UInt64Value(uint64_t value) : Value(std::to_string(value)), value(value) { +setTypeId(); + } + explicit UInt64Value(const std::string ) + : Value(strvalue), +value(std::stoull(strvalue)) { +setTypeId(); } - uint64_t getValue() { + + uint64_t getValue() const { return value; } protected: + + virtual bool getValue(int ) { +return false; + } + + virtual bool getValue(int64_t ) { +if (value < std::numeric_limits::max()) { + ref = value; + return true; +} +return false; + } + + virtual bool getValue(uint64_t ) { +ref = value; +return true; + } + + virtual bool getValue(bool ) { +return false; + } + uint64_t value; }; +class Int64Value : public Value { + public: + explicit Int64Value(int64_t value) + : Value(std::to_string(value)), +value(value) { +setTypeId(); + } + explicit Int64Value(const std::string ) + : Value(strvalue), +value(std::stoll(strvalue)) { +setTypeId(); + } + + int64_t getValue() { +return value; + } + protected: + + virtual bool getValue(int ) { +return false; + } + + virtual bool getValue(int64_t ) { +ref = value; +return true; + } + + virtual bool getValue(uint64_t ) { +if (value >= 0) { + ref = value; + return true; +} +return true; + } + + virtual bool getValue(bool ) { +return false; + } -static inline std::shared_ptr createValue( -const bool ) { + int64_t value; +}; + +static inline std::shared_ptr createValue(const bool ) { return std::make_shared(object); } -static inline std::shared_ptr createValue( -const char *object) { +static inline std::shared_ptr createValue(const char *object) { return std::make_shared(object); } -static inline std::shared_ptr createValue( -char *object) { +static inline std::shared_ptr createValue(char *object) { return std::make_shared(std::string(object)); } -static inline std::shared_ptr createValue( -const std::string ) { +static inline std::shared_ptr createValue(const std::string ) { return std::make_shared(object); } - -static inline std::shared_ptr createValue( -const uint32_t ) { - return std::make_shared(object); +static inline std::shared_ptr createValue(const uint32_t ) { + return std::make_shared(object); +} +#if ( defined(__APPLE__) || defined(__MACH__) || defined(DARWIN) ) +static inline std::shared_ptr createValue(const size_t ) { + return std::make_shared(object); +} +#endif +static inline std::shared_ptr createValue(const uint64_t ) { + return std::make_shared(object); } -static inline std::shared_pt
[GitHub] nifi-minifi-cpp pull request #460: MINIFICPP-479: Add processor property des...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/460#discussion_r241193264 --- Diff: libminifi/include/core/PropertyValidation.h --- @@ -0,0 +1,347 @@ +/** + * + * 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. + */ +#ifndef LIBMINIFI_INCLUDE_CORE_PROPERTYVALIDATION_H_ +#define LIBMINIFI_INCLUDE_CORE_PROPERTYVALIDATION_H_ + +#include "core/Core.h" +#include "core/state/Value.h" +#include "TypedValues.h" +#include "utils/StringUtils.h" +#include + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace core { + +class ValidationResult; + +class ValidationResult { + public: + bool valid() const { +return valid_; + } + + class Builder { + public: +static Builder createBuilder() { + return Builder(); +} +Builder (bool valid) { + valid_ = valid; + return *this; +} +Builder (const std::string ) { + subject_ = subject; + return *this; +} +Builder (const std::string ) { + input_ = input; + return *this; +} + +ValidationResult build() { + return ValidationResult(*this); +} + + protected: +bool valid_; +std::string subject_; +std::string input_; +friend class ValidationResult; + }; + private: + + bool valid_; + std::string subject_; + std::string input_; + + ValidationResult(const Builder ) + : valid_(builder.valid_), +subject_(builder.subject_), +input_(builder.input_) { + } + + friend class Builder; +}; + +class PropertyValidator { + public: + + PropertyValidator(const std::string ) + : name_(name) { + } + virtual ~PropertyValidator() { + + } + + std::string getName() const { +return name_; + } + + virtual ValidationResult validate(const std::string , const std::shared_ptr ) const = 0; + + virtual ValidationResult validate(const std::string , const std::string ) const = 0; + + protected: + template + ValidationResult _validate_internal(const std::string , const std::shared_ptr ) const { +if (std::dynamic_pointer_cast(input) != nullptr) { + return ValidationResult::Builder::createBuilder().withSubject(subject).withInput(input->getStringValue()).isValid(true).build(); +} else { + state::response::ValueNode vn; + vn = input->getStringValue(); + return validate(subject, input->getStringValue()); +} + + } + + std::string name_; +}; + +class AlwaysValid : public PropertyValidator { + bool always_valid_; + public: + AlwaysValid(bool isalwaysvalid, const std::string ) + : always_valid_(isalwaysvalid), +PropertyValidator(name) { + + } + virtual ~AlwaysValid() { + } + ValidationResult validate(const std::string , const std::shared_ptr ) const { +return ValidationResult::Builder::createBuilder().withSubject(subject).withInput(input->getStringValue()).isValid(always_valid_).build(); + } + + ValidationResult validate(const std::string , const std::string ) const { +return ValidationResult::Builder::createBuilder().withSubject(subject).withInput(input).isValid(always_valid_).build(); + } + +}; + +class BooleanValidator : public PropertyValidator { + public: + BooleanValidator(const std::string ) + : PropertyValidator(name) { + } + virtual ~BooleanValidator() { + + } + + ValidationResult validate(const std::string , const std::shared_ptr ) const { +return PropertyValidator::_validate_internal(subject, input); + } + + ValidationResult validate(const std::string , const std::s
[GitHub] nifi-minifi-cpp pull request #460: MINIFICPP-479: Add processor property des...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/460#discussion_r241192961 --- Diff: libminifi/include/core/state/Value.h --- @@ -74,94 +157,215 @@ class BoolValue : public Value { explicit BoolValue(bool value) : Value(value ? "true" : "false"), value(value) { +setTypeId(); + } + explicit BoolValue(const std::string ) + : Value(strvalue) { +bool l; +std::istringstream(strvalue) >> std::boolalpha >> l; +value = l; // avoid warnings } - bool getValue() { + + bool getValue() const { return value; } protected: + + virtual bool getValue(int ) { +if (ref == 1) { + ref = true; + return true; +} else if (ref == 0) { + ref = false; + return true; +} else { + return false; +} + } + + virtual bool getValue(int64_t ) { +if (ref == 1) { + ref = true; + return true; +} else if (ref == 0) { + ref = false; + return true; +} else { + return false; +} + } + + virtual bool getValue(uint64_t ) { +if (ref == 1) { + ref = true; + return true; +} else if (ref == 0) { + ref = false; + return true; +} else { + return false; +} + } + + virtual bool getValue(bool ) { +ref = value; +return true; + } + bool value; }; -class Int64Value : public Value { +class UInt64Value : public Value { public: - explicit Int64Value(uint64_t value) + explicit UInt64Value(uint64_t value) : Value(std::to_string(value)), value(value) { +setTypeId(); + } + explicit UInt64Value(const std::string ) + : Value(strvalue), +value(std::stoull(strvalue)) { +setTypeId(); } - uint64_t getValue() { + + uint64_t getValue() const { return value; } protected: + + virtual bool getValue(int ) { +return false; + } + + virtual bool getValue(int64_t ) { +if (value < std::numeric_limits::max()) { + ref = value; + return true; +} +return false; + } + + virtual bool getValue(uint64_t ) { +ref = value; +return true; + } + + virtual bool getValue(bool ) { +return false; + } + uint64_t value; }; +class Int64Value : public Value { + public: + explicit Int64Value(int64_t value) + : Value(std::to_string(value)), +value(value) { +setTypeId(); + } + explicit Int64Value(const std::string ) + : Value(strvalue), +value(std::stoll(strvalue)) { +setTypeId(); + } + + int64_t getValue() { +return value; + } + protected: + + virtual bool getValue(int ) { +return false; + } + + virtual bool getValue(int64_t ) { +ref = value; +return true; + } + + virtual bool getValue(uint64_t ) { +if (value >= 0) { + ref = value; + return true; +} +return true; + } + + virtual bool getValue(bool ) { +return false; + } -static inline std::shared_ptr createValue( -const bool ) { + int64_t value; --- End diff -- I think that's probably a differing opinion of style. I don't like using "using" directives and don't think the duplication is enough to warrant its usage. I have and do use "using" but very sparingly. ---
[GitHub] nifi-minifi-cpp pull request #459: MINIFICPP-695 - NanoFi Examples appear to...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/459#discussion_r241191018 --- Diff: nanofi/examples/CMakeLists.txt --- @@ -50,11 +50,11 @@ if (WIN32) set(LINK_FLAGS "/WHOLEARCHIVE") set(LINK_END_FLAGS "") elseif (APPLE) -set(LINK_FLAGS "-Wl,-all_load") +set(LINK_FLAGS "") --- End diff -- This seems wrong based on what it should do, but hard to argue with it not working... ---
[GitHub] nifi-minifi-cpp pull request #459: MINIFICPP-695 - NanoFi Examples appear to...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/459#discussion_r240863016 --- Diff: nanofi/examples/CMakeLists.txt --- @@ -50,11 +50,11 @@ if (WIN32) set(LINK_FLAGS "/WHOLEARCHIVE") set(LINK_END_FLAGS "") elseif (APPLE) -set(LINK_FLAGS "-Wl,-all_load") +set(LINK_FLAGS "") --- End diff -- Unfortunately this doesn't solve the problem. This only causes the curl support to not be built. I'll take a closer look tomorrow. Thanks! ---
[GitHub] nifi-minifi-cpp pull request #460: MINIFICPP-479: Add processor property des...
GitHub user phrocker opened a pull request: https://github.com/apache/nifi-minifi-cpp/pull/460 MINIFICPP-479: Add processor property descriptor updates. WIP 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: - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? - [ ] Does your PR title start with MINIFICPP- where is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. - [ ] Has your PR been rebased against the latest commit within the target branch (typically master)? - [ ] Is your initial contribution a single, squashed commit? ### For code changes: - [ ] 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)? - [ ] If applicable, have you updated the LICENSE file? - [ ] If applicable, have you updated the NOTICE file? ### For documentation related changes: - [ ] 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/phrocker/nifi-minifi-cpp MINIFICPP-479 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi-minifi-cpp/pull/460.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 #460 commit 371ab8cf0cbcd25c4924696ffe1c7215da2c2977 Author: Marc Parisi Date: 2018-08-12T17:22:00Z MINIFICPP-479 and others: commit initial stuff get back on track MINIFICPP-479: begin incorporating validators MINIFICPP-479: Adding code found on laptop Found more code in stashed repos commit ce89c4dfc6839ef071a8488af61abbefd0038027 Author: Marc Parisi Date: 2018-08-19T16:00:00Z MINIFICPP-479: inc commit .. does not work fully commit 72df0111bb5c6ae03be38c0471578178e7945365 Author: Marc Parisi Date: 2018-12-11T01:03:34Z MINIFICPP-479: Make updates to how values can be used MINIFICPP-479: Add comments commit 54fc1f36cea1f7bb30e208acf95487c29b0fe2af Author: Marc Parisi Date: 2018-12-12T01:12:58Z MINIFICPP-479: Update processors ---
[GitHub] nifi-minifi-cpp pull request #457: MINIFICPP-691: Add method for getting pro...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/457#discussion_r239819770 --- Diff: extensions/mqtt/processors/PublishMQTT.h --- @@ -137,7 +137,7 @@ class PublishMQTT : public processors::AbstractMQTTProcessor { std::shared_ptr logger_; }; -REGISTER_RESOURCE(PublishMQTT); +REGISTER_RESOURCE(PublishMQTT, "This Processor puts the contents of a FlowFile to a MQTT broker for a specified topic. The content of a FlowFile becomes the payload of the MQTT message."); --- End diff -- Hmm that's a good point. I'll see if I can clarify this, then. ---
[GitHub] nifi-minifi-cpp pull request #457: MINIFICPP-691: Add method for getting pro...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/457#discussion_r239815707 --- Diff: libminifi/include/processors/GetFile.h --- @@ -194,7 +194,7 @@ class GetFile : public core::Processor, public state::response::MetricsNodeSourc std::shared_ptr logger_; }; -REGISTER_RESOURCE(GetFile); +REGISTER_RESOURCE(GetFile,"Creates FlowFiles from files in a directory. NiFi will ignore files for which it doesn't have read permissions."); --- End diff -- ha actually this one I modified as it ended in a prepositional phrase but I didn't notice the NiFi. Thanks! ---
[GitHub] nifi-minifi-cpp pull request #457: MINIFICPP-691: Add method for getting pro...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/457#discussion_r239815379 --- Diff: extensions/mqtt/processors/PublishMQTT.h --- @@ -137,7 +137,7 @@ class PublishMQTT : public processors::AbstractMQTTProcessor { std::shared_ptr logger_; }; -REGISTER_RESOURCE(PublishMQTT); +REGISTER_RESOURCE(PublishMQTT, "This Processor puts the contents of a FlowFile to a MQTT broker for a specified topic. The content of a FlowFile becomes the payload of the MQTT message."); --- End diff -- In plural form contents can referenced in a concrete sense to things contained within something. This isn't incorrect. I'll err on avoiding to change the original author's wording. ---
[GitHub] nifi-minifi-cpp pull request #457: MINIFICPP-691: Add method for getting pro...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/457#discussion_r239814559 --- Diff: extensions/libarchive/MergeContent.h --- @@ -334,7 +334,9 @@ class MergeContent : public processors::BinFiles { std::string readContent(std::string path); }; -REGISTER_RESOURCE(MergeContent); +REGISTER_RESOURCE(MergeContent, "Merges a Group of FlowFiles together based on a user-defined strategy and packages them into a single FlowFile. " +"It is recommended that the Processor be configured with only a single incoming connection, as Group of FlowFiles will not be created from " --- End diff -- "Processor is configured" would be passive voice, so not the best choice if we are to nit. ---
[GitHub] nifi-minifi-cpp pull request #457: MINIFICPP-691: Add method for getting pro...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/457#discussion_r239792561 --- Diff: extensions/mqtt/processors/AbstractMQTTProcessor.h --- @@ -157,7 +157,6 @@ class AbstractMQTTProcessor : public core::Processor { std::string securityPrivateKeyPassWord_; }; -REGISTER_RESOURCE(AbstractMQTTProcessor); --- End diff -- The appropriate thing would be to remove this class, actually. I'll try to put the details in a ticket, but the priority is low since it's an extension ---
[GitHub] nifi-minifi-cpp pull request #457: MINIFICPP-691: Add method for getting pro...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/457#discussion_r239792102 --- Diff: libminifi/include/processors/GetFile.h --- @@ -194,7 +194,7 @@ class GetFile : public core::Processor, public state::response::MetricsNodeSourc std::shared_ptr logger_; }; -REGISTER_RESOURCE(GetFile); +REGISTER_RESOURCE(GetFile,"Creates FlowFiles from files in a directory. NiFi will ignore files for which it doesn't have read permissions."); --- End diff -- Yah. These are auto copied from processors.md, so these typos exist there too. Thank for catching. ---
[GitHub] nifi-minifi-cpp pull request #457: MINIFICPP-691: Add method for getting pro...
GitHub user phrocker opened a pull request: https://github.com/apache/nifi-minifi-cpp/pull/457 MINIFICPP-691: Add method for getting processor description. Internal⦠⦠API change, but is strictly voluntary for contributors Based on work from September -- enables us to get a better documentation picture in agent information. Will allow us to eventually auto generate some docs. While this is an internal API call we still don't want to fully break anyone, so I've updated every usage of it in our code base. Further, this is purely optional function to be used, so the risk of making a change to it is minimal. 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: - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? - [ ] Does your PR title start with MINIFICPP- where is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. - [ ] Has your PR been rebased against the latest commit within the target branch (typically master)? - [ ] Is your initial contribution a single, squashed commit? ### For code changes: - [ ] 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)? - [ ] If applicable, have you updated the LICENSE file? - [ ] If applicable, have you updated the NOTICE file? ### For documentation related changes: - [ ] 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/phrocker/nifi-minifi-cpp MINIFICPP-691 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi-minifi-cpp/pull/457.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 #457 commit c3bcc1e4ec1a5665d3615fd55869fdaf9ebed53c Author: Marc Parisi Date: 2018-12-06T12:25:37Z MINIFICPP-691: Add method for getting processor description. Internal API change, but is strictly voluntary for contributors ---
[GitHub] nifi-minifi-cpp issue #448: MINIFICPP-682 - C API: provide functions to crea...
Github user phrocker commented on the issue: https://github.com/apache/nifi-minifi-cpp/pull/448 Also added https://issues.apache.org/jira/browse/MINIFICPP-695 since examples don't appear to work in testing. Merging anyway so we can fix that as a follow on ---
[GitHub] nifi-minifi-cpp pull request #448: MINIFICPP-682 - C API: provide functions ...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/448#discussion_r239481840 --- Diff: nanofi/include/api/nanofi.h --- @@ -165,6 +355,31 @@ uint8_t remove_attribute(flow_file_record*, char *key); int transmit_flowfile(flow_file_record *, nifi_instance *); +/** + * Adds a custom processor for later instantiation + * @param name name of the processor + * @param logic the callback to be invoked when the processor is triggered + * @return 0 on success, -1 otherwise (name already in use for eg.) + **/ +int add_custom_processor(const char * name, processor_logic* logic); --- End diff -- Typically the session can define a mapping of properties and can call a "scheduling" piece before every iteration. In some cases, this could be at the outset of execution of a custom processor. Effectively before their actions are invoked, the processor should be configured. We can make that stipulation a priori unless properties are dynamic, in which case we've sort of tabled that for the interim. MINIFICPP-694 is a good follow on to that. ---
[GitHub] nifi-minifi-cpp pull request #448: MINIFICPP-682 - C API: provide functions ...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/448#discussion_r239479166 --- Diff: nanofi/include/api/nanofi.h --- @@ -68,60 +94,173 @@ typedef int c2_start_callback(char *); void enable_async_c2(nifi_instance *, C2_Server *, c2_stop_callback *, c2_start_callback *, c2_update_callback *); +/** + * Creates a new, empty flow + * @param instance the instance new flow will belong to + * @return a pointer to the created flow + **/ +flow *create_new_flow(nifi_instance * instance); -uint8_t run_processor(const processor *processor); - -flow *create_new_flow(nifi_instance *); -flow *create_flow(nifi_instance *, const char *); +/** + * Creates new flow and adds the first processor in case a valid name is provided + * @deprecated as there is no proper indication of processor adding errors, + * usage of "create_new_flow" and "add_processor is recommended instead + * @param instance the instance new flow will belong to + * @param first_processor name of the first processor to be instanciated + * @attention in case first processor is empty or doesn't name any existing processor, an empty flow is returned. + * @return a pointer to the created flow + **/ +DEPRECATED flow *create_flow(nifi_instance * instance, const char * first_processor); -flow *create_getfile(nifi_instance *instance, flow *parent, GetFileConfig *c); +/** + * Add a getfile processor to "parent" flow. + * Creates new flow in instance in case "parent" is nullptr + * @deprecated as getfile processor can be added using "add_processor" function, + * properties can be set using "set_property". + * @param instance the instance the flow belongs to + * @param parent the flow to be extended with a new getfile processor + * @param c configuration of the new processor + * @return parent in case it wasn't null, otherwise a pointer to a new flow + */ +DEPRECATED flow *create_getfile(nifi_instance *instance, flow *parent, GetFileConfig *c); -processor *add_processor(flow *, const char *); +/** + * Extend a flow with a new processor + * @param flow the flow to be extended with the new processor + * @param name name of the new processor + * @return pointer to the new processor or nullptr in case it cannot be instantiated (wrong name?) + */ +processor *add_processor(flow * flow, const char * name); processor *add_python_processor(flow *, void (*ontrigger_callback)(processor_session *session)); -standalone_processor *create_processor(const char *); +/** + * Create a standalone instance of the given processor. + * Standalone instances can be invoked without having an instance/flow that contains them. + * @param name the name of the processor to instanciate + * @return pointer to the new processor or nullptr in case it cannot be instantiated (wrong name?) + **/ +standalone_processor *create_processor(const char * name); -void free_standalone_processor(standalone_processor*); +/** + * Free a standalone processor + * @param processor the processor to be freed + */ +void free_standalone_processor(standalone_processor* processor); /** -* Register your callback to received flow files that the flow failed to process -* The flow file ownership is transferred to the caller! -* The first callback should be registered before the flow is used. Can be changed later during runtime. -*/ + * Register your callback to received flow files that the flow failed to process + * The flow file ownership is transferred to the caller! + * The first callback should be registered before the flow is used. Can be changed later during runtime. + * @param flow flow the callback belongs to + * @param onerror_callback callback to execute in case of failure + * @return 0 in case of success, -1 otherwise (flow is already in use) + **/ int add_failure_callback(flow *flow, void (*onerror_callback)(flow_file_record*)); - /** -* Set failure strategy. Please use the enum defined in cstructs.h -* Return values: 0 (success), -1 (strategy cannot be set - no failure callback added?) -* Can be changed runtime. -* The defailt strategy is AS IS. -*/ + * Set failure strategy. Please use the enum defined in cstructs.h + * Can be changed runtime. + * The default strategy is AS IS. + * @param flow the flow to set strategy for + * @param strategy the strategy to be set + * @return 0 (success), -1 (strategy cannot be set - no failure callback added?) + **/ int set_failure_strategy(flow *flow, FailureStrategy strategy); -int set_property(processor *, con
[GitHub] nifi-minifi-cpp pull request #448: MINIFICPP-682 - C API: provide functions ...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/448#discussion_r239477701 --- Diff: nanofi/include/api/nanofi.h --- @@ -68,60 +94,173 @@ typedef int c2_start_callback(char *); void enable_async_c2(nifi_instance *, C2_Server *, c2_stop_callback *, c2_start_callback *, c2_update_callback *); +/** + * Creates a new, empty flow + * @param instance the instance new flow will belong to + * @return a pointer to the created flow + **/ +flow *create_new_flow(nifi_instance * instance); -uint8_t run_processor(const processor *processor); - -flow *create_new_flow(nifi_instance *); -flow *create_flow(nifi_instance *, const char *); +/** + * Creates new flow and adds the first processor in case a valid name is provided + * @deprecated as there is no proper indication of processor adding errors, --- End diff -- Could we not change it to return a null pointer? ---
[GitHub] nifi-minifi-cpp pull request #448: MINIFICPP-682 - C API: provide functions ...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/448#discussion_r239477181 --- Diff: nanofi/include/api/nanofi.h --- @@ -71,62 +94,173 @@ typedef int c2_start_callback(char *); void enable_async_c2(nifi_instance *, C2_Server *, c2_stop_callback *, c2_start_callback *, c2_update_callback *); +/** + * Creates a new, empty flow + * @param instance the instance new flow will belong to + * @return a pointer to the created flow + **/ +flow *create_new_flow(nifi_instance * instance); -uint8_t run_processor(const processor *processor); - -flow *create_new_flow(nifi_instance *); -flow *create_flow(nifi_instance *, const char *); +/** + * Creates new flow and adds the first processor in case a valid name is provided + * @deprecated as there is no proper indication of processor adding errors, + * usage of "create_new_flow" and "add_processor is recommended instead + * @param instance the instance new flow will belong to + * @param first_processor name of the first processor to be instanciated + * @attention in case first processor is empty or doesn't name any existing processor, an empty flow is returned. + * @return a pointer to the created flow + **/ +DEPRECATED flow *create_flow(nifi_instance * instance, const char * first_processor); -flow *create_getfile(nifi_instance *instance, flow *parent, GetFileConfig *c); +/** + * Add a getfile processor to "parent" flow. + * Creates new flow in instance in case "parent" is nullptr + * @deprecated as getfile processor can be added using "add_processor" function, + * properties can be set using "set_property". + * @param instance the instance the flow belongs to + * @param parent the flow to be extended with a new getfile processor + * @param c configuration of the new processor + * @return parent in case it wasn't null, otherwise a pointer to a new flow + */ +DEPRECATED flow *create_getfile(nifi_instance *instance, flow *parent, GetFileConfig *c); -processor *add_processor(flow *, const char *); +/** + * Extend a flow with a new processor + * @param flow the flow to be extended with the new processor + * @param name name of the new processor + * @return pointer to the new processor or nullptr in case it cannot be instantiated (wrong name?) + */ +processor *add_processor(flow * flow, const char * name); processor *add_python_processor(flow *, void (*ontrigger_callback)(processor_session *session)); -standalone_processor *create_processor(const char *); +/** + * Create a standalone instance of the given processor. + * Standalone instances can be invoked without having an instance/flow that contains them. + * @param name the name of the processor to instanciate + * @return pointer to the new processor or nullptr in case it cannot be instantiated (wrong name?) + **/ +standalone_processor *create_processor(const char * name); -void free_standalone_processor(standalone_processor*); +/** + * Free a standalone processor + * @param processor the processor to be freed + */ +void free_standalone_processor(standalone_processor* processor); /** -* Register your callback to received flow files that the flow failed to process -* The flow file ownership is transferred to the caller! -* The first callback should be registered before the flow is used. Can be changed later during runtime. -*/ + * Register your callback to received flow files that the flow failed to process + * The flow file ownership is transferred to the caller! + * The first callback should be registered before the flow is used. Can be changed later during runtime. + * @param flow flow the callback belongs to + * @param onerror_callback callback to execute in case of failure + * @return 0 in case of success, -1 otherwise (flow is already in use) + **/ int add_failure_callback(flow *flow, void (*onerror_callback)(flow_file_record*)); - /** -* Set failure strategy. Please use the enum defined in cstructs.h -* Return values: 0 (success), -1 (strategy cannot be set - no failure callback added?) -* Can be changed runtime. -* The default strategy is AS IS. -*/ + * Set failure strategy. Please use the enum defined in cstructs.h + * Can be changed runtime. + * The default strategy is AS IS. + * @param flow the flow to set strategy for + * @param strategy the strategy to be set + * @return 0 (success), -1 (strategy cannot be set - no failure callback added?) + **/ int set_failure_strategy(flow *flow, FailureStrategy strategy); -int set_property(processor *, con
[GitHub] nifi-minifi-cpp pull request #456: MINIFICPP-690: Correct log statement and ...
GitHub user phrocker opened a pull request: https://github.com/apache/nifi-minifi-cpp/pull/456 MINIFICPP-690: Correct log statement and regenerate docs 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: - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? - [ ] Does your PR title start with MINIFICPP- where is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. - [ ] Has your PR been rebased against the latest commit within the target branch (typically master)? - [ ] Is your initial contribution a single, squashed commit? ### For code changes: - [ ] 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)? - [ ] If applicable, have you updated the LICENSE file? - [ ] If applicable, have you updated the NOTICE file? ### For documentation related changes: - [ ] 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/phrocker/nifi-minifi-cpp MINIFICPP-690 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi-minifi-cpp/pull/456.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 #456 commit 3bd7eb12e5b05a4cd8df7f0f92aef44c0c1ad4d3 Author: Marc Parisi Date: 2018-12-06T12:04:59Z MINIFICPP-690: Correct log statement and regenerate docs ---
[GitHub] nifi-minifi-cpp pull request #455: MINIFICPP-689 - Make minifi::Exception co...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/455#discussion_r239144665 --- Diff: libminifi/include/Exception.h --- @@ -60,16 +60,17 @@ class Exception : public std::exception { public: // Constructor /*! - * Create a new flow record + * Create a new exception */ - Exception(ExceptionType type, const char *errorMsg) + Exception(ExceptionType type, std::string errorMsg) : _type(type), -_errorMsg(errorMsg) { +_errorMsg(std::move(errorMsg)) { --- End diff -- Ah yah. I don't remember either, but that sounds right If I don't see the warning when I run the build then all is well that ends well. Thanks. ---
[GitHub] nifi-minifi-cpp pull request #455: MINIFICPP-689 - Make minifi::Exception co...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/455#discussion_r239144107 --- Diff: libminifi/include/Exception.h --- @@ -60,16 +60,17 @@ class Exception : public std::exception { public: // Constructor /*! - * Create a new flow record + * Create a new exception */ - Exception(ExceptionType type, const char *errorMsg) + Exception(ExceptionType type, std::string errorMsg) : _type(type), -_errorMsg(errorMsg) { +_errorMsg(std::move(errorMsg)) { } + // Destructor - virtual ~Exception() throw () { + virtual ~Exception() noexcept { --- End diff -- I'm not sure how that applies to my comment...but I think the end result is that I will still run basic tests across compilers. Are you suggesting we needn't run tests for verification and validation? ---
[GitHub] nifi-minifi-cpp pull request #455: MINIFICPP-689 - Make minifi::Exception co...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/455#discussion_r239117109 --- Diff: libminifi/include/Exception.h --- @@ -60,16 +60,17 @@ class Exception : public std::exception { public: // Constructor /*! - * Create a new flow record + * Create a new exception */ - Exception(ExceptionType type, const char *errorMsg) + Exception(ExceptionType type, std::string errorMsg) : _type(type), -_errorMsg(errorMsg) { +_errorMsg(std::move(errorMsg)) { --- End diff -- Just saw this when I was typing the one below, I'll run the build before merging obviously, but does this not generate an elision warning? ---
[GitHub] nifi-minifi-cpp pull request #455: MINIFICPP-689 - Make minifi::Exception co...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/455#discussion_r239117254 --- Diff: libminifi/include/Exception.h --- @@ -60,16 +60,17 @@ class Exception : public std::exception { public: // Constructor /*! - * Create a new flow record + * Create a new exception */ - Exception(ExceptionType type, const char *errorMsg) + Exception(ExceptionType type, std::string errorMsg) : _type(type), -_errorMsg(errorMsg) { +_errorMsg(std::move(errorMsg)) { } + // Destructor - virtual ~Exception() throw () { + virtual ~Exception() noexcept { --- End diff -- I didn't notice that throw was here. Odd choice. The compiler usually generates an implicit noexcept unless told otherwise, so I'm tempted to do a little more testing of this across compilers. I'll do this before merge. ---
[GitHub] nifi-minifi-cpp pull request #448: MINIFICPP-682 - C API: provide functions ...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/448#discussion_r239109360 --- Diff: nanofi/include/api/nanofi.h --- @@ -165,6 +355,31 @@ uint8_t remove_attribute(flow_file_record*, char *key); int transmit_flowfile(flow_file_record *, nifi_instance *); +/** + * Adds a custom processor for later instantiation + * @param name name of the processor + * @param logic the callback to be invoked when the processor is triggered + * @return 0 on success, -1 otherwise (name already in use for eg.) + **/ +int add_custom_processor(const char * name, processor_logic* logic); --- End diff -- processor_logic doesn't encapsulate the potential of "scheduling" May want to keep that fundamentally so that we allow configuration items to be loaded only once. The Python code left that as a todo ---
[GitHub] nifi-minifi-cpp pull request #448: MINIFICPP-682 - C API: provide functions ...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/448#discussion_r239110104 --- Diff: nanofi/include/core/cstructs.h --- @@ -114,4 +126,6 @@ typedef enum FS { ROLLBACK } FailureStrategy; +typedef void (processor_logic)(processor_session*, processor_context *); --- End diff -- You have a comment, below, about accessing properties not being supported. Does that mean that processor_logic will go in tandem with processor configuration somehow? ---
[GitHub] nifi-minifi-cpp pull request #448: MINIFICPP-682 - C API: provide functions ...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/448#discussion_r239108187 --- Diff: nanofi/include/api/nanofi.h --- @@ -135,16 +274,62 @@ flow_file_record* create_ff_object(const char *file, const size_t len, const uin flow_file_record* create_ff_object_na(const char *file, const size_t len, const uint64_t size); -void free_flowfile(flow_file_record*); +/** + * Get incoming flow file. To be used in processor logic callbacks. + * @param session current processor session + * @param context current processor context + * @return a flow file record or nullptr in case there is none in the session + **/ +flow_file_record* get_flowfile(processor_session* session, processor_context* context); + + +/** + * Free flow file + * @param ff flow file + **/ +void free_flowfile(flow_file_record* ff); +/** + * Adds an attribute, fails in case there is already an attribute with the given key. + * @param ff flow file + * @param key name of attribute + * @param value location of value + * @size size size of the data pointed by "value" + * @return 0 in case of success, -1 otherwise (already existed) + **/ uint8_t add_attribute(flow_file_record*, const char *key, void *value, size_t size); -void update_attribute(flow_file_record*, const char *key, void *value, size_t size); +/** + * Updates an attribute (adds if it hasn't existed before) + * @param ff flow file + * @param key name of attribute + * @param value location of value + * @size size size of the data pointed by "value" + **/ +void update_attribute(flow_file_record* ff, const char *key, void *value, size_t size); -uint8_t get_attribute(flow_file_record *ff, attribute *caller_attribute); +/** + * Get the value of an attribute. Value and value size are written to parameter "caller_attribute" + * @param ff flow file + * @param caller_attribute attribute structure to provide name and get value, size + * @return 0 in case of success, -1 otherwise (no such attribute) + **/ +uint8_t get_attribute(const flow_file_record *ff, attribute *caller_attribute); +/** + * Get the quantity of attributes + * @param ff flow file + * @return the number of attributes + **/ int get_attribute_qty(const flow_file_record* ff); --- End diff -- I thought there was a ticket for this ( can't find it so maybe it was never made ?? ) but we shouldn't be using qty or similar within an API. This should be count or quantity. ---
[GitHub] nifi-minifi-cpp pull request #448: MINIFICPP-682 - C API: provide functions ...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/448#discussion_r239107724 --- Diff: nanofi/include/api/nanofi.h --- @@ -135,16 +274,62 @@ flow_file_record* create_ff_object(const char *file, const size_t len, const uin flow_file_record* create_ff_object_na(const char *file, const size_t len, const uint64_t size); -void free_flowfile(flow_file_record*); +/** + * Get incoming flow file. To be used in processor logic callbacks. + * @param session current processor session + * @param context current processor context + * @return a flow file record or nullptr in case there is none in the session + **/ +flow_file_record* get_flowfile(processor_session* session, processor_context* context); --- End diff -- So get has been replaced by get_flowfile ? Any reason we can't use this in python? ---
[GitHub] nifi-minifi-cpp pull request #448: MINIFICPP-682 - C API: provide functions ...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/448#discussion_r239106621 --- Diff: nanofi/include/api/nanofi.h --- @@ -68,60 +94,173 @@ typedef int c2_start_callback(char *); void enable_async_c2(nifi_instance *, C2_Server *, c2_stop_callback *, c2_start_callback *, c2_update_callback *); +/** + * Creates a new, empty flow + * @param instance the instance new flow will belong to + * @return a pointer to the created flow + **/ +flow *create_new_flow(nifi_instance * instance); -uint8_t run_processor(const processor *processor); - -flow *create_new_flow(nifi_instance *); -flow *create_flow(nifi_instance *, const char *); +/** + * Creates new flow and adds the first processor in case a valid name is provided + * @deprecated as there is no proper indication of processor adding errors, + * usage of "create_new_flow" and "add_processor is recommended instead + * @param instance the instance new flow will belong to + * @param first_processor name of the first processor to be instanciated + * @attention in case first processor is empty or doesn't name any existing processor, an empty flow is returned. + * @return a pointer to the created flow + **/ +DEPRECATED flow *create_flow(nifi_instance * instance, const char * first_processor); -flow *create_getfile(nifi_instance *instance, flow *parent, GetFileConfig *c); +/** + * Add a getfile processor to "parent" flow. + * Creates new flow in instance in case "parent" is nullptr + * @deprecated as getfile processor can be added using "add_processor" function, + * properties can be set using "set_property". + * @param instance the instance the flow belongs to + * @param parent the flow to be extended with a new getfile processor + * @param c configuration of the new processor + * @return parent in case it wasn't null, otherwise a pointer to a new flow + */ +DEPRECATED flow *create_getfile(nifi_instance *instance, flow *parent, GetFileConfig *c); -processor *add_processor(flow *, const char *); +/** + * Extend a flow with a new processor + * @param flow the flow to be extended with the new processor + * @param name name of the new processor + * @return pointer to the new processor or nullptr in case it cannot be instantiated (wrong name?) + */ +processor *add_processor(flow * flow, const char * name); processor *add_python_processor(flow *, void (*ontrigger_callback)(processor_session *session)); -standalone_processor *create_processor(const char *); +/** + * Create a standalone instance of the given processor. + * Standalone instances can be invoked without having an instance/flow that contains them. + * @param name the name of the processor to instanciate + * @return pointer to the new processor or nullptr in case it cannot be instantiated (wrong name?) + **/ +standalone_processor *create_processor(const char * name); -void free_standalone_processor(standalone_processor*); +/** + * Free a standalone processor + * @param processor the processor to be freed + */ +void free_standalone_processor(standalone_processor* processor); /** -* Register your callback to received flow files that the flow failed to process -* The flow file ownership is transferred to the caller! -* The first callback should be registered before the flow is used. Can be changed later during runtime. -*/ + * Register your callback to received flow files that the flow failed to process + * The flow file ownership is transferred to the caller! + * The first callback should be registered before the flow is used. Can be changed later during runtime. + * @param flow flow the callback belongs to + * @param onerror_callback callback to execute in case of failure + * @return 0 in case of success, -1 otherwise (flow is already in use) + **/ int add_failure_callback(flow *flow, void (*onerror_callback)(flow_file_record*)); - /** -* Set failure strategy. Please use the enum defined in cstructs.h -* Return values: 0 (success), -1 (strategy cannot be set - no failure callback added?) -* Can be changed runtime. -* The defailt strategy is AS IS. -*/ + * Set failure strategy. Please use the enum defined in cstructs.h + * Can be changed runtime. + * The default strategy is AS IS. + * @param flow the flow to set strategy for + * @param strategy the strategy to be set + * @return 0 (success), -1 (strategy cannot be set - no failure callback added?) + **/ int set_failure_strategy(flow *flow, FailureStrategy strategy); -int set_property(processor *, con
[GitHub] nifi-minifi-cpp pull request #448: MINIFICPP-682 - C API: provide functions ...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/448#discussion_r239107442 --- Diff: nanofi/include/api/nanofi.h --- @@ -68,60 +94,173 @@ typedef int c2_start_callback(char *); void enable_async_c2(nifi_instance *, C2_Server *, c2_stop_callback *, c2_start_callback *, c2_update_callback *); +/** + * Creates a new, empty flow + * @param instance the instance new flow will belong to + * @return a pointer to the created flow + **/ +flow *create_new_flow(nifi_instance * instance); -uint8_t run_processor(const processor *processor); - -flow *create_new_flow(nifi_instance *); -flow *create_flow(nifi_instance *, const char *); +/** + * Creates new flow and adds the first processor in case a valid name is provided + * @deprecated as there is no proper indication of processor adding errors, + * usage of "create_new_flow" and "add_processor is recommended instead + * @param instance the instance new flow will belong to + * @param first_processor name of the first processor to be instanciated + * @attention in case first processor is empty or doesn't name any existing processor, an empty flow is returned. + * @return a pointer to the created flow + **/ +DEPRECATED flow *create_flow(nifi_instance * instance, const char * first_processor); -flow *create_getfile(nifi_instance *instance, flow *parent, GetFileConfig *c); +/** + * Add a getfile processor to "parent" flow. + * Creates new flow in instance in case "parent" is nullptr + * @deprecated as getfile processor can be added using "add_processor" function, + * properties can be set using "set_property". + * @param instance the instance the flow belongs to + * @param parent the flow to be extended with a new getfile processor + * @param c configuration of the new processor + * @return parent in case it wasn't null, otherwise a pointer to a new flow + */ +DEPRECATED flow *create_getfile(nifi_instance *instance, flow *parent, GetFileConfig *c); -processor *add_processor(flow *, const char *); +/** + * Extend a flow with a new processor + * @param flow the flow to be extended with the new processor + * @param name name of the new processor + * @return pointer to the new processor or nullptr in case it cannot be instantiated (wrong name?) + */ +processor *add_processor(flow * flow, const char * name); processor *add_python_processor(flow *, void (*ontrigger_callback)(processor_session *session)); -standalone_processor *create_processor(const char *); +/** + * Create a standalone instance of the given processor. + * Standalone instances can be invoked without having an instance/flow that contains them. + * @param name the name of the processor to instanciate + * @return pointer to the new processor or nullptr in case it cannot be instantiated (wrong name?) + **/ +standalone_processor *create_processor(const char * name); -void free_standalone_processor(standalone_processor*); +/** + * Free a standalone processor + * @param processor the processor to be freed + */ +void free_standalone_processor(standalone_processor* processor); /** -* Register your callback to received flow files that the flow failed to process -* The flow file ownership is transferred to the caller! -* The first callback should be registered before the flow is used. Can be changed later during runtime. -*/ + * Register your callback to received flow files that the flow failed to process + * The flow file ownership is transferred to the caller! + * The first callback should be registered before the flow is used. Can be changed later during runtime. + * @param flow flow the callback belongs to + * @param onerror_callback callback to execute in case of failure + * @return 0 in case of success, -1 otherwise (flow is already in use) + **/ int add_failure_callback(flow *flow, void (*onerror_callback)(flow_file_record*)); - /** -* Set failure strategy. Please use the enum defined in cstructs.h -* Return values: 0 (success), -1 (strategy cannot be set - no failure callback added?) -* Can be changed runtime. -* The defailt strategy is AS IS. -*/ + * Set failure strategy. Please use the enum defined in cstructs.h + * Can be changed runtime. + * The default strategy is AS IS. + * @param flow the flow to set strategy for + * @param strategy the strategy to be set + * @return 0 (success), -1 (strategy cannot be set - no failure callback added?) + **/ int set_failure_strategy(flow *flow, FailureStrategy strategy); -int set_property(processor *, con
[GitHub] nifi-minifi-cpp pull request #448: MINIFICPP-682 - C API: provide functions ...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/448#discussion_r239105538 --- Diff: nanofi/include/api/nanofi.h --- @@ -68,60 +94,173 @@ typedef int c2_start_callback(char *); void enable_async_c2(nifi_instance *, C2_Server *, c2_stop_callback *, c2_start_callback *, c2_update_callback *); +/** + * Creates a new, empty flow + * @param instance the instance new flow will belong to + * @return a pointer to the created flow + **/ +flow *create_new_flow(nifi_instance * instance); -uint8_t run_processor(const processor *processor); - -flow *create_new_flow(nifi_instance *); -flow *create_flow(nifi_instance *, const char *); +/** + * Creates new flow and adds the first processor in case a valid name is provided + * @deprecated as there is no proper indication of processor adding errors, + * usage of "create_new_flow" and "add_processor is recommended instead + * @param instance the instance new flow will belong to + * @param first_processor name of the first processor to be instanciated + * @attention in case first processor is empty or doesn't name any existing processor, an empty flow is returned. + * @return a pointer to the created flow + **/ +DEPRECATED flow *create_flow(nifi_instance * instance, const char * first_processor); -flow *create_getfile(nifi_instance *instance, flow *parent, GetFileConfig *c); +/** + * Add a getfile processor to "parent" flow. + * Creates new flow in instance in case "parent" is nullptr + * @deprecated as getfile processor can be added using "add_processor" function, + * properties can be set using "set_property". + * @param instance the instance the flow belongs to + * @param parent the flow to be extended with a new getfile processor + * @param c configuration of the new processor + * @return parent in case it wasn't null, otherwise a pointer to a new flow + */ +DEPRECATED flow *create_getfile(nifi_instance *instance, flow *parent, GetFileConfig *c); -processor *add_processor(flow *, const char *); +/** + * Extend a flow with a new processor + * @param flow the flow to be extended with the new processor + * @param name name of the new processor + * @return pointer to the new processor or nullptr in case it cannot be instantiated (wrong name?) + */ +processor *add_processor(flow * flow, const char * name); processor *add_python_processor(flow *, void (*ontrigger_callback)(processor_session *session)); -standalone_processor *create_processor(const char *); +/** + * Create a standalone instance of the given processor. + * Standalone instances can be invoked without having an instance/flow that contains them. + * @param name the name of the processor to instanciate + * @return pointer to the new processor or nullptr in case it cannot be instantiated (wrong name?) + **/ +standalone_processor *create_processor(const char * name); -void free_standalone_processor(standalone_processor*); +/** + * Free a standalone processor + * @param processor the processor to be freed + */ +void free_standalone_processor(standalone_processor* processor); /** -* Register your callback to received flow files that the flow failed to process -* The flow file ownership is transferred to the caller! -* The first callback should be registered before the flow is used. Can be changed later during runtime. -*/ + * Register your callback to received flow files that the flow failed to process + * The flow file ownership is transferred to the caller! --- End diff -- "transferred to the caller" of the callback or of this function? ---
[GitHub] nifi-minifi-cpp pull request #448: MINIFICPP-682 - C API: provide functions ...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/448#discussion_r239106929 --- Diff: nanofi/include/api/nanofi.h --- @@ -71,62 +94,173 @@ typedef int c2_start_callback(char *); void enable_async_c2(nifi_instance *, C2_Server *, c2_stop_callback *, c2_start_callback *, c2_update_callback *); +/** + * Creates a new, empty flow + * @param instance the instance new flow will belong to + * @return a pointer to the created flow + **/ +flow *create_new_flow(nifi_instance * instance); -uint8_t run_processor(const processor *processor); - -flow *create_new_flow(nifi_instance *); -flow *create_flow(nifi_instance *, const char *); +/** + * Creates new flow and adds the first processor in case a valid name is provided + * @deprecated as there is no proper indication of processor adding errors, + * usage of "create_new_flow" and "add_processor is recommended instead + * @param instance the instance new flow will belong to + * @param first_processor name of the first processor to be instanciated + * @attention in case first processor is empty or doesn't name any existing processor, an empty flow is returned. + * @return a pointer to the created flow + **/ +DEPRECATED flow *create_flow(nifi_instance * instance, const char * first_processor); -flow *create_getfile(nifi_instance *instance, flow *parent, GetFileConfig *c); +/** + * Add a getfile processor to "parent" flow. + * Creates new flow in instance in case "parent" is nullptr + * @deprecated as getfile processor can be added using "add_processor" function, + * properties can be set using "set_property". + * @param instance the instance the flow belongs to + * @param parent the flow to be extended with a new getfile processor + * @param c configuration of the new processor + * @return parent in case it wasn't null, otherwise a pointer to a new flow + */ +DEPRECATED flow *create_getfile(nifi_instance *instance, flow *parent, GetFileConfig *c); -processor *add_processor(flow *, const char *); +/** + * Extend a flow with a new processor + * @param flow the flow to be extended with the new processor + * @param name name of the new processor + * @return pointer to the new processor or nullptr in case it cannot be instantiated (wrong name?) + */ +processor *add_processor(flow * flow, const char * name); processor *add_python_processor(flow *, void (*ontrigger_callback)(processor_session *session)); -standalone_processor *create_processor(const char *); +/** + * Create a standalone instance of the given processor. + * Standalone instances can be invoked without having an instance/flow that contains them. + * @param name the name of the processor to instanciate + * @return pointer to the new processor or nullptr in case it cannot be instantiated (wrong name?) + **/ +standalone_processor *create_processor(const char * name); -void free_standalone_processor(standalone_processor*); +/** + * Free a standalone processor + * @param processor the processor to be freed + */ +void free_standalone_processor(standalone_processor* processor); /** -* Register your callback to received flow files that the flow failed to process -* The flow file ownership is transferred to the caller! -* The first callback should be registered before the flow is used. Can be changed later during runtime. -*/ + * Register your callback to received flow files that the flow failed to process + * The flow file ownership is transferred to the caller! + * The first callback should be registered before the flow is used. Can be changed later during runtime. + * @param flow flow the callback belongs to + * @param onerror_callback callback to execute in case of failure + * @return 0 in case of success, -1 otherwise (flow is already in use) + **/ int add_failure_callback(flow *flow, void (*onerror_callback)(flow_file_record*)); - /** -* Set failure strategy. Please use the enum defined in cstructs.h -* Return values: 0 (success), -1 (strategy cannot be set - no failure callback added?) -* Can be changed runtime. -* The default strategy is AS IS. -*/ + * Set failure strategy. Please use the enum defined in cstructs.h + * Can be changed runtime. + * The default strategy is AS IS. + * @param flow the flow to set strategy for + * @param strategy the strategy to be set + * @return 0 (success), -1 (strategy cannot be set - no failure callback added?) + **/ int set_failure_strategy(flow *flow, FailureStrategy strategy); -int set_property(processor *, con
[GitHub] nifi-minifi-cpp pull request #448: MINIFICPP-682 - C API: provide functions ...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/448#discussion_r239105138 --- Diff: nanofi/include/api/nanofi.h --- @@ -71,62 +94,173 @@ typedef int c2_start_callback(char *); void enable_async_c2(nifi_instance *, C2_Server *, c2_stop_callback *, c2_start_callback *, c2_update_callback *); +/** + * Creates a new, empty flow + * @param instance the instance new flow will belong to + * @return a pointer to the created flow + **/ +flow *create_new_flow(nifi_instance * instance); -uint8_t run_processor(const processor *processor); - -flow *create_new_flow(nifi_instance *); -flow *create_flow(nifi_instance *, const char *); +/** + * Creates new flow and adds the first processor in case a valid name is provided + * @deprecated as there is no proper indication of processor adding errors, + * usage of "create_new_flow" and "add_processor is recommended instead + * @param instance the instance new flow will belong to + * @param first_processor name of the first processor to be instanciated + * @attention in case first processor is empty or doesn't name any existing processor, an empty flow is returned. + * @return a pointer to the created flow + **/ +DEPRECATED flow *create_flow(nifi_instance * instance, const char * first_processor); -flow *create_getfile(nifi_instance *instance, flow *parent, GetFileConfig *c); +/** + * Add a getfile processor to "parent" flow. + * Creates new flow in instance in case "parent" is nullptr + * @deprecated as getfile processor can be added using "add_processor" function, + * properties can be set using "set_property". + * @param instance the instance the flow belongs to + * @param parent the flow to be extended with a new getfile processor + * @param c configuration of the new processor + * @return parent in case it wasn't null, otherwise a pointer to a new flow + */ +DEPRECATED flow *create_getfile(nifi_instance *instance, flow *parent, GetFileConfig *c); -processor *add_processor(flow *, const char *); +/** + * Extend a flow with a new processor + * @param flow the flow to be extended with the new processor + * @param name name of the new processor + * @return pointer to the new processor or nullptr in case it cannot be instantiated (wrong name?) + */ +processor *add_processor(flow * flow, const char * name); processor *add_python_processor(flow *, void (*ontrigger_callback)(processor_session *session)); --- End diff -- This was starved off due to other work, but we will eventually need directory specific accessor functions for languages , I would imagine. This could be a candidate for that. ---
[GitHub] nifi-minifi-cpp pull request #448: MINIFICPP-682 - C API: provide functions ...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/448#discussion_r239103770 --- Diff: nanofi/include/api/nanofi.h --- @@ -68,60 +94,173 @@ typedef int c2_start_callback(char *); void enable_async_c2(nifi_instance *, C2_Server *, c2_stop_callback *, c2_start_callback *, c2_update_callback *); +/** + * Creates a new, empty flow + * @param instance the instance new flow will belong to + * @return a pointer to the created flow + **/ +flow *create_new_flow(nifi_instance * instance); -uint8_t run_processor(const processor *processor); - -flow *create_new_flow(nifi_instance *); -flow *create_flow(nifi_instance *, const char *); +/** + * Creates new flow and adds the first processor in case a valid name is provided + * @deprecated as there is no proper indication of processor adding errors, --- End diff -- I'm unclear about deprecation. Does this mean that it's deprecated because you have no way of indicating the processor could not be instantiated? Wouldn't that arrive at the case where flow is null? Flow in create_new_flow could be null by virtue of a malloc error, so why deprecate a function that results in the same behavior and fewer function calls? ---
[GitHub] nifi-minifi-cpp pull request #448: MINIFICPP-682 - C API: provide functions ...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/448#discussion_r239104013 --- Diff: nanofi/include/api/nanofi.h --- @@ -68,60 +94,173 @@ typedef int c2_start_callback(char *); void enable_async_c2(nifi_instance *, C2_Server *, c2_stop_callback *, c2_start_callback *, c2_update_callback *); +/** + * Creates a new, empty flow + * @param instance the instance new flow will belong to + * @return a pointer to the created flow + **/ +flow *create_new_flow(nifi_instance * instance); -uint8_t run_processor(const processor *processor); - -flow *create_new_flow(nifi_instance *); -flow *create_flow(nifi_instance *, const char *); +/** + * Creates new flow and adds the first processor in case a valid name is provided + * @deprecated as there is no proper indication of processor adding errors, + * usage of "create_new_flow" and "add_processor is recommended instead + * @param instance the instance new flow will belong to + * @param first_processor name of the first processor to be instanciated + * @attention in case first processor is empty or doesn't name any existing processor, an empty flow is returned. + * @return a pointer to the created flow + **/ +DEPRECATED flow *create_flow(nifi_instance * instance, const char * first_processor); -flow *create_getfile(nifi_instance *instance, flow *parent, GetFileConfig *c); +/** + * Add a getfile processor to "parent" flow. + * Creates new flow in instance in case "parent" is nullptr + * @deprecated as getfile processor can be added using "add_processor" function, --- End diff -- This is precisely something we want to keep by design. Let's talk about this before merging this. ---
[GitHub] nifi-minifi-cpp issue #448: MINIFICPP-682 - C API: provide functions to crea...
Github user phrocker commented on the issue: https://github.com/apache/nifi-minifi-cpp/pull/448 taking a look ---
[GitHub] nifi-minifi-cpp pull request #454: MINIFICPP-404: Correct invalid assumption...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/454#discussion_r239092725 --- Diff: libminifi/src/core/yaml/YamlConfiguration.cpp --- @@ -325,6 +325,12 @@ void YamlConfiguration::parseRemoteProcessGroupYaml(YAML::Node *rpgNode, core::P } } } + } else if (transport_protocol == "RAW") { +group->setTransportProtocol(transport_protocol); + } else { +std::stringstream stream; +stream << "Invalid transport protocol " << transport_protocol; +throw minifi::Exception(ExceptionType::SITE2SITE_EXCEPTION, stream.str().c_str()); --- End diff -- I think it's vestigial (existed since the early days of the project )-- no reason, just no desire to make changes that require unnecessary classes to change in this PR. If someone said, "it has to be done to approve," I'd go ahead and do it but a follow on PR like the one you made is perfect. ---
[GitHub] nifi-minifi-cpp pull request #454: MINIFICPP-404: Correct invalid assumption...
GitHub user phrocker opened a pull request: https://github.com/apache/nifi-minifi-cpp/pull/454 MINIFICPP-404: Correct invalid assumption and protect against invalid⦠⦠protocols 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: - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? - [ ] Does your PR title start with MINIFICPP- where is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. - [ ] Has your PR been rebased against the latest commit within the target branch (typically master)? - [ ] Is your initial contribution a single, squashed commit? ### For code changes: - [ ] 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)? - [ ] If applicable, have you updated the LICENSE file? - [ ] If applicable, have you updated the NOTICE file? ### For documentation related changes: - [ ] 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/phrocker/nifi-minifi-cpp MINIFICPP-404 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi-minifi-cpp/pull/454.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 #454 commit 8c08f31273f72f37bf640d27ea52c5821e98a8d4 Author: Marc Parisi Date: 2018-12-03T18:14:26Z MINIFICPP-404: Correct invalid assumption and protect against invalid protocols ---
[GitHub] nifi-minifi-cpp pull request #:
Github user phrocker commented on the pull request: https://github.com/apache/nifi-minifi-cpp/commit/4cc6702a9841ca7441a9553080f81b148daac2fc#commitcomment-31523402 I just skimmed the latest commit. Really good stuff. This will go a long way toward helping consumers of this API. Very excited! Is this ready for review? If so I'll try to two a look this weekend sometime. Thanks! ---
[GitHub] nifi-minifi-cpp issue #453: POF: static property improvements
Github user phrocker commented on the issue: https://github.com/apache/nifi-minifi-cpp/pull/453 Thanks for submitting this. I think there is definite overlap between work I previously had with MINIFICPP-479 (https://github.com/apache/nifi-minifi-cpp/compare/master...phrocker:MINIFICPP-479?expand=1) I collected commits from across computers and squashed them, but has the side effect that it does validation at flow file load time ( something we've desperately needed) -- giving us a much earlier failure. a bit different implementation -- and it informs c2 of java validators to be used. what is the motivation of this PR beyond that work that we discussed offline? I think the same "pros" exist for both works. That work has been around since June -- so it's probably stale in its ideas, so I'll take a look at this at some point. Thanks again. ---
[GitHub] nifi-minifi-cpp pull request #448: MINIFICPP-682 - C API: provide functions ...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/448#discussion_r237139770 --- Diff: nanofi/src/api/nanofi.cpp --- @@ -223,13 +226,15 @@ void free_flowfile(flow_file_record *ff) { return; } auto content_repo_ptr = static_cast*>(ff->crp); - if (content_repo_ptr->get()) { + if (content_repo_ptr->get() && (ff->keepContent == 0)) { --- End diff -- Yeah that seems like it could cause issues when freeing the flow file, but if they were to do all of this, this means that they've either threaded the reads of content or are calling free in the middle of accessing that content? I think it's reasonable for each read to "keep the content" because it's not the owner. A better way might be to use the reference counting in ResourceClaim but we don't presently have that since we make new claim objects. I think what you've done is not unreasonable. ---
[GitHub] nifi-minifi-cpp pull request #445: MINIFICPP-681 - Add content hash processo...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/445#discussion_r237058367 --- Diff: libminifi/src/processors/ContentHash.cpp --- @@ -0,0 +1,100 @@ +/** + * @file ContentHash.cpp + * ContentHash 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. + */ + +#ifdef OPENSSL_SUPPORT + +#include +#include +#include +#include +#include "processors/ContentHash.h" +#include "core/ProcessContext.h" +#include "core/ProcessSession.h" +#include "core/FlowFile.h" + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace processors { + +core::Property ContentHash::HashAttribute("Hash Attribute", "Attribute to store checksum to", "Checksum"); +core::Property ContentHash::HashAlgorithm("Hash Algorithm", "Name of the algorithm used to generate checksum", "MD5"); +core::Relationship ContentHash::Success("success", "success operational on the flow record"); + +void ContentHash::initialize() { + //! Set the supported properties + std::set properties; + properties.insert(HashAttribute); + properties.insert(HashAlgorithm); + setSupportedProperties(properties); + //! Set the supported relationships + std::set relationships; + relationships.insert(Success); + setSupportedRelationships(relationships); +} + +void ContentHash::onTrigger(core::ProcessContext *context, core::ProcessSession *session) { + std::shared_ptr flowFile = session->get(); + + if (!flowFile) { +return; + } + + ReadCallback cb(flowFile, context); + session->read(flowFile, ); + session->transfer(flowFile, Success); +} + +int64_t ContentHash::ReadCallback::process(std::shared_ptr stream) { + std::string attrKey, algoName; + ctx_->getProperty(HashAttribute.getName(), attrKey); + ctx_->getProperty(HashAlgorithm.getName(), algoName); + std::transform(algoName.begin(), algoName.end(), algoName.begin(), ::toupper); + + // Erase '-' to make sha-256 and sha-2 work, too + algoName.erase(std::remove(algoName.begin(), algoName.end(), '-'), algoName.end()); + + // This throws in case algo is not found, but that's fine --- End diff -- Failure is a generic term and is generally up to the independent processor to define -- your definition is not true across all processors in NiFi, so I'm fine leaving that up to the author to decide in this case; however, if the empty content case accounted for within the processor? Some have perceived empty content hashing as a potential failure case. Can make that a follow on task, though, but we should probably reach parity with NiFI eventually ---
[GitHub] nifi-minifi-cpp pull request #445: MINIFICPP-681 - Add content hash processo...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/445#discussion_r237057728 --- Diff: libminifi/src/processors/HashContent.cpp --- @@ -0,0 +1,100 @@ +/** + * @file HashContent.cpp + * HashContent 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. + */ + +#ifdef OPENSSL_SUPPORT + +#include +#include +#include +#include +#include "processors/HashContent.h" +#include "core/ProcessContext.h" +#include "core/ProcessSession.h" +#include "core/FlowFile.h" + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace processors { + +core::Property HashContent::HashAttribute("Hash Attribute", "Attribute to store checksum to", "Checksum"); +core::Property HashContent::HashAlgorithm("Hash Algorithm", "Name of the algorithm used to generate checksum", "MD5"); +core::Relationship HashContent::Success("success", "success operational on the flow record"); + +void HashContent::initialize() { + //! Set the supported properties + std::set properties; + properties.insert(HashAttribute); + properties.insert(HashAlgorithm); + setSupportedProperties(properties); + //! Set the supported relationships + std::set relationships; + relationships.insert(Success); + setSupportedRelationships(relationships); +} + +void HashContent::onSchedule(core::ProcessContext *context, core::ProcessSessionFactory *sessionFactory) { + std::string value; + + attrKey_ = (context->getProperty(HashAttribute.getName(), value)) ? value : "Checksum"; + algoName_ = (context->getProperty(HashAlgorithm.getName(), value)) ? value : "MD5"; --- End diff -- I'm not sure that's "low power friendly," but they can deal with that through configuration. ---
[GitHub] nifi-minifi-cpp pull request #445: MINIFICPP-681 - Add content hash processo...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/445#discussion_r237057613 --- Diff: libminifi/src/processors/HashContent.cpp --- @@ -0,0 +1,100 @@ +/** + * @file HashContent.cpp + * HashContent 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. + */ + +#ifdef OPENSSL_SUPPORT + +#include +#include +#include +#include +#include "processors/HashContent.h" +#include "core/ProcessContext.h" +#include "core/ProcessSession.h" +#include "core/FlowFile.h" + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace processors { + +core::Property HashContent::HashAttribute("Hash Attribute", "Attribute to store checksum to", "Checksum"); +core::Property HashContent::HashAlgorithm("Hash Algorithm", "Name of the algorithm used to generate checksum", "MD5"); +core::Relationship HashContent::Success("success", "success operational on the flow record"); + +void HashContent::initialize() { + //! Set the supported properties + std::set properties; + properties.insert(HashAttribute); + properties.insert(HashAlgorithm); + setSupportedProperties(properties); + //! Set the supported relationships + std::set relationships; + relationships.insert(Success); + setSupportedRelationships(relationships); +} + +void HashContent::onSchedule(core::ProcessContext *context, core::ProcessSessionFactory *sessionFactory) { + std::string value; + + attrKey_ = (context->getProperty(HashAttribute.getName(), value)) ? value : "Checksum"; + algoName_ = (context->getProperty(HashAlgorithm.getName(), value)) ? value : "MD5"; --- End diff -- Default should probably be sha-256. I believe NiFi has transitioned to this. ---
[GitHub] nifi-minifi-cpp pull request #445: MINIFICPP-681 - Add content hash processo...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/445#discussion_r237056704 --- Diff: libminifi/include/processors/HashContent.h --- @@ -0,0 +1,196 @@ +/** + * @file HashContent.h + * HashContent class declaration + * + * 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. + */ +#ifndef NIFI_MINIFI_CPP_HashContent_H +#define NIFI_MINIFI_CPP_HashContent_H + +#ifdef OPENSSL_SUPPORT + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "FlowFileRecord.h" +#include "core/Processor.h" +#include "core/ProcessSession.h" +#include "core/Resource.h" +#include "io/BaseStream.h" + +using HashReturnType = std::pair; + +namespace { +#define HASH_BUFFER_SIZE 16384 + + std::string digestToString(const unsigned char * const digest, size_t size) { +std::stringstream ss; +for(int i = 0; i < size; i++) +{ + ss << std::uppercase << std::hex << std::setw(2) << std::setfill('0') << (int)digest[i]; +} +return ss.str(); + } + + HashReturnType MD5Hash(const std::shared_ptr& stream) { +HashReturnType ret_val; +ret_val.second = 0; +uint8_t buffer[HASH_BUFFER_SIZE]; +MD5_CTX context; +MD5_Init(); + +size_t ret = 0; +do { + ret = stream->readData(buffer, HASH_BUFFER_SIZE); + if(ret > 0) { +MD5_Update(, buffer, ret); +ret_val.second += ret; + } +} while(ret > 0); + +if (ret_val.second > 0) { + unsigned char digest[MD5_DIGEST_LENGTH]; + MD5_Final(digest, ); + ret_val.first = digestToString(digest, MD5_DIGEST_LENGTH); +} +return ret_val; + } + + HashReturnType SHA1Hash(const std::shared_ptr& stream) { +HashReturnType ret_val; +ret_val.second = 0; +uint8_t buffer[HASH_BUFFER_SIZE]; +SHA_CTX context; +SHA1_Init(); + +size_t ret = 0; +do { + ret = stream->readData(buffer, HASH_BUFFER_SIZE); + if(ret > 0) { +SHA1_Update(, buffer, ret); +ret_val.second += ret; + } +} while(ret > 0); + +if (ret_val.second > 0) { + unsigned char digest[SHA_DIGEST_LENGTH]; + SHA1_Final(digest, ); + ret_val.first = digestToString(digest, SHA_DIGEST_LENGTH); +} +return ret_val; + } + + HashReturnType SHA256Hash(const std::shared_ptr& stream) { +HashReturnType ret_val; +ret_val.second = 0; +uint8_t buffer[HASH_BUFFER_SIZE]; +SHA256_CTX context; +SHA256_Init(); + +size_t ret ; +do { + ret = stream->readData(buffer, HASH_BUFFER_SIZE); + if(ret > 0) { +SHA256_Update(, buffer, ret); +ret_val.second += ret; + } +} while(ret > 0); + +if (ret_val.second > 0) { + unsigned char digest[SHA256_DIGEST_LENGTH]; + SHA256_Final(digest, ); + ret_val.first = digestToString(digest, SHA256_DIGEST_LENGTH); +} +return ret_val; + } +} + + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace processors { + +static const std::map&)>> HashAlgos = + { {"MD5", MD5Hash}, {"SHA1", SHA1Hash}, {"SHA256", SHA256Hash} }; + +//! HashContent Class +class HashContent : public core::Processor { + public: + //! Constructor + /*! + * Create a new processor + */ + explicit HashContent(std::string name, utils::Identifier uuid = utils::Identifier()) + : Processor(name, uuid) + { +logger_ = logging::LoggerFactory
[GitHub] nifi-minifi-cpp issue #446: MINIFICPP-684 - ExtractText processor doesn't ha...
Github user phrocker commented on the issue: https://github.com/apache/nifi-minifi-cpp/pull/446 > > @arpadboda I'll update the commit on merge to what was intended if you don't have a chance to in the next few minutes. > > Done. I had some issues with pushing to apache's git servers last week. Will try again today, sorry for the delay. ---
[GitHub] nifi-minifi-cpp pull request #449: MINIFICPP-685 - Improve const correctness...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/449#discussion_r236664502 --- Diff: libminifi/include/core/ConfigurableComponent.h --- @@ -153,14 +153,14 @@ class ConfigurableComponent { * * @return vector of property keys */ - std::vector getDynamicPropertyKeys(); + std::vector getDynamicPropertyKeys() const; /** * Returns a vector all properties * * @return map of property keys to Property instances. */ - std::map getProperties(); + std::map getProperties() const; --- End diff -- Did you not change to const ref map because current implementations expect to modify this map? ---
[GitHub] nifi-minifi-cpp pull request #447: MINIFICPP-558: initial provisioning for C...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/447#discussion_r235487951 --- Diff: extensions/coap/controllerservice/CoapConnector.cpp --- @@ -0,0 +1,97 @@ +/** + * + * 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 "CoapConnector.h" + +#include "core/logging/LoggerConfiguration.h" +#include "core/controller/ControllerService.h" +#include +#include +#include +#include "core/Property.h" +#include "CoapConnector.h" +#include "io/validation.h" +#include "properties/Configure.h" + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace coap { +namespace controllers { + +static core::Property RemoteServer; +static core::Property Port; +static core::Property MaxQueueSize; + +core::Property CoapConnectorService::RemoteServer(core::PropertyBuilder::createProperty("Remote Server")->withDescription("Remote CoAP server")->isRequired(true)->build()); +core::Property CoapConnectorService::Port(core::PropertyBuilder::createProperty("Remote Port")->withDescription("Remote CoAP server port")->isRequired(true)->build()); +core::Property CoapConnectorService::MaxQueueSize(core::PropertyBuilder::createProperty("Max Queue Size")->withDescription("Max queue size for received data ")->isRequired(true)->build()); + +void CoapConnectorService::initialize() { + if (initialized_) +return; + + CoapMessaging::getInstance(); --- End diff -- Mixed casing of CoAP and coap is quite confusing and hard to follow. ---
[GitHub] nifi-minifi-cpp pull request #447: MINIFICPP-558: initial provisioning for C...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/447#discussion_r235480882 --- Diff: extensions/coap/COAPLoader.h --- @@ -0,0 +1,81 @@ +/** + * + * 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. + */ +#ifndef EXTENSIONS_COAPLOADER_H_ +#define EXTENSIONS_COAPLOADER_H_ + +#ifdef WIN32 +#pragma comment(lib, "wldap32.lib" ) +#pragma comment(lib, "crypt32.lib" ) +#pragma comment(lib, "Ws2_32.lib") +#endif + +#include "core/ClassLoader.h" +#include "utils/StringUtils.h" +#include "protocols/CoapC2Protocol.h" + +/** + * Object factory class loader for this extension. + * Can add extensions to the default class loader through REGISTER_RESOURCE, + * but we want to ensure this factory is used specifically for CoAP and not the default loader. + */ +class COAPObjectFactory : public core::ObjectFactory { + public: + COAPObjectFactory() { + + } + + /** + * Gets the name of the object. + * @return class name of processor + */ + virtual std::string getName() override{ +return "COAPObjectFactory"; + } + + virtual std::string getClassName() override{ +return "COAPObjectFactory"; + } + /** + * Gets the class name for the object + * @return class name for the processor. + */ + virtual std::vector getClassNames() override{ +std::vector class_names; +class_names.push_back("CoapProtocol"); --- End diff -- May want to make CoapServer accessible. ---
[GitHub] nifi-minifi-cpp pull request #447: MINIFICPP-558: initial provisioning for C...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/447#discussion_r235480740 --- Diff: extensions/coap/CMakeLists.txt --- @@ -0,0 +1,93 @@ +# +# 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(${CMAKE_SOURCE_DIR}/extensions/ExtensionHeader.txt) +include_directories(protocols nanofi controllerservice server) +include_directories(../http-curl/) + +file(GLOB CSOURCES "nanofi/*.c") +file(GLOB SOURCES "*.cpp" "protocols/*.cpp" "processors/*.cpp" "controllerservice/*.cpp" "server/*.cpp" ) + +add_library(nanofi-coap-c STATIC ${CSOURCES}) +add_library(minifi-coap STATIC ${SOURCES}) +set_property(TARGET minifi-coap PROPERTY POSITION_INDEPENDENT_CODE ON) + +if(CMAKE_THREAD_LIBS_INIT) + target_link_libraries(minifi-coap "${CMAKE_THREAD_LIBS_INIT}") +endif() + + set(BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}/extensions/coap") + # determine version of GNUTLSs --- End diff -- this is meant as a bit of a todo. ---
[GitHub] nifi-minifi-cpp issue #447: MINIFICPP-558: initial provisioning for CoAP sti...
Github user phrocker commented on the issue: https://github.com/apache/nifi-minifi-cpp/pull/447 Since this is pretty large I'm doing a self review of this now. ---
[GitHub] nifi-minifi-cpp pull request #445: MINIFICPP-681 - Add content hash processo...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/445#discussion_r235477945 --- Diff: libminifi/include/processors/ContentHash.h --- @@ -0,0 +1,186 @@ +/** + * @file ContentHash.h + * ContentHash class declaration + * + * 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. + */ +#ifndef NIFI_MINIFI_CPP_CONTENTHASH_H +#define NIFI_MINIFI_CPP_CONTENTHASH_H + +#ifdef OPENSSL_SUPPORT + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "FlowFileRecord.h" +#include "core/Processor.h" +#include "core/ProcessSession.h" +#include "core/Resource.h" +#include "io/BaseStream.h" + +using HashReturnType = std::pair; + +namespace { +#define HASH_BUFFER_SIZE 16384 + + std::string digestToString(const unsigned char * const digest, size_t size) { +std::stringstream ss; +for(int i = 0; i < size; i++) +{ + ss << std::uppercase << std::hex << std::setw(2) << std::setfill('0') << (int)digest[i]; +} +return ss.str(); + } + + HashReturnType MD5Hash(std::shared_ptr stream) { +HashReturnType ret_val; +ret_val.second = 0; +uint8_t buffer[HASH_BUFFER_SIZE]; +MD5_CTX context; +MD5_Init(); + +size_t ret = 0; +do { + ret = stream->readData(buffer, HASH_BUFFER_SIZE); + if(ret > 0) { +MD5_Update(, buffer, ret); +ret_val.second += ret; --- End diff -- As mentioned, below, the HashReturnType seems like it might not be necessary. If ret < 0 on any given rad you exit the conditional and loop, then you proceed to call finalize on the hash functions with that partially written context. The code then supplies a digest that is potentially incorrect. Alternatively you can simply short circuit and return an empty string on any stream error and be guaranteed that the resulting hash is an error case. ---
[GitHub] nifi-minifi-cpp pull request #445: MINIFICPP-681 - Add content hash processo...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/445#discussion_r235459513 --- Diff: libminifi/include/processors/ContentHash.h --- @@ -0,0 +1,186 @@ +/** + * @file ContentHash.h + * ContentHash class declaration + * + * 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. + */ +#ifndef NIFI_MINIFI_CPP_CONTENTHASH_H +#define NIFI_MINIFI_CPP_CONTENTHASH_H + +#ifdef OPENSSL_SUPPORT + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "FlowFileRecord.h" +#include "core/Processor.h" +#include "core/ProcessSession.h" +#include "core/Resource.h" +#include "io/BaseStream.h" + +using HashReturnType = std::pair; + +namespace { +#define HASH_BUFFER_SIZE 16384 + + std::string digestToString(const unsigned char * const digest, size_t size) { +std::stringstream ss; +for(int i = 0; i < size; i++) +{ + ss << std::uppercase << std::hex << std::setw(2) << std::setfill('0') << (int)digest[i]; +} +return ss.str(); + } + + HashReturnType MD5Hash(std::shared_ptr stream) { --- End diff -- Is the ref count increment intentional? ---
[GitHub] nifi-minifi-cpp pull request #445: MINIFICPP-681 - Add content hash processo...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/445#discussion_r235474428 --- Diff: libminifi/include/processors/ContentHash.h --- @@ -0,0 +1,186 @@ +/** + * @file ContentHash.h + * ContentHash class declaration + * + * 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. + */ +#ifndef NIFI_MINIFI_CPP_CONTENTHASH_H +#define NIFI_MINIFI_CPP_CONTENTHASH_H + +#ifdef OPENSSL_SUPPORT + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "FlowFileRecord.h" +#include "core/Processor.h" +#include "core/ProcessSession.h" +#include "core/Resource.h" +#include "io/BaseStream.h" + +using HashReturnType = std::pair; + +namespace { +#define HASH_BUFFER_SIZE 16384 + + std::string digestToString(const unsigned char * const digest, size_t size) { +std::stringstream ss; +for(int i = 0; i < size; i++) +{ + ss << std::uppercase << std::hex << std::setw(2) << std::setfill('0') << (int)digest[i]; +} +return ss.str(); + } + + HashReturnType MD5Hash(std::shared_ptr stream) { +HashReturnType ret_val; +ret_val.second = 0; +uint8_t buffer[HASH_BUFFER_SIZE]; +MD5_CTX context; +MD5_Init(); + +size_t ret = 0; +do { + ret = stream->readData(buffer, HASH_BUFFER_SIZE); + if(ret > 0) { +MD5_Update(, buffer, ret); +ret_val.second += ret; + } +} while(ret > 0); +unsigned char digest[MD5_DIGEST_LENGTH]; +MD5_Final(digest, ); + +ret_val.first = digestToString(digest, MD5_DIGEST_LENGTH); +return ret_val; + } + + HashReturnType SHA1Hash(std::shared_ptr stream) { +HashReturnType ret_val; +ret_val.second = 0; +uint8_t buffer[HASH_BUFFER_SIZE]; +SHA_CTX context; +SHA1_Init(); + +size_t ret = 0; +do { + ret = stream->readData(buffer, HASH_BUFFER_SIZE); + if(ret > 0) { +SHA1_Update(, buffer, ret); +ret_val.second += ret; + } +} while(ret > 0); +unsigned char digest[SHA_DIGEST_LENGTH]; +SHA1_Final(digest, ); + +ret_val.first = digestToString(digest, SHA_DIGEST_LENGTH); +return ret_val; + } + + HashReturnType SHA256Hash(std::shared_ptr stream) { +HashReturnType ret_val; +ret_val.second = 0; +uint8_t buffer[HASH_BUFFER_SIZE]; +SHA256_CTX context; +SHA256_Init(); + +size_t ret ; +do { + ret = stream->readData(buffer, HASH_BUFFER_SIZE); + if(ret > 0) { +SHA256_Update(, buffer, ret); +ret_val.second += ret; + } +} while(ret > 0); +unsigned char digest[SHA256_DIGEST_LENGTH]; +SHA256_Final(digest, ); + +ret_val.first = digestToString(digest, SHA256_DIGEST_LENGTH); +return ret_val; + } +} + + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace processors { + +static const std::map)>> HashAlgos = --- End diff -- SHA-2 is suite of digests ( a set of function). It's not tantamount to SHA-256 as it includes others. We should probably avoid using that as it's not a ubiquitous understanding. ---
[GitHub] nifi-minifi-cpp pull request #445: MINIFICPP-681 - Add content hash processo...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/445#discussion_r235461700 --- Diff: libminifi/src/processors/ContentHash.cpp --- @@ -0,0 +1,100 @@ +/** + * @file ContentHash.cpp + * ContentHash 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. + */ + +#ifdef OPENSSL_SUPPORT + +#include +#include +#include +#include +#include "processors/ContentHash.h" +#include "core/ProcessContext.h" +#include "core/ProcessSession.h" +#include "core/FlowFile.h" + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace processors { + +core::Property ContentHash::HashAttribute("Hash Attribute", "Attribute to store checksum to", "Checksum"); +core::Property ContentHash::HashAlgorithm("Hash Algorithm", "Name of the algorithm used to generate checksum", "MD5"); +core::Relationship ContentHash::Success("success", "success operational on the flow record"); + +void ContentHash::initialize() { + //! Set the supported properties + std::set properties; + properties.insert(HashAttribute); + properties.insert(HashAlgorithm); + setSupportedProperties(properties); + //! Set the supported relationships + std::set relationships; + relationships.insert(Success); + setSupportedRelationships(relationships); +} + +void ContentHash::onTrigger(core::ProcessContext *context, core::ProcessSession *session) { + std::shared_ptr flowFile = session->get(); + + if (!flowFile) { +return; + } + + ReadCallback cb(flowFile, context); + session->read(flowFile, ); + session->transfer(flowFile, Success); +} + +int64_t ContentHash::ReadCallback::process(std::shared_ptr stream) { + std::string attrKey, algoName; + ctx_->getProperty(HashAttribute.getName(), attrKey); --- End diff -- These can be done in onSchedule since this isn't dynamic ---
[GitHub] nifi-minifi-cpp pull request #445: MINIFICPP-681 - Add content hash processo...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/445#discussion_r235458978 --- Diff: PROCESSORS.md --- @@ -130,6 +131,31 @@ default values, and whether a property supports the NiFi Expression Language. | success | All FlowFiles are routed to this relationship. | +## ContentHash + +### Description + +ContentHash calculates the checksum of the content of the flowfile and adds it as an attribute. --- End diff -- In the NiFi Ecosystem processors are VerbNoun, so this would be more applicably, "HashContent" ---
[GitHub] nifi-minifi-cpp pull request #445: MINIFICPP-681 - Add content hash processo...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/445#discussion_r235476969 --- Diff: libminifi/src/processors/ContentHash.cpp --- @@ -0,0 +1,100 @@ +/** + * @file ContentHash.cpp + * ContentHash 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. + */ + +#ifdef OPENSSL_SUPPORT + +#include +#include +#include +#include +#include "processors/ContentHash.h" +#include "core/ProcessContext.h" +#include "core/ProcessSession.h" +#include "core/FlowFile.h" + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace processors { + +core::Property ContentHash::HashAttribute("Hash Attribute", "Attribute to store checksum to", "Checksum"); +core::Property ContentHash::HashAlgorithm("Hash Algorithm", "Name of the algorithm used to generate checksum", "MD5"); +core::Relationship ContentHash::Success("success", "success operational on the flow record"); + +void ContentHash::initialize() { + //! Set the supported properties + std::set properties; + properties.insert(HashAttribute); + properties.insert(HashAlgorithm); + setSupportedProperties(properties); + //! Set the supported relationships + std::set relationships; + relationships.insert(Success); + setSupportedRelationships(relationships); +} + +void ContentHash::onTrigger(core::ProcessContext *context, core::ProcessSession *session) { + std::shared_ptr flowFile = session->get(); + + if (!flowFile) { +return; + } + + ReadCallback cb(flowFile, context); + session->read(flowFile, ); + session->transfer(flowFile, Success); +} + +int64_t ContentHash::ReadCallback::process(std::shared_ptr stream) { + std::string attrKey, algoName; + ctx_->getProperty(HashAttribute.getName(), attrKey); + ctx_->getProperty(HashAlgorithm.getName(), algoName); + std::transform(algoName.begin(), algoName.end(), algoName.begin(), ::toupper); + + // Erase '-' to make sha-256 and sha-2 work, too + algoName.erase(std::remove(algoName.begin(), algoName.end(), '-'), algoName.end()); + + // This throws in case algo is not found, but that's fine + auto algo = HashAlgos.at(algoName); + + const auto& ret_val = algo(stream); + + if (ret_val.second <= 0) { --- End diff -- Is this necessary? Cryptographic hash functions ensure the result will never be empty. If the stream failed the digest string would be empty. This would make the return code unnecessary. ---
[GitHub] nifi-minifi-cpp pull request #445: MINIFICPP-681 - Add content hash processo...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/445#discussion_r235471397 --- Diff: libminifi/src/processors/ContentHash.cpp --- @@ -0,0 +1,100 @@ +/** + * @file ContentHash.cpp + * ContentHash 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. + */ + +#ifdef OPENSSL_SUPPORT + +#include +#include +#include +#include +#include "processors/ContentHash.h" +#include "core/ProcessContext.h" +#include "core/ProcessSession.h" +#include "core/FlowFile.h" + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace processors { + +core::Property ContentHash::HashAttribute("Hash Attribute", "Attribute to store checksum to", "Checksum"); +core::Property ContentHash::HashAlgorithm("Hash Algorithm", "Name of the algorithm used to generate checksum", "MD5"); +core::Relationship ContentHash::Success("success", "success operational on the flow record"); + +void ContentHash::initialize() { + //! Set the supported properties + std::set properties; + properties.insert(HashAttribute); + properties.insert(HashAlgorithm); + setSupportedProperties(properties); + //! Set the supported relationships + std::set relationships; + relationships.insert(Success); + setSupportedRelationships(relationships); +} + +void ContentHash::onTrigger(core::ProcessContext *context, core::ProcessSession *session) { + std::shared_ptr flowFile = session->get(); + + if (!flowFile) { +return; + } + + ReadCallback cb(flowFile, context); + session->read(flowFile, ); + session->transfer(flowFile, Success); +} + +int64_t ContentHash::ReadCallback::process(std::shared_ptr stream) { + std::string attrKey, algoName; + ctx_->getProperty(HashAttribute.getName(), attrKey); + ctx_->getProperty(HashAlgorithm.getName(), algoName); + std::transform(algoName.begin(), algoName.end(), algoName.begin(), ::toupper); + + // Erase '-' to make sha-256 and sha-2 work, too + algoName.erase(std::remove(algoName.begin(), algoName.end(), '-'), algoName.end()); + + // This throws in case algo is not found, but that's fine --- End diff -- Might the code above be less duplicative with a simple if statement here? ---
[GitHub] nifi-minifi-cpp pull request #445: MINIFICPP-681 - Add content hash processo...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/445#discussion_r235461430 --- Diff: libminifi/src/processors/ContentHash.cpp --- @@ -0,0 +1,100 @@ +/** + * @file ContentHash.cpp + * ContentHash 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. + */ + +#ifdef OPENSSL_SUPPORT + +#include +#include +#include +#include +#include "processors/ContentHash.h" +#include "core/ProcessContext.h" +#include "core/ProcessSession.h" +#include "core/FlowFile.h" + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace processors { + +core::Property ContentHash::HashAttribute("Hash Attribute", "Attribute to store checksum to", "Checksum"); +core::Property ContentHash::HashAlgorithm("Hash Algorithm", "Name of the algorithm used to generate checksum", "MD5"); +core::Relationship ContentHash::Success("success", "success operational on the flow record"); + +void ContentHash::initialize() { + //! Set the supported properties + std::set properties; + properties.insert(HashAttribute); + properties.insert(HashAlgorithm); + setSupportedProperties(properties); + //! Set the supported relationships + std::set relationships; + relationships.insert(Success); + setSupportedRelationships(relationships); +} + +void ContentHash::onTrigger(core::ProcessContext *context, core::ProcessSession *session) { + std::shared_ptr flowFile = session->get(); + + if (!flowFile) { +return; + } + + ReadCallback cb(flowFile, context); + session->read(flowFile, ); + session->transfer(flowFile, Success); +} + +int64_t ContentHash::ReadCallback::process(std::shared_ptr stream) { + std::string attrKey, algoName; + ctx_->getProperty(HashAttribute.getName(), attrKey); --- End diff -- Unless these are going to be dynamic they should be done in onSchedule. ---
[GitHub] nifi-minifi-cpp pull request #445: MINIFICPP-681 - Add content hash processo...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/445#discussion_r235472601 --- Diff: libminifi/src/processors/ContentHash.cpp --- @@ -0,0 +1,100 @@ +/** + * @file ContentHash.cpp + * ContentHash 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. + */ + +#ifdef OPENSSL_SUPPORT + +#include +#include +#include +#include +#include "processors/ContentHash.h" +#include "core/ProcessContext.h" +#include "core/ProcessSession.h" +#include "core/FlowFile.h" + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace processors { + +core::Property ContentHash::HashAttribute("Hash Attribute", "Attribute to store checksum to", "Checksum"); +core::Property ContentHash::HashAlgorithm("Hash Algorithm", "Name of the algorithm used to generate checksum", "MD5"); +core::Relationship ContentHash::Success("success", "success operational on the flow record"); + +void ContentHash::initialize() { + //! Set the supported properties + std::set properties; + properties.insert(HashAttribute); + properties.insert(HashAlgorithm); + setSupportedProperties(properties); + //! Set the supported relationships + std::set relationships; + relationships.insert(Success); + setSupportedRelationships(relationships); +} + +void ContentHash::onTrigger(core::ProcessContext *context, core::ProcessSession *session) { + std::shared_ptr flowFile = session->get(); + + if (!flowFile) { +return; + } + + ReadCallback cb(flowFile, context); + session->read(flowFile, ); + session->transfer(flowFile, Success); +} + +int64_t ContentHash::ReadCallback::process(std::shared_ptr stream) { + std::string attrKey, algoName; + ctx_->getProperty(HashAttribute.getName(), attrKey); + ctx_->getProperty(HashAlgorithm.getName(), algoName); + std::transform(algoName.begin(), algoName.end(), algoName.begin(), ::toupper); + + // Erase '-' to make sha-256 and sha-2 work, too + algoName.erase(std::remove(algoName.begin(), algoName.end(), '-'), algoName.end()); + + // This throws in case algo is not found, but that's fine --- End diff -- Curious about the comment, "This throws in case algo is not found, but that's fine" What do you mean by "that's fine?" That would cause a rollback, which may then put back pressure on the flow. This may not be desired. It doesn't allow the user to gracefully deal with the failure relationship. Might there be a way to deal with this such that failure is a condition we can account for in our relationships? ---
[GitHub] nifi-minifi-cpp pull request #445: MINIFICPP-681 - Add content hash processo...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/445#discussion_r235461991 --- Diff: libminifi/include/processors/ContentHash.h --- @@ -0,0 +1,186 @@ +/** + * @file ContentHash.h + * ContentHash class declaration + * + * 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. + */ +#ifndef NIFI_MINIFI_CPP_CONTENTHASH_H +#define NIFI_MINIFI_CPP_CONTENTHASH_H + +#ifdef OPENSSL_SUPPORT + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "FlowFileRecord.h" +#include "core/Processor.h" +#include "core/ProcessSession.h" +#include "core/Resource.h" +#include "io/BaseStream.h" + +using HashReturnType = std::pair; + +namespace { +#define HASH_BUFFER_SIZE 16384 + + std::string digestToString(const unsigned char * const digest, size_t size) { +std::stringstream ss; +for(int i = 0; i < size; i++) +{ + ss << std::uppercase << std::hex << std::setw(2) << std::setfill('0') << (int)digest[i]; +} +return ss.str(); + } + + HashReturnType MD5Hash(std::shared_ptr stream) { +HashReturnType ret_val; +ret_val.second = 0; +uint8_t buffer[HASH_BUFFER_SIZE]; +MD5_CTX context; +MD5_Init(); + +size_t ret = 0; +do { + ret = stream->readData(buffer, HASH_BUFFER_SIZE); + if(ret > 0) { +MD5_Update(, buffer, ret); +ret_val.second += ret; + } +} while(ret > 0); +unsigned char digest[MD5_DIGEST_LENGTH]; +MD5_Final(digest, ); + +ret_val.first = digestToString(digest, MD5_DIGEST_LENGTH); +return ret_val; + } + + HashReturnType SHA1Hash(std::shared_ptr stream) { +HashReturnType ret_val; +ret_val.second = 0; +uint8_t buffer[HASH_BUFFER_SIZE]; +SHA_CTX context; +SHA1_Init(); + +size_t ret = 0; +do { + ret = stream->readData(buffer, HASH_BUFFER_SIZE); + if(ret > 0) { +SHA1_Update(, buffer, ret); +ret_val.second += ret; + } +} while(ret > 0); +unsigned char digest[SHA_DIGEST_LENGTH]; +SHA1_Final(digest, ); + +ret_val.first = digestToString(digest, SHA_DIGEST_LENGTH); +return ret_val; + } + --- End diff -- Can these functions be combined to reduce duplication? ---
[GitHub] nifi-minifi-cpp issue #445: MINIFICPP-681 - Add content hash processor
Github user phrocker commented on the issue: https://github.com/apache/nifi-minifi-cpp/pull/445 taking a look. ---
[GitHub] nifi-minifi-cpp issue #446: MINIFICPP-684 - ExtractText processor doesn't ha...
Github user phrocker commented on the issue: https://github.com/apache/nifi-minifi-cpp/pull/446 @arpadboda I'll update the commit on merge to what was intended if you don't have a chance to in the next few minutes. ---
[GitHub] nifi-minifi-cpp pull request #447: MINIFICPP-558: initial provisioning for C...
GitHub user phrocker opened a pull request: https://github.com/apache/nifi-minifi-cpp/pull/447 MINIFICPP-558: initial provisioning for CoAP still a wip test framework still under dev MINIFICPP-683: Remove extraneous std::move MINIFICPP-558: Add some test capabilities 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: - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? - [ ] Does your PR title start with MINIFICPP- where is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. - [ ] Has your PR been rebased against the latest commit within the target branch (typically master)? - [ ] Is your initial contribution a single, squashed commit? ### For code changes: - [ ] 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)? - [ ] If applicable, have you updated the LICENSE file? - [ ] If applicable, have you updated the NOTICE file? ### For documentation related changes: - [ ] 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/phrocker/nifi-minifi-cpp MINIFICPP-558-683 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi-minifi-cpp/pull/447.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 #447 commit 6eaca2afe64c42273fdd6ff111518ca3e0ca0a3d Author: Marc Parisi Date: 2018-10-23T15:51:19Z MINIFICPP-558: initial provisioning for CoAP still a wip test framework still under dev MINIFICPP-683: Remove extraneous std::move MINIFICPP-558: Add some test capabilities ---
[GitHub] nifi-minifi-cpp pull request #437: MINIFICPP-558: initial provisioning for C...
Github user phrocker closed the pull request at: https://github.com/apache/nifi-minifi-cpp/pull/437 ---
[GitHub] nifi-minifi-cpp pull request #444: MINIFICPP-679: Revert changes. We can mak...
GitHub user phrocker opened a pull request: https://github.com/apache/nifi-minifi-cpp/pull/444 MINIFICPP-679: Revert changes. We can make them const but we should w⦠â¦ait after additional testing before pushing these changes 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: - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? - [ ] Does your PR title start with MINIFICPP- where is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. - [ ] Has your PR been rebased against the latest commit within the target branch (typically master)? - [ ] Is your initial contribution a single, squashed commit? ### For code changes: - [ ] 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)? - [ ] If applicable, have you updated the LICENSE file? - [ ] If applicable, have you updated the NOTICE file? ### For documentation related changes: - [ ] 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/phrocker/nifi-minifi-cpp MINIFICPP-679-b Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi-minifi-cpp/pull/444.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 #444 commit 7d239c5c449480349852dc40751f163dee62a277 Author: Marc Parisi Date: 2018-11-20T01:05:23Z MINIFICPP-679: Revert changes. We can make them const but we should wait after additional testing before pushing these changes ---
[GitHub] nifi-minifi-cpp issue #444: MINIFICPP-679: Revert changes. We can make them ...
Github user phrocker commented on the issue: https://github.com/apache/nifi-minifi-cpp/pull/444 @apiri Master is broken. We need to revert these two changes. Not sure how I missed it...but the goal was to limit changes to avoid breaking changes. ---
[GitHub] nifi-minifi-cpp pull request #443: MINIFICPP-680: Remove Xcode 7.3
GitHub user phrocker opened a pull request: https://github.com/apache/nifi-minifi-cpp/pull/443 MINIFICPP-680: Remove Xcode 7.3 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: - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? - [ ] Does your PR title start with MINIFICPP- where is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. - [ ] Has your PR been rebased against the latest commit within the target branch (typically master)? - [ ] Is your initial contribution a single, squashed commit? ### For code changes: - [ ] 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)? - [ ] If applicable, have you updated the LICENSE file? - [ ] If applicable, have you updated the NOTICE file? ### For documentation related changes: - [ ] 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/phrocker/nifi-minifi-cpp MINIFICPP-680 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi-minifi-cpp/pull/443.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 #443 commit cff647d4b20931c2614614b5ef058544d138826b Author: Marc Parisi Date: 2018-11-16T18:29:29Z MINIFICPP-680: Remove Xcode 7.3 ---
[GitHub] nifi-minifi-cpp issue #439: MINIFICPP-645 - Move from new to malloc in CAPI ...
Github user phrocker commented on the issue: https://github.com/apache/nifi-minifi-cpp/pull/439 > There is no delete, it was wrong before, this PR just fixes: > > ``` > void free_flowfile(flow_file_record *ff) { > if (ff == nullptr) { > return; > } > auto content_repo_ptr = static_cast*>(ff->crp); > if (content_repo_ptr->get()) { > std::shared_ptr claim = std::make_shared(ff->contentLocation, *content_repo_ptr); > (*content_repo_ptr)->remove(claim); > } > if (ff->ffp == nullptr) { > auto map = static_cast(ff->attributes); > delete map; > } > free(ff->contentLocation); > free(ff); > ``` > The last line is the one that frees. Ah sorry, I was referencing the fact that over the course of PRs we've gone back and forth a little between malloc/new. There is a free_flow(flow *) that still uses delete. Happy to see a different PR if you prefer to do that, but it all falls under the guise of this ticket IMO. Would you prefer I merge this and then keep the ticket open as a blocker for the free? No real preference on my part. ---
[GitHub] nifi-minifi-cpp pull request #442: MINIFICPP-679: Make minor changes for con...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/442#discussion_r234040428 --- Diff: libminifi/include/core/Core.h --- @@ -142,52 +141,30 @@ class CoreComponent { * Constructor that sets the name and uuid. */ - explicit CoreComponent(const std::string name, utils::Identifier uuid) + explicit CoreComponent(const std::string , utils::Identifier uuid) : name_(name) { if (uuid == nullptr) { // Generate the global UUID for the flow record id_generator_->generate(uuid_); } else { uuid_ = uuid; } - uuidStr_ = uuid_.to_string(); } - explicit CoreComponent(const std::string name) + explicit CoreComponent(const std::string ) : name_(name) { - // Generate the global UUID for the flow record id_generator_->generate(uuid_); - uuidStr_ = uuid_.to_string(); } - /* - #ifdef WIN32 - #else - - explicit CoreComponent(const std::string name, Identifier uuid = nullptr) - : name_(name) { - if (nullptr == uuid) - // Generate the global UUID for the flow record - id_generator_->generate(uuid_); - else - uuid_copy(uuid_, uuid); - - char uuidStr[37] = { 0 }; - uuid_unparse_lower(uuid_, uuidStr); - uuidStr_ = uuidStr; - } - #endif - */ + + explicit CoreComponent(const CoreComponent ) = default; /** * Move Constructor. */ - explicit CoreComponent(const CoreComponent &) - : name_(std::move(other.name_)) { -uuid_ = other.uuid_; -//uuid_copy(uuid_, other.uuid_); - } + --- End diff -- should be safe since we added a non trial move con to ident, but this will require some testing on all platforms. again, still running windows build. Will probably report back tomorrow. ---
[GitHub] nifi-minifi-cpp pull request #442: MINIFICPP-679: Make minor changes for con...
GitHub user phrocker opened a pull request: https://github.com/apache/nifi-minifi-cpp/pull/442 MINIFICPP-679: Make minor changes for const correctness improvements Running a windows build now. If I see errors there I'll re-submit, but ran general tests and build across a variety of platforms. 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: - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? - [ ] Does your PR title start with MINIFICPP- where is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. - [ ] Has your PR been rebased against the latest commit within the target branch (typically master)? - [ ] Is your initial contribution a single, squashed commit? ### For code changes: - [ ] 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)? - [ ] If applicable, have you updated the LICENSE file? - [ ] If applicable, have you updated the NOTICE file? ### For documentation related changes: - [ ] 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/phrocker/nifi-minifi-cpp MINIFICPP-679 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi-minifi-cpp/pull/442.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 #442 commit 12fe6ccdf163bc585425df28e6bbc7f5cfb6347f Author: Marc Parisi Date: 2018-11-15T22:10:42Z MINIFICPP-679: Make minor changes for const correctness improvements ---
[GitHub] nifi-minifi-cpp issue #440: MINIFICPP-676 - Cleanup and fix serializable int...
Github user phrocker commented on the issue: https://github.com/apache/nifi-minifi-cpp/pull/440 hmmm, I should have checked appveyor because I would have saved some time building on windows...but as I suspected we have issues there too. ---
[GitHub] nifi-minifi-cpp pull request #439: MINIFICPP-645 - Move from new to malloc i...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/439#discussion_r234012390 --- Diff: nanofi/src/api/nanofi.cpp --- @@ -205,7 +205,7 @@ flow_file_record* create_ff_object(const char *file, const size_t len, const uin } flow_file_record* create_ff_object_na(const char *file, const size_t len, const uint64_t size) { - flow_file_record *new_ff = new flow_file_record; + flow_file_record *new_ff = (flow_file_record*) malloc(sizeof(flow_file_record)); --- End diff -- Oops, sorry, must change the delete to free due to avoid heap corruption. ---
[GitHub] nifi-minifi-cpp pull request #436: MINIFICPP-667: Add structural definitions...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/436#discussion_r234011794 --- Diff: nanofi/include/core/utlist.h --- @@ -0,0 +1,1073 @@ +/* --- End diff -- As per the title this is to work out a plan so that it's out in the open on Apache. I won't be merging this. ---
[GitHub] nifi-minifi-cpp pull request #440: MINIFICPP-676 - Cleanup and fix serializa...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/440#discussion_r234011459 --- Diff: extensions/http-curl/client/HTTPCallback.h --- @@ -78,7 +78,7 @@ class HttpStreamingCallback : public ByteInputCallBack { } - virtual int64_t process(uint8_t *vector, size_t size) { + virtual int64_t process(const uint8_t *vector, size_t size) { --- End diff -- in general when i see something like const uint8_t *ptr, then I wonder what the true intent may be there. You have a pointer that can be modified. Should also make that pointer const too, but as with all comments I'm not sure that's the best approach here. ---
[GitHub] nifi-minifi-cpp pull request #440: MINIFICPP-676 - Cleanup and fix serializa...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/440#discussion_r234009476 --- Diff: libminifi/src/io/FileStream.cpp --- @@ -82,16 +82,16 @@ void FileStream::seek(uint64_t offset) { file_stream_->seekp(offset_); } -int FileStream::writeData(std::vector , int buflen) { +int FileStream::writeData(const std::vector , int buflen) { if (static_cast(buf.capacity()) < buflen) { return -1; } - return writeData(reinterpret_cast([0]), buflen); --- End diff -- fails to compile on some of my archs. perhaps run make docker ? ---
[GitHub] nifi-minifi-cpp pull request #440: MINIFICPP-676 - Cleanup and fix serializa...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/440#discussion_r234009236 --- Diff: libminifi/include/io/tls/TLSSocket.h --- @@ -173,19 +173,19 @@ class TLSSocket : public Socket { * @param buflen buffer to write * */ - int writeData(std::vector , int buflen); + int writeData(const std::vector , int buflen); --- End diff -- if we chose ( and we eventually will in further tickets ) to take this memory and do a memmove ( in a different stream -- can discuss later ) we can't do that with the changes. This was intentional and not an oversight. ---
[GitHub] nifi-minifi-cpp pull request #440: MINIFICPP-676 - Cleanup and fix serializa...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/440#discussion_r234008835 --- Diff: libminifi/include/io/Serializable.h --- @@ -173,8 +147,22 @@ class Serializable { **/ int readUTF(std::string , DataStream *stream, bool widen = false); - protected: + /** + * reads 2-8 bytes from the stream + * @param value reference in which will set the result + * @param stream stream from which we will read + * @return resulting read size + **/ + template 1) && + std::is_integral::value && + !std::is_signed::value + ,Integral>::type* = nullptr> + int read(Integral , DataStream *stream, bool is_little_endian = EndiannessCheck::IS_LITTLE) { --- End diff -- My IDEs does not make this clear the function to use. In some ways java made this easier with their streams "writeInt, writeShort, writeUnsignedShort" and we can do the same with write(short) write(int), write(long), but my one IDE correctly provides this while others don't. I agree that generally reducing "Needless functions" is a good thing, but here it served a purpose. Happy to further discuss how we can benefit that purpose. ---
[GitHub] nifi-minifi-cpp pull request #440: MINIFICPP-676 - Cleanup and fix serializa...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/440#discussion_r234008240 --- Diff: libminifi/include/io/Serializable.h --- @@ -22,11 +22,36 @@ #include #include "EndianCheck.h" #include "DataStream.h" + +namespace { + template
[GitHub] nifi-minifi-cpp pull request #440: MINIFICPP-676 - Cleanup and fix serializa...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/440#discussion_r234007116 --- Diff: libminifi/include/io/CRCStream.h --- @@ -194,15 +194,12 @@ int CRCStream::readData(uint8_t *buf, int buflen) { } template -int CRCStream::writeData(std::vector , int buflen) { - - if ((int)buf.capacity() < buflen) --- End diff -- This existed for a reason. Did you test this in flight ? This causes a failure. We have non const because we reserve the right to adjust buffers. That's the intent behind making the signatures the way they are. ---
[GitHub] nifi-minifi-cpp pull request #440: MINIFICPP-676 - Cleanup and fix serializa...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/440#discussion_r234006270 --- Diff: extensions/http-curl/client/HTTPStream.h --- @@ -100,14 +100,14 @@ class HttpStream : public io::BaseStream { * @param buflen buffer to write * */ - virtual int writeData(std::vector , int buflen); + virtual int writeData(const std::vector , int buflen); --- End diff -- Same. C and C++ developers see const and they know what that means. They see the lack of const and know their data may change. If it's non const that doesn't mean it should be changed without discussion. I think these should be non const as we reserve the right to take ownership in the internal API. I would agree for external API. ---
[GitHub] nifi-minifi-cpp pull request #440: MINIFICPP-676 - Cleanup and fix serializa...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/440#discussion_r234005818 --- Diff: extensions/http-curl/client/HTTPStream.cpp --- @@ -53,16 +53,16 @@ void HttpStream::seek(uint64_t offset) { throw std::exception(); } -int HttpStream::writeData(std::vector , int buflen) { +int HttpStream::writeData(const std::vector , int buflen) { if ((int)buf.capacity() < buflen) { return -1; } - return writeData(reinterpret_cast([0]), buflen); --- End diff -- this fails on some compilers. I spent a long time and saw failures on older versions ( not sure if specifically this one ). Did this cause a specific bug? These are non const for a reason and that's to tell the caller that their data may change. You're making an assumption that it shouldn't be const. ---
[GitHub] nifi-minifi-cpp issue #440: MINIFICPP-676 - Cleanup and fix serializable int...
Github user phrocker commented on the issue: https://github.com/apache/nifi-minifi-cpp/pull/440 @arpadboda I've run some flows and seen a lot of failures as well. ---
[GitHub] nifi-minifi-cpp pull request #441: Minificpp 677 -- resolve travis failures....
GitHub user phrocker opened a pull request: https://github.com/apache/nifi-minifi-cpp/pull/441 Minificpp 677 -- resolve travis failures. 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: - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? - [ ] Does your PR title start with MINIFICPP- where is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. - [ ] Has your PR been rebased against the latest commit within the target branch (typically master)? - [ ] Is your initial contribution a single, squashed commit? ### For code changes: - [ ] 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)? - [ ] If applicable, have you updated the LICENSE file? - [ ] If applicable, have you updated the NOTICE file? ### For documentation related changes: - [ ] 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/phrocker/nifi-minifi-cpp MINIFICPP-677 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi-minifi-cpp/pull/441.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 #441 commit 3548470fbe7a58b6dc0cb91fce0f4d61f1ce7fd0 Author: Marc Parisi Date: 2018-11-15T20:30:46Z MINIFICPP-677: Change behavior of async callback commit efad47ec4f6d2a6f4e57fd34a1a26d98f4d1c72c Author: Marc Parisi Date: 2018-11-15T20:47:20Z com ---
[GitHub] nifi-minifi-cpp pull request #437: MINIFICPP-558: initial provisioning for C...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/437#discussion_r233951286 --- Diff: extensions/coap/controllerservice/CoapConnector.cpp --- @@ -0,0 +1,189 @@ +/** + * + * 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 "CoapConnector.h" +#include +#include +#include +#include +#include +#include "core/Property.h" +#include "CoapConnector.h" +#include "io/validation.h" +#include "properties/Configure.h" + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace controllers { + +static core::Property RemoteServer; +static core::Property Port; +static core::Property MaxQueueSize; + +core::Property CoapConnectorService::RemoteServer(core::PropertyBuilder::createProperty("Remote Server")->withDescription("Remote CoAP server")->isRequired(true)->build()); +core::Property CoapConnectorService::Port(core::PropertyBuilder::createProperty("Remote Port")->withDescription("Remote CoAP server port")->isRequired(true)->build()); +core::Property CoapConnectorService::MaxQueueSize(core::PropertyBuilder::createProperty("Max Queue Size")->withDescription("Max queue size for received data ")->isRequired(true)->build()); + +void CoapConnectorService::initialize() { + if (initialized_) +return; + + callback_pointers ptrs; + ptrs.data_received = receiveMessage; + ptrs.received_error = receiveError; + init_coap_api(this, ); + + std::lock_guard lock(initialization_mutex_); + + ControllerService::initialize(); + + initializeProperties(); + + initialized_ = true; +} + +void CoapConnectorService::onEnable() { + std::string port_str; + if (getProperty(RemoteServer.getName(), host_) && !host_.empty() && getProperty(Port.getName(), port_str) && !port_str.empty()) { +core::Property::StringToInt(port_str, port_); + } else { +// this is the case where we aren't being used in the context of a single controller service. +if (configuration_->get("nifi.c2.agent.coap.host", host_) && configuration_->get("nifi.c2.agent.coap.port", port_str)) { + core::Property::StringToInt(port_str, port_); +} + + } +} + +CoapConnectorService::CoAPMessage CoapConnectorService::sendPayload(uint8_t type, const std::string endpoint, unsigned char *payload, size_t size) { + struct coap_context_t* ctx=NULL; + struct coap_session_t* session=NULL; + + coap_address_t dst_addr, src_addr; + coap_uri_t uri; + uri.host.s = reinterpret_cast(const_cast(host_.c_str())); + uri.host.length = host_.size(); + uri.path.s = reinterpret_cast(const_cast(endpoint.c_str())); + uri.path.length = endpoint.size(); + uri.port = port_; + + fd_set readfds; + coap_pdu_t* request; + unsigned char get_method = 1; + + int res = resolve_address(, _addr.addr.sa); + if (res < 0) { +return CoAPMessage(); + } + + dst_addr.size = res; + dst_addr.addr.sin.sin_port = htons(uri.port); + + void *addrptr = NULL; + char port_str[NI_MAXSERV] = "0"; + char node_str[NI_MAXHOST] = ""; + switch (dst_addr.addr.sa.sa_family) { +case AF_INET: + addrptr = _addr.addr.sin.sin_addr; + + /* create context for IPv4 */ + if (!create_session(, , node_str[0] == 0 ? "0.0.0.0" : node_str, port_str, _addr)) { +break; + } else { +return CoAPMessage(); + } +case AF_INET6: + addrptr = _addr.addr.sin6.sin6_addr; + + /* create context for IPv6 */ + if (!create_session(, , node_str[0] == 0 ? "::" : node_str, port
[GitHub] nifi-minifi-cpp pull request #437: MINIFICPP-558: initial provisioning for C...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/437#discussion_r233950116 --- Diff: extensions/coap/controllerservice/CoapConnector.cpp --- @@ -0,0 +1,189 @@ +/** + * + * 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 "CoapConnector.h" +#include +#include +#include +#include +#include +#include "core/Property.h" +#include "CoapConnector.h" +#include "io/validation.h" +#include "properties/Configure.h" + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace controllers { + +static core::Property RemoteServer; +static core::Property Port; +static core::Property MaxQueueSize; + +core::Property CoapConnectorService::RemoteServer(core::PropertyBuilder::createProperty("Remote Server")->withDescription("Remote CoAP server")->isRequired(true)->build()); +core::Property CoapConnectorService::Port(core::PropertyBuilder::createProperty("Remote Port")->withDescription("Remote CoAP server port")->isRequired(true)->build()); +core::Property CoapConnectorService::MaxQueueSize(core::PropertyBuilder::createProperty("Max Queue Size")->withDescription("Max queue size for received data ")->isRequired(true)->build()); + +void CoapConnectorService::initialize() { + if (initialized_) +return; + + callback_pointers ptrs; + ptrs.data_received = receiveMessage; + ptrs.received_error = receiveError; + init_coap_api(this, ); + + std::lock_guard lock(initialization_mutex_); + + ControllerService::initialize(); + + initializeProperties(); + + initialized_ = true; +} + +void CoapConnectorService::onEnable() { + std::string port_str; + if (getProperty(RemoteServer.getName(), host_) && !host_.empty() && getProperty(Port.getName(), port_str) && !port_str.empty()) { +core::Property::StringToInt(port_str, port_); + } else { +// this is the case where we aren't being used in the context of a single controller service. +if (configuration_->get("nifi.c2.agent.coap.host", host_) && configuration_->get("nifi.c2.agent.coap.port", port_str)) { + core::Property::StringToInt(port_str, port_); +} + + } +} + +CoapConnectorService::CoAPMessage CoapConnectorService::sendPayload(uint8_t type, const std::string endpoint, unsigned char *payload, size_t size) { + struct coap_context_t* ctx=NULL; + struct coap_session_t* session=NULL; + + coap_address_t dst_addr, src_addr; + coap_uri_t uri; + uri.host.s = reinterpret_cast(const_cast(host_.c_str())); --- End diff -- Ah thanks for the diligence. This was changed last minute ( from coap to coap2 ) and I may return back to libcoap where the signature is unsigned char. I posted this early for someone to take a gander from an integration perspective ---
[GitHub] nifi-minifi-cpp pull request #436: MINIFICPP-667: Add structural definitions...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/436#discussion_r233919353 --- Diff: nanofi/include/core/utlist.h --- @@ -0,0 +1,1073 @@ +/* --- End diff -- sorry CMAKE_SOURCE_DIR. It can go there and should. I think I updated the NOTICE and we direct people to the root source thirdparty, so we can probably just use that. No reason to create levels of thirdparty source dirs yet. ---
[GitHub] nifi-minifi-cpp pull request #436: MINIFICPP-667: Add structural definitions...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/436#discussion_r233913139 --- Diff: nanofi/include/core/utlist.h --- @@ -0,0 +1,1073 @@ +/* --- End diff -- We have a third party dir in the main directory, which is where this should go. ---
[GitHub] nifi-minifi-cpp pull request #436: MINIFICPP-667: Add structural definitions...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/436#discussion_r233913016 --- Diff: nanofi/include/core/utlist.h --- @@ -0,0 +1,1073 @@ +/* --- End diff -- Ah thanks for calling this out. I have a more recent commit with a lot of changes, but didn't move this yet and probably would have forgotten. ---
[GitHub] nifi-minifi-cpp pull request #436: MINIFICPP-667: Add structural definitions...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/436#discussion_r233911949 --- Diff: nanofi/include/core/cstructs.h --- @@ -76,6 +80,12 @@ typedef struct { * ## */ +typedef struct{ + char *key; --- End diff -- I'll add that I'm not against this, but the code pointer's management was a little different. Again, I'll take a look at if this makes sense. core will be things that don't reflect a user experience though. That is code that's not part of our public API. ---
[GitHub] nifi-minifi-cpp pull request #436: MINIFICPP-667: Add structural definitions...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/436#discussion_r233911441 --- Diff: nanofi/src/api/nanofi.cpp --- @@ -72,19 +41,17 @@ class DirectoryConfiguration { * nifi_instance *create_instance(nifi_port const *port) { */ nifi_instance *create_instance(const char *url, nifi_port *port) { - // make sure that we have a thread safe way of initializing the content directory - DirectoryConfiguration::initialize(); - - // need reinterpret cast until we move to C for this module. - nifi_instance *instance = reinterpret_cast(malloc(sizeof(nifi_instance))); +// need reinterpret cast until we move to C for this module. + nifi_instance *instance = (nifi_instance*)(malloc(sizeof(nifi_instance))); /** * This API will gradually move away from C++, hence malloc is used for nifi_instance * Since minifi::Instance is currently being used, then we need to use new in that case. */ - instance->instance_ptr = new minifi::Instance(url, port->port_id); + instance->instance_ptr = create_cxx_instance(url,port); // may have to translate port ID here in the future // need reinterpret cast until we move to C for this module. - instance->port.port_id = reinterpret_cast(malloc(strlen(port->port_id) + 1)); + instance->port.port_id = (char*)(malloc(strlen(port->port_id) + 1)); --- End diff -- Yes. We won't be able to use the C++ linter on C files. I haven't pushed the recent commit, but I'm moving toward renaming this to nanofi.c ---
[GitHub] nifi-minifi-cpp pull request #436: MINIFICPP-667: Add structural definitions...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/436#discussion_r233910857 --- Diff: nanofi/include/core/cstructs.h --- @@ -76,6 +80,12 @@ typedef struct { * ## */ +typedef struct{ + char *key; --- End diff -- The example code I took this from had this as char*, not sure we can do this. I'd have to look at the library. ---
[GitHub] nifi-minifi-cpp pull request #438: MINIFICPP-675: Fix issue with hearder eva...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/438#discussion_r233590484 --- Diff: extensions/http-curl/tests/HTTPSiteToSiteTests.cpp --- @@ -123,61 +123,66 @@ struct test_profile { void run_variance(std::string test_file_location, bool isSecure, std::string url, const struct test_profile ) { SiteToSiteTestHarness harness(isSecure); - SiteToSiteLocationResponder responder(isSecure); + SiteToSiteLocationResponder *responder = new SiteToSiteLocationResponder(isSecure); --- End diff -- this is a short lived test, we don't care about memory leaks here. and we don't control stoppage of the web server, so we can avoid issues entirely by simply adding this to the heap and not concerning ourselves with scope. ---
[GitHub] nifi-minifi-cpp pull request #438: MINIFICPP-675: Fix issue with hearder eva...
GitHub user phrocker opened a pull request: https://github.com/apache/nifi-minifi-cpp/pull/438 MINIFICPP-675: Fix issue with hearder evaluation and re-enable test MINIFICPP-668: don't append port if it is not valid 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: - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? - [ ] Does your PR title start with MINIFICPP- where is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. - [ ] Has your PR been rebased against the latest commit within the target branch (typically master)? - [ ] Is your initial contribution a single, squashed commit? ### For code changes: - [ ] 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)? - [ ] If applicable, have you updated the LICENSE file? - [ ] If applicable, have you updated the NOTICE file? ### For documentation related changes: - [ ] 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/phrocker/nifi-minifi-cpp MINIFICPP-675 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi-minifi-cpp/pull/438.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 #438 commit ede5ccebee81ef8af51e38828c7afaf7947cf992 Author: Marc Parisi Date: 2018-11-14T19:22:28Z MINIFICPP-675: Fix issue with hearder evaluation and re-enable test MINIFICPP-668: don't append port if it is not valid ---
[GitHub] nifi-minifi-cpp pull request #437: MINIFICPP-558: initial provisioning for C...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/437#discussion_r233474220 --- Diff: extensions/coap/CMakeLists.txt --- @@ -0,0 +1,92 @@ +# +# 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(${CMAKE_SOURCE_DIR}/extensions/ExtensionHeader.txt) +include_directories(protocols nanofi controllerservice) +include_directories(../http-curl/) + +file(GLOB CSOURCES "nanofi/*.c") +file(GLOB SOURCES "*.cpp" "protocols/*.cpp" "processors/*.cpp" "controllerservice/*.cpp" ) + +add_library(nanofi-coap-c STATIC ${CSOURCES}) +add_library(minifi-coap STATIC ${SOURCES}) +set_property(TARGET minifi-coap PROPERTY POSITION_INDEPENDENT_CODE ON) + +if(CMAKE_THREAD_LIBS_INIT) + target_link_libraries(minifi-coap "${CMAKE_THREAD_LIBS_INIT}") +endif() + + set(BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}/extensions/coap") + if (APPLE) + set(BYPRODUCT "${BASE_DIR}/extensions/coap/thirdparty/libcoap-src/.libs/libcoap-2-gnutls.a") --- End diff -- this may need a little modification as artifacts can vary depending on what is used for building TLS ---
[GitHub] nifi-minifi-cpp issue #437: MINIFICPP-558: initial provisioning for CoAP
Github user phrocker commented on the issue: https://github.com/apache/nifi-minifi-cpp/pull/437 Adding tests presently, but providing a wip view. ---
[GitHub] nifi-minifi-cpp pull request #437: MINIFICPP-558: initial provisioning for C...
GitHub user phrocker opened a pull request: https://github.com/apache/nifi-minifi-cpp/pull/437 MINIFICPP-558: initial provisioning for CoAP 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: - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? - [ ] Does your PR title start with MINIFICPP- where is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. - [ ] Has your PR been rebased against the latest commit within the target branch (typically master)? - [ ] Is your initial contribution a single, squashed commit? ### For code changes: - [ ] 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)? - [ ] If applicable, have you updated the LICENSE file? - [ ] If applicable, have you updated the NOTICE file? ### For documentation related changes: - [ ] 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/phrocker/nifi-minifi-cpp MINIFICPP-558 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi-minifi-cpp/pull/437.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 #437 commit bee4aad6c91b1926e90ac9ce5646e04e865410cc Author: Marc Parisi Date: 2018-10-23T15:51:19Z MINIFICPP-558: initial provisioning for CoAP ---
[GitHub] nifi-minifi-cpp pull request #436: MINIFICPP-667: Add structural definitions...
GitHub user phrocker opened a pull request: https://github.com/apache/nifi-minifi-cpp/pull/436 MINIFICPP-667: Add structural definitions to work out plan for C migr⦠â¦ation 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: - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? - [ ] Does your PR title start with MINIFICPP- where is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. - [ ] Has your PR been rebased against the latest commit within the target branch (typically master)? - [ ] Is your initial contribution a single, squashed commit? ### For code changes: - [ ] 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)? - [ ] If applicable, have you updated the LICENSE file? - [ ] If applicable, have you updated the NOTICE file? ### For documentation related changes: - [ ] 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/phrocker/nifi-minifi-cpp MINIFICPP-667 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi-minifi-cpp/pull/436.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 #436 commit afe8fedac949270f408227ced9f8bb3bbd6cc09b Author: Marc Parisi Date: 2018-11-12T18:12:40Z MINIFICPP-667: Add structural definitions to work out plan for C migration ---
[GitHub] nifi-minifi-cpp pull request #432: MINIFICPP-648 - add processor and add pro...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/432#discussion_r232751327 --- Diff: nanofi/src/api/nanofi.cpp --- @@ -323,55 +360,45 @@ int transmit_flowfile(flow_file_record *ff, nifi_instance *instance) { flow * create_new_flow(nifi_instance * instance) { auto minifi_instance_ref = static_cast(instance->instance_ptr); - flow *new_flow = (flow*) malloc(sizeof(flow)); - - auto execution_plan = new ExecutionPlan(minifi_instance_ref->getContentRepository(), minifi_instance_ref->getNoOpRepository(), minifi_instance_ref->getNoOpRepository()); - - new_flow->plan = execution_plan; - - return new_flow; + return new flow(minifi_instance_ref->getContentRepository(), minifi_instance_ref->getNoOpRepository(), minifi_instance_ref->getNoOpRepository()); } flow *create_flow(nifi_instance *instance, const char *first_processor) { if (nullptr == instance || nullptr == instance->instance_ptr) { return nullptr; } auto minifi_instance_ref = static_cast(instance->instance_ptr); - flow *new_flow = (flow*) malloc(sizeof(flow)); - - auto execution_plan = new ExecutionPlan(minifi_instance_ref->getContentRepository(), minifi_instance_ref->getNoOpRepository(), minifi_instance_ref->getNoOpRepository()); - new_flow->plan = execution_plan; + flow *new_flow = new flow(minifi_instance_ref->getContentRepository(), minifi_instance_ref->getNoOpRepository(), minifi_instance_ref->getNoOpRepository()); if (first_processor != nullptr && strlen(first_processor) > 0) { // automatically adds it with success -execution_plan->addProcessor(first_processor, first_processor); --- End diff -- What are you basing the statement, "it's now faster than it was?" What profiler did you use to gather this, and what benefit does that have over readability concerns? ---
[GitHub] nifi-minifi-cpp pull request #432: MINIFICPP-648 - add processor and add pro...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/432#discussion_r23274 --- Diff: nanofi/include/core/cxxstructs.h --- @@ -0,0 +1,41 @@ +/** + * + * 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. + */ + +#ifndef NIFI_MINIFI_CPP_CXXSTRUCTS_H +#define NIFI_MINIFI_CPP_CXXSTRUCTS_H + +#include "cstructs.h" +#include "cxx/Plan.h" + --- End diff -- What do you mean by "I don't think is moving that way, just simplifies the current structure." ? You don't see it moving away from C++? ---
[GitHub] nifi-minifi-cpp issue #435: MINIFICPP-665: Add reference checks for self
Github user phrocker commented on the issue: https://github.com/apache/nifi-minifi-cpp/pull/435 @arpadboda yah we can compare templates. But we lose the ability to change source of streams. Was on fence about that ---