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