public override void SendTask(TaskRunContext task) { //todo rewrite all this sht later if (taskCacheCollector == null) { taskCacheCollector = base.GetTaskCacheCollector(); } var data = ExtractInfoCountPerNode(task); var iter = data.GetEnumerator(); int current = 0; var t = 0; var coeff = Math.Sin(t); var angleRandom = new Random(); Utility.CreateAndRunRepeatedProcess(1000, false, () => { Common.Utility.ExceptionablePlaceWrapper(() => { var info = GenerateTaskMockData(iter.Current.Item1.NodeName, t); taskCacheCollector.push(task, task.TaskId, info); }, " Exception while creating and pushing task mock data for taskId=" + task.TaskId + " in MockCacheCollectorFactory", " Mock statistic data for task with taskId=" + task.TaskId + " have been generated and pushed", false); }, () => { if (current == 0) { if (!iter.MoveNext()) { t = 0; return(true); } current = iter.Current.Item2; } t += angleRandom.Next(5, 20); --current; return(false); }); }
public static TaskCacheCollector GetInstance(/*IEnumerable<TaskRunContext> tasks*/) { return _instance ?? (_instance = new TaskCacheCollector(/*tasks*/)); }
public static TaskCacheCollector GetInstance(/*IEnumerable<TaskRunContext> tasks*/) { return(_instance ?? (_instance = new TaskCacheCollector(/*tasks*/))); }
public override void SendTask(TaskRunContext task) { //todo rewrite all this sht later if (taskCacheCollector == null) { taskCacheCollector = base.GetTaskCacheCollector(); } var data = ExtractInfoCountPerNode(task); var iter = data.GetEnumerator(); int current = 0; var t = 0; var coeff = Math.Sin(t); var angleRandom = new Random(); Utility.CreateAndRunRepeatedProcess(1000, false, () => { Common.Utility.ExceptionablePlaceWrapper(() => { var info = GenerateTaskMockData(iter.Current.Item1.NodeName, t); taskCacheCollector.push(task, task.TaskId, info); }, " Exception while creating and pushing task mock data for taskId=" + task.TaskId + " in MockCacheCollectorFactory", " Mock statistic data for task with taskId=" + task.TaskId + " have been generated and pushed", false); } , () => { if (current == 0) { if (!iter.MoveNext()) { t = 0; return true; } current = iter.Current.Item2; } t += angleRandom.Next(5,20); --current; return false; }); }
public virtual TaskCacheCollector GetTaskCacheCollector() { return(pushTaskStat ? TaskCacheCollector.GetInstance() : new EmptyTaskCacheCollector()); }