StartTask() public method

public StartTask ( int numberOfManagers, int numberOfNodes, bool useLoadBalancerIfJustOneManager, CancellationTokenSource cancellationTokenSource ) : Task
numberOfManagers int
numberOfNodes int
useLoadBalancerIfJustOneManager bool
cancellationTokenSource System.Threading.CancellationTokenSource
return Task
		public virtual void TestFixtureSetUp()
		{
			HttpSender = new HttpSender();
			HttpRequestManager = new HttpRequestManager();

			AppDomain = AppDomain.CurrentDomain;

			ManagerDbConnectionString =
				ConfigurationManager.ConnectionStrings["ManagerConnectionString"].ConnectionString;

			var configurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
			XmlConfigurator.ConfigureAndWatch(new FileInfo(configurationFile));

			DatabaseHelper.ClearDatabase(ManagerDbConnectionString);

			CancellationTokenSource = new CancellationTokenSource();

			AppDomainTask = new AppDomainTask(BuildMode);

			Task = AppDomainTask.StartTask(numberOfManagers: NumberOfManagers,
			                               numberOfNodes: NumberOfNodes,
										   useLoadBalancerIfJustOneManager: UseLoadBalancerIfJustOneManager,
										   cancellationTokenSource: CancellationTokenSource);

			bool managerUp = HttpRequestManager.IsManagerUp();
			while (!managerUp)
			{
				managerUp = HttpRequestManager.IsManagerUp();
			}

			if (WaitToStartUp)
			{
				var sqlNotiferCancellationTokenSource = new CancellationTokenSource();
				var sqlNotifier = new SqlNotifier(ManagerDbConnectionString);

				var task = sqlNotifier.CreateNotifyWhenNodesAreUpTask(NumberOfNodes,
																	  sqlNotiferCancellationTokenSource);
				task.Start();

				sqlNotifier.NotifyWhenAllNodesAreUp.Wait(TimeSpan.FromMinutes(10));
				sqlNotifier.Dispose();
			}
		}
Example #2
0
		public void StartConsoleHost()
		{
			Task.Factory.StartNew(() =>
			{
				CancellationTokenSourceAppDomainTask = new CancellationTokenSource();

				AppDomainTask = new AppDomainTask("Debug");

				var task = AppDomainTask.StartTask(NumberOfManagers,
				                                   NumberOfNodes,
				                                   useLoadBalancerIfJustOneManager: true,
				                                   cancellationTokenSource: CancellationTokenSourceAppDomainTask);

				IsConsoleHostStarted = true;
			});
		}