Search in sources :

Example 1 with WALFactory

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

the class HBaseTestingUtility method createWal.

/**
   * Create an unmanaged WAL. Be sure to close it when you're through.
   */
public static WAL createWal(final Configuration conf, final Path rootDir, final HRegionInfo hri) throws IOException {
    // The WAL subsystem will use the default rootDir rather than the passed in rootDir
    // unless I pass along via the conf.
    Configuration confForWAL = new Configuration(conf);
    confForWAL.set(HConstants.HBASE_DIR, rootDir.toString());
    return (new WALFactory(confForWAL, Collections.<WALActionsListener>singletonList(new MetricsWAL()), "hregion-" + RandomStringUtils.randomNumeric(8))).getWAL(hri.getEncodedNameAsBytes(), hri.getTable().getNamespace());
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) MetricsWAL(org.apache.hadoop.hbase.regionserver.wal.MetricsWAL) WALFactory(org.apache.hadoop.hbase.wal.WALFactory)

Example 2 with WALFactory

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

the class TestWALMonotonicallyIncreasingSeqId method initHRegion.

private Region initHRegion(HTableDescriptor htd, byte[] startKey, byte[] stopKey, int replicaId) throws IOException {
    Configuration conf = TEST_UTIL.getConfiguration();
    conf.setBoolean("hbase.hregion.mvcc.preassign", false);
    Path tableDir = FSUtils.getTableDir(testDir, htd.getTableName());
    HRegionInfo info = new HRegionInfo(htd.getTableName(), startKey, stopKey, false, 0, replicaId);
    fileSystem = tableDir.getFileSystem(conf);
    HRegionFileSystem fs = new HRegionFileSystem(conf, fileSystem, tableDir, info);
    final Configuration walConf = new Configuration(conf);
    FSUtils.setRootDir(walConf, tableDir);
    this.walConf = walConf;
    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) Configuration(org.apache.hadoop.conf.Configuration) WALFactory(org.apache.hadoop.hbase.wal.WALFactory)

Example 3 with WALFactory

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

the class TestStore method init.

@SuppressWarnings("deprecation")
private Store init(String methodName, Configuration conf, HTableDescriptor htd, HColumnDescriptor hcd) throws IOException {
    //Setting up a Store
    Path basedir = new Path(DIR + methodName);
    Path tableDir = FSUtils.getTableDir(basedir, htd.getTableName());
    final Path logdir = new Path(basedir, AbstractFSWALProvider.getWALDirectoryName(methodName));
    FileSystem fs = FileSystem.get(conf);
    fs.delete(logdir, true);
    if (htd.hasFamily(hcd.getName())) {
        htd.modifyFamily(hcd);
    } else {
        htd.addFamily(hcd);
    }
    HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false);
    final Configuration walConf = new Configuration(conf);
    FSUtils.setRootDir(walConf, basedir);
    final WALFactory wals = new WALFactory(walConf, null, methodName);
    HRegion region = new HRegion(tableDir, wals.getWAL(info.getEncodedNameAsBytes(), info.getTable().getNamespace()), fs, conf, info, htd, null);
    store = new HStore(region, hcd, conf);
    return store;
}
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) CompactionConfiguration(org.apache.hadoop.hbase.regionserver.compactions.CompactionConfiguration) FileSystem(org.apache.hadoop.fs.FileSystem) FilterFileSystem(org.apache.hadoop.fs.FilterFileSystem) LocalFileSystem(org.apache.hadoop.fs.LocalFileSystem) WALFactory(org.apache.hadoop.hbase.wal.WALFactory)

Example 4 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 5 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)

Aggregations

WALFactory (org.apache.hadoop.hbase.wal.WALFactory)64 Path (org.apache.hadoop.fs.Path)42 Configuration (org.apache.hadoop.conf.Configuration)33 WAL (org.apache.hadoop.hbase.wal.WAL)28 Test (org.junit.Test)23 FileSystem (org.apache.hadoop.fs.FileSystem)22 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)13 HRegion (org.apache.hadoop.hbase.regionserver.HRegion)13 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)12 WALEdit (org.apache.hadoop.hbase.wal.WALEdit)12 IOException (java.io.IOException)11 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)11 KeyValue (org.apache.hadoop.hbase.KeyValue)11 WALKeyImpl (org.apache.hadoop.hbase.wal.WALKeyImpl)10 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)9 WALProvider (org.apache.hadoop.hbase.wal.WALProvider)9 TreeMap (java.util.TreeMap)8 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)8 Before (org.junit.Before)8 Result (org.apache.hadoop.hbase.client.Result)7