diff --git a/asterix-maven-plugins/pom.xml b/asterix-maven-plugins/pom.xml
index 56bc697..b26a6d6 100644
--- a/asterix-maven-plugins/pom.xml
+++ b/asterix-maven-plugins/pom.xml
@@ -35,5 +35,6 @@
 
   <modules>
     <module>lexer-generator-maven-plugin</module>
+    <module>record-manager-generator-maven-plugin</module>
   </modules>
 </project>
diff --git a/asterix-maven-plugins/record-manager-generator-maven-plugin/pom.xml b/asterix-maven-plugins/record-manager-generator-maven-plugin/pom.xml
new file mode 100644
index 0000000..9ffc8d2
--- /dev/null
+++ b/asterix-maven-plugins/record-manager-generator-maven-plugin/pom.xml
@@ -0,0 +1,56 @@
+<!--
+ ! Copyright 2009-2013 by The Regents of the University of California
+ ! Licensed 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 from
+ ! 
+ !     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.
+ !-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>edu.uci.ics.asterix</groupId>
+  <artifactId>record-manager-generator-maven-plugin</artifactId>
+    <parent>
+        <artifactId>asterix-maven-plugins</artifactId>
+        <groupId>edu.uci.ics.asterix</groupId>
+        <version>0.8.1-SNAPSHOT</version>
+    </parent>
+
+  <packaging>maven-plugin</packaging>
+  <name>record-manager-generator-maven-plugin</name>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.0.2</version>
+        <configuration>
+          <source>1.7</source>
+          <target>1.7</target>
+          <fork>true</fork>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.8.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0.2</version>
+    </dependency>
+  </dependencies>    
+</project>
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/Generator.java b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/recordmanagergenerator/Generator.java
similarity index 74%
rename from asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/Generator.java
rename to asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/recordmanagergenerator/Generator.java
index a87d321..66f366e 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/Generator.java
+++ b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/recordmanagergenerator/Generator.java
@@ -1,13 +1,34 @@
-package edu.uci.ics.asterix.transaction.management.service.locking;
+/*
+ * Copyright 2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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 edu.uci.ics.asterix.recordmanagergenerator;
 
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 
-import edu.uci.ics.asterix.transaction.management.service.locking.RecordType.Field;
+import edu.uci.ics.asterix.recordmanagergenerator.RecordType.Field;
 
 public class Generator {
+    
+    public enum Manager {
+        RECORD,
+        ARENA
+    }
+    
     public static void main(String args[]) {
         
         RecordType resource = new RecordType("Resource");
@@ -30,19 +51,28 @@
         
         StringBuilder sb = new StringBuilder();
 
-        generateMemoryManagerSource(request, sb);
+        //generateMemoryManagerSource(request, sb);
         //generateMemoryManagerSource(resource, sb);
         //generateArenaManagerSource(request, sb);
         //generateArenaManagerSource(resource, sb);
 
         System.out.println(sb.toString());
     }
+    
+    public static void generateSource(Manager mgr, RecordType rec, InputStream is, StringBuilder sb) {
+        switch (mgr) {
+            case RECORD:
+                generateMemoryManagerSource(rec, is, sb);
+                break;
+            case ARENA:
+                generateArenaManagerSource(rec, is, sb);
+                break;
+            default:
+                throw new IllegalArgumentException();
+        }        
+    }
 
-    private static void generateMemoryManagerSource(RecordType resource, StringBuilder sb) {
-        InputStream is = resource.getClass().getResourceAsStream("StructuredMemoryManager.java.txt");
-        if (is == null) {
-            throw new IllegalStateException();
-        }
+    private static void generateMemoryManagerSource(RecordType resource, InputStream is, StringBuilder sb) {
         BufferedReader in = new BufferedReader(new InputStreamReader(is));
         String line = null;
 
@@ -83,11 +113,7 @@
         }
     }
 
-    private static void generateArenaManagerSource(RecordType resource, StringBuilder sb) {
-        InputStream is = resource.getClass().getResourceAsStream("ArenaManager.java.txt");
-        if (is == null) {
-            throw new IllegalStateException();
-        }
+    private static void generateArenaManagerSource(RecordType resource, InputStream is, StringBuilder sb) {
         BufferedReader in = new BufferedReader(new InputStreamReader(is));
         String line = null;
 
diff --git a/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/recordmanagergenerator/RecordManagerGeneratorMojo.java b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/recordmanagergenerator/RecordManagerGeneratorMojo.java
new file mode 100644
index 0000000..7c932f4
--- /dev/null
+++ b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/recordmanagergenerator/RecordManagerGeneratorMojo.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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 edu.uci.ics.asterix.recordmanagergenerator;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * @goal generate-record-manager
+ * @phase generate-sources
+ * @requiresDependencyResolution compile
+ */
+public class RecordManagerGeneratorMojo extends AbstractMojo {
+    /**
+     * parameter injected from pom.xml
+     * 
+     * @parameter
+     */
+    private String arenaManagerTemplate;
+    /**
+     * parameter injected from pom.xml
+     * 
+     * @parameter
+     */
+    private String recordManagerTemplate;
+    /**
+     * parameter injected from pom.xml
+     * 
+     * @parameter
+     * @required
+     */
+    private String[] recordTypes;
+    /**
+     * parameter injected from pom.xml
+     * 
+     * @parameter
+     * @required
+     */
+    private File outputDir;
+
+    private Map<String, RecordType> typeMap;
+
+    public RecordManagerGeneratorMojo() {
+        typeMap = new HashMap<String, RecordType>();
+
+        RecordType resource = new RecordType("Resource");
+        resource.addField("last holder", RecordType.Type.INT, "-1");
+        resource.addField("first waiter", RecordType.Type.INT, "-1");
+        resource.addField("first upgrader", RecordType.Type.INT, "-1");
+        resource.addField("max mode", RecordType.Type.INT, "LockMode.NL");
+        resource.addField("dataset id", RecordType.Type.INT, null);
+        resource.addField("pk hash val", RecordType.Type.INT, null);
+        resource.addField("next", RecordType.Type.INT, null);
+
+        typeMap.put(resource.name, resource);
+
+        RecordType request = new RecordType("Request");
+        request.addField("resource id", RecordType.Type.INT, null);
+        request.addField("lock mode", RecordType.Type.INT, null);
+        request.addField("job id", RecordType.Type.INT, null);
+        request.addField("prev job request", RecordType.Type.INT, null);
+        request.addField("next job request", RecordType.Type.INT, null);
+        request.addField("next request", RecordType.Type.INT, null);
+
+        typeMap.put(request.name, request);
+    }
+
+    public void execute() throws MojoExecutionException {
+        if (!outputDir.exists()) {
+            outputDir.mkdirs();
+        }
+
+        for (int i = 0; i < recordTypes.length; ++i) {
+            final String recordType = recordTypes[i];
+
+            if (recordManagerTemplate != null) {
+                generateSource(Generator.Manager.RECORD, recordManagerTemplate, recordType);
+            }
+
+            if (arenaManagerTemplate != null) {
+                generateSource(Generator.Manager.ARENA, arenaManagerTemplate, recordType);
+            }
+        }
+    }
+
+    private void generateSource(Generator.Manager mgrType, String template, String recordType) {
+        try {
+            InputStream is = getClass().getClassLoader().getResourceAsStream(template);
+            if (is == null) {
+                throw new IllegalStateException();
+            }
+
+            StringBuilder sb = new StringBuilder();
+            Generator.generateSource(mgrType, typeMap.get(recordType), is, sb);
+
+            is.close();
+
+            File outputFile = new File(outputDir, recordType + template);
+            getLog().info("generating " + outputFile.toString());
+
+            FileWriter outWriter = new FileWriter(outputFile);
+            outWriter.write(sb.toString());
+            outWriter.close();
+        } catch (IOException ioe) {
+            ioe.printStackTrace();
+        }
+    }
+}
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/RecordType.java b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/recordmanagergenerator/RecordType.java
similarity index 93%
rename from asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/RecordType.java
rename to asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/recordmanagergenerator/RecordType.java
index 0b6c255..5212885 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/RecordType.java
+++ b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/recordmanagergenerator/RecordType.java
@@ -1,4 +1,19 @@
-package edu.uci.ics.asterix.transaction.management.service.locking;
+/*
+ * Copyright 2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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 edu.uci.ics.asterix.recordmanagergenerator;
 
 import java.util.ArrayList;
 
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/ArenaManager.java.txt b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/ArenaManager.java
similarity index 65%
rename from asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/ArenaManager.java.txt
rename to asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/ArenaManager.java
index cf14280..744b0f9 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/ArenaManager.java.txt
+++ b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/ArenaManager.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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 edu.uci.ics.asterix.transaction.management.service.locking;
 
 import java.util.ArrayList;
@@ -5,13 +20,13 @@
 public class @E@ArenaManager {
     
     private final int noArenas;
-    private ArrayList<@E@MemoryManager> arenas;
+    private ArrayList<@E@RecordManager> arenas;
     private volatile int nextArena; 
     private ThreadLocal<LocalManager> local;    
     
     public @E@ArenaManager() {
         noArenas = Runtime.getRuntime().availableProcessors() * 2;
-        arenas = new ArrayList<@E@MemoryManager>(noArenas);
+        arenas = new ArrayList<@E@RecordManager>(noArenas);
         nextArena = 0;
         local = new ThreadLocal<LocalManager>() {
             @Override
@@ -43,9 +58,9 @@
     
     public synchronized LocalManager getNext() {
         if (nextArena >= arenas.size()) { 
-            arenas.add(new @E@MemoryManager());
+            arenas.add(new @E@RecordManager());
         }
-        @E@MemoryManager mgr = arenas.get(nextArena);
+        @E@RecordManager mgr = arenas.get(nextArena);
         LocalManager res = new LocalManager();
         res.mgr = mgr;
         res.arenaId = nextArena;
@@ -53,11 +68,11 @@
         return res;
     }
     
-    public @E@MemoryManager get(int i) {
+    public @E@RecordManager get(int i) {
         return arenas.get(i);
     }
     
-    public @E@MemoryManager local() {
+    public @E@RecordManager local() {
         return local.get().mgr;
     }
     
@@ -65,7 +80,7 @@
     
     static class LocalManager {
         int arenaId;
-        @E@MemoryManager mgr;
+        @E@RecordManager mgr;
     }
     
     StringBuffer append(StringBuffer sb) {
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/StructuredMemoryManager.java.txt b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/RecordManager.java
similarity index 90%
rename from asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/StructuredMemoryManager.java.txt
rename to asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/RecordManager.java
index 0f82d72..c8c64ab 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/StructuredMemoryManager.java.txt
+++ b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/RecordManager.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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 edu.uci.ics.asterix.transaction.management.service.locking;
 
 import java.nio.ByteBuffer;
@@ -5,7 +20,7 @@
 
 import edu.uci.ics.asterix.transaction.management.service.transaction.TransactionManagementConstants.LockManagerConstants.LockMode;
 
-public class @E@MemoryManager {
+public class @E@RecordManager {
 
     public static final int SHRINK_TIMER_THRESHOLD = 120000; //2min
 
@@ -20,7 +35,7 @@
     private long shrinkTimer;
     private boolean isShrinkTimerOn;
     
-    public @E@MemoryManager() {
+    public @E@RecordManager() {
         buffers = new ArrayList<Buffer>();
         buffers.add(new Buffer());
         current = 0;
@@ -238,4 +253,4 @@
         }
     }
     
-}
\ No newline at end of file
+}
diff --git a/asterix-transactions/pom.xml b/asterix-transactions/pom.xml
index 3123008..67dc5a0 100644
--- a/asterix-transactions/pom.xml
+++ b/asterix-transactions/pom.xml
@@ -33,6 +33,44 @@
 					<fork>true</fork>
 				</configuration>
 			</plugin>
+            <plugin>
+                <groupId>edu.uci.ics.asterix</groupId>
+                <artifactId>record-manager-generator-maven-plugin</artifactId>
+                <version>0.8.1-SNAPSHOT</version>
+                <configuration>
+                    <arenaManagerTemplate>ArenaManager.java</arenaManagerTemplate>
+                    <recordManagerTemplate>RecordManager.java</recordManagerTemplate>
+                    <recordTypes><param>Request</param><param>Resource</param></recordTypes>
+                    <outputDir>${project.build.directory}/generated-sources/java/edu/uci/ics/asterix/transaction/management/service/locking</outputDir>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>generate-record-manager</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>generate-record-manager</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>add-source</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>add-source</goal>
+                        </goals>
+                        <configuration>
+                            <sources>
+                                <source>${project.build.directory}/generated-sources/java/</source>
+                            </sources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
 		</plugins>
 
 	</build>
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/RequestArenaManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/RequestArenaManager.java
deleted file mode 100644
index 0247dc7..0000000
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/RequestArenaManager.java
+++ /dev/null
@@ -1,190 +0,0 @@
-package edu.uci.ics.asterix.transaction.management.service.locking;
-
-import java.util.ArrayList;
-
-public class RequestArenaManager {
-    
-    private final int noArenas;
-    private ArrayList<RequestMemoryManager> arenas;
-    private volatile int nextArena; 
-    private ThreadLocal<LocalManager> local;    
-    
-    public RequestArenaManager() {
-        noArenas = Runtime.getRuntime().availableProcessors() * 2;
-        arenas = new ArrayList<RequestMemoryManager>(noArenas);
-        nextArena = 0;
-        local = new ThreadLocal<LocalManager>() {
-            @Override
-            protected LocalManager initialValue() {
-                return getNext();
-            }
-        };
-    }
-    
-    public static int arenaId(int i) {
-        return (i >> 24) & 0xff;
-    }
-
-    public static int localId(int i) {
-        return i & 0xffffff;
-    }
-
-    public int allocate() {
-        final LocalManager localManager = local.get();
-        int result = localManager.arenaId << 24;
-        result |= localManager.mgr.allocate();
-        return result;
-    }
-    
-    public void deallocate(int slotNum) {
-        final int arenaId = arenaId(slotNum);
-        get(arenaId).deallocate(localId(slotNum));
-    }
-    
-    public synchronized LocalManager getNext() {
-        if (nextArena >= arenas.size()) { 
-            arenas.add(new RequestMemoryManager());
-        }
-        RequestMemoryManager mgr = arenas.get(nextArena);
-        LocalManager res = new LocalManager();
-        res.mgr = mgr;
-        res.arenaId = nextArena;
-        nextArena = (nextArena + 1) % noArenas;
-        return res;
-    }
-    
-    public RequestMemoryManager get(int i) {
-        return arenas.get(i);
-    }
-    
-    public RequestMemoryManager local() {
-        return local.get().mgr;
-    }
-    
-    public int getResourceId(int slotNum) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        return local.get().mgr.getResourceId(localId(slotNum));
-    }
-
-    public void setResourceId(int slotNum, int value) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        local.get().mgr.setResourceId(localId(slotNum), value);
-    }
-
-    public int getLockMode(int slotNum) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        return local.get().mgr.getLockMode(localId(slotNum));
-    }
-
-    public void setLockMode(int slotNum, int value) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        local.get().mgr.setLockMode(localId(slotNum), value);
-    }
-
-    public int getJobId(int slotNum) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        return local.get().mgr.getJobId(localId(slotNum));
-    }
-
-    public void setJobId(int slotNum, int value) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        local.get().mgr.setJobId(localId(slotNum), value);
-    }
-
-    public int getPrevJobRequest(int slotNum) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        return local.get().mgr.getPrevJobRequest(localId(slotNum));
-    }
-
-    public void setPrevJobRequest(int slotNum, int value) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        local.get().mgr.setPrevJobRequest(localId(slotNum), value);
-    }
-
-    public int getNextJobRequest(int slotNum) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        return local.get().mgr.getNextJobRequest(localId(slotNum));
-    }
-
-    public void setNextJobRequest(int slotNum, int value) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        local.get().mgr.setNextJobRequest(localId(slotNum), value);
-    }
-
-    public int getNextRequest(int slotNum) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        return local.get().mgr.getNextRequest(localId(slotNum));
-    }
-
-    public void setNextRequest(int slotNum, int value) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        local.get().mgr.setNextRequest(localId(slotNum), value);
-    }
-
-    
-    static class LocalManager {
-        int arenaId;
-        RequestMemoryManager mgr;
-    }
-    
-    StringBuffer append(StringBuffer sb) {
-        for (int i = 0; i < arenas.size(); ++i) {
-            sb.append("++++ arena ").append(i).append(" ++++\n");
-            arenas.get(i).append(sb);
-        }
-        return sb;
-    }
-    
-    public String toString() {
-        return append(new StringBuffer()).toString();
-    }
-}
-
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/RequestMemoryManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/RequestMemoryManager.java
deleted file mode 100644
index 2d47185..0000000
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/RequestMemoryManager.java
+++ /dev/null
@@ -1,361 +0,0 @@
-package edu.uci.ics.asterix.transaction.management.service.locking;
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-
-import edu.uci.ics.asterix.transaction.management.service.transaction.TransactionManagementConstants.LockManagerConstants.LockMode;
-
-public class RequestMemoryManager {
-
-    public static final int SHRINK_TIMER_THRESHOLD = 120000; //2min
-
-    static final int NO_SLOTS = 10;
-    static final int NEXT_FREE_SLOT_OFFSET = 0;
-
-    public static int ITEM_SIZE = 24;
-    public static int RESOURCE_ID_OFF = 0;
-    public static int LOCK_MODE_OFF = 4;
-    public static int JOB_ID_OFF = 8;
-    public static int PREV_JOB_REQUEST_OFF = 12;
-    public static int NEXT_JOB_REQUEST_OFF = 16;
-    public static int NEXT_REQUEST_OFF = 20;
-
-
-    private ArrayList<Buffer> buffers;
-    private int current;
-    private int occupiedSlots;
-    private long shrinkTimer;
-    private boolean isShrinkTimerOn;
-    
-    public RequestMemoryManager() {
-        buffers = new ArrayList<Buffer>();
-        buffers.add(new Buffer());
-        current = 0;
-    }
-    
-    public int allocate() {
-        if (buffers.get(current).isFull()) {
-            int size = buffers.size();
-            boolean needNewBuffer = true;
-            for (int i = 0; i < size; i++) {
-                Buffer buffer = buffers.get(i);
-                if (! buffer.isInitialized()) {
-                    buffer.initialize();
-                    current = i;
-                    needNewBuffer = false;
-                    break;
-                }
-            }
-
-            if (needNewBuffer) {
-                buffers.add(new Buffer());
-                current = buffers.size() - 1;
-            }
-        }
-        ++occupiedSlots;
-        return buffers.get(current).allocate() + current * NO_SLOTS;
-    }
-
-    void deallocate(int slotNum) {
-        buffers.get(slotNum / NO_SLOTS).deallocate(slotNum % NO_SLOTS);
-        --occupiedSlots;
-
-        if (needShrink()) {
-            shrink();
-        }
-    }
-
-    /**
-     * Shrink policy:
-     * Shrink when the resource under-utilization lasts for a certain amount of time.
-     * TODO Need to figure out which of the policies is better
-     * case1.
-     * buffers status : O x x x x x O (O is initialized, x is deinitialized)
-     * In the above status, 'CURRENT' needShrink() returns 'TRUE'
-     * even if there is nothing to shrink or deallocate.
-     * It doesn't distinguish the deinitialized children from initialized children
-     * by calculating totalNumOfSlots = buffers.size() * ChildEntityLockInfoArrayManager.NUM_OF_SLOTS.
-     * In other words, it doesn't subtract the deinitialized children's slots.
-     * case2.
-     * buffers status : O O x x x x x
-     * However, in the above case, if we subtract the deinitialized children's slots,
-     * needShrink() will return false even if we shrink the buffers at this case.
-     * 
-     * @return
-     */
-    private boolean needShrink() {
-        int size = buffers.size();
-        int usedSlots = occupiedSlots;
-        if (usedSlots == 0) {
-            usedSlots = 1;
-        }
-
-        if (size > 1 && size * NO_SLOTS / usedSlots >= 3) {
-            if (isShrinkTimerOn) {
-                if (System.currentTimeMillis() - shrinkTimer >= SHRINK_TIMER_THRESHOLD) {
-                    isShrinkTimerOn = false;
-                    return true;
-                }
-            } else {
-                //turn on timer
-                isShrinkTimerOn = true;
-                shrinkTimer = System.currentTimeMillis();
-            }
-        } else {
-            //turn off timer
-            isShrinkTimerOn = false;
-        }
-
-        return false;
-    }
-
-    /**
-     * Shrink() may
-     * deinitialize(:deallocates ByteBuffer of child) Children(s) or
-     * shrink buffers according to the deinitialized children's contiguity status.
-     * It doesn't deinitialze or shrink more than half of children at a time.
-     */
-    private void shrink() {
-        int i;
-        int removeCount = 0;
-        int size = buffers.size();
-        int maxDecreaseCount = size / 2;
-        Buffer buffer;
-
-        //The first buffer never be deinitialized.
-        for (i = 1; i < size; i++) {
-            if (buffers.get(i).isEmpty()) {
-                buffers.get(i).deinitialize();
-            }
-        }
-
-        //remove the empty buffers from the end
-        for (i = size - 1; i >= 1; i--) {
-            buffer = buffers.get(i);
-            if (! buffer.isInitialized()) {
-                buffers.remove(i);
-                if (++removeCount == maxDecreaseCount) {
-                    break;
-                }
-            } else {
-                break;
-            }
-        }
-        
-        //reset allocChild to the first buffer
-        current = 0;
-
-        isShrinkTimerOn = false;
-    }
-
-    public int getResourceId(int slotNum) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        return b.getInt((slotNum % NO_SLOTS) * ITEM_SIZE + RESOURCE_ID_OFF);
-    }
-
-    public void setResourceId(int slotNum, int value) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        b.putInt((slotNum % NO_SLOTS) * ITEM_SIZE + RESOURCE_ID_OFF, value);
-    }
-
-    public int getLockMode(int slotNum) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        return b.getInt((slotNum % NO_SLOTS) * ITEM_SIZE + LOCK_MODE_OFF);
-    }
-
-    public void setLockMode(int slotNum, int value) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        b.putInt((slotNum % NO_SLOTS) * ITEM_SIZE + LOCK_MODE_OFF, value);
-    }
-
-    public int getJobId(int slotNum) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        return b.getInt((slotNum % NO_SLOTS) * ITEM_SIZE + JOB_ID_OFF);
-    }
-
-    public void setJobId(int slotNum, int value) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        b.putInt((slotNum % NO_SLOTS) * ITEM_SIZE + JOB_ID_OFF, value);
-    }
-
-    public int getPrevJobRequest(int slotNum) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        return b.getInt((slotNum % NO_SLOTS) * ITEM_SIZE + PREV_JOB_REQUEST_OFF);
-    }
-
-    public void setPrevJobRequest(int slotNum, int value) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        b.putInt((slotNum % NO_SLOTS) * ITEM_SIZE + PREV_JOB_REQUEST_OFF, value);
-    }
-
-    public int getNextJobRequest(int slotNum) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        return b.getInt((slotNum % NO_SLOTS) * ITEM_SIZE + NEXT_JOB_REQUEST_OFF);
-    }
-
-    public void setNextJobRequest(int slotNum, int value) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        b.putInt((slotNum % NO_SLOTS) * ITEM_SIZE + NEXT_JOB_REQUEST_OFF, value);
-    }
-
-    public int getNextRequest(int slotNum) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        return b.getInt((slotNum % NO_SLOTS) * ITEM_SIZE + NEXT_REQUEST_OFF);
-    }
-
-    public void setNextRequest(int slotNum, int value) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        b.putInt((slotNum % NO_SLOTS) * ITEM_SIZE + NEXT_REQUEST_OFF, value);
-    }
-
-    
-    StringBuffer append(StringBuffer sb) {
-        sb.append("+++ current: ")
-          .append(current)
-          .append(" no occupied slots: ")
-          .append(occupiedSlots)
-          .append(" +++\n");
-        for (int i = 0; i < buffers.size(); ++i) {
-            buffers.get(i).append(sb);
-            sb.append("\n");
-        }
-        return sb;
-    }
-    
-    public String toString() {
-        StringBuffer sb = new StringBuffer();
-        append(sb);
-        return sb.toString();
-    }
-
-    static class Buffer {
-        private ByteBuffer bb;
-        private int freeSlotNum;
-        private int occupiedSlots = -1; //-1 represents 'deinitialized' state.
-        
-        Buffer() {
-            initialize();
-        }
-
-        void initialize() {
-            bb = ByteBuffer.allocate(NO_SLOTS * ITEM_SIZE);
-            freeSlotNum = 0;
-            occupiedSlots = 0;
-
-            for (int i = 0; i < NO_SLOTS - 1; i++) {
-                setNextFreeSlot(i, i + 1);
-            }
-            setNextFreeSlot(NO_SLOTS - 1, -1); //-1 represents EOL(end of link)
-        }
-        
-        public void deinitialize() {
-            bb = null;
-            occupiedSlots = -1;
-        }
-        
-        public boolean isInitialized() {
-            return occupiedSlots >= 0;
-        }
-
-        public boolean isFull() {
-            return occupiedSlots == NO_SLOTS;
-        }
-
-        public boolean isEmpty() {
-            return occupiedSlots == 0;
-        }
-        
-        public int allocate() {
-            int currentSlot = freeSlotNum;
-            freeSlotNum = getNextFreeSlot(currentSlot);
-            occupiedSlots++;
-            return currentSlot;
-        }
-    
-        public void deallocate(int slotNum) {
-            setNextFreeSlot(slotNum, freeSlotNum);
-            freeSlotNum = slotNum;
-            occupiedSlots--;
-        }
-
-        public int getNextFreeSlot(int slotNum) {
-            return bb.getInt(slotNum * ITEM_SIZE + NEXT_FREE_SLOT_OFFSET);
-        }    
-            
-        public void setNextFreeSlot(int slotNum, int nextFreeSlot) {
-            bb.putInt(slotNum * ITEM_SIZE + NEXT_FREE_SLOT_OFFSET, nextFreeSlot);
-        }
-
-        StringBuffer append(StringBuffer sb) {
-            sb.append("++ free slot: ")
-              .append(freeSlotNum)
-              .append(" no occupied slots: ")
-              .append(occupiedSlots)
-              .append(" ++\n");
-            sb.append("resource id      | ");
-            for (int i = 0; i < occupiedSlots; ++i) {
-                int value = bb.getInt(i * ITEM_SIZE + RESOURCE_ID_OFF);
-                sb.append(String.format("%1$2x", RequestArenaManager.arenaId(value)));
-                sb.append(" ");
-                sb.append(String.format("%1$6x", RequestArenaManager.localId(value)));
-                sb.append(" | ");
-            }
-            sb.append("\n");
-            sb.append("lock mode        | ");
-            for (int i = 0; i < occupiedSlots; ++i) {
-                int value = bb.getInt(i * ITEM_SIZE + LOCK_MODE_OFF);
-                sb.append(String.format("%1$2x", RequestArenaManager.arenaId(value)));
-                sb.append(" ");
-                sb.append(String.format("%1$6x", RequestArenaManager.localId(value)));
-                sb.append(" | ");
-            }
-            sb.append("\n");
-            sb.append("job id           | ");
-            for (int i = 0; i < occupiedSlots; ++i) {
-                int value = bb.getInt(i * ITEM_SIZE + JOB_ID_OFF);
-                sb.append(String.format("%1$2x", RequestArenaManager.arenaId(value)));
-                sb.append(" ");
-                sb.append(String.format("%1$6x", RequestArenaManager.localId(value)));
-                sb.append(" | ");
-            }
-            sb.append("\n");
-            sb.append("prev job request | ");
-            for (int i = 0; i < occupiedSlots; ++i) {
-                int value = bb.getInt(i * ITEM_SIZE + PREV_JOB_REQUEST_OFF);
-                sb.append(String.format("%1$2x", RequestArenaManager.arenaId(value)));
-                sb.append(" ");
-                sb.append(String.format("%1$6x", RequestArenaManager.localId(value)));
-                sb.append(" | ");
-            }
-            sb.append("\n");
-            sb.append("next job request | ");
-            for (int i = 0; i < occupiedSlots; ++i) {
-                int value = bb.getInt(i * ITEM_SIZE + NEXT_JOB_REQUEST_OFF);
-                sb.append(String.format("%1$2x", RequestArenaManager.arenaId(value)));
-                sb.append(" ");
-                sb.append(String.format("%1$6x", RequestArenaManager.localId(value)));
-                sb.append(" | ");
-            }
-            sb.append("\n");
-            sb.append("next request     | ");
-            for (int i = 0; i < occupiedSlots; ++i) {
-                int value = bb.getInt(i * ITEM_SIZE + NEXT_REQUEST_OFF);
-                sb.append(String.format("%1$2x", RequestArenaManager.arenaId(value)));
-                sb.append(" ");
-                sb.append(String.format("%1$6x", RequestArenaManager.localId(value)));
-                sb.append(" | ");
-            }
-            sb.append("\n");
-
-            return sb;
-        }
-        
-        public String toString() {
-            StringBuffer sb = new StringBuffer();
-            append(sb);
-            return sb.toString();
-        }
-    }
-    
-}
-
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/ResourceArenaManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/ResourceArenaManager.java
deleted file mode 100644
index f38b6ce..0000000
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/ResourceArenaManager.java
+++ /dev/null
@@ -1,208 +0,0 @@
-package edu.uci.ics.asterix.transaction.management.service.locking;
-
-import java.util.ArrayList;
-
-public class ResourceArenaManager {
-    
-    private final int noArenas;
-    private ArrayList<ResourceMemoryManager> arenas;
-    private volatile int nextArena; 
-    private ThreadLocal<LocalManager> local;    
-    
-    public ResourceArenaManager() {
-        noArenas = Runtime.getRuntime().availableProcessors() * 2;
-        arenas = new ArrayList<ResourceMemoryManager>(noArenas);
-        nextArena = 0;
-        local = new ThreadLocal<LocalManager>() {
-            @Override
-            protected LocalManager initialValue() {
-                return getNext();
-            }
-        };
-    }
-    
-    public static int arenaId(int i) {
-        return (i >> 24) & 0xff;
-    }
-
-    public static int localId(int i) {
-        return i & 0xffffff;
-    }
-
-    public int allocate() {
-        final LocalManager localManager = local.get();
-        int result = localManager.arenaId << 24;
-        result |= localManager.mgr.allocate();
-        return result;
-    }
-    
-    public void deallocate(int slotNum) {
-        final int arenaId = arenaId(slotNum);
-        get(arenaId).deallocate(localId(slotNum));
-    }
-    
-    public synchronized LocalManager getNext() {
-        if (nextArena >= arenas.size()) { 
-            arenas.add(new ResourceMemoryManager());
-        }
-        ResourceMemoryManager mgr = arenas.get(nextArena);
-        LocalManager res = new LocalManager();
-        res.mgr = mgr;
-        res.arenaId = nextArena;
-        nextArena = (nextArena + 1) % noArenas;
-        return res;
-    }
-    
-    public ResourceMemoryManager get(int i) {
-        return arenas.get(i);
-    }
-    
-    public ResourceMemoryManager local() {
-        return local.get().mgr;
-    }
-    
-    public int getLastHolder(int slotNum) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        return local.get().mgr.getLastHolder(localId(slotNum));
-    }
-
-    public void setLastHolder(int slotNum, int value) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        local.get().mgr.setLastHolder(localId(slotNum), value);
-    }
-
-    public int getFirstWaiter(int slotNum) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        return local.get().mgr.getFirstWaiter(localId(slotNum));
-    }
-
-    public void setFirstWaiter(int slotNum, int value) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        local.get().mgr.setFirstWaiter(localId(slotNum), value);
-    }
-
-    public int getFirstUpgrader(int slotNum) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        return local.get().mgr.getFirstUpgrader(localId(slotNum));
-    }
-
-    public void setFirstUpgrader(int slotNum, int value) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        local.get().mgr.setFirstUpgrader(localId(slotNum), value);
-    }
-
-    public int getMaxMode(int slotNum) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        return local.get().mgr.getMaxMode(localId(slotNum));
-    }
-
-    public void setMaxMode(int slotNum, int value) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        local.get().mgr.setMaxMode(localId(slotNum), value);
-    }
-
-    public int getDatasetId(int slotNum) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        return local.get().mgr.getDatasetId(localId(slotNum));
-    }
-
-    public void setDatasetId(int slotNum, int value) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        local.get().mgr.setDatasetId(localId(slotNum), value);
-    }
-
-    public int getPkHashVal(int slotNum) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        return local.get().mgr.getPkHashVal(localId(slotNum));
-    }
-
-    public void setPkHashVal(int slotNum, int value) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        local.get().mgr.setPkHashVal(localId(slotNum), value);
-    }
-
-    public int getNext(int slotNum) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        return local.get().mgr.getNext(localId(slotNum));
-    }
-
-    public void setNext(int slotNum, int value) {
-        final int arenaId = arenaId(slotNum);
-        if (arenaId != local.get().arenaId) {
-            local.get().arenaId = arenaId;
-            local.get().mgr = get(arenaId);
-        }
-        local.get().mgr.setNext(localId(slotNum), value);
-    }
-
-    
-    static class LocalManager {
-        int arenaId;
-        ResourceMemoryManager mgr;
-    }
-    
-    StringBuffer append(StringBuffer sb) {
-        for (int i = 0; i < arenas.size(); ++i) {
-            sb.append("++++ arena ").append(i).append(" ++++\n");
-            arenas.get(i).append(sb);
-        }
-        return sb;
-    }
-    
-    public String toString() {
-        return append(new StringBuffer()).toString();
-    }
-}
-
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/ResourceMemoryManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/ResourceMemoryManager.java
deleted file mode 100644
index aeeb395..0000000
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/ResourceMemoryManager.java
+++ /dev/null
@@ -1,385 +0,0 @@
-package edu.uci.ics.asterix.transaction.management.service.locking;
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-
-import edu.uci.ics.asterix.transaction.management.service.transaction.TransactionManagementConstants.LockManagerConstants.LockMode;
-
-public class ResourceMemoryManager {
-
-    public static final int SHRINK_TIMER_THRESHOLD = 120000; //2min
-
-    static final int NO_SLOTS = 10;
-    static final int NEXT_FREE_SLOT_OFFSET = 0;
-
-    public static int ITEM_SIZE = 28;
-    public static int LAST_HOLDER_OFF = 0;
-    public static int FIRST_WAITER_OFF = 4;
-    public static int FIRST_UPGRADER_OFF = 8;
-    public static int MAX_MODE_OFF = 12;
-    public static int DATASET_ID_OFF = 16;
-    public static int PK_HASH_VAL_OFF = 20;
-    public static int NEXT_OFF = 24;
-
-
-    private ArrayList<Buffer> buffers;
-    private int current;
-    private int occupiedSlots;
-    private long shrinkTimer;
-    private boolean isShrinkTimerOn;
-    
-    public ResourceMemoryManager() {
-        buffers = new ArrayList<Buffer>();
-        buffers.add(new Buffer());
-        current = 0;
-    }
-    
-    public int allocate() {
-        if (buffers.get(current).isFull()) {
-            int size = buffers.size();
-            boolean needNewBuffer = true;
-            for (int i = 0; i < size; i++) {
-                Buffer buffer = buffers.get(i);
-                if (! buffer.isInitialized()) {
-                    buffer.initialize();
-                    current = i;
-                    needNewBuffer = false;
-                    break;
-                }
-            }
-
-            if (needNewBuffer) {
-                buffers.add(new Buffer());
-                current = buffers.size() - 1;
-            }
-        }
-        ++occupiedSlots;
-        return buffers.get(current).allocate() + current * NO_SLOTS;
-    }
-
-    void deallocate(int slotNum) {
-        buffers.get(slotNum / NO_SLOTS).deallocate(slotNum % NO_SLOTS);
-        --occupiedSlots;
-
-        if (needShrink()) {
-            shrink();
-        }
-    }
-
-    /**
-     * Shrink policy:
-     * Shrink when the resource under-utilization lasts for a certain amount of time.
-     * TODO Need to figure out which of the policies is better
-     * case1.
-     * buffers status : O x x x x x O (O is initialized, x is deinitialized)
-     * In the above status, 'CURRENT' needShrink() returns 'TRUE'
-     * even if there is nothing to shrink or deallocate.
-     * It doesn't distinguish the deinitialized children from initialized children
-     * by calculating totalNumOfSlots = buffers.size() * ChildEntityLockInfoArrayManager.NUM_OF_SLOTS.
-     * In other words, it doesn't subtract the deinitialized children's slots.
-     * case2.
-     * buffers status : O O x x x x x
-     * However, in the above case, if we subtract the deinitialized children's slots,
-     * needShrink() will return false even if we shrink the buffers at this case.
-     * 
-     * @return
-     */
-    private boolean needShrink() {
-        int size = buffers.size();
-        int usedSlots = occupiedSlots;
-        if (usedSlots == 0) {
-            usedSlots = 1;
-        }
-
-        if (size > 1 && size * NO_SLOTS / usedSlots >= 3) {
-            if (isShrinkTimerOn) {
-                if (System.currentTimeMillis() - shrinkTimer >= SHRINK_TIMER_THRESHOLD) {
-                    isShrinkTimerOn = false;
-                    return true;
-                }
-            } else {
-                //turn on timer
-                isShrinkTimerOn = true;
-                shrinkTimer = System.currentTimeMillis();
-            }
-        } else {
-            //turn off timer
-            isShrinkTimerOn = false;
-        }
-
-        return false;
-    }
-
-    /**
-     * Shrink() may
-     * deinitialize(:deallocates ByteBuffer of child) Children(s) or
-     * shrink buffers according to the deinitialized children's contiguity status.
-     * It doesn't deinitialze or shrink more than half of children at a time.
-     */
-    private void shrink() {
-        int i;
-        int removeCount = 0;
-        int size = buffers.size();
-        int maxDecreaseCount = size / 2;
-        Buffer buffer;
-
-        //The first buffer never be deinitialized.
-        for (i = 1; i < size; i++) {
-            if (buffers.get(i).isEmpty()) {
-                buffers.get(i).deinitialize();
-            }
-        }
-
-        //remove the empty buffers from the end
-        for (i = size - 1; i >= 1; i--) {
-            buffer = buffers.get(i);
-            if (! buffer.isInitialized()) {
-                buffers.remove(i);
-                if (++removeCount == maxDecreaseCount) {
-                    break;
-                }
-            } else {
-                break;
-            }
-        }
-        
-        //reset allocChild to the first buffer
-        current = 0;
-
-        isShrinkTimerOn = false;
-    }
-
-    public int getLastHolder(int slotNum) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        return b.getInt((slotNum % NO_SLOTS) * ITEM_SIZE + LAST_HOLDER_OFF);
-    }
-
-    public void setLastHolder(int slotNum, int value) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        b.putInt((slotNum % NO_SLOTS) * ITEM_SIZE + LAST_HOLDER_OFF, value);
-    }
-
-    public int getFirstWaiter(int slotNum) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        return b.getInt((slotNum % NO_SLOTS) * ITEM_SIZE + FIRST_WAITER_OFF);
-    }
-
-    public void setFirstWaiter(int slotNum, int value) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        b.putInt((slotNum % NO_SLOTS) * ITEM_SIZE + FIRST_WAITER_OFF, value);
-    }
-
-    public int getFirstUpgrader(int slotNum) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        return b.getInt((slotNum % NO_SLOTS) * ITEM_SIZE + FIRST_UPGRADER_OFF);
-    }
-
-    public void setFirstUpgrader(int slotNum, int value) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        b.putInt((slotNum % NO_SLOTS) * ITEM_SIZE + FIRST_UPGRADER_OFF, value);
-    }
-
-    public int getMaxMode(int slotNum) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        return b.getInt((slotNum % NO_SLOTS) * ITEM_SIZE + MAX_MODE_OFF);
-    }
-
-    public void setMaxMode(int slotNum, int value) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        b.putInt((slotNum % NO_SLOTS) * ITEM_SIZE + MAX_MODE_OFF, value);
-    }
-
-    public int getDatasetId(int slotNum) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        return b.getInt((slotNum % NO_SLOTS) * ITEM_SIZE + DATASET_ID_OFF);
-    }
-
-    public void setDatasetId(int slotNum, int value) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        b.putInt((slotNum % NO_SLOTS) * ITEM_SIZE + DATASET_ID_OFF, value);
-    }
-
-    public int getPkHashVal(int slotNum) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        return b.getInt((slotNum % NO_SLOTS) * ITEM_SIZE + PK_HASH_VAL_OFF);
-    }
-
-    public void setPkHashVal(int slotNum, int value) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        b.putInt((slotNum % NO_SLOTS) * ITEM_SIZE + PK_HASH_VAL_OFF, value);
-    }
-
-    public int getNext(int slotNum) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        return b.getInt((slotNum % NO_SLOTS) * ITEM_SIZE + NEXT_OFF);
-    }
-
-    public void setNext(int slotNum, int value) {
-        final ByteBuffer b = buffers.get(slotNum / NO_SLOTS).bb;
-        b.putInt((slotNum % NO_SLOTS) * ITEM_SIZE + NEXT_OFF, value);
-    }
-
-    
-    StringBuffer append(StringBuffer sb) {
-        sb.append("+++ current: ")
-          .append(current)
-          .append(" no occupied slots: ")
-          .append(occupiedSlots)
-          .append(" +++\n");
-        for (int i = 0; i < buffers.size(); ++i) {
-            buffers.get(i).append(sb);
-            sb.append("\n");
-        }
-        return sb;
-    }
-    
-    public String toString() {
-        StringBuffer sb = new StringBuffer();
-        append(sb);
-        return sb.toString();
-    }
-
-    static class Buffer {
-        private ByteBuffer bb;
-        private int freeSlotNum;
-        private int occupiedSlots = -1; //-1 represents 'deinitialized' state.
-        
-        Buffer() {
-            initialize();
-        }
-
-        void initialize() {
-            bb = ByteBuffer.allocate(NO_SLOTS * ITEM_SIZE);
-            freeSlotNum = 0;
-            occupiedSlots = 0;
-
-            for (int i = 0; i < NO_SLOTS - 1; i++) {
-                setNextFreeSlot(i, i + 1);
-            }
-            setNextFreeSlot(NO_SLOTS - 1, -1); //-1 represents EOL(end of link)
-        }
-        
-        public void deinitialize() {
-            bb = null;
-            occupiedSlots = -1;
-        }
-        
-        public boolean isInitialized() {
-            return occupiedSlots >= 0;
-        }
-
-        public boolean isFull() {
-            return occupiedSlots == NO_SLOTS;
-        }
-
-        public boolean isEmpty() {
-            return occupiedSlots == 0;
-        }
-        
-        public int allocate() {
-            int currentSlot = freeSlotNum;
-            freeSlotNum = getNextFreeSlot(currentSlot);
-            bb.putInt(currentSlot * ITEM_SIZE + LAST_HOLDER_OFF, -1);
-            bb.putInt(currentSlot * ITEM_SIZE + FIRST_WAITER_OFF, -1);
-            bb.putInt(currentSlot * ITEM_SIZE + FIRST_UPGRADER_OFF, -1);
-            bb.putInt(currentSlot * ITEM_SIZE + MAX_MODE_OFF, LockMode.NL);
-            occupiedSlots++;
-            return currentSlot;
-        }
-    
-        public void deallocate(int slotNum) {
-            setNextFreeSlot(slotNum, freeSlotNum);
-            freeSlotNum = slotNum;
-            occupiedSlots--;
-        }
-
-        public int getNextFreeSlot(int slotNum) {
-            return bb.getInt(slotNum * ITEM_SIZE + NEXT_FREE_SLOT_OFFSET);
-        }    
-            
-        public void setNextFreeSlot(int slotNum, int nextFreeSlot) {
-            bb.putInt(slotNum * ITEM_SIZE + NEXT_FREE_SLOT_OFFSET, nextFreeSlot);
-        }
-
-        StringBuffer append(StringBuffer sb) {
-            sb.append("++ free slot: ")
-              .append(freeSlotNum)
-              .append(" no occupied slots: ")
-              .append(occupiedSlots)
-              .append(" ++\n");
-            sb.append("last holder    | ");
-            for (int i = 0; i < occupiedSlots; ++i) {
-                int value = bb.getInt(i * ITEM_SIZE + LAST_HOLDER_OFF);
-                sb.append(String.format("%1$2x", ResourceArenaManager.arenaId(value)));
-                sb.append(" ");
-                sb.append(String.format("%1$6x", ResourceArenaManager.localId(value)));
-                sb.append(" | ");
-            }
-            sb.append("\n");
-            sb.append("first waiter   | ");
-            for (int i = 0; i < occupiedSlots; ++i) {
-                int value = bb.getInt(i * ITEM_SIZE + FIRST_WAITER_OFF);
-                sb.append(String.format("%1$2x", ResourceArenaManager.arenaId(value)));
-                sb.append(" ");
-                sb.append(String.format("%1$6x", ResourceArenaManager.localId(value)));
-                sb.append(" | ");
-            }
-            sb.append("\n");
-            sb.append("first upgrader | ");
-            for (int i = 0; i < occupiedSlots; ++i) {
-                int value = bb.getInt(i * ITEM_SIZE + FIRST_UPGRADER_OFF);
-                sb.append(String.format("%1$2x", ResourceArenaManager.arenaId(value)));
-                sb.append(" ");
-                sb.append(String.format("%1$6x", ResourceArenaManager.localId(value)));
-                sb.append(" | ");
-            }
-            sb.append("\n");
-            sb.append("max mode       | ");
-            for (int i = 0; i < occupiedSlots; ++i) {
-                int value = bb.getInt(i * ITEM_SIZE + MAX_MODE_OFF);
-                sb.append(String.format("%1$2x", ResourceArenaManager.arenaId(value)));
-                sb.append(" ");
-                sb.append(String.format("%1$6x", ResourceArenaManager.localId(value)));
-                sb.append(" | ");
-            }
-            sb.append("\n");
-            sb.append("dataset id     | ");
-            for (int i = 0; i < occupiedSlots; ++i) {
-                int value = bb.getInt(i * ITEM_SIZE + DATASET_ID_OFF);
-                sb.append(String.format("%1$2x", ResourceArenaManager.arenaId(value)));
-                sb.append(" ");
-                sb.append(String.format("%1$6x", ResourceArenaManager.localId(value)));
-                sb.append(" | ");
-            }
-            sb.append("\n");
-            sb.append("pk hash val    | ");
-            for (int i = 0; i < occupiedSlots; ++i) {
-                int value = bb.getInt(i * ITEM_SIZE + PK_HASH_VAL_OFF);
-                sb.append(String.format("%1$2x", ResourceArenaManager.arenaId(value)));
-                sb.append(" ");
-                sb.append(String.format("%1$6x", ResourceArenaManager.localId(value)));
-                sb.append(" | ");
-            }
-            sb.append("\n");
-            sb.append("next           | ");
-            for (int i = 0; i < occupiedSlots; ++i) {
-                int value = bb.getInt(i * ITEM_SIZE + NEXT_OFF);
-                sb.append(String.format("%1$2x", ResourceArenaManager.arenaId(value)));
-                sb.append(" ");
-                sb.append(String.format("%1$6x", ResourceArenaManager.localId(value)));
-                sb.append(" | ");
-            }
-            sb.append("\n");
-
-            return sb;
-        }
-        
-        public String toString() {
-            StringBuffer sb = new StringBuffer();
-            append(sb);
-            return sb.toString();
-        }
-    }
-    
-}
-
