changes and data/eval files for new evaluations
[IRC.git] / 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
23                 atomic {
24                         firstmachine = global new GlobalString(args[1]);
25
26                         works = global new Work[NUM_THREADS];
27                         qt = global new QueryTask[NUM_THREADS];
28                         currentWorkList = global new GlobalQuery[NUM_THREADS];
29                         
30                         GlobalQuery firstquery = global new GlobalQuery(firstmachine);
31
32                         Queue todoList = global new Queue();
33                         DistributedHashMap doneList = global new DistributedHashMap(500, 500, 0.75f);
34                         DistributedHashMap results = global new DistributedHashMap(100, 100, 0.75f);
35                         
36                         todoList.push(firstquery);
37
38                         for (i = 0; i < NUM_THREADS; i++) {
39                                 qt[i] = global new QueryTask(todoList, doneList, maxDepth, results);
40                                 works[i] = global new Work(qt[i], NUM_THREADS, i, currentWorkList);
41                         }
42                 }
43                 System.printString("Finished to create Objects\n");
44
45                 Work tmp;
46                 for (i = 0; i < NUM_THREADS; i++) {
47                         atomic {
48                                 tmp = works[i];
49                         }
50                         Thread.myStart(tmp, mid[i]);
51                 }
52
53                 for (i = 0; i < NUM_THREADS; i++) {
54                         atomic {
55                                 tmp = works[i];
56                         }
57                         tmp.join();
58                 }
59         }
60 }