dariuszseweryn commented on code in PR #10596:
URL: https://github.com/apache/nifi/pull/10596#discussion_r2588475036


##########
nifi-extension-bundles/nifi-kafka-bundle/nifi-kafka-service-shared/src/main/java/org/apache/nifi/kafka/service/verification/KafkaClusterVerifier.java:
##########
@@ -0,0 +1,363 @@
+/*
+ * 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.
+ */
+package org.apache.nifi.kafka.service.verification;
+
+import org.apache.commons.io.function.IOTriConsumer;
+import org.apache.kafka.clients.admin.Admin;
+import org.apache.kafka.clients.admin.DescribeClusterOptions;
+import org.apache.kafka.clients.admin.DescribeClusterResult;
+import org.apache.kafka.common.KafkaFuture;
+import org.apache.kafka.common.Node;
+import org.apache.kafka.common.errors.AuthorizationException;
+import org.apache.nifi.components.ConfigVerificationResult;
+import org.apache.nifi.logging.ComponentLog;
+import org.jetbrains.annotations.VisibleForTesting;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+import static 
org.apache.nifi.components.ConfigVerificationResult.Outcome.FAILED;
+import static 
org.apache.nifi.components.ConfigVerificationResult.Outcome.SKIPPED;
+import static 
org.apache.nifi.components.ConfigVerificationResult.Outcome.SUCCESSFUL;
+
+/**
+ * Verifies Kafka cluster connectivity and node reachability.
+ */
+public class KafkaClusterVerifier {
+
+    private static final String CLUSTER_DESCRIPTION_STEP = "Kafka Cluster 
Description";
+    private static final String NODE_CONFIG_CHECK_STEP = "Kafka Node 
Reachability";
+    private static final String BOOTSTRAP_REACHABILITY_STEP = "Bootstrap 
Server Reachability";
+
+    private final Duration verifyTimeout;
+    private final ComponentLog logger;
+    private final IOTriConsumer<String, Integer, Duration> socketConnector;
+
+    public KafkaClusterVerifier(final Duration verifyTimeout, final 
ComponentLog logger) {
+        this.verifyTimeout = verifyTimeout;
+        this.logger = logger;
+        this.socketConnector = KafkaClusterVerifier::defaultReachServer;
+    }
+
+    @VisibleForTesting
+    KafkaClusterVerifier(final Duration verifyTimeout, final ComponentLog 
logger, final IOTriConsumer<String, Integer, Duration> socketConnector) {

Review Comment:
   Not a concern — it is the only class in the package. The annotation is to 
hint that this constructor is expected to be used only by the tests. Can move 
to the other package though.



-- 
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]

Reply via email to