Recovery
[IRC.git] / Robust / src / Benchmarks / Recovery / Spider / Spider.java
1 public class Spider {
2         public static void main(String[] args) {
3                 int NUM_THREADS = 3;
4                 int maxDepth = 4;
5                 int i, j;
6                 Work[] works;
7                 QueryTask[] qt;
8                 GlobalQuery[] currentWorkList;
9
10                 NUM_THREADS = Integer.parseInt(args[0]);
11
12                 GlobalString firstmachine;
13                 GlobalString firstpage;
14
15                 int mid[] = new int[NUM_THREADS];
16                 mid[0] = (128<<24)|(195<<16)|(136<<8)|162;
17                 mid[1] = (128<<24)|(195<<16)|(136<<8)|163;
18                 mid[2] = (128<<24)|(195<<16)|(136<<8)|164;
19
20                 atomic {
21                         firstmachine = global new GlobalString(args[1]);
22                         if (args.length == 3) {
23                                 firstpage = global new GlobalString(args[2]);
24                         }
25                         else 
26                                 firstpage = global new GlobalString("");;
27
28                         works = global new Work[NUM_THREADS];
29                         qt = global new QueryTask[NUM_THREADS];
30                         currentWorkList = global new GlobalQuery[NUM_THREADS];
31                         
32                         GlobalQuery firstquery = global new GlobalQuery(firstmachine, firstpage);
33
34                         Queue todoList = global new Queue();
35                         DistributedHashMap doneList = global new DistributedHashMap(500, 500, 0.75f);
36                         DistributedHashMap results = global new DistributedHashMap(100, 100, 0.75f);
37                         
38                         todoList.push(firstquery);
39
40                         for (i = 0; i < NUM_THREADS; i++) {
41                                 qt[i] = global new QueryTask(todoList, doneList, maxDepth, results);
42                                 works[i] = global new Work(qt[i], NUM_THREADS, i, currentWorkList);
43                         }
44                 }
45                 System.printString("Finished to create Objects\n");
46
47                 Work tmp;
48                 for (i = 0; i < NUM_THREADS; i++) {
49                         atomic {
50                                 tmp = works[i];
51                         }
52                         Thread.myStart(tmp, mid[i]);
53                 }
54
55                 for (i = 0; i < NUM_THREADS; i++) {
56                         atomic {
57                                 tmp = works[i];
58                         }
59                         tmp.join();
60                 }
61         }
62 }