Java 类org.apache.hadoop.hbase.regionserver.wal.MetricsWAL 实例源码

项目:ditb    文件:WALFactory.java   
/**
 * @param identifier may not be null, contents will not be altered
 */
public WAL getMetaWAL(final byte[] identifier) throws IOException {
  WALProvider metaProvider = this.metaProvider.get();
  if (null == metaProvider) {
    final WALProvider temp = getProvider(META_WAL_PROVIDER, DEFAULT_META_WAL_PROVIDER,
        Collections.<WALActionsListener>singletonList(new MetricsWAL()),
        DefaultWALProvider.META_WAL_PROVIDER_ID);
    if (this.metaProvider.compareAndSet(null, temp)) {
      metaProvider = temp;
    } else {
      // reference must now be to a provider created in another thread.
      temp.close();
      metaProvider = this.metaProvider.get();
    }
  }
  return metaProvider.getWAL(identifier);
}
项目:ditb    文件:HRegion.java   
/**
 * Convenience method creating new HRegions. Used by createTable. The {@link WAL} for the created
 * region needs to be closed explicitly, if it is not null. Use {@link HRegion#getWAL()} to get
 * access.
 *
 * @param info       Info for region to create.
 * @param rootDir    Root directory for HBase instance
 * @param tableDir   table directory
 * @param wal        shared WAL
 * @param initialize - true to initialize the region
 * @param ignoreWAL  - true to skip generate new wal if it is null, mostly for createTable
 * @return new HRegion
 * @throws IOException
 */
public static HRegion createHRegion(final HRegionInfo info, final Path rootDir,
    final Path tableDir, final Configuration conf, final HTableDescriptor hTableDescriptor,
    final WAL wal, final boolean initialize, final boolean ignoreWAL) throws IOException {
  LOG.info("creating HRegion " + info.getTable().getNameAsString() + " HTD == " + hTableDescriptor
      + " RootDir = " + rootDir + " Table name == " + info.getTable().getNameAsString());
  FileSystem fs = FileSystem.get(conf);
  HRegionFileSystem.createRegionOnFileSystem(conf, fs, tableDir, info);
  WAL effectiveWAL = wal;
  if (wal == null && !ignoreWAL) {
    // TODO HBASE-11983 There'll be no roller for this wal?
    // 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());
    effectiveWAL = (new WALFactory(confForWAL,
        Collections.<WALActionsListener>singletonList(new MetricsWAL()),
        "hregion-" + RandomStringUtils.randomNumeric(8))).getWAL(info.getEncodedNameAsBytes());
  }
  HRegion region =
      HRegion.newHRegion(tableDir, effectiveWAL, fs, conf, info, hTableDescriptor, null);
  if (initialize) region.initialize(null);
  return region;
}
项目:pbase    文件:WALFactory.java   
/**
 * @param identifier may not be null, contents will not be altered
 */
public WAL getMetaWAL(final byte[] identifier) throws IOException {
  WALProvider metaProvider = this.metaProvider.get();
  if (null == metaProvider) {
    final WALProvider temp = getProvider(META_WAL_PROVIDER, DEFAULT_META_WAL_PROVIDER,
        Collections.<WALActionsListener>singletonList(new MetricsWAL()),
        DefaultWALProvider.META_WAL_PROVIDER_ID);
    if (this.metaProvider.compareAndSet(null, temp)) {
      metaProvider = temp;
    } else {
      // reference must now be to a provider created in another thread.
      temp.close();
      metaProvider = this.metaProvider.get();
    }
  }
  return metaProvider.getWAL(identifier);
}
项目:ditb    文件:HRegionServer.java   
/**
 * 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(rootDir, HConstants.HREGION_OLDLOGDIR_NAME);
  final String logName = DefaultWALProvider.getWALDirectoryName(this.serverName.toString());

  Path logdir = new Path(rootDir, logName);
  if (LOG.isDebugEnabled()) LOG.debug("logdir=" + logdir);
  if (this.fs.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.fs, logdir, oldLogDir);

  // listeners the wal factory will add to wals it creates.
  final List<WALActionsListener> listeners = new ArrayList<WALActionsListener>();
  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());
}
项目:ditb    文件:HBaseTestingUtility.java   
/**
 * 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());
}
项目:ditb    文件:TestHRegion.java   
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));
}
项目:pbase    文件:HRegionServer.java   
/**
 * 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(rootDir, HConstants.HREGION_OLDLOGDIR_NAME);
    final String logName = DefaultWALProvider.getWALDirectoryName(this.serverName.toString());

    Path logdir = new Path(rootDir, logName);
    if (LOG.isDebugEnabled()) LOG.debug("logdir=" + logdir);
    if (this.fs.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.fs, logdir, oldLogDir);

    // listeners the wal factory will add to wals it creates.
    final List<WALActionsListener> listeners = new ArrayList<WALActionsListener>();
    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());
}
项目:pbase    文件:HRegion.java   
/**
 * Convenience method creating new HRegions. Used by createTable.
 * The {@link WAL} for the created region needs to be closed
 * explicitly, if it is not null.
 * Use {@link HRegion#getWAL()} to get access.
 *
 * @param info       Info for region to create.
 * @param rootDir    Root directory for HBase instance
 * @param tableDir   table directory
 * @param wal        shared WAL
 * @param initialize - true to initialize the region
 * @param ignoreWAL  - true to skip generate new wal if it is null, mostly for createTable
 * @return new HRegion
 * @throws IOException
 */
public static HRegion createHRegion(final HRegionInfo info, final Path rootDir, final Path tableDir,
                                    final Configuration conf,
                                    final HTableDescriptor hTableDescriptor,
                                    final WAL wal,
                                    final boolean initialize, final boolean ignoreWAL)
        throws IOException {
    LOG.info("creating HRegion " + info.getTable().getNameAsString()
            + " HTD == " + hTableDescriptor + " RootDir = " + rootDir +
            " Table name == " + info.getTable().getNameAsString());
    FileSystem fs = FileSystem.get(conf);
    HRegionFileSystem.createRegionOnFileSystem(conf, fs, tableDir, info);
    WAL effectiveWAL = wal;
    if (wal == null && !ignoreWAL) {
        // TODO HBASE-11983 There'll be no roller for this wal?
        // 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());
        effectiveWAL = (new WALFactory(confForWAL,
                Collections.<WALActionsListener>singletonList(new MetricsWAL()),
                "hregion-" + RandomStringUtils.randomNumeric(8))).
                getWAL(info.getEncodedNameAsBytes());
    }
    HRegion region = HRegion.newHRegion(tableDir,
            effectiveWAL, fs, conf, info, hTableDescriptor, null);
    if (initialize) {
        // If initializing, set the sequenceId. It is also required by WALPerformanceEvaluation when
        // verifying the WALEdits.
        region.setSequenceId(region.initialize(null));
    }
    return region;
}
项目:hbase    文件:WALFactory.java   
/**
 * instantiate a provider from a config property. requires conf to have already been set (as well
 * as anything the provider might need to read).
 */
WALProvider getProvider(String key, String defaultValue, String providerId) throws IOException {
  Class<? extends WALProvider> clazz = getProviderClass(key, defaultValue);
  WALProvider provider = createProvider(clazz, providerId);
  provider.addWALActionsListener(new MetricsWAL());
  return provider;
}