@Inject HBaseTableUtilProvider(CConfiguration cConf) { this.hBaseTableUtilFactory = new HBaseTableUtilFactory(cConf); }
@Inject HBaseTableUtilProvider(CConfiguration cConf) { this.hBaseTableUtilFactory = new HBaseTableUtilFactory(cConf); }
public static Class<? extends HBaseTableUtil> getHBaseTableUtilClass(CConfiguration cConf) { // Since we only need the class name, it is fine to have a null namespaceQueryAdmin, // since we do not use the tableUtil instance return new HBaseTableUtilFactory(cConf).get().getClass(); }
public static Class<? extends HBaseTableUtil> getHBaseTableUtilClass(CConfiguration cConf) { // Since we only need the class name, it is fine to have a null namespaceQueryAdmin, // since we do not use the tableUtil instance return new HBaseTableUtilFactory(cConf).get().getClass(); }
/** * Creates HBase namespace for the cdap system namespace. */ private void createSystemHBaseNamespace() { HBaseTableUtil tableUtil = new HBaseTableUtilFactory(cConf).get(); try (HBaseDDLExecutor ddlExecutor = new HBaseDDLExecutorFactory(cConf, hConf).get()) { ddlExecutor.createNamespaceIfNotExists(tableUtil.getHBaseNamespace(NamespaceId.SYSTEM)); } catch (IOException e) { throw Throwables.propagate(e); } }
private static Map<String, Long> getMapFromTable(String rowType) throws IOException { HBaseTableUtil tableUtil = new HBaseTableUtilFactory(cConf).get(); HTable hTable = tableUtil.createHTable(hConf, getReplicationStateTableId(tableUtil)); // Scan the table to scan for all regions. ScanBuilder scan = getScanBuilder(tableUtil, rowType); Result result; HashMap<String, Long> timeMap = new HashMap<>(); try (ResultScanner resultScanner = hTable.getScanner(scan.build())) { while ((result = resultScanner.next()) != null) { ReplicationStatusKey key = new ReplicationStatusKey(result.getRow()); String region = key.getRegionName(); Long timestamp = getTimeFromResult(result, rowType); if (timeMap.get(region) == null || timestamp > timeMap.get(region)) { timeMap.put(region, timestamp); } } } catch (Exception e) { LOG.error("Error while reading table.", e); throw Throwables.propagate(e); } finally { hTable.close(); } return timeMap; }
/** * Creates the configuration HBase table if it does not exist. */ @VisibleForTesting void createTableIfNecessary() throws IOException { try (HBaseDDLExecutor ddlExecutor = new HBaseDDLExecutorFactory(cConf, hConf).get()) { HBaseTableUtil tableUtil = new HBaseTableUtilFactory(cConf).get(); TableId tableId = tableUtil.createHTableId(NamespaceId.SYSTEM, TABLE_NAME); ColumnFamilyDescriptorBuilder cfdBuilder = HBaseTableUtil.getColumnFamilyDescriptorBuilder(Bytes.toString(FAMILY), hConf); TableDescriptorBuilder tdBuilder = HBaseTableUtil.getTableDescriptorBuilder(tableId, cConf).addColumnFamily(cfdBuilder.build()); ddlExecutor.createTableIfNotExists(tdBuilder.build(), null); } } }
/** * Creates the configuration HBase table if it does not exist. */ @VisibleForTesting void createTableIfNecessary() throws IOException { try (HBaseDDLExecutor ddlExecutor = new HBaseDDLExecutorFactory(cConf, hConf).get()) { HBaseTableUtil tableUtil = new HBaseTableUtilFactory(cConf).get(); TableId tableId = tableUtil.createHTableId(NamespaceId.SYSTEM, TABLE_NAME); ColumnFamilyDescriptorBuilder cfdBuilder = HBaseTableUtil.getColumnFamilyDescriptorBuilder(Bytes.toString(FAMILY), hConf); TableDescriptorBuilder tdBuilder = HBaseTableUtil.getTableDescriptorBuilder(tableId, cConf).addColumnFamily(cfdBuilder.build()); ddlExecutor.createTableIfNotExists(tdBuilder.build(), null); } } }
@BeforeClass public static void setup() throws Exception { conf = TEST_HBASE.getConfiguration(); cConf = CConfiguration.create(); tableUtil = new HBaseTableUtilFactory(cConf).get(); }
static HRegion createRegion(Configuration hConf, CConfiguration cConf, TableId tableId, HColumnDescriptor cfd) throws Exception { HBaseTableUtil tableUtil = new HBaseTableUtilFactory(cConf).get(); HTableDescriptorBuilder htd = tableUtil.buildHTableDescriptor(tableId); cfd.setMaxVersions(Integer.MAX_VALUE); cfd.setKeepDeletedCells(true); htd.addFamily(cfd); htd.addCoprocessor(IncrementHandler.class.getName()); HTableDescriptor desc = htd.build(); String tableName = desc.getNameAsString(); Path tablePath = new Path("/tmp/" + tableName); Path hlogPath = new Path("/tmp/hlog-" + tableName); FileSystem fs = FileSystem.get(hConf); assertTrue(fs.mkdirs(tablePath)); WALFactory walFactory = new WALFactory(hConf, null, hlogPath.toString()); WAL hLog = walFactory.getWAL(new byte[]{1}); HRegionInfo regionInfo = new HRegionInfo(desc.getTableName()); HRegionFileSystem regionFS = HRegionFileSystem.createRegionOnFileSystem(hConf, fs, tablePath, regionInfo); return new HRegion(regionFS, hLog, hConf, desc, new LocalRegionServerServices(hConf, ServerName.valueOf( InetAddress.getLocalHost().getHostName(), 0, System.currentTimeMillis()))); }
static HRegion createRegion(Configuration hConf, CConfiguration cConf, TableId tableId, HColumnDescriptor cfd) throws Exception { HBaseTableUtil tableUtil = new HBaseTableUtilFactory(cConf).get(); HTableDescriptorBuilder htd = tableUtil.buildHTableDescriptor(tableId); cfd.setMaxVersions(Integer.MAX_VALUE); cfd.setKeepDeletedCells(true); htd.addFamily(cfd); htd.addCoprocessor(IncrementHandler.class.getName()); HTableDescriptor desc = htd.build(); String tableName = desc.getNameAsString(); Path tablePath = new Path("/tmp/" + tableName); Path hlogPath = new Path("/tmp/hlog-" + tableName); FileSystem fs = FileSystem.get(hConf); assertTrue(fs.mkdirs(tablePath)); WALFactory walFactory = new WALFactory(hConf, null, hlogPath.toString()); WAL hLog = walFactory.getWAL(new byte[]{1}); HRegionInfo regionInfo = new HRegionInfo(desc.getTableName()); HRegionFileSystem regionFS = HRegionFileSystem.createRegionOnFileSystem(hConf, fs, tablePath, regionInfo); return new HRegion(regionFS, hLog, hConf, desc, new LocalRegionServerServices(hConf, ServerName.valueOf( InetAddress.getLocalHost().getHostName(), 0, System.currentTimeMillis()))); }
static HRegion createRegion(Configuration hConf, CConfiguration cConf, TableId tableId, HColumnDescriptor cfd) throws Exception { HBaseTableUtil tableUtil = new HBaseTableUtilFactory(cConf).get(); HTableDescriptorBuilder htd = tableUtil.buildHTableDescriptor(tableId); cfd.setMaxVersions(Integer.MAX_VALUE); cfd.setKeepDeletedCells(true); htd.addFamily(cfd); htd.addCoprocessor(IncrementHandler.class.getName()); HTableDescriptor desc = htd.build(); String tableName = desc.getNameAsString(); Path tablePath = new Path("/tmp/" + tableName); Path hlogPath = new Path("/tmp/hlog-" + tableName); FileSystem fs = FileSystem.get(hConf); assertTrue(fs.mkdirs(tablePath)); WALFactory walFactory = new WALFactory(hConf, null, hlogPath.toString()); WAL hLog = walFactory.getWAL(new byte[]{1}); HRegionInfo regionInfo = new HRegionInfo(desc.getTableName()); HRegionFileSystem regionFS = HRegionFileSystem.createRegionOnFileSystem(hConf, fs, tablePath, regionInfo); return new HRegion(regionFS, hLog, hConf, desc, new LocalRegionServerServices(hConf, ServerName.valueOf( InetAddress.getLocalHost().getHostName(), 0, System.currentTimeMillis()))); }
static HRegion createRegion(Configuration hConf, CConfiguration cConf, TableId tableId, HColumnDescriptor cfd) throws Exception { HBaseTableUtil tableUtil = new HBaseTableUtilFactory(cConf).get(); HTableDescriptorBuilder htd = tableUtil.buildHTableDescriptor(tableId); cfd.setMaxVersions(Integer.MAX_VALUE); cfd.setKeepDeletedCells(true); htd.addFamily(cfd); htd.addCoprocessor(IncrementHandler.class.getName()); HTableDescriptor desc = htd.build(); String tableName = desc.getNameAsString(); Path tablePath = new Path("/tmp/" + tableName); Path hlogPath = new Path("/tmp/hlog-" + tableName); FileSystem fs = FileSystem.get(hConf); assertTrue(fs.mkdirs(tablePath)); HLog hLog = HLogFactory.createHLog(fs, hlogPath, tableName, hConf); HRegionInfo regionInfo = new HRegionInfo(desc.getTableName()); HRegionFileSystem regionFS = HRegionFileSystem.createRegionOnFileSystem(hConf, fs, tablePath, regionInfo); return new HRegion(regionFS, hLog, hConf, desc, new MockRegionServerServices(hConf, null)); } }
@Override public HTable createTable(TableId tableId) throws Exception { HBaseTableUtil tableUtil = new HBaseTableUtilFactory(cConf).get(); HTableDescriptorBuilder tableDesc = tableUtil.buildHTableDescriptor(tableId); HColumnDescriptor columnDesc = new HColumnDescriptor(FAMILY); columnDesc.setMaxVersions(Integer.MAX_VALUE); columnDesc.setValue(IncrementHandlerState.PROPERTY_TRANSACTIONAL, "false"); tableDesc.addFamily(columnDesc); tableDesc.addCoprocessor(IncrementHandler.class.getName()); HTableDescriptor htd = tableDesc.build(); TEST_HBASE.getHBaseAdmin().createTable(htd); TEST_HBASE.waitUntilTableAvailable(htd.getName(), 5000); return tableUtil.createHTable(conf, tableId); }
@Override public HTable createTable(TableId tableId) throws Exception { HBaseTableUtil tableUtil = new HBaseTableUtilFactory(cConf).get(); HTableDescriptorBuilder tableDesc = tableUtil.buildHTableDescriptor(tableId); HColumnDescriptor columnDesc = new HColumnDescriptor(FAMILY); columnDesc.setMaxVersions(Integer.MAX_VALUE); columnDesc.setValue(IncrementHandlerState.PROPERTY_TRANSACTIONAL, "false"); tableDesc.addFamily(columnDesc); tableDesc.addCoprocessor(IncrementHandler.class.getName()); HTableDescriptor htd = tableDesc.build(); TEST_HBASE.getHBaseAdmin().createTable(htd); TEST_HBASE.waitUntilTableAvailable(htd.getName(), 5000); return tableUtil.createHTable(conf, tableId); }
@Override public HTable createTable(TableId tableId) throws Exception { HBaseTableUtil tableUtil = new HBaseTableUtilFactory(cConf).get(); HTableDescriptorBuilder tableDesc = tableUtil.buildHTableDescriptor(tableId); HColumnDescriptor columnDesc = new HColumnDescriptor(FAMILY); columnDesc.setMaxVersions(Integer.MAX_VALUE); columnDesc.setValue(IncrementHandlerState.PROPERTY_TRANSACTIONAL, "false"); tableDesc.addFamily(columnDesc); tableDesc.addCoprocessor(IncrementHandler.class.getName()); HTableDescriptor htd = tableDesc.build(); TEST_HBASE.getHBaseAdmin().createTable(htd); TEST_HBASE.waitUntilTableAvailable(htd.getName(), 5000); return tableUtil.createHTable(conf, tableId); }
@Override public HTable createTable(TableId tableId) throws Exception { HBaseTableUtil tableUtil = new HBaseTableUtilFactory(cConf).get(); HTableDescriptorBuilder tableDesc = tableUtil.buildHTableDescriptor(tableId); HColumnDescriptor columnDesc = new HColumnDescriptor(FAMILY); columnDesc.setMaxVersions(Integer.MAX_VALUE); columnDesc.setValue(IncrementHandlerState.PROPERTY_TRANSACTIONAL, "false"); tableDesc.addFamily(columnDesc); tableDesc.addCoprocessor(IncrementHandler.class.getName()); HTableDescriptor htd = tableDesc.build(); TEST_HBASE.getHBaseAdmin().createTable(htd); TEST_HBASE.waitUntilTableAvailable(htd.getName(), 5000); return tableUtil.createHTable(conf, tableId); }
@Override public HTable createTable(TableId tableId) throws Exception { HBaseTableUtil tableUtil = new HBaseTableUtilFactory(cConf).get(); HTableDescriptorBuilder tableDesc = tableUtil.buildHTableDescriptor(tableId); HColumnDescriptor columnDesc = new HColumnDescriptor(FAMILY); columnDesc.setMaxVersions(Integer.MAX_VALUE); columnDesc.setValue(IncrementHandlerState.PROPERTY_TRANSACTIONAL, "false"); tableDesc.addFamily(columnDesc); tableDesc.addCoprocessor(IncrementHandler.class.getName()); HTableDescriptor htd = tableDesc.build(); TEST_HBASE.getHBaseAdmin().createTable(htd); TEST_HBASE.waitUntilTableAvailable(htd.getName(), 5000); return tableUtil.createHTable(conf, tableId); }
@Override public HTable createTable(TableId tableId) throws Exception { HBaseTableUtil tableUtil = new HBaseTableUtilFactory(cConf).get(); HTableDescriptorBuilder tableDesc = tableUtil.buildHTableDescriptor(tableId); HColumnDescriptor columnDesc = new HColumnDescriptor(FAMILY); columnDesc.setMaxVersions(Integer.MAX_VALUE); columnDesc.setValue(IncrementHandlerState.PROPERTY_TRANSACTIONAL, "false"); tableDesc.addFamily(columnDesc); tableDesc.addCoprocessor(IncrementHandler.class.getName()); HTableDescriptor htd = tableDesc.build(); TEST_HBASE.getHBaseAdmin().createTable(htd); TEST_HBASE.waitUntilTableAvailable(htd.getName(), 5000); return tableUtil.createHTable(conf, tableId); }
@Override public HTable createTable(TableId tableId) throws Exception { HBaseTableUtil tableUtil = new HBaseTableUtilFactory(cConf).get(); HTableDescriptorBuilder tableDesc = tableUtil.buildHTableDescriptor(tableId); HColumnDescriptor columnDesc = new HColumnDescriptor(FAMILY); columnDesc.setMaxVersions(Integer.MAX_VALUE); columnDesc.setValue(IncrementHandlerState.PROPERTY_TRANSACTIONAL, "false"); tableDesc.addFamily(columnDesc); tableDesc.addCoprocessor(IncrementHandler.class.getName()); HTableDescriptor htd = tableDesc.build(); TEST_HBASE.getHBaseAdmin().createTable(htd); TEST_HBASE.waitUntilTableAvailable(htd.getName(), 5000); return tableUtil.createHTable(conf, tableId); }