changeset 177:723187e39311

*** empty log message ***
author kent
date Thu, 28 Aug 2008 22:04:11 +0900
parents 9cf8147591ea
children a097b1d619a1
files rep/channel/NetworkSimulator.java test/channeltest/testNetworkSimulator.java
diffstat 2 files changed, 15 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/rep/channel/NetworkSimulator.java	Thu Aug 28 21:35:26 2008 +0900
+++ b/rep/channel/NetworkSimulator.java	Thu Aug 28 22:04:11 2008 +0900
@@ -5,11 +5,13 @@
 import java.util.LinkedList;
 
 
-public class NetworkSimulator<P> extends REPLogger {
+public class NetworkSimulator<P> {
 	public static NetworkSimulator<?> ns;
 	
+
 	public HashMap<SocketAddress,Integer>namedb = new HashMap<SocketAddress,Integer>();
 	public int ipcount = 1;
+	public REPLogger logger;
 	
 	@SuppressWarnings("unchecked")  // <?> から <T> へのキャストのため. 
 	public static <T> NetworkSimulator<T> singleton(){
@@ -29,26 +31,27 @@
 	/** Constructor. */
 	public NetworkSimulator(){
 		serverList = new LinkedList<ServerData<P>>();
-		writeLog("construct Networksimulator", 1);
+		logger = REPLogger.singleton();
+		logger.writeLog("construct Networksimulator", 1);
 		printAllState();
 	}
 	
 	/*   */
 	synchronized public void listen(SocketAddress ip, SelectorSimulator selector) {
 		serverList.add(new ServerData<P>(ip, selector));
-		writeLog("listen", 1);
+		logger.writeLog("listen", 1);
 		printAllState();
 	}
 
 	synchronized public ChannelSimulator<P> accept(SocketAddress ip) {
 		for (ServerData<P> sd: serverList){
 			if (!sd.IP.equals(ip)) continue;
-			writeLog("accepting..", 1);
+			logger.writeLog("accepting..", 1);
 
 			ChannelSimulator<P> serverCH = sd.acceptWaitingList.remove();
 			sd.establishedList.add(serverCH);
 
-			writeLog("accepted", 1);
+			logger.writeLog("accepted", 1);
 			printAllState();
 			return serverCH;
 		}
@@ -64,7 +67,7 @@
 
 	public boolean connect(SocketAddress ip, ChannelSimulator<P> clientCH) {
 		ServerData<P> sd = null;
-		writeLog("connecting..", 1);
+		logger.writeLog("connecting..", 1);
 		synchronized (this){
 			for (ServerData<P> sd0: serverList){
 				if (sd0.IP.equals(ip)){
@@ -86,18 +89,18 @@
 		synchronized (sd.selector) {
 			sd.selector.notifyAll();
 		}
-		writeLog("connected", 1);
+		logger.writeLog("connected", 1);
 		printAllState();
 		return true;
 	}
 
 	/** for DEBUG methods. */
 	synchronized void printAllState(){
-		writeLog("NetworkSimulator State:");
+		logger.writeLog("NetworkSimulator State:");
 		for (ServerData<P> sd: serverList){
-			writeLog("\tSessionManager(ip="+sd.IP.toString()+"): ");
-			writeLog("\tacceptWaitingList="+sd.acceptWaitingList.size());
-			writeLog("\testablishedList="+sd.establishedList.size());
+			logger.writeLog("\tSessionManager(ip="+sd.IP.toString()+"): ");
+			logger.writeLog("\tacceptWaitingList="+sd.acceptWaitingList.size());
+			logger.writeLog("\testablishedList="+sd.establishedList.size());
 		}
 	}
 
--- a/test/channeltest/testNetworkSimulator.java	Thu Aug 28 21:35:26 2008 +0900
+++ b/test/channeltest/testNetworkSimulator.java	Thu Aug 28 22:04:11 2008 +0900
@@ -16,7 +16,7 @@
 
 	public static void main(String[] args){
 		REPServerSocketChannel.isSimulation = true;
-		testNetworkSimulator testns = new testNetworkSimulator(1, 0, 2);
+		testNetworkSimulator testns = new testNetworkSimulator(1, 0, 50);
 		logger.setLogLevel(5);
 		
 		testns.startTest();