*** empty log message ***
authorhkhang <hkhang>
Tue, 24 Nov 2009 22:13:09 +0000 (22:13 +0000)
committerhkhang <hkhang>
Tue, 24 Nov 2009 22:13:09 +0000 (22:13 +0000)
Robust/src/Benchmarks/Recovery/FileSystem/LookUpService.java

index 938321c171ae414fceda946a8a0254bec43f3af6..2a264a9902fe834b66b12297329474879a5a74a0 100644 (file)
@@ -1,6 +1,7 @@
 public class LookUpService extends Task {\r
        DistributedHashMap dir;\r
        DistributedHashMap fs;\r
+       GlobalString error[];                   // String for incorrect path, etc.\r
        \r
        public LookUpService(Queue todoList, DistributedHashMap dir, DistributedHashMap fs) {\r
                this.todoList = todoList;\r
@@ -9,16 +10,31 @@ public class LookUpService extends Task {
        }\r
        \r
        public void init() {\r
+               makeErrorStatement();\r
                fillHashTable();\r
                fillTodoList();\r
        }\r
+\r
+       public void makeErrorStatement() {\r
+               int num = 4;\r
+               int i = 0;\r
+\r
+               atomic {\r
+                       error = global new GlobalString[num];\r
+\r
+                       error[i++] = global new GlobalString("/hkhang/error/");                                         // w: no root (hkhang), r: non existed path\r
+                       error[i++] = global new GlobalString("/home/abc/def/ghi/");                             // w: create multiple directories, r: non existed path\r
+                       error[i++] = global new GlobalString("/home/hkhang/abc");                                       // w: create directory and file together\r
+                       error[i++] = global new GlobalString("/home/hkhang/abc/def");                   // w: create directory and file together\r
+               }\r
+       }\r
        \r
        public void fillHashTable() {\r
                GlobalString path;\r
                DistributedLinkedList list; \r
 \r
                atomic {\r
-                       path = global new GlobalString("/home/");\r
+                       path = global new GlobalString("/home/");                       // root is home\r
                        list = global new DistributedLinkedList();\r
 \r
                        dir.put(path, list);\r
@@ -51,7 +67,8 @@ public class LookUpService extends Task {
                        }\r
                }\r
 \r
-               int rdprob = 95;\r
+               int rdprob = 93;\r
+               int wrtprob = 98;\r
                int dirprob = 90;\r
                int rdwr;\r
                int isdir;\r
@@ -64,7 +81,7 @@ public class LookUpService extends Task {
                                isdir = rand.nextInt(100);\r
                                findex = rand.nextInt(1000);\r
        \r
-                               if (rdwr < rdprob) {\r
+                               if (rdwr < rdprob) {                            // read\r
                                        c = 'r';\r
                                        if (isdir < dirprob) {          // file\r
                                                file = global new GlobalString(str+"file_"+findex);\r
@@ -75,7 +92,7 @@ public class LookUpService extends Task {
                                                t = global new Transaction(c, directory);\r
                                        }\r
                                }\r
-                               else {\r
+                               else if (rdwr >= rdprob && rdwr < wrtprob) {            // write\r
                                        c = 'w';\r
                                        if (isdir < dirprob) {          // file\r
                                                file = global new GlobalString(str+"file_"+findex);\r
@@ -88,6 +105,12 @@ public class LookUpService extends Task {
                                                t = global new Transaction(c, directory);\r
                                        }\r
                                }\r
+                               else {                  // error\r
+                                       int err = rand.nextInt(4);\r
+                                       file = error[err];\r
+                                       val = global new GlobalString("It is error path!!");\r
+                                       t = global new Transaction(c, file, val);\r
+                               }\r
                                todoList.push(t);\r
                        }\r
                }\r