Package org.apache.hadoop.hbase.exceptions

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


        return SnapshotDescription.parseFrom(in);
      } finally {
        if (in != null) in.close();
      }
    } catch (IOException e) {
      throw new CorruptedSnapshotException("Couldn't read snapshot info from:" + snapshotInfo, e);
    }
  }
View Full Code Here


  }

  private static void assertNull(SnapshotDescription snapshot, String msg, Object isNull)
      throws CorruptedSnapshotException {
    if (isNull != null) {
      throw new CorruptedSnapshotException(msg + ", Expected " + isNull + " to be null.", snapshot);
    }
  }
View Full Code Here

  }

  private static void assertNotNull(SnapshotDescription snapshot, String msg, Object notNull)
      throws CorruptedSnapshotException {
    if (notNull == null) {
      throw new CorruptedSnapshotException(msg + ", Expected object to not be null, but was null.",
          snapshot);
    }
  }
View Full Code Here

  }

  private static void assertTrue(SnapshotDescription snapshot, String msg, boolean isTrue)
      throws CorruptedSnapshotException {
    if (!isTrue) {
      throw new CorruptedSnapshotException(msg + ", Expected true, but was false", snapshot);
    }
  }
View Full Code Here

   * @throws CorruptedSnapshotException thrown if the two elements don't match
   */
  private static void assertEquals(SnapshotDescription snapshot, String msg, int expected,
      int gotten) throws CorruptedSnapshotException {
    if (expected != gotten) {
      throw new CorruptedSnapshotException(msg + ". Expected:" + expected + ", got:" + gotten,
          snapshot);
    }
  }
View Full Code Here

   * @throws CorruptedSnapshotException thrown if the two elements don't match
   */
  private static void assertEquals(SnapshotDescription snapshot, String msg, long expected,
      long gotten) throws CorruptedSnapshotException {
    if (expected != gotten) {
      throw new CorruptedSnapshotException(msg + ". Expected:" + expected + ", got:" + gotten,
          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, 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 = 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) && !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

TOP

Related Classes of org.apache.hadoop.hbase.exceptions.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.