Class MiniZooKeeperCluster
java.lang.Object
org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster
TODO: Most of the code in this class is ripped from ZooKeeper tests. Instead of redoing it, we
should contribute updates to their code which let us more easily access testing helper objects.
-
Field Summary
Modifier and TypeFieldDescriptionprivate int
private final org.apache.hadoop.conf.Configuration
private int
private static final int
private int
The default port.static final String
private static final org.slf4j.Logger
static final String
private final List<org.apache.zookeeper.server.NIOServerCnxnFactory>
private boolean
private static final int
private int
private static final int
private final List<org.apache.zookeeper.server.ZooKeeperServer>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addClientPort
(int clientPort) Add a client port to the list.private void
Returns Address for this cluster instance.int
int
Get the list of client ports.private String
getServerConfigurationOnOneLine
(org.apache.zookeeper.server.ZooKeeperServer server) int
(package private) List<org.apache.zookeeper.server.ZooKeeperServer>
private boolean
hasValidClientPortInList
(int index) Check whether the client port in a specific position of the client port list is valid.int
void
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
void
shutdown()
int
int
private static boolean
waitForServerDown
(int port, long timeout) private static boolean
waitForServerUp
(int port, long timeout)
-
Field Details
-
LOG
-
TICK_TIME
- See Also:
-
TIMEOUT
- See Also:
-
DEFAULT_CONNECTION_TIMEOUT
- See Also:
-
connectionTimeout
-
LOOPBACK_HOST
-
HOST
-
started
-
defaultClientPort
The default port. If zero, we use a random port. -
standaloneServerFactoryList
-
zooKeeperServers
-
clientPortList
-
activeZKServerIndex
-
tickTime
-
configuration
-
-
Constructor Details
-
MiniZooKeeperCluster
public MiniZooKeeperCluster() -
MiniZooKeeperCluster
-
-
Method Details
-
addClientPort
Add a client port to the list.- Parameters:
clientPort
- the specified port
-
getClientPortList
Get the list of client ports.- Returns:
- clientPortList the client port list
-
hasValidClientPortInList
Check whether the client port in a specific position of the client port list is valid.- Parameters:
index
- the specified position
-
setDefaultClientPort
-
selectClientPort
Selects a ZK client port.- Parameters:
seedPort
- the seed port to start with; -1 means first time.- Returns:
- a valid and unused client port
-
setTickTime
-
getBackupZooKeeperServerNum
-
getZooKeeperServerNum
-
setupTestEnv
-
startup
- Throws:
IOException
InterruptedException
-
startup
- Parameters:
baseDir
- the base directory to usenumZooKeeperServers
- the number of ZooKeeper servers- Returns:
- ClientPort server bound to, -1 if there was a binding problem and we couldn't pick another port.
- Throws:
IOException
- if an operation fails during the startupInterruptedException
- if the startup fails
-
getServerConfigurationOnOneLine
-
createDir
- Throws:
IOException
-
shutdown
- Throws:
IOException
- if waiting for the shutdown of a server fails
-
killCurrentActiveZooKeeperServer
- Returns:
- clientPort return clientPort if there is another ZK backup can run when killing the current active; return -1, if there is no backups.
- Throws:
IOException
- if waiting for the shutdown of a server failsInterruptedException
-
killOneBackupZooKeeperServer
Kill one back up ZK servers.- Throws:
IOException
- if waiting for the shutdown of a server failsInterruptedException
-
waitForServerDown
- Throws:
IOException
-
waitForServerUp
- Throws:
IOException
-
getClientPort
-
getAddress
Returns Address for this cluster instance. -
getZooKeeperServers
List<org.apache.zookeeper.server.ZooKeeperServer> getZooKeeperServers()
-