lordgamez commented on code in PR #1902: URL: https://github.com/apache/nifi-minifi-cpp/pull/1902#discussion_r1860926806
########## core/include/minifi-cpp/core/FlowFile.h: ########## @@ -0,0 +1,112 @@ +/** + * + * 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 <map> +#include <memory> +#include <optional> +#include <set> +#include <unordered_set> +#include <string> +#include <utility> +#include <vector> + +#include "minifi-cpp/ResourceClaim.h" +#include "Connectable.h" +#include "WeakReference.h" +#include "minifi-cpp/utils/FlatMap.h" + +namespace org::apache::nifi::minifi::core { + +class Connectable; + +class FlowFile : public virtual CoreComponent, public virtual ReferenceContainer { + public: + using AttributeMap = utils::FlatMap<std::string, std::string>; + + virtual void copy(const FlowFile&) = 0; + + [[nodiscard]] virtual std::shared_ptr<ResourceClaim> getResourceClaim() const = 0; + virtual void setResourceClaim(const std::shared_ptr<ResourceClaim>& claim) = 0; + virtual void clearResourceClaim() = 0; + virtual std::shared_ptr<ResourceClaim> getStashClaim(const std::string& key) = 0; + virtual void setStashClaim(const std::string& key, const std::shared_ptr<ResourceClaim>& claim) = 0; + virtual void clearStashClaim(const std::string& key) = 0; + virtual bool hasStashClaim(const std::string& key) = 0; + virtual const std::vector<utils::Identifier>& getlineageIdentifiers() const = 0; + virtual std::vector<utils::Identifier>& getlineageIdentifiers() = 0; + [[nodiscard]] virtual bool isDeleted() const = 0; + virtual void setDeleted(bool deleted) = 0; + [[nodiscard]] virtual std::chrono::system_clock::time_point getEntryDate() const = 0; + [[nodiscard]] virtual std::chrono::system_clock::time_point getEventTime() const = 0; + [[nodiscard]] virtual std::chrono::system_clock::time_point getlineageStartDate() const = 0; + virtual void setLineageStartDate(std::chrono::system_clock::time_point date) = 0; + virtual void setLineageIdentifiers(const std::vector<utils::Identifier>& lineage_Identifiers) = 0; + virtual bool getAttribute(std::string_view key, std::string& value) const = 0; + [[nodiscard]] virtual std::optional<std::string> getAttribute(std::string_view key) const = 0; + virtual bool updateAttribute(std::string_view key, const std::string& value) = 0; + virtual bool removeAttribute(std::string_view key) = 0; + virtual bool setAttribute(std::string_view key, std::string value) = 0; + [[nodiscard]] virtual std::map<std::string, std::string> getAttributes() const = 0; + virtual AttributeMap *getAttributesPtr() = 0; + virtual bool addAttribute(std::string_view key, const std::string& value) = 0; + virtual void setSize(const uint64_t size) = 0; + [[nodiscard]] virtual uint64_t getSize() const = 0; + virtual void setOffset(const uint64_t offset) = 0; + [[nodiscard]] virtual std::chrono::steady_clock::time_point getPenaltyExpiration() const = 0; + virtual void setPenaltyExpiration(std::chrono::time_point<std::chrono::steady_clock> to_be_processed_after) = 0; + [[nodiscard]] virtual uint64_t getOffset() const = 0; + [[nodiscard]] virtual bool isPenalized() const = 0; + [[nodiscard]] virtual uint64_t getId() const = 0; + virtual void setConnection(core::Connectable* connection) = 0; + [[nodiscard]] virtual Connectable* getConnection() const = 0; + virtual void setStoredToRepository(bool storedInRepository) = 0; + [[nodiscard]] virtual bool isStored() const = 0; + + static std::shared_ptr<FlowFile> create(); +}; + +// FlowFile Attribute +struct SpecialFlowAttribute { + // The flowfile's path indicates the relative directory to which a FlowFile belongs and does not contain the filename + MINIFIAPI static constexpr std::string_view PATH = "path"; + // The flowfile's absolute path indicates the absolute directory to which a FlowFile belongs and does not contain the filename + MINIFIAPI static constexpr std::string_view ABSOLUTE_PATH = "absolute.path"; + // The filename of the FlowFile. The filename should not contain any directory structure. + MINIFIAPI static constexpr std::string_view FILENAME = "filename"; + // A unique UUID assigned to this FlowFile. + MINIFIAPI static constexpr std::string_view UUID = "uuid"; + // A numeric value indicating the FlowFile priority + MINIFIAPI static constexpr std::string_view priority = "priority"; + // The MIME Type of this FlowFile + MINIFIAPI static constexpr std::string_view MIME_TYPE = "mime.type"; + // Specifies the reason that a FlowFile is being discarded + MINIFIAPI static constexpr std::string_view DISCARD_REASON = "discard.reason"; + // Indicates an identifier other than the FlowFile's UUID that is known to refer to this FlowFile. + MINIFIAPI static constexpr std::string_view ALTERNATE_IDENTIFIER = "alternate.identifier"; + // Flow identifier + MINIFIAPI static constexpr std::string_view FLOW_ID = "flow.id"; Review Comment: I think these comments can be removed ########## core/include/minifi-cpp/core/ObjectFactory.h: ########## @@ -0,0 +1,51 @@ +/** + * 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 <string> +#include <memory> +#include <utility> +#include "Core.h" + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace core { + +/** + * Factory that is used as an interface for + * creating processors from shared objects. + */ Review Comment: Is this comment valid? ########## core/include/minifi-cpp/core/Property.h: ########## @@ -147,8 +120,10 @@ class Property { void setAllowedValues(gsl::span<const std::string_view> allowed_values, const core::PropertyParser& property_parser); + /** + * Add value to the collection of values. + */ Review Comment: I think this and other method comments that have no additional value in this file can be removed ########## core/include/minifi-cpp/core/ProcessSessionFactory.h: ########## @@ -0,0 +1,45 @@ +/** + * @file ProcessSessionFactory.h + * ProcessSessionFactory 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. + */ + +#pragma once + +#include <memory> + +#include "ProcessContext.h" +#include "ProcessSession.h" + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace core { Review Comment: Could be merged ########## core/include/minifi-cpp/core/Repository.h: ########## @@ -0,0 +1,80 @@ +/** + * @file Repository + * Repository 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. + */ +#pragma once + +#include <atomic> +#include <cstdint> +#include <cstring> +#include <map> +#include <memory> +#include <set> +#include <string> +#include <string_view> Review Comment: atomic and string_view can be removed ########## core/include/minifi-cpp/core/controller/ControllerServiceLookup.h: ########## @@ -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. + */ +#ifndef LIBMINIFI_INCLUDE_CORE_CONTROLLER_CONTROLLERSERVICELOOKUP_H_ +#define LIBMINIFI_INCLUDE_CORE_CONTROLLER_CONTROLLERSERVICELOOKUP_H_ + +#include <memory> +#include <string> +#include <map> +#include "minifi-cpp/core/Core.h" +#include "minifi-cpp/core/ConfigurableComponent.h" +#include "ControllerService.h" + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace core { +namespace controller { Review Comment: The include guards can be replaced with #pragma once and merge the namespaces ########## extension-utils/include/FlowFileRecord.h: ########## @@ -0,0 +1,21 @@ +/** + * + * 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 "minifi-cpp/FlowFileRecord.h" Review Comment: Can we replace the #include "FlowFileRecord.h" with #include "minifi-cpp/FlowFileRecord.h" in all files and remove this file? ########## extension-utils/include/ResourceClaim.h: ########## @@ -0,0 +1,21 @@ +/** + * + * 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 "minifi-cpp/ResourceClaim.h" Review Comment: Can we replace the #include "ResourceClaim.h" with #include "minifi-cpp/ResourceClaim.h" where it is used and remove this file? ########## libminifi/include/core/state/FlowIdentifier.h: ########## @@ -15,10 +15,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef LIBMINIFI_INCLUDE_CORE_STATE_FLOWIDENTIFIER_H_ -#define LIBMINIFI_INCLUDE_CORE_STATE_FLOWIDENTIFIER_H_ +#pragma once #include <string> +#include "minifi-cpp/core/state/FlowIdentifier.h" namespace org { Review Comment: These namespaces could be merged ########## libminifi/include/core/controller/ControllerServiceNode.h: ########## @@ -25,25 +25,26 @@ #include "core/Core.h" #include "core/ConfigurableComponent.h" #include "core/logging/Logger.h" +#include "minifi-cpp/core/controller/ControllerServiceNode.h" #include "core/PropertyDefinition.h" #include "core/PropertyDefinitionBuilder.h" #include "properties/Configure.h" -#include "ControllerService.h" +#include "minifi-cpp/core/controller/ControllerService.h" #include "io/validation.h" #include "Exception.h" namespace org::apache::nifi::minifi::core::controller { -class ControllerServiceNode : public CoreComponent, public ConfigurableComponent { +class ControllerServiceNodeImpl : public CoreComponentImpl, public ConfigurableComponentImpl, public virtual ControllerServiceNode { public: /** * Constructor for the controller service node. * @param service controller service reference * @param id identifier for this node. * @param configuration shared pointer configuration. */ Review Comment: This comment can be removed, please check if other comments could also be removed in this file. ########## core/include/minifi-cpp/core/ProcessorMetrics.h: ########## @@ -0,0 +1,51 @@ +/** + * 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 <string> +#include <chrono> +#include <atomic> +#include <unordered_map> Review Comment: This can be removed ########## core/include/minifi-cpp/core/controller/ControllerService.h: ########## @@ -0,0 +1,67 @@ +/** + * + * 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 <memory> +#include <string> +#include <utility> +#include <vector> + +#include "minifi-cpp/properties/Configure.h" +#include "minifi-cpp/core/Core.h" +#include "minifi-cpp/core/ConfigurableComponent.h" +#include "minifi-cpp/core/Connectable.h" + +namespace org::apache::nifi::minifi::core::controller { + +enum ControllerServiceState { + /** + * Controller Service is disabled and cannot be used. + */ + DISABLED, + /** + * Controller Service is in the process of being disabled. + */ + DISABLING, + /** + * Controller Service is being enabled. + */ + ENABLING, + /** + * Controller Service is enabled. + */ + ENABLED Review Comment: I think these comments can be removed ########## libminifi/include/provenance/Provenance.h: ########## @@ -440,8 +339,8 @@ class ProvenanceReporter { // Prevent default copy constructor and assignment operation // Only support pass by reference or pointer Review Comment: Remove comments ########## libminifi/test/schema-tests/SchemaTests.cpp: ########## @@ -132,6 +132,7 @@ TEST_CASE("The generated JSON schema matches a valid json flow") { } TEST_CASE("The JSON schema detects invalid values in the json flow") { + std::ofstream{"/Users/adebreceni/work/minifi-homes/json-schema-test/schema.json"} << minifi::docs::generateJsonSchema(); Review Comment: Is this left here by mistake? ########## core/include/minifi-cpp/core/ProcessContextBuilder.h: ########## @@ -0,0 +1,57 @@ +/** + * 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 <string> +#include <vector> +#include <queue> +#include <map> +#include <mutex> +#include <atomic> +#include <algorithm> +#include <memory> Review Comment: Vector, queue, atomic, mutex, map can be removed here (maybe Property.h and VariableRegistry.h as well) ########## utils/include/core/ProcessorMetrics.h: ########## @@ -36,26 +36,30 @@ concept DividableByInteger = requires(T x, uint32_t divisor) { x / divisor; }; class Processor; -class ProcessorMetrics : public state::response::ResponseNode { +class ProcessorMetricsImpl : public state::response::ResponseNodeImpl, public virtual ProcessorMetrics { public: - explicit ProcessorMetrics(const Processor& source_processor); + explicit ProcessorMetricsImpl(const Processor& source_processor); [[nodiscard]] std::string getName() const override; std::vector<state::response::SerializedResponseNode> serialize() override; std::vector<state::PublishedMetric> calculateMetrics() override; - void increaseRelationshipTransferCount(const std::string& relationship, size_t count = 1); - std::chrono::milliseconds getAverageOnTriggerRuntime() const; - std::chrono::milliseconds getLastOnTriggerRuntime() const; - void addLastOnTriggerRuntime(std::chrono::milliseconds runtime); + void increaseRelationshipTransferCount(const std::string& relationship, size_t count = 1) override; + std::chrono::milliseconds getAverageOnTriggerRuntime() const override; + std::chrono::milliseconds getLastOnTriggerRuntime() const override; + void addLastOnTriggerRuntime(std::chrono::milliseconds runtime) override; - std::chrono::milliseconds getAverageSessionCommitRuntime() const; - std::chrono::milliseconds getLastSessionCommitRuntime() const; - void addLastSessionCommitRuntime(std::chrono::milliseconds runtime); + std::chrono::milliseconds getAverageSessionCommitRuntime() const override; + std::chrono::milliseconds getLastSessionCommitRuntime() const override; + void addLastSessionCommitRuntime(std::chrono::milliseconds runtime) override; - std::atomic<size_t> iterations{0}; - std::atomic<size_t> transferred_flow_files{0}; - std::atomic<uint64_t> transferred_bytes{0}; + std::atomic<size_t>& iterations() override {return iterations_;} + std::atomic<size_t>& transferred_flow_files() override {return transferred_flow_files_;} + std::atomic<uint64_t>& transferred_bytes() override {return transferred_bytes_;} + + const std::atomic<size_t>& iterations() const override {return iterations_;} + const std::atomic<size_t>& transferred_flow_files() const override {return transferred_flow_files_;} + const std::atomic<uint64_t>& transferred_bytes() const override {return transferred_bytes_;} Review Comment: We should use camelCase if we change these to getter methods. ########## core/include/minifi-cpp/core/ProcessorNode.h: ########## @@ -0,0 +1,52 @@ +/** + * 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 <memory> +#include <set> +#include <string> +#include <utility> +#include <vector> + +#include "ConfigurableComponent.h" +#include "Connectable.h" +#include "Property.h" + +namespace org::apache::nifi::minifi::core { + +/** + * Processor node functions as a pass through to the implementing Connectables + */ Review Comment: This can be removed, I'm not sure it makes sense ########## core/include/minifi-cpp/core/Scheduling.h: ########## @@ -0,0 +1,57 @@ +/** + * + * 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_SCHEDULING_H_ +#define LIBMINIFI_INCLUDE_CORE_SCHEDULING_H_ + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace core { Review Comment: We can replace it with #pragma once and merge the namespaces ########## core/include/minifi-cpp/core/ProcessorConfig.h: ########## @@ -0,0 +1,62 @@ +/** + * 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_PROCESSORCONFIG_H_ +#define LIBMINIFI_INCLUDE_CORE_PROCESSORCONFIG_H_ Review Comment: We could replace these with #pragma once ########## core/include/minifi-cpp/core/Processor.h: ########## @@ -0,0 +1,104 @@ +/** + * 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 <utils/Id.h> + +#include <algorithm> +#include <atomic> +#include <chrono> +#include <condition_variable> +#include <functional> +#include <memory> +#include <mutex> +#include <string> +#include <string_view> +#include <unordered_set> +#include <unordered_map> +#include <utility> +#include <vector> + +#include "ConfigurableComponent.h" +#include "Connectable.h" +#include "Core.h" +#include "minifi-cpp/core/Annotation.h" +#include "DynamicProperty.h" +#include "Scheduling.h" +#include "utils/TimeUtil.h" +#include "minifi-cpp/core/state/nodes/MetricsBase.h" +#include "ProcessorMetrics.h" +#include "utils/gsl.h" Review Comment: I think algorithm, atomic, condition_variable, functional, string_view, DynamicProperty, TimeUtil can be removed ########## core/include/minifi-cpp/core/ProcessContext.h: ########## @@ -0,0 +1,91 @@ +/** + * 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 <algorithm> +#include <atomic> +#include <concepts> +#include <map> +#include <memory> +#include <mutex> +#include <optional> +#include <queue> +#include <string> +#include <unordered_map> +#include <vector> Review Comment: Some includes like algorithm, athomic, concepts, map, mutex, queue, unordered_map can be removed ########## core/include/minifi-cpp/core/ProcessorConfig.h: ########## @@ -0,0 +1,62 @@ +/** + * 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_PROCESSORCONFIG_H_ +#define LIBMINIFI_INCLUDE_CORE_PROCESSORCONFIG_H_ + +#include <string> +#include <vector> + +#include "Core.h" +#include "Property.h" + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace core { Review Comment: These can be merged ########## core/include/minifi-cpp/core/ObjectFactory.h: ########## @@ -0,0 +1,51 @@ +/** + * 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 <string> +#include <memory> +#include <utility> +#include "Core.h" + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace core { Review Comment: These namespaces can be merged ########## core/include/minifi-cpp/core/ProcessSession.h: ########## @@ -0,0 +1,136 @@ +/** + * + * 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 <memory> +#include <string> +#include <utility> +#include <vector> +#include <queue> +#include <map> +#include <mutex> +#include <atomic> +#include <algorithm> +#include <set> +#include <unordered_map> +#include <unordered_set> Review Comment: Most of these can be removed as well. ########## core/include/minifi-cpp/core/state/nodes/ResponseNodeLoader.h: ########## @@ -0,0 +1,56 @@ +/** + * + * 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 <unordered_map> Review Comment: This include can be removed ########## core/include/minifi-cpp/core/PropertyDefinition.h: ########## @@ -33,17 +32,17 @@ struct PropertyDefinition { std::string_view name; std::string_view display_name; std::string_view description; - bool is_required = false; - bool is_sensitive = false; + bool is_required; + bool is_sensitive; std::array<std::string_view, NumAllowedValues> allowed_values; std::span<const std::string_view> allowed_types; std::array<std::string_view, NumDependentProperties> dependent_properties; std::array<std::pair<std::string_view, std::string_view>, NumExclusiveOfProperties> exclusive_of_properties; std::optional<std::string_view> default_value; - gsl::not_null<const PropertyType*> type{gsl::make_not_null(&StandardPropertyTypes::VALID_TYPE)}; - bool supports_expression_language = false; + gsl::not_null<const PropertyType*> type; + bool supports_expression_language; - uint8_t version = 1; + uint8_t version; Review Comment: Why were the default initializations removed here? ########## core/include/minifi-cpp/core/WeakReference.h: ########## @@ -0,0 +1,62 @@ +/** + * + * 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 <memory> + +#include <type_traits> +#include <vector> + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace core { Review Comment: we can merge these namespaces ########## utils/include/core/logging/Logger.h: ########## @@ -0,0 +1,20 @@ +/** + * 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 "minifi-cpp/core/logging/Logger.h" Review Comment: Same as before ########## core/include/minifi-cpp/utils/TimeUtil.h: ########## @@ -0,0 +1,58 @@ +/** + * 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 <string> +#include <chrono> + +namespace org::apache::nifi::minifi::utils::timeutils { + +/** + * Mockable clock classes + */ Review Comment: This comment can be removed ########## core/include/minifi-cpp/core/state/nodes/MetricsBase.h: ########## @@ -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. + */ +#pragma once + +#include <utility> +#include <vector> +#include <memory> +#include <string> +#include <optional> +#include <unordered_map> Review Comment: The unordered_map include can be removed, and I think the comments can be removed in this file ########## core/include/minifi-cpp/core/extension/ExtensionManager.h: ########## @@ -0,0 +1,36 @@ +/** + * 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 <memory> +#include <string> +#include <vector> Review Comment: I think these can be removed ########## core/include/minifi-cpp/core/state/FlowIdentifier.h: ########## @@ -0,0 +1,48 @@ +/** + * + * 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 <string> + + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace state { Review Comment: These can be merged ########## utils/include/core/ContentRepository.h: ########## @@ -25,46 +25,45 @@ #include <utility> #include <list> -#include "properties/Configure.h" -#include "ResourceClaim.h" #include "StreamManager.h" #include "ContentSession.h" -#include "core/RepositoryMetricsSource.h" #include "core/Core.h" +#include "minifi-cpp/core/ContentRepository.h" +#include "core/RepositoryMetricsSource.h" namespace org::apache::nifi::minifi::core { /** * Content repository definition that extends StreamManager. */ -class ContentRepository : public core::CoreComponent, public StreamManager<minifi::ResourceClaim>, public utils::EnableSharedFromThis<ContentRepository>, public core::RepositoryMetricsSource { +class ContentRepositoryImpl : public CoreComponentImpl, public StreamManagerImpl<minifi::ResourceClaim>, public RepositoryMetricsSourceImpl, public virtual ContentRepository { class ContentStreamAppendLock : public StreamAppendLock { public: - ContentStreamAppendLock(std::shared_ptr<ContentRepository> repository, const minifi::ResourceClaim& claim): repository_(std::move(repository)), content_path_(claim.getContentFullPath()) {} + ContentStreamAppendLock(std::shared_ptr<ContentRepositoryImpl> repository, const minifi::ResourceClaim& claim): repository_(std::move(repository)), content_path_(claim.getContentFullPath()) {} ~ContentStreamAppendLock() override {repository_->unlockAppend(content_path_);} private: - std::shared_ptr<ContentRepository> repository_; + std::shared_ptr<ContentRepositoryImpl> repository_; ResourceClaim::Path content_path_; }; public: - explicit ContentRepository(std::string_view name, const utils::Identifier& uuid = {}) : core::CoreComponent(name, uuid) {} - ~ContentRepository() override = default; + explicit ContentRepositoryImpl(std::string_view name, const utils::Identifier& uuid = {}) : core::CoreComponentImpl(name, uuid) {} + ~ContentRepositoryImpl() override = default; - virtual bool initialize(const std::shared_ptr<Configure> &configure) = 0; + bool initialize(const std::shared_ptr<Configure> &configure) override = 0; std::string getStoragePath() const override; - virtual std::shared_ptr<ContentSession> createSession(); - void reset(); + std::shared_ptr<ContentSession> createSession() override; + void reset() override; uint32_t getStreamCount(const minifi::ResourceClaim &streamId) override; void incrementStreamCount(const minifi::ResourceClaim &streamId) override; StreamState decrementStreamCount(const minifi::ResourceClaim &streamId) override; - virtual void clearOrphans() = 0; + void clearOrphans() override = 0; Review Comment: Methods with `override = 0;` should be removed ########## extension-utils/include/core/FlowFile.h: ########## @@ -0,0 +1,20 @@ +/** + * 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 "minifi-cpp/core/FlowFile.h" Review Comment: Can the #include "core/FlowFile.h" includes replaced with #include "minifi-cpp/core/FlowFile.h" and this file removed? ########## utils/include/core/OutputAttributeDefinition.h: ########## @@ -0,0 +1,20 @@ +/** + * 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 "minifi-cpp/core/OutputAttributeDefinition.h" Review Comment: Same as before ########## utils/include/core/Annotation.h: ########## @@ -0,0 +1,20 @@ +/** + * 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 "minifi-cpp/core/Annotation.h" Review Comment: Same as before ########## utils/include/utils/gsl.h: ########## @@ -0,0 +1,21 @@ +/** + * + * 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 "minifi-cpp/utils/gsl.h" Review Comment: Same as before ########## utils/src/core/Core.cpp: ########## @@ -33,21 +33,21 @@ CoreComponent::CoreComponent(std::string_view name, const utils::Identifier& uui } // Set UUID -void CoreComponent::setUUID(const utils::Identifier& uuid) { +void CoreComponentImpl::setUUID(const utils::Identifier& uuid) { uuid_ = uuid; } // Get UUID -utils::Identifier CoreComponent::getUUID() const { +utils::Identifier CoreComponentImpl::getUUID() const { return uuid_; } // Set Processor Name -void CoreComponent::setName(std::string name) { +void CoreComponentImpl::setName(std::string name) { name_ = std::move(name); } // Get Process Name Review Comment: These useless comments can be removed ########## extension-utils/include/properties/Properties.h: ########## @@ -0,0 +1,19 @@ +/** + * 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 "minifi-cpp/properties/Properties.h" Review Comment: Can the includes be changed and this file removed? ########## core/include/minifi-cpp/utils/AnyRef.h: ########## @@ -0,0 +1,29 @@ +/** + * 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 + +namespace org::apache::nifi::minifi::utils { + +class AnyRef { Review Comment: Is this class used anywhere? Maybe this file can be removed. ########## utils/include/utils/MinifiConcurrentQueue.h: ########## @@ -0,0 +1,251 @@ +/** + * 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_UTILS_MINIFICONCURRENTQUEUE_H_ +#define LIBMINIFI_INCLUDE_UTILS_MINIFICONCURRENTQUEUE_H_ + + +#include <algorithm> +#include <chrono> +#include <deque> +#include <mutex> +#include <condition_variable> +#include <utility> +#include <stdexcept> +#include <atomic> + +#include "utils/TryMoveCall.h" + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace utils { Review Comment: We can merge these namespaces ########## utils/include/io/BaseStream.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. + */ + +#pragma once + +#include <string> +#include <vector> +#include <iostream> +#include <cstdint> Review Comment: I think these includes can be removed ########## utils/include/core/Core.h: ########## @@ -141,48 +89,45 @@ std::unique_ptr<T> instantiate(const std::string name = {}) { * Purpose: Many objects store a name and UUID, therefore * the functionality is localized here to avoid duplication */ -class CoreComponent { +class CoreComponentImpl : public virtual CoreComponent { public: - explicit CoreComponent(std::string_view name, const utils::Identifier &uuid = {}, const std::shared_ptr<utils::IdGenerator> &idGenerator = utils::IdGenerator::getIdGenerator()); - CoreComponent(const CoreComponent &other) = default; - CoreComponent(CoreComponent &&other) = default; - CoreComponent& operator=(const CoreComponent&) = default; - CoreComponent& operator=(CoreComponent&&) = default; + explicit CoreComponentImpl(std::string_view name, const utils::Identifier &uuid = {}, const std::shared_ptr<utils::IdGenerator> &idGenerator = utils::IdGenerator::getIdGenerator()); + CoreComponentImpl(const CoreComponentImpl &other) = default; + CoreComponentImpl(CoreComponentImpl &&other) = default; + CoreComponentImpl& operator=(const CoreComponentImpl&) = default; + CoreComponentImpl& operator=(CoreComponentImpl&&) = default; - virtual ~CoreComponent() = default; + ~CoreComponentImpl() override = default; // Get component name - [[nodiscard]] virtual std::string getName() const; + [[nodiscard]] std::string getName() const override; /** * Set name. * @param name */ - virtual void setName(std::string name); + void setName(std::string name) override; /** * Set UUID in this instance * @param uuid uuid to apply to the internal representation. */ - virtual void setUUID(const utils::Identifier& uuid); + void setUUID(const utils::Identifier& uuid) override; /** * Returns the UUID. * @return the uuid of the component */ - [[nodiscard]] utils::Identifier getUUID() const; + [[nodiscard]] utils::Identifier getUUID() const override; /** * Return the UUID string */ Review Comment: These comments can be removed ########## utils/include/agent/agent_version.h: ########## @@ -0,0 +1,19 @@ +/** + * 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 "minifi-cpp/agent/agent_version.h" Review Comment: Same as before ########## utils/include/utils/Literals.h: ########## @@ -0,0 +1,19 @@ +/** + * 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 "minifi-cpp/utils/Literals.h" Review Comment: Same as before ########## utils/include/core/ContentRepository.h: ########## @@ -25,46 +25,45 @@ #include <utility> #include <list> -#include "properties/Configure.h" -#include "ResourceClaim.h" #include "StreamManager.h" #include "ContentSession.h" -#include "core/RepositoryMetricsSource.h" #include "core/Core.h" +#include "minifi-cpp/core/ContentRepository.h" +#include "core/RepositoryMetricsSource.h" namespace org::apache::nifi::minifi::core { /** * Content repository definition that extends StreamManager. */ Review Comment: This comment can be removed ########## utils/include/core/RelationshipDefinition.h: ########## @@ -0,0 +1,20 @@ +/** + * 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 "minifi-cpp/core/RelationshipDefinition.h" Review Comment: Same as before ########## utils/include/io/ArchiveStream.h: ########## @@ -0,0 +1,20 @@ +/** + * + * 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 "minifi-cpp/io/ArchiveStream.h" Review Comment: Same as before ########## extension-utils/include/properties/Configure.h: ########## @@ -0,0 +1,19 @@ +/** + * 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 "minifi-cpp/properties/Configure.h" Review Comment: Can the includes be changed and this file removed? ########## extension-utils/include/controllers/SSLContextService.h: ########## @@ -0,0 +1,19 @@ +/** + * 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 "minifi-cpp/controllers/SSLContextService.h" Review Comment: Can the #include "controllers/SSLContextService.h" includes be replaced with #include "minifi-cpp/controllers/SSLContextService.h" and this file removed? ########## libminifi/include/core/WeakReference.h: ########## @@ -16,38 +16,21 @@ * limitations under the License. */ -#ifndef LIBMINIFI_INCLUDE_CORE_WEAKREFERENCE_H_ -#define LIBMINIFI_INCLUDE_CORE_WEAKREFERENCE_H_ +#pragma once #include <memory> #include <type_traits> #include <vector> +#include "minifi-cpp/core/WeakReference.h" + namespace org { namespace apache { namespace nifi { namespace minifi { namespace core { Review Comment: Thse namespaces can be merged ########## libminifi/include/core/ProcessSession.h: ########## @@ -30,135 +30,129 @@ #include <unordered_map> #include <unordered_set> -#include "ProcessContext.h" +#include "core/ProcessContext.h" #include "FlowFileRecord.h" #include "Exception.h" #include "core/logging/LoggerFactory.h" -#include "core/Deprecated.h" #include "FlowFile.h" #include "WeakReference.h" #include "provenance/Provenance.h" #include "utils/gsl.h" -#include "ProcessorMetrics.h" +#include "minifi-cpp/core/ProcessorMetrics.h" +#include "minifi-cpp/core/ProcessSession.h" -namespace org::apache::nifi::minifi::core { -namespace detail { -struct ReadBufferResult { - int64_t status; - std::vector<std::byte> buffer; -}; +namespace org::apache::nifi::minifi::core::detail { std::string to_string(const ReadBufferResult& read_buffer_result); -} // namespace detail + +} // namespace org::apache::nifi::minifi::core::detail + +namespace org::apache::nifi::minifi::core { // ProcessSession Class -class ProcessSession : public ReferenceContainer { +class ProcessSessionImpl : public ReferenceContainerImpl, public virtual ProcessSession { public: // Constructor /*! * Create a new process session */ - explicit ProcessSession(std::shared_ptr<ProcessContext> processContext); + explicit ProcessSessionImpl(std::shared_ptr<ProcessContext> processContext); // Destructor - virtual ~ProcessSession(); + ~ProcessSessionImpl() override; // Commit the session - void commit(); + void commit() override; // Roll Back the session - void rollback(); + void rollback() override; - nonstd::expected<void, std::exception_ptr> rollbackNoThrow() noexcept; + nonstd::expected<void, std::exception_ptr> rollbackNoThrow() noexcept override; // Get Provenance Report Review Comment: These and similar useless comments in this file could be removed. ########## utils/include/utils/MinifiConcurrentQueue.h: ########## @@ -0,0 +1,251 @@ +/** + * 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_UTILS_MINIFICONCURRENTQUEUE_H_ +#define LIBMINIFI_INCLUDE_UTILS_MINIFICONCURRENTQUEUE_H_ Review Comment: This can be changed to `#pragma once` ########## utils/include/core/ProcessContext.h: ########## @@ -28,44 +28,38 @@ #include <unordered_map> #include <vector> -#include "controllers/keyvalue/KeyValueStateStorage.h" +#include "minifi-cpp/core/repository/FileSystemRepository.h" #include "core/Core.h" #include "core/ContentRepository.h" -#include "core/repository/FileSystemRepository.h" -#include "core/controller/ControllerServiceProvider.h" -#include "core/controller/ControllerServiceLookup.h" +#include "minifi-cpp/core/controller/ControllerServiceProvider.h" +#include "minifi-cpp/core/controller/ControllerServiceLookup.h" #include "core/logging/LoggerFactory.h" -#include "core/ProcessorNode.h" -#include "core/Property.h" -#include "core/PropertyDefinition.h" -#include "core/Repository.h" -#include "core/FlowFile.h" -#include "core/StateStorage.h" +#include "minifi-cpp/core/ProcessorNode.h" +#include "minifi-cpp/core/Property.h" +#include "minifi-cpp/core/Repository.h" +#include "minifi-cpp/core/FlowFile.h" +#include "minifi-cpp/core/StateStorage.h" #include "core/VariableRegistry.h" -#include "utils/file/FileUtils.h" -#include "utils/PropertyErrors.h" +#include "minifi-cpp/core/ProcessContext.h" +#include "minifi-cpp/controllers/keyvalue/KeyValueStateStorage.h" +#include "core/ConfigurableComponent.h" namespace org::apache::nifi::minifi::core { -namespace detail { -template<typename T> -concept NotAFlowFile = !std::convertible_to<T &, const FlowFile &> && !std::convertible_to<T &, const std::shared_ptr<FlowFile> &>; -} // namespace detail - -class ProcessContext : public core::VariableRegistry, public std::enable_shared_from_this<VariableRegistry> { +class ProcessContextImpl : public core::VariableRegistryImpl, public virtual ProcessContext { public: /*! * Create a new process context associated with the processor/controller service/state manager */ Review Comment: This and similar useless comments can be removed. ########## libminifi/include/core/ProcessSessionFactory.h: ########## @@ -32,25 +32,25 @@ namespace minifi { namespace core { // ProcessSessionFactory Class Review Comment: Please remove the useless comments in this file as well. ########## utils/include/SwapManager.h: ########## @@ -0,0 +1,21 @@ +/** + * + * 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 "minifi-cpp/SwapManager.h" Review Comment: Same as before ########## libminifi/include/core/state/nodes/MetricsBase.h: ########## @@ -24,98 +24,44 @@ #include <optional> #include <unordered_map> -#include "../Value.h" -#include "../PublishedMetricProvider.h" +#include "core/state/Value.h" +#include "core/state/PublishedMetricProvider.h" #include "core/Core.h" #include "core/Connectable.h" +#include "minifi-cpp/core/state/nodes/MetricsBase.h" +#include "core/state/nodes/ResponseNode.h" namespace org::apache::nifi::minifi::state::response { -class ResponseNode; -using SharedResponseNode = gsl::not_null<std::shared_ptr<ResponseNode>>; - -/** - * Purpose: Defines a metric. Serialization is intended to be thread safe. - */ -class ResponseNode : public core::Connectable, public PublishedMetricProvider { - public: - ResponseNode() - : core::Connectable("metric"), - is_array_(false) { - } - - explicit ResponseNode(std::string_view name) - : core::Connectable(name), - is_array_(false) { - } - - ResponseNode(std::string_view name, const utils::Identifier& uuid) - : core::Connectable(name, uuid), - is_array_(false) { - } - - ~ResponseNode() override = default; - - static std::vector<SerializedResponseNode> serializeAndMergeResponseNodes(const std::vector<SharedResponseNode>& nodes); - - virtual std::vector<SerializedResponseNode> serialize() = 0; - - void yield() override { - } - - bool isRunning() const override { - return true; - } - - bool isWorkAvailable() override { - return true; - } - - bool isArray() const { - return is_array_; - } - - virtual bool isEmpty() { - return false; - } - - protected: - bool is_array_; - - void setArray(bool array) { - is_array_ = array; - } -}; - /** * Purpose: Defines a metric that */ -class DeviceInformation : public ResponseNode { +class DeviceInformation : public ResponseNodeImpl { public: DeviceInformation(std::string_view name, const utils::Identifier& uuid) - : ResponseNode(name, uuid) { + : ResponseNodeImpl(name, uuid) { } explicit DeviceInformation(std::string_view name) - : ResponseNode(name) { + : ResponseNodeImpl(name) { } }; /** * Purpose: Defines a metric that */ Review Comment: Thse comments can be removed ########## utils/include/core/PropertyDefinition.h: ########## @@ -0,0 +1,20 @@ +/** + * 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 "minifi-cpp/core/PropertyDefinition.h" Review Comment: We could change these includes as well and remove this file. ########## libminifi/include/core/WeakReference.h: ########## @@ -16,38 +16,21 @@ * limitations under the License. */ -#ifndef LIBMINIFI_INCLUDE_CORE_WEAKREFERENCE_H_ -#define LIBMINIFI_INCLUDE_CORE_WEAKREFERENCE_H_ +#pragma once #include <memory> #include <type_traits> Review Comment: There is an additional space here ########## libminifi/include/properties/Properties.h: ########## @@ -29,40 +29,36 @@ #include "core/logging/Logger.h" #include "utils/ChecksumCalculator.h" #include "utils/StringUtils.h" +#include "minifi-cpp/properties/Properties.h" namespace org::apache::nifi::minifi { -enum class PropertyChangeLifetime { - TRANSIENT, // the changed value will not be committed to disk - PERSISTENT // the changed value will be written to the source file -}; - -class Properties { +class PropertiesImpl : public virtual Properties { struct PropertyValue { std::string persisted_value; std::string active_value; bool need_to_persist_new_value{false}; }; public: - explicit Properties(std::string name = ""); + explicit PropertiesImpl(std::string name = ""); - virtual ~Properties() = default; + ~PropertiesImpl() override = default; - virtual const std::string& getName() const { + const std::string& getName() const override { return name_; } // Clear the load config - void clear() { + void clear() override { std::lock_guard<std::mutex> lock(mutex_); properties_.clear(); } - void set(const std::string& key, const std::string& value) { + void set(const std::string& key, const std::string& value) override { set(key, value, PropertyChangeLifetime::PERSISTENT); } // Set the config value Review Comment: Thrse comments can be removed ########## libminifi/test/flow-tests/FlowControllerTests.cpp: ########## @@ -109,7 +109,7 @@ TEST_CASE("Flow shutdown drains connections", "[TestFlow1]") { testController.configuration_->set(minifi::Configure::nifi_flowcontroller_drain_timeout, "100 ms"); - auto sinkProc = static_cast<minifi::processors::TestProcessor*>(root->findProcessorByName("TestProcessor")); + auto sinkProc = dynamic_cast<minifi::processors::TestProcessor*>(root->findProcessorByName("TestProcessor")); Review Comment: Should we check for cast failure if we change it to dynamic_cast? Same question for libminifi/test/flow-tests/LoopTest.cpp and libminifi/test/flow-tests/MultiLoopTest.cpp ########## utils/CMakeLists.txt: ########## @@ -0,0 +1,23 @@ +file(GLOB SOURCES + src/*.cpp + src/core/*.cpp + src/core/extension/*.cpp + src/io/*.cpp + src/http/*.cpp + src/utils/*.cpp + src/utils/crypto/*.cpp + src/utils/crypto/ciphers/*.cpp + src/utils/crypto/property_encryption/*.cpp + src/utils/net/*.cpp + src/utils/file/*.cpp) + +add_minifi_library(minifi-utils STATIC ${SOURCES}) +target_include_directories(minifi-utils PUBLIC include) +#target_link_libraries(minifi-utils PUBLIC minifi-core magic_enum gsl-lite range-v3 expected-lite spdlog) Review Comment: I suppose this can be removed ########## utils/include/Exception.h: ########## @@ -0,0 +1,21 @@ +/** + * + * 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 "minifi-cpp/Exception.h" Review Comment: These include can probably also can be changed and this file removed ########## libminifi/include/core/state/FlowIdentifier.h: ########## @@ -32,14 +32,14 @@ namespace state { * * Design: Immutable collection of strings for the component parts. */ -class FlowIdentifier { +class FlowIdentifierImpl : public virtual FlowIdentifier { public: - FlowIdentifier() = delete; + FlowIdentifierImpl() = delete; /** * Constructor accepts the url, bucket id, and flow id. */ Review Comment: This comment can be removed ########## libminifi/include/core/controller/ControllerServiceLookup.h: ########## @@ -15,78 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef LIBMINIFI_INCLUDE_CORE_CONTROLLER_CONTROLLERSERVICELOOKUP_H_ -#define LIBMINIFI_INCLUDE_CORE_CONTROLLER_CONTROLLERSERVICELOOKUP_H_ -#include <memory> -#include <string> -#include <map> -#include "core/Core.h" -#include "core/ConfigurableComponent.h" -#include "ControllerService.h" +#pragma once -namespace org { -namespace apache { -namespace nifi { -namespace minifi { -namespace core { -namespace controller { - -/** - * Controller Service Lookup pure virtual class. - * - * Purpose: Provide a mechanism that controllers can lookup information about - * controller services. - * - */ -class ControllerServiceLookup { - public: - ControllerServiceLookup() = default; - - virtual ~ControllerServiceLookup() = default; - - /** - * Gets the controller service via the provided identifier. This overload returns the controller service in a global scope from all - * available controller services in the flow. - * @param identifier reference string for controller service. - * @return controller service reference. - */ - virtual std::shared_ptr<ControllerService> getControllerService(const std::string &identifier) const = 0; - - /** - * Gets the controller service in the scope of the processor via the provided identifier. - * @param identifier reference string for controller service. - * @param processor_uuid uuid of the processor - * @return controller service reference. - */ - virtual std::shared_ptr<ControllerService> getControllerService(const std::string &identifier, const utils::Identifier &processor_uuid) const = 0; - - /** - * Detects if controller service is enabled. - * @param identifier reference string for controller service. - * @return true if controller service is enabled. - */ - virtual bool isControllerServiceEnabled(const std::string &identifier) = 0; - - /** - * Detects if controller service is being enabled. - * @param identifier reference string for controller service. - * @return true if controller service is enabled. - */ - virtual bool isControllerServiceEnabling(const std::string &identifier) = 0; - - /** - * Gets the controller service name for the provided reference identifier - * @param identifier reference string for the controller service. - */ - virtual const std::string getControllerServiceName(const std::string &identifier) const = 0; -}; - -} // namespace controller -} // namespace core -} // namespace minifi -} // namespace nifi -} // namespace apache -} // namespace org - -#endif // LIBMINIFI_INCLUDE_CORE_CONTROLLER_CONTROLLERSERVICELOOKUP_H_ +#include "minifi-cpp/core/controller/ControllerServiceLookup.h" Review Comment: include "core/controller/ControllerServiceLookup.h" includes could be replaced with include "minifi-cpp/core/controller/ControllerServiceLookup.h" and this file removed -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
