public abstract class BaseFileBucket extends java.lang.Object implements RandomAccessBucket
| Modifier and Type | Field and Description |
|---|---|
protected long |
fileRestartCounter |
static int |
MAGIC |
protected static java.lang.String |
tempDir |
| Modifier | Constructor and Description |
|---|---|
protected |
BaseFileBucket() |
protected |
BaseFileBucket(java.io.DataInputStream dis) |
|
BaseFileBucket(java.io.File file,
boolean deleteOnExit)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract boolean |
createFileOnly()
If true, we will fail if the file already exist.
|
protected void |
deleteFile()
Actually delete the underlying file.
|
protected abstract boolean |
deleteOnExit() |
protected abstract boolean |
deleteOnFree() |
void |
free()
Free the bucket, if supported.
|
void |
free(boolean forceFree) |
abstract java.io.File |
getFile()
Returns the file object this buckets data is kept in.
|
java.io.InputStream |
getInputStream()
Returns an InputStream that reads data from this Bucket.
|
java.io.InputStream |
getInputStreamUnbuffered() |
java.lang.String |
getName()
Returns a name for the bucket, may be used to identify them in
certain in certain situations.
|
java.io.OutputStream |
getOutputStream()
Returns an OutputStream that is used to put data in this Bucket, from the
beginning.
|
java.io.OutputStream |
getOutputStreamUnbuffered()
Get an OutputStream which is not buffered.
|
protected long |
getPersistentTempID() |
static java.lang.String |
getTempDir()
Return directory used for temp files.
|
protected java.io.File |
getTempfile()
Create a temporary file in the same directory as this file.
|
void |
onResume(ClientContext context)
Called after restarting.
|
protected void |
setDeleteOnExit(java.io.File file) |
static void |
setTempDir(java.lang.String dirName)
Set temp file directory.
|
long |
size()
Returns the amount of data currently in this bucket in bytes.
|
Bucket[] |
split(int splitSize) |
void |
storeTo(java.io.DataOutputStream dos)
Write enough data to reconstruct the Bucket, or throw UnsupportedOperationException.
|
protected abstract boolean |
tempFileAlreadyExists()
If true, then the file is temporary and must already exist, so we will just open it.
|
LockableRandomAccessBuffer |
toRandomAccessBuffer()
Convert the Bucket to a LockableRandomAccessBuffer.
|
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcreateShadowisReadOnly, setReadOnlyprotected long fileRestartCounter
protected static java.lang.String tempDir
public static final int MAGIC
public BaseFileBucket(java.io.File file,
boolean deleteOnExit)
file - deleteOnExit - If true, call File.deleteOnExit() on the file.
WARNING: Delete on exit is a memory leak: The filenames are kept until the JVM exits, and
cannot be removed even when the file has been deleted! It should only be used where it is
ESSENTIAL! Note that if you want temp files to be deleted on exit, you also need to override
deleteOnExit().protected BaseFileBucket()
protected BaseFileBucket(java.io.DataInputStream dis)
throws java.io.IOException,
StorageFormatException
java.io.IOExceptionStorageFormatExceptionprotected void setDeleteOnExit(java.io.File file)
public java.io.OutputStream getOutputStreamUnbuffered()
throws java.io.IOException
BucketgetOutputStreamUnbuffered in interface Bucketjava.io.IOExceptionpublic java.io.OutputStream getOutputStream()
throws java.io.IOException
BucketgetOutputStream in interface Bucketjava.io.IOExceptionprotected abstract boolean tempFileAlreadyExists()
protected abstract boolean createFileOnly()
protected abstract boolean deleteOnExit()
protected abstract boolean deleteOnFree()
protected java.io.File getTempfile()
throws java.io.IOException
java.io.IOExceptionpublic java.io.InputStream getInputStreamUnbuffered()
throws java.io.IOException
getInputStreamUnbuffered in interface Bucketjava.io.IOExceptionpublic java.io.InputStream getInputStream()
throws java.io.IOException
BucketgetInputStream in interface Bucketjava.io.IOExceptionpublic java.lang.String getName()
Bucketpublic long size()
Bucketprotected void deleteFile()
public static java.lang.String getTempDir()
public static void setTempDir(java.lang.String dirName)
The directory must exist.
public Bucket[] split(int splitSize)
public void free()
Bucketpublic void free(boolean forceFree)
public java.lang.String toString()
toString in class java.lang.Objectpublic abstract java.io.File getFile()
public void onResume(ClientContext context) throws ResumeFailedException
BucketonResume in interface Bucketcontext - All the necessary runtime support will be on this object.ResumeFailedExceptionpublic void storeTo(java.io.DataOutputStream dos)
throws java.io.IOException
Bucketpublic LockableRandomAccessBuffer toRandomAccessBuffer() throws java.io.IOException
RandomAccessBuckettoRandomAccessBuffer in interface RandomAccessBucketjava.io.IOExceptionprotected long getPersistentTempID()