diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java index a7982e4..1bc7edd 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java @@ -208,6 +208,32 @@ public class HRegionFileSystem { } /** + * Return Qualified Path of the specified family/file + * + * @param familyName Column Family Name + * @param fileName File Name + * @return The qualified Path for the specified family/file + */ + Path getStoreFilePath(final String familyName, final String fileName) { + Path familyDir = getStoreDir(familyName); + return new Path(familyDir, fileName).makeQualified(this.fs); + } + + /** + * Return the store file information of the specified family/file. + * + * @param familyName Column Family Name + * @param fileName File Name + * @return The {@link StoreFileInfo} for the specified family/file + */ + StoreFileInfo getStoreFileInfo(final String familyName, final String fileName) + throws IOException { + Path familyDir = getStoreDir(familyName); + FileStatus status = fs.getFileStatus(new Path(familyDir, fileName)); + return new StoreFileInfo(this.conf, this.fs, status); + } + + /** * Returns true if the specified family has reference files * @param familyName Column Family Name * @return true if family contains reference files diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java index cb5fbcb..2bc9c9c 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java @@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.regionserver; import java.io.IOException; +import java.io.FileNotFoundException; import java.io.InterruptedIOException; import java.net.InetSocketAddress; import java.security.Key; @@ -501,7 +502,7 @@ public class HStore implements Store { completionService.submit(new Callable() { @Override public StoreFile call() throws IOException { - StoreFile storeFile = createStoreFileAndReader(storeFileInfo.getPath()); + StoreFile storeFile = createStoreFileAndReader(storeFileInfo); return storeFile; } }); @@ -537,7 +538,7 @@ public class HStore implements Store { for (StoreFile file : results) { try { if (file != null) file.closeReader(true); - } catch (IOException e) { + } catch (IOException e) { LOG.warn(e.getMessage()); } } @@ -549,6 +550,11 @@ public class HStore implements Store { private StoreFile createStoreFileAndReader(final Path p) throws IOException { StoreFileInfo info = new StoreFileInfo(conf, this.getFileSystem(), p); + return createStoreFileAndReader(info); + } + + private StoreFile createStoreFileAndReader(final StoreFileInfo info) + throws IOException { info.setRegionCoprocessorHost(this.region.getCoprocessorHost()); StoreFile storeFile = new StoreFile(this.getFileSystem(), info, this.conf, this.cacheConf, this.family.getBloomFilterType()); @@ -1202,7 +1208,7 @@ public class HStore implements Store { /** * Call to complete a compaction. Its for the case where we find in the WAL a compaction * that was not finished. We could find one recovering a WAL after a regionserver crash. - * See HBASE-2331. + * See HBASE-2231. * @param compaction */ @Override @@ -1212,36 +1218,38 @@ public class HStore implements Store { List compactionInputs = compaction.getCompactionInputList(); List compactionOutputs = compaction.getCompactionOutputList(); + String familyName = family.getNameAsString(); List outputStoreFiles = new ArrayList(compactionOutputs.size()); for (String compactionOutput : compactionOutputs) { //we should have this store file already boolean found = false; - Path outputPath = new Path(fs.getStoreDir(family.getNameAsString()), compactionOutput); - outputPath = outputPath.makeQualified(fs.getFileSystem()); + Path outputPath = fs.getStoreFilePath(familyName, compactionOutput); for (StoreFile sf : this.getStorefiles()) { - if (sf.getPath().makeQualified(sf.getPath().getFileSystem(conf)).equals(outputPath)) { + if (sf.getQualifiedPath().equals(outputPath)) { found = true; break; } } if (!found) { - if (getFileSystem().exists(outputPath)) { - outputStoreFiles.add(createStoreFileAndReader(outputPath)); + try { + StoreFileInfo fileInfo = fs.getStoreFileInfo(familyName, compactionOutput); + outputStoreFiles.add(createStoreFileAndReader(fileInfo)); + } catch (FileNotFoundException e) { + LOG.debug("compaction file missing: " + outputPath); } } } List inputPaths = new ArrayList(compactionInputs.size()); for (String compactionInput : compactionInputs) { - Path inputPath = new Path(fs.getStoreDir(family.getNameAsString()), compactionInput); - inputPath = inputPath.makeQualified(fs.getFileSystem()); + Path inputPath = fs.getStoreFilePath(familyName, compactionInput); inputPaths.add(inputPath); } //some of the input files might already be deleted List inputStoreFiles = new ArrayList(compactionInputs.size()); for (StoreFile sf : this.getStorefiles()) { - if (inputPaths.contains(sf.getPath().makeQualified(fs.getFileSystem()))) { + if (inputPaths.contains(sf.getQualifiedPath())) { inputStoreFiles.add(sf); } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java index ecac797..fec9542 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java @@ -234,6 +234,13 @@ public class StoreFile { } /** + * @return Returns the qualified path of this StoreFile + */ + public Path getQualifiedPath() { + return this.fileInfo.getPath().makeQualified(fs); + } + + /** * @return True if this is a StoreFile Reference; call after {@link #open()} * else may get wrong answer. */