Ejemplo n.º 1
0
        private static void RetryWhileConcurrent(eRepositoryType repoType, Guid aggyId, int value)
        {
            while (true)
            {
                try
                {
                    Stopwatch sw = new Stopwatch();
                    sw.Start();

                    _log.Trace("Getting Aggregate [{0}]", aggyId);
                    var repo = new TestRepository(repoType);
                    var aggy = repo.GetSimpleAggregateById(aggyId, 0);
                    aggy.ChangeFoo(value);

                    _log.Trace("Saving Aggregate [{0}]", aggyId);
                    repo.Save(aggy, Guid.NewGuid(), null);

                    _log.Trace("Saved Aggregate [{0}]", aggyId);
                    break;
                }
                catch (ConcurrencyException)
                {
                    _log.Trace("Concurrency Detected, will retry shortly");
                    var rand = new Random();
                    Thread.Sleep(rand.Next(0, 200));                            // this is to increase race condition likelyhood
                }
                catch (Exception ex)
                {
                    _log.Trace("BAD!!!!!! Generic Exception, [{0}], we will let the aggregate retry though", ex.Message);
                    var rand = new Random();
                    Thread.Sleep(rand.Next(0, 200));                            // this is to increase race condition likelyhood
                }
            }
        }
Ejemplo n.º 2
0
        private static void SnapshotAggregate(eRepositoryType repoType, Guid aggyId)
        {
            var sw   = Stopwatch.StartNew();
            var repo = new TestRepository(repoType);
            var aggy = repo.GetSimpleAggregateById(aggyId, Int32.MaxValue);

            repo.Snapshot(aggy);
            _log.Info("Snapshot took [{0}] ms", sw.ElapsedMilliseconds);
        }
Ejemplo n.º 3
0
        private static void CheckAggregate(TestRepository repository, Guid aggregateId, IEnumerable <int> valuesItShouldHave)
        {
            var isGood = true;
            var aggy   = repository.GetSimpleAggregateById(aggregateId, 0);

            foreach (var valueItShouldHave in valuesItShouldHave)
            {
                if (!aggy.FooHolder.Contains(valueItShouldHave))
                {
                    _log.Error("Aggy [{0}] missing value [{1}].  There is something wrong!!!", aggregateId, valueItShouldHave);
                    isGood = false;
                }
            }

            _log.Info("Aggregate [{0}] is {1}good", aggregateId, isGood ? string.Empty : "NOT ");
        }