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)); }
/// <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(); } }
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); }
/// <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); }
public void SetNodeAffinity(string projectFile, NodeAffinity nodeAffinity) { if (projectFile == null) { throw new ArgumentNullException("projectFile"); } node_affinities [projectFile] = nodeAffinity; }
/// <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, });
/// <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); }
/// <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; } }
/// <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; }
public void SetNodeAffinity(string projectFile, NodeAffinity nodeAffinity) { throw new NotImplementedException(); }
/// <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); }
public BuildNode(BuildNodeManager manager, NodeAffinity affinity) { Manager = manager; Affinity = affinity; Id = rnd.Next(); }
/// <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); }
/// <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; }
public IList <NodeInfo> CreateNodes(NodeConfiguration configuration, NodeAffinity affinity, int numberOfNodesToCreate) => throw new NotSupportedException("not used");
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)); }
public void SetNodeAffinity (string projectFile, NodeAffinity nodeAffinity) { if (projectFile == null) throw new ArgumentNullException ("projectFile"); node_affinities [projectFile] = nodeAffinity; }
/// <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; }
/// <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)); }
/// <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"); }
/// <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"); }
public void SetNodeAffinity (string projectFile, NodeAffinity nodeAffinity) { throw new NotImplementedException (); }
/// <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); }
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; }
/// <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(); } }
public BuildNode (BuildNodeManager manager, NodeAffinity affinity) { Manager = manager; Affinity = affinity; Id = rnd.Next (); }