HADOOP-10808. Merging change r1609509 from trunk to branch-2.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1609512 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris Nauroth 2014-07-10 17:14:24 +00:00
parent 41406e3702
commit d3f53852bc
4 changed files with 4 additions and 49 deletions

View File

@ -8,6 +8,8 @@ Release 2.6.0 - UNRELEASED
IMPROVEMENTS IMPROVEMENTS
HADOOP-10808. Remove unused native code for munlock. (cnauroth)
OPTIMIZATIONS OPTIMIZATIONS
BUG FIXES BUG FIXES

View File

@ -292,8 +292,6 @@ public class NativeIO {
static native void mlock_native( static native void mlock_native(
ByteBuffer buffer, long len) throws NativeIOException; ByteBuffer buffer, long len) throws NativeIOException;
static native void munlock_native(
ByteBuffer buffer, long len) throws NativeIOException;
/** /**
* Locks the provided direct ByteBuffer into memory, preventing it from * Locks the provided direct ByteBuffer into memory, preventing it from
@ -312,23 +310,6 @@ public class NativeIO {
} }
mlock_native(buffer, len); mlock_native(buffer, len);
} }
/**
* Unlocks a locked direct ByteBuffer, allowing it to swap out of memory.
* This is a no-op if the ByteBuffer was not previously locked.
*
* See the munlock(2) man page for more information.
*
* @throws NativeIOException
*/
public static void munlock(ByteBuffer buffer, long len)
throws IOException {
assertCodeLoaded();
if (!buffer.isDirect()) {
throw new IOException("Cannot munlock a non-direct ByteBuffer");
}
munlock_native(buffer, len);
}
/** /**
* Unmaps the block from memory. See munmap(2). * Unmaps the block from memory. See munmap(2).

View File

@ -404,34 +404,6 @@ Java_org_apache_hadoop_io_nativeio_NativeIO_00024POSIX_mlock_1native(
#endif #endif
} }
/**
* public static native void munlock_native(
* ByteBuffer buffer, long offset);
*
* The "00024" in the function name is an artifact of how JNI encodes
* special characters. U+0024 is '$'.
*/
JNIEXPORT void JNICALL
Java_org_apache_hadoop_io_nativeio_NativeIO_00024POSIX_munlock_1native(
JNIEnv *env, jclass clazz,
jobject buffer, jlong len)
{
#ifdef UNIX
void* buf = (void*)(*env)->GetDirectBufferAddress(env, buffer);
PASS_EXCEPTIONS(env);
if (munlock(buf, len)) {
CHECK_DIRECT_BUFFER_ADDRESS(buf);
throw_ioe(env, errno);
}
#endif
#ifdef WINDOWS
THROW(env, "java/io/IOException",
"The function POSIX.munlock_native() is not supported on Windows");
#endif
}
#ifdef __FreeBSD__ #ifdef __FreeBSD__
static int toFreeBSDFlags(int flags) static int toFreeBSDFlags(int flags)
{ {

View File

@ -607,8 +607,8 @@ public class TestNativeIO {
sum += mapbuf.get(i); sum += mapbuf.get(i);
} }
assertEquals("Expected sums to be equal", bufSum, sum); assertEquals("Expected sums to be equal", bufSum, sum);
// munlock the buffer // munmap the buffer, which also implicitly unlocks it
NativeIO.POSIX.munlock(mapbuf, fileSize); NativeIO.POSIX.munmap(mapbuf);
} finally { } finally {
if (channel != null) { if (channel != null) {
channel.close(); channel.close();