Search in sources :

Example 6 with WALFactory

use of org.apache.hadoop.hbase.wal.WALFactory in project hbase by apache.

the class TestStoreFileRefresherChore method initHRegion.

private Region initHRegion(HTableDescriptor htd, byte[] startKey, byte[] stopKey, int replicaId) throws IOException {
    Configuration conf = TEST_UTIL.getConfiguration();
    Path tableDir = FSUtils.getTableDir(testDir, htd.getTableName());
    HRegionInfo info = new HRegionInfo(htd.getTableName(), startKey, stopKey, false, 0, replicaId);
    HRegionFileSystem fs = new FailingHRegionFileSystem(conf, tableDir.getFileSystem(conf), tableDir, info);
    final Configuration walConf = new Configuration(conf);
    FSUtils.setRootDir(walConf, tableDir);
    final WALFactory wals = new WALFactory(walConf, null, "log_" + replicaId);
    HRegion region = new HRegion(fs, wals.getWAL(info.getEncodedNameAsBytes(), info.getTable().getNamespace()), conf, htd, null);
    region.initialize();
    return region;
}
Also used : Path(org.apache.hadoop.fs.Path) HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) Configuration(org.apache.hadoop.conf.Configuration) WALFactory(org.apache.hadoop.hbase.wal.WALFactory)

Example 7 with WALFactory

use of org.apache.hadoop.hbase.wal.WALFactory in project hbase by apache.

the class TestWALObserver method setUp.

@Before
public void setUp() throws Exception {
    this.conf = HBaseConfiguration.create(TEST_UTIL.getConfiguration());
    // this.cluster = TEST_UTIL.getDFSCluster();
    this.fs = TEST_UTIL.getDFSCluster().getFileSystem();
    this.hbaseRootDir = FSUtils.getRootDir(conf);
    this.hbaseWALRootDir = FSUtils.getWALRootDir(conf);
    this.oldLogDir = new Path(this.hbaseWALRootDir, HConstants.HREGION_OLDLOGDIR_NAME);
    String serverName = ServerName.valueOf(currentTest.getMethodName(), 16010, System.currentTimeMillis()).toString();
    this.logDir = new Path(this.hbaseWALRootDir, AbstractFSWALProvider.getWALDirectoryName(serverName));
    if (TEST_UTIL.getDFSCluster().getFileSystem().exists(this.hbaseRootDir)) {
        TEST_UTIL.getDFSCluster().getFileSystem().delete(this.hbaseRootDir, true);
    }
    if (TEST_UTIL.getDFSCluster().getFileSystem().exists(this.hbaseWALRootDir)) {
        TEST_UTIL.getDFSCluster().getFileSystem().delete(this.hbaseWALRootDir, true);
    }
    this.wals = new WALFactory(conf, null, serverName);
}
Also used : Path(org.apache.hadoop.fs.Path) WALFactory(org.apache.hadoop.hbase.wal.WALFactory) Before(org.junit.Before)

Example 8 with WALFactory

use of org.apache.hadoop.hbase.wal.WALFactory in project hbase by apache.

the class TestCompactionArchiveConcurrentClose method initHRegion.

private Region initHRegion(HTableDescriptor htd, HRegionInfo info) throws IOException {
    Configuration conf = testUtil.getConfiguration();
    Path tableDir = FSUtils.getTableDir(testDir, htd.getTableName());
    HRegionFileSystem fs = new WaitingHRegionFileSystem(conf, tableDir.getFileSystem(conf), tableDir, info);
    final Configuration walConf = new Configuration(conf);
    FSUtils.setRootDir(walConf, tableDir);
    final WALFactory wals = new WALFactory(walConf, null, "log_" + info.getEncodedName());
    HRegion region = new HRegion(fs, wals.getWAL(info.getEncodedNameAsBytes(), info.getTable().getNamespace()), conf, htd, null);
    region.initialize();
    return region;
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) WALFactory(org.apache.hadoop.hbase.wal.WALFactory)

Example 9 with WALFactory

use of org.apache.hadoop.hbase.wal.WALFactory in project hbase by apache.

the class TestCompactionArchiveIOException method initHRegion.

private HRegion initHRegion(HTableDescriptor htd, HRegionInfo info) throws IOException {
    Configuration conf = testUtil.getConfiguration();
    Path tableDir = FSUtils.getTableDir(testDir, htd.getTableName());
    Path regionDir = new Path(tableDir, info.getEncodedName());
    Path storeDir = new Path(regionDir, htd.getColumnFamilies()[0].getNameAsString());
    FileSystem errFS = spy(testUtil.getTestFileSystem());
    // Prior to HBASE-16964, when an exception is thrown archiving any compacted file,
    // none of the other files are cleared from the compactedfiles list.
    // Simulate this condition with a dummy file
    doThrow(new IOException("Error for test")).when(errFS).rename(eq(new Path(storeDir, ERROR_FILE)), any(Path.class));
    HRegionFileSystem fs = new HRegionFileSystem(conf, errFS, tableDir, info);
    final Configuration walConf = new Configuration(conf);
    FSUtils.setRootDir(walConf, tableDir);
    final WALFactory wals = new WALFactory(walConf, null, "log_" + info.getEncodedName());
    HRegion region = new HRegion(fs, wals.getWAL(info.getEncodedNameAsBytes(), info.getTable().getNamespace()), conf, htd, null);
    region.initialize();
    return region;
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) FileSystem(org.apache.hadoop.fs.FileSystem) WALFactory(org.apache.hadoop.hbase.wal.WALFactory) IOException(java.io.IOException)

Example 10 with WALFactory

use of org.apache.hadoop.hbase.wal.WALFactory in project hbase by apache.

the class TestDefaultMemStore method testShouldFlushMeta.

@Test
public void testShouldFlushMeta() throws Exception {
    // write an edit in the META and ensure the shouldFlush (that the periodic memstore
    // flusher invokes) returns true after SYSTEM_CACHE_FLUSH_INTERVAL (even though
    // the MEMSTORE_PERIODIC_FLUSH_INTERVAL is set to a higher value)
    Configuration conf = new Configuration();
    conf.setInt(HRegion.MEMSTORE_PERIODIC_FLUSH_INTERVAL, HRegion.SYSTEM_CACHE_FLUSH_INTERVAL * 10);
    HBaseTestingUtility hbaseUtility = HBaseTestingUtility.createLocalHTU(conf);
    Path testDir = hbaseUtility.getDataTestDir();
    EnvironmentEdgeForMemstoreTest edge = new EnvironmentEdgeForMemstoreTest();
    EnvironmentEdgeManager.injectEdge(edge);
    edge.setCurrentTimeMillis(1234);
    WALFactory wFactory = new WALFactory(conf, null, "1234");
    HRegion meta = HRegion.createHRegion(HRegionInfo.FIRST_META_REGIONINFO, testDir, conf, FSTableDescriptors.createMetaTableDescriptor(conf), wFactory.getMetaWAL(HRegionInfo.FIRST_META_REGIONINFO.getEncodedNameAsBytes()));
    HRegionInfo hri = new HRegionInfo(TableName.valueOf(name.getMethodName()), Bytes.toBytes("row_0200"), Bytes.toBytes("row_0300"));
    HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
    desc.addFamily(new HColumnDescriptor("foo".getBytes()));
    HRegion r = HRegion.createHRegion(hri, testDir, conf, desc, wFactory.getWAL(hri.getEncodedNameAsBytes(), hri.getTable().getNamespace()));
    HRegion.addRegionToMETA(meta, r);
    edge.setCurrentTimeMillis(1234 + 100);
    StringBuffer sb = new StringBuffer();
    assertTrue(meta.shouldFlush(sb) == false);
    edge.setCurrentTimeMillis(edge.currentTime() + HRegion.SYSTEM_CACHE_FLUSH_INTERVAL + 1);
    assertTrue(meta.shouldFlush(sb) == true);
}
Also used : Path(org.apache.hadoop.fs.Path) HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) HBaseTestingUtility(org.apache.hadoop.hbase.HBaseTestingUtility) HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) WALFactory(org.apache.hadoop.hbase.wal.WALFactory) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) Test(org.junit.Test)

Aggregations

WALFactory (org.apache.hadoop.hbase.wal.WALFactory)42 Path (org.apache.hadoop.fs.Path)30 WAL (org.apache.hadoop.hbase.wal.WAL)24 Configuration (org.apache.hadoop.conf.Configuration)19 Test (org.junit.Test)17 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)16 FileSystem (org.apache.hadoop.fs.FileSystem)15 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)14 HRegion (org.apache.hadoop.hbase.regionserver.HRegion)12 MetricsWAL (org.apache.hadoop.hbase.regionserver.wal.MetricsWAL)11 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)10 KeyValue (org.apache.hadoop.hbase.KeyValue)8 WALKey (org.apache.hadoop.hbase.wal.WALKey)8 TreeMap (java.util.TreeMap)7 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)7 Result (org.apache.hadoop.hbase.client.Result)7 WALEdit (org.apache.hadoop.hbase.regionserver.wal.WALEdit)7 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 Before (org.junit.Before)6