@Override public boolean run(ClientContext context) { cb.onEncode(key, SingleBlockInserter.this, context); return false; }
@Override public void run() { cb.onEncode(key, SingleBlockInserter.this, context); } }, "Got URI");
@Override public void onEncode(BaseClientKey key, ClientPutState state, ClientContext context) { synchronized(this) { if(state != generator) return; if(encodedKey != null) { if(key.equals(encodedKey)) return; // Squash duplicated call to onEncode(). else Logger.error(this, "Encoded twice with different keys for "+this+" : "+encodedKey+" -> "+key); } encodedKey = key; } cb.onEncode(key, this, context); }
@Override public void onEncode(BaseClientKey key, ClientPutState state, ClientContext context) { if(persistent) // FIXME debug-point if(logMINOR) Logger.minor(this, "onEncode() for "+this+" : "+state+" : "+key); synchronized(this) { if(state != metadataPutter) { if(logMINOR) Logger.minor(this, "ignored onEncode() for "+this+" : "+state); return; } } cb.onEncode(key, this, context); }
@Override public void innerOnResume(ClientContext context) throws InsertException, ResumeFailedException { sourceData.onResume(context); if(cb != parent) cb.onResume(context); if(resultingKey != null) cb.onEncode(resultingKey, SingleBlockInserter.this, context); this.schedule(context); }
cb.onEncode(pubUSK.copy(edition), this, context); insertSucceeded(context, l); if(freeData) {
protected ClientKeyBlock encode(ClientContext context, boolean calledByCB) throws InsertException { ClientKeyBlock block; boolean shouldSend; synchronized(this) { if(finished) return null; if(sourceData == null) { Logger.error(this, "Source data is null on "+this+" but not finished!"); return null; } block = innerEncode(context.random); shouldSend = (resultingKey == null); resultingKey = block.getClientKey(); } if(logMINOR) Logger.minor(this, "Encoded "+resultingKey.getURI()+" for "+this+" shouldSend="+shouldSend+" dontSendEncoded="+dontSendEncoded); if(shouldSend && !dontSendEncoded) cb.onEncode(block.getClientKey(), this, context); return block; }
@Override public synchronized void onSuccess(ClientPutState state, ClientContext context) { USK newEdition = pubUSK.copy(edition); finished = true; sbi = null; FreenetURI targetURI = pubUSK.getSSK(edition).getURI(); FreenetURI realURI = ((SingleBlockInserter)state).getURI(context); if(!targetURI.equals(realURI)) Logger.error(this, "URI should be "+targetURI+" actually is "+realURI); else { if(logMINOR) Logger.minor(this, "URI should be "+targetURI+" actually is "+realURI); context.uskManager.updateKnownGood(pubUSK, edition, context); } if(freeData) { data.free(); data = null; } cb.onEncode(newEdition, this, context); insertSucceeded(context, edition); // FINISHED!!!! Yay!!! }
if(logMINOR) Logger.minor(this, "Calling onSuccess for "+cb); if(shouldSendKey) cb.onEncode(key, this, context); // In case of race conditions etc, especially for LocalRequestOnly. cb.onSuccess(this, context);