下面列出了org.apache.zookeeper.server.ZKDatabase#close ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@After
public void tearDown() throws IOException, InterruptedException {
if (zks != null) {
ZKDatabase zkDb = zks.getZKDatabase();
factory.shutdown();
try {
zkDb.close();
} catch (IOException ie) {
}
final int PORT = Integer.parseInt(hostPort.split(":")[1]);
Assert.assertTrue("waiting for server down",
waitForServerDown("127.0.0.1:" + PORT,
CONNECTION_TIMEOUT));
}
}
static void shutdownServerInstance(ServerCnxnFactory factory,
String hostPort)
{
if (factory != null) {
ZKDatabase zkDb;
{
ZooKeeperServer zs = getServer(factory);
zkDb = zs.getZKDatabase();
}
factory.shutdown();
try {
zkDb.close();
} catch (IOException ie) {
LOG.warn("Error closing logs ", ie);
}
final int PORT = getPort(hostPort);
Assert.assertTrue("waiting for server down",
ClientBaseWithFixes.waitForServerDown("127.0.0.1:" + PORT,
CONNECTION_TIMEOUT));
}
}
@After
public void tearDown() throws IOException, InterruptedException {
if (zks != null) {
ZKDatabase zkDb = zks.getZKDatabase();
factory.shutdown();
try {
zkDb.close();
} catch (IOException ie) {
}
final int PORT = Integer.parseInt(hostPort.split(":")[1]);
Assert.assertTrue("waiting for server down",
waitForServerDown("127.0.0.1:" + PORT,
CONNECTION_TIMEOUT));
}
}
static void shutdownServerInstance(ServerCnxnFactory factory,
String hostPort)
{
if (factory != null) {
ZKDatabase zkDb;
{
ZooKeeperServer zs = getServer(factory);
zkDb = zs.getZKDatabase();
}
factory.shutdown();
try {
zkDb.close();
} catch (IOException ie) {
LOG.warn("Error closing logs ", ie);
}
final int PORT = getPort(hostPort);
Assert.assertTrue("waiting for server down",
ClientBaseWithFixes.waitForServerDown("127.0.0.1:" + PORT,
CONNECTION_TIMEOUT));
}
}
/** */
private void shutdownServerInstance(ServerCnxnFactory factory)
{
if (factory != null) {
ZKDatabase zkDb = null;
{
ZooKeeperServer zs = getServer(factory);
if (zs != null)
zkDb = zs.getZKDatabase();
}
factory.shutdown();
try {
if (zkDb != null)
zkDb.close();
} catch (IOException ie) {
// ignore
}
}
}
/**
* Shutdown the serving instance
* @throws IOException If there is a low-level I/O error.
*/
protected void shutdown() throws IOException {
// shutting down the cnxnFactory will close the zooKeeperServer
// zooKeeperServer.shutdown();
ZKDatabase zkDb = zooKeeperServer.getZKDatabase();
try {
if (cnxnFactory != null) {
while (true) {
cnxnFactory.shutdown();
try {
cnxnFactory.join();
break;
} catch (InterruptedException e) {
// Thread.currentThread().interrupt();
// don't keep interrupted status
}
}
}
if (zkDb != null) {
zkDb.close();
}
if (cnxnFactory != null && cnxnFactory.getLocalPort() != 0) {
waitForServerDown(getZkHost(), 30000);
}
} finally {
ObjectReleaseTracker.release(this);
}
}