public synchronized void addURIGenerator(ClientPutState ps) { add(ps); generator = ps; }
public void arm(ClientContext context) { if(logMINOR) Logger.minor(this, "Arming "+this); boolean allDone; boolean allGotBlocks; boolean doCancel; synchronized(this) { started = true; allDone = waitingFor.isEmpty(); allGotBlocks = waitingForBlockSet.isEmpty(); doCancel = cancelling; } if(allGotBlocks) { cb.onBlockSetFinished(this, context); } if(allDone) { complete(e, context); } else if(doCancel) { cancel(context); } }
@Override public void onShutdown(ClientContext context) { for(ClientPutState state : getWaitingFor()) { state.onShutdown(context); } }
new MultiPutCompletionCallback(cb, parent, token, persistent, false, ctx.earlyEncode); SingleBlockInserter dataPutter = new SingleBlockInserter(parent, data, codecNumber, FreenetURI.EMPTY_CHK_URI, ctx, realTimeFlag, mcb, metadata, (int)origSize, -1, true, false, token, context, persistent, shouldFreeData, forSplitfile ? ctx.extraInsertsSplitfileHeaderBlock : ctx.extraInsertsSingleBlock, cryptoAlgorithm, forceCryptoKey); if(logMINOR) if(logMINOR) Logger.minor(this, "Inserting metadata: "+metaPutter+" for "+this); mcb.addURIGenerator(metaPutter); mcb.add(dataPutter); cb.onTransition(this, mcb, context); Logger.minor(this, ""+mcb+" : data "+dataPutter+" meta "+metaPutter); mcb.arm(context); dataPutter.schedule(context); if(ctx.earlyEncode && metaPutter instanceof SingleBlockInserter)
@Override public void onSuccess(ClientPutState state, ClientContext context) { onBlockSetFinished(state, context); onFetchable(state); boolean complete = true; synchronized(this) { if(finished) { Logger.error(this, "Already finished but got onSuccess() for "+state+" on "+this); return; } ListUtils.removeBySwapLast(waitingFor,state); ListUtils.removeBySwapLast(waitingForBlockSet,state); ListUtils.removeBySwapLast(waitingForFetchable,state); if(!(waitingFor.isEmpty() && started)) { complete = false; } if(state == generator) { generator = null; } } if(complete) { Logger.minor(this, "Completing..."); complete(null, context); } }
MultiPutCompletionCallback m = new MultiPutCompletionCallback(cb, parent, tokenObject, persistent, true); byte[] hintData; try { ctx, realTimeFlag, m, false, sourceLength, token, true, true /* we don't use it */, null, context, persistent, true, extraInserts, cryptoAlgorithm, forceCryptoKey); Logger.normal(this, "Inserting "+uri+" with "+sb+" for insert of "+pubUSK); m.add(sb); sb.schedule(context); added = true; m.arm(context);
@Override public void onResume(ClientContext context) throws InsertException, ResumeFailedException { synchronized(this) { if(resumed) return; resumed = true; } for(ClientPutState s : getWaitingFor()) s.onResume(context); if(cb != parent) cb.onResume(context); }