From c36c32067e08e886b44d6607522fa566bb86b2c3 Mon Sep 17 00:00:00 2001 From: navid Date: Tue, 10 Feb 2009 03:15:21 +0000 Subject: [PATCH] *** empty log message *** --- .../core/ExtendedTransaction.java | 283 +++++++++++------- .../src/TransactionalIO/core/MYLock.java | 80 +++++ .../core/MYReadWriteWLock.java | 64 ++++ .../src/TransactionalIO/core/OffsetLock.java | 27 -- .../core/TransactionalFile.java | 67 +++-- .../src/TransactionalIO/core/Wrapper.java | 3 + 6 files changed, 360 insertions(+), 164 deletions(-) create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/core/MYLock.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/core/MYReadWriteWLock.java delete mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/core/OffsetLock.java diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/ExtendedTransaction.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/ExtendedTransaction.java index 723a50e2..2afcfa56 100644 --- a/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/ExtendedTransaction.java +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/ExtendedTransaction.java @@ -37,16 +37,13 @@ import java.util.logging.Logger; public class ExtendedTransaction implements TransactionStatu { private static native int nativepwrite(byte buff[], long offset, int size, FileDescriptor fd); - - - - public TransactionStatu memorystate; public int starttime; public int endtime; public TreeMap msg = new TreeMap(); public int numberofwrites; public int numberofreads; + private TreeMap sortedAccesedFiles; public enum Status { @@ -55,7 +52,7 @@ public class ExtendedTransaction implements TransactionStatu { private boolean writesmerged = true; private Vector heldlengthlocks; //private Vector heldoffsetlocks; - // private Vector heldoffsetlocks; + // private Vector heldoffsetlocks; //private Vector heldblocklocks; //private Vector heldblocklocks; //private HashMap> AccessedFiles; @@ -67,7 +64,8 @@ public class ExtendedTransaction implements TransactionStatu { public HashMap merge_for_writes_done; private HashMap writeBuffer; private volatile Status status; - public ReentrantReadWriteLock[] toholoffsetlocks; + //public ReentrantReadWriteLock[] toholoffsetlocks; + public MYLock[] toholoffsetlocks; public int offsetcount = 0; public Lock[] toholdblocklocks; public int blockcount = 0; @@ -75,13 +73,14 @@ public class ExtendedTransaction implements TransactionStatu { public ExtendedTransaction() { // super(); // id = Integer.valueOf(Thread.currentThread().getName().substring(7)); - toholoffsetlocks = new ReentrantReadWriteLock[20]; + //toholoffsetlocks = new ReentrantReadWriteLock[20]; + toholoffsetlocks = new MYLock[20]; toholdblocklocks = new Lock[20]; - // for (int i=0; i<20; i++) - // toholoffsetlocks[i] = new ReentrantLock(); + // for (int i=0; i<20; i++) + // toholoffsetlocks[i] = new ReentrantLock(); heldlengthlocks = new Vector(); // heldblocklocks = new Vector(); - // heldoffsetlocks = new Vector(); + // heldoffsetlocks = new Vector(); AccessedFiles = new HashMap(); GlobaltoLocalMappings = new HashMap/**/(); writeBuffer = new HashMap(); @@ -111,7 +110,6 @@ public class ExtendedTransaction implements TransactionStatu { } - public void abort() { synchronized (this) { this.status = Status.ABORTED; @@ -133,7 +131,6 @@ public class ExtendedTransaction implements TransactionStatu { return this.getStatus() == Status.ABORTED; } - public HashMap getWriteBuffer() { return writeBuffer; } @@ -169,14 +166,16 @@ public class ExtendedTransaction implements TransactionStatu { public TreeMap getSortedFileAccessMap(HashMap hmap) { /*TreeMap sortedMap = new TreeMap(hmap); return sortedMap;*/ - return new TreeMap(hmap); + sortedAccesedFiles = new TreeMap(hmap); + return sortedAccesedFiles; + //return new TreeMap(hmap); } - public void addFile(TransactionalFile tf, long offsetnumber/*, TransactionLocalFileAttributes tmp*/) { - tf.getInodestate().commitedfilesize.lengthlock.lock(); - TransactionLocalFileAttributes tmp = new TransactionLocalFileAttributes(offsetnumber, tf.getInodestate().commitedfilesize.getLength()); - tf.getInodestate().commitedfilesize.lengthlock.unlock(); + //tf.getInodestate().commitedfilesize.lengthlock.lock(); + //TransactionLocalFileAttributes tmp = new TransactionLocalFileAttributes(offsetnumber, tf.getInodestate().commitedfilesize.getLength()); + TransactionLocalFileAttributes tmp = new TransactionLocalFileAttributes(offsetnumber, 0); + //tf.getInodestate().commitedfilesize.lengthlock.unlock(); Vector dummy; if (AccessedFiles.containsKey(tf.getInode())) { @@ -197,42 +196,47 @@ public class ExtendedTransaction implements TransactionStatu { TreeMap hm = getSortedFileAccessMap(AccessedFiles); Iterator iter = hm.keySet().iterator(); offsetcount = 0; - - // for (int j=0; j< hm.size(); j++){ + + // for (int j=0; j< hm.size(); j++){ while (iter.hasNext()/* && (this.getStatus() == Status.ACTIVE)*/) { INode key = (INode) iter.next(); Vector vec = (Vector) AccessedFiles.get(key); - + Collections.sort(vec); - for (int i=0; i