Package org.apache.bookkeeper.bookie
Class FileInfoBackingCache.CachedFileInfo
java.lang.Object
org.apache.bookkeeper.common.util.Watchable<LastAddConfirmedUpdateNotification>
org.apache.bookkeeper.bookie.FileInfo
org.apache.bookkeeper.bookie.FileInfoBackingCache.CachedFileInfo
- All Implemented Interfaces:
Recyclable
- Enclosing class:
- FileInfoBackingCache
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.bookkeeper.bookie.FileInfo
FileInfo.FileInfoDeletedException -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final long(package private) final AtomicIntegerFields inherited from class org.apache.bookkeeper.bookie.FileInfo
CURRENT_HEADER_VERSION, headerVersion, masterKey, mode, NO_MASTER_KEY, SIGNATURE, START_OF_DATA, STATE_FENCED_BIT, V0, V1 -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.apache.bookkeeper.bookie.FileInfo
cancelWaitForLastAddConfirmedUpdate, checkOpen, close, delete, flushHeader, getExplicitLac, getLastAddConfirmed, getLf, getMasterKey, getSizeSinceLastWrite, isClosed, isDeleted, isFenced, isSameFile, moveToNewLocation, read, readHeader, setExplicitLac, setFenced, setLastAddConfirmed, size, waitForLastAddConfirmedUpdate, writeMethods inherited from class org.apache.bookkeeper.common.util.Watchable
addWatcher, deleteWatcher, deleteWatchers, notifyWatchers, recycle
-
Field Details
-
ledgerId
final long ledgerId -
refCount
-
-
Constructor Details
-
CachedFileInfo
CachedFileInfo(long ledgerId, File lf, byte[] masterKey) throws IOException - Throws:
IOException
-
-
Method Details
-
tryRetain
boolean tryRetain()Attempt to retain the file info. When a client obtains a fileinfo from a container object, but that container object may release the fileinfo before the client has a chance to call retain. In this case, the file info could be released and the destroyed before we ever get a chance to use it.tryRetain avoids this problem, by doing a compare-and-swap on the reference count. If the refCount is negative, it means that the fileinfo is being cleaned up, and this fileinfo object should not be used. This works in tandem with #markDead, which will only set the refCount to negative if noone currently has it retained (i.e. the refCount is 0).
- Returns:
- true if we managed to increment the refcount, false otherwise
-
getRefCount
int getRefCount() -
release
void release() -
toString
-