Class Segment
- java.lang.Object
-
- java.util.concurrent.locks.ReentrantReadWriteLock
-
- net.sf.ehcache.store.disk.Segment
-
- All Implemented Interfaces:
java.io.Serializable,java.util.concurrent.locks.ReadWriteLock
public class Segment extends java.util.concurrent.locks.ReentrantReadWriteLockSegment implementation used in LocalStore.The segment extends ReentrantReadWriteLock to allow read locking on read operations. In addition to the typical CHM-like methods, this classes additionally supports replacement under a read lock - which is accomplished using an atomic CAS on the associated HashEntry.
- Author:
- Chris Dennis, Ludovic Orban
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Segment(int initialCapacity, float loadFactor, DiskStorageFactory primary, CacheConfiguration cacheConfiguration, PoolAccessor onHeapPoolAccessor, PoolAccessor onDiskPoolAccessor, RegisteredEventListeners cacheEventNotificationService, org.terracotta.statistics.observer.OperationObserver<CacheOperationOutcomes.EvictionOutcome> evictionObserver)Create a Segment with the given initial capacity, load-factor, primary element substitute factory, and identity element substitute factory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisFaulted(int hash, java.lang.Object key)Verifies if the mapping for a key is marked as faultedjava.lang.StringtoString()-
Methods inherited from class java.util.concurrent.locks.ReentrantReadWriteLock
getOwner, getQueuedReaderThreads, getQueuedThreads, getQueuedWriterThreads, getQueueLength, getReadHoldCount, getReadLockCount, getWaitingThreads, getWaitQueueLength, getWriteHoldCount, hasQueuedThread, hasQueuedThreads, hasWaiters, isFair, isWriteLocked, isWriteLockedByCurrentThread, readLock, writeLock
-
-
-
-
Field Detail
-
count
protected volatile int count
Count of elements in the map.A volatile reference is needed here for the same reasons as in the table reference.
-
modCount
protected int modCount
Mod-count used to track concurrent modifications when doing size calculations or iterating over the store.Note that we don't actually have any iterators yet...
-
-
Constructor Detail
-
Segment
public Segment(int initialCapacity, float loadFactor, DiskStorageFactory primary, CacheConfiguration cacheConfiguration, PoolAccessor onHeapPoolAccessor, PoolAccessor onDiskPoolAccessor, RegisteredEventListeners cacheEventNotificationService, org.terracotta.statistics.observer.OperationObserver<CacheOperationOutcomes.EvictionOutcome> evictionObserver)Create a Segment with the given initial capacity, load-factor, primary element substitute factory, and identity element substitute factory.An identity element substitute factory is specified at construction time because only one subclass of IdentityElementProxyFactory can be used with a Segment. Without this requirement the mapping between bare
Elementinstances and the factory responsible for them would be ambiguous.If a
nullidentity element substitute factory is specified then encountering a raw element (i.e. as a result of using an identity element substitute factory) will result in a null pointer exception during decode.- Parameters:
initialCapacity- initial capacity of storeloadFactor- fraction of capacity at which rehash occursprimary- primary element substitute factorycacheConfiguration- the cache configurationonHeapPoolAccessor- the pool tracking on-heap usageonDiskPoolAccessor- the pool tracking on-disk usagecacheEventNotificationService-
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.util.concurrent.locks.ReentrantReadWriteLock
-
isFaulted
public boolean isFaulted(int hash, java.lang.Object key)Verifies if the mapping for a key is marked as faulted- Parameters:
key- the key to check the mapping for- Returns:
- true if faulted, false otherwise (including no mapping)
-
-