@Override protected Collection<? extends Operation> cloneGet(KeyedOperation op) { Collection<Operation> rv = new ArrayList<Operation>(); GetOperation.Callback callback = new MultiGetOperationCallback(op.getCallback(), op.getKeys().size()); for (String k : op.getKeys()) { rv.add(get(k, callback)); } return rv; }
public Collection<Operation> clone(KeyedOperation op) { assert op.getState() == OperationState.WRITING : "Who passed me an operation in the " + op.getState() + "state?"; assert !op.isCancelled() : "Attempted to clone a canceled op"; assert !op.hasErrored() : "Attempted to clone an errored op"; op.getKeys().size()); if(op instanceof GetOperation) { rv.addAll(cloneGet(op)); } else if(op instanceof GetsOperation) { GetsOperation.Callback callback = (GetsOperation.Callback)op.getCallback(); for(String k : op.getKeys()) { rv.add(gets(k, callback)); rv.add(cas(cop.getStoreType(), first(op.getKeys()), cop.getCasValue(), cop.getFlags(), cop.getExpiration(), cop.getBytes(), cop.getCallback())); } else if(op instanceof DeleteOperation) { rv.add(delete(first(op.getKeys()), op.getCallback())); } else if(op instanceof MutatorOperation) { MutatorOperation mo = (MutatorOperation)op; rv.add(mutate(mo.getType(), first(op.getKeys()), mo.getBy(), mo.getDefault(), mo.getExpiration(), op.getCallback())); } else if(op instanceof StoreOperation) { StoreOperation so = (StoreOperation)op; rv.add(store(so.getStoreType(), first(op.getKeys()), so.getFlags(), so.getExpiration(), so.getData(), op.getCallback())); } else if(op instanceof ConcatenationOperation) {
private void redistributeOperations(Collection<Operation> ops) { for(Operation op : ops) { if(op instanceof KeyedOperation) { KeyedOperation ko = (KeyedOperation)op; int added = 0; for(String k : ko.getKeys()) { for(Operation newop : opFact.clone(ko)) { addOperation(k, newop); added++; } } assert added > 0 : "Didn't add any new operations when redistributing"; } else { // Cancel things that don't have definite targets. op.cancel(); } } }
public Collection<Operation> clone(KeyedOperation op) { assert op.getState() == OperationState.WRITING : "Who passed me an operation in the " + op.getState() + "state?"; assert !op.isCancelled() : "Attempted to clone a canceled op"; assert !op.hasErrored() : "Attempted to clone an errored op"; op.getKeys().size()); if(op instanceof GetOperation) { rv.addAll(cloneGet(op)); } else if(op instanceof GetsOperation) { GetsOperation.Callback callback = (GetsOperation.Callback)op.getCallback(); for(String k : op.getKeys()) { rv.add(gets(k, callback)); rv.add(cas(cop.getStoreType(), first(op.getKeys()), cop.getCasValue(), cop.getFlags(), cop.getExpiration(), cop.getBytes(), cop.getCallback())); } else if(op instanceof DeleteOperation) { rv.add(delete(first(op.getKeys()), op.getCallback())); } else if(op instanceof MutatorOperation) { MutatorOperation mo = (MutatorOperation)op; rv.add(mutate(mo.getType(), first(op.getKeys()), mo.getBy(), mo.getDefault(), mo.getExpiration(), op.getCallback())); } else if(op instanceof StoreOperation) { StoreOperation so = (StoreOperation)op; rv.add(store(so.getStoreType(), first(op.getKeys()), so.getFlags(), so.getExpiration(), so.getData(), op.getCallback())); } else if(op instanceof ConcatenationOperation) {
private void redistributeOperations(Collection<Operation> ops) { for(Operation op : ops) { if(op instanceof KeyedOperation) { KeyedOperation ko = (KeyedOperation)op; int added = 0; for(String k : ko.getKeys()) { for(Operation newop : opFact.clone(ko)) { addOperation(k, newop); added++; } } assert added > 0 : "Didn't add any new operations when redistributing"; } else { // Cancel things that don't have definite targets. op.cancel(); } } }
public Collection<Operation> clone(KeyedOperation op) { assert (op.getState() == OperationState.WRITE_QUEUED || op.getState() == OperationState.RETRY) : "Who passed me an operation in the " + op.getState() + "state?"; assert !op.isCancelled() : "Attempted to clone a canceled op"; assert !op.hasErrored() : "Attempted to clone an errored op"; Collection<Operation> rv = new ArrayList<Operation>(op.getKeys().size()); if (op instanceof GetOperation) { rv.addAll(cloneGet(op)); } else if (op instanceof GetsOperation) { GetsOperation.Callback callback = (GetsOperation.Callback) op.getCallback(); for (String k : op.getKeys()) { rv.add(gets(k, callback)); rv.add(cas(cop.getStoreType(), first(op.getKeys()), cop.getCasValue(), cop.getFlags(), cop.getExpiration(), cop.getData(), (StoreOperation.Callback) cop.getCallback())); } else if(op instanceof DeleteOperation) { rv.add(delete(first(op.getKeys()), op.getCallback())); } else if (op instanceof MutatorOperation) { MutatorOperation mo = (MutatorOperation) op; rv.add(mutate(mo.getType(), first(op.getKeys()), mo.getBy(), mo.getDefault(), mo.getExpiration(), op.getCallback())); } else if (op instanceof StoreOperation) { StoreOperation so = (StoreOperation) op; rv.add(store(so.getStoreType(), first(op.getKeys()), so.getFlags(), so.getExpiration(), so.getData(), (StoreOperation.Callback) op.getCallback()));
@Override protected Collection<? extends Operation> cloneGet(KeyedOperation op) { Collection<Operation> rv = new ArrayList<Operation>(); GetOperation.Callback callback = new MultiGetOperationCallback(op.getCallback(), op.getKeys().size()); for (String k : op.getKeys()) { rv.add(get(k, callback)); } return rv; }
private void redistributeOperations(Collection<Operation> ops, String cause) { for (Operation op : ops) { if (op instanceof KeyedOperation) { KeyedOperation ko = (KeyedOperation) op; int added = 0; for (String k : ko.getKeys()) { for (Operation newop : opFact.clone(ko)) { addOperation(k, newop); added++; } } assert added > 0 : "Didn't add any new operations when redistributing"; } else { // Cancel things that don't have definite targets. op.cancel(cause); } } }
public Collection<Operation> clone(KeyedOperation op) { assert (op.getState() == OperationState.WRITE_QUEUED || op.getState() == OperationState.RETRY) : "Who passed me an operation in the " + op.getState() + "state?"; assert !op.isCancelled() : "Attempted to clone a canceled op"; assert !op.hasErrored() : "Attempted to clone an errored op"; Collection<Operation> rv = new ArrayList<Operation>(op.getKeys().size()); if (op instanceof GetOperation) { rv.addAll(cloneGet(op)); } else if (op instanceof ReplicaGetsOperation) { ReplicaGetsOperation.Callback callback = (ReplicaGetsOperation.Callback) op.getCallback(); for (String k : op.getKeys()) { rv.add(replicaGets(k, ((ReplicaGetsOperation) op).getReplicaIndex(), callback)); (GetsOperation.Callback) op.getCallback(); for (String k : op.getKeys()) { rv.add(gets(k, callback)); rv.add(cas(cop.getStoreType(), first(op.getKeys()), cop.getCasValue(), cop.getFlags(), cop.getExpiration(), cop.getData(), (StoreOperation.Callback) cop.getCallback())); } else if(op instanceof DeleteOperation) { rv.add(delete(first(op.getKeys()), (DeleteOperation.Callback)op.getCallback())); } else if (op instanceof MutatorOperation) { MutatorOperation mo = (MutatorOperation) op;
@Override protected Collection<? extends Operation> cloneGet(KeyedOperation op) { Collection<Operation> rv = new ArrayList<Operation>(); GetOperation.Callback callback = new MultiGetOperationCallback( op.getCallback(), op.getKeys().size()); for (String k : op.getKeys()) { rv.add(get(k, callback)); } return rv; }
@Override public void addOperations(final Map<MemcachedNode, Operation> ops) { for (Map.Entry<MemcachedNode, Operation> me : ops.entrySet()) { final MemcachedNode node = me.getKey(); if (!node.isActive()) { cf.checkConfigUpdate(); } Operation o = me.getValue(); // add the vbucketIndex to the operation if (locator instanceof VBucketNodeLocator) { if (o instanceof KeyedOperation && o instanceof VBucketAware) { Collection<String> keys = ((KeyedOperation) o).getKeys(); VBucketNodeLocator vbucketLocator = (VBucketNodeLocator) locator; for (String key : keys) { short vbucketIndex = (short) vbucketLocator.getVBucketIndex(key); VBucketAware vbucketAwareOp = (VBucketAware) o; vbucketAwareOp.setVBucket(key, vbucketIndex); } } } o.setHandlingNode(node); o.initialize(); node.addOp(o); addedQueue.offer(node); } updateLastWrite(); Selector s = selector.wakeup(); assert s == selector : "Wakeup returned the wrong selector."; }
public Collection<Operation> clone(KeyedOperation op) { assert (op.getState() == OperationState.WRITE_QUEUED || op.getState() == OperationState.RETRY) : "Who passed me an operation in the " + op.getState() + "state?"; assert !op.isCancelled() : "Attempted to clone a canceled op"; assert !op.hasErrored() : "Attempted to clone an errored op"; Collection<Operation> rv = new ArrayList<Operation>(op.getKeys().size()); if (op instanceof GetOperation) { rv.addAll(cloneGet(op)); } else if (op instanceof ReplicaGetsOperation) { ReplicaGetsOperation.Callback callback = (ReplicaGetsOperation.Callback) op.getCallback(); for (String k : op.getKeys()) { rv.add(replicaGets(k, ((ReplicaGetsOperation) op).getReplicaIndex(), callback)); (GetsOperation.Callback) op.getCallback(); for (String k : op.getKeys()) { rv.add(gets(k, callback)); rv.add(cas(cop.getStoreType(), first(op.getKeys()), cop.getCasValue(), cop.getFlags(), cop.getExpiration(), cop.getData(), (StoreOperation.Callback) cop.getCallback())); } else if(op instanceof DeleteOperation) { rv.add(delete(first(op.getKeys()), (DeleteOperation.Callback)op.getCallback())); } else if (op instanceof MutatorOperation) { MutatorOperation mo = (MutatorOperation) op;
@Override protected Collection<? extends Operation> cloneGet(KeyedOperation op) { Collection<Operation> rv = new ArrayList<Operation>(); GetOperation.Callback callback = new MultiGetOperationCallback(op.getCallback(), op.getKeys().size()); for (String k : op.getKeys()) { rv.add(get(k, callback)); } return rv; }
private void redistributeOperations(Collection<Operation> ops) { for (Operation op : ops) { if (op.isCancelled() || op.isTimedOut()) { continue; } if (op instanceof KeyedOperation) { KeyedOperation ko = (KeyedOperation) op; int added = 0; for (String k : ko.getKeys()) { for (Operation newop : opFact.clone(ko)) { addOperation(k, newop); added++; } } assert added > 0 : "Didn't add any new operations when redistributing"; } else { // Cancel things that don't have definite targets. op.cancel(); } } }
public Collection<Operation> clone(KeyedOperation op) { assert op.getState() == OperationState.WRITING : "Who passed me an operation in the " + op.getState() + "state?"; assert !op.isCancelled() : "Attempted to clone a canceled op"; assert !op.hasErrored() : "Attempted to clone an errored op"; op.getKeys().size()); if (op instanceof GetOperation) { rv.addAll(cloneGet(op)); } else if (op instanceof GetsOperation) { GetsOperation.Callback callback = (GetsOperation.Callback) op.getCallback(); for (String k : op.getKeys()) { rv.add(gets(k, callback)); rv.add(cas(cop.getStoreType(), first(op.getKeys()), cop.getCasValue(), cop.getFlags(), cop.getExpiration(), cop.getBytes(), cop.getCallback())); } else if (op instanceof DeleteOperation) { rv.add(delete(first(op.getKeys()), op.getCallback())); } else if (op instanceof MutatorOperation) { MutatorOperation mo = (MutatorOperation) op; rv.add(mutate(mo.getType(), first(op.getKeys()), mo.getBy(), mo.getDefault(), mo.getExpiration(), op.getCallback())); } else if (op instanceof StoreOperation) { StoreOperation so = (StoreOperation) op; rv.add(store(so.getStoreType(), first(op.getKeys()), so.getFlags(), so.getExpiration(), so.getData(), op.getCallback())); } else if (op instanceof ConcatenationOperation) {
@Override protected Collection<? extends Operation> cloneGet(KeyedOperation op) { Collection<Operation> rv=new ArrayList<Operation>(); GetOperation.Callback callback = new MultiGetOperationCallback( op.getCallback(), op.getKeys().size()); for(String k : op.getKeys()) { rv.add(get(k, callback)); } return rv; }
KeyedOperation ko = (KeyedOperation) op; int added = 0; for (String k : ko.getKeys()) { for (Operation newop : opFact.clone(ko)) { addOperation(k, newop);
@Override protected Collection<? extends Operation> cloneGet(KeyedOperation op) { Collection<Operation> rv=new ArrayList<Operation>(); GetOperation.Callback callback = new MultiGetOperationCallback( op.getCallback(), op.getKeys().size()); for(String k : op.getKeys()) { rv.add(get(k, callback)); } return rv; }
if (newop instanceof KeyedOperation) { KeyedOperation newKeyedOp = (KeyedOperation) newop; for (String k : newKeyedOp.getKeys()) { addOperation(k, newop); op.addClone(newop);
@Override protected Collection<? extends Operation> cloneGet(KeyedOperation op) { Collection<Operation> rv=new ArrayList<Operation>(); GetOperation.Callback getCb = null; GetsOperation.Callback getsCb = null; if(op.getCallback() instanceof GetOperation.Callback) { getCb=new MultiGetOperationCallback( op.getCallback(), op.getKeys().size()); } else { getsCb=new MultiGetsOperationCallback( op.getCallback(), op.getKeys().size()); } for(String k : op.getKeys()) { rv.add(getCb == null ? gets(k, getsCb) : get(k, getCb)); } return rv; }