while ((comm = fis.readLine()) != null) { // 'command' 'path'\r
c = comm.charAt(0); // ex) w /home/abc.c \r
key = comm.subString(2);\r
- if (c == 'c') {\r
-// System.out.println(c + " " + key);\r
- t = new Transaction(c, key);\r
-// t = new Transaction(c, key, val);\r
- }\r
- else {\r
-// System.out.println(c + " " + key);\r
- t = new Transaction(c, key);\r
- }\r
+ t = new Transaction(c, key);\r
todoList.add(t);\r
}\r
}\r
}\r
\r
LinkedList todoList = new LinkedList();\r
+ LinkedList myDir = new LinkedList();\r
fillTodoList(file, todoList);\r
\r
while (!todoList.isEmpty()) {\r
}\r
\r
if (command == 'r') { \r
- System.out.println("["+command+"] ["+key+"]");\r
+// System.out.println("["+command+"] ["+key+"]");\r
if (isDir == true) {\r
atomic {\r
readDirectory(gkey);\r
}\r
else if (command == 'c') { \r
if (isDir == true) {\r
- System.out.println("["+command+"] ["+key+"]");\r
+// System.out.println("["+command+"] ["+key+"]");\r
atomic {\r
createDirectory(gkey);\r
+ if(!myDir.contains(key)) {\r
+ myDir.add(key);\r
+ }\r
}\r
}\r
else {\r
val = t.getValue();\r
- System.out.println("["+command+"] ["+key+"] ["+val+"]");\r
+// System.out.println("["+command+"] ["+key+"] ["+val+"]");\r
atomic {\r
gval = global new GlobalString(val);\r
createFile(gkey, gval);\r
}\r
}\r
}\r
+ output(myDir);\r
+ }\r
+\r
+ public static void output(LinkedList myDir) { \r
+ Iterator iter;\r
+ String str;\r
+\r
+ iter = myDir.iterator();\r
+\r
+ while (iter.hasNext()) {\r
+ str = (String)(iter.next());\r
+ System.printString(str + "\n");\r
+ }\r
}\r
\r
public void readFile(GlobalString gkey) {\r
}\r
\r
public void createFile(GlobalString gkey) {\r
+ GlobalString path;\r
+ GlobalString target;\r
+ GlobalString gval;\r
+ int index;\r
+ DistributedLinkedList list;\r
+\r
+ index = gkey.lastindexOf('/');\r
+ path = gkey.subString(0, index+1);\r
+ target = gkey.subString(index+1);\r
+ gval = global new GlobalString();\r
+\r
+ if (dir.containsKey(path)) {\r
+ list = (DistributedLinkedList)(dir.get(path));\r
+ list.push(target);\r
+ dir.put(path, list);\r
+ fs.put(gkey, gval);\r
+ }\r
+ else {\r
+ System.out.println("Cannot create file");\r
+ }\r
}\r
\r
public Object read(DistributedHashMap mydhmap, GlobalString key) {\r
\r
int[] mid = new int[8];\r
mid[0] = (128<<24)|(195<<16)|(180<<8)|21;//dw-2\r
- mid[1] = (128<<24)|(195<<16)|(180<<8)|24;//dw-5\r
- mid[2] = (128<<24)|(195<<16)|(180<<8)|26;//dw-7\r
+// mid[1] = (128<<24)|(195<<16)|(180<<8)|24;//dw-5\r
+ mid[1] = (128<<24)|(195<<16)|(180<<8)|26;//dw-7\r
// mid[0] = (128<<24)|(195<<16)|(136<<8)|165;//dc-4\r
// mid[1] = (128<<24)|(195<<16)|(136<<8)|166;//dc-5\r
// mid[2] = (128<<24)|(195<<16)|(136<<8)|167;//dc-6\r