Mercurial > hg > Members > tatsuki > Alice
changeset 182:52a1fa5ba38b working
add filp api
author | e095732 |
---|---|
date | Tue, 26 Feb 2013 13:46:18 +0900 |
parents | 52dcead81b90 |
children | 75150396681c |
files | src/alice/codesegment/OutputDataSegment.java src/alice/daemon/AliceDaemon.java src/alice/datasegment/DataSegmentKey.java src/alice/datasegment/LocalDataSegmentManager.java src/alice/test/codesegment/local/StartCodeSegment.java src/alice/test/codesegment/local/TestCodeSegment.java src/alice/test/topology/share/AutoIncrement.java src/alice/test/topology/share/LookUpData.java src/alice/topology/node/StartTopologyNode.java |
diffstat | 9 files changed, 52 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/codesegment/OutputDataSegment.java Fri Feb 08 19:03:52 2013 +0900 +++ b/src/alice/codesegment/OutputDataSegment.java Tue Feb 26 13:46:18 2013 +0900 @@ -15,6 +15,26 @@ DataSegment.getLocal().flip(receiver, val); } + public void flip(Receiver receiver, String val) { + DataSegment.getLocal().flip(receiver, ValueFactory.createRawValue(val)); + } + + public void flip(Receiver receiver, int val) { + DataSegment.getLocal().flip(receiver, ValueFactory.createIntegerValue(val)); + } + + public void flip(Receiver receiver, byte[] val) { + DataSegment.getLocal().flip(receiver, ValueFactory.createRawValue(val)); + } + + public <T> void filp(Receiver receiver, T val) { + try { + DataSegment.getLocal().flip(receiver, SingletonMessage.getInstance().unconvert(val)); + } catch (IOException e) { + e.printStackTrace(); + } + } + public void put(String managerKey, String key, Value val) { DataSegment.get(managerKey).put(key, val); }
--- a/src/alice/daemon/AliceDaemon.java Fri Feb 08 19:03:52 2013 +0900 +++ b/src/alice/daemon/AliceDaemon.java Tue Feb 26 13:46:18 2013 +0900 @@ -2,6 +2,7 @@ import java.io.FileWriter; import java.io.IOException; +import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.ServerSocket; import java.nio.channels.ServerSocketChannel; @@ -46,9 +47,9 @@ ServerSocket ss = ssChannel.socket(); ss.setReuseAddress(true); - InetSocketAddress a = new InetSocketAddress("::", conf.localPort); - System.out.println(a); - //ss.bind(new InetSocketAddress(InetAddress.getLocalHost(), conf.localPort)); + //InetSocketAddress a = new InetSocketAddress("::", conf.localPort); + InetSocketAddress a = new InetSocketAddress(InetAddress.getLocalHost(), conf.localPort); + //System.out.println(a); ss.bind(a); acceptThread = new AcceptThread(ss, "ACCEPT" + conf.localPort); acceptThread.start();
--- a/src/alice/datasegment/DataSegmentKey.java Fri Feb 08 19:03:52 2013 +0900 +++ b/src/alice/datasegment/DataSegmentKey.java Tue Feb 26 13:46:18 2013 +0900 @@ -17,6 +17,10 @@ private ArrayList<Command> waitList = new ArrayList<Command>(); private AtomicInteger tailIndex = new AtomicInteger(1); + public AtomicInteger getTailIndex(){ + return tailIndex; + } + public ArrayList<DataSegmentValue> getDataList(){ return dataList; }
--- a/src/alice/datasegment/LocalDataSegmentManager.java Fri Feb 08 19:03:52 2013 +0900 +++ b/src/alice/datasegment/LocalDataSegmentManager.java Tue Feb 26 13:46:18 2013 +0900 @@ -126,7 +126,7 @@ ArrayList<DataSegmentValue> dataList = dataSegmentKey.getDataList(); DataSegmentValue dval = new DataSegmentValue(receiver.index, val, "local"); synchronized(dataList){ - dataList.set(receiver.index, dval); + dataList.set(receiver.index-1, dval); } }
--- a/src/alice/test/codesegment/local/StartCodeSegment.java Fri Feb 08 19:03:52 2013 +0900 +++ b/src/alice/test/codesegment/local/StartCodeSegment.java Tue Feb 26 13:46:18 2013 +0900 @@ -4,6 +4,8 @@ public class StartCodeSegment extends CodeSegment { + + public static long t = 0; @Override public void run() { System.out.println("run StartCodeSegment"); @@ -15,13 +17,14 @@ ods.update("local", "key1", 0); // bind string data to datasegment local.key1 // this startup TestCodeSegment. */ + t = System.currentTimeMillis(); ods.put("local", "key1", 0); - ods.put("local", "key1", 1); - ods.put("local", "key1", 2); - ods.put("local", "key1", 3); + //ods.put("local", "key1", 1); + //ods.put("local", "key1", 2); + //ods.put("local", "key1", 3); - new TestCodeSegment(1); - System.out.println("create TestCodeSegment"); + new TestCodeSegment(); + //System.out.println("create TestCodeSegment"); //ods.update("local", "key1", 0); }
--- a/src/alice/test/codesegment/local/TestCodeSegment.java Fri Feb 08 19:03:52 2013 +0900 +++ b/src/alice/test/codesegment/local/TestCodeSegment.java Tue Feb 26 13:46:18 2013 +0900 @@ -9,7 +9,7 @@ static int count = 0; // create input datasegment arg1 - Receiver arg1 = ids.create(CommandType.TAKE); + Receiver arg1 = ids.create(CommandType.PEEK); public TestCodeSegment(){ arg1.setKey("key1"); } @@ -20,19 +20,23 @@ @Override public void run() { //System.out.println("index = " + arg1.index); - System.out.println("data = " + arg1.val); + //System.out.println("data = " + arg1.val); //System.out.println(arg1.val.getType()); - + if(count > 10000){ + System.out.println(System.currentTimeMillis() - StartCodeSegment.t); + System.exit(1); + } /* TestCodeSegment cs = new TestCodeSegment(); cs.arg1.setKey("key1", arg1.index); */ - + ods.update("local","key1",arg1.asInteger()+1); + //ods.flip(arg1, arg1.asInteger()+1); new TestCodeSegment(); //new TestCodeSegment(arg1.index); - + count++; // DataSegment.get("local").update //ods.update("local", "key1", arg1.index);
--- a/src/alice/test/topology/share/AutoIncrement.java Fri Feb 08 19:03:52 2013 +0900 +++ b/src/alice/test/topology/share/AutoIncrement.java Tue Feb 26 13:46:18 2013 +0900 @@ -23,7 +23,7 @@ e.printStackTrace(); } } - ods.update("local", key, new DataInfo(System.currentTimeMillis())); + ods.update("local", key, new DataInfo(System.nanoTime())); new AutoIncrement(this.key ,this.position.index); }
--- a/src/alice/test/topology/share/LookUpData.java Fri Feb 08 19:03:52 2013 +0900 +++ b/src/alice/test/topology/share/LookUpData.java Tue Feb 26 13:46:18 2013 +0900 @@ -25,7 +25,7 @@ public void run(){ new LookUpData(this.key,this.data.index); DataInfo di = data.asClass(DataInfo.class); - System.out.println("Time "+(System.currentTimeMillis()-di.getTime())+" ms"); + System.out.println(System.nanoTime()-di.getTime()); }
--- a/src/alice/topology/node/StartTopologyNode.java Fri Feb 08 19:03:52 2013 +0900 +++ b/src/alice/topology/node/StartTopologyNode.java Tue Feb 26 13:46:18 2013 +0900 @@ -3,6 +3,7 @@ import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; +import java.net.UnknownHostException; import java.util.Enumeration; import alice.codesegment.CodeSegment; @@ -23,12 +24,12 @@ public void run() { DataSegment.connect("manager", "", conf.managerHostName, conf.managerPort); String localHostName = null; - //localHostName = InetAddress.getLocalHost().getHostName(); try { - localHostName = getIPAddress(); - } catch (SocketException e) { + localHostName = InetAddress.getLocalHost().getHostName(); + } catch (UnknownHostException e) { e.printStackTrace(); } + HostMessage host = new HostMessage(localHostName, conf.localPort); ods.put("manager", "host", host);