154
|
1 package test.channeltest;
|
|
2
|
|
3 import java.util.ArrayList;
|
|
4 import java.util.Random;
|
|
5 import rep.channel.REPLogger;
|
|
6
|
|
7 public class testNetworkSimulator {
|
|
8 private ArrayList<testSeMa> semaList;
|
|
9 private ArrayList<testSeMaSlave> semasList;
|
|
10 private ArrayList<testEditor> editorList;
|
|
11 private int NoSemaMaster;
|
|
12 private int NoSemaSlave;
|
|
13 private int NoEditor;
|
|
14 static public REPLogger ns = new REPLogger();
|
|
15
|
|
16 public static void main(String[] args){
|
|
17 testNetworkSimulator testns = new testNetworkSimulator(3, 10, 50);
|
|
18
|
|
19 testns.startTest();
|
|
20 }
|
|
21
|
|
22
|
|
23 /** Constructor. */
|
|
24 public testNetworkSimulator(int sm, int ss,int e){
|
|
25 semaList = new ArrayList<testSeMa>();
|
|
26 semasList = new ArrayList<testSeMaSlave>();
|
|
27 editorList = new ArrayList<testEditor>();
|
|
28 NoSemaMaster = sm;
|
|
29 NoSemaSlave = ss;
|
|
30 NoEditor = e;
|
|
31 }
|
|
32
|
|
33 public void startTest(){
|
|
34 Random rand = new Random();
|
|
35 for (int i=0; i<NoSemaMaster; i++){
|
|
36 testSeMa sm = new testSeMa(ns, "SeMa"+i, i);
|
|
37 semaList.add(sm);
|
|
38 sm.start();
|
|
39 }
|
|
40 for (int i=0; i<NoSemaSlave; i++){
|
|
41 testSeMaSlave sm = new testSeMaSlave(ns, "SeMaS"+i, i+NoSemaMaster, rand.nextInt(NoSemaMaster));
|
|
42 semasList.add(sm);
|
|
43 sm.start();
|
|
44 }
|
|
45 for (int i=0; i<NoEditor; i++){
|
|
46 testEditor te = new testEditor(ns, "Editor"+i, rand.nextInt(NoSemaMaster+NoSemaSlave));
|
|
47 editorList.add(te);
|
|
48 te.start();
|
|
49 }
|
|
50
|
|
51 Checker();
|
|
52
|
|
53 try {
|
|
54 for (testEditor te: editorList)
|
|
55 te.join();
|
|
56 ns.writeLog("main: all clients exited.", 1);
|
|
57
|
|
58 } catch (InterruptedException e) {
|
|
59 e.printStackTrace();
|
|
60 }
|
|
61 System.exit(0);
|
|
62 }
|
|
63
|
|
64 public void Checker(){
|
|
65
|
|
66 }
|
|
67 }
|