Class MigrationChunkTransfer
java.lang.Object
com.loomcache.server.cluster.MigrationChunkTransfer
Handles chunked data transfer for partition migrations with integrity checking and flow control.
Features:
- Configurable chunk size (default 1MB)
- CRC32 checksum per chunk for integrity verification
- Flow control with backpressure via semaphore
- Progress tracking callback support
- Automatic CRC32 computation and verification
- Since:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRecord representing a single chunk with metadata. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintGet current backpressure queue depth.longGet total bytes transferred.longGet total chunks sent.voidReset transfer statistics.transferChunk(int partitionId, long chunkIndex, byte[] data) Transfer a chunk with automatic CRC32 computation.longtransferData(int partitionId, byte[] data, @Nullable Consumer<MigrationChunkTransfer.TransferChunk> callback) Transfer multiple chunks from a data buffer.
-
Field Details
-
DEFAULT_CHUNK_SIZE
public static final int DEFAULT_CHUNK_SIZE- See Also:
-
DEFAULT_BACKPRESSURE_LIMIT
public static final int DEFAULT_BACKPRESSURE_LIMIT- See Also:
-
-
Constructor Details
-
MigrationChunkTransfer
public MigrationChunkTransfer() -
MigrationChunkTransfer
public MigrationChunkTransfer(int chunkSize, int backpressureLimit)
-
-
Method Details
-
transferChunk
public MigrationChunkTransfer.TransferChunk transferChunk(int partitionId, long chunkIndex, byte[] data) throws IOException, InterruptedException Transfer a chunk with automatic CRC32 computation. Applies backpressure if too many chunks are in flight.- Parameters:
partitionId- partition identifierchunkIndex- zero-based chunk numberdata- chunk data to transfer- Returns:
- the chunk with computed checksum
- Throws:
IOException- if transfer failsInterruptedException- if interrupted while waiting for backpressure
-
transferData
public long transferData(int partitionId, byte[] data, @Nullable Consumer<MigrationChunkTransfer.TransferChunk> callback) throws IOException, InterruptedException Transfer multiple chunks from a data buffer. Splits the buffer into chunks of configured size.- Parameters:
partitionId- partition identifierdata- complete data to transfercallback- optional callback for each chunk- Returns:
- number of chunks transferred
- Throws:
IOException- if transfer failsInterruptedException- if interrupted
-
getTotalChunksSent
public long getTotalChunksSent()Get total chunks sent.- Returns:
- number of chunks transferred
-
getTotalBytesTransferred
public long getTotalBytesTransferred()Get total bytes transferred.- Returns:
- bytes transferred
-
resetStats
public void resetStats()Reset transfer statistics. -
getBackpressureDepth
public int getBackpressureDepth()Get current backpressure queue depth.- Returns:
- number of permits currently held
-