Mercurial > hg > FederatedLinda
diff src/fdl/test/topology/ring/RingTopologyManagerEngine.java @ 80:04bd4ae97e7c
RingTopology is finished.
author | one |
---|---|
date | Sun, 22 Nov 2009 13:59:05 +0900 |
parents | 4fd2d1094bb9 |
children | c001797f3fdb |
line wrap: on
line diff
--- a/src/fdl/test/topology/ring/RingTopologyManagerEngine.java Tue Nov 17 18:19:39 2009 +0900 +++ b/src/fdl/test/topology/ring/RingTopologyManagerEngine.java Sun Nov 22 13:59:05 2009 +0900 @@ -1,9 +1,16 @@ package fdl.test.topology.ring; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.text.SimpleDateFormat; +import java.util.Date; + import fdl.MetaLinda; +import fdl.PSXReply; import fdl.test.topology.TopologyManagerEngine; public class RingTopologyManagerEngine extends TopologyManagerEngine { + private int relayId = 10; // Constructor public RingTopologyManagerEngine(MetaLinda ml, int nodeNum) { @@ -12,12 +19,12 @@ public void mainLoop() { super.mainLoop(); - + startRelay(); + endRelay(); } protected void makeTopology() { super.makeTopology(); - startRelay(); } @Override protected void makeConnection() { @@ -28,9 +35,29 @@ } private void startRelay() { - - + String relayString = "test"; + ByteBuffer data = ByteBuffer.wrap(relayString.getBytes()); + nodes[0].linda.out(relayId, data); + try { + nodes[0].linda.sync(1); + } catch (IOException e) { + e.printStackTrace(); + } } + private void endRelay() { + PSXReply reply; + reply = manager.in(relayId); + do { + try { + manager.sync(1); + } catch (IOException e) { + e.printStackTrace(); + } + } while (!reply.ready()); + ByteBuffer data = reply.getData(); + String resultData = new String(data.array()); + System.out.println("[DEBUG] RelayTime: " + resultData); + } }