public class ChunkedMappedFile extends MappedFile
DEFAULT_SYNC_MODE, newChunkListener, RETAIN
Constructor and Description |
---|
ChunkedMappedFile(@NotNull File file,
@NotNull RandomAccessFile raf,
long chunkSize,
long overlapSize,
long capacity,
boolean readOnly) |
Modifier and Type | Method and Description |
---|---|
@NotNull MappedBytesStore |
acquireByteStore(net.openhft.chronicle.core.io.ReferenceOwner owner,
long position,
BytesStore oldByteStore,
@NotNull MappedBytesStoreFactory mappedBytesStoreFactory)
Acquires a byte store at the specified position with the ability to re-use an existing byte store,
and specify a custom byte store factory.
|
long |
actualSize()
Returns the actual size of the mapped file in bytes, including any space reserved
for metadata, headers, etc.
|
long |
capacity()
Returns the capacity of the mapped file in bytes.
|
long |
chunkCount()
Returns the number of chunks in this mapped file.
|
void |
chunkCount(long[] chunkCount)
Populates the provided array with detailed chunk count information.
|
long |
chunkSize()
Returns the size of each chunk in the mapped file in bytes.
|
MappedBytes |
createBytesFor()
Creates a MappedBytes object for this mapped file.
|
protected void |
finalize()
This finalize() is used to detect when a component is not released deterministically.
|
NewChunkListener |
getNewChunkListener()
Returns the listener that is notified when a new chunk is created.
|
FileLock |
lock(long position,
long size,
boolean shared)
Calls lock on the underlying file channel
|
long |
overlapSize()
Returns the size of the overlap between consecutive chunks in the mapped file in bytes.
|
protected void |
performRelease() |
@NotNull RandomAccessFile |
raf()
Returns the RandomAccessFile associated with the mapped file.
|
@NotNull String |
referenceCounts()
Returns a string representation of the reference counts for the underlying mapped byte stores.
|
void |
setNewChunkListener(NewChunkListener listener)
Sets the listener to be notified when a new chunk is created.
|
void |
syncMode(SyncMode syncMode)
This mode determines whether an MS_ASYNC or MS_SYNC should be performed on a chunk release.
|
protected boolean |
threadSafetyCheck(boolean isUsed)
Performs a thread safety check on the component.
|
FileLock |
tryLock(long position,
long size,
boolean shared)
Calls tryLock on the underlying file channel
|
static void |
warmup() |
acquireBytesForRead, acquireBytesForRead, acquireBytesForWrite, acquireBytesForWrite, acquireByteStore, acquireByteStore, canReleaseInBackground, file, internalizedToken, mappedFile, mappedFile, mappedFile, mappedFile, mappedFile, mappedFile, of, ofSingle, readOnly, readOnly
backgroundPerformRelease, close, isClosed, release, releaseLast, reserve, reserveTransfer, setClosed, setClosing, throwExceptionIfClosed, throwExceptionIfClosedInSetter, tryReserve
addReferenceChangeListener, assertReferencesReleased, clearUsedByThread, createdHere, disableReferenceTracing, enableReferenceTracing, refCount, referenceCountedUnmonitored, referenceId, removeReferenceChangeListener, reservedBy, singleThreadedCheckDisabled, singleThreadedCheckReset, throwExceptionIfNotReleased, throwExceptionIfReleased, toString, unmonitor, warnAndReleaseIfNotReleased
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
public ChunkedMappedFile(@NotNull @NotNull File file, @NotNull @NotNull RandomAccessFile raf, long chunkSize, long overlapSize, long capacity, boolean readOnly) throws net.openhft.chronicle.core.io.IORuntimeException
net.openhft.chronicle.core.io.IORuntimeException
public static void warmup()
@NotNull public @NotNull MappedBytesStore acquireByteStore(net.openhft.chronicle.core.io.ReferenceOwner owner, long position, BytesStore oldByteStore, @NotNull @NotNull MappedBytesStoreFactory mappedBytesStoreFactory) throws IOException, IllegalArgumentException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
MappedFile
acquireByteStore
in class MappedFile
owner
- The owner of the byte store.position
- The position at which the byte store should be acquired.oldByteStore
- The old byte store that can be re-used, or null if not available.mappedBytesStoreFactory
- The factory to use for creating the MappedBytesStore.IOException
- If an I/O error occurs.IllegalArgumentException
- If an illegal argument is provided.net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waypublic void syncMode(SyncMode syncMode)
MappedFile
Performs this sync on any open store as well
syncMode
in class MappedFile
syncMode
- of sync to perform.protected void performRelease()
performRelease
in class net.openhft.chronicle.core.io.AbstractReferenceCounted
@NotNull public @NotNull String referenceCounts()
MappedFile
referenceCounts
in class MappedFile
public long capacity()
MappedFile
capacity
in class MappedFile
public long chunkSize()
MappedFile
chunkSize
in class MappedFile
public long overlapSize()
MappedFile
overlapSize
in class MappedFile
public NewChunkListener getNewChunkListener()
MappedFile
getNewChunkListener
in class MappedFile
public void setNewChunkListener(NewChunkListener listener)
MappedFile
setNewChunkListener
in class MappedFile
listener
- The listener to be set.public long actualSize() throws net.openhft.chronicle.core.io.IORuntimeException, IllegalStateException
MappedFile
actualSize
in class MappedFile
net.openhft.chronicle.core.io.IORuntimeException
IllegalStateException
@NotNull public @NotNull RandomAccessFile raf()
MappedFile
raf
in class MappedFile
protected void finalize() throws Throwable
finalize
in class MappedFile
Throwable
protected boolean threadSafetyCheck(boolean isUsed)
MappedFile
threadSafetyCheck
in class MappedFile
isUsed
- Flag to indicate whether the component is used.public FileLock lock(long position, long size, boolean shared) throws IOException
lock
in class MappedFile
position
- The byte position at which the locked region begins.size
- The size of the region to lock, in bytes.shared
- If true
, the lock will be shared. Otherwise, it will be exclusive.IOException
- If an I/O error occurs.public FileLock tryLock(long position, long size, boolean shared) throws IOException
tryLock
in class MappedFile
position
- The byte position at which the locked region begins.size
- The size of the region to lock, in bytes.shared
- If true
, the lock will be shared. Otherwise, it will be exclusive.null
if the lock could not be acquired.IOException
- If an I/O error occurs.public long chunkCount()
MappedFile
chunkCount
in class MappedFile
public void chunkCount(long[] chunkCount)
MappedFile
chunkCount
in class MappedFile
chunkCount
- The array to be populated with detailed chunk count information.public MappedBytes createBytesFor() throws net.openhft.chronicle.core.io.ClosedIllegalStateException
MappedFile
createBytesFor
in class MappedFile
net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.Copyright © 2023. All rights reserved.