2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
5 package dstm2.benchmark;
7 import TransactionalIO.Utilities.Range;
8 import TransactionalIO.interfaces.IOOperations;
9 import TransactionalIO.core.MyDefaults;
10 import TransactionalIO.core.ExtendedTransaction;
11 import TransactionalIO.core.TransactionLocalFileAttributes;
12 import TransactionalIO.core.TransactionalFile;
13 import TransactionalIO.core.Wrapper;
14 import TransactionalIO.core.WriteOperations;
15 import TransactionalIO.exceptions.GracefulException;
16 import dstm2.SpecialTransactionalFile;
17 import java.io.FileNotFoundException;
18 import java.io.IOException;
19 import java.util.Iterator;
20 import java.util.HashMap;
21 import java.util.logging.Level;
22 import java.util.logging.Logger;
25 import dstm2.AtomicArray;
26 import dstm2.Defaults;
27 import dstm2.factory.Factory;
30 import java.io.RandomAccessFile;
32 import java.util.Vector;
34 import java.util.concurrent.Callable;
40 public class CustomThread implements Runnable {
43 private Thread thread;
44 private String benchmark;
46 boolean inevitable = Defaults.INEVITABLE;
49 static int version = 0;
50 static int occurence = 0;
53 ///////////////////PureIO data structure//////////////////////
55 static TransactionalFile[] pureiofiles;
56 static SpecialTransactionalFile[] inevitablepureiofiles;
58 ///////////////////financialbenchmark data structure//////////////////
62 String st = new String();
63 byte[] financedata = new byte[11];
64 char[] balance = new char[20];
65 byte[] financedata2 = new byte[41];
66 TransactionalFile accountbalance=null;
67 SpecialTransactionalFile inevitableaccountbalance=null;
68 static AtomicArray<FTrHolder> financialTransactionKeeper;
69 private static Factory<FinancialTransactionDS> factory = Thread.makeFactory(FinancialTransactionDS.class);
70 private static Factory<RootHolder> factory2 = Thread.makeFactory(RootHolder.class);
71 private static Factory<FTrHolder> factory3 = Thread.makeFactory(FTrHolder.class);
72 //////////////////////////////////////////////////////////////////////
75 ///////////////////counter data structure//////////////////////////////
76 static TransactionalFile counterfile;
77 static SpecialTransactionalFile inevitablecounterfile;
78 static Factory<CountKeeper> counterfactory = Thread.makeFactory(CountKeeper.class);
79 private static CountKeeper word1_occurence;
80 private static CountKeeper word2_occurence;
81 private static CountKeeper word3_occurence;
82 private static CountKeeper word4_occurence;
83 private static CountKeeper word5_occurence;
84 public static RandomAccessFile globallocktestfile;
85 public static SpecialTransactionalFile inevitabletestfile;
86 public static TransactionalFile outoftransactiontestfile;
87 public static Object lock = new Object();
88 ///////////////////////////////////////////////////////////////////////
90 public CustomThread(String benchmark, int versionwanted) {
92 this.benchmark = benchmark;
93 version = versionwanted;
95 if (benchmark.equals("dstm2.benchmark.ParralelGrep")) {
97 } else if (benchmark.equals("dstm2.benchmark.FinancialTransaction")) {
99 } else if (benchmark.equals("dstm2.benchmark.ParralelSort")) {
102 /*} else if (benchmark.equals("dstm2.benchmark.PureIOInevitablev2")) {
104 } else if (benchmark.equals("dstm2.benchmark.PureIOTransactionalv2")) {
108 thread = new Thread(this);
113 public int dummy(int j){
115 for (int i=0; i<10000;i++){
117 for (int k=0; k<10;k++){
124 public int lock(RandomAccessFile g, byte[] res){
129 for(int j=0;j<5;j++){
134 }catch(IOException e){
141 public int lock(IOOperations g, byte[] res){
146 for(int j=0;j<5;j++){
151 }catch(IOException e){
157 public void GlobalLockTest(){
158 byte[] res = new byte[1023];
159 for (int l=0; l<1023;l++)
162 RandomAccessFile g = new RandomAccessFile("/scratch/TransactionalIO/test","rw");
163 long toseek = (Integer.valueOf(Thread.currentThread().getName().substring(7))) *4000;
164 for (int i=0; i<2000;i++){
167 int resu = lock(g, res);
171 for(int j=0;j<5;j++){
175 }catch(IOException e){
180 }catch(IOException e){
185 public void NonTest(){
186 final byte[] res = new byte[1023];
187 for (int l=0; l<1023;l++)
190 final RandomAccessFile g = new RandomAccessFile("/scratch/TransactionalIO/test","rw");
191 long toseek = (Integer.valueOf(Thread.currentThread().getName().substring(7))) *4000;
192 for (int i=0; i<2000;i++){
194 // for (int j=0; j<300;j++){
196 int resu = lock(g, res);
197 // for(int j=0;j<50;j++)
200 for (int j=0; j<5;j++){
204 // }catch(IOException e){
205 // e.printStackTrace();
209 }catch(IOException e){
214 public void InevitableTest(){
215 final byte[] res = new byte[1023];
216 for (int l=0; l<1023;l++)
219 final SpecialTransactionalFile in = new SpecialTransactionalFile("/scratch/TransactionalIO/test","rw");
220 final long toseek = (Integer.valueOf(Thread.currentThread().getName().substring(7))) *4000;
222 for (int i=0; i<2000;i++){
224 // for (int j=0; j<300;j++){
225 Thread.doIt(new Callable<Boolean>(){
226 public Boolean call(){
230 for (int j=0; j<5;j++){
234 }catch(IOException e){
240 int resu = lock(in, res);
246 }catch(IOException e){
251 public void TransactionalTest(){
252 final byte[] res = new byte[1023];
253 for (int l=0; l<1023;l++)
256 final TransactionalFile in = new TransactionalFile("/scratch/TransactionalIO/test","rw");
257 final long toseek = (Integer.valueOf(Thread.currentThread().getName().substring(7))) *4000;
259 for (int i=0; i<2000;i++){
261 //for (int j=0; j<30;j++){
262 // long st = System.currentTimeMillis();
263 Thread.doIt(new Callable<Boolean>(){
264 public Boolean call(){
268 for (int j=0; j<5;j++){
273 catch(IOException e){
279 int resu = lock(in, res);
283 // long sp = System.currentTimeMillis();
284 // System.out.println("aaaa " + (sp-st));
288 }catch(IOException e){
296 public void intiFinance()
302 inevitableaccountbalance= new SpecialTransactionalFile("/scratch/TransactionalIO/FinancialTransactionFilesv0/accountbalance.txt","rw");
304 accountbalance= new TransactionalFile("/scratch/TransactionalIO/FinancialTransactionFilesv0/accountbalance.txt","rw");
306 else if (version == 1){
308 inevitableaccountbalance= new SpecialTransactionalFile("/scratch/TransactionalIO/FinancialTransactionFilesv1/accountbalance.txt","rw");
310 accountbalance= new TransactionalFile("/scratch/TransactionalIO/FinancialTransactionFilesv1/accountbalance.txt","rw");
313 }catch(IOException ex){
314 ex.printStackTrace();
321 RootHolder ck = factory2.create();
322 ck.setFinancialTransactionKeeper(new AtomicArray<FTrHolder>(FTrHolder.class, 20));
324 financialTransactionKeeper = ck.getFinancialTransactionKeeper();
325 for (int i=0; i<20; i++){
326 FTrHolder f1 = factory3.create();
328 f1.setFinancialTransactionKeeper(new AtomicArray<FinancialTransactionDS>(FinancialTransactionDS.class, 5));
329 for (int j=0; j<5; j++) {
330 FinancialTransactionDS ftk = factory.create();
334 AtomicArray<FinancialTransactionDS> tmp = f1.getFinancialTransactionKeeper();
338 financialTransactionKeeper.set(i, f1);
343 public void initPureIO(){
348 inevitablepureiofiles = new SpecialTransactionalFile[26];
349 for (int i=0; i<26; i++){
352 inevitablepureiofiles[i] = new SpecialTransactionalFile("/scratch/TransactionalIO/ParallelSortFilesv0/"+String.valueOf((char) (97+i))+ ".text","rw");
353 else if (version == 1)
354 inevitablepureiofiles[i] = new SpecialTransactionalFile("/scratch/TransactionalIO/ParallelSortFilesv1/"+String.valueOf((char) (97+i))+ ".text","rw");
358 pureiofiles = new TransactionalFile[26];
359 for (int i=0; i<26; i++){
362 pureiofiles[i] = new TransactionalFile("/scratch/TransactionalIO/ParallelSortFilesv0/"+String.valueOf((char) (97+i))+ ".text","rw");
363 else if (version == 1)
364 pureiofiles[i] = new TransactionalFile("/scratch/TransactionalIO/ParallelSortFilesv1/"+String.valueOf((char) (97+i))+ ".text","rw");
368 }catch(IOException ex){
369 ex.printStackTrace();
377 public void initParralelGrep(){
382 word1_occurence = counterfactory.create();
383 word1_occurence.setOccurence(0);
385 word2_occurence = counterfactory.create();
386 word2_occurence.setOccurence(0);
388 word3_occurence = counterfactory.create();
389 word3_occurence.setOccurence(0);
391 word4_occurence = counterfactory.create();
392 word4_occurence.setOccurence(0);
394 word5_occurence = counterfactory.create();
395 word5_occurence.setOccurence(0);
400 inevitablecounterfile = new SpecialTransactionalFile("/scratch/TransactionalIO/ParallelGrepFilesv0/output.text", "rw");
401 } catch (FileNotFoundException ex) {
402 Logger.getLogger(CustomThread.class.getName()).log(Level.SEVERE, null, ex);
406 counterfile = new TransactionalFile("/scratch/TransactionalIO/ParallelGrepFilesv0/output.text", "rw");
408 else if (version ==1){
411 inevitablecounterfile = new SpecialTransactionalFile("/scratch/TransactionalIO/ParallelGrepFilesv1/output.text", "rw");
412 } catch (FileNotFoundException ex) {
413 Logger.getLogger(CustomThread.class.getName()).log(Level.SEVERE, null, ex);
417 counterfile = new TransactionalFile("/scratch/TransactionalIO/ParallelGrepFilesv1/output.text", "rw");
426 public void start() {
433 } catch (InterruptedException ex) {
434 Logger.getLogger(CustomThread.class.getName()).log(Level.SEVERE, null, ex);
440 if (benchmark.equals("GlobalLockTest")) {
443 else if (benchmark.equals("NonTest")) {
446 else if (benchmark.equals("InevitableTest")) {
449 else if (benchmark.equals("TransactionalTest")) {
452 else if (benchmark.equals("dstm2.benchmark.ParralelGrep")) {
453 parralelGrepBenchmark();
454 } else if (benchmark.equals("dstm2.benchmark.FinancialTransaction")) {
455 financialBenchmark();
456 } else if (benchmark.equals("dstm2.benchmark.ParralelSort")) {
460 System.out.println("No Such Benchmark");
461 /* } else if (benchmark.equals("dstm2.benchmark.PureIOInevitablev2")) {
462 pureIOInevitablev2();
463 } else if (benchmark.equals("dstm2.benchmark.PureIOTransactionalv2")) {
464 pureIOTransactionalv2();
468 public void pureIOBenchmark() {
472 f1 = new RandomAccessFile("/scratch/TransactionalIO/ParallelSortFilesv0/randomwords.text", "rw");
474 f1 = new RandomAccessFile("/scratch/TransactionalIO/ParallelSortFilesv1/randomwords.text", "rw");
478 threadoffset = 51121;
480 (Integer.valueOf(Thread.currentThread().getName().substring(7))) * threadoffset;
482 for (int i=0; i<10; i++){
485 //////////////// skipt the first word since its been read already
488 while (f1.getFilePointer() < toseek + threadoffset) {
489 final String pureiodata = f1.readLine();
490 if (pureiodata == null) {
493 boolean resultt = Thread.doIt(new Callable<Boolean>() {
495 public Boolean call() {
496 pureioexecute(pureiodata);
503 }catch (IOException ex) {
504 Logger.getLogger(CustomThread.class.getName()).log(Level.SEVERE, null, ex);
511 public void financialBenchmark() {
515 f1 = new RandomAccessFile("/scratch/TransactionalIO/FinancialTransactionFilesv0/financialtransaction.text", "rw");
517 f1 = new RandomAccessFile("/scratch/TransactionalIO/FinancialTransactionFilesv1/financialtransaction.text", "rw");
519 String data = new String();
522 long threadoffset = 360611*2;
523 toseek = (Integer.valueOf(Thread.currentThread().getName().substring(7))) * threadoffset;
526 //////////////// skipt the first line since its been read already
527 data = f1.readLine();
532 while (f1.getFilePointer() < toseek + threadoffset) {
535 data = f1.readLine();
540 while (data.charAt(counter) != ' ') {
544 final String oldowner = data.substring(0, counter);
546 int counter2 = counter;
547 while (data.charAt(counter) != ' ') {
552 final int exchange = Integer.parseInt(data.substring(counter2, counter ));
557 while (data.charAt(counter) != ' ') {
561 final String newowner = data.substring(counter2, counter);
565 for (int j=counter; j<data.length(); j++) {
569 final String company = data.substring(counter2, counter);
570 boolean result = Thread.doIt(new Callable<Boolean>() {
571 public Boolean call() {
572 financialexecute(oldowner, exchange, newowner, company);
579 } catch (IOException ex) {
580 Logger.getLogger(CustomThread.class.getName()).log(Level.SEVERE, null, ex);
586 public void parralelGrepBenchmark() {
589 final IOOperations f1;
592 f1 = new TransactionalFile("/scratch/TransactionalIO/ParallelGrepFilesv0/iliad.text", "rw");
594 f1 = new TransactionalFile("/scratch/TransactionalIO/ParallelGrepFilesv1/iliad.text", "rw");
598 f1 = new SpecialTransactionalFile("/scratch/TransactionalIO/ParallelGrepFilesv0/iliad.text", "rw");
600 f1 = new SpecialTransactionalFile("/scratch/TransactionalIO/ParallelGrepFilesv1/iliad.text", "rw");
602 final long threadoffset;
604 final byte[] data = new byte[1000];
605 //threadoffset = 52921;
606 threadoffset = 50000;
607 toseek = Integer.valueOf(Thread.currentThread().getName().substring(7)) * threadoffset;
608 for (int m=0; m<3000; m++){
610 for (int l=0; l<2; l++){
611 Thread.doIt (new Callable<Boolean>(){
612 public Boolean call(){
614 for (int k=0; k<25; k++){
618 int result = f1.read(data);
621 while (end<data.length){
623 while(!(Character.isLetter((char)data[end]))){
627 while(Character.isLetter((char)data[end])){
631 int index_of_object = processInput(new String(data, start, end-start));
632 if (index_of_object == -1)
636 String tmp = "\n\n Found word " + new String(data, start, end-start) + " At offset: " + offset +"\n\n";
637 inevitablecounterfile.write(tmp.getBytes());
638 inevitablecounterfile.write(data, 0, end);
641 String tmp = "\n\n Found word " + new String(data, start, end-start) + " At offset: " + offset + "\n\n";
642 counterfile.write(tmp.getBytes());
643 counterfile.write(data, 0, end);
645 switch(index_of_object){
647 word1_occurence.setOccurence(word1_occurence.getOccurence() + 1);
650 word2_occurence.setOccurence(word2_occurence.getOccurence() + 1);
653 word3_occurence.setOccurence(word3_occurence.getOccurence() + 1);
656 word4_occurence.setOccurence(word4_occurence.getOccurence() + 1);
659 word5_occurence.setOccurence(word5_occurence.getOccurence() + 1);
664 } catch (IOException ex) {
665 Logger.getLogger(CustomThread.class.getName()).log(Level.SEVERE, null, ex);
675 } catch (IOException ex) {
676 Logger.getLogger(CustomThread.class.getName()).log(Level.SEVERE, null, ex);
683 private long financialcomputeandupdate(boolean type, String oldowner, int stocktrade, String newowner, String nameofstock) {
688 inevitableaccountbalance.read(financedata);
690 accountbalance.read(financedata);
692 for (adad = 0; adad < stocks.length; adad++) {
693 if (stocks[adad].equalsIgnoreCase(nameofstock)) {
698 inevitableaccountbalance.skipBytes(adad * 41);
699 inevitableaccountbalance.read(financedata2);
702 accountbalance.skipBytes(adad * 41);
703 accountbalance.read(financedata2);
707 while ((char) financedata2[i] != ':') {
716 offsettowrite = inevitableaccountbalance.getFilePointer();
718 offsettowrite = accountbalance.getFilePointer();
720 offsettowrite += i - 40;
724 balance[counter] = (char) financedata2[i];
726 } while (Character.isDigit((char) financedata2[i]) || (char) financedata2[i] == '-');
728 int oldbalance = Integer.parseInt(String.valueOf(balance, 0, counter - 1));
731 newnumber = oldbalance - stocktrade;
733 newnumber = oldbalance + stocktrade;
736 st = String.valueOf(newnumber);
737 if (st.length() < counter - 1) {
739 for (int j = 0; j < counter - String.valueOf(newnumber).length(); j++) {
740 st += new String(" ");
744 return offsettowrite;
747 } catch (IOException ex) {
748 Logger.getLogger(CustomThread.class.getName()).log(Level.SEVERE, null, ex);
755 public void pureioexecute(String str){
758 int i = str.toLowerCase().charAt(0) - 'a';
760 inevitablepureiofiles[i].write(str.getBytes());
762 pureiofiles[i].write(str.getBytes());
764 }catch(IOException e){
771 static Integer processInput(String str) {
772 if (str.equalsIgnoreCase("Polydamas")) {
775 else if (str.equalsIgnoreCase("Cebriones")) {
778 else if (str.equalsIgnoreCase("Eurybates")) {
781 else if (str.equalsIgnoreCase("Menoetius")) {
784 else if (str.equalsIgnoreCase("countless")) {
792 private void preparenamelist() {
794 byte[] data = new byte[1];
795 char[] name = new char[20];
796 RandomAccessFile file = new RandomAccessFile("/scratch/TransactionalIO/FinancialTransactionFilesv0/namelist.text", "rw");
797 RandomAccessFile file3 = new RandomAccessFile("/scratch/TransactionalIO/FinancialTransactionFilesv0/accountbalance.text", "rw");
799 stocks = new String[20];
801 stocks[1] = "Google";
802 stocks[2] = "Microsoft";
803 stocks[3] = "Broadcom";
805 stocks[5] = "Qualcom";
811 stocks[11] = "Nokia";
812 stocks[12] = "Motorolla";
813 stocks[13] = "Samsung";
814 stocks[14] = "TMobile";
816 stocks[16] = "PRops";
819 stocks[19] = "Brita";
821 boolean flag = false;
822 boolean done = false;
825 financialbm1 = new HashMap();
826 financialbm2 = new HashMap();
833 financialbm1.put(Integer.valueOf(wordcounter), String.copyValueOf(name, 0, counter));
834 financialbm2.put(String.copyValueOf(name, 0, counter), Integer.valueOf(wordcounter));
840 while (data[0] != '\n') {
842 res = file.read(data);
847 if (!(Character.isLetter((char) data[0]))) {
850 name[counter] = (char) data[0];
858 ///preparing the accountbalance file/////////
860 for (int i = 0; i < 50; i++) {
861 String towrite = (String) financialbm1.get(Integer.valueOf(i));
862 String tmpst = (String) financialbm2.get(Integer.valueOf(i));
863 System.out.println("Ss " + tmpst);
864 int tmp = tmpst.length();
866 towrite += new String(" ");
870 for (int j = 0; j < stocks.length; j++) {
871 tmpst = stocks[j] + " Stock Balance: " + ((int) (Math.random() * 100 + 100));
872 towrite += stocks[j] + " Stock Balance: " + ((int) (Math.random() * 100 + 100));
873 tmp = tmpst.length();
875 towrite += new String(" ");
881 file3.write(towrite.getBytes());
882 while (file3.getFilePointer() < (i + 1) * MyDefaults.FILEFRAGMENTSIZE) {
883 file3.write(new String(" ").getBytes());
887 ////////////////////////////////////////////
891 } catch (IOException ex) {
892 Logger.getLogger(CustomThread.class.getName()).log(Level.SEVERE, null, ex);
898 protected void financialexecute(String oldowner, int stocktrade, String newowner, String nameofstock) {
900 Integer offset1 = (Integer) financialbm2.get(oldowner);
901 Integer offset2 = (Integer) financialbm2.get(newowner);
904 inevitableaccountbalance.seek(offset1 * MyDefaults.FILEFRAGMENTSIZE);
906 accountbalance.seek(offset1 * MyDefaults.FILEFRAGMENTSIZE);
908 long offsettowrite = financialcomputeandupdate(true, oldowner, stocktrade, newowner, nameofstock);
910 inevitableaccountbalance.seek(offsettowrite);
911 inevitableaccountbalance.write(st.getBytes());
914 accountbalance.seek(offsettowrite);
915 accountbalance.write(st.getBytes());
920 inevitableaccountbalance.seek(offset2 * MyDefaults.FILEFRAGMENTSIZE);
922 accountbalance.seek(offset2 * MyDefaults.FILEFRAGMENTSIZE);
924 offsettowrite = financialcomputeandupdate(false, oldowner, stocktrade, newowner, nameofstock);
928 inevitableaccountbalance.seek(offsettowrite);
929 inevitableaccountbalance.write(st.getBytes());
932 accountbalance.seek(offsettowrite);
933 accountbalance.write(st.getBytes());
937 for (i = 0; i < stocks.length; i++) {
938 if (stocks[i].equalsIgnoreCase(nameofstock)) {
942 switch (financialTransactionKeeper.get(i).getCounter()) {
944 financialTransactionKeeper.get(i).getFinancialTransactionKeeper().get(0).setSeller(oldowner);
945 financialTransactionKeeper.get(i).getFinancialTransactionKeeper().get(0).setSoldShare(stocktrade);
946 financialTransactionKeeper.get(i).getFinancialTransactionKeeper().get(0).setBuyer(newowner);
947 financialTransactionKeeper.get(i).setCounter(2);
950 financialTransactionKeeper.get(i).getFinancialTransactionKeeper().get(1).setSeller(oldowner);
951 financialTransactionKeeper.get(i).getFinancialTransactionKeeper().get(1).setSoldShare(stocktrade);
952 financialTransactionKeeper.get(i).getFinancialTransactionKeeper().get(1).setBuyer(newowner);
953 financialTransactionKeeper.get(i).setCounter(3);
956 financialTransactionKeeper.get(i).getFinancialTransactionKeeper().get(2).setSeller(oldowner);
957 financialTransactionKeeper.get(i).getFinancialTransactionKeeper().get(2).setSoldShare(stocktrade);
958 financialTransactionKeeper.get(i).getFinancialTransactionKeeper().get(2).setBuyer(newowner);
959 financialTransactionKeeper.get(i).setCounter(4);
962 financialTransactionKeeper.get(i).getFinancialTransactionKeeper().get(3).setSeller(oldowner);
963 financialTransactionKeeper.get(i).getFinancialTransactionKeeper().get(3).setSoldShare(stocktrade);
964 financialTransactionKeeper.get(i).getFinancialTransactionKeeper().get(3).setBuyer(newowner);
965 financialTransactionKeeper.get(i).setCounter(5);
968 financialTransactionKeeper.get(i).getFinancialTransactionKeeper().get(4).setSeller(oldowner);
969 financialTransactionKeeper.get(i).getFinancialTransactionKeeper().get(4).setSoldShare(stocktrade);
970 financialTransactionKeeper.get(i).getFinancialTransactionKeeper().get(4).setBuyer(newowner);
971 financialTransactionKeeper.get(i).setCounter(1);
975 } catch (IOException ex) {
976 Logger.getLogger(CustomThread.class.getName()).log(Level.SEVERE, null, ex);
982 public interface FinancialTransactionDS {
984 void setSeller(String value);
986 void setSoldShare(int value);
988 void setBuyer(String value);
993 public interface FTrHolder {
994 AtomicArray<FinancialTransactionDS> getFinancialTransactionKeeper();
995 void setFinancialTransactionKeeper(AtomicArray<FinancialTransactionDS> arr);
997 void setCounter(int value);
1001 public interface RootHolder {
1002 AtomicArray<FTrHolder> getFinancialTransactionKeeper();
1003 void setFinancialTransactionKeeper(AtomicArray<FTrHolder> arr);
1008 public interface CountKeeper{
1010 void setOccurence(int value);;
1014 /* public void pureIOInevitablev2() {
1017 final SpecialTransactionalFile f1;
1018 f1 = new SpecialTransactionalFile("/scratch/TransactionalIO/PureIOBenchmarkFiles/randomwords.text", "rw");
1020 final long threadoffset = 51121;
1021 toseek = (Integer.valueOf(Thread.currentThread().getName().substring(7))) * threadoffset;
1022 for (int l=0; l<10; l++){
1026 while (f1.getFilePointer() < toseek + threadoffset) {
1027 boolean resultt = Thread.doIt(new Callable<Boolean>() {
1028 public Boolean call() {
1030 for (int k=0; k<1000; k++){
1031 if (f1.getFilePointer() < toseek + threadoffset){
1033 String str = f1.readLine();
1036 int i = Character.toLowerCase((char)str.charAt(0)) - 'a';
1037 inevitablepureiofiles[i].write(str.getBytes());
1046 } catch (IOException ex) {
1048 Logger.getLogger(CustomThread.class.getName()).log(Level.SEVERE, null, ex);
1055 } catch (IOException ex) {
1056 Logger.getLogger(CustomThread.class.getName()).log(Level.SEVERE, null, ex);
1060 public void pureIOTransactionalv2() {
1062 final TransactionalFile f1;
1063 f1 = new TransactionalFile("/scratch/TransactionalIO/PureIOBenchmarkFiles/randomwords.text", "rw");
1065 final long threadoffset = 51121;
1066 toseek = (Integer.valueOf(Thread.currentThread().getName().substring(7))) * threadoffset;
1067 for (int l=0; l<10; l++){
1071 while (f1.getFilePointer() < toseek + threadoffset) {
1072 boolean resultt = Thread.doIt(new Callable<Boolean>() {
1073 public Boolean call() {
1075 for (int k=0; k<1000; k++){
1076 if (f1.getFilePointer() < toseek + threadoffset){
1077 String str = f1.readLine();
1080 int i = Character.toLowerCase(str.charAt(0)) - 'a';
1081 pureiofiles[i].write(str.getBytes());
1088 } catch (IOException ex) {
1089 Logger.getLogger(CustomThread.class.getName()).log(Level.SEVERE, null, ex);
1099 } catch (IOException ex) {
1100 Logger.getLogger(CustomThread.class.getName()).log(Level.SEVERE, null, ex);