Mercurial > hg > Members > tatsuki > Alice
changeset 33:20c67f673224
change name of DataSegmentReceiver
line wrap: on
line diff
--- a/src/alice/codesegment/InputDataSegment.java Tue Jan 17 20:49:26 2012 +0900 +++ b/src/alice/codesegment/InputDataSegment.java Wed Jan 18 01:34:23 2012 +0900 @@ -4,7 +4,7 @@ import alice.datasegment.CommandType; import alice.datasegment.DataSegment; -import alice.datasegment.DataSegmentReceiver; +import alice.datasegment.Receiver; import alice.datasegment.DataSegmentValue; public class InputDataSegment { @@ -17,23 +17,23 @@ this.cs = cs; } - public void peek(DataSegmentReceiver receiver, String managerKey, String key) { + public void peek(Receiver receiver, String managerKey, String key) { peek(receiver, managerKey, key, 0); } - public void peek(DataSegmentReceiver receiver, String managerKey, String key, int index) { + public void peek(Receiver receiver, String managerKey, String key, int index) { DataSegment.get(managerKey).peek(receiver, key, index, cs); } - public void take(DataSegmentReceiver receiver, String managerKey, String key) { + public void take(Receiver receiver, String managerKey, String key) { take(receiver, managerKey, key, 0); } - public void take(DataSegmentReceiver receiver, String managerKey, String key, int index) { + public void take(Receiver receiver, String managerKey, String key, int index) { DataSegment.get(managerKey).take(receiver, key, index, cs); } - public void reply(DataSegmentReceiver receiver, DataSegmentValue val) { + public void reply(Receiver receiver, DataSegmentValue val) { receiver.index = val.index; receiver.val = val.val; receiver.from = val.from; @@ -61,8 +61,8 @@ } } - public DataSegmentReceiver createReceiver(CommandType type) { - return new DataSegmentReceiver(this, type); + public Receiver create(CommandType type) { + return new Receiver(this, type); } }
--- a/src/alice/datasegment/Command.java Tue Jan 17 20:49:26 2012 +0900 +++ b/src/alice/datasegment/Command.java Wed Jan 18 01:34:23 2012 +0900 @@ -9,7 +9,7 @@ public class Command { public CommandType type; public String key; - public DataSegmentReceiver receiver; + public Receiver receiver; public Value val; public int index; public int seq; @@ -17,7 +17,7 @@ public CodeSegment cs; public String reverseKey; - public Command(CommandType cmdType, DataSegmentReceiver receiver, String key, Value val, int index, int seq, BlockingQueue<Command> replyQueue, CodeSegment cs, String reverseKey) { + public Command(CommandType cmdType, Receiver receiver, String key, Value val, int index, int seq, BlockingQueue<Command> replyQueue, CodeSegment cs, String reverseKey) { this.type = cmdType; this.receiver = receiver; this.key = key;
--- a/src/alice/datasegment/DataSegmentManager.java Tue Jan 17 20:49:26 2012 +0900 +++ b/src/alice/datasegment/DataSegmentManager.java Wed Jan 18 01:34:23 2012 +0900 @@ -33,14 +33,14 @@ public abstract void put(String key, Value val); public abstract void update(String key, Value val); - public void take(DataSegmentReceiver receiver, String key, CodeSegment cs) { + public void take(Receiver receiver, String key, CodeSegment cs) { take(receiver, key, 0, cs); } - public abstract void take(DataSegmentReceiver receiver, String key, int index, CodeSegment cs); - public void peek(DataSegmentReceiver receiver, String key, CodeSegment cs) { + public abstract void take(Receiver receiver, String key, int index, CodeSegment cs); + public void peek(Receiver receiver, String key, CodeSegment cs) { peek(receiver, key, 0, cs); } - public abstract void peek(DataSegmentReceiver receiver, String key, int index, CodeSegment cs); + public abstract void peek(Receiver receiver, String key, int index, CodeSegment cs); public abstract void remove(String key); public abstract void finish();
--- a/src/alice/datasegment/DataSegmentReceiver.java Tue Jan 17 20:49:26 2012 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -package alice.datasegment; - -import org.msgpack.type.Value; -import org.msgpack.type.ValueType; - -import alice.codesegment.InputDataSegment; - -public class DataSegmentReceiver { - public InputDataSegment ids; - public int index; - public Value val; - public String from; - public CommandType type; - - - public DataSegmentReceiver(InputDataSegment ids, CommandType type) { - this.ids = ids; - this.type = type; - ids.regist(); - } - - public void setKey(String managerKey, String key) { - setKey(managerKey, key, 0); - } - - public void setKey(String managerKey, String key, int index) { - switch (type) { - case PEEK: - ids.peek(this, managerKey, key, index); - break; - case TAKE: - ids.take(this, managerKey, key, index); - break; - } - ids.setKey(); - } - - public String asString() { - if (val.getType() == ValueType.RAW) { - return val.asRawValue().getString(); - } - return null; - } - - public int asInteger() { - if (val.getType() == ValueType.INTEGER) { - return val.asIntegerValue().getInt(); - } - return 0; - } - -}
--- a/src/alice/datasegment/LocalDataSegmentManager.java Tue Jan 17 20:49:26 2012 +0900 +++ b/src/alice/datasegment/LocalDataSegmentManager.java Wed Jan 18 01:34:23 2012 +0900 @@ -39,7 +39,7 @@ } @Override - public void take(DataSegmentReceiver receiver, String key, int index, CodeSegment cs) { + public void take(Receiver receiver, String key, int index, CodeSegment cs) { DataSegmentKey dataSegmentKey = getDataSegmentKey(key); int seq = this.seq.getAndIncrement(); Command cmd = new Command(CommandType.TAKE, receiver, null, null, index, seq, replyQueue, cs, null); @@ -48,7 +48,7 @@ } @Override - public void peek(DataSegmentReceiver receiver, String key, int index, CodeSegment cs) { + public void peek(Receiver receiver, String key, int index, CodeSegment cs) { DataSegmentKey dataSegmentKey = getDataSegmentKey(key); int seq = this.seq.getAndIncrement(); Command cmd = new Command(CommandType.PEEK, receiver, null, null, index, seq, replyQueue, cs, null);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/datasegment/Receiver.java Wed Jan 18 01:34:23 2012 +0900 @@ -0,0 +1,52 @@ +package alice.datasegment; + +import org.msgpack.type.Value; +import org.msgpack.type.ValueType; + +import alice.codesegment.InputDataSegment; + +public class Receiver { + public InputDataSegment ids; + public int index; + public Value val; + public String from; + public CommandType type; + + + public Receiver(InputDataSegment ids, CommandType type) { + this.ids = ids; + this.type = type; + ids.regist(); + } + + public void setKey(String managerKey, String key) { + setKey(managerKey, key, 0); + } + + public void setKey(String managerKey, String key, int index) { + switch (type) { + case PEEK: + ids.peek(this, managerKey, key, index); + break; + case TAKE: + ids.take(this, managerKey, key, index); + break; + } + ids.setKey(); + } + + public String asString() { + if (val.getType() == ValueType.RAW) { + return val.asRawValue().getString(); + } + return null; + } + + public int asInteger() { + if (val.getType() == ValueType.INTEGER) { + return val.asIntegerValue().getInt(); + } + return 0; + } + +}
--- a/src/alice/datasegment/RemoteDataSegmentManager.java Tue Jan 17 20:49:26 2012 +0900 +++ b/src/alice/datasegment/RemoteDataSegmentManager.java Wed Jan 18 01:34:23 2012 +0900 @@ -68,7 +68,7 @@ } @Override - public void take(DataSegmentReceiver receiver, String key, int index, CodeSegment cs) { + public void take(Receiver receiver, String key, int index, CodeSegment cs) { int seq = this.seq.getAndIncrement(); Command cmd = new Command(CommandType.TAKE, receiver, key, null, index, seq, replyQueue, cs, null); seqHash.put(seq, cmd); @@ -76,7 +76,7 @@ } @Override - public void peek(DataSegmentReceiver receiver, String key, int index, CodeSegment cs) { + public void peek(Receiver receiver, String key, int index, CodeSegment cs) { int seq = this.seq.getAndIncrement(); Command cmd = new Command(CommandType.PEEK, receiver, key, null, index, seq, replyQueue, cs, null); seqHash.put(seq, cmd);
--- a/src/alice/test/codesegment/local/TestCodeSegment.java Tue Jan 17 20:49:26 2012 +0900 +++ b/src/alice/test/codesegment/local/TestCodeSegment.java Wed Jan 18 01:34:23 2012 +0900 @@ -5,11 +5,11 @@ import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; -import alice.datasegment.DataSegmentReceiver; +import alice.datasegment.Receiver; public class TestCodeSegment extends CodeSegment { - DataSegmentReceiver arg1 = ids.createReceiver(CommandType.PEEK); + Receiver arg1 = ids.create(CommandType.PEEK); @Override public void run() {
--- a/src/alice/test/codesegment/remote/RemoteIncrement.java Tue Jan 17 20:49:26 2012 +0900 +++ b/src/alice/test/codesegment/remote/RemoteIncrement.java Wed Jan 18 01:34:23 2012 +0900 @@ -4,11 +4,11 @@ import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; -import alice.datasegment.DataSegmentReceiver; +import alice.datasegment.Receiver; public class RemoteIncrement extends CodeSegment { - public DataSegmentReceiver num = ids.createReceiver(CommandType.TAKE); + public Receiver num = ids.create(CommandType.TAKE); @Override public void run() {
--- a/src/alice/test/topology/ring/CheckMyName.java Tue Jan 17 20:49:26 2012 +0900 +++ b/src/alice/test/topology/ring/CheckMyName.java Wed Jan 18 01:34:23 2012 +0900 @@ -2,11 +2,11 @@ import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; -import alice.datasegment.DataSegmentReceiver; +import alice.datasegment.Receiver; public class CheckMyName extends CodeSegment { - DataSegmentReceiver host = ids.createReceiver(CommandType.PEEK); + Receiver host = ids.create(CommandType.PEEK); @Override public void run() {
--- a/src/alice/test/topology/ring/FirstRingMessagePassing.java Tue Jan 17 20:49:26 2012 +0900 +++ b/src/alice/test/topology/ring/FirstRingMessagePassing.java Wed Jan 18 01:34:23 2012 +0900 @@ -4,11 +4,11 @@ import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; -import alice.datasegment.DataSegmentReceiver; +import alice.datasegment.Receiver; public class FirstRingMessagePassing extends CodeSegment { - DataSegmentReceiver counter = ids.createReceiver(CommandType.TAKE); + Receiver counter = ids.create(CommandType.TAKE); @Override public void run() {
--- a/src/alice/test/topology/ring/RingFinish.java Tue Jan 17 20:49:26 2012 +0900 +++ b/src/alice/test/topology/ring/RingFinish.java Wed Jan 18 01:34:23 2012 +0900 @@ -4,12 +4,12 @@ import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; -import alice.datasegment.DataSegmentReceiver; +import alice.datasegment.Receiver; public class RingFinish extends CodeSegment { private String sendKey; - public DataSegmentReceiver finish = ids.createReceiver(CommandType.TAKE); + public Receiver finish = ids.create(CommandType.TAKE); public RingFinish(String sendKey) { this.sendKey = sendKey;
--- a/src/alice/test/topology/ring/RingMessagePassing.java Tue Jan 17 20:49:26 2012 +0900 +++ b/src/alice/test/topology/ring/RingMessagePassing.java Wed Jan 18 01:34:23 2012 +0900 @@ -5,11 +5,11 @@ import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; -import alice.datasegment.DataSegmentReceiver; +import alice.datasegment.Receiver; public class RingMessagePassing extends CodeSegment { - public DataSegmentReceiver counter = ids.createReceiver(CommandType.TAKE); + public Receiver counter = ids.create(CommandType.TAKE); @Override public void run() {
--- a/src/alice/topology/manager/IncomingHosts.java Tue Jan 17 20:49:26 2012 +0900 +++ b/src/alice/topology/manager/IncomingHosts.java Wed Jan 18 01:34:23 2012 +0900 @@ -12,14 +12,14 @@ import alice.datasegment.CommandType; import alice.datasegment.DataSegment; import alice.datasegment.DataSegmentManager; -import alice.datasegment.DataSegmentReceiver; +import alice.datasegment.Receiver; import alice.topology.HostMessage; public class IncomingHosts extends CodeSegment { HashMap<String, LinkedList<NodeInfo>> topology; LinkedList<String> nodeNames; - DataSegmentReceiver host = ids.createReceiver(CommandType.TAKE); + Receiver host = ids.create(CommandType.TAKE); Logger logger = Logger.getLogger(IncomingHosts.class); public IncomingHosts(HashMap<String, LinkedList<NodeInfo>> topology, LinkedList<String> nodeNames) {
--- a/src/alice/topology/manager/TopologyFinish.java Tue Jan 17 20:49:26 2012 +0900 +++ b/src/alice/topology/manager/TopologyFinish.java Wed Jan 18 01:34:23 2012 +0900 @@ -2,10 +2,10 @@ import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; -import alice.datasegment.DataSegmentReceiver; +import alice.datasegment.Receiver; public class TopologyFinish extends CodeSegment { - public DataSegmentReceiver finish = ids.createReceiver(CommandType.TAKE); + public Receiver finish = ids.create(CommandType.TAKE); @Override public void run() { System.exit(0);
--- a/src/alice/topology/node/ConfigurationFinish.java Tue Jan 17 20:49:26 2012 +0900 +++ b/src/alice/topology/node/ConfigurationFinish.java Wed Jan 18 01:34:23 2012 +0900 @@ -2,12 +2,12 @@ import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; -import alice.datasegment.DataSegmentReceiver; +import alice.datasegment.Receiver; public class ConfigurationFinish extends CodeSegment { - public DataSegmentReceiver reverseCount = ids.createReceiver(CommandType.PEEK); - public DataSegmentReceiver configNodeNum = ids.createReceiver(CommandType.PEEK); + public Receiver reverseCount = ids.create(CommandType.PEEK); + public Receiver configNodeNum = ids.create(CommandType.PEEK); private Class<? extends CodeSegment> clazz; public ConfigurationFinish(Class<? extends CodeSegment> clazz) {
--- a/src/alice/topology/node/IncomingAbstractHostName.java Tue Jan 17 20:49:26 2012 +0900 +++ b/src/alice/topology/node/IncomingAbstractHostName.java Wed Jan 18 01:34:23 2012 +0900 @@ -2,11 +2,11 @@ import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; -import alice.datasegment.DataSegmentReceiver; +import alice.datasegment.Receiver; public class IncomingAbstractHostName extends CodeSegment { - public DataSegmentReceiver absName = ids.createReceiver(CommandType.PEEK); + public Receiver absName = ids.create(CommandType.PEEK); @Override public void run() {
--- a/src/alice/topology/node/IncomingConnectionInfo.java Tue Jan 17 20:49:26 2012 +0900 +++ b/src/alice/topology/node/IncomingConnectionInfo.java Wed Jan 18 01:34:23 2012 +0900 @@ -3,18 +3,16 @@ import java.io.IOException; import org.msgpack.MessagePack; -import org.msgpack.type.ValueFactory; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.DataSegment; -import alice.datasegment.DataSegmentManager; -import alice.datasegment.DataSegmentReceiver; +import alice.datasegment.Receiver; import alice.topology.HostMessage; public class IncomingConnectionInfo extends CodeSegment { - public DataSegmentReceiver hostInfo = ids.createReceiver(CommandType.TAKE); + public Receiver hostInfo = ids.create(CommandType.TAKE); private String absName; private int count;
--- a/src/alice/topology/node/IncomingReverseKey.java Tue Jan 17 20:49:26 2012 +0900 +++ b/src/alice/topology/node/IncomingReverseKey.java Wed Jan 18 01:34:23 2012 +0900 @@ -5,12 +5,12 @@ import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.DataSegment; -import alice.datasegment.DataSegmentReceiver; +import alice.datasegment.Receiver; public class IncomingReverseKey extends CodeSegment { - public DataSegmentReceiver reverseKey = ids.createReceiver(CommandType.TAKE); - public DataSegmentReceiver reverseCount = ids.createReceiver(CommandType.PEEK); + public Receiver reverseKey = ids.create(CommandType.TAKE); + public Receiver reverseCount = ids.create(CommandType.PEEK); @Override public void run() {