@Override public void batch(final List<? extends Row> actions, final Object[] results) throws IOException, InterruptedException { run(new TableRunnable<Void>() { @Override public Void run(HTableInterface table) throws IOException, InterruptedException { table.batch(actions, results); return null; } }); }
@Override public <T extends CoprocessorProtocol> T coprocessorProxy(final Class<T> protocol, final byte[] row) { return runNoExc(new TableRunnable<T>() { @Override public T run(HTableInterface table) throws IOException, InterruptedException { return table.coprocessorProxy(protocol, row); } }); }
@Override public Result getRowOrBefore(final byte[] row, final byte[] family) throws IOException { return runNoIE(new TableRunnable<Result>() { @Override public Result run(HTableInterface table) throws IOException, InterruptedException { return table.getRowOrBefore(row, family); } }); }
/** * Retrieves an Index. * * @throws IndexNotFoundException if the index does not exist */ public Index getIndex(String name) throws IOException, IndexNotFoundException { HTableInterface table; try { table = new LocalHTable(hbaseConf, name); } catch (RuntimeException e) { if (e.getCause() != null && e.getCause() instanceof TableNotFoundException) { throw new IndexNotFoundException(name); } else { throw e; } } catch (TableNotFoundException e) { throw new IndexNotFoundException(name); } return instantiateIndex(name, table); }
this.tableName = tableName; this.tableNameString = Bytes.toString(tableName); this.pool = getHTablePool(conf); runNoIE(new TableRunnable<Object>() { @Override public Object run(HTableInterface table) throws IOException {
@PreDestroy public void stop() { try { // LocalHTable keeps HTablePools in static vars: make sure that is cleaned out // (to avoid leaks when using resetLilyState) LocalHTable.closeAllPools(); // FIXME : is this still needed? HConnectionManager.deleteConnection(conf, true); } catch (Throwable t) { LogFactory.getLog(getClass()).error("Problem cleaning up HBase connections", t); } } }
@Override public void close() throws IOException { this.isClosed = true; zk.removeDefaultWatcher(watcher); schemaCache.close(); synchronized (this) { for (ServerNode node : servers) { node.close(); } servers.clear(); } if (managedZk && zk != null) { zk.close(); } // Close pools related to the Configuration objects managed by this LilyClient instance for (Configuration config : hbaseConnections.getConfigurations()) { LocalHTable.closePool(config); } // Close HBase connections created by [only] this LilyClient instance. // This will almost always contain only one connection, if not we would need a more // advanced connection mgmt so that these connections don't stay open for the lifetime // of LilyClient. Closer.close(hbaseConnections); }
conf.set("hbase.zookeeper.quorum", zkConnect); HTableInterface table = new LocalHTable(conf, metaTable);
@Override public void put(final Put put) throws IOException { runNoIE(new TableRunnable<Void>() { @Override public Void run(HTableInterface table) throws IOException, InterruptedException { table.put(put); return null; } }); }
return new LocalHTable(configuration, tableDescriptor.getName()); } finally { admin.close();
@Override public Configuration getConfiguration() { return runNoExc(new TableRunnable<Configuration>() { @Override public Configuration run(HTableInterface table) throws IOException, InterruptedException { return table.getConfiguration(); } }); }
@Override public Object[] batch(final List<? extends Row> actions) throws IOException, InterruptedException { return run(new TableRunnable<Object[]>() { @Override public Object[] run(HTableInterface table) throws IOException, InterruptedException { return table.batch(actions); } }); }
@Override public Result get(final Get get) throws IOException { return runNoIE(new TableRunnable<Result>() { @Override public Result run(HTableInterface table) throws IOException, InterruptedException { return table.get(get); } }); }
@Override public HTableDescriptor getTableDescriptor() throws IOException { return runNoExc(new TableRunnable<HTableDescriptor>() { @Override public HTableDescriptor run(HTableInterface table) throws IOException, InterruptedException { return table.getTableDescriptor(); } }); }
@Override public ResultScanner getScanner(final Scan scan) throws IOException { return runNoIE(new TableRunnable<ResultScanner>() { @Override public ResultScanner run(HTableInterface table) throws IOException, InterruptedException { return table.getScanner(scan); } }); }
@Override public byte[] getTableName() { return runNoExc(new TableRunnable<byte[]>() { @Override public byte[] run(HTableInterface table) throws IOException, InterruptedException { return table.getTableName(); } }); }
@Override public boolean checkAndDelete(final byte[] row, final byte[] family, final byte[] qualifier, final byte[] value, final Delete delete) throws IOException { return runNoIE(new TableRunnable<Boolean>() { @Override public Boolean run(HTableInterface table) throws IOException, InterruptedException { return table.checkAndDelete(row, family, qualifier, value, delete); } }); }
@Override public RowLock lockRow(final byte[] row) throws IOException { return runNoIE(new TableRunnable<RowLock>() { @Override public RowLock run(HTableInterface table) throws IOException, InterruptedException { return table.lockRow(row); } }); }
@Override public void put(final List<Put> puts) throws IOException { runNoIE(new TableRunnable<Void>() { @Override public Void run(HTableInterface table) throws IOException, InterruptedException { table.put(puts); return null; } }); }
@Override public void delete(final List<Delete> deletes) throws IOException { runNoIE(new TableRunnable<Void>() { @Override public Void run(HTableInterface table) throws IOException, InterruptedException { table.delete(deletes); return null; } }); }