Exemplo n.º 1
0
        public void ReportWritesProgress(int threadId,
                                         int sent,
                                         int prepareTimeouts,
                                         int commitTimeouts,
                                         int forwardTimeouts,
                                         int wrongExpctdVersions,
                                         int streamsDeleted,
                                         int fails,
                                         int requests)
        {
            var sentP  = ToPercent(sent, requests);
            var failsP = ToPercent(fails, sent);

            var table = new ConsoleTable("WRITER ID", "Completed %", "Completed/Total",
                                         "Failed %", "Failed/Sent", "Prepare Timeouts",
                                         "Commit Timeouts", "Forward Timeouts",
                                         "Wrong Versions", "Stream Deleted");

            table.AppendRow(threadId.ToString(), string.Format("{0:0.0}%", sentP), string.Format("{0}/{1}", sent, requests),
                            string.Format("{0:0.0}%", failsP), string.Format("{0}/{1}", fails, sent), prepareTimeouts.ToString(),
                            commitTimeouts.ToString(), forwardTimeouts.ToString(),
                            wrongExpctdVersions.ToString(), streamsDeleted.ToString());

            if (failsP > 50d)
            {
                _log.Fatal(table.CreateIndentedTable());
            }
            else
            {
                _log.Info(table.CreateIndentedTable());
            }
        }
Exemplo n.º 2
0
        public void ReportWritesProgress(int threadId,
                                         int sent,
                                         int prepareTimeouts,
                                         int commitTimeouts,
                                         int forwardTimeouts,
                                         int wrongExpctdVersions,
                                         int streamsDeleted,
                                         int fails,
                                         int requests)
        {
            var sentP = ToPercent(sent, requests);
            var failsP = ToPercent(fails, sent);

            var table = new ConsoleTable("WRITER ID", "Completed %", "Completed/Total",
                                         "Failed %", "Failed/Sent", "Prepare Timeouts",
                                         "Commit Timeouts", "Forward Timeouts",
                                         "Wrong Versions", "Stream Deleted");
            table.AppendRow(threadId.ToString(), string.Format("{0:0.0}%", sentP), string.Format("{0}/{1}", sent, requests),
                            string.Format("{0:0.0}%", failsP), string.Format("{0}/{1}", fails, sent), prepareTimeouts.ToString(),
                            commitTimeouts.ToString(), forwardTimeouts.ToString(),
                            wrongExpctdVersions.ToString(), streamsDeleted.ToString());

            if (failsP > 50d)
                _log.Fatal(table.CreateIndentedTable());
            else
                _log.Info(table.CreateIndentedTable());
        }
Exemplo n.º 3
0
        public void ReportReadsProgress(int threadId, int successes, int fails)
        {
            var all = successes + fails;

            var table = new ConsoleTable("READER ID", "Fails", "Total Random Reads");
            table.AppendRow(threadId.ToString(), fails.ToString(), all.ToString());

            if (fails != 0)
                _log.Fatal(table.CreateIndentedTable());
            else
                _log.Info(table.CreateIndentedTable());
        }
Exemplo n.º 4
0
        public void ReportReadsProgress(int threadId, int successes, int fails)
        {
            var all = successes + fails;

            var table = new ConsoleTable("READER ID", "Fails", "Total Random Reads");

            table.AppendRow(threadId.ToString(), fails.ToString(), all.ToString());

            if (fails != 0)
            {
                _log.Fatal(table.CreateIndentedTable());
            }
            else
            {
                _log.Info(table.CreateIndentedTable());
            }
        }
Exemplo n.º 5
0
        private bool Verify(CommandProcessorContext context, int writers, int readers, int events)
        {
            var readStatuses = Enumerable.Range(0, readers).Select(x => new Status(context.Log)).ToArray();
            var readNotifications = Enumerable.Range(0, readers).Select(x => new ManualResetEventSlim(false)).ToArray();
            var writeStatuses = Enumerable.Range(0, writers).Select(x => new Status(context.Log)).ToArray();
            var writeNotifications = Enumerable.Range(0, writers).Select(x => new ManualResetEventSlim(false)).ToArray();

            for (int i = 0; i < readers; i++)
            {
                var i1 = i;
                var thread = new Thread(() => Read(readStatuses[i1], i1, context, readNotifications[i1]));
                thread.IsBackground = true;
                thread.Start();
            }

            for (int i = 0; i < writers; i++)
            {
                var i1 = i;
                var thread = new Thread(() => Write(writeStatuses[i1], i1, context, events / writers, writeNotifications[i1]));
                thread.IsBackground = true;
                thread.Start();
            }

            foreach (var writeNotification in writeNotifications)
            {
                writeNotification.Wait();
            }
            _stopReading = true;
            foreach (var readNotification in readNotifications)
            {
                readNotification.Wait();
            }

            context.Log.Info("dvub finished execution : ");

            var writersTable = new ConsoleTable("WRITER ID", "Status");
            
            foreach (var ws in writeStatuses)
            {
                writersTable.AppendRow(ws.ThreadId.ToString(), ws.Success ? "Success" : "Fail");
            }

            var readersTable = new ConsoleTable("READER ID", "Status");
            foreach (var rs in readStatuses) 
            {
                readersTable.AppendRow(rs.ThreadId.ToString(), rs.Success ? "Success" : "Fail");
            }

            context.Log.Info(writersTable.CreateIndentedTable());
            context.Log.Info(readersTable.CreateIndentedTable());

            var success = writeStatuses.All(s => s.Success) && readStatuses.All(s => s.Success);
            if (success)
                context.Success();
            else
                context.Fail();
            return success;
        }
Exemplo n.º 6
0
        public void NotifyEventCommitted(VerificationEvent @event)
        {
            _eventsForVerification.Enqueue(@event);

            var com = Interlocked.Increment(ref _totalWritten);

            if (com % NotificationStep == 0)
            {
                var table = new ConsoleTable("WORKER", "COMMITTED");
                table.AppendRow("WRITER", com.ToString());
                Log.Info(table.CreateIndentedTable());
            }
        }
Exemplo n.º 7
0
        public void NotifyEventVerified(VerificationEvent @event)
        {
            var ver = Interlocked.Increment(ref _totalVerified);

            if (ver % NotificationStep == 0)
            {
                var table = new ConsoleTable("WORKER", "VERIFIED");
                table.AppendRow("VERIFIER", ver.ToString());
                Log.Info(table.CreateIndentedTable());
            }

            var committed = _totalWritten;

            if (committed == _totalEvents)
            {
                _doneEvent.Set();
            }
        }
Exemplo n.º 8
0
        private bool Verify(CommandProcessorContext context, int writers, int readers, int events)
        {
            var readStatusses     = Enumerable.Range(0, readers).Select(x => new Status(context.Log)).ToList();
            var readNotifications = new List <AutoResetEvent>();

            for (int i = 0; i < readers; i++)
            {
                readNotifications.Add(new AutoResetEvent(false));
            }
            for (int i = 0; i < readers; i++)
            {
                var i1 = i;
                new Thread(() => Read(readStatusses[i1], i1, context, readNotifications[i1]))
                {
                    IsBackground = true
                }.Start();
            }

            var writeStatusses     = Enumerable.Range(0, writers).Select(x => new Status(context.Log)).ToList();
            var writeNotifications = new List <AutoResetEvent>();

            for (int i = 0; i < writers; i++)
            {
                writeNotifications.Add(new AutoResetEvent(false));
            }
            for (int i = 0; i < writers; i++)
            {
                var i1 = i;
                new Thread(() => Write(writeStatusses[i1], i1, context, events / writers, writeNotifications[i1]))
                {
                    IsBackground = true
                }.Start();
            }

            writeNotifications.ForEach(w => w.WaitOne());
            _stopReading = true;
            readNotifications.ForEach(r => r.WaitOne());

            context.Log.Info("dvub finished execution : ");

            var writersTable = new ConsoleTable("WRITER ID", "Status");

            writeStatusses.ForEach(ws =>
            {
                writersTable.AppendRow(ws.ThreadId.ToString(),
                                       ws.Success ? "Success" : "Fail");
            });

            var readersTable = new ConsoleTable("READER ID", "Status");

            readStatusses.ForEach(rs =>
            {
                readersTable.AppendRow(rs.ThreadId.ToString(),
                                       rs.Success ? "Success" : "Fail");
            });

            context.Log.Info(writersTable.CreateIndentedTable());
            context.Log.Info(readersTable.CreateIndentedTable());

            var success = writeStatusses.All(s => s.Success) && readStatusses.All(s => s.Success);

            if (success)
            {
                context.Success();
            }
            else
            {
                context.Fail();
            }
            return(success);
        }
Exemplo n.º 9
0
        private bool Verify(CommandProcessorContext context, int writers, int readers, int events)
        {
            var readStatuses = Enumerable.Range(0, readers).Select(x => new Status(context.Log)).ToArray();
            var readNotifications = Enumerable.Range(0, readers).Select(x => new ManualResetEventSlim(false)).ToArray();
            var writeStatuses = Enumerable.Range(0, writers).Select(x => new Status(context.Log)).ToArray();
            var writeNotifications = Enumerable.Range(0, writers).Select(x => new ManualResetEventSlim(false)).ToArray();

            for (int i = 0; i < readers; i++)
            {
                var i1 = i;
                var thread = new Thread(() => Read(readStatuses[i1], i1, context, readNotifications[i1]));
                thread.IsBackground = true;
                thread.Start();
            }

            for (int i = 0; i < writers; i++)
            {
                var i1 = i;
                var thread = new Thread(() => Write(writeStatuses[i1], i1, context, events / writers, writeNotifications[i1]));
                thread.IsBackground = true;
                thread.Start();
            }

            foreach (var writeNotification in writeNotifications)
            {
                writeNotification.Wait();
            }
            _stopReading = true;
            foreach (var readNotification in readNotifications)
            {
                readNotification.Wait();
            }

            context.Log.Info("dvub finished execution : ");

            var writersTable = new ConsoleTable("WRITER ID", "Status");
            
            foreach (var ws in writeStatuses)
            {
                writersTable.AppendRow(ws.ThreadId.ToString(), ws.Success ? "Success" : "Fail");
            }

            var readersTable = new ConsoleTable("READER ID", "Status");
            foreach (var rs in readStatuses) 
            {
                readersTable.AppendRow(rs.ThreadId.ToString(), rs.Success ? "Success" : "Fail");
            }

            context.Log.Info(writersTable.CreateIndentedTable());
            context.Log.Info(readersTable.CreateIndentedTable());

            var success = writeStatuses.All(s => s.Success) && readStatuses.All(s => s.Success);
            if (success)
                context.Success();
            else
                context.Fail();
            return success;
        }
Exemplo n.º 10
0
        private bool Verify(CommandProcessorContext context, int writers, int readers, int events)
        {
            var readStatusses = Enumerable.Range(0, readers).Select(x => new Status(context.Log)).ToList();
            var readNotifications = new List<AutoResetEvent>();
            for (int i = 0; i < readers; i++)
                readNotifications.Add(new AutoResetEvent(false));
            for (int i = 0; i < readers; i++)
            {
                var i1 = i;
                new Thread(() => Read(readStatusses[i1], i1, context, readNotifications[i1])) { IsBackground = true }.Start();
            }

            var writeStatusses = Enumerable.Range(0, writers).Select(x => new Status(context.Log)).ToList();
            var writeNotifications = new List<AutoResetEvent>();
            for (int i = 0; i < writers; i++)
                writeNotifications.Add(new AutoResetEvent(false));
            for (int i = 0; i < writers; i++)
            {
                var i1 = i;
                new Thread(() => Write(writeStatusses[i1], i1, context, events / writers, writeNotifications[i1])) { IsBackground = true }.Start();
            }

            writeNotifications.ForEach(w => w.WaitOne());
            _stopReading = true;
            readNotifications.ForEach(r => r.WaitOne());

            context.Log.Info("dvub finished execution : ");

            var writersTable = new ConsoleTable("WRITER ID", "Status");
            writeStatusses.ForEach(ws =>
            {
                writersTable.AppendRow(ws.ThreadId.ToString(),
                                       ws.Success ? "Success" : "Fail");
            });

            var readersTable = new ConsoleTable("READER ID", "Status");
            readStatusses.ForEach(rs =>
            {
                readersTable.AppendRow(rs.ThreadId.ToString(),
                                       rs.Success ? "Success" : "Fail");
            });

            context.Log.Info(writersTable.CreateIndentedTable());
            context.Log.Info(readersTable.CreateIndentedTable());

            var success = writeStatusses.All(s => s.Success) && readStatusses.All(s => s.Success);
            if(success)
                context.Success();
            else
                context.Fail();
            return success;
        }
Exemplo n.º 11
0
        public void NotifyEventVerified(VerificationEvent @event)
        {
            var ver = Interlocked.Increment(ref _totalVerified);
            if (ver % NotificationStep == 0)
            {
                var table = new ConsoleTable("WORKER", "VERIFIED");
                table.AppendRow("VERIFIER", ver.ToString());
                Log.Info(table.CreateIndentedTable());
            }

            var committed = _totalWritten;
            if (committed == _totalEvents)
                _doneEvent.Set();
        }
Exemplo n.º 12
0
        public void NotifyEventCommitted(VerificationEvent @event)
        {
            _eventsForVerification.Enqueue(@event);

            var com = Interlocked.Increment(ref _totalWritten);
            if (com % NotificationStep == 0)
            {
                var table = new ConsoleTable("WORKER", "COMMITTED");
                table.AppendRow("WRITER", com.ToString());
                Log.Info(table.CreateIndentedTable());
            }
        }