comparison src/alice/test/topology/aquarium/CheckMyName.java @ 217:b5c642ba998e working

change as** method and remove "local" key in TEST
author sugi
date Wed, 27 Mar 2013 20:02:38 +0900
parents b5daccf36104
children 7f7b3506bff9
comparison
equal deleted inserted replaced
216:21bd8af1cf26 217:b5c642ba998e
13 private Receiver host = ids.create(CommandType.PEEK); 13 private Receiver host = ids.create(CommandType.PEEK);
14 private Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$"); 14 private Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$");
15 private String key = "fish"; 15 private String key = "fish";
16 16
17 public CheckMyName(){ 17 public CheckMyName(){
18 host.setKey("local","host"); 18 host.setKey("host");
19 } 19 }
20 20
21 @Override 21 @Override
22 public void run(){ 22 public void run(){
23 23
24 String name = host.data.asString(host); 24 String name = host.asString();
25 Matcher matcher = pattern.matcher(name); 25 Matcher matcher = pattern.matcher(name);
26 26
27 matcher.find(); 27 matcher.find();
28 String type = matcher.group(1); 28 String type = matcher.group(1);
29 int num = new Integer(matcher.group(2)); 29 int num = new Integer(matcher.group(2));
30 ods.put("local", "host_num", num*2); 30 ods.put("host_num", num*2);
31 MakeFrame frame = new MakeFrame(name,num*2); 31 MakeFrame frame = new MakeFrame(name,num*2);
32 RoutingTable routing = new RoutingTable(); 32 RoutingTable routing = new RoutingTable();
33 ods.put("local", "num", 1); 33 ods.put("num", 1);
34 34
35 if (type.equals("cli")){ 35 if (type.equals("cli")){
36 System.out.println("cli"+num); 36 System.out.println("cli"+num);
37 routing.table.add(new Routing("parent")); 37 routing.table.add(new Routing("parent"));
38 ods.put("local", "list", routing); 38 ods.put("list", routing);
39 39
40 new AddRoutingTable(routing,0); 40 new AddRoutingTable(routing,0);
41 ods.put("parent", "member", name); 41 ods.put("parent", "member", name);
42 new TakeMynum(); 42 new TakeMynum();
43 43
49 new TakeMynum(); 49 new TakeMynum();
50 50
51 } else { 51 } else {
52 new SendMaxsize(0); 52 new SendMaxsize(0);
53 } 53 }
54 ods.put("local", "list", routing); 54 ods.put("list", routing);
55 new AddRoutingTable(routing,0); 55 new AddRoutingTable(routing,0);
56 56
57 } 57 }
58 new CheckLocalIndex("maxsize",0); 58 new CheckLocalIndex("maxsize",0);
59 59
60 ods.update("local", key, new FishPoint(-0.1f,-0.1f)); 60 ods.update(key, new FishPoint(-0.1f,-0.1f));
61 new SetLocation(new MakeObject(frame), key, 0, num); 61 new SetLocation(new MakeObject(frame), key, 0, num);
62 new CheckLocalIndex(key,1); 62 new CheckLocalIndex(key,1);
63 for (int i = 0; i < 3 ; i++){ 63 for (int i = 0; i < 3 ; i++){
64 key = "fish"+i; 64 key = "fish"+i;
65 if (num == 0) new AutoIncrement(key,0); 65 if (num == 0) new AutoIncrement(key,0);
66 ods.update("local", key, new FishPoint((float)Math.random(), 66 ods.update(key, new FishPoint((float)Math.random(),
67 (float)Math.random(), (float)Math.random())); 67 (float)Math.random(), (float)Math.random()));
68 new SetLocation(new MakeObject(frame), key, 0, num); 68 new SetLocation(new MakeObject(frame), key, 0, num);
69 new CheckLocalIndex(key,1); 69 new CheckLocalIndex(key,1);
70 } 70 }
71 71
73 key = "fish"+i; 73 key = "fish"+i;
74 if (num == 1) new AutoIncrement(key,0); 74 if (num == 1) new AutoIncrement(key,0);
75 Random rnd = new Random(); 75 Random rnd = new Random();
76 int tmp = rnd.nextInt(3); 76 int tmp = rnd.nextInt(3);
77 int rand = tmp + 1; 77 int rand = tmp + 1;
78 ods.update("local", key, new FishPoint( (float)rand, 78 ods.update(key, new FishPoint( (float)rand,
79 -(float)Math.random(), -(float)Math.random())); 79 -(float)Math.random(), -(float)Math.random()));
80 new SetLocation(new MakeObject(frame), key, 0, num); 80 new SetLocation(new MakeObject(frame), key, 0, num);
81 new CheckLocalIndex(key,1); 81 new CheckLocalIndex(key,1);
82 } 82 }
83 83
85 key = "fish"+i; 85 key = "fish"+i;
86 if (num == 2) new AutoIncrement(key,0); 86 if (num == 2) new AutoIncrement(key,0);
87 Random rnd = new Random(); 87 Random rnd = new Random();
88 int tmp = rnd.nextInt(3); 88 int tmp = rnd.nextInt(3);
89 int rand = tmp + 3; 89 int rand = tmp + 3;
90 ods.update("local", key, new FishPoint( (float)rand, 90 ods.update(key, new FishPoint( (float)rand,
91 (float)Math.random(), -(float)Math.random())); 91 (float)Math.random(), -(float)Math.random()));
92 new SetLocation(new MakeObject(frame), key, 0, num); 92 new SetLocation(new MakeObject(frame), key, 0, num);
93 new CheckLocalIndex(key,1); 93 new CheckLocalIndex(key,1);
94 } 94 }
95 95
99 99
100 Random rnd = new Random(); 100 Random rnd = new Random();
101 int tmp = rnd.nextInt(3); 101 int tmp = rnd.nextInt(3);
102 int rand = tmp + 5; 102 int rand = tmp + 5;
103 103
104 ods.update("local", key, new FishPoint( (float)rand, 104 ods.update(key, new FishPoint( (float)rand,
105 -(float)Math.random(), (float)Math.random())); 105 -(float)Math.random(), (float)Math.random()));
106 new SetLocation(new MakeObject(frame), key, 0, num); 106 new SetLocation(new MakeObject(frame), key, 0, num);
107 new CheckLocalIndex(key,1); 107 new CheckLocalIndex(key,1);
108 } 108 }
109 109