Package org.apache.hadoop.hbase.snapshot

Examples of org.apache.hadoop.hbase.snapshot.CorruptedSnapshotException


   * @param snapshotDir snapshot directory to check
   */
  private void verifySnapshotDescription(Path snapshotDir) throws CorruptedSnapshotException {
    SnapshotDescription found = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);
    if (!this.snapshot.equals(found)) {
      throw new CorruptedSnapshotException("Snapshot read (" + found
          + ") doesn't equal snapshot we ran (" + snapshot + ").", snapshot);
    }
  }
View Full Code Here


  private void verifyRegion(FileSystem fs, Path snapshotDir, HRegionInfo region) throws IOException {
    // make sure we have region in the snapshot
    Path regionDir = new Path(snapshotDir, region.getEncodedName());
    if (!fs.exists(regionDir)) {
      // could happen due to a move or split race.
      throw new CorruptedSnapshotException("No region directory found for region:" + region,
          snapshot);
    }
    // make sure we have the region info in the snapshot
    Path regionInfo = new Path(regionDir, HRegion.REGIONINFO_FILE);
    // make sure the file exists
    if (!fs.exists(regionInfo)) {
      throw new CorruptedSnapshotException("No region info found for region:" + region, snapshot);
    }
    FSDataInputStream in = fs.open(regionInfo);
    HRegionInfo found = new HRegionInfo();
    try {
      found.readFields(in);
      if (!region.equals(found)) {
        throw new CorruptedSnapshotException("Found region info (" + found
           + ") doesn't match expected region:" + region, snapshot);
      }
    } finally {
      in.close();
    }

    // make sure we have the expected recovered edits files
    TakeSnapshotUtils.verifyRecoveredEdits(fs, snapshotDir, found, snapshot);

    // check for the existance of each hfile
    PathFilter familiesDirs = new FSUtils.FamilyDirFilter(fs);
    FileStatus[] columnFamilies = FSUtils.listStatus(fs, regionDir, familiesDirs);
    // should we do some checking here to make sure the cfs are correct?
    if (columnFamilies == null) return;

    // setup the suffixes for the snapshot directories
    Path tableNameSuffix = new Path(tableName);
    Path regionNameSuffix = new Path(tableNameSuffix, region.getEncodedName());

    // get the potential real paths
    Path archivedRegion = new Path(HFileArchiveUtil.getArchivePath(services.getConfiguration()),
        regionNameSuffix);
    Path realRegion = new Path(rootDir, regionNameSuffix);

    // loop through each cf and check we can find each of the hfiles
    for (FileStatus cf : columnFamilies) {
      FileStatus[] hfiles = FSUtils.listStatus(fs, cf.getPath(), null);
      // should we check if there should be hfiles?
      if (hfiles == null || hfiles.length == 0) continue;

      Path realCfDir = new Path(realRegion, cf.getPath().getName());
      Path archivedCfDir = new Path(archivedRegion, cf.getPath().getName());
      for (FileStatus hfile : hfiles) {
        // make sure the name is correct
        if (!StoreFile.validateStoreFileName(hfile.getPath().getName())) {
          throw new CorruptedSnapshotException("HFile: " + hfile.getPath()
              + " is not a valid hfile name.", snapshot);
        }

        // check to see if hfile is present in the real table
        String fileName = hfile.getPath().getName();
        Path file = new Path(realCfDir, fileName);
        Path archived = new Path(archivedCfDir, fileName);
        if (!fs.exists(file) && !file.equals(archived)) {
          throw new CorruptedSnapshotException("Can't find hfile: " + hfile.getPath()
              + " in the real (" + realCfDir + ") or archive (" + archivedCfDir
              + ") directory for the primary table.", snapshot);
        }
      }
    }
View Full Code Here

   * @param snapshotDir snapshot directory to check
   */
  private void verifySnapshotDescription(Path snapshotDir) throws CorruptedSnapshotException {
    SnapshotDescription found = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);
    if (!this.snapshot.equals(found)) {
      throw new CorruptedSnapshotException("Snapshot read (" + found
          + ") doesn't equal snapshot we ran (" + snapshot + ").", snapshot);
    }
  }
View Full Code Here

    Set<String> snapshotRegions = SnapshotReferenceUtil.getSnapshotRegionNames(fs, snapshotDir);
    if (snapshotRegions == null) {
      String msg = "Snapshot " + SnapshotDescriptionUtils.toString(snapshot) + " looks empty";
      LOG.error(msg);
      throw new CorruptedSnapshotException(msg);
    }

    if (snapshotRegions.size() != regions.size()) {
      String msg = "Regions moved during the snapshot '" +
                   SnapshotDescriptionUtils.toString(snapshot) + "'. expected=" +
                   regions.size() + " snapshotted=" + snapshotRegions.size();
      LOG.error(msg);
      throw new CorruptedSnapshotException(msg);
    }

    for (HRegionInfo region : regions) {
      if (!snapshotRegions.contains(region.getEncodedName())) {
        // could happen due to a move or split race.
        String msg = "No region directory found for region:" + region;
        LOG.error(msg);
        throw new CorruptedSnapshotException(msg, snapshot);
      }

      verifyRegion(fs, snapshotDir, region);
    }
  }
View Full Code Here

    // make sure we have the region info in the snapshot
    Path regionInfo = new Path(regionDir, HRegion.REGIONINFO_FILE);
    // make sure the file exists
    if (!fs.exists(regionInfo)) {
      throw new CorruptedSnapshotException("No region info found for region:" + region, snapshot);
    }

    FSDataInputStream in = fs.open(regionInfo);
    HRegionInfo found = new HRegionInfo();
    try {
      found.readFields(in);
      if (!region.equals(found)) {
        throw new CorruptedSnapshotException("Found region info (" + found
           + ") doesn't match expected region:" + region, snapshot);
      }
    } finally {
      in.close();
    }
View Full Code Here

      // If is a reference file check if the parent file is present in the snapshot
      Path snapshotHFilePath = new Path(new Path(
          new Path(snapshotDir, regionInfo.getEncodedName()), family), fileName);
      refPath = StoreFile.getReferredToFile(snapshotHFilePath);
      if (!fs.exists(refPath)) {
        throw new CorruptedSnapshotException("Missing parent hfile for: " + fileName, snapshot);
      }
    }

    Path linkPath;
    if (refPath != null && HFileLink.isHFileLink(refPath)) {
      linkPath = new Path(family, refPath.getName());
    } else if (HFileLink.isHFileLink(fileName)) {
      linkPath = new Path(family, fileName);
    } else {
      linkPath = new Path(family, HFileLink.createHFileLinkName(tableName,
        regionInfo.getEncodedName(), fileName));
    }

    // check if the linked file exists (in the archive, or in the table dir)
    HFileLink link = new HFileLink(services.getConfiguration(), linkPath);
    if (!link.exists(fs)) {
      throw new CorruptedSnapshotException("Can't find hfile: " + fileName
          + " in the real (" + link.getOriginPath() + ") or archive (" + link.getArchivePath()
          + ") directory for the primary table.", snapshot);
    }
  }
View Full Code Here

   * @param snapshotDir snapshot directory to check
   */
  private void verifySnapshotDescription(Path snapshotDir) throws CorruptedSnapshotException {
    SnapshotDescription found = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);
    if (!this.snapshot.equals(found)) {
      throw new CorruptedSnapshotException("Snapshot read (" + found
          + ") doesn't equal snapshot we ran (" + snapshot + ").", snapshot);
    }
  }
View Full Code Here

    Set<String> snapshotRegions = SnapshotReferenceUtil.getSnapshotRegionNames(fs, snapshotDir);
    if (snapshotRegions == null) {
      String msg = "Snapshot " + ClientSnapshotDescriptionUtils.toString(snapshot) + " looks empty";
      LOG.error(msg);
      throw new CorruptedSnapshotException(msg);
    }

    if (snapshotRegions.size() != regions.size()) {
      String msg = "Regions moved during the snapshot '" +
                   ClientSnapshotDescriptionUtils.toString(snapshot) + "'. expected=" +
                   regions.size() + " snapshotted=" + snapshotRegions.size();
      LOG.error(msg);
      throw new CorruptedSnapshotException(msg);
    }

    for (HRegionInfo region : regions) {
      if (!snapshotRegions.contains(region.getEncodedName())) {
        // could happen due to a move or split race.
        String msg = "No region directory found for region:" + region;
        LOG.error(msg);
        throw new CorruptedSnapshotException(msg, snapshot);
      }

      verifyRegion(fs, snapshotDir, region);
    }
  }
View Full Code Here

    // make sure we have the region info in the snapshot
    Path regionInfo = new Path(regionDir, HRegionFileSystem.REGION_INFO_FILE);
    // make sure the file exists
    if (!fs.exists(regionInfo)) {
      throw new CorruptedSnapshotException("No region info found for region:" + region, snapshot);
    }

    HRegionInfo found = HRegionFileSystem.loadRegionInfoFileContent(fs, regionDir);
    if (!region.equals(found)) {
      throw new CorruptedSnapshotException("Found region info (" + found
        + ") doesn't match expected region:" + region, snapshot);
    }

    // make sure we have the expected recovered edits files
    TakeSnapshotUtils.verifyRecoveredEdits(fs, snapshotDir, found, snapshot);
View Full Code Here

      // If is a reference file check if the parent file is present in the snapshot
      Path snapshotHFilePath = new Path(new Path(
          new Path(snapshotDir, regionInfo.getEncodedName()), family), fileName);
      refPath = StoreFileInfo.getReferredToFile(snapshotHFilePath);
      if (!fs.exists(refPath)) {
        throw new CorruptedSnapshotException("Missing parent hfile for: " + fileName, snapshot);
      }
    }

    Path linkPath;
    if (refPath != null && HFileLink.isHFileLink(refPath)) {
      linkPath = new Path(family, refPath.getName());
    } else if (HFileLink.isHFileLink(fileName)) {
      linkPath = new Path(family, fileName);
    } else {
      linkPath = new Path(family, HFileLink.createHFileLinkName(tableName,
        regionInfo.getEncodedName(), fileName));
    }

    // check if the linked file exists (in the archive, or in the table dir)
    HFileLink link = new HFileLink(services.getConfiguration(), linkPath);
    if (!link.exists(fs)) {
      throw new CorruptedSnapshotException("Can't find hfile: " + fileName
          + " in the real (" + link.getOriginPath() + ") or archive (" + link.getArchivePath()
          + ") directory for the primary table.", snapshot);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.snapshot.CorruptedSnapshotException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.