public async Task DeleteSystems() { if (CreateNodeOnEachTest) { return; } Console.WriteLine(); Console.WriteLine("Stopping node"); await GridNode.Stop(); }
private static void RawCommandExecution(int totalAggregateScenariosCount, int aggregateScenarioPackSize, int aggregateChangeAmount) { var dbCfg = new AutoTestAkkaConfiguration(); using (var connection = new SqlConnection(dbCfg.Persistence.JournalConnectionString)) { connection.Open(); var sqlText = @"TRUNCATE TABLE Journal"; var cmdJournal = new SqlCommand(sqlText, connection); cmdJournal.ExecuteNonQuery(); var sqlText1 = @"TRUNCATE TABLE Snapshots"; var cmdSnapshots = new SqlCommand(sqlText, connection); cmdSnapshots.ExecuteNonQuery(); } var unityContainer = new UnityContainer(); unityContainer.Register(new SampleDomainContainerConfiguration()); var cfg = new CustomContainerConfiguration( c => c.Register(new SampleDomainContainerConfiguration()), c => c.RegisterType <IPersistentChildsRecycleConfiguration, InsertOptimazedBulkConfiguration>(), c => c.RegisterType <IQuartzConfig, PersistedQuartzConfig>()); Func <ActorSystem[]> actorSystemFactory = () => new[] { new StressTestAkkaConfiguration().CreateSystem() }; var node = new GridDomainNode(cfg, new SampleRouteMap(unityContainer), actorSystemFactory); node.Start().Wait(); var timer = new Stopwatch(); timer.Start(); int timeoutedCommads = 0; var random = new Random(); var commandsInScenario = aggregateScenarioPackSize * (aggregateChangeAmount + 1); var totalCommandsToIssue = commandsInScenario * totalAggregateScenariosCount; for (int i = 0; i < totalAggregateScenariosCount; i++) { var packTimer = new Stopwatch(); packTimer.Start(); var tasks = Enumerable.Range(0, aggregateScenarioPackSize) .Select(t => WaitAggregateCommands(aggregateChangeAmount, random, node)) .ToArray(); try { Task.WhenAll(tasks).Wait(); } catch { timeoutedCommads += tasks.Count(t => t.IsCanceled || t.IsFaulted); } packTimer.Stop(); var speed = (decimal)(commandsInScenario / packTimer.Elapsed.TotalSeconds); var timeLeft = TimeSpan.FromSeconds((double)((totalCommandsToIssue - i * commandsInScenario) / speed)); Console.WriteLine($"speed :{speed} cmd/sec," + $"total errors: {timeoutedCommads}, " + $"total commands executed: {i*commandsInScenario}/{totalCommandsToIssue}," + $"approx time remaining: {timeLeft}"); } timer.Stop(); node.Stop().Wait(); var speedTotal = (decimal)(totalCommandsToIssue / timer.Elapsed.TotalSeconds); Console.WriteLine( $"Executed {totalAggregateScenariosCount} batches = {totalCommandsToIssue} commands in {timer.Elapsed}"); Console.WriteLine($"Average speed was {speedTotal} cmd/sec"); using (var connection = new SqlConnection(dbCfg.Persistence.JournalConnectionString)) { connection.Open(); var sqlText = @"SELECT COUNT(*) FROM Journal"; var cmdJournal = new SqlCommand(sqlText, connection); var count = (int)cmdJournal.ExecuteScalar(); Console.WriteLine(count == totalCommandsToIssue ? "Journal contains all events" : $"Journal contains only {count} of {totalCommandsToIssue}"); } }
public void Stop() { _gridDomainNode.Stop().Wait(); }
public async Task TurnOffNode() { await _node.Stop(); }
public async Task Down() { await _gridDomainNode.Stop(); }