Package freenet.support.io

Examples of freenet.support.io.StorageFormatException


   
    protected ClientRequest(DataInputStream dis, RequestIdentifier reqID,
            ClientContext context) throws IOException, StorageFormatException {
        long magic = dis.readLong();
        if(magic != CLIENT_DETAIL_MAGIC)
            throw new StorageFormatException("Bad magic");
        int version = dis.readInt();
        if(version != CLIENT_DETAIL_VERSION)
            throw new StorageFormatException("Bad version");
        RequestIdentifier copyReq = new RequestIdentifier(dis);
        if(!copyReq.equals(reqID))
            throw new StorageFormatException("Request identifier has changed");
        realTime = dis.readBoolean();
        verbosity = dis.readInt();
        startupTime = dis.readLong();
        priorityClass = dis.readShort();
        if(priorityClass < RequestStarter.MAXIMUM_PRIORITY_CLASS ||
                priorityClass > RequestStarter.PAUSED_PRIORITY_CLASS)
            throw new StorageFormatException("Bogus priority");
        if(dis.readBoolean())
            clientToken = dis.readUTF();
        else
            clientToken = null;
        finished = dis.readBoolean();
View Full Code Here


    }
   
    public GetFailedMessage(DataInputStream dis, RequestIdentifier reqID,
            long expectedSize, String expectedType) throws StorageFormatException, IOException {
        int version = dis.readInt();
        if(version != VERSION) throw new StorageFormatException("Bad version in GetFailedMessage");
        int x = dis.readInt();
        try {
            code = FetchExceptionMode.getByCode(x);
        } catch (IllegalArgumentException e) {
            throw new StorageFormatException("Bad error code");
        }
        this.isFatal = FetchException.isFatal(code);
        this.extraDescription = readPossiblyNull(dis);
        this.finalizedExpected = dis.readBoolean();
        String s = readPossiblyNull(dis);
        if(s != null) {
            try {
                redirectURI = new FreenetURI(s);
            } catch (MalformedURLException e) {
                throw new StorageFormatException("Bad redirect URI in GetFailedMessage: "+e);
            }
        } else {
            redirectURI = null;
        }
        this.global = reqID.globalQueue;
View Full Code Here

    throws IOException, StorageFormatException, ResumeFailedException {
        super(dis, reqID, context);
        ClientGetter getter = null;
        long magic = dis.readLong();
        if(magic != CLIENT_DETAIL_MAGIC)
            throw new StorageFormatException("Bad magic for request");
        int version = dis.readInt();
        if(version != CLIENT_DETAIL_VERSION)
            throw new StorageFormatException("Bad version "+version);
        String s = dis.readUTF();
        try {
            uri = new FreenetURI(s);
        } catch (MalformedURLException e) {
            throw new StorageFormatException("Bad URI");
        }
        short r = dis.readShort();
        try {
            returnType = ReturnType.getByCode(r);
        } catch (IllegalArgumentException e) {
            throw new StorageFormatException("Bad return type "+r);
        }
        if(returnType == ReturnType.DISK) {
            targetFile = new File(dis.readUTF());
        } else {
            targetFile = null;
View Full Code Here

    }
   
    public FailureCodeTracker(boolean insert, DataInputStream dis) throws IOException, StorageFormatException {
        this.insert = insert;
        if(dis.readInt() != MAGIC)
            throw new StorageFormatException("Bad magic for FailureCodeTracker");
        if(dis.readInt() != VERSION)
            throw new StorageFormatException("Bad version for FailureCodeTracker");
        int upperLimit =
            insert ? InsertException.UPPER_LIMIT_ERROR_CODE : FetchException.UPPER_LIMIT_ERROR_CODE;
        if(dis.readInt() != upperLimit)
            throw new StorageFormatException("Bad upper limit for FailureCodeTracker");
        for(int i=0;i<upperLimit;i++) {
            int x = dis.readInt();
            if(x < 0) throw new StorageFormatException("Negative error counts");
            if(x == 0) continue;
            if(map == null) map = new HashMap<Integer, Integer>();
            total += x;
            map.put(i, x);
        }
View Full Code Here

        segments = new SplitFileFetcherSegmentStorage[totalBlocks];
        blockNumbers = new int[totalBlocks];
        for(int i=0;i<totalBlocks;i++) {
            int readSeg = dis.readInt();
            if(readSeg < 0 || readSeg >= parent.segments.length)
                throw new StorageFormatException("Invalid segment number "+readSeg);
            SplitFileFetcherSegmentStorage segment = parent.segments[readSeg];
            this.segments[i] = segment;
            int blockNo = dis.readInt();
            if(blockNo < 0 || blockNo >= segment.totalBlocks())
                throw new StorageFormatException("Invalid block number "+blockNo+" for segment "+segment.segNo);
            this.blockNumbers[i] = blockNo;
            segment.resumeCallback(blockNo, this);
        }
    }
View Full Code Here

        dos.writeInt(maxRetries);
        writeRetries(dos);
    }
   
    public void read(DataInputStream dis) throws StorageFormatException, IOException {
        if(dis.readInt() != VERSION) throw new StorageFormatException("Bad version in block chooser");
        for(int i=0;i<completed.length;i++) {
            completed[i] = dis.readBoolean();
            if(completed[i]) completedCount++;
        }
        if(dis.readInt() != maxRetries) throw new StorageFormatException("Max retries has changed");
        readRetries(dis);
    }
View Full Code Here

        localSalt = new byte[32];
        dis.readFully(localSalt);
        mainBloomFilterSizeBytes = dis.readInt();
        // FIXME impose an upper bound based on estimate of bits per key.
        if(mainBloomFilterSizeBytes < 0)
            throw new StorageFormatException("Bad main bloom filter size");
        mainBloomK = dis.readInt();
        if(mainBloomK < 1)
            throw new StorageFormatException("Bad main bloom filter K");
        perSegmentBloomFilterSizeBytes = dis.readInt();
        if(perSegmentBloomFilterSizeBytes < 0)
            throw new StorageFormatException("Bad per segment bloom filter size");
        perSegmentK = dis.readInt();
        if(perSegmentK < 0)
            throw new StorageFormatException("Bad per segment bloom filter K");
        int segments = storage.segments.length;
        segmentFilters = new BinaryBloomFilter[segments];
        byte[] segmentsFilterBuffer = new byte[perSegmentBloomFilterSizeBytes * segments];
        try {
            storage.preadChecksummed(storage.offsetSegmentBloomFilters, segmentsFilterBuffer, 0, segmentsFilterBuffer.length);
View Full Code Here

    throws IOException, StorageFormatException {
        this.segNo = segNo;
        this.parent = parent;
        this.dataBlocks = dis.readInt();
        if(dataBlocks < 1 || dataBlocks > 256)
            throw new StorageFormatException("Bad data block count");
        this.crossSegmentCheckBlocks = dis.readInt();
        // REDFLAG one day we will support more than 256 blocks per segment?
        if(crossSegmentCheckBlocks < 0 || crossSegmentCheckBlocks > 256)
            throw new StorageFormatException("Bad cross-segment check block count");
        this.checkBlocks = dis.readInt();
        if(checkBlocks < 0 || checkBlocks > 256)
            throw new StorageFormatException("Bad check block count");
        int total = dataBlocks+checkBlocks+crossSegmentCheckBlocks;
        if(total > 256)
            throw new StorageFormatException("Too many blocks in segment");
        boolean ignoreLastBlock =
            (segNo == parent.segments.length-1 && parent.lastBlockMightNotBePadded());
        blockChooser = new SplitFileFetcherSegmentBlockChooser(total, parent.random,
                parent.maxRetries, parent.cooldownTries, parent.cooldownLength,
                this, keysFetching, ignoreLastBlock ? dataBlocks - 1 : -1);
View Full Code Here

        }
        DataInputStream dis = new DataInputStream(new ByteArrayInputStream(buf));
        for(int i=0;i<blocksFetched.length;i++) {
            int s = dis.readInt();
            if(s < -1 || s >= totalBlocks())
                throw new StorageFormatException("Bogus block number in blocksFetched["+i+"]: "+s);
            blocksFetched[i] = s;
            if(s >= 0) {
                if(!blockChooser.hasSucceeded(s)) {
                    blockChooser.onSuccess(s);
                } else {
                    throw new StorageFormatException("Duplicated block number in blocksFetched in "+this);
                }
            }
        }
        blockChooser.readRetries(dis);
        failedBlocks = blockChooser.countFailedBlocks();
View Full Code Here

        dos.writeBoolean(definitive);
    }
   
    public CompatibilityAnalyser(DataInputStream dis) throws IOException, StorageFormatException {
        int ver = dis.readInt();
        if(ver != VERSION) throw new StorageFormatException("Unknown version for CompatibilityAnalyser");
        try {
        min = CompatibilityMode.byCode(dis.readShort());
        max = CompatibilityMode.byCode(dis.readShort());
        } catch (IllegalArgumentException e) {
            throw new StorageFormatException("Bad min value");
        }
        if(dis.readBoolean()) {
            cryptoKey = new byte[32];
            dis.readFully(cryptoKey);
        }
View Full Code Here

TOP

Related Classes of freenet.support.io.StorageFormatException

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.