From: jihoonl Date: Tue, 2 Feb 2010 00:35:24 +0000 (+0000) Subject: well.. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=0cfbc88018d921b1983160f63c8a2e812ce9cdbb;p=IRC.git well.. --- diff --git a/Robust/src/Benchmarks/Recovery/FileSystem/FileSystem.java b/Robust/src/Benchmarks/Recovery/FileSystem/FileSystem.java new file mode 100644 index 00000000..d3f7f8f6 --- /dev/null +++ b/Robust/src/Benchmarks/Recovery/FileSystem/FileSystem.java @@ -0,0 +1,343 @@ +/* +Usage : + ./FileSystem.bin +*/ + + + +public class FileSystem extends Thread { + DistributedHashMap dir; + DistributedHashMap fs; + GlobalString inputfile; + int mid; + + public FileSystem(DistributedHashMap dir, DistributedHashMap fs) { + this.dir = dir; + this.fs = fs; + } + + public FileSystem(DistributedHashMap dir, DistributedHashMap fs, String filename, int mid) { + this.dir = dir; + this.fs = fs; + this.mid = mid; + this.inputfile = global new GlobalString("data/"+filename + mid); + } + + public void init() { + fillHashTable(); + } + + public void fillHashTable() { + GlobalString path; + DistributedLinkedList list; + + atomic { + path = global new GlobalString("/home/"); // root is 'home' + list = global new DistributedLinkedList(); + + dir.put(path, list); + } + } + + public static void fillTodoList(String file, LinkedList todoList) { + FileInputStream fis; + String comm; + char c; + String key; + String val; + Transaction t; + + fis = new FileInputStream(file); + + while ((comm = fis.readLine()) != null) { // 'command' 'path' + c = comm.charAt(0); // ex) w /home/abc.c + key = comm.subString(2); + t = new Transaction(c, key); + todoList.add(t); + } + } + + public void run() { + Transaction t; + + char command; + String key; + String val; + boolean isDir; + + GlobalString gkey; + GlobalString gval; + + int index; + String file; + atomic { + file = inputfile.toLocalString(); + } + + LinkedList todoList = new LinkedList(); + LinkedList myDir = new LinkedList(); + fillTodoList(file, todoList); + + while (!todoList.isEmpty()) { + t = (Transaction)(todoList.removeFirst()); + + command = t.getCommand(); + key = t.getKey(); + + index = key.lastindexOf('/'); + if (index+1 == key.length()) + isDir = true; + else + isDir = false; + + atomic { + gkey = global new GlobalString(key); + } + + if (command == 'r') { + System.out.println("["+command+"] ["+key+"]"); + atomic { + if (isDir == true) { + readDirectory(gkey); + } + else { + readFile(gkey); + } + } + } + else if (command == 'c') { + System.out.println("["+command+"] ["+key+"]"); + atomic { + if (isDir == true) { + createDirectory(gkey); + if(!myDir.contains(key)) { + myDir.add(key); + } + } + else { + val = t.getValue(); + gval = global new GlobalString(val); + createFile(gkey, gval); + } + } + } + } + output(myDir); + + RecoveryStat.printRecoveryStat(); + } + + public static void output(LinkedList myDir) { + Iterator iter; + String str; + + iter = myDir.iterator(); + + while (iter.hasNext()) { + str = (String)(iter.next()); + System.printString(str + "\n"); + } + } + + public void readFile(GlobalString gkey) { + GlobalString gval; + + gval = (GlobalString)(fs.get(gkey)); + if (gval != null) { +// System.out.println("<"+gval.toLocalString()+">"); + } + else { + System.out.println("No such file or directory"); + } + } + + public void readDirectory(GlobalString gkey) { + DistributedLinkedList list; + Iterator iter; + GlobalString gval; + + list = (DistributedLinkedList)(dir.get(gkey)); + + if (list != null) { + iter = list.iterator(); + while (iter.hasNext() == true) { + gval = (GlobalString)(iter.next()); +// System.out.print("["+gval.toLocalString()+"] "); + } +// System.out.println(""); + } + else { + System.out.println("No such file or directory"); + } + } + + public void createFile(GlobalString gkey, GlobalString gval) { + GlobalString path; + GlobalString target; + int index; + DistributedLinkedList list; + + index = gkey.lastindexOf('/'); + path = gkey.subString(0, index+1); + target = gkey.subString(index+1); + + if (dir.containsKey(path)) { + list = (DistributedLinkedList)(dir.get(path)); + list.push(target); + dir.put(path, list); + fs.put(gkey, gval); + } + else { + System.out.println("Cannot create file"); + } + } + + public void createDirectory(GlobalString gkey) { + int index; + GlobalString path; + GlobalString target; + DistributedLinkedList list; + + index = gkey.lastindexOf('/', gkey.length()-2); + + if (index != -1) { + path = gkey.subString(0, index+1); + target = gkey.subString(index+1); + + if (dir.containsKey(path)) { + list = (DistributedLinkedList)(dir.get(path)); + list.push(target); + dir.put(path, list); + + list = global new DistributedLinkedList(); + dir.put(gkey, list); + } + else { + System.out.println("Cannot create directory"); + } + } + } + + public void createFile(GlobalString gkey) { + GlobalString path; + GlobalString target; + GlobalString gval; + int index; + DistributedLinkedList list; + + index = gkey.lastindexOf('/'); + path = gkey.subString(0, index+1); + target = gkey.subString(index+1); + gval = global new GlobalString(); + + if (dir.containsKey(path)) { + list = (DistributedLinkedList)(dir.get(path)); + list.push(target); + dir.put(path, list); + fs.put(gkey, gval); + } + else { + System.out.println("Cannot create file"); + } + } + + public Object read(DistributedHashMap mydhmap, GlobalString key) { + Object obj = mydhmap.get(key); + + return obj; + } + + public static void main(String[] args) { + int NUM_THREADS = 3; + String filename; + + NUM_THREADS = Integer.parseInt(args[0]); + filename = args[1]; + + int[] mid = new int[8]; +/* mid[0] = (128<<24)|(195<<16)|(180<<8)|21;//dw-2 + mid[1] = (128<<24)|(195<<16)|(180<<8)|26;//dw-7 +*/ + mid[0] = (128<<24)|(195<<16)|(136<<8)|162;//dc-1 + mid[1] = (128<<24)|(195<<16)|(136<<8)|163;//dc-2 + mid[2] = (128<<24)|(195<<16)|(136<<8)|164;//dc-3 + mid[3] = (128<<24)|(195<<16)|(136<<8)|165;//dc-4 + mid[4] = (128<<24)|(195<<16)|(136<<8)|166;//dc-5 + mid[5] = (128<<24)|(195<<16)|(136<<8)|167;//dc-6 + mid[6] = (128<<24)|(195<<16)|(136<<8)|168;//dc-7 + mid[7] = (128<<24)|(195<<16)|(136<<8)|169;//dc-8 + + FileSystem[] lus; + FileSystem initLus; + + Work[] works; + Transaction[] currentWorkList; // type might be something else + + atomic { + currentWorkList = global new Transaction[NUM_THREADS]; // something else + works = global new Work[NUM_THREADS]; + + DistributedHashMap fs = global new DistributedHashMap(500, 500, 0.75f); + DistributedHashMap dir = global new DistributedHashMap(500, 500, 0.75f); + + initLus = global new FileSystem(dir, fs); + initLus.init(); + + lus = global new FileSystem[NUM_THREADS]; + for(int i = 0; i < NUM_THREADS; i++) { + lus[i] = global new FileSystem(initLus.dir, initLus.fs, filename, i); + } + } + + FileSystem tmp; + /* Start threads */ + for(int i = 0; i < NUM_THREADS; i++) { + atomic { + tmp = lus[i]; + } + Thread.myStart(tmp, mid[i]); + } + + /* Join threads */ + for(int i = 0; i < NUM_THREADS; i++) { + atomic { + tmp = lus[i]; + } + tmp.join(); + } + + System.printString("Finished\n"); + } +} + +public class Transaction { // object for todoList + char command; // r: read, w: write + String key; + String val; + + Transaction (char c, String key) { + command = c; + + this.key = new String(key); + this.val = new String(); + } + + Transaction (char c, String key, String val) { + command = c; + + this.key = new String(key); + this.val = new String(val); + } + + public char getCommand() { + return command; + } + + public String getKey() { + return key; + } + + public String getValue() { + return val; + } +} diff --git a/Robust/src/Benchmarks/Recovery/FileSystem/LookUpService.java b/Robust/src/Benchmarks/Recovery/FileSystem/LookUpService.java deleted file mode 100644 index 39333501..00000000 --- a/Robust/src/Benchmarks/Recovery/FileSystem/LookUpService.java +++ /dev/null @@ -1,339 +0,0 @@ -/* -Usage : - ./LookupService.bin -*/ - - - -public class LookUpService extends Thread { - DistributedHashMap dir; - DistributedHashMap fs; - GlobalString inputfile; - int mid; - - public LookUpService(DistributedHashMap dir, DistributedHashMap fs) { - this.dir = dir; - this.fs = fs; - } - - public LookUpService(DistributedHashMap dir, DistributedHashMap fs, String filename, int mid) { - this.dir = dir; - this.fs = fs; - this.mid = mid; - this.inputfile = global new GlobalString("data/"+filename + mid); - } - - public void init() { - fillHashTable(); - } - - public void fillHashTable() { - GlobalString path; - DistributedLinkedList list; - - atomic { - path = global new GlobalString("/home/"); // root is 'home' - list = global new DistributedLinkedList(); - - dir.put(path, list); - } - } - - public static void fillTodoList(String file, LinkedList todoList) { - FileInputStream fis; - String comm; - char c; - String key; - String val; - Transaction t; - - fis = new FileInputStream(file); - - while ((comm = fis.readLine()) != null) { // 'command' 'path' - c = comm.charAt(0); // ex) w /home/abc.c - key = comm.subString(2); - t = new Transaction(c, key); - todoList.add(t); - } - } - - public void run() { - Transaction t; - - char command; - String key; - String val; - boolean isDir; - - GlobalString gkey; - GlobalString gval; - - int index; - String file; - atomic { - file = inputfile.toLocalString(); - } - - LinkedList todoList = new LinkedList(); - LinkedList myDir = new LinkedList(); - fillTodoList(file, todoList); - - while (!todoList.isEmpty()) { - t = (Transaction)(todoList.removeFirst()); - - command = t.getCommand(); - key = t.getKey(); - - index = key.lastindexOf('/'); - if (index+1 == key.length()) - isDir = true; - else - isDir = false; - - atomic { - gkey = global new GlobalString(key); - } - - if (command == 'r') { - System.out.println("["+command+"] ["+key+"]"); - atomic { - if (isDir == true) { - readDirectory(gkey); - } - else { - readFile(gkey); - } - } - } - else if (command == 'c') { - System.out.println("["+command+"] ["+key+"]"); - atomic { - if (isDir == true) { - createDirectory(gkey); - if(!myDir.contains(key)) { - myDir.add(key); - } - } - else { - val = t.getValue(); - gval = global new GlobalString(val); - createFile(gkey, gval); - } - } - } - } - output(myDir); - - RecoveryStat.printRecoveryStat(); - } - - public static void output(LinkedList myDir) { - Iterator iter; - String str; - - iter = myDir.iterator(); - - while (iter.hasNext()) { - str = (String)(iter.next()); - System.printString(str + "\n"); - } - } - - public void readFile(GlobalString gkey) { - GlobalString gval; - - gval = (GlobalString)(fs.get(gkey)); - if (gval != null) { -// System.out.println("<"+gval.toLocalString()+">"); - } - else { - System.out.println("No such file or directory"); - } - } - - public void readDirectory(GlobalString gkey) { - DistributedLinkedList list; - Iterator iter; - GlobalString gval; - - list = (DistributedLinkedList)(dir.get(gkey)); - - if (list != null) { - iter = list.iterator(); - while (iter.hasNext() == true) { - gval = (GlobalString)(iter.next()); -// System.out.print("["+gval.toLocalString()+"] "); - } -// System.out.println(""); - } - else { - System.out.println("No such file or directory"); - } - } - - public void createFile(GlobalString gkey, GlobalString gval) { - GlobalString path; - GlobalString target; - int index; - DistributedLinkedList list; - - index = gkey.lastindexOf('/'); - path = gkey.subString(0, index+1); - target = gkey.subString(index+1); - - if (dir.containsKey(path)) { - list = (DistributedLinkedList)(dir.get(path)); - list.push(target); - dir.put(path, list); - fs.put(gkey, gval); - } - else { - System.out.println("Cannot create file"); - } - } - - public void createDirectory(GlobalString gkey) { - int index; - GlobalString path; - GlobalString target; - DistributedLinkedList list; - - index = gkey.lastindexOf('/', gkey.length()-2); - - if (index != -1) { - path = gkey.subString(0, index+1); - target = gkey.subString(index+1); - - if (dir.containsKey(path)) { - list = (DistributedLinkedList)(dir.get(path)); - list.push(target); - dir.put(path, list); - - list = global new DistributedLinkedList(); - dir.put(gkey, list); - } - else { - System.out.println("Cannot create directory"); - } - } - } - - public void createFile(GlobalString gkey) { - GlobalString path; - GlobalString target; - GlobalString gval; - int index; - DistributedLinkedList list; - - index = gkey.lastindexOf('/'); - path = gkey.subString(0, index+1); - target = gkey.subString(index+1); - gval = global new GlobalString(); - - if (dir.containsKey(path)) { - list = (DistributedLinkedList)(dir.get(path)); - list.push(target); - dir.put(path, list); - fs.put(gkey, gval); - } - else { - System.out.println("Cannot create file"); - } - } - - public Object read(DistributedHashMap mydhmap, GlobalString key) { - Object obj = mydhmap.get(key); - - return obj; - } - - public static void main(String[] args) { - int NUM_THREADS = 3; - String filename; - - NUM_THREADS = Integer.parseInt(args[0]); - filename = args[1]; - - int[] mid = new int[8]; - mid[0] = (128<<24)|(195<<16)|(180<<8)|21;//dw-2 -// mid[1] = (128<<24)|(195<<16)|(180<<8)|24;//dw-5 - mid[1] = (128<<24)|(195<<16)|(180<<8)|26;//dw-7 -// mid[0] = (128<<24)|(195<<16)|(136<<8)|165;//dc-4 -// mid[1] = (128<<24)|(195<<16)|(136<<8)|166;//dc-5 -// mid[2] = (128<<24)|(195<<16)|(136<<8)|167;//dc-6 -// mid[3] = (128<<24)|(195<<16)|(136<<8)|168;//dc-7 - - LookUpService[] lus; - LookUpService initLus; - - Work[] works; - Transaction[] currentWorkList; // type might be something else - - atomic { - currentWorkList = global new Transaction[NUM_THREADS]; // something else - works = global new Work[NUM_THREADS]; - - DistributedHashMap fs = global new DistributedHashMap(500, 500, 0.75f); - DistributedHashMap dir = global new DistributedHashMap(500, 500, 0.75f); - - initLus = global new LookUpService(dir, fs); - initLus.init(); - - lus = global new LookUpService[NUM_THREADS]; - for(int i = 0; i < NUM_THREADS; i++) { - lus[i] = global new LookUpService(initLus.dir, initLus.fs, filename, i); - } - } - - LookUpService tmp; - /* Start threads */ - for(int i = 0; i < NUM_THREADS; i++) { - atomic { - tmp = lus[i]; - } - Thread.myStart(tmp, mid[i]); - } - - /* Join threads */ - for(int i = 0; i < NUM_THREADS; i++) { - atomic { - tmp = lus[i]; - } - tmp.join(); - } - - System.printString("Finished\n"); - } -} - -public class Transaction { // object for todoList - char command; // r: read, w: write - String key; - String val; - - Transaction (char c, String key) { - command = c; - - this.key = new String(key); - this.val = new String(); - } - - Transaction (char c, String key, String val) { - command = c; - - this.key = new String(key); - this.val = new String(val); - } - - public char getCommand() { - return command; - } - - public String getKey() { - return key; - } - - public String getValue() { - return val; - } -} diff --git a/Robust/src/Benchmarks/Recovery/FileSystem/dstm.conf b/Robust/src/Benchmarks/Recovery/FileSystem/dstm.conf new file mode 100644 index 00000000..74a1e24c --- /dev/null +++ b/Robust/src/Benchmarks/Recovery/FileSystem/dstm.conf @@ -0,0 +1,3 @@ +128.195.180.21 +#128.195.180.24 +128.195.180.26 diff --git a/Robust/src/Benchmarks/Recovery/FileSystem/makefile b/Robust/src/Benchmarks/Recovery/FileSystem/makefile index 260b37a4..07625ee5 100644 --- a/Robust/src/Benchmarks/Recovery/FileSystem/makefile +++ b/Robust/src/Benchmarks/Recovery/FileSystem/makefile @@ -1,4 +1,4 @@ -MAINCLASS=LookUpService +MAINCLASS=FileSystem SRC1=${MAINCLASS}.java FLAGS= -recoverystats -dsm -dsmtask -32bit -recovery -nooptimize -mainclass ${MAINCLASS} default: diff --git a/Robust/src/Benchmarks/Recovery/SpamFilter/SpamFilter.java b/Robust/src/Benchmarks/Recovery/SpamFilter/SpamFilter.java index db426964..32df643f 100644 --- a/Robust/src/Benchmarks/Recovery/SpamFilter/SpamFilter.java +++ b/Robust/src/Benchmarks/Recovery/SpamFilter/SpamFilter.java @@ -113,6 +113,8 @@ public class SpamFilter extends Thread { // Sanity check // System.out.println((i)+"th iteration correct = " + correct + " Wrong = " + wrong + " percentage = " + ((float)correct/(float)nemails)); System.out.println("\n\n\n I'm Done\n\n\n"); + + RecoveryStat.printRecoveryStat(); } public static void main(String[] args) { diff --git a/Robust/src/Benchmarks/Recovery/Spider/QueryTask.java b/Robust/src/Benchmarks/Recovery/Spider/QueryTask.java index 2cb1145c..34415df8 100644 --- a/Robust/src/Benchmarks/Recovery/Spider/QueryTask.java +++ b/Robust/src/Benchmarks/Recovery/Spider/QueryTask.java @@ -81,6 +81,14 @@ public class QueryTask extends Task { s.close(); } } + + public void output() { + + System.out.println("size = " + results.size()); + + + } + public static boolean isDocument(String str) { int index = str.lastindexOf('.'); @@ -97,6 +105,8 @@ public class QueryTask extends Task { else if ((str.subString(index+1)).equals("docx")) return true; else if ((str.subString(index+1)).equals("mov")) return true; else if ((str.subString(index+1)).equals("flv")) return true; + else if ((str.subString(index+1)).equals("tar")) return true; + else if ((str.subString(index+1)).equals("tgz")) return true; else return false; } return false; diff --git a/Robust/src/Benchmarks/Recovery/Spider/Spider.java b/Robust/src/Benchmarks/Recovery/Spider/Spider.java index e86229ce..b9ec3df8 100644 --- a/Robust/src/Benchmarks/Recovery/Spider/Spider.java +++ b/Robust/src/Benchmarks/Recovery/Spider/Spider.java @@ -1,3 +1,9 @@ +/* +Usage : + ./Spider.java master +*/ + + public class Spider { public static void main(String[] args) { int NUM_THREADS = 3; @@ -7,14 +13,27 @@ public class Spider { Work[] works; QueryTask[] qt; GlobalQuery[] currentWorkList; + String fm = "www.uci.edu"; + String fp = ""; - NUM_THREADS = Integer.parseInt(args[0]); + if(args.length != 4) { + System.out.println("./Spider.java master "); + System.exit(0); + } + else { + NUM_THREADS = Integer.parseInt(args[0]); + fm = args[1]; + fp = args[2]; + maxDepth = Integer.parseInt(args[3]); + } GlobalString firstmachine; GlobalString firstpage; int mid[] = new int[8]; - mid[0] = (128<<24)|(195<<16)|(136<<8)|162; + mid[0] = (128<<24)|(195<<16)|(180<<8)|21; + mid[1] = (128<<24)|(195<<16)|(180<<8)|26; +/* mid[0] = (128<<24)|(195<<16)|(136<<8)|162; mid[1] = (128<<24)|(195<<16)|(136<<8)|163; mid[2] = (128<<24)|(195<<16)|(136<<8)|164; mid[3] = (128<<24)|(195<<16)|(136<<8)|165; @@ -22,15 +41,15 @@ public class Spider { mid[5] = (128<<24)|(195<<16)|(136<<8)|167; mid[6] = (128<<24)|(195<<16)|(136<<8)|168; mid[7] = (128<<24)|(195<<16)|(136<<8)|169; - + */ atomic { - firstmachine = global new GlobalString(args[1]); + firstmachine = global new GlobalString(fm); if (args.length == 3) { - firstpage = global new GlobalString(args[2]); + firstpage = global new GlobalString(fp); } else firstpage = global new GlobalString("");; - + works = global new Work[NUM_THREADS]; qt = global new QueryTask[NUM_THREADS]; currentWorkList = global new GlobalQuery[NUM_THREADS]; diff --git a/Robust/src/Benchmarks/Recovery/Spider/dstm.conf b/Robust/src/Benchmarks/Recovery/Spider/dstm.conf index eff447b8..28d63559 100644 --- a/Robust/src/Benchmarks/Recovery/Spider/dstm.conf +++ b/Robust/src/Benchmarks/Recovery/Spider/dstm.conf @@ -1,6 +1,6 @@ -#128.195.180.21 +128.195.180.21 #128.195.180.24 -#128.195.180.26 -128.195.136.162 -128.195.136.163 -128.195.136.164 +128.195.180.26 +#128.195.136.162 +#128.195.136.163 +#128.195.136.164 diff --git a/Robust/src/Benchmarks/Recovery/Spider/makefile b/Robust/src/Benchmarks/Recovery/Spider/makefile index 8077da54..7bed2f63 100644 --- a/Robust/src/Benchmarks/Recovery/Spider/makefile +++ b/Robust/src/Benchmarks/Recovery/Spider/makefile @@ -3,7 +3,7 @@ SUBCLASS=Query SRC1=${MAINCLASS}.java SRC2=Global${SUBCLASS}.java SRC3=${SUBCLASS}Task.java -FLAGS= -recovery -dsmtask -dsm -32bit -nooptimize -debug -mainclass ${MAINCLASS} +FLAGS= -recoverystats -recovery -dsmtask -dsm -32bit -nooptimize -debug -mainclass ${MAINCLASS} default: ../../../buildscript ${FLAGS} -o ${MAINCLASS} ${SRC2} ${SRC3} ${SRC1} diff --git a/Robust/src/Benchmarks/Recovery/bm_args.txt b/Robust/src/Benchmarks/Recovery/bm_args.txt index d6512b02..3aa95998 100644 --- a/Robust/src/Benchmarks/Recovery/bm_args.txt +++ b/Robust/src/Benchmarks/Recovery/bm_args.txt @@ -1 +1 @@ -MatrixMultiply:400 80 +FileSystem:data diff --git a/Robust/src/Benchmarks/Recovery/runjava.sh b/Robust/src/Benchmarks/Recovery/runjava.sh index 395ad565..d5e22949 100755 --- a/Robust/src/Benchmarks/Recovery/runjava.sh +++ b/Robust/src/Benchmarks/Recovery/runjava.sh @@ -1,7 +1,7 @@ # !/bin/sh BASEDIR=`pwd` ITERATIONS=10 -WAITTIME=30 +WAITTIME=300 # killClients <# of machines> function killclients {