@Override public void addBlock() { BaseManifestPutter.this.addBlock(); synchronized(this) { minSuccessFetchBlocks++; } }
@Override public void addBlocks(int num) { BaseManifestPutter.this.addBlocks(num); synchronized(this) { minSuccessFetchBlocks+=num; } }
@Override public synchronized void addMustSucceedBlocks(int blocks) { BaseManifestPutter.this.addMustSucceedBlocks(blocks); synchronized(this) { minSuccessFetchBlocks += blocks; } }
public void start(ClientContext context) throws InsertException { if (logMINOR) Logger.minor(this, "Starting " + this+" persistence="+persistent()+ " containermode="+containerMode); PutHandler[] running; PutHandler[] containers; running = runningPutHandlers.toArray(new PutHandler[runningPutHandlers.size()]); if (containerMode) { containers = getContainersToStart(running.length > 0); } else { containers = null; if (logMINOR) Logger.minor(this, "Started " + i + " of " + running.length); if (isFinished()) { if (logMINOR) Logger.minor(this, "Already finished, killing start() on " + this); if (logMINOR) Logger.minor(this, "Started " + i + " of " + containers.length); if (isFinished()) { if (logMINOR) Logger.minor(this, "Already finished, killing start() on " + this); gotAllMetadata(context); cancelAndFinish(context); throw e;
public static HashMap<String, Object> bucketsByNameToManifestEntries(HashMap<String,Object> bucketsByName) { HashMap<String,Object> manifestEntries = new HashMap<String,Object>(); for(Map.Entry<String,Object> entry: bucketsByName.entrySet()) { String name = entry.getKey(); Object o = entry.getValue(); if(o instanceof ManifestElement) { manifestEntries.put(name, o); } else if(o instanceof Bucket) { RandomAccessBucket data = (RandomAccessBucket) o; manifestEntries.put(name, new ManifestElement(name, data, null, data.size())); } else if(o instanceof HashMap) { manifestEntries.put(name, bucketsByNameToManifestEntries(Metadata.forceMap(o))); } else throw new IllegalArgumentException(String.valueOf(o)); } return manifestEntries; }
@Override public synchronized void addRedundantBlocksInsert(int blocks) { BaseManifestPutter.this.addRedundantBlocksInsert(blocks); }
@Override public void completedBlock(boolean dontNotify, ClientContext context) { BaseManifestPutter.this.completedBlock(dontNotify, context); }
@Override public void onBlockSetFinished(ClientPutState state, ClientContext context) { boolean allBlockSets = false; synchronized(BaseManifestPutter.this) { putHandlerWaitingForBlockSets.remove(this); if (freeformMode) { allBlockSets = hasResolvedBase && putHandlerWaitingForBlockSets.isEmpty(); } else { allBlockSets = putHandlerWaitingForBlockSets.isEmpty(); } } if(allBlockSets) BaseManifestPutter.this.blockSetFinalized(context); }
protected void onFetchable(PutHandler handler) { //new Error("Trace_ME onFetchable").printStackTrace(); if(checkFetchable(handler)) { cb.onFetchable(this); } }
private void fail(InsertException e, ClientContext context) { // Cancel all, then call the callback synchronized(this) { if(finished) return; finished = true; } cancelAndFinish(context); cb.onFailure(e, this); }
complete(context);
@Override public FreenetURI insertManifest(FreenetURI insertURI, HashMap<String, Object> bucketsByName, String defaultName, short priorityClass, byte[] forceCryptoKey) throws InsertException { PutWaiter pw = new PutWaiter(this); DefaultManifestPutter putter; try { putter = new DefaultManifestPutter(pw, BaseManifestPutter.bucketsByNameToManifestEntries(bucketsByName), priorityClass, insertURI, defaultName, getInsertContext(true), false, forceCryptoKey, core.clientContext); } catch (TooManyFilesInsertException e1) { throw new InsertException(InsertExceptionMode.TOO_MANY_FILES); } try { core.clientContext.start(putter); } catch (PersistenceDisabledException e) { // Impossible } return pw.waitForCompletion(); }