comparison 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 (2014-04-16)
parents
children aefbe41fcf12
comparison
equal deleted inserted replaced
344:9f97ec18f8c5 345:8f71c3e6f11d
1 package alice.test.topology.ring;
2
3 import org.msgpack.type.ValueFactory;
4
5 import alice.codesegment.CodeSegment;
6 import alice.datasegment.CommandType;
7 import alice.datasegment.Receiver;
8
9 public class FirstRingMessagePassing extends CodeSegment {
10
11 public Receiver ds1 = ids.create(CommandType.TAKE);
12 private long startTime;
13 private int count;
14 private int nodeNum;
15
16 public FirstRingMessagePassing(long startTime, int count, int nodeNum) {
17 this.startTime = startTime;
18 this.count = count;
19 this.nodeNum = nodeNum;
20 }
21
22 public FirstRingMessagePassing(int count, int nodeNum) { // at first
23 this.startTime = System.nanoTime();
24 this.count = count;
25 this.nodeNum = nodeNum;
26 }
27
28 @Override
29 public void run() {
30 ods.put("right", "c", ds1.getVal()); // copy whole DataSegment to the right
31 if (ds1.index > count) { // after count time update of ds1
32 ods.put("right", "finish", ValueFactory.createNilValue());
33 long endTime = System.nanoTime();
34 long time = endTime - startTime;
35 System.out.println(nodeNum + " " + time / count / 1000000.0);
36 return;
37 }
38
39 FirstRingMessagePassing cs = new FirstRingMessagePassing(startTime, count, nodeNum);
40 cs.ds1.setKey("c");
41 }
42
43 }