annotate src/alice/test/topology/ring/FirstRingMessagePassing.java @ 46:1a498f436332

bug fix for time calculate
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Sat, 04 Feb 2012 16:03:05 +0900
parents ae24d5d40c10
children 5b6624b2f055
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 package alice.test.topology.ring;
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
45
ae24d5d40c10 add to calculate the time of RingTopology required
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 39
diff changeset
3 import java.util.Date;
39
3155337e754e add logger
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
4
30
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 import org.msgpack.type.ValueFactory;
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 import alice.codesegment.CodeSegment;
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 import alice.datasegment.CommandType;
33
20c67f673224 change name of DataSegmentReceiver
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
9 import alice.datasegment.Receiver;
30
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 public class FirstRingMessagePassing extends CodeSegment {
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12
45
ae24d5d40c10 add to calculate the time of RingTopology required
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 39
diff changeset
13 public Receiver counter = ids.create(CommandType.TAKE);
46
1a498f436332 bug fix for time calculate
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
14 private Date startTime;
1a498f436332 bug fix for time calculate
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
15 private int count;
45
ae24d5d40c10 add to calculate the time of RingTopology required
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 39
diff changeset
16
46
1a498f436332 bug fix for time calculate
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
17 public FirstRingMessagePassing(Date startTime, int count) {
45
ae24d5d40c10 add to calculate the time of RingTopology required
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 39
diff changeset
18 this.startTime = startTime;
46
1a498f436332 bug fix for time calculate
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
19 this.count = count;
45
ae24d5d40c10 add to calculate the time of RingTopology required
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 39
diff changeset
20 }
30
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 @Override
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 public void run() {
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 int counter = this.counter.asInteger();
45
ae24d5d40c10 add to calculate the time of RingTopology required
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 39
diff changeset
25 ++counter;
30
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 ods.put("right", "counter", counter);
46
1a498f436332 bug fix for time calculate
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
27 System.out.println(count);
1a498f436332 bug fix for time calculate
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
28 if (counter >= count) {
30
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 ods.put("right", "finish", ValueFactory.createNilValue());
45
ae24d5d40c10 add to calculate the time of RingTopology required
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 39
diff changeset
30 Date endTime = new Date();
ae24d5d40c10 add to calculate the time of RingTopology required
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 39
diff changeset
31 long time = endTime.getTime() - startTime.getTime();
ae24d5d40c10 add to calculate the time of RingTopology required
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 39
diff changeset
32 System.out.println(time);
30
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 return;
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 }
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35
46
1a498f436332 bug fix for time calculate
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
36 FirstRingMessagePassing cs = new FirstRingMessagePassing(startTime, count);
30
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 cs.counter.setKey("local", "counter");
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 }
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 }