示例#1
0
        private static async ValueTask <long> SlowEnqueueAsync(FasterLog @this, IReadOnlySpanBatch readOnlySpanBatch, CancellationToken token)
        {
            long logicalAddress;

            while (true)
            {
                var task = @this.CommitTask;
                if (@this.TryEnqueue(readOnlySpanBatch, out logicalAddress))
                {
                    break;
                }
                if (@this.NeedToWait(@this.CommittedUntilAddress, @this.TailAddress))
                {
                    // Wait for *some* commit - failure can be ignored except if the token was signaled (which the caller should handle correctly)
                    try
                    {
                        await task.WithCancellationAsync(token);
                    }
                    catch when(!token.IsCancellationRequested)
                    {
                    }
                }
            }

            return(logicalAddress);
        }
示例#2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="fasterLog"></param>
        /// <param name="hlog"></param>
        /// <param name="beginAddress"></param>
        /// <param name="endAddress"></param>
        /// <param name="scanBufferingMode"></param>
        /// <param name="epoch"></param>
        /// <param name="headerSize"></param>
        /// <param name="name"></param>
        /// <param name="getMemory"></param>
        /// <param name="scanUncommitted"></param>
        internal unsafe FasterLogScanIterator(FasterLog fasterLog, BlittableAllocator <Empty, byte> hlog, long beginAddress, long endAddress, GetMemory getMemory, ScanBufferingMode scanBufferingMode, LightEpoch epoch, int headerSize, string name, bool scanUncommitted = false)
            : base(beginAddress == 0 ? hlog.GetFirstValidLogicalAddress(0) : beginAddress, endAddress, scanBufferingMode, epoch, hlog.LogPageSizeBits)
        {
            this.fasterLog       = fasterLog;
            this.allocator       = hlog;
            this.getMemory       = getMemory;
            this.headerSize      = headerSize;
            this.scanUncommitted = scanUncommitted;

            this.name             = name;
            CompletedUntilAddress = beginAddress;

            if (frameSize > 0)
            {
                frame = new BlittableFrame(frameSize, hlog.PageSize, hlog.GetDeviceSectorSize());
            }
        }
示例#3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="fasterLog"></param>
        /// <param name="hlog"></param>
        /// <param name="beginAddress"></param>
        /// <param name="endAddress"></param>
        /// <param name="scanBufferingMode"></param>
        /// <param name="epoch"></param>
        /// <param name="headerSize"></param>
        /// <param name="name"></param>
        /// <param name="getMemory"></param>
        /// <param name="scanUncommitted"></param>
        internal unsafe FasterLogScanIterator(FasterLog fasterLog, BlittableAllocator <Empty, byte> hlog, long beginAddress, long endAddress, GetMemory getMemory, ScanBufferingMode scanBufferingMode, LightEpoch epoch, int headerSize, string name, bool scanUncommitted = false)
        {
            this.fasterLog       = fasterLog;
            this.allocator       = hlog;
            this.getMemory       = getMemory;
            this.epoch           = epoch;
            this.headerSize      = headerSize;
            this.scanUncommitted = scanUncommitted;

            if (beginAddress == 0)
            {
                beginAddress = hlog.GetFirstValidLogicalAddress(0);
            }

            this.name       = name;
            this.endAddress = endAddress;
            NextAddress     = CompletedUntilAddress = beginAddress;

            if (scanBufferingMode == ScanBufferingMode.SinglePageBuffering)
            {
                frameSize = 1;
            }
            else if (scanBufferingMode == ScanBufferingMode.DoublePageBuffering)
            {
                frameSize = 2;
            }
            else if (scanBufferingMode == ScanBufferingMode.NoBuffering)
            {
                frameSize = 0;
                return;
            }

            frame          = new BlittableFrame(frameSize, hlog.PageSize, hlog.GetDeviceSectorSize());
            loaded         = new CountdownEvent[frameSize];
            loadedCancel   = new CancellationTokenSource[frameSize];
            loadedPage     = new long[frameSize];
            nextLoadedPage = new long[frameSize];
            for (int i = 0; i < frameSize; i++)
            {
                loadedPage[i]     = -1;
                nextLoadedPage[i] = -1;
                loadedCancel[i]   = new CancellationTokenSource();
            }
        }
示例#4
0
        public FasterLog(BlobManager blobManager, NetheriteOrchestrationServiceSettings settings)
        {
            this.log = new FASTER.core.FasterLog(blobManager.EventLogSettings(settings.UsePremiumStorage));
            this.terminationToken = blobManager.PartitionErrorHandler.Token;

            var _ = this.terminationToken.Register(
                () => {
                try
                {
                    this.log.Dispose();
                    blobManager.EventLogDevice.Dispose();
                }
                catch (Exception e)
                {
                    blobManager.TraceHelper.FasterStorageError("Disposing FasterLog", e);
                }
            },
                useSynchronizationContext: false);
        }
示例#5
0
 /// <inheritdoc/>
 public override void OnAttached(FasterLog log)
 {
 }
示例#6
0
 /// <summary>
 /// Invoked when policy object is attached to a FasterLog instance.
 /// </summary>
 /// <param name="log">The log this log commit policy is attached to</param>
 public abstract void OnAttached(FasterLog log);
示例#7
0
 /// <inheritdoc/>
 public override void OnAttached(FasterLog log) => this.log = log;