Search in sources :

Example 71 with TableDescriptor

use of org.apache.hadoop.hbase.client.TableDescriptor in project hbase by apache.

the class TestFSTableDescriptorForceCreation method testShouldNotCreateTheSameTableDescriptorIfForcefulCreationIsFalse.

@Test
public void testShouldNotCreateTheSameTableDescriptorIfForcefulCreationIsFalse() throws IOException {
    final String name = this.name.getMethodName();
    FileSystem fs = FileSystem.get(UTIL.getConfiguration());
    // Cleanup old tests if any detritus laying around.
    Path rootdir = new Path(UTIL.getDataTestDir(), name);
    FSTableDescriptors fstd = new FSTableDescriptors(fs, rootdir);
    TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf(name)).build();
    fstd.update(htd);
    assertFalse("Should not create new table descriptor", fstd.createTableDescriptor(htd, false));
}
Also used : Path(org.apache.hadoop.fs.Path) FileSystem(org.apache.hadoop.fs.FileSystem) FSTableDescriptors(org.apache.hadoop.hbase.util.FSTableDescriptors) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) Test(org.junit.Test)

Example 72 with TableDescriptor

use of org.apache.hadoop.hbase.client.TableDescriptor in project hbase by apache.

the class TestColumnFamilyDescriptorDefaultVersions method testCreateTableWithDefaultFromConf.

@Test
public void testCreateTableWithDefaultFromConf() throws Exception {
    TEST_UTIL.shutdownMiniCluster();
    TEST_UTIL.getConfiguration().setInt("hbase.column.max.version", 3);
    TEST_UTIL.startMiniCluster(1);
    Admin admin = TEST_UTIL.getAdmin();
    // Create a table with one family
    TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(TABLE_NAME).setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(FAMILY).setMaxVersions(TEST_UTIL.getConfiguration().getInt("hbase.column.max.version", 1)).build()).build();
    admin.createTable(tableDescriptor);
    admin.disableTable(TABLE_NAME);
    try {
        // Verify the column descriptor
        verifyHColumnDescriptor(3, TABLE_NAME, FAMILY);
    } finally {
        admin.deleteTable(TABLE_NAME);
    }
}
Also used : Admin(org.apache.hadoop.hbase.client.Admin) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) Test(org.junit.Test)

Example 73 with TableDescriptor

use of org.apache.hadoop.hbase.client.TableDescriptor in project hbase by apache.

the class TestColumnFamilyDescriptorDefaultVersions method testCreateTableWithSetVersion.

@Test
public void testCreateTableWithSetVersion() throws Exception {
    TEST_UTIL.shutdownMiniCluster();
    TEST_UTIL.getConfiguration().setInt("hbase.column.max.version", 3);
    TEST_UTIL.startMiniCluster(1);
    Admin admin = TEST_UTIL.getAdmin();
    // Create a table with one family
    TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(TABLE_NAME).setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(FAMILY).setMaxVersions(5).build()).build();
    admin.createTable(tableDescriptor);
    admin.disableTable(TABLE_NAME);
    try {
        // Verify the column descriptor
        verifyHColumnDescriptor(5, TABLE_NAME, FAMILY);
    } finally {
        admin.deleteTable(TABLE_NAME);
    }
}
Also used : Admin(org.apache.hadoop.hbase.client.Admin) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) Test(org.junit.Test)

Example 74 with TableDescriptor

use of org.apache.hadoop.hbase.client.TableDescriptor in project hbase by apache.

the class TestColumnFamilyDescriptorDefaultVersions method testCreateTableWithDefault.

@Test
public void testCreateTableWithDefault() throws IOException {
    Admin admin = TEST_UTIL.getAdmin();
    // Create a table with one family
    TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(TABLE_NAME).setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILY)).build();
    admin.createTable(tableDescriptor);
    admin.disableTable(TABLE_NAME);
    try {
        // Verify the column descriptor
        verifyHColumnDescriptor(1, TABLE_NAME, FAMILY);
    } finally {
        admin.deleteTable(TABLE_NAME);
    }
}
Also used : Admin(org.apache.hadoop.hbase.client.Admin) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) Test(org.junit.Test)

Example 75 with TableDescriptor

use of org.apache.hadoop.hbase.client.TableDescriptor in project hbase by apache.

the class TestColumnFamilyDescriptorDefaultVersions method verifyHColumnDescriptor.

private void verifyHColumnDescriptor(int expected, final TableName tableName, final byte[]... families) throws IOException {
    Admin admin = TEST_UTIL.getAdmin();
    // Verify descriptor from master
    TableDescriptor htd = admin.getDescriptor(tableName);
    ColumnFamilyDescriptor[] hcds = htd.getColumnFamilies();
    verifyColumnFamilyDescriptor(expected, hcds, tableName, families);
    // Verify descriptor from HDFS
    MasterFileSystem mfs = TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterFileSystem();
    Path tableDir = CommonFSUtils.getTableDir(mfs.getRootDir(), tableName);
    TableDescriptor td = FSTableDescriptors.getTableDescriptorFromFs(mfs.getFileSystem(), tableDir);
    hcds = td.getColumnFamilies();
    verifyColumnFamilyDescriptor(expected, hcds, tableName, families);
}
Also used : MasterFileSystem(org.apache.hadoop.hbase.master.MasterFileSystem) Path(org.apache.hadoop.fs.Path) Admin(org.apache.hadoop.hbase.client.Admin) ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor)

Aggregations

TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)639 Test (org.junit.Test)356 TableName (org.apache.hadoop.hbase.TableName)237 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)180 IOException (java.io.IOException)151 Put (org.apache.hadoop.hbase.client.Put)142 Admin (org.apache.hadoop.hbase.client.Admin)136 Path (org.apache.hadoop.fs.Path)124 Table (org.apache.hadoop.hbase.client.Table)121 ColumnFamilyDescriptor (org.apache.hadoop.hbase.client.ColumnFamilyDescriptor)96 Configuration (org.apache.hadoop.conf.Configuration)91 TableDescriptorBuilder (org.apache.hadoop.hbase.client.TableDescriptorBuilder)77 ArrayList (java.util.ArrayList)75 FileSystem (org.apache.hadoop.fs.FileSystem)66 Result (org.apache.hadoop.hbase.client.Result)66 HRegion (org.apache.hadoop.hbase.regionserver.HRegion)64 Connection (org.apache.hadoop.hbase.client.Connection)59 Scan (org.apache.hadoop.hbase.client.Scan)50 Get (org.apache.hadoop.hbase.client.Get)49 List (java.util.List)39