/** * Clean up any merge detritus that may have been left around from previous merge attempts. */ void cleanupMergesDir() throws IOException { deleteDir(getMergesDir()); }
Path getMergesDir(final RegionInfo hri) { return new Path(getMergesDir(), hri.getEncodedName()); }
/** * Commit a merged region, moving it from the merges temporary directory to * the proper location in the filesystem. * @param mergedRegionInfo merged region {@link RegionInfo} * @throws IOException */ public void commitMergedRegion(final RegionInfo mergedRegionInfo) throws IOException { Path regionDir = new Path(this.tableDir, mergedRegionInfo.getEncodedName()); Path mergedRegionTmpDir = this.getMergesDir(mergedRegionInfo); // Move the tmp dir in the expected location if (mergedRegionTmpDir != null && fs.exists(mergedRegionTmpDir)) { if (!fs.rename(mergedRegionTmpDir, regionDir)) { throw new IOException("Unable to rename " + mergedRegionTmpDir + " to " + regionDir); } } }
/** * Create the region merges directory. * @throws IOException If merges dir already exists or we fail to create it. * @see HRegionFileSystem#cleanupMergesDir() */ public void createMergesDir() throws IOException { Path mergesdir = getMergesDir(); if (fs.exists(mergesdir)) { LOG.info("The " + mergesdir + " directory exists. Hence deleting it to recreate it"); if (!fs.delete(mergesdir, true)) { throw new IOException("Failed deletion of " + mergesdir + " before creating them again."); } } if (!mkdirs(fs, conf, mergesdir)) throw new IOException("Failed create of " + mergesdir); }
/** * Create a merged region * @param env MasterProcedureEnv */ private void createMergedRegion(final MasterProcedureEnv env) throws IOException { final MasterFileSystem mfs = env.getMasterServices().getMasterFileSystem(); final Path tabledir = FSUtils.getTableDir(mfs.getRootDir(), regionsToMerge[0].getTable()); final FileSystem fs = mfs.getFileSystem(); HRegionFileSystem regionFs = HRegionFileSystem.openRegionFromFileSystem( env.getMasterConfiguration(), fs, tabledir, regionsToMerge[0], false); regionFs.createMergesDir(); mergeStoreFiles(env, regionFs, regionFs.getMergesDir()); HRegionFileSystem regionFs2 = HRegionFileSystem.openRegionFromFileSystem( env.getMasterConfiguration(), fs, tabledir, regionsToMerge[1], false); mergeStoreFiles(env, regionFs2, regionFs.getMergesDir()); regionFs.commitMergedRegion(mergedRegion); //Prepare to create merged regions env.getAssignmentManager().getRegionStates(). getOrCreateRegionStateNode(mergedRegion).setState(State.MERGING_NEW); }
/** * Clean up any merge detritus that may have been left around from previous merge attempts. */ void cleanupMergesDir() throws IOException { deleteDir(getMergesDir()); }
Path getMergesDir(final HRegionInfo hri) { return new Path(getMergesDir(), hri.getEncodedName()); }
/** * Commit a merged region, moving it from the merges temporary directory to * the proper location in the filesystem. * @param mergedRegionInfo merged region {@link HRegionInfo} * @throws IOException */ void commitMergedRegion(final HRegionInfo mergedRegionInfo) throws IOException { Path regionDir = new Path(this.tableDir, mergedRegionInfo.getEncodedName()); Path mergedRegionTmpDir = this.getMergesDir(mergedRegionInfo); // Move the tmp dir in the expected location if (mergedRegionTmpDir != null && fs.exists(mergedRegionTmpDir)) { if (!fs.rename(mergedRegionTmpDir, regionDir)) { throw new IOException("Unable to rename " + mergedRegionTmpDir + " to " + regionDir); } } }
/** * Create the region merges directory. * @throws IOException If merges dir already exists or we fail to create it. * @see HRegionFileSystem#cleanupMergesDir() */ void createMergesDir() throws IOException { Path mergesdir = getMergesDir(); if (fs.exists(mergesdir)) { LOG.info("The " + mergesdir + " directory exists. Hence deleting it to recreate it"); if (!fs.delete(mergesdir, true)) { throw new IOException("Failed deletion of " + mergesdir + " before creating them again."); } } if (!fs.mkdirs(mergesdir)) throw new IOException("Failed create of " + mergesdir); }
/** * Constructor * @param a region a to merge * @param b region b to merge * @param forcible if false, we will only merge adjacent regions * @param masterSystemTime the time at the master side */ public RegionMergeTransactionImpl(final Region a, final Region b, final boolean forcible, long masterSystemTime) { if (a.getRegionInfo().compareTo(b.getRegionInfo()) <= 0) { this.region_a = (HRegion)a; this.region_b = (HRegion)b; } else { this.region_a = (HRegion)b; this.region_b = (HRegion)a; } this.forcible = forcible; this.masterSystemTime = masterSystemTime; this.mergesdir = region_a.getRegionFileSystem().getMergesDir(); }