public GetOperation get(Collection<String> value, Callback cb) { return new MultiGetOperationImpl(value, cb); }
public MultiGetOperationImpl(Collection<String> k, OperationCallback cb) { super(DUMMY_OPCODE, -1, cb); for (String s : new HashSet<String>(k)) { addKey(s); } }
@Override protected void finishedPayload(byte[] pl) throws IOException { if (responseOpaque == terminalOpaque) { getCallback().receivedStatus(STATUS_OK); transitionState(OperationState.COMPLETE); } else if (errorCode != 0) { getLogger().warn("Error on key %s: %s (%d)", keys.get(responseOpaque), new String(pl), errorCode); } else { final int flags = decodeInt(pl, 0); final byte[] data = new byte[pl.length - EXTRA_HDR_LEN]; System.arraycopy(pl, EXTRA_HDR_LEN, data, 0, pl.length - EXTRA_HDR_LEN); Callback cb = (Callback) getCallback(); cb.gotData(keys.get(responseOpaque), flags, data); } resetInput(); }
/** * Add a key (and return its new opaque value). */ protected int addKey(String k) { Integer rv=rkeys.get(k); if(rv == null) { rv=generateOpaque(); keys.put(rv, k); bkeys.put(rv, KeyUtil.getKeyBytes(k)); rkeys.put(k, rv); } return rv; }
@Override protected void finishedPayload(byte[] pl) throws IOException { if (responseOpaque == terminalOpaque) { getCallback().receivedStatus(STATUS_OK); transitionState(OperationState.COMPLETE); } else if (errorCode != 0) { getLogger().warn("Error on key %s: %s (%d)", keys.get(responseOpaque), new String(pl), errorCode); } else { final int flags = decodeInt(pl, 0); final byte[] data = new byte[pl.length - EXTRA_HDR_LEN]; System.arraycopy(pl, EXTRA_HDR_LEN, data, 0, pl.length - EXTRA_HDR_LEN); Callback cb = (Callback) getCallback(); cb.gotData(keys.get(responseOpaque), flags, data); } resetInput(); }
/** * Add a key (and return its new opaque value). */ protected int addKey(String k) { Integer rv = rkeys.get(k); if (rv == null) { rv = generateOpaque(); keys.put(rv, k); bkeys.put(rv, KeyUtil.getKeyBytes(k)); rkeys.put(k, rv); synchronized (vbmap) { vbmap.put(k, new Short((short) 0)); } } return rv; }
@Override protected void finishedPayload(byte[] pl) throws IOException { if(responseOpaque == terminalOpaque) { getCallback().receivedStatus(STATUS_OK); transitionState(OperationState.COMPLETE); } else if(errorCode != 0) { getLogger().warn("Error on key %s: %s (%d)", keys.get(responseOpaque), new String(pl), errorCode); } else { final int flags=decodeInt(pl, 0); final byte[] data=new byte[pl.length - EXTRA_HDR_LEN]; System.arraycopy(pl, EXTRA_HDR_LEN, data, 0, pl.length-EXTRA_HDR_LEN); Callback cb=(Callback)getCallback(); cb.gotData(keys.get(responseOpaque), flags, data); } resetInput(); }
public MultiGetOperationImpl(Collection<String> k, OperationCallback cb) { super(-1, -1, cb); for(String s : new HashSet<String>(k)) { addKey(s); } }
/** * Add a key (and return its new opaque value). */ protected int addKey(String k) { Integer rv=rkeys.get(k); if(rv == null) { rv=generateOpaque(); keys.put(rv, k); bkeys.put(rv, KeyUtil.getKeyBytes(k)); rkeys.put(k, rv); } return rv; }
public GetOperation get(Collection<String> value, Callback cb) { return new MultiGetOperationImpl(value, cb); }
@Override protected void finishedPayload(byte[] pl) throws IOException { if(responseOpaque == terminalOpaque) { getCallback().receivedStatus(STATUS_OK); transitionState(OperationState.COMPLETE); } else if(errorCode != 0) { getLogger().warn("Error on key %s: %s (%d)", keys.get(responseOpaque), new String(pl), errorCode); } else { final int flags=decodeInt(pl, 0); final byte[] data=new byte[pl.length - EXTRA_HDR_LEN]; System.arraycopy(pl, EXTRA_HDR_LEN, data, 0, pl.length-EXTRA_HDR_LEN); Callback cb=(Callback)getCallback(); cb.gotData(keys.get(responseOpaque), flags, data); } resetInput(); }
public MultiGetOperationImpl(Collection<String> k, OperationCallback cb) { super(DUMMY_OPCODE, -1, cb); for (String s : new HashSet<String>(k)) { addKey(s); } }
/** * Add a key (and return its new opaque value). */ protected int addKey(String k) { Integer rv = rkeys.get(k); if (rv == null) { rv = generateOpaque(); keys.put(rv, k); bkeys.put(rv, KeyUtil.getKeyBytes(k)); rkeys.put(k, rv); } return rv; }
public GetOperation get(Collection<String> value, Callback cb) { return new MultiGetOperationImpl(value, cb); }
@Override protected void finishedPayload(byte[] pl) throws IOException { getStatusForErrorCode(errorCode, pl); if (responseOpaque == terminalOpaque) { if (retryKeys.size() > 0) { transitionState(OperationState.RETRY); OperationStatus retryStatus = new OperationStatus(true, Integer.toString(retryKeys.size()), StatusCode.ERR_NOT_MY_VBUCKET); getCallback().receivedStatus(retryStatus); getCallback().complete(); } else { getCallback().receivedStatus(STATUS_OK); transitionState(OperationState.COMPLETE); } } else if (errorCode == ERR_NOT_MY_VBUCKET) { retryKeys.add(keys.get(responseOpaque)); } else if (errorCode != SUCCESS) { getLogger().warn("Error on key %s: %s (%d)", keys.get(responseOpaque), new String(pl), errorCode); } else { final int flags = decodeInt(pl, 0); final byte[] data = new byte[pl.length - EXTRA_HDR_LEN]; System.arraycopy(pl, EXTRA_HDR_LEN, data, 0, pl.length - EXTRA_HDR_LEN); Callback cb = (Callback) getCallback(); cb.gotData(keys.get(responseOpaque), flags, data); } resetInput(); }
public MultiGetOperationImpl(Collection<String> k, OperationCallback cb) { super(-1, -1, cb); for(String s : new HashSet<String>(k)) { addKey(s); } }