public void close() { if (managed) { if (aborted) { HConnectionManager.deleteStaleConnection(this); } else { HConnectionManager.deleteConnection(this, false); } } else { internalClose(); } if (LOG.isTraceEnabled()) LOG.debug("" + this.zooKeeper + " closed."); }
/** * Workaround for the problem that zookeeper connections from HBase are not all closed. HBase (HConnection) does * reference counting to keep track of clients of connections, and apparently somewhere a close doesn't happen * while it should (thus the refCount is 1 at the end, in stead of 0). * * @param conf hbase configuration */ private void forceClose(Configuration conf) { final HConnection connection; try { connection = HConnectionManager.getConnection(conf); HConnectionManager.deleteStaleConnection(connection); } catch (ZooKeeperConnectionException e) { throw new RuntimeException("failed to close stale connection", e); } } }
HConnectionManager.deleteStaleConnection(this.connection); this.connection = HConnectionManager.getConnection(this.conf); if (tries >= numRetries) { HConnectionManager.deleteStaleConnection(this.connection); throw new MasterNotRunningException("Retried " + numRetries + " times"); Thread.currentThread().interrupt(); HConnectionManager.deleteStaleConnection(this.connection); throw new MasterNotRunningException( "Interrupted after "+tries+" tries");