Fields Modifier and Type Field Description
(package private) long
(package private) java.util.concurrent.atomic.AtomicInteger
Constructors Constructor Description
CachedFileInfo(long ledgerId, java.io.File lf, byte masterKey)
All Methods Instance Methods Concrete Methods Modifier and Type Method Description
(package private) int
(package private) void
(package private) boolean
tryRetain()Attempt to retain the file info.
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, write
Methods inherited from class org.apache.bookkeeper.common.util.Watchable
addWatcher, deleteWatcher, deleteWatchers, notifyWatchers, recycle
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).
- true if we managed to increment the refcount, false otherwise
public java.lang.String toString()