Example #1
0
        private async Task LogPerformanceWorkloadWorker(
            ILogicalLog lLog,
            byte[] recordBuffer,
            TestLogNotification tn75,
            CancellationToken tn75CancelToken,
            CancellationToken CancelToken
            )
        {
            try
            {
                Task taskUsageNotification75;
                long bytes = 0;
                taskUsageNotification75 = tn75.SetupLogUsageNotificationAsync(lLog, 75, tn75CancelToken);

                if (_DedicatedLogOnly)
                {
                    await lLog.ConfigureWritesToOnlyDedicatedLogAsync(CancellationToken.None);
                }

                bool canceled = false;
                this.StartPerfWorkloads.WaitOne();

                while (!canceled)
                {
                    await lLog.AppendAsync(recordBuffer, 0, 40, /*recordBuffer.Length,*/ CancellationToken.None);

                    bytes += 40; /*recordBuffer.Length;*/

                    if (tn75.Fired)
                    {
                        //
                        // Truncate back to 10%
                        //
                        long allowedData        = lLog.Length / 10;
                        long truncationPosition = bytes - allowedData;
                        lLog.TruncateHead(truncationPosition);
                        taskUsageNotification75 = tn75.SetupLogUsageNotificationAsync(lLog, 75, tn75CancelToken);
                    }

                    if (CancelToken.IsCancellationRequested)
                    {
                        canceled = true;
                    }
                }
                await lLog.FlushWithMarkerAsync(CancellationToken.None);

                Interlocked.Add(ref this.TotalByteCount, bytes);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            Console.WriteLine("Tasks completed");

            return;
        }
Example #2
0
 // Truncate the oldest information
 void TruncateHead(
     ILogicalLog logicalLog,
     long streamOffset)
 {
     logicalLog.TruncateHead(streamOffset);
 }