Class MigrationChunkTransfer

java.lang.Object
com.loomcache.server.cluster.MigrationChunkTransfer

public class MigrationChunkTransfer extends Object
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
  • Field Details

  • 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 identifier
      chunkIndex - zero-based chunk number
      data - chunk data to transfer
      Returns:
      the chunk with computed checksum
      Throws:
      IOException - if transfer fails
      InterruptedException - 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 identifier
      data - complete data to transfer
      callback - optional callback for each chunk
      Returns:
      number of chunks transferred
      Throws:
      IOException - if transfer fails
      InterruptedException - 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