You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mnemonic.apache.org by ga...@apache.org on 2016/04/09 00:00:06 UTC

[4/7] incubator-mnemonic git commit: format codestyle & add Apache License

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/551c8247/core/src/main/java/org/apache/mnemonic/BigDataMemAllocator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/BigDataMemAllocator.java b/core/src/main/java/org/apache/mnemonic/BigDataMemAllocator.java
index 3ed3181..f81a304 100644
--- a/core/src/main/java/org/apache/mnemonic/BigDataMemAllocator.java
+++ b/core/src/main/java/org/apache/mnemonic/BigDataMemAllocator.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.mnemonic;
 
 import java.nio.ByteBuffer;
@@ -7,260 +24,255 @@ import org.flowcomputing.commons.primitives.*;
 import org.apache.mnemonic.service.allocatorservice.VolatileMemoryAllocatorService;
 
 /**
- * manage a big native memory pool through libvmem.so that is provied by Intel nvml library.
+ * manage a big native memory pool through libvmem.so that is provied by Intel
+ * nvml library.
  * 
  *
  */
 public class BigDataMemAllocator extends CommonAllocator<BigDataMemAllocator> {
 
-    private boolean m_activegc = true;
-    private long m_gctimeout = 100;
-    private long m_nid = -1;
-    private VolatileMemoryAllocatorService m_vmasvc = null;
-
-    /**
-     * Constructor, it initializes and allocate a memory pool from specified uri
-     * location with specified capacity and an allocator service instance. 
-     * usually, the uri points to a mounted
-     * memory device or a location of file system.
-     * 
-     * @param vmasvc
-     *            the volatile memory allocation service instance
-     *
-     * @param capacity
-     *            the capacity of memory pool
-     * 
-     * @param uri
-     *            the location of memory pool will be created
-     * 
-     * @param isnew
-     *            a place holder, always specify it as true
-     */
-    public BigDataMemAllocator(VolatileMemoryAllocatorService vmasvc, long capacity, String uri, boolean isnew) {
-	assert null != vmasvc : "VolatileMemoryAllocatorService object is null";
-	if (capacity <= 0) {
-	    throw new IllegalArgumentException("BigDataMemAllocator cannot be initialized with capacity <= 0.");
-	}
-                
-	m_vmasvc = vmasvc;
-	m_nid = m_vmasvc.init(capacity, uri, isnew);
-		
-	/**
-	 * create a resource collector to release specified bytebuffer that backed
-	 * by underlying big memory pool.
-	 */
-	m_bufcollector = new ResCollector<MemBufferHolder<BigDataMemAllocator>, ByteBuffer>(
-											    new ResReclaim<ByteBuffer>() {
-												@Override
-												public void reclaim(ByteBuffer mres) {
-												    boolean cb_reclaimed = false;
-												    if (null != m_bufferreclaimer) {
-													cb_reclaimed = m_bufferreclaimer.reclaim(mres, Long.valueOf(mres.capacity()));
-												    }
-												    if (!cb_reclaimed) {
-													m_vmasvc.destroyByteBuffer(m_nid, mres);
-													mres = null;
-												    }
-												}
-											    });
+  private boolean m_activegc = true;
+  private long m_gctimeout = 100;
+  private long m_nid = -1;
+  private VolatileMemoryAllocatorService m_vmasvc = null;
 
-	/**
-	 * create a resource collector to release specified chunk that backed by
-	 * underlying big memory pool.
-	 */
-	m_chunkcollector = new ResCollector<MemChunkHolder<BigDataMemAllocator>, Long>(
-										       new ResReclaim<Long>() {
-											   @Override
-											   public void reclaim(Long mres) {
-											       // System.out.println(String.format("Reclaim: %X", mres));
-											       boolean cb_reclaimed = false;
-											       if (null != m_chunkreclaimer) {
-												   cb_reclaimed = m_chunkreclaimer.reclaim(mres, null);
-											       }
-											       if (!cb_reclaimed) {
-												   m_vmasvc.free(m_nid, mres);
-												   mres = null;
-											       }
-											   }
-										       });
+  /**
+   * Constructor, it initializes and allocate a memory pool from specified uri
+   * location with specified capacity and an allocator service instance.
+   * usually, the uri points to a mounted memory device or a location of file
+   * system.
+   * 
+   * @param vmasvc
+   *          the volatile memory allocation service instance
+   *
+   * @param capacity
+   *          the capacity of memory pool
+   * 
+   * @param uri
+   *          the location of memory pool will be created
+   * 
+   * @param isnew
+   *          a place holder, always specify it as true
+   */
+  public BigDataMemAllocator(VolatileMemoryAllocatorService vmasvc, long capacity, String uri, boolean isnew) {
+    assert null != vmasvc : "VolatileMemoryAllocatorService object is null";
+    if (capacity <= 0) {
+      throw new IllegalArgumentException("BigDataMemAllocator cannot be initialized with capacity <= 0.");
     }
 
-    /**
-     * enable active garbage collection. the GC will be forced to collect garbages when
-     * there is no more space for current allocation request.
-     *
-     * @param timeout
-     *            the timeout is used to yield for GC performing
-     *
-     * @return this allocator
-     */
-    @Override
-    public BigDataMemAllocator enableActiveGC(long timeout) {
-	m_activegc = true;
-	m_gctimeout = timeout;
-	return this;
-    }
+    m_vmasvc = vmasvc;
+    m_nid = m_vmasvc.init(capacity, uri, isnew);
 
     /**
-     * disable active garbage collection.
-     *
-     * @return this allocator 
+     * create a resource collector to release specified bytebuffer that backed
+     * by underlying big memory pool.
      */
-    @Override
-    public BigDataMemAllocator disableActiveGC() {
-	m_activegc = false;
-	return this;
-    }
+    m_bufcollector = new ResCollector<MemBufferHolder<BigDataMemAllocator>, ByteBuffer>(new ResReclaim<ByteBuffer>() {
+      @Override
+      public void reclaim(ByteBuffer mres) {
+        boolean cb_reclaimed = false;
+        if (null != m_bufferreclaimer) {
+          cb_reclaimed = m_bufferreclaimer.reclaim(mres, Long.valueOf(mres.capacity()));
+        }
+        if (!cb_reclaimed) {
+          m_vmasvc.destroyByteBuffer(m_nid, mres);
+          mres = null;
+        }
+      }
+    });
 
     /**
-     * release the memory pool and close it.
-     *
+     * create a resource collector to release specified chunk that backed by
+     * underlying big memory pool.
      */
-    @Override
-    public void close() {
-	super.close();
+    m_chunkcollector = new ResCollector<MemChunkHolder<BigDataMemAllocator>, Long>(new ResReclaim<Long>() {
+      @Override
+      public void reclaim(Long mres) {
+        // System.out.println(String.format("Reclaim: %X", mres));
+        boolean cb_reclaimed = false;
+        if (null != m_chunkreclaimer) {
+          cb_reclaimed = m_chunkreclaimer.reclaim(mres, null);
+        }
+        if (!cb_reclaimed) {
+          m_vmasvc.free(m_nid, mres);
+          mres = null;
+        }
+      }
+    });
+  }
+
+  /**
+   * enable active garbage collection. the GC will be forced to collect garbages
+   * when there is no more space for current allocation request.
+   *
+   * @param timeout
+   *          the timeout is used to yield for GC performing
+   *
+   * @return this allocator
+   */
+  @Override
+  public BigDataMemAllocator enableActiveGC(long timeout) {
+    m_activegc = true;
+    m_gctimeout = timeout;
+    return this;
+  }
+
+  /**
+   * disable active garbage collection.
+   *
+   * @return this allocator
+   */
+  @Override
+  public BigDataMemAllocator disableActiveGC() {
+    m_activegc = false;
+    return this;
+  }
+
+  /**
+   * release the memory pool and close it.
+   *
+   */
+  @Override
+  public void close() {
+    super.close();
+  }
+
+  /**
+   * force to synchronize uncommitted data to backed memory pool (this is a
+   * placeholder).
+   *
+   */
+  @Override
+  public void sync() {
+  }
+
+  /**
+   * re-size a specified chunk on its backed memory pool.
+   * 
+   * @param mholder
+   *          the holder of memory chunk. it can be null.
+   * 
+   * @param size
+   *          specify a new size of memory chunk
+   * 
+   * @return the resized memory chunk handler
+   */
+  @Override
+  public MemChunkHolder<BigDataMemAllocator> resizeChunk(MemChunkHolder<BigDataMemAllocator> mholder, long size) {
+    MemChunkHolder<BigDataMemAllocator> ret = null;
+    boolean ac = null != mholder.getRefId();
+    if (size > 0) {
+      Long addr = m_vmasvc.reallocate(m_nid, mholder.get(), size, true);
+      if (0 == addr && m_activegc) {
+        m_chunkcollector.waitReclaimCoolDown(m_gctimeout);
+        addr = m_vmasvc.reallocate(m_nid, mholder.get(), size, true);
+      }
+      if (0 != addr) {
+        mholder.clear();
+        mholder.destroy();
+        ret = new MemChunkHolder<BigDataMemAllocator>(this, addr, size);
+        if (ac) {
+          m_chunkcollector.register(ret);
+        }
+      }
     }
+    return ret;
+  }
 
-    /**
-     * force to synchronize uncommitted data to backed memory pool
-     * (this is a placeholder).
-     *
-     */
-    @Override
-    public void sync() {
+  /**
+   * resize a specified buffer on its backed memory pool.
+   *
+   * @param mholder
+   *          the holder of memory buffer. it can be null.
+   * 
+   * @param size
+   *          specify a new size of memory chunk
+   * 
+   * @return the resized memory buffer handler
+   *
+   */
+  @Override
+  public MemBufferHolder<BigDataMemAllocator> resizeBuffer(MemBufferHolder<BigDataMemAllocator> mholder, long size) {
+    MemBufferHolder<BigDataMemAllocator> ret = null;
+    boolean ac = null != mholder.getRefId();
+    if (size > 0) {
+      int bufpos = mholder.get().position();
+      int buflimit = mholder.get().limit();
+      ByteBuffer buf = m_vmasvc.resizeByteBuffer(m_nid, mholder.get(), size);
+      if (null == buf && m_activegc) {
+        m_bufcollector.waitReclaimCoolDown(m_gctimeout);
+        buf = m_vmasvc.resizeByteBuffer(m_nid, mholder.get(), size);
+      }
+      if (null != buf) {
+        mholder.clear();
+        mholder.destroy();
+        buf.position(bufpos <= size ? bufpos : 0);
+        buf.limit(buflimit <= size ? buflimit : (int) size);
+        ret = new MemBufferHolder<BigDataMemAllocator>(this, buf);
+        if (ac) {
+          m_bufcollector.register(ret);
+        }
+      }
     }
+    return ret;
+  }
 
-    /**
-     * re-size a specified chunk on its backed memory pool.
-     * 
-     * @param mholder
-     *            the holder of memory chunk. it can be
-     *            null.
-     * 
-     * @param size
-     *            specify a new size of memory chunk
-     * 
-     * @return the resized memory chunk handler
-     */
-    @Override
-    public MemChunkHolder<BigDataMemAllocator> resizeChunk(MemChunkHolder<BigDataMemAllocator> mholder, long size){
-	MemChunkHolder<BigDataMemAllocator> ret = null;
-	boolean ac = null != mholder.getRefId();
-	if (size > 0) {
-	    Long addr = m_vmasvc.reallocate(m_nid, mholder.get(), size, true);
-	    if (0 == addr && m_activegc) {
-	        m_chunkcollector.waitReclaimCoolDown(m_gctimeout);
-		addr = m_vmasvc.reallocate(m_nid, mholder.get(), size, true);
-	    }
-	    if (0 != addr) {
-		mholder.clear();
-		mholder.destroy();
-		ret = new MemChunkHolder<BigDataMemAllocator>(this, addr, size);
-		if (ac) {
-		    m_chunkcollector.register(ret);
-		}
-	    }
-	}
-	return ret;
+  /**
+   * create a memory chunk that is managed by its holder.
+   * 
+   * @param size
+   *          specify the size of memory chunk
+   * 
+   * @param autoreclaim
+   *          specify whether or not to reclaim this chunk automatically
+   *
+   * @return a holder contains a memory chunk
+   */
+  @Override
+  public MemChunkHolder<BigDataMemAllocator> createChunk(long size, boolean autoreclaim) {
+    MemChunkHolder<BigDataMemAllocator> ret = null;
+    Long addr = m_vmasvc.allocate(m_nid, size, true);
+    if (0 == addr && m_activegc) {
+      m_chunkcollector.waitReclaimCoolDown(m_gctimeout);
+      addr = m_vmasvc.allocate(m_nid, size, true);
     }
-	
-    /**
-     * resize a specified buffer on its backed memory pool.
-     *
-     * @param mholder
-     *            the holder of memory buffer. it can be
-     *            null.
-     * 
-     * @param size
-     *            specify a new size of memory chunk
-     * 
-     * @return the resized memory buffer handler
-     *
-     */
-    @Override
-    public MemBufferHolder<BigDataMemAllocator> resizeBuffer(MemBufferHolder<BigDataMemAllocator> mholder, long size) {
-	MemBufferHolder<BigDataMemAllocator> ret = null;
-	boolean ac = null != mholder.getRefId();
-	if (size > 0) {
-	    int bufpos = mholder.get().position();
-	    int buflimit = mholder.get().limit();
-	    ByteBuffer buf = m_vmasvc.resizeByteBuffer(m_nid, mholder.get(), size);
-	    if (null == buf && m_activegc) {
-	        m_bufcollector.waitReclaimCoolDown(m_gctimeout);
-		buf = m_vmasvc.resizeByteBuffer(m_nid, mholder.get(), size);
-	    }
-	    if (null != buf) {
-		mholder.clear();
-		mholder.destroy();
-		buf.position(bufpos <= size ? bufpos : 0);
-		buf.limit(buflimit <= size ? buflimit : (int)size);
-		ret = new MemBufferHolder<BigDataMemAllocator>(this, buf);
-		if (ac) {
-		    m_bufcollector.register(ret);
-		}
-	    }
-	}
-	return ret;
+    if (0 != addr) {
+      ret = new MemChunkHolder<BigDataMemAllocator>(this, addr, size);
+      ret.setCollector(m_chunkcollector);
+      if (autoreclaim) {
+        m_chunkcollector.register(ret);
+      }
     }
+    return ret;
+  }
 
-    /**
-     * create a memory chunk that is managed by its holder.
-     * 
-     * @param size
-     *            specify the size of memory chunk
-     * 
-     * @param autoreclaim
-     * 	          specify whether or not to reclaim this
-     *            chunk automatically
-     *
-     * @return a holder contains a memory chunk
-     */
-    @Override
-    public MemChunkHolder<BigDataMemAllocator> createChunk(long size, boolean autoreclaim) {
-	MemChunkHolder<BigDataMemAllocator> ret = null;
-	Long addr = m_vmasvc.allocate(m_nid, size, true);
-	if (0 == addr && m_activegc) {
-	    m_chunkcollector.waitReclaimCoolDown(m_gctimeout);
-	    addr = m_vmasvc.allocate(m_nid, size, true);
-	}
-	if (0 != addr) {
-	    ret = new MemChunkHolder<BigDataMemAllocator>(this, addr, size);
-	    ret.setCollector(m_chunkcollector);
-	    if (autoreclaim) {
-		m_chunkcollector.register(ret);
-	    }
-	}
-	return ret;
+  /**
+   * create a memory buffer that is managed by its holder.
+   * 
+   * @param size
+   *          specify the size of memory buffer
+   * 
+   * @param autoreclaim
+   *          specify whether or not to reclaim this buffer automatically
+   *
+   * @return a holder contains a memory buffer
+   */
+  @Override
+  public MemBufferHolder<BigDataMemAllocator> createBuffer(long size, boolean autoreclaim) {
+    MemBufferHolder<BigDataMemAllocator> ret = null;
+    ByteBuffer bb = m_vmasvc.createByteBuffer(m_nid, size);
+    if (null == bb && m_activegc) {
+      m_bufcollector.waitReclaimCoolDown(m_gctimeout);
+      bb = m_vmasvc.createByteBuffer(m_nid, size);
     }
-
-    /**
-     * create a memory buffer that is managed by its holder.
-     * 
-     * @param size
-     *            specify the size of memory buffer
-     * 
-     * @param autoreclaim
-     * 	          specify whether or not to reclaim this
-     *            buffer automatically
-     *
-     * @return a holder contains a memory buffer
-     */
-    @Override
-    public MemBufferHolder<BigDataMemAllocator> createBuffer(long size, boolean autoreclaim) {
-	MemBufferHolder<BigDataMemAllocator> ret = null;
-	ByteBuffer bb = m_vmasvc.createByteBuffer(m_nid, size);
-	if (null == bb && m_activegc) {
-	    m_bufcollector.waitReclaimCoolDown(m_gctimeout);
-	    bb = m_vmasvc.createByteBuffer(m_nid, size);
-	}
-	if (null != bb) {
-	    ret = new MemBufferHolder<BigDataMemAllocator>(this, bb);
-	    ret.setCollector(m_bufcollector);
-	    if (autoreclaim) {
-		m_bufcollector.register(ret);
-	    }
-	}
-	return ret;
+    if (null != bb) {
+      ret = new MemBufferHolder<BigDataMemAllocator>(this, bb);
+      ret.setCollector(m_bufcollector);
+      if (autoreclaim) {
+        m_bufcollector.register(ret);
+      }
     }
+    return ret;
+  }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/551c8247/core/src/main/java/org/apache/mnemonic/BigDataPMemAllocator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/BigDataPMemAllocator.java b/core/src/main/java/org/apache/mnemonic/BigDataPMemAllocator.java
index a067309..99af1b7 100644
--- a/core/src/main/java/org/apache/mnemonic/BigDataPMemAllocator.java
+++ b/core/src/main/java/org/apache/mnemonic/BigDataPMemAllocator.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.mnemonic;
 
 import java.nio.ByteBuffer;
@@ -7,449 +24,447 @@ import org.flowcomputing.commons.primitives.*;
 import org.apache.mnemonic.service.allocatorservice.NonVolatileMemoryAllocatorService;
 
 /**
- * manage a big native persistent memory pool through libpmalloc.so provided by pmalloc project.
+ * manage a big native persistent memory pool through libpmalloc.so provided by
+ * pmalloc project.
  * 
  *
  */
-public class BigDataPMemAllocator extends CommonPersistAllocator<BigDataPMemAllocator> implements PMAddressTranslator{
+public class BigDataPMemAllocator extends CommonPersistAllocator<BigDataPMemAllocator> implements PMAddressTranslator {
 
-    private boolean m_activegc = true;
-    private long m_gctimeout = 100;
-    private long m_nid = -1;
-    private long b_addr = 0;
-    private NonVolatileMemoryAllocatorService m_nvmasvc = null;
+  private boolean m_activegc = true;
+  private long m_gctimeout = 100;
+  private long m_nid = -1;
+  private long b_addr = 0;
+  private NonVolatileMemoryAllocatorService m_nvmasvc = null;
 
-    /**
-     * Constructor, it initializes and allocate a memory pool from specified uri
-     * location with specified capacity and an allocator service instance. 
-     * usually, the uri points to a mounted
-     * non-volatile memory device or a location of file system.
-     * 
-     * @param nvmasvc
-     *            the non-volatile memory allocation service instance
-     *
-     * @param capacity
-     *            the capacity of memory pool
-     * 
-     * @param uri
-     *            the location of memory pool will be created
-     * 
-     * @param isnew
-     *            a place holder, always specify it as true
-     */
-    public BigDataPMemAllocator(NonVolatileMemoryAllocatorService nvmasvc, long capacity, String uri, boolean isnew) {
-	assert null != nvmasvc : "NonVolatileMemoryAllocatorService object is null";
-	if (capacity <= 0) {
-	    throw new IllegalArgumentException("BigDataPMemAllocator cannot be initialized with capacity <= 0.");
-	}
-
-	m_nvmasvc = nvmasvc;
-             
-	m_nid = m_nvmasvc.init(capacity, uri, isnew);
-	b_addr = m_nvmasvc.getBaseAddress(m_nid);
-		
-	/**
-	 * create a resource collector to release specified chunk that backed by
-	 * underlying big memory pool.
-	 */
-	m_chunkcollector = new ResCollector<MemChunkHolder<BigDataPMemAllocator>, Long>(new ResReclaim<Long>() {
-		@Override
-		public void reclaim(Long mres) {
-		    // System.out.println(String.format("Reclaim: %X", mres));
-		    boolean cb_reclaimed = false;
-		    if (null != m_chunkreclaimer) {
-			cb_reclaimed = m_chunkreclaimer.reclaim(mres, null);
-		    }
-		    if (!cb_reclaimed) {
-			m_nvmasvc.free(m_nid, mres);
-			mres = null;
-		    }
-		}
-	    });
-
-	/**
-	 * create a resource collector to release specified bytebuffer that backed
-	 * by underlying big memory pool.
-	 */
-	m_bufcollector = new ResCollector<MemBufferHolder<BigDataPMemAllocator>, ByteBuffer>(
-											     new ResReclaim<ByteBuffer>() {
-												 @Override
-												 public void reclaim(ByteBuffer mres) {
-												     boolean cb_reclaimed = false;
-												     if (null != m_bufferreclaimer) {
-													 cb_reclaimed = m_bufferreclaimer.reclaim(mres, Long.valueOf(mres.capacity()));
-												     }
-												     if (!cb_reclaimed) {
-													 m_nvmasvc.destroyByteBuffer(m_nid, mres);
-													 mres = null;
-												     }
-												 }
-											     });
+  /**
+   * Constructor, it initializes and allocate a memory pool from specified uri
+   * location with specified capacity and an allocator service instance.
+   * usually, the uri points to a mounted non-volatile memory device or a
+   * location of file system.
+   * 
+   * @param nvmasvc
+   *          the non-volatile memory allocation service instance
+   *
+   * @param capacity
+   *          the capacity of memory pool
+   * 
+   * @param uri
+   *          the location of memory pool will be created
+   * 
+   * @param isnew
+   *          a place holder, always specify it as true
+   */
+  public BigDataPMemAllocator(NonVolatileMemoryAllocatorService nvmasvc, long capacity, String uri, boolean isnew) {
+    assert null != nvmasvc : "NonVolatileMemoryAllocatorService object is null";
+    if (capacity <= 0) {
+      throw new IllegalArgumentException("BigDataPMemAllocator cannot be initialized with capacity <= 0.");
     }
 
-    /**
-     * enable active garbage collection. the GC will be forced to collect garbages when
-     * there is no more space for current allocation request.
-     * 
-     * @param timeout
-     *            the timeout is used to yield for GC performing
-     */
-    @Override
-    public BigDataPMemAllocator enableActiveGC(long timeout) {
-	m_activegc = true;
-	m_gctimeout = timeout;
-	return this;
-    }
+    m_nvmasvc = nvmasvc;
+
+    m_nid = m_nvmasvc.init(capacity, uri, isnew);
+    b_addr = m_nvmasvc.getBaseAddress(m_nid);
 
     /**
-     * disable active garbage collection.
-     * 
+     * create a resource collector to release specified chunk that backed by
+     * underlying big memory pool.
      */
-    @Override
-    public BigDataPMemAllocator disableActiveGC() {
-	m_activegc = false;
-	return this;
-    }
+    m_chunkcollector = new ResCollector<MemChunkHolder<BigDataPMemAllocator>, Long>(new ResReclaim<Long>() {
+      @Override
+      public void reclaim(Long mres) {
+        // System.out.println(String.format("Reclaim: %X", mres));
+        boolean cb_reclaimed = false;
+        if (null != m_chunkreclaimer) {
+          cb_reclaimed = m_chunkreclaimer.reclaim(mres, null);
+        }
+        if (!cb_reclaimed) {
+          m_nvmasvc.free(m_nid, mres);
+          mres = null;
+        }
+      }
+    });
 
     /**
-     * Release the memory pool and close it.
-     *
+     * create a resource collector to release specified bytebuffer that backed
+     * by underlying big memory pool.
      */
-    @Override
-    public void close() {
-	super.close();
-	m_nvmasvc.close(m_nid);
+    m_bufcollector = new ResCollector<MemBufferHolder<BigDataPMemAllocator>, ByteBuffer>(new ResReclaim<ByteBuffer>() {
+      @Override
+      public void reclaim(ByteBuffer mres) {
+        boolean cb_reclaimed = false;
+        if (null != m_bufferreclaimer) {
+          cb_reclaimed = m_bufferreclaimer.reclaim(mres, Long.valueOf(mres.capacity()));
+        }
+        if (!cb_reclaimed) {
+          m_nvmasvc.destroyByteBuffer(m_nid, mres);
+          mres = null;
+        }
+      }
+    });
+  }
+
+  /**
+   * enable active garbage collection. the GC will be forced to collect garbages
+   * when there is no more space for current allocation request.
+   * 
+   * @param timeout
+   *          the timeout is used to yield for GC performing
+   */
+  @Override
+  public BigDataPMemAllocator enableActiveGC(long timeout) {
+    m_activegc = true;
+    m_gctimeout = timeout;
+    return this;
+  }
+
+  /**
+   * disable active garbage collection.
+   * 
+   */
+  @Override
+  public BigDataPMemAllocator disableActiveGC() {
+    m_activegc = false;
+    return this;
+  }
+
+  /**
+   * Release the memory pool and close it.
+   *
+   */
+  @Override
+  public void close() {
+    super.close();
+    m_nvmasvc.close(m_nid);
+  }
+
+  /**
+   * force to synchronize uncommitted data to backed memory pool (this is a
+   * placeholder).
+   *
+   */
+  @Override
+  public void sync() {
+  }
+
+  /**
+   * re-size a specified chunk on its backed memory pool.
+   * 
+   * @param mholder
+   *          the holder of memory chunk. it can be null.
+   * 
+   * @param size
+   *          specify a new size of memory chunk
+   * 
+   * @return the resized memory chunk handler
+   */
+  @Override
+  public MemChunkHolder<BigDataPMemAllocator> resizeChunk(MemChunkHolder<BigDataPMemAllocator> mholder, long size) {
+    MemChunkHolder<BigDataPMemAllocator> ret = null;
+    boolean ac = null != mholder.getRefId();
+    if (size > 0) {
+      Long addr = m_nvmasvc.reallocate(m_nid, mholder.get(), size, true);
+      if (0 == addr && m_activegc) {
+        m_chunkcollector.waitReclaimCoolDown(m_gctimeout);
+        addr = m_nvmasvc.reallocate(m_nid, mholder.get(), size, true);
+      }
+      if (0 != addr) {
+        mholder.clear();
+        mholder.destroy();
+        ret = new MemChunkHolder<BigDataPMemAllocator>(this, addr, size);
+        if (ac) {
+          m_chunkcollector.register(ret);
+        }
+      }
     }
+    return ret;
+  }
 
-    /**
-     * force to synchronize uncommitted data to backed memory pool
-     * (this is a placeholder).
-     *
-     */
-    @Override
-    public void sync() {
+  /**
+   * resize a specified buffer on its backed memory pool.
+   *
+   * @param mholder
+   *          the holder of memory buffer. it can be null.
+   * 
+   * @param size
+   *          specify a new size of memory chunk
+   * 
+   * @return the resized memory buffer handler
+   *
+   */
+  @Override
+  public MemBufferHolder<BigDataPMemAllocator> resizeBuffer(MemBufferHolder<BigDataPMemAllocator> mholder, long size) {
+    MemBufferHolder<BigDataPMemAllocator> ret = null;
+    boolean ac = null != mholder.getRefId();
+    if (size > 0) {
+      int bufpos = mholder.get().position();
+      int buflimit = mholder.get().limit();
+      ByteBuffer buf = m_nvmasvc.resizeByteBuffer(m_nid, mholder.get(), size);
+      if (null == buf && m_activegc) {
+        m_bufcollector.waitReclaimCoolDown(m_gctimeout);
+        buf = m_nvmasvc.resizeByteBuffer(m_nid, mholder.get(), size);
+      }
+      if (null != buf) {
+        mholder.clear();
+        mholder.destroy();
+        buf.position(bufpos <= size ? bufpos : 0);
+        buf.limit(buflimit <= size ? buflimit : (int) size);
+        ret = new MemBufferHolder<BigDataPMemAllocator>(this, buf);
+        if (ac) {
+          m_bufcollector.register(ret);
+        }
+      }
     }
+    return ret;
+  }
 
-    /**
-     * re-size a specified chunk on its backed memory pool.
-     * 
-     * @param mholder
-     *            the holder of memory chunk. it can be
-     *            null.
-     * 
-     * @param size
-     *            specify a new size of memory chunk
-     * 
-     * @return the resized memory chunk handler
-     */
-    @Override
-    public MemChunkHolder<BigDataPMemAllocator> resizeChunk(MemChunkHolder<BigDataPMemAllocator> mholder, long size){
-	MemChunkHolder<BigDataPMemAllocator> ret = null;
-	boolean ac = null != mholder.getRefId();
-	if (size > 0) {
-	    Long addr = m_nvmasvc.reallocate(m_nid, mholder.get(), size, true);
-	    if (0 == addr && m_activegc) {
-	        m_chunkcollector.waitReclaimCoolDown(m_gctimeout);
-		addr = m_nvmasvc.reallocate(m_nid, mholder.get(), size, true);
-	    }
-	    if (0 != addr) {
-		mholder.clear();
-		mholder.destroy();
-		ret = new MemChunkHolder<BigDataPMemAllocator>(this, addr, size);
-		if (ac) {
-		    m_chunkcollector.register(ret);
-		}
-	    }
-	}
-	return ret;
+  /**
+   * create a memory chunk that is managed by its holder.
+   * 
+   * @param size
+   *          specify the size of memory chunk
+   * 
+   * @param autoreclaim
+   *          specify whether or not to reclaim this chunk automatically
+   *
+   * @return a holder contains a memory chunk
+   */
+  @Override
+  public MemChunkHolder<BigDataPMemAllocator> createChunk(long size, boolean autoreclaim) {
+    MemChunkHolder<BigDataPMemAllocator> ret = null;
+    Long addr = m_nvmasvc.allocate(m_nid, size, true);
+    if ((null == addr || 0 == addr) && m_activegc) {
+      m_chunkcollector.waitReclaimCoolDown(m_gctimeout);
+      addr = m_nvmasvc.allocate(m_nid, size, true);
     }
-	
-    /**
-     * resize a specified buffer on its backed memory pool.
-     *
-     * @param mholder
-     *            the holder of memory buffer. it can be
-     *            null.
-     * 
-     * @param size
-     *            specify a new size of memory chunk
-     * 
-     * @return the resized memory buffer handler
-     *
-     */
-    @Override
-    public MemBufferHolder<BigDataPMemAllocator> resizeBuffer(MemBufferHolder<BigDataPMemAllocator> mholder, long size) {
-	MemBufferHolder<BigDataPMemAllocator> ret = null;
-	boolean ac = null != mholder.getRefId();
-	if (size > 0) {
-	    int bufpos = mholder.get().position();
-	    int buflimit = mholder.get().limit();
-	    ByteBuffer buf = m_nvmasvc.resizeByteBuffer(m_nid, mholder.get(), size);
-	    if (null == buf && m_activegc) {
-	        m_bufcollector.waitReclaimCoolDown(m_gctimeout);
-		buf = m_nvmasvc.resizeByteBuffer(m_nid, mholder.get(), size);
-	    }
-	    if (null != buf) {
-		mholder.clear();
-		mholder.destroy();
-		buf.position(bufpos <= size ? bufpos : 0);
-		buf.limit(buflimit <= size ? buflimit : (int)size);
-		ret = new MemBufferHolder<BigDataPMemAllocator>(this, buf);
-		if (ac) {
-		    m_bufcollector.register(ret);
-		}
-	    }
-	}
-	return ret;
+    if (null != addr && 0 != addr) {
+      ret = new MemChunkHolder<BigDataPMemAllocator>(this, addr, size);
+      ret.setCollector(m_chunkcollector);
+      if (autoreclaim) {
+        m_chunkcollector.register(ret);
+      }
     }
+    return ret;
+  }
 
-    /**
-     * create a memory chunk that is managed by its holder.
-     * 
-     * @param size
-     *            specify the size of memory chunk
-     * 
-     * @param autoreclaim
-     * 	          specify whether or not to reclaim this
-     *            chunk automatically
-     *
-     * @return a holder contains a memory chunk
-     */
-    @Override
-    public MemChunkHolder<BigDataPMemAllocator> createChunk(long size, boolean autoreclaim) {
-	MemChunkHolder<BigDataPMemAllocator> ret = null;
-	Long addr = m_nvmasvc.allocate(m_nid, size, true);
-	if ((null == addr || 0 == addr) && m_activegc) {
-	    m_chunkcollector.waitReclaimCoolDown(m_gctimeout);
-	    addr = m_nvmasvc.allocate(m_nid, size, true);
-	}
-	if (null != addr && 0 != addr) {
-	    ret = new MemChunkHolder<BigDataPMemAllocator>(this, addr, size);
-	    ret.setCollector(m_chunkcollector);
-	    if (autoreclaim) {
-		m_chunkcollector.register(ret);
-	    }
-	}
-	return ret;
+  /**
+   * create a memory buffer that is managed by its holder.
+   * 
+   * @param size
+   *          specify the size of memory buffer
+   * 
+   * @param autoreclaim
+   *          specify whether or not to reclaim this buffer automatically
+   *
+   * @return a holder contains a memory buffer
+   */
+  @Override
+  public MemBufferHolder<BigDataPMemAllocator> createBuffer(long size, boolean autoreclaim) {
+    MemBufferHolder<BigDataPMemAllocator> ret = null;
+    ByteBuffer bb = m_nvmasvc.createByteBuffer(m_nid, size);
+    if (null == bb && m_activegc) {
+      m_bufcollector.waitReclaimCoolDown(m_gctimeout);
+      bb = m_nvmasvc.createByteBuffer(m_nid, size);
     }
-
-    /**
-     * create a memory buffer that is managed by its holder.
-     * 
-     * @param size
-     *            specify the size of memory buffer
-     * 
-     * @param autoreclaim
-     * 	          specify whether or not to reclaim this
-     *            buffer automatically
-     *
-     * @return a holder contains a memory buffer
-     */
-    @Override
-    public MemBufferHolder<BigDataPMemAllocator> createBuffer(long size, boolean autoreclaim) {
-	MemBufferHolder<BigDataPMemAllocator> ret = null;
-	ByteBuffer bb = m_nvmasvc.createByteBuffer(m_nid, size);
-	if (null == bb && m_activegc) {
-	    m_bufcollector.waitReclaimCoolDown(m_gctimeout);
-	    bb = m_nvmasvc.createByteBuffer(m_nid, size);
-	}
-	if (null != bb) {
-	    ret = new MemBufferHolder<BigDataPMemAllocator>(this, bb);
-	    ret.setCollector(m_bufcollector);
-	    if (autoreclaim) {
-		m_bufcollector.register(ret);
-	    }
-	}
-	return ret;
+    if (null != bb) {
+      ret = new MemBufferHolder<BigDataPMemAllocator>(this, bb);
+      ret.setCollector(m_bufcollector);
+      if (autoreclaim) {
+        m_bufcollector.register(ret);
+      }
     }
+    return ret;
+  }
 
-    /**
-     * retrieve a memory buffer from its backed memory allocator.
-     * 
-     * @param phandler
-     *            specify the handler of memory buffer to retrieve
-     *
-     * @param autoreclaim
-     *            specify whether this retrieved memory buffer can be reclaimed automatically or not
-     * 
-     * @return a holder contains the retrieved memory buffer
-     */
-    @Override
-    public MemBufferHolder<BigDataPMemAllocator> retrieveBuffer(long phandler, boolean autoreclaim) {
-	MemBufferHolder<BigDataPMemAllocator> ret = null;
-	ByteBuffer bb = m_nvmasvc.retrieveByteBuffer(m_nid, getEffectiveAddress(phandler));
-	if (null != bb) {
-	    ret = new MemBufferHolder<BigDataPMemAllocator>(this, bb);
-	    if (autoreclaim) {
-		m_bufcollector.register(ret);
-	    }
-	}
-	return ret;
+  /**
+   * retrieve a memory buffer from its backed memory allocator.
+   * 
+   * @param phandler
+   *          specify the handler of memory buffer to retrieve
+   *
+   * @param autoreclaim
+   *          specify whether this retrieved memory buffer can be reclaimed
+   *          automatically or not
+   * 
+   * @return a holder contains the retrieved memory buffer
+   */
+  @Override
+  public MemBufferHolder<BigDataPMemAllocator> retrieveBuffer(long phandler, boolean autoreclaim) {
+    MemBufferHolder<BigDataPMemAllocator> ret = null;
+    ByteBuffer bb = m_nvmasvc.retrieveByteBuffer(m_nid, getEffectiveAddress(phandler));
+    if (null != bb) {
+      ret = new MemBufferHolder<BigDataPMemAllocator>(this, bb);
+      if (autoreclaim) {
+        m_bufcollector.register(ret);
+      }
     }
+    return ret;
+  }
 
-    /**
-     * retrieve a memory chunk from its backed memory allocator.
-     * 
-     * @param phandler
-     *            specify the handler of memory chunk to retrieve
-     *
-     * @param autoreclaim
-     *            specify whether this retrieved memory chunk can be reclaimed automatically or not
-     * 
-     * @return a holder contains the retrieved memory chunk
-     */
-    @Override
-    public MemChunkHolder<BigDataPMemAllocator>  retrieveChunk(long phandler, boolean autoreclaim) {
-	MemChunkHolder<BigDataPMemAllocator> ret = null;
-	long eaddr = getEffectiveAddress(phandler);
-	long sz = m_nvmasvc.retrieveSize(m_nid, eaddr);
-	if (sz > 0L) {
-	    ret = new MemChunkHolder<BigDataPMemAllocator>(this, eaddr, sz);
-	    if (autoreclaim) {
-		m_chunkcollector.register(ret);
-	    }
-	}
-	return ret;
+  /**
+   * retrieve a memory chunk from its backed memory allocator.
+   * 
+   * @param phandler
+   *          specify the handler of memory chunk to retrieve
+   *
+   * @param autoreclaim
+   *          specify whether this retrieved memory chunk can be reclaimed
+   *          automatically or not
+   * 
+   * @return a holder contains the retrieved memory chunk
+   */
+  @Override
+  public MemChunkHolder<BigDataPMemAllocator> retrieveChunk(long phandler, boolean autoreclaim) {
+    MemChunkHolder<BigDataPMemAllocator> ret = null;
+    long eaddr = getEffectiveAddress(phandler);
+    long sz = m_nvmasvc.retrieveSize(m_nid, eaddr);
+    if (sz > 0L) {
+      ret = new MemChunkHolder<BigDataPMemAllocator>(this, eaddr, sz);
+      if (autoreclaim) {
+        m_chunkcollector.register(ret);
+      }
     }
+    return ret;
+  }
 
-    /**
-     * get the handler from a memory buffer holder.
-     * 
-     * @param mbuf
-     *            specify the memory buffer holder
-     *
-     * @return a handler that could be used to retrieve its memory buffer
-     */
-    @Override
-    public long getBufferHandler(MemBufferHolder<BigDataPMemAllocator> mbuf) {
-	return getPortableAddress(m_nvmasvc.getByteBufferHandler(m_nid, mbuf.get()));
-    }
+  /**
+   * get the handler from a memory buffer holder.
+   * 
+   * @param mbuf
+   *          specify the memory buffer holder
+   *
+   * @return a handler that could be used to retrieve its memory buffer
+   */
+  @Override
+  public long getBufferHandler(MemBufferHolder<BigDataPMemAllocator> mbuf) {
+    return getPortableAddress(m_nvmasvc.getByteBufferHandler(m_nid, mbuf.get()));
+  }
 
-    /**
-     * get the handler from a memory chunk holder.
-     * 
-     * @param mchunk
-     *            specify the memory chunk holder
-     *
-     * @return a handler that could be used to retrieve its memory chunk
-     */
-    @Override
-    public long getChunkHandler(MemChunkHolder<BigDataPMemAllocator> mchunk) {
-	return getPortableAddress(mchunk.get());
-    }
+  /**
+   * get the handler from a memory chunk holder.
+   * 
+   * @param mchunk
+   *          specify the memory chunk holder
+   *
+   * @return a handler that could be used to retrieve its memory chunk
+   */
+  @Override
+  public long getChunkHandler(MemChunkHolder<BigDataPMemAllocator> mchunk) {
+    return getPortableAddress(mchunk.get());
+  }
 
-    /**
-     * determine whether this allocator supports to store non-volatile handler or not.
-     * (it is a placeholder)
-     *
-     * @return true if there is
-     */
-    @Override
-    public boolean hasNonVolatileHandlerStore() {
-	return true;
-    }
+  /**
+   * determine whether this allocator supports to store non-volatile handler or
+   * not. (it is a placeholder)
+   *
+   * @return true if there is
+   */
+  @Override
+  public boolean hasNonVolatileHandlerStore() {
+    return true;
+  }
 
-    /**
-     * start a application level transaction on this allocator.
-     * (it is a place holder)
-     *
-     */
-    @Override
-    public void beginTransaction() {
-	throw new UnsupportedOperationException("Transaction Unsupported.");
-    }
+  /**
+   * start a application level transaction on this allocator. (it is a place
+   * holder)
+   *
+   */
+  @Override
+  public void beginTransaction() {
+    throw new UnsupportedOperationException("Transaction Unsupported.");
+  }
 
-    /**
-     * end a application level transaction on this allocator.
-     * (it is a place holder)
-     *
-     */
-    @Override
-    public void endTransaction() {
-	throw new UnsupportedOperationException("Transaction Unsupported.");
-    }
+  /**
+   * end a application level transaction on this allocator. (it is a place
+   * holder)
+   *
+   */
+  @Override
+  public void endTransaction() {
+    throw new UnsupportedOperationException("Transaction Unsupported.");
+  }
 
-    /**
-     * set a handler on key.
-     * 
-     * @param key
-     *            the key to set its value
-     *            
-     * @param handler
-     *            the handler 
-     */
-    public void setHandler(long key, long handler) {
-	m_nvmasvc.setHandler(m_nid, key, handler);
-    }
+  /**
+   * set a handler on key.
+   * 
+   * @param key
+   *          the key to set its value
+   * 
+   * @param handler
+   *          the handler
+   */
+  public void setHandler(long key, long handler) {
+    m_nvmasvc.setHandler(m_nid, key, handler);
+  }
 
-    /**
-     * get a handler value.
-     * 
-     * @param key
-     *            the key to set its value
-     *            
-     * @return the value of handler
-     */
-    public long getHandler(long key) {
-	return m_nvmasvc.getHandler(m_nid, key);
-    }
-	
-    /**
-     * return the capacity of non-volatile handler store.
-     * 
-     * @return the capacity of handler store
-     * 
-     */
-    public long handlerCapacity() {
-	return m_nvmasvc.handlerCapacity(m_nid);
-    }
-	
-    /**
-     * calculate the portable address
-     *
-     * @param addr 
-     *           the address to be calculated
-     *
-     * @return the portable address
-     */
-    @Override
-    public long getPortableAddress(long addr) {
-	return addr - b_addr;
-    }
+  /**
+   * get a handler value.
+   * 
+   * @param key
+   *          the key to set its value
+   * 
+   * @return the value of handler
+   */
+  public long getHandler(long key) {
+    return m_nvmasvc.getHandler(m_nid, key);
+  }
 
-    /**
-     * calculate the effective address
-     *
-     * @param addr 
-     *           the address to be calculated
-     *
-     * @return the effective address
-     */
-    @Override
-    public long getEffectiveAddress(long addr) {
-	return addr + b_addr;
-    }
+  /**
+   * return the capacity of non-volatile handler store.
+   * 
+   * @return the capacity of handler store
+   * 
+   */
+  public long handlerCapacity() {
+    return m_nvmasvc.handlerCapacity(m_nid);
+  }
 
-    /**
-     * get the base address
-     *
-     * @return the base address
-     */
-    @Override
-    public long getBaseAddress() {
-	return b_addr;
-    }
+  /**
+   * calculate the portable address
+   *
+   * @param addr
+   *          the address to be calculated
+   *
+   * @return the portable address
+   */
+  @Override
+  public long getPortableAddress(long addr) {
+    return addr - b_addr;
+  }
 
-    /**
-     * set the base address for calculation
-     *
-     * @param addr 
-     *           the base address
-     *
-     */
-    @Override
-    public long setBaseAddress(long addr) {
-	return b_addr = addr;
-    }
+  /**
+   * calculate the effective address
+   *
+   * @param addr
+   *          the address to be calculated
+   *
+   * @return the effective address
+   */
+  @Override
+  public long getEffectiveAddress(long addr) {
+    return addr + b_addr;
+  }
+
+  /**
+   * get the base address
+   *
+   * @return the base address
+   */
+  @Override
+  public long getBaseAddress() {
+    return b_addr;
+  }
+
+  /**
+   * set the base address for calculation
+   *
+   * @param addr
+   *          the base address
+   *
+   */
+  @Override
+  public long setBaseAddress(long addr) {
+    return b_addr = addr;
+  }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/551c8247/core/src/main/java/org/apache/mnemonic/ByteBufferBackedInputStream.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/ByteBufferBackedInputStream.java b/core/src/main/java/org/apache/mnemonic/ByteBufferBackedInputStream.java
index 046472b..7a554dd 100644
--- a/core/src/main/java/org/apache/mnemonic/ByteBufferBackedInputStream.java
+++ b/core/src/main/java/org/apache/mnemonic/ByteBufferBackedInputStream.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.mnemonic;
 
 import java.io.IOException;
@@ -11,51 +28,51 @@ import java.nio.ByteBuffer;
  */
 public class ByteBufferBackedInputStream extends InputStream {
 
-    private ByteBuffer buf;
+  private ByteBuffer buf;
 
-    /**
-     * accept a ByteBuffer as backed object for inputStream.
-     * 
-     * @param buf
-     *            specify a bytebuffer that is where any data is from
-     */
-    public ByteBufferBackedInputStream(ByteBuffer buf) {
-	this.buf = buf;
-    }
+  /**
+   * accept a ByteBuffer as backed object for inputStream.
+   * 
+   * @param buf
+   *          specify a bytebuffer that is where any data is from
+   */
+  public ByteBufferBackedInputStream(ByteBuffer buf) {
+    this.buf = buf;
+  }
 
-    /**
-     * read an integer value from backed ByteBuffer.
-     * 
-     * @return a integer value from stream input
-     */
-    public int read() throws IOException {
-	if (!buf.hasRemaining()) {
-	    return -1;
-	}
-	return buf.get() & 0xFF;
+  /**
+   * read an integer value from backed ByteBuffer.
+   * 
+   * @return a integer value from stream input
+   */
+  public int read() throws IOException {
+    if (!buf.hasRemaining()) {
+      return -1;
     }
+    return buf.get() & 0xFF;
+  }
 
-    /**
-     * read a specified range of byte array from backed ByteBuffer.
-     * 
-     * @param bytes
-     *            specify a output byte array to store data
-     * 
-     * @param off
-     *            specify the offset from ByteBuffer to read
-     * 
-     * @param len
-     *            specify the length of bytes to read
-     * 
-     * @return the number of bytes has been read
-     */
-    public int read(byte[] bytes, int off, int len) throws IOException {
-	if (!buf.hasRemaining()) {
-	    return -1;
-	}
-
-	len = Math.min(len, buf.remaining());
-	buf.get(bytes, off, len);
-	return len;
+  /**
+   * read a specified range of byte array from backed ByteBuffer.
+   * 
+   * @param bytes
+   *          specify a output byte array to store data
+   * 
+   * @param off
+   *          specify the offset from ByteBuffer to read
+   * 
+   * @param len
+   *          specify the length of bytes to read
+   * 
+   * @return the number of bytes has been read
+   */
+  public int read(byte[] bytes, int off, int len) throws IOException {
+    if (!buf.hasRemaining()) {
+      return -1;
     }
+
+    len = Math.min(len, buf.remaining());
+    buf.get(bytes, off, len);
+    return len;
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/551c8247/core/src/main/java/org/apache/mnemonic/ByteBufferBackedOutputStream.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/ByteBufferBackedOutputStream.java b/core/src/main/java/org/apache/mnemonic/ByteBufferBackedOutputStream.java
index 6755444..2a1792d 100644
--- a/core/src/main/java/org/apache/mnemonic/ByteBufferBackedOutputStream.java
+++ b/core/src/main/java/org/apache/mnemonic/ByteBufferBackedOutputStream.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.mnemonic;
 
 import java.io.IOException;
@@ -11,46 +28,46 @@ import java.nio.ByteBuffer;
  */
 public class ByteBufferBackedOutputStream extends OutputStream {
 
-    private ByteBuffer buf;
-
-    /**
-     * accept a ByteBuffer to store external data, the capacity of it could be
-     * extended at will.
-     * 
-     * @param buf
-     *            specify a ByteBuffer object that is used to store external
-     *            data to its backed buffer
-     * 
-     */
-    public ByteBufferBackedOutputStream(ByteBuffer buf) {
-	this.buf = buf;
-    }
-
-    /**
-     * write an integer value to backed buffer.
-     * 
-     * @param b
-     *            specify an integer value to be written
-     */
-    public void write(int b) throws IOException {
-	buf.put((byte) b);
-    }
-
-    /**
-     * write an array of bytes to a specified range of backed buffer
-     * 
-     * @param bytes
-     *            specify a byte array to write
-     * 
-     * @param off
-     *            specify the offset of backed buffer where is start point to be
-     *            written
-     * 
-     * @param len
-     *            specify the length of bytes to be written
-     */
-    public void write(byte[] bytes, int off, int len) throws IOException {
-	buf.put(bytes, off, len);
-    }
+  private ByteBuffer buf;
+
+  /**
+   * accept a ByteBuffer to store external data, the capacity of it could be
+   * extended at will.
+   * 
+   * @param buf
+   *          specify a ByteBuffer object that is used to store external data to
+   *          its backed buffer
+   * 
+   */
+  public ByteBufferBackedOutputStream(ByteBuffer buf) {
+    this.buf = buf;
+  }
+
+  /**
+   * write an integer value to backed buffer.
+   * 
+   * @param b
+   *          specify an integer value to be written
+   */
+  public void write(int b) throws IOException {
+    buf.put((byte) b);
+  }
+
+  /**
+   * write an array of bytes to a specified range of backed buffer
+   * 
+   * @param bytes
+   *          specify a byte array to write
+   * 
+   * @param off
+   *          specify the offset of backed buffer where is start point to be
+   *          written
+   * 
+   * @param len
+   *          specify the length of bytes to be written
+   */
+  public void write(byte[] bytes, int off, int len) throws IOException {
+    buf.put(bytes, off, len);
+  }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/551c8247/core/src/main/java/org/apache/mnemonic/ByteBufferSerializer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/ByteBufferSerializer.java b/core/src/main/java/org/apache/mnemonic/ByteBufferSerializer.java
index 7ed9f05..b6371d5 100644
--- a/core/src/main/java/org/apache/mnemonic/ByteBufferSerializer.java
+++ b/core/src/main/java/org/apache/mnemonic/ByteBufferSerializer.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.mnemonic;
 
 import java.io.ByteArrayOutputStream;
@@ -15,135 +32,134 @@ import java.io.InputStream;
 
 public class ByteBufferSerializer {
 
-    /**
-     * serialize object to a ByteBuffer object.
-     * 
-     * @param <ValueT>
-     *           the type of object
-     * 
-     * @param obj
-     *            specify a object that is serializable
-     * 
-     * @throws IOException
-     *            the exception of serialization
-     * 
-     * @return a ByteBuffer object contained serialized object
-     */
-    public static <ValueT> ByteBuffer toByteBuffer(ValueT obj)
-	throws IOException {
-	byte[] bytes = null;
-	ByteArrayOutputStream bos = null;
-	ObjectOutputStream oos = null;
-	try {
-	    bos = new ByteArrayOutputStream();
-	    oos = new ObjectOutputStream(bos);
-	    oos.writeObject(obj);
-	    oos.flush();
-	    bytes = bos.toByteArray();
-	} finally {
-	    if (oos != null) {
-		oos.close();
-	    }
-	    if (bos != null) {
-		bos.close();
-	    }
-	}
-	return ByteBuffer.wrap(bytes);
+  /**
+   * serialize object to a ByteBuffer object.
+   * 
+   * @param <ValueT>
+   *          the type of object
+   * 
+   * @param obj
+   *          specify a object that is serializable
+   * 
+   * @throws IOException
+   *           the exception of serialization
+   * 
+   * @return a ByteBuffer object contained serialized object
+   */
+  public static <ValueT> ByteBuffer toByteBuffer(ValueT obj) throws IOException {
+    byte[] bytes = null;
+    ByteArrayOutputStream bos = null;
+    ObjectOutputStream oos = null;
+    try {
+      bos = new ByteArrayOutputStream();
+      oos = new ObjectOutputStream(bos);
+      oos.writeObject(obj);
+      oos.flush();
+      bytes = bos.toByteArray();
+    } finally {
+      if (oos != null) {
+        oos.close();
+      }
+      if (bos != null) {
+        bos.close();
+      }
     }
+    return ByteBuffer.wrap(bytes);
+  }
 
-    /**
-     * de-serialize an object from a ByteBuffer object.
-     * 
-     * @param <ValueT>
-     *           the type of object
-     * 
-     * @param bf
-     *            specify an ByteBuffer contains data that can be de-serialized
-     * 
-     * @throws IOException
-     *            the exception of deserialization
-     * 
-     * @throws ClassNotFoundException
-     *            Not found class of de-serialized object
-     * 
-     * @return a de-serialized object
-     */
-    @SuppressWarnings("unchecked")
-    public static <ValueT> ValueT toObject(ByteBuffer bf) throws IOException,
-								 ClassNotFoundException {
-	Object obj = null;
-	InputStream is = null;
-	ObjectInputStream ois = null;
-	try {
-	    is = new ByteBufferBackedInputStream(bf);
-	    ois = new ObjectInputStream(is);
-	    obj = ois.readObject();
-	} finally {
-	    if (is != null) {
-		is.close();
-	    }
-	    if (ois != null) {
-		ois.close();
-	    }
-	}
-	return (ValueT) obj;
+  /**
+   * de-serialize an object from a ByteBuffer object.
+   * 
+   * @param <ValueT>
+   *          the type of object
+   * 
+   * @param bf
+   *          specify an ByteBuffer contains data that can be de-serialized
+   * 
+   * @throws IOException
+   *           the exception of deserialization
+   * 
+   * @throws ClassNotFoundException
+   *           Not found class of de-serialized object
+   * 
+   * @return a de-serialized object
+   */
+  @SuppressWarnings("unchecked")
+  public static <ValueT> ValueT toObject(ByteBuffer bf) throws IOException, ClassNotFoundException {
+    Object obj = null;
+    InputStream is = null;
+    ObjectInputStream ois = null;
+    try {
+      is = new ByteBufferBackedInputStream(bf);
+      ois = new ObjectInputStream(is);
+      obj = ois.readObject();
+    } finally {
+      if (is != null) {
+        is.close();
+      }
+      if (ois != null) {
+        ois.close();
+      }
     }
+    return (ValueT) obj;
+  }
 
-    /**
-     * serialize object to a MemBufferHolder object.
-     * 
-     * @param <A> the type of bound allocator 
-     * 
-     * @param <ValueT>
-     *           the type of object
-     * 
-     * @param ar
-     *            specify an Allocator that is used to generate MemBufferHolder
-     *            which is backed by a native memory block
-     * 
-     * @param obj
-     *            specify a object that is serializable
-     * 
-     * @throws IOException
-     *            the exception of serialization
-     *  
-     * @return a MemBufferHolder object contained serialized object
-     */
-    public static <A extends CommonAllocator<A>, ValueT> MemBufferHolder<A> 
-			     toMemBufferHolder(A ar, ValueT obj) throws IOException {
-	MemBufferHolder<A> ret = null;
-	ByteBuffer bb = toByteBuffer(obj);
-	if (null != bb && bb.remaining() > 0) {
-	    ret = ar.createBuffer(bb.remaining());
-	    ret.get().put(bb);
-	    ret.get().flip();
-	}
-	return ret;
+  /**
+   * serialize object to a MemBufferHolder object.
+   * 
+   * @param <A>
+   *          the type of bound allocator
+   * 
+   * @param <ValueT>
+   *          the type of object
+   * 
+   * @param ar
+   *          specify an Allocator that is used to generate MemBufferHolder
+   *          which is backed by a native memory block
+   * 
+   * @param obj
+   *          specify a object that is serializable
+   * 
+   * @throws IOException
+   *           the exception of serialization
+   * 
+   * @return a MemBufferHolder object contained serialized object
+   */
+  public static <A extends CommonAllocator<A>, ValueT> MemBufferHolder<A> toMemBufferHolder(A ar, ValueT obj)
+      throws IOException {
+    MemBufferHolder<A> ret = null;
+    ByteBuffer bb = toByteBuffer(obj);
+    if (null != bb && bb.remaining() > 0) {
+      ret = ar.createBuffer(bb.remaining());
+      ret.get().put(bb);
+      ret.get().flip();
     }
+    return ret;
+  }
 
-    /**
-     * de-serialize an object from a MemBufferHolder object.
-     * 
-     * @param <A> the type of bound allocator 
-     * 
-     * @param <ValueT>
-     *           the type of object
-     * 
-     * @param mbh
-     *            specify an MemBufferHolder who contains data that can be
-     *            de-serialized
-     *            
-     * @throws IOException
-     *            the exception of deserialization
-     * 
-     * @throws ClassNotFoundException
-     *            Not found class of de-serialized object
-     * 
-     * @return a de-serialized object
-     */
-    public static <A extends CommonAllocator<A>, ValueT> ValueT 
-			     fromMemBufferHolder(MemBufferHolder<A> mbh)
-	throws IOException, ClassNotFoundException {
-	return toObject(mbh.get());
-    }
+  /**
+   * de-serialize an object from a MemBufferHolder object.
+   * 
+   * @param <A>
+   *          the type of bound allocator
+   * 
+   * @param <ValueT>
+   *          the type of object
+   * 
+   * @param mbh
+   *          specify an MemBufferHolder who contains data that can be
+   *          de-serialized
+   * 
+   * @throws IOException
+   *           the exception of deserialization
+   * 
+   * @throws ClassNotFoundException
+   *           Not found class of de-serialized object
+   * 
+   * @return a de-serialized object
+   */
+  public static <A extends CommonAllocator<A>, ValueT> ValueT fromMemBufferHolder(MemBufferHolder<A> mbh)
+      throws IOException, ClassNotFoundException {
+    return toObject(mbh.get());
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/551c8247/core/src/main/java/org/apache/mnemonic/CachePool.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/CachePool.java b/core/src/main/java/org/apache/mnemonic/CachePool.java
index 8a9af75..37a87ee 100644
--- a/core/src/main/java/org/apache/mnemonic/CachePool.java
+++ b/core/src/main/java/org/apache/mnemonic/CachePool.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.mnemonic;
 
 import java.util.Set;
@@ -11,134 +28,126 @@ import java.util.Map;
  * 
  * 
  */
-public abstract class CachePool<KeyT, ValueT> extends
-						  LinkedHashMap<KeyT, ValueT> {
+public abstract class CachePool<KeyT, ValueT> extends LinkedHashMap<KeyT, ValueT> {
 
-    /**
-     * 
-     */
-    private static final long serialVersionUID = 1L;
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 1L;
 
-    public CachePool(int initialCapacity, float loadFactor) {
-	super(initialCapacity, loadFactor);
-    }
+  public CachePool(int initialCapacity, float loadFactor) {
+    super(initialCapacity, loadFactor);
+  }
 
-    /**
-     * Return available capacity for new entries.
-     * 
-     * @return available capacity in this cache pool
-     */
-    public abstract long freeCapacity();
+  /**
+   * Return available capacity for new entries.
+   * 
+   * @return available capacity in this cache pool
+   */
+  public abstract long freeCapacity();
 
-    /**
-     * Return the used capacity of cached entries.
-     * 
-     * @return the used size of this cache pool
-     */
-    public abstract long usedCapacity();
+  /**
+   * Return the used capacity of cached entries.
+   * 
+   * @return the used size of this cache pool
+   */
+  public abstract long usedCapacity();
 
-    /**
-     * Put an entry in this cache pool and evict eldest entries if necessary
-     * that will free enough space to hold new entry, which entry could be
-     * evicted that can be customized by ({@link EvictFilter}), regarding how
-     * to post-process the eldest entry that can be customized by (
-     * {@link DropEvent}). If this cache pool previously contained an entry for
-     * the key, the old value will be replaced by the specified value
-     * 
-     * @param k
-     *            the key whoes associated value is to be put
-     * 
-     * @param v
-     *            the value to be put
-     * 
-     * @param fsop
-     *            the customized operations to free space to hold new entry
-     * 
-     * @param dfilter
-     *            the filter of entries for deletion
-     * 
-     * @return <tt>true</tt> if the entry has been put into this container
-     * 
-     */
-    public abstract ValueT put(KeyT k, ValueT v, DropEvent<KeyT, ValueT> fsop,
-			       EvictFilter<KeyT, ValueT> dfilter);
+  /**
+   * Put an entry in this cache pool and evict eldest entries if necessary that
+   * will free enough space to hold new entry, which entry could be evicted that
+   * can be customized by ({@link EvictFilter}), regarding how to post-process
+   * the eldest entry that can be customized by ( {@link DropEvent}). If this
+   * cache pool previously contained an entry for the key, the old value will be
+   * replaced by the specified value
+   * 
+   * @param k
+   *          the key whoes associated value is to be put
+   * 
+   * @param v
+   *          the value to be put
+   * 
+   * @param fsop
+   *          the customized operations to free space to hold new entry
+   * 
+   * @param dfilter
+   *          the filter of entries for deletion
+   * 
+   * @return <tt>true</tt> if the entry has been put into this container
+   * 
+   */
+  public abstract ValueT put(KeyT k, ValueT v, DropEvent<KeyT, ValueT> fsop, EvictFilter<KeyT, ValueT> dfilter);
 
-    /**
-     * Put all entries into this cache pool and evict eldes entries if
-     * necessary.
-     * 
-     * @param m
-     *            the Map object that contains entries to be put
-     * 
-     * @param fsop
-     *            the customized operations to free space to hold new entry
-     * 
-     * @param dfilter
-     *            the filter of entries for deletion
-     * 
-     */
-    public abstract void putAll(
-				Map<? extends KeyT, ? extends ValueT> m,
-				DropEvent<KeyT, ValueT> fsop,
-				EvictFilter<KeyT, ValueT> dfilter);
+  /**
+   * Put all entries into this cache pool and evict eldes entries if necessary.
+   * 
+   * @param m
+   *          the Map object that contains entries to be put
+   * 
+   * @param fsop
+   *          the customized operations to free space to hold new entry
+   * 
+   * @param dfilter
+   *          the filter of entries for deletion
+   * 
+   */
+  public abstract void putAll(Map<? extends KeyT, ? extends ValueT> m, DropEvent<KeyT, ValueT> fsop,
+      EvictFilter<KeyT, ValueT> dfilter);
 
-    /**
-     * Returns a new {@link Set} view of the keys of this cache pool, It
-     * contains the most recently visited keys
-     * 
-     * @param n
-     *            the number of keys to retrieve
-     * 
-     * @return a set of hot keys
-     */
-    public abstract Set<KeyT> hotKeySet(int n);
+  /**
+   * Returns a new {@link Set} view of the keys of this cache pool, It contains
+   * the most recently visited keys
+   * 
+   * @param n
+   *          the number of keys to retrieve
+   * 
+   * @return a set of hot keys
+   */
+  public abstract Set<KeyT> hotKeySet(int n);
 
-    /**
-     * Ensure the free capacity is greater than the specified size
-     * 
-     * @param freesz
-     *            the size of free capacity that needs to be secured
-     * 
-     * @return <tt>true</tt> if the size of free capacity is greater than the
-     *         specified size after evacuation
-     * 
-     * @see #ensureFreeSpace(long, DropEvent, EvictFilter)
-     */
-    public abstract boolean ensureFreeSpace(long freesz);
+  /**
+   * Ensure the free capacity is greater than the specified size
+   * 
+   * @param freesz
+   *          the size of free capacity that needs to be secured
+   * 
+   * @return <tt>true</tt> if the size of free capacity is greater than the
+   *         specified size after evacuation
+   * 
+   * @see #ensureFreeSpace(long, DropEvent, EvictFilter)
+   */
+  public abstract boolean ensureFreeSpace(long freesz);
 
-    /**
-     * Removes a first qualified entry in this cache pool
-     * 
-     * @param fsop
-     *            the customized callback to post-process its evicted entry
-     * 
-     * @param dfilter
-     *            the filter for entry deletion
-     * 
-     * @return <tt>true</tt> if there is one qualified entry that has been
-     *         dropped
-     */
-    public abstract boolean removeFirstEntry(DropEvent<KeyT, ValueT> fsop,
-					     EvictFilter<KeyT, ValueT> dfilter);
+  /**
+   * Removes a first qualified entry in this cache pool
+   * 
+   * @param fsop
+   *          the customized callback to post-process its evicted entry
+   * 
+   * @param dfilter
+   *          the filter for entry deletion
+   * 
+   * @return <tt>true</tt> if there is one qualified entry that has been dropped
+   */
+  public abstract boolean removeFirstEntry(DropEvent<KeyT, ValueT> fsop, EvictFilter<KeyT, ValueT> dfilter);
 
-    /**
-     * Ensure the size of free capacity is greater than the specified size, the
-     * entries will be filtered by {@link EvictFilter} before dropping, the
-     * {@link DropEvent} is used for post-processing
-     * 
-     * @param freesz
-     *            the size of free capacity that needs to be secured
-     * 
-     * @param fsop
-     *            the customized operations to free space to hold new entry
-     * 
-     * @param dfilter
-     *            the filter of entries for deletion
-     * 
-     * @return <tt>true</tt> if the size of free capacity is greater than the
-     *         specified size after evication if necessary
-     */
-    public abstract boolean ensureFreeSpace(long freesz,
-					    DropEvent<KeyT, ValueT> fsop, EvictFilter<KeyT, ValueT> dfilter);
+  /**
+   * Ensure the size of free capacity is greater than the specified size, the
+   * entries will be filtered by {@link EvictFilter} before dropping, the
+   * {@link DropEvent} is used for post-processing
+   * 
+   * @param freesz
+   *          the size of free capacity that needs to be secured
+   * 
+   * @param fsop
+   *          the customized operations to free space to hold new entry
+   * 
+   * @param dfilter
+   *          the filter of entries for deletion
+   * 
+   * @return <tt>true</tt> if the size of free capacity is greater than the
+   *         specified size after evication if necessary
+   */
+  public abstract boolean ensureFreeSpace(long freesz, DropEvent<KeyT, ValueT> fsop, EvictFilter<KeyT, ValueT> dfilter);
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/551c8247/core/src/main/java/org/apache/mnemonic/CommonAllocator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/CommonAllocator.java b/core/src/main/java/org/apache/mnemonic/CommonAllocator.java
index 20a584b..643704c 100644
--- a/core/src/main/java/org/apache/mnemonic/CommonAllocator.java
+++ b/core/src/main/java/org/apache/mnemonic/CommonAllocator.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.mnemonic;
 
 import java.nio.ByteBuffer;
@@ -11,94 +28,94 @@ import org.flowcomputing.commons.resgc.ResCollector;
  */
 public abstract class CommonAllocator<A extends CommonAllocator<A>> implements Allocator<A> {
 
-    protected Reclaim<Long> m_chunkreclaimer = null;
-    protected Reclaim<ByteBuffer> m_bufferreclaimer = null;
-	
-    protected ResCollector<MemChunkHolder<A>, Long> m_chunkcollector = null;
-    protected ResCollector<MemBufferHolder<A>, ByteBuffer> m_bufcollector = null;
-    
-    /**
-     * set a reclaimer to reclaim memory buffer
-     * 
-     * @param reclaimer
-     *            specify a reclaimer to accept reclaim request
-     */
-    public void setBufferReclaimer(Reclaim<ByteBuffer> reclaimer) {
-	m_bufferreclaimer = reclaimer;
-    }
+  protected Reclaim<Long> m_chunkreclaimer = null;
+  protected Reclaim<ByteBuffer> m_bufferreclaimer = null;
 
-    /**
-     * set a reclaimer to reclaim memory chunk
-     * 
-     * @param reclaimer
-     *            specify a reclaimer to accept reclaim request
-     */
-    public void setChunkReclaimer(Reclaim<Long> reclaimer) {
-	m_chunkreclaimer = reclaimer;
-    }
-	
-    /**
-     * create a memory chunk that is managed by its holder.
-     * 
-     * @param size
-     *            specify the size of memory chunk
-     * 
-     * @return a holder contains a memory chunk
-     */
-    @Override
-    public MemChunkHolder<A> createChunk(long size) {
-	return createChunk(size, true);
-    }
+  protected ResCollector<MemChunkHolder<A>, Long> m_chunkcollector = null;
+  protected ResCollector<MemBufferHolder<A>, ByteBuffer> m_bufcollector = null;
 
-    /**
-     * create a memory buffer that is managed by its holder.
-     * 
-     * @param size
-     *            specify the size of memory buffer
-     * 
-     * @return a holder contains a memory buffer
-     */
-    @Override
-    public MemBufferHolder<A> createBuffer(long size) {
-	return createBuffer(size, true);
-    }
+  /**
+   * set a reclaimer to reclaim memory buffer
+   * 
+   * @param reclaimer
+   *          specify a reclaimer to accept reclaim request
+   */
+  public void setBufferReclaimer(Reclaim<ByteBuffer> reclaimer) {
+    m_bufferreclaimer = reclaimer;
+  }
 
-    /**
-     * register a memory chunk for auto-reclaim
-     *
-     * @param mholder
-     *           specify a chunk holder to register
-     */
-    @Override
-    public void registerChunkAutoReclaim(MemChunkHolder<A> mholder) {
-	m_chunkcollector.register(mholder);
-    }
+  /**
+   * set a reclaimer to reclaim memory chunk
+   * 
+   * @param reclaimer
+   *          specify a reclaimer to accept reclaim request
+   */
+  public void setChunkReclaimer(Reclaim<Long> reclaimer) {
+    m_chunkreclaimer = reclaimer;
+  }
 
-    /**
-     * register a memory buffer for auto-reclaim
-     *
-     * @param mholder
-     *           specify a buffer holder to register
-     */
-    @Override
-    public void registerBufferAutoReclaim(MemBufferHolder<A> mholder) {
-	m_bufcollector.register(mholder);
-    }
+  /**
+   * create a memory chunk that is managed by its holder.
+   * 
+   * @param size
+   *          specify the size of memory chunk
+   * 
+   * @return a holder contains a memory chunk
+   */
+  @Override
+  public MemChunkHolder<A> createChunk(long size) {
+    return createChunk(size, true);
+  }
+
+  /**
+   * create a memory buffer that is managed by its holder.
+   * 
+   * @param size
+   *          specify the size of memory buffer
+   * 
+   * @return a holder contains a memory buffer
+   */
+  @Override
+  public MemBufferHolder<A> createBuffer(long size) {
+    return createBuffer(size, true);
+  }
+
+  /**
+   * register a memory chunk for auto-reclaim
+   *
+   * @param mholder
+   *          specify a chunk holder to register
+   */
+  @Override
+  public void registerChunkAutoReclaim(MemChunkHolder<A> mholder) {
+    m_chunkcollector.register(mholder);
+  }
 
-    /**
-     * close both of resource collectors for this allocator
-     *
-     */
-    @Override
-    public void close() {
-	if (null != m_chunkcollector) {
-	    m_chunkcollector.close();
-	    m_chunkcollector = null;
-	}
-	if (null != m_bufcollector) {
-	    m_bufcollector.close();
-	    m_bufcollector = null;
-	}
+  /**
+   * register a memory buffer for auto-reclaim
+   *
+   * @param mholder
+   *          specify a buffer holder to register
+   */
+  @Override
+  public void registerBufferAutoReclaim(MemBufferHolder<A> mholder) {
+    m_bufcollector.register(mholder);
+  }
+
+  /**
+   * close both of resource collectors for this allocator
+   *
+   */
+  @Override
+  public void close() {
+    if (null != m_chunkcollector) {
+      m_chunkcollector.close();
+      m_chunkcollector = null;
+    }
+    if (null != m_bufcollector) {
+      m_bufcollector.close();
+      m_bufcollector = null;
     }
-	
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/551c8247/core/src/main/java/org/apache/mnemonic/CommonPersistAllocator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/CommonPersistAllocator.java b/core/src/main/java/org/apache/mnemonic/CommonPersistAllocator.java
index 6e0374d..afc7e02 100644
--- a/core/src/main/java/org/apache/mnemonic/CommonPersistAllocator.java
+++ b/core/src/main/java/org/apache/mnemonic/CommonPersistAllocator.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.mnemonic;
 
 /**
@@ -6,115 +23,118 @@ package org.apache.mnemonic;
  *
  */
 public abstract class CommonPersistAllocator<A extends CommonAllocator<A>> extends CommonAllocator<A> {
-    
-    /**
-     * determine whether the allocator supports transaction feature or not
-     *
-     * @return true if supported
-     */
-    public boolean supportTransaction() {
-	return false;
-    }
 
-    /**
-     * determine whether the allocator does atomic operations on memory pool
-     *
-     * @return true if it is
-     *
-     */
-    public boolean isAtomicOperation() {
-	return false;
-    }
+  /**
+   * determine whether the allocator supports transaction feature or not
+   *
+   * @return true if supported
+   */
+  public boolean supportTransaction() {
+    return false;
+  }
+
+  /**
+   * determine whether the allocator does atomic operations on memory pool
+   *
+   * @return true if it is
+   *
+   */
+  public boolean isAtomicOperation() {
+    return false;
+  }
 
-    /**
-     * determine whether this allocator supports to store non-volatile handler or not
-     *
-     * @return true if there is
-     */
-    public boolean hasNonVolatileHandlerStore() {
-	return false;
-    }
+  /**
+   * determine whether this allocator supports to store non-volatile handler or
+   * not
+   *
+   * @return true if there is
+   */
+  public boolean hasNonVolatileHandlerStore() {
+    return false;
+  }
 
-    /**
-     * retrieve a memory buffer from its backed memory allocator.
-     * 
-     * @param phandler
-     *            specify the handler of memory buffer to retrieve
-     *
-     * @return a holder contains the retrieved memory buffer
-     */
-    public MemBufferHolder<A> retrieveBuffer(long phandler) {
-	return retrieveBuffer(phandler, true);
-    }
+  /**
+   * retrieve a memory buffer from its backed memory allocator.
+   * 
+   * @param phandler
+   *          specify the handler of memory buffer to retrieve
+   *
+   * @return a holder contains the retrieved memory buffer
+   */
+  public MemBufferHolder<A> retrieveBuffer(long phandler) {
+    return retrieveBuffer(phandler, true);
+  }
 
-    /**
-     * retrieve a memory chunk from its backed memory allocator.
-     * 
-     * @param phandler
-     *            specify the handler of memory chunk to retrieve
-     *
-     * @return a holder contains the retrieved memory chunk
-     */
-    public MemChunkHolder<A>  retrieveChunk(long phandler) {
-	return retrieveChunk(phandler, true);
-    }
+  /**
+   * retrieve a memory chunk from its backed memory allocator.
+   * 
+   * @param phandler
+   *          specify the handler of memory chunk to retrieve
+   *
+   * @return a holder contains the retrieved memory chunk
+   */
+  public MemChunkHolder<A> retrieveChunk(long phandler) {
+    return retrieveChunk(phandler, true);
+  }
 
-    /**
-     * retrieve a memory buffer from its backed memory allocator.
-     * 
-     * @param phandler
-     *            specify the handler of memory buffer to retrieve
-     *
-     * @param autoreclaim
-     *            specify whether this retrieved memory buffer can be reclaimed automatically or not
-     * 
-     * @return a holder contains the retrieved memory buffer
-     */
-    abstract public MemBufferHolder<A> retrieveBuffer(long phandler, boolean autoreclaim);
+  /**
+   * retrieve a memory buffer from its backed memory allocator.
+   * 
+   * @param phandler
+   *          specify the handler of memory buffer to retrieve
+   *
+   * @param autoreclaim
+   *          specify whether this retrieved memory buffer can be reclaimed
+   *          automatically or not
+   * 
+   * @return a holder contains the retrieved memory buffer
+   */
+  abstract public MemBufferHolder<A> retrieveBuffer(long phandler, boolean autoreclaim);
 
-    /**
-     * retrieve a memory chunk from its backed memory allocator.
-     * 
-     * @param phandler
-     *            specify the handler of memory chunk to retrieve
-     *
-     * @param autoreclaim
-     *            specify whether this retrieved memory chunk can be reclaimed automatically or not
-     * 
-     * @return a holder contains the retrieved memory chunk
-     */
-    abstract public MemChunkHolder<A>  retrieveChunk(long phandler, boolean autoreclaim);
+  /**
+   * retrieve a memory chunk from its backed memory allocator.
+   * 
+   * @param phandler
+   *          specify the handler of memory chunk to retrieve
+   *
+   * @param autoreclaim
+   *          specify whether this retrieved memory chunk can be reclaimed
+   *          automatically or not
+   * 
+   * @return a holder contains the retrieved memory chunk
+   */
+  abstract public MemChunkHolder<A> retrieveChunk(long phandler, boolean autoreclaim);
 
-    /**
-     * get the handler from a memory buffer holder.
-     * 
-     * @param mbuf
-     *            specify the memory buffer holder
-     *
-     * @return a handler that could be used to retrieve its memory buffer
-     */
-    abstract public long getBufferHandler(MemBufferHolder<A> mbuf);
+  /**
+   * get the handler from a memory buffer holder.
+   * 
+   * @param mbuf
+   *          specify the memory buffer holder
+   *
+   * @return a handler that could be used to retrieve its memory buffer
+   */
+  abstract public long getBufferHandler(MemBufferHolder<A> mbuf);
 
-    /**
-     * get the handler from a memory chunk holder.
-     * 
-     * @param mchunk
-     *            specify the memory chunk holder
-     *
-     * @return a handler that could be used to retrieve its memory chunk
-     */
-    abstract public long getChunkHandler(MemChunkHolder<A> mchunk);
+  /**
+   * get the handler from a memory chunk holder.
+   * 
+   * @param mchunk
+   *          specify the memory chunk holder
+   *
+   * @return a handler that could be used to retrieve its memory chunk
+   */
+  abstract public long getChunkHandler(MemChunkHolder<A> mchunk);
 
-    /**
-     * start a application level transaction on this allocator.
-     *
-     */
-    abstract public void beginTransaction();
+  /**
+   * start a application level transaction on this allocator.
+   *
+   */
+  abstract public void beginTransaction();
 
-    /**
-     * end a application level transaction on this allocator.
-     *
-     */
-    abstract public void endTransaction();
+  /**
+   * end a application level transaction on this allocator.
+   *
+   */
+  abstract public void endTransaction();
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/551c8247/core/src/main/java/org/apache/mnemonic/ContainerOverflowException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/ContainerOverflowException.java b/core/src/main/java/org/apache/mnemonic/ContainerOverflowException.java
index d6c053a..1791602 100644
--- a/core/src/main/java/org/apache/mnemonic/ContainerOverflowException.java
+++ b/core/src/main/java/org/apache/mnemonic/ContainerOverflowException.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.mnemonic;
 
 /**
@@ -6,15 +23,15 @@ package org.apache.mnemonic;
  */
 public class ContainerOverflowException extends RuntimeException {
 
-    private static final long serialVersionUID = -8515518456414990004L;
+  private static final long serialVersionUID = -8515518456414990004L;
 
-    /**
-     * accept a exception message to describe specific condition.
-     * 
-     * @param message
-     *            exception message
-     */
-    public ContainerOverflowException(String message) {
-	super(message);
-    }
+  /**
+   * accept a exception message to describe specific condition.
+   * 
+   * @param message
+   *          exception message
+   */
+  public ContainerOverflowException(String message) {
+    super(message);
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/551c8247/core/src/main/java/org/apache/mnemonic/DropEvent.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/DropEvent.java b/core/src/main/java/org/apache/mnemonic/DropEvent.java
index b3ca93f..f1bfa9c 100644
--- a/core/src/main/java/org/apache/mnemonic/DropEvent.java
+++ b/core/src/main/java/org/apache/mnemonic/DropEvent.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.mnemonic;
 
 /**
@@ -6,19 +23,19 @@ package org.apache.mnemonic;
  * 
  */
 public interface DropEvent<KeyT, ValueT> {
-    /**
-     * A call-back actor when an entry has been evicted. a customized drop
-     * action can be implemented on this interface's method e.g. spill this
-     * entry to disk or release associated resources etc.
-     * 
-     * @param pool
-     *            the pool which an entry has been evicted from
-     *            
-     * @param k
-     *            the key of an entry that has been evicted
-     *            
-     * @param v
-     *            the value of an entry that has been evicted
-     */
-    public void drop(CachePool<KeyT, ValueT> pool, KeyT k, ValueT v);
+  /**
+   * A call-back actor when an entry has been evicted. a customized drop action
+   * can be implemented on this interface's method e.g. spill this entry to disk
+   * or release associated resources etc.
+   * 
+   * @param pool
+   *          the pool which an entry has been evicted from
+   * 
+   * @param k
+   *          the key of an entry that has been evicted
+   * 
+   * @param v
+   *          the value of an entry that has been evicted
+   */
+  public void drop(CachePool<KeyT, ValueT> pool, KeyT k, ValueT v);
 }