FileOffer(long uid, RandomAccessBuffer data, String filename, String mimeType, String comment) throws IOException { this.uid = uid; this.data = data; this.filename = filename; this.mimeType = mimeType; this.comment = comment; size = data.size(); amIOffering = true; }
/** * Construct a PartiallyReceivedBulk. * @param size Size of the file, does not have to be a multiple of blockSize. * @param blockSize Block size. * @param raf Where to store the data. * @param initialState If true, assume all blocks have been received. If false, assume no blocks have * been received. */ public PartiallyReceivedBulk(MessageCore usm, long size, int blockSize, RandomAccessBuffer raf, boolean initialState) { this.size = size; this.blockSize = blockSize; this.raf = raf; this.usm = usm; long blocks = (size + blockSize - 1) / blockSize; if(blocks > Integer.MAX_VALUE) throw new IllegalArgumentException("Too big"); this.blocks = (int)blocks; blocksReceived = new BitArray(this.blocks); if(initialState) { blocksReceived.setAllOnes(); blocksReceivedCount = this.blocks; } assert(raf.size() >= size); }
private void innerTestSize(long sz) throws IOException { RandomAccessBuffer raf = construct(sz); assertEquals(raf.size(), sz); raf.close(); raf.free(); }
assertEquals(raf.size(), sz); int x = 0;
length = data.size(); prb = new PartiallyReceivedBulk(updateManager.node.getUSM(), length, Node.PACKET_SIZE, data, true);
private void innerTestWriteOverLimit(long sz, int choppedBytes) throws IOException { RandomAccessBuffer raf = construct(sz); assertEquals(raf.size(), sz); long startAt = sz - choppedBytes; byte[] buf = new byte[choppedBytes];