Package one.nio.mem
Class SharedMemoryMap<K,V>
- java.lang.Object
-
- one.nio.mem.OffheapMap<K,V>
-
- one.nio.mem.SharedMemoryMap<K,V>
-
- All Implemented Interfaces:
OffheapMapMXBean,SharedMemoryMapMXBean
- Direct Known Subclasses:
SharedMemoryFixedMap,SharedMemoryLongMap,SharedMemoryStringMap
public abstract class SharedMemoryMap<K,V> extends OffheapMap<K,V> implements SharedMemoryMapMXBean
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class one.nio.mem.OffheapMap
OffheapMap.BasicCleanup, OffheapMap.Record<K,V>, OffheapMap.SamplingCleanup, OffheapMap.Visitor<K,V>, OffheapMap.WritableRecord<K,V>, OffheapMap.WritableVisitor<K,V>
-
-
Field Summary
Fields Modifier and Type Field Description protected MallocMTallocatorprotected static longBASE_OFFSETprotected static longCAPACITY_OFFSETprotected StringclassNameprotected static longCUSTOM_DATA_OFFSETprotected static longCUSTOM_SIZE_OFFSETprotected static longMAP_OFFSETprotected static intMAX_CUSTOM_DATA_SIZEprotected MappedFilemmapprotected Stringnameprotected Serializer<V>serializerprotected static longSIGNATURE_CLEARprotected static longSIGNATURE_DIRTYprotected static longSIGNATURE_LEGACYprotected static longSIGNATURE_OFFSETprotected static longTIMESTAMP_OFFSETprotected static longUID_OFFSET-
Fields inherited from class one.nio.mem.OffheapMap
byteArrayOffset, capacity, cleanupInterval, cleanupThread, cleanupThreshold, CONCURRENCY_LEVEL, count, expirations, HASH_OFFSET, HEADER_SIZE, locks, lockWaitTime, log, mapBase, maxSamples, MB, minTimeToLive, NEXT_OFFSET, TIME_OFFSET, timeToLive, unsafe
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSharedMemoryMap(int capacity, String fileName, long fileSize)protectedSharedMemoryMap(int capacity, String fileName, long fileSize, long expirationTime)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected longallocateEntry(K key, long hashCode, int size)protected voidcloseInternal()protected voidconvert(Serializer<V> oldSerializer, Serializer<V> newSerializer)protected voidcreateAllocator(long startAddress, long totalMemory)protected voiddestroyEntry(long entry)intentriesToClean()protected byte[]getCustomData()longgetFreeMemory()protected longgetHeader(long offset)longgetTotalMemory()longgetUsedMemory()protected intheaderSize(long entry)protected voidloadSchema()protected booleanneedCleanup(long expirationTime)protected voidrelocate(long delta)protected voidsetCustomData(byte[] data)protected voidsetHeader(long offset, long value)voidsetSerializer(Class<V> valueType)voidsetSerializer(Serializer<V> serializer)protected voidsetValueAt(long entry, V value)protected intsizeOf(long entry)protected intsizeOf(V value)protected voidstoreSchema()protected VvalueAt(long entry)-
Methods inherited from class one.nio.mem.OffheapMap
bucketFor, clear, close, equalsAt, get, getCapacity, getCleanupInterval, getCleanupThreshold, getCount, getExpirations, getLockWaitTime, getMaxSamples, getMinTimeToLive, getTimeToLive, hashCode, isExpired, iterate, iterate, iterate, iterate, iterate, iterate, keyAt, lockFor, lockRecordForRead, lockRecordForRead, lockRecordForWrite, lockRecordForWrite, put, putIfAbsent, remove, removeExpired, reuseEntry, setCleanupInterval, setCleanupThreshold, setLockWaitTime, setMaxSamples, setMinTimeToLive, setTimeAt, setTimeAt, setTimeToLive, shouldCleanup, timeAt, touch
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface one.nio.mem.OffheapMapMXBean
getCapacity, getCleanupInterval, getCleanupThreshold, getCount, getExpirations, getLockWaitTime, getMaxSamples, getMinTimeToLive, getTimeToLive, setCleanupInterval, setCleanupThreshold, setLockWaitTime, setMaxSamples, setMinTimeToLive, setTimeToLive
-
-
-
-
Field Detail
-
SIGNATURE_CLEAR
protected static final long SIGNATURE_CLEAR
- See Also:
- Constant Field Values
-
SIGNATURE_LEGACY
protected static final long SIGNATURE_LEGACY
- See Also:
- Constant Field Values
-
SIGNATURE_DIRTY
protected static final long SIGNATURE_DIRTY
- See Also:
- Constant Field Values
-
SIGNATURE_OFFSET
protected static final long SIGNATURE_OFFSET
- See Also:
- Constant Field Values
-
TIMESTAMP_OFFSET
protected static final long TIMESTAMP_OFFSET
- See Also:
- Constant Field Values
-
CAPACITY_OFFSET
protected static final long CAPACITY_OFFSET
- See Also:
- Constant Field Values
-
BASE_OFFSET
protected static final long BASE_OFFSET
- See Also:
- Constant Field Values
-
UID_OFFSET
protected static final long UID_OFFSET
- See Also:
- Constant Field Values
-
CUSTOM_SIZE_OFFSET
protected static final long CUSTOM_SIZE_OFFSET
- See Also:
- Constant Field Values
-
CUSTOM_DATA_OFFSET
protected static final long CUSTOM_DATA_OFFSET
- See Also:
- Constant Field Values
-
MAP_OFFSET
protected static final long MAP_OFFSET
- See Also:
- Constant Field Values
-
MAX_CUSTOM_DATA_SIZE
protected static final int MAX_CUSTOM_DATA_SIZE
- See Also:
- Constant Field Values
-
className
protected final String className
-
mmap
protected final MappedFile mmap
-
name
protected final String name
-
allocator
protected MallocMT allocator
-
serializer
protected Serializer<V> serializer
-
-
Constructor Detail
-
SharedMemoryMap
protected SharedMemoryMap(int capacity, String fileName, long fileSize) throws IOException- Throws:
IOException
-
SharedMemoryMap
protected SharedMemoryMap(int capacity, String fileName, long fileSize, long expirationTime) throws IOException- Throws:
IOException
-
-
Method Detail
-
closeInternal
protected void closeInternal()
- Overrides:
closeInternalin classOffheapMap<K,V>
-
needCleanup
protected boolean needCleanup(long expirationTime)
-
relocate
protected void relocate(long delta)
-
getHeader
protected long getHeader(long offset)
-
setHeader
protected void setHeader(long offset, long value)
-
getCustomData
protected byte[] getCustomData()
-
setCustomData
protected void setCustomData(byte[] data)
-
allocateEntry
protected long allocateEntry(K key, long hashCode, int size)
- Specified by:
allocateEntryin classOffheapMap<K,V>
-
destroyEntry
protected void destroyEntry(long entry)
- Specified by:
destroyEntryin classOffheapMap<K,V>
-
sizeOf
protected int sizeOf(long entry)
- Specified by:
sizeOfin classOffheapMap<K,V>
-
valueAt
protected V valueAt(long entry)
- Specified by:
valueAtin classOffheapMap<K,V>
-
setValueAt
protected void setValueAt(long entry, V value)- Specified by:
setValueAtin classOffheapMap<K,V>
-
sizeOf
protected int sizeOf(V value)
- Specified by:
sizeOfin classOffheapMap<K,V>
-
headerSize
protected int headerSize(long entry)
-
getTotalMemory
public long getTotalMemory()
- Specified by:
getTotalMemoryin interfaceSharedMemoryMapMXBean
-
getFreeMemory
public long getFreeMemory()
- Specified by:
getFreeMemoryin interfaceSharedMemoryMapMXBean
-
getUsedMemory
public long getUsedMemory()
- Specified by:
getUsedMemoryin interfaceSharedMemoryMapMXBean
-
entriesToClean
public int entriesToClean()
- Overrides:
entriesToCleanin classOffheapMap<K,V>
-
createAllocator
protected void createAllocator(long startAddress, long totalMemory)
-
setSerializer
public void setSerializer(Class<V> valueType) throws IOException
- Throws:
IOException
-
setSerializer
public void setSerializer(Serializer<V> serializer) throws IOException
- Throws:
IOException
-
loadSchema
protected void loadSchema() throws IOException- Throws:
IOException
-
storeSchema
protected void storeSchema()
-
convert
protected void convert(Serializer<V> oldSerializer, Serializer<V> newSerializer)
-
-