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, 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);

    // 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 = FSUtils.getTableDir(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 (!StoreFileInfo.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) && !fs.exists(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

  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) && !fs.exists(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

   * @param manifest snapshot manifest to inspect
   */
  private void verifyTableInfo(final SnapshotManifest manifest) throws IOException {
    HTableDescriptor htd = manifest.getTableDescriptor();
    if (htd == null) {
      throw new CorruptedSnapshotException("Missing Table Descriptor", snapshot);
    }

    if (!htd.getNameAsString().equals(snapshot.getTable())) {
      throw new CorruptedSnapshotException("Invalid Table Descriptor. Expected "
        + snapshot.getTable() + " name, got " + htd.getNameAsString(), snapshot);
    }
  }
View Full Code Here

    Map<String, SnapshotRegionManifest> regionManifests = manifest.getRegionManifestsMap();
    if (regionManifests == null) {
      String msg = "Snapshot " + ClientSnapshotDescriptionUtils.toString(snapshot) + " looks empty";
      LOG.error(msg);
      throw new CorruptedSnapshotException(msg);
    }

    String errorMsg = "";
    if (regionManifests.size() != regions.size()) {
      errorMsg = "Regions moved during the snapshot '" +
                   ClientSnapshotDescriptionUtils.toString(snapshot) + "'. expected=" +
                   regions.size() + " snapshotted=" + regionManifests.size() + ".";
      LOG.error(errorMsg);
    }

    // Verify HRegionInfo
    for (HRegionInfo region : regions) {
      SnapshotRegionManifest regionManifest = regionManifests.get(region.getEncodedName());
      if (regionManifest == null) {
        // could happen due to a move or split race.
        String mesg = " No snapshot region directory found for region:" + region;
        if (errorMsg.isEmpty()) errorMsg = mesg;
        LOG.error(mesg);
        continue;
      }

      verifyRegionInfo(region, regionManifest);
    }

    if (!errorMsg.isEmpty()) {
      throw new CorruptedSnapshotException(errorMsg);
    }

    // Verify Snapshot HFiles
    SnapshotReferenceUtil.verifySnapshot(services.getConfiguration(), fs, manifest);
  }
View Full Code Here

      final SnapshotRegionManifest manifest) throws IOException {
    HRegionInfo manifestRegionInfo = HRegionInfo.convert(manifest.getRegionInfo());
    if (!region.equals(manifestRegionInfo)) {
      String msg = "Manifest region info " + manifestRegionInfo +
                   "doesn't match expected region:" + region;
      throw new CorruptedSnapshotException(msg, 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

   * @param manifest snapshot manifest to inspect
   */
  private void verifyTableInfo(final SnapshotManifest manifest) throws IOException {
    HTableDescriptor htd = manifest.getTableDescriptor();
    if (htd == null) {
      throw new CorruptedSnapshotException("Missing Table Descriptor", snapshot);
    }

    if (!htd.getNameAsString().equals(snapshot.getTable())) {
      throw new CorruptedSnapshotException("Invalid Table Descriptor. Expected "
        + snapshot.getTable() + " name, got " + htd.getNameAsString(), 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.