public synchronized void close() { if (closed) { return; } LOG.info("BookKeeper Client closed {}", name); if (null != bkc) { try { bkc.close(); } catch (InterruptedException e) { LOG.warn("Interrupted on closing bookkeeper client {} : ", name, e); Thread.currentThread().interrupt(); } catch (BKException e) { LOG.warn("Error on closing bookkeeper client {} : ", name, e); } } if (null != zkc) { if (null != sessionExpireWatcher) { zkc.unregister(sessionExpireWatcher); } if (ownZK) { zkc.close(); } } closed = true; }
bookKeeper.close(); } catch (BKException e) { throw new ManagedLedgerException(e);
public void shutdown() { try { super.close(); } catch (Exception e) { } synchronized (this) { defaultResponse = FutureUtils.exception(new BKException.BKClientClosedException()); } for (PulsarMockLedgerHandle ledger : ledgers.values()) { ledger.entries.clear(); } ledgers.clear(); }
/** * Gracefully release resources that this client uses. * * @throws InterruptedException * if there is an error shutting down the clients that this * class uses. */ @Override public void close() throws InterruptedException, BKException { if (ownsBK) { bkc.close(); } }
@Override public void close() throws Exception { if (nonNull(bookKeeper)) { bookKeeper.close(); } }
@Override public void close() { val bk = this.bookKeeper.getAndSet(null); if (bk != null) { try { bk.close(); } catch (Exception ex) { log.error("Unable to close BookKeeper client.", ex); } } }
@Override public void close() { if (forceLastAddConfirmedTimer != null) { try { forceLastAddConfirmedTimer.shutdown(); } finally { forceLastAddConfirmedTimer = null; } } if (bookKeeper != null) { try { bookKeeper.close(); } catch (InterruptedException | BKException ex) { LOG.log(Level.SEVERE, null, ex); } } } private static final Logger LOG = Logger.getLogger(BookkeeperCommitLogManager.class.getName());
public void close() throws IOException { try { managedLedgerFactory.shutdown(); log.info("Closed managed ledger factory"); bkClient.close(); log.info("Closed BookKeeper client"); } catch (Exception e) { log.warn(e.getMessage(), e); throw new IOException(e); } } }
/** * Shutdown the auditor. */ public void shutdown() { LOG.info("Shutting down auditor"); executor.shutdown(); try { while (!executor.awaitTermination(30, TimeUnit.SECONDS)) { LOG.warn("Executor not shutting down, interrupting"); executor.shutdownNow(); } admin.close(); if (ownBkc) { bkc.close(); } } catch (InterruptedException ie) { Thread.currentThread().interrupt(); LOG.warn("Interrupted while shutting down auditor bookie", ie); } catch (BKException bke) { LOG.warn("Exception while shutting down auditor bookie", bke); } }
public void close() throws IOException { try { managedLedgerFactory.shutdown(); log.info("Closed managed ledger factory"); try { bkClient.close(); } catch (RejectedExecutionException ree) { // when closing bookkeeper client, it will error outs all pending metadata operations. // those callbacks of those operations will be triggered, and submitted to the scheduler // in managed ledger factory. but the managed ledger factory has been shutdown before, // so `RejectedExecutionException` will be thrown there. we can safely ignore this exception. // // an alternative solution is to close bookkeeper client before shutting down managed ledger // factory, however that might be introducing more unknowns. log.warn("Encountered exceptions on closing bookkeeper client", ree); } log.info("Closed BookKeeper client"); } catch (Exception e) { log.warn(e.getMessage(), e); throw new IOException(e); } } }
public void close() { BookKeeper bkcToClose; ZooKeeperClient zkcToClose; synchronized (this) { if (closed) { return; } closed = true; bkcToClose = bkc; zkcToClose = zkc; } LOG.info("BookKeeper Client closed {}", name); if (null != bkcToClose) { try { bkcToClose.close(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); LOG.warn("Interrupted on closing bookkeeper client {} : ", name, e); Thread.currentThread().interrupt(); } catch (BKException e) { LOG.warn("Error on closing bookkeeper client {} : ", name, e); } } if (null != zkcToClose) { if (ownZK) { zkcToClose.close(); } } }
private void shutdown(int exitCode) { LOG.info("Shutting down auto recovery: {}", exitCode); if (shuttingDown) { return; } LOG.info("Shutting down AutoRecovery"); shuttingDown = true; running = false; this.exitCode = exitCode; try { auditorElector.shutdown(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); LOG.warn("Interrupted shutting down auditor elector", e); } replicationWorker.shutdown(); try { bkc.close(); } catch (BKException e) { LOG.warn("Failed to close bookkeeper client for auto recovery", e); } catch (InterruptedException e) { Thread.currentThread().interrupt(); LOG.warn("Interrupted closing bookkeeper client for auto recovery", e); } }
bkc.close(); } catch (InterruptedException e) { LOG.warn("Interrupted while closing the Bookie client", e);
/** * Shutting down AuditorElector. */ public void shutdown() throws InterruptedException { synchronized (this) { if (executor.isShutdown()) { return; } submitShutdownTask(); executor.shutdown(); } if (auditor != null) { auditor.shutdown(); auditor = null; } if (ownBkc) { try { bkc.close(); } catch (BKException e) { LOG.warn("Failed to close bookkeeper client", e); } } }
bookKeeper.close(); } catch (BKException e) { throw new ManagedLedgerException(e);
bookKeeper.close(); } catch (BKException e) { throw new ManagedLedgerException(e);
@Override public int runCmd(CommandLine cmdLine) throws Exception { ClientConfiguration clientConf = new ClientConfiguration(bkConf); clientConf.setDiskWeightBasedPlacementEnabled(true); BookKeeper bk = new BookKeeper(clientConf); Map<BookieSocketAddress, BookieInfo> map = bk.getBookieInfo(); if (map.size() == 0) { System.out.println("Failed to retrieve bookie information from any of the bookies"); bk.close(); return 0; } System.out.println("Free disk space info:"); long totalFree = 0, total = 0; for (Map.Entry<BookieSocketAddress, BookieInfo> e : map.entrySet()) { BookieInfo bInfo = e.getValue(); BookieSocketAddress bookieId = e.getKey(); System.out.println(getBookieSocketAddrStringRepresentation(bookieId) + ":\tFree: " + bInfo.getFreeDiskSpace() + getReadable(bInfo.getFreeDiskSpace()) + "\tTotal: " + bInfo.getTotalDiskSpace() + getReadable(bInfo.getTotalDiskSpace())); totalFree += bInfo.getFreeDiskSpace(); total += bInfo.getTotalDiskSpace(); } System.out.println("Total free disk space in the cluster:\t" + totalFree + getReadable(totalFree)); System.out.println("Total disk capacity in the cluster:\t" + total + getReadable(total)); bk.close(); return 0; } }
@Override public int runCmd(CommandLine cmdLine) throws Exception { final long lid = getOptionLedgerIdValue(cmdLine, "ledgerid", -1); if (lid == -1) { System.err.println("Must specify a ledger id"); return -1; } boolean force = cmdLine.hasOption("f"); boolean confirm = false; if (!force) { confirm = IOUtils.confirmPrompt( "Are you sure to delete Ledger : " + ledgerIdFormatter.formatLedgerId(lid) + "?"); } BookKeeper bk = null; try { if (force || confirm) { ClientConfiguration conf = new ClientConfiguration(); conf.addConfiguration(bkConf); bk = new BookKeeper(conf); bk.deleteLedger(lid); } } finally { if (bk != null) { bk.close(); } } return 0; }
log.info("Compaction of topic {} complete. Compacted to ledger {}", arguments.topic, ledgerId); } finally { bk.close(); bkClientFactory.close(); zk.close();