Java Code Examples for org.apache.hadoop.hbase.regionserver.HRegionFileSystem#hasReferences()

The following examples show how to use org.apache.hadoop.hbase.regionserver.HRegionFileSystem#hasReferences() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MajorCompactionRequest.java    From hbase with Apache License 2.0 6 votes vote down vote up
boolean shouldCFBeCompacted(HRegionFileSystem fileSystem, String family, long ts)
    throws IOException {

  // do we have any store files?
  Collection<StoreFileInfo> storeFiles = fileSystem.getStoreFiles(family);
  if (storeFiles == null) {
    LOG.info("Excluding store: " + family + " for compaction for region:  " + fileSystem
        .getRegionInfo().getEncodedName(), " has no store files");
    return false;
  }
  // check for reference files
  if (fileSystem.hasReferences(family) && familyHasReferenceFile(fileSystem, family, ts)) {
    LOG.info("Including store: " + family + " with: " + storeFiles.size()
        + " files for compaction for region: " + fileSystem.getRegionInfo().getEncodedName());
    return true;
  }
  // check store file timestamps
  boolean includeStore = this.shouldIncludeStore(fileSystem, family, storeFiles, ts);
  if (!includeStore) {
    LOG.info("Excluding store: " + family + " for compaction for region:  " + fileSystem
        .getRegionInfo().getEncodedName() + " already compacted");
  }
  return includeStore;
}
 
Example 2
Source File: CatalogJanitor.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * If merged region no longer holds reference to the merge regions, archive
 * merge region on hdfs and perform deleting references in hbase:meta
 * @return true if we delete references in merged region on hbase:meta and archive
 *   the files on the file system
 */
private boolean cleanMergeRegion(final RegionInfo mergedRegion, List<RegionInfo> parents)
    throws IOException {
  FileSystem fs = this.services.getMasterFileSystem().getFileSystem();
  Path rootdir = this.services.getMasterFileSystem().getRootDir();
  Path tabledir = CommonFSUtils.getTableDir(rootdir, mergedRegion.getTable());
  TableDescriptor htd = getDescriptor(mergedRegion.getTable());
  HRegionFileSystem regionFs = null;
  try {
    regionFs = HRegionFileSystem.openRegionFromFileSystem(
        this.services.getConfiguration(), fs, tabledir, mergedRegion, true);
  } catch (IOException e) {
    LOG.warn("Merged region does not exist: " + mergedRegion.getEncodedName());
  }
  if (regionFs == null || !regionFs.hasReferences(htd)) {
    LOG.debug("Deleting parents ({}) from fs; merged child {} no longer holds references",
         parents.stream().map(r -> RegionInfo.getShortNameToLog(r)).
            collect(Collectors.joining(", ")),
        mergedRegion);
    ProcedureExecutor<MasterProcedureEnv> pe = this.services.getMasterProcedureExecutor();
    pe.submitProcedure(new GCMultipleMergedRegionsProcedure(pe.getEnvironment(),
        mergedRegion,  parents));
    for (RegionInfo ri:  parents) {
      // The above scheduled GCMultipleMergedRegionsProcedure does the below.
      // Do we need this?
      this.services.getAssignmentManager().getRegionStates().deleteRegion(ri);
      this.services.getServerManager().removeRegion(ri);
    }
    return true;
  }
  return false;
}
 
Example 3
Source File: CatalogJanitor.java    From hbase with Apache License 2.0 4 votes vote down vote up
/**
 * Checks if a daughter region -- either splitA or splitB -- still holds
 * references to parent.
 * @param parent Parent region
 * @param daughter Daughter region
 * @return A pair where the first boolean says whether or not the daughter
 *   region directory exists in the filesystem and then the second boolean says
 *   whether the daughter has references to the parent.
 */
private Pair<Boolean, Boolean> checkDaughterInFs(final RegionInfo parent,
  final RegionInfo daughter)
throws IOException {
  if (daughter == null)  {
    return new Pair<>(Boolean.FALSE, Boolean.FALSE);
  }

  FileSystem fs = this.services.getMasterFileSystem().getFileSystem();
  Path rootdir = this.services.getMasterFileSystem().getRootDir();
  Path tabledir = CommonFSUtils.getTableDir(rootdir, daughter.getTable());

  Path daughterRegionDir = new Path(tabledir, daughter.getEncodedName());

  HRegionFileSystem regionFs;

  try {
    if (!CommonFSUtils.isExists(fs, daughterRegionDir)) {
      return new Pair<>(Boolean.FALSE, Boolean.FALSE);
    }
  } catch (IOException ioe) {
    LOG.error("Error trying to determine if daughter region exists, " +
             "assuming exists and has references", ioe);
    return new Pair<>(Boolean.TRUE, Boolean.TRUE);
  }

  boolean references = false;
  TableDescriptor parentDescriptor = getDescriptor(parent.getTable());
  try {
    regionFs = HRegionFileSystem.openRegionFromFileSystem(
        this.services.getConfiguration(), fs, tabledir, daughter, true);

    for (ColumnFamilyDescriptor family: parentDescriptor.getColumnFamilies()) {
      if ((references = regionFs.hasReferences(family.getNameAsString()))) {
        break;
      }
    }
  } catch (IOException e) {
    LOG.error("Error trying to determine referenced files from : " + daughter.getEncodedName()
        + ", to: " + parent.getEncodedName() + " assuming has references", e);
    return new Pair<>(Boolean.TRUE, Boolean.TRUE);
  }
  return new Pair<>(Boolean.TRUE, references);
}