if (HFileLink.isHFileLink(file.getPath())) { HFileLink hfileLink = HFileLink.buildFromHFileLinkPattern(conf, file.getPath()); fileName = hfileLink.getOriginPath().getName();
size = fs.getFileStatus(p).getLen(); } else { p = link.getOriginPath(); al = uniqueHFilesSize; size = link.getFileStatus(fs).getLen();
link.getOriginPath() + ") or archive (" + link.getArchivePath() + ") directory for the primary table."; LOG.error(msg);
@Test public void testMobFilePath() throws IOException { final TableName tableName = TableName.valueOf(name.getMethodName()); Configuration conf = HBaseConfiguration.create(); FileSystem fs = FileSystem.get(conf); Path rootDir = FSUtils.getRootDir(conf); Path tableDir = FSUtils.getTableDir(rootDir, tableName); Path archiveDir = FSUtils.getTableDir(HFileArchiveUtil.getArchivePath(conf), tableName); String fileName = "mobFile"; String encodedRegionName = MobUtils.getMobRegionInfo(tableName).getEncodedName(); String columnFamily = "columnFamily"; Path regionDir = new Path(tableDir, encodedRegionName); Path archivedRegionDir = new Path(archiveDir, encodedRegionName); Path expectedMobFilePath = new Path(MobUtils.getMobFamilyPath(conf, tableName, columnFamily), fileName).makeQualified(fs.getUri(), fs.getWorkingDirectory()); Path expectedOriginPath = new Path(new Path(regionDir, columnFamily), fileName).makeQualified( fs.getUri(), fs.getWorkingDirectory()); Path expectedArchivePath = new Path(new Path(archivedRegionDir, columnFamily), fileName) .makeQualified(fs.getUri(), fs.getWorkingDirectory()); String hfileLinkName = tableName.getNameAsString() + "=" + encodedRegionName + "-" + fileName; Path hfileLinkPath = new Path(columnFamily, hfileLinkName); HFileLink hfileLink = HFileLink.buildFromHFileLinkPattern(conf, hfileLinkPath); Assert.assertEquals(expectedMobFilePath, hfileLink.getMobPath()); Assert.assertEquals(expectedOriginPath, hfileLink.getOriginPath()); Assert.assertEquals(expectedArchivePath, hfileLink.getArchivePath()); } }
private List<Path> getPreNSPathsForHFileLink(HFileLink fileLink) throws IOException { if (defaultNamespace == null) setDefaultNamespaceDir(); List<Path> p = new ArrayList<Path>(); String relativeTablePath = removeDefaultNSPath(fileLink.getOriginPath()); p.add(getPreNSPath(PRE_NS_DOT_ARCHIVE, relativeTablePath)); p.add(getPreNSPath(PRE_NS_DOT_TMP, relativeTablePath)); p.add(getPreNSPath(null, relativeTablePath)); return p; }
link.getOriginPath() + ") or archive (" + link.getArchivePath() + ") directory for the primary table."; LOG.error(msg);
@Test public void testMobFilePath() throws IOException { final TableName tableName = TableName.valueOf(name.getMethodName()); Configuration conf = HBaseConfiguration.create(); FileSystem fs = FileSystem.get(conf); Path rootDir = FSUtils.getRootDir(conf); Path tableDir = FSUtils.getTableDir(rootDir, tableName); Path archiveDir = FSUtils.getTableDir(HFileArchiveUtil.getArchivePath(conf), tableName); String fileName = "mobFile"; String encodedRegionName = MobUtils.getMobRegionInfo(tableName).getEncodedName(); String columnFamily = "columnFamily"; Path regionDir = new Path(tableDir, encodedRegionName); Path archivedRegionDir = new Path(archiveDir, encodedRegionName); Path expectedMobFilePath = new Path(MobUtils.getMobFamilyPath(conf, tableName, columnFamily), fileName).makeQualified(fs.getUri(), fs.getWorkingDirectory()); Path expectedOriginPath = new Path(new Path(regionDir, columnFamily), fileName).makeQualified( fs.getUri(), fs.getWorkingDirectory()); Path expectedArchivePath = new Path(new Path(archivedRegionDir, columnFamily), fileName) .makeQualified(fs.getUri(), fs.getWorkingDirectory()); String hfileLinkName = tableName.getNameAsString() + "=" + encodedRegionName + "-" + fileName; Path hfileLinkPath = new Path(columnFamily, hfileLinkName); HFileLink hfileLink = HFileLink.buildFromHFileLinkPattern(conf, hfileLinkPath); Assert.assertEquals(expectedMobFilePath, hfileLink.getMobPath()); Assert.assertEquals(expectedOriginPath, hfileLink.getOriginPath()); Assert.assertEquals(expectedArchivePath, hfileLink.getArchivePath()); } }