Beispiel #1
0
        /// <summary>
        /// See <see cref="ITwoPhaseFingerprintStore.TryPublishCacheEntryAsync"/>
        /// </summary>
        public virtual async Task <Possible <CacheEntryPublishResult, Failure> > TryPublishCacheEntryAsync(
            Pip pip,
            WeakContentFingerprint weakFingerprint,
            ContentHash pathSetHash,
            StrongContentFingerprint strongFingerprint,
            CacheEntry entry,
            CacheEntryPublishMode mode = CacheEntryPublishMode.CreateNew)
        {
            Contract.Requires(pathSetHash.IsValid);
            Contract.Requires(entry.MetadataHash.IsValid);

            var result = await TwoPhaseFingerprintStore.TryPublishCacheEntryAsync(
                weakFingerprint,
                pathSetHash,
                strongFingerprint,
                entry,
                mode);

            if (result.Succeeded)
            {
                var publishedEntry = result.Result.Status == CacheEntryPublishStatus.Published ? entry : result.Result.ConflictingEntry;
                Tracing.Logger.Log.PipTwoPhaseCachePublishCacheEntry(
                    LoggingContext,
                    pip.GetDescription(Context),
                    weakFingerprint.ToString(),
                    pathSetHash.ToString(),
                    strongFingerprint.ToString(),
                    entry.MetadataHash.ToString(),
                    result.Result.Status.ToString(),
                    publishedEntry.MetadataHash.ToString());
            }

            return(result);
        }
        private static async Task <Possible <CacheEntryPublishResult, Failure> > TryPublishNodeTemporalCacheEntryAsync(
            this ITwoPhaseFingerprintStore store,
            LoggingContext loggingContext,
            TimeTreeNode node,
            ContentFingerprint fingerprint,
            CacheEntry entry)
        {
            // Unblock the caller
            await Task.Yield();

            var result = await store.TryPublishCacheEntryAsync(
                new WeakContentFingerprint(fingerprint.Hash),
                s_dummyPathSetHash,
                node.NodeFingerprint,
                entry);

            Logger.Log.TemporalCacheEntryTrace(loggingContext, I($"Publishing temporal cache entry: Node='{node}', Fingerprint='{fingerprint}' MetadataHash='{entry.MetadataHash}' Success='{result.Succeeded}'"));

            if (result.Succeeded)
            {
                Logger.Log.TemporalCacheEntryTrace(loggingContext, I($"Published temporal cache entry: Node='{node}', Fingerprint='{fingerprint}' Status='{result.Result.Status}'"));
            }
            else
            {
                Logger.Log.TemporalCacheEntryTrace(loggingContext, I($"Failed publish of temporal cache entry: Node='{node}', Fingerprint='{fingerprint}' Failure:='{result.Failure.DescribeIncludingInnerFailures()}'"));
            }

            return(result);
        }