private StreamMetadata GetStreamMetadataUncached(TFReaderLease reader, string streamId) { var metastreamId = SystemStreams.MetastreamOf(streamId); var metaEventNumber = GetStreamLastEventNumberCached(reader, metastreamId); if (metaEventNumber == ExpectedVersion.NoStream || metaEventNumber == EventNumber.DeletedStream) { return(StreamMetadata.Empty); } PrepareLogRecord prepare = ReadPrepareInternal(reader, metastreamId, metaEventNumber); if (prepare == null) { throw new Exception(string.Format("ReadPrepareInternal couldn't find metaevent #{0} on metastream '{1}'. " + "That should never happen.", metaEventNumber, metastreamId)); } if (prepare.Data.Length == 0 || prepare.Flags.HasNoneOf(PrepareFlags.IsJson)) { return(StreamMetadata.Empty); } try { return(StreamMetadata.FromJsonBytes(prepare.Data)); } catch (Exception) { return(StreamMetadata.Empty); } }
public StreamMetadata GetStreamMetadata(string streamId) { StreamMeta meta; if (_streamRawMetas.TryGet(streamId, out meta)) { if (meta.Meta != null) { return(meta.Meta); } var m = Helper.EatException(() => StreamMetadata.FromJsonBytes(meta.RawMeta), StreamMetadata.Empty); _streamRawMetas.Put(streamId, new StreamMeta(meta.RawMeta, m), 0); return(m); } return(_indexReader.GetStreamMetadata(streamId)); }
private StreamMetadata GetStreamMetadataUncached(TFReaderLease reader, string streamId) { var metastreamId = SystemStreams.MetastreamOf(streamId); var metaEventNumber = GetStreamLastEventNumberCached(reader, metastreamId); if (metaEventNumber == ExpectedVersion.NoStream || metaEventNumber == EventNumber.DeletedStream) { return(StreamMetadata.Empty); } PrepareLogRecord prepare = ReadPrepareInternal(reader, metastreamId, metaEventNumber); if (prepare == null) { throw new Exception(string.Format("ReadPrepareInternal could not find metaevent #{0} on metastream '{1}'. " + "That should never happen.", metaEventNumber, metastreamId)); } if (prepare.Data.Length == 0 || prepare.Flags.HasNoneOf(PrepareFlags.IsJson)) { return(StreamMetadata.Empty); } try { var metadata = StreamMetadata.FromJsonBytes(prepare.Data); if (prepare.Version == LogRecordVersion.LogRecordV0 && metadata.TruncateBefore == int.MaxValue) { metadata = new StreamMetadata(metadata.MaxCount, metadata.MaxAge, EventNumber.DeletedStream, metadata.TempStream, metadata.CacheControl, metadata.Acl); } return(metadata); } catch (Exception) { return(StreamMetadata.Empty); } }