@Override public final void handleLine(String line) { if (line.equals("END")) { getLogger().debug("Get complete!"); getCallback().receivedStatus(END); transitionState(OperationState.COMPLETE); data = null; } else if (line.startsWith("VALUE ")) { getLogger().debug("Got line %s", line); String[] stuff = line.split(" "); assert stuff[0].equals("VALUE"); currentKey = stuff[1]; currentFlags = Integer.parseInt(stuff[2]); data = new byte[Integer.parseInt(stuff[3])]; if (stuff.length > 4) { casValue = Long.parseLong(stuff[4]); } readOffset = 0; getLogger().debug("Set read type to data"); setReadType(OperationReadType.DATA); } else { assert false : "Unknown line type: " + line; } }
@Override public final void initialize() { // Figure out the length of the request int size = 6; // Enough for gets\r\n Collection<byte[]> keyBytes = KeyUtil.getKeyBytes(keys); for (byte[] k : keyBytes) { size += k.length; size++; } size += afterKeyBytesSize(); ByteBuffer b = ByteBuffer.allocate(size); b.put(cmd.getBytes()); for (byte[] k : keyBytes) { b.put((byte) ' '); b.put(k); } afterKeyBytes(b); b.put(RN_BYTES); b.flip(); setBuffer(b); }
: "readOffset is " + readOffset + " data.length is " + data.length; getLogger().debug("readOffset: %d, length: %d", readOffset, data.length); int available=b.remaining(); toRead=Math.min(toRead, available); getLogger().debug("Reading %d bytes", toRead); b.get(data, readOffset, toRead); readOffset+=toRead; GetOperation.Callback gcb=(GetOperation.Callback)getCallback(); gcb.gotData(currentKey, currentFlags, data); } catch(ClassCastException e) { GetsOperation.Callback gcb=(GetsOperation.Callback) getCallback(); gcb.gotData(currentKey, currentFlags, casValue, data); readOffset=0; currentFlags=0; getLogger().debug("Setting read type back to line."); setReadType(OperationReadType.LINE);
@Override protected final void wasCancelled() { getCallback().receivedStatus(CANCELLED); }
@Override public final void initialize() { // Figure out the length of the request int size=6; // Enough for gets\r\n Collection<byte[]> keyBytes=KeyUtil.getKeyBytes(keys); for(byte[] k : keyBytes) { size+=k.length; size++; } ByteBuffer b=ByteBuffer.allocate(size); b.put(cmd.getBytes()); for(byte[] k : keyBytes) { b.put((byte)' '); b.put(k); } b.put(RN_BYTES); b.flip(); setBuffer(b); }
ByteBuffer b; String keysString = generateKeysString(); b.put(commandLine); b.flip(); setBuffer(b);
: "readOffset is " + readOffset + " data.length is " + data.length; getLogger().debug("readOffset: %d, length: %d", readOffset, data.length); int available = b.remaining(); toRead = Math.min(toRead, available); getLogger().debug("Reading %d bytes", toRead); b.get(data, readOffset, toRead); readOffset += toRead; GetOperation.Callback gcb = (GetOperation.Callback) getCallback(); gcb.gotData(currentKey, currentFlags, data); } catch (ClassCastException e) { GetsOperation.Callback gcb = (GetsOperation.Callback) getCallback(); gcb.gotData(currentKey, currentFlags, casValue, data); readOffset = 0; currentFlags = 0; getLogger().debug("Setting read type back to line."); setReadType(OperationReadType.LINE);
@Override protected final void wasCancelled() { getCallback().receivedStatus(CANCELLED); }
@Override public final void initialize() { // Figure out the length of the request int size=6; // Enough for gets\r\n Collection<byte[]> keyBytes=KeyUtil.getKeyBytes(keys); for(byte[] k : keyBytes) { size+=k.length; size++; } ByteBuffer b=ByteBuffer.allocate(size); b.put(cmd.getBytes()); for(byte[] k : keyBytes) { b.put((byte)' '); b.put(k); } b.put("\r\n".getBytes()); b.flip(); setBuffer(b); }
@Override public final void handleLine(String line) { if(line.equals("END")) { getLogger().debug("Get complete!"); getCallback().receivedStatus(END); transitionState(OperationState.COMPLETE); data=null; } else if(line.startsWith("VALUE ")) { getLogger().debug("Got line %s", line); String[] stuff=line.split(" "); assert stuff[0].equals("VALUE"); currentKey=stuff[1]; currentFlags=Integer.parseInt(stuff[2]); data=new byte[Integer.parseInt(stuff[3])]; if(stuff.length > 4) { casValue=Long.parseLong(stuff[4]); } readOffset=0; getLogger().debug("Set read type to data"); setReadType(OperationReadType.DATA); } else { assert false : "Unknown line type: " + line; } }
: "readOffset is " + readOffset + " data.length is " + data.length; getLogger().debug("readOffset: %d, length: %d", readOffset, data.length); int available=b.remaining(); toRead=Math.min(toRead, available); getLogger().debug("Reading %d bytes", toRead); b.get(data, readOffset, toRead); readOffset+=toRead; GetOperation.Callback gcb=(GetOperation.Callback)getCallback(); gcb.gotData(currentKey, currentFlags, data); } catch(ClassCastException e) { GetsOperation.Callback gcb=(GetsOperation.Callback) getCallback(); gcb.gotData(currentKey, currentFlags, casValue, data); readOffset=0; currentFlags=0; getLogger().debug("Setting read type back to line."); setReadType(OperationReadType.LINE);
@Override protected final void wasCancelled() { getCallback().receivedStatus(CANCELLED); }
@Override public final void initialize() { // Figure out the length of the request int size = 6; // Enough for gets\r\n Collection<byte[]> keyBytes = KeyUtil.getKeyBytes(keys); for (byte[] k : keyBytes) { size += k.length; size++; } size += afterKeyBytesSize(); ByteBuffer b = ByteBuffer.allocate(size); b.put(cmd.getBytes()); for (byte[] k : keyBytes) { b.put((byte) ' '); b.put(k); } afterKeyBytes(b); b.put(RN_BYTES); b.flip(); setBuffer(b); }
@Override public final void initialize() { // Figure out the length of the request int size = 6; // Enough for gets\r\n Collection<byte[]> keyBytes = KeyUtil.getKeyBytes(keys); for (byte[] k : keyBytes) { size += k.length; size++; } byte[] e = String.valueOf(exp).getBytes(); if (hasExp) { size += e.length + 1; } ByteBuffer b = ByteBuffer.allocate(size); b.put(cmd.getBytes()); for (byte[] k : keyBytes) { b.put((byte) ' '); b.put(k); } if (hasExp) { b.put((byte) ' '); b.put(e); } b.put(RN_BYTES); b.flip(); setBuffer(b); }
@Override public final void handleLine(String line) { if(line.equals("END")) { getLogger().debug("Get complete!"); getCallback().receivedStatus(END); transitionState(OperationState.COMPLETE); data=null; } else if(line.startsWith("VALUE ")) { getLogger().debug("Got line %s", line); String[] stuff=line.split(" "); assert stuff[0].equals("VALUE"); currentKey=stuff[1]; currentFlags=Integer.parseInt(stuff[2]); data=new byte[Integer.parseInt(stuff[3])]; if(stuff.length > 4) { casValue=Long.parseLong(stuff[4]); } readOffset=0; getLogger().debug("Set read type to data"); setReadType(OperationReadType.DATA); } else { assert false : "Unknown line type: " + line; } }
+ " data.length is " + data.length; getLogger().debug("readOffset: %d, length: %d", readOffset, data.length); int available = b.remaining(); toRead = Math.min(toRead, available); getLogger().debug("Reading %d bytes", toRead); b.get(data, readOffset, toRead); readOffset += toRead; OperationCallback cb = getCallback(); if (cb instanceof GetOperation.Callback) { GetOperation.Callback gcb = (GetOperation.Callback) cb; readOffset = 0; currentFlags = 0; getLogger().debug("Setting read type back to line."); setReadType(OperationReadType.LINE);
@Override protected final void wasCancelled() { getCallback().receivedStatus(CANCELLED); }
@Override public final void handleLine(String line) { if (line.equals("END")) { getLogger().debug("Get complete!"); if (hasValue) { getCallback().receivedStatus(END); } else { getCallback().receivedStatus(NOT_FOUND); transitionState(OperationState.COMPLETE); data = null; } else if (line.startsWith("VALUE ")) { getLogger().debug("Got line %s", line); String[] stuff = line.split(" "); assert stuff[0].equals("VALUE"); getLogger().debug("Set read type to data"); setReadType(OperationReadType.DATA); } else if (line.equals("LOCK_ERROR")) { getCallback().receivedStatus(LOCK_ERROR); transitionState(OperationState.COMPLETE); } else { assert false : "Unknown line type: " + line;
+ " data.length is " + data.length; getLogger().debug("readOffset: %d, length: %d", readOffset, data.length); int available = b.remaining(); toRead = Math.min(toRead, available); getLogger().debug("Reading %d bytes", toRead); b.get(data, readOffset, toRead); readOffset += toRead; OperationCallback cb = getCallback(); if (cb instanceof GetOperation.Callback) { GetOperation.Callback gcb = (GetOperation.Callback) cb; readOffset = 0; currentFlags = 0; getLogger().debug("Setting read type back to line."); setReadType(OperationReadType.LINE);
@Override protected final void wasCancelled() { getCallback().receivedStatus(CANCELLED); }