Search in sources :

Example 21 with FSTableDescriptors

use of org.apache.hadoop.hbase.util.FSTableDescriptors in project hbase by apache.

the class TestReadAndWriteRegionInfoFile method testReadAndWriteRegionInfoFile.

@Test
public void testReadAndWriteRegionInfoFile() throws IOException, InterruptedException {
    RegionInfo ri = RegionInfoBuilder.FIRST_META_REGIONINFO;
    // Create a region. That'll write the .regioninfo file.
    FSTableDescriptors fsTableDescriptors = new FSTableDescriptors(FS, ROOT_DIR);
    FSTableDescriptors.tryUpdateAndGetMetaTableDescriptor(CONF, FS, ROOT_DIR);
    HRegion r = HBaseTestingUtil.createRegionAndWAL(ri, ROOT_DIR, CONF, fsTableDescriptors.get(TableName.META_TABLE_NAME));
    // Get modtime on the file.
    long modtime = getModTime(r);
    HBaseTestingUtil.closeRegionAndWAL(r);
    Thread.sleep(1001);
    r = HRegion.openHRegion(ROOT_DIR, ri, fsTableDescriptors.get(TableName.META_TABLE_NAME), null, CONF);
    // Ensure the file is not written for a second time.
    long modtime2 = getModTime(r);
    assertEquals(modtime, modtime2);
    // Now load the file.
    HRegionFileSystem.loadRegionInfoFileContent(r.getRegionFileSystem().getFileSystem(), r.getRegionFileSystem().getRegionDir());
    HBaseTestingUtil.closeRegionAndWAL(r);
}
Also used : FSTableDescriptors(org.apache.hadoop.hbase.util.FSTableDescriptors) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) Test(org.junit.Test)

Aggregations

FSTableDescriptors (org.apache.hadoop.hbase.util.FSTableDescriptors)21 Path (org.apache.hadoop.fs.Path)16 Test (org.junit.Test)10 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)6 FileSystem (org.apache.hadoop.fs.FileSystem)5 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)5 MasterFileSystem (org.apache.hadoop.hbase.master.MasterFileSystem)4 Configuration (org.apache.hadoop.conf.Configuration)3 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)3 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)3 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)2 HBaseTestingUtil (org.apache.hadoop.hbase.HBaseTestingUtil)2 HBaseTestingUtility (org.apache.hadoop.hbase.HBaseTestingUtility)2 TableDescriptors (org.apache.hadoop.hbase.TableDescriptors)2 WALFactory (org.apache.hadoop.hbase.wal.WALFactory)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Cell (org.apache.hadoop.hbase.Cell)1 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)1 MiniHBaseCluster (org.apache.hadoop.hbase.MiniHBaseCluster)1