Mercurial > hg > Members > tatsuki > Alice
changeset 254:2ec10cfa8cc3
refactor
author | sugi |
---|---|
date | Mon, 01 Jul 2013 20:00:07 +0900 |
parents | 32e7d5271477 |
children | f213bccfe1db |
files | src/alice/codesegment/InputDataSegment.java src/alice/codesegment/OutputDataSegment.java src/alice/datasegment/DataSegmentManager.java src/alice/datasegment/LocalDataSegmentManager.java src/alice/datasegment/Receiver.java src/alice/datasegment/RemoteDataSegmentManager.java |
diffstat | 6 files changed, 55 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/codesegment/InputDataSegment.java Tue Jun 18 17:14:20 2013 +0900 +++ b/src/alice/codesegment/InputDataSegment.java Mon Jul 01 20:00:07 2013 +0900 @@ -23,36 +23,41 @@ this.cs = cs; } - public void quickPeek(Receiver receiver, String managerKey, String key, int index) { + public void quickPeek(Receiver receiver) { cs.list.add(receiver); - DataSegment.get(managerKey).quickPeek(receiver, key, index, cs); - } - - public void quickTake(Receiver receiver, String managerKey, String key, int index) { - cs.list.add(receiver); - DataSegment.get(managerKey).quickTake(receiver, key, index, cs); + if (receiver.managerKey==null){ + DataSegment.getLocal().quickPeek(receiver, cs); + } else { + DataSegment.get(receiver.managerKey).quickPeek(receiver ,cs); + } } - - public void peek(Receiver receiver, String managerKey, String key, int index) { + public void quickTake(Receiver receiver) { cs.list.add(receiver); - DataSegment.get(managerKey).peek(receiver, key, index, cs); + if (receiver.managerKey==null){ + DataSegment.getLocal().quickTake(receiver, cs); + } else { + DataSegment.get(receiver.managerKey).quickTake(receiver ,cs); + } } - public void peek(Receiver receiver, String key, int index) { + public void peek(Receiver receiver) { cs.list.add(receiver); - DataSegment.getLocal().peek(receiver, key, index, cs); + if (receiver.managerKey==null){ + DataSegment.getLocal().peek(receiver, cs); + } else { + DataSegment.get(receiver.managerKey).peek(receiver, cs); + } } - public void take(Receiver receiver, String managerKey, String key, int index) { + public void take(Receiver receiver) { cs.list.add(receiver); - DataSegment.get(managerKey).take(receiver, key, index, cs); - } - - public void take(Receiver receiver, String key, int index) { - cs.list.add(receiver); - DataSegment.getLocal().take(receiver, key, index, cs); + if (receiver.managerKey==null){ + DataSegment.getLocal().take(receiver, cs); + } else { + DataSegment.get(receiver.managerKey).take(receiver, cs); + } } public void reply(Receiver receiver, Command reply) {
--- a/src/alice/codesegment/OutputDataSegment.java Tue Jun 18 17:14:20 2013 +0900 +++ b/src/alice/codesegment/OutputDataSegment.java Mon Jul 01 20:00:07 2013 +0900 @@ -16,6 +16,7 @@ */ public void flip(Receiver receiver) { + receiver.managerKey=null; DataSegment.getLocal().putObject(receiver.key, receiver.getObj()); }
--- a/src/alice/datasegment/DataSegmentManager.java Tue Jun 18 17:14:20 2013 +0900 +++ b/src/alice/datasegment/DataSegmentManager.java Mon Jul 01 20:00:07 2013 +0900 @@ -53,14 +53,8 @@ public abstract void put(String key, Value val); public abstract void update(String key, Value val); - public void take(Receiver receiver, String key, CodeSegment cs) { - take(receiver, key, 0, cs); - } - public abstract void take(Receiver receiver, String key, int index, CodeSegment cs); - public void peek(Receiver receiver, String key, CodeSegment cs) { - peek(receiver, key, 0, cs); - } - public abstract void peek(Receiver receiver, String key, int index, CodeSegment cs); + public abstract void take(Receiver receiver, CodeSegment cs); + public abstract void peek(Receiver receiver, CodeSegment cs); public abstract void remove(String key); public abstract void close(); public abstract void finish(); @@ -68,16 +62,8 @@ public abstract void quickPut(String key, Value val); public abstract void quickUpdate(String key, Value val); - public void quickPeek(Receiver receiver, String key, CodeSegment cs) { - quickPeek(receiver, key, 0, cs); - } - public abstract void quickPeek(Receiver receiver, String key, int index, CodeSegment cs); - - public void quickTake(Receiver receiver, String key, CodeSegment cs) { - quickTake(receiver, key, 0, cs); - } - - public abstract void quickTake(Receiver receiver, String key, int index, CodeSegment cs); + public abstract void quickPeek(Receiver receiver, CodeSegment cs); + public abstract void quickTake(Receiver receiver, CodeSegment cs); }
--- a/src/alice/datasegment/LocalDataSegmentManager.java Tue Jun 18 17:14:20 2013 +0900 +++ b/src/alice/datasegment/LocalDataSegmentManager.java Mon Jul 01 20:00:07 2013 +0900 @@ -99,20 +99,20 @@ } @Override - public void take(Receiver receiver, String key, int index, CodeSegment cs) { - DataSegmentKey dataSegmentKey = getDataSegmentKey(key); + public void take(Receiver receiver, CodeSegment cs) { + DataSegmentKey dataSegmentKey = getDataSegmentKey(receiver.key); int seq = this.seq.getAndIncrement(); - Command cmd = new Command(CommandType.TAKE, receiver, key, null, index, seq, replyQueue, cs, null); + Command cmd = new Command(CommandType.TAKE, receiver, receiver.key, null, receiver.index, seq, replyQueue, cs, null); dataSegmentKey.runCommand(cmd); if (logger.isDebugEnabled()) logger.debug(cmd.getCommandString()); } @Override - public void peek(Receiver receiver, String key, int index, CodeSegment cs) { - DataSegmentKey dataSegmentKey = getDataSegmentKey(key); + public void peek(Receiver receiver, CodeSegment cs) { + DataSegmentKey dataSegmentKey = getDataSegmentKey(receiver.key); int seq = this.seq.getAndIncrement(); - Command cmd = new Command(CommandType.PEEK, receiver, key, null, index, seq, replyQueue, cs, null); + Command cmd = new Command(CommandType.PEEK, receiver, receiver.key, null, receiver.index, seq, replyQueue, cs, null); dataSegmentKey.runCommand(cmd); if (logger.isDebugEnabled()) logger.debug(cmd.getCommandString()); @@ -147,12 +147,12 @@ } @Override - public void quickPeek(Receiver receiver, String key, int index, CodeSegment cs) { + public void quickPeek(Receiver receiver, CodeSegment cs) { } @Override - public void quickTake(Receiver receiver, String key, int index, CodeSegment cs) { + public void quickTake(Receiver receiver, CodeSegment cs) { }
--- a/src/alice/datasegment/Receiver.java Tue Jun 18 17:14:20 2013 +0900 +++ b/src/alice/datasegment/Receiver.java Mon Jul 01 20:00:07 2013 +0900 @@ -25,18 +25,18 @@ } public void setQuickKey(String managerKey, String key){ - this.managerKey = managerKey; setQuickKey(managerKey, key, 0); } public void setQuickKey(String managerKey, String key, int index) { + this.managerKey = managerKey; this.key = key; switch (type) { case PEEK: - ids.quickPeek(this, managerKey, key, index); + ids.quickPeek(this); break; case TAKE: - ids.quickTake(this, managerKey, key, index); + ids.quickTake(this); break; default: break; @@ -45,18 +45,19 @@ } public void setKey(String managerKey, String key) { - this.managerKey = managerKey; setKey(managerKey, key, 0); } public void setKey(String managerKey, String key, int index) { + this.managerKey = managerKey; this.key = key; + this.index = index; switch (type) { case PEEK: - ids.peek(this, managerKey, key, index); + ids.peek(this); break; case TAKE: - ids.take(this, managerKey, key, index); + ids.take(this); break; default: break; @@ -70,12 +71,13 @@ public void setKey(String key, int index) { this.key = key; + this.index = index; switch (type) { case PEEK: - ids.peek(this, key, index); + ids.peek(this); break; case TAKE: - ids.take(this, key, index); + ids.take(this); break; default: break;
--- a/src/alice/datasegment/RemoteDataSegmentManager.java Tue Jun 18 17:14:20 2013 +0900 +++ b/src/alice/datasegment/RemoteDataSegmentManager.java Mon Jul 01 20:00:07 2013 +0900 @@ -83,9 +83,9 @@ } @Override - public void take(Receiver receiver, String key, int index, CodeSegment cs) { + public void take(Receiver receiver, CodeSegment cs) { int seq = this.seq.getAndIncrement(); - Command cmd = new Command(CommandType.TAKE, receiver, key, null, index, seq, replyQueue, cs, null); + Command cmd = new Command(CommandType.TAKE, receiver, receiver.key, null, receiver.index, seq, replyQueue, cs, null); seqHash.put(seq, cmd); connection.sendCommand(cmd); if (logger.isDebugEnabled()) @@ -93,9 +93,9 @@ } @Override - public void quickTake(Receiver receiver, String key, int index, CodeSegment cs) { + public void quickTake(Receiver receiver, CodeSegment cs) { int seq = this.seq.getAndIncrement(); - Command cmd = new Command(CommandType.TAKE, receiver, key, null, index, seq, replyQueue, cs, null, true); + Command cmd = new Command(CommandType.TAKE, receiver, receiver.key, null, receiver.index, seq, replyQueue, cs, null, true); seqHash.put(seq, cmd); connection.write(cmd); if (logger.isDebugEnabled()) @@ -103,9 +103,9 @@ } @Override - public void peek(Receiver receiver, String key, int index, CodeSegment cs) { + public void peek(Receiver receiver, CodeSegment cs) { int seq = this.seq.getAndIncrement(); - Command cmd = new Command(CommandType.PEEK, receiver, key, null, index, seq, replyQueue, cs, null); + Command cmd = new Command(CommandType.PEEK, receiver, receiver.key, null, receiver.index, seq, replyQueue, cs, null); seqHash.put(seq, cmd); connection.sendCommand(cmd); if (logger.isDebugEnabled()) @@ -114,9 +114,9 @@ @Override - public void quickPeek(Receiver receiver, String key, int index, CodeSegment cs) { + public void quickPeek(Receiver receiver, CodeSegment cs) { int seq = this.seq.getAndIncrement(); - Command cmd = new Command(CommandType.PEEK, receiver, key, null, index, seq, replyQueue, cs, null, true); + Command cmd = new Command(CommandType.PEEK, receiver, receiver.key, null, receiver.index, seq, replyQueue, cs, null, true); seqHash.put(seq, cmd); connection.write(cmd); if (logger.isDebugEnabled())