当前位置: 首页>>代码示例>>Java>>正文


Java MetaEditor.addRegionsToMeta方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.catalog.MetaEditor.addRegionsToMeta方法的典型用法代码示例。如果您正苦于以下问题:Java MetaEditor.addRegionsToMeta方法的具体用法?Java MetaEditor.addRegionsToMeta怎么用?Java MetaEditor.addRegionsToMeta使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.catalog.MetaEditor的用法示例。


在下文中一共展示了MetaEditor.addRegionsToMeta方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addRegionsToMeta

import org.apache.hadoop.hbase.catalog.MetaEditor; //导入方法依赖的package包/类
/**
 * Add the specified set of regions to the META table.
 */
protected void addRegionsToMeta(final CatalogTracker ct, final List<HRegionInfo> regionInfos)
    throws IOException {
  MetaEditor.addRegionsToMeta(this.catalogTracker, regionInfos);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:8,代码来源:CreateTableHandler.java

示例2: handleTableOperation

import org.apache.hadoop.hbase.catalog.MetaEditor; //导入方法依赖的package包/类
/**
 * The restore table is executed in place.
 *  - The on-disk data will be restored - reference files are put in place without moving data
 *  -  [if something fail here: you need to delete the table and re-run the restore]
 *  - META will be updated
 *  -  [if something fail here: you need to run hbck to fix META entries]
 * The passed in list gets changed in this method
 */
@Override
protected void handleTableOperation(List<HRegionInfo> hris) throws IOException {
  MasterFileSystem fileSystemManager = masterServices.getMasterFileSystem();
  CatalogTracker catalogTracker = masterServices.getCatalogTracker();
  FileSystem fs = fileSystemManager.getFileSystem();
  Path rootDir = fileSystemManager.getRootDir();
  byte[] tableName = hTableDescriptor.getName();
  Path tableDir = HTableDescriptor.getTableDir(rootDir, tableName);

  try {
    // 1. Update descriptor
    this.masterServices.getTableDescriptors().add(hTableDescriptor);

    // 2. Execute the on-disk Restore
    LOG.debug("Starting restore snapshot=" + SnapshotDescriptionUtils.toString(snapshot));
    Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshot, rootDir);
    RestoreSnapshotHelper restoreHelper = new RestoreSnapshotHelper(
        masterServices.getConfiguration(), fs,
        snapshot, snapshotDir, hTableDescriptor, tableDir, monitor, status);
    RestoreSnapshotHelper.RestoreMetaChanges metaChanges = restoreHelper.restoreHdfsRegions();

    // 3. Forces all the RegionStates to be offline
    //
    // The AssignmentManager keeps all the region states around
    // with no possibility to remove them, until the master is restarted.
    // This means that a region marked as SPLIT before the restore will never be assigned again.
    // To avoid having all states around all the regions are switched to the OFFLINE state,
    // which is the same state that the regions will be after a delete table.
    forceRegionsOffline(metaChanges);
    forceRegionsOffline(metaChanges);

    // 4. Applies changes to .META.

    // 4.1 Removes the current set of regions from META
    //
    // By removing also the regions to restore (the ones present both in the snapshot
    // and in the current state) we ensure that no extra fields are present in META
    // e.g. with a simple add addRegionToMeta() the splitA and splitB attributes
    // not overwritten/removed, so you end up with old informations
    // that are not correct after the restore.
    List<HRegionInfo> hrisToRemove = new LinkedList<HRegionInfo>();
    if (metaChanges.hasRegionsToRemove()) hrisToRemove.addAll(metaChanges.getRegionsToRemove());
    MetaEditor.deleteRegions(catalogTracker, hrisToRemove);

    // 4.2 Add the new set of regions to META
    //
    // At this point the old regions are no longer present in META.
    // and the set of regions present in the snapshot will be written to META.
    // All the information in META are coming from the .regioninfo of each region present
    // in the snapshot folder.
    hris.clear();
    if (metaChanges.hasRegionsToAdd()) hris.addAll(metaChanges.getRegionsToAdd());
    MetaEditor.addRegionsToMeta(catalogTracker, hris);
    if (metaChanges.hasRegionsToRestore()) {
      MetaEditor.overwriteRegions(catalogTracker, metaChanges.getRegionsToRestore());
    }
    metaChanges.updateMetaParentRegions(catalogTracker, hris);

    // At this point the restore is complete. Next step is enabling the table.
    LOG.info("Restore snapshot=" + SnapshotDescriptionUtils.toString(snapshot) + " on table=" +
      Bytes.toString(tableName) + " completed!");
  } catch (IOException e) {
    String msg = "restore snapshot=" + SnapshotDescriptionUtils.toString(snapshot)
        + " failed. Try re-running the restore command.";
    LOG.error(msg, e);
    monitor.receive(new ForeignException(masterServices.getServerName().toString(), e));
    throw new RestoreSnapshotException(msg, e);
  } finally {
    this.stopped = true;
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:80,代码来源:RestoreSnapshotHandler.java

示例3: addRegionsToMeta

import org.apache.hadoop.hbase.catalog.MetaEditor; //导入方法依赖的package包/类
/**
 * Add the specified set of regions to the hbase:meta table.
 */
protected void addRegionsToMeta(final CatalogTracker ct, final List<HRegionInfo> regionInfos)
    throws IOException {
  MetaEditor.addRegionsToMeta(this.catalogTracker, regionInfos);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:8,代码来源:CreateTableHandler.java

示例4: handleTableOperation

import org.apache.hadoop.hbase.catalog.MetaEditor; //导入方法依赖的package包/类
/**
 * The restore table is executed in place.
 *  - The on-disk data will be restored - reference files are put in place without moving data
 *  -  [if something fail here: you need to delete the table and re-run the restore]
 *  - hbase:meta will be updated
 *  -  [if something fail here: you need to run hbck to fix hbase:meta entries]
 * The passed in list gets changed in this method
 */
@Override
protected void handleTableOperation(List<HRegionInfo> hris) throws IOException {
  MasterFileSystem fileSystemManager = masterServices.getMasterFileSystem();
  CatalogTracker catalogTracker = masterServices.getCatalogTracker();
  FileSystem fs = fileSystemManager.getFileSystem();
  Path rootDir = fileSystemManager.getRootDir();
  TableName tableName = hTableDescriptor.getTableName();

  try {
    // 1. Update descriptor
    this.masterServices.getTableDescriptors().add(hTableDescriptor);

    // 2. Execute the on-disk Restore
    LOG.debug("Starting restore snapshot=" + ClientSnapshotDescriptionUtils.toString(snapshot));
    Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshot, rootDir);
    RestoreSnapshotHelper restoreHelper = new RestoreSnapshotHelper(
        masterServices.getConfiguration(), fs,
        snapshot, snapshotDir, hTableDescriptor, rootDir, monitor, status);
    RestoreSnapshotHelper.RestoreMetaChanges metaChanges = restoreHelper.restoreHdfsRegions();

    // 3. Forces all the RegionStates to be offline
    //
    // The AssignmentManager keeps all the region states around
    // with no possibility to remove them, until the master is restarted.
    // This means that a region marked as SPLIT before the restore will never be assigned again.
    // To avoid having all states around all the regions are switched to the OFFLINE state,
    // which is the same state that the regions will be after a delete table.
    forceRegionsOffline(metaChanges);

    // 4. Applies changes to hbase:meta
    status.setStatus("Preparing to restore each region");

    // 4.1 Removes the current set of regions from META
    //
    // By removing also the regions to restore (the ones present both in the snapshot
    // and in the current state) we ensure that no extra fields are present in META
    // e.g. with a simple add addRegionToMeta() the splitA and splitB attributes
    // not overwritten/removed, so you end up with old informations
    // that are not correct after the restore.
    List<HRegionInfo> hrisToRemove = new LinkedList<HRegionInfo>();
    if (metaChanges.hasRegionsToRemove()) hrisToRemove.addAll(metaChanges.getRegionsToRemove());
    MetaEditor.deleteRegions(catalogTracker, hrisToRemove);

    // 4.2 Add the new set of regions to META
    //
    // At this point the old regions are no longer present in META.
    // and the set of regions present in the snapshot will be written to META.
    // All the information in hbase:meta are coming from the .regioninfo of each region present
    // in the snapshot folder.
    hris.clear();
    if (metaChanges.hasRegionsToAdd()) hris.addAll(metaChanges.getRegionsToAdd());
    MetaEditor.addRegionsToMeta(catalogTracker, hris);
    if (metaChanges.hasRegionsToRestore()) {
      MetaEditor.overwriteRegions(catalogTracker, metaChanges.getRegionsToRestore());
    }
    metaChanges.updateMetaParentRegions(catalogTracker, hris);

    // At this point the restore is complete. Next step is enabling the table.
    LOG.info("Restore snapshot=" + ClientSnapshotDescriptionUtils.toString(snapshot) +
      " on table=" + tableName + " completed!");
  } catch (IOException e) {
    String msg = "restore snapshot=" + ClientSnapshotDescriptionUtils.toString(snapshot)
        + " failed. Try re-running the restore command.";
    LOG.error(msg, e);
    monitor.receive(new ForeignException(masterServices.getServerName().toString(), e));
    throw new RestoreSnapshotException(msg, e);
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:77,代码来源:RestoreSnapshotHandler.java

示例5: handleCreateTable

import org.apache.hadoop.hbase.catalog.MetaEditor; //导入方法依赖的package包/类
private void handleCreateTable() throws IOException, KeeperException {

    // TODO: Currently we make the table descriptor and as side-effect the
    // tableDir is created.  Should we change below method to be createTable
    // where we create table in tmp dir with its table descriptor file and then
    // do rename to move it into place?
    FSTableDescriptors.createTableDescriptor(this.hTableDescriptor, this.conf);

    List<HRegionInfo> regionInfos = new ArrayList<HRegionInfo>();
    final int batchSize =
      this.conf.getInt("hbase.master.createtable.batchsize", 100);
    HLog hlog = null;
    for (int regionIdx = 0; regionIdx < this.newRegions.length; regionIdx++) {
      HRegionInfo newRegion = this.newRegions[regionIdx];
      // 1. Create HRegion
      HRegion region = HRegion.createHRegion(newRegion,
        this.fileSystemManager.getRootDir(), this.conf,
        this.hTableDescriptor, hlog);
      if (hlog == null) {
        hlog = region.getLog();
      }

      regionInfos.add(region.getRegionInfo());
      if (regionIdx % batchSize == 0) {
        // 2. Insert into META
        MetaEditor.addRegionsToMeta(this.catalogTracker, regionInfos);
        regionInfos.clear();
      }

      // 3. Close the new region to flush to disk.  Close log file too.
      region.close();
    }
    hlog.closeAndDelete();
    if (regionInfos.size() > 0) {
      MetaEditor.addRegionsToMeta(this.catalogTracker, regionInfos);
    }

    // 4. Trigger immediate assignment of the regions in round-robin fashion
    List<ServerName> servers = serverManager.getOnlineServersList();
    try {
      this.assignmentManager.assignUserRegions(Arrays.asList(newRegions),
        servers);
    } catch (InterruptedException ie) {
      LOG.error("Caught " + ie + " during round-robin assignment");
      throw new IOException(ie);
    }

    // 5. Set table enabled flag up in zk.
    try {
      assignmentManager.getZKTable().
        setEnabledTable(this.hTableDescriptor.getNameAsString());
    } catch (KeeperException e) {
      throw new IOException("Unable to ensure that the table will be" +
        " enabled because of a ZooKeeper issue", e);
    }
  }
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:57,代码来源:CreateTableHandler.java

示例6: handleTableOperation

import org.apache.hadoop.hbase.catalog.MetaEditor; //导入方法依赖的package包/类
/**
 * The restore table is executed in place.
 *  - The on-disk data will be restored - reference files are put in place without moving data
 *  -  [if something fail here: you need to delete the table and re-run the restore]
 *  - hbase:meta will be updated
 *  -  [if something fail here: you need to run hbck to fix hbase:meta entries]
 * The passed in list gets changed in this method
 */
@Override
protected void handleTableOperation(List<HRegionInfo> hris) throws IOException {
  MasterFileSystem fileSystemManager = masterServices.getMasterFileSystem();
  CatalogTracker catalogTracker = masterServices.getCatalogTracker();
  FileSystem fs = fileSystemManager.getFileSystem();
  Path rootDir = fileSystemManager.getRootDir();
  TableName tableName = hTableDescriptor.getTableName();

  try {
    // 1. Update descriptor
    this.masterServices.getTableDescriptors().add(hTableDescriptor);

    // 2. Execute the on-disk Restore
    LOG.debug("Starting restore snapshot=" + ClientSnapshotDescriptionUtils.toString(snapshot));
    Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshot, rootDir);
    SnapshotManifest manifest = SnapshotManifest.open(masterServices.getConfiguration(), fs,
                                                      snapshotDir, snapshot);
    RestoreSnapshotHelper restoreHelper = new RestoreSnapshotHelper(
        masterServices.getConfiguration(), fs, manifest,
        this.hTableDescriptor, rootDir, monitor, status);
    RestoreSnapshotHelper.RestoreMetaChanges metaChanges = restoreHelper.restoreHdfsRegions();

    // 3. Forces all the RegionStates to be offline
    //
    // The AssignmentManager keeps all the region states around
    // with no possibility to remove them, until the master is restarted.
    // This means that a region marked as SPLIT before the restore will never be assigned again.
    // To avoid having all states around all the regions are switched to the OFFLINE state,
    // which is the same state that the regions will be after a delete table.
    forceRegionsOffline(metaChanges);

    // 4. Applies changes to hbase:meta
    status.setStatus("Preparing to restore each region");

    // 4.1 Removes the current set of regions from META
    //
    // By removing also the regions to restore (the ones present both in the snapshot
    // and in the current state) we ensure that no extra fields are present in META
    // e.g. with a simple add addRegionToMeta() the splitA and splitB attributes
    // not overwritten/removed, so you end up with old informations
    // that are not correct after the restore.
    List<HRegionInfo> hrisToRemove = new LinkedList<HRegionInfo>();
    if (metaChanges.hasRegionsToRemove()) hrisToRemove.addAll(metaChanges.getRegionsToRemove());
    MetaEditor.deleteRegions(catalogTracker, hrisToRemove);

    // 4.2 Add the new set of regions to META
    //
    // At this point the old regions are no longer present in META.
    // and the set of regions present in the snapshot will be written to META.
    // All the information in hbase:meta are coming from the .regioninfo of each region present
    // in the snapshot folder.
    hris.clear();
    if (metaChanges.hasRegionsToAdd()) hris.addAll(metaChanges.getRegionsToAdd());
    MetaEditor.addRegionsToMeta(catalogTracker, hris);
    if (metaChanges.hasRegionsToRestore()) {
      MetaEditor.overwriteRegions(catalogTracker, metaChanges.getRegionsToRestore());
    }
    metaChanges.updateMetaParentRegions(catalogTracker, hris);

    // At this point the restore is complete. Next step is enabling the table.
    LOG.info("Restore snapshot=" + ClientSnapshotDescriptionUtils.toString(snapshot) +
      " on table=" + tableName + " completed!");
  } catch (IOException e) {
    String msg = "restore snapshot=" + ClientSnapshotDescriptionUtils.toString(snapshot)
        + " failed. Try re-running the restore command.";
    LOG.error(msg, e);
    monitor.receive(new ForeignException(masterServices.getServerName().toString(), e));
    throw new RestoreSnapshotException(msg, e);
  }
}
 
开发者ID:shenli-uiuc,项目名称:PyroDB,代码行数:79,代码来源:RestoreSnapshotHandler.java


注:本文中的org.apache.hadoop.hbase.catalog.MetaEditor.addRegionsToMeta方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。