Mercurial > hg > Members > tatsuki > Alice
changeset 217:b5c642ba998e working
change as** method and remove "local" key in TEST
line wrap: on
line diff
--- a/src/alice/codesegment/ReceiveLocalData.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/codesegment/ReceiveLocalData.java Wed Mar 27 20:02:38 2013 +0900 @@ -5,7 +5,6 @@ import org.msgpack.type.ArrayValue; import org.msgpack.type.Value; -import alice.datasegment.Receiver; import alice.datasegment.ReceiverData; public class ReceiveLocalData implements ReceiverData { @@ -15,19 +14,19 @@ this.obj = obj2; } - public String asString(Receiver receiver) { + public String asString() { return (String) obj; } - public int asInteger(Receiver receiver) { + public int asInteger() { return (Integer) obj; } - public Float asFloat(Receiver receiver) { + public Float asFloat() { return (Float) obj; } - public ArrayValue asArray(Receiver receiver){ + public ArrayValue asArray(){ return (ArrayValue) obj; }
--- a/src/alice/datasegment/Command.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/datasegment/Command.java Wed Mar 27 20:02:38 2013 +0900 @@ -61,12 +61,4 @@ return this.type + "\t" + key + "\t" + val + "\tindex=" + index + "\tcs=" + csName; } - public void setElement(CommandType cmdType, String key, Value val, Object obj){ - this.type = cmdType; - this.key = key; - this.val = val; - this.obj = obj; - this.reverseKey = "local"; - } - }
--- a/src/alice/datasegment/ReceiveRemoteData.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/datasegment/ReceiveRemoteData.java Wed Mar 27 20:02:38 2013 +0900 @@ -18,28 +18,28 @@ this.val = val2; } - public String asString(Receiver receiver) { + public String asString() { if (val.getType() == ValueType.RAW) { return val.asRawValue().getString(); } return null; } - public int asInteger(Receiver receiver) { + public int asInteger() { if (val.getType() == ValueType.INTEGER) { return val.asIntegerValue().getInt(); } return 0; } - public Float asFloat(Receiver receiver) { + public Float asFloat() { if (val.getType() == ValueType.FLOAT) { return val.asFloatValue().getFloat(); } return 0.0f; } - public ArrayValue asArray(Receiver receiver){ + public ArrayValue asArray(){ if (val.getType() == ValueType.ARRAY){ return val.asArrayValue(); }
--- a/src/alice/datasegment/Receiver.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/datasegment/Receiver.java Wed Mar 27 20:02:38 2013 +0900 @@ -68,20 +68,24 @@ } - public Object getVal() { - return data.getVal(); + public int asInteger() { + return data.asInteger(); } + public String asString() { + return data.asString(); + } + public <T> T asClass(Class<T> clazz) { return data.asClass(clazz); } - - public int asInteger(Receiver receiver) { - return data.asInteger(receiver); - } - + public Object getObj() { return data.getObj(); } + + public Object getVal() { + return data.getVal(); + } }
--- a/src/alice/datasegment/ReceiverData.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/datasegment/ReceiverData.java Wed Mar 27 20:02:38 2013 +0900 @@ -5,10 +5,10 @@ public interface ReceiverData { - public String asString(Receiver receiver); - public int asInteger(Receiver receiver); - public Float asFloat(Receiver receiver) ; - public ArrayValue asArray(Receiver receiver); + public String asString(); + public int asInteger(); + public Float asFloat() ; + public ArrayValue asArray(); public <T> T asClass(Class<T> clazz); public Value getVal(); public Object getObj();
--- a/src/alice/test/codesegment/local/bitonicsort/OddPhase.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/codesegment/local/bitonicsort/OddPhase.java Wed Mar 27 20:02:38 2013 +0900 @@ -28,8 +28,8 @@ @Override public void run() { RangeInfo info = info0.asClass(RangeInfo.class); - int sort_count = info5.asInteger(info5); - int count = info6.asInteger(info6); + int sort_count = info5.asInteger(); + int count = info6.asInteger(); //System.out.println("count is " +count); int i = info.range;
--- a/src/alice/test/codesegment/local/bitonicsort/ShowData.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/codesegment/local/bitonicsort/ShowData.java Wed Mar 27 20:02:38 2013 +0900 @@ -22,7 +22,7 @@ @Override public void run() { System.out.println(System.currentTimeMillis() -SetTask.t +" ms"); - int cnt = info0.asInteger(info0); + int cnt = info0.asInteger(); int size = 0; for (int i= 0;i < cnt; i++){
--- a/src/alice/test/codesegment/remote/RemoteIncrement.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/codesegment/remote/RemoteIncrement.java Wed Mar 27 20:02:38 2013 +0900 @@ -13,7 +13,7 @@ */ @Override public void run() { - int num = this.num.data.asInteger(this.num); + int num = this.num.asInteger(); System.out.println("[CodeSegment] " + num++); if (num == 10) System.exit(0);
--- a/src/alice/test/topology/aquarium/AddRoutingTable.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/topology/aquarium/AddRoutingTable.java Wed Mar 27 20:02:38 2013 +0900 @@ -11,7 +11,7 @@ public AddRoutingTable(RoutingTable routing,int index){ this.routing = routing; - this.mail.setKey("local", "member", index); + this.mail.setKey("member", index); } @@ -20,7 +20,7 @@ //System.out.println("add "+this.mail.from); routing.table.add(new Routing(this.mail.from)); - ods.update("local", "list", this.routing); + ods.update("list", this.routing); new AddRoutingTable(this.routing, this.mail.index); }
--- a/src/alice/test/topology/aquarium/AutoIncrement.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/topology/aquarium/AutoIncrement.java Wed Mar 27 20:02:38 2013 +0900 @@ -12,14 +12,14 @@ private float max; public AutoIncrement(String key,int index){ - this.number.setKey("local", "maxsize"); - this.position.setKey("local", key, index); + this.number.setKey("maxsize"); + this.position.setKey(key, index); } @Override public void run() { - max = this.number.data.asInteger(this.number)*2-1+0.3f; - FishPoint fp = this.position.data.asClass(FishPoint.class); + max = this.number.asInteger()*2-1+0.3f; + FishPoint fp = this.position.asClass(FishPoint.class); if (fp.getX()+0.01>max){ fp.setXYZ(min, fp.getY(), fp.getZ()); } else if (fp.getX()+0.01< min){ @@ -29,7 +29,7 @@ fp.setXYZ(fp.getX()+0.01f, fp.getY(), fp.getZ()); } - ods.update("local", position.key, fp); + ods.update(position.key, fp); synchronized(this){ try { // TODO
--- a/src/alice/test/topology/aquarium/CheckLocalIndex.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/topology/aquarium/CheckLocalIndex.java Wed Mar 27 20:02:38 2013 +0900 @@ -11,8 +11,8 @@ public CheckLocalIndex(String key, int index){ - this.list.setKey("local", "list"); - this.data.setKey("local", key, index); + this.list.setKey("list"); + this.data.setKey(key, index); } @Override @@ -24,7 +24,7 @@ } } - new CheckLocalIndex(data.key, this.data.index); + new CheckLocalIndex(this.data.key, this.data.index); }
--- a/src/alice/test/topology/aquarium/CheckMyName.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/topology/aquarium/CheckMyName.java Wed Mar 27 20:02:38 2013 +0900 @@ -15,27 +15,27 @@ private String key = "fish"; public CheckMyName(){ - host.setKey("local","host"); + host.setKey("host"); } @Override public void run(){ - String name = host.data.asString(host); + String name = host.asString(); Matcher matcher = pattern.matcher(name); matcher.find(); String type = matcher.group(1); int num = new Integer(matcher.group(2)); - ods.put("local", "host_num", num*2); + ods.put("host_num", num*2); MakeFrame frame = new MakeFrame(name,num*2); RoutingTable routing = new RoutingTable(); - ods.put("local", "num", 1); + ods.put("num", 1); if (type.equals("cli")){ System.out.println("cli"+num); routing.table.add(new Routing("parent")); - ods.put("local", "list", routing); + ods.put("list", routing); new AddRoutingTable(routing,0); ods.put("parent", "member", name); @@ -51,19 +51,19 @@ } else { new SendMaxsize(0); } - ods.put("local", "list", routing); + ods.put("list", routing); new AddRoutingTable(routing,0); } new CheckLocalIndex("maxsize",0); - ods.update("local", key, new FishPoint(-0.1f,-0.1f)); + ods.update(key, new FishPoint(-0.1f,-0.1f)); new SetLocation(new MakeObject(frame), key, 0, num); new CheckLocalIndex(key,1); for (int i = 0; i < 3 ; i++){ key = "fish"+i; if (num == 0) new AutoIncrement(key,0); - ods.update("local", key, new FishPoint((float)Math.random(), + ods.update(key, new FishPoint((float)Math.random(), (float)Math.random(), (float)Math.random())); new SetLocation(new MakeObject(frame), key, 0, num); new CheckLocalIndex(key,1); @@ -75,7 +75,7 @@ Random rnd = new Random(); int tmp = rnd.nextInt(3); int rand = tmp + 1; - ods.update("local", key, new FishPoint( (float)rand, + ods.update(key, new FishPoint( (float)rand, -(float)Math.random(), -(float)Math.random())); new SetLocation(new MakeObject(frame), key, 0, num); new CheckLocalIndex(key,1); @@ -87,7 +87,7 @@ Random rnd = new Random(); int tmp = rnd.nextInt(3); int rand = tmp + 3; - ods.update("local", key, new FishPoint( (float)rand, + ods.update(key, new FishPoint( (float)rand, (float)Math.random(), -(float)Math.random())); new SetLocation(new MakeObject(frame), key, 0, num); new CheckLocalIndex(key,1); @@ -101,7 +101,7 @@ int tmp = rnd.nextInt(3); int rand = tmp + 5; - ods.update("local", key, new FishPoint( (float)rand, + ods.update(key, new FishPoint( (float)rand, -(float)Math.random(), (float)Math.random())); new SetLocation(new MakeObject(frame), key, 0, num); new CheckLocalIndex(key,1);
--- a/src/alice/test/topology/aquarium/RefreshWindow.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/topology/aquarium/RefreshWindow.java Wed Mar 27 20:02:38 2013 +0900 @@ -8,7 +8,7 @@ private MakeFrame frame; public RefreshWindow(MakeFrame frame){ - this.host.setKey("local","host_num"); + this.host.setKey("host_num"); this.frame = frame; } @@ -17,7 +17,7 @@ frame.getJFrame().dispose(); ObjectList list = frame.getList(); - frame = new MakeFrame(this.host.data.asString(this.host),host.data.asInteger(host)); + frame = new MakeFrame(this.host.asString(),host.asInteger()); for (MakeObject obj : list.table) { this.frame.register(obj); }
--- a/src/alice/test/topology/aquarium/ResetFish.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/topology/aquarium/ResetFish.java Wed Mar 27 20:02:38 2013 +0900 @@ -9,7 +9,7 @@ @Override public void run() { FishPoint fp = new FishPoint(0.0f,0.0f,0.0f); - ods.update("local", "fish", fp); + ods.update("fish", fp); }
--- a/src/alice/test/topology/aquarium/SendLocation.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/topology/aquarium/SendLocation.java Wed Mar 27 20:02:38 2013 +0900 @@ -16,14 +16,14 @@ this.x = x; this.y = y; this.z = z; - position.setKey("local", "fish"); + position.setKey("fish"); } @Override public void run() { - FishPoint fp = this.position.data.asClass(FishPoint.class); + FishPoint fp = this.position.asClass(FishPoint.class); fp.setXYZ(fp.getX()+x, fp.getY()+y, fp.getZ()+z); - ods.update("local", "fish", fp); + ods.update("fish", fp); }
--- a/src/alice/test/topology/aquarium/SendMaxsize.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/topology/aquarium/SendMaxsize.java Wed Mar 27 20:02:38 2013 +0900 @@ -9,13 +9,13 @@ private Receiver max = ids.create(CommandType.PEEK); public SendMaxsize(int index){ - this.max.setKey("local", "num", index); + this.max.setKey("num", index); } @Override public void run() { - int size = max.data.asInteger(max); - ods.update("local","maxsize",size); + int size = max.asInteger(); + ods.update("maxsize",size); new SendMaxsize(this.max.index); }
--- a/src/alice/test/topology/aquarium/SetLocation.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/topology/aquarium/SetLocation.java Wed Mar 27 20:02:38 2013 +0900 @@ -14,7 +14,7 @@ public SetLocation(MakeObject obj ,String key, int index, int range){ this.obj = obj; this.range = range; - this.position.setKey("local",key,index); + this.position.setKey(key,index); } @Override
--- a/src/alice/test/topology/aquarium/TakeMynum.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/topology/aquarium/TakeMynum.java Wed Mar 27 20:02:38 2013 +0900 @@ -9,17 +9,17 @@ private Receiver mynum = ids.create(CommandType.TAKE); public TakeMynum(){ - this.mynum.setKey("local", "num"); + this.mynum.setKey("num"); } public TakeMynum(int index){ - this.mynum.setKey("local", "num", index); + this.mynum.setKey("num", index); } @Override public void run() { new TakePnum(this.mynum); - ods.put("local", "num", 0); + ods.put("num", 0); new TakeMynum(this.mynum.index+1); }
--- a/src/alice/test/topology/aquarium/TakePnum.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/topology/aquarium/TakePnum.java Wed Mar 27 20:02:38 2013 +0900 @@ -18,7 +18,7 @@ @Override public void run() { ods.update("parent", "num", - this.pnum.data.asInteger(this.pnum)+this.mynum.data.asInteger(this.mynum)); + this.pnum.asInteger()+this.mynum.asInteger()); } }
--- a/src/alice/test/topology/fish/CheckMyName.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/topology/fish/CheckMyName.java Wed Mar 27 20:02:38 2013 +0900 @@ -12,12 +12,12 @@ private Receiver host = ids.create(CommandType.PEEK); public CheckMyName(){ - host.setKey("local", "host"); + host.setKey("host"); } @Override public void run() { - String name = host.data.asString(host); + String name = host.asString(); Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$"); Matcher matcher = pattern.matcher(name);
--- a/src/alice/test/topology/fish/GetStartX.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/topology/fish/GetStartX.java Wed Mar 27 20:02:38 2013 +0900 @@ -10,7 +10,7 @@ @Override public void run() { - int startX = this.startX.data.asInteger(this.startX); + int startX = this.startX.asInteger(); System.out.println("GetStartX: " + startX);
--- a/src/alice/test/topology/fish/PeekStartX.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/topology/fish/PeekStartX.java Wed Mar 27 20:02:38 2013 +0900 @@ -15,9 +15,9 @@ @Override public void run() { - int startX = this.startX.data.asInteger(this.startX); + int startX = this.startX.asInteger(); AsignStartX cs = new AsignStartX(startX, this.startX.index); - cs.routing.setKey("local", "routing", this.startX.index); + cs.routing.setKey("routing", this.startX.index); } }
--- a/src/alice/test/topology/fish/SendWidth.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/topology/fish/SendWidth.java Wed Mar 27 20:02:38 2013 +0900 @@ -10,13 +10,13 @@ @Override public void run() { - int width = this.width.data.asInteger(this.width); + int width = this.width.asInteger(); ods.put("parent", "widths", width); System.out.println("send widths: " + width); SendWidth cs = new SendWidth(); - cs.width.setKey("local", "width", this.width.index); + cs.width.setKey("width", this.width.index); } }
--- a/src/alice/test/topology/fish/WidthReceiver.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/topology/fish/WidthReceiver.java Wed Mar 27 20:02:38 2013 +0900 @@ -14,7 +14,7 @@ @Override public void run() { - int width = this.widths.asInteger(this.widths); + int width = this.widths.asInteger(); String from = this.widths.from; RoutingTable routing = this.routing.asClass(RoutingTable.class); Routing newRouting = new Routing(from, width); @@ -43,13 +43,13 @@ System.out.println("NODE NUM: " + routing.table.size()); - ods.update("local", "width", routing.sumWidth); - ods.update("local", "routing", routing); + ods.update("width", routing.sumWidth); + ods.update("routing", routing); WidthReceiver cs = new WidthReceiver(); - cs.widths.setKey("local", "widths", this.widths.index); - cs.routing.setKey("local", "routing"); - //cs.routing.setKey("local", "routing", this.routing.index); + cs.widths.setKey("widths", this.widths.index); + cs.routing.setKey("routing"); + //cs.routing.setKey("routing", this.routing.index); } }
--- a/src/alice/test/topology/ring/CheckMyName.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/topology/ring/CheckMyName.java Wed Mar 27 20:02:38 2013 +0900 @@ -19,7 +19,7 @@ @Override public void run() { - String host = this.ds1.data.asString(this.ds1); + String host = this.ds1.asString(); logger.debug(host); if (host.equals("node0")) { ods.put("local", "c", new byte[conf.size]);
--- a/src/alice/test/topology/share/AutoIncrement.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/topology/share/AutoIncrement.java Wed Mar 27 20:02:38 2013 +0900 @@ -11,7 +11,7 @@ public AutoIncrement(String key,int index){ this.key = key; - this.position.setKey("local", key, index); + this.position.setKey(key, index); } @Override @@ -23,7 +23,7 @@ e.printStackTrace(); } } - ods.update("local", key, new DataInfo(System.nanoTime())); + ods.update(key, new DataInfo(System.nanoTime())); new AutoIncrement(this.key ,this.position.index); }
--- a/src/alice/test/topology/share/CheckLocalIndex.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/topology/share/CheckLocalIndex.java Wed Mar 27 20:02:38 2013 +0900 @@ -15,9 +15,9 @@ public CheckLocalIndex(String key, int index){ this.key = key; - this.host.setKey("local","host"); - this.list.setKey("local", "list"); - this.data.setKey("local", this.key, index); + this.host.setKey("host"); + this.list.setKey("list"); + this.data.setKey(this.key, index); } @Override
--- a/src/alice/test/topology/share/CheckMyName.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/topology/share/CheckMyName.java Wed Mar 27 20:02:38 2013 +0900 @@ -17,13 +17,13 @@ String key = "fish"; public CheckMyName(){ - this.host.setKey("local","host"); + this.host.setKey("host"); } @Override public void run(){ - String name = host.data.asString(host); + String name = host.asString(); Matcher matcher = pattern.matcher(name); matcher.find(); @@ -35,7 +35,7 @@ if (type.equals("cli")){ System.out.println("cli"+num); routing.table.add(new Routing("parent")); - ods.put("local", "list", routing); + ods.put("list", routing); new AddRoutingTable(routing,0); ods.put("parent", "member", name); @@ -49,12 +49,12 @@ }else{ new LookUpData("data",0); } - ods.put("local", "list", routing); + ods.put("list", routing); new AddRoutingTable(routing,0); } for (int i =0 ;i<1000000;i++){} - ods.update("local", key, new DataInfo()); + ods.update(key, new DataInfo()); if (num == 0) new AutoIncrement(key,0); new CheckLocalIndex(key,1);
--- a/src/alice/test/topology/share/LookUpData.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/topology/share/LookUpData.java Wed Mar 27 20:02:38 2013 +0900 @@ -12,19 +12,19 @@ public LookUpData(String key,int index){ this.key = key; - this.data.setKey("local", key, index); + this.data.setKey(key, index); } public LookUpData(String key,int index, int depth){ this.key = key; this.depth = depth; - this.data.setKey("local", key, index); + this.data.setKey(key, index); } @Override public void run(){ new LookUpData(this.key,this.data.index); - DataInfo di = data.data.asClass(DataInfo.class); + DataInfo di = data.asClass(DataInfo.class); System.out.println(System.nanoTime()-di.getTime()); }
--- a/src/alice/test/topology/share/SendData.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/test/topology/share/SendData.java Wed Mar 27 20:02:38 2013 +0900 @@ -8,7 +8,7 @@ private Receiver data = ids.create(CommandType.PEEK); public SendData(int index){ - this.data.setKey("local", "data", index); + this.data.setKey("data", index); } @Override
--- a/src/alice/topology/node/IncomingAbstractHostName.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/topology/node/IncomingAbstractHostName.java Wed Mar 27 20:02:38 2013 +0900 @@ -14,7 +14,7 @@ @Override public void run() { - String absName = this.absName.data.asString(this.absName); + String absName = this.absName.asString(); IncomingConnectionInfo cs = new IncomingConnectionInfo(absName, 0); cs.hostInfo.setKey("manager", absName); }
--- a/src/alice/topology/node/IncomingReverseKey.java Wed Mar 27 19:38:33 2013 +0900 +++ b/src/alice/topology/node/IncomingReverseKey.java Wed Mar 27 20:02:38 2013 +0900 @@ -17,7 +17,7 @@ String from = this.reverseKey.from; DataSegment.getAccept(from).reverseKey = reverseKey; - int reverseCount = this.reverseCount.asInteger(this.reverseCount); + int reverseCount = this.reverseCount.asInteger(); reverseCount++; ods.update("local", "reverseCount", reverseCount);