/// <summary> /// This method will only be internally called by session launcher, /// before the job is submitted. It combines the user's job properties and the /// items set in the service start info. The job properties will override the start info items. /// </summary> /// <param name="startInfo">the session start info</param> /// <param name="schedulerJob">service job</param> /// <param name="traceLevel">diag trace level</param> internal static void MakeJobProperties(SessionStartInfoContract startInfo, ISchedulerJob schedulerJob, string traceLevel) { Debug.Assert(startInfo != null, "The session startInfo cannot be null."); Debug.Assert(!string.IsNullOrEmpty(startInfo.ServiceName), "The service name in the session start info cannnot be null or empty."); schedulerJob.ServiceName = startInfo.ServiceName; schedulerJob.SetEnvironmentVariable("CCP_SERVICENAME", startInfo.ServiceName); if (startInfo.CanPreempt.HasValue) { schedulerJob.CanPreempt = startInfo.CanPreempt.Value; } if (!string.IsNullOrEmpty(startInfo.JobTemplate)) { schedulerJob.SetJobTemplate(startInfo.JobTemplate); } if (startInfo.Priority.HasValue) { schedulerJob.Priority = (JobPriority)startInfo.Priority.Value; } if (startInfo.ExtendedPriority.HasValue) { schedulerJob.ExpandedPriority = startInfo.ExtendedPriority.Value; } schedulerJob.Progress = 0; // For max units if (startInfo.MaxUnits != null) { schedulerJob.MaximumNumberOfCores = schedulerJob.MaximumNumberOfSockets = schedulerJob.MaximumNumberOfNodes = startInfo.MaxUnits.Value; schedulerJob.AutoCalculateMax = false; } // For min units if (startInfo.MinUnits != null) { schedulerJob.MinimumNumberOfCores = schedulerJob.MinimumNumberOfSockets = schedulerJob.MinimumNumberOfNodes = startInfo.MinUnits.Value; schedulerJob.AutoCalculateMin = false; } // Should set UnitType after above resource count update if (startInfo.ResourceUnitType != null) { schedulerJob.UnitType = (JobUnitType)startInfo.ResourceUnitType.Value; } schedulerJob.Name = string.IsNullOrEmpty(startInfo.ServiceJobName) ? string.Format("{0} - WCF service", startInfo.ServiceName) : startInfo.ServiceJobName; if (!string.IsNullOrEmpty(startInfo.ServiceJobProject)) { schedulerJob.Project = startInfo.ServiceJobProject; } if (!string.IsNullOrEmpty(startInfo.NodeGroupsStr)) { string[] nodes = startInfo.NodeGroupsStr.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string node in nodes) { schedulerJob.NodeGroups.Add(node); } } if (!string.IsNullOrEmpty(startInfo.RequestedNodesStr)) { schedulerJob.RequestedNodes = new StringCollection(startInfo.RequestedNodesStr.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)); } if (startInfo.Runtime >= 0) { schedulerJob.Runtime = startInfo.Runtime; } // start adding the broker settings. schedulerJob.SetCustomProperty(BrokerSettingsConstants.ShareSession, startInfo.ShareSession.ToString()); schedulerJob.SetCustomProperty(BrokerSettingsConstants.UseAad, startInfo.UseAad.ToString()); schedulerJob.SetCustomProperty(BrokerSettingsConstants.Secure, startInfo.Secure.ToString()); schedulerJob.SetCustomProperty(BrokerSettingsConstants.TransportScheme, ((int)startInfo.TransportScheme).ToString()); schedulerJob.SetCustomProperty(BrokerSettingsConstants.UseAzureQueue, (startInfo.UseAzureQueue == true).ToString()); schedulerJob.SetCustomProperty(BrokerSettingsConstants.LocalUser, (startInfo.LocalUser == true).ToString()); var context = HpcContext.Get(); var principal = Thread.CurrentPrincipal; if (principal.IsHpcAadPrincipal(context)) { string identity = principal.GenerateSecurityIdentifierFromAadPrincipal(context).Value + ";" + principal.Identity.Name; schedulerJob.SetCustomProperty(BrokerSettingsConstants.AadUserIdentity, identity); } // Save ServiceVersion if set if (startInfo.ServiceVersion != null) { schedulerJob.SetCustomProperty(BrokerSettingsConstants.ServiceVersion, startInfo.ServiceVersion.ToString()); } string[] customPropNames = new string[] { BrokerSettingsConstants.AllocationGrowLoadRatioThreshold, BrokerSettingsConstants.AllocationShrinkLoadRatioThreshold, BrokerSettingsConstants.ClientIdleTimeout, BrokerSettingsConstants.SessionIdleTimeout, BrokerSettingsConstants.MessagesThrottleStartThreshold, BrokerSettingsConstants.MessagesThrottleStopThreshold, BrokerSettingsConstants.ClientConnectionTimeout, BrokerSettingsConstants.ServiceConfigMaxMessageSize, BrokerSettingsConstants.ServiceConfigOperationTimeout, BrokerSettingsConstants.DispatcherCapacityInGrowShrink }; int?[] intNullableValues = new int?[] { startInfo.AllocationGrowLoadRatioThreshold, startInfo.AllocationShrinkLoadRatioThreshold, startInfo.ClientIdleTimeout, startInfo.SessionIdleTimeout, startInfo.MessagesThrottleStartThreshold, startInfo.MessagesThrottleStopThreshold, startInfo.ClientConnectionTimeout, startInfo.MaxMessageSize, startInfo.ServiceOperationTimeout, startInfo.DispatcherCapacityInGrowShrink }; Debug.Assert(intNullableValues.Length == customPropNames.Length); for (int i = 0; i < customPropNames.Length; i++) { if (intNullableValues[i].HasValue) { schedulerJob.SetCustomProperty(customPropNames[i], intNullableValues[i].Value.ToString()); } } // add soa diag settings schedulerJob.SetCustomProperty(BrokerSettingsConstants.SoaDiagTraceLevel, traceLevel); schedulerJob.SetCustomProperty(BrokerSettingsConstants.SoaDiagTraceCleanup, Boolean.FalseString); }