Mercurial > hg > Members > tatsuki > Alice
changeset 128:9db7fcf98ee9 working
add ApiTest take
author | sugi |
---|---|
date | Mon, 06 Aug 2012 17:35:45 +0900 |
parents | 117dad267a9b |
children | b93a1c0a4dc7 |
files | src/alice/test/codesegment/api/PutCodeSegment.java src/alice/test/codesegment/api/StartCodeSegment.java src/alice/test/codesegment/api/TakeCodeSegment.java |
diffstat | 3 files changed, 48 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- 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(); }
--- 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); + } }
--- /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(); + + } +}