Mercurial > hg > RemoteEditor > REPSessionManager
view test/channeltest/testNetworkSimulator.java @ 189:d03e34861a26
*** empty log message ***
author | pin |
---|---|
date | Fri, 29 Aug 2008 17:16:51 +0900 |
parents | fc8ee7600cf3 |
children | b85525d83b46 |
line wrap: on
line source
package test.channeltest; import java.util.ArrayList; import java.util.Random; import rep.channel.REPLogger; import rep.channel.REPServerSocketChannel; public class testNetworkSimulator { private ArrayList<testSeMa> semaList; private ArrayList<testSeMaSlave> semasList; private ArrayList<testEditor> editorList; private int NoSemaMaster; private int NoSemaSlave; private int NoEditor; static public REPLogger logger = REPLogger.singleton(); public static void main(String[] args){ REPServerSocketChannel.isSimulation = true; testNetworkSimulator testns = new testNetworkSimulator(1, 0, 2); logger.setLogLevel(5); testns.startTest(); } /** Constructor. */ public testNetworkSimulator(int sm, int ss,int e){ semaList = new ArrayList<testSeMa>(); semasList = new ArrayList<testSeMaSlave>(); editorList = new ArrayList<testEditor>(); NoSemaMaster = sm; NoSemaSlave = ss; NoEditor = e; } 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("SeMa"+i, host, port++); semaList.add(sm); sm.start(); } logger.writeLog("all master SessionManagers were created",1); slavePort = port; for (int i=0; i<NoSemaSlave; i++){ 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(); } logger.writeLog("all slave SessionManagers were created",1); for (int i=0; i<NoEditor; i++){ testEditor te = new testEditor("Editor"+i,host, masterPort+rand.nextInt(NoSemaMaster+NoSemaSlave)); editorList.add(te); te.start(); } logger.writeLog("all SessionManagers and Editors ware constructed."); Checker(); try { for (testEditor te: editorList) te.join(); logger.writeLog("main: all clients exited."); } catch (InterruptedException e) { e.printStackTrace(); } System.exit(0); } public void Checker(){ } }