public class TestingCluster extends Object implements Closeable
| Constructor and Description |
|---|
TestingCluster(Collection<InstanceSpec> specs)
Creates an ensemble using the given server specs
|
TestingCluster(InstanceSpec... specs)
Creates an ensemble using the given server specs
|
TestingCluster(int instanceQty)
Creates an ensemble comprised of
n servers. |
TestingCluster(Map<InstanceSpec,Collection<InstanceSpec>> specs)
Creates an ensemble using the given server specs
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Shutdown the ensemble, free resources, etc.
|
InstanceSpec |
findConnectionInstance(org.apache.zookeeper.ZooKeeper client)
Given a ZooKeeper instance, returns which server it is connected to
|
String |
getConnectString()
Returns the connection string to pass to the ZooKeeper constructor
|
Collection<InstanceSpec> |
getInstances()
Returns the set of servers in the ensemble
|
List<TestingZooKeeperServer> |
getServers() |
boolean |
killServer(InstanceSpec instance)
Kills the given server.
|
boolean |
restartServer(InstanceSpec instance)
Restart the given server of the cluster
|
void |
start()
Start the ensemble.
|
void |
stop()
Shutdown the ensemble WITHOUT freeing resources, etc.
|
public TestingCluster(int instanceQty)
n servers. Each server will use
a temp directory and random portsinstanceQty - number of servers to create in the ensemblepublic TestingCluster(InstanceSpec... specs)
specs - the server specspublic TestingCluster(Collection<InstanceSpec> specs)
specs - the server specspublic TestingCluster(Map<InstanceSpec,Collection<InstanceSpec>> specs)
specs - map of an instance spec to its set of quorum instances. Allows simulation of an ensemble with instances
having different config peerspublic Collection<InstanceSpec> getInstances()
public List<TestingZooKeeperServer> getServers()
public String getConnectString()
public void start()
throws Exception
Exception - errorspublic void stop()
throws IOException
IOExceptionpublic void close()
throws IOException
finally block.close in interface Closeableclose in interface AutoCloseableIOException - errorspublic boolean killServer(InstanceSpec instance) throws Exception
instance - server to killException - errorspublic boolean restartServer(InstanceSpec instance) throws Exception
instance - server instanceException - errorspublic InstanceSpec findConnectionInstance(org.apache.zookeeper.ZooKeeper client) throws Exception
client - ZK instanceException - errorsCopyright © 2011–2016 The Apache Software Foundation. All rights reserved.