Java Code Examples for org.apache.zookeeper.server.ZKDatabase#close()

The following examples show how to use org.apache.zookeeper.server.ZKDatabase#close() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestZKClient.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@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));
  }

}
 
Example 2
Source File: ClientBaseWithFixes.java    From hadoop with Apache License 2.0 6 votes vote down vote up
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));
    }
}
 
Example 3
Source File: TestZKClient.java    From big-c with Apache License 2.0 6 votes vote down vote up
@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));
  }

}
 
Example 4
Source File: ClientBaseWithFixes.java    From big-c with Apache License 2.0 6 votes vote down vote up
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));
    }
}
 
Example 5
Source File: ZookeeperDiscoverySpiSaslAuthAbstractTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** */
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
        }
    }
}
 
Example 6
Source File: ZkTestServer.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
  }
}