@Override public ClientGetter fetchFromMetadata(Bucket initialMetadata, ClientGetCallback callback, FetchContext fctx, short prio) throws FetchException { if(initialMetadata == null) throw new NullPointerException(); ClientGetter get = new ClientGetter(callback, FreenetURI.EMPTY_CHK_URI, fctx, prio, null, null, initialMetadata); try { core.clientContext.start(get); } catch (PersistenceDisabledException e) { // Impossible } return get; }
@Override public ClientGetter fetch(FreenetURI uri, ClientGetCallback callback, FetchContext fctx, short prio) throws FetchException { if(uri == null) throw new NullPointerException(); ClientGetter get = new ClientGetter(callback, uri, fctx, prio, null, null, null); try { core.clientContext.start(get); } catch (PersistenceDisabledException e) { // Impossible } return get; }
public FProxyFetchInProgress(FProxyFetchTracker tracker, FreenetURI key, long maxSize2, long identifier, ClientContext context, FetchContext fctx, RequestClient rc, REFILTER_POLICY refilter) { this.refilterPolicy = refilter; this.tracker = tracker; this.uri = key; this.maxSize = maxSize2; this.timeStarted = System.currentTimeMillis(); this.fctx = fctx; this.rc = rc; FetchContext alteredFctx = new FetchContext(fctx, FetchContext.IDENTICAL_MASK); alteredFctx.maxOutputLength = fctx.maxTempLength = maxSize; alteredFctx.eventProducer.addEventListener(this); waiters = new ArrayList<FProxyFetchWaiter>(); results = new ArrayList<FProxyFetchResult>(); getter = new ClientGetter(this, uri, alteredFctx, FProxyToadlet.PRIORITY, null, null, null); }
@Override public FetchResult fetch(FreenetURI uri, long overrideMaxSize, RequestClient clientContext) throws FetchException { if(uri == null) throw new NullPointerException(); FetchWaiter fw = new FetchWaiter(clientContext); FetchContext context = getFetchContext(overrideMaxSize); ClientGetter get = new ClientGetter(fw, uri, context, priorityClass, null, null, null); try { core.clientContext.start(get); } catch (PersistenceDisabledException e) { // Impossible } return fw.waitForCompletion(); }
/** * Fetch a key. Either returns the data, or throws an exception. */ @Override public FetchResult fetchFromMetadata(Bucket initialMetadata) throws FetchException { if(initialMetadata == null) throw new NullPointerException(); FetchContext context = getFetchContext(); FetchWaiter fw = new FetchWaiter(this); ClientGetter get = new ClientGetter(fw, FreenetURI.EMPTY_CHK_URI, context, priorityClass, null, null, initialMetadata); try { core.clientContext.start(get); } catch (PersistenceDisabledException e) { // Impossible } return fw.waitForCompletion(); }
/** * Fetch a key. Either returns the data, or throws an exception. */ @Override public FetchResult fetch(FreenetURI uri) throws FetchException { if(uri == null) throw new NullPointerException(); FetchContext context = getFetchContext(); FetchWaiter fw = new FetchWaiter(this); ClientGetter get = new ClientGetter(fw, uri, context, priorityClass, null, null, null); try { core.clientContext.start(get); } catch (PersistenceDisabledException e) { // Impossible } return fw.waitForCompletion(); }
DependencyJarFetcher(File filename, FreenetURI chk, long expectedLength, byte[] expectedHash, JarFetcherCallback cb, boolean essential, boolean executable) throws FetchException { FetchContext myCtx = new FetchContext(dependencyCtx, FetchContext.IDENTICAL_MASK); File parent = filename.getParentFile(); if(parent == null) parent = new File("."); try { tempFile = File.createTempFile(filename.getName(), NodeUpdateManager.TEMP_FILE_SUFFIX, parent); } catch (InsufficientDiskSpaceException e) { throw new FetchException(FetchExceptionMode.NOT_ENOUGH_DISK_SPACE); } catch (IOException e) { throw new FetchException(FetchExceptionMode.BUCKET_ERROR, "Cannot create temp file for "+filename+" in "+parent+" - disk full? permissions problem?"); } getter = new ClientGetter(this, chk, myCtx, RequestStarter.IMMEDIATE_SPLITFILE_PRIORITY_CLASS, new FileBucket(tempFile, false, false, false, false), null, null); myCtx.eventProducer.addEventListener(this); this.cb = cb; this.filename = filename; this.expectedHash = expectedHash; this.expectedLength = expectedLength; this.essential = essential; this.executable = executable; }
public void start(short priority, long maxSize) { HighLevelSimpleClient hlsc = node.clientCore.makeClient(priority, false, false); FetchContext context = hlsc.getFetchContext(); context.maxNonSplitfileRetries = -1; context.maxSplitfileBlockRetries = -1; context.maxTempLength = maxSize; context.maxOutputLength = maxSize; ClientGetter get = new ClientGetter(this, freenetURI, context, priority, null, null, null); try { node.clientCore.clientContext.start(get); } catch (PersistenceDisabledException e) { // Impossible } catch (FetchException e) { onFailure(e, null); } }
private ClientGetter makeGetter(NodeClientCore core, Bucket ret) throws IOException { if (binaryBlob && ret == null) { ret = core.clientContext.getBucketFactory(persistence == Persistence.FOREVER).makeBucket(fctx.maxOutputLength); } return new ClientGetter(this, uri, fctx, priorityClass, binaryBlob ? new NullBucket() : ret, binaryBlob ? new BinaryBlobWriter(ret) : null, false, initialMetadata, extensionCheck); }
cg = new ClientGetter(this, uri, ctx, RequestStarter.IMMEDIATE_SPLITFILE_PRIORITY_CLASS, null, new BinaryBlobWriter(new FileBucket(tempFile, false, false, false, false)));
if(logMINOR) Logger.minor(this, "Prefetching content for background fetch for edition "+l+" on "+key); FetchContext fctx = new FetchContext(realFetchContext, FetchContext.IDENTICAL_MASK); final ClientGetter get = new ClientGetter(new ClientGetCallback() {
ClientGetter cg = new ClientGetter(myCallback, uri, tempContext, (short) 0, null, new BinaryBlobWriter(cleanedBlob), null);
@Override public void prefetch(FreenetURI uri, long timeout, long maxSize, Set<String> allowedTypes, short prio) { FetchContext ctx = getFetchContext(maxSize); ctx.allowedMIMETypes = allowedTypes; final ClientGetter get = new ClientGetter(nullCallback, uri, ctx, prio, new NullBucket(), null, null); core.getTicker().queueTimedJob(new Runnable() { @Override public void run() { get.cancel(core.clientContext); } }, timeout); try { core.clientContext.start(get); } catch (FetchException e) { // Ignore } catch (PersistenceDisabledException e) { // Impossible } }
/** * A non-authoritative hint that a specific edition *might* exist. At the moment, * we just fetch the block. We do not fetch the contents, and it is possible that * USKFetcher's are also fetching the block. FIXME would it be more efficient to * pass it along to a USKFetcher? * @param usk * @param edition * @param context */ public void hintUpdate(USK usk, long edition, ClientContext context) { if(edition < lookupLatestSlot(usk)) return; FreenetURI uri = usk.copy(edition).getURI().sskForUSK(); final ClientGetter get = new ClientGetter(new NullClientCallback(rcBulk), uri, new FetchContext(backgroundFetchContext, FetchContext.IDENTICAL_MASK), RequestStarter.UPDATE_PRIORITY_CLASS, new NullBucket(), null, null); try { get.start(context); } catch (FetchException e) { // Ignore } }
if(uri.isUSK()) uri = uri.sskForUSK(); if(logMINOR) Logger.minor(this, "Doing hint fetch for "+uri); final ClientGetter get = new ClientGetter(new ClientGetCallback() {
FreenetURI uri = URI.setSuggestedEdition(availableVersion); uri = uri.sskForUSK(); cg = new ClientGetter(this, uri, ctx, RequestStarter.IMMEDIATE_SPLITFILE_PRIORITY_CLASS, null, new BinaryBlobWriter(new FileBucket(tempBlobFile, false, false, false, false)), null);
get = new ClientGetter(fw, uri, context, PluginManager.PRIO, null, null, null); try { node.clientCore.clientContext.start(get);
/** * A non-authoritative hint that a specific edition *might* exist. At the moment, * we just fetch the block. We do not fetch the contents, and it is possible that * USKFetcher's are also fetching the block. FIXME would it be more efficient to * pass it along to a USKFetcher? * @param context * @throws MalformedURLException If the uri passed in is not a USK. */ public void hintUpdate(FreenetURI uri, ClientContext context, short priority) throws MalformedURLException { if(uri.getSuggestedEdition() < lookupLatestSlot(USK.create(uri))) { if(logMINOR) Logger.minor(this, "Ignoring hint because edition is "+uri.getSuggestedEdition()+" but latest is "+lookupLatestSlot(USK.create(uri))); return; } uri = uri.sskForUSK(); if(logMINOR) Logger.minor(this, "Doing hint fetch for "+uri); final ClientGetter get = new ClientGetter(new NullClientCallback(rcBulk), uri, new FetchContext(backgroundFetchContext, FetchContext.IDENTICAL_MASK), priority, new NullBucket(), null, null); try { get.start(context); } catch (FetchException e) { if(logMINOR) Logger.minor(this, "Cannot start hint fetch for "+uri+" : "+e, e); // Ignore } }
cg = revocationGetter = new ClientGetter(this, manager.getRevocationURI(), ctxRevocation, aggressive ? RequestStarter.MAXIMUM_PRIORITY_CLASS : RequestStarter.IMMEDIATE_SPLITFILE_PRIORITY_CLASS,
Bucket blobBucket = node.clientCore.tempBucketFactory.makeBucket(FILE_SIZE*3); BinaryBlobWriter bbw = new BinaryBlobWriter(blobBucket); ClientGetter getter = new ClientGetter(fw, uri, ctx, (short) 0, null, bbw, false, null, null); getter.start(node.clientCore.clientContext); fw.waitForCompletion();