Skip to content

Commit

Permalink
Minor debug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vinothchandar committed Jan 12, 2013
1 parent a18d91b commit f97699b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
4 changes: 2 additions & 2 deletions META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 20.1-b02 (Sun Microsystems Inc.)
Created-By: 20.2-b06 (Sun Microsystems Inc.)
Implementation-Title: Voldemort
Implementation-Version: 1.1.4
Implementation-Version: 1.1.7
Implementation-Vendor: LinkedIn

9 changes: 5 additions & 4 deletions src/java/voldemort/store/readonly/io/MemLock.java
Expand Up @@ -13,7 +13,7 @@

public class MemLock implements Closeable {

private static final Logger log = Logger.getLogger(MemLock.class);
private static final Logger logger = Logger.getLogger(MemLock.class);

private Pointer pa;
private long length;
Expand All @@ -33,8 +33,8 @@ public class MemLock implements Closeable {
*/
public MemLock(File file, FileDescriptor descriptor, long offset, long length)
throws IOException {

log.debug("mlocking " + file + " with length " + length);
if(logger.isDebugEnabled())
logger.debug("mlocking " + file + " with length " + length);

this.setFile(file);
this.setDescriptor(descriptor);
Expand All @@ -61,7 +61,8 @@ public void close() throws IOException {
mman.munlock(pa, length);
mman.munmap(pa, length);

log.debug("munlocking " + file + " with length " + length);
if(logger.isDebugEnabled())
logger.debug("munlocking " + file + " with length " + length);

}

Expand Down
33 changes: 18 additions & 15 deletions src/java/voldemort/store/readonly/io/jna/mman.java
Expand Up @@ -46,8 +46,8 @@ public static Pointer mmap(long len, int prot, int flags, int fildes, long off)
new NativeLong(off));

if(Pointer.nativeValue(result) == -1) {

logger.debug(errno.strerror());
if(logger.isDebugEnabled())
logger.debug(errno.strerror());
}

return result;
Expand All @@ -59,7 +59,8 @@ public static int munmap(Pointer addr, long len) throws IOException {
int result = Delegate.munmap(addr, new NativeLong(len));

if(result != 0) {
logger.debug(errno.strerror());
if(logger.isDebugEnabled())
logger.debug(errno.strerror());
}

return result;
Expand All @@ -70,12 +71,13 @@ public static void mlock(Pointer addr, long len) throws IOException {

int res = Delegate.mlock(addr, new NativeLong(len));
if(res != 0) {
String error = errno.strerror();
logger.warn("Mlock failed probably because of insufficient privileges");
logger.debug(error);
logger.debug(res);
if(logger.isDebugEnabled()) {
logger.debug("Mlock failed probably because of insufficient privileges, errno:"
+ errno.strerror() + ", return value:" + res);
}
} else {
logger.debug("Mlock successfull");
if(logger.isDebugEnabled())
logger.debug("Mlock successfull");

}

Expand All @@ -87,11 +89,12 @@ public static void mlock(Pointer addr, long len) throws IOException {
public static void munlock(Pointer addr, long len) throws IOException {

if(Delegate.munlock(addr, new NativeLong(len)) != 0) {
logger.warn(errno.strerror());
if(logger.isDebugEnabled())
logger.debug("munlocking failed with errno:" + errno.strerror());
} else {
logger.debug("munlocking region");
if(logger.isDebugEnabled())
logger.debug("munlocking region");
}

}

static class Delegate {
Expand Down Expand Up @@ -122,13 +125,13 @@ public static void main(String[] args) throws Exception {
File file = new File(path);
FileInputStream in = new FileInputStream(file);
int fd = voldemort.store.readonly.io.Native.getFd(in.getFD());

logger.debug("File descriptor is: " + fd);
if(logger.isDebugEnabled())
logger.debug("File descriptor is: " + fd);

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

logger.debug("mmap address is: " + Pointer.nativeValue(addr));
if(logger.isDebugEnabled())
logger.debug("mmap address is: " + Pointer.nativeValue(addr));

// try to mlock it directly
mlock(addr, file.length());
Expand Down

0 comments on commit f97699b

Please sign in to comment.