Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Embedded Zookeeper listen on 127.0.0.1 #2196

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
mhratson marked this conversation as resolved.
Show resolved Hide resolved
_cnxnFactory.configure(bindAddress, 0);
_cnxnFactory.startup(_zk);
_port = _zk.getClientPort();
Expand Down