Mercurial > hg > Database > Alice
changeset 260:68f6e0fa4a89
refactor share test
author | sugi |
---|---|
date | Tue, 16 Jul 2013 16:17:14 +0900 |
parents | ccce30f84380 |
children | 7e1f6b575b5a |
files | src/alice/test/topology/share/AutoIncrement.java src/alice/test/topology/share/CheckLocalIndex.java src/alice/test/topology/share/CheckMyName.java |
diffstat | 3 files changed, 21 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/test/topology/share/AutoIncrement.java Tue Jul 16 16:00:41 2013 +0900 +++ b/src/alice/test/topology/share/AutoIncrement.java Tue Jul 16 16:17:14 2013 +0900 @@ -7,10 +7,8 @@ public class AutoIncrement extends CodeSegment { public Receiver position = ids.create(CommandType.PEEK); - String key; public AutoIncrement(String key,int index){ - this.key = key; this.position.setKey(key, index); } @@ -23,8 +21,8 @@ e.printStackTrace(); } } - ods.update(key, new DataInfo(System.nanoTime())); - new AutoIncrement(this.key ,this.position.index); + ods.update(position.key, new DataInfo(System.nanoTime())); + new AutoIncrement(position.key ,position.index); } }
--- a/src/alice/test/topology/share/CheckLocalIndex.java Tue Jul 16 16:00:41 2013 +0900 +++ b/src/alice/test/topology/share/CheckLocalIndex.java Tue Jul 16 16:17:14 2013 +0900 @@ -1,42 +1,46 @@ package alice.test.topology.share; +import java.util.Iterator; +import java.util.List; + import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; -import alice.test.topology.aquarium.Routing; -import alice.test.topology.aquarium.RoutingTable; public class CheckLocalIndex extends CodeSegment { private Receiver data = ids.create(CommandType.PEEK); private Receiver list = ids.create(CommandType.PEEK); private Receiver host = ids.create(CommandType.PEEK); - private String key; + public CheckLocalIndex(String key, int index){ - this.key = key; this.host.setKey("host"); - this.list.setKey("list"); - this.data.setKey(this.key, index); + this.list.setKey("_CLIST"); + this.data.setKey(key, index); } @Override public void run() { - RoutingTable rt = this.list.asClass(RoutingTable.class); + @SuppressWarnings("unchecked") + List<String> r = list.asClass(List.class); int count = 0; boolean flag = false; - for (Routing r : rt.table) { - if (r.name.equals("parent"))flag=true; - if (!r.name.equals(this.data.from)){ - ods.update(r.name, this.key, this.data.getVal()); + for (Iterator<String> ir = r.iterator();ir.hasNext();) { + String node = ir.next(); + if (node.equals("parent")){ + flag=true; + } + if (!node.equals(this.data.from)){ + ods.update(node, data.key, data.getVal()); count++; } } if (count==0&&flag){ - ods.put("parent", "data", this.data.getVal()); + ods.put("parent", "data", data.getVal()); } - new CheckLocalIndex(this.key, this.data.index); + new CheckLocalIndex(data.key, data.index); }
--- a/src/alice/test/topology/share/CheckMyName.java Tue Jul 16 16:00:41 2013 +0900 +++ b/src/alice/test/topology/share/CheckMyName.java Tue Jul 16 16:17:14 2013 +0900 @@ -6,9 +6,6 @@ import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; -import alice.test.topology.aquarium.AddRoutingTable; -import alice.test.topology.aquarium.Routing; -import alice.test.topology.aquarium.RoutingTable; public class CheckMyName extends CodeSegment { @@ -29,29 +26,18 @@ matcher.find(); String type = matcher.group(1); int num = new Integer(matcher.group(2)); - - RoutingTable routing = new RoutingTable(); - + if (type.equals("cli")){ System.out.println("cli"+num); - routing.table.add(new Routing("parent")); - ods.put("list", routing); + new SendData(0); - new AddRoutingTable(routing,0); - ods.put("parent", "member", name); - new SendData(0); }else if (type.equals("node")){ System.out.println("node"+num); if (num != 0){ - routing.table.add(new Routing("parent")); - ods.put("parent", "member", name); new SendData(0); }else{ new LookUpData("data",0); } - ods.put("list", routing); - new AddRoutingTable(routing,0); - } for (int i =0 ;i<1000000;i++){} ods.update(key, new DataInfo());