Package com.lucimber.dbus.util
Class FrameRecoveryManager
java.lang.Object
com.lucimber.dbus.util.FrameRecoveryManager
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumTypes of frame corruption.static classResult of frame analysis.static classFrame diagnostic information.static classFrame recovery statistics. -
Method Summary
Modifier and TypeMethodDescriptionanalyzeFrame(ByteBuffer buffer) Analyzes a potentially corrupted frame and provides recovery information.createDiagnostic(ByteBuffer buffer, int maxBytes) Creates a detailed diagnostic report for a corrupted frame.static intfindNextFrameBoundary(ByteBuffer buffer, int maxScanBytes) Attempts to find the next valid frame boundary in a corrupted buffer.Gets frame recovery statistics.static voidrecordCorruption(FrameRecoveryManager.CorruptionType corruptionType, boolean recovered) Records a frame corruption incident for monitoring.static voidResets frame recovery statistics.
-
Method Details
-
analyzeFrame
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
Attempts to find the next valid frame boundary in a corrupted buffer.- Parameters:
buffer- the buffer to scanmaxScanBytes- 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 buffermaxBytes- 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 detectedrecovered- whether the frame was successfully recovered
-
getStatistics
Gets frame recovery statistics.- Returns:
- current statistics
-
resetStatistics
public static void resetStatistics()Resets frame recovery statistics.
-