Exemple #1
0
        /// <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, "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.
 /// </summary>
 public SchedulerCircularDependencyException(BuildRequest request, IList <SchedulableRequest> ancestors)
 {
     _request   = request;
     _ancestors = ancestors;
 }
Exemple #3
0
 /// <summary>
 /// Constructor over a request.
 /// </summary>
 public BlockingRequestKey(BuildRequest request)
 {
     _globalRequestId = request.GlobalRequestId;
     _nodeRequestId   = request.NodeRequestId;
 }
Exemple #4
0
 /// <summary>
 /// Constructor for the unblocker for circular dependencies
 /// </summary>
 internal BuildRequestUnblocker(BuildRequest parentRequest, BuildResult buildResult)
     : this(buildResult)
 {
     ErrorUtilities.VerifyThrowArgumentNull(parentRequest, nameof(parentRequest));
     _blockedGlobalRequestId = parentRequest.GlobalRequestId;
 }
Exemple #5
0
 /// <summary>
 /// Handles the BuildRequest packet.
 /// </summary>
 private void HandleBuildRequest(BuildRequest request)
 {
     _buildRequestEngine.SubmitBuildRequest(request);
 }
Exemple #6
0
 /// <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));
 }
Exemple #7
0
 /// <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));
 }
Exemple #8
0
 /// <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;
 }
Exemple #9
0
        /// <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);
        }