/** * Retrieves an Hbase table instance identified by its name and charset using the given table factory. * * @param tableName table name * @param configuration Hbase configuration object * @param charset name charset (may be null) * @param tableFactory table factory (may be null) * @return table instance */ public static HTableInterface getHTable(String tableName, Configuration configuration, Charset charset, HTableInterfaceFactory tableFactory) { if (HbaseSynchronizationManager.hasResource(tableName)) { return (HTable) HbaseSynchronizationManager.getResource(tableName); } HTableInterface t = null; try { if (tableFactory != null) { t = tableFactory.createHTableInterface(configuration, tableName.getBytes(charset)); } else { t = new HTable(configuration, tableName.getBytes(charset)); } return t; } catch (Exception ex) { throw convertHbaseException(ex); } }
private static void doReleaseTable(String tableName, HTableInterface table, HTableInterfaceFactory tableFactory) throws IOException { if (table == null) { return; } // close only if its unbound if (!isBoundToThread(tableName)) { if (tableFactory != null) { tableFactory.releaseHTableInterface(table); } else { table.close(); } } }
protected CrossSiteClientScanner(final Configuration conf, final Scan scan, final byte[] tableName, List<Pair<ClusterInfo, Pair<byte[], byte[]>>> clusterStartStopKeyPairs, boolean failover, ExecutorService pool, CrossSiteZNodes znodes, HTableInterfaceFactory hTableFactory) throws IOException { this.configuration = conf; this.scan = scan; this.tableName = Bytes.toString(tableName); this.pool = pool; this.ignoreUnavailableClusters = configuration.getBoolean( CrossSiteConstants.CROSS_SITE_TABLE_SCAN_IGNORE_UNAVAILABLE_CLUSTERS, false); this.failover = failover; this.clusterStartStopKeyPairs = clusterStartStopKeyPairs; this.znodes = znodes; clusterScannerIterators = new ArrayList<ScannerIterator>(); this.hTableFactory = hTableFactory; initialize(); }
/** * Retrieves an Hbase table instance identified by its name and charset * using the given table factory. * * @param tableName table name * @param configuration Hbase configuration object * @param charset name charset (may be null) * @param tableFactory table factory (may be null) * @return table instance */ public static HTableInterface getHTable(String tableName, Configuration configuration, Charset charset, HTableInterfaceFactory tableFactory) { if (HbaseSynchronizationManager.hasResource(tableName)) { return (HTable) HbaseSynchronizationManager.getResource(tableName); } HTableInterface t = null; try { if (tableFactory != null) { t = tableFactory.createHTableInterface(configuration, tableName.getBytes(charset)); } else { t = new HTable(configuration, tableName.getBytes(charset)); } return t; } catch (Exception ex) { throw convertHbaseException(ex); } }
/** * Releases (or closes) the given table, created via the given configuration if it is not managed externally (or bound to the thread). * * @param tableName table name * @param table table * @param tableFactory table factory */ public static void releaseTable(String tableName, HTableInterface table, HTableInterfaceFactory tableFactory) { try { doReleaseTable(tableName, table, tableFactory); } catch (IOException ex) { throw HbaseUtils.convertHbaseException(ex); } }
public HTableInterfaceFactory getTableFactory() { return tableFactory; }
public void setTableFactory(HTableInterfaceFactory tableFactory) { this.tableFactory = tableFactory; }
public DefaultHaeinsaTableIfaceFactory(HTableInterfaceFactory tableInterfaceFactory) { this.tableInterfaceFactory = tableInterfaceFactory; }
/** * Releases (or closes) the given table, created via the given configuration * if it is not managed externally (or bound to the thread). * * @param tableName table name * @param table table * @param tableFactory table factory */ public static void releaseTable(String tableName, HTableInterface table, HTableInterfaceFactory tableFactory) { try { doReleaseTable(tableName, table, tableFactory); } catch (IOException ex) { throw HbaseUtils.convertHbaseException(ex); } }
/** * Sets the table factory. * * @param tableFactory The tableFactory to set. */ public void setTableFactory(HTableInterfaceFactory tableFactory) { this.tableFactory = tableFactory; }