public class FileBucket extends BaseFileBucket implements Bucket, java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
createFileOnly |
protected boolean |
deleteOnExit |
protected boolean |
deleteOnFree |
protected java.io.File |
file |
static int |
MAGIC |
protected boolean |
readOnly |
fileRestartCounter, tempDir| Modifier | Constructor and Description |
|---|---|
protected |
FileBucket() |
protected |
FileBucket(java.io.DataInputStream dis) |
|
FileBucket(java.io.File file,
boolean readOnly,
boolean createFileOnly,
boolean deleteOnExit,
boolean deleteOnFree)
Creates a new FileBucket.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
createFileOnly()
If true, we will fail if the file already exist.
|
RandomAccessBucket |
createShadow()
Create a shallow read-only copy of this bucket, using different
objects but using the same external storage.
|
protected boolean |
deleteOnExit() |
protected boolean |
deleteOnFree() |
boolean |
equals(java.lang.Object obj) |
java.io.File |
getFile()
Returns the file object this buckets data is kept in.
|
int |
hashCode() |
boolean |
isReadOnly()
Is the bucket read-only?
|
void |
onResume(ClientContext context)
Called after restarting.
|
void |
setReadOnly()
Make the bucket read-only.
|
void |
storeTo(java.io.DataOutputStream dos)
Write enough data to reconstruct the Bucket, or throw UnsupportedOperationException.
|
protected boolean |
tempFileAlreadyExists()
If true, then the file is temporary and must already exist, so we will just open it.
|
deleteFile, free, free, getInputStream, getInputStreamUnbuffered, getName, getOutputStream, getOutputStreamUnbuffered, getPersistentTempID, getTempDir, getTempfile, setDeleteOnExit, setTempDir, size, split, toRandomAccessBuffer, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitfree, getInputStream, getInputStreamUnbuffered, getName, getOutputStream, getOutputStreamUnbuffered, sizeprotected final java.io.File file
protected boolean readOnly
protected boolean deleteOnFree
protected final boolean deleteOnExit
protected final boolean createFileOnly
public static final int MAGIC
public FileBucket(java.io.File file,
boolean readOnly,
boolean createFileOnly,
boolean deleteOnExit,
boolean deleteOnFree)
file - The File to read and write to.readOnly - If true, any attempt to write to the bucket will result in an IOException.
Can be set later. Irreversible. @see isReadOnly(), setReadOnly()createFileOnly - If true, create the file if it doesn't exist, but if it does exist,
throw a FileExistsException on any write operation. This is safe against symlink attacks
because we write to a temp file and then rename. It is technically possible that the rename
will clobber an existing file if there is a race condition, but since it will not write over
a symlink this is probably not dangerous. User-supplied filenames should in any case be
restricted by higher levels.deleteOnExit - If true, delete the file on a clean exit of the JVM. Irreversible - use with care!deleteOnFree - If true, delete the file on finalization. Reversible.protected FileBucket()
protected FileBucket(java.io.DataInputStream dis)
throws java.io.IOException,
StorageFormatException
java.io.IOExceptionStorageFormatExceptionpublic java.io.File getFile()
getFile in class BaseFileBucketpublic boolean isReadOnly()
BucketisReadOnly in interface Bucketpublic void setReadOnly()
BucketsetReadOnly in interface Bucketprotected boolean createFileOnly()
BaseFileBucketcreateFileOnly in class BaseFileBucketprotected boolean deleteOnExit()
deleteOnExit in class BaseFileBucketprotected boolean deleteOnFree()
deleteOnFree in class BaseFileBucketpublic RandomAccessBucket createShadow()
BucketcreateShadow in interface BucketcreateShadow in interface RandomAccessBucketpublic void onResume(ClientContext context) throws ResumeFailedException
BucketonResume in interface BucketonResume in class BaseFileBucketcontext - All the necessary runtime support will be on this object.ResumeFailedExceptionprotected boolean tempFileAlreadyExists()
BaseFileBuckettempFileAlreadyExists in class BaseFileBucketpublic void storeTo(java.io.DataOutputStream dos)
throws java.io.IOException
BucketstoreTo in interface BucketstoreTo in class BaseFileBucketjava.io.IOExceptionpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Object