private static TableId getReplicationStateTableId(HBaseTableUtil tableUtil) throws IOException { String tableName = hConf.get(ReplicationConstants.ReplicationStatusTool.REPLICATION_STATE_TABLE_NAME); String ns = hConf.get(ReplicationConstants.ReplicationStatusTool.REPLICATION_STATE_TABLE_NAMESPACE); TableId tableId = tableUtil.createHTableId( (ns != null) ? new NamespaceId(ns) : new NamespaceId(ReplicationConstants.ReplicationStatusTool.REPLICATION_STATE_TABLE_DEFAULT_NAMESPACE), (tableName != null) ? tableName : ReplicationConstants.ReplicationStatusTool.REPLICATION_STATE_TABLE_DEFAULT_NAME); return tableId; }
public void disableMessageTable(String tableName) throws IOException { TableId tableId = tableUtil.createHTableId(NamespaceId.SYSTEM, tableName); try (HBaseDDLExecutor ddlExecutor = ddlExecutorFactory.get()) { disableTable(ddlExecutor, tableId); } }
public void disablePayloadTable(String tableName) throws IOException { TableId tableId = tableUtil.createHTableId(NamespaceId.SYSTEM, tableName); try (HBaseDDLExecutor ddlExecutor = ddlExecutorFactory.get()) { disableTable(ddlExecutor, tableId); } }
private DatasetAdminImpl(DatasetContext datasetContext, String tableName, HBaseTableUtil tableUtil, Configuration hConf, CConfiguration cConf) throws IOException { this.hConf = hConf; this.cConf = cConf; this.tableUtil = tableUtil; this.tableId = tableUtil.createHTableId(new NamespaceId(datasetContext.getNamespaceId()), tableName); this.ddlExecutorFactory = new HBaseDDLExecutorFactory(cConf, hConf); }
KVTableImpl(DatasetContext datasetContext, String tableName, Configuration hConf, HBaseTableUtil tableUtil) throws IOException { this.tableUtil = tableUtil; TableId tableId = tableUtil.createHTableId(new NamespaceId(datasetContext.getNamespaceId()), tableName); this.table = this.tableUtil.createHTable(hConf, tableId); }
private DatasetAdminImpl(DatasetContext datasetContext, String tableName, HBaseTableUtil tableUtil, Configuration hConf, CConfiguration cConf) throws IOException { this.hConf = hConf; this.cConf = cConf; this.tableUtil = tableUtil; this.tableId = tableUtil.createHTableId(new NamespaceId(datasetContext.getNamespaceId()), tableName); this.ddlExecutorFactory = new HBaseDDLExecutorFactory(cConf, hConf); }
KVTableImpl(DatasetContext datasetContext, String tableName, Configuration hConf, HBaseTableUtil tableUtil) throws IOException { this.tableUtil = tableUtil; TableId tableId = tableUtil.createHTableId(new NamespaceId(datasetContext.getNamespaceId()), tableName); this.table = this.tableUtil.createHTable(hConf, tableId); }
public HBaseTableAdmin(DatasetContext datasetContext, DatasetSpecification spec, Configuration hConf, HBaseTableUtil tableUtil, CConfiguration conf, LocationFactory locationFactory) throws IOException { super(tableUtil.createHTableId(new NamespaceId(datasetContext.getNamespaceId()), spec.getName()), hConf, conf, tableUtil, locationFactory); this.spec = spec; this.conf = conf; }
public HBaseTableAdmin(DatasetContext datasetContext, DatasetSpecification spec, Configuration hConf, HBaseTableUtil tableUtil, CConfiguration conf, LocationFactory locationFactory) throws IOException { super(tableUtil.createHTableId(new NamespaceId(datasetContext.getNamespaceId()), spec.getName()), hConf, conf, tableUtil, locationFactory); this.spec = spec; this.conf = conf; }
public TableId getDataTableId(FlowId flowId, QueueConstants.QueueType queueType) throws IOException { String tableName = String.format("%s.%s.%s.%s", NamespaceId.SYSTEM.getNamespace(), queueType, flowId.getApplication(), flowId.getEntityName()); return tableUtil.createHTableId(new NamespaceId(flowId.getNamespace()), tableName); }
private HBaseTableUtil.TableStats getTableStats(String namespace, String tableName) throws IOException { HBaseTableUtil tableUtil = getTableUtil(); // todo : should support custom table-prefix TableId tableId = tableUtil.createHTableId(new NamespaceId(namespace), tableName); Map<TableId, HBaseTableUtil.TableStats> statsMap = tableUtil.getTableStats(hAdmin); return statsMap.get(tableId); } }
@Override protected void dropTable(TableId tableId) throws IOException { try (HBaseDDLExecutor ddlExecutor = ddlExecutorFactory.get(); HBaseAdmin admin = new HBaseAdmin(hConf)) { TableId hBaseTableId = tableUtil.createHTableId(new NamespaceId(tableId.getNamespace()), tableId.getTableName()); if (tableUtil.tableExists(admin, hBaseTableId)) { tableUtil.dropTable(ddlExecutor, hBaseTableId); } } }
private void truncate(String namespace, String tableName) throws IOException { HBaseTableUtil tableUtil = getTableUtil(); TableId hTableId = tableUtil.createHTableId(new NamespaceId(namespace), tableName); tableUtil.truncateTable(ddlExecutor, hTableId); }
@Override public synchronized void dropAllInNamespace(NamespaceId namespace) throws IOException { try (HBaseDDLExecutor executor = ddlExecutorFactory.get(); HBaseAdmin admin = new HBaseAdmin(hConf)) { TableId tableId = StreamUtils.getStateStoreTableId(namespace); TableId hbaseTableId = tableUtil.createHTableId(new NamespaceId(tableId.getNamespace()), tableId.getTableName()); if (tableUtil.tableExists(admin, hbaseTableId)) { tableUtil.dropTable(executor, hbaseTableId); } } } }
private HTableDescriptor getTableDescriptor(String namespace, String name) throws IOException { HBaseTableUtil tableUtil = getTableUtil(); TableId hTableId = tableUtil.createHTableId(new NamespaceId(namespace), name); return getTableUtil().getHTableDescriptor(hAdmin, hTableId); }
public HBaseMetricsTable(DatasetContext datasetContext, DatasetSpecification spec, Configuration hConf, HBaseTableUtil tableUtil, CConfiguration cConf) throws IOException { this.tableUtil = tableUtil; this.tableId = tableUtil.createHTableId(new NamespaceId(datasetContext.getNamespaceId()), spec.getName()); initializeVars(cConf, spec); HTable hTable = tableUtil.createHTable(hConf, tableId); // todo: make configurable hTable.setWriteBufferSize(HBaseTableUtil.DEFAULT_WRITE_BUFFER_SIZE); hTable.setAutoFlushTo(false); this.hTable = hTable; this.columnFamily = TableProperties.getColumnFamilyBytes(spec.getProperties()); }
private void writeSome(String namespace, String tableName) throws IOException { HBaseTableUtil tableUtil = getTableUtil(); TableId hTableId = tableUtil.createHTableId(new NamespaceId(namespace), tableName); try (HTable table = tableUtil.createHTable(TEST_HBASE.getConfiguration(), hTableId)) { // writing at least couple megs to reflect in "megabyte"-based metrics for (int i = 0; i < 8; i++) { Put put = new Put(Bytes.toBytes("row" + i)); put.add(Bytes.toBytes("d"), Bytes.toBytes("col" + i), new byte[1024 * 1024]); table.put(put); } } }
private boolean exists(TableId tableId) throws IOException { HBaseTableUtil tableUtil = getTableUtil(); TableId hTableId = tableUtil.createHTableId(new NamespaceId(tableId.getNamespace()), tableId.getTableName()); return tableUtil.tableExists(hAdmin, hTableId); }
private void enable(String namespace, String tableName) throws IOException { HBaseTableUtil tableUtil = getTableUtil(); TableId hTableId = tableUtil.createHTableId(new NamespaceId(namespace), tableName); TableName name = HTableNameConverter.toTableName(getPrefix(), hTableId); ddlExecutor.enableTableIfDisabled(name.getNamespaceAsString(), name.getQualifierAsString()); }
private void disable(String namespace, String tableName) throws IOException { HBaseTableUtil tableUtil = getTableUtil(); TableId hTableId = tableUtil.createHTableId(new NamespaceId(namespace), tableName); TableName name = HTableNameConverter.toTableName(getPrefix(), hTableId); ddlExecutor.disableTableIfEnabled(name.getNamespaceAsString(), name.getQualifierAsString()); }