/// <exception cref="System.IO.IOException"/> public static MD5Hash DownloadImageToStorage(Uri fsName, long imageTxId, Storage dstStorage, bool needDigest) { string fileid = ImageServlet.GetParamStringForImage(null, imageTxId, dstStorage); string fileName = NNStorage.GetCheckpointImageFileName(imageTxId); IList <FilePath> dstFiles = dstStorage.GetFiles(NNStorage.NameNodeDirType.Image, fileName ); if (dstFiles.IsEmpty()) { throw new IOException("No targets in destination storage!"); } MD5Hash hash = GetFileClient(fsName, fileid, dstFiles, dstStorage, needDigest); Log.Info("Downloaded file " + dstFiles[0].GetName() + " size " + dstFiles[0].Length () + " bytes."); return(hash); }
/// <exception cref="System.IO.IOException"/> internal static MD5Hash HandleUploadImageRequest(HttpServletRequest request, long imageTxId, Storage dstStorage, InputStream stream, long advertisedSize, DataTransferThrottler throttler) { string fileName = NNStorage.GetCheckpointImageFileName(imageTxId); IList <FilePath> dstFiles = dstStorage.GetFiles(NNStorage.NameNodeDirType.Image, fileName ); if (dstFiles.IsEmpty()) { throw new IOException("No targets in destination storage!"); } MD5Hash advertisedDigest = ParseMD5Header(request); MD5Hash hash = ReceiveFile(fileName, dstFiles, dstStorage, true, advertisedSize, advertisedDigest, fileName, stream, throttler); Log.Info("Downloaded file " + dstFiles[0].GetName() + " size " + dstFiles[0].Length () + " bytes."); return(hash); }