Class ByteBufferRedoLogFileStorage<T extends IReplicationOrderedPacket>
java.lang.Object
com.gigaspaces.internal.server.space.redolog.storage.bytebuffer.ByteBufferRedoLogFileStorage<T>
- All Implemented Interfaces:
IStorageSegmentsMediator,IRedoLogFileStorage<T>,IRedoLogFileStorageStatistics
public class ByteBufferRedoLogFileStorage<T extends IReplicationOrderedPacket>
extends Object
implements IRedoLogFileStorage<T>, IStorageSegmentsMediator
An implementation of redo log file storage which is based on an underlying byte buffer storages
provider which simulated an endless byte buffer
- Since:
- 7.1
- Author:
- eitany
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassA resource for byte array, ensure capacity must be called each time this resource is taken -
Constructor Summary
ConstructorsConstructorDescriptionByteBufferRedoLogFileStorage(IByteBufferStorageFactory byteBufferStorageProvider) ByteBufferRedoLogFileStorage(IByteBufferStorageFactory byteBufferStorageProvider, ByteBufferRedoLogFileConfig<T> config, BacklogWeightPolicy backlogWeightPolicy) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidappendBatch(List<T> replicationPackets) Adds a batch of packets that will be stored at the end of the listvoidclose()Close the storage and clears its resources, the storage can no longer be used.voiddeleteOldestPackets(long packetsCount) Delete a batch from the start of the listlonglonglonglonglonglonglonglongbooleanisEmpty()performCompaction(long from, long to) readOnlyIterator(long fromIndex) removeFirstBatch(int batchCapacity, long lastCompactionRangeEndKey) Removes a batch from the start of the listlongsize()This method should not assume a reader lock is obtained when accessing itvoidPerforms an integrity check that verifies the storage state and data is not compromisedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.gigaspaces.internal.server.space.redolog.storage.IRedoLogFileStorage
getOldest, getOldestKey, removeOldest
-
Constructor Details
-
ByteBufferRedoLogFileStorage
-
ByteBufferRedoLogFileStorage
public ByteBufferRedoLogFileStorage(IByteBufferStorageFactory byteBufferStorageProvider, ByteBufferRedoLogFileConfig<T> config, BacklogWeightPolicy backlogWeightPolicy)
-
-
Method Details
-
appendBatch
Description copied from interface:IRedoLogFileStorageAdds a batch of packets that will be stored at the end of the list- Specified by:
appendBatchin interfaceIRedoLogFileStorage<T extends IReplicationOrderedPacket>- Parameters:
replicationPackets- packets to store- Throws:
StorageExceptionStorageFullException
-
deleteOldestPackets
Description copied from interface:IRedoLogFileStorageDelete a batch from the start of the list- Specified by:
deleteOldestPacketsin interfaceIRedoLogFileStorage<T extends IReplicationOrderedPacket>- Parameters:
packetsCount- number of packets to delete- Throws:
StorageException
-
removeFirstBatch
public WeightedBatch<T> removeFirstBatch(int batchCapacity, long lastCompactionRangeEndKey) throws StorageException Description copied from interface:IRedoLogFileStorageRemoves a batch from the start of the list- Specified by:
removeFirstBatchin interfaceIRedoLogFileStorage<T extends IReplicationOrderedPacket>- Parameters:
batchCapacity- WeightToRemove to removelastCompactionRangeEndKey- packets with keys larger than this cannot be discarded- Returns:
- removed batch
- Throws:
StorageException
-
readOnlyIterator
- Specified by:
readOnlyIteratorin interfaceIRedoLogFileStorage<T extends IReplicationOrderedPacket>- Parameters:
fromIndex- index to start iterating from- Returns:
- read only iterator that starts from the specified index
- Throws:
StorageException
-
size
Description copied from interface:IRedoLogFileStorageThis method should not assume a reader lock is obtained when accessing it- Specified by:
sizein interfaceIRedoLogFileStorage<T extends IReplicationOrderedPacket>- Returns:
- number of packets in the storage
- Throws:
StorageException
-
isEmpty
- Specified by:
isEmptyin interfaceIRedoLogFileStorage<T extends IReplicationOrderedPacket>- Returns:
- true if the storage has no packets
- Throws:
StorageException
-
getSpaceUsed
public long getSpaceUsed()- Specified by:
getSpaceUsedin interfaceIRedoLogFileStorageStatistics- Returns:
- used space in bytes
-
getExternalPacketsCount
public long getExternalPacketsCount()- Specified by:
getExternalPacketsCountin interfaceIRedoLogFileStorageStatistics- Returns:
- number of packets held outside of jvm memory
-
getMemoryPacketsCount
public long getMemoryPacketsCount()- Specified by:
getMemoryPacketsCountin interfaceIRedoLogFileStorageStatistics- Returns:
- number of packets held in jvm memory
-
getMemoryPacketsWeight
public long getMemoryPacketsWeight()- Specified by:
getMemoryPacketsWeightin interfaceIRedoLogFileStorageStatistics- Returns:
- total weight of packets held in memory
-
getExternalStoragePacketsWeight
public long getExternalStoragePacketsWeight()- Specified by:
getExternalStoragePacketsWeightin interfaceIRedoLogFileStorageStatistics- Returns:
- total weight of packets held in external storage
-
close
public void close()Description copied from interface:IRedoLogFileStorageClose the storage and clears its resources, the storage can no longer be used.- Specified by:
closein interfaceIRedoLogFileStorage<T extends IReplicationOrderedPacket>
-
getWeight
public long getWeight()- Specified by:
getWeightin interfaceIRedoLogFileStorage<T extends IReplicationOrderedPacket>
-
getDiscardedPacketsCount
public long getDiscardedPacketsCount()- Specified by:
getDiscardedPacketsCountin interfaceIRedoLogFileStorage<T extends IReplicationOrderedPacket>
-
performCompaction
- Specified by:
performCompactionin interfaceIRedoLogFileStorage<T extends IReplicationOrderedPacket>
-
getCacheWeight
public long getCacheWeight()- Specified by:
getCacheWeightin interfaceIRedoLogFileStorage<T extends IReplicationOrderedPacket>
-
allocatedNewResource
- Specified by:
allocatedNewResourcein interfaceIStorageSegmentsMediator
-
validateIntegrity
Performs an integrity check that verifies the storage state and data is not compromised- Specified by:
validateIntegrityin interfaceIRedoLogFileStorage<T extends IReplicationOrderedPacket>- Throws:
ByteBufferStorageCompromisedException
-