Mercurial > hg > Members > tatsuki > Alice
changeset 132:1044a79ce4ef working
delete cs from OutputCodeSegment
author | sugi |
---|---|
date | Tue, 14 Aug 2012 19:43:10 +0900 |
parents | 2b991e8b7fc0 |
children | 26b4b18c51fa |
files | src/alice/codesegment/CodeSegment.java src/alice/codesegment/OutputDataSegment.java src/alice/daemon/OutboundTcpConnection.java src/alice/datasegment/DataSegmentManager.java src/alice/datasegment/LocalDataSegmentManager.java src/alice/datasegment/RemoteDataSegmentManager.java src/alice/test/codesegment/local/TestCodeSegment.java src/alice/test/topology/fishmodel/alpha/AutoIncrement.java src/alice/test/topology/fishmodel/alpha/MakeFrame.java src/alice/test/topology/fishmodel/alpha/SendLocation.java src/alice/test/topology/fishmodel/beta/CheckMyName.java |
diffstat | 11 files changed, 50 insertions(+), 74 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/codesegment/CodeSegment.java Tue Aug 14 12:55:28 2012 +0900 +++ b/src/alice/codesegment/CodeSegment.java Tue Aug 14 19:43:10 2012 +0900 @@ -5,7 +5,7 @@ public abstract class CodeSegment implements Runnable { public InputDataSegment ids = new InputDataSegment(this); - public OutputDataSegment ods = new OutputDataSegment(this); + public OutputDataSegment ods = new OutputDataSegment(); public void execute() { ids.receive();
--- a/src/alice/codesegment/OutputDataSegment.java Tue Aug 14 12:55:28 2012 +0900 +++ b/src/alice/codesegment/OutputDataSegment.java Tue Aug 14 19:43:10 2012 +0900 @@ -10,48 +10,41 @@ public class OutputDataSegment { - public CodeSegment cs; - //private static MessagePack MSGPACK = new MessagePack(); - - public OutputDataSegment(CodeSegment codeSegment) { - this.cs = codeSegment; - } - public void put(String managerKey, String key, Value val) { - DataSegment.get(managerKey).put(key, val, cs); + DataSegment.get(managerKey).put(key, val); } public void update(String managerKey, String key, Value val) { - DataSegment.get(managerKey).update(key, val, cs); + DataSegment.get(managerKey).update(key, val); } public void put(String managerKey, String key, String val) { - DataSegment.get(managerKey).put(key, ValueFactory.createRawValue(val), cs); + DataSegment.get(managerKey).put(key, ValueFactory.createRawValue(val)); } public void update(String managerKey, String key, String val) { - DataSegment.get(managerKey).update(key, ValueFactory.createRawValue(val), cs); + DataSegment.get(managerKey).update(key, ValueFactory.createRawValue(val)); } public void put(String managerKey, String key, byte[] val) { - DataSegment.get(managerKey).put(key, ValueFactory.createRawValue(val, true), cs); + DataSegment.get(managerKey).put(key, ValueFactory.createRawValue(val, true)); } public void update(String managerKey, String key, byte[] val) { - DataSegment.get(managerKey).update(key, ValueFactory.createRawValue(val, true), cs); + DataSegment.get(managerKey).update(key, ValueFactory.createRawValue(val, true)); } public void put(String managerKey, String key, int val) { - DataSegment.get(managerKey).put(key, ValueFactory.createIntegerValue(val), cs); + DataSegment.get(managerKey).put(key, ValueFactory.createIntegerValue(val)); } public void update(String managerKey, String key, int val) { - DataSegment.get(managerKey).update(key, ValueFactory.createIntegerValue(val), cs); + DataSegment.get(managerKey).update(key, ValueFactory.createIntegerValue(val)); } public <T> void put(String managerKey, String key, T val) { try { - DataSegment.get(managerKey).put(key, SingletonMessage.getInstance().unconvert(val), cs); + DataSegment.get(managerKey).put(key, SingletonMessage.getInstance().unconvert(val)); } catch (IOException e) { e.printStackTrace(); } @@ -59,7 +52,7 @@ public <T> void update(String managerKey, String key, T val) { try { - DataSegment.get(managerKey).update(key, SingletonMessage.getInstance().unconvert(val), cs); + DataSegment.get(managerKey).update(key, SingletonMessage.getInstance().unconvert(val)); } catch (IOException e) { e.printStackTrace(); }
--- a/src/alice/daemon/OutboundTcpConnection.java Tue Aug 14 12:55:28 2012 +0900 +++ b/src/alice/daemon/OutboundTcpConnection.java Tue Aug 14 19:43:10 2012 +0900 @@ -3,14 +3,12 @@ import java.io.IOException; import java.nio.ByteBuffer; -import org.msgpack.MessagePack; - +import alice.codesegment.SingletonMessage; import alice.datasegment.Command; public class OutboundTcpConnection extends Thread { public Connection connection; - private static MessagePack MSGPACK = new MessagePack(); public OutboundTcpConnection(Connection connection) { this.connection = connection; @@ -38,7 +36,7 @@ break; } CommandMessage cmdMsg = convert(cmd); - ByteBuffer buffer = ByteBuffer.wrap(MSGPACK.write(cmdMsg)); + ByteBuffer buffer = ByteBuffer.wrap(SingletonMessage.getInstance().write(cmdMsg)); while (buffer.hasRemaining()) { connection.socket.getChannel().write(buffer); }
--- a/src/alice/datasegment/DataSegmentManager.java Tue Aug 14 12:55:28 2012 +0900 +++ b/src/alice/datasegment/DataSegmentManager.java Tue Aug 14 19:43:10 2012 +0900 @@ -47,8 +47,8 @@ } } - public abstract void put(String key, Value val, CodeSegment cs); - public abstract void update(String key, Value val, CodeSegment cs); + public abstract void put(String key, Value val); + public abstract void update(String key, Value val); public void take(Receiver receiver, String key, CodeSegment cs) { take(receiver, key, 0, cs); }
--- a/src/alice/datasegment/LocalDataSegmentManager.java Tue Aug 14 12:55:28 2012 +0900 +++ b/src/alice/datasegment/LocalDataSegmentManager.java Tue Aug 14 19:43:10 2012 +0900 @@ -60,9 +60,9 @@ } @Override - public void put(String key, Value val, CodeSegment cs) { + public void put(String key, Value val) { DataSegmentKey dataSegmentKey = getDataSegmentKey(key); - Command cmd = new Command(CommandType.PUT, null, key, val, 0, 0, replyQueue, cs, reverseKey); + Command cmd = new Command(CommandType.PUT, null, key, val, 0, 0, replyQueue, null, reverseKey); addCommand(dataSegmentKey, cmd); if (logger.isDebugEnabled()) logger.debug(cmd.getCommandString()); @@ -72,9 +72,9 @@ * Enqueue update command to the queue of each DataSegment key */ @Override - public void update(String key, Value val, CodeSegment cs) { + public void update(String key, Value val) { DataSegmentKey dataSegmentKey = getDataSegmentKey(key); - Command cmd = new Command(CommandType.UPDATE, null, key, val, 0, 0, replyQueue, cs, reverseKey); + Command cmd = new Command(CommandType.UPDATE, null, key, val, 0, 0, replyQueue, null, reverseKey); addCommand(dataSegmentKey, cmd); if (logger.isDebugEnabled()) logger.debug(cmd.getCommandString());
--- a/src/alice/datasegment/RemoteDataSegmentManager.java Tue Aug 14 12:55:28 2012 +0900 +++ b/src/alice/datasegment/RemoteDataSegmentManager.java Tue Aug 14 19:43:10 2012 +0900 @@ -50,16 +50,16 @@ * send put command to target DataSegment */ @Override - public void put(String key, Value val, CodeSegment cs) { - Command cmd = new Command(CommandType.PUT, null, key, val, 0, 0, null, cs, null); + public void put(String key, Value val) { + Command cmd = new Command(CommandType.PUT, null, key, val, 0, 0, null, null, null); connection.sendCommand(cmd); // put command on the transmission thread if (logger.isDebugEnabled()) logger.debug(cmd.getCommandString()); } @Override - public void update(String key, Value val, CodeSegment cs) { - Command cmd = new Command(CommandType.UPDATE, null, key, val, 0, 0, null, cs, null); + public void update(String key, Value val) { + Command cmd = new Command(CommandType.UPDATE, null, key, val, 0, 0, null, null, null); connection.sendCommand(cmd); if (logger.isDebugEnabled()) logger.debug(cmd.getCommandString());
--- a/src/alice/test/codesegment/local/TestCodeSegment.java Tue Aug 14 12:55:28 2012 +0900 +++ b/src/alice/test/codesegment/local/TestCodeSegment.java Tue Aug 14 19:43:10 2012 +0900 @@ -21,9 +21,9 @@ @Override public void run() { FishPoint fp = this.arg1.asClass(FishPoint.class); - System.out.println("index = " + arg1.index); + //System.out.println("index = " + arg1.index); System.out.println("data = " + arg1.val); - System.out.println(arg1.val.getType()); + //System.out.println(arg1.val.getType()); /* if (arg1.index == 10) { @@ -36,7 +36,7 @@ */ new TestCodeSegment(arg1.index); - + fp.setXYZ(fp.getX()+1.0f, fp.getY()+1.0f, fp.getZ()+1.0f); // DataSegment.get("local").update ods.update("local", "key1", fp);
--- a/src/alice/test/topology/fishmodel/alpha/AutoIncrement.java Tue Aug 14 12:55:28 2012 +0900 +++ b/src/alice/test/topology/fishmodel/alpha/AutoIncrement.java Tue Aug 14 19:43:10 2012 +0900 @@ -11,44 +11,37 @@ float max = 3.3f; float min = -1.3f; - - public AutoIncrement(String key,int index){ - + public AutoIncrement(String key){ this.key = key; this.position.setKey("local", key); - - } - - public void Init(){ - this.ods = null; - this.position = null; - } @Override - public synchronized void run() { - FishPoint FP = this.position.asClass(FishPoint.class); - - if (FP.getX()+0.01>max){ - FP.setXY(min, FP.getY()); - } else if (FP.getX()+0.01< min){ - FP.setXY(max, FP.getY()); + public void run() { + FishPoint fp = this.position.asClass(FishPoint.class); + if (fp.getX()+0.01>max){ + fp.setXY(min, fp.getY()); + } else if (fp.getX()+0.01< min){ + fp.setXY(max, fp.getY()); } else { - FP.setXY(FP.getX()+0.01f, FP.getY()); + fp.setXY(fp.getX()+0.01f, fp.getY()); } + ods.update("local", key, fp); + synchronized(this){ + try { + // TODO + // Waiting should be done in Alice kernel + // ids.create(CommandType.WAIT); + + wait(10); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } - ods.update("local", key, FP); - /* - try { - wait(100); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - */ - new AutoIncrement(this.key,this.position.index); + new AutoIncrement(this.key); } }
--- a/src/alice/test/topology/fishmodel/alpha/MakeFrame.java Tue Aug 14 12:55:28 2012 +0900 +++ b/src/alice/test/topology/fishmodel/alpha/MakeFrame.java Tue Aug 14 19:43:10 2012 +0900 @@ -28,7 +28,6 @@ int fSizeY = 800; private Canvas3D canvas; private SimpleUniverse universe; - private KeyInput key; private KeyInputCodeSegment kics; public MakeFrame(String str){ @@ -48,10 +47,7 @@ universe = new SimpleUniverse(canvas); universe.addBranchGraph(createLight()); universe.addBranchGraph(setBackground()); - /* - key = new KeyInput(); - canvas.addKeyListener(key); - */ + kics = new KeyInputCodeSegment(); canvas.addKeyListener(kics); frame.setVisible(true); @@ -103,10 +99,6 @@ return this.canvas; } - public KeyInput getKey(){ - return this.key; - } - public KeyInputCodeSegment getKeySegment(){ return this.kics; }
--- a/src/alice/test/topology/fishmodel/alpha/SendLocation.java Tue Aug 14 12:55:28 2012 +0900 +++ b/src/alice/test/topology/fishmodel/alpha/SendLocation.java Tue Aug 14 19:43:10 2012 +0900 @@ -25,7 +25,7 @@ fp.setXY(fp.getX()+this.x, fp.getY()+this.y); /* if (fp.getX()+this.x>max){ - FP.setXY(-1.0f, fp.getY()+this.y); + fp.setXY(-1.0f, fp.getY()+this.y); } else if (fp.getX()+this.x< min){ fp.setXY(max, fp.getY()+this.y); }
--- a/src/alice/test/topology/fishmodel/beta/CheckMyName.java Tue Aug 14 12:55:28 2012 +0900 +++ b/src/alice/test/topology/fishmodel/beta/CheckMyName.java Tue Aug 14 19:43:10 2012 +0900 @@ -72,7 +72,7 @@ for (int i = 0;i < 3 ; i++){ key = "fish"+i; - if (num == 0) new AutoIncrement(key,0); + if (num == 0) new AutoIncrement(key); ods.update("local", key, new FishPoint(0.2f*i,0.2f*i)); new SetLocation(new MakeObject(frame),key,0,num); new CheckLocalIndex(key,1);