public class FileStore extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected long |
fileSize
The file size (cached).
|
protected FreeSpaceBitSet |
freeSpace
The free spaces between the chunks.
|
protected AtomicLong |
readBytes
The number of read bytes.
|
protected AtomicLong |
readCount
The number of read operations.
|
protected AtomicLong |
writeBytes
The number of written bytes.
|
protected AtomicLong |
writeCount
The number of write operations.
|
| 构造器和说明 |
|---|
FileStore() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
clear()
Mark the file as empty.
|
void |
close()
Close this store.
|
void |
free(long pos,
int length)
Mark the space as free.
|
int |
getDefaultRetentionTime()
Get the default retention time for this store in milliseconds.
|
FileChannel |
getEncryptedFile()
Get the encrypted file instance, if encryption is used.
|
FileChannel |
getFile()
Get the file instance in use.
|
String |
getFileName()
Get the file name.
|
int |
getFillRate() |
int |
getProjectedFillRate(int vacatedBlocks)
Calculates a prospective fill rate, which store would have after rewrite
of sparsely populated chunk(s) and evacuation of still live data into a
new chunk.
|
long |
getReadBytes()
Get the number of read bytes since this store was opened.
|
long |
getReadCount()
Get the number of read operations since this store was opened.
|
long |
getWriteBytes()
Get the number of written bytes since this store was opened.
|
long |
getWriteCount()
Get the number of write operations since this store was opened.
|
boolean |
isReadOnly() |
void |
markUsed(long pos,
int length)
Mark the space as in use.
|
FileStore |
open(String fileName,
boolean readOnly) |
void |
open(String fileName,
boolean readOnly,
char[] encryptionKey)
Try to open the file.
|
ByteBuffer |
readFully(long pos,
int len)
Read from the file.
|
long |
size()
Get the file size.
|
void |
sync()
Flush all changes.
|
String |
toString() |
void |
truncate(long size)
Truncate the file.
|
void |
writeFully(long pos,
ByteBuffer src)
Write to the file.
|
protected final AtomicLong readCount
protected final AtomicLong readBytes
protected final AtomicLong writeCount
protected final AtomicLong writeBytes
protected final FreeSpaceBitSet freeSpace
protected long fileSize
public ByteBuffer readFully(long pos, int len)
pos - the write positionlen - the number of bytes to readpublic void writeFully(long pos,
ByteBuffer src)
pos - the write positionsrc - the source bufferpublic void open(String fileName, boolean readOnly, char[] encryptionKey)
fileName - the file namereadOnly - whether the file should only be opened in read-only mode,
even if the file is writableencryptionKey - the encryption key, or null if encryption is not
usedpublic void close()
public void sync()
public long size()
public void truncate(long size)
size - the new file sizepublic FileChannel getFile()
The application may read from the file (for example for online backup), but not write to it or truncate it.
public FileChannel getEncryptedFile()
The application may read from the file (for example for online backup), but not write to it or truncate it.
public long getWriteCount()
public long getWriteBytes()
public long getReadCount()
public long getReadBytes()
public boolean isReadOnly()
public int getDefaultRetentionTime()
public void markUsed(long pos,
int length)
pos - the position in byteslength - the number of bytespublic void free(long pos,
int length)
pos - the position in byteslength - the number of bytespublic int getFillRate()
public int getProjectedFillRate(int vacatedBlocks)
vacatedBlocks - number of blocks vacatedpublic void clear()
public String getFileName()
Copyright © 2022. All rights reserved.