@ThreadSafe public class ZookeeperServer extends Object
KafkaCluster| Modifier and Type | Field and Description |
|---|---|
private File |
dataDir |
static int |
DEFAULT_TICK_TIME |
private org.apache.zookeeper.server.ServerCnxnFactory |
factory |
private File |
logDir |
private static org.slf4j.Logger |
LOGGER |
private int |
port |
private org.apache.zookeeper.server.ZooKeeperServer |
server |
private File |
snapshotDir |
private int |
tickTime
The basic time unit in milliseconds used by ZooKeeper.
|
| Constructor and Description |
|---|
ZookeeperServer()
Create a new server instance.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getConnection()
Get the connection string.
|
(package private) File |
getLogDirectory()
Get the parent directory where the server's logs are kept.
|
int |
getPort()
Get the current port.
|
(package private) File |
getSnapshotDirectory()
Get the parent directory where the server's snapshots are kept.
|
File |
getStateDirectory()
Get the parent directory where the server's logs and snapshots will be kept.
|
int |
getTickTime()
Get the basic time unit in milliseconds used by ZooKeeper.
|
(package private) void |
onEachDirectory(Consumer<File> consumer)
Perform the supplied function on each directory used by this server.
|
ZookeeperServer |
setPort(int port)
Set the port for the server.
|
ZookeeperServer |
setStateDirectory(File dataDir)
Set the parent directory where the server's logs and snapshots will be kept.
|
ZookeeperServer |
setTickTime(int tickTime)
Set the basic time unit in milliseconds used by ZooKeeper.
|
void |
shutdown()
Shutdown the embedded Zookeeper server and delete all data.
|
void |
shutdown(boolean deleteData)
Shutdown the embedded Kafka server.
|
ZookeeperServer |
startup()
Start the embedded Zookeeper server.
|
String |
toString() |
private static final org.slf4j.Logger LOGGER
public static int DEFAULT_TICK_TIME
private volatile int tickTime
private volatile int port
private volatile org.apache.zookeeper.server.ServerCnxnFactory factory
private volatile File dataDir
private volatile File snapshotDir
private volatile File logDir
private volatile org.apache.zookeeper.server.ZooKeeperServer server
public ZookeeperServer startup() throws IOException
IOException - if there is an error during startupIllegalStateException - if the server is already runningpublic void shutdown()
public void shutdown(boolean deleteData)
deleteData - true if the data should be removed, or false otherwisepublic String getConnection()
running and the port is to be dynamically discovered
upon startup, then this method returns "localhost:-1".public ZookeeperServer setPort(int port)
port - the desired port, or -1 if a random available port should be found and usedpublic ZookeeperServer setTickTime(int tickTime)
tickTime - the desired value, or non-positive if the default of DEFAULT_TICK_TIME be usedpublic int getPort()
-1 if the port should be discovered upon startup()public int getTickTime()
void onEachDirectory(Consumer<File> consumer)
consumer - the consumer function; may not be nullFile getSnapshotDirectory()
File getLogDirectory()
public File getStateDirectory()
public ZookeeperServer setStateDirectory(File dataDir)
dataDir - the parent directory for the server's logs and snapshots; may be null if a temporary directory will be usedIllegalArgumentException - if the supplied file is not a directory or not writableCopyright © 2021 JBoss by Red Hat. All rights reserved.