Mercurial > hg > Members > tatsuki > Alice
changeset 65:ca42a2c8ac22
add local access api
author | kazz |
---|---|
date | Thu, 09 Feb 2012 19:33:46 +0900 |
parents | 7aaadd08288c |
children | 3c5c567c47d7 |
files | src/alice/codesegment/InputDataSegment.java src/alice/datasegment/Receiver.java src/alice/test/topology/ring/CheckMyName.java src/alice/test/topology/ring/FirstRingMessagePassing.java src/alice/test/topology/ring/RingMessagePassing.java src/alice/test/topology/ring/StartRing.java |
diffstat | 6 files changed, 42 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/codesegment/InputDataSegment.java Thu Feb 09 19:20:24 2012 +0900 +++ b/src/alice/codesegment/InputDataSegment.java Thu Feb 09 19:33:46 2012 +0900 @@ -31,6 +31,14 @@ DataSegment.get(managerKey).peek(receiver, key, index, cs); } + public void peek(Receiver receiver, String key) { + peek(receiver, key, 0); + } + + public void peek(Receiver receiver, String key, int index) { + DataSegment.getLocal().peek(receiver, key, index, cs); + } + public void take(Receiver receiver, String managerKey, String key) { take(receiver, managerKey, key, 0); } @@ -39,6 +47,14 @@ DataSegment.get(managerKey).take(receiver, key, index, cs); } + public void take(Receiver receiver, String key) { + take(receiver, key, 0); + } + + public void take(Receiver receiver, String key, int index) { + DataSegment.getLocal().take(receiver, key, index, cs); + } + public void reply(Receiver receiver, DataSegmentValue val) { receiver.index = val.index; receiver.val = val.val;
--- a/src/alice/datasegment/Receiver.java Thu Feb 09 19:20:24 2012 +0900 +++ b/src/alice/datasegment/Receiver.java Thu Feb 09 19:33:46 2012 +0900 @@ -47,6 +47,23 @@ ids.setKey(); } + public void setKey(String key) { + this.key = key; + setKey(key, 0); + } + + public void setKey(String key, int index) { + switch (type) { + case PEEK: + ids.peek(this, key, index); + break; + case TAKE: + ids.take(this, key, index); + break; + } + ids.setKey(); + } + public String asString() { if (val.getType() == ValueType.RAW) { return val.asRawValue().getString();
--- a/src/alice/test/topology/ring/CheckMyName.java Thu Feb 09 19:20:24 2012 +0900 +++ b/src/alice/test/topology/ring/CheckMyName.java Thu Feb 09 19:33:46 2012 +0900 @@ -12,9 +12,11 @@ private Logger logger = Logger.getLogger(CheckMyName.class); private RingTopologyConfig conf; + public CheckMyName(RingTopologyConfig conf) { this.conf = conf; } + @Override public void run() { String host = this.host.asString(); @@ -22,15 +24,15 @@ if (host.equals("node0")) { ods.put("local", "counter", new byte[conf.size]); FirstRingMessagePassing cs1 = new FirstRingMessagePassing(System.nanoTime(), conf.count, conf.nodeNum); - cs1.counter.setKey("local", "counter"); + cs1.counter.setKey("counter"); RingFinish cs2 = new RingFinish("manager"); - cs2.finish.setKey("local", "finish"); + cs2.finish.setKey("finish"); } else { ods.close("manager"); RingMessagePassing cs1 = new RingMessagePassing(); - cs1.counter.setKey("local", "counter"); + cs1.counter.setKey("counter"); RingFinish cs2 = new RingFinish("right"); - cs2.finish.setKey("local", "finish"); + cs2.finish.setKey("finish"); } }
--- a/src/alice/test/topology/ring/FirstRingMessagePassing.java Thu Feb 09 19:20:24 2012 +0900 +++ b/src/alice/test/topology/ring/FirstRingMessagePassing.java Thu Feb 09 19:33:46 2012 +0900 @@ -31,7 +31,7 @@ } FirstRingMessagePassing cs = new FirstRingMessagePassing(startTime, count, nodeNum); - cs.counter.setKey("local", "counter"); + cs.counter.setKey("counter"); } }
--- a/src/alice/test/topology/ring/RingMessagePassing.java Thu Feb 09 19:20:24 2012 +0900 +++ b/src/alice/test/topology/ring/RingMessagePassing.java Thu Feb 09 19:33:46 2012 +0900 @@ -12,7 +12,7 @@ public void run() { ods.put("right", "counter", this.counter.val); RingMessagePassing cs = new RingMessagePassing(); - cs.counter.setKey("local", "counter"); + cs.counter.setKey("counter"); } }
--- a/src/alice/test/topology/ring/StartRing.java Thu Feb 09 19:20:24 2012 +0900 +++ b/src/alice/test/topology/ring/StartRing.java Thu Feb 09 19:33:46 2012 +0900 @@ -10,7 +10,7 @@ @Override public void run() { CheckMyName cs = new CheckMyName(conf); - cs.host.setKey("local", "host"); + cs.host.setKey("host"); } }