Mercurial > hg > Database > Alice
changeset 209:96110f25adcc working
add new flip API
author | sugi |
---|---|
date | Tue, 26 Mar 2013 17:10:38 +0900 |
parents | a645cece5edc |
children | 214a13d5ee31 |
files | src/alice/codesegment/InputDataSegment.java src/alice/codesegment/OutputDataSegment.java src/alice/datasegment/DataSegmentManager.java src/alice/datasegment/LocalDataSegmentManager.java src/alice/datasegment/Receiver.java |
diffstat | 5 files changed, 58 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/codesegment/InputDataSegment.java Tue Mar 26 17:08:32 2013 +0900 +++ b/src/alice/codesegment/InputDataSegment.java Tue Mar 26 17:10:38 2013 +0900 @@ -5,7 +5,6 @@ import alice.datasegment.Command; import alice.datasegment.CommandType; import alice.datasegment.DataSegment; -import alice.datasegment.DataSegmentValue; import alice.datasegment.Receiver; /** @@ -60,11 +59,11 @@ DataSegment.getLocal().flip(cmd); } - public void reply(Receiver receiver, DataSegmentValue val, Command reply) { - receiver.index = val.index; - receiver.val = val.val; - receiver.from = val.from; - receiver.obj = val.obj; + public void reply(Receiver receiver, Command reply) { + receiver.index = reply.index; + receiver.val = reply.val; + receiver.from = reply.reverseKey; + receiver.obj = reply.obj; receiver.setCommand(reply); receive(); }
--- a/src/alice/codesegment/OutputDataSegment.java Tue Mar 26 17:08:32 2013 +0900 +++ b/src/alice/codesegment/OutputDataSegment.java Tue Mar 26 17:10:38 2013 +0900 @@ -7,6 +7,7 @@ import org.msgpack.type.ValueFactory; import alice.datasegment.DataSegment; +import alice.datasegment.Receiver; public class OutputDataSegment { @@ -53,6 +54,15 @@ } } + public void put(Receiver receiver, String key, Object obj, boolean flag) { + DataSegment.getLocal().put(receiver, key, obj); + } + + public void update(Receiver receiver, String key, Object obj, boolean flag) { + DataSegment.getLocal().update(receiver, key, obj); + } + + public void update(String key, Value val) { DataSegment.getLocal().update(key, val); } @@ -152,4 +162,6 @@ DataSegment.get(managerKey).close(); } + + }
--- a/src/alice/datasegment/DataSegmentManager.java Tue Mar 26 17:08:32 2013 +0900 +++ b/src/alice/datasegment/DataSegmentManager.java Tue Mar 26 17:10:38 2013 +0900 @@ -28,7 +28,7 @@ continue; } seqHash.remove(reply.seq); - cmd.cs.ids.reply(cmd.receiver, new DataSegmentValue(reply.index, reply.val, reply.obj, reply.reverseKey), reply); + cmd.cs.ids.reply(cmd.receiver, reply); if (logger.isDebugEnabled()) logger.debug(reply.getCommandString() + " " + cmd.getCommandString()); } catch (InterruptedException e) {
--- a/src/alice/datasegment/LocalDataSegmentManager.java Tue Mar 26 17:08:32 2013 +0900 +++ b/src/alice/datasegment/LocalDataSegmentManager.java Tue Mar 26 17:10:38 2013 +0900 @@ -136,14 +136,6 @@ } - - public void flip(String key, Object val,CommandType type) { - DataSegmentKey dataSegmentKey = getDataSegmentKey(key); - Command cmd = new Command(type, null, key, val, 0, 0, null, null, reverseKey); - addCommand(dataSegmentKey, cmd); - if (logger.isDebugEnabled()) - logger.debug(cmd.getCommandString()); - } public void flip(Command cmd){ DataSegmentKey dataSegmentKey = getDataSegmentKey(cmd.key); @@ -152,4 +144,40 @@ logger.debug(cmd.getCommandString()); } + public void put(Command cmd){ + DataSegmentKey dataSegmentKey = getDataSegmentKey(cmd.key); + addCommand(dataSegmentKey, cmd); + if (logger.isDebugEnabled()) + logger.debug(cmd.getCommandString()); + } + + public void update(Command cmd){ + DataSegmentKey dataSegmentKey = getDataSegmentKey(cmd.key); + addCommand(dataSegmentKey, cmd); + if (logger.isDebugEnabled()) + logger.debug(cmd.getCommandString()); + } + + + + public void put(Receiver receiver, String key, Object obj) { + DataSegmentKey dataSegmentKey = getDataSegmentKey(key); + Command cmd = receiver.getCommand(); + cmd.setElement(CommandType.PUT, key, null, obj); + addCommand(dataSegmentKey, cmd); + if (logger.isDebugEnabled()) + logger.debug(cmd.getCommandString()); + + } + + public void update(Receiver receiver, String key, Object obj) { + DataSegmentKey dataSegmentKey = getDataSegmentKey(key); + Command cmd = receiver.getCommand(); + cmd.setElement(CommandType.UPDATE, key, null, obj); + addCommand(dataSegmentKey, cmd); + if (logger.isDebugEnabled()) + logger.debug(cmd.getCommandString()); + + } + }