/** * Shutdown the send/event threads. This method should not be called * directly - rather it should be called as part of close operation. This * method is primarily here to allow the tests to verify disconnection * behavior. */ public void disconnect() { if (LOG.isDebugEnabled()) { LOG.debug("Disconnecting client for session: 0x" + Long.toHexString(getSessionId())); } sendThread.close(); try { sendThread.join(); } catch (InterruptedException ex) { LOG.warn("Got interrupted while waiting for the sender thread to close", ex); } eventThread.queueEventOfDeath(); if (zooKeeperSaslClient != null) { zooKeeperSaslClient.shutdown(); } }
eventThreadField.setAccessible(true); EventThread eventThread = (EventThread) eventThreadField.get(clientCnxn); sendThread.join(CONNECTION_TIMEOUT); eventThread.join(CONNECTION_TIMEOUT); Assert.assertFalse("SendThread did not shutdown after authFail", sendThread.isAlive());
/** * Wait up to wait milliseconds for the underlying threads to shutdown. * THIS METHOD IS EXPECTED TO BE USED FOR TESTING ONLY!!! * * @since 3.3.0 * * @param wait max wait in milliseconds * @return true iff all threads are shutdown, otw false */ protected boolean testableWaitForShutdown(int wait) throws InterruptedException { cnxn.sendThread.join(wait); if (cnxn.sendThread.isAlive()) return false; cnxn.eventThread.join(wait); if (cnxn.eventThread.isAlive()) return false; return true; }
/** * Wait up to wait milliseconds for the underlying threads to shutdown. * THIS METHOD IS EXPECTED TO BE USED FOR TESTING ONLY!!! * * @since 3.3.0 * * @param wait max wait in milliseconds * @return true iff all threads are shutdown, otw false */ protected boolean testableWaitForShutdown(int wait) throws InterruptedException { cnxn.sendThread.join(wait); if (cnxn.sendThread.isAlive()) return false; cnxn.eventThread.join(wait); if (cnxn.eventThread.isAlive()) return false; return true; }
/** * Wait up to wait milliseconds for the underlying threads to shutdown. * THIS METHOD IS EXPECTED TO BE USED FOR TESTING ONLY!!! * * @since 3.3.0 * * @param wait max wait in milliseconds * @return true iff all threads are shutdown, otw false */ protected boolean testableWaitForShutdown(int wait) throws InterruptedException { cnxn.sendThread.join(wait); if (cnxn.sendThread.isAlive()) return false; cnxn.eventThread.join(wait); if (cnxn.eventThread.isAlive()) return false; return true; }