@Override public synchronized LockableRandomAccessBuffer makeRAF(byte[] initialContents, int offset, int size, boolean readOnly) throws IOException { lock.lock(); try { if(dir.getUsableSpace() > size + minDiskSpace) return underlying.makeRAF(initialContents, offset, size, readOnly); else throw new InsufficientDiskSpaceException(); } finally { lock.unlock(); } }
@Override public LockableRandomAccessBuffer makeRAF(long size) throws IOException { lock.lock(); try { if(dir.getUsableSpace() > size + minDiskSpace) return underlying.makeRAF(size); else throw new InsufficientDiskSpaceException(); } finally { lock.unlock(); } }
@Override public LockableRandomAccessBuffer makeRAF(long size) throws IOException { LockableRandomAccessBuffer t = rafFactory.makeRAF(size); cb.snoopRAF(t); return t; }
@Override public LockableRandomAccessBuffer makeRAF(byte[] initialContents, int offset, int size, boolean readOnly) throws IOException { LockableRandomAccessBuffer t = rafFactory.makeRAF(initialContents, offset, size, readOnly); cb.snoopRAF(t); return t; }
@Override public LockableRandomAccessBuffer makeRAF(byte[] initialContents, int offset, int size, boolean readOnly) throws IOException { boolean reallyEncrypt = false; synchronized(this) { reallyEncrypt = this.reallyEncrypt; } if(reallyEncrypt) { // FIXME do the encryption in memory? Test it ... LockableRandomAccessBuffer ret = makeRAF(size); ret.pwrite(0, initialContents, offset, size); if(readOnly) ret = new ReadOnlyRandomAccessBuffer(ret); return ret; } else { return factory.makeRAF(initialContents, offset, size, readOnly); } }
private LockableRandomAccessBuffer generateData(Random random, long size, LockableRandomAccessBufferFactory smallRAFFactory) throws IOException { LockableRandomAccessBuffer thing = smallRAFFactory.makeRAF(size); BucketTools.fill(thing, random, 0, size); return new ReadOnlyRandomAccessBuffer(thing); }
private LockableRandomAccessBuffer generateData(Random random, long size, LockableRandomAccessBufferFactory factory) throws IOException { LockableRandomAccessBuffer thing = factory.makeRAF(size); BucketTools.fill(thing, random, 0, size); return new ReadOnlyRandomAccessBuffer(thing); }
@Override public LockableRandomAccessBuffer makeRAF(long size) throws IOException { long realSize = size; long paddedSize = size; MasterSecret secret = null; synchronized(this) { if(reallyEncrypt && this.secret != null) { secret = this.secret; realSize += TempBucketFactory.CRYPT_TYPE.headerLen; paddedSize = PaddedEphemerallyEncryptedBucket.paddedLength(realSize, PaddedEphemerallyEncryptedBucket.MIN_PADDED_SIZE); if(logMINOR) Logger.minor(this, "Encrypting and padding "+size+" to "+paddedSize); } } LockableRandomAccessBuffer raf = factory.makeRAF(paddedSize); if(secret != null) { if(realSize != paddedSize) raf = new PaddedRandomAccessBuffer(raf, realSize); try { raf = new EncryptedRandomAccessBuffer(TempBucketFactory.CRYPT_TYPE, raf, secret, true); } catch (GeneralSecurityException e) { Logger.error(this, "Cannot create encrypted tempfile: "+e, e); } } return raf; }
byte[] originalData = new byte[(int)size]; r.nextBytes(originalData); LockableRandomAccessBuffer data = smallRAFFactory.makeRAF(originalData, 0, originalData.length, true); HashResult[] hashes = getHashes(data); MyCallback cb = new MyCallback();
Logger.normal(this, "Creating splitfile storage file for complete-via-truncation: "+storageFile); } else { raf = rafFactory.makeRAF(totalLength);
/** 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 }