Пример #1
0
        public NodeInfo CreateNode(NodeConfiguration configuration, NodeAffinity nodeAffinity)
        {
            // We will prefer to make nodes on the "closest" providers first; in-proc, then
            // out-of-proc, then remote.
            // When we support distributed build, we will also consider the remote provider.
            int nodeId = InvalidNodeId;

            if ((nodeAffinity == NodeAffinity.Any || nodeAffinity == NodeAffinity.InProc) && !_componentHost.BuildParameters.DisableInProcNode)
            {
                nodeId = AttemptCreateNode(_inProcNodeProvider, configuration);
            }

            if (nodeId == InvalidNodeId && (nodeAffinity == NodeAffinity.Any || nodeAffinity == NodeAffinity.OutOfProc))
            {
                nodeId = AttemptCreateNode(_outOfProcNodeProvider, configuration);
            }

            if (nodeId == InvalidNodeId)
            {
                return(null);
            }

            // If we created a node, they should no longer be considered shut down.
            _nodesShutdown = false;

            return(new NodeInfo(nodeId, _nodeIdToProvider[nodeId].ProviderType));
        }
Пример #2
0
        /// <summary>
        /// Retrieves the node affinity for a particular project file.
        /// </summary>
        private NodeAffinity GetNodeAffinity(string projectFile, out bool isExplicit)
        {
            isExplicit = false;

            // Projects with a registered host object must build in-proc
            if (HasInProcessHostObject(projectFile))
            {
                return(NodeAffinity.InProc);
            }

            // Now see if a specific affinity has been provided.
            if (_projectAffinities != null)
            {
                NodeAffinity affinity = NodeAffinity.Any;

                if (_projectAffinities.TryGetValue(projectFile, out affinity))
                {
                    isExplicit = true;
                    return(affinity);
                }

                if (_projectAffinities.TryGetValue(String.Empty, out affinity))
                {
                    return(affinity);
                }
            }

            // Attempts to find a specific affinity failed, so just go with Any.
            return(NodeAffinity.Any);
        }
 /// <summary>
 /// Validate the object.
 /// </summary>
 /// <exception cref="Microsoft.Rest.ValidationException">
 /// Thrown if validation fails
 /// </exception>
 public virtual void Validate()
 {
     if (NodeAffinity != null)
     {
         NodeAffinity.Validate();
     }
 }
Пример #4
0
        BuildNode GetReusableNode(NodeAffinity affinity)
        {
            if (!BuildManager.OngoingBuildParameters.EnableNodeReuse)
            {
                return(null);
            }

            if (affinity != NodeAffinity.OutOfProc)
            {
                foreach (var n in in_proc_nodes)
                {
                    if (n.IsAvailable && (n.Affinity & affinity) != 0)
                    {
                        return(n);
                    }
                }
            }
            if (affinity != NodeAffinity.InProc)
            {
                foreach (var n in out_proc_nodes)
                {
                    if (n.IsAvailable && (n.Affinity & affinity) != 0)
                    {
                        return(n);
                    }
                }
            }
            return(null);
        }
Пример #5
0
        /// <summary>
        /// Creates a node on an available NodeProvider, if any..
        /// </summary>
        /// <param name="configuration">The configuration to use for the remote node.</param>
        /// <param name="nodeAffinity">The <see cref="NodeAffinity"/> to use.</param>
        /// <param name="numberOfNodesToCreate">Number of nodes to be reused ot created.</param>
        /// <returns>A NodeInfo describing the node created, or null if none could be created.</returns>
        public IList <NodeInfo> CreateNodes(NodeConfiguration configuration, NodeAffinity nodeAffinity, int numberOfNodesToCreate)
        {
            // We will prefer to make nodes on the "closest" providers first; in-proc, then
            // out-of-proc, then remote.
            // When we support distributed build, we will also consider the remote provider.
            List <NodeInfo> nodes = new(numberOfNodesToCreate);

            if ((nodeAffinity == NodeAffinity.Any || nodeAffinity == NodeAffinity.InProc) && !_componentHost !.BuildParameters.DisableInProcNode)
            {
                nodes.AddRange(AttemptCreateNode(_inProcNodeProvider !, configuration, numberOfNodesToCreate));
            }

            if (nodes.Count < numberOfNodesToCreate && (nodeAffinity == NodeAffinity.Any || nodeAffinity == NodeAffinity.OutOfProc))
            {
                nodes.AddRange(AttemptCreateNode(_outOfProcNodeProvider !, configuration, numberOfNodesToCreate - nodes.Count));
            }

            // If we created a node, they should no longer be considered shut down.
            if (nodes.Count > 0)
            {
                _nodesShutdown = false;
            }

            return(nodes);
        }
Пример #6
0
 public void SetNodeAffinity(string projectFile, NodeAffinity nodeAffinity)
 {
     if (projectFile == null)
     {
         throw new ArgumentNullException("projectFile");
     }
     node_affinities [projectFile] = nodeAffinity;
 }
Пример #7
0
 /// <summary>
 /// Returns true if this node can service requests with the specified affinity.
 /// </summary>
 internal bool CanServiceRequestWithAffinity(NodeAffinity nodeAffinity)
 {
     return(nodeAffinity switch
     {
         NodeAffinity.Any => true,
         NodeAffinity.InProc => _providerType == NodeProviderType.InProc,
         NodeAffinity.OutOfProc => _providerType != NodeProviderType.InProc,
         _ => true,
     });
Пример #8
0
        /// <summary>
        /// Returns true if this node can service requests with the specified affinity.
        /// </summary>
        internal bool CanServiceRequestWithAffinity(NodeAffinity nodeAffinity)
        {
            switch (nodeAffinity)
            {
            case NodeAffinity.Any:
                return(true);

            case NodeAffinity.InProc:
                return(_providerType == NodeProviderType.InProc);

            case NodeAffinity.OutOfProc:
                return(_providerType != NodeProviderType.InProc);
            }

            return(true);
        }
Пример #9
0
        /// <summary>
        /// Sets the node affinity for a particular project file.
        /// </summary>
        /// <param name="projectFile">
        /// The project file.  If set to String.Empty, all projects will use the specified affinity.  If set to null, all affinities will be cleared.
        /// </param>
        /// <param name="nodeAffinity">The <see cref="NodeAffinity"/> to set.</param>
        public void SetNodeAffinity(string projectFile, NodeAffinity nodeAffinity)
        {
            if (projectFile == null)
            {
                _projectAffinities = null;
            }
            else
            {
                if (HasInProcessHostObject(projectFile))
                {
                    ErrorUtilities.VerifyThrowInvalidOperation(nodeAffinity == NodeAffinity.InProc, "InvalidAffinityForProjectWithHostObject");
                }

                if (_projectAffinities == null)
                {
                    _projectAffinities = new Dictionary <string, NodeAffinity>(StringComparer.OrdinalIgnoreCase);
                }

                _projectAffinities[projectFile] = nodeAffinity;
            }
        }
Пример #10
0
        /// <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;
        }
Пример #11
0
 public void SetNodeAffinity(string projectFile, NodeAffinity nodeAffinity)
 {
     throw new NotImplementedException();
 }
Пример #12
0
        /// <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);
        }
Пример #13
0
 public BuildNode(BuildNodeManager manager, NodeAffinity affinity)
 {
     Manager  = manager;
     Affinity = affinity;
     Id       = rnd.Next();
 }
Пример #14
0
        /// <summary>
        /// Creates a node on an available NodeProvider, if any..
        /// </summary>
        /// <param name="configuration">The configuration to use for the remote node.</param>
        /// <returns>A NodeInfo describing the node created, or null if none could be created.</returns>
        public NodeInfo CreateNode(NodeConfiguration configuration, NodeAffinity nodeAffinity)
        {
            // We will prefer to make nodes on the "closest" providers first; in-proc, then
            // out-of-proc, then remote.
            // When we support distributed build, we will also consider the remote provider.
            int nodeId = InvalidNodeId;
            if ((nodeAffinity == NodeAffinity.Any || nodeAffinity == NodeAffinity.InProc) && !_componentHost.BuildParameters.DisableInProcNode)
            {
                nodeId = AttemptCreateNode(_inProcNodeProvider, configuration);
            }

            if (nodeId == InvalidNodeId && (nodeAffinity == NodeAffinity.Any || nodeAffinity == NodeAffinity.OutOfProc))
            {
                nodeId = AttemptCreateNode(_outOfProcNodeProvider, configuration);
            }

            if (nodeId == InvalidNodeId)
            {
                return null;
            }

            // If we created a node, they should no longer be considered shut down.
            _nodesShutdown = false;

            return new NodeInfo(nodeId, _nodeIdToProvider[nodeId].ProviderType);
        }
Пример #15
0
 /// <summary>
 /// Constructs a response indicating what type of node we need to create.
 /// </summary>
 private ScheduleResponse(NodeAffinity affinity, int count)
 {
     Action = ScheduleActionType.CreateNode;
     RequiredNodeType = affinity;
     NumberOfNodesToCreate = count;
 }
Пример #16
0
 public IList <NodeInfo> CreateNodes(NodeConfiguration configuration, NodeAffinity affinity, int numberOfNodesToCreate)
 => throw new NotSupportedException("not used");
Пример #17
0
        private BuildRequest CreateBuildRequest(int nodeRequestId, int configId, string[] targets, NodeAffinity nodeAffinity, BuildRequest parentRequest, ProxyTargets proxyTargets = null)
        {
            (targets == null ^ proxyTargets == null).ShouldBeTrue();

            HostServices hostServices = null;

            if (nodeAffinity != NodeAffinity.Any)
            {
                hostServices = new HostServices();
                hostServices.SetNodeAffinity(String.Empty, nodeAffinity);
            }

            if (targets != null)
            {
                return(new BuildRequest(
                           submissionId: 1,
                           nodeRequestId,
                           configId,
                           targets,
                           hostServices,
                           BuildEventContext.Invalid,
                           parentRequest));
            }

            parentRequest.ShouldBeNull();
            return(new BuildRequest(
                       submissionId: 1,
                       nodeRequestId,
                       configId,
                       proxyTargets,
                       hostServices));
        }
Пример #18
0
		public void SetNodeAffinity (string projectFile, NodeAffinity nodeAffinity)
		{
			if (projectFile == null)
				throw new ArgumentNullException ("projectFile");
			node_affinities [projectFile] = nodeAffinity;
		}
Пример #19
0
        /// <summary>
        /// Returns true if this node can service requests with the specified affinity.
        /// </summary>
        internal bool CanServiceRequestWithAffinity(NodeAffinity nodeAffinity)
        {
            switch (nodeAffinity)
            {
                case NodeAffinity.Any:
                    return true;

                case NodeAffinity.InProc:
                    return _providerType == NodeProviderType.InProc;

                case NodeAffinity.OutOfProc:
                    return _providerType != NodeProviderType.InProc;
            }

            return true;
        }
Пример #20
0
 /// <summary>
 /// Create a CreateNode response
 /// </summary>
 /// <param name="typeOfNodeToCreate">The type of node to create.</param>
 /// <param name="count">The number of new nodes of that particular affinity to create.</param>
 /// <returns>The ScheduleResponse.</returns>
 public static ScheduleResponse CreateNewNodeResponse(NodeAffinity typeOfNodeToCreate, int count)
 {
     return(new ScheduleResponse(typeOfNodeToCreate, count));
 }
Пример #21
0
 /// <summary>
 /// Constructs a response indicating what type of node we need to create.
 /// </summary>
 private ScheduleResponse(NodeAffinity affinity, int count)
 {
     Action                = ScheduleActionType.CreateNode;
     RequiredNodeType      = affinity;
     NumberOfNodesToCreate = count;
 }
Пример #22
0
 /// <summary>
 /// Creates a node on an available NodeProvider, if any..
 /// </summary>
 /// <param name="configuration">The configuration to use for the remote node.</param>
 /// <returns>A NodeInfo describing the node created, or null if none could be created.</returns>
 public NodeInfo CreateNode(NodeConfiguration configuration, NodeAffinity nodeAffinity)
 {
     throw new NotSupportedException("not used");
 }
Пример #23
0
 /// <summary>
 /// Creates a node on an available NodeProvider, if any..
 /// </summary>
 /// <param name="configuration">The configuration to use for the remote node.</param>
 /// <param name="nodeAffinity">The <see cref="NodeAffinity"/> to use.</param>
 /// <returns>A NodeInfo describing the node created, or null if none could be created.</returns>
 public NodeInfo CreateNode(NodeConfiguration configuration, NodeAffinity nodeAffinity)
 {
     throw new NotSupportedException("not used");
 }
Пример #24
0
 public void SetNodeAffinity (string projectFile, NodeAffinity nodeAffinity)
 {
         throw new NotImplementedException ();
 }
Пример #25
0
 /// <summary>
 /// Create a CreateNode response
 /// </summary>
 /// <param name="typeOfNodeToCreate">The type of node to create.</param>
 /// <param name="count">The number of new nodes of that particular affinity to create.</param>
 /// <returns>The ScheduleResponse.</returns>
 public static ScheduleResponse CreateNewNodeResponse(NodeAffinity typeOfNodeToCreate, int count)
 {
     return new ScheduleResponse(typeOfNodeToCreate, count);
 }
Пример #26
0
		BuildNode GetReusableNode (NodeAffinity affinity)
		{
			if (!BuildManager.OngoingBuildParameters.EnableNodeReuse)
				return null;
			
			if (affinity != NodeAffinity.OutOfProc)
				foreach (var n in in_proc_nodes)
					if (n.IsAvailable && (n.Affinity & affinity) != 0)
						return n;
			if (affinity != NodeAffinity.InProc)
				foreach (var n in out_proc_nodes)
					if (n.IsAvailable && (n.Affinity & affinity) != 0)
						return n;
			return null;
		}
Пример #27
0
 /// <summary>
 /// Validate the object.
 /// </summary>
 /// <exception cref="Microsoft.Rest.ValidationException">
 /// Thrown if validation fails
 /// </exception>
 public virtual void Validate()
 {
     if (AwsElasticBlockStore != null)
     {
         AwsElasticBlockStore.Validate();
     }
     if (AzureDisk != null)
     {
         AzureDisk.Validate();
     }
     if (AzureFile != null)
     {
         AzureFile.Validate();
     }
     if (Cephfs != null)
     {
         Cephfs.Validate();
     }
     if (Cinder != null)
     {
         Cinder.Validate();
     }
     if (Csi != null)
     {
         Csi.Validate();
     }
     if (FlexVolume != null)
     {
         FlexVolume.Validate();
     }
     if (GcePersistentDisk != null)
     {
         GcePersistentDisk.Validate();
     }
     if (Glusterfs != null)
     {
         Glusterfs.Validate();
     }
     if (HostPath != null)
     {
         HostPath.Validate();
     }
     if (Iscsi != null)
     {
         Iscsi.Validate();
     }
     if (Local != null)
     {
         Local.Validate();
     }
     if (Nfs != null)
     {
         Nfs.Validate();
     }
     if (NodeAffinity != null)
     {
         NodeAffinity.Validate();
     }
     if (PhotonPersistentDisk != null)
     {
         PhotonPersistentDisk.Validate();
     }
     if (PortworxVolume != null)
     {
         PortworxVolume.Validate();
     }
     if (Quobyte != null)
     {
         Quobyte.Validate();
     }
     if (Rbd != null)
     {
         Rbd.Validate();
     }
     if (ScaleIO != null)
     {
         ScaleIO.Validate();
     }
     if (VsphereVolume != null)
     {
         VsphereVolume.Validate();
     }
 }
Пример #28
0
			public BuildNode (BuildNodeManager manager, NodeAffinity affinity)
			{
				Manager = manager;
				Affinity = affinity;
				Id = rnd.Next ();
			}