public void push(TaskRunContext context, ulong taskId, TaskStateInfo info) { Common.Utility.LogInfo("TaskCacheCollector.push taskId=" + taskId + " info=" + info.ProcessInfo.TimeSnapshot); if (!IsServicedController(context.Controller)) { return; } var resName = context.Resource.ResourceName; lock (_lock) { if (!bufferTaskInfo.ContainsKey(taskId)) { bufferTaskInfo.Add(taskId, new TaskStatInfo(new Dictionary <string, List <ProcessStatInfo> >(), resName)); } if (!bufferTaskInfo[taskId].ProcessInfoCollection.ContainsKey(info.NodeName)) { bufferTaskInfo[taskId].ProcessInfoCollection.Add(info.NodeName, new List <ProcessStatInfo>()); } bufferTaskInfo[taskId].ProcessInfoCollection[info.NodeName].Add(info.ProcessInfo); } }
private void HandleTaskStateChanged(List <TaskStateInfo> taskStateInfo) { for (int i = 0; i < taskStateInfo.Count; ++i) { TaskStateInfo tsi = taskStateInfo[i]; ITaskEngine taskEngine = m_taskEngines[tsi.PlayerId]; if (taskEngine != null) { taskEngine.SetTaskState(tsi.TaskId, tsi.State, tsi.StatusCode); } } }
public IEnumerator FindPathClientSidePreprocessingTest() { BeginTest(TestEnv0, 4, 0, () => { MapRoot map = Dependencies.Map.Map; IMatchEngineCli matchEngineCli = Dependencies.MatchEngine; const int playerId = 3; Coordinate[] coords = map.FindDataOfType((int)KnownVoxelTypes.Eater, playerId); VoxelData data = map.Get(coords[0]); Coordinate targetCoordinate = coords[0].Add(-1, -1); MovementCmd moveCmd = new MovementCmd(CmdCode.Move, data.UnitOrAssetIndex, 0); moveCmd.Coordinates = new[] { coords[0], targetCoordinate }; MatchEngineCliEvent <long, CommandsBundle> eventHandler = null; eventHandler = (e, tick, commandsBundle) => { if (commandsBundle.TasksStateInfo != null) { TaskStateInfo taskStateInfo = commandsBundle.TasksStateInfo[0]; Assert.AreEqual(taskStateInfo.PlayerId, playerId); if (taskStateInfo.State == TaskState.Completed) { matchEngineCli.ExecuteCommands -= eventHandler; Coordinate[] newCoords = map.FindDataOfType((int)KnownVoxelTypes.Eater, playerId); Assert.AreEqual(targetCoordinate, newCoords[0]); EndTest(); } else { Assert.AreEqual(TaskState.Active, taskStateInfo.State); } } }; matchEngineCli.ExecuteCommands += eventHandler; TaskInfo taskInfo = new TaskInfo(moveCmd); taskInfo.RequiresClientSidePreprocessing = true; matchEngineCli.GetClientTaskEngine(playerId).GenerateIdentitifers(taskInfo); matchEngineCli.Submit(playerId, new TaskCmd(SerializedTask.FromTaskInfo(taskInfo))); }); yield return(Run()); }
private TaskStateInfo GenerateTaskMockData(string nodeName, int koeff) { //todo recode it in a proper way later. var info = new ProcessStatInfo(); var k1 = koeff * koeff + koeff + 1; var k2 = koeff * koeff; var k3 = Math.Sqrt(koeff) + koeff * koeff; info.FileCount = "5"; info.Net = 1000 * k1; info.PhysicalMem = 5000 * k2; info.ProcUsage = (long)(3000 * k3); info.TotalProcTime = (long)(4000 * k3); info.WorkDirSize = 11000 * k1; info.TimeSnapshot = DateTime.Now; var taskStateInfo = new TaskStateInfo(); taskStateInfo.NodeName = nodeName; taskStateInfo.ProcessInfo = info; return(taskStateInfo); }
public void push(TaskRunContext context, ulong taskId, TaskStateInfo info) { }
private TaskStateInfo SubmitTask(TaskRunContext task, ResourceCache resourceCache) { TaskStateInfo taskStateInfo; lock (resourceCache.StateLock) { try { bool nodesOverloaded = false; var nodeStates = resourceCache.NodeStateInfo; foreach (var nodeConfig in task.NodesConfig) { var nodeState = nodeStates.Single(n => n.NodeName == nodeConfig.NodeName); if (nodeState.CoresAvailable <= nodeConfig.Cores) nodesOverloaded = true; nodeState.TasksSubmitted++; nodeState.CoresReserved += nodeConfig.Cores; } if (nodesOverloaded) { Log.Error("Nodes overload for resource " + task.Resource.ResourceName); throw new Exception("Wrong config for task " + task.TaskId.ToString() + ". Selected nodes are overloaded"); } task.LocalId = task.Controller.Run(task); taskStateInfo = new TaskStateInfo(TaskState.Started, task.LocalId.ToString()); } catch (Exception e) { RevokeTask(task, resourceCache); Log.Error(String.Format("Unable to run task {1}: {2}{0}{3}", Environment.NewLine, task.TaskId, e.Message, e.StackTrace )); throw; } } return taskStateInfo; }