adam-markovics commented on a change in pull request #1066:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1066#discussion_r630147443
##########
File path: libminifi/test/unit/MemoryUsageTest.cpp
##########
@@ -20,22 +20,22 @@
#include "utils/OsUtils.h"
#include "../TestBase.h"
-TEST_CASE("Test memory usage", "[testmemoryusage]") {
+TEST_CASE("Test Physical memory usage", "[testphysicalmemoryusage]") {
constexpr bool cout_enabled = true;
Review comment:
What is the purpose of this constant?
##########
File path: extensions/pdh/tests/PerformanceDataMonitorTests.cpp
##########
@@ -0,0 +1,268 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <memory>
+#include <string>
+#include <vector>
+#include <set>
+#include <fstream>
+
+#include "TestBase.h"
+#include "processors/PutFile.h"
+#include "utils/file/FileUtils.h"
+#include "PerformanceDataMonitor.h"
+#include "rapidjson/filereadstream.h"
+
+using PutFile = org::apache::nifi::minifi::processors::PutFile;
Review comment:
It's simpler just like
`using org::apache::nifi::minifi::processors::PutFile;`
Also for the others.
##########
File path: extensions/pdh/PDHCounters.h
##########
@@ -0,0 +1,98 @@
+/**
+ * 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 <TCHAR.h>
+#include <pdh.h>
+#include <pdhmsg.h>
+#include <string>
+
+#include "PerformanceDataCounter.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace processors {
+
+class PDHCounterBase : public PerformanceDataCounter {
+ public:
+ virtual ~PDHCounterBase() {}
+ static PDHCounterBase* createPDHCounter(const std::string& query_name, bool
is_double = true);
+
+ const std::string& getName() const;
+ virtual std::string getObjectName() const;
+ virtual std::string getCounterName() const;
+ virtual PDH_STATUS addToQuery(PDH_HQUERY& pdh_query) = 0;
+ virtual PDH_STATUS collectData() = 0;
+ protected:
+ PDHCounterBase(const std::string& query_name, bool is_double) :
PerformanceDataCounter(),
+ is_double_format_(is_double), pdh_english_counter_name_(query_name) {
+ }
+ DWORD getDWFormat() const;
+ const bool is_double_format_;
+ std::string pdh_english_counter_name_;
+};
+
+class PDHCounter : public PDHCounterBase {
+ public:
+ void addToJson(rapidjson::Value& body, rapidjson::Document::AllocatorType&
alloc) const override;
+
+ PDH_STATUS addToQuery(PDH_HQUERY& pdh_query) override;
+ PDH_STATUS collectData() override;
+
+ protected:
+ friend PDHCounterBase* PDHCounterBase::createPDHCounter(const std::string&
query_name, bool is_double);
+ explicit PDHCounter(const std::string& query_name, bool is_double) :
PDHCounterBase(query_name, is_double),
+ counter_(), current_value_() {
+ }
+ rapidjson::Value getValue() const;
+
+ PDH_HCOUNTER counter_;
+ PDH_FMT_COUNTERVALUE current_value_;
+};
+
+class PDHCounterArray : public PDHCounterBase {
+ public:
+ virtual ~PDHCounterArray() { clearCurrentData(); }
+ void addToJson(rapidjson::Value& body, rapidjson::Document::AllocatorType&
alloc) const override;
+
+ std::string getObjectName() const override;
+ PDH_STATUS addToQuery(PDH_HQUERY& pdh_query) override;
+ PDH_STATUS collectData() override;
+
+ protected:
+ friend PDHCounterBase* PDHCounterBase::createPDHCounter(const std::string&
query_name, bool is_double);
+ explicit PDHCounterArray(std::string query_name, bool is_double) :
PDHCounterBase(query_name, is_double),
Review comment:
If you take query_name by value, you could move it into base class (copy
and move idiom). This could also be done at other constructors.
##########
File path: extensions/pdh/PDHCounters.h
##########
@@ -0,0 +1,98 @@
+/**
+ * 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 <TCHAR.h>
+#include <pdh.h>
+#include <pdhmsg.h>
+#include <string>
+
+#include "PerformanceDataCounter.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace processors {
+
+class PDHCounterBase : public PerformanceDataCounter {
+ public:
+ virtual ~PDHCounterBase() {}
+ static PDHCounterBase* createPDHCounter(const std::string& query_name, bool
is_double = true);
+
+ const std::string& getName() const;
+ virtual std::string getObjectName() const;
+ virtual std::string getCounterName() const;
+ virtual PDH_STATUS addToQuery(PDH_HQUERY& pdh_query) = 0;
+ virtual PDH_STATUS collectData() = 0;
+ protected:
+ PDHCounterBase(const std::string& query_name, bool is_double) :
PerformanceDataCounter(),
+ is_double_format_(is_double), pdh_english_counter_name_(query_name) {
+ }
+ DWORD getDWFormat() const;
+ const bool is_double_format_;
+ std::string pdh_english_counter_name_;
+};
+
+class PDHCounter : public PDHCounterBase {
+ public:
+ void addToJson(rapidjson::Value& body, rapidjson::Document::AllocatorType&
alloc) const override;
+
+ PDH_STATUS addToQuery(PDH_HQUERY& pdh_query) override;
+ PDH_STATUS collectData() override;
+
+ protected:
+ friend PDHCounterBase* PDHCounterBase::createPDHCounter(const std::string&
query_name, bool is_double);
+ explicit PDHCounter(const std::string& query_name, bool is_double) :
PDHCounterBase(query_name, is_double),
+ counter_(), current_value_() {
Review comment:
I think it could be, as they could be fundamental types, so don't let
memory garbage in there. I'm not sure, it should be checked on Windows.
An alternative is default member initialization.
--
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:
[email protected]