annotate src/main/java/alice/test/topology/ring/FirstRingMessagePassing.java @ 345:8f71c3e6f11d

Change directory structure Maven standard
author sugi
date Wed, 16 Apr 2014 18:26:07 +0900
parents
children aefbe41fcf12
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
345
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
1 package alice.test.topology.ring;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
2
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
3 import org.msgpack.type.ValueFactory;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
4
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
5 import alice.codesegment.CodeSegment;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
6 import alice.datasegment.CommandType;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
7 import alice.datasegment.Receiver;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
8
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
9 public class FirstRingMessagePassing extends CodeSegment {
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
10
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
11 public Receiver ds1 = ids.create(CommandType.TAKE);
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
12 private long startTime;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
13 private int count;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
14 private int nodeNum;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
15
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
16 public FirstRingMessagePassing(long startTime, int count, int nodeNum) {
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
17 this.startTime = startTime;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
18 this.count = count;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
19 this.nodeNum = nodeNum;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
20 }
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
21
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
22 public FirstRingMessagePassing(int count, int nodeNum) { // at first
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
23 this.startTime = System.nanoTime();
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
24 this.count = count;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
25 this.nodeNum = nodeNum;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
26 }
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
27
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
28 @Override
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
29 public void run() {
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
30 ods.put("right", "c", ds1.getVal()); // copy whole DataSegment to the right
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
31 if (ds1.index > count) { // after count time update of ds1
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
32 ods.put("right", "finish", ValueFactory.createNilValue());
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
33 long endTime = System.nanoTime();
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
34 long time = endTime - startTime;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
35 System.out.println(nodeNum + " " + time / count / 1000000.0);
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
36 return;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
37 }
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
38
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
39 FirstRingMessagePassing cs = new FirstRingMessagePassing(startTime, count, nodeNum);
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
40 cs.ds1.setKey("c");
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
41 }
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
42
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
43 }