fillTodoList(file, todoList);\r
long st = System.currentTimeMillis();\r
long fi;\r
- long tot1;\r
+ long tot1, tot2;\r
\r
if(todoList.isEmpty())\r
System.out.println("todoList is Empty\n");\r
while (!todoList.isEmpty()) {\r
int count = 10;\r
atomic {\r
- while(count>0 && !todoList.isEmpty()) { //commit 5 transactions\r
+ while(count>0 && !todoList.isEmpty()) { //commit 10 transactions\r
t = (Transaction)(todoList.removeFirst());\r
if(t==null) {\r
count--;\r
else \r
isDir = false;\r
\r
- long st1 = 0L;\r
- long fi1 = 0L;\r
if (command == 'r') {\r
- st1 = System.currentTimeMillis();\r
+ long st1 = System.currentTimeMillis();\r
//System.out.println("["+command+"] ["+key+"]");\r
- if (isDir == true) {\r
- readDirectory(gkey);\r
- }\r
- else {\r
+ if (isDir != true) {\r
readFile(gkey);\r
}\r
- fi1 = System.currentTimeMillis();\r
+ long fi1 = System.currentTimeMillis();\r
+ tot1 += fi1 - st1;\r
}\r
- tot1 += fi1 - st1;\r
+\r
if (command == 'c') {\r
+ long st2 = System.currentTimeMillis();\r
//System.out.println("["+command+"] ["+key+"]");\r
- if (isDir == true) {\r
- createDirectory(gkey);\r
- }\r
- else {\r
- String val = t.getValue();\r
+ if (isDir != true) {\r
+ String val = "Testrun";\r
GlobalString gval = global new GlobalString(val);\r
- createFile(gkey, gval);\r
+ writetoFile(gkey, gval);\r
}\r
+ long fi2 = System.currentTimeMillis();\r
+ tot2 += fi2 - st2;\r
}\r
count--;\r
}//end of inside loop\r
\r
System.out.println("\n\n\n I'm done - Time Elapse : "+ ((double)(fi-st)/1000) + "\n\n\n");\r
System.out.println("\n Reading - Time Elapse : "+ ((double)tot1/1000) + "\n");\r
+ System.out.println("\n Creating - Time Elapse : "+ ((double)tot2/1000) + "\n");\r
while(true) {\r
sleep(100000);\r
}\r
public void readFile(GlobalString gkey) {\r
GlobalString gval=null;\r
String val=null;\r
+ int FILE_SIZE = 4096;\r
\r
gval = (GlobalString)(fs.get(gkey));\r
if(gval!=null) {\r
val = gval.toLocalString();\r
+ //System.out.println("readFile(): ["+gkey.toLocalString()+"] ");\r
//Add some useless extra work for now\r
//to increase read time\r
+ String filename = gkey.toLocalString();\r
+ FileInputStream inputFile = new FileInputStream(filename);\r
+ int n;\r
+ byte b[] = new byte[FILE_SIZE];\r
+ while ((n = inputFile.read(b)) != 0) {\r
+ for(int x=0; x<n; x++) {\r
+ byte buf = b[x];\r
+ }\r
+ }\r
+ inputFile.close();\r
+ /*\r
int hashVal = val.hashCode();\r
int a=0;\r
for(int t=0; t<hashVal; t++) {\r
a = a + t;\r
}\r
+ */\r
}\r
if (val == null) {\r
System.out.println("No such file or directory");\r
}\r
}\r
\r
+ public void writetoFile(GlobalString gkey, GlobalString gval) {\r
+ int index = gkey.lastindexOf('/');\r
+ GlobalString gpath = gkey.subString(0, index+1);\r
+ GlobalString gtarget = gkey.subString(index+1);\r
+ /*\r
+ String s = gpath.toLocalString()+gtarget.toLocalString();\r
+ FileInputStream inputFile = new FileInputStream(s);\r
+ int n;\r
+ byte b[] = new byte[10];\r
+ while ((n = inputFile.read(b)) != 0) {\r
+ for(int x=0; x<10; x++) {\r
+ b[x] = (byte)(x+1);\r
+ }\r
+ }\r
+ inputFile.close();\r
+ */\r
+ if (dir.containsKey(gpath)) {\r
+ fs.put(gkey, gval);\r
+ }\r
+ }\r
+\r
public void createFile(GlobalString gkey, GlobalString gval) {\r
String path;\r
String target;\r
gpath = gkey.subString(0, index+1);\r
gtarget = gkey.subString(index+1);\r
String s = gpath.toLocalString()+gtarget.toLocalString();\r
+ /*\r
FileOutputStream fos = new FileOutputStream(s);\r
fos.FileOutputStream(s);\r
byte[] b = new byte[1];\r
- for(int i=0; i<10; i++) {\r
+ for(int i=0; i<4096; i++) {\r
b[0] = (byte) i;\r
fos.write(b);\r
fos.flush();\r
}\r
fos.close();\r
+ */\r
\r
if(dir==null)\r
System.out.println("dir is null");\r
GlobalString target = gkey.subString(index+1);\r
String val = new String(target.toLocalString());\r
GlobalString gval = global new GlobalString(val);\r
+ //System.out.println("Creating file: " + key);\r
initLus.createFile(gkey, gval);\r
}\r
}\r