@InterfaceAudience.Public @InterfaceStability.Evolving public class MiniZooKeeperCluster extends Object
Modifier and Type | Field and Description |
---|---|
private int |
activeZKServerIndex |
private List<Integer> |
clientPortList |
private org.apache.hadoop.conf.Configuration |
configuration |
private static int |
CONNECTION_TIMEOUT |
private int |
defaultClientPort
The default port.
|
private static org.apache.commons.logging.Log |
LOG |
private List<org.apache.zookeeper.server.NIOServerCnxnFactory> |
standaloneServerFactoryList |
private boolean |
started |
private static int |
TICK_TIME |
private int |
tickTime |
private List<org.apache.zookeeper.server.ZooKeeperServer> |
zooKeeperServers |
Constructor and Description |
---|
MiniZooKeeperCluster() |
MiniZooKeeperCluster(org.apache.hadoop.conf.Configuration configuration) |
Modifier and Type | Method and Description |
---|---|
void |
addClientPort(int clientPort)
Add a client port to the list.
|
private void |
createDir(File dir) |
int |
getBackupZooKeeperServerNum() |
int |
getClientPort() |
List<Integer> |
getClientPortList()
Get the list of client ports.
|
int |
getZooKeeperServerNum() |
private boolean |
hasValidClientPortInList(int index)
Check whether the client port in a specific position of the client port list is valid.
|
int |
killCurrentActiveZooKeeperServer() |
void |
killOneBackupZooKeeperServer()
Kill one back up ZK servers
|
private int |
selectClientPort(int seedPort)
Selects a ZK client port.
|
void |
setDefaultClientPort(int clientPort) |
void |
setTickTime(int tickTime) |
private static void |
setupTestEnv() |
void |
shutdown() |
int |
startup(File baseDir) |
int |
startup(File baseDir,
int numZooKeeperServers) |
private static boolean |
waitForServerDown(int port,
long timeout) |
private static boolean |
waitForServerUp(int port,
long timeout) |
private static final org.apache.commons.logging.Log LOG
private static final int TICK_TIME
private static final int CONNECTION_TIMEOUT
private boolean started
private int defaultClientPort
private List<org.apache.zookeeper.server.NIOServerCnxnFactory> standaloneServerFactoryList
private List<org.apache.zookeeper.server.ZooKeeperServer> zooKeeperServers
private int activeZKServerIndex
private int tickTime
private org.apache.hadoop.conf.Configuration configuration
public MiniZooKeeperCluster()
public MiniZooKeeperCluster(org.apache.hadoop.conf.Configuration configuration)
public void addClientPort(int clientPort)
clientPort
- the specified portpublic List<Integer> getClientPortList()
private boolean hasValidClientPortInList(int index)
index
- the specified positionpublic void setDefaultClientPort(int clientPort)
private int selectClientPort(int seedPort)
seedPort
- the seed port to start with; -1 means first time.public void setTickTime(int tickTime)
public int getBackupZooKeeperServerNum()
public int getZooKeeperServerNum()
private static void setupTestEnv()
public int startup(File baseDir) throws IOException, InterruptedException
IOException
InterruptedException
public int startup(File baseDir, int numZooKeeperServers) throws IOException, InterruptedException
baseDir
- numZooKeeperServers
- IOException
InterruptedException
private void createDir(File dir) throws IOException
IOException
public void shutdown() throws IOException
IOException
public int killCurrentActiveZooKeeperServer() throws IOException, InterruptedException
IOException
InterruptedException
public void killOneBackupZooKeeperServer() throws IOException, InterruptedException
IOException
InterruptedException
private static boolean waitForServerDown(int port, long timeout) throws IOException
IOException
private static boolean waitForServerUp(int port, long timeout) throws IOException
IOException
public int getClientPort()
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.