Class FrameRecoveryManager

java.lang.Object
com.lucimber.dbus.util.FrameRecoveryManager

public final class FrameRecoveryManager extends Object
Frame recovery manager for handling corrupted D-Bus messages and frame synchronization.

This utility provides sophisticated frame recovery mechanisms including:

  • Frame corruption detection and diagnostics
  • Frame boundary synchronization after corruption
  • Partial frame recovery when possible
  • Detailed error context for debugging
  • Statistics collection for monitoring frame health

The frame recovery manager is designed to be stateless and thread-safe, making it suitable for use across multiple connections and decoder instances.

  • Method Details

    • analyzeFrame

      public static FrameRecoveryManager.FrameAnalysis analyzeFrame(ByteBuffer buffer)
      Analyzes a potentially corrupted frame and provides recovery information.
      Parameters:
      buffer - the buffer containing the potentially corrupted frame
      Returns:
      frame analysis result with recovery recommendations
    • findNextFrameBoundary

      public static int findNextFrameBoundary(ByteBuffer buffer, int maxScanBytes)
      Attempts to find the next valid frame boundary in a corrupted buffer.
      Parameters:
      buffer - the buffer to scan
      maxScanBytes - maximum number of bytes to scan
      Returns:
      position of next potential frame start, or -1 if not found
    • createDiagnostic

      public static FrameRecoveryManager.FrameDiagnostic createDiagnostic(ByteBuffer buffer, int maxBytes)
      Creates a detailed diagnostic report for a corrupted frame.
      Parameters:
      buffer - the corrupted frame buffer
      maxBytes - maximum bytes to include in the hex dump
      Returns:
      diagnostic report
    • recordCorruption

      public static void recordCorruption(FrameRecoveryManager.CorruptionType corruptionType, boolean recovered)
      Records a frame corruption incident for monitoring.
      Parameters:
      corruptionType - the type of corruption detected
      recovered - whether the frame was successfully recovered
    • getStatistics

      public static FrameRecoveryManager.FrameStatistics getStatistics()
      Gets frame recovery statistics.
      Returns:
      current statistics
    • resetStatistics

      public static void resetStatistics()
      Resets frame recovery statistics.