[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #1042: MINIFICPP-1457 - Implement InputRequirements

2021-05-03 Thread GitBox


adamdebreceni commented on a change in pull request #1042:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1042#discussion_r624906408



##
File path: libminifi/src/FlowController.cpp
##
@@ -302,6 +302,10 @@ void FlowController::load(const 
std::shared_ptr , bool
   this->root_ = std::shared_ptr(loadInitialFlow());
 }
 
+if (root) {
+  root_->verify();

Review comment:
   shouldn't we check `root_`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #1042: MINIFICPP-1457 - Implement InputRequirements

2021-04-26 Thread GitBox


adamdebreceni commented on a change in pull request #1042:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1042#discussion_r620066444



##
File path: libminifi/include/core/Annotation.h
##
@@ -0,0 +1,79 @@
+/**
+
+ * 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.
+ */
+
+#pragma once
+
+#include 
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace core {
+namespace annotation {
+
+template 
+struct Annotation {
+  const T value_;

Review comment:
   agree with the member pollution concern, we could get rid of the 
`value_` altogether by trying successive `dynamic_cast`s to `Required`, 
`Allowed` and `Forbidden`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #1042: MINIFICPP-1457 - Implement InputRequirements

2021-04-26 Thread GitBox


adamdebreceni commented on a change in pull request #1042:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1042#discussion_r620063174



##
File path: libminifi/include/core/Annotation.h
##
@@ -0,0 +1,79 @@
+/**
+
+ * 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.
+ */
+
+#pragma once
+
+#include 
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace core {
+namespace annotation {
+
+template 
+struct Annotation {
+  const T value_;

Review comment:
   compile-time would be a nice touch, but I don't see how could we verify 
at compile-time that a processor requiring inputs actually gets some input 
connections, also wouldn't this require the code to a) either cast all 
processors to their most derived type b) reimplement the input requirement 
validation for all processor types?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #1042: MINIFICPP-1457 - Implement InputRequirements

2021-04-26 Thread GitBox


adamdebreceni commented on a change in pull request #1042:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1042#discussion_r620060353



##
File path: libminifi/include/core/Processor.h
##
@@ -251,6 +252,10 @@ class Processor : public Connectable, public 
ConfigurableComponent, public std::
 
   std::shared_ptr pickIncomingConnection() override;
 
+  virtual void validateAnnotations() const;

Review comment:
   are there any plans for processor-specific annotation validation making 
this method`virtual`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #1042: MINIFICPP-1457 - Implement InputRequirements

2021-04-08 Thread GitBox


adamdebreceni commented on a change in pull request #1042:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1042#discussion_r609658525



##
File path: extensions/standard-processors/processors/ExecuteProcess.h
##
@@ -51,7 +51,7 @@ namespace processors {
 #ifndef WIN32
 
 // ExecuteProcess Class
-class ExecuteProcess : public core::Processor {
+class ExecuteProcess : public core::Processor, public 
core::annotation::input::Forbidden {

Review comment:
   it can be specified but it seems to me, that it won't be used, this 
might be a bug




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #1042: MINIFICPP-1457 - Implement InputRequirements

2021-04-08 Thread GitBox


adamdebreceni commented on a change in pull request #1042:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1042#discussion_r609397913



##
File path: libminifi/src/core/Processor.cpp
##
@@ -386,6 +379,39 @@ std::shared_ptr 
Processor::pickIncomingConnection() {
   return getNextIncomingConnectionImpl(rel_guard);
 }
 
+using annotation::input::EInputRequirement;
+
+void Processor::validateAnnotations() const {

Review comment:
   some unit tests could 'secure' this method




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #1042: MINIFICPP-1457 - Implement InputRequirements

2021-04-08 Thread GitBox


adamdebreceni commented on a change in pull request #1042:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1042#discussion_r609396538



##
File path: libminifi/src/ThreadedSchedulingAgent.cpp
##
@@ -88,6 +88,7 @@ void 
ThreadedSchedulingAgent::schedule(std::shared_ptr processo
 
   auto sessionFactory = 
std::make_shared(processContext);
 
+  processor->validateAnnotations();

Review comment:
   given our direction towards all kinds of flow-verification, this could 
be moved into either a `FlowController::verifyFlow(ProcessGroup&)` or 
`ProcessGroup::verify` (the former might be better as then we could access the 
services and repositories all at once) which could then be expanded as needed 
(calling it from `FlowController::load`)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #1042: MINIFICPP-1457 - Implement InputRequirements

2021-04-08 Thread GitBox


adamdebreceni commented on a change in pull request #1042:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1042#discussion_r609356101



##
File path: libminifi/src/core/Processor.cpp
##
@@ -386,6 +379,39 @@ std::shared_ptr 
Processor::pickIncomingConnection() {
   return getNextIncomingConnectionImpl(rel_guard);
 }
 
+using annotation::input::EInputRequirement;
+
+void Processor::validateAnnotations() const {
+  switch (getInputRequirement()) {
+case EInputRequirement::INPUT_ALLOWED:
+  return;
+case EInputRequirement::INPUT_REQUIRED: {
+  if (!hasIncomingConnections()) {
+throw Exception(PROCESS_SCHEDULE_EXCEPTION, "INPUT_REQUIRED was 
specified for the processor, but no inputs were found");
+  }
+  break;
+}
+case EInputRequirement::INPUT_FORBIDDEN: {
+  if (hasIncomingConnections()) {
+throw Exception(PROCESS_SCHEDULE_EXCEPTION, "INPUT_FORBIDDEN was 
specified for the processor, but at least one input was found");
+  }
+  break;
+}
+  }
+}
+
+EInputRequirement Processor::getInputRequirement() const {
+  // default input requirement
+  EInputRequirement myInputRequirement = EInputRequirement::INPUT_ALLOWED;
+  // get own input annotation if InputRequirementAnnotationBase is a base class

Review comment:
   this comment got out of sync with the removal of 
`InputRequirementAnnotationBase`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #1042: MINIFICPP-1457 - Implement InputRequirements

2021-04-07 Thread GitBox


adamdebreceni commented on a change in pull request #1042:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1042#discussion_r608475655



##
File path: libminifi/include/core/Annotation.h
##
@@ -0,0 +1,77 @@
+/**
+
+ * 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.
+ */
+
+#pragma once
+
+#include 
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace core {
+
+template 
+struct AnnotationBase {

Review comment:
   is `dynamic_cast*>(_)` malformed?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #1042: MINIFICPP-1457 - Implement InputRequirements

2021-04-07 Thread GitBox


adamdebreceni commented on a change in pull request #1042:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1042#discussion_r608449176



##
File path: extensions/standard-processors/processors/TailFile.h
##
@@ -71,7 +71,7 @@ enum class Mode {
   SINGLE, MULTIPLE, UNDEFINED
 };
 
-class TailFile : public core::Processor {
+class TailFile : public core::Processor, public 
core::InputRequirementAnnotation {

Review comment:
   we could introduce an `annotation` namespace in `core` and provide type 
aliases for these, like `core::annotation::InputForbidden`, this might make it 
more compact




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #1042: MINIFICPP-1457 - Implement InputRequirements

2021-04-07 Thread GitBox


adamdebreceni commented on a change in pull request #1042:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1042#discussion_r608447451



##
File path: libminifi/include/core/Annotation.h
##
@@ -0,0 +1,77 @@
+/**
+
+ * 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.
+ */
+
+#pragma once
+
+#include 
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace core {
+
+template 
+struct AnnotationBase {

Review comment:
   are more kinds of annotations in the works? if so, we could drop the 
default definition, and specialize on `Annotation` thus we 
wouldn't need the `InputRequirementAnnotationBase` anymore




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org