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());
}
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());
}
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));
}
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());
}
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;
}
Aggregations