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
class FileInfoBackingCache.CachedFileInfo extends FileInfo
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.bookkeeper.bookie.FileInfo
FileInfo.FileInfoDeletedException
-
-
Field Summary
Fields Modifier and Type Field Description (package private) long
ledgerId
(package private) java.util.concurrent.atomic.AtomicInteger
refCount
-
Fields 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 Constructor Description CachedFileInfo(long ledgerId, java.io.File lf, byte[] masterKey)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) int
getRefCount()
(package private) void
release()
java.lang.String
toString()
(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
-
-
-
-
Method Detail
-
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
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-