Mercurial > hg > Database > Alice
changeset 548:b44a2bf16eb3 dispose
add IDS ODS constructor & work TestLocalAlice
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 25 Aug 2015 19:54:30 +0900 |
parents | e91a574b69de |
children | 9f577ff4f7ea |
files | src/main/java/alice/codesegment/CodeSegment.java src/main/java/alice/codesegment/CodeSegmentManager.java src/main/java/alice/codesegment/InputDataSegment.java src/main/java/alice/codesegment/OutputDataSegment.java src/main/java/alice/datasegment/DataSegment.java src/main/java/alice/test/codesegment/local/StartCodeSegment.java src/main/java/alice/test/codesegment/local/TestCodeSegment.java |
diffstat | 7 files changed, 22 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/alice/codesegment/CodeSegment.java Tue Aug 18 16:15:17 2015 +0900 +++ b/src/main/java/alice/codesegment/CodeSegment.java Tue Aug 25 19:54:30 2015 +0900 @@ -8,8 +8,8 @@ public abstract class CodeSegment implements Runnable { - public InputDataSegment ids = new InputDataSegment(); - public OutputDataSegment ods = new OutputDataSegment(); + public InputDataSegment ids = new InputDataSegment(this); + public OutputDataSegment ods = new OutputDataSegment(this); public AliceDaemon aliceDaemon; private ArrayList<Receiver> list = new ArrayList<Receiver>(); private int priority = Thread.NORM_PRIORITY;//?
--- a/src/main/java/alice/codesegment/CodeSegmentManager.java Tue Aug 18 16:15:17 2015 +0900 +++ b/src/main/java/alice/codesegment/CodeSegmentManager.java Tue Aug 25 19:54:30 2015 +0900 @@ -43,6 +43,8 @@ } else { csManager.codeSegmentExecutor.setThreadFactory(csManager.maxPriority); } + cs.ods.alice = alice; + cs.ids.alice = alice; csManager.codeSegmentExecutor.execute(cs); if (csManager.logger.isDebugEnabled()) { csManager.logger.debug(cs.getClass().getName());
--- a/src/main/java/alice/codesegment/InputDataSegment.java Tue Aug 18 16:15:17 2015 +0900 +++ b/src/main/java/alice/codesegment/InputDataSegment.java Tue Aug 25 19:54:30 2015 +0900 @@ -21,12 +21,17 @@ private AtomicInteger count = new AtomicInteger(1); // 1 for no input data segments private AtomicInteger keyCount = new AtomicInteger(0); // number of DataSegments private CodeSegment cs; - private AliceDaemon alice; + public AliceDaemon alice; + + public InputDataSegment(CodeSegment cs){ + this.cs = cs; + } public void setAliceDaemon(CodeSegment cs){ - this.cs = cs; this.alice = cs.getAliceDaemon(); + this.cs.aliceDaemon = this.alice; } + public void init(){ count = new AtomicInteger(1); keyCount = new AtomicInteger(0);
--- a/src/main/java/alice/codesegment/OutputDataSegment.java Tue Aug 18 16:15:17 2015 +0900 +++ b/src/main/java/alice/codesegment/OutputDataSegment.java Tue Aug 25 19:54:30 2015 +0900 @@ -1,20 +1,20 @@ package alice.codesegment; import alice.daemon.AliceDaemon; -import alice.datasegment.CommandType; -import alice.datasegment.DataSegment; -import alice.datasegment.ReceiveData; -import alice.datasegment.Receiver; -import alice.datasegment.SendOption; +import alice.datasegment.*; public class OutputDataSegment { private CodeSegment cs; - private AliceDaemon alice; + public AliceDaemon alice; + + public OutputDataSegment(CodeSegment cs){ + this.cs = cs; + } public void setAliceDaemon(CodeSegment cs){ - this.cs = cs; this.alice = cs.getAliceDaemon(); + this.cs.aliceDaemon = this.alice; } /** @@ -104,7 +104,8 @@ public void update(String managerKey, String key, Object val) { ReceiveData rData = new ReceiveData(val); - alice.dataSegment.get(managerKey).update(key, rData, false); + DataSegmentManager manager = alice.dataSegment.get(managerKey); + manager.update(key, rData, false); } public void quickUpdate(String managerKey, String key, ReceiveData rData) {
--- a/src/main/java/alice/datasegment/DataSegment.java Tue Aug 18 16:15:17 2015 +0900 +++ b/src/main/java/alice/datasegment/DataSegment.java Tue Aug 25 19:54:30 2015 +0900 @@ -10,7 +10,6 @@ public class DataSegment { private final AliceDaemon alice; - //private static DataSegment dataSegment = new DataSegment();//ToDo: static消す private LocalDataSegmentManager local = new LocalDataSegmentManager(); private CompressedLocalDataSegmentManager compressedLocal = new CompressedLocalDataSegmentManager(local);//追加 private ConcurrentHashMap<String, DataSegmentManager> dataSegmentManagers = new ConcurrentHashMap<String, DataSegmentManager>(); //TODO Over Head
--- a/src/main/java/alice/test/codesegment/local/StartCodeSegment.java Tue Aug 18 16:15:17 2015 +0900 +++ b/src/main/java/alice/test/codesegment/local/StartCodeSegment.java Tue Aug 25 19:54:30 2015 +0900 @@ -9,12 +9,12 @@ System.out.println("run StartCodeSegment"); TestCodeSegment cs = new TestCodeSegment(); - ods.update("local", "key1", 0); + cs.arg1.setKey("key1", this); // unbound datasegment key1 is created and connect to cs. // cs is waiting for local.key1 System.out.println("create TestCodeSegment"); - // ods.update("local", "key1", "String data"); // bind string data to datasegment local.key1 + ods.update("local", "key1", 0); // bind string data to datasegment local.key1 // this startup TestCodeSegment. }
--- a/src/main/java/alice/test/codesegment/local/TestCodeSegment.java Tue Aug 18 16:15:17 2015 +0900 +++ b/src/main/java/alice/test/codesegment/local/TestCodeSegment.java Tue Aug 25 19:54:30 2015 +0900 @@ -15,10 +15,8 @@ public void run() { System.out.println("in TestCodeSegment"); System.out.println("type = " + arg1.type); - //System.out.println("index = " + arg1.index); int num = arg1.asInteger(); System.out.println("data = " + num); - System.out.println(((Value)arg1.getVal()).getType());//←伝統。なくてもいい。 if (num++ == 10) { System.exit(0); @@ -26,7 +24,6 @@ } TestCodeSegment cs = new TestCodeSegment(); - //cs.ids.setAliceDaemon(this); cs.arg1.setKey("key1", this);//Receiverに値をpeekしてくる // DataSegment.get("local").update