Mercurial > hg > RemoteEditor > REPSessionManager
comparison test/channeltest/testNetworkSimulator.java @ 208:302c4a0afab6
*** empty log message ***
author | kono |
---|---|
date | Sat, 30 Aug 2008 12:15:21 +0900 |
parents | 4c0a94836357 |
children | 44d502851c9e |
comparison
equal
deleted
inserted
replaced
207:9aeade335af0 | 208:302c4a0afab6 |
---|---|
14 private int NoEditor; | 14 private int NoEditor; |
15 static public REPLogger logger = REPLogger.singleton(); | 15 static public REPLogger logger = REPLogger.singleton(); |
16 | 16 |
17 public static void main(String[] args){ | 17 public static void main(String[] args){ |
18 REPServerSocketChannel.isSimulation = false; | 18 REPServerSocketChannel.isSimulation = false; |
19 testNetworkSimulator testns = new testNetworkSimulator(1, 0, 2); | 19 testNetworkSimulator testns = new testNetworkSimulator(1, 2, 2); |
20 logger.setLogLevel(5); | 20 logger.setLogLevel(5); |
21 | 21 |
22 testns.startTest(); | 22 testns.startTest(); |
23 } | 23 } |
24 | 24 |
43 testSeMa sm = new testSeMa("SeMa"+i, host, port++); | 43 testSeMa sm = new testSeMa("SeMa"+i, host, port++); |
44 semaList.add(sm); | 44 semaList.add(sm); |
45 sm.start(); | 45 sm.start(); |
46 } | 46 } |
47 logger.writeLog("all master SessionManagers were created",1); | 47 logger.writeLog("all master SessionManagers were created",1); |
48 sleep(100); | |
48 slavePort = port; | 49 slavePort = port; |
49 for (int i=0; i<NoSemaSlave; i++){ | 50 for (int i=0; i<NoSemaSlave; i++){ |
50 testSeMaSlave sm = new testSeMaSlave("SeMaS"+i, | 51 testSeMaSlave sm = new testSeMaSlave("SeMaS"+i, |
51 host, port++, // own ip address | 52 host, port++, // own ip address |
52 host, masterPort+rand.nextInt(NoSemaMaster)); // random server address to connect | 53 host, masterPort+rand.nextInt(NoSemaMaster)); // random server address to connect |
53 semasList.add(sm); | 54 semasList.add(sm); |
54 sm.start(); | 55 sm.start(); |
55 } | 56 } |
56 logger.writeLog("all slave SessionManagers were created "+slavePort,1); | 57 logger.writeLog("all slave SessionManagers were created "+slavePort,1); |
57 synchronized (this) { | 58 sleep(100); |
58 try { | |
59 wait(100); | |
60 } catch (InterruptedException e) { | |
61 } | |
62 } | |
63 for (int i=0; i<NoEditor; i++){ | 59 for (int i=0; i<NoEditor; i++){ |
64 testEditor te = new testEditor("Editor"+i,host, masterPort+rand.nextInt(NoSemaMaster+NoSemaSlave)); | 60 testEditor te = new testEditor("Editor"+i,host, masterPort+rand.nextInt(NoSemaMaster+NoSemaSlave)); |
65 editorList.add(te); | 61 editorList.add(te); |
66 te.start(); | 62 te.start(); |
67 } | 63 } |
80 } catch (InterruptedException e) { | 76 } catch (InterruptedException e) { |
81 e.printStackTrace(); | 77 e.printStackTrace(); |
82 } | 78 } |
83 //System.exit(0); | 79 //System.exit(0); |
84 } | 80 } |
81 | |
82 | |
83 private void sleep(int time) { | |
84 synchronized (this) { | |
85 try { | |
86 wait(time); | |
87 } catch (InterruptedException e) { | |
88 } | |
89 } | |
90 } | |
85 | 91 |
86 public void Checker(){ | 92 public void Checker(){ |
87 | 93 |
88 } | 94 } |
89 } | 95 } |