Search in sources :

Example 36 with HTableDescriptor

use of org.apache.hadoop.hbase.HTableDescriptor in project hbase by apache.

the class TestBackupBase method createTables.

protected static void createTables() throws Exception {
    long tid = System.currentTimeMillis();
    table1 = TableName.valueOf("ns1:test-" + tid);
    HBaseAdmin ha = TEST_UTIL.getHBaseAdmin();
    // Create namespaces
    NamespaceDescriptor desc1 = NamespaceDescriptor.create("ns1").build();
    NamespaceDescriptor desc2 = NamespaceDescriptor.create("ns2").build();
    NamespaceDescriptor desc3 = NamespaceDescriptor.create("ns3").build();
    NamespaceDescriptor desc4 = NamespaceDescriptor.create("ns4").build();
    ha.createNamespace(desc1);
    ha.createNamespace(desc2);
    ha.createNamespace(desc3);
    ha.createNamespace(desc4);
    HTableDescriptor desc = new HTableDescriptor(table1);
    HColumnDescriptor fam = new HColumnDescriptor(famName);
    desc.addFamily(fam);
    ha.createTable(desc);
    table1Desc = desc;
    Connection conn = ConnectionFactory.createConnection(conf1);
    Table table = conn.getTable(table1);
    loadTable(table);
    table.close();
    table2 = TableName.valueOf("ns2:test-" + tid + 1);
    desc = new HTableDescriptor(table2);
    desc.addFamily(fam);
    ha.createTable(desc);
    table = conn.getTable(table2);
    loadTable(table);
    table.close();
    table3 = TableName.valueOf("ns3:test-" + tid + 2);
    table = TEST_UTIL.createTable(table3, famName);
    table.close();
    table4 = TableName.valueOf("ns4:test-" + tid + 3);
    table = TEST_UTIL.createTable(table4, famName);
    table.close();
    ha.close();
    conn.close();
}
Also used : HBaseAdmin(org.apache.hadoop.hbase.client.HBaseAdmin) BackupSystemTable(org.apache.hadoop.hbase.backup.impl.BackupSystemTable) HTable(org.apache.hadoop.hbase.client.HTable) Table(org.apache.hadoop.hbase.client.Table) HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) Connection(org.apache.hadoop.hbase.client.Connection) NamespaceDescriptor(org.apache.hadoop.hbase.NamespaceDescriptor) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Example 37 with HTableDescriptor

use of org.apache.hadoop.hbase.HTableDescriptor in project hbase by apache.

the class TestAdmin2 method testTableNames.

/**
   * Test that user table names can contain '-' and '.' so long as they do not
   * start with same. HBASE-771
   * @throws IOException
   */
@Test(timeout = 300000)
public void testTableNames() throws IOException {
    byte[][] illegalNames = new byte[][] { Bytes.toBytes("-bad"), Bytes.toBytes(".bad") };
    for (byte[] illegalName : illegalNames) {
        try {
            new HTableDescriptor(TableName.valueOf(illegalName));
            throw new IOException("Did not detect '" + Bytes.toString(illegalName) + "' as an illegal user table name");
        } catch (IllegalArgumentException e) {
        // expected
        }
    }
    byte[] legalName = Bytes.toBytes("g-oo.d");
    try {
        new HTableDescriptor(TableName.valueOf(legalName));
    } catch (IllegalArgumentException e) {
        throw new IOException("Legal user table name: '" + Bytes.toString(legalName) + "' caused IllegalArgumentException: " + e.getMessage());
    }
}
Also used : IOException(java.io.IOException) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) Test(org.junit.Test)

Example 38 with HTableDescriptor

use of org.apache.hadoop.hbase.HTableDescriptor in project hadoop by apache.

the class ApplicationTable method createTable.

/*
   * (non-Javadoc)
   *
   * @see
   * org.apache.hadoop.yarn.server.timelineservice.storage.BaseTable#createTable
   * (org.apache.hadoop.hbase.client.Admin,
   * org.apache.hadoop.conf.Configuration)
   */
public void createTable(Admin admin, Configuration hbaseConf) throws IOException {
    TableName table = getTableName(hbaseConf);
    if (admin.tableExists(table)) {
        // output directory exists
        throw new IOException("Table " + table.getNameAsString() + " already exists.");
    }
    HTableDescriptor applicationTableDescp = new HTableDescriptor(table);
    HColumnDescriptor infoCF = new HColumnDescriptor(ApplicationColumnFamily.INFO.getBytes());
    infoCF.setBloomFilterType(BloomType.ROWCOL);
    applicationTableDescp.addFamily(infoCF);
    HColumnDescriptor configCF = new HColumnDescriptor(ApplicationColumnFamily.CONFIGS.getBytes());
    configCF.setBloomFilterType(BloomType.ROWCOL);
    configCF.setBlockCacheEnabled(true);
    applicationTableDescp.addFamily(configCF);
    HColumnDescriptor metricsCF = new HColumnDescriptor(ApplicationColumnFamily.METRICS.getBytes());
    applicationTableDescp.addFamily(metricsCF);
    metricsCF.setBlockCacheEnabled(true);
    // always keep 1 version (the latest)
    metricsCF.setMinVersions(1);
    metricsCF.setMaxVersions(DEFAULT_METRICS_MAX_VERSIONS);
    metricsCF.setTimeToLive(hbaseConf.getInt(METRICS_TTL_CONF_NAME, DEFAULT_METRICS_TTL));
    applicationTableDescp.setRegionSplitPolicyClassName("org.apache.hadoop.hbase.regionserver.KeyPrefixRegionSplitPolicy");
    applicationTableDescp.setValue("KeyPrefixRegionSplitPolicy.prefix_length", TimelineHBaseSchemaConstants.USERNAME_SPLIT_KEY_PREFIX_LENGTH);
    admin.createTable(applicationTableDescp, TimelineHBaseSchemaConstants.getUsernameSplits());
    LOG.info("Status of table creation for " + table.getNameAsString() + "=" + admin.tableExists(table));
}
Also used : TableName(org.apache.hadoop.hbase.TableName) HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) IOException(java.io.IOException) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Example 39 with HTableDescriptor

use of org.apache.hadoop.hbase.HTableDescriptor in project hbase by apache.

the class IntegrationTestLoadAndVerify method testLoadAndVerify.

@Test
public void testLoadAndVerify() throws Exception {
    HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(TEST_NAME));
    htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
    Admin admin = getTestingUtil(getConf()).getAdmin();
    admin.createTable(htd, Bytes.toBytes(0L), Bytes.toBytes(-1L), 40);
    doLoad(getConf(), htd);
    doVerify(getConf(), htd);
    // Only disable and drop if we succeeded to verify - otherwise it's useful
    // to leave it around for post-mortem
    getTestingUtil(getConf()).deleteTable(htd.getTableName());
}
Also used : HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) Admin(org.apache.hadoop.hbase.client.Admin) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) Test(org.junit.Test)

Example 40 with HTableDescriptor

use of org.apache.hadoop.hbase.HTableDescriptor in project hbase by apache.

the class IntegrationTestWithCellVisibilityLoadAndVerify method runTestFromCommandLine.

@Override
public int runTestFromCommandLine() throws Exception {
    IntegrationTestingUtility.setUseDistributedCluster(getConf());
    int numPresplits = getConf().getInt("loadmapper.numPresplits", 5);
    // create HTableDescriptor for specified table
    HTableDescriptor htd = new HTableDescriptor(getTablename());
    htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
    try (Connection conn = ConnectionFactory.createConnection(getConf());
        Admin admin = conn.getAdmin()) {
        admin.createTable(htd, Bytes.toBytes(0L), Bytes.toBytes(-1L), numPresplits);
    }
    doLoad(getConf(), htd);
    doVerify(getConf(), htd);
    getTestingUtil(getConf()).deleteTable(getTablename());
    return 0;
}
Also used : HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) Connection(org.apache.hadoop.hbase.client.Connection) Admin(org.apache.hadoop.hbase.client.Admin) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Aggregations

HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)867 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)555 Test (org.junit.Test)425 TableName (org.apache.hadoop.hbase.TableName)258 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)171 IOException (java.io.IOException)167 Put (org.apache.hadoop.hbase.client.Put)149 Table (org.apache.hadoop.hbase.client.Table)134 Path (org.apache.hadoop.fs.Path)127 Admin (org.apache.hadoop.hbase.client.Admin)121 Configuration (org.apache.hadoop.conf.Configuration)87 HBaseAdmin (org.apache.hadoop.hbase.client.HBaseAdmin)77 ArrayList (java.util.ArrayList)75 FileSystem (org.apache.hadoop.fs.FileSystem)66 Result (org.apache.hadoop.hbase.client.Result)62 Connection (org.apache.hadoop.hbase.client.Connection)57 Scan (org.apache.hadoop.hbase.client.Scan)51 Cell (org.apache.hadoop.hbase.Cell)44 Delete (org.apache.hadoop.hbase.client.Delete)44 HRegion (org.apache.hadoop.hbase.regionserver.HRegion)43