@After public void tearDown() throws Exception { LOG.info("STOPPING quorum " + getClass().getName()); for (int i = 0; i < SERVER_COUNT; i++) { mt[i].shutdown(); } }
@Override public void start() { try { latch.countDown(); followerAMT.shutdown(); } catch (Exception e) {} } };
MainThread shutdown(int index) { MainThread mainThread = mt.get(index); try { mainThread.shutdown(); } catch (InterruptedException e) { } finally { mt.remove(index); } mainThread.deleteBaseDir(); return mainThread; } }
/** * It's possible during taking fuzzy snapshot, the parent is serialized * before the child get deleted in the fuzzy range. * * In which case, we need to make sure the pzxid get correctly updated * when replaying the txns. */ @Test public void testPZxidUpdatedWhenLoadingSnapshot() throws Exception { final String parent = "/testPZxidUpdatedDuringTakingSnapshot"; final String child = parent + "/child"; createEmptyNode(zk[followerA], parent); createEmptyNode(zk[followerA], child); LOG.info("Set up ZKDatabase to catch the node serializing in DataTree"); addSerializeListener(followerA, parent, child); LOG.info("Take snapshot on follower A"); ZooKeeperServer zkServer = mt[followerA].main.quorumPeer.getActiveServer(); zkServer.takeSnapshot(true); LOG.info("Restarting follower A to load snapshot"); mt[followerA].shutdown(); QuorumPeerMainTest.waitForOne(zk[followerA], States.CONNECTING); mt[followerA].start(); QuorumPeerMainTest.waitForOne(zk[followerA], States.CONNECTED); LOG.info("Check and make sure the pzxid of the parent is the same " + "on leader and follower A"); compareStat(parent, leaderId, followerA); }
/** * Developers might use standalone mode (which is the default for one server). * This test checks SSL works in standalone mode of ZK server. * <p/> * Note that in this test the Zk server has only secureClientPort */ @Test public void testSecureStandaloneServer() throws Exception { Integer secureClientPort = PortAssignment.unique(); MainThread mt = new MainThread(MainThread.UNSET_MYID, "", secureClientPort, false); mt.start(); ZooKeeper zk = ClientBase.createZKClient("127.0.0.1:" + secureClientPort, TIMEOUT); zk.create("/test", "".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); zk.delete("/test", -1); zk.close(); mt.shutdown(); } }
private void shutdown() throws InterruptedException { LOG.info("Shutting down all servers"); zk.close(); q1.shutdown(); q2.shutdown(); q3.shutdown(); Assert.assertTrue("Waiting for server 1 to shut down", ClientBase.waitForServerDown("127.0.0.1:"+CLIENT_PORT_QP1, ClientBase.CONNECTION_TIMEOUT)); Assert.assertTrue("Waiting for server 2 to shut down", ClientBase.waitForServerDown("127.0.0.1:"+CLIENT_PORT_QP2, ClientBase.CONNECTION_TIMEOUT)); Assert.assertTrue("Waiting for server 3 to shut down", ClientBase.waitForServerDown("127.0.0.1:"+CLIENT_PORT_OBS, ClientBase.CONNECTION_TIMEOUT)); }
@After public void tearDown() { // stop all severs if (null != mt) { for (int i = 0; i < SERVER_COUNT; i++) { try { // With the defect, leader hangs here also, but with fix // it does not mt[i].shutdown(); } catch (InterruptedException e) { LOG.warn("Quorum Peer interrupted while shutting it down", e); } } } }
private void stopAppendConfigRestartAll(Map<Integer, MainThread> members, String config) throws Exception { for (Map.Entry<Integer, MainThread> entry : members.entrySet()) { int clientPort = entry.getKey(); MainThread member = entry.getValue(); member.shutdown(); Assert.assertTrue(ClientBase.waitForServerDown("127.0.0.1:" + clientPort, CONNECTION_TIMEOUT)); FileWriter fileWriter = new FileWriter(member.getConfFile(), true); fileWriter.write(config); fileWriter.flush(); fileWriter.close(); member.start(); Assert.assertTrue(ClientBase.waitForServerUp("127.0.0.1:" + clientPort, CONNECTION_TIMEOUT)); } }
public void shutDownAllServers() throws InterruptedException { for (MainThread t: mt) { t.shutdown(); } }
@After public void tearDown() { // stop all severs if (null != mt) { for (int i = 0; i < mt.length; i++) { try { mt[i].shutdown(); } catch (InterruptedException e) { LOG.warn("Quorum Peer interrupted while shutting it down", e); } } } }
@After public void tearDown() throws Exception { for (MainThread mainThread : mt) { mainThread.shutdown(); mainThread.deleteBaseDir(); } }
@After public void tearDown() { // stop all severs for (int i = 0; i < mt.length; i++) { try { mt[i].shutdown(); } catch (InterruptedException e) { LOG.warn("Quorum Peer interrupted while shutting it down", e); } } }
@After public void tearDown() throws Exception { for (MainThread mainThread : mt) { mainThread.shutdown(); mainThread.deleteBaseDir(); } }
@After public void tearDown() throws Exception { if (mt != null) { for (MainThread t: mt) { t.shutdown(); } } if (zk != null) { for (ZooKeeper z: zk) { z.close(); } } }
void verifyStandalone(MainThread mt, int clientPort) throws InterruptedException { mt.start(); try { Assert.assertTrue("waiting for server 1 being up", ClientBase.waitForServerUp("127.0.0.1:" + clientPort, CONNECTION_TIMEOUT)); } finally { Assert.assertFalse("Error- MainThread started in Quorum Mode!", mt.isQuorumPeerRunning()); mt.shutdown(); } }
@After public void tearDown() throws Exception { if (servers == null || servers.mt == null) { LOG.info("No servers to shutdown!"); return; } for (int i = 0; i < numServers; i++) { if (i < servers.mt.length) { servers.mt[i].shutdown(); } } }
/** * Shuts down a server, waits for it to disconnect, * and gives enough time for the learner handler * in its ensemble to realize it's been shut down. */ private void shutDownServer(int id) throws Exception { peers[id].shutdown(); ClientBase.waitForServerDown("127.0.0.1:" + clientPorts[id], CONNECTION_TIMEOUT); TimeUnit.SECONDS.sleep(25); }
/** * Stop server threads. */ private void shutDownData() throws Exception { for (int i = 0; i < NUM_SERVERS; i++) { zkHandles[i].close(); zkAdminHandles[i].close(); } for (int i = 1; i < NUM_SERVERS; i++) { peers[i].shutdown(); } }
@After public void tearDown() throws Exception { for (MainThread mainThread : mt) { mainThread.shutdown(); mainThread.deleteBaseDir(); } }