private void ReadRootPartition() { SeqReadResult result; _reader.Reposition(0); while ((result = _reader.TryReadNext()).Success) { var rec = result.LogRecord; switch (rec.RecordType) { case LogRecordType.PartitionType: var r = ((PartitionTypeLogRecord)rec).Record; if (r.StringPayload == RootPartitionTypeName && r.SubHeader.PartitionId == Guid.Empty) { RootTypeId = r.Header.RecordId; _log.Debug("Root partition type read, id: {id}", RootTypeId); break; } throw new InvalidDataException( "Unexpected partition type encountered while trying to read the root partition type."); case LogRecordType.Partition: var p = ((PartitionLogRecord)rec).Record; if (p.StringPayload == RootPartitionName && p.SubHeader.PartitionTypeId == RootTypeId && p.SubHeader.ParentPartitionId == Guid.Empty) { RootId = p.Header.RecordId; _recordFactory.SetRootPartitionId(RootId.Value); _log.Debug("Root partition read, id: {id}", RootId); return; } throw new InvalidDataException( "Unexpected partition encountered while trying to read the root partition."); case LogRecordType.System: var systemLogRecord = (ISystemLogRecord)result.LogRecord; if (systemLogRecord.SystemRecordType == SystemRecordType.Epoch) { continue; } throw new ArgumentOutOfRangeException("SystemRecordType", "Unexpected system record while trying to read the root partition"); default: throw new ArgumentOutOfRangeException("RecordType", "Unexpected record while trying to read the root partition"); } } }
public SeqReadResult TryReadNext() { return(Reader.TryReadNext()); }