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


Java FSUtils.DirFilter方法代码示例

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


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

示例1: getStoreFiles

import org.apache.hadoop.hbase.util.FSUtils; //导入方法依赖的package包/类
/**
 * Returns all files belonging to the given region directory. Could return an
 * empty list.
 *
 * @param fs  The file system reference.
 * @param regionDir  The region directory to scan.
 * @return The list of files found.
 * @throws IOException When scanning the files fails.
 */
static List<Path> getStoreFiles(FileSystem fs, Path regionDir)
throws IOException {
  List<Path> res = new ArrayList<Path>();
  PathFilter dirFilter = new FSUtils.DirFilter(fs);
  FileStatus[] familyDirs = fs.listStatus(regionDir, dirFilter);
  for(FileStatus dir : familyDirs) {
    FileStatus[] files = fs.listStatus(dir.getPath());
    for (FileStatus file : files) {
      if (!file.isDir()) {
        res.add(file.getPath());
      }
    }
  }
  return res;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:25,代码来源:IndexFile.java

示例2: getStoreFiles

import org.apache.hadoop.hbase.util.FSUtils; //导入方法依赖的package包/类
/**
 * Returns all HFiles belonging to the given region directory. Could return an
 * empty list.
 *
 * @param fs  The file system reference.
 * @param regionDir  The region directory to scan.
 * @return The list of files found.
 * @throws IOException When scanning the files fails.
 */
static List<Path> getStoreFiles(FileSystem fs, Path regionDir) throws IOException {
  List<Path> regionHFiles = new ArrayList<Path>();
  PathFilter dirFilter = new FSUtils.DirFilter(fs);
  FileStatus[] familyDirs = fs.listStatus(regionDir, dirFilter);
  for (FileStatus dir : familyDirs) {
    FileStatus[] files = fs.listStatus(dir.getPath());
    for (FileStatus file : files) {
      if (!file.isDirectory() && (!file.getPath().toString()
          .contains(HConstants.HREGION_OLDLOGDIR_NAME)) && (!file.getPath().toString()
          .contains(HConstants.RECOVERED_EDITS_DIR))) {
        regionHFiles.add(file.getPath());
      }
    }
  }
  return regionHFiles;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:26,代码来源:HFile.java

示例3: archiveRegion

import org.apache.hadoop.hbase.util.FSUtils; //导入方法依赖的package包/类
/**
 * Remove an entire region from the table directory via archiving the region's hfiles.
 * @param fs {@link FileSystem} from which to remove the region
 * @param rootdir {@link Path} to the root directory where hbase files are stored (for building
 *          the archive path)
 * @param tableDir {@link Path} to where the table is being stored (for building the archive path)
 * @param regionDir {@link Path} to where a region is being stored (for building the archive path)
 * @return <tt>true</tt> if the region was sucessfully deleted. <tt>false</tt> if the filesystem
 *         operations could not complete.
 * @throws IOException if the request cannot be completed
 */
public static boolean archiveRegion(FileSystem fs, Path rootdir, Path tableDir, Path regionDir)
    throws IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("ARCHIVING " + regionDir.toString());
  }

  // otherwise, we archive the files
  // make sure we can archive
  if (tableDir == null || regionDir == null) {
    LOG.error("No archive directory could be found because tabledir (" + tableDir
        + ") or regiondir (" + regionDir + "was null. Deleting files instead.");
    deleteRegionWithoutArchiving(fs, regionDir);
    // we should have archived, but failed to. Doesn't matter if we deleted
    // the archived files correctly or not.
    return false;
  }

  // make sure the regiondir lives under the tabledir
  Preconditions.checkArgument(regionDir.toString().startsWith(tableDir.toString()));
  Path regionArchiveDir = HFileArchiveUtil.getRegionArchiveDir(rootdir,
      FSUtils.getTableName(tableDir),
      regionDir.getName());

  FileStatusConverter getAsFile = new FileStatusConverter(fs);
  // otherwise, we attempt to archive the store files

  // build collection of just the store directories to archive
  Collection<File> toArchive = new ArrayList<File>();
  final PathFilter dirFilter = new FSUtils.DirFilter(fs);
  PathFilter nonHidden = new PathFilter() {
    @Override
    public boolean accept(Path file) {
      return dirFilter.accept(file) && !file.getName().toString().startsWith(".");
    }
  };
  FileStatus[] storeDirs = FSUtils.listStatus(fs, regionDir, nonHidden);
  // if there no files, we can just delete the directory and return;
  if (storeDirs == null) {
    LOG.debug("Region directory (" + regionDir + ") was empty, just deleting and returning!");
    return deleteRegionWithoutArchiving(fs, regionDir);
  }

  // convert the files in the region to a File
  toArchive.addAll(Lists.transform(Arrays.asList(storeDirs), getAsFile));
  LOG.debug("Archiving " + toArchive);
  boolean success = false;
  try {
    success = resolveAndArchive(fs, regionArchiveDir, toArchive);
  } catch (IOException e) {
    LOG.error("Failed to archive " + toArchive, e);
    success = false;
  }

  // if that was successful, then we delete the region
  if (success) {
    return deleteRegionWithoutArchiving(fs, regionDir);
  }

  throw new IOException("Received error when attempting to archive files (" + toArchive
      + "), cannot delete region directory. ");
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:73,代码来源:HFileArchiver.java


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