# HG changeset patch # User sugi # Date 1371539153 -32400 # Node ID b78f52865b8d68d66e8119adfc7f4a260de06d85 # Parent 88be2824a98981b86d6c221c88cedf07bd4a5ac6 no use Queue API diff -r 88be2824a989 -r b78f52865b8d src/alice/datasegment/Command.java --- a/src/alice/datasegment/Command.java Mon Jun 17 18:56:54 2013 +0900 +++ b/src/alice/datasegment/Command.java Tue Jun 18 16:05:53 2013 +0900 @@ -36,6 +36,19 @@ this.flag = false; } + public Command(CommandType cmdType, Receiver receiver, String key, Value val, int index, int seq, BlockingQueue replyQueue, CodeSegment cs, String reverseKey, boolean flag) { + this.type = cmdType; + this.receiver = receiver; + this.key = key; + this.val = val; + this.index = index; + this.seq = seq; + this.replyQueue = replyQueue; + this.cs = cs; + this.reverseKey = reverseKey; + this.flag = flag; + } + public Command(CommandType cmdType, Receiver receiver, String key, Value val, int index, int seq, Connection connection, CodeSegment cs, String reverseKey, boolean flag) { this.type = cmdType; this.receiver = receiver; diff -r 88be2824a989 -r b78f52865b8d src/alice/datasegment/DataSegmentManager.java --- a/src/alice/datasegment/DataSegmentManager.java Mon Jun 17 18:56:54 2013 +0900 +++ b/src/alice/datasegment/DataSegmentManager.java Tue Jun 18 16:05:53 2013 +0900 @@ -65,4 +65,19 @@ public abstract void close(); public abstract void finish(); + 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); + + } diff -r 88be2824a989 -r b78f52865b8d src/alice/datasegment/LocalDataSegmentManager.java --- a/src/alice/datasegment/LocalDataSegmentManager.java Mon Jun 17 18:56:54 2013 +0900 +++ b/src/alice/datasegment/LocalDataSegmentManager.java Tue Jun 18 16:05:53 2013 +0900 @@ -146,4 +146,26 @@ } + @Override + public void quickPeek(Receiver receiver, String key, int index, CodeSegment cs) { + + } + + @Override + public void quickTake(Receiver receiver, String key, int index, CodeSegment cs) { + + } + + @Override + public void quickPut(String key, Value val) { + + } + + @Override + public void quickUpdate(String key, Value val) { + + } + + + } diff -r 88be2824a989 -r b78f52865b8d src/alice/datasegment/RemoteDataSegmentManager.java --- a/src/alice/datasegment/RemoteDataSegmentManager.java Mon Jun 17 18:56:54 2013 +0900 +++ b/src/alice/datasegment/RemoteDataSegmentManager.java Tue Jun 18 16:05:53 2013 +0900 @@ -58,12 +58,29 @@ } @Override + public void quickPut(String key, Value val) { + Command cmd = new Command(CommandType.PUT, null, key, val, 0, 0, null, null, null); + connection.write(cmd); // put command is executed right now + if (logger.isDebugEnabled()) + logger.debug(cmd.getCommandString()); + } + + @Override public void update(String key, Value val) { Command cmd = new Command(CommandType.UPDATE, null, key, val, 0, 0, null, null, null); connection.sendCommand(cmd); if (logger.isDebugEnabled()) logger.debug(cmd.getCommandString()); } + + @Override + public void quickUpdate(String key, Value val) { + Command cmd = new Command(CommandType.UPDATE, null, key, val, 0, 0, null, null, null); + connection.write(cmd); + if (logger.isDebugEnabled()) + logger.debug(cmd.getCommandString()); + + } @Override public void take(Receiver receiver, String key, int index, CodeSegment cs) { @@ -74,6 +91,16 @@ if (logger.isDebugEnabled()) logger.debug(cmd.getCommandString()); } + + @Override + public void quickTake(Receiver receiver, String key, int index, CodeSegment cs) { + int seq = this.seq.getAndIncrement(); + Command cmd = new Command(CommandType.TAKE, receiver, key, null, index, seq, replyQueue, cs, null); + seqHash.put(seq, cmd); + connection.write(cmd); + if (logger.isDebugEnabled()) + logger.debug(cmd.getCommandString()); + } @Override public void peek(Receiver receiver, String key, int index, CodeSegment cs) { @@ -84,6 +111,18 @@ if (logger.isDebugEnabled()) logger.debug(cmd.getCommandString()); } + + + @Override + public void quickPeek(Receiver receiver, String key, int index, CodeSegment cs) { + int seq = this.seq.getAndIncrement(); + Command cmd = new Command(CommandType.PEEK, receiver, key, null, index, seq, replyQueue, cs, null, true); + seqHash.put(seq, cmd); + connection.write(cmd); + if (logger.isDebugEnabled()) + logger.debug(cmd.getCommandString()); + + } @Override public void remove(String key) { @@ -105,4 +144,5 @@ connection.sendCommand(cmd); } + }