/// <summary> /// Set up /// </summary> public Scheduler_Tests() { // Since we're creating our own BuildManager, we need to make sure that the default // one has properly relinquished the inproc node NodeProviderInProc nodeProviderInProc = ((IBuildComponentHost)BuildManager.DefaultBuildManager).GetComponent(BuildComponentType.InProcNodeProvider) as NodeProviderInProc; if (nodeProviderInProc != null) { nodeProviderInProc.Dispose(); } _host = new MockHost(); _scheduler = new Scheduler(); _scheduler.InitializeComponent(_host); CreateConfiguration(99, "parent.proj"); _defaultParentRequest = CreateBuildRequest(99, 99, new string[] { }, null); // Set up the scheduler with one node to start with. _scheduler.ReportNodesCreated(new NodeInfo[] { new NodeInfo(1, NodeProviderType.InProc) }); _scheduler.ReportRequestBlocked(1, new BuildRequestBlocker(-1, new string[] { }, new BuildRequest[] { _defaultParentRequest })); _logger = new MockLogger(); _parameters = new BuildParameters(); _parameters.Loggers = new ILogger[] { _logger }; _parameters.ShutdownInProcNodeOnBuildFinish = true; _buildManager = new BuildManager(); }
public void SetUp() { LoggingServiceFactory loggingFactory = new LoggingServiceFactory(LoggerMode.Synchronous, 1); _loggingService = loggingFactory.CreateInstance(BuildComponentType.LoggingService) as LoggingService; _customLogger = new MyCustomLogger(); _mockHost = new MockHost(); _mockHost.LoggingService = _loggingService; _loggingService.RegisterLogger(_customLogger); _elementLocation = ElementLocation.Create("MockFile", 5, 5); BuildRequest buildRequest = new BuildRequest(1 /* submissionId */, 1, 1, new List<string>(), null, BuildEventContext.Invalid, null); BuildRequestConfiguration configuration = new BuildRequestConfiguration(1, new BuildRequestData("Nothing", new Dictionary<string, string>(), "4.0", new string[0], null), "2.0"); configuration.Project = new ProjectInstance(ProjectRootElement.Create()); BuildRequestEntry entry = new BuildRequestEntry(buildRequest, configuration); BuildResult buildResult = new BuildResult(buildRequest, false); buildResult.AddResultsForTarget("Build", new TargetResult(new TaskItem[] { new TaskItem("IamSuper", configuration.ProjectFullPath) }, TestUtilities.GetSkippedResult())); _mockRequestCallback = new MockIRequestBuilderCallback(new BuildResult[] { buildResult }); entry.Builder = (IRequestBuilder)_mockRequestCallback; _taskHost = new TaskHost(_mockHost, entry, _elementLocation, null /*Dont care about the callback either unless doing a build*/); _taskHost.LoggingContext = new TaskLoggingContext(_loggingService, BuildEventContext.Invalid); }
public void TestMissingResults() { ResultsCache cache = new ResultsCache(); BuildRequest request = new BuildRequest(1 /* submissionId */, 0, 1, new string[1] { "testTarget" }, null, BuildEventContext.Invalid, null); BuildResult retrievedResult = cache.GetResultForRequest(request); Assert.Null(retrievedResult); }
public void TestAddAndRetrieveResults() { ResultsCache cache = new ResultsCache(); BuildRequest request = new BuildRequest(1 /* submissionId */, 0, 1, new string[1] { "testTarget" }, null, BuildEventContext.Invalid, null); BuildResult result = new BuildResult(request); result.AddResultsForTarget("testTarget", TestUtilities.GetEmptyFailingTargetResult()); cache.AddResult(result); BuildResult retrievedResult = cache.GetResultForRequest(request); Assert.True(AreResultsIdentical(result, retrievedResult)); }
public void TestAddAndRetrieveResultsByConfiguration() { ResultsCache cache = new ResultsCache(); BuildRequest request = new BuildRequest(1 /* submissionId */, 0, 1, new string[1] { "testTarget" }, null, BuildEventContext.Invalid, null); BuildResult result = new BuildResult(request); result.AddResultsForTarget("testTarget", TestUtilities.GetEmptyFailingTargetResult()); cache.AddResult(result); request = new BuildRequest(1 /* submissionId */, 0, 1, new string[1] { "otherTarget" }, null, BuildEventContext.Invalid, null); result = new BuildResult(request); result.AddResultsForTarget("otherTarget", TestUtilities.GetEmptySucceedingTargetResult()); cache.AddResult(result); BuildResult retrievedResult = cache.GetResultsForConfiguration(1); Assert.True(retrievedResult.HasResultsForTarget("testTarget")); Assert.True(retrievedResult.HasResultsForTarget("otherTarget")); }
/// <summary> /// Constructor. /// </summary> public SchedulableRequest(SchedulingData collection, BuildRequest request, SchedulableRequest parent) { ErrorUtilities.VerifyThrowArgumentNull(collection, nameof(collection)); ErrorUtilities.VerifyThrowArgumentNull(request, nameof(request)); ErrorUtilities.VerifyThrow((parent == null) || (parent._schedulingData == collection), "Parent request does not belong to the same collection."); _schedulingData = collection; _request = request; _parent = parent; _assignedNodeId = -1; _requestsWeAreBlockedBy = new Dictionary <BlockingRequestKey, SchedulableRequest>(); _requestsWeAreBlocking = new HashSet <SchedulableRequest>(); _timeRecords = new Dictionary <SchedulableRequestState, ScheduleTimeRecord>(5); _timeRecords[SchedulableRequestState.Unscheduled] = new ScheduleTimeRecord(); _timeRecords[SchedulableRequestState.Blocked] = new ScheduleTimeRecord(); _timeRecords[SchedulableRequestState.Yielding] = new ScheduleTimeRecord(); _timeRecords[SchedulableRequestState.Executing] = new ScheduleTimeRecord(); _timeRecords[SchedulableRequestState.Ready] = new ScheduleTimeRecord(); _timeRecords[SchedulableRequestState.Completed] = new ScheduleTimeRecord(); ChangeToState(SchedulableRequestState.Unscheduled); }
/// <summary> /// Initializes a build request with a parent context. /// </summary> /// <param name="submissionId">The id of the build submission.</param> /// <param name="nodeRequestId">The id of the node issuing the request</param> /// <param name="configurationId">The configuration id to use.</param> /// <param name="escapedTargets">The targets to be built</param> /// <param name="hostServices">Host services if any. May be null.</param> /// <param name="parentBuildEventContext">The build event context of the parent project.</param> /// <param name="parentRequest">The parent build request, if any.</param> /// <param name="skipStaticGraphIsolationConstraints"></param> /// <param name="buildRequestDataFlags">Additional flags for the request.</param> /// <param name="requestedProjectState">Filter for desired build results.</param> public BuildRequest( int submissionId, int nodeRequestId, int configurationId, ICollection <string> escapedTargets, HostServices hostServices, BuildEventContext parentBuildEventContext, BuildRequest parentRequest, BuildRequestDataFlags buildRequestDataFlags = BuildRequestDataFlags.None, RequestedProjectState requestedProjectState = null, bool skipStaticGraphIsolationConstraints = false) { ErrorUtilities.VerifyThrowArgumentNull(escapedTargets, "targets"); ErrorUtilities.VerifyThrowArgumentNull(parentBuildEventContext, nameof(parentBuildEventContext)); _submissionId = submissionId; _configurationId = configurationId; // When targets come into a build request, we unescape them. _targets = new List <string>(escapedTargets.Count); foreach (string target in escapedTargets) { _targets.Add(EscapingUtilities.UnescapeAll(target)); } HostServices = hostServices; _buildEventContext = BuildEventContext.Invalid; _parentBuildEventContext = parentBuildEventContext; _globalRequestId = InvalidGlobalRequestId; _parentGlobalRequestId = parentRequest?.GlobalRequestId ?? InvalidGlobalRequestId; _nodeRequestId = nodeRequestId; _buildRequestDataFlags = buildRequestDataFlags; _requestedProjectState = requestedProjectState; _skipStaticGraphIsolationConstraints = skipStaticGraphIsolationConstraints; }
/// <summary> /// Constructor over a request. /// </summary> public BlockingRequestKey(BuildRequest request) { _globalRequestId = request.GlobalRequestId; _nodeRequestId = request.NodeRequestId; }
public bool IsProxyBuildRequest() => BuildRequest.IsProxyBuildRequest();
/// <summary> /// Creates a build request entry from a build request. /// </summary> /// <param name="request">The originating build request.</param> /// <param name="requestConfiguration">The build request configuration.</param> internal BuildRequestEntry(BuildRequest request, BuildRequestConfiguration requestConfiguration) { ErrorUtilities.VerifyThrowArgumentNull(request, "request"); ErrorUtilities.VerifyThrowArgumentNull(requestConfiguration, "requestConfiguration"); ErrorUtilities.VerifyThrow(requestConfiguration.ConfigurationId == request.ConfigurationId, "Configuration id mismatch"); _dataMonitor = new Object(); _request = request; _requestConfiguration = requestConfiguration; _blockingGlobalRequestId = BuildRequest.InvalidGlobalRequestId; _completedResult = null; ChangeState(BuildRequestEntryState.Ready); }
/// <summary> /// Adds a request to the set of waiting requests. /// </summary> private void WaitForResult(BuildRequest newRequest, bool addToIssueList) { lock (_dataMonitor) { ErrorUtilities.VerifyThrow(_state == BuildRequestEntryState.Active || _state == BuildRequestEntryState.Waiting, "Must be in Active or Waiting state to wait for results. Config: {0} State: {1}", _requestConfiguration.ConfigurationId, _state); if (newRequest.IsConfigurationResolved) { _outstandingRequests = _outstandingRequests ?? new Dictionary<int, BuildRequest>(); ErrorUtilities.VerifyThrow(!_outstandingRequests.ContainsKey(newRequest.NodeRequestId), "Already waiting for local request {0}", newRequest.NodeRequestId); _outstandingRequests.Add(newRequest.NodeRequestId, newRequest); } else { ErrorUtilities.VerifyThrow(addToIssueList == true, "Requests with unresolved configurations should always be added to the issue list."); _unresolvedConfigurations = _unresolvedConfigurations ?? new Dictionary<int, List<BuildRequest>>(); if (!_unresolvedConfigurations.ContainsKey(newRequest.ConfigurationId)) { _unresolvedConfigurations.Add(newRequest.ConfigurationId, new List<BuildRequest>()); } _unresolvedConfigurations[newRequest.ConfigurationId].Add(newRequest); } if (addToIssueList) { _requestsToIssue = _requestsToIssue ?? new List<BuildRequest>(); _requestsToIssue.Add(newRequest); } ChangeState(BuildRequestEntryState.Waiting); } }
public void TestRetrieveSubsetTargetsFromResult() { ResultsCache cache = new ResultsCache(); BuildRequest request = new BuildRequest(1 /* submissionId */, 0, 1, new string[1] { "testTarget2" }, null, BuildEventContext.Invalid, null); BuildResult result = new BuildResult(request); result.AddResultsForTarget("testTarget", TestUtilities.GetEmptyFailingTargetResult()); result.AddResultsForTarget("testTarget2", TestUtilities.GetEmptySucceedingTargetResult()); cache.AddResult(result); ResultsCacheResponse response = cache.SatisfyRequest(request, new List<string>(), new List<string>(new string[] { "testTarget2" }), new List<string>(new string[] { "testTarget" }), skippedResultsAreOK: false); Assert.Equal(ResultsCacheResponseType.Satisfied, response.Type); Assert.True(AreResultsIdenticalForTarget(result, response.Results, "testTarget2")); Assert.False(response.Results.HasResultsForTarget("testTarget")); Assert.Equal(BuildResultCode.Failure, response.Results.OverallResult); }
/// <summary> /// Creates a Schedule or ScheduleWithConfiguration response /// </summary> /// <param name="node">The node to which the response should be sent.</param> /// <param name="requestToSchedule">The request to be scheduled.</param> /// <param name="sendConfiguration">Flag indicating whether or not the configuration for the request must be sent to the node as well.</param> /// <returns>The ScheduleResponse.</returns> public static ScheduleResponse CreateScheduleResponse(int node, BuildRequest requestToSchedule, bool sendConfiguration) { return new ScheduleResponse(node, requestToSchedule, sendConfiguration); }
/// <summary> /// Creates a build result for a request /// </summary> private BuildResult CreateBuildResult(BuildRequest request, string target, WorkUnitResult workUnitResult) { BuildResult result = new BuildResult(request); result.AddResultsForTarget(target, new TargetResult(new TaskItem[] { }, workUnitResult)); return result; }
public void VerifyRequestOrderingDoesNotAffectNodeCreationCountWithInProcAndAnyRequests() { // Since we're creating our own BuildManager, we need to make sure that the default // one has properly relinquished the inproc node NodeProviderInProc nodeProviderInProc = ((IBuildComponentHost)BuildManager.DefaultBuildManager).GetComponent(BuildComponentType.InProcNodeProvider) as NodeProviderInProc; if (nodeProviderInProc != null) { nodeProviderInProc.Dispose(); } _host = new MockHost(); _host.BuildParameters.MaxNodeCount = 3; _scheduler = new Scheduler(); _scheduler.InitializeComponent(_host); _logger = new MockLogger(); _parameters = new BuildParameters(); _parameters.Loggers = new ILogger[] { _logger }; _parameters.ShutdownInProcNodeOnBuildFinish = true; _buildManager = new BuildManager(); CreateConfiguration(99, "parent.proj"); _defaultParentRequest = CreateBuildRequest(99, 99, new string[] { }, null); CreateConfiguration(1, "foo.proj"); BuildRequest request1 = CreateBuildRequest(1, 1, new string[] { "foo" }, NodeAffinity.Any, _defaultParentRequest); BuildRequest request2 = CreateBuildRequest(2, 1, new string[] { "bar" }, NodeAffinity.InProc, _defaultParentRequest); BuildRequest request3 = CreateBuildRequest(3, 1, new string[] { "bar" }, NodeAffinity.InProc, _defaultParentRequest); List<ScheduleResponse> response = new List<ScheduleResponse>(_scheduler.ReportRequestBlocked(1, new BuildRequestBlocker(-1, new string[] { }, new BuildRequest[] { _defaultParentRequest, request1, request2, request3 }))); Assert.Equal(1, response.Count); Assert.Equal(ScheduleActionType.CreateNode, response[0].Action); Assert.Equal(NodeAffinity.InProc, response[0].RequiredNodeType); Assert.Equal(1, response[0].NumberOfNodesToCreate); List<NodeInfo> nodeInfos = new List<NodeInfo>(new NodeInfo[] { new NodeInfo(1, NodeProviderType.InProc) }); List<ScheduleResponse> moreResponses = new List<ScheduleResponse>(_scheduler.ReportNodesCreated(nodeInfos)); Assert.Equal(2, moreResponses.Count); Assert.Equal(ScheduleActionType.ScheduleWithConfiguration, moreResponses[0].Action); Assert.Equal(ScheduleActionType.CreateNode, moreResponses[1].Action); Assert.Equal(NodeAffinity.OutOfProc, moreResponses[1].RequiredNodeType); Assert.Equal(1, moreResponses[1].NumberOfNodesToCreate); }
/// <summary> /// Constructor. /// </summary> public SchedulerCircularDependencyException(BuildRequest request, IList <SchedulableRequest> ancestors) { _request = request; _ancestors = ancestors; }
/// <summary> /// Creates a Schedule or ScheduleWithConfiguration response /// </summary> /// <param name="node">The node to which the response should be sent.</param> /// <param name="requestToSchedule">The request to be scheduled.</param> /// <param name="sendConfiguration">Flag indicating whether or not the configuration for the request must be sent to the node as well.</param> /// <returns>The ScheduleResponse.</returns> public static ScheduleResponse CreateScheduleResponse(int node, BuildRequest requestToSchedule, bool sendConfiguration) { return(new ScheduleResponse(node, requestToSchedule, sendConfiguration)); }
/// <summary> /// Handles the BuildRequest packet. /// </summary> private void HandleBuildRequest(BuildRequest request) { _buildRequestEngine.SubmitBuildRequest(request); }
public void TestMergeResultsWithException() { ResultsCache cache = new ResultsCache(); BuildRequest request = new BuildRequest(1 /* submissionId */, 0, 1, new string[] { "testTarget" }, null, BuildEventContext.Invalid, null); BuildResult result = new BuildResult(request); result.AddResultsForTarget("testTarget", TestUtilities.GetEmptyFailingTargetResult()); cache.AddResult(result); BuildResult result2 = new BuildResult(request, new Exception("Test exception")); cache.AddResult(result2); BuildResult retrievedResult = cache.GetResultForRequest(request); Assert.NotNull(retrievedResult.Exception); }
/// <summary> /// Creates a CircularDependency response. /// </summary> /// <param name="node">The node to which the response should be sent.</param> /// <param name="parentRequest">The request which attempted to invoke the request causing the circular dependency.</param> /// <param name="requestCausingCircularDependency">The request which caused the circular dependency.</param> /// <returns>The ScheduleResponse.</returns> public static ScheduleResponse CreateCircularDependencyResponse(int node, BuildRequest parentRequest, BuildRequest requestCausingCircularDependency) { return(new ScheduleResponse(node, parentRequest, requestCausingCircularDependency)); }
/// <summary> /// Constructs a response where a request should be scheduled. /// </summary> /// <param name="node">The node ID to which the request should be sent.</param> /// <param name="request">The request to send.</param> /// <param name="sendConfiguration"><code>true</code> to send the configuration, otherwise <code>false</code>.</param> private ScheduleResponse(int node, BuildRequest request, bool sendConfiguration) { Action = sendConfiguration ? ScheduleActionType.ScheduleWithConfiguration : ScheduleActionType.Schedule; NodeId = node; BuildRequest = request; }
/// <summary> /// Creates a build request. /// </summary> private BuildRequest CreateBuildRequest(int nodeRequestId, int configId, string[] targets, NodeAffinity nodeAffinity, BuildRequest parentRequest) { HostServices hostServices = null; if (nodeAffinity != NodeAffinity.Any) { hostServices = new HostServices(); hostServices.SetNodeAffinity(String.Empty, nodeAffinity); } BuildRequest request = new BuildRequest(1 /* submissionId */, nodeRequestId, configId, targets, hostServices, BuildEventContext.Invalid, parentRequest); return request; }
/// <summary> /// Constructs a response indicating there is a circular dependency caused by the specified request. /// </summary> private ScheduleResponse(int nodeId, BuildRequest parentRequest, BuildRequest requestCausingCircularDependency) { Action = ScheduleActionType.CircularDependency; BuildRequest = requestCausingCircularDependency; NodeId = nodeId; Unblocker = new BuildRequestUnblocker(parentRequest, new BuildResult(requestCausingCircularDependency, true /* circularDependency */)); }
public void VerifyNoOverCreationOfNodesWithBuildLoop() { // Since we're creating our own BuildManager, we need to make sure that the default // one has properly relinquished the inproc node NodeProviderInProc nodeProviderInProc = ((IBuildComponentHost)BuildManager.DefaultBuildManager).GetComponent(BuildComponentType.InProcNodeProvider) as NodeProviderInProc; if (nodeProviderInProc != null) { nodeProviderInProc.Dispose(); } _host = new MockHost(); _host.BuildParameters.MaxNodeCount = 3; _scheduler = new Scheduler(); _scheduler.InitializeComponent(_host); _parameters = new BuildParameters(); _parameters.ShutdownInProcNodeOnBuildFinish = true; _buildManager = new BuildManager(); CreateConfiguration(99, "parent.proj"); _defaultParentRequest = CreateBuildRequest(99, 99, new string[] { }, null); CreateConfiguration(1, "foo.proj"); BuildRequest request1 = CreateBuildRequest(1, 1, new string[] { "foo" }, NodeAffinity.OutOfProc, _defaultParentRequest); CreateConfiguration(2, "foo2.proj"); BuildRequest request2 = CreateBuildRequest(2, 2, new string[] { "bar" }, NodeAffinity.OutOfProc, _defaultParentRequest); CreateConfiguration(3, "foo3.proj"); BuildRequest request3 = CreateBuildRequest(3, 3, new string[] { "bar" }, NodeAffinity.InProc, _defaultParentRequest); List<ScheduleResponse> responses = new List<ScheduleResponse>(_scheduler.ReportRequestBlocked(1, new BuildRequestBlocker(-1, new string[] { }, new BuildRequest[] { _defaultParentRequest, request1, request2, request3 }))); int nextNodeId = 1; bool inProcNodeExists = false; MockPerformSchedulingActions(responses, ref nextNodeId, ref inProcNodeExists); Assert.Equal(4, nextNodeId); // 3 nodes }
public void TestClearResultsCache() { ResultsCache cache = new ResultsCache(); cache.ClearResults(); BuildRequest request = new BuildRequest(1 /* submissionId */, 0, 1, new string[1] { "testTarget2" }, null, BuildEventContext.Invalid, null); BuildResult result = new BuildResult(request); result.AddResultsForTarget("testTarget", TestUtilities.GetEmptyFailingTargetResult()); cache.AddResult(result); cache.ClearResults(); Assert.Null(cache.GetResultForRequest(request)); }
/// <summary> /// Creates and caches a built result. /// </summary> private BuildResult CacheBuildResult(BuildRequest request, string target, WorkUnitResult workUnitResult) { BuildResult result = CreateBuildResult(request, target, workUnitResult); IResultsCache resultsCache = _host.GetComponent(BuildComponentType.ResultsCache) as IResultsCache; resultsCache.AddResult(result); return result; }
/// <summary> /// A new build request for this definition is submitted. This call is in the ProcessorThread of the TestDataProvider /// </summary> public void RaiseOnNewBuildRequest(BuildRequest request) { this.Build(request); }
/// <summary> /// Creates a build request. /// </summary> private BuildRequest CreateBuildRequest(int nodeRequestId, int configId, string[] targets, BuildRequest parentRequest) { return CreateBuildRequest(nodeRequestId, configId, targets, NodeAffinity.Any, parentRequest); }
/// <summary> /// Request for this definition is completed. This call is in the ProcessorThread of the TestDataProvider /// </summary> public void RaiseOnBuildRequestCompleted(BuildRequest request, BuildResult result) { if (!result.ResultBelongsToRootRequest) { // Don't report root requests to the request engine, as it doesn't wait on them. _requestEngine.UnblockBuildRequest(new BuildRequestUnblocker(result)); } _buildResult = result; _testProjectCompletedEvent.Set(); }
/// <summary> /// Waits for a result from a request. /// </summary> /// <param name="newRequest">The build request</param> public void WaitForResult(BuildRequest newRequest) { WaitForResult(newRequest, true); }
/// <summary> /// Cache the configuration for this build definition and then submit the build request to the request engine. If the request being submitted does not have /// a GlobalRequestId than assign one. /// Since we want to make all requests rooted - it the passed in request is null then we will use the dummy root request and make that the parent. This is usually /// the case when tests submit build requets. When a request is submitted by the RequestBuilder the request is always populated and likely rooted. /// </summary> public void Build(BuildRequest request) { if (request == null) { _configuration = _testDataProvider.CreateConfiguration(this); _buildRequest = new BuildRequest(1 /* submissionId */, 1, _configuration.ConfigurationId, _targetsToBuild, null, BuildEventContext.Invalid, null); _buildRequest.GlobalRequestId = RequestDefinition.s_globalRequestId++; } else { _buildRequest = request; // Assign a new Global Request id if one is not already there bool assignNewId = false; if (_buildRequest.GlobalRequestId == BuildRequest.InvalidGlobalRequestId) { foreach (KeyValuePair<int, RequestDefinition> idRequestPair in _testDataProvider.RequestDefinitions) { if ( idRequestPair.Value._buildRequest != null && idRequestPair.Value._buildRequest.ConfigurationId == _buildRequest.ConfigurationId && idRequestPair.Value._buildRequest.Targets.Count == _buildRequest.Targets.Count ) { List<string> leftTargets = new List<string>(idRequestPair.Value._buildRequest.Targets); List<string> rightTargets = new List<string>(_buildRequest.Targets); leftTargets.Sort(StringComparer.OrdinalIgnoreCase); rightTargets.Sort(StringComparer.OrdinalIgnoreCase); for (int i = 0; i < leftTargets.Count; i++) { if (!leftTargets[i].Equals(rightTargets[i], StringComparison.OrdinalIgnoreCase)) { assignNewId = true; break; } } if (!assignNewId) { _buildRequest.GlobalRequestId = idRequestPair.Value._buildRequest.GlobalRequestId; break; } } } } if (assignNewId) { _buildRequest.GlobalRequestId = RequestDefinition.s_globalRequestId++; } } _requestEngine.SubmitBuildRequest(_buildRequest); }
/// <summary> /// Constructs a response where a request should be scheduled. /// </summary> /// <param name="node">The node ID to which the request should be sent.</param> /// <param name="request">The request to send.</param> private ScheduleResponse(int node, BuildRequest request, bool sendConfiguration) { Action = sendConfiguration ? ScheduleActionType.ScheduleWithConfiguration : ScheduleActionType.Schedule; NodeId = node; BuildRequest = request; }
/// <summary> /// Constructor. This is the only way of setting the data members. /// </summary> public ResultFromEngine(BuildRequest request, BuildResult result) { this.request = request; this.result = result; }
/// <summary> /// Creates a CircularDependency response. /// </summary> /// <param name="node">The node to which the response should be sent.</param> /// <param name="parentRequest">The request which attempted to invoke the request causing the circular dependency.</param> /// <param name="requestCausingCircularDependency">The request which caused the circular dependency.</param> /// <returns>The ScheduleResponse.</returns> public static ScheduleResponse CreateCircularDependencyResponse(int node, BuildRequest parentRequest, BuildRequest requestCausingCircularDependency) { return new ScheduleResponse(node, parentRequest, requestCausingCircularDependency); }
/// <summary> /// Initializes a build request with a parent context. /// </summary> /// <param name="submissionId">The id of the build submission.</param> /// <param name="nodeRequestId">The id of the node issuing the request</param> /// <param name="configurationId">The configuration id to use.</param> /// <param name="escapedTargets">The targets to be built</param> /// <param name="hostServices">Host services if any. May be null.</param> /// <param name="parentBuildEventContext">The build event context of the parent project.</param> /// <param name="parentRequest">The parent build request, if any.</param> /// <param name="buildRequestDataFlags">Additional flags for the request.</param> public BuildRequest( int submissionId, int nodeRequestId, int configurationId, ICollection<string> escapedTargets, HostServices hostServices, BuildEventContext parentBuildEventContext, BuildRequest parentRequest, BuildRequestDataFlags buildRequestDataFlags = BuildRequestDataFlags.None) { ErrorUtilities.VerifyThrowArgumentNull(escapedTargets, "targets"); ErrorUtilities.VerifyThrowArgumentNull(parentBuildEventContext, "parentBuildEventContext"); _submissionId = submissionId; _configurationId = configurationId; // When targets come into a build request, we unescape them. _targets = new List<string>(escapedTargets.Count); foreach (string target in escapedTargets) { _targets.Add(EscapingUtilities.UnescapeAll(target)); } _hostServices = hostServices; _buildEventContext = BuildEventContext.Invalid; _parentBuildEventContext = parentBuildEventContext; _globalRequestId = InvalidGlobalRequestId; if (null != parentRequest) { _parentGlobalRequestId = parentRequest.GlobalRequestId; } else { _parentGlobalRequestId = InvalidGlobalRequestId; } _nodeRequestId = nodeRequestId; _buildRequestDataFlags = buildRequestDataFlags; }
/// <summary> /// Call the actual implementation /// </summary> /// <param name="request">The request for which results should be retrieved.</param> /// <returns>The build results for the specified request.</returns> public BuildResult GetResultForRequest(BuildRequest request) { _getCount++; return _resultCache.GetResultForRequest(request); }
/// <summary> /// Constructor. /// </summary> public SchedulableRequest(SchedulingData collection, BuildRequest request, SchedulableRequest parent) { ErrorUtilities.VerifyThrowArgumentNull(collection, "collection"); ErrorUtilities.VerifyThrowArgumentNull(request, "request"); ErrorUtilities.VerifyThrow((parent == null) || (parent._schedulingData == collection), "Parent request does not belong to the same collection."); _schedulingData = collection; _request = request; _parent = parent; _assignedNodeId = -1; _requestsWeAreBlockedBy = new Dictionary<BlockingRequestKey, SchedulableRequest>(); _requestsWeAreBlocking = new HashSet<SchedulableRequest>(); _timeRecords = new Dictionary<SchedulableRequestState, ScheduleTimeRecord>(5); _timeRecords[SchedulableRequestState.Unscheduled] = new ScheduleTimeRecord(); _timeRecords[SchedulableRequestState.Blocked] = new ScheduleTimeRecord(); _timeRecords[SchedulableRequestState.Yielding] = new ScheduleTimeRecord(); _timeRecords[SchedulableRequestState.Executing] = new ScheduleTimeRecord(); _timeRecords[SchedulableRequestState.Ready] = new ScheduleTimeRecord(); _timeRecords[SchedulableRequestState.Completed] = new ScheduleTimeRecord(); ChangeToState(SchedulableRequestState.Unscheduled); }
/// <summary> /// Call the actual implementation. /// </summary> public ResultsCacheResponse SatisfyRequest(BuildRequest request, List<string> configInitialTargets, List<string> configDefaultTargets, List<string> additionalTargetsToCheckForOverallResult, bool skippedResultsAreOK) { return _resultCache.SatisfyRequest(request, configInitialTargets, configDefaultTargets, additionalTargetsToCheckForOverallResult, skippedResultsAreOK); }
internal BuildRequestUnblocker(BuildRequest parentRequest, BuildResult buildResult) : this(buildResult) { ErrorUtilities.VerifyThrowArgumentNull(parentRequest, nameof(parentRequest)); _blockedGlobalRequestId = parentRequest.GlobalRequestId; }
/// <summary> /// Attempts to satisfy the request from the cache. The request can be satisfied only if: /// 1. All specified targets in the request have successful results in the cache or if the sequence of target results /// includes 0 or more successful targets followed by at least one failed target. /// 2. All initial targets in the configuration for the request have non-skipped results in the cache. /// 3. If there are no specified targets, then all default targets in the request must have non-skipped results /// in the cache. /// </summary> /// <param name="request">The request whose results we should return</param> /// <param name="configInitialTargets">The initial targets for the request's configuration.</param> /// <param name="configDefaultTargets">The default targets for the request's configuration.</param> /// <param name="skippedResultsDoNotCauseCacheMiss">If false, a cached skipped target will cause this method to return "NotSatisfied". /// If true, then as long as there is a result in the cache (regardless of whether it was skipped or not), this method /// will return "Satisfied". In most cases this should be false, but it may be set to true in a situation where there is no /// chance of re-execution (which is the usual response to missing / skipped targets), and the caller just needs the data.</param> /// <returns>A response indicating the results, if any, and the targets needing to be built, if any.</returns> public ResultsCacheResponse SatisfyRequest(BuildRequest request, List <string> configInitialTargets, List <string> configDefaultTargets, bool skippedResultsDoNotCauseCacheMiss) { ErrorUtilities.VerifyThrowArgument(request.IsConfigurationResolved, "UnresolvedConfigurationInRequest"); ResultsCacheResponse response = new ResultsCacheResponse(ResultsCacheResponseType.NotSatisfied); lock (_resultsByConfiguration) { if (_resultsByConfiguration.ContainsKey(request.ConfigurationId)) { BuildResult allResults = _resultsByConfiguration[request.ConfigurationId]; // Check for targets explicitly specified. bool explicitTargetsSatisfied = CheckResults(allResults, request.Targets, response.ExplicitTargetsToBuild, skippedResultsDoNotCauseCacheMiss); if (explicitTargetsSatisfied) { // All of the explicit targets, if any, have been satisfied response.Type = ResultsCacheResponseType.Satisfied; // Check for the initial targets. If we don't know what the initial targets are, we assume they are not satisfied. if (configInitialTargets == null || !CheckResults(allResults, configInitialTargets, null, skippedResultsDoNotCauseCacheMiss)) { response.Type = ResultsCacheResponseType.NotSatisfied; } // We could still be missing implicit targets, so check those... if (request.Targets.Count == 0) { // Check for the default target, if necessary. If we don't know what the default targets are, we // assume they are not satisfied. if (configDefaultTargets == null || !CheckResults(allResults, configDefaultTargets, null, skippedResultsDoNotCauseCacheMiss)) { response.Type = ResultsCacheResponseType.NotSatisfied; } } // Now report those results requested, if they are satisfied. if (response.Type == ResultsCacheResponseType.Satisfied) { List <string> targetsToAddResultsFor = new List <string>(configInitialTargets); // Now report either the explicit targets or the default targets if (request.Targets.Count > 0) { targetsToAddResultsFor.AddRange(request.Targets); } else { targetsToAddResultsFor.AddRange(configDefaultTargets); } response.Results = new BuildResult(request, allResults, targetsToAddResultsFor.ToArray(), null); } } else { // Some targets were not satisfied. response.Type = ResultsCacheResponseType.NotSatisfied; } } } return(response); }