use of org.apache.hadoop.hbase.fs.HFileSystem in project hbase by apache.
the class TestHRegionFileSystem method getHRegionFS.
private HRegionFileSystem getHRegionFS(HTable table, Configuration conf) throws IOException {
FileSystem fs = TEST_UTIL.getDFSCluster().getFileSystem();
Path tableDir = FSUtils.getTableDir(TEST_UTIL.getDefaultRootDirPath(), table.getName());
List<Path> regionDirs = FSUtils.getRegionDirs(fs, tableDir);
assertEquals(1, regionDirs.size());
List<Path> familyDirs = FSUtils.getFamilyDirs(fs, regionDirs.get(0));
assertEquals(2, familyDirs.size());
HRegionInfo hri = table.getRegionLocator().getAllRegionLocations().get(0).getRegionInfo();
HRegionFileSystem regionFs = new HRegionFileSystem(conf, new HFileSystem(fs), tableDir, hri);
return regionFs;
}
use of org.apache.hadoop.hbase.fs.HFileSystem in project hbase by apache.
the class HRegionFileSystem method bulkLoadStoreFile.
/**
* Bulk load: Add a specified store file to the specified family.
* If the source file is on the same different file-system is moved from the
* source location to the destination location, otherwise is copied over.
*
* @param familyName Family that will gain the file
* @param srcPath {@link Path} to the file to import
* @param seqNum Bulk Load sequence number
* @return The destination {@link Path} of the bulk loaded file
* @throws IOException
*/
Pair<Path, Path> bulkLoadStoreFile(final String familyName, Path srcPath, long seqNum) throws IOException {
// Copy the file if it's on another filesystem
FileSystem srcFs = srcPath.getFileSystem(conf);
srcPath = srcFs.resolvePath(srcPath);
FileSystem realSrcFs = srcPath.getFileSystem(conf);
FileSystem desFs = fs instanceof HFileSystem ? ((HFileSystem) fs).getBackingFs() : fs;
// TODO deal with viewFS
if (!FSHDFSUtils.isSameHdfs(conf, realSrcFs, desFs)) {
LOG.info("Bulk-load file " + srcPath + " is on different filesystem than " + "the destination store. Copying file over to destination filesystem.");
Path tmpPath = createTempName();
FileUtil.copy(realSrcFs, srcPath, fs, tmpPath, false, conf);
LOG.info("Copied " + srcPath + " to temporary path on destination filesystem: " + tmpPath);
srcPath = tmpPath;
}
return new Pair<>(srcPath, preCommitStoreFile(familyName, srcPath, seqNum, true));
}
Aggregations