changeset 127:117dad267a9b working

add apiTest put
author sugi
date Mon, 06 Aug 2012 16:19:38 +0900
parents 669dba7cbb69
children 9db7fcf98ee9
files src/alice/daemon/IncomingTcpConnection.java src/alice/test/codesegment/api/PutCodeSegment.java src/alice/test/codesegment/api/StartCodeSegment.java src/alice/test/codesegment/api/TestApiAlice.java src/alice/test/topology/fishmodel/alpha/MakeFrame.java src/alice/test/topology/fishmodel/alpha/SendLocation.java src/alice/test/topology/fishmodel/alpha/SetLocation.java
diffstat 7 files changed, 70 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/alice/daemon/IncomingTcpConnection.java	Fri Aug 03 19:14:46 2012 +0900
+++ b/src/alice/daemon/IncomingTcpConnection.java	Mon Aug 06 16:19:38 2012 +0900
@@ -21,7 +21,7 @@
 	public Connection connection;
 	public DataSegmentManager manager;
 	public String reverseKey;
-	private LocalDataSegmentManager lmanager = DataSegment.getLocal();;
+	private LocalDataSegmentManager lmanager = DataSegment.getLocal();
 
 	public IncomingTcpConnection(Connection connection, DataSegmentManager manager, String reverseKey) {
 		this.manager = manager;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/alice/test/codesegment/api/PutCodeSegment.java	Mon Aug 06 16:19:38 2012 +0900
@@ -0,0 +1,36 @@
+package alice.test.codesegment.api;
+
+import org.msgpack.type.Value;
+import org.msgpack.type.ValueFactory;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class PutCodeSegment extends CodeSegment{
+	
+	Receiver ds1 = ids.create(CommandType.PEEK);
+	String key;
+	
+	public PutCodeSegment(String key, int index){
+		this.key = key;
+		this.ds1.setKey(key, index);
+	}
+	
+	@Override
+	public void run() {
+		new PutCodeSegment(this.key, this.ds1.index);
+		Value[] array = ds1.val.asArrayValue().getElementArray();
+		int val = array[0].asIntegerValue().getInt();
+		if (val % 10 == 0)
+			System.out.println((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024 + "MB");
+		if (val >= 10000000) {
+			System.exit(0);
+		}
+		array[0] = ValueFactory.createIntegerValue(val + 1);
+		System.out.println(array[0]);
+		ods.put("local", this.key, array);
+	}
+	
+
+}
--- a/src/alice/test/codesegment/api/StartCodeSegment.java	Fri Aug 03 19:14:46 2012 +0900
+++ b/src/alice/test/codesegment/api/StartCodeSegment.java	Mon Aug 06 16:19:38 2012 +0900
@@ -3,11 +3,23 @@
 import alice.codesegment.CodeSegment;
 
 public class StartCodeSegment extends CodeSegment {
+	String[] args;
+	
+	public StartCodeSegment(String[] args){
+		this.args = args;
+	}
 
 	@Override
 	public void run() {
-		UpdateCodeSegment cs1 = new UpdateCodeSegment();
-		cs1.ds1.setKey("key");
+		for (int i = 0;i<args.length;i++){
+			if ("-update".equals(args[i])){
+				UpdateCodeSegment cs1 = new UpdateCodeSegment();
+				cs1.ds1.setKey("key");
+			} else if ("-put".equals(args[i])){
+				new PutCodeSegment("key",0);
+			}
+			
+		}
 		int[] array = new int[65536];
 		array[0] = 0;
 		ods.update("local", "key", array);  
--- a/src/alice/test/codesegment/api/TestApiAlice.java	Fri Aug 03 19:14:46 2012 +0900
+++ b/src/alice/test/codesegment/api/TestApiAlice.java	Mon Aug 06 16:19:38 2012 +0900
@@ -6,7 +6,7 @@
 	 * @param args
 	 */
 	public static void main(String[] args) {
-		new StartCodeSegment().execute();
+		new StartCodeSegment(args).execute();
 	}
 
 }
--- a/src/alice/test/topology/fishmodel/alpha/MakeFrame.java	Fri Aug 03 19:14:46 2012 +0900
+++ b/src/alice/test/topology/fishmodel/alpha/MakeFrame.java	Mon Aug 06 16:19:38 2012 +0900
@@ -29,7 +29,7 @@
 	private Canvas3D canvas;
 	private SimpleUniverse universe;
 	private KeyInput key;
-	private KeyInputCodeSegment KIC;
+	private KeyInputCodeSegment kics;
 	
 	public MakeFrame(String str){
 		JFrame frame = new JFrame(str);
@@ -52,8 +52,8 @@
 		key = new KeyInput();
 		canvas.addKeyListener(key);
 		*/
-		KIC = new KeyInputCodeSegment();
-		canvas.addKeyListener(KIC);
+		kics = new KeyInputCodeSegment();
+		canvas.addKeyListener(kics);
 		frame.setVisible(true);
 		
 		ViewingPlatform camera = universe.getViewingPlatform();
@@ -108,7 +108,7 @@
 	}
 	
 	public KeyInputCodeSegment getKeySegment(){
-		return this.KIC;
+		return this.kics;
 	}
 
 }
--- a/src/alice/test/topology/fishmodel/alpha/SendLocation.java	Fri Aug 03 19:14:46 2012 +0900
+++ b/src/alice/test/topology/fishmodel/alpha/SendLocation.java	Mon Aug 06 16:19:38 2012 +0900
@@ -20,21 +20,21 @@
 	
 	@Override
 	public void run() {
-		FishPoint FP = this.position.asClass(FishPoint.class);
+		FishPoint fp = this.position.asClass(FishPoint.class);
 		
-		FP.setXY(FP.getX()+this.x, FP.getY()+this.y);
+		fp.setXY(fp.getX()+this.x, fp.getY()+this.y);
 		/*
-		if (FP.getX()+this.x>max){
-			FP.setXY(-1.0f, FP.getY()+this.y);
-		} else if (FP.getX()+this.x< min){
-			FP.setXY(max, FP.getY()+this.y);
+		if (fp.getX()+this.x>max){
+			FP.setXY(-1.0f, fp.getY()+this.y);
+		} else if (fp.getX()+this.x< min){
+			fp.setXY(max, fp.getY()+this.y);
 		}
 		else {
-			FP.setXY(FP.getX()+this.x, FP.getY()+this.y);
+			fp.setXY(fp.getX()+this.x, fp.getY()+this.y);
 		}
 		*/
 		
-		ods.update("local", "fish", FP);
+		ods.update("local", "fish", fp);
 		
 	}
 
--- a/src/alice/test/topology/fishmodel/alpha/SetLocation.java	Fri Aug 03 19:14:46 2012 +0900
+++ b/src/alice/test/topology/fishmodel/alpha/SetLocation.java	Mon Aug 06 16:19:38 2012 +0900
@@ -13,8 +13,8 @@
 	String vector;
 	int range;
 	
-	public SetLocation(MakeObject MO ,String key,int index,int range){
-		this.obj = MO;
+	public SetLocation(MakeObject obj ,String key,int index,int range){
+		this.obj = obj;
 		this.key = key;
 		this.range = range;
 		this.position.setKey("local",key,index);
@@ -23,13 +23,13 @@
 	@Override
 	public void run(){
 		
-		FishPoint FP = this.position.asClass(FishPoint.class);
-		//obj.setLocation(FP.getX() - 2*range, FP.getY());
+		FishPoint fp = this.position.asClass(FishPoint.class);
+		//obj.setLocation(fp.getX() - 2*range, fp.getY());
 		
 		float startX = 2*range - 1.5f;
 		float endX = 2*range + 1.5f;
-		if (startX <= FP.getX() && FP.getX() < endX)
-			obj.setLocation(FP.getX() - 2*range, FP.getY());
+		if (startX <= fp.getX() && fp.getX() < endX)
+			obj.setLocation(fp.getX() - 2*range, fp.getY());
 		
 		new SetLocation(this.obj,this.key,this.position.index,this.range);