Class FixedSizeSwapRedoLogFile<T extends IReplicationOrderedPacket>
java.lang.Object
com.gigaspaces.internal.server.space.redolog.FixedSizeSwapRedoLogFile<T>
- All Implemented Interfaces:
IRedoLogFileStatistics,IRedoLogFile<T>
public class FixedSizeSwapRedoLogFile<T extends IReplicationOrderedPacket>
extends Object
implements IRedoLogFile<T>
A swap based implementation of the
IRedoLogFile interface, A fixed number of packets can
be held in the memory and once this number is exceeded the other packets are stored in a provided
INonBatchRedoLogFileStorage- Since:
- 7.1
- Author:
- eitany
-
Constructor Summary
ConstructorsConstructorDescriptionFixedSizeSwapRedoLogFile(FixedSizeSwapRedoLogFileConfig config, String name, AbstractSingleFileGroupBacklog groupBacklog) Constructs a fixed size swap redo log file -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a replication packet to the file as the latest packetvoidclose()Closes the redo log filevoiddeleteOldestPackets(long packetsCount) Deletes the oldest packets, starting from the oldest up until the specified batch sizelongGets an approximation of the number of replication packets held in the file, implementation of this method should not assume a reader lock is held and hence can return a result which is not accurate if it cannot do so without a lock.longlonglonglonglonglonglonglonglongbooleanisEmpty()performCompaction(long from, long to) readOnlyIterator(long fromKey) Remove and returns the oldest replication packet in the filelongsize()voidValidates the integrity of the redo log fileMethods 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.IRedoLogFile
flushToStorage, getSwapStorageType
-
Constructor Details
-
FixedSizeSwapRedoLogFile
public FixedSizeSwapRedoLogFile(FixedSizeSwapRedoLogFileConfig config, String name, AbstractSingleFileGroupBacklog groupBacklog) Constructs a fixed size swap redo log file
-
-
Method Details
-
add
Description copied from interface:IRedoLogFileAdd a replication packet to the file as the latest packet- Specified by:
addin interfaceIRedoLogFile<T extends IReplicationOrderedPacket>- Parameters:
replicationPacket- packet to add
-
getOldest
- Specified by:
getOldestin interfaceIRedoLogFile<T extends IReplicationOrderedPacket>- Returns:
- Gets the oldest replication packet in the file
-
getOldestKey
public long getOldestKey()- Specified by:
getOldestKeyin interfaceIRedoLogFile<T extends IReplicationOrderedPacket>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceIRedoLogFile<T extends IReplicationOrderedPacket>- Returns:
- true if the file has no replication packets stored
-
readOnlyIterator
- Specified by:
readOnlyIteratorin interfaceIRedoLogFile<T extends IReplicationOrderedPacket>- Parameters:
fromKey- index to start from- Returns:
- read only iterator over the packets in the file that will start from the given index, where 0 specified the oldest packet
-
removeOldest
Description copied from interface:IRedoLogFileRemove and returns the oldest replication packet in the file- Specified by:
removeOldestin interfaceIRedoLogFile<T extends IReplicationOrderedPacket>- Returns:
- returns the oldest replication packet in the file
-
size
public long size()- Specified by:
sizein interfaceIRedoLogFile<T extends IReplicationOrderedPacket>- Specified by:
sizein interfaceIRedoLogFileStatistics- Returns:
- the number of replication packets held in the file
-
getApproximateSize
public long getApproximateSize()Description copied from interface:IRedoLogFileGets an approximation of the number of replication packets held in the file, implementation of this method should not assume a reader lock is held and hence can return a result which is not accurate if it cannot do so without a lock.- Specified by:
getApproximateSizein interfaceIRedoLogFile<T extends IReplicationOrderedPacket>- Returns:
- an approximation of the replication packets held in the file
-
deleteOldestPackets
public void deleteOldestPackets(long packetsCount) Description copied from interface:IRedoLogFileDeletes the oldest packets, starting from the oldest up until the specified batch size- Specified by:
deleteOldestPacketsin interfaceIRedoLogFile<T extends IReplicationOrderedPacket>- Parameters:
packetsCount- number of oldest packets to delete
-
getMemoryPacketCount
public long getMemoryPacketCount() -
getStoragePacketCount
public long getStoragePacketCount() -
getExternalStorageSpaceUsed
public long getExternalStorageSpaceUsed()- Specified by:
getExternalStorageSpaceUsedin interfaceIRedoLogFileStatistics- Returns:
- used space in bytes which is external to the jvm
-
getExternalStoragePacketsCount
public long getExternalStoragePacketsCount()- Specified by:
getExternalStoragePacketsCountin interfaceIRedoLogFileStatistics- Returns:
- number of packets held in storage
-
getMemoryPacketsWeight
public long getMemoryPacketsWeight()- Specified by:
getMemoryPacketsWeightin interfaceIRedoLogFileStatistics- Returns:
- total weight of packets held in memory
-
getExternalStoragePacketsWeight
public long getExternalStoragePacketsWeight()- Specified by:
getExternalStoragePacketsWeightin interfaceIRedoLogFileStatistics- Returns:
- total weight of packets held in external storage
-
getMemoryPacketsCount
public long getMemoryPacketsCount()- Specified by:
getMemoryPacketsCountin interfaceIRedoLogFileStatistics- Returns:
- number of packets held in memory
-
validateIntegrity
Description copied from interface:IRedoLogFileValidates the integrity of the redo log file- Specified by:
validateIntegrityin interfaceIRedoLogFile<T extends IReplicationOrderedPacket>- Throws:
RedoLogFileCompromisedException
-
close
public void close()Description copied from interface:IRedoLogFileCloses the redo log file- Specified by:
closein interfaceIRedoLogFile<T extends IReplicationOrderedPacket>
-
getWeight
public long getWeight()- Specified by:
getWeightin interfaceIRedoLogFile<T extends IReplicationOrderedPacket>
-
performCompaction
- Specified by:
performCompactionin interfaceIRedoLogFile<T extends IReplicationOrderedPacket>- Parameters:
from- key to start searching transient packet fromto- key to end searching transient packet from- Returns:
- number of discarded packets
-
getMemoryRedoLogFile
-