public class CacheLastRedoLogFileStorageDecorator<T extends IReplicationOrderedPacket> extends Object implements INonBatchRedoLogFileStorage<T>
INonBatchRedoLogFileStorage
with a cache that keeps a constant size number of
packets in memory which were the last appended packet. Since the most frequent read access to the
redo log file are to the end of the file (or the start), keeping the latest packets in memory
will reduce the accesses to the storage which creates a much more serious bottleneckConstructor and Description |
---|
CacheLastRedoLogFileStorageDecorator(int bufferSize,
INonBatchRedoLogFileStorage<T> storage,
AbstractSingleFileGroupBacklog groupBacklog) |
Modifier and Type | Method and Description |
---|---|
void |
append(T replicationPacket)
Add a single packet to the end of the storage list
|
void |
appendBatch(List<T> replicationPackets)
Adds a batch of packets that will be stored at the end of the list
|
void |
close()
Close the storage and clears its resources, the storage can no longer be used.
|
void |
deleteOldestPackets(long packetsCount)
Delete a batch from the start of the list
|
long |
getCacheWeight() |
long |
getDiscardedPacketsCount() |
long |
getExternalPacketsCount() |
long |
getMemoryPacketsCount() |
long |
getSpaceUsed() |
long |
getWeight() |
boolean |
isEmpty() |
CompactionResult |
performCompaction(long from,
long to) |
StorageReadOnlyIterator<T> |
readOnlyIterator() |
StorageReadOnlyIterator<T> |
readOnlyIterator(long fromIndex) |
WeightedBatch<T> |
removeFirstBatch(int batchCapacity,
long lastCompactionRangeEndKey)
Removes a batch from the start of the list
|
long |
size()
This method should not assume a reader lock is obtained when accessing it
|
void |
validateIntegrity()
Validates the integrity of the storage
|
public CacheLastRedoLogFileStorageDecorator(int bufferSize, INonBatchRedoLogFileStorage<T> storage, AbstractSingleFileGroupBacklog groupBacklog)
public void append(T replicationPacket) throws StorageException, StorageFullException
INonBatchRedoLogFileStorage
append
in interface INonBatchRedoLogFileStorage<T extends IReplicationOrderedPacket>
StorageException
StorageFullException
public void appendBatch(List<T> replicationPackets) throws StorageException, StorageFullException
IRedoLogFileStorage
appendBatch
in interface IRedoLogFileStorage<T extends IReplicationOrderedPacket>
replicationPackets
- packets to storeStorageException
StorageFullException
public void validateIntegrity() throws RedoLogFileCompromisedException
IRedoLogFileStorage
validateIntegrity
in interface IRedoLogFileStorage<T extends IReplicationOrderedPacket>
RedoLogFileCompromisedException
public void close()
IRedoLogFileStorage
close
in interface IRedoLogFileStorage<T extends IReplicationOrderedPacket>
public long getWeight()
getWeight
in interface IRedoLogFileStorage<T extends IReplicationOrderedPacket>
public long getDiscardedPacketsCount()
getDiscardedPacketsCount
in interface IRedoLogFileStorage<T extends IReplicationOrderedPacket>
public CompactionResult performCompaction(long from, long to)
performCompaction
in interface IRedoLogFileStorage<T extends IReplicationOrderedPacket>
public void deleteOldestPackets(long packetsCount) throws StorageException
IRedoLogFileStorage
deleteOldestPackets
in interface IRedoLogFileStorage<T extends IReplicationOrderedPacket>
packetsCount
- to deleteStorageException
public boolean isEmpty() throws StorageException
isEmpty
in interface IRedoLogFileStorage<T extends IReplicationOrderedPacket>
StorageException
public long getSpaceUsed()
getSpaceUsed
in interface IRedoLogFileStorageStatistics
public long getExternalPacketsCount()
getExternalPacketsCount
in interface IRedoLogFileStorageStatistics
public long getMemoryPacketsCount()
getMemoryPacketsCount
in interface IRedoLogFileStorageStatistics
public StorageReadOnlyIterator<T> readOnlyIterator() throws StorageException
readOnlyIterator
in interface IRedoLogFileStorage<T extends IReplicationOrderedPacket>
StorageException
public StorageReadOnlyIterator<T> readOnlyIterator(long fromIndex) throws StorageException
readOnlyIterator
in interface IRedoLogFileStorage<T extends IReplicationOrderedPacket>
fromIndex
- index to start iterating fromStorageException
public WeightedBatch<T> removeFirstBatch(int batchCapacity, long lastCompactionRangeEndKey) throws StorageException
IRedoLogFileStorage
removeFirstBatch
in interface IRedoLogFileStorage<T extends IReplicationOrderedPacket>
batchCapacity
- WeightToRemove to removelastCompactionRangeEndKey
- packets with keys larger then this cannot be discardedStorageException
public long size() throws StorageException
IRedoLogFileStorage
size
in interface IRedoLogFileStorage<T extends IReplicationOrderedPacket>
StorageException
public long getCacheWeight()
getCacheWeight
in interface IRedoLogFileStorage<T extends IReplicationOrderedPacket>
Copyright © GigaSpaces.