public class TempBucketFactory extends java.lang.Object implements BucketFactory, LockableRandomAccessBufferFactory
Modifier and Type | Class and Description |
---|---|
class |
TempBucketFactory.TempBucket |
Modifier and Type | Field and Description |
---|---|
static EncryptedRandomAccessBufferType |
CRYPT_TYPE |
static float |
DEFAULT_FACTOR |
static long |
defaultIncrement |
Constructor and Description |
---|
TempBucketFactory(Executor executor,
FilenameGenerator filenameGenerator,
long maxBucketSizeKeptInRam,
long maxRamUsed,
java.util.Random weakPRNG,
boolean reallyEncrypt,
long minDiskSpace,
MasterSecret masterSecret) |
Modifier and Type | Method and Description |
---|---|
long |
getMaxRAMBucketSize() |
long |
getMaxRamUsed() |
long |
getRamUsed() |
DiskSpaceCheckingRandomAccessBufferFactory |
getUnderlyingRAFFactory() |
boolean |
isEncrypting() |
RandomAccessBucket |
makeBucket(long size)
Create a bucket.
|
RandomAccessBucket |
makeBucket(long size,
float factor) |
TempBucketFactory.TempBucket |
makeBucket(long size,
float factor,
long increment)
Create a temp bucket
|
LockableRandomAccessBuffer |
makeRAF(byte[] initialContents,
int offset,
int size,
boolean readOnly)
Create a bucket with specified initial contents.
|
LockableRandomAccessBuffer |
makeRAF(long size)
Create a bucket.
|
void |
setEncryption(boolean value) |
void |
setMaxRAMBucketSize(long size) |
void |
setMaxRamUsed(long size) |
void |
setMinDiskSpace(long min) |
public static final long defaultIncrement
public static final float DEFAULT_FACTOR
public static final EncryptedRandomAccessBufferType CRYPT_TYPE
public TempBucketFactory(Executor executor, FilenameGenerator filenameGenerator, long maxBucketSizeKeptInRam, long maxRamUsed, java.util.Random weakPRNG, boolean reallyEncrypt, long minDiskSpace, MasterSecret masterSecret)
public RandomAccessBucket makeBucket(long size) throws java.io.IOException
BucketFactory
makeBucket
in interface BucketFactory
size
- The maximum size of the data, or -1 or Long.MAX_VALUE if we don't know.
Some buckets will throw IOException if you go over this length.java.io.IOException
public RandomAccessBucket makeBucket(long size, float factor) throws java.io.IOException
java.io.IOException
public long getRamUsed()
public void setMaxRamUsed(long size)
public long getMaxRamUsed()
public void setMaxRAMBucketSize(long size)
public long getMaxRAMBucketSize()
public void setEncryption(boolean value)
public void setMinDiskSpace(long min)
public boolean isEncrypting()
public TempBucketFactory.TempBucket makeBucket(long size, float factor, long increment) throws java.io.IOException
size
- Maximum sizefactor
- Factor to increase size by when need more spacejava.io.IOException
- If it is not possible to create a temp bucket due to an
I/O errorpublic LockableRandomAccessBuffer makeRAF(long size) throws java.io.IOException
LockableRandomAccessBufferFactory
makeRAF
in interface LockableRandomAccessBufferFactory
size
- The maximum size of the data. Most factories will pre-allocate this space, and
it may not be exceeded. However we do not guarantee that any I/O operation will complete;
even if we have pre-allocated the disk space, we may be unable to write to it because of
e.g. a hardware error.java.io.IOException
- If an I/O error prevented the operation.public LockableRandomAccessBuffer makeRAF(byte[] initialContents, int offset, int size, boolean readOnly) throws java.io.IOException
LockableRandomAccessBufferFactory
makeRAF
in interface LockableRandomAccessBufferFactory
initialContents
- Byte array from which to copy data. Data will be copied even if the
underlying implementation is a byte array, for reasons of consistency.offset
- Offset within the array to start copying data from.size
- Number of bytes to copy i.e. length of the new RandomAccessBuffer.java.io.IOException
- If an I/O error prevented the operation.public DiskSpaceCheckingRandomAccessBufferFactory getUnderlyingRAFFactory()