fgerlits commented on code in PR #1941:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1941#discussion_r2185700590
##########
bin/minifi.sh:
##########
@@ -183,6 +183,25 @@ status_service() {
fi
}
+flowStatus() {
+ if ! [ -f "${bin_dir}/minificontroller" ]; then
+ echo "MiNiFi Controller is not installed"
+ return
+ fi
+ if [ "$#" -lt 2 ]; then
+ echo "MiNiFi flowStatus operation requires a flow status query
parameter like \"processor:TailFile:health,stats,bulletins\""
+ return
+ fi
+
+ if [ "$#" -lt 3 ]; then
+ exec "${bin_dir}/minificontroller" --flowstatus "$2"
+ elif [ "$#" -lt 3 ]; then
+ exec "${bin_dir}/minificontroller" --port "$2" --flowstatus "$3"
Review Comment:
typo:
```suggestion
elif [ "$#" -lt 4 ]; then
exec "${bin_dir}/minificontroller" --port "$2" --flowstatus "$3"
```
##########
libminifi/include/c2/FlowStatusRequest.h:
##########
@@ -0,0 +1,60 @@
+/**
+ * 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 <unordered_set>
+
+#include "utils/StringUtils.h"
+#include "utils/Enum.h"
+
+namespace org::apache::nifi::minifi::c2 {
+
+enum class FlowStatusQueryType {
+ processor,
+ connection,
+ instance,
+ systemdiagnostics
+};
+
+struct FlowStatusRequest {
+ FlowStatusQueryType query_type;
+ std::string identifier;
+ std::unordered_set<std::string> options;
+
+ explicit FlowStatusRequest(const std::string& query_string) {
+ auto query_parameters =
minifi::utils::string::splitAndTrimRemovingEmpty(query_string, ":");
+ if (query_parameters.size() < 2) {
+ throw std::invalid_argument("Invalid query string: " + query_string);
+ }
+ auto query_type_result =
magic_enum::enum_cast<FlowStatusQueryType>(query_parameters[0]);
+ if (!query_type_result) {
+ throw std::invalid_argument("Invalid query type: " +
query_parameters[0]);
+ }
+ query_type = *query_type_result;
+ if (query_parameters.size() > 2) {
+ identifier = query_parameters[1];
+ auto option_vector =
minifi::utils::string::splitAndTrimRemovingEmpty(query_parameters[2], ",");
+ options = std::unordered_set<std::string>(option_vector.begin(),
option_vector.end());
Review Comment:
Not super-important, but it would seem more natural to parse the options
into enum values, as well. That would help with syntax checking, too.
Currently, if I mistype "bulletins" to "bulletin" (for example), it will be
silently accepted and ignored.
##########
libminifi/include/c2/FlowStatusRequest.h:
##########
@@ -0,0 +1,60 @@
+/**
+ * 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 <unordered_set>
+
+#include "utils/StringUtils.h"
+#include "utils/Enum.h"
+
+namespace org::apache::nifi::minifi::c2 {
+
+enum class FlowStatusQueryType {
+ processor,
+ connection,
+ instance,
+ systemdiagnostics
+};
+
+struct FlowStatusRequest {
+ FlowStatusQueryType query_type;
+ std::string identifier;
+ std::unordered_set<std::string> options;
+
+ explicit FlowStatusRequest(const std::string& query_string) {
Review Comment:
I think this function is too long to be in the header; I would move it to a
.cpp file.
--
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]