add missing files
authoradash <adash>
Wed, 19 May 2010 17:21:30 +0000 (17:21 +0000)
committeradash <adash>
Wed, 19 May 2010 17:21:30 +0000 (17:21 +0000)
Robust/src/Benchmarks/Recovery/FileSystem/recovery/DFile.java [new file with mode: 0644]
Robust/src/Benchmarks/Recovery/FileSystem/recovery/Directory.java [new file with mode: 0644]

diff --git a/Robust/src/Benchmarks/Recovery/FileSystem/recovery/DFile.java b/Robust/src/Benchmarks/Recovery/FileSystem/recovery/DFile.java
new file mode 100644 (file)
index 0000000..1c3773f
--- /dev/null
@@ -0,0 +1,30 @@
+public class DFile {
+  char [] data;
+  int size;
+  public DFile() {
+    data=global new char[4096];
+    size=data.length;
+  }
+  public void write(int offset, char[] towrite) {
+    int length=offset+towrite.length;
+    if (length>size) {
+      if (length>data.length) {
+       char [] ptr=global new char[length];
+       for(int i=0;i<size;i++) {
+         ptr[i]=data[i];
+       }
+       this.data=ptr;
+      }
+      size=length;
+    }
+    int j=0;
+    for(int i=offset;i<length;i++)
+      data[i]=towrite[j++];
+  }
+  public char[] read() {
+    char[] ptr=new char[size];
+    for(int i=0;i<size;i++)
+      ptr[i]=data[i];
+    return ptr;
+  }
+}
diff --git a/Robust/src/Benchmarks/Recovery/FileSystem/recovery/Directory.java b/Robust/src/Benchmarks/Recovery/FileSystem/recovery/Directory.java
new file mode 100644 (file)
index 0000000..5d771c2
--- /dev/null
@@ -0,0 +1,46 @@
+public class Directory {
+  GlobalString name;
+  DistributedHashMap table;
+  DistributedLinkedList files;
+
+  public Directory(GlobalString name) {
+    this.name=name;
+    this.table=global new DistributedHashMap(500, 0.75f);
+    this.files=global new DistributedLinkedList();
+  }
+
+  public DFile getFile(GlobalString name) {
+    return (DFile) table.get(name);
+  }
+
+  public DFile createFile(GlobalString name) {
+    DFile file=global new DFile();
+    if (!table.containsKey(name)) {
+      files.add(name);
+    }
+    table.put(name, file);
+    return file;
+  }
+
+  public Directory getDirectory(GlobalString name) {
+    return (Directory) table.get(name);
+  }
+
+  public Directory makeDirectory(GlobalString name) {
+    if (!table.containsKey(name)) {
+      Directory d=global new Directory(name);
+      files.add(name);
+      table.put(name, d);
+      return d;
+    } else
+      return (Directory) table.get(name);
+  }
+
+  public void init() {
+    Random r=new Random();
+    for(int count=0; count<100; count++) {
+      GlobalString filename=global new GlobalString(String.valueOf(r.nextInt(200)));
+      createFile(filename);
+    }
+  }
+}