Skip to content

Commit

Permalink
Do not try to connect to zookeeper if connection string is empty (pro…
Browse files Browse the repository at this point in the history
…vectus#428)

Co-authored-by: Jakub Štiller <stiller@2n.cz>
  • Loading branch information
Delorien84 and Jakub Štiller committed May 13, 2021
1 parent 56c0223 commit dce6020
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import lombok.extern.log4j.Log4j2;
import org.I0Itec.zkclient.ZkClient;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
@RequiredArgsConstructor
Expand All @@ -17,10 +18,12 @@ public class ZookeeperService {

public boolean isZookeeperOnline(KafkaCluster kafkaCluster) {
var isConnected = false;
var zkClient = getOrCreateZkClient(kafkaCluster);
log.debug("Start getting Zookeeper metrics for kafkaCluster: {}", kafkaCluster.getName());
if (zkClient != null) {
isConnected = isZkClientConnected(zkClient);
if (StringUtils.hasText(kafkaCluster.getZookeeper())) {
var zkClient = getOrCreateZkClient(kafkaCluster);
log.debug("Start getting Zookeeper metrics for kafkaCluster: {}", kafkaCluster.getName());
if (zkClient != null) {
isConnected = isZkClientConnected(zkClient);
}
}
return isConnected;
}
Expand Down

0 comments on commit dce6020

Please sign in to comment.