List of usage examples for org.apache.zookeeper.server ZKDatabase close
public void close() throws IOException
From source file:com.linkedin.d2.quorum.ZKPeer.java
License:Apache License
public void close() throws Exception { _log.info("Closing quorum peer #" + getPeerPortsInfo()); try {//w w w . ja v a 2s.c om ZooKeeperServer zkServer = _peer.getActiveServer(); if (zkServer != null) { ZKDatabase zkDb = zkServer.getZKDatabase(); if (zkDb != null) { // make ZK server close its log files zkDb.close(); } } } catch (Exception e) { _log.debug("Failed to close peer #" + getPeerPortsInfo(), e); } }
From source file:com.netflix.curator.test.TestingServer.java
License:Apache License
/** * Stop the server without deleting the temp directory *//*from ww w. j a v a 2s . c o m*/ public void stop() { if (!isStopped.compareAndSet(false, true)) { return; } ZKDatabase zkDb = server.getZKDatabase(); try { zkDb.commit(); zkDb.close(); } catch (Throwable e) { System.err.println("Error closing logs"); e.printStackTrace(); } try { server.shutdown(); ServerHelper.shutdownFactory(factory); } catch (Throwable e) { System.err.println("Error shutting down server"); e.printStackTrace(); } }
From source file:com.netflix.curator.utils.TestingServer.java
License:Apache License
/** * Stop the server without deleting the temp directory *///from w ww .ja v a2s.c o m public void stop() { ZKDatabase zkDb = server.getZKDatabase(); try { zkDb.close(); } catch (IOException e) { System.err.println("Error closing logs"); e.printStackTrace(); } server.shutdown(); factory.shutdown(); }
From source file:org.apache.curator.test.TestingZooKeeperMain.java
License:Apache License
@Override public void close() throws IOException { try {/* ww w . j a v a 2s .c o m*/ shutdown(); } catch (Throwable e) { e.printStackTrace(); // just ignore - this class is only for testing } try { ServerCnxnFactory cnxnFactory = getServerConnectionFactory(); if (cnxnFactory != null) { ZooKeeperServer zkServer = getZooKeeperServer(cnxnFactory); if (zkServer != null) { ZKDatabase zkDb = zkServer.getZKDatabase(); if (zkDb != null) { // make ZK server close its log files zkDb.close(); } } } } catch (Exception e) { e.printStackTrace(); // just ignore - this class is only for testing } }
From source file:org.apache.hadoop.ha.ClientBaseWithFixes.java
License:Apache License
static void shutdownServerInstance(ServerCnxnFactory factory, String hostPort) { if (factory != null) { ZKDatabase zkDb; {/* ww w . ja v a2 s. c om*/ 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)); } }
From source file:org.apache.hadoop.yarn.lib.TestZKClient.java
License:Apache License
@After public void tearDown() throws IOException, InterruptedException { if (zks != null) { ZKDatabase zkDb = zks.getZKDatabase(); factory.shutdown();//from w w w . j a v a 2s. c o m 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)); } }