Package freenet.clients.fcp

Examples of freenet.clients.fcp.ClientRequest


        boolean changed = writeAnyway;
        synchronized(completedRequestIdentifiers) {
          identifiers = completedRequestIdentifiers.toArray(new String[completedRequestIdentifiers.size()]);
        }
        for(String identifier: identifiers) {
          ClientRequest req = fcp.getGlobalRequest(identifier);
          if(req == null || req instanceof ClientGet == uploads) {
            synchronized(completedRequestIdentifiers) {
              completedRequestIdentifiers.remove(identifier);
            }
            changed = true;
View Full Code Here


            int restoredRestarted = 0;
            int restoredFully = 0;
            int failed = 0;
            // Resume the requests.
            for(PartiallyLoadedRequest partial : loaded.partiallyLoadedRequests.values()) {
                ClientRequest req = partial.request;
                if(req == null) continue;
                try {
                    req.onResume(context);
                    if(partial.status == RequestLoadStatus.RESTORED_FULLY ||
                            partial.status == RequestLoadStatus.RESTORED_RESTARTED) {
                        req.start(context);
                    }
                    switch(partial.status) {
                    case LOADED:
                        success++;
                        break;
                    case RESTORED_FULLY:
                        restoredFully++;
                        break;
                    case RESTORED_RESTARTED:
                        restoredRestarted++;
                        break;
                    case FAILED:
                        failed++;
                        break;
                    }
                } catch (Throwable t) {
                    if(partial.status == RequestLoadStatus.LOADED)
                        failedSerialize = true;
                    failed++;
                    System.err.println("Unable to resume request "+req+" after loading it.");
                    Logger.error(this, "Unable to resume request "+req+" after loading it: "+t, t);
                    try {
                        req.cancel(context);
                    } catch (Throwable t1) {
                        Logger.error(this, "Unable to terminate "+req+" after failure: "+t1, t1);
                    }
                }
            }
View Full Code Here

            Logger.error(this, "Unable to read global salt (checksum failed)");
        }
        requestStarters.setGlobalSalt(salt);
        int requestCount = ois.readInt();
        for(int i=0;i<requestCount;i++) {
            ClientRequest request = null;
            RequestIdentifier reqID = readRequestIdentifier(ois);
            if(reqID != null && context.persistentRoot.hasRequest(reqID)) {
                Logger.warning(this, "Not reading request because already have it");
                skipChecksummedObject(ois, length); // Request itself
                skipChecksummedObject(ois, length); // Recovery data
                continue;
            }
            try {
                if(!noSerialize) {
                    request = (ClientRequest) readChecksummedObject(ois, length);
                    if(request != null) {
                        if(reqID != null) {
                            if(!reqID.sameIdentifier(request.getRequestIdentifier())) {
                                Logger.error(this, "Request does not match request identifier, discarding");
                                request = null;
                            } else {
                                loaded.addPartiallyLoadedRequest(reqID, request, RequestLoadStatus.LOADED);
                            }
                        }
                    }
                } else
                    skipChecksummedObject(ois, length);
            } catch (ChecksumFailedException e) {
                Logger.error(this, "Failed to load request (checksum failed)");
                System.err.println("Failed to load a request (checksum failed)");
            } catch (Throwable t) {
                // Some more serious problem. Try to load the rest anyway.
                Logger.error(this, "Failed to load request: "+t, t);
                System.err.println("Failed to load a request: "+t);
                t.printStackTrace();
            }
            if(request == null || logMINOR) {
                try {
                    ClientRequest restored = readRequestFromRecoveryData(ois, length, reqID);
                    if(request == null && restored != null) {
                        request = restored;
                        boolean loadedFully = restored.fullyResumed();
                        loaded.addPartiallyLoadedRequest(reqID, request,
                                loadedFully ? RequestLoadStatus.RESTORED_FULLY : RequestLoadStatus.RESTORED_RESTARTED);
                    }
                } catch (ChecksumFailedException e) {
                    if(request == null) {
View Full Code Here

   
    private ClientRequest readRequestFromRecoveryData(ObjectInputStream is, long totalLength, RequestIdentifier reqID) throws IOException, ChecksumFailedException, StorageFormatException {
        InputStream tmp = checker.checksumReaderWithLength(is, this.tempBucketFactory, totalLength);
        try {
            DataInputStream dis = new DataInputStream(tmp);
            ClientRequest request = ClientRequest.restartFrom(dis, reqID, getClientContext(), checker);
            dis.close();
            dis = null;
            tmp = null;
            return request;
        } catch (Throwable t) {
View Full Code Here

TOP

Related Classes of freenet.clients.fcp.ClientRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.