@Override public TableDescriptor getDescriptor() throws IOException { return HBaseAdmin.getTableDescriptor(tableName, connection, rpcCallerFactory, rpcControllerFactory, operationTimeoutMs, readRpcTimeoutMs); }
@Override public HTableDescriptor getTableDescriptor(String tableName) throws TableNotFoundException, IOException { return adm.getTableDescriptor(tableName.getBytes()); }
@Override public HTableDescriptor getTableDescriptor(String tableName) throws TableNotFoundException, IOException { return adm.getTableDescriptor(tableName.getBytes()); }
@Override public HTableDescriptor getTableDescriptor(String tableName) throws TableNotFoundException, IOException { return adm.getTableDescriptor(tableName.getBytes()); }
@Override public TableDescriptor getDescriptor(TableName tableName) throws TableNotFoundException, IOException { return getTableDescriptor(tableName, getConnection(), rpcCallerFactory, rpcControllerFactory, operationTimeout, rpcTimeout); }
public void check(List<String> segFullNameList) { issueExistHTables = Lists.newArrayList(); inconsistentHTables = Lists.newArrayList(); for (String segFullName : segFullNameList) { String[] sepNameList = StringUtil.splitByComma(segFullName); try { HTableDescriptor hTableDescriptor = hbaseAdmin.getTableDescriptor(TableName.valueOf(sepNameList[0])); String host = hTableDescriptor.getValue(IRealizationConstants.HTableTag); if (!dstCfg.getMetadataUrlPrefix().equalsIgnoreCase(host)) { inconsistentHTables.add(segFullName); } } catch (IOException e) { issueExistHTables.add(segFullName); continue; } } }
case CHANGE_HTABLE_HOST: { String tableName = (String) opt.params[0]; HTableDescriptor desc = hbaseAdmin.getTableDescriptor(TableName.valueOf(tableName)); hbaseAdmin.disableTable(tableName); desc.setValue(IRealizationConstants.HTableTag, srcConfig.getMetadataUrlPrefix());
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("----------------------------------------------------"); } }
@Override public void cloneTableSchema(final TableName tableName, final TableName newTableName, final boolean preserveSplits) throws IOException { checkTableExists(tableName); if (tableExists(newTableName)) { throw new TableExistsException(newTableName); } TableDescriptor htd = TableDescriptorBuilder.copy(newTableName, getTableDescriptor(tableName)); if (preserveSplits) { createTable(htd, getTableSplits(tableName)); } else { createTable(htd); } }
@Override public TableDescriptor getDescriptor() throws IOException { return HBaseAdmin.getTableDescriptor(tableName, connection, rpcCallerFactory, rpcControllerFactory, operationTimeoutMs, readRpcTimeoutMs); }
String tableName = (String) opt.params[0]; System.out.println("CHANGE_HTABLE_HOST, table name: " + tableName); HTableDescriptor desc = hbaseAdmin.getTableDescriptor(TableName.valueOf(tableName)); hbaseAdmin.disableTable(tableName); desc.setValue(IRealizationConstants.HTableTag, dstConfig.getMetadataUrlPrefix());
@Override public TableDescriptor getDescriptor(TableName tableName) throws TableNotFoundException, IOException { return getTableDescriptor(tableName, getConnection(), rpcCallerFactory, rpcControllerFactory, operationTimeout, rpcTimeout); }
private static void createHTableIfNeeded(HConnection conn, String tableName) throws IOException { HBaseAdmin hbase = new HBaseAdmin(conn); try { boolean tableExist = false; try { hbase.getTableDescriptor(TableName.valueOf(tableName)); tableExist = true; } catch (TableNotFoundException e) { } if (tableExist) { System.out.println("HTable '" + tableName + "' already exists"); return; } System.out.println("Creating HTable '" + tableName + "'"); HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName)); HColumnDescriptor fd = new HColumnDescriptor(CF); fd.setBlocksize(CELL_SIZE); desc.addFamily(fd); hbase.createTable(desc); System.out.println("HTable '" + tableName + "' created"); } finally { hbase.close(); } }
/** * update method update schema and table for the list of tableInfos * * @param tableInfos * list of TableInfos. */ protected void update(List<TableInfo> tableInfos) { try { if (admin.isTableAvailable(databaseName)) { HTableDescriptor hTableDescriptor = admin.getTableDescriptor(databaseName.getBytes()); addColumnFamilies(tableInfos, hTableDescriptor, true); } else { createTable(tableInfos); } } catch (IOException ioe) { logger.error("Either check for network connection or table isn't in enabled state, Caused by:", ioe); throw new SchemaGenerationException(ioe, "Hbase"); } }
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); }
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(); }
@Override public void cloneTableSchema(final TableName tableName, final TableName newTableName, final boolean preserveSplits) throws IOException { checkTableExists(tableName); if (tableExists(newTableName)) { throw new TableExistsException(newTableName); } TableDescriptor htd = TableDescriptorBuilder.copy(newTableName, getTableDescriptor(tableName)); if (preserveSplits) { createTable(htd, getTableSplits(tableName)); } else { createTable(htd); } } }
/** * Alter the table metadata and return modified value * @param driver * @param tableName * @return value of VERSIONS option for the table * @throws Exception */ private int verifyModificationTableMetadata(PhoenixSysCatCreationTestingDriver driver, String tableName) throws Exception { // Modify table metadata Connection conn = driver.getConnectionQueryServices(getJdbcUrl(), new Properties()).connect(getJdbcUrl(), new Properties()); conn.createStatement().execute("ALTER TABLE " + tableName + " SET VERSIONS = " + MODIFIED_MAX_VERSIONS); // Connect via a client that creates a new ConnectionQueryServices instance driver.resetCQS(); driver.getConnectionQueryServices(getJdbcUrl(), new Properties()).connect(getJdbcUrl(), new Properties()); HTableDescriptor descriptor = testUtil.getHBaseAdmin().getTableDescriptor(TableName.valueOf(tableName)); return descriptor.getFamily(QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES).getMaxVersions(); }
@Test public void testCreatedrop() throws IOException { propertyMap.put(PersistenceProperties.KUNDERA_DDL_AUTO_PREPARE, "create-drop"); EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, propertyMap); // schemaManager = new // HBaseSchemaManager(HBaseClientFactory.class.getName(), null); // schemaManager.exportSchema(); Assert.assertTrue(admin.isTableAvailable(TABLE)); HTableDescriptor descriptor = admin.getTableDescriptor(TABLE.getBytes()); Assert.assertNotNull(descriptor.getFamilies()); Assert.assertEquals(1, descriptor.getFamilies().size()); for (HColumnDescriptor columnDescriptor : descriptor.getFamilies()) { Assert.assertNotNull(columnDescriptor); Assert.assertNotNull(columnDescriptor.getNameAsString()); Assert.assertEquals(HBASE_ENTITY_SIMPLE, columnDescriptor.getNameAsString()); } HBaseClientFactory clientFactory = (HBaseClientFactory) ClientResolver.getClientFactory(persistenceUnit); clientFactory.getSchemaManager(null).dropSchema(); Assert.assertTrue(admin.isTableAvailable(TABLE)); Assert.assertNull(admin.getTableDescriptor(TABLE.getBytes()).getFamily(HBASE_ENTITY_SIMPLE.getBytes())); }
@Test public void testCreate() throws IOException { propertyMap.put(PersistenceProperties.KUNDERA_DDL_AUTO_PREPARE, "create"); EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, propertyMap); Assert.assertTrue(admin.isTableAvailable(TABLE)); HTableDescriptor descriptor = admin.getTableDescriptor(TABLE.getBytes()); Assert.assertNotNull(descriptor.getFamilies()); Assert.assertEquals(1, descriptor.getFamilies().size()); for (HColumnDescriptor columnDescriptor : descriptor.getFamilies()) { Assert.assertNotNull(columnDescriptor); Assert.assertNotNull(columnDescriptor.getNameAsString()); Assert.assertEquals(HBASE_ENTITY_SIMPLE, columnDescriptor.getNameAsString()); } admin.disableTable(TABLE); admin.deleteTable(TABLE); Assert.assertFalse(admin.isTableAvailable(TABLE)); }