Example #1
0
        /// <summary>
        /// This method lets the engine provide node with results of an evaluation it was waiting on.
        /// </summary>
        internal void PostBuildResult(BuildResult buildResult)
        {
            ErrorUtilities.VerifyThrow(localEngine != null, "Local engine should be initialized");

            // Figure out the local handle id
            NodeRequestMapping nodeRequestMapping = null;

            try
            {
                lock (requestToLocalIdMapping)
                {
                    nodeRequestMapping = (NodeRequestMapping)requestToLocalIdMapping[buildResult.RequestId];
                    requestToLocalIdMapping.Remove(buildResult.RequestId);
                }

                if (Engine.debugMode)
                {
                    Console.WriteLine(nodeId + ": Got result for Request Id " + buildResult.RequestId);
                    Console.WriteLine(nodeId + ": Received result for HandleId " + buildResult.HandleId + ":" + buildResult.RequestId + " mapped to " + nodeRequestMapping.HandleId + ":" + nodeRequestMapping.RequestId);
                }

                buildResult.HandleId  = nodeRequestMapping.HandleId;
                buildResult.RequestId = nodeRequestMapping.RequestId;
                nodeRequestMapping.AddResultToCache(buildResult);

                // posts the result to the inproc node
                localEngine.Router.PostDoneNotice(0, buildResult);
            }
            catch (Exception ex)
            {
                ReportUnhandledError(ex);
            }
        }
 public void AddResultToCacheUncacheableResult()
 {
     Assert.IsNull(cacheScope.GetCacheEntry("TaskItems"), "Cache should not have an entry");
     NodeRequestMapping requestMapping = new NodeRequestMapping(1, 1, cacheScope);
     Assert.AreEqual(1, requestMapping.HandleId, "Expected NodeProxyId to be 1");
     Assert.AreEqual(1, requestMapping.RequestId, "Expected RequestId to be 1");
     requestMapping.AddResultToCache(uncacheableResult);
     Assert.IsNull(cacheScope.GetCacheEntry("TaskItems"), 
         "Expected null to be retrieved from the cache as the targetNamesList should not have been added");
 }
 public void AddResultToCache()
 {
     Assert.IsNull(cacheScope.GetCacheEntry("TaskItems"), "Cache should not have an entry");
     NodeRequestMapping requestMapping = new NodeRequestMapping(1, 1, cacheScope);
     Assert.AreEqual(1,requestMapping.HandleId,"Expected NodeProxyId to be 1");
     Assert.AreEqual(1,requestMapping.RequestId,"Expected RequestId to be 1");
     requestMapping.AddResultToCache(resultWithOutputs);
     Assert.IsTrue(resultWithOutputs.EvaluationResult == ((BuildResultCacheEntry)cacheScope.GetCacheEntry("TaskItems")).BuildResult, 
         "Expected EvaluationResult to be the same after it was retrieved from the cache");
     Assert.IsTrue(((BuildItem[])resultWithOutputs.OutputsByTarget["TaskItems"])[0].Include == ((BuildResultCacheEntry)cacheScope.GetCacheEntry("TaskItems")).BuildItems[0].Include,
         "Expected EvaluationResult to be the same after it was retrieved from the cache");
     // Remove the entry from the cache
     cacheScope.ClearCacheEntry("TaskItems");
 }
Example #4
0
        internal void PostBuildRequestToHost(BuildRequest currentRequest)
        {
            // Since this request is going back to the host the local node should not have a project object for it
            ErrorUtilities.VerifyThrow(currentRequest.ProjectToBuild == null, "Should not have a project object");
            // Add the request to the mapping hashtable so that we can recognize the outputs
            CacheScope         cacheScope         = localEngine.CacheManager.GetCacheScope(currentRequest.ProjectFileName, currentRequest.GlobalProperties, currentRequest.ToolsetVersion, CacheContentType.BuildResults);
            NodeRequestMapping nodeRequestMapping =
                new NodeRequestMapping(currentRequest.HandleId, currentRequest.RequestId, cacheScope);

            lock (requestToLocalIdMapping)
            {
                requestToLocalIdMapping.Add(lastRequestIdUsed, nodeRequestMapping);
                // Keep the request id local for this node
                currentRequest.RequestId = lastRequestIdUsed;
                lastRequestIdUsed++;
            }

            // Find the original external request that caused us to run this task
            TaskExecutionContext taskExecutionContext = localEngine.EngineCallback.GetTaskContextFromHandleId(currentRequest.HandleId);

            while (!taskExecutionContext.BuildContext.BuildRequest.IsExternalRequest)
            {
                ErrorUtilities.VerifyThrow(taskExecutionContext.BuildContext.BuildRequest.IsGeneratedRequest,
                                           "Must be a generated request");

                taskExecutionContext =
                    localEngine.EngineCallback.GetTaskContextFromHandleId(taskExecutionContext.BuildContext.BuildRequest.HandleId);
            }

            //Modify the request with the data that is expected by the parent engine
            currentRequest.HandleId  = taskExecutionContext.BuildContext.BuildRequest.HandleId;
            currentRequest.NodeIndex = taskExecutionContext.BuildContext.BuildRequest.NodeIndex;

            try
            {
                outProcLoggingService.ProcessPostedLoggingEvents();
                parentCallback.PostBuildRequestsToHost(new BuildRequest[] { currentRequest });
            }
            catch (Exception e)
            {
                ReportUnhandledError(e);
            }
        }
Example #5
0
        internal void PostBuildRequestToHost(BuildRequest currentRequest)
        {
            // Since this request is going back to the host the local node should not have a project object for it
            ErrorUtilities.VerifyThrow(currentRequest.ProjectToBuild == null, "Should not have a project object");
            // Add the request to the mapping hashtable so that we can recognize the outputs
            CacheScope cacheScope = localEngine.CacheManager.GetCacheScope(currentRequest.ProjectFileName, currentRequest.GlobalProperties, currentRequest.ToolsetVersion, CacheContentType.BuildResults);
            NodeRequestMapping nodeRequestMapping =
                new NodeRequestMapping(currentRequest.HandleId, currentRequest.RequestId, cacheScope );
            lock (requestToLocalIdMapping)
            {
                requestToLocalIdMapping.Add(lastRequestIdUsed, nodeRequestMapping);
                // Keep the request id local for this node
                currentRequest.RequestId = lastRequestIdUsed;
                lastRequestIdUsed++;
            }

            // Find the original external request that caused us to run this task
            TaskExecutionContext taskExecutionContext = localEngine.EngineCallback.GetTaskContextFromHandleId(currentRequest.HandleId);
            while (!taskExecutionContext.BuildContext.BuildRequest.IsExternalRequest)
            {
                ErrorUtilities.VerifyThrow(taskExecutionContext.BuildContext.BuildRequest.IsGeneratedRequest, 
                                           "Must be a generated request");

                taskExecutionContext =
                   localEngine.EngineCallback.GetTaskContextFromHandleId(taskExecutionContext.BuildContext.BuildRequest.HandleId);
            }

            //Modify the request with the data that is expected by the parent engine
            currentRequest.HandleId = taskExecutionContext.BuildContext.BuildRequest.HandleId;
            currentRequest.NodeIndex = taskExecutionContext.BuildContext.BuildRequest.NodeIndex;

            try
            {
                outProcLoggingService.ProcessPostedLoggingEvents();
                parentCallback.PostBuildRequestsToHost(new BuildRequest[] { currentRequest });
            }
            catch (Exception e)
            {
                ReportUnhandledError(e);
            }
        }
 public void AddResultToCacheFailedResult()
 {
     Assert.IsNull(cacheScope.GetCacheEntry("TaskItems"), "Cache should not have an entry");
     NodeRequestMapping requestMapping = new NodeRequestMapping(1, 1, cacheScope);
     Assert.AreEqual(1, requestMapping.HandleId, "Expected NodeProxyId to be 1");
     Assert.AreEqual(1, requestMapping.RequestId, "Expected RequestId to be 1");
     requestMapping.AddResultToCache(failedResult);
     Assert.IsTrue(failedResult.EvaluationResult == ((BuildResultCacheEntry)cacheScope.GetCacheEntry("TaskItems")).BuildResult,
         "Expected EvaluationResult to be the same after it was retrieved from the cache");
     Assert.IsNull(((BuildResultCacheEntry)cacheScope.GetCacheEntry("TaskItems")).BuildItems,
         "Task items should not be cached for failed build results");
     // Remove the entry from the cache
     cacheScope.ClearCacheEntry("TaskItems");
 }