Author: hairong
Date: Mon Feb 2 23:44:43 2009
New Revision: 740157
URL: http://svn.apache.org/viewvc?rev=740157&view=rev
Log:
HADOOP-5085. Copying a file to local with Crc throws an exception. Contributed
by Hairong Kuang.
Modified:
hadoop/core/trunk/CHANGES.txt
hadoop/core/trunk/src/core/org/apache/hadoop/fs/FsShell.java
Modified: hadoop/core/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=740157&r1=740156&r2=740157&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Mon Feb 2 23:44:43 2009
@@ -677,6 +677,9 @@
HADOOP-5139. Catch IllegalArgumentException during metrics registration
in RPC. (Hairong Kuang via szetszwo)
+ HADOOP-5085. Copying a file to local with Crc throws an exception.
+ (hairong)
+
Release 0.19.1 - Unreleased
IMPROVEMENTS
Modified: hadoop/core/trunk/src/core/org/apache/hadoop/fs/FsShell.java
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/src/core/org/apache/hadoop/fs/FsShell.java?rev=740157&r1=740156&r2=740157&view=diff
==============================================================================
--- hadoop/core/trunk/src/core/org/apache/hadoop/fs/FsShell.java (original)
+++ hadoop/core/trunk/src/core/org/apache/hadoop/fs/FsShell.java Mon Feb 2
23:44:43 2009
@@ -168,7 +168,7 @@
System.err.println("Usage: java FsShell " + GET_SHORT_USAGE);
throw iae;
}
- final boolean copyCrc = cf.getOpt("crc");
+ boolean copyCrc = cf.getOpt("crc");
final boolean verifyChecksum = !cf.getOpt("ignoreCrc");
if (dststr.equals("-")) {
@@ -180,6 +180,11 @@
File dst = new File(dststr);
Path srcpath = new Path(srcstr);
FileSystem srcFS = getSrcFileSystem(srcpath, verifyChecksum);
+ if (copyCrc && !(srcFS instanceof ChecksumFileSystem)) {
+ System.err.println("-crc option is not valid when source file system "
+
+ "does not have crc files. Automatically turn the option off.");
+ copyCrc = false;
+ }
FileStatus[] srcs = srcFS.globStatus(srcpath);
boolean dstIsDir = dst.isDirectory();
if (srcs.length > 1 && !dstIsDir) {
@@ -249,6 +254,10 @@
}
if (copyCrc) {
+ if (!(srcFS instanceof ChecksumFileSystem)) {
+ throw new IOException("Source file system does not have crc files");
+ }
+
ChecksumFileSystem csfs = (ChecksumFileSystem) srcFS;
File dstcs = FileSystem.getLocal(srcFS.getConf())
.pathToFile(csfs.getChecksumFile(new Path(dst.getCanonicalPath())));