public class PersistentTempBucketFactory extends java.lang.Object implements BucketFactory, PersistentFileTracker
Modifier and Type | Field and Description |
---|---|
FilenameGenerator |
fg
Filename generator.
|
Constructor and Description |
---|
PersistentTempBucketFactory(java.io.File dir,
java.lang.String prefix,
RandomSource strongPRNG,
java.util.Random weakPRNG,
boolean encrypt)
Create a temporary bucket factory.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkDiskSpace(java.io.File file,
int toWrite,
int bufferSize)
Is there enough space to extend the file?
|
long |
commitID()
A positive number incremented on every transaction.
|
void |
completedInit()
Called when boot-up is complete.
|
void |
delayedFree(DelayedFree b,
long createdCommitID)
Free an allocated bucket, but only after the change has been written to disk.
|
void |
finishDelayedFree(DelayedFree[] buckets)
Delete the buckets.
|
java.io.File |
getDir()
Get the directory we are creating temporary files in
|
FilenameGenerator |
getGenerator()
Get the FilenameGenerator
|
DelayedFree[] |
grabBucketsToFree()
Returns a list of buckets to free.
|
boolean |
isEncrypting()
Are we encrypting temporary files?
|
RandomAccessBucket |
makeBucket(long size)
Create a persistent temporary bucket.
|
void |
register(java.io.File file)
Notify the bucket factory that a file is a temporary file, and not to be deleted.
|
void |
setDiskSpaceChecker(DiskSpaceChecker checker) |
void |
setEncryption(boolean encrypt)
Set whether to encrypt new persistent temp buckets.
|
void |
setMasterSecret(MasterSecret secret) |
public final FilenameGenerator fg
public PersistentTempBucketFactory(java.io.File dir, java.lang.String prefix, RandomSource strongPRNG, java.util.Random weakPRNG, boolean encrypt) throws java.io.IOException
dir
- Where to put it.prefix
- Prefix for temporary file names.strongPRNG
- Cryptographically strong random number generator, for making keys etc.weakPRNG
- Weak but fast random number generator.encrypt
- Whether to encrypt temporary files.java.io.IOException
- If we are unable to read the directory, etc.public void setDiskSpaceChecker(DiskSpaceChecker checker)
public void setMasterSecret(MasterSecret secret)
public void register(java.io.File file)
register
in interface PersistentFileTracker
public void completedInit()
public RandomAccessBucket makeBucket(long size) throws java.io.IOException
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 void delayedFree(DelayedFree b, long createdCommitID)
delayedFree
in interface PersistentFileTracker
b
- The bucket to free.createdCommitID
- 0 if the bucket was created before the last node restart, otherwise
the return value of commitID() when it was created. If there hasn't been a commit, we can
free the bucket immediately...public DelayedFree[] grabBucketsToFree()
public long commitID()
PersistentFileTracker
commitID
in interface PersistentFileTracker
public java.io.File getDir()
getDir
in interface PersistentFileTracker
public FilenameGenerator getGenerator()
getGenerator
in interface PersistentFileTracker
public boolean isEncrypting()
public void setEncryption(boolean encrypt)
public void finishDelayedFree(DelayedFree[] buckets)
public boolean checkDiskSpace(java.io.File file, int toWrite, int bufferSize)
DiskSpaceChecker
checkDiskSpace
in interface DiskSpaceChecker
file
- The current filenametoWrite
- Length of the proposed writebufferSize
- The caller only checks disk space when the number of bytes written since
the last check exceeds this value.