Mercurial > hg > RemoteEditor > REPSessionManager
changeset 161:5b4be02e7243
*** empty log message ***
author | kono |
---|---|
date | Thu, 28 Aug 2008 16:54:47 +0900 |
parents | 6a5974dd0368 |
children | 2bd3264abf55 |
files | test/channeltest/testNetworkSimulator.java test/channeltest/testSeMa.java test/channeltest/testSeMaSlave.java |
diffstat | 3 files changed, 16 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/test/channeltest/testNetworkSimulator.java Thu Aug 28 16:53:12 2008 +0900 +++ b/test/channeltest/testNetworkSimulator.java Thu Aug 28 16:54:47 2008 +0900 @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.Random; import rep.channel.REPLogger; +import rep.channel.REPServerSocketChannel; public class testNetworkSimulator { private ArrayList<testSeMa> semaList; @@ -14,6 +15,7 @@ static public REPLogger ns = new REPLogger(); public static void main(String[] args){ + REPServerSocketChannel.isSimulation = false; testNetworkSimulator testns = new testNetworkSimulator(3, 10, 50); testns.startTest(); @@ -31,19 +33,26 @@ } public void startTest(){ + int port = 11000; + int masterPort = port; + int slavePort; + String host = "localhost"; Random rand = new Random(); for (int i=0; i<NoSemaMaster; i++){ - testSeMa sm = new testSeMa(ns, "SeMa"+i, i); + testSeMa sm = new testSeMa("SeMa"+i, host, port++); semaList.add(sm); sm.start(); } + slavePort = port; for (int i=0; i<NoSemaSlave; i++){ - testSeMaSlave sm = new testSeMaSlave(ns, "SeMaS"+i, i+NoSemaMaster, rand.nextInt(NoSemaMaster)); + testSeMaSlave sm = new testSeMaSlave("SeMaS"+i, + host, port++, // own ip address + host, masterPort+rand.nextInt(NoSemaMaster)); // random server address to connect semasList.add(sm); sm.start(); } for (int i=0; i<NoEditor; i++){ - testEditor te = new testEditor(ns, "Editor"+i, rand.nextInt(NoSemaMaster+NoSemaSlave)); + testEditor te = new testEditor("Editor"+i,host, masterPort+rand.nextInt(NoSemaMaster+NoSemaSlave)); editorList.add(te); te.start(); }
--- a/test/channeltest/testSeMa.java Thu Aug 28 16:53:12 2008 +0900 +++ b/test/channeltest/testSeMa.java Thu Aug 28 16:54:47 2008 +0900 @@ -10,8 +10,6 @@ import rep.channel.REPSelector; import rep.channel.REPServerSocketChannel; import rep.channel.REPSocketChannel; -import sun.nio.ch.SocketOpts.IP; - public class testSeMa extends Thread{ @@ -20,10 +18,10 @@ REPLogger ns; LinkedList<REPSocketChannel<String>> channels; - public testSeMa(REPLogger _ns, String name, String host, int port){ + public testSeMa(String name, String host, int port){ super(name); IP = new InetSocketAddress(host,port); - ns = _ns; + ns = testNetworkSimulator.ns; channels = new LinkedList<REPSocketChannel<String>>(); } public void init(){
--- a/test/channeltest/testSeMaSlave.java Thu Aug 28 16:53:12 2008 +0900 +++ b/test/channeltest/testSeMaSlave.java Thu Aug 28 16:54:47 2008 +0900 @@ -17,7 +17,7 @@ SocketAddress ownIP; SocketAddress masterIP; boolean running=true; - REPLogger ns = new REPLogger(); + REPLogger ns; LinkedList<ClientInfo> cis; public testSeMaSlave(String name, String oname,int oport, String mname,int mport){ @@ -25,6 +25,7 @@ ownIP = new InetSocketAddress(oname,oport); masterIP = new InetSocketAddress(mname,mport); cis = new LinkedList<ClientInfo>(); + ns = testNetworkSimulator.ns; } public void init(){