Mercurial > hg > FederatedLinda
diff src/fdl/test/debug/MetaProtocolEngine.java @ 90:9cdc24bae625
ring test
author | one |
---|---|
date | Sat, 13 Feb 2010 04:16:15 +0900 |
parents | b658ff1eb90f |
children | 4df1d50df52a |
line wrap: on
line diff
--- a/src/fdl/test/debug/MetaProtocolEngine.java Thu Feb 11 16:26:04 2010 +0900 +++ b/src/fdl/test/debug/MetaProtocolEngine.java Sat Feb 13 04:16:15 2010 +0900 @@ -60,6 +60,8 @@ private int relayNum, relaySize, relayCounter; + private Date startTime, endTime; + // Callback class class AcceptXMLCallback implements PSXCallback { int tid; @@ -167,36 +169,37 @@ ml.in(BODY); ml.out(BODY, reply); print("Update body"); + } else if (str.equals("shutdown") && (tid == RINGLEFT || tid == RINGRIGHT)) { + print("get shutdown command"); + if (nodeId != 0) { + Routing r = null; + if (tid == RINGLEFT) { + r = nodes.get(new Integer(RINGRIGHT)); + } else if (tid == RINGRIGHT) { + r = nodes.get(new Integer(RINGLEFT)); + } + print("out"); + PSXReply o = r.linda.out(r.dstId, ByteBuffer.wrap("shutdown".getBytes())); + while (ml.fdl.qsize != 0) + ml.sync(1); + print("sync"); + ((PSXLindaImpl) r.linda).close(); + } + running = false; + return; } else if (nodeId == 0 && tid == RINGLEFT) { relayCounter++; print(new Integer(relayCounter).toString() + " relay"); if (relayCounter >= relayNum) { - sendLocalHostName(); + // 実験終了 + endTime = new Date(); + Double resultTime = new Double(((endTime.getTime() - startTime.getTime()) / (double)relayNum)); + ByteBuffer data = ByteBuffer.wrap(resultTime.toString().getBytes()); + manager.out(MANAGE, data); + //sendLocalHostName(); ml.in(tid, this); return; } - } else if (str.equals("shutdown")) { - if (tid == RINGLEFT) { - Routing r = nodes.get(new Integer(RINGRIGHT)); - r.linda.out(r.dstId, ByteBuffer.wrap("shutdown".getBytes())); - try { - r.linda.sync(1); - } catch (IOException e) { - e.printStackTrace(); - } - running = false; - return; - } else if (tid == RINGRIGHT) { - Routing r = nodes.get(new Integer(RINGLEFT)); - r.linda.out(r.dstId, ByteBuffer.wrap("shutdown".getBytes())); - try { - r.linda.sync(1); - } catch (IOException e) { - e.printStackTrace(); - } - running = false; - return; - } } Iterator<Integer> it = routing.route.iterator(); @@ -241,12 +244,15 @@ print("relay num=" + new Integer(relayNum).toString() + " size=" + new Integer(relaySize).toString()); Routing r = nodes.get(new Integer(RINGRIGHT)); + + // 実験開始 + startTime = new Date(); r.linda.out(r.dstId, ByteBuffer.wrap(new byte[relaySize])); ml.in(DEBUGSTART, this); } else if (command.equals("shutdown")) { Routing r = nodes.get(new Integer(RINGRIGHT)); r.linda.out(r.dstId, ByteBuffer.wrap("shutdown".getBytes())); - running = false; + //running = false; } } } @@ -272,6 +278,8 @@ while (running) { ml.sync(); } + print("Terminated"); + } protected void initPoller() {