private void debugSegment ( WriteStream out , SegmentServiceImpl segmentService , SegmentExtent extent , byte [ ] debugTableKey ) throws IOException { int length = extent . length ( ) ; try ( InSegment in = segmentService . openRead ( extent ) ) { ReadStream is = new ReadStream ( in ) ; is . position ( length - BLOCK_SIZE ) ; long seq = BitsUtil . readLong ( is ) ; if ( seq <= 0 ) { return ; } byte [ ] tableKey = new byte [ 32 ] ; is . readAll ( tableKey , 0 , tableKey . length ) ; TableEntry table = segmentService . findTable ( tableKey ) ; if ( table == null ) { return ; } if ( debugTableKey != null && ! Arrays . equals ( debugTableKey , tableKey ) ) { return ; } out . println ( ) ; StringBuilder sb = new StringBuilder ( ) ; Base64Util . encode ( sb , seq ) ; long time = _idGen . time ( seq ) ; out . println ( "Segment: " + extent . getId ( ) + " (seq: " + sb + ", table: " + Hex . toShortHex ( tableKey ) + ", addr: 0x" + Long . toHexString ( extent . address ( ) ) + ", len: 0x" + Integer . toHexString ( length ) + ", time: " + LocalDateTime . ofEpochSecond ( time / 1000 , 0 , ZoneOffset . UTC ) + ")" ) ; debugSegmentEntries ( out , is , extent , table ) ; } }
Trace through a segment displaying its sequence table and extent .