Skip to content

Commit

Permalink
test(journal): add more logging for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
symbiont-stevan-andjelkovic committed Jan 19, 2022
1 parent ce46b8b commit c1f6dad
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/journal/src/Journal/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ tryClaim jour len = do
termBeginPosition =
computeTermBeginPosition termId (positionBitsToShift termLen) initTermId

putStrLn ("tryClaim, termCount: " ++ show (unTermCount termCount))
putStrLn ("tryClaim, activePartitionIndex: " ++ show (unPartitionIndex activePartitionIndex))
putStrLn ("tryClaim, termOffset: " ++ show (unTermOffset termOffset))
limit <- calculatePositionLimit jour
let termAppender = jTermBuffers jour Vector.! unPartitionIndex activePartitionIndex
Expand Down Expand Up @@ -171,23 +173,36 @@ headerWrite termBuffer termOffset len _termId = do
rotateTerm :: Metadata -> IO ()
rotateTerm meta = do
termCount <- activeTermCount meta
putStrLn ("rotateTerm, termCount: " ++ show (unTermCount termCount))
let activePartitionIndex = indexByTermCount termCount
nextIndex = nextPartitionIndex activePartitionIndex
rawTail <- readRawTail meta activePartitionIndex
initTermId <- readInitialTermId meta
let termId = rawTailTermId rawTail
nextTermId = termId + 1
termCount = fromIntegral (nextTermId - initTermId)
putStrLn ("rotateTerm, nextTermId: " ++ show (unTermId nextTermId))
termId' = termId + 1
termCount' = fromIntegral (termId' - initTermId)
putStrLn ("rotateTerm, activePartitionIndex: " ++
show (unPartitionIndex activePartitionIndex))
putStrLn ("rotateTerm, initialTermId: " ++ show (unTermId initTermId))
putStrLn ("rotateTerm, termId: " ++ show (unTermId termId))
putStrLn ("rotateTerm, termId': " ++ show (unTermId termId'))
putStrLn ("rotateTerm, termCount': " ++ show (unTermCount termCount'))

-- XXX: cache this? where exactly?
-- activePartionIndex := nextIndex
-- termOffset := 0
-- termId := nextTermId
-- termBeginPosition += termBufferLength

initialiseTailWithTermId meta nextIndex nextTermId
writeActiveTermCount meta termCount
initialiseTailWithTermId meta nextIndex termId'
writeActiveTermCount meta termCount'

-- XXX: Remove
newTermCount <- activeTermCount meta
putStrLn ("rotateTerm, newTermCount: " ++ show (unTermCount newTermCount))
let newActivePartitionIndex = indexByTermCount newTermCount
putStrLn ("rotateTerm, newActivePartitionIndex: " ++
show (unPartitionIndex newActivePartitionIndex))

------------------------------------------------------------------------

Expand Down

0 comments on commit c1f6dad

Please sign in to comment.