# HG changeset patch # User kent # Date 1219926127 -32400 # Node ID 5653cf8e3c8b2e349923c5f4af75b615e3c943d9 # Parent 72252e970a8bbda95a14960c571afc39d6f62d71 *** empty log message *** diff -r 72252e970a8b -r 5653cf8e3c8b rep/channel/ChannelSimulator.java --- a/rep/channel/ChannelSimulator.java Thu Aug 28 19:49:41 2008 +0900 +++ b/rep/channel/ChannelSimulator.java Thu Aug 28 21:22:07 2008 +0900 @@ -32,14 +32,10 @@ /** Connecting methods */ // for clients. - public boolean connect(int ip){ + public boolean connect(SocketAddress ip){ return ns.connect(ip, this); } - public boolean connect(SocketAddress semaIP) throws IOException { - int ip = ns.nslookup(semaIP); - return ns.connect(ip, this); - } public ChannelSimulator
accept(){
return null;
diff -r 72252e970a8b -r 5653cf8e3c8b rep/channel/NetworkSimulator.java
--- a/rep/channel/NetworkSimulator.java Thu Aug 28 19:49:41 2008 +0900
+++ b/rep/channel/NetworkSimulator.java Thu Aug 28 21:22:07 2008 +0900
@@ -11,7 +11,7 @@
public HashMap (ip, selector));
writeLog("listen", 1);
printAllState();
}
- synchronized public ChannelSimulator accept(int ip) {
+ synchronized public ChannelSimulator accept(SocketAddress ip) {
for (ServerData sd: serverList){
- if (sd.virtualIP!=ip) continue;
+ if (!sd.IP.equals(ip)) continue;
writeLog("accepting..", 1);
ChannelSimulator serverCH = sd.acceptWaitingList.remove();
@@ -56,23 +54,24 @@
}
return null;
}
- synchronized public boolean canAccept(int ip){
+ synchronized public boolean canAccept(SocketAddress ip){
for (ServerData sd: serverList){
- if (sd.virtualIP!=ip) continue;
+ if (!sd.IP.equals(ip)) continue;
return !sd.acceptWaitingList.isEmpty();
}
return false;
}
- public boolean connect(int ip, ChannelSimulator clientCH) {
+ public boolean connect(SocketAddress ip, ChannelSimulator clientCH) {
ServerData sd = null;
writeLog("connecting..", 1);
synchronized (this){
for (ServerData sd0: serverList){
- if (sd0.virtualIP!=ip) continue;
-
- sd = sd0;
- }
+ if (sd0.IP.equals(ip)){
+ sd=sd0;
+ break;
+ }
+ }
if (sd==null) return false;
//ChannelSimulator channel = new ChannelSimulator (sd.selector);
@@ -96,7 +95,7 @@
synchronized void printAllState(){
writeLog("NetworkSimulator State:");
for (ServerData sd: serverList){
- writeLog("\tSessionManager(ip="+sd.virtualIP+"): ");
+ writeLog("\tSessionManager(ip="+sd.IP.toString()+"): ");
writeLog("\tacceptWaitingList="+sd.acceptWaitingList.size());
writeLog("\testablishedList="+sd.establishedList.size());
}
@@ -116,13 +115,14 @@
}
class ServerData {
- int virtualIP;
+ //int virtualIP;
+ SocketAddress IP;
SelectorSimulator selector;
LinkedList extends REPServerSocketChannel {
protected NetworkSimulator ns;
//public REPServerSocket singleton();
}
- public void bind(int ip){
- virtualIP = ip;
+ public void bind(SocketAddress ip){
+ IP = ip;
}
public REPSocketChannel accept1() /*throws IOException*/ {
- return ns.accept(virtualIP);
+ return ns.accept(IP);
}
@Override
@@ -55,9 +57,12 @@
public SelectionKey register(REPSelector sel, int ops, Object att) throws ClosedChannelException {
REPSelector selector = sel;
- ns.listen(virtualIP, (SelectorSimulator) selector);
+ ns.listen(IP, (SelectorSimulator) selector);
return selector.register(this, ops, att);
}
+ public boolean isAcceptable() {
+ return ns.canAccept(IP);
+ }
}
diff -r 72252e970a8b -r 5653cf8e3c8b test/channeltest/testNetworkSimulator.java
--- a/test/channeltest/testNetworkSimulator.java Thu Aug 28 19:49:41 2008 +0900
+++ b/test/channeltest/testNetworkSimulator.java Thu Aug 28 21:22:07 2008 +0900
@@ -17,7 +17,7 @@
public static void main(String[] args){
REPServerSocketChannel.isSimulation = true;
testNetworkSimulator testns = new testNetworkSimulator(1, 0, 2);
-
+ logger.setLogLevel(5);
testns.startTest();
}
diff -r 72252e970a8b -r 5653cf8e3c8b test/channeltest/testSeMa.java
--- a/test/channeltest/testSeMa.java Thu Aug 28 19:49:41 2008 +0900
+++ b/test/channeltest/testSeMa.java Thu Aug 28 21:22:07 2008 +0900
@@ -39,10 +39,14 @@
scs.socket().setReuseAddress(true);
scs.socket().bind(IP);
scs.configureBlocking(false);
- selector.register(scs, SelectionKey.OP_ACCEPT, null);
+ //selector.register(scs, SelectionKey.OP_ACCEPT, null);
+ scs.register(selector, SelectionKey.OP_ACCEPT, null);
} catch (IOException e1) {
+ ns.writeLog("cannot create REPServerSocketChannel!, exit.");
return;
}
+ ns.writeLog("selector is "+selector.toString());
+ ns.writeLog("REPssc is "+scs.toString());
ns.writeLog("SessionManager starts mainroutin.", 1);
@@ -59,7 +63,8 @@
REPServerSocketChannel