Author: suresh
Date: Fri May 24 05:34:41 2013
New Revision: 1485934
URL: http://svn.apache.org/r1485934
Log:
HADOOP-8562. Merge r1464780 HDFS-4625, r1465869 YARN-557, r1466148 HDFS-4674,
r1466306 HADOOP-9437, r1466746 YARN-487
Modified:
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/NativeIO.c
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/nativeio/TestNativeIO.java
Modified:
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1485934&r1=1485933&r2=1485934&view=diff
==============================================================================
---
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
(original)
+++
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
Fri May 24 05:34:41 2013
@@ -326,6 +326,10 @@ Release 2.0.5-beta - UNRELEASED
HADOOP-9353. Activate native-win maven profile by default on Windows.
(Arpit Agarwal via szetszwo)
+ HADOOP-9437. TestNativeIO#testRenameTo fails on Windows due to assumption
+ that POSIX errno is embedded in NativeIOException. (Chris Nauroth via
+ suresh)
+
Release 2.0.4-beta - UNRELEASED
INCOMPATIBLE CHANGES
Modified:
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/NativeIO.c
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/NativeIO.c?rev=1485934&r1=1485933&r2=1485934&view=diff
==============================================================================
---
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/NativeIO.c
(original)
+++
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/NativeIO.c
Fri May 24 05:34:41 2013
@@ -816,6 +816,7 @@ JNIEXPORT void JNICALL
Java_org_apache_hadoop_io_nativeio_NativeIO_renameTo0(JNIEnv *env,
jclass clazz, jstring jsrc, jstring jdst)
{
+#ifdef UNIX
const char *src = NULL, *dst = NULL;
src = (*env)->GetStringUTFChars(env, jsrc, NULL);
@@ -829,6 +830,23 @@ jclass clazz, jstring jsrc, jstring jdst
done:
if (src) (*env)->ReleaseStringUTFChars(env, jsrc, src);
if (dst) (*env)->ReleaseStringUTFChars(env, jdst, dst);
+#endif
+
+#ifdef WINDOWS
+ LPCWSTR src = NULL, dst = NULL;
+
+ src = (LPCWSTR) (*env)->GetStringChars(env, jsrc, NULL);
+ if (!src) goto done; // exception was thrown
+ dst = (LPCWSTR) (*env)->GetStringChars(env, jdst, NULL);
+ if (!dst) goto done; // exception was thrown
+ if (!MoveFile(src, dst)) {
+ throw_ioe(env, GetLastError());
+ }
+
+done:
+ if (src) (*env)->ReleaseStringChars(env, jsrc, src);
+ if (dst) (*env)->ReleaseStringChars(env, jdst, dst);
+#endif
}
/**
Modified:
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/nativeio/TestNativeIO.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/nativeio/TestNativeIO.java?rev=1485934&r1=1485933&r2=1485934&view=diff
==============================================================================
---
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/nativeio/TestNativeIO.java
(original)
+++
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/nativeio/TestNativeIO.java
Fri May 24 05:34:41 2013
@@ -446,7 +446,13 @@ public class TestNativeIO {
NativeIO.renameTo(nonExistentFile, targetFile);
Assert.fail();
} catch (NativeIOException e) {
- Assert.assertEquals(e.getErrno(), Errno.ENOENT);
+ if (Path.WINDOWS) {
+ Assert.assertEquals(
+ String.format("The system cannot find the file specified.%n"),
+ e.getMessage());
+ } else {
+ Assert.assertEquals(Errno.ENOENT, e.getErrno());
+ }
}
// Test renaming a file to itself. It should succeed and do nothing.
@@ -465,7 +471,13 @@ public class TestNativeIO {
NativeIO.renameTo(sourceFile, badTarget);
Assert.fail();
} catch (NativeIOException e) {
- Assert.assertEquals(e.getErrno(), Errno.ENOTDIR);
+ if (Path.WINDOWS) {
+ Assert.assertEquals(
+ String.format("The parameter is incorrect.%n"),
+ e.getMessage());
+ } else {
+ Assert.assertEquals(Errno.ENOTDIR, e.getErrno());
+ }
}
FileUtils.deleteQuietly(TEST_DIR);