*** empty log message ***
authornavid <navid>
Fri, 21 Nov 2008 03:01:40 +0000 (03:01 +0000)
committernavid <navid>
Fri, 21 Nov 2008 03:01:40 +0000 (03:01 +0000)
40 files changed:
Robust/Transactions/TransactionalIOSrc/Utilities/Range.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/benchmarks/Main.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/benchmarks/MainforLocks.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/benchmarks/StatisticsWrapper.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/benchmarks/benchmark.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/benchmarks/customhandler.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/benchmarks/lockthread1.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/benchmarks/thread1.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/benchmarks/thread2.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/benchmarks/thread3.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/benchmarks/thread4.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/core/BlockDataStructure.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/core/CustomLock.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/core/CustomThread.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/core/Defaults.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/core/ExtendedTransaction.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/core/FileBlockManager.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/core/GlobalINodeState.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/core/GlobalOffset.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/core/HelloWorld.c [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/core/HelloWorld.h [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/core/INode.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/core/IOlib [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/core/IOlib.so [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/core/ManagerRepository.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/core/NativeFunctions.c [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/core/NativeFunctions.h [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/core/NativeFunctions.o [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/core/TransactionLocalFileAttributes.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/core/TransactionalFile.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/core/TransactionalFileWrapperFactory.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/core/Wrapper.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/core/WriteOperations.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/exceptions/PanicException.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/interfaces/BlockAccessModesEnum.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/interfaces/ContentionManager.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/interfaces/FileAccessModesEum.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/interfaces/OffsetDependency.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/interfaces/TransactionStatu.java [new file with mode: 0644]
Robust/Transactions/TransactionalIOSrc/interfaces/TransactionalProgram.java [new file with mode: 0644]

diff --git a/Robust/Transactions/TransactionalIOSrc/Utilities/Range.java b/Robust/Transactions/TransactionalIOSrc/Utilities/Range.java
new file mode 100644 (file)
index 0000000..0de34e3
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package TransactionalIO.Utilities;
+
+
+/**
+ *
+ * @author navid
+ */
+public class Range implements Comparable {
+
+    private long start;
+    private long end;
+
+    public Range() {
+    }
+
+    public Range(long start, long end) {
+        this.start = start;
+        this.end = end;
+    }
+
+    public long getEnd() {
+        return end;
+    }
+
+    public void setEnd(long end) {
+        this.end = end;
+    }
+
+    public long getStart() {
+        return start;
+    }
+
+    public void setStart(long start) {
+        this.start = start;
+    }
+
+    public Range intersection(Range secondrange) {
+        if ((secondrange.start <= this.start) && (this.start <= secondrange.end)) {
+            return new Range(this.start, Math.min(this.end, secondrange.end));
+        } else if ((secondrange.start <= this.end) && (this.end <= secondrange.end)) {
+            return new Range(Math.max(this.start, secondrange.start), this.end);
+        } else if ((this.start <= secondrange.start) && (secondrange.end <= this.end)) {
+            return new Range(secondrange.start, secondrange.end);
+        } else {
+            return null;
+        }
+    }
+
+    public boolean hasIntersection(Range secondrange) {
+        if ((secondrange.start <= this.start) && (this.start <= secondrange.end)) {
+            return true;
+        } else if ((secondrange.start <= this.end) && (this.end <= secondrange.end)) {
+            return true;
+        } else if ((this.start <= secondrange.start) && (secondrange.end <= this.end)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+    
+
+    public boolean includes(Range secondrange) {
+        if (this.start <= secondrange.start && secondrange.end <= this.end) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public Range[] minus(Range[] intersectedranges, int size) {
+        Range[] tmp = new Range[size + 1];
+        
+        int counter = 0;
+        if (this.start < intersectedranges[0].start) {
+            tmp[counter] = new Range(this.start, intersectedranges[0].start);
+            counter++;
+        }
+        for (int i = 1; i < size; i++) {
+            tmp[counter] = new Range(intersectedranges[i - 1].end, intersectedranges[i].start);
+            counter++;
+        }
+        if (this.end > intersectedranges[size - 1].end) {
+            tmp[counter] = new Range(intersectedranges[size - 1].end, this.end);
+            counter++;
+        }
+        Range[] result = new Range[counter];
+        for (int i = 0; i < counter; i++) {
+            result[i] = tmp[i];
+        }
+        return result;
+    }
+
+    public int compareTo(Object arg0) {
+
+        Range tmp = (Range) arg0;
+        if (this.start < tmp.start) {
+            return -1;
+        } else if (this.start == tmp.start) {
+            return 0;
+        } else {
+            return 1;
+        }
+    }
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/benchmarks/Main.java b/Robust/Transactions/TransactionalIOSrc/benchmarks/Main.java
new file mode 100644 (file)
index 0000000..7797e90
--- /dev/null
@@ -0,0 +1,152 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.benchmarks;
+
+import TransactionalIO.core.CustomThread;
+import TransactionalIO.core.ExtendedTransaction;
+import TransactionalIO.core.TransactionalFile;
+import java.io.File;
+import java.util.Iterator;
+import java.util.TreeMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author navid
+ */
+public class Main {
+
+    public static void main(String args[]){
+        try {
+        //    benchmark.init();
+          
+            
+        // for (int i=0; i<100; i++){
+            benchmark.init();
+            //System.out.println(
+            long starttime = System.nanoTime();
+           /* thread1 tr1 = new thread1();
+            thread2 tr2 = new thread2();
+            thread3 tr3 = new thread3();
+            thread4 tr4 = new thread4();*/
+            /*TransactionalIO tr2 = new TransactionalIO();
+            TransactionalIO tr3 = new TransactionalIO();
+            CustomThread ct1 = new CustomThread(tr1);
+            CustomThread ct2 = new CustomThread(tr2);*/
+           
+          /*  CustomThread ct1 = new CustomThread(new thread1('a', new TransactionalFile("/home/navid/output.text", "rw")));
+            CustomThread ct2 = new CustomThread(new thread1('b', new TransactionalFile("/home/navid/output.text", "rw")));
+            CustomThread ct3 = new CustomThread(new thread1('c', new TransactionalFile("/home/navid/output.text", "rw")));
+            CustomThread ct4= new CustomThread(new thread1('d', new TransactionalFile("/home/navid/output.text", "rw")));
+            CustomThread ct5 = new CustomThread(new thread1('e', new TransactionalFile("/home/navid/output.text", "rw")));
+            CustomThread ct6 = new CustomThread(new thread1('f', new TransactionalFile("/home/navid/output.text", "rw")));
+            CustomThread ct7 = new CustomThread(new thread1('g', new TransactionalFile("/home/navid/output.text", "rw")));
+            CustomThread ct8 = new CustomThread(new thread1('h', new TransactionalFile("/home/navid/output.text", "rw")));
+            CustomThread ct9 = new CustomThread(new thread1('i',new TransactionalFile("/home/navid/output.text", "rw")));
+            CustomThread ct10 = new CustomThread(new thread1('j', new TransactionalFile("/home/navid/output.text", "rw")));
+            CustomThread ct11 = new CustomThread(new thread1('k', new TransactionalFile("/home/navid/output.text", "rw")));
+            CustomThread ct12 = new CustomThread(new thread1('l', new TransactionalFile("/home/navid/output.text", "rw")));
+            CustomThread ct13 = new CustomThread(new thread1('m', new TransactionalFile("/home/navid/output.text", "rw")));
+            CustomThread ct14 = new CustomThread(new thread1('n', new TransactionalFile("/home/navid/output.text", "rw")));
+            
+            CustomThread ct15 = new CustomThread(new thread1('o', new TransactionalFile("/home/navid/output.text", "rw")));
+            CustomThread ct16 = new CustomThread(new thread1('p', new TransactionalFile("/home/navid/output.text", "rw")));
+            CustomThread ct17 = new CustomThread(new thread1('q', new TransactionalFile("/home/navid/output.text", "rw")));
+            CustomThread ct18 = new CustomThread(new thread1('r', new TransactionalFile("/home/navid/output.text", "rw")));
+             
+           // CustomThread ct15 = new CustomThread(tr2);
+            CustomThread ct19 = new CustomThread(new thread1('s', new TransactionalFile("/home/navid/output.text", "rw")));
+            CustomThread ct20 = new CustomThread(new thread1('t', new TransactionalFile("/home/navid/output.text", "rw")));*/
+            
+            
+            CustomThread ct1 = new CustomThread(new thread1('a'));
+            CustomThread ct2 = new CustomThread(new thread1('b'));
+            CustomThread ct3 = new CustomThread(new thread1('c'));
+            CustomThread ct4= new CustomThread(new thread1('d'));
+            CustomThread ct5 = new CustomThread(new thread1('e'));
+            CustomThread ct6 = new CustomThread(new thread1('f'));
+            CustomThread ct7 = new CustomThread(new thread1('g'));
+            CustomThread ct8 = new CustomThread(new thread1('h'));
+            CustomThread ct9 = new CustomThread(new thread1('i'));
+            CustomThread ct10 = new CustomThread(new thread1('j'));
+            CustomThread ct11 = new CustomThread(new thread1('k'));
+            CustomThread ct12 = new CustomThread(new thread1('l'));
+            CustomThread ct13 = new CustomThread(new thread1('m'));
+            CustomThread ct14 = new CustomThread(new thread1('n'));
+            
+            CustomThread ct15 = new CustomThread(new thread1('o'));
+            CustomThread ct16 = new CustomThread(new thread1('p'));
+            CustomThread ct17 = new CustomThread(new thread1('q'));
+            CustomThread ct18 = new CustomThread(new thread1('r'));
+             
+           // CustomThread ct15 = new CustomThread(tr2);
+            CustomThread ct19 = new CustomThread(new thread1('s'));
+            CustomThread ct20 = new CustomThread(new thread1('t'));
+            
+           
+            //CustomThread ct4 = new CustomThread(tr3);
+            
+            // CustomThread ct5 = new CustomThread(tr4);
+            // CustomThread ct6 = new CustomThread(tr2); 
+              
+           //  CustomThread ct4 = new CustomThread(tr2);
+            ct1.runner.join();
+            ct2.runner.join();
+            ct3.runner.join();
+            ct4.runner.join();
+            ct5.runner.join();
+            ct6.runner.join();
+            ct7.runner.join();
+            ct8.runner.join();
+            ct9.runner.join(); 
+            ct10.runner.join();
+            ct11.runner.join(); 
+            ct12.runner.join();
+            ct13.runner.join();
+            ct14.runner.join();
+            
+            
+          
+            ct15.runner.join();
+            ct16.runner.join();
+            ct17.runner.join();
+            ct18.runner.join(); 
+            ct19.runner.join();
+            
+            ct20.runner.join();
+            
+            long endttime = System.nanoTime();
+           // System.out.println(endttime - starttime);
+            System.out.println((endttime - starttime)/1000000);
+            //}
+          /*  TreeMap msgs = new TreeMap();
+            Iterator it = benchmark.transacctions.iterator();
+            while(it.hasNext()){
+                ExtendedTransaction tr = (ExtendedTransaction) it.next();
+                msgs.putAll(tr.msg);
+            }
+            
+            Iterator it2 = msgs.keySet().iterator();
+            while(it2.hasNext()){
+                 Long time = (Long) it2.next();
+                 System.out.print(time +" " + msgs.get(time));
+            }*/
+            int index =97;
+            for (int j = 0; j < 26; j++) {
+                ((TransactionalFile)(benchmark.m.get(String.valueOf((char) (index+j))))).close();
+            }
+      //  }
+              
+            //System.out.println(Thread.currentThread().getName());
+       } catch (InterruptedException ex) {
+            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        //System.out.println(Thread.currentThread().getName());
+    
+        
+    }
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/benchmarks/MainforLocks.java b/Robust/Transactions/TransactionalIOSrc/benchmarks/MainforLocks.java
new file mode 100644 (file)
index 0000000..e74f497
--- /dev/null
@@ -0,0 +1,142 @@
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.benchmarks;
+
+import TransactionalIO.core.TransactionalFile;
+import java.io.FileNotFoundException;
+import java.io.RandomAccessFile;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author navid
+ */
+public class MainforLocks {
+    
+    public static void main(String args[]){
+        try {
+            RandomAccessFile file = new RandomAccessFile("/home/navid/randomwords.text", "rw");
+            benchmark.init();
+            long starttime = System.nanoTime();
+            
+      //      benchmark.filelock.writeLock().lock();
+            lockthread1 thread1 = new lockthread1(file, 'a');
+    //        benchmark.filelock.writeLock().unlock();
+            
+//            benchmark.filelock.writeLock().lock();
+            lockthread1 thread2 = new lockthread1(file, 'b');
+  //          benchmark.filelock.writeLock().unlock();
+            
+     //       benchmark.filelock.writeLock().lock();
+            lockthread1 thread3 = new lockthread1(file, 'c');
+       //     benchmark.filelock.writeLock().unlock();
+            
+         //   benchmark.filelock.writeLock().lock();
+            lockthread1 thread4 = new lockthread1(file, 'd');
+         //   benchmark.filelock.writeLock().unlock(); 
+            
+         //   benchmark.filelock.writeLock().lock();
+            lockthread1 thread5 = new lockthread1(file, 'e');
+         //   benchmark.filelock.writeLock().unlock();
+            
+         //   benchmark.filelock.writeLock().lock();
+            lockthread1 thread6 = new lockthread1(file, 'f');
+         //   benchmark.filelock.writeLock().unlock(); 
+            
+         //   benchmark.filelock.writeLock().lock();
+            lockthread1 thread7 = new lockthread1(file, 'g');
+         //   benchmark.filelock.writeLock().unlock();
+            
+         //   benchmark.filelock.writeLock().lock();
+            lockthread1 thread8 = new lockthread1(file, 'h');
+         //   benchmark.filelock.writeLock().unlock();
+            
+         //   benchmark.filelock.writeLock().lock();
+            lockthread1 thread9 = new lockthread1(file, 'i');
+         //   benchmark.filelock.writeLock().unlock();
+            
+         //   benchmark.filelock.writeLock().lock();
+            lockthread1 thread10 = new lockthread1(file, 'j');
+         //   benchmark.filelock.writeLock().unlock();
+            
+         //   benchmark.filelock.writeLock().lock();
+            lockthread1 thread11 = new lockthread1(file, 'k');
+         //   benchmark.filelock.writeLock().unlock();
+            
+         //   benchmark.filelock.writeLock().lock();
+            lockthread1 thread12 = new lockthread1(file, 'l');
+         //   benchmark.filelock.writeLock().unlock();
+           
+         //   benchmark.filelock.writeLock().lock();
+            lockthread1 thread13 = new lockthread1(file, 'm');
+         //   benchmark.filelock.writeLock().unlock();
+            
+         //   benchmark.filelock.writeLock().lock();
+            lockthread1 thread14 = new lockthread1(file, 'n');
+         //   benchmark.filelock.writeLock().unlock(); 
+            
+         //   benchmark.filelock.writeLock().lock();
+            lockthread1 thread15 = new lockthread1(file, 'o');
+         //   benchmark.filelock.writeLock().unlock();
+            
+         //   benchmark.filelock.writeLock().lock();
+            lockthread1 thread16 = new lockthread1(file, 'p');
+         //   benchmark.filelock.writeLock().unlock();
+            
+         //   benchmark.filelock.writeLock().lock();
+            lockthread1 thread17 = new lockthread1(file, 'q');
+         //   benchmark.filelock.writeLock().unlock();
+            
+         //   benchmark.filelock.writeLock().lock();
+            lockthread1 thread18 = new lockthread1(file, 'r');
+         //   benchmark.filelock.writeLock().unlock();
+            
+         //   benchmark.filelock.writeLock().lock();
+            lockthread1 thread19 = new lockthread1(file, 's');
+         //   benchmark.filelock.writeLock().unlock();
+            
+         //   benchmark.filelock.writeLock().lock();
+            lockthread1 thread20 = new lockthread1(file, 't');
+         //   benchmark.filelock.writeLock().unlock();
+
+            thread1.join();
+            thread2.join();
+            thread3.join();
+            thread4.join();
+            thread5.join();
+            thread6.join();
+            thread7.join();
+            thread8.join();
+            thread9.join();
+            thread10.join();
+            thread11.join();
+            thread12.join();
+            thread13.join();
+            thread14.join();
+            thread15.join();
+            thread16.join();
+            thread17.join();
+            thread18.join();
+            thread19.join();
+            thread20.join();
+
+            long endttime = System.nanoTime();
+            System.out.println(endttime - starttime);
+            System.out.println((endttime - starttime) / 1000000);
+             int index =97;
+            for (int j = 0; j < 26; j++) {
+                ((TransactionalFile)(benchmark.m.get(String.valueOf((char) (index+j))))).close();
+            }
+        } catch (InterruptedException ex) {
+            Logger.getLogger(MainforLocks.class.getName()).log(Level.SEVERE, null, ex);
+        } catch (FileNotFoundException ex) {
+            Logger.getLogger(MainforLocks.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        
+    }
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/benchmarks/StatisticsWrapper.java b/Robust/Transactions/TransactionalIOSrc/benchmarks/StatisticsWrapper.java
new file mode 100644 (file)
index 0000000..5fcf21c
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.benchmarks;
+
+/**
+ *
+ * @author navid
+ */
+public class StatisticsWrapper {
+    
+    public static int totalcommitted;
+    public static int totalaborted;
+
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/benchmarks/benchmark.java b/Robust/Transactions/TransactionalIOSrc/benchmarks/benchmark.java
new file mode 100644 (file)
index 0000000..b611e14
--- /dev/null
@@ -0,0 +1,270 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.benchmarks;
+
+import TransactionalIO.core.Defaults;
+import TransactionalIO.core.TransactionalFile;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+import java.util.Vector;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+
+/**
+ *
+ * @author navid
+ */
+public class benchmark {
+    static public HashMap TransactionalFiles = new HashMap();
+     static public HashMap hotwords = new HashMap();
+     static public HashMap names = new HashMap();
+     static public HashMap reversenames = new HashMap();
+    static int count = 0;
+    public static String msg = new String();
+    public static ReentrantLock lock = new ReentrantLock();
+    public static Vector transacctions = new Vector();
+    public static ReentrantLock filelock = new ReentrantLock();
+    public static Map m;
+    public static Map m2;
+    public static Map m3;
+    public static Map m4;
+    public static String[] stocks;
+    
+
+    public benchmark() {
+        
+    }
+     
+    private static void preparenamelist(){
+        try {
+            byte[] data = new byte[1];
+            char[] name = new char[20];
+            RandomAccessFile file = new RandomAccessFile("/home/navid/namelist.text", "rw");
+            RandomAccessFile file2 = new RandomAccessFile("/home/navid/financialtransaction.text", "rw");
+            RandomAccessFile file3 = new RandomAccessFile("/home/navid/accountbalance.text", "rw");
+            
+           
+          stocks  = new String[20];
+          stocks[0] = "Yahoo";
+          stocks[1] = "Google";
+          stocks[2] = "Microsoft";
+          stocks[3] = "Broadcom";
+          stocks[4] = "Sun";
+          stocks[5] = "Qualcom";
+          stocks[6] = "Intel";
+          stocks[7] = "WaMU";
+          stocks[8] = "BoA";
+          stocks[9] = "IMU";
+          stocks[10] = "BMW";
+          stocks[11] = "Nokia";
+          stocks[12] = "Motorolla";
+          stocks[13] = "Samsung";
+          stocks[14] = "TMobile";
+          stocks[15] = "ATT";
+          stocks[16] = "PRops";
+          stocks[17] = "Asia";
+          stocks[18] = "LOLa";
+          stocks[19] = "Brita";
+        /*          boolean hh = false; 
+           boolean found = false;    
+           while (true) {
+     
+                if (found){
+                    System.out.println(file4.getFilePointer()-1);
+                    file4.seek(file4.getFilePointer()-1);
+                    file4.write(' ');
+                    file4.write(stocks[(int)(Math.random()*10)].getBytes());
+                    file4.write('\n');
+                }
+                if (hh)
+                    break;
+                found = false;
+                data[0] = 'a';
+                while (data[0] != '\n') {
+                    int tt =0;
+                    tt = file4.read(data);
+                    found = true;
+                    if (tt == -1) {
+                        hh = true;
+                        break;
+                    } 
+                }
+           }*/
+            
+            boolean flag = false;
+            boolean done = false;
+            int wordcounter = 0;
+            int counter =0;
+            while(true){
+                if (flag)
+                    break;
+                if (done){
+             //       System.out.println("At " + wordcounter + " inserted " +String.copyValueOf(name, 0, counter));
+                    m3.put(Integer.valueOf(wordcounter), String.copyValueOf(name, 0, counter));
+                    m4.put(String.copyValueOf(name, 0, counter), Integer.valueOf(wordcounter));
+                    wordcounter++;
+                    done = false;
+                }
+                counter = 0;    
+                data[0] = 'a';
+                while (data[0] != '\n') {
+                    int res;
+                    res = file.read(data);
+                    if (res == -1) {
+                        flag = true;
+                        break;
+                    }
+                    //System.out.println((char)data[0]);
+                    if (!(Character.isLetter((char) data[0]))) {
+                        continue;
+                   }
+                   name[counter] = (char)data[0];
+                   done = true;
+                   counter++;
+                }
+          }
+            
+            
+      /*    counter = 0;  
+          while (counter <30000)  {
+              int index1 = (int)(Math.random()*50);
+              int stocktrade = (int)(Math.random()*100);
+              while (stocktrade == 0)
+                  stocktrade = (int)(Math.random()*100);
+              int index2 = (int)(Math.random()*50);
+              while (index2 == index1)
+                  index2 = (int)(Math.random()*50);
+              //System.out.println(index);
+              String towrite = (String)m3.get(Integer.valueOf(index1)) + " ";
+              towrite += String.valueOf(stocktrade) + " ";
+              towrite += (String)m3.get(Integer.valueOf(index2)) + " ";
+              towrite += stocks[(int)(Math.random()*20)] + "\n";
+              
+              file2.write(towrite.getBytes());
+            //  System.out.println(towrite);
+              counter++;
+          }*/
+         // for (int i=0; i<50*Defaults.FILEFRAGMENTSIZE; i++)
+              //file3.write('');
+        
+          
+          for (int i=0; i<50; i++){
+              String towrite = (String)m3.get(Integer.valueOf(i)) +"\n";
+              for (int j=0; j<stocks.length; j++)
+                towrite +=  stocks[j] + " Stock Balance: " + ((int)(Math.random()*100+100)) + "             \n";
+              System.out.println(towrite);
+              file3.write(towrite.getBytes());
+              while (file3.getFilePointer()<(i+1)*Defaults.FILEFRAGMENTSIZE)
+                  file3.write(new String(" ").getBytes());    
+          }
+          
+
+        /*  for (int i=0; i<10; i++)
+              System.out.println((char)f[i]);*/
+          file.close();
+//          file2.close();
+          file3.close();
+        } catch (IOException ex) {
+            Logger.getLogger(benchmark.class.getName()).log(Level.SEVERE, null, ex);
+        } 
+       
+    
+    }
+
+    public static void init(){
+        try {
+
+            m3 = Collections.synchronizedMap(names);
+            m4 = Collections.synchronizedMap(reversenames);
+
+
+
+
+           preparenamelist();
+            count = 0;
+            m = Collections.synchronizedMap(TransactionalFiles);
+            TransactionalFile tr = new TransactionalFile("/home/navid/randomwords.text", "rw");
+            m.put(String.valueOf(count), tr);
+            count++;
+            TransactionalFile tr2 = new TransactionalFile("/home/navid/input.text", "rw");
+            m.put(String.valueOf(count), tr2);
+            count++;
+            TransactionalFile tr3 = new TransactionalFile("/home/navid/iliad.text", "rw");
+            m.put(String.valueOf(count), tr3);
+            count++;
+            TransactionalFile tr4 = new TransactionalFile("/home/navid/counter_benchmark_output.text", "rw");
+            m.put(String.valueOf(count), tr4);
+            count++;
+
+            TransactionalFile tr5 = new TransactionalFile("/home/navid/financialtransaction.text", "rw");
+            m.put(String.valueOf(count), tr5);
+
+            count++;
+
+            TransactionalFile tr6 = new TransactionalFile("/home/navid/accountbalance.text", "rw");
+            m.put(String.valueOf(count), tr6);
+
+            count++;
+
+            TransactionalFile tr7 = new TransactionalFile("/home/navid/financialtransactionlog.text", "rw");
+            m.put(String.valueOf(count), tr7);
+
+            count++;
+
+            RandomAccessFile tr8 = new RandomAccessFile("/home/navid/accountbalance.text", "rw");
+            m.put(String.valueOf(count), tr8);
+//
+            count++;
+
+            RandomAccessFile tr9 = new RandomAccessFile("/home/navid/financialtransactionlog.text", "rw");
+            m.put(String.valueOf(count), tr9);
+
+            count++;
+
+            int index = 97;
+            for (int i = 0; i < 26; i++) {
+                //     System.out.println("here " +String.valueOf((char)(index+i)));
+                m.put(String.valueOf((char) (index+i)), new TransactionalFile("/home/navid/" + String.valueOf((char) (index+i)) + ".text", "rw"));
+                count++;
+            }
+            count = 0;
+            m2 = Collections.synchronizedMap(hotwords);
+            m2.put(Integer.valueOf(count), "Polydamas");
+            count++;
+            m2.put(Integer.valueOf(count), "Cebriones");
+            count++;
+            m2.put(Integer.valueOf(count), "Eurybates");
+            count++;
+            m2.put(Integer.valueOf(count), "Menoetius");
+            count++;
+            m2.put(Integer.valueOf(count), "countless");
+            count++;
+            m2.put(Integer.valueOf(count), "huntsman");
+            count++;
+            m2.put(Integer.valueOf(count), "presence");
+            count++;
+            m2.put(Integer.valueOf(count), "pursuit");
+            count++;
+            m2.put(Integer.valueOf(count), "masterfully");
+            count++;
+            m2.put(Integer.valueOf(count), "unweariable");
+        } catch (FileNotFoundException ex) {
+            Logger.getLogger(benchmark.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        
+    }
+    
+
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/benchmarks/customhandler.java b/Robust/Transactions/TransactionalIOSrc/benchmarks/customhandler.java
new file mode 100644 (file)
index 0000000..7d0d1b1
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.benchmarks;
+
+import TransactionalIO.core.CustomThread;
+import TransactionalIO.core.ExtendedTransaction;
+import TransactionalIO.core.ExtendedTransaction.Status;
+import TransactionalIO.interfaces.TransactionStatu;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+/**
+ *
+ * @author navid
+ */
+    public class customhandler implements PropertyChangeListener{
+    private Object abortcondition;    
+        
+    public void setAbortCondition(Object abortcondition){
+        this.abortcondition = abortcondition;
+    }
+
+    public customhandler() {
+    }
+
+    
+    public customhandler(Object abortcondition) {
+        this.abortcondition = abortcondition;
+    }
+
+    public void propertyChange(PropertyChangeEvent e) {
+        if (e.getNewValue().equals(abortcondition))
+        if (e.getSource().getClass() == ExtendedTransaction.class){
+            //if (e.getNewValue() == Status.ABORTED){
+//                ((ExtendedTransaction)e.getSource()).memorystate.abort();
+               // synchronized(benchmark.lock)
+               // {
+                    //System.out.println("1- " +Thread.currentThread() + " " + e.getNewValue());
+                    //System.out.println("2- " +CustomThread.getTransaction());
+               //     System.out.println("3- " +e.getSource());
+                //}
+            // Code for aborting the memory system for the correspondent Thread(transaction) 
+            //Thread.getTransaction().abort();
+            //}
+        }
+        else{ 
+               //check to see if the memory is aborted
+            e.getSource().getClass().cast(e.getSource()).hashCode();
+               
+        }
+        
+        if (e.getNewValue().equals(abortcondition))
+            if (((TransactionStatu)e.getSource()).getOtherSystem() != null)
+                ((TransactionStatu)e.getSource()).getOtherSystem().abortThisSystem();
+    }
+
+}
+     
+
diff --git a/Robust/Transactions/TransactionalIOSrc/benchmarks/lockthread1.java b/Robust/Transactions/TransactionalIOSrc/benchmarks/lockthread1.java
new file mode 100644 (file)
index 0000000..9d5ca4d
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.benchmarks;
+
+import TransactionalIO.core.TransactionalFile;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author navid
+ */
+public class lockthread1 extends Thread{
+
+    RandomAccessFile f1;
+    char sample;
+    public lockthread1(RandomAccessFile file, char sample) {
+        f1 = file;
+        this.sample = sample;
+        this.start();
+    }
+
+    
+    
+    public void run(){
+        try {
+
+
+            //  f1.read(b);
+            byte[] b = new byte[20];
+            for (int j = 0; j < 19; j++) {
+                b[j] = (byte) sample;
+            }
+            b[19] = (byte) '\n';
+
+            
+
+            //  f1 = (TransactionalFile)benchmark.m.get("0");
+            //  f1 = (TransactionalFile)benchmark.m.get("0");
+            byte[] data = new byte[1];
+            char[] holder = new char[40];
+            benchmark.filelock.lock();
+
+            long toseek = Integer.valueOf(Thread.currentThread().getName().substring(7)) * 20448;
+            f1.seek(toseek);
+
+            data[0] = 'a';
+            if (toseek != 0) {
+                //////////////// skipt the first word since its been read already
+                while (data[0] != '\n') {
+                    f1.read(data);
+                }
+            }
+            while (f1.getFilePointer() < toseek + 20448) {
+                data[0] = 'a';
+                int i = 0;
+                int result = 0;
+                while (data[0] != '\n') {
+                    result = f1.read(data);
+                    holder[i] = (char) data[0];
+                    i++;
+                }
+
+                byte[] towrite = new byte[String.valueOf(holder, 0, i).length()];
+                towrite = String.valueOf(holder, 0, i).getBytes();
+                try {
+                    ((TransactionalFile) (benchmark.m.get(String.valueOf(holder,0,i).toLowerCase().substring(0, 1)))).file.write(towrite);
+                } catch (IOException ex) {
+                    Logger.getLogger(thread1.class.getName()).log(Level.SEVERE, null, ex);
+                }
+            }
+
+            benchmark.filelock.unlock();
+        } catch (IOException ex) {
+            Logger.getLogger(lockthread1.class.getName()).log(Level.SEVERE, null, ex);
+        }
+           
+
+
+    }
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/benchmarks/thread1.java b/Robust/Transactions/TransactionalIOSrc/benchmarks/thread1.java
new file mode 100644 (file)
index 0000000..fe63b8a
--- /dev/null
@@ -0,0 +1,489 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.benchmarks;
+
+import TransactionalIO.core.TransactionalFile;
+import TransactionalIO.interfaces.TransactionalProgram;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.util.Random;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author navid
+ */
+public class thread1 implements TransactionalProgram{
+
+    char sample;
+    TransactionalFile tf;
+    Vector v = new Vector();
+            
+    public thread1(char sample, TransactionalFile tf) {
+        this.sample = sample;
+        this.tf = tf;
+        v.add("Real State");
+        v.add("Loan");
+        v.add("Mortgage");
+        v.add("Account");
+        v.add("Debit-card Purchase");
+        v.add("Credit-card Purchase");
+       
+    }
+    
+    public thread1(char sample) {
+        this.sample = sample;
+        this.tf = null;
+       /* v.add("Real State");
+        v.add("Loan");
+        v.add("Mortgage");
+        v.add("Account");
+        v.add("Debit-card Purchase");
+        v.add("Credit-card Purchase");*/
+       
+    }
+
+    
+
+    
+   
+    public void execute() {
+        //TransactionalFile f1 = (TransactionalFile)benchmark.TransactionalFiles.get("0");
+            TransactionalFile f1;
+            if (tf != null)
+                f1 = tf;
+            else 
+                f1 = (TransactionalFile)benchmark.m.get("0");
+            byte[] b = new byte[20];
+            byte[] data = new byte[1];
+            char[] holder = new char[40];
+   
+            
+           long toseek = (Integer.valueOf(Thread.currentThread().getName().substring(7)))%20 * 20448; 
+           f1.seek(toseek);
+           
+           data[0] ='a';
+           if (toseek != 0) //////////////// skipt the first word since its been read already
+                while (data[0] != '\n'){
+                    f1.read(data);
+                }
+               
+               
+           while (f1.getFilePointer() < toseek +20448)
+           {
+                data[0] = 'a';
+                int i = 0;
+                int result = 0;
+                while (data[0] != '\n'){
+                    result = f1.read(data);
+                    holder[i] = (char)data[0];
+                    i++;
+                }
+                
+                byte[] towrite = new byte[String.valueOf(holder,0,i).length()];
+                towrite = String.valueOf(holder,0,i).getBytes();
+               try {
+                      ((TransactionalFile) (benchmark.m.get(String.valueOf(holder,0,i).toLowerCase().substring(0, 1)))).write(towrite);         
+                      
+                } catch (IOException ex) {
+                    Logger.getLogger(thread1.class.getName()).log(Level.SEVERE, null, ex);
+                }
+           }
+        
+          
+           // for (int k=0; k< i; k++)
+           //     System.out.println(Thread.currentThread() + " " +holder[k]);
+          //  f1.seek(40);
+          //  System.out.println("current offset " +f1.getFilePointer());
+          //  f1.write(b);
+          //  f1.write(b);
+            
+            
+          //  f1.write(b);
+            //
+          
+          
+          /*  for (int i =0; i< 2000; i++){
+                
+                String str = "Number: " + (Integer.valueOf(Thread.currentThread().getName().substring(7))*200+i) +"\nType: " + v.get((int)(Math.random()*6)) + "\n\n";
+                byte[] buff; 
+                char[] charar =  new char[str.length()];
+                charar = str.toCharArray();
+                buff = new byte[str.length()];
+                for (int j=0; j<str.length(); j++)
+                    buff[j] = (byte) charar[j];
+                
+                f1.write(buff);
+            }*/
+            
+      /*      f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+          //  f1.seek(0);
+           // f1.seek(0);
+         //   f1.getFilePointer();
+           // synchronized(benchmark.lock){
+              //   /*System.out.println(Thread.currentThread() +" 1-offset " + *///f1.getFilePointer();
+            //}
+          //      synchronized(benchmark.lock){
+          // f1.getFilePointer();
+            //   }
+           /// f1.read(bread);
+    /*        f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);*/
+            /*f1.read(bread);
+           // f1.seek(0);
+            
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);*/
+            
+          /*  f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);*/
+         //   f1.seek(0);
+          //  f1.read(bread2);
+          /*  synchronized(benchmark.lock){
+                for (int j =0; j<20; j++)
+                    System.out.println(j+1 + "-" +Thread.currentThread() + "   " + (char)bread2[j]); 
+                }*/
+           // f1.read(bread);
+               /*synchronized(benchmark.lock){
+                for (int j =0; j<20; j++)
+                    System.out.println(j+1 + "-" +Thread.currentThread() + "   " + (char)bread[j]); 
+                }*/
+           //f1.read(bread);
+            //*synchronized(benchmark.lock){
+       //         for (int j =0; j<20; j++)
+          //          System.out.println(j+1 + "-" +Thread.currentThread() + "   " + (char)bread[j]); 
+          //      }*/
+             //  f1.read(bread);
+           /*    synchronized(benchmark.lock){
+                for (int j =0; j<20; j++)
+                    System.out.println(j+1 + "-" +Thread.currentThread() + "   " + (char)bread[j]); 
+                }*/
+               //  f1.read(bread);
+           /*      synchronized(benchmark.lock){
+                for (int j =0; j<20; j++)
+                    System.out.println(j+1 + "-" +Thread.currentThread() + "   " + (char)bread[j]); 
+                }*/
+             //f1.read(bread);
+       /*      synchronized(benchmark.lock){
+                for (int j =0; j<20; j++)
+                    System.out.println(j+1 + "-" +Thread.currentThread() + "   " + (char)bread[j]); 
+                }*/
+              //f1.read(bread);
+              /*synchronized(benchmark.lock){
+                for (int j =0; j<20; j++)
+                    System.out.println(j+1 + "-" +Thread.currentThread() + "   " + (char)bread[j]); 
+                }*/
+               //f1.read(bread);
+               /*synchronized(benchmark.lock){
+                for (int j =0; j<20; j++)
+                    System.out.println(j+1 + "-" +Thread.currentThread() + "   " + (char)bread[j]); 
+                }*/
+               /*
+               f1.read(bread);
+                 f1.read(bread2);
+            f1.read(bread);
+            f1.read(bread);
+               f1.read(bread);
+                 f1.read(bread2);
+             f1.read(bread);
+              f1.read(bread);
+               f1.read(bread);
+               f1.read(bread);
+            
+                 f1.read(bread2);
+            f1.read(bread);
+            f1.read(bread);
+               f1.read(bread);
+                 f1.read(bread2);
+             f1.read(bread);
+              f1.read(bread);
+               f1.read(bread);
+               f1.read(bread);
+            
+            
+             
+           // f1.seek(0);
+          /*      synchronized(benchmark.lock){
+                for (int j =0; j<20; j++)
+                    System.out.println(j+1 + "-" +Thread.currentThread() + "   " + (char)bread[j]); 
+                }
+                 synchronized(benchmark.lock){
+                for (int j =0; j<20; j++)
+                    System.out.println(j+1 + "-" +Thread.currentThread() + "   " + (char)bread2[j]); 
+                }
+            */
+           /* synchronized(benchmark.lock){
+                 System.out.println(Thread.currentThread() +" 2-offset " + f1.getFilePointer());
+            }*/
+            /*f1.write(b);
+            f1.write(b);
+           // f1.seek(0);
+           
+            f1.write(b);
+            f1.write(b);*/
+            
+            
+             /* synchronized(benchmark.lock){
+                 System.out.println(Thread.currentThread() +" 3-offset " + f1.getFilePointer());
+            }*/
+           // f1.seek(50);
+           /* synchronized(benchmark.lock){
+                 System.out.println(Thread.currentThread() +" 4-offset " + f1.getFilePointer());
+            }*/
+               // f1.read(bread);
+            /*    synchronized(benchmark.lock){
+                for (int j =0; j<20; j++)
+                    System.out.println(j+1 + "-" +Thread.currentThread() + "   " + (char)bread[j]); 
+                }*/
+               // f1.read(bread);
+                /*synchronized(benchmark.lock){
+                for (int j =0; j<20; j++)
+                    System.out.println(j+1 + "-" +Thread.currentThread() + "   " + (char)bread[j]);
+                }*/
+               // f1.read(bread);
+                /*synchronized(benchmark.lock){
+                for (int j =0; j<20; j++)
+                    System.out.println(j+1 + "-" +Thread.currentThread() + "   " + (char)bread[j]);
+                }*/
+               // f1.read(bread);
+                /*synchronized(benchmark.lock){
+                for (int j =0; j<20; j++)
+                    System.out.println(j+1 + "-" +Thread.currentThread() + "   " + (char)bread[j]);
+                }*/
+                
+                //f1.read(bread);
+                /*synchronized(benchmark.lock){
+                for (int j =0; j<20; j++)
+                    System.out.println(j+1 + "-" +Thread.currentThread() + "   " + (char)bread[j]);
+                }*/
+            /*  synchronized(benchmark.lock){
+                 System.out.println(Thread.currentThread() +" 5-offset " + f1.getFilePointer());
+            }*/
+            //System.out.println("offset " + f1.getFilePointer());
+           /* for (int j =0; j<20; j++)
+                System.out.println(j+1 + "-" +Thread.currentThread() + "   " + (char)bread[j]);*/
+           /* f1.read(bread);
+            System.out.println("offset " + f1.getFilePointer());*/
+           // for (int j =0; j<20; j++)
+            //    System.out.println(j+1 + "-" +Thread.currentThread() + "   " + (char)bread[j]);
+          //  f1.write(b);
+         /*    synchronized(benchmark.lock){
+                 System.out.println(Thread.currentThread() +" 6-offset " + f1.getFilePointer());
+            }*/
+            //f1.read(bread);
+            /*  synchronized(benchmark.lock){
+                 System.out.println(Thread.currentThread() +" 5-offset " + f1.getFilePointer());
+            }*/
+           // System.out.println("offset " + f1.getFilePointer());
+            /*f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);
+            f1.read(bread);*/
+           // f1.write(b);
+           // f1.write(b);
+            
+         
+        
+          //  f1.seek(40);
+            
+            //   for (int j =0; j<10; j++)
+            //    System.out.println((char) b[j]);
+
+//        } catch (IOException ex) {
+   //       Logger.getLogger(thread1.class.getName()).log(Level.SEVERE, null, ex);
+   //     }
+       // TransactionalFile f1 = new TransactionalFile("/home/navid/output1.txt", "rw");
+       // TransactionalFile f1 = new TransactionalFile("/home/navid/output1.txt", "rw");
+       // TransactionalFile f1 = new TransactionalFile("/home/navid/output1.txt", "rw");
+    }
+    
+
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/benchmarks/thread2.java b/Robust/Transactions/TransactionalIOSrc/benchmarks/thread2.java
new file mode 100644 (file)
index 0000000..793c666
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.benchmarks;
+
+import TransactionalIO.core.TransactionalFile;
+import TransactionalIO.interfaces.TransactionalProgram;
+
+/**
+ *
+ * @author navid
+ */
+public class thread2 implements TransactionalProgram{
+
+    public void execute() {
+        TransactionalFile tf1 = (TransactionalFile) benchmark.TransactionalFiles.get("0");
+        //TransactionalFile tf1 = new TransactionalFile("/home/navid/output.text", "rw");
+        byte[] b = new byte[20];
+       // tf1.seek(20);
+        int i = tf1.read(b);
+        i = tf1.read(b);
+        i = tf1.read(b);
+        i = tf1.read(b);
+           i = tf1.read(b);
+              i = tf1.read(b);
+                 i = tf1.read(b);
+                    i = tf1.read(b);
+                       i = tf1.read(b);
+                          i = tf1.read(b);
+                             i = tf1.read(b);
+                                i = tf1.read(b);
+                                
+
+    }
+
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/benchmarks/thread3.java b/Robust/Transactions/TransactionalIOSrc/benchmarks/thread3.java
new file mode 100644 (file)
index 0000000..defed14
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.benchmarks;
+
+import TransactionalIO.core.TransactionalFile;
+import TransactionalIO.interfaces.TransactionalProgram;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author navid
+ */
+public class thread3 implements TransactionalProgram{
+
+    
+      public void execute() {
+        TransactionalFile f1 = (TransactionalFile)benchmark.TransactionalFiles.get("0");
+        byte[] b = new byte[30];
+     //   int i = f1.read(b);
+     //   i = f1.read(b);
+    //    i = f1.read(b);
+     //   i = f1.read(b);
+     //   i = f1.read(b);
+     //   i = f1.read(b);
+       // System.out.println(i);
+       // for (int j =0; j<10; j++)
+    //        System.out.println((char) b[j]);
+        try {
+          //  f1.read(b);
+            for (int j =0; j<30; j++)
+                b[j] = 'k';
+          //  f1.seek(40);
+          //  System.out.println("current offset " +f1.getFilePointer());
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+          //  f1.seek(40);
+            //f1.read(b);
+            //   for (int j =0; j<10; j++)
+            //    System.out.println((char) b[j]);
+
+        } catch (IOException ex) {
+            Logger.getLogger(thread1.class.getName()).log(Level.SEVERE, null, ex);
+        }
+       // TransactionalFile f1 = new TransactionalFile("/home/navid/output1.txt", "rw");
+       // TransactionalFile f1 = new TransactionalFile("/home/navid/output1.txt", "rw");
+       // TransactionalFile f1 = new TransactionalFile("/home/navid/output1.txt", "rw");
+    }
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/benchmarks/thread4.java b/Robust/Transactions/TransactionalIOSrc/benchmarks/thread4.java
new file mode 100644 (file)
index 0000000..cbbde6d
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.benchmarks;
+
+import TransactionalIO.core.TransactionalFile;
+import TransactionalIO.interfaces.TransactionalProgram;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author navid
+ */
+public class thread4  implements TransactionalProgram{
+    public void execute() {
+        TransactionalFile f1 = (TransactionalFile)benchmark.TransactionalFiles.get("0");
+        byte[] b = new byte[40];
+     //   int i = f1.read(b);
+     //   i = f1.read(b);
+    //    i = f1.read(b);
+     //   i = f1.read(b);
+     //   i = f1.read(b);
+     //   i = f1.read(b);
+       // System.out.println(i);
+       // for (int j =0; j<10; j++)
+    //        System.out.println((char) b[j]);
+        try {
+          //  f1.read(b);
+            for (int j =0; j<40; j++)
+                b[j] = 'l';
+          //  f1.seek(40);
+          //  System.out.println("current offset " +f1.getFilePointer());
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+            f1.write(b);
+          //  f1.seek(40);
+            //f1.read(b);
+            //   for (int j =0; j<10; j++)
+            //    System.out.println((char) b[j]);
+
+        } catch (IOException ex) {
+            Logger.getLogger(thread1.class.getName()).log(Level.SEVERE, null, ex);
+        }
+       // TransactionalFile f1 = new TransactionalFile("/home/navid/output1.txt", "rw");
+       // TransactionalFile f1 = new TransactionalFile("/home/navid/output1.txt", "rw");
+       // TransactionalFile f1 = new TransactionalFile("/home/navid/output1.txt", "rw");
+    }
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/core/BlockDataStructure.java b/Robust/Transactions/TransactionalIOSrc/core/BlockDataStructure.java
new file mode 100644 (file)
index 0000000..8370c09
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.core;
+
+
+import java.util.Vector;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/**
+ *
+ * @author navid
+ */
+public class BlockDataStructure {
+    private ReentrantReadWriteLock lock;
+    private ExtendedTransaction owner;
+    private INode inode;
+    private int blocknumber;
+    private AtomicInteger version;
+    private int referncount;
+    //private Vector<ExtendedTransaction> readers;
+    private Vector blockreaders;
+
+    public static enum MODE {READ, WRITE, READ_WRITE};
+    private MODE accessmode;
+    
+    protected BlockDataStructure(INode inode, int blocknumber) {
+        version = new AtomicInteger(0);
+        //lock = new ReentrantReadWriteLock();
+        blockreaders = new Vector();
+        lock = new ReentrantReadWriteLock();
+        this.inode = inode;
+        this.blocknumber = blocknumber;
+        referncount = 0;
+        owner = null;
+    }
+
+    public Vector getReaders() {
+        return blockreaders;
+    }
+
+    public void setReaders(Vector readers) {
+        this.blockreaders = readers;
+    }
+    
+    public ReentrantReadWriteLock getLock() {
+        return lock;
+    }
+
+    public void setLock(ReentrantReadWriteLock lock) {
+        this.lock = lock;
+    }
+
+    public synchronized ExtendedTransaction getOwner() {
+        return owner;
+    }
+    
+    public synchronized void setOwner(ExtendedTransaction owner) {
+        this.owner = owner;
+    }
+
+    public INode getInode() {
+        return inode;
+    }
+
+    public void setInode(INode inode) {
+        this.inode = inode;
+    }
+
+    public int getBlocknumber() {
+        return blocknumber;
+    }
+
+    public void setBlocknumber(int blocknumber) {
+        this.blocknumber = blocknumber;
+    }
+
+    public AtomicInteger getVersion() {
+        return version;
+    }
+
+    public void setVersion(AtomicInteger version) {
+        this.version = version;
+    }
+
+    public MODE getAccessmode() {
+        return accessmode;
+    }
+
+    public void setAccessmode(MODE accessmode) {
+        this.accessmode = accessmode;
+    }
+
+    public synchronized int getReferncount() {
+        return referncount;
+    }
+
+    public synchronized void setReferncount(int referncount) {
+        this.referncount = referncount;
+    }
+    
+    
+
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/core/CustomLock.java b/Robust/Transactions/TransactionalIOSrc/core/CustomLock.java
new file mode 100644 (file)
index 0000000..265716b
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.core;
+
+
+import TransactionalIO.benchmarks.benchmark;
+import TransactionalIO.benchmarks.thread1;
+import TransactionalIO.interfaces.TransactionalProgram;
+
+/**
+ *
+ * @author navid
+ */
+public class CustomLock implements Runnable{
+
+    private static ThreadLocal transactioncontainer = new ThreadLocal();
+    private TransactionalProgram ioprogram;
+    private static ThreadLocal/*<TransactionalProgram>*/ program = new ThreadLocal();
+    private ExtendedTransaction transaction;
+    public Thread runner;
+    
+   
+    public CustomLock(TransactionalProgram ioprogram) {
+        this.ioprogram = ioprogram;
+        transaction = new ExtendedTransaction();
+        runner = new Thread(this);
+        runner.start();
+    }
+    
+    public static void setTransaction(ExtendedTransaction transaction){
+        transactioncontainer.set(transaction);
+    }
+    
+    public static ExtendedTransaction getTransaction(){
+        return (ExtendedTransaction) transactioncontainer.get(); 
+    }
+    
+    public static void setProgram(TransactionalProgram transaction){
+        program.set(transaction);
+    }
+    
+    public static TransactionalProgram getProgram(){
+        return (TransactionalProgram) program.get(); 
+    }
+    
+    
+    public void run() {
+        setTransaction(transaction);
+        setProgram(ioprogram);
+        synchronized(benchmark.lock){
+            benchmark.transacctions.add(transaction);
+        }
+//        System.out.println(Thread.currentThread().getName());
+        ioprogram.execute();
+        transaction.prepareCommit();
+        transaction.commitChanges();
+    }
+    
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/core/CustomThread.java b/Robust/Transactions/TransactionalIOSrc/core/CustomThread.java
new file mode 100644 (file)
index 0000000..429f34c
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.core;
+
+import TransactionalIO.exceptions.AbortedException;
+import TransactionalIO.benchmarks.benchmark;
+import TransactionalIO.interfaces.TransactionalProgram;
+import java.io.IOException;
+import java.util.Vector;
+
+/**
+ *
+ * @author navid
+ */
+public class CustomThread implements Runnable{
+
+    
+    private static ThreadLocal transactioncontainer = new ThreadLocal();
+    private static ThreadLocal onAbort = new ThreadLocal();
+    private TransactionalProgram ioprogram;
+    private static ThreadLocal/*<TransactionalProgram>*/ program = new ThreadLocal();
+    private ExtendedTransaction transaction;
+    public Thread runner;
+   
+    
+   
+    public CustomThread(TransactionalProgram ioprogram) {
+        this.ioprogram = ioprogram;
+        runner = new Thread(this);
+        runner.start();
+    }
+    
+    
+    
+  /*  public static void setTransaction(ExtendedTransaction transaction){
+        transactioncontainer.set(transaction);
+    }
+    
+    public static ExtendedTransaction getTransaction(){
+        return (ExtendedTransaction) transactioncontainer.get(); 
+    }*/
+    
+    public static void setProgram(TransactionalProgram transaction){
+        program.set(transaction);
+    }
+    
+    public static TransactionalProgram getProgram(){
+        return (TransactionalProgram) program.get(); 
+    }
+    
+    public static Vector getonAbort(){
+        return (Vector) onAbort.get();
+    }
+    
+    public static void setonAbort(Vector s){
+        onAbort.set(s);
+    }
+    
+    
+    public void run() {
+      
+        setProgram(ioprogram);
+       // setonAbort(new Vector());
+//        System.out.println(Thread.currentThread().getName());
+        while (true){
+            try{
+               /* getonAbort().add(new terminateHandler() {
+                    public void cleanup() {
+                        synchronized(benchmark.lock){
+                            System.out.println(Thread.currentThread() +" KEWL");
+                        }
+                    }
+                });
+                */
+                
+                Wrapper.Initialize(null);
+              //  transaction = new ExtendedTransaction();
+               // setTransaction(transaction);
+                synchronized(benchmark.lock){
+                    benchmark.transacctions.add(Wrapper.getTransaction());
+                }
+                ioprogram.execute();
+                Wrapper.prepareIOCommit();
+                
+                Wrapper.commitIO();
+                 break;
+            }
+            catch (AbortedException e){
+              /*  Iterator it = getonAbort().iterator();
+                while(it.hasNext()) {
+                    terminateHandler th = (terminateHandler)it.next();
+                    th.cleanup();
+                }
+                getonAbort().clear();*/
+                
+                
+             /*   synchronized(benchmark.lock){
+                    System.out.println(Thread.currentThread() +" retried");
+                }*/
+               
+            }
+            finally{
+                Wrapper.getTransaction().unlockAllLocks();
+            }
+        }
+    }
+    
+
+   
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/core/Defaults.java b/Robust/Transactions/TransactionalIOSrc/core/Defaults.java
new file mode 100644 (file)
index 0000000..cf8d075
--- /dev/null
@@ -0,0 +1,73 @@
+package TransactionalIO.core;
+
+/*
+ * Defaults.java
+ *
+ * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa
+ * Clara, California 95054, U.S.A.  All rights reserved.  
+ * 
+ * Sun Microsystems, Inc. has intellectual property rights relating to
+ * technology embodied in the product that is described in this
+ * document.  In particular, and without limitation, these
+ * intellectual property rights may include one or more of the
+ * U.S. patents listed at http://www.sun.com/patents and one or more
+ * additional patents or pending patent applications in the U.S. and
+ * in other countries.
+ * 
+ * U.S. Government Rights - Commercial software.
+ * Government users are subject to the Sun Microsystems, Inc. standard
+ * license agreement and applicable provisions of the FAR and its
+ * supplements.  Use is subject to license terms.  Sun, Sun
+ * Microsystems, the Sun logo and Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other
+ * countries.  
+ * 
+ * This product is covered and controlled by U.S. Export Control laws
+ * and may be subject to the export or import laws in other countries.
+ * Nuclear, missile, chemical biological weapons or nuclear maritime
+ * end uses or end users, whether direct or indirect, are strictly
+ * prohibited.  Export or reexport to countries subject to
+ * U.S. embargo or to entities identified on U.S. export exclusion
+ * lists, including, but not limited to, the denied persons and
+ * specially designated nationals lists is strictly prohibited.
+ */
+
+
+
+/**
+ * 
+ * @author Maurice Herlihy
+ */
+
+
+public class Defaults {
+  /**
+   * how many threads
+   **/
+  public static final int THREADS = 1;
+  /**
+   * benchmark duration in milliseconds
+   **/
+  public static final int TIME = 10000;
+  /**
+   * uninterpreted arg passed to benchmark
+   **/
+  public static final int EXPERIMENT = 100;
+  /**
+   * fully-qualified contention manager name
+   **/
+  public static final String MANAGER = "dstm2.manager.BackoffManager";
+  /**
+   * fully-qualified factory name
+   **/
+  public static final String FACTORY = "dstm2.factory.shadow.Factory";
+  /**
+   * fully-qualified adapter name
+   **/
+  public static final String ADAPTER = "dstm2.factory.shadow.Adapter";;
+  
+  public static final int FILEFRAGMENTSIZE= 1024;
+  
+  public static final boolean READWRITECONFLIT = true;
+  
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/core/ExtendedTransaction.java b/Robust/Transactions/TransactionalIOSrc/core/ExtendedTransaction.java
new file mode 100644 (file)
index 0000000..42b757a
--- /dev/null
@@ -0,0 +1,971 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package TransactionalIO.core;
+
+
+
+
+
+import TransactionalIO.exceptions.AbortedException;
+import TransactionalIO.benchmarks.benchmark;
+import TransactionalIO.benchmarks.customhandler;
+import TransactionalIO.benchmarks.customhandler;
+import TransactionalIO.interfaces.BlockAccessModesEnum;
+import TransactionalIO.interfaces.ContentionManager;
+import TransactionalIO.interfaces.TransactionStatu;
+//import dstm2.file.managers.BaseManager;
+import java.awt.event.ActionListener;
+import java.beans.EventHandler;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.FileDescriptor;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.Vector;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author navid
+ */
+public class ExtendedTransaction implements TransactionStatu {
+    
+    
+    private native int nativepwrite(byte buff[], long offset, int size, FileDescriptor fd);
+    
+    {
+        System.load("/home/navid/libkooni.so");
+    }
+    
+    private boolean flag = true;
+    public TransactionStatu memorystate; 
+    private PropertyChangeSupport changes = new PropertyChangeSupport(this);
+    public int starttime;
+    public int endtime;
+    
+    public TreeMap msg = new TreeMap();
+    public int numberofwrites;
+    public int numberofreads;
+    
+    public enum Status {ABORTED, ACTIVE, COMMITTED};
+    private boolean writesmerged = true;
+    
+    //private Vector<ReentrantLock> heldoffsetlocks;    
+    private Vector heldoffsetlocks;    
+    
+    //private Vector<ReentrantLock> heldblocklocks;    
+    private Vector heldblocklocks;
+    
+    //private HashMap<INode, Vector<TransactionalFile>> AccessedFiles;
+    private HashMap AccessedFiles;  
+    
+    //private HashMap<INode, HashMap<Integer, BlockAccessModesEnum> > accessedBlocks;
+    private HashMap accessedBlocks; 
+   
+     //private HashMap<TransactionalFile, TransactionLocalFileAttributes> LocaltoGlobalMappings;
+    private HashMap GlobaltoLocalMappings;
+    
+    public HashMap merge_for_writes_done;
+    
+   
+   
+    
+    private HashMap writeBuffer;
+    
+    private ContentionManager contentionmanager;
+    private /*volatile*/ Status status;
+    
+    private int id;
+
+
+    
+    public ExtendedTransaction() {
+      //  super();
+       // id = Integer.valueOf(Thread.currentThread().getName().substring(7));
+        heldblocklocks = new Vector() ;
+        heldoffsetlocks= new Vector();
+        AccessedFiles = new HashMap();
+        GlobaltoLocalMappings = new HashMap/*<TransactionalFile, TransactionLocalFileAttributes >*/();
+        writeBuffer = new HashMap();
+        status = Status.ACTIVE;
+        accessedBlocks = new HashMap();
+        merge_for_writes_done = new HashMap();
+        writesmerged = true;
+     //   setContentionmanager(new BaseManager());
+    //    beginTransaction();
+        
+    }
+    
+    public ExtendedTransaction(TransactionStatu memorystate){
+        this();
+        /*    heldblocklocks = new Vector() ;
+        heldoffsetlocks= new Vector();
+        AccessedFiles = new HashMap();
+        GlobaltoLocalMappings = new HashMap();
+        writeBuffer = new HashMap();
+        status = Status.ACTIVE;
+        accessedBlocks = new HashMap();
+        merge_for_writes_done = new HashMap();
+        writesmerged = true;*/
+        this.memorystate = memorystate ;
+    }
+    
+     private int invokeNativepwrite(byte buff[], long offset, int size, RandomAccessFile file) {
+        try {
+            //System.out.println(buff.length);
+           // System.out.println(offset);
+            return nativepwrite(buff, offset, buff.length, file.getFD());
+        } catch (IOException ex) {
+            
+            Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex);
+            return -1;
+        }
+        
+    }
+    
+    public void beginTransaction(){
+        this.addPropertyChangeListener(new customhandler(Status.ABORTED));
+    }
+    
+    
+   
+  
+    public void abort() {
+        synchronized(this){
+          //  Status oldst = getStatus();         
+    /*        synchronized(benchmark.lock){
+                    System.out.println("be ga raftim 0");
+                }*/
+            this.status = Status.ABORTED;
+            if (this.memorystate !=null && !(this.memorystate).isAborted()){
+        /*        synchronized(benchmark.lock){
+                    System.out.println(Thread.currentThread() +" be ga raftim 1 file");
+                }*/
+                this.memorystate.abortThisSystem();
+               /* synchronized(benchmark.lock){
+                    System.out.println(Thread.currentThread() + " be ga raftim 2 file");
+                }*/
+            }
+           // Thread[] group = new Thread[30];
+          //  Thread.currentThread().enumerate(group);
+          //  group[this.id].interrupt();
+            /*synchronized(benchmark.lock){
+                System.out.println("/////////////");
+                System.out.println(Thread.currentThread() + " " +Thread.currentThread().enumerate(group));
+                System.out.println(Thread.currentThread() + " " +group[0]);
+                System.out.println(Thread.currentThread() + " " +group[1]);
+                System.out.println(Thread.currentThread() + " " +group[2]);
+                System.out.println("/////////////");
+            }*/
+            
+            
+          //  this.changes.firePropertyChange("status", oldst, Status.ABORTED);
+        }
+
+    }
+        
+    public Status getStatus() {
+        return status;
+    }
+  
+    public boolean isActive() {
+        return this.getStatus() == Status.ACTIVE;
+    }
+  
+  
+    public boolean isAborted() {
+        return this.getStatus() == Status.ABORTED;
+    }
+    
+    public ContentionManager getContentionmanager() {
+        return contentionmanager;
+    }
+
+    public void setContentionmanager(ContentionManager contentionmanager) {
+        this.contentionmanager = contentionmanager;
+    }
+    
+
+    public HashMap getWriteBuffer() {
+        return writeBuffer;
+    }
+    
+    public HashMap getAccessedFiles() {
+        return AccessedFiles;
+    }
+    
+    public boolean isWritesmerged() {
+        return writesmerged;
+    }
+
+    public void setWritesmerged(boolean writesmerged) {
+        this.writesmerged = writesmerged;
+    }
+
+
+
+
+    
+    
+    public HashMap getGlobaltoLocalMappings() {
+        return GlobaltoLocalMappings;
+    }
+
+    public HashMap getAccessedBlocks() {
+        return accessedBlocks;
+    }
+
+    
+    public ContentionManager getBlockContentionManager(){
+        return ManagerRepository.getBlockcm();
+    }
+    
+    public ContentionManager getOffsetContentionManager(){
+        return ManagerRepository.getOffsetcm();
+    }
+    
+    public TreeMap getSortedFileAccessMap(HashMap hmap) {
+        /*TreeMap sortedMap = new TreeMap(hmap);
+        return sortedMap;*/
+        return new TreeMap(hmap);
+    }
+    
+    
+    public void setStatus(Status st){
+        Status oldst = getStatus();
+        this.status = st;
+        this.changes.firePropertyChange("status", oldst, st);
+    }
+
+    
+    
+
+    public void addFile(TransactionalFile tf/*, TransactionLocalFileAttributes tmp*/) {
+
+
+       /* if (tf.appendmode) {
+            this.addtoFileAccessModeMap(tf.getInode(), FileAccessModesEum.APPEND);
+        } else if (tf.writemode) {
+            this.addtoFileAccessModeMap(tf.getInode(), FileAccessModesEum.READ_WRITE);
+        } else {
+            this.addtoFileAccessModeMap(tf.getInode(), FileAccessModesEum.READ);
+        }*/
+      //  System.out.println("dsadssasadssa");
+                
+          tf.lockOffset(this);
+          
+          //tf.offsetlock.lock();
+           TransactionLocalFileAttributes tmp = new TransactionLocalFileAttributes(tf.getCommitedoffset().getOffsetnumber()/*, tf.getInodestate().commitedfilesize.get()*/);
+          //this.heldoffsetlocks.remove(tf.offsetlock);  
+              tf.offsetlock.unlock();     
+          
+            Vector dummy;     
+            
+            if (AccessedFiles.containsKey(tf.getInode())){
+                    dummy = (Vector) AccessedFiles.get(tf.getInode());
+            }
+            else{ 
+                dummy = new Vector();
+                AccessedFiles.put(tf.getInode(), dummy);
+            }
+            
+        
+           
+      //      this.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Unlocked the offset lock " + tf.offsetlock + " for file " + tf.getInode() + " form descriptor " + tf.getSequenceNum());
+            dummy.add(tf);
+            GlobaltoLocalMappings.put(tf, tmp);
+            merge_for_writes_done.put(tf.getInode(), Boolean.TRUE);
+            
+        
+        //}
+
+    }
+
+
+    public boolean lockOffsets() {   /// Locking offsets for File Descriptors
+
+
+        TreeMap hm = getSortedFileAccessMap(AccessedFiles);
+        Iterator iter = hm.keySet().iterator();     
+    
+        while (iter.hasNext() && (this.getStatus() == Status.ACTIVE)) {
+            INode key = (INode) iter.next();
+            
+            Vector vec = (Vector) AccessedFiles.get(key);
+            Collections.sort(vec);
+            Iterator it = vec.iterator();
+            while (it.hasNext()){
+                TransactionalFile value = (TransactionalFile) it.next();
+                while (this.getStatus() ==Status.ACTIVE){
+                    //if (value.offsetlock.tryLock()) {
+                    value.offsetlock.lock();
+                  
+                     //   synchronized(value.getCommitedoffset()){
+                     //       value.getCommitedoffset().setOffsetOwner(this);
+      
+         //               this.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Locked the offset lock in commit for file " + value.getInode() + " from descriptor "+ value.getSequenceNum() +"\n");
+                        heldoffsetlocks.add(value.offsetlock);
+  
+                        //else 
+                        //    getContentionmanager().resolveConflict(this, value.getCommitedoffset());
+                        break;
+                    //}
+                }
+                if (this.getStatus() != Status.ACTIVE){
+  
+                           
+                    return false;
+                }
+            }
+           // outercounter++;
+        }
+        if (this.getStatus() != Status.ACTIVE){
+    
+            
+            return false;
+        }
+        return true;
+    }         
+            
+    /*public boolean commit() {   /// Locking offsets for File Descriptors
+
+        Map hm = getSortedFileAccessMap(FilesAccesses);
+        //lock phase
+        Iterator iter = hm.keySet().iterator();
+        TransactionLocalFileAttributes value;
+        while (iter.hasNext() && (this.getStatus() == Status.ACTIVE)) {
+            INode key = (INode) iter.next();
+            value = (TransactionLocalFileAttributes) hm.get(key);
+            synchronized(value.getCurrentcommitedoffset()){
+                if (value.offsetlock.tryLock()) {
+                    value.getCurrentcommitedoffset().setOffsetOwner(this);
+                    heldblocklocks.add(value.offsetlock);
+                    Iterator it =  value.getCurrentcommitedoffset().getOffsetReaders().iterator(); // for in-place aborting visible readers strategy
+                    while (it.hasNext())
+                    {
+                        ExtendedTransaction tr = (ExtendedTransaction) it.next();
+                        tr.abort();
+                    }
+                }
+                } 
+            }
+            getOffsetContentionManager().resolveConflict(this, value.getCurrentcommitedoffset().getOffsetOwner());
+        }
+        return true;
+    } */        
+    
+   /*public boolean commit() {   /// Locking offsets for File Descriptors with checking strategy
+
+        Map hm = getSortedFileAccessMap(FilesAccesses);
+        //lock phase
+        Iterator iter = hm.keySet().iterator();
+        TransactionLocalFileAttributes value;
+        while (iter.hasNext() && (this.getStatus() == Status.ACTIVE)) {
+            INode key = (INode) iter.next();
+            value = (TransactionLocalFileAttributes) hm.get(key);
+    
+             if (value.isValidatelocaloffset()) {
+                if (value.getCopylocaloffset() == value.currentcommitedoffset.getOffsetnumber()) {
+                    value.offsetlock.lock();
+                    heldoffsetlocks.add(value.offsetlock);
+                    if (!(value.getCopylocaloffset() == value.currentcommitedoffset.getOffsetnumber())) {
+                        unlockAllLocks();
+                        return false;
+                    }
+                } else {
+                    unlockAllLocks();
+                    return false;
+                }
+            } else {
+                value.offsetlock.lock();
+                heldoffsetlocks.add(value.offsetlock);
+            }
+        }
+    }*/
+
+
+   
+
+    public boolean lockBlock(BlockDataStructure block, BlockAccessModesEnum mode/*, GlobalINodeState adapter, BlockAccessModesEnum mode, int expvalue, INode inode, TransactionLocalFileAttributes tf*/) {
+
+        
+        //boolean locked = false;
+        Lock lock;
+      
+        
+        
+        if (mode == BlockAccessModesEnum.READ){
+                lock = block.getLock().readLock();
+                  
+             
+            }
+        else {
+              
+            lock = block.getLock().writeLock();
+            
+        }
+        
+        while (this.getStatus() == Status.ACTIVE) {
+            //synchronized(block){
+                
+              //  if (lock.tryLock()) {
+                lock.lock();    
+                   // synchronized(benchmark.lock){
+                  //      System.out.println(Thread.currentThread() + " Lock the block lock for " + lock +" number " + block.getBlocknumber());
+                  //  }
+                    heldblocklocks.add(lock);
+                //    block.setOwner(this);
+                    return true;
+               // }
+                
+                
+                    //getContentionmanager().resolveConflict(this, block);
+        }
+        
+        return false;
+    }
+       /*
+    public boolean lockBlock(BlockDataStructure block, Adapter adapter, BlockAccessModesEnum mode, int expvalue) { // from here for visible readers strategy
+        while (this.getStatus() == Status.ACTIVE) {
+             if (lock.tryLock()) {
+                Thread.onAbortOnce(new Runnable() {
+
+                    public void run() {
+                        lock.unlock();
+                    }
+                });
+
+                heldblocklocks.add(lock);
+  
+                synchronized (adapter) {
+                    block.setOwner(this);
+            //        Iterator it =  block.getReaders().iterator(); 
+            //        while (it.hasNext())
+            //        {
+            //            ExtendedTransaction tr = (ExtendedTransaction) it.next();
+            //            tr.abort();
+            //       }
+                }
+
+                return true;
+            } else {
+                getBlockContentionManager().resolveConflict(this, block.getOwner());
+            }
+        }
+        return false;*/
+        
+        
+    /*
+    public boolean lockBlock(BlockDataStructure block, Adapter adapter, BlockAccessModesEnum mode, int expvalue) { // versioning strat
+         while (this.getStatus() == Status.ACTIVE) {
+            if (lock.tryLock()) {
+                Thread.onAbortOnce(new Runnable() {
+
+                    public void run() {
+                        lock.unlock();
+                    }
+                });
+
+                heldblocklocks.add(lock);
+                if (mode != BlockAccessModesEnum.WRITE) {   egy
+                    if (block.getVersion().get() != expvalue) {
+                        unlockAllLocks();
+                        return false;
+                    }
+                }
+                synchronized (adapter) {
+                    block.setOwner(this);
+                }
+
+                return true;
+            } else {
+                getContentionManager().resolveConflict(this, block.getOwner());
+            }
+        }
+        return false;
+    }*/
+
+    public void prepareCommit() {
+        if (this.status != Status.ACTIVE)
+            throw new AbortedException();
+        
+        boolean ok = true;
+        if (!lockOffsets())
+        {
+//            unlockAllLocks();
+        //    this.msg.put(System.nanoTime(),Thread.currentThread().getName() + " Aborted \n");
+          /*  synchronized(benchmark.lock){
+                benchmark.msg += Thread.currentThread().getName() + " Aborted in prepare commit\n";
+            }*/
+            //Thread.currentThread().stop();
+            throw new AbortedException();
+        }
+        
+
+        ///////////////////////////
+        
+        
+        Map hm = getWriteBuffer();
+        
+        Iterator iter = hm.keySet().iterator();
+        WriteOperations value;
+        Vector vec = new Vector();
+        while (iter.hasNext() && (this.getStatus() == Status.ACTIVE) && ok) {
+            //int expvalue = 0;
+            
+            INode key = (INode) iter.next();
+            vec = (Vector) hm.get(key);
+            Collections.sort(vec);
+            Iterator it = vec.iterator();
+            while (it.hasNext()){
+          
+                value = (WriteOperations) it.next();
+                if (value.isUnknownoffset()){
+                   
+                    long start;
+                    long end;
+                    
+                    //synchronized(value.getOwnertransactionalFile().getCommitedoffset()){
+                        start = value.getRange().getStart() - value.getBelongingto().getCopylocaloffset() + value.getOwnertransactionalFile().getCommitedoffset().getOffsetnumber();
+                        end = value.getRange().getEnd() - value.getBelongingto().getCopylocaloffset() + value.getOwnertransactionalFile().getCommitedoffset().getOffsetnumber();
+                        if (value.getBelongingto().isUnknown_inital_offset_for_write()){
+                            value.getBelongingto().setLocaloffset(value.getBelongingto().getLocaloffset() - value.getBelongingto().getCopylocaloffset() + value.getOwnertransactionalFile().getCommitedoffset().getOffsetnumber());
+                            value.getBelongingto().setUnknown_inital_offset_for_write(false);
+                        }
+                    
+                    //}
+                 //   System.out.println("start write " + start);
+                  ///  System.out.println("end write " + end);
+                    int startblock = FileBlockManager.getCurrentFragmentIndexofTheFile(start);
+                    int targetblock = FileBlockManager.getTargetFragmentIndexofTheFile(start, value.getRange().getEnd() - value.getRange().getStart());
+                    
+                    TreeMap sset;
+                    if (this.getAccessedBlocks().get(key) != null){
+                       sset = (TreeMap) this.getAccessedBlocks().get(key);
+                    }
+                    
+                    else{
+                       sset = new TreeMap();
+                       this.getAccessedBlocks().put(key, sset);
+                    } 
+
+                    
+                    for (int i = startblock; i <= targetblock; i++) {
+                        if (sset.containsKey(Integer.valueOf(i))){
+                            if (sset.get(Integer.valueOf(i)) != BlockAccessModesEnum.WRITE) 
+                                sset.put(Integer.valueOf(i), BlockAccessModesEnum.READ_WRITE);
+                        }
+                        else
+                            sset.put(Integer.valueOf(i), BlockAccessModesEnum.WRITE);
+                        
+                       // tt.add(Integer.valueOf(i));
+                    }
+                    
+                    value.getRange().setStart(start);
+                    value.getRange().setEnd(end);
+                    
+                 //  System.out.println(Thread.currentThread().);
+                 //   System.out.println(value.getRange().getStart());
+                 //   System.out.println(value.getRange().getEnd());
+                 //   System.out.println("---------------");
+                    //this.getAccessedBlocks().put(value.getOwnertransactionalFile().getInode(), sset);
+                }
+            }
+
+        }
+
+        Iterator it = this.getAccessedBlocks().keySet().iterator();
+        while (it.hasNext() && (this.getStatus() == Status.ACTIVE)) {
+          INode inode = (INode) it.next();
+          GlobalINodeState inodestate = TransactionalFileWrapperFactory.getTateransactionalFileINodeState(inode);
+          TreeMap vec2 = (TreeMap) this.getAccessedBlocks().get(inode);
+          Iterator iter2 = vec2.keySet().iterator();
+          while(iter2.hasNext()){
+            Integer num = (Integer) iter2.next();         
+            
+            //BlockDataStructure blockobj = (BlockDataStructure) inodestate.lockmap.get(num);
+            BlockDataStructure blockobj;
+          //  if (((BlockAccessModesEnum)vec2.get(num)) == BlockAccessModesEnum.WRITE){
+                blockobj = inodestate.getBlockDataStructure(num);
+          //  }
+          //  else 
+          //      blockobj = (BlockDataStructure) inodestate.lockmap.get(num);
+            
+            ok = this.lockBlock(blockobj, (BlockAccessModesEnum)vec2.get(num));
+            if (ok == false) 
+                break;
+          /*  synchronized(benchmark.lock){
+                benchmark.msg += Thread.currentThread().getName() + " Locked the Block Number " + blockobj.getBlocknumber() +" for " + inode + "\n";
+            }*/
+     //       this.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Locked the Block Number " + blockobj.getBlocknumber() + " for file " + inode + "\n");
+          }
+        }
+         
+       if (this.getStatus() != Status.ACTIVE){ 
+          //  unlockAllLocks();
+       //           this.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Aborted \n");
+           /* synchronized(benchmark.lock){
+                    benchmark.msg += Thread.currentThread().getName() + " Aborted \n";
+            }*/
+           // Thread.currentThread().stop();
+            throw new AbortedException(); 
+       }
+       abortAllReaders();  
+          
+            // }
+            //expvalue = ((Integer) value.getBlockversions().get(it)).intValue(); //for versioning strategy
+            /*if (!(value.isValidatelocaloffset())) {
+                if (((BlockAccessModesEnum) (value.getAccesedblocks().get(blockno))) != BlockAccessModesEnum.WRITE) { //versioning strategy
+
+                    /if (blockobj.getVersion().get() == expvalue) {
+
+                        ok = this.lock(blockobj, value.adapter, (BlockAccessModesEnum) (value.getAccesedblocks().get(blockno)), expvalue);
+                        if (ok == false) {
+                            //        unlockAllLocks();
+                            break;
+                        }
+                    } else {
+                        ok = false;
+                        break;
+                    }
+                } else {
+
+                    ok = this.lock(blockobj, value.adapter, (BlockAccessModesEnum) (value.getAccesedblocks().get(blockno)), expvalue);
+                    if (ok == false) {
+                        break;
+                    }
+                }
+            }
+
+
+        if (!(ok)) {
+           unlockAllLocks();
+           throw new AbortedException();
+        }*/
+    }
+        
+        public void commitChanges(){
+
+        //   this.msg.put(System.nanoTime(), Thread.currentThread().getName() + " is committing \n");
+            
+          
+           
+          //synchronized(benchmark.lock){
+            //    System.out.println(Thread.currentThread().getName() + " is commiting");
+          //}
+            
+            
+            Map hm = getWriteBuffer();
+            Iterator iter = hm.keySet().iterator();
+            Iterator it;
+            WriteOperations writeop;
+            Vector vec;
+            while (iter.hasNext() && (this.getStatus() == Status.ACTIVE)) {
+                INode key = (INode) iter.next();
+                 
+                vec = (Vector) hm.get(key);
+                Collections.sort(vec);
+                it = vec.iterator();
+                while (it.hasNext()){
+                 
+          
+                    //value = (WriteOperations) it.next();
+                   // writeop = (WriteOperations) writeBuffer.get(key);
+                    writeop = (WriteOperations) it.next();
+                  //  System.out.println(writeop);
+                    Byte[] data = new Byte[(int) (writeop.getRange().getEnd() - writeop.getRange().getStart())];
+                    byte[] bytedata = new byte[(int) (writeop.getRange().getEnd() - writeop.getRange().getStart())];
+                    data = (Byte[]) writeop.getData();
+
+                    for (int i = 0; i < data.length; i++) {
+                        bytedata[i] = data[i];
+                    }
+                
+               //     try {
+                   //     
+                //        writeop.getOwnertransactionalFile().file.seek(writeop.getRange().getStart());
+                   //    System.out.println(Thread.currentThread() + " range " + writeop.getRange().getStart());
+                 //       writeop.getOwnertransactionalFile().file.write(bytedata);
+                        invokeNativepwrite(bytedata, writeop.getRange().getStart(), bytedata.length, writeop.getOwnertransactionalFile().file);
+                       // System.out.println(Thread.currentThread() + " " + bytedata);
+                        
+                 //  } catch (IOException ex) {
+                 //       Logger.getLogger(ExtendedTransaction.class.getName()).log(Level.SEVERE, null, ex);
+                  // }
+                //
+                
+                }
+            }
+                
+                /*if (((FileAccessModesEum) (this.FilesAccessModes.get(key))) == FileAccessModesEum.APPEND) {
+                    try {
+                        Range range = (Range) value.getWrittendata().firstKey();
+
+
+                        //synchronized(value.adapter){
+                        //value.f.seek(value.adapter.commitedfilesize.get());
+                        value.f.seek(value.getFilelength());
+                        //}
+
+                        Byte[] data = new Byte[(int) (range.getEnd() - range.getStart())];
+                        byte[] bytedata = new byte[(int) (range.getEnd() - range.getStart())];
+                        data = (Byte[]) value.getWrittendata().get(range);
+
+                        for (int i = 0; i < data.length; i++) {
+                            bytedata[i] = data[i];
+                        }
+                        value.f.write(bytedata);
+
+                    } catch (IOException ex) {
+                        Logger.getLogger(ExtendedTransaction.class.getName()).log(Level.SEVERE, null, ex);
+                    }
+
+                } else if (((FileAccessModesEum) (this.FilesAccessModes.get(key))) == FileAccessModesEum.READ) {
+                    continue;
+                }
+                else if (value.relocatablewrite && value.getContinious_written_data() != null){
+                    
+                    
+                }
+                else if (!(value.getNon_Speculative_Writtendata().isEmpty())) {
+                    int tobeaddedoffset = 0;
+
+                    if (value.isValidatelocaloffset()) {
+                        tobeaddedoffset = 0;
+                    } else {
+                        tobeaddedoffset = (int) (value.getCurrentcommitedoffset().getOffsetnumber() - value.getCopylocaloffset());
+                    }
+                    Iterator it = value.getNon_Speculative_Writtendata().keySet().iterator();
+                    int counter = 0;
+                    while (it.hasNext() && (this.getStatus() == Status.ACTIVE)) {
+                        try {
+                            Range range = (Range) it.next();
+
+                           
+                            value.f.seek(range.getStart() + tobeaddedoffset);
+
+                            Byte[] data = new Byte[(int) (range.getEnd() - range.getStart())];
+                            byte[] bytedata = new byte[(int) (range.getEnd() - range.getStart())];
+                            data = (Byte[]) value.getNon_Speculative_Writtendata().get(range);
+
+                            for (int i = 0; i < data.length; i++) {
+                                bytedata[i] = data[i];
+                            }
+                            value.f.write(bytedata);
+                            counter++;
+
+                        } catch (IOException ex) {
+                            Logger.getLogger(ExtendedTransaction.class.getName()).log(Level.SEVERE, null, ex);
+                        }
+                    }
+                } else {
+                    continue;
+                }
+            }
+
+
+            iter = hm.keySet().iterator();
+            while (iter.hasNext() ) {
+                INode key = (INode) iter.next();
+                value = (TransactionLocalFileAttributes) hm.get(key);
+                Iterator it = value.getAccesedblocks().keySet().iterator();
+
+                while (it.hasNext()) {
+                    Integer blockno = (Integer) it.next();
+                    synchronized (value.adapter) {
+                        //BlockDataStructure blockobj = (BlockDataStructure) value.adapter.lockmap.get(blockno);
+                        //blockobj.getVersion().getAndIncrement(); for versioning strategy
+                        //value.getCurrentcommitedoffset().setOffsetnumber(value.getLocaloffset());
+                        //value.adapter.commitedfilesize.getAndSet(value.getFilelength());
+                    }
+                }
+            }*/
+        Iterator k = GlobaltoLocalMappings.keySet().iterator();
+        while (k.hasNext()){
+            TransactionalFile trf = (TransactionalFile) (k.next());
+        //    synchronized(trf.getCommitedoffset()){
+                trf.getCommitedoffset().setOffsetnumber(((TransactionLocalFileAttributes)GlobaltoLocalMappings.get(trf)).getLocaloffset());
+                /*synchronized(benchmark.lock){
+                    System.out.println(Thread.currentThread() + " KIRIR " +GlobaltoLocalMappings.get(trf).getLocaloffset());
+                }*/
+        //    }
+        }
+        //unlockAllLocks();
+
+    }
+
+    public void unlockAllLocks() {
+        Iterator it = heldblocklocks.iterator();
+
+        while (it.hasNext()) {
+            
+           Lock lock = (Lock) it.next();    
+           lock.unlock();
+           
+            /*synchronized(benchmark.lock){
+                System.out.println(Thread.currentThread().getName() + " Released the block lock for " + lock);
+            }*/
+        }
+        heldblocklocks.clear();
+        
+        it = heldoffsetlocks.iterator();
+        while (it.hasNext()) {
+            ReentrantLock lock = (ReentrantLock) it.next(); 
+            lock.unlock();   
+        //    synchronized(benchmark.lock){
+       //         System.out.println(Thread.currentThread().getName() + " Released the offset lock for "+ lock +"\n");
+       //    }
+        }
+        heldoffsetlocks.clear();
+    }
+    
+    public void abortAllReaders(){
+        TreeMap hm = getSortedFileAccessMap(AccessedFiles);
+        //lock phase
+        Iterator iter = hm.keySet().iterator();
+        TransactionalFile value;
+        while (iter.hasNext()) {
+            INode key = (INode) iter.next();
+            Vector vec = (Vector) AccessedFiles.get(key);
+            Iterator it = vec.iterator();
+            while (it.hasNext())
+            {
+               
+                value = (TransactionalFile)it.next();
+           
+            //value = (TransactionalFile) hm.get(key);
+                //System.out.println(value.getCommitedoffset().getOffsetReaders());
+
+                    Iterator it2 =  value.getCommitedoffset().getOffsetReaders().iterator(); // for visible readers strategy
+                    while ( it2.hasNext())
+                    {
+                      
+                        ExtendedTransaction tr = (ExtendedTransaction) it2.next();
+                        if (tr != this)
+                            tr.abort();
+                    }
+                    value.getCommitedoffset().getOffsetReaders().clear();
+                //}
+            }
+            
+            
+            
+            TreeMap vec2;
+            if (accessedBlocks.get(key) != null){
+                vec2 = (TreeMap) accessedBlocks.get(key);
+            }
+            else{
+                vec2 = new TreeMap();
+
+            }
+            GlobalINodeState inodestate = TransactionalFileWrapperFactory.getTateransactionalFileINodeState(key);
+            Iterator it2 = vec2.keySet().iterator();
+          
+            while (it2.hasNext())
+            {
+              
+                Integer num = (Integer)it2.next();
+                if (vec2.get(num) != BlockAccessModesEnum.READ)
+                {
+                  BlockDataStructure blockobj = (BlockDataStructure) inodestate.getBlockDataStructure(num);//lockmap.get(num);
+                    Iterator it4 =  blockobj.getReaders().iterator(); // from here for visible readers strategy
+                
+                    while (it4.hasNext())
+                    {
+                        
+                        ExtendedTransaction tr = (ExtendedTransaction) it4.next();
+                        if (this != tr)
+                            tr.abort();
+                    }
+                    blockobj.getReaders().clear();
+                    
+                }
+            }
+        
+        
+        
+                
+       /*         SortedSet sst = (SortedSet) this.getAccessedBlocks().get(key);
+                Iterator it3 =  sst.iterator();
+                while (it3.hasNext()){
+                    Integer num = (Integer)it.next();
+                    BlockDataStructure blockobj = (BlockDataStructure) value.getInodestate().lockmap.get(num);
+                    Iterator it4 =  blockobj.getReaders().iterator(); // from here for visible readers strategy
+                    while (it4.hasNext())
+                    {
+                        ExtendedTransaction tr = (ExtendedTransaction) it3.next();
+                        tr.abort();
+                    }
+
+                }*/
+            
+        }
+    }
+    
+    public void addPropertyChangeListener(PropertyChangeListener listener){
+        this.changes.addPropertyChangeListener("status",listener);
+    }
+    
+     public void removePropertyChangeListener(PropertyChangeListener listener){
+        this.changes.removePropertyChangeListener("status",listener);
+    }
+
+    public TransactionStatu getOtherSystem() {
+        return memorystate;
+    }
+
+    public void setOtherSystem(TransactionStatu othersystem) {
+        memorystate = othersystem;
+    }
+
+    public Vector getHeldblocklocks() {
+        return heldblocklocks;
+    }
+
+    public void setHeldblocklocks(Vector heldblocklocks) {
+        this.heldblocklocks = heldblocklocks;
+    }
+
+    public Vector getHeldoffsetlocks() {
+        return heldoffsetlocks;
+    }
+
+    public void setHeldoffsetlocks(Vector heldoffsetlocks) {
+        this.heldoffsetlocks = heldoffsetlocks;
+    }
+
+    public void abortThisSystem() {
+        abort();
+    }
+
+    public boolean isCommitted() {
+        if (this.status == Status.COMMITTED)
+            return true;
+            
+         return  false;
+        
+    }
+    
+    
+    
+}
+     
+    
+   
+
+
+
diff --git a/Robust/Transactions/TransactionalIOSrc/core/FileBlockManager.java b/Robust/Transactions/TransactionalIOSrc/core/FileBlockManager.java
new file mode 100644 (file)
index 0000000..bff7234
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package TransactionalIO.core;
+
+//import Defaults;
+
+
+
+
+
+
+
+
+
+/**
+ *
+ * @author navid
+ */
+public class FileBlockManager {
+
+    public static long getFragmentIndexofTheFile(long filesize) {
+        return (filesize / Defaults.FILEFRAGMENTSIZE);
+    }
+
+    public static int getCurrentFragmentIndexofTheFile(long start) {
+        return (int) ((start / Defaults.FILEFRAGMENTSIZE));
+    }
+
+    public static int getTargetFragmentIndexofTheFile(long start, long offset) {
+        return (int) (((offset + start) / Defaults.FILEFRAGMENTSIZE));
+    }
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/core/GlobalINodeState.java b/Robust/Transactions/TransactionalIOSrc/core/GlobalINodeState.java
new file mode 100644 (file)
index 0000000..f3705a9
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Adapter.java
+ *
+ * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa
+ * Clara, California 95054, U.S.A.  All rights reserved.  
+ * 
+ * Sun Microsystems, Inc. has intellectual property rights relating to
+ * technology embodied in the product that is described in this
+ * document.  In particular, and without limitation, these
+ * intellectual property rights may include one or more of the
+ * U.S. patents listed at http://www.sun.com/patents and one or more
+ * additional patents or pending patent applications in the U.S. and
+ * in other countries.
+ * 
+ * U.S. Government Rights - Commercial software.
+ * Government users are subject to the Sun Microsystems, Inc. standard
+ * license agreement and applicable provisions of the FAR and its
+ * supplements.  Use is subject to license terms.  Sun, Sun
+ * Microsystems, the Sun logo and Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other
+ * countries.  
+ * 
+ * This product is covered and controlled by U.S. Export Control laws
+ * and may be subject to the export or import laws in other countries.
+ * Nuclear, missile, chemical biological weapons or nuclear maritime
+ * end uses or end users, whether direct or indirect, are strictly
+ * prohibited.  Export or reexport to countries subject to
+ * U.S. embargo or to entities identified on U.S. export exclusion
+ * lists, including, but not limited to, the denied persons and
+ * specially designated nationals lists is strictly prohibited.
+ */
+package TransactionalIO.core;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * Obstruction-free atomic object implementation. Visible reads.
+ * Support snapshots and early release.
+ * @author Navid Farri
+ */
+public class GlobalINodeState {
+
+   // public HashMap<Integer,BlockLock> lockmap;  
+    public HashMap lockmap;
+    private ConcurrentHashMap conlockmap = new ConcurrentHashMap();
+    
+    public AtomicLong commitedfilesize = new AtomicLong();
+    private ExtendedTransaction writer;
+    public int seqNum = 0;
+    private INode inode;
+
+    public GlobalINodeState() {
+    }
+    
+    
+    
+    
+    protected GlobalINodeState(INode inode, long length) {
+        writer = null;
+        lockmap = new HashMap();
+       
+        commitedfilesize.set(length);
+        this.inode = inode;
+    }
+    
+    
+
+
+    public AtomicLong getCommitedfilesize() {
+        return commitedfilesize;
+    }
+
+    public void setCommitedfilesize(AtomicLong commitedfilesize) {
+        this.commitedfilesize = commitedfilesize;
+    }
+    
+    public ExtendedTransaction getWriter() {
+        return writer;
+    }
+
+    public void setWriter(ExtendedTransaction writer) {
+        this.writer = writer;
+    }
+    
+     public BlockDataStructure getBlockDataStructure(Integer blocknumber) {
+     /*       synchronized (lockmap) {
+                if (lockmap.containsKey(blocknumber)) {
+                    return ((BlockDataStructure) (lockmap.get(blocknumber)));
+                } else {
+                    BlockDataStructure tmp = new BlockDataStructure(inode, blocknumber);
+                    lockmap.put(blocknumber, tmp);
+                    return tmp;
+               }    
+           }
+     }*/   
+    BlockDataStructure rec = (BlockDataStructure)conlockmap.get(blocknumber);
+    if (rec == null) {
+        // record does not yet exist
+        BlockDataStructure newRec = new BlockDataStructure(inode, blocknumber);
+        rec = (BlockDataStructure)conlockmap.putIfAbsent(blocknumber, newRec);
+        if (rec == null) {
+            // put succeeded, use new value
+            rec = newRec;
+        }
+    }
+    return rec;
+}
+         
+            
+     
+
+
+}
+
diff --git a/Robust/Transactions/TransactionalIOSrc/core/GlobalOffset.java b/Robust/Transactions/TransactionalIOSrc/core/GlobalOffset.java
new file mode 100644 (file)
index 0000000..f32ffe3
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.core;
+
+import java.util.Vector;
+
+/**
+ *
+ * @author navid
+ */
+public class GlobalOffset {
+    private long offsetnumber;
+    //private Vector<ExtendedTransaction> offsetReaders;
+    private Vector offsetReaders = new Vector();
+    private ExtendedTransaction offsetOwner;
+
+    public GlobalOffset(long offsetnumber) {
+        this.offsetnumber = offsetnumber;
+    }
+    
+
+    public long getOffsetnumber() {
+        return offsetnumber;
+    }
+
+    public ExtendedTransaction getOffsetOwner(){
+        return offsetOwner;
+    }
+    
+    public void setOffsetOwner(ExtendedTransaction ex){
+        offsetOwner = ex;
+    }
+    
+    public void setOffsetnumber(long offsetnumber) {
+        this.offsetnumber = offsetnumber;
+    }
+
+    public Vector getOffsetReaders() {
+        return offsetReaders;
+    }
+
+    public void setOffsetReaders(Vector offsetReaders) {
+        this.offsetReaders = offsetReaders;
+    }
+    
+    
+    
+
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/core/HelloWorld.c b/Robust/Transactions/TransactionalIOSrc/core/HelloWorld.c
new file mode 100644 (file)
index 0000000..35fa4e0
--- /dev/null
@@ -0,0 +1,9 @@
+#include <jni.h>
+#include <stdio.h>
+#include "HelloWorld.h"
+
+JNIEXPORT void JNICALL Java_HelloWorld_displayMessage(JNIEnv *env, jobject obj){
+       printf("HelloWorld!\n");
+}
+
+
diff --git a/Robust/Transactions/TransactionalIOSrc/core/HelloWorld.h b/Robust/Transactions/TransactionalIOSrc/core/HelloWorld.h
new file mode 100644 (file)
index 0000000..7cdd58e
--- /dev/null
@@ -0,0 +1,19 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#include <jni.h>
+
+#ifndef __dstm2_file_factory_HelloWorld__
+#define __dstm2_file_factory_HelloWorld__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_dstm2_file_factory_HelloWorld_displayMessage (JNIEnv *env, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __dstm2_file_factory_HelloWorld__ */
diff --git a/Robust/Transactions/TransactionalIOSrc/core/INode.java b/Robust/Transactions/TransactionalIOSrc/core/INode.java
new file mode 100644 (file)
index 0000000..e5a1f82
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.core;
+
+/**
+ *
+ * @author navid
+ */
+public class INode implements Comparable{
+   
+    private String filepath;
+    private long number;
+
+
+    public INode(long number) {
+        this.number = number;
+    }
+    
+    public INode(long number, String filepath) {
+        this(number);
+        this.filepath = filepath;
+    }
+
+    public String getFilepath() {
+        return filepath;
+    }
+
+    public void setFilepath(String filepath) {
+        this.filepath = filepath;
+    }
+    
+    
+    
+    public long getNumber() {
+        return number;
+    }
+
+    public void setNumber(long number) {
+        this.number = number;
+    }
+
+    public int compareTo(Object arg0) {
+        INode other = (INode) arg0;
+        if (this.getNumber() < other.getNumber())
+            return -1;
+        else if (this.getNumber() > other.getNumber())
+            return 1;
+        else{ 
+            System.out.println("Logical Eroor Two Inodes cannot have the same number");
+            return 0;
+        }
+       
+    }
+    
+    
+    
+
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/core/IOlib b/Robust/Transactions/TransactionalIOSrc/core/IOlib
new file mode 100644 (file)
index 0000000..cc5c990
Binary files /dev/null and b/Robust/Transactions/TransactionalIOSrc/core/IOlib differ
diff --git a/Robust/Transactions/TransactionalIOSrc/core/IOlib.so b/Robust/Transactions/TransactionalIOSrc/core/IOlib.so
new file mode 100644 (file)
index 0000000..cc5c990
Binary files /dev/null and b/Robust/Transactions/TransactionalIOSrc/core/IOlib.so differ
diff --git a/Robust/Transactions/TransactionalIOSrc/core/ManagerRepository.java b/Robust/Transactions/TransactionalIOSrc/core/ManagerRepository.java
new file mode 100644 (file)
index 0000000..79e2efd
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.core;
+
+import TransactionalIO.interfaces.ContentionManager;
+
+
+/**
+ *
+ * @author navid
+ */
+public class ManagerRepository {
+    private static ContentionManager blockcm;
+    private static ContentionManager offsetcm;
+
+    public synchronized static ContentionManager getBlockcm() {
+        return blockcm;
+    }
+
+    public synchronized static void setBlockcm(ContentionManager blockcm) {
+        ManagerRepository.blockcm = blockcm;
+    }
+
+    public synchronized static ContentionManager getOffsetcm() {
+        return offsetcm;
+    }
+
+    public synchronized static void setOffsetcm(ContentionManager offsetcm) {
+        ManagerRepository.offsetcm = offsetcm;
+    }
+    
+
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/core/NativeFunctions.c b/Robust/Transactions/TransactionalIOSrc/core/NativeFunctions.c
new file mode 100644 (file)
index 0000000..2c05b78
--- /dev/null
@@ -0,0 +1,30 @@
+/* 
+ * File:   HelloWorld.cpp
+ * Author: navid
+ *
+ * Created on September 3, 2008, 2:17 PM
+ */
+
+        #include <jni.h>
+        #include <stdio.h>
+       #include <sys/stat.h>
+        #include "NativeFunctions.h"
+        
+        JNIEXPORT jlong JNICALL Java_test2_Main_getINodeNative
+            (JNIEnv *env, jobject obj, jstring filename) 
+        {
+           struct stat status_buf;
+           jlong inodenum;
+          // stat("/home/navid/myfile.txt",&status_buf);
+           char *str = (*env)->GetStringUTFChars(env, filename, 0);
+           printf("\n");
+           printf("File Name is: %s \n", str);
+           if (stat(str,&status_buf)<0)
+               inodenum = -1;   
+           else
+           {
+                   printf("Inode number is: %lu \n", status_buf.st_ino);
+                   inodenum = status_buf.st_ino;
+           }
+           return inodenum;
+        }
diff --git a/Robust/Transactions/TransactionalIOSrc/core/NativeFunctions.h b/Robust/Transactions/TransactionalIOSrc/core/NativeFunctions.h
new file mode 100644 (file)
index 0000000..4d9b0a2
--- /dev/null
@@ -0,0 +1,19 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#include <jni.h>
+
+#ifndef __test2_Main__
+#define __test2_Main__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT jlong JNICALL test2_Main_getINodeNative (JNIEnv *env, jobject, jstring);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __HellWorld__ */
diff --git a/Robust/Transactions/TransactionalIOSrc/core/NativeFunctions.o b/Robust/Transactions/TransactionalIOSrc/core/NativeFunctions.o
new file mode 100644 (file)
index 0000000..b799c0a
Binary files /dev/null and b/Robust/Transactions/TransactionalIOSrc/core/NativeFunctions.o differ
diff --git a/Robust/Transactions/TransactionalIOSrc/core/TransactionLocalFileAttributes.java b/Robust/Transactions/TransactionalIOSrc/core/TransactionLocalFileAttributes.java
new file mode 100644 (file)
index 0000000..3da6913
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package TransactionalIO.core;
+
+
+import TransactionalIO.interfaces.OffsetDependency;
+import java.io.RandomAccessFile;
+
+/**
+ *
+ * @author navid
+ */
+public class TransactionLocalFileAttributes {
+
+
+    private INode inode;
+    public boolean to_be_created = false;
+    RandomAccessFile f;
+    OffsetDependency offsetdependency;
+    private long copylocaloffset;
+    private boolean unknown_inital_offset_for_write = true;
+    private long localoffset;
+    private long localsize;
+    
+    public TransactionLocalFileAttributes(long initialoffset/*, long initialsize*/){
+        localoffset = initialoffset;
+        copylocaloffset = initialoffset;
+        //copylocaloffset = 0;
+        unknown_inital_offset_for_write = true; 
+        offsetdependency = OffsetDependency.NO_ACCESS;
+        //localsize = initialsize;
+    }
+
+    public long getCopylocaloffset() {
+        return copylocaloffset;
+    }
+    
+    public void setCopylocaloffset(long copylocaloffset) {
+        this.copylocaloffset = copylocaloffset;
+    }
+
+    public long getLocalsize() {
+        return localsize;
+    }
+
+    public void setLocalsize(long localsize) {
+        this.localsize = localsize;
+    }
+    
+
+    public OffsetDependency getOffsetdependency() {
+        return offsetdependency;
+    }
+
+    public void setOffsetdependency(OffsetDependency offsetdependency) {
+        this.offsetdependency = offsetdependency;
+    }
+
+    public boolean isUnknown_inital_offset_for_write() {
+        return unknown_inital_offset_for_write;
+    }
+
+    public void setUnknown_inital_offset_for_write(boolean unknown_inital_offset_for_write) {
+        this.unknown_inital_offset_for_write = unknown_inital_offset_for_write;
+    }
+    
+    public long getLocaloffset() {
+        return localoffset;
+    }
+
+    public void setLocaloffset(long localoffset) {
+        this.localoffset = localoffset;
+    }
+    
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/core/TransactionalFile.java b/Robust/Transactions/TransactionalIOSrc/core/TransactionalFile.java
new file mode 100644 (file)
index 0000000..72cdf44
--- /dev/null
@@ -0,0 +1,1592 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package TransactionalIO.core;
+
+
+
+import TransactionalIO.Utilities.Range;
+import TransactionalIO.exceptions.AbortedException;
+import TransactionalIO.exceptions.PanicException;
+import TransactionalIO.benchmarks.benchmark;
+import TransactionalIO.core.ExtendedTransaction.Status;
+import TransactionalIO.interfaces.BlockAccessModesEnum;
+import TransactionalIO.interfaces.OffsetDependency;
+import com.sun.org.apache.bcel.internal.generic.IFEQ;
+import java.io.File;
+import java.io.FileDescriptor;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.ByteBuffer;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.Vector;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import sun.misc.ConditionLock;
+
+/**
+ *
+ * @author navid
+ */
+
+
+public class TransactionalFile implements Comparable{
+
+    
+    private native int nativepread(byte buff[], long offset, int size, FileDescriptor fd);
+    
+    {
+        System.load("/home/navid/libkooni.so");
+    }
+    
+    
+    public RandomAccessFile file;
+    private INode inode;
+    private int sequenceNum = 0;
+    public static int currenSeqNumforInode = 0;
+    /*  public AtomicLong commitedoffset;
+    public AtomicLong commitedfilesize;*/
+    public boolean to_be_created = false;
+    public boolean writemode = false;
+    public boolean appendmode = false;
+    public ReentrantLock offsetlock;
+    private GlobalOffset committedoffset;
+    private GlobalINodeState inodestate ;
+    
+    
+    public TransactionalFile(String filename, String mode) {
+        
+       
+        File f = new File(filename);
+  
+        if ((!(f.exists()))) {
+            to_be_created = true;
+            file = null;
+
+        } else {
+
+            try {
+
+                offsetlock = new ReentrantLock();
+                file = new RandomAccessFile(f, mode);
+            } catch (FileNotFoundException ex) {
+                Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex);
+            }
+      
+        }
+        inode = TransactionalFileWrapperFactory.getINodefromFileName(filename);
+        inodestate = TransactionalFileWrapperFactory.createTransactionalFile(inode, filename, mode);
+        
+        
+        sequenceNum = inodestate.seqNum;
+        inodestate.seqNum++;
+        
+        
+        
+
+
+        if (mode.equals("rw")) {
+            writemode = true;
+        } else if (mode.equals("a")) {
+            appendmode = true;
+        }
+
+        if (inodestate != null) {
+            synchronized (inodestate) {
+                try {
+                    //      if (!(to_be_created)) {
+                    //   } else {
+                    //       adapter.commitedfilesize.set(0);
+                    //   }
+
+                    if (!appendmode) {
+                        //commitedoffset.setOffsetnumber(0);
+                        committedoffset = new GlobalOffset(0);
+                    } else {
+                        committedoffset = new GlobalOffset(file.length());
+                    }
+
+                } catch (IOException ex) {
+                    Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex);
+                }
+            }
+        }
+        
+                
+    }
+
+    private int invokeNativepread(byte buff[], long offset, int size) {
+        try {
+            return nativepread(buff, offset, size, file.getFD());
+        } catch (IOException ex) {
+            
+            Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex);
+            return -1;
+        }
+        
+    }
+
+    
+    public int getSequenceNum() {
+        return sequenceNum;
+    }
+
+    
+    public GlobalOffset getCommitedoffset() {
+        return committedoffset;
+    }
+
+    public GlobalINodeState getInodestate() {
+        return inodestate;
+    }
+
+    /*  public TransactionalFile(Adapter adapter, RandomAccessFile file) {
+    
+    this.adapter = adapter;
+    this.file = file;
+    decriptors = new Vector();
+    }
+    
+    public void copyTransactionalFile(TransactionalFile tf){
+    try {
+    int tmp = tf.commitedoffset.get();
+    boolean flag = tf.to_be_created;
+    FileDescriptor fd = tf.file.getFD();
+    Adapter ad = new Adapter(tf.adapter);
+    } catch (IOException ex) {
+    Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex);
+    }
+    }*/
+    
+   /* public BlockDataStructure getBlockDataStructure(int blocknumber) {
+        synchronized (inodestate.lockmap) {
+            if (inodestate.lockmap.containsKey(blocknumber)) {
+       
+                return ((BlockDataStructure) (inodestate.lockmap.get(Long.valueOf(blocknumber))));
+            } else {
+       
+                BlockDataStructure tmp = new BlockDataStructure(getInode(), blocknumber);
+                inodestate.lockmap.put(Integer.valueOf(blocknumber), tmp);
+                return tmp;
+            }
+        }
+
+    }*/
+
+
+     
+    public INode getInode() {
+        return inode;
+    }
+    /* public boolean deleteBlockLock(int blocknumber){
+    synchronized(adapter.lockmap){
+    //adapter.lockmap.get(blocknumber)
+    if (adapter.lockmap.containsKey(blocknumber)){
+    if (((BlockLock)(adapter.lockmap.get(blocknumber))).referncount == 0){
+    adapter.lockmap.remove(adapter.lockmap.get(blocknumber));
+    return true;
+    }
+    else
+    return false;
+    }
+    else {
+    return false;
+    }
+    }
+    }*/
+    public void close() {
+        try {
+            file.close();
+        } catch (IOException ex) {
+            Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    public long getFilePointer(){
+        
+        ExtendedTransaction me = Wrapper.getTransaction();
+        TransactionLocalFileAttributes tmp = null;
+        
+        if (me == null) {
+            return non_Transactional_getFilePointer();
+        }
+        
+        if (!(me.getGlobaltoLocalMappings().containsKey(this))){
+           
+                //if (!(me.getFilesAccesses().containsKey(this.inode))) {
+                tmp = new TransactionLocalFileAttributes(0);/*, tf.getInodestate().commitedfilesize.get();*/
+                  
+                 Vector dummy;   
+                 if (me.getAccessedFiles().containsKey(this.getInode())){
+                    dummy = (Vector) me.getAccessedFiles().get(this.getInode());
+                 }
+                 else{ 
+                  dummy = new Vector();
+                  me.getAccessedFiles().put(this.getInode(), dummy);
+                 }
+            
+        
+           
+      //      this.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Unlocked the offset lock " + tf.offsetlock + " for file " + tf.getInode() + " form descriptor " + tf.getSequenceNum());
+                dummy.add(this);
+                me.getGlobaltoLocalMappings().put(this, tmp);
+                me.merge_for_writes_done.put(this.getInode(), Boolean.TRUE);
+              // me.addFile(this);
+           
+            //me.addFile(this);
+        }
+        
+        tmp = (TransactionLocalFileAttributes) me.getGlobaltoLocalMappings().get(this);
+        if ((tmp.getOffsetdependency() == OffsetDependency.WRITE_DEPENDENCY_1) || (tmp.getOffsetdependency() == OffsetDependency.NO_ACCESS)){   
+             tmp.setOffsetdependency(OffsetDependency.READ_DEPENDENCY);
+             //System.out.println("sad");
+             //synchronized(this.committedoffset)
+             long target;
+             lockOffset(me);
+             //{
+             
+                    if (!(this.committedoffset.getOffsetReaders().contains(me))){
+                        this.committedoffset.getOffsetReaders().add(me);
+                        /*synchronized(benchmark.lock){
+                            benchmark.msg += Thread.currentThread().getName() + " Added to Offset Readers for file " + this.inode + " from descriptor "+ this.sequenceNum +"\n";
+                        }*/
+      //                  me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Added to Offset Readers for file " + this.inode + " from descriptor "+ this.sequenceNum +"\n");
+                      /*  synchronized(benchmark.lock){
+                          System.out.println(Thread.currentThread().getName() + " Added to Offset Readers for file " + this.inode + " from descriptor "+ this.sequenceNum +"\n");
+                        }*/
+                    }
+             
+                    tmp.setLocaloffset(tmp.getLocaloffset() + this.committedoffset.getOffsetnumber() - tmp.getCopylocaloffset());
+                    target = this.committedoffset.getOffsetnumber() - tmp.getCopylocaloffset();
+                    
+                    
+             offsetlock.unlock();         
+             //me.getHeldoffsetlocks().remove(offsetlock);
+             
+             Iterator it;
+
+             if ((me.getWriteBuffer().get(inode)) != null)
+             {
+                
+                it = ((Vector) (me.getWriteBuffer().get(inode))).iterator();
+                while (it.hasNext()){
+                    WriteOperations wrp = (WriteOperations) it.next();
+                    if (wrp.getBelongingto() == tmp && wrp.isUnknownoffset())
+                        wrp.setUnknownoffset(false);
+                        /*wrp.getRange().setStart(wrp.getOwnertransactionalFile().committedoffset.getOffsetnumber() - wrp.getBelongingto().getCopylocaloffset() + wrp.getRange().getStart());
+                        wrp.getRange().setEnd(wrp.getOwnertransactionalFile().committedoffset.getOffsetnumber() - wrp.getBelongingto().getCopylocaloffset() + wrp.getRange().getEnd());*/
+                        wrp.getRange().setStart(target + wrp.getRange().getStart());
+                        wrp.getRange().setEnd(target + wrp.getRange().getEnd());
+                }   
+             }
+              
+
+            //}    
+        }
+        
+       
+        tmp.setUnknown_inital_offset_for_write(false);
+       
+     /*   synchronized(benchmark.lock){
+            benchmark.msg += Thread.currentThread().getName() + " Read the offset value for the file "  + this.inode +" from descriptor " + this.sequenceNum + "\n";
+        }
+        me.msg += Thread.currentThread().getName() + " Read the offset value for the file "  + this.inode +" from descriptor " + this.sequenceNum + "\n";*/
+       /* synchronized(benchmark.lock){
+            System.out.println("offset " + Thread.currentThread()  + " " + tmp.getLocaloffset());
+        }*/
+        return tmp.getLocaloffset();
+    }
+    
+    public void seek(long offset) {
+
+        if (appendmode) {
+            throw new PanicException("Cannot seek into a file opened in append mode");
+        }
+        ExtendedTransaction me = Wrapper.getTransaction();
+        
+        if (me == null) {
+            non_Transactional_Seek(offset);
+            return;
+        }
+        
+        else {
+         //   if (me.getStatus() != Status.ACTIVE)
+          //      throw new AbortedException();
+            
+           TransactionLocalFileAttributes tmp = null;
+          //tf.offsetlock.lock();
+           
+          //this.heldoffsetlocks.remove(tf.offsetlock);  
+          //tf.offsetlock.unlock(); 
+            if (!(me.getGlobaltoLocalMappings().containsKey(this))){
+                //if (!(me.getFilesAccesses().containsKey(this.inode))) {
+                 tmp = new TransactionLocalFileAttributes(offset);/*, tf.getInodestate().commitedfilesize.get();*/
+                  
+                 Vector dummy;   
+                 if (me.getAccessedFiles().containsKey(this.getInode())){
+                    dummy = (Vector) me.getAccessedFiles().get(this.getInode());
+                 }
+                 else{ 
+                  dummy = new Vector();
+                  me.getAccessedFiles().put(this.getInode(), dummy);
+                 }
+            
+        
+           
+      //      this.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Unlocked the offset lock " + tf.offsetlock + " for file " + tf.getInode() + " form descriptor " + tf.getSequenceNum());
+                dummy.add(this);
+                me.getGlobaltoLocalMappings().put(this, tmp);
+                me.merge_for_writes_done.put(this.getInode(), Boolean.TRUE);
+                //me.addFile(this);
+            }
+            tmp = (TransactionLocalFileAttributes) me.getGlobaltoLocalMappings().get(this);
+            //tmp = ((TransactionLocalFileAttributes) (me.getFilesAccesses().get(this.getInode())));
+            
+            if (tmp.getOffsetdependency() == OffsetDependency.NO_ACCESS)
+                tmp.setOffsetdependency(OffsetDependency.NO_DEPENDENCY);
+            
+            else if (tmp.getOffsetdependency() == OffsetDependency.WRITE_DEPENDENCY_1)
+                tmp.setOffsetdependency(OffsetDependency.WRITE_DEPENDENCY_2);
+            
+            tmp.setUnknown_inital_offset_for_write(false);
+          
+            tmp.setLocaloffset(offset);
+            
+          
+          /*  synchronized(benchmark.lock){
+                System.out.println(tmp.getLocaloffset());
+            }*/
+     //       me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Seeked to the file"  + this.inode +" from descriptor " + this.sequenceNum + "\n");
+        }
+    }
+
+    public int read(byte[] b) {
+
+        if (appendmode) {
+            throw new PanicException("Cannot seek into a file opened in append mode");
+        }
+        
+        boolean firsttime = false;
+        ExtendedTransaction me = Wrapper.getTransaction();
+        int size = b.length;
+        int result = 0;
+
+
+
+        if (me == null) {  // not a transaction, but any I/O operation even though within a non-transaction is considered a single opertion transactiion 
+            return non_Transactional_Read(b);
+        }
+        
+        //if (me.getStatus() != Status.ACTIVE)
+          //      throw new AbortedException();
+        
+  
+         if (me.getGlobaltoLocalMappings().containsKey(this)){
+            
+            /*long target;
+            Vector locktracker = new Vector();
+            TreeMap hm = me.getSortedFileAccessMap(me.getAccessedFiles());;
+            Vector vec = (Vector)hm.get(inode);
+            Iterator vecit = vec.iterator();
+            while(vecit.hasNext()){
+                TransactionalFile tr = (TransactionalFile)vecit.next();
+                TransactionLocalFileAttributes tmp = (TransactionLocalFileAttributes) me.getGlobaltoLocalMappings().get(tr);
+                
+                if ((tmp.getOffsetdependency() == OffsetDependency.WRITE_DEPENDENCY_1) || (tmp.offsetdependency == OffsetDependency.NO_ACCESS) || (tmp.getOffsetdependency() == OffsetDependency.WRITE_DEPENDENCY_2)){
+                    tmp.setUnknown_inital_offset_for_write(false);
+                    tmp.setOffsetdependency(OffsetDependency.READ_DEPENDENCY);  
+                    tr.lockOffset(me);
+                   System.out.printtln(Thread.currentThread() + " kiri");
+                        if (!(tr.committedoffset.getOffsetReaders().contains(me))){
+                            tr.committedoffset.getOffsetReaders().add(me);
+                            target = this.committedoffset.getOffsetnumber() - tmp.getCopylocaloffset();
+                            me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Added to Offset Readers for file " + this.inode + " from descriptor "+ this.sequenceNum +"\n");
+                        }
+                }   
+            }*/
+            
+            
+            
+            
+            TransactionLocalFileAttributes tmp = (TransactionLocalFileAttributes) me.getGlobaltoLocalMappings().get(this);
+            tmp.setUnknown_inital_offset_for_write(false);
+            if ((tmp.getOffsetdependency() == OffsetDependency.WRITE_DEPENDENCY_1) || (tmp.offsetdependency == OffsetDependency.NO_ACCESS) || (tmp.getOffsetdependency() == OffsetDependency.WRITE_DEPENDENCY_2)){
+              //System.out.println(Thread.currentThread() + " here");
+               //synchronized(this.committedoffset){
+               lockOffset(me);
+                    if (tmp.getOffsetdependency() != OffsetDependency.WRITE_DEPENDENCY_2){     
+                        tmp.setLocaloffset(tmp.getLocaloffset() + this.committedoffset.getOffsetnumber() - tmp.getCopylocaloffset()); 
+                    }
+                    
+                    tmp.setOffsetdependency(OffsetDependency.READ_DEPENDENCY);  
+                    if (!(this.committedoffset.getOffsetReaders().contains(me))){
+                        this.committedoffset.getOffsetReaders().add(me);
+                         /*                                  synchronized(benchmark.lock){
+                                       System.out.println("adding offset " + committedoffset + " " +Thread.currentThread());
+                                    }*/
+                       /* synchronized(benchmark.lock){
+                            benchmark.msg += Thread.currentThread().getName() + " Added to Offset Readers for file " + this.inode + " from descriptor "+ this.sequenceNum +"\n";
+                        }*/
+     //                   me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Added to Offset Readers for file " + this.inode + " from descriptor "+ this.sequenceNum +"\n");
+                        /*synchronized(benchmark.lock){
+                          System.out.println(Thread.currentThread().getName() + " Added to Offset Readers for file " + this.inode + " from descriptor "+ this.sequenceNum);
+                        }*/
+                    }
+               
+               offsetlock.unlock();
+              // me.getHeldoffsetlocks().remove(offsetlock);     
+                //}
+            }
+            Iterator it;
+            if (me.getWriteBuffer().get(inode) != null)
+            //if (!(((Vector)(me.getWriteBuffer().get(inode))).isEmpty()))
+            {
+                it = ((Vector) (me.getWriteBuffer().get(inode))).iterator();
+                while (it.hasNext()){
+                 
+                      WriteOperations wrp = (WriteOperations) it.next();
+                      if (wrp.isUnknownoffset()){
+                        wrp.setUnknownoffset(false);
+                        //synchronized(wrp.getOwnertransactionalFile().committedoffset){
+                        wrp.getOwnertransactionalFile().lockOffset(me);
+                        
+                            wrp.getRange().setStart(wrp.getOwnertransactionalFile().committedoffset.getOffsetnumber() - wrp.getBelongingto().getCopylocaloffset() + wrp.getRange().getStart());
+                            wrp.getRange().setEnd(wrp.getOwnertransactionalFile().committedoffset.getOffsetnumber() - wrp.getBelongingto().getCopylocaloffset() + wrp.getRange().getEnd());
+                            if ((wrp.getBelongingto().getOffsetdependency() == OffsetDependency.WRITE_DEPENDENCY_1) || (wrp.getBelongingto().offsetdependency == OffsetDependency.NO_ACCESS) || (wrp.getBelongingto().getOffsetdependency() == OffsetDependency.WRITE_DEPENDENCY_2)){
+                                wrp.getBelongingto().setOffsetdependency(OffsetDependency.READ_DEPENDENCY);
+                                wrp.getBelongingto().setUnknown_inital_offset_for_write(false);
+                                if (!(wrp.getOwnertransactionalFile().committedoffset.getOffsetReaders().contains(me)))
+                                    wrp.getOwnertransactionalFile().committedoffset.getOffsetReaders().add(me);
+                                wrp.getBelongingto().setLocaloffset(wrp.getBelongingto().getLocaloffset() + wrp.getOwnertransactionalFile().committedoffset.getOffsetnumber() - wrp.getBelongingto().getCopylocaloffset());
+                               /* synchronized(benchmark.lock){
+                                    benchmark.msg += Thread.currentThread().getName() + " Added to Offset Readers for file " + this.inode + " from descriptor "+ wrp.getOwnertransactionalFile().sequenceNum +"\n";
+                                }*/
+                      //          me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Added to Offset Readers for file " + this.inode + " from descriptor "+ wrp.getOwnertransactionalFile().sequenceNum +"\n");   
+                            }
+                         
+                        // me.getHeldoffsetlocks().remove(wrp.getOwnertransactionalFile().offsetlock);   
+                         wrp.getOwnertransactionalFile().offsetlock.unlock();  
+                         
+                         //}
+                        
+                        
+                        
+                        markAccessedBlocks(me, (int)wrp.getRange().getStart(), (int)(wrp.getRange().getEnd() - wrp.getRange().getStart()), BlockAccessModesEnum.WRITE);
+//                        markWriteBlocks((int)wrp.getRange().getStart(), (int)(wrp.getRange().getEnd() - wrp.getRange().getStart()));
+                      }
+                }
+            }
+            
+        /*    if (!(me.isWritesmerged())){
+               //    synchronized(benchmark.lock){
+                 //   System.out.println("ssssad " + Thread.currentThread() + " " + me.getWriteBuffer());
+               // }
+                mergeWrittenData();
+            }*/
+          //  System.out.println("ssssad " + Thread.currentThread() + " " + me.getWriteBuffer());
+            if ((Boolean)me.merge_for_writes_done.get(inode) == Boolean.FALSE){
+               // synchronized(benchmark.lock){
+                System.out.println("ssssad " + Thread.currentThread() + " " + me.getWriteBuffer());
+                 mergeWrittenData(me);
+               //}
+            }
+               
+            
+            long loffset = tmp.getLocaloffset();
+            markAccessedBlocks(me, loffset, size, BlockAccessModesEnum.READ);
+   
+
+            Vector writebuffer;
+            if ((me.getWriteBuffer().get(this.inode)) != null)
+                writebuffer = (Vector) (me.getWriteBuffer().get(this.inode));
+            else {
+                writebuffer = new Vector();
+                me.getWriteBuffer().put(this.inode, writebuffer);
+            }
+            Range readrange = new Range(loffset, loffset + size);
+            Range writerange = null;
+            Range[] intersectedrange = new Range[writebuffer.size()];
+            WriteOperations[] markedwriteop = new WriteOperations[writebuffer.size()];
+            
+            int counter = 0;
+
+
+
+
+            boolean flag = false;
+            //System.out.println("yani che>??");
+                    
+            it = writebuffer.iterator();
+            while (it.hasNext()) {
+                
+                WriteOperations wrp = (WriteOperations) it.next();
+                writerange = wrp.getRange();
+                if (writerange.includes(readrange)) {
+                    markedwriteop[counter] = wrp;
+                    flag = true;
+                    break;
+                }
+
+                if (writerange.hasIntersection(readrange)) {
+                    intersectedrange[counter] = readrange.intersection(writerange);
+                    markedwriteop[counter] = wrp;
+                   
+                    counter++;
+                }
+            }
+
+
+            // for block versioning mechanism
+            /*if (!(validateBlocksVersions(startblock, targetblock))) { ////check to see if version are still valid 
+            
+                    throw new AbortedException();
+            
+            }*/
+            if (flag) {
+                
+                result = readFromBuffer(b, tmp, markedwriteop[counter],writerange);    
+               
+             /*   synchronized(benchmark.lock){
+                    benchmark.msg += Thread.currentThread().getName() + " Read " + this.inode + " from descriptor "+ this.sequenceNum +"\n";
+                }*/
+                
+            //    me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Read " + this.inode + " from descriptor "+ this.sequenceNum +"\n");
+                return result;
+            }
+            
+            else{
+                
+                if (counter == 0) {
+                  /*                 synchronized(benchmark.lock){
+                                       System.out.println("here"  +Thread.currentThread());
+                    }*/
+                
+                 //   lockOffset(me);
+                    result = readFromFile(me, b, tmp);
+                }
+                else {
+                    
+                    for (int i = 0; i < counter; i++) {
+
+                        
+                        Byte[] data = markedwriteop[i].getData();
+                        byte[] copydata = new byte[data.length];
+
+                        for (int j = 0; j < data.length; j++) {
+                            copydata[j] = data[j].byteValue();
+                        }
+                        System.arraycopy(copydata, (int) (intersectedrange[i].getStart() - markedwriteop[i].getRange().getStart()), b, (int) (intersectedrange[i].getStart() - readrange.getStart()), (int) (Math.min(intersectedrange[i].getEnd(), readrange.getEnd()) - intersectedrange[i].getStart()));
+                        result += Math.min(intersectedrange[i].getEnd(), readrange.getEnd()) - intersectedrange[i].getStart();
+                    }
+
+                    Range[] non_intersected_ranges = readrange.minus(intersectedrange, counter);
+                    Vector occupiedblocks = new Vector();
+                    Vector heldlocks = new Vector();
+                    for (int i = 0; i < non_intersected_ranges.length; i++) {
+                        int st = FileBlockManager.getCurrentFragmentIndexofTheFile(non_intersected_ranges[i].getStart());
+                        int en = FileBlockManager.getCurrentFragmentIndexofTheFile(non_intersected_ranges[i].getEnd());
+                        for (int j = st; j <= en; j++) {
+                            if (!(occupiedblocks.contains(Integer.valueOf(j)))) {
+                                occupiedblocks.add(Integer.valueOf(j));
+                            }
+                        }
+                    }
+
+
+                
+                    lockOffset(me);
+                    me.getHeldoffsetlocks().add(offsetlock);
+                    
+                    
+                    for (int k = 0; k < occupiedblocks.size(); k++) {   // locking the block locks
+
+                        while (me.getStatus() == Status.ACTIVE) {
+                          
+                            BlockDataStructure block = this.inodestate.getBlockDataStructure((Integer)(occupiedblocks.get(k)));//(BlockDataStructure) tmp.adapter.lockmap.get(Integer.valueOf(k)));
+                      
+                            //synchronized(block){
+
+                               // if (block.getLock().readLock().tryLock()) {
+                            block.getLock().readLock().lock();
+                                   /* synchronized(benchmark.lock){
+                                        benchmark.msg += Thread.currentThread().getName() + " Locked The Block Number " + block.getBlocknumber()+ " for file " + this.inode + " from descriptor "+ this.sequenceNum +"\n";
+                                    }*/
+           //                         me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Added The Block Number " + block.getBlocknumber()+ " for file " + this.inode + " from descriptor "+ this.sequenceNum +"\n");
+                                    //synchronized (block){
+                                    if (!(block.getReaders().contains(me))){
+                                       /*     synchronized(benchmark.lock){
+                                                benchmark.msg += Thread.currentThread().getName() + " Added to Block Readers for Block Number " + block.getBlocknumber()+ " for file " + this.inode + " from descriptor "+ this.sequenceNum +"\n";
+                                            }*/
+              //                          me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Added to Block Readers for Block Number " + block.getBlocknumber()+ " for file " + this.inode + " from descriptor "+ this.sequenceNum +"\n");
+                                        block.getReaders().add(me);
+                                     }
+                                     me.getHeldblocklocks().add(block.getLock().readLock());
+                                     //heldlocks.add(block.getLock().readLock());
+                                    //}
+                                    break;
+                              //  }
+                                //} else {
+                               //     me.getContentionmanager().resolveConflict(me, block);
+                               // }
+                            //}
+                        }
+                       if (me.getStatus() == Status.ABORTED) {
+                            //unlockLocks(heldlocks);
+                            //offsetlock.unlock();
+           //                 me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Aborted in locking blocks in read\n");
+                   /*         synchronized(benchmark.lock){
+                                benchmark.msg += Thread.currentThread().getName() + " Aborted \n";
+                            }*/
+                          //  Thread.currentThread().stop();
+                            throw new AbortedException();
+                        }
+                    }
+                   /*  
+                        int expvalue = ((Integer) tmp.getBlockversions().get(Integer.valueOf(k))).intValue();
+                        while (me.getStatus() == Status.ACTIVE) {
+                            BlockDataStructure block = ((BlockDataStructure) tmp.adapter.lockmap.get(Integer.valueOf(k)));
+                            if (block.getLock().tryLock()) {
+                                heldlocks.add(block.getLock());
+                                if (!(block.getVersion().get() == expvalue)) {  // for block versioning mechanism
+                                        me.abort();
+                                } 
+                                else {
+                                        break;
+                                }
+                            } 
+                            else {
+                                    me.getContentionManager().resolveConflict(me, block.getOwner());
+                            }
+                        }
+                      if (me.getStatus() == Status.ABORTED) {
+                            unlockLocks(heldlocks);
+                            offsetlock.unlock();
+                            throw new AbortedException();
+                        }
+                    }
+                   }*/
+
+
+                    for (int i = 0; i < non_intersected_ranges.length; i++) {
+                        try {
+                            synchronized(benchmark.lock){
+                                System.out.println("read start " + non_intersected_ranges[i].getStart());
+                            }
+                            file.seek(non_intersected_ranges[i].getStart());
+                            int tmpsize = file.read(b, (int) (non_intersected_ranges[i].getStart() - readrange.getStart()), (int) (non_intersected_ranges[i].getEnd() - non_intersected_ranges[i].getStart()));
+                            result += tmpsize;
+                        } catch (IOException ex) {
+                            
+                            //unlockLocks(heldlocks);
+                            //offsetlock.unlock();
+                            Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex);
+                        }
+                    }
+                    me.unlockAllLocks();
+                    tmp.setLocaloffset(tmp.getLocaloffset() + result);
+                   // unlockLocks(heldlocks);
+                   // offsetlock.unlock();
+                }
+                /*synchronized(benchmark.lock){
+                    benchmark.msg += Thread.currentThread().getName() + " Read from file " + this.inode + " from descriptor "+ this.sequenceNum +"\n";
+                }*/
+           //     me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Read from file " + this.inode + " from descriptor "+ this.sequenceNum +"\n");
+                return result;
+            }
+
+        } else {           // add to the readers list  
+            System.out.println("form read???");
+            me.addFile(this);
+            return read(b);
+        }
+
+    }
+
+    public void write(byte[] data) throws IOException {
+
+        if (!(writemode)) {
+            throw new IOException();
+
+        }
+
+        ExtendedTransaction me = Wrapper.getTransaction();
+        int size = data.length;
+
+
+        if (me == null) // not a transaction 
+        {
+            
+            non_Transactional_Write(data);
+            return;
+        }
+        
+        //else if (me.getFilesAccesses().containsKey(this.getInode())) // 
+        //{
+     //   if (me.getStatus() != Status.ACTIVE)
+       //         throw new AbortedException();
+        
+        if (me.getGlobaltoLocalMappings().containsKey(this)) // 
+        {
+            
+            
+            Byte[] by = new Byte[size];
+            for (int i = 0; i < size; i++) {
+                by[i] = Byte.valueOf(data[i]);
+            }
+            TransactionLocalFileAttributes tmp = ((TransactionLocalFileAttributes) (me.getGlobaltoLocalMappings().get(this)));
+
+            /*if (appendmode) {
+                newwriterange = new Range((((Range) (tm.firstKey())).getStart()), (((Range) (tm.firstKey())).getEnd()) + size);
+                Range range = new Range((((Range) (tm.firstKey())).getStart()), (((Range) (tm.firstKey())).getEnd()));
+                Byte[] appenddata = new Byte[(int) (newwriterange.getEnd() - newwriterange.getStart())];
+                Byte[] tempor = new Byte[(int) (range.getEnd() - range.getStart())];
+                System.arraycopy(tempor, 0, appenddata, 0, tempor.length);
+                System.arraycopy(by, 0, appenddata, tempor.length, by.length);
+                tm.remove(range);
+                tm.put(newwriterange, appenddata);
+                tmp.setLocaloffset(loffset + size);
+                tmp.setFilelength(tmp.getFilelength() + size);
+
+                return;
+            }*/
+            Vector dummy;
+            if (((Vector)(me.getWriteBuffer().get(this.inode))) != null){
+                dummy = new Vector((Vector)(me.getWriteBuffer().get(this.inode)));
+            }
+            else 
+                dummy = new Vector();
+            /* synchronized(benchmark.lock){
+                    System.out.println(Thread.currentThread() + " gg " + tmp.getLocaloffset() + " " + (tmp.getLocaloffset()+by.length));
+                }*/
+            /*if (!(tmp.isUnknown_inital_offset_for_write())){
+                lockOffset(me);
+                tmp.setLocaloffset(this.committedoffset.getOffsetnumber());
+                offsetlock.unlock();
+            }*/
+                
+            dummy.add(new WriteOperations(by, new Range(tmp.getLocaloffset(), tmp.getLocaloffset() + by.length), tmp.isUnknown_inital_offset_for_write(), this, tmp));
+            me.getWriteBuffer().put(this.inode, dummy);
+            
+            long loffset = tmp.getLocaloffset();
+             
+             
+            tmp.setLocaloffset(tmp.getLocaloffset() + by.length);
+            
+            me.merge_for_writes_done.put(inode, Boolean.FALSE);
+            //me.setWritesmerged(false);
+            
+           
+            
+            if (!(tmp.isUnknown_inital_offset_for_write())){
+                markAccessedBlocks(me, loffset, size, BlockAccessModesEnum.WRITE);
+//                markWriteBlocks(loffset, size);
+            }
+            /*{
+                int startblock = FileBlockManager.getCurrentFragmentIndexofTheFile(loffset);
+                    int targetblock = FileBlockManager.getTargetFragmentIndexofTheFile(loffset, size);
+                    for (int i = startblock; i <= targetblock; i++) {
+                        if (me.getAccessedBlocks().containsKey(Integer.valueOf(i))) {
+                            if (((BlockAccessModesEnum) (me.getAccessedBlocks().get(Integer.valueOf(i)))) == BlockAccessModesEnum.READ) {
+                                me.getAccessedBlocks().put(Integer.valueOf(i), BlockAccessModesEnum.READ_WRITE);
+                            }
+                        } else {
+                            me.getAccessedBlocks().put(Integer.valueOf(i), BlockAccessModesEnum.WRITE);
+                        // tmp.getBlockversions().put(Integer.valueOf(i), Integer.valueOf(getBlockDataStructure(i).getVersion().get())); //For Block Versioning Mechanism
+                        }
+                    }
+            }*/
+           
+            if (tmp.getOffsetdependency() == OffsetDependency.NO_ACCESS)
+                tmp.offsetdependency = OffsetDependency.WRITE_DEPENDENCY_1;
+            
+             
+            
+            /*if ((tmp.access_from_absolute_offset) || !(tmp.relocatablewrite))
+            {  
+                int startblock = FileBlockManager.getCurrentFragmentIndexofTheFile(loffset);
+                int targetblock = FileBlockManager.getTargetFragmentIndexofTheFile(loffset, size);
+                for (int i = startblock; i <= targetblock; i++) {
+                    if (tmp.getAccesedblocks().containsKey(Integer.valueOf(i))) {
+                        if (((BlockAccessModesEnum) (tmp.getAccesedblocks().get(Integer.valueOf(i)))) == BlockAccessModesEnum.READ) {
+                            tmp.getAccesedblocks().put(Integer.valueOf(i), BlockAccessModesEnum.READ_WRITE);
+                        }
+                    } else {
+                        tmp.getAccesedblocks().put(Integer.valueOf(i), BlockAccessModesEnum.WRITE);
+                    // tmp.getBlockversions().put(Integer.valueOf(i), Integer.valueOf(getBlockDataStructure(i).getVersion().get())); //For Block Versioning Mechanism
+                    }
+                }
+            }
+            
+            if (tmp.access_from_absolute_offset){
+                
+                mergeWrittenData(tmp.getNon_Speculative_Writtendata(), data, newwriterange);
+                tmp.setLocaloffset(loffset + size);
+                if (tmp.getLocaloffset() > tmp.getFilelength()) {
+                    tmp.setFilelength(tmp.getLocaloffset());
+                }
+                return;
+            }
+            
+            else  // for comtimious determingin the accessed block is postpond till commit instant
+            {   
+                Byte[] dd = new Byte[size];
+                System.arraycopy(by, 0, dd, 0, size);
+                if (!(tmp.getSpeculative_Writtendata().isEmpty())){
+                
+                    Range lastrange = (Range) tmp.getSpeculative_Writtendata().lastKey();
+                    if (lastrange.getEnd() == newwriterange.getStart()){
+                        dd = new Byte[(int)(size + lastrange.getEnd() - lastrange.getStart())];
+                        System.arraycopy(((Byte[])tmp.getSpeculative_Writtendata().get(lastrange)), 0, dd, 0, (int)(lastrange.getEnd() - lastrange.getStart()));
+                        System.arraycopy(by, 0, dd, (int)(lastrange.getEnd() - lastrange.getStart()), size);
+                        newwriterange = new Range(lastrange.getStart(), size + lastrange.getEnd());
+                        tmp.getSpeculative_Writtendata().remove(lastrange);
+                    }
+                       
+                }
+                
+                tmp.getSpeculative_Writtendata().put(newwriterange, dd);
+                
+                tmp.setLocaloffset(loffset + size);
+                if (tmp.getLocaloffset() > tmp.getFilelength()) {
+                    tmp.setFilelength(tmp.getLocaloffset());
+                }
+                
+                return;
+            }
+                
+            */
+
+            /*
+
+            if (tmp.accessmode == TransactionLocalFileAttributes.MODE.READ)
+            tmp.accessmode = TransactionLocalFileAttributes.MODE.READ_WRITE;
+            else if (tmp.accessmode == TransactionLocalFileAttributes.MODE.WRITE)
+            simpleWritetoBuffer(by, newwriterange, tm);
+             */
+           //  me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Writes to " + this.inode + " from descriptor "+ this.sequenceNum +"\n");
+
+        } else {
+           // System.out.println("form write??");
+           // me.addFile(this/*, TransactionLocalFileAttributes.MODE.WRITE*/);
+               //if (!(me.getGlobaltoLocalMappings().containsKey(this))){
+                //if (!(me.getFilesAccesses().containsKey(this.inode))) {
+                TransactionLocalFileAttributes tmp = new TransactionLocalFileAttributes(0);/*, tf.getInodestate().commitedfilesize.get();*/
+                  
+                 Vector dummy;   
+                 if (me.getAccessedFiles().containsKey(this.getInode())){
+                    dummy = (Vector) me.getAccessedFiles().get(this.getInode());
+                 }
+                 else{ 
+                  dummy = new Vector();
+                  me.getAccessedFiles().put(this.getInode(), dummy);
+                 }
+            
+        
+           
+      //      this.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Unlocked the offset lock " + tf.offsetlock + " for file " + tf.getInode() + " form descriptor " + tf.getSequenceNum());
+                dummy.add(this);
+                me.getGlobaltoLocalMappings().put(this, tmp);
+                me.merge_for_writes_done.put(this.getInode(), Boolean.TRUE);
+            //me.addFile(this);
+            //}
+            
+            write(data);
+        }
+       /* synchronized(benchmark.lock){
+            benchmark.msg += Thread.currentThread().getName() + " Writes to " + this.inode + " from descriptor "+ this.sequenceNum +"\n";
+        }*/
+        
+
+    }
+
+    
+    private void markAccessedBlocks(ExtendedTransaction me,long loffset, int size, BlockAccessModesEnum mode){
+        
+        TreeMap map;
+        
+        if (me.getAccessedBlocks().get(this.getInode()) != null)
+            map = (TreeMap) me.getAccessedBlocks().get(this.getInode());
+        else{ 
+            map = new TreeMap();
+            me.getAccessedBlocks().put(this.inode, map);
+        }
+        int startblock = FileBlockManager.getCurrentFragmentIndexofTheFile(loffset);
+        int targetblock = FileBlockManager.getTargetFragmentIndexofTheFile(loffset, size);
+        for (int i = startblock; i <= targetblock; i++) {
+            if (map.containsKey(Integer.valueOf(i))){
+                 if (map.get(Integer.valueOf(i)) != mode){ 
+                    map.put(Integer.valueOf(i), BlockAccessModesEnum.READ_WRITE);
+                 }
+            }
+            else{
+                  map.put(Integer.valueOf(i), mode);
+            }
+        }
+        /*int startblock = FileBlockManager.getCurrentFragmentIndexofTheFile(loffset);
+        int targetblock = FileBlockManager.getTargetFragmentIndexofTheFile(loffset, size);
+        for (int i = startblock; i <= targetblock; i++) {
+            if (me.getAccessedBlocks().containsKey(Integer.valueOf(i))) {
+                if (((BlockAccessModesEnum) (me.getAccessedBlocks().get(Integer.valueOf(i)))) == BlockAccessModesEnum.READ) {
+                    me.getAccessedBlocks().put(Integer.valueOf(i), BlockAccessModesEnum.READ_WRITE);
+                 }
+                
+                
+             } else {
+                    me.getAccessedBlocks().put(Integer.valueOf(i), BlockAccessModesEnum.WRITE);
+                // tmp.getBlockversions().put(Integer.valueOf(i), Integer.valueOf(getBlockDataStructure(i).getVersion().get())); //For Block Versioning Mechanism
+             }
+        }*/
+    }
+    
+/*    private void markWriteBlocks(long loffset, int size){
+        ExtendedTransaction me = CustomThread.getTransaction();
+        SortedSet tt;
+        if (me.writeBlocks.get(this.inode) != null)
+            tt = (SortedSet) me.writeBlocks.get(this.inode);
+        else {
+            tt = new TreeSet();
+            me.writeBlocks.put(this.inode, tt);
+        }
+
+        int startblock = FileBlockManager.getCurrentFragmentIndexofTheFile(loffset);
+        int targetblock = FileBlockManager.getTargetFragmentIndexofTheFile(loffset, size);
+        for (int i = startblock; i <= targetblock; i++) {
+            tt.add(Integer.valueOf(i));
+        }
+    }*/
+    
+    private int readFromFile(ExtendedTransaction me, byte[] readdata, TransactionLocalFileAttributes tmp) {
+     
+
+        //ExtendedTransaction me = Wrapper.getTransaction();
+        int st = FileBlockManager.getCurrentFragmentIndexofTheFile(tmp.getLocaloffset());
+        int end = FileBlockManager.getTargetFragmentIndexofTheFile(tmp.getLocaloffset(), readdata.length);
+        
+         BlockDataStructure block = null;
+         boolean locked = false;
+        for (int k = st; k <= end; k++) {
+           // int expvalue = ((Integer) tmp.getBlockversions().get(Integer.valueOf(k))).intValue(); // all comments here for versioning mechanism
+            while (me.getStatus() == Status.ACTIVE) {
+                //BlockDataStructure block = ((BlockDataStructure) this.inodestate.lockmap.get(Integer.valueOf(k)));
+              //  BlockDataStructure block;
+                //if (me.getAccessedBlocks().get(inode))
+                block = this.inodestate.getBlockDataStructure(Integer.valueOf(k));
+      
+                block.getLock().readLock().lock();
+                      //  me.getHeldblocklocks().add(block.getLock().readLock());
+                        if (!(block.getReaders().contains(me))){
+                            block.getReaders().add(me);
+                        }
+                        locked = true;
+             //       if (!(block.getVersion().get() == expvalue)) {
+             //           me.abort();
+             //       } else {
+                     break;
+             //       }
+           //     }
+            /* else {
+                    me.getContentionmanager().resolveConflict(me, block);
+                }*/
+
+            }
+            if (me.getStatus() == Status.ABORTED) {
+                int m;
+                if (locked){
+                    m = k+1;
+                }
+                else 
+                    m = k;
+                for (int i=st; i<m; i++){
+                 /*   System.out.println("///////////////////");
+                    synchronized(benchmark.lock){
+                      System.out.println(block.getBlocknumber() + " =? " + i);
+                    }*/
+                    block = this.inodestate.getBlockDataStructure(Integer.valueOf(k));
+                    me.getHeldblocklocks().add(block.getLock().readLock());
+                  //  System.out.println("///////////////////");
+                }
+             
+                locked = false;
+                
+                throw new AbortedException();
+            }
+
+        }
+        if (me.getStatus() == Status.ABORTED) {
+             for (int i=st; i<=end; i++){
+                    block = this.inodestate.getBlockDataStructure(Integer.valueOf(i));
+                    me.getHeldblocklocks().add(block.getLock().readLock());
+             }
+                throw new AbortedException();
+        }
+        
+        int size = -1;
+     
+            //ByteBuffer buffer = ByteBuffer.wrap(readdata);
+            //size = file.getChannel().read(buffer, tmp.getLocaloffset());
+            size = invokeNativepread(readdata, tmp.getLocaloffset(), readdata.length);
+            
+           // synchronized(benchmark.lock){
+           // if (Integer.valueOf(Thread.currentThread().getName().substring(7)) == 0)
+          /*  for (int i =0; i<readdata.length; i++)
+                System.out.println(Thread.currentThread() +  " " + (char)readdata[i]);
+            }*/
+           // file.seek(tmp.getLocaloffset());
+          //  size = file.read(readdata);
+
+            tmp.setLocaloffset(tmp.getLocaloffset() + size);
+            
+            if (size == 0)
+                size = -1;
+  
+           
+         /*   while (it.hasNext()) {
+            
+                Lock lock = (Lock) it.next();
+                lock.unlock();
+            }*/
+        //    me.getHeldblocklocks().clear();
+    // }
+        
+        if (me.getStatus() == Status.ABORTED) {
+                  for (int i=st; i<=end; i++){
+                    block = this.inodestate.getBlockDataStructure(Integer.valueOf(i));
+                    me.getHeldblocklocks().add(block.getLock().readLock());
+             }
+                throw new AbortedException();
+        }
+        for (int k = st; k <= end; k++) {
+                    block = this.inodestate.getBlockDataStructure(Integer.valueOf(k));
+                    block.getLock().readLock().unlock();
+        }
+        return size;
+
+
+    }
+
+    private int readFromBuffer(byte[] readdata, TransactionLocalFileAttributes tmp, WriteOperations wrp, Range writerange) {
+        /*synchronized(benchmark.lock){
+            System.out.println("in read buffer " + Thread.currentThread());
+        }*/
+        
+        long loffset = tmp.getLocaloffset();
+
+        Byte[] data = (Byte[]) wrp.getData();
+        byte[] copydata = new byte[data.length];
+
+        for (int i = 0; i < data.length; i++) {
+            copydata[i] = data[i].byteValue();
+        }
+        System.arraycopy(copydata, (int) (loffset - writerange.getStart()), readdata, 0, readdata.length);
+        tmp.setLocaloffset(tmp.getLocaloffset() + readdata.length);
+        return readdata.length;
+
+    }
+
+    public void simpleWritetoBuffer(Byte[] data, Range newwriterange, TreeMap tm) {
+        tm.put(newwriterange, data);
+    }
+
+    public void unlockLocks(Vector heldlocks) {
+        for (int i = 0; i < heldlocks.size(); i++) {
+            ((Lock) heldlocks.get(i)).unlock();
+        }
+    }
+    
+
+/*    public boolean validateBlocksVersions(int startblock, int targetblock) { // For Block Versioning Mechanism
+        boolean valid = true;
+        ExtendedTransaction me = ExtendedTransaction.getTransaction();
+        TransactionLocalFileAttributes tmp = ((TransactionLocalFileAttributes) (me.getFilesAccesses().get(this.getInode())));
+        for (int i = startblock; i <= targetblock; i++) {
+            int expvalue = ((Integer) tmp.getBlockversions().get(Integer.valueOf(i))).intValue();
+            BlockDataStructure block = ((BlockDataStructure) tmp.adapter.lockmap.get(Integer.valueOf(i)));
+            if (expvalue != block.getVersion().get()) {
+                valid = false;
+                break;
+            }
+        }
+
+        return valid;
+    }*/
+
+
+
+    public void setInode(INode inode) {
+        this.inode = inode;
+    }
+    
+    public void lockOffset(ExtendedTransaction me){
+    //     
+           // System.out.println(Integer.getInteger(me.getStatus().toString()));
+          //  lo.lockWhen(sequenceNum);
+            boolean locked = false;
+            while (me.getStatus() == Status.ACTIVE) {                        //locking the offset
+                  //synchronized(this.commitedoffset){
+               //   System.out.println("Trying");
+              //  try{
+              //  offsetlock.lockInterruptibly();
+                    offsetlock.lock();
+               // }
+               // catch(InterruptedException e){
+                 //   System.out.println("dsadsa");
+                //}
+                
+                //me.getHeldoffsetlocks().add(offsetlock);
+               
+               locked = true;
+               break;
+                
+                
+               //   if (offsetlock.tryLock()) {
+                        //    synchronized(this.commitedoffset){
+                        //        this.commitedoffset.setOffsetOwner(me);
+                      //System.out.println(Thread.currentThread().getName() + " grabbd the lock");
+                       //     }
+                   /*   synchronized(benchmark.lock){
+                        benchmark.msg += Thread.currentThread().getName() + " Locked the offset lock for " + this.inode + " from descriptor "+ this.sequenceNum +"\n";
+                      }*/
+                   /*   synchronized(benchmark.lock){
+                                       System.out.println(Thread.currentThread() + "LOCked the offset lock "  + offsetlock);
+                      }*/
+                      
+                      //offsetlocks.add(offsetlock);
+    //                  me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Locked the offset lock for file " + this.inode + " from descriptor "+ this.sequenceNum +"\n");
+                      //break;
+                 // }
+                       //} 
+                       //me.getContentionmanager().resolveConflict(me, this.commitedoffset);
+            }
+            
+          //  if (me.getStatus() != Status.ACTIVE){
+             
+    //             me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Aborted  in lock offset\n");
+                 /*synchronized(benchmark.lock){
+                    benchmark.msg += Thread.currentThread().getName() + " Aborted \n";
+                 }*/
+                 //  CustomThread.getTransaction().setStatus(Status.ACTIVE);
+                 //  CustomThread.getProgram().execute();
+//                 if (offsetlock.isHeldByCurrentThread())
+                 //if (locked)
+                 //  offsetlock.unlock();
+                 //unlockOffsetLocks();
+                /* synchronized(benchmark.lock){
+                     System.out.println("aborting " + committedoffset + " " +Thread.currentThread());
+                 }*/
+                 //Thread.currentThread().stop();
+            if (me.getStatus() != Status.ACTIVE){
+               if (locked)
+                    me.getHeldoffsetlocks().add(offsetlock);
+                throw new AbortedException();
+            }
+                   
+           // }
+    }
+    
+    public void mergeWrittenData(ExtendedTransaction me/*TreeMap target, byte[] data, Range to_be_merged_data_range*/){
+            
+            //ExtendedTransaction me = Wrapper.getTransaction();
+            boolean flag = false;
+            Vector vec = (Vector) me.getWriteBuffer().get(this.inode);     
+            Range intersectedrange = new Range(0, 0);
+            Iterator it1 = vec.iterator();
+            WriteOperations wrp;
+            WriteOperations wrp2;
+            Vector toberemoved = new Vector();
+            while (it1.hasNext()) {
+                wrp = (WriteOperations) (it1.next());
+                
+                if (toberemoved.contains(wrp)){
+                    continue;
+                }
+                    
+                Iterator it2 = vec.listIterator();
+                while (it2.hasNext()) {
+                    flag = false;
+                    wrp2 = (WriteOperations) (it2.next());
+                    /*if (wrp2.getRange().includes(wrp.getRange())) {
+                        flag = true;
+                        intersect = wrp2.getRange().intersection(wrp.getRange());
+                        break;
+                    }
+                    */
+                    if ((wrp2 == wrp) || toberemoved.contains(wrp2)){
+                        continue;
+                    }
+                        
+                    if (wrp.getRange().hasIntersection(wrp2.getRange())) {
+                        flag = true;
+                        intersectedrange = wrp2.getRange().intersection(wrp.getRange());
+                        toberemoved.add(wrp2);
+                    }
+                    
+                    
+                    long startprefix = 0;
+                    long endsuffix = 0;
+                    long startsuffix = 0;
+                    int prefixsize = 0;
+                    int suffixsize = 0;
+                    int intermediatesize = 0;
+                    Byte[] prefixdata = null;
+                    Byte[] suffixdata = null;
+                    boolean prefix = false;
+                    boolean suffix = false;
+                    if (flag){
+                        
+                        
+                        if (wrp.getRange().getStart() < wrp2.getRange().getStart()) {
+                             prefixdata = new Byte[(int) (wrp2.getRange().getStart() - wrp.getRange().getStart())];
+                             prefixdata = (Byte[]) (wrp.getData());
+                             startprefix = wrp.getRange().getStart();
+                             prefixsize = (int)(intersectedrange.getStart() - startprefix);
+                             intermediatesize = (int)(intersectedrange.getEnd() -intersectedrange.getStart());
+                             prefix = true;   
+                        }
+
+                        else if (wrp2.getRange().getStart() <= wrp.getRange().getStart()) {
+                             prefixdata = new Byte[(int) (wrp.getRange().getStart() - wrp2.getRange().getStart())];
+                             prefixdata = (Byte[]) (wrp2.getData());
+                             startprefix = wrp2.getRange().getStart();
+                             prefixsize = (int)(intersectedrange.getStart() - startprefix);
+                             intermediatesize = (int)(intersectedrange.getEnd() -intersectedrange.getStart());
+                             prefix = true;
+                        }
+
+                        if (wrp2.getRange().getEnd() >= wrp.getRange().getEnd()) {
+
+                             suffixdata = new Byte[(int) (wrp2.getRange().getEnd() - intersectedrange.getEnd())];
+                             suffixdata = (Byte[]) (wrp2.getData());
+                             startsuffix = intersectedrange.getEnd() - wrp2.getRange().getStart();
+                             suffixsize = (int)(wrp2.getRange().getEnd() - intersectedrange.getEnd());
+                             suffix = true;
+                             //System.out.println("wrp2 > wrp");
+                            
+                             endsuffix = wrp2.getRange().getEnd();
+                             //suffixstart = (int) (intersectedrange[i].getEnd() - intersectedrange[i].getStart());
+                        }
+
+                        else if (wrp.getRange().getEnd() > wrp2.getRange().getEnd()) {
+                             suffixdata = new Byte[(int) (wrp.getRange().getEnd() - intersectedrange.getEnd())];
+                             suffixdata = (Byte[]) (wrp.getData());
+                             startsuffix = intersectedrange.getEnd() - wrp.getRange().getStart();
+                             suffixsize = (int)(wrp.getRange().getEnd() - intersectedrange.getEnd());
+                            // System.out.println("wrp2 < wrp");
+                             endsuffix = wrp.getRange().getEnd();
+                             suffix = true;
+
+                        }
+                    /*   System.out.println("prefix start:" + startprefix);
+                        System.out.println("suffix end:" + endsuffix);
+                        System.out.println("suffix start:" + startsuffix);
+                        System.out.println("intermediate start:" + intermediatetart);
+                      
+                        System.out.println("suffix size:" + suffixsize);*/
+                        
+
+                        Byte[] data_to_insert;
+
+                        if ((prefix) && (suffix)) {
+                            data_to_insert = new Byte[(int) (endsuffix - startprefix)];
+                            System.arraycopy(prefixdata, 0, data_to_insert, 0, prefixsize);
+                            System.arraycopy(wrp2.getData(), (int)(intersectedrange.getStart() - wrp2.getRange().getStart()), data_to_insert, prefixsize, intermediatesize);
+                            System.arraycopy(suffixdata, (int)startsuffix, data_to_insert, (prefixsize + intermediatesize), suffixsize);
+                            wrp.setData(data_to_insert);
+                            wrp.setRange(new Range(startprefix, endsuffix));
+                        }
+                       
+                    }
+                }
+            }
+            Iterator it = toberemoved.iterator();
+            while (it.hasNext())
+                vec.remove(it.next());
+            
+            toberemoved.clear();
+            Collections.sort(vec);
+            me.merge_for_writes_done.put(inode, Boolean.TRUE);
+            //me.setWritesmerged(true);
+            
+                    /*} else if (prefix) {
+                        data_to_insert = new Byte[(int) (to_be_merged_data_range.getStart() - start + size)];
+                        System.arraycopy(prefixdata, 0, data_to_insert, 0, (int) (to_be_merged_data_range.getStart() - start));
+                        System.arraycopy(by, 0, data_to_insert, (int) (to_be_merged_data_range.getStart() - start), size);
+                        to_be_merged_data_range.setStart(start);
+                    } else if (suffix) {
+                        data_to_insert = new Byte[(int) (to_be_merged_data_range.getEnd() - end + size)];
+                        System.arraycopy(by, 0, data_to_insert, 0, size);
+                        System.arraycopy(suffixdata, suffixstart, data_to_insert, size, (int) (end - to_be_merged_data_range.getEnd()));
+                        to_be_merged_data_range.setEnd(end);
+                    } else {
+                        data_to_insert = new Byte[size];
+                        System.arraycopy(data_to_insert, (int) (to_be_merged_data_range.getStart() - start), by, 0, size);
+                    }*/
+                    //target.put(to_be_merged_data_range, data_to_insert);
+             
+/*
+            if (flag) {
+                int datasize = (int) (oldwriterange.getEnd() - oldwriterange.getStart());
+                Byte[] original = (Byte[]) (wrp.getData());
+                byte[] originaldata = new byte[datasize];
+
+                //for (int i = 0; i < data.length; i++) {
+                //    originaldata[i] = original[i].byteValue();
+               // }
+                System.arraycopy(data, 0, originaldata, (int) (to_be_merged_data_range.getStart() - oldwriterange.getStart()), size);
+                Byte[] to_be_inserted = new Byte[datasize];
+
+                for (int i = 0; i < datasize; i++) {
+                    to_be_inserted[i] = Byte.valueOf(originaldata[i]);
+                }
+                target.put(oldwriterange, to_be_inserted);
+                return;
+
+            } else if (counter == 0) {
+                target.put(to_be_merged_data_range, data);
+                return;
+                
+            } else {
+
+                int suffixstart = 0;
+                long start = 0;
+                long end = 0;
+                Byte[] prefixdata = null;
+                Byte[] suffixdata = null;
+                boolean prefix = false;
+                boolean suffix = false;
+
+                for (int i = 0; i < counter; i++) {
+                    if (markedwriteranges[i].getStart() < to_be_merged_data_range.getStart()) {
+                        prefixdata = new Byte[(int) (to_be_merged_data_range.getStart() - markedwriteranges[i].getStart())];
+                        prefixdata = (Byte[]) (target.get(markedwriteranges[i]));
+                        start = markedwriteranges[i].getStart();
+                        //newdata = new Byte[size +  newwriterange.getStart() - markedwriteranges[i].getStart()];
+                        //System.arraycopy(by, 0, newdata, newwriterange.getStart() - markedwriteranges[i].getStart(), size);
+                        //System.arraycopy(originaldata, 0, newdata, 0, newwriterange.getStart() - markedwriteranges[i].getStart());
+
+                        //newwriterange.setStart(markedwriteranges[i].getStart());
+                        prefix = true;
+
+
+                    } else if (markedwriteranges[i].getEnd() > to_be_merged_data_range.getEnd()) {
+
+                        suffixdata = new Byte[(int) (markedwriteranges[i].getStart() - to_be_merged_data_range.getStart())];
+                        suffixdata = (Byte[]) (target.get(markedwriteranges[i]));
+                        end = markedwriteranges[i].getEnd();
+
+                        //Byte [] originaldata = (Byte [])(tmp.getWrittendata().get(markedwriteranges[i]));
+                        //newdata = new Byte[size +  newwriterange.getStart() - markedwriteranges[i].getStart()];
+                        //System.arraycopy(originaldata, 0, newdata, 0, newwriterange.getStart() - markedwriteranges[i].getStart());
+
+                        //newwriterange.setStart(markedwriteranges[i].getStart());
+                        ///newwriterange.setEnd(markedwriteranges[i].getEnd());
+                        suffix = true;
+                        suffixstart = (int) (intersectedrange[i].getEnd() - intersectedrange[i].getStart());
+                    //tm.remove(markedwriteranges[i]); 
+                    }
+                    target.remove(markedwriteranges[i]);
+
+                }
+                Byte[] data_to_insert;
+
+                if ((prefix) && (suffix)) {
+                    data_to_insert = new Byte[(int) (to_be_merged_data_range.getStart() - start + size - to_be_merged_data_range.getEnd() + end)];
+                    System.arraycopy(prefixdata, 0, data_to_insert, 0, (int) (to_be_merged_data_range.getStart() - start));
+                    System.arraycopy(by, 0, data_to_insert, (int) (to_be_merged_data_range.getStart() - start), size);
+                    System.arraycopy(suffixdata, suffixstart, data_to_insert, (int) (size + to_be_merged_data_range.getStart() - start), (int) (end - to_be_merged_data_range.getEnd()));
+                    to_be_merged_data_range.setStart(start);
+                    to_be_merged_data_range.setEnd(end);
+                } else if (prefix) {
+                    data_to_insert = new Byte[(int) (to_be_merged_data_range.getStart() - start + size)];
+                    System.arraycopy(prefixdata, 0, data_to_insert, 0, (int) (to_be_merged_data_range.getStart() - start));
+                    System.arraycopy(by, 0, data_to_insert, (int) (to_be_merged_data_range.getStart() - start), size);
+                    to_be_merged_data_range.setStart(start);
+                } else if (suffix) {
+                    data_to_insert = new Byte[(int) (to_be_merged_data_range.getEnd() - end + size)];
+                    System.arraycopy(by, 0, data_to_insert, 0, size);
+                    System.arraycopy(suffixdata, suffixstart, data_to_insert, size, (int) (end - to_be_merged_data_range.getEnd()));
+                    to_be_merged_data_range.setEnd(end);
+                } else {
+                    data_to_insert = new Byte[size];
+                    System.arraycopy(data_to_insert, (int) (to_be_merged_data_range.getStart() - start), by, 0, size);
+                }
+                target.put(to_be_merged_data_range, data_to_insert);
+                return;
+            }*/
+    }
+    
+    public void non_Transactional_Write(byte[] data){
+        
+            Vector heldlocks = new Vector();
+            boolean flag = true;
+            offsetlock.lock();
+            int startblock = FileBlockManager.getCurrentFragmentIndexofTheFile(committedoffset.getOffsetnumber());
+            int targetblock = FileBlockManager.getTargetFragmentIndexofTheFile(committedoffset.getOffsetnumber(), data.length);
+            for (int i = startblock; i <= targetblock; i++) {
+                BlockDataStructure block =this.inodestate.getBlockDataStructure(i);
+                //if (block.getLock().writeLock().tryLock()) {
+                block.getLock().writeLock().lock(); 
+                    heldlocks.add(block.getLock().writeLock());
+                //} else {
+                //    unlockLocks(heldlocks);
+                //    offsetlock.unlock();
+                //    flag = false;
+                //    break;
+                //}
+            }
+            
+            /*if (flag) {
+                throw new PanicException("The I/O operation could not be done to contention for the file");
+            }*/
+            
+            //else {
+                try {
+
+                    file.seek(committedoffset.getOffsetnumber());
+                    file.write(data);                    
+                    
+                    committedoffset.setOffsetnumber(committedoffset.getOffsetnumber() +data.length);
+                    
+                } catch (IOException ex) {
+                    Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex);
+                } finally {
+                    unlockLocks(heldlocks);
+                    offsetlock.unlock();
+                }
+            //}
+    }
+    
+    public int non_Transactional_Read(byte[] b){
+            int size = -1;
+            Vector heldlocks = new Vector();
+            boolean flag = true;
+            offsetlock.lock();
+            int startblock;    
+            int targetblock; 
+            startblock = FileBlockManager.getCurrentFragmentIndexofTheFile(committedoffset.getOffsetnumber());
+            targetblock = FileBlockManager.getTargetFragmentIndexofTheFile(committedoffset.getOffsetnumber(), size);
+         /*   long offset = committedoffset.getOffsetnumber();
+            committedoffset.setOffsetnumber(committedoffset.getOffsetnumber() +b.length);
+            if (!(committedoffset.getOffsetReaders().isEmpty())){
+                Iterator it2 =  committedoffset.getOffsetReaders().iterator(); // for visible readers strategy
+                while ( it2.hasNext())
+                {
+                    ExtendedTransaction tr = (ExtendedTransaction) it2.next();
+                    tr.abort();
+                }
+                committedoffset.getOffsetReaders().clear();
+            }
+            offsetlock.unlock();*/
+                
+            for (int i = startblock; i <= targetblock; i++) {
+                BlockDataStructure block = this.inodestate.getBlockDataStructure(i);
+                //if (block.getLock().readLock().tryLock()) {
+                block.getLock().readLock().lock();    
+                    heldlocks.add(block.getLock().readLock());
+                /*} else {
+                    unlockLocks(heldlocks);
+                    offsetlock.unlock();
+                    flag = false;
+                    break;
+                }*/
+            }
+            /*if (flag) {
+                size = -1;
+            } else {*/
+          
+            
+            
+         //   try {
+                //ByteBuffer buffer = ByteBuffer.wrap(b);
+                //System.out.println(committedoffset.getOffsetnumber());
+                //size = file.getChannel().read(buffer, offset);
+                //file.seek(committedoffset.getOffsetnumber());
+               // size = file.read(b);
+                size = invokeNativepread(b, committedoffset.getOffsetnumber(), b.length);
+                
+                     
+                committedoffset.setOffsetnumber(committedoffset.getOffsetnumber() +size);
+                if (!(committedoffset.getOffsetReaders().isEmpty())){
+                    Iterator it2 =  committedoffset.getOffsetReaders().iterator(); // for visible readers strategy
+                    while ( it2.hasNext())
+                    {
+                        ExtendedTransaction tr = (ExtendedTransaction) it2.next();
+                        tr.abort();
+                }   
+                committedoffset.getOffsetReaders().clear();
+                }
+                
+      //      } catch (IOException ex) {
+         //       Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex);
+        //        size = -1;
+        //   } finally {
+                unlockLocks(heldlocks);
+                offsetlock.unlock();
+                if (size == 0)
+                    size = -1;
+         //   }
+           // }
+            return size;
+        
+    }
+    
+    public void non_Transactional_Seek(long offset){
+            offsetlock.lock();
+            //try {
+                //file.seek(offset);
+                //synchronized(adapter){
+                committedoffset.setOffsetnumber(offset);
+              //  inodestate.commitedfilesize.set(offset);
+            //}
+            //} catch (IOException ex) {
+             ///   Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex);
+            //} finally {
+                offsetlock.unlock();
+            //}
+    }
+
+    public long non_Transactional_getFilePointer(){
+            long offset = -1;;
+            offsetlock.lock();
+         
+                    
+           // try {
+                
+                //synchronized(adapter){
+                offset = committedoffset.getOffsetnumber();
+            //}
+         //   } catch (IOException ex) {
+         //       Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex);
+          //  } finally {
+                offsetlock.unlock();
+          //  }
+            return offset;
+    }
+    
+    public int compareTo(Object arg0) {
+        TransactionalFile tf = (TransactionalFile) arg0;
+        if (this.inode.getNumber() < tf.inode.getNumber())
+            return -1;
+        else if (this.inode.getNumber() > tf.inode.getNumber())
+            return 1;
+        else {
+            if (this.sequenceNum < tf.sequenceNum)
+                return -1;
+            else 
+                return 1;
+        }
+    }
+
+} 
diff --git a/Robust/Transactions/TransactionalIOSrc/core/TransactionalFileWrapperFactory.java b/Robust/Transactions/TransactionalIOSrc/core/TransactionalFileWrapperFactory.java
new file mode 100644 (file)
index 0000000..b684a55
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package TransactionalIO.core;
+
+import java.io.File;
+import java.util.HashMap;
+
+/**
+ *
+ * @author navid
+ */
+public class TransactionalFileWrapperFactory {
+
+
+
+    private TransactionalFileWrapperFactory() {
+    }
+  //  private static HashMap<INode, Adapter> filemappings;
+    public static HashMap filemappings = new HashMap();
+    
+    private static native long getINodeNative(String filename);
+    
+    static{
+        //System.load("/home/navid/libnav.so");
+        System.load("/home/navid/libnativeIO.so");
+    }
+    
+    static INode getINodefromFileName(String filename) {
+        return new INode(getINodeNative(filename), filename);
+    }
+
+    
+    
+    public synchronized static GlobalINodeState getTateransactionalFileINodeState(INode inode) {
+            
+        return (GlobalINodeState)filemappings.get(inode.getNumber());
+            
+    }
+    public synchronized static GlobalINodeState createTransactionalFile(INode inode, String filename, String mode) {
+
+        long inodenumber = inode.getNumber();
+        if (inodenumber != -1)
+            
+            if (filemappings.containsKey(inode.getNumber())) {
+             //   System.out.println("here");
+                return (GlobalINodeState)filemappings.get(inode.getNumber());
+
+            } else {
+                
+            
+                long length = new File(filename).length();
+                
+                GlobalINodeState inodestate = new GlobalINodeState(inode, length);
+                filemappings.put(inode.getNumber(), inodestate);
+                return inodestate;
+            }
+        
+        else
+        {       
+            return null;
+        }
+
+    }
+        
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/core/Wrapper.java b/Robust/Transactions/TransactionalIOSrc/core/Wrapper.java
new file mode 100644 (file)
index 0000000..b68f488
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.core;
+
+import TransactionalIO.core.ExtendedTransaction;
+
+import TransactionalIO.core.CustomThread;
+import TransactionalIO.interfaces.TransactionStatu;
+import java.util.Vector;
+
+
+/**
+ *
+ * @author navid
+ */
+public class Wrapper{
+    
+    
+    private ExtendedTransaction transaction = new ExtendedTransaction();
+    private static ThreadLocal IOtransactioncontainer = new ThreadLocal();
+    private static ThreadLocal onMemoryAbort = new ThreadLocal();
+    private static ThreadLocal onIOAbort = new ThreadLocal();
+    
+
+    
+    public static void prepareIOCommit(){
+        
+        getTransaction().prepareCommit();
+    }
+    
+    public static void commitIO(){
+        getTransaction().commitChanges();
+    }
+    
+    
+    
+    public static void Initialize(TransactionStatu memory){
+        ExtendedTransaction transaction = new ExtendedTransaction();
+        setTransaction(transaction);
+        transaction.setOtherSystem(memory);
+        
+        if (memory != null)
+            memory.setOtherSystem(transaction);
+        
+        
+        
+   /*     setonIOAbort(new Vector());
+        setonMemoryAbort(new Vector());
+        
+        getonIOAbort().add(new terminateHandler() {
+                    public void cleanup() {
+                        Thread.getTransaction().abort();
+                        synchronized(benchmark.lock){
+                            System.out.println(Thread.currentThread() +" KEWL");
+                        }
+                    }
+        });
+        
+        getonMemoryAbort().add(new terminateHandler() {
+                    public void cleanup() {
+                        CustomThread.getTransaction().abort();
+                        synchronized(benchmark.lock){
+                            System.out.println(Thread.currentThread() +" KEWL");
+                        }
+                    }
+        });*/
+    }
+    
+    public static void memoryCommit(){
+        
+    }
+    
+    
+    public static void setTransaction(ExtendedTransaction transaction){
+        IOtransactioncontainer.set(transaction);
+    }
+    
+   
+    
+    public static ExtendedTransaction getTransaction(){
+        return (ExtendedTransaction) IOtransactioncontainer.get(); 
+    }
+    
+    public static void setonIOAbort(Vector vec){
+        onIOAbort.set(vec);
+    }
+    
+    
+    private static Vector getonIOAbort(){
+         return (Vector) onIOAbort.get();
+    }
+
+    public static void setonMemoryAbort(Vector vec){
+        onMemoryAbort.set(vec);
+    }
+    
+    
+    private static Vector getonMemoryAbort(){
+         return (Vector) onMemoryAbort.get();
+    }
+
+        
+    
+    
+    
+    
+
+}
+
+
+
diff --git a/Robust/Transactions/TransactionalIOSrc/core/WriteOperations.java b/Robust/Transactions/TransactionalIOSrc/core/WriteOperations.java
new file mode 100644 (file)
index 0000000..9a37667
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.core;
+
+import TransactionalIO.Utilities.Range;
+
+/**
+ *
+ * @author navid
+ */
+public class WriteOperations implements Comparable{
+    
+    private Byte[] data;
+    private Range range;
+    private boolean unknownoffset;
+    private TransactionLocalFileAttributes belongingto;
+    private TransactionalFile ownertransactionalfile;
+
+    public WriteOperations(Byte[] data, Range range, boolean unknownoffset, TransactionalFile ownertransactionalfile, TransactionLocalFileAttributes belongingto) {
+        this.data = data;
+        this.range = range;
+        this.unknownoffset = unknownoffset;
+        this.ownertransactionalfile = ownertransactionalfile;
+        this.belongingto = belongingto;
+    }
+
+    public TransactionalFile getOwnertransactionalFile() {
+        return ownertransactionalfile;
+    }
+
+    public void setOwnertransaction(TransactionalFile ownertransaction) {
+        this.ownertransactionalfile = ownertransaction;
+    }
+    
+    
+
+    public Byte[] getData() {
+        return data;
+    }
+
+    public Range getRange() {
+        return range;
+    }
+
+    public boolean isUnknownoffset() {
+        return unknownoffset;
+    }
+
+    public void setData(Byte[] data) {
+        this.data = new Byte[data.length];
+        System.arraycopy(data, 0, this.data, 0, data.length);
+    }
+
+    public void setRange(Range range) {
+        this.range = range;
+    }
+
+    public void setUnknownoffset(boolean unknownoffset) {
+        this.unknownoffset = unknownoffset;
+    }
+
+    public TransactionLocalFileAttributes getBelongingto() {
+        return belongingto;
+    }
+
+    public void setBelongingto(TransactionLocalFileAttributes belongingto) {
+        this.belongingto = belongingto;
+    }
+    
+    
+    public int compareTo(Object other) {
+        WriteOperations tmp = (WriteOperations) other;
+        return this.range.compareTo(tmp.range);
+    }
+    
+    
+    
+
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/exceptions/PanicException.java b/Robust/Transactions/TransactionalIOSrc/exceptions/PanicException.java
new file mode 100644 (file)
index 0000000..ed58fc6
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * PanicException.java
+ *
+ * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa
+ * Clara, California 95054, U.S.A.  All rights reserved.  
+ * 
+ * Sun Microsystems, Inc. has intellectual property rights relating to
+ * technology embodied in the product that is described in this
+ * document.  In particular, and without limitation, these
+ * intellectual property rights may include one or more of the
+ * U.S. patents listed at http://www.sun.com/patents and one or more
+ * additional patents or pending patent applications in the U.S. and
+ * in other countries.
+ * 
+ * U.S. Government Rights - Commercial software.
+ * Government users are subject to the Sun Microsystems, Inc. standard
+ * license agreement and applicable provisions of the FAR and its
+ * supplements.  Use is subject to license terms.  Sun, Sun
+ * Microsystems, the Sun logo and Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other
+ * countries.  
+ * 
+ * This product is covered and controlled by U.S. Export Control laws
+ * and may be subject to the export or import laws in other countries.
+ * Nuclear, missile, chemical biological weapons or nuclear maritime
+ * end uses or end users, whether direct or indirect, are strictly
+ * prohibited.  Export or reexport to countries subject to
+ * U.S. embargo or to entities identified on U.S. export exclusion
+ * lists, including, but not limited to, the denied persons and
+ * specially designated nationals lists is strictly prohibited.
+ */
+
+package TransactionalIO.exceptions;
+
+/**
+ * Thrown to indicate an error in the use of the transactional memory;
+ * that is, a violation of the assumptions of use.
+ */
+public class PanicException extends java.lang.RuntimeException {
+
+    /**
+     * Creates new <code>PanicException</code> with no detail message.
+     */
+    public PanicException() {
+    }
+
+    public PanicException(String format, Object ... args) {
+      super(String.format(format, args));
+    }
+
+    /**
+     * Creates a new <code>PanicException</code> with the specified detail message.
+     * 
+     * @param msg the detail message.
+     */
+    public PanicException(String msg) {
+        super(msg);
+    }
+
+    /**
+     * Creates an <code>PanicException</code> with the specified cause.
+     * 
+     * @param cause Throwable that caused PanicException to be thrown
+     */
+    public PanicException(Throwable cause) {
+        super(cause);
+    }
+}
+
diff --git a/Robust/Transactions/TransactionalIOSrc/interfaces/BlockAccessModesEnum.java b/Robust/Transactions/TransactionalIOSrc/interfaces/BlockAccessModesEnum.java
new file mode 100644 (file)
index 0000000..37ce6dd
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.interfaces;
+
+/**
+ *
+ * @author navid
+ */
+public enum BlockAccessModesEnum {
+    READ_WRITE, WRITE, READ
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/interfaces/ContentionManager.java b/Robust/Transactions/TransactionalIOSrc/interfaces/ContentionManager.java
new file mode 100644 (file)
index 0000000..af21ee9
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.interfaces;
+
+import TransactionalIO.core.BlockDataStructure;
+import TransactionalIO.core.ExtendedTransaction;
+import TransactionalIO.core.GlobalOffset;
+import TransactionalIO.core.TransactionalFile;
+import java.util.Vector;
+
+/**
+ *
+ * @author navid
+ */
+
+public interface ContentionManager {
+
+    
+  public void resolveConflict(ExtendedTransaction me, ExtendedTransaction other, GlobalOffset obj);
+  public void resolveConflict(ExtendedTransaction me, ExtendedTransaction other, BlockDataStructure obj);
+
+  public void resolveConflict(ExtendedTransaction me, Vector/*<ExtendedTransaction>*/ other, GlobalOffset obj);
+  public void resolveConflict(ExtendedTransaction me, Vector/*<ExtendedTransaction>*/ other, BlockDataStructure obj);
+  
+  public void resolveConflict(ExtendedTransaction me, GlobalOffset obj);
+  public void resolveConflict(ExtendedTransaction me, BlockDataStructure obj);
+
+  public long getPriority();
+  
+
+  public void setPriority(long value);
+  
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/interfaces/FileAccessModesEum.java b/Robust/Transactions/TransactionalIOSrc/interfaces/FileAccessModesEum.java
new file mode 100644 (file)
index 0000000..c956c78
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.interfaces;
+
+import java.io.WriteAbortedException;
+
+/**
+ *
+ * @author navid
+ */
+public enum FileAccessModesEum {
+    READ_WRITE, APPEND, READ
+
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/interfaces/OffsetDependency.java b/Robust/Transactions/TransactionalIOSrc/interfaces/OffsetDependency.java
new file mode 100644 (file)
index 0000000..a0f85f1
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.interfaces;
+
+/**
+ *
+ * @author navid
+ */
+public enum OffsetDependency {
+    NO_ACCESS, NO_DEPENDENCY, WRITE_DEPENDENCY_1, WRITE_DEPENDENCY_2, READ_DEPENDENCY
+
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/interfaces/TransactionStatu.java b/Robust/Transactions/TransactionalIOSrc/interfaces/TransactionStatu.java
new file mode 100644 (file)
index 0000000..4aeee17
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.interfaces;
+
+import TransactionalIO.core.ExtendedTransaction.Status;
+
+/**
+ *
+ * @author navid
+ */
+public interface TransactionStatu {
+    
+    public void abortThisSystem();
+    public TransactionStatu getOtherSystem();
+    public void setOtherSystem(TransactionStatu othersystem);
+    public boolean isActive();
+    public boolean isCommitted();
+    public boolean isAborted();
+    
+}
diff --git a/Robust/Transactions/TransactionalIOSrc/interfaces/TransactionalProgram.java b/Robust/Transactions/TransactionalIOSrc/interfaces/TransactionalProgram.java
new file mode 100644 (file)
index 0000000..40a2516
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package TransactionalIO.interfaces;
+
+/**
+ *
+ * @author navid
+ */
+public interface TransactionalProgram {
+    public void execute();
+
+}