@Override public void close() throws IOException { table.close(); } }
@Override public void close() throws IOException { table.close(); } }
@Override public void close() throws IOException { table.close(); } }
/** * Close the table. */ @Override public void close() throws IOException { table.close(); }
@Override public void close() throws Exception { synchronized(this) { if(table != null) { table.close(); } } } }
@Override public void close() throws Exception { table.close(); }
/** * Close the table */ @Override public void close() { try { this.table.close(); } catch (IOException ex) { LOG.error("Unable to close connection to HBase table {}", tableName, ex); } } }
@Override public void close() throws Exception { super.close(); table.close(); } }
private void closeTable() { try { if (table != null) { table.close(); } } catch (Throwable t) { throw new StorageException("Error when close table " + tableName, t); } }
@Override public void cleanup() throws IOException { synchronized(sync) { try { persist(true); } catch(Throwable t) { LOG.error("Unable to persist underlying tracker", t); } underlyingTracker.cleanup(); accessTrackerTable.close(); } } }
public HTableInterface getTable(String tableName, String cf) throws IOException { synchronized(this) { boolean isInitial = this.tableName == null || this.cf == null; boolean isValid = tableName != null && cf != null; if( isInitial || (isValid && (!this.tableName.equals(tableName) || !this.cf.equals(cf)) ) ) { Configuration conf = HBaseConfiguration.create(); //new table connection if(table != null) { table.close(); } LOG.debug("Fetching table '{}', column family: '{}'", tableName, cf); table = getProvider().getTable(conf, tableName); this.tableName = tableName; this.cf = cf; } return table; } }
@Override protected boolean removeLRU(LinkEntry entry) { HTableInterface table = (HTableInterface) entry.getValue(); if (LOG.isDebugEnabled()) { LOG.debug("Closing connection to table: " + Bytes.toString(table.getTableName()) + " because it was evicted from the cache."); } try { table.close(); } catch (IOException e) { LOG.info("Failed to correctly close HTable: " + Bytes.toString(table.getTableName()) + " ignoring since being removed from queue."); } return true; } }
@Override public void close() throws SQLException { try { delegate.close(); } finally { try { htable.close(); } catch (IOException e) { throw ServerUtil.parseServerException(e); } } }
table.close();
hTable.close(); } catch (IOException e) { if (sqlE == null) {
private static void initTableValues() throws Exception { ConnectionQueryServices services = driver.getConnectionQueryServices(getUrl(), TEST_PROPERTIES); HTableInterface hTable = services.getTable(SchemaUtil.getTableNameAsBytes(HBASE_DYNAMIC_COLUMNS_SCHEMA_NAME,HBASE_DYNAMIC_COLUMNS)); try { // Insert rows using standard HBase mechanism with standard HBase "types" List<Row> mutations = new ArrayList<Row>(); byte[] dv = Bytes.toBytes("DV"); byte[] first = Bytes.toBytes("F"); byte[] f1v1 = Bytes.toBytes("F1V1"); byte[] f1v2 = Bytes.toBytes("F1V2"); byte[] f2v1 = Bytes.toBytes("F2V1"); byte[] f2v2 = Bytes.toBytes("F2V2"); byte[] key = Bytes.toBytes("entry1"); Put put = new Put(key); put.add(QueryConstants.EMPTY_COLUMN_BYTES, dv, Bytes.toBytes("default")); put.add(QueryConstants.EMPTY_COLUMN_BYTES, first, Bytes.toBytes("first")); put.add(FAMILY_NAME, f1v1, Bytes.toBytes("f1value1")); put.add(FAMILY_NAME, f1v2, Bytes.toBytes("f1value2")); put.add(FAMILY_NAME2, f2v1, Bytes.toBytes("f2value1")); put.add(FAMILY_NAME2, f2v2, Bytes.toBytes("f2value2")); mutations.add(put); hTable.batch(mutations); } finally { hTable.close(); } // Create Phoenix table after HBase table was created through the native APIs // The timestamp of the table creation must be later than the timestamp of the data ensureTableCreated(getUrl(), HBASE_DYNAMIC_COLUMNS); }
} finally { try { htable.close(); } catch (IOException e) { if (sqlE == null) {
@Test public void testCacheCorrectlyExpiresTable() throws Exception { // setup the mocks for the tables we will request HTableFactory delegate = Mockito.mock(HTableFactory.class); ImmutableBytesPtr t1 = new ImmutableBytesPtr(Bytes.toBytes("t1")); ImmutableBytesPtr t2 = new ImmutableBytesPtr(Bytes.toBytes("t2")); ImmutableBytesPtr t3 = new ImmutableBytesPtr(Bytes.toBytes("t3")); HTableInterface table1 = Mockito.mock(HTableInterface.class); HTableInterface table2 = Mockito.mock(HTableInterface.class); HTableInterface table3 = Mockito.mock(HTableInterface.class); Mockito.when(delegate.getTable(t1)).thenReturn(table1); Mockito.when(delegate.getTable(t2)).thenReturn(table2); Mockito.when(delegate.getTable(t3)).thenReturn(table3); // setup our factory with a cache size of 2 CachingHTableFactory factory = new CachingHTableFactory(delegate, 2); factory.getTable(t1); factory.getTable(t2); factory.getTable(t3); // get the same table a second time, after it has gone out of cache factory.getTable(t1); Mockito.verify(delegate, Mockito.times(2)).getTable(t1); Mockito.verify(delegate, Mockito.times(1)).getTable(t2); Mockito.verify(delegate, Mockito.times(1)).getTable(t3); Mockito.verify(table1).close(); } }
hTable.close();
} finally { if (table != null) table.close(); if (conn != null) conn.close();