/** * Verify that the previously saved md5 for the given file matches * expectedMd5. * @throws IOException */ public static void verifySavedMD5(File dataFile, MD5Hash expectedMD5) throws IOException { MD5Hash storedHash = readStoredMd5ForFile(dataFile); // Check the hash itself if (!expectedMD5.equals(storedHash)) { throw new IOException( "File " + dataFile + " did not match stored MD5 checksum " + " (stored: " + storedHash + ", computed: " + expectedMD5); } }
!computedDigest.equals(advertisedDigest)) { deleteTmpFiles(localPaths); throw new IOException("File " + url + " computed digest " +
/** * Load in the filesystem image from file. It's a big list of * filenames and blocks. */ private void loadFSImage(File curFile, MD5Hash expectedMd5, FSNamesystem target, MetaRecoveryContext recovery, boolean requireSameLayoutVersion) throws IOException { // BlockPoolId is required when the FsImageLoader loads the rolling upgrade // information. Make sure the ID is properly set. target.setBlockPoolId(this.getBlockPoolID()); FSImageFormat.LoaderDelegator loader = FSImageFormat.newLoader(conf, target); loader.load(curFile, requireSameLayoutVersion); // Check that the image digest we loaded matches up with what // we expected MD5Hash readImageMd5 = loader.getLoadedImageMd5(); if (expectedMd5 != null && !expectedMd5.equals(readImageMd5)) { throw new IOException("Image file " + curFile + " is corrupt with MD5 checksum of " + readImageMd5 + " but expecting " + expectedMd5); } long txId = loader.getLoadedImageTxId(); LOG.info("Loaded image for txid " + txId + " from " + curFile); lastAppliedTxId = txId; storage.setMostRecentCheckpointInfo(txId, curFile.lastModified()); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; HihoTuple other = (HihoTuple) obj; if (hash == null) { if (other.hash != null) return false; } else if (!hash.equals(other.hash)) return false; if (key == null) { if (other.key != null) return false; } else if (!key.equals(other.key)) return false; if (keyClass == null) { if (other.keyClass != null) return false; } else if (!keyClass.equals(other.keyClass)) return false; return true; }
/** * Verify that the previously saved md5 for the given file matches * expectedMd5. * @throws IOException */ public static void verifySavedMD5(File dataFile, MD5Hash expectedMD5) throws IOException { MD5Hash storedHash = readStoredMd5ForFile(dataFile); // Check the hash itself if (!expectedMD5.equals(storedHash)) { throw new IOException( "File " + dataFile + " did not match stored MD5 checksum " + " (stored: " + storedHash + ", computed: " + expectedMD5); } }
/** * Verify that the previously saved md5 for the given file matches * expectedMd5. * @throws IOException */ public static void verifySavedMD5(File dataFile, MD5Hash expectedMD5) throws IOException { MD5Hash storedHash = readStoredMd5ForFile(dataFile); // Check the hash itself if (!expectedMD5.equals(storedHash)) { throw new IOException( "File " + dataFile + " did not match stored MD5 checksum " + " (stored: " + storedHash + ", computed: " + expectedMD5); } }
/** * Moves fsimage.ckpt to fsImage and edits.new to edits * Reopens the new edits file. * * @param newImageSignature the signature of the new image */ void rollFSImage(CheckpointSignature newImageSignature) throws IOException { MD5Hash newImageDigest = newImageSignature.getImageDigest(); if (!newImageDigest.equals(checkpointImageDigest)) { throw new IOException( "Checkpoint image is corrupt: expecting an MD5 checksum of" + newImageDigest + " but is " + checkpointImageDigest); } rollFSImage(newImageSignature.getImageDigest()); }
String fileid; File[] srcNames; if (sig.imageDigest.equals(checkpointImage.imageDigest)) { downloadImage = false; LOG.info("Image has not changed. Will not download image.");
!computedDigest.equals(advertisedDigest)) { deleteTmpFiles(localPaths); throw new IOException("File " + url + " computed digest " +
!computedDigest.equals(advertisedDigest)) { deleteTmpFiles(localPaths); throw new IOException("File " + url + " computed digest " +
/** * Load in the filesystem image from file. It's a big list of * filenames and blocks. */ private void loadFSImage(File curFile, MD5Hash expectedMd5, FSNamesystem target, MetaRecoveryContext recovery, boolean requireSameLayoutVersion) throws IOException { // BlockPoolId is required when the FsImageLoader loads the rolling upgrade // information. Make sure the ID is properly set. target.setBlockPoolId(this.getBlockPoolID()); FSImageFormat.LoaderDelegator loader = FSImageFormat.newLoader(conf, target); loader.load(curFile, requireSameLayoutVersion); // Check that the image digest we loaded matches up with what // we expected MD5Hash readImageMd5 = loader.getLoadedImageMd5(); if (expectedMd5 != null && !expectedMd5.equals(readImageMd5)) { throw new IOException("Image file " + curFile + " is corrupt with MD5 checksum of " + readImageMd5 + " but expecting " + expectedMd5); } long txId = loader.getLoadedImageTxId(); LOG.info("Loaded image for txid " + txId + " from " + curFile); lastAppliedTxId = txId; storage.setMostRecentCheckpointInfo(txId, curFile.lastModified()); }
/** * Load in the filesystem image from file. It's a big list of * filenames and blocks. */ private void loadFSImage(File curFile, MD5Hash expectedMd5, FSNamesystem target, MetaRecoveryContext recovery, boolean requireSameLayoutVersion) throws IOException { // BlockPoolId is required when the FsImageLoader loads the rolling upgrade // information. Make sure the ID is properly set. target.setBlockPoolId(this.getBlockPoolID()); FSImageFormat.LoaderDelegator loader = FSImageFormat.newLoader(conf, target); loader.load(curFile, requireSameLayoutVersion); // Check that the image digest we loaded matches up with what // we expected MD5Hash readImageMd5 = loader.getLoadedImageMd5(); if (expectedMd5 != null && !expectedMd5.equals(readImageMd5)) { throw new IOException("Image file " + curFile + " is corrupt with MD5 checksum of " + readImageMd5 + " but expecting " + expectedMd5); } long txId = loader.getLoadedImageTxId(); LOG.info("Loaded image for txid " + txId + " from " + curFile); lastAppliedTxId = txId; storage.setMostRecentCheckpointInfo(txId, curFile.lastModified()); }
boolean loadFSImage(File curFile) throws IOException { assert curFile != null : "curFile is null"; FSImageFormat.Loader loader = new FSImageFormat.Loader(namesystem.getConf(), namesystem, this); loader.load(curFile, null); editLog.setStartTransactionId(loader.getLoadedImageTxId() + 1); MD5Hash readImageMd5 = loader.getLoadedImageMd5(); if (this.newImageDigest) { this.setImageDigest(readImageMd5); // set this fsimage's checksum } else if (!this.getImageDigest().equals(readImageMd5)) { throw new IOException("Image file " + curFile + " is corrupt!"); } return loader.getNeedToSave(); } /**