@Override public void cancel(ClientContext context) { ClientPutState[] states = new ClientPutState[waitingFor.size()]; synchronized(this) { states = waitingFor.toArray(states); } boolean logDEBUG = Logger.shouldLog(LogLevel.DEBUG, this); for(int i=0;i<states.length;i++) { if(logDEBUG) Logger.minor(this, "Cancelling state "+i+" of "+states.length+" : "+states[i]); states[i].cancel(context); } }
@Override public void cancel(ClientContext context) { if(logMINOR) Logger.minor(this, "Cancelling "+this); ClientPutState oldSFI = null; ClientPutState oldMetadataPutter = null; synchronized(this) { oldSFI = sfi; oldMetadataPutter = metadataPutter; } if(oldSFI != null) oldSFI.cancel(context); if(oldMetadataPutter != null) oldMetadataPutter.cancel(context); // FIXME in the other cases, fail() and onSuccess(), we only free when // we set finished. But we haven't set finished here. Can we rely on // the callback and not do anything here? Note that it is in fact safe // to double-free, it's not safe to not free. if(freeData) { block.free(); } else { block.nullData(); } }
private void fail(InsertException e, ClientContext context) { if(logMINOR) Logger.minor(this, "Failing: "+e, e); ClientPutState oldSFI = null; ClientPutState oldMetadataPutter = null; synchronized(this) { if(finished){ return; } finished = true; oldSFI = sfi; oldMetadataPutter = metadataPutter; } if(oldSFI != null) oldSFI.cancel(context); if(oldMetadataPutter != null) oldMetadataPutter.cancel(context); synchronized(this) { if(freeData) block.free(); else { block.nullData(); } } cb.onFailure(e, this, context); }
@Override public void cancel(ClientContext context) { if(logMINOR) Logger.minor(this, "Cancelling "+this, new Exception("debug")); ClientPutState oldState = null; synchronized(this) { if(cancelled) return; super.cancel(); oldState = currentState; } if(oldState != null) oldState.cancel(context); onFailure(new InsertException(InsertExceptionMode.CANCELLED), oldState, context); }
/** Cancel the insert. Will call onFailure() if it is not already cancelled, so the callback will * normally be called. */ @Override public void cancel(ClientContext context) { if(logMINOR) Logger.minor(this, "Cancelling "+this, new Exception("debug")); ClientPutState oldState = null; synchronized(this) { if(cancelled) return; if(finished) return; super.cancel(); oldState = currentState; } if(oldState != null) oldState.cancel(context); onFailure(new InsertException(InsertExceptionMode.CANCELLED), null, context); }