*** empty log message ***
authornavid <navid>
Fri, 6 Feb 2009 01:23:00 +0000 (01:23 +0000)
committernavid <navid>
Fri, 6 Feb 2009 01:23:00 +0000 (01:23 +0000)
Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/benchmark.java
Robust/Transactions/TransactionalIO/src/TransactionalIO/core/ExtendedTransaction.java
Robust/Transactions/TransactionalIO/src/TransactionalIO/core/TransactionalFile.java

index d239dd92229fad0787a020136c8fd32bf92449b2..4a31551d7c6fdde274a628cb9f68d65ac4dbfb70 100644 (file)
@@ -2,7 +2,6 @@
  * To change this template, choose Tools | Templates
  * and open the template in the editor.
  */
-
 package TransactionalIO.benchmarks;
 
 import TransactionalIO.core.Defaults;
@@ -18,16 +17,16 @@ import java.util.concurrent.locks.ReentrantLock;
 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 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();
@@ -38,13 +37,11 @@ public class benchmark {
     public static Map m3;
     public static Map m4;
     public static String[] stocks;
-    
 
     public benchmark() {
-        
     }
-     
-    private static void preparenamelist(){
+
+    private static void preparenamelist() {
         try {
             byte[] data = new byte[1];
             char[] name = new char[20];
@@ -53,71 +50,47 @@ public class benchmark {
             /*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;
-                    } 
-                }
-           }*/
-            
+
+
+
+            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 flag = false;
             boolean done = false;
             int wordcounter = 0;
-            int counter =0;
-            while(true){
-                if (flag)
+            int counter = 0;
+            while (true) {
+                if (flag) {
                     break;
-                if (done){
-             //       System.out.println("At " + wordcounter + " inserted " +String.copyValueOf(name, 0, counter));
+                }
+                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;    
+                counter = 0;
                 data[0] = 'a';
                 while (data[0] != '\n') {
                     int res;
@@ -129,85 +102,73 @@ public class benchmark {
                     //System.out.println((char)data[0]);
                     if (!(Character.isLetter((char) data[0]))) {
                         continue;
-                   }
-                   name[counter] = (char)data[0];
-                   done = true;
-                   counter++;
+                    }
+                    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";
             
-      /*    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());
+            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));
-              String tmpst = (String)m3.get(Integer.valueOf(i));
-              int tmp = tmpst.length();
-              while(tmp<10){
-                  towrite += new String(" ");
-                  tmp++;
-              }
-              towrite += "\n";
-              for (int j=0; j<stocks.length; j++){
-                tmpst = stocks[j] + " Stock Balance: " + ((int)(Math.random()*100+100));  
-                towrite +=  stocks[j] + " Stock Balance: " + ((int)(Math.random()*100+100));
-                tmp = tmpst.length();
-                System.out.println(tmp);
-                while(tmp<40){
-                  towrite += new String(" ");
-                  tmp++;
+            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));
+                String tmpst = (String) m3.get(Integer.valueOf(i));
+                int tmp = tmpst.length();
+                while (tmp < 10) {
+                    towrite += new String(" ");
+                    tmp++;
                 }
                 towrite += "\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();
-          byte[] b= new byte[41];
-          
-          file3.seek(1024);
-          file3.read(new byte[11]);
-          file3.read(b);
-          System.out.println("h " + (char)b[40]);
-          System.out.println((char)file3.readByte());
-          file3.close();
+                for (int j = 0; j < stocks.length; j++) {
+                    tmpst = stocks[j] + " Stock Balance: " + ((int) (Math.random() * 100 + 100));
+                    towrite += stocks[j] + " Stock Balance: " + ((int) (Math.random() * 100 + 100));
+                    tmp = tmpst.length();
+                    while (tmp < 40) {
+                        towrite += new String(" ");
+                        tmp++;
+                    }
+                    towrite += "\n";
+                }
+
+                file3.write(towrite.getBytes());
+                while (file3.getFilePointer() < (i + 1) * Defaults.FILEFRAGMENTSIZE) {
+                    file3.write(new String(" ").getBytes());
+                }
+            }
+
+            file.close();
+            file3.close();
         } catch (IOException ex) {
             Logger.getLogger(benchmark.class.getName()).log(Level.SEVERE, null, ex);
-        } 
-       
-    
+        }
+
+
     }
 
-    public static void init(){
+    public static void init() {
         try {
 
             m3 = Collections.synchronizedMap(names);
@@ -217,122 +178,30 @@ public class benchmark {
 
 
             preparenamelist();
-            count = 0;
+            
             m = Collections.synchronizedMap(TransactionalFiles);
-            //TransactionalFile tr = new TransactionalFile("/home/navid/randomwords.text", "rw");
-            TransactionalFile tr = new TransactionalFile("/scratch/TransactionalIO/PureIOBenchmarkFiles/randomwords.text", "rw");
-            m.put(String.valueOf(count), tr);
-            count++;
-            //TransactionalFile tr2 = new TransactionalFile("/home/navid/input.text", "rw");
-            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");
-            TransactionalFile tr3 = new TransactionalFile("/scratch/TransactionalIO/WordCunterBenchmarkFiles/iliad.text", "rw");
-            m.put(String.valueOf(count), tr3);
-            count++;
-            //TransactionalFile tr4 = new TransactionalFile("/home/navid/counter_benchmark_output.text", "rw");
+            
             TransactionalFile tr4 = new TransactionalFile("/scratch/TransactionalIO/WordCunterBenchmarkFiles/counter_benchmark_output.text", "rw");
             m.put("counteroutput", tr4);
-            //m.put(String.valueOf(count), tr4);
-            count++;
 
-            //TransactionalFile tr5 = new TransactionalFile("/home/navid/financialtransaction.text", "rw");
-            TransactionalFile tr5 = new TransactionalFile("/scratch/TransactionalIO/FinancialTransactionBenchmarkFiles/financialtransaction.text", "rw");
-            m.put(String.valueOf(count), tr5);
-
-            count++;
-
-            //TransactionalFile tr6 = new TransactionalFile("/home/navid/accountbalance.text", "rw");
-          //  TransactionalFile tr6 = new TransactionalFile("/scratch/TransactionalIO/FinancialTransactionBenchmarkFiles/accountbalance.text", "rw");
-            //m.put("accountbalance", tr6);
-            //m.put(String.valueOf(count), tr6);
-
-            count++;
-
-            //TransactionalFile tr7 = new TransactionalFile("/home/navid/financialtransactionlog.text", "rw");
-          //  TransactionalFile tr7 = new TransactionalFile("/scratch/TransactionalIO/FinancialTransactionBenchmarkFiles/financialtransactionlog.text", "rw");
-          //  m.put("financialtransactionlog", tr7);
-          //  m.put(String.valueOf(count), tr7);
-            count++;
-
-            //RandomAccessFile tr8 = new RandomAccessFile("/home/navid/accountbalance.text", "rw");
             RandomAccessFile tr8 = new RandomAccessFile("/scratch/TransactionalIO/FinancialTransactionBenchmarkFiles/accountbalance.text", "rw");
-            //m.put(String.valueOf(count), tr8);
             m.put("accountbalancerandom", tr8);
-//
-            count++;
 
-            //RandomAccessFile tr9 = new RandomAccessFile("/home/navid/financialtransactionlog.text", "rw");
             RandomAccessFile tr9 = new RandomAccessFile("/scratch/TransactionalIO/FinancialTransactionBenchmarkFiles/financialtransactionlog.text", "rw");
-            //m.put(String.valueOf(count), tr9);
             m.put("financialtransactionlograndom", tr9);
-            count++;
+
 
             int index = 97;
             for (int i = 0; i < 26; i++) {
-                      m.put(String.valueOf((char) (index+i))+"random", new RandomAccessFile("/home/navid/" + String.valueOf((char) (index+i)) + ".text", "rw"));
-                      m.put(String.valueOf((char) (index+i)), new TransactionalFile("/home/navid/" + String.valueOf((char) (index+i)) + ".text", "rw"));
-                      m.put(String.valueOf((char) (index+i)), new TransactionalFile("/scratch/TransactionalIO/PureIOBenchmarkFiles/" + String.valueOf((char) (index+i)) + ".text", "rw"));
-                      count++;
-            }
-                 
-               
-            //m.put(100, new RandomAccessFile("/home/navid/counter_benchmark_output.text", "rw"));   
-            m.put("counterdstm2output", new RandomAccessFile("/scratch/TransactionalIO/WordCunterBenchmarkFiles/counter_benchmark_output.text", "rw"));   
-            //m.put(100, new RandomAccessFile("/scratch/TransactionalIO/WordCunterBenchmarkFiles/counter_benchmark_output.text", "rw"));   
-            /*count = 0;
-            m = Collections.synchronizedMap(TransactionalFiles);
-            TransactionalFile tr = new TransactionalFile("/scratch/TransactionalIO/PureIOBenchmarkFiles/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("/scratch/TransactionalIO/WordCunterBenchmarkFiles/iliad.text", "rw");
-            m.put(String.valueOf(count), tr3);
-            count++;
-            TransactionalFile tr4 = new TransactionalFile("/scratch/TransactionalIO/WordCunterBenchmarkFiles/counter_benchmark_output.text", "rw");
-            m.put(String.valueOf(count), tr4);
-            count++;
-
-            TransactionalFile tr5 = new TransactionalFile("/scratch/TransactionalIO/FinancialTransactionBenchmarkFiles/financialtransaction.text", "rw");
-            m.put(String.valueOf(count), tr5);
-
-            count++;
-
-            TransactionalFile tr6 = new TransactionalFile("/scratch/TransactionalIO/FinancialTransactionBenchmarkFiles/accountbalance.text", "rw");
-            m.put(String.valueOf(count), tr6);
-
-            count++;
-
-            TransactionalFile tr7 = new TransactionalFile("/scratch/TransactionalIO/FinancialTransactionBenchmarkFiles/financialtransactionlog.text", "rw");
-            m.put(String.valueOf(count), tr7);
-
-            count++;
-
-            RandomAccessFile tr8 = new RandomAccessFile("/scratch/TransactionalIO/FinancialTransactionBenchmarkFiles/accountbalance.text", "rw");
-            m.put(String.valueOf(count), tr8);
-//
-            count++;
+                m.put(String.valueOf((char) (index + i)) + "random", new RandomAccessFile("/home/navid/" + String.valueOf((char) (index + i)) + ".text", "rw"));
+                m.put(String.valueOf((char) (index + i)), new TransactionalFile("/home/navid/" + String.valueOf((char) (index + i)) + ".text", "rw"));
+                m.put(String.valueOf((char) (index + i)), new TransactionalFile("/scratch/TransactionalIO/PureIOBenchmarkFiles/" + String.valueOf((char) (index + i)) + ".text", "rw"));
+                count++;
+            }   
+            m.put("counterdstm2output", new RandomAccessFile("/scratch/TransactionalIO/WordCunterBenchmarkFiles/counter_benchmark_output.text", "rw"));
+   
 
-            RandomAccessFile tr9 = new RandomAccessFile("/scratch/TransactionalIO/FinancialTransactionBenchmarkFiles/financialtransactionlog.text", "rw");
-            m.put(String.valueOf(count), tr9);
-
-            count++;
 
-            int index = 97;
-            for (int i = 0; i < 26; i++) {
-           
-            m.put(String.valueOf((char) (index+i)), new TransactionalFile("/scratch/TransactionalIO/PureIOBenchmarkFiles/"
-+ String.valueOf((char) (index+i)) + ".text", "rw"));
-                //count++;*/
-          /*     m.put(String.valueOf((char) (index+i)), new RandomAccessFile("/scratch/TransactionalIO/PureIOBenchmarkFiles/"
-+ String.valueOf((char) (index+i)) + ".text", "rw"));
-                count++;*/
-            //}
-           
-           
             count = 0;
             m2 = Collections.synchronizedMap(hotwords);
             m2.put(Integer.valueOf(count), "Polydamas");
@@ -356,15 +225,13 @@ public class benchmark {
             m2.put(Integer.valueOf(count), "unweariable");
             count++;
         //    m2.put(Integer.valueOf(count), "Atreus");
-         //    count++;
-          //  m2.put(Integer.valueOf(count), "Olympus");
-        
-            
+        //    count++;
+        //  m2.put(Integer.valueOf(count), "Olympus");
+
+
         } catch (FileNotFoundException ex) {
             Logger.getLogger(benchmark.class.getName()).log(Level.SEVERE, null, ex);
         }
-        
-    }
-    
 
+    }
 }
index 00f81329e47efeae43bbaed12f75cf02947230a6..55213d1dc30199dd2bcbfe8aae2e6baa107a8d5d 100644 (file)
@@ -5,16 +5,13 @@
 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;
@@ -28,7 +25,7 @@ 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;
 
@@ -42,10 +39,9 @@ public class ExtendedTransaction implements TransactionStatu {
     
 
     {
-        System.load("/home/navid/libnav.so");
+        System.load("/scratch/TransactionalIO/libnav.so");
     }
-    
-    private boolean flag = true;
+
     public TransactionStatu memorystate;
     private PropertyChangeSupport changes = new PropertyChangeSupport(this);
     public int starttime;
@@ -75,11 +71,8 @@ public class ExtendedTransaction implements TransactionStatu {
     private ContentionManager contentionmanager;
     private volatile Status status;
     private int id;
-    
-    
     public ReentrantLock[] toholoffsetlocks;
     public int offsetcount = 0;
-    
     public Lock[] toholdblocklocks;
     public int blockcount = 0;
 
@@ -214,54 +207,47 @@ public class ExtendedTransaction implements TransactionStatu {
 
     public boolean lockOffsets() {   /// Locking offsets for File Descriptors
 
-      //  toholoffsetlocks = new ReentrantLock[30];
-        
+
+
         TreeMap hm = getSortedFileAccessMap(AccessedFiles);
         Iterator iter = hm.keySet().iterator();
         offsetcount = 0;
         while (iter.hasNext() && (this.getStatus() == Status.ACTIVE)) {
             INode key = (INode) iter.next();
             Vector vec = (Vector) AccessedFiles.get(key);
-            
-       /*     if (vec.size() == 1){
-                TransactionalFile tf = ((TransactionalFile)vec.firstElement());
-                tf.offsetlock.lock();
-             //   toholoffsetlocks[offsetcount] = tf.offsetlock;
+
+            /*     if (vec.size() == 1){
+            TransactionalFile tf = ((TransactionalFile)vec.firstElement());
+            tf.offsetlock.lock();
+            //   toholoffsetlocks[offsetcount] = tf.offsetlock;
             //   offsetcount++;
-                heldoffsetlocks.add(tf.offsetlock);
-                continue;
+            heldoffsetlocks.add(tf.offsetlock);
+            continue;
             }*/
-            
+
             Collections.sort(vec);
             Iterator it = vec.iterator();
             while (it.hasNext() /*&& this.getStatus() == Status.ACTIVE*/) {
-               TransactionalFile value = (TransactionalFile) it.next();
-               value.offsetlock.lock();
-             //   toholoffsetlocks[offsetcount] = value.offsetlock;
-            //    offsetcount++;
+                TransactionalFile value = (TransactionalFile) it.next();
+                value.offsetlock.lock();
+
                 heldoffsetlocks.add(value.offsetlock);
-                
-                if (((TransactionLocalFileAttributes) GlobaltoLocalMappings.get(value)).lenght_read)
-                    if (!(value.getInodestate().commitedfilesize.lengthlock.isHeldByCurrentThread())){
+
+                if (((TransactionLocalFileAttributes) GlobaltoLocalMappings.get(value)).lenght_read) {
+                    if (!(value.getInodestate().commitedfilesize.lengthlock.isHeldByCurrentThread())) {
                         value.getInodestate().commitedfilesize.lengthlock.lock();
                         heldlengthlocks.add(value.getInodestate().commitedfilesize.lengthlock);
                     }
                 }
-                break;
+               // break;
             }
         }
 
         if (this.getStatus() != Status.ACTIVE) {
-         //   for (int j=0; j<offsetcount; j++){
-         //       heldoffsetlocks.add(toholoffsetlocks[j]);
-         //   }
             return false;
         }
         return true;
     }
-    
-    
-    
 
     public boolean lockBlock(BlockDataStructure block, BlockAccessModesEnum mode/*, GlobalINodeState adapter, BlockAccessModesEnum mode, int expvalue, INode inode, TransactionLocalFileAttributes tf*/) {
 
@@ -272,13 +258,13 @@ public class ExtendedTransaction implements TransactionStatu {
 
             lock = block.getLock().writeLock();
         }
-        
+
         lock.lock();
-      //  toholdblocklocks[blockcount] = lock;
-      //  blockcount++;
+        //  toholdblocklocks[blockcount] = lock;
+        //  blockcount++;
         heldblocklocks.add(lock);
         return true;
-       
+
     }
 
     public void prepareCommit() {
@@ -289,11 +275,11 @@ public class ExtendedTransaction implements TransactionStatu {
         if (!lockOffsets()) {
             throw new AbortedException();
         }
-        
-      //  boolean lengthslock = true;
-     //   if (!lockOffsets()) {
-     //       throw new AbortedException();
-     //   }
+
+        //  boolean lengthslock = true;
+        //   if (!lockOffsets()) {
+        //       throw new AbortedException();
+        //   }
 
 
         ///////////////////////////
@@ -351,28 +337,28 @@ public class ExtendedTransaction implements TransactionStatu {
             }
 
         }
-        
+
         //toholdblocklocks = new Lock[100];
-        
+
         Iterator it = this.getAccessedBlocks().keySet().iterator();
         //if (this.getStatus() == Status.ACTIVE)
-            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() && this.getStatus() == Status.ACTIVE) {
-                    Integer num = (Integer) iter2.next();    
-                    BlockDataStructure blockobj = inodestate.getBlockDataStructure(num);
-                    this.lockBlock(blockobj, (BlockAccessModesEnum) vec2.get(num));
-                    
-                }
+        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() && this.getStatus() == Status.ACTIVE) {
+                Integer num = (Integer) iter2.next();
+                BlockDataStructure blockobj = inodestate.getBlockDataStructure(num);
+                this.lockBlock(blockobj, (BlockAccessModesEnum) vec2.get(num));
+
             }
+        }
 
         if (this.getStatus() != Status.ACTIVE) {
-        //    for (int i=0; i<blockcount; i++)
-        //        heldblocklocks.add(toholdblocklocks[i]); 
+            //    for (int i=0; i<blockcount; i++)
+            //        heldblocklocks.add(toholdblocklocks[i]); 
             throw new AbortedException();
         }
         abortAllReaders();
@@ -410,14 +396,13 @@ public class ExtendedTransaction implements TransactionStatu {
         while (k.hasNext()) {
             TransactionalFile trf = (TransactionalFile) (k.next());
             trf.getCommitedoffset().setOffsetnumber(((TransactionLocalFileAttributes) GlobaltoLocalMappings.get(trf)).getLocaloffset());
-            if (((TransactionLocalFileAttributes) GlobaltoLocalMappings.get(trf)).getInitiallocallength() != ((TransactionLocalFileAttributes) GlobaltoLocalMappings.get(trf)).getLocalsize()){
+            if (((TransactionLocalFileAttributes) GlobaltoLocalMappings.get(trf)).getInitiallocallength() != ((TransactionLocalFileAttributes) GlobaltoLocalMappings.get(trf)).getLocalsize()) {
                 try {
-                    if (!(trf.getInodestate().commitedfilesize.lengthlock.isHeldByCurrentThread()))
+                    if (!(trf.getInodestate().commitedfilesize.lengthlock.isHeldByCurrentThread())) {
                         trf.getInodestate().commitedfilesize.lengthlock.lock();
-                    
+                    }
                     Iterator it2 = trf.getInodestate().commitedfilesize.getLengthReaders().iterator();
-                    if (((TransactionLocalFileAttributes)getGlobaltoLocalMappings().get(trf)).getInitiallocallength() != ((TransactionLocalFileAttributes)getGlobaltoLocalMappings().get(trf)).getLocalsize())
-                    {
+                    if (((TransactionLocalFileAttributes) getGlobaltoLocalMappings().get(trf)).getInitiallocallength() != ((TransactionLocalFileAttributes) getGlobaltoLocalMappings().get(trf)).getLocalsize()) {
                         while (it2.hasNext()) {
                             ExtendedTransaction tr = (ExtendedTransaction) it2.next();
                             if (tr != this) {
@@ -427,32 +412,32 @@ public class ExtendedTransaction implements TransactionStatu {
                         trf.getInodestate().commitedfilesize.getLengthReaders().clear();
                     }
                     trf.getInodestate().commitedfilesize.setLength(trf.file.length());
-                    
-                    if (trf.getInodestate().commitedfilesize.lengthlock.isHeldByCurrentThread()){
+
+                    if (trf.getInodestate().commitedfilesize.lengthlock.isHeldByCurrentThread()) {
                         heldlengthlocks.remove(trf.getInodestate().commitedfilesize.lengthlock);
                         trf.getInodestate().commitedfilesize.lengthlock.unlock();
                     }
-                    if (((TransactionLocalFileAttributes) GlobaltoLocalMappings.get(trf)).lenght_read){
+                    if (((TransactionLocalFileAttributes) GlobaltoLocalMappings.get(trf)).lenght_read) {
                         trf.getInodestate().commitedfilesize.getLengthReaders().remove(this);
-                        //heldlengthlocks.remove(trf.getInodestate().commitedfilesize.lengthlock);
-                        //trf.getInodestate().commitedfilesize.lengthlock.unlock();
+                    //heldlengthlocks.remove(trf.getInodestate().commitedfilesize.lengthlock);
+                    //trf.getInodestate().commitedfilesize.lengthlock.unlock();
                     }
-                    
+
                 } catch (IOException ex) {
                     Logger.getLogger(ExtendedTransaction.class.getName()).log(Level.SEVERE, null, ex);
                 }
             }
-            
-          
-        }
-        
-        
-      /*  for (int i =0; i<blockcount; i++){
-            toholdblocklocks[i].unlock();
+
+
         }
-        for (int i =0; i<offsetcount; i++){
-            toholoffsetlocks[i].unlock();
-        }*/
+
+
+    /*  for (int i =0; i<blockcount; i++){
+    toholdblocklocks[i].unlock();
+    }
+    for (int i =0; i<offsetcount; i++){
+    toholoffsetlocks[i].unlock();
+    }*/
     }
 
     public void unlockAllLocks() {
@@ -471,9 +456,9 @@ public class ExtendedTransaction implements TransactionStatu {
             lock.unlock();
         }
         heldoffsetlocks.clear();
-        
-       it = heldlengthlocks.iterator(); 
-       while (it.hasNext()) {
+
+        it = heldlengthlocks.iterator();
+        while (it.hasNext()) {
             ReentrantLock lock = (ReentrantLock) it.next();
             lock.unlock();
         }
@@ -501,9 +486,9 @@ public class ExtendedTransaction implements TransactionStatu {
                     }
                 }
                 value.getCommitedoffset().getOffsetReaders().clear();
-                
-            
-                
+
+
+
             }
 
             TreeMap vec2;
@@ -538,8 +523,6 @@ public class ExtendedTransaction implements TransactionStatu {
 
         }
     }
-    
-  
 
     public void addPropertyChangeListener(PropertyChangeListener listener) {
         this.changes.addPropertyChangeListener("status", listener);
@@ -568,7 +551,7 @@ public class ExtendedTransaction implements TransactionStatu {
     public Vector getHeldoffsetlocks() {
         return heldoffsetlocks;
     }
-    
+
     public Vector getHeldlengthlocks() {
         return heldlengthlocks;
     }
index 8eebab2b3c2da5e48b9ecaaf4797813f8efea23b..01c0205a683c24b62fc5ca50d44ddc484c5d0a98 100644 (file)
@@ -7,20 +7,15 @@ package TransactionalIO.core;
 import TransactionalIO.Utilities.Conversions;
 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.DataOutputStream;
 import java.io.File;
 import java.io.FileDescriptor;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.RandomAccessFile;
 import java.io.UTFDataFormatException;
-import java.nio.ByteBuffer;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.TreeMap;
@@ -46,7 +41,7 @@ public class TransactionalFile implements Comparable {
     
 
     {
-        System.load("/home/navid/libnav.so");
+        System.load("/scratch/TransactionalIO/libnav.so");
     }
     public RandomAccessFile file;
     private INode inode;