Search in sources :

Example 1 with MetricsWAL

use of org.apache.hadoop.hbase.regionserver.wal.MetricsWAL 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 MetricsWAL

use of org.apache.hadoop.hbase.regionserver.wal.MetricsWAL in project hbase by apache.

the class HRegionServer method setupWALAndReplication.

/**
   * Setup WAL log and replication if enabled.
   * Replication setup is done in here because it wants to be hooked up to WAL.
   * @return A WAL instance.
   * @throws IOException
   */
private WALFactory setupWALAndReplication() throws IOException {
    // TODO Replication make assumptions here based on the default filesystem impl
    final Path oldLogDir = new Path(walRootDir, HConstants.HREGION_OLDLOGDIR_NAME);
    final String logName = AbstractFSWALProvider.getWALDirectoryName(this.serverName.toString());
    Path logDir = new Path(walRootDir, logName);
    if (LOG.isDebugEnabled())
        LOG.debug("logDir=" + logDir);
    if (this.walFs.exists(logDir)) {
        throw new RegionServerRunningException("Region server has already " + "created directory at " + this.serverName.toString());
    }
    // Instantiate replication manager if replication enabled.  Pass it the
    // log directories.
    createNewReplicationInstance(conf, this, this.walFs, logDir, oldLogDir);
    // listeners the wal factory will add to wals it creates.
    final List<WALActionsListener> listeners = new ArrayList<>();
    listeners.add(new MetricsWAL());
    if (this.replicationSourceHandler != null && this.replicationSourceHandler.getWALActionsListener() != null) {
        // Replication handler is an implementation of WALActionsListener.
        listeners.add(this.replicationSourceHandler.getWALActionsListener());
    }
    return new WALFactory(conf, listeners, serverName.toString());
}
Also used : Path(org.apache.hadoop.fs.Path) MetricsWAL(org.apache.hadoop.hbase.regionserver.wal.MetricsWAL) ArrayList(java.util.ArrayList) WALActionsListener(org.apache.hadoop.hbase.regionserver.wal.WALActionsListener) WALFactory(org.apache.hadoop.hbase.wal.WALFactory)

Example 3 with MetricsWAL

use of org.apache.hadoop.hbase.regionserver.wal.MetricsWAL in project hbase by apache.

the class TestHRegion method createWALFactory.

static WALFactory createWALFactory(Configuration conf, Path rootDir) throws IOException {
    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));
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) MetricsWAL(org.apache.hadoop.hbase.regionserver.wal.MetricsWAL) WALFactory(org.apache.hadoop.hbase.wal.WALFactory)

Example 4 with MetricsWAL

use of org.apache.hadoop.hbase.regionserver.wal.MetricsWAL in project hbase by apache.

the class TestHRegion method createWALCompatibleWithFaultyFileSystem.

/**
   * Create a WAL outside of the usual helper in
   * {@link HBaseTestingUtility#createWal(Configuration, Path, HRegionInfo)} because that method
   * doesn't play nicely with FaultyFileSystem. Call this method before overriding
   * {@code fs.file.impl}.
   * @param callingMethod a unique component for the path, probably the name of the test method.
   */
private static WAL createWALCompatibleWithFaultyFileSystem(String callingMethod, Configuration conf, TableName tableName) throws IOException {
    final Path logDir = TEST_UTIL.getDataTestDirOnTestFS(callingMethod + ".log");
    final Configuration walConf = new Configuration(conf);
    FSUtils.setRootDir(walConf, logDir);
    return (new WALFactory(walConf, Collections.<WALActionsListener>singletonList(new MetricsWAL()), callingMethod)).getWAL(tableName.toBytes(), tableName.getNamespace());
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) MetricsWAL(org.apache.hadoop.hbase.regionserver.wal.MetricsWAL) WALFactory(org.apache.hadoop.hbase.wal.WALFactory)

Example 5 with MetricsWAL

use of org.apache.hadoop.hbase.regionserver.wal.MetricsWAL in project hbase by apache.

the class HBaseFsck method createNewMeta.

/**
   * This borrows code from MasterFileSystem.bootstrap(). Explicitly creates it's own WAL, so be
   * sure to close it as well as the region when you're finished.
   * @param walFactoryID A unique identifier for WAL factory. Filesystem implementations will use
   *          this ID to make a directory inside WAL directory path.
   * @return an open hbase:meta HRegion
   */
private HRegion createNewMeta(String walFactoryID) throws IOException {
    Path rootdir = FSUtils.getRootDir(getConf());
    Configuration c = getConf();
    HRegionInfo metaHRI = new HRegionInfo(HRegionInfo.FIRST_META_REGIONINFO);
    HTableDescriptor metaDescriptor = new FSTableDescriptors(c).get(TableName.META_TABLE_NAME);
    MasterFileSystem.setInfoFamilyCachingForMeta(metaDescriptor, false);
    // 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(c);
    confForWAL.set(HConstants.HBASE_DIR, rootdir.toString());
    WAL wal = (new WALFactory(confForWAL, Collections.<WALActionsListener>singletonList(new MetricsWAL()), walFactoryID)).getWAL(metaHRI.getEncodedNameAsBytes(), metaHRI.getTable().getNamespace());
    HRegion meta = HRegion.createHRegion(metaHRI, rootdir, c, metaDescriptor, wal);
    MasterFileSystem.setInfoFamilyCachingForMeta(metaDescriptor, true);
    return meta;
}
Also used : Path(org.apache.hadoop.fs.Path) HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) HRegion(org.apache.hadoop.hbase.regionserver.HRegion) WAL(org.apache.hadoop.hbase.wal.WAL) MetricsWAL(org.apache.hadoop.hbase.regionserver.wal.MetricsWAL) Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) MetricsWAL(org.apache.hadoop.hbase.regionserver.wal.MetricsWAL) WALFactory(org.apache.hadoop.hbase.wal.WALFactory) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Aggregations

MetricsWAL (org.apache.hadoop.hbase.regionserver.wal.MetricsWAL)5 WALFactory (org.apache.hadoop.hbase.wal.WALFactory)5 Configuration (org.apache.hadoop.conf.Configuration)4 Path (org.apache.hadoop.fs.Path)3 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)3 ArrayList (java.util.ArrayList)1 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)1 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)1 HRegion (org.apache.hadoop.hbase.regionserver.HRegion)1 WALActionsListener (org.apache.hadoop.hbase.regionserver.wal.WALActionsListener)1 WAL (org.apache.hadoop.hbase.wal.WAL)1