Mercurial > hg > Members > tatsuki > Alice
changeset 17:bb075e103cd3
bug fix for take()
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 15 Jan 2012 15:18:01 +0900 |
parents | 433e601a8e28 |
children | 72dd27d952b0 |
files | build.xml src/alice/daemon/IncomingTcpConnection.java src/alice/datasegment/DataSegmentKey.java src/alice/datasegment/SocketDataSegmentManager.java src/alice/test/codesegment/TestRemoteAlice.java |
diffstat | 5 files changed, 14 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- a/build.xml Sun Jan 15 12:17:30 2012 +0900 +++ b/build.xml Sun Jan 15 15:18:01 2012 +0900 @@ -20,6 +20,7 @@ <target name="jar" depends="compile"> <jar jarfile="${jar}" basedir="${classes}"> <zipgroupfileset dir="lib" includes="*.jar" /> + <fileset dir="src" includes="log4j.xml" /> </jar> </target>
--- a/src/alice/daemon/IncomingTcpConnection.java Sun Jan 15 12:17:30 2012 +0900 +++ b/src/alice/daemon/IncomingTcpConnection.java Sun Jan 15 15:18:01 2012 +0900 @@ -47,7 +47,6 @@ msgBuf.flip(); CommandMessage msg = msgpack.read(msgBuf, CommandMessage.class); msgBuf.flip(); - System.out.println(msgpack.read(msgBuf)); CommandType type = CommandType.getCommandTypeFromId(msg.type); LocalDataSegmentManager lmanager = (LocalDataSegmentManager)DataSegment.get("local"); DataSegmentKey dsKey = lmanager.getDataSegmentKey(msg.key);
--- a/src/alice/datasegment/DataSegmentKey.java Sun Jan 15 12:17:30 2012 +0900 +++ b/src/alice/datasegment/DataSegmentKey.java Sun Jan 15 15:18:01 2012 +0900 @@ -1,6 +1,7 @@ package alice.datasegment; import java.util.ArrayList; +import java.util.Iterator; import java.util.LinkedList; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.atomic.AtomicInteger; @@ -40,19 +41,18 @@ DataSegmentValue dsv = new DataSegmentValue(index, cmd.val); dataList.add(dsv); // run waiting peek and take - LinkedList<Command> removeList = new LinkedList<Command>(); - for (Command waitCmd : waitList) { + boolean takeFlag = true; + for (Iterator<Command> iter = waitList.iterator(); iter.hasNext() && takeFlag; ) { + Command waitCmd = iter.next(); if (waitCmd.index < index) { waitCmd.replyQueue.put(new Command(CommandType.REPLY, null, null, cmd.val, index, waitCmd.seq, null, null)); - removeList.add(waitCmd); + iter.remove(); if (waitCmd.type == CommandType.TAKE) { // delete data, if it run take cmd. dataList.remove(dsv); break; } } - } - for (Command rmCmd : removeList) { - waitList.remove(rmCmd); + } break; case PEEK: @@ -73,14 +73,18 @@ waitList.add(cmd); break; } - for (DataSegmentValue data : dataList) { + boolean waitFlag = true; + for (Iterator<DataSegmentValue> iter = dataList.iterator(); iter.hasNext(); ) { + DataSegmentValue data = iter.next(); if (data.index > cmd.index) { cmd.replyQueue.put(new Command(CommandType.REPLY, null, null, data.val, data.index, cmd.seq, null, null)); - dataList.remove(data); + iter.remove(); + waitFlag = false; break; } } - waitList.add(cmd); + if (waitFlag) + waitList.add(cmd); break; case REMOVE: // TODO: implements later
--- a/src/alice/datasegment/SocketDataSegmentManager.java Sun Jan 15 12:17:30 2012 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -package alice.datasegment; - -import org.msgpack.type.Value; - -import alice.codesegment.CodeSegment; - -public class SocketDataSegmentManager extends DataSegmentManager { - - @Override - public void put(String key, Value val) { - // TODO Auto-generated method stub - - } - - @Override - public void update(String key, Value val) { - // TODO Auto-generated method stub - - } - - @Override - public void take(String argKey, String key, int index, CodeSegment cs) { - // TODO Auto-generated method stub - - } - - @Override - public void peek(String argKey, String key, int index, CodeSegment cs) { - // TODO Auto-generated method stub - - } - - @Override - public void remove(String key) { - // TODO Auto-generated method stub - - } - -}
--- a/src/alice/test/codesegment/TestRemoteAlice.java Sun Jan 15 12:17:30 2012 +0900 +++ b/src/alice/test/codesegment/TestRemoteAlice.java Sun Jan 15 15:18:01 2012 +0900 @@ -2,7 +2,6 @@ import java.io.IOException; import java.net.InetSocketAddress; -import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; import alice.codesegment.CodeSegment; @@ -16,10 +15,6 @@ public static void main(String[] args) { Config conf = new Config(args); - System.out.println(conf.port); - System.out.println(conf.hostname); - System.out.println(conf.connectPort); - System.out.println(conf.key); final AliceDaemon daemon = new AliceDaemon(conf); new Thread() {