/** * Compute the checksum for a block file that does not already have * its checksum computed, and save it to dstMeta file. */ public static void computeChecksum(File srcMeta, File dstMeta, File blockFile, int smallBufferSize, Configuration conf) throws IOException { Preconditions.checkNotNull(srcMeta); Preconditions.checkNotNull(dstMeta); Preconditions.checkNotNull(blockFile); // Create a dummy ReplicaInfo object pointing to the blockFile. ReplicaInfo wrapper = new FinalizedReplica(0, 0, 0, null, null) { @Override public URI getMetadataURI() { return srcMeta.toURI(); } @Override public InputStream getDataInputStream(long seekOffset) throws IOException { return new FileInputStream(blockFile); } }; FsDatasetImpl.computeChecksum(wrapper, dstMeta, smallBufferSize, conf); } }
static File[] copyBlockFiles(ReplicaInfo srcReplica, File dstMeta, File dstFile, boolean calculateChecksum, int smallBufferSize, final Configuration conf) throws IOException { if (calculateChecksum) { computeChecksum(srcReplica, dstMeta, smallBufferSize, conf); } else { try { srcReplica.copyMetadata(dstMeta.toURI()); } catch (IOException e) { throw new IOException("Failed to copy " + srcReplica + " metadata to " + dstMeta, e); } } try { srcReplica.copyBlockdata(dstFile.toURI()); } catch (IOException e) { throw new IOException("Failed to copy " + srcReplica + " block file to " + dstFile, e); } if (LOG.isDebugEnabled()) { if (calculateChecksum) { LOG.debug("Copied " + srcReplica.getMetadataURI() + " meta to " + dstMeta + " and calculated checksum"); } else { LOG.debug("Copied " + srcReplica.getBlockURI() + " to " + dstFile); } } return new File[] {dstMeta, dstFile}; }
/** * Compute the checksum for a block file that does not already have * its checksum computed, and save it to dstMeta file. */ public static void computeChecksum(File srcMeta, File dstMeta, File blockFile) throws IOException { Preconditions.checkNotNull(srcMeta); Preconditions.checkNotNull(dstMeta); Preconditions.checkNotNull(blockFile); FsDatasetImpl.computeChecksum(srcMeta, dstMeta, blockFile); } }
static File[] copyBlockFiles(File srcMeta, File srcFile, File dstMeta, File dstFile, boolean calculateChecksum) throws IOException { if (calculateChecksum) { computeChecksum(srcMeta, dstMeta, srcFile); } else { try { Storage.nativeCopyFileUnbuffered(srcMeta, dstMeta, true); } catch (IOException e) { throw new IOException("Failed to copy " + srcMeta + " to " + dstMeta, e); } } try { Storage.nativeCopyFileUnbuffered(srcFile, dstFile, true); } catch (IOException e) { throw new IOException("Failed to copy " + srcFile + " to " + dstFile, e); } if (LOG.isDebugEnabled()) { if (calculateChecksum) { LOG.debug("Copied " + srcMeta + " to " + dstMeta + " and calculated checksum"); } else { LOG.debug("Copied " + srcFile + " to " + dstFile); } } return new File[] {dstMeta, dstFile}; }
/** * Compute the checksum for a block file that does not already have * its checksum computed, and save it to dstMeta file. */ public static void computeChecksum(File srcMeta, File dstMeta, File blockFile) throws IOException { Preconditions.checkNotNull(srcMeta); Preconditions.checkNotNull(dstMeta); Preconditions.checkNotNull(blockFile); FsDatasetImpl.computeChecksum(srcMeta, dstMeta, blockFile); } }
static File[] copyBlockFiles(File srcMeta, File srcFile, File dstMeta, File dstFile, boolean calculateChecksum) throws IOException { if (calculateChecksum) { computeChecksum(srcMeta, dstMeta, srcFile); } else { try { Storage.nativeCopyFileUnbuffered(srcMeta, dstMeta, true); } catch (IOException e) { throw new IOException("Failed to copy " + srcMeta + " to " + dstMeta, e); } } try { Storage.nativeCopyFileUnbuffered(srcFile, dstFile, true); } catch (IOException e) { throw new IOException("Failed to copy " + srcFile + " to " + dstFile, e); } if (LOG.isDebugEnabled()) { if (calculateChecksum) { LOG.debug("Copied " + srcMeta + " to " + dstMeta + " and calculated checksum"); } else { LOG.debug("Copied " + srcFile + " to " + dstFile); } } return new File[] {dstMeta, dstFile}; }