public void maybeFinish(ClientContext context) { boolean success; boolean wasFatal; synchronized(this) { if(completedBlocks != inserters.length) return; success = completedBlocks == succeededBlocks; wasFatal = fatal; } if(success) { parent.onSuccess(this, context); } else if(wasFatal) parent.onFailure(new InsertException(InsertExceptionMode.FATAL_ERRORS_IN_BLOCKS, errors, null), this, context); else parent.onFailure(new InsertException(InsertExceptionMode.TOO_MANY_RETRIES_IN_BLOCKS, errors, null), this, context); }
@Override public void cancel(ClientContext context) { for(MySendableInsert inserter: inserters) { if(inserter != null) inserter.cancel(context); } parent.onFailure(new InsertException(InsertExceptionMode.CANCELLED), this, 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); }
@Override public void innerOnResume(ClientContext context) throws ResumeFailedException { super.innerOnResume(context); if(currentState != null) { try { currentState.onResume(context); } catch (InsertException e) { this.onFailure(e, null, context); return; } } if(data != null) data.onResume(context); notifyClients(context); }