/** * Clean up any split detritus that may have been left around from previous * split attempts. * Call this method on initial region deploy. * @throws IOException */ void cleanupAnySplitDetritus() throws IOException { Path splitdir = this.getSplitsDir(); if (!fs.exists(splitdir)) return; // Look at the splitdir. It could have the encoded names of the daughter // regions we tried to make. See if the daughter regions actually got made // out under the tabledir. If here under splitdir still, then the split did // not complete. Try and do cleanup. This code WILL NOT catch the case // where we successfully created daughter a but regionserver crashed during // the creation of region b. In this case, there'll be an orphan daughter // dir in the filesystem. TOOD: Fix. FileStatus[] daughters = FSUtils.listStatus(fs, splitdir, new FSUtils.DirFilter(fs)); if (daughters != null) { for (FileStatus daughter: daughters) { Path daughterDir = new Path(getTableDir(), daughter.getPath().getName()); if (fs.exists(daughterDir) && !deleteDir(daughterDir)) { throw new IOException("Failed delete of " + daughterDir); } } } cleanupSplitsDir(); LOG.info("Cleaned up old failed split transaction detritus: " + splitdir); }
/** * Useful when reopening a closed region (normally for unit tests) * @param other original object * @param reporter An interface we can report progress against. * @return new HRegion */ public static HRegion openHRegion(final HRegion other, final CancelableProgressable reporter) throws IOException { HRegionFileSystem regionFs = other.getRegionFileSystem(); HRegion r = newHRegion(regionFs.getTableDir(), other.getWAL(), regionFs.getFileSystem(), other.baseConf, other.getRegionInfo(), other.getTableDescriptor(), null); return r.openHRegion(reporter); }
/** * Helper method to get the store archive directory for the specified region * @param conf {@link Configuration} to check for the name of the archive directory * @param region region that is being archived * @param store store that is archiving files * @return {@link Path} to the store archive directory for the given region */ public static Path getStoreArchivePath(Configuration conf, HRegion region, Store store) throws IOException { return HFileArchiveUtil.getStoreArchivePath(conf, region.getRegionInfo(), region.getRegionFileSystem().getTableDir(), store.getColumnFamilyDescriptor().getName()); }
Path rootDir = region.getRegionFileSystem().getTableDir().getParent(); Path regionDir = HRegion.getRegionDir(rootDir, region.getRegionInfo());
Path dstPath = new Path(regionFs.getTableDir(), new Path("test-region", TEST_FAMILY)); HFileLink.create(testConf, this.fs, dstPath, hri, storeFilePath.getName()); Path linkFilePath = new Path(dstPath,
/** * Clean up any split detritus that may have been left around from previous * split attempts. * Call this method on initial region deploy. * @throws IOException */ void cleanupAnySplitDetritus() throws IOException { Path splitdir = this.getSplitsDir(); if (!fs.exists(splitdir)) return; // Look at the splitdir. It could have the encoded names of the daughter // regions we tried to make. See if the daughter regions actually got made // out under the tabledir. If here under splitdir still, then the split did // not complete. Try and do cleanup. This code WILL NOT catch the case // where we successfully created daughter a but regionserver crashed during // the creation of region b. In this case, there'll be an orphan daughter // dir in the filesystem. TOOD: Fix. FileStatus[] daughters = FSUtils.listStatus(fs, splitdir, new FSUtils.DirFilter(fs)); if (daughters != null) { for (FileStatus daughter: daughters) { Path daughterDir = new Path(getTableDir(), daughter.getPath().getName()); if (fs.exists(daughterDir) && !deleteDir(daughterDir)) { throw new IOException("Failed delete of " + daughterDir); } } } cleanupSplitsDir(); LOG.info("Cleaned up old failed split transaction detritus: " + splitdir); }
/** * Useful when reopening a closed region (normally for unit tests) * @param other original object * @param reporter An interface we can report progress against. * @return new HRegion * @throws IOException */ public static HRegion openHRegion(final HRegion other, final CancelableProgressable reporter) throws IOException { HRegionFileSystem regionFs = other.getRegionFileSystem(); HRegion r = newHRegion(regionFs.getTableDir(), other.getWAL(), regionFs.getFileSystem(), other.baseConf, other.getRegionInfo(), other.getTableDesc(), null); return r.openHRegion(reporter); }
/** * Helper method to get the store archive directory for the specified region * @param conf {@link Configuration} to check for the name of the archive directory * @param region region that is being archived * @param store store that is archiving files * @return {@link Path} to the store archive directory for the given region */ public static Path getStoreArchivePath(Configuration conf, HRegion region, Store store) throws IOException { return HFileArchiveUtil.getStoreArchivePath(conf, region.getRegionInfo(), region.getRegionFileSystem().getTableDir(), store.getColumnFamilyDescriptor().getName()); }
/** * Create a daughter region from given a temp directory with the region data. * @param hri Spec. for daughter region to open. * @throws IOException */ HRegion createDaughterRegionFromSplits(final HRegionInfo hri) throws IOException { // Move the files from the temporary .splits to the final /table/region directory fs.commitDaughterRegion(hri); // Create the daughter HRegion instance HRegion r = HRegion.newHRegion(this.fs.getTableDir(), this.getWAL(), fs.getFileSystem(), this.getBaseConf(), hri, this.getTableDesc(), rsServices); r.readRequestsCount.set(this.getReadRequestsCount() / 2); r.writeRequestsCount.set(this.getWriteRequestsCount() / 2); return r; }
/** * Create a merged region given a temp directory with the region data. * @param region_b another merging region * @return merged HRegion * @throws IOException */ HRegion createMergedRegionFromMerges(final HRegionInfo mergedRegionInfo, final HRegion region_b) throws IOException { HRegion r = HRegion.newHRegion(this.fs.getTableDir(), this.getWAL(), fs.getFileSystem(), this.getBaseConf(), mergedRegionInfo, this.getTableDesc(), this.rsServices); r.readRequestsCount.set(this.getReadRequestsCount() + region_b.getReadRequestsCount()); r.writeRequestsCount.set(this.getWriteRequestsCount() + region_b.getWriteRequestsCount()); this.fs.commitMergedRegion(mergedRegionInfo); return r; }
Path rootDir = region.getRegionFileSystem().getTableDir().getParent(); Path regionDir = HRegion.getRegionDir(rootDir, region.getRegionInfo());
Path dstPath = new Path(regionFs.getTableDir(), new Path("test-region", TEST_FAMILY)); HFileLink.create(testConf, this.fs, dstPath, hri, storeFilePath.getName()); Path linkFilePath = new Path(dstPath,
Region a = this.parent.createDaughterRegionFromSplits(this.hri_a); assertReferenceFileCount(expectedReferences.getFirst(), new Path(this.parent.getRegionFileSystem().getTableDir(), this.hri_a.getEncodedName())); Region b = this.parent.createDaughterRegionFromSplits(this.hri_b); assertReferenceFileCount(expectedReferences.getSecond(), new Path(this.parent.getRegionFileSystem().getTableDir(), this.hri_b.getEncodedName()));