Bend.LogSegmentsHandler._processCommand C# (CSharp) Method

_processCommand() private method

private _processCommand ( LogCommands cmdtype, byte cmdbytes ) : void
cmdtype LogCommands
cmdbytes byte
return void
        private void _processCommand(LogCommands cmdtype, byte[] cmdbytes)
        {
            if (cmdtype == LogCommands.CHECKPOINT_START) {
                // (1) make sure there is no pending checkpoint
                if (checkpoint_log_segments != null) {
                    throw new Exception("can't process two checkpoints at once!");
                }
                // setup for the checkpoint..
                checkpoint_log_segments = new List<RootBlockLogSegment>();
                checkpointReady = false;

                // (2) make a record of the "freeable" log segments
                lock (this) {
                    foreach (RootBlockLogSegment seg in active_log_segments) {
                        // skip the currently active segment because we can only drop whole log segments
                        if (!seg.Equals(currentLogSegmentInfo)) {
                            checkpoint_log_segments.Add(seg);
                        }
                    }
                }
            }
            // this happens in the lock to be sure the flag and the drop end up in the same packet
            if (cmdtype == LogCommands.CHECKPOINT_DROP) {
                // (1) match the checkpoint number against our current pending checkpoint info...
                // (2) "drop" the old log segments by moving them to the pending-free-list
                checkpointReady = true; // the actual flush will take care of the drop
            }
        }