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


Java HBaseFileSystem.createNewFileOnFileSystem方法代码示例

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


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

示例1: markCorrupted

import org.apache.hadoop.hbase.HBaseFileSystem; //导入方法依赖的package包/类
public static void markCorrupted(Path rootdir, String logFileName,
    FileSystem fs) {
  Path file = new Path(getSplitLogDir(rootdir, logFileName), "corrupt");
  try {
    HBaseFileSystem.createNewFileOnFileSystem(fs, file);
  } catch (IOException e) {
    LOG.warn("Could not flag a log file as corrupted. Failed to create " +
        file, e);
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:11,代码来源:ZKSplitLog.java

示例2: addRegionToSnapshot

import org.apache.hadoop.hbase.HBaseFileSystem; //导入方法依赖的package包/类
/**
 * Complete taking the snapshot on the region. Writes the region info and adds references to the
 * working snapshot directory. TODO for api consistency, consider adding another version with no
 * {@link ForeignExceptionSnare} arg. (In the future other cancellable HRegion methods could
 * eventually add a {@link ForeignExceptionSnare}, or we could do something fancier).
 * @param desc snasphot description object
 * @param exnSnare ForeignExceptionSnare that captures external exeptions in case we need to bail
 *          out. This is allowed to be null and will just be ignored in that case.
 * @throws IOException if there is an external or internal error causing the snapshot to fail
 */
public void addRegionToSnapshot(SnapshotDescription desc, ForeignExceptionSnare exnSnare)
    throws IOException {
  // This should be "fast" since we don't rewrite store files but instead
  // back up the store files by creating a reference
  Path rootDir = FSUtils.getRootDir(this.rsServices.getConfiguration());
  Path snapshotRegionDir =
      TakeSnapshotUtils.getRegionSnapshotDirectory(desc, rootDir, regionInfo.getEncodedName());

  // 1. dump region meta info into the snapshot directory
  LOG.debug("Storing region-info for snapshot.");
  checkRegioninfoOnFilesystem(snapshotRegionDir);

  // 2. iterate through all the stores in the region
  LOG.debug("Creating references for hfiles");

  // This ensures that we have an atomic view of the directory as long as we have < ls limit
  // (batch size of the files in a directory) on the namenode. Otherwise, we get back the files in
  // batches and may miss files being added/deleted. This could be more robust (iteratively
  // checking to see if we have all the files until we are sure), but the limit is currently 1000
  // files/batch, far more than the number of store files under a single column family.
  for (Store store : stores.values()) {
    // 2.1. build the snapshot reference directory for the store
    Path dstStoreDir =
        TakeSnapshotUtils.getStoreSnapshotDirectory(snapshotRegionDir,
          Bytes.toString(store.getFamily().getName()));
    List<StoreFile> storeFiles = store.getStorefiles();
    if (LOG.isDebugEnabled()) {
      LOG.debug("Adding snapshot references for " + storeFiles + " hfiles");
    }

    // 2.2. iterate through all the store's files and create "references".
    int sz = storeFiles.size();
    for (int i = 0; i < sz; i++) {
      if (exnSnare != null) {
        exnSnare.rethrowException();
      }
      StoreFile storeFile = storeFiles.get(i);
      Path file = storeFile.getPath();

      LOG.debug("Creating reference for file (" + (i + 1) + "/" + sz + ") : " + file);
      Path referenceFile = new Path(dstStoreDir, file.getName());
      boolean success = true;
      if (storeFile.isReference()) {
        // write the Reference object to the snapshot
        storeFile.getReference().write(fs, referenceFile);
      } else {
        // create "reference" to this store file. It is intentionally an empty file -- all
        // necessary information is captured by its fs location and filename. This allows us to
        // only figure out what needs to be done via a single nn operation (instead of having to
        // open and read the files as well).
        success = HBaseFileSystem.createNewFileOnFileSystem(fs, referenceFile);
      }
      if (!success) {
        throw new IOException("Failed to create reference file:" + referenceFile);
      }
    }
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:69,代码来源:HRegion.java

示例3: addRegionToSnapshot

import org.apache.hadoop.hbase.HBaseFileSystem; //导入方法依赖的package包/类
/**
 * Complete taking the snapshot on the region. Writes the region info and adds references to the
 * working snapshot directory.
 *
 * TODO for api consistency, consider adding another version with no {@link ForeignExceptionSnare}
 * arg.  (In the future other cancellable HRegion methods could eventually add a
 * {@link ForeignExceptionSnare}, or we could do something fancier).
 *
 * @param desc snasphot description object
 * @param exnSnare ForeignExceptionSnare that captures external exeptions in case we need to
 *   bail out.  This is allowed to be null and will just be ignored in that case.
 * @throws IOException if there is an external or internal error causing the snapshot to fail
 */
public void addRegionToSnapshot(SnapshotDescription desc,
    ForeignExceptionSnare exnSnare) throws IOException {
  // This should be "fast" since we don't rewrite store files but instead
  // back up the store files by creating a reference
  Path rootDir = FSUtils.getRootDir(this.rsServices.getConfiguration());
  Path snapshotRegionDir = TakeSnapshotUtils.getRegionSnapshotDirectory(desc, rootDir,
    regionInfo.getEncodedName());

  // 1. dump region meta info into the snapshot directory
  LOG.debug("Storing region-info for snapshot.");
  checkRegioninfoOnFilesystem(snapshotRegionDir);

  // 2. iterate through all the stores in the region
  LOG.debug("Creating references for hfiles");

  // This ensures that we have an atomic view of the directory as long as we have < ls limit
  // (batch size of the files in a directory) on the namenode. Otherwise, we get back the files in
  // batches and may miss files being added/deleted. This could be more robust (iteratively
  // checking to see if we have all the files until we are sure), but the limit is currently 1000
  // files/batch, far more than the number of store files under a single column family.
  for (Store store : stores.values()) {
    // 2.1. build the snapshot reference directory for the store
    Path dstStoreDir = TakeSnapshotUtils.getStoreSnapshotDirectory(snapshotRegionDir,
      Bytes.toString(store.getFamily().getName()));
    List<StoreFile> storeFiles = store.getStorefiles();
    if (LOG.isDebugEnabled()) {
      LOG.debug("Adding snapshot references for " + storeFiles  + " hfiles");
    }

    // 2.2. iterate through all the store's files and create "references".
    int sz = storeFiles.size();
    for (int i = 0; i < sz; i++) {
      if (exnSnare != null) {
        exnSnare.rethrowException();
      }
      StoreFile storeFile = storeFiles.get(i);
      Path file = storeFile.getPath();

      LOG.debug("Creating reference for file (" + (i+1) + "/" + sz + ") : " + file);
      Path referenceFile = new Path(dstStoreDir, file.getName());
      boolean success = true;
      if (storeFile.isReference()) {
        // write the Reference object to the snapshot
        storeFile.getReference().write(fs, referenceFile);
      } else {
        // create "reference" to this store file.  It is intentionally an empty file -- all
        // necessary information is captured by its fs location and filename.  This allows us to
        // only figure out what needs to be done via a single nn operation (instead of having to
        // open and read the files as well).
        success = HBaseFileSystem.createNewFileOnFileSystem(fs, referenceFile);
      }
      if (!success) {
        throw new IOException("Failed to create reference file:" + referenceFile);
      }
    }
  }
}
 
开发者ID:wanhao,项目名称:IRIndex,代码行数:71,代码来源:HRegion.java

示例4: addRegionToSnapshot

import org.apache.hadoop.hbase.HBaseFileSystem; //导入方法依赖的package包/类
/**
 * Complete taking the snapshot on the region. Writes the region info and adds references to the
 * working snapshot directory.
 *
 * TODO for api consistency, consider adding another version with no {@link ForeignExceptionSnare}
 * arg.  (In the future other cancellable HRegion methods could eventually add a
 * {@link ForeignExceptionSnare}, or we could do something fancier).
 *
 * @param desc snasphot description object
 * @param exnSnare ForeignExceptionSnare that captures external exeptions in case we need to
 *   bail out.  This is allowed to be null and will just be ignored in that case.
 * @throws IOException if there is an external or internal error causing the snapshot to fail
 */
public void addRegionToSnapshot(SnapshotDescription desc,
    ForeignExceptionSnare exnSnare) throws IOException {
  // This should be "fast" since we don't rewrite store files but instead
  // back up the store files by creating a reference
  Path rootDir = FSUtils.getRootDir(this.rsServices.getConfiguration());
  Path snapshotRegionDir = TakeSnapshotUtils.getRegionSnapshotDirectory(desc, rootDir,
    regionInfo.getEncodedName());

  // 1. dump region meta info into the snapshot directory
  LOG.debug("Storing region-info for snapshot.");
  checkRegioninfoOnFilesystem(snapshotRegionDir);

  // 2. iterate through all the stores in the region
  LOG.debug("Creating references for hfiles");

  // This ensures that we have an atomic view of the directory as long as we have < ls limit
  // (batch size of the files in a directory) on the namenode. Otherwise, we get back the files in
  // batches and may miss files being added/deleted. This could be more robust (iteratively
  // checking to see if we have all the files until we are sure), but the limit is currently 1000
  // files/batch, far more than the number of store files under a single column family.
  for (Store store : stores.values()) {
    // 2.1. build the snapshot reference directory for the store
    Path dstStoreDir = TakeSnapshotUtils.getStoreSnapshotDirectory(snapshotRegionDir,
      Bytes.toString(store.getFamily().getName()));
    List<StoreFile> storeFiles = store.getStorefiles();
    if (LOG.isDebugEnabled()) {
      LOG.debug("Adding snapshot references for " + storeFiles  + " hfiles");
    }

    // 2.2. iterate through all the store's files and create "references".
    int sz = storeFiles.size();
    for (int i = 0; i < sz; i++) {
      if (exnSnare != null) {
        exnSnare.rethrowException();
      }
      Path file = storeFiles.get(i).getPath();
      // create "reference" to this store file.  It is intentionally an empty file -- all
      // necessary infomration is captured by its fs location and filename.  This allows us to
      // only figure out what needs to be done via a single nn operation (instead of having to
      // open and read the files as well).
      LOG.debug("Creating reference for file (" + (i+1) + "/" + sz + ") : " + file);
      Path referenceFile = new Path(dstStoreDir, file.getName());
      boolean success = HBaseFileSystem.createNewFileOnFileSystem(fs, referenceFile);
      if (!success) {
        throw new IOException("Failed to create reference file:" + referenceFile);
      }
    }
  }
}
 
开发者ID:zwqjsj0404,项目名称:HBase-Research,代码行数:63,代码来源:HRegion.java


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