@Override public void cleanup() throws DBException { if (bulkMutation != null) { try { bulkMutation.flush(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new DBException(e); } catch(RuntimeException e){ throw new DBException(e); } } synchronized (CONFIG) { --threadCount; if (threadCount <= 0) { try { session.close(); } catch (IOException e) { throw new DBException(e); } } } }
@Override public void close() throws IOException { // Goal: by the end of this function, both results and session are null and closed, // independent of what errors they throw or prior state. if (session == null) { // Only possible when previously closed, so we know that results is also null. return; } // Session does not implement Closeable -- it's AutoCloseable. So we can't register it with // the Closer, but we can use the Closer to simplify the error handling. try (Closer closer = Closer.create()) { if (results != null) { closer.register(results); results = null; } session.close(); } finally { session = null; } }
@Override public void close() throws IOException { LOG.debug("closeing BigtableAsyncConnection"); if (!this.closed) { this.session.close(); this.closed = true; } }
@Override public void close() throws IOException { LOG.debug("closeing BigtableAsyncConnection"); if (!this.closed) { this.session.close(); this.closed = true; } }
/** {@inheritDoc} */ @Override public void close() throws IOException{ if (!this.closed) { this.session.close(); // If the clients are shutdown, there shouldn't be any more activity on the // batch pool (assuming we created it ourselves). If exceptions were raised // shutting down the clients, it's not entirely safe to shutdown the pool // (via a finally block). shutdownBatchPool(); if (this.bufferedMutatorExecutorService != null) { this.bufferedMutatorExecutorService.shutdown(); this.bufferedMutatorExecutorService = null; } this.closed = true; } }
/** {@inheritDoc} */ @Override public void close() throws IOException{ if (!this.closed) { this.session.close(); // If the clients are shutdown, there shouldn't be any more activity on the // batch pool (assuming we created it ourselves). If exceptions were raised // shutting down the clients, it's not entirely safe to shutdown the pool // (via a finally block). shutdownBatchPool(); if (this.bufferedMutatorExecutorService != null) { this.bufferedMutatorExecutorService.shutdown(); this.bufferedMutatorExecutorService = null; } this.closed = true; } }
@Override public void close() throws IOException { try { if (bulkMutation != null) { try { bulkMutation.flush(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); // We fail since flush() operation was interrupted. throw new IOException(e); } bulkMutation = null; } } finally { if (session != null) { session.close(); session = null; } } }
@After public void tearDown() throws Exception { final String tableName = bigtableOptions.getInstanceName().toTableNameStr(tableId); deleteTable(tableName); session.close(); }