@Override public void enableTable(String tableName) throws IOException { adm.enableTable(tableName); }
@Override public void enableTable(String tableName) throws IOException { adm.enableTable(tableName); }
@Override public void enableTable(String tableName) throws IOException { adm.enableTable(tableName); }
@Override public HTableDescriptor[] enableTables(Pattern pattern) throws IOException { List<HTableDescriptor> failed = new LinkedList<>(); for (HTableDescriptor table : listTables(pattern)) { if (isTableDisabled(table.getTableName())) { try { enableTable(table.getTableName()); } catch (IOException ex) { LOG.info("Failed to enable table " + table.getTableName(), ex); failed.add(table); } } } return failed.toArray(new HTableDescriptor[failed.size()]); }
desc.setValue(IRealizationConstants.HTableTag, srcConfig.getMetadataUrlPrefix()); hbaseAdmin.modifyTable(tableName, desc); hbaseAdmin.enableTable(tableName); break;
public void fixInconsistent() throws IOException { if (ifFix == true) { for (String segFullName : inconsistentHTables) { String[] sepNameList = StringUtil.splitByComma(segFullName); HTableDescriptor desc = hbaseAdmin.getTableDescriptor(TableName.valueOf(sepNameList[0])); logger.info("Change the host of htable " + sepNameList[0] + "belonging to cube " + sepNameList[1] + " from " + desc.getValue(IRealizationConstants.HTableTag) + " to " + dstCfg.getMetadataUrlPrefix()); hbaseAdmin.disableTable(sepNameList[0]); desc.setValue(IRealizationConstants.HTableTag, dstCfg.getMetadataUrlPrefix()); hbaseAdmin.modifyTable(sepNameList[0], desc); hbaseAdmin.enableTable(sepNameList[0]); } } else { logger.info("------ Inconsistent HTables Needed To Be Fixed ------"); for (String hTable : inconsistentHTables) { String[] sepNameList = StringUtil.splitByComma(hTable); logger.info(sepNameList[0] + " belonging to cube " + sepNameList[1]); } logger.info("----------------------------------------------------"); } }
/** * Verify backup system table snapshot. * * @throws Exception if an operation on the table fails */ // @Test public void _testBackupRestoreSystemTable() throws Exception { LOG.info("test snapshot system table"); TableName backupSystem = BackupSystemTable.getTableName(conf1); HBaseAdmin hba = TEST_UTIL.getHBaseAdmin(); String snapshotName = "sysTable"; hba.snapshot(snapshotName, backupSystem); hba.disableTable(backupSystem); hba.restoreSnapshot(snapshotName); hba.enableTable(backupSystem); hba.close(); } }
desc.setValue(IRealizationConstants.HTableTag, dstConfig.getMetadataUrlPrefix()); hbaseAdmin.modifyTable(tableName, desc); hbaseAdmin.enableTable(tableName); logger.info("CHANGE_HTABLE_HOST is completed"); break;
@Override public HTableDescriptor[] enableTables(Pattern pattern) throws IOException { List<HTableDescriptor> failed = new LinkedList<>(); for (HTableDescriptor table : listTables(pattern)) { if (isTableDisabled(table.getTableName())) { try { enableTable(table.getTableName()); } catch (IOException ex) { LOG.info("Failed to enable table " + table.getTableName(), ex); failed.add(table); } } } return failed.toArray(new HTableDescriptor[failed.size()]); }
desc.setValue(IRealizationConstants.HTableTag, srcConfig.getMetadataUrlPrefix()); hbaseAdmin.modifyTable(tableName, desc); hbaseAdmin.enableTable(tableName); break;
admin.enableTable(TEST_TABLE); verifyAllowed(new AccessReadAction(TEST_TABLE), USER_OWNER, USER_RW); verifyDenied(new AccessReadAction(TEST_TABLE), USER_RO, USER_NONE); admin.enableTable(TEST_TABLE); verifyAllowed(new AccessReadAction(TEST_TABLE), USER_OWNER, USER_RO, USER_RW); verifyDenied(new AccessReadAction(TEST_TABLE), USER_NONE);
public static void resetCoprocessor(String tableName, HBaseAdmin hbaseAdmin, Path hdfsCoprocessorJar) throws IOException { logger.info("Disable " + tableName); hbaseAdmin.disableTable(tableName); logger.info("Unset coprocessor on " + tableName); HTableDescriptor desc = hbaseAdmin.getTableDescriptor(TableName.valueOf(tableName)); while (desc.hasCoprocessor(OBSERVER_CLS_NAME)) { desc.removeCoprocessor(OBSERVER_CLS_NAME); } while (desc.hasCoprocessor(ENDPOINT_CLS_NAMAE)) { desc.removeCoprocessor(ENDPOINT_CLS_NAMAE); } addCoprocessorOnHTable(desc, hdfsCoprocessorJar); hbaseAdmin.modifyTable(tableName, desc); logger.info("Enable " + tableName); hbaseAdmin.enableTable(tableName); }
admin.enableTable(tableName); admin.enableTable(tableName);
admin.enableTable(databaseName);
private void alter() throws IOException { Configuration conf = HBaseConfiguration.create(); HBaseAdmin hbaseAdmin = new HBaseAdmin(conf); HTableDescriptor table = hbaseAdmin.getTableDescriptor(TableName.valueOf(tableName)); hbaseAdmin.disableTable(table.getTableName()); table.setValue(metadataKey, metadataValue); hbaseAdmin.modifyTable(table.getTableName(), table); hbaseAdmin.enableTable(table.getTableName()); hbaseAdmin.close(); }
admin.enableTable(databaseName);
/** * Creates the table. * * @param tableName * the table name */ public void createTable(String tableName, String columnFamily) { try { if (!utility.getHBaseAdmin().tableExists(tableName)) { utility.createTable(tableName.getBytes(), columnFamily.getBytes()); if (utility.getHBaseAdmin().isTableDisabled(tableName)) { utility.getHBaseAdmin().enableTable(tableName); } } else { logger.info("Table:" + tableName + " already exist:"); } } catch (IOException e) { logger.error(e.getMessage()); } }
private void addColumnFamilies(List<TableInfo> tableInfos, HTableDescriptor hTableDescriptor, boolean isUpdate) throws IOException { if (admin.isTableEnabled(databaseName)) { admin.disableTable(databaseName); } for (TableInfo tableInfo : tableInfos) { HColumnDescriptor columnDescriptor = hTableDescriptor.getFamily(tableInfo.getTableName().getBytes()); if (columnDescriptor != null && !isUpdate) { admin.deleteColumn(databaseName, tableInfo.getTableName()); addColumn(tableInfo); } else if (columnDescriptor == null) { addColumn(tableInfo); } } if (admin.isTableDisabled(databaseName)) { admin.enableTable(databaseName); } }
/** * Adds the column family. * * @param tableName * the table name * @param columnFamily * the column family */ public void addColumnFamily(String tableName, String columnFamily) { try { utility.getHBaseAdmin().disableTable(tableName); utility.getHBaseAdmin().addColumn(tableName, new HColumnDescriptor(columnFamily)); utility.getHBaseAdmin().enableTable(tableName); while (utility.getHBaseAdmin().isTableEnabled(tableName)) { return; } } catch (InvalidFamilyOperationException ife) { logger.info("Column family:" + columnFamily + " already exist!", ife); } catch (IOException e) { logger.error("", e); } }
@Test public void testRetriveHtableHost() throws IOException { Configuration conf = HBaseConfiguration.create(); HBaseAdmin hbaseAdmin = new HBaseAdmin(conf); HTableDescriptor[] tableDescriptors = hbaseAdmin.listTables(); for (HTableDescriptor table : tableDescriptors) { String value = table.getValue("KYLIN_HOST"); if (value != null) { System.out.println(table.getTableName()); System.out.println("host is " + value); hbaseAdmin.disableTable(table.getTableName()); table.setValue("KYLIN_HOST_ANOTHER", "dev02"); hbaseAdmin.modifyTable(table.getTableName(), table); hbaseAdmin.enableTable(table.getTableName()); } } hbaseAdmin.close(); } }