Mercurial > hg > Members > tatsuki > Alice
changeset 199:15b68b65f8a4 working
Failed api flip
author | sugi |
---|---|
date | Thu, 21 Mar 2013 16:48:26 +0900 |
parents | f151dea22b2c |
children | 099bb3afd74f |
files | src/alice/codesegment/InputDataSegment.java src/alice/codesegment/OutputDataSegment.java src/alice/datasegment/DataSegmentKey.java src/alice/datasegment/LocalDataSegmentManager.java src/alice/test/codesegment/api/FlipCodeSegment.java src/alice/test/codesegment/api/FlipTest.java |
diffstat | 6 files changed, 16 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/codesegment/InputDataSegment.java Tue Mar 19 01:25:09 2013 +0900 +++ b/src/alice/codesegment/InputDataSegment.java Thu Mar 21 16:48:26 2013 +0900 @@ -64,10 +64,7 @@ } public void flip(Receiver receiver, Value val, Object obj){ - //int index = DataSegment.getLocal().getDataSegmentKey(receiver.key).getIndex(); - //dsv.setValue(index, val, obj); DataSegment.getLocal().flip(receiver.key, val, obj, dsv); - } public void reply(Receiver receiver, DataSegmentValue val) {
--- a/src/alice/codesegment/OutputDataSegment.java Tue Mar 19 01:25:09 2013 +0900 +++ b/src/alice/codesegment/OutputDataSegment.java Thu Mar 21 16:48:26 2013 +0900 @@ -71,7 +71,9 @@ public <T> void update(String key, T val) { try { + long t = System.currentTimeMillis(); DataSegment.getLocal().update(key, SingletonMessage.getInstance().unconvert(val)); + System.out.println(System.currentTimeMillis() - t); } catch (IOException e) { e.printStackTrace(); }
--- a/src/alice/datasegment/DataSegmentKey.java Tue Mar 19 01:25:09 2013 +0900 +++ b/src/alice/datasegment/DataSegmentKey.java Thu Mar 21 16:48:26 2013 +0900 @@ -21,8 +21,8 @@ return tailIndex.getAndIncrement(); } - public ArrayList<DataSegmentValue> getDataList(){ - return dataList; + public synchronized int getWaitListSize(){ + return waitList.size(); } public void runCommand(Command cmd) { @@ -98,19 +98,18 @@ waitList.add(cmd); break; case FLIP: + // check waitList index = cmd.dsv.index; - // need to check waitList for (Iterator<Command> iter = waitList.iterator(); iter.hasNext(); ) { Command waitCmd = iter.next(); if (waitCmd.index < index) { try { - //waitCmd.replyQueue.put(new Command(CommandType.REPLY, null, null, cmd.val, cmd.obj, index, waitCmd.seq, null, null, cmd.reverseKey)); waitCmd.replyQueue.put(new Command(CommandType.REPLY, waitCmd.seq, cmd.dsv)); } catch (InterruptedException e) { e.printStackTrace(); } iter.remove(); - if (waitCmd.type == CommandType.TAKE) { // someone is waiting for this put or update command + if (waitCmd.type == CommandType.TAKE) { dataList.remove(cmd.dsv); break; }
--- a/src/alice/datasegment/LocalDataSegmentManager.java Tue Mar 19 01:25:09 2013 +0900 +++ b/src/alice/datasegment/LocalDataSegmentManager.java Thu Mar 21 16:48:26 2013 +0900 @@ -140,10 +140,13 @@ DataSegmentKey dataSegmentKey = getDataSegmentKey(key); int index = dataSegmentKey.getIndex(); dsv.setValue(index, val, obj); - Command cmd = new Command(CommandType.FLIP, 0, dsv); - //addCommand(dataSegmentKey, cmd); - if (logger.isDebugEnabled()) - logger.debug(cmd.getCommandString()); + if (dataSegmentKey.getWaitListSize()!=0){ + Command cmd = new Command(CommandType.FLIP, 0, dsv); + addCommand(dataSegmentKey, cmd); + if (logger.isDebugEnabled()) + logger.debug(cmd.getCommandString()); + } + } }
--- a/src/alice/test/codesegment/api/FlipCodeSegment.java Tue Mar 19 01:25:09 2013 +0900 +++ b/src/alice/test/codesegment/api/FlipCodeSegment.java Thu Mar 21 16:48:26 2013 +0900 @@ -13,14 +13,9 @@ public void run() { Integer num = new Integer(0); ods.put(key, num, false); + //System.out.println("Key is " +key); new FlipTest(key); - //for (int i = 0; i < 1000000; i++){ - //ods.put(key, num, false); - //System.out.println("put"); - //} - - } }
--- a/src/alice/test/codesegment/api/FlipTest.java Tue Mar 19 01:25:09 2013 +0900 +++ b/src/alice/test/codesegment/api/FlipTest.java Thu Mar 21 16:48:26 2013 +0900 @@ -23,25 +23,22 @@ public void run() { if (flag){ System.out.println(System.currentTimeMillis() - t); - System.out.println(arg1.obj); + //System.out.println(" "+arg1.obj+" "+arg1.index); if (count >= 100) System.exit(0); flag = false; count++; new FlipCodeSegment(Long.toString(t)).execute(); - } else { t = System.currentTimeMillis(); for (int i = 0;i<1000000;i++){ Integer num = i; arg1.flip(num); - //System.out.println("flip"); //ods.update(arg1.key, num, false); } flag = true; - new FlipTest(arg1.key); - //new FlipTest(arg1.key ,1000000); + new FlipTest(arg1.key ,1000000); } }