Skip to content

Commit

Permalink
Set Embedded Zookeeper listen on 127.0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
akatona84 committed Sep 9, 2024
1 parent 15ad631 commit 196634f
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package com.linkedin.kafka.cruisecontrol.metricsreporter.utils;

import java.io.File;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.concurrent.CountDownLatch;
import org.apache.zookeeper.server.NIOServerCnxnFactory;
Expand All @@ -14,7 +13,7 @@


public class CCEmbeddedZookeeper implements AutoCloseable {
private final String _hostAddress;
private final String _hostAddress = "127.0.0.1";
private final int _port;
private final ZooKeeperServer _zk;
private final ServerCnxnFactory _cnxnFactory;
Expand All @@ -27,9 +26,7 @@ public CCEmbeddedZookeeper() {
File logDir = CCKafkaTestUtils.newTempDir();
_zk = new ZooKeeperServer(snapshotDir, logDir, tickTime);
_cnxnFactory = new NIOServerCnxnFactory();
InetAddress localHost = InetAddress.getLocalHost();
_hostAddress = localHost.getHostAddress();
InetSocketAddress bindAddress = new InetSocketAddress(localHost, 0);
InetSocketAddress bindAddress = new InetSocketAddress(_hostAddress, 0);
_cnxnFactory.configure(bindAddress, 0);
_cnxnFactory.startup(_zk);
_port = _zk.getClientPort();
Expand Down

0 comments on commit 196634f

Please sign in to comment.