@Override public void onBlockSetFinished(ClientPutState state, ClientContext context) { synchronized(this) { ListUtils.removeBySwapLast(this.waitingForBlockSet,state); if(!started) return; if(!waitingForBlockSet.isEmpty()) return; } cb.onBlockSetFinished(this, context); }
@Override public boolean run(ClientContext context) { inserter.cb.onFailure(e, inserter, context); return true; }
private void insertSucceeded(ClientContext context, long edition) { if(ctx.ignoreUSKDatehints) { if(logMINOR) Logger.minor(this, "Inserted to edition "+edition); cb.onSuccess(this, context); return; Logger.error(this, "Unable to insert USK date hints due to disk I/O error: "+e, e); if(!added) { cb.onFailure(new InsertException(InsertExceptionMode.BUCKET_ERROR, e, pubUSK.getSSK(edition).getURI()), this, context); return; Logger.error(this, "Unable to insert USK date hints due to error: "+e, e); if(!added) { cb.onFailure(e, this, context); return; cb.onTransition(this, m, context); m.arm(context);
if(logMINOR) Logger.minor(this, "Inserting without metadata: "+bi+" for "+this); cb.onTransition(this, bi, context); if(ctx.earlyEncode && bi instanceof SingleBlockInserter && isCHK) ((SingleBlockInserter)bi).getBlock(context, true); bi.schedule(context); if(!isUSK) cb.onBlockSetFinished(this, context); synchronized(this) { started = true; Logger.minor(this, "Inserting with metadata: "+dataPutter+" for "+this); Metadata meta = makeMetadata(archiveType, dataPutter.getURI(context), hashes); cb.onMetadata(meta, this, context); cb.onTransition(this, dataPutter, context); dataPutter.schedule(context); if(!isUSK) cb.onBlockSetFinished(this, context); synchronized(this) { mcb.addURIGenerator(metaPutter); mcb.add(dataPutter); cb.onTransition(this, mcb, context); Logger.minor(this, ""+mcb+" : data "+dataPutter+" meta "+metaPutter); mcb.arm(context); metaPutter.schedule(context); if(!isUSK) cb.onBlockSetFinished(this, context);
@Override public boolean run(ClientContext context) { cb.onEncode(key, SingleBlockInserter.this, context); return false; }
private void complete(InsertException e, ClientContext context) { synchronized(this) { if(finished) return; finished = true; if(e != null && this.e != null && this.e != e) { if(e.getMode() == InsertExceptionMode.CANCELLED) { // Cancelled is okay, ignore it, we cancel after failure sometimes. // Ignore the new failure mode, use the old one e = this.e; if(persistent) { e = e.clone(); // Since we will remove it, we can't pass it on } } else { // Delete the old failure mode, use the new one this.e = e; } } if(e == null) { e = this.e; if(persistent && e != null) { e = e.clone(); // Since we will remove it, we can't pass it on } } } if(e != null) cb.onFailure(e, this, context); else cb.onSuccess(this, context); }
protected void reportMetadata(Metadata metadata) { // Splitfile insert is always reportMetadataOnly, i.e. it always passes the metadata back // to the parent SingleFileInserter, which will write it to a Bucket and probably insert it. cb.onMetadata(metadata, this, 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); }
@Override public void onFetchable(ClientPutState state) { synchronized(this) { ListUtils.removeBySwapLast(this.waitingForFetchable,state); if(!started) return; if(!waitingForFetchable.isEmpty()) return; if(calledFetchable) { if(logMINOR) Logger.minor(this, "Trying to call onFetchable() twice"); return; } calledFetchable = true; } cb.onFetchable(this); }
@Override public boolean run(ClientContext context) { if(logMINOR) Logger.minor(this, "Succeeding on "+SplitFileInserter.this); unregisterSender(); if(!(ctx.earlyEncode || ctx.getCHKOnly)) { reportMetadata(metadata); } cb.onSuccess(SplitFileInserter.this, context); raf.close(); raf.free(); originalData.close(); if(freeData) originalData.free(); return true; }
if(logMINOR) Logger.minor(this, "Inserting container: "+sfi+" for "+this); cb.onTransition(this, sfi, context); try { sfi.schedule(context);
@Override public void run() { cb.onEncode(key, SingleBlockInserter.this, context); } }, "Got URI");
@Override public synchronized void onMetadata(Bucket metadata, ClientPutState state, ClientContext context) { if(generator == state) { cb.onMetadata(metadata, this, context); } else { Logger.error(this, "Got metadata for "+state); } }
@Override public void onResume(ClientContext context) throws InsertException, ResumeFailedException { synchronized(this) { if(resumed) return; resumed = true; } if(cb != null && cb != parent) cb.onResume(context); if(containerItems != null) { for(ContainerElement e : containerItems) { if(e.data != null) e.data.onResume(context); } } resumeMetadata(origMetadata, context); // Do not call start(). start() immediately transitions to another state. }
cb.onFetchable(this);
cb.onSuccess(this, context);
@Override public boolean run(ClientContext context) { inserter.cb.onFailure(ie, inserter, context); return true; }
@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); }