public TempRandomAccessBuffer(LockableRandomAccessBuffer underlying, long creationTime, boolean migrated, TempBucket tempBucket) throws IOException { super(underlying, underlying.size()); this.creationTime = creationTime; this.hasMigrated = hasFreedRAM = migrated; this.original = tempBucket; if (TRACE_BUCKET_LEAKS) tracer = new Throwable(); else tracer = null; }
@Override public long size() { return underlying.size(); }
@Override public long size() { return underlyingBuffer.size()-type.headerLen; }
@Override public long size() { return underlying.size(); }
public RAFBucket(LockableRandomAccessBuffer underlying) throws IOException { this.underlying = underlying; size = underlying.size(); }
SwitchableProxyRandomAccessBuffer(LockableRandomAccessBuffer initialWrap, long size) throws IOException { this.underlying = initialWrap; this.size = size; if(underlying.size() < size) throw new IOException("Underlying must be >= size given"); }
RAFBucket(DataInputStream dis, FilenameGenerator fg, PersistentFileTracker persistentFileTracker, MasterSecret masterKey) throws IOException, StorageFormatException, ResumeFailedException { underlying = BucketTools.restoreRAFFrom(dis, fg, persistentFileTracker, masterKey); size = underlying.size(); }
@Override public InputStream getInputStreamUnbuffered() throws IOException { return new RAFInputStream(underlying, 0, underlying.size()); }
@Override public long size() { return underlying.size(); }
public boolean writeTrivialProgress(DataOutputStream dos) throws IOException { boolean done = false; synchronized(this) { done = failed || succeeded; } if(done) { dos.writeBoolean(false); return false; } dos.writeBoolean(true); if(callbackCompleteViaTruncation == null) { dos.writeBoolean(false); raf.storeTo(dos); } else { dos.writeBoolean(true); dos.writeUTF(fileCompleteViaTruncation.toString()); dos.writeLong(raf.size()); } dos.writeLong(token); return true; }
public PaddedRandomAccessBuffer(DataInputStream dis, FilenameGenerator fg, PersistentFileTracker persistentFileTracker, MasterSecret masterSecret) throws ResumeFailedException, IOException, StorageFormatException { realSize = dis.readLong(); if(realSize < 0) throw new StorageFormatException("Negative length"); raf = BucketTools.restoreRAFFrom(dis, fg, persistentFileTracker, masterSecret); if(realSize > raf.size()) throw new ResumeFailedException("Padded file is smaller than expected length"); }
byte[] readBlock(SplitFileFetcherSegmentStorage segment, int slotNumber) throws IOException { long offset = segment.blockOffset(slotNumber); if(logDEBUG) Logger.minor(this, "Reading block "+slotNumber+" for "+segment.segNo+"/"+segments.length+" from "+offset+" RAF length is "+raf.size()); byte[] buf = new byte[CHKBlock.DATA_LENGTH]; raf.pread(offset, buf, 0, buf.length); return buf; }
private HashResult[] getHashes(LockableRandomAccessBuffer data) throws IOException { InputStream is = new RAFInputStream(data, 0, data.size()); MultiHashInputStream hashStream = new MultiHashInputStream(is, HashType.SHA256.bitmask); FileUtil.copy(is, new NullOutputStream(), data.size()); is.close(); return hashStream.getResults(); }
private HashResult[] getHashes(LockableRandomAccessBuffer data) throws IOException { InputStream is = new RAFInputStream(data, 0, data.size()); MultiHashInputStream hashStream = new MultiHashInputStream(is, HashType.SHA256.bitmask); FileUtil.copy(is, new NullOutputStream(), data.size()); is.close(); return hashStream.getResults(); }
if(underlyingBuffer.size() < type.headerLen){ throw new IOException("Underlying RandomAccessBuffer is not long enough to include the " + "footer.");
assertEquals(length, raf.size()); RAFBucket wrapped = new RAFBucket(raf); assertTrue(BucketTools.equalBuckets(bucket, wrapped));
this.completeViaTruncation = completeViaTruncation; rafLength = raf.size(); if(raf.size() < 8 /* FIXME more! */) throw new StorageFormatException("Too short"); dis = new DataInputStream(new ByteArrayInputStream(buf)); int basicSettingsLength = dis.readInt(); if(basicSettingsLength < 0 || basicSettingsLength + 12 + 4 + checksumLength > raf.size() || basicSettingsLength > 1024*1024) throw new StorageFormatException("Bad basic settings length");
this.random = random; this.raf = raf; rafLength = raf.size(); InputStream ois = new RAFInputStream(raf, 0, rafLength); DataInputStream dis = new DataInputStream(ois); if(dataLength != originalData.size()) throw new ResumeFailedException("Original data size is "+originalData.size()+" should be "+dataLength); if(((dataLength + CHKBlock.DATA_LENGTH - 1) / CHKBlock.DATA_LENGTH) != totalDataBlocks) throw new StorageFormatException("Data blocks "+totalDataBlocks+" not compatible with size "+dataLength);
/** Status. Generally depends on the status of the individual segments... * Not persisted: Can be deduced from the state of the segments, except for the last 3 states, * which are only used during completion (we don't keep the storage around once we're * finished). */ enum Status { NOT_STARTED, STARTED, ENCODED_CROSS_SEGMENTS, ENCODED, GENERATING_METADATA, SUCCEEDED, FAILED }