示例#1
0
        /// <summary>
        /// This method is called to update the datastructures to reflect that given request will
        /// be built on a given node.
        /// </summary>
        /// <param name="currentRequest"></param>
        /// <param name="nodeUsed"></param>
        internal void NotifyOfSchedulingDecision(BuildRequest currentRequest, int nodeUsed)
        {
            // Don't update structures on the child node or in single proc mode
            if (childMode || nodes.Length == 1)
            {
                return;
            }

            // Update the count of requests being build on the node
            totalRequestsPerNode[nodeUsed]++;

            // Ignore host requests
            if (currentRequest.HandleId == EngineCallback.invalidEngineHandle)
            {
                return;
            }

            if (Engine.debugMode)
            {
                string targetnames = currentRequest.TargetNames != null?String.Join(";", currentRequest.TargetNames) : "null";

                Console.WriteLine("Sending project " + currentRequest.ProjectFileName + " Target " + targetnames + " to " + nodeUsed);
            }

            // Update the records
            ScheduleRecordKey recordKey = new ScheduleRecordKey(currentRequest.HandleId, currentRequest.RequestId);
            ScheduleRecordKey parentKey = new ScheduleRecordKey(currentRequest.ParentHandleId, currentRequest.ParentRequestId);
            ScheduleRecord    record    = new ScheduleRecord(recordKey, parentKey, nodeUsed, currentRequest.ProjectFileName,
                                                             currentRequest.ToolsetVersion, currentRequest.TargetNames);

            lock (scheduleTableLock)
            {
                ErrorUtilities.VerifyThrow(!handleIdToScheduleRecord.ContainsKey(recordKey),
                                           "Schedule record should not be in the table");

                handleIdToScheduleRecord.Add(recordKey, record);

                // The ParentHandleId is an invalidEngineHandle when the host is the one who created
                // the current request
                if (currentRequest.ParentHandleId != EngineCallback.invalidEngineHandle)
                {
                    ErrorUtilities.VerifyThrow(handleIdToScheduleRecord.ContainsKey(parentKey),
                                               "Parent schedule record should be in the table");
                    ScheduleRecord parentRecord = handleIdToScheduleRecord[parentKey];
                    if (!parentRecord.Blocked)
                    {
                        blockedRequestsPerNode[parentRecord.EvaluationNode]++;
                    }
                    parentRecord.AddChildRecord(record);
                }
            }
        }