Skip to content

Commit

Permalink
debug msgs# Explicit paths specified without -i nor -o; assuming --on…
Browse files Browse the repository at this point in the history
…ly paths...
  • Loading branch information
abh1nay committed Nov 29, 2012
1 parent 763ff89 commit 220c5f1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/java/voldemort/store/readonly/io/jna/mman.java
Expand Up @@ -20,6 +20,8 @@ public class mman {
public static final int MAP_SHARED = 0x01; /* Share changes. */
public static final int MAP_PRIVATE = 0x02; /* Changes are private. */

public static final int MAP_ALIGN = 0x200; /* addr specifies alignment */

public static final int MAP_LOCKED = 0x02000; /* Lock the mapping. */

// http://linux.die.net/man/2/mmap
Expand Down Expand Up @@ -60,9 +62,12 @@ public static int munmap(Pointer addr, long len) throws IOException {

public static void mlock(Pointer addr, long len) throws IOException {

if(Delegate.mlock(addr, len) != 0) {
int res = Delegate.mlock(addr, len);
if(res != 0) {
String error = errno.strerror();
logger.warn("Mlock failed probably because of insufficient privileges");
logger.warn(errno.strerror());
logger.warn(error);
logger.warn(res);
} else {
logger.info("Mlock successfull");

Expand Down Expand Up @@ -112,8 +117,12 @@ public static void main(String[] args) throws Exception {
FileInputStream in = new FileInputStream(file);
int fd = voldemort.store.readonly.io.Native.getFd(in.getFD());

logger.info("File descriptor is: " + fd);

// mmap a large file...
Pointer addr = mmap(file.length(), PROT_READ, mman.MAP_SHARED | mman.MAP_LOCKED, fd, 0);
Pointer addr = mmap(file.length(), PROT_READ, mman.MAP_SHARED | mman.MAP_ALIGN, fd, 0L);

logger.info("mmap address is: " + Pointer.nativeValue(addr));

// try to mlock it directly
mlock(addr, file.length());
Expand All @@ -122,5 +131,4 @@ public static void main(String[] args) throws Exception {
munmap(addr, file.length());

}

}

0 comments on commit 220c5f1

Please sign in to comment.