# HG changeset patch # User sugi # Date 1344242145 -32400 # Node ID 9db7fcf98ee95d5c3a06ce05ff366fec31b61a3a # Parent 117dad267a9bffef07811164a37268da19b5562b add ApiTest take diff -r 117dad267a9b -r 9db7fcf98ee9 src/alice/test/codesegment/api/PutCodeSegment.java --- a/src/alice/test/codesegment/api/PutCodeSegment.java Mon Aug 06 16:19:38 2012 +0900 +++ b/src/alice/test/codesegment/api/PutCodeSegment.java Mon Aug 06 17:35:45 2012 +0900 @@ -1,35 +1,31 @@ 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); - } + private static int count = 0; @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) + public synchronized void run() { + + int[] array = new int[1000]; + for (int i = 0;i< 999; i++) + array[i] = i; + + if (count % 10 == 0) System.out.println((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024 + "MB"); - if (val >= 10000000) { + if (count >= 10000000) { System.exit(0); } - array[0] = ValueFactory.createIntegerValue(val + 1); - System.out.println(array[0]); - ods.put("local", this.key, array); + ods.put("local", "num", array); + count++; + try { + wait(100); + } catch (InterruptedException e) { + e.printStackTrace(); + } + new PutCodeSegment().execute(); } diff -r 117dad267a9b -r 9db7fcf98ee9 src/alice/test/codesegment/api/StartCodeSegment.java --- a/src/alice/test/codesegment/api/StartCodeSegment.java Mon Aug 06 16:19:38 2012 +0900 +++ b/src/alice/test/codesegment/api/StartCodeSegment.java Mon Aug 06 17:35:45 2012 +0900 @@ -15,14 +15,22 @@ if ("-update".equals(args[i])){ UpdateCodeSegment cs1 = new UpdateCodeSegment(); cs1.ds1.setKey("key"); + int[] array = new int[65536]; + array[0] = 0; + ods.update("local", "key", array); + } else if ("-put".equals(args[i])){ - new PutCodeSegment("key",0); + new PutCodeSegment().execute(); + + } else if ("-take".equals(args[i])){ + new PutCodeSegment().execute(); + new TakeCodeSegment(); + } + } - int[] array = new int[65536]; - array[0] = 0; - ods.update("local", "key", array); + } } diff -r 117dad267a9b -r 9db7fcf98ee9 src/alice/test/codesegment/api/TakeCodeSegment.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/codesegment/api/TakeCodeSegment.java Mon Aug 06 17:35:45 2012 +0900 @@ -0,0 +1,19 @@ +package alice.test.codesegment.api; + +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; + +public class TakeCodeSegment extends CodeSegment { + + Receiver ds1 = ids.create(CommandType.TAKE); + + public TakeCodeSegment(){ + this.ds1.setKey("num"); + } + @Override + public void run() { + new TakeCodeSegment(); + + } +}