/// <summary> /// Initializes a new instance of the HpcSchedulerAdapterInternalClient class /// </summary> /// <param name="headNodeMachine">indicating the headnode</param> public HpcSchedulerAdapterInternalClient(string headNodeMachine, string certThumbprint) : base( BindingHelper.HardCodedInternalSchedulerDelegationBinding, SoaHelper.CreateInternalCertEndpointAddress(new Uri(SoaHelper.GetSchedulerDelegationInternalAddress(headNodeMachine)), certThumbprint)) { #if BrokerLauncher BrokerTracing.TraceVerbose("[HpcSchedulerAdapterInternalClient] In constructor"); #endif // use certificate for cluster internal authentication this.ClientCredentials.UseInternalAuthentication(certThumbprint); if (BrokerIdentity.IsHAMode) { // Bug 10301 : Explicitly open channel when impersonating the resource group's account if running on failover cluster so identity flows correctly when // calling HpcSession. // NOTE: The patch we got from the WCF team (KB981001) only works when the caller is on a threadpool thread. // NOTE: Channel must be opened before setting OperationTimeout using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); this.Open(); } } this.InnerChannel.OperationTimeout = OperationTimeout; }
/// <summary> /// Initializes a new instance of the HpcSchedulerAdapterClient class /// </summary> /// <param name="headnode">indicating the headnode</param> /// <param name="instanceContext">indicating the instance context</param> public HpcSchedulerAdapterClient(string headnode, string certThrumbprint, InstanceContext instanceContext) : base( instanceContext, BindingHelper.HardCodedInternalSchedulerDelegationBinding, SoaHelper.CreateInternalCertEndpointAddress(new Uri(SoaHelper.GetSchedulerDelegationAddress(headnode)), certThrumbprint)) { BrokerTracing.TraceVerbose("[HpcSchedulerAdapterClient] In constructor"); this.ClientCredentials.UseInternalAuthentication(certThrumbprint); if (BrokerIdentity.IsHAMode) { // Bug 10301 : Explicitly open channel when impersonating the resource group's account if running on failover cluster so identity flows correctly when // calling HpcSession. // NOTE: The patch we got from the WCF team (KB981001) only works when the caller is on a threadpool thread. // NOTE: Channel must be opened before setting OperationTimeout using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); this.Open(); } } this.InnerChannel.OperationTimeout = SchedulerAdapterTimeout; foreach (OperationDescription op in this.Endpoint.Contract.Operations) { DataContractSerializerOperationBehavior dataContractBehavior = op.Behaviors.Find <DataContractSerializerOperationBehavior>() as DataContractSerializerOperationBehavior; if (dataContractBehavior != null) { dataContractBehavior.MaxItemsInObjectGraph = int.MaxValue; } } }
/// <summary> /// Gets SOA configurations /// </summary> /// <param name="keys">indicating the keys</param> /// <returns>returns the values</returns> public async Task <Dictionary <string, string> > GetSOAConfigurations(List <string> keys) { RetryManager retry = SoaHelper.GetDefaultExponentialRetryManager(); return(await RetryHelper <Dictionary <string, string> > .InvokeOperationAsync( async() => { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); return await this.sessionLauncherClient.Value.GetSOAConfigurationsAsync(keys); } }, async (e, r) => { TraceHelper.TraceEvent( TraceEventType.Warning, "[SchedulerHelper] Failed to get SOA configuration, Key:{0}, Retry:{1}, Error:{2}", string.Join(",", keys), r.RetryCount, e); await this.RenewSessionLauncherClientAsync(); }, retry)); }
/// <summary> /// Get the graceful preemption info. /// </summary> /// <param name="jobId">the job id</param> /// <returns>tuple of if the method succeeded, the number of plannedCoreCount and the taskIds.</returns> public async Task <(bool succeed, BalanceInfo balanceInfo, List <int> taskIds, List <int> runningTaskIds)> GetGracefulPreemptionInfo(int jobId) { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); return(await this.Channel.GetGracefulPreemptionInfo(jobId)); } }
/// <summary> /// Get the error code property of the specified task. /// </summary> /// <param name="jobId">job id</param> /// <param name="globalTaskId">unique task id</param> /// <returns>return error code value if it exists, otherwise return null</returns> public async Task <int?> GetTaskErrorCode(int jobId, int globalTaskId) { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); return(await this.Channel.GetTaskErrorCode(jobId, globalTaskId)); } }
/// <summary> /// Add a node to job's exclude node list /// </summary> /// <param name="jobid">the job id</param> /// <param name="nodeName">name of the node to be excluded</param> /// <returns>true if the node is successfully blacklisted, or the job is failed. false otherwise</returns> public async Task <bool> ExcludeNode(int jobid, string nodeName) { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); return(await this.Channel.ExcludeNode(jobid, nodeName)); } }
/// <summary> /// Requeue or fail a service job with the reason /// </summary> /// <param name="jobid">the job id</param> /// <param name="reason">the reason string</param> public async Task RequeueOrFailJob(int jobid, string reason) { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); await this.Channel.RequeueOrFailJob(jobid, reason); } }
/// <summary> /// Create the sessionstartinfo from job properties. /// </summary> /// <param name="jobid">job id</param> /// <returns>the sessionstart info</returns> public async Task <BrokerRecoverInfo> GetRecoverInfoFromJob(int jobid) { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); return(await base.Channel.GetRecoverInfoFromJob(jobid)); } }
/// <summary> /// Update the job's properties /// </summary> /// <param name="jobid">the job id</param> /// <param name="properties">the properties table</param> public async Task <bool> UpdateBrokerInfo(int jobid, Dictionary <string, object> properties) { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); return(await this.Channel.UpdateBrokerInfo(jobid, properties)); } }
/// <summary> /// Get the task's allocated node name. /// </summary> /// <param name="jobId">job id</param> /// <param name="taskId">task id</param> /// <returns>list of the node name and location flag (on premise or not)</returns> public async Task <List <Tuple <string, bool> > > GetTaskAllocatedNodeName(int jobId, int taskId) { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); return(await base.Channel.GetTaskAllocatedNodeName(jobId, taskId)); } }
/// <summary> /// Fail a service job with the reason /// </summary> /// <param name="jobid">the job id</param> /// <param name="reason">the reason string</param> public async Task FailJob(int jobid, string reason) { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); await base.Channel.FailJob(jobid, reason); } }
/// <summary> /// Dump the event log onto a target file /// </summary> /// <param name="targetFolder">indicating the target folder to put the dumped file</param> /// <param name="logName">indicating the log name</param> /// <returns>returns the dumped file name</returns> public async Task <string> DumpEventLog(string targetFolder, string logName) { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); return(await base.Channel.DumpEventLog(targetFolder, logName)); } }
/// <summary> /// Get specified job's customized properties. /// </summary> /// <param name="propNames">customized property names</param> /// <returns>customized properties</returns> public async Task <Dictionary <string, string> > GetJobCustomizedProperties(int jobid, string[] propNames) { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); return(await base.Channel.GetJobCustomizedProperties(jobid, propNames)); } }
/// <summary> /// Check if the job id is valid /// </summary> /// <param name="jobid">jobid</param> /// <returns>true if the job id is valid</returns> public async Task <bool> IsValidJob(int jobid) { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); return(await base.Channel.IsValidJob(jobid)); } }
/// <summary> /// Get the broker node name list. /// </summary> /// <returns>name list</returns> public async Task <List <string> > GetBrokerNodeName() { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); return(await base.Channel.GetBrokerNodeName()); } }
/// <summary> /// Get specified job requeue count /// </summary> /// <param name="jobid">job id</param> /// <returns>requeue count</returns> public async Task <int> GetJobRequeueCount(int jobid) { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); return(await base.Channel.GetJobRequeueCount(jobid)); } }
/// <summary> /// Set job's progress message. /// </summary> /// <param name="jobid">job id</param> /// <param name="message">progress message</param> public async Task SetJobProgressMessage(int jobid, string message) { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); await base.Channel.SetJobProgressMessage(jobid, message); } }
/// <summary> /// Get all the exist session id list /// </summary> /// <returns>session id list</returns> public async Task <List <int> > GetAllSessionId() { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); return(await base.Channel.GetAllSessionId()); } }
/// <summary> /// Get all the non terminated session id and requeue count. /// </summary> /// <returns> /// dictionary /// key: session Id /// value: requeue count /// </returns> public async Task <Dictionary <int, int> > GetNonTerminatedSession() { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); return(await base.Channel.GetNonTerminatedSession()); } }
/// <summary> /// Get all the running and queued service jobs whose broker node is machinename. /// </summary> /// <param name="machineName">Node Name</param> /// <returns>sessionid, sessionstart info table</returns> public async Task <BrokerRecoverInfo[]> GetRecoverInfoFromJobs(string machineName) { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); return(await base.Channel.GetRecoverInfoFromJobs(machineName)); } }
/// <summary> /// Get ACL string from a job template /// </summary> /// <param name="jobTemplate">the job template name</param> /// <returns>ACL string</returns> public async Task <string> GetJobTemlpateACL(string jobTemplate) { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); return(await base.Channel.GetJobTemlpateACL(jobTemplate)); } }
/// <summary> /// Get the job's owner SID /// </summary> /// <param name="jobid"></param> /// <returns></returns> public async Task <string> GetJobOwnerSID(int jobid) { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); return(await base.Channel.GetJobOwnerSID(jobid)); } }
/// <summary> /// Check if the soa diag trace enabled for the specified session. /// </summary> /// <param name="jobid">job id of the session</param> /// <returns>soa diag trace is enabled or disabled </returns> public bool IsDiagTraceEnabled(int jobid) { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); return(base.Channel.IsDiagTraceEnabled(jobid)); } }
/// <summary> /// Get the session's broker node name. /// </summary> /// <param name="jobid">job id of the session</param> /// <returns>broker node name</returns> public async Task <string> GetSessionBrokerNodeName(int jobid) { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); return(await base.Channel.GetSessionBrokerNodeName(jobid)); } }
/// <summary> /// Finish a task. /// </summary> /// <param name="jobid">the job id</param> /// <param name="taskUniqueId">the task unique id</param> /// <returns>true if the method succeeded.</returns> public Task <bool> FinishTask(int jobid, int taskUniqueId) { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); return(this.Channel.FinishTask(jobid, taskUniqueId)); } }
/// <summary> /// Async Pattern /// Begin method for ProcessMessage /// </summary> /// <param name="request">request message</param> /// <param name="callback">async callback</param> /// <param name="asyncState">async state</param> /// <returns>async result</returns> public IAsyncResult BeginProcessMessage(System.ServiceModel.Channels.Message request, AsyncCallback callback, object asyncState) { // Impersonate the broker's identity. If this is a non-failover BN, BrokerIdentity.Impersonate // does nothing and the computer account is used. If this is a failover BN, Impersonate will use // resource group's network name using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); return(this.Channel.BeginProcessMessage(request, callback, asyncState)); } }
/// <summary> /// Update the job's properties /// </summary> /// <param name="jobid">the job id</param> /// <param name="properties">the properties table</param> public async Task <bool> UpdateBrokerInfo(int jobid, Dictionary <string, object> properties) { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); return(await base.Channel.UpdateBrokerInfo(jobid, properties)); // Call async version and block on completion in order to workaround System.Net.Socket bug #750028 // IAsyncResult result = base.Channel.BeginUpdateBrokerInfo(jobid, properties, null, null); // return base.Channel.EndUpdateBrokerInfo(result); } }
/// <summary> /// Start to subscribe the job and task event /// </summary> /// <param name="jobid">indicating the job id</param> /// <returns>tuple of jobstate, automax, automin of the job</returns> public async Task <Tuple <JobState, int, int> > RegisterJob(int jobid) { using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); return(await this.Channel.RegisterJob(jobid)); // Call async version and block on completion in order to workaround System.Net.Socket bug #750028 //IAsyncResult result = base.Channel.BeginRegisterJob(jobid, null, null); //return base.Channel.EndRegisterJob(out autoMax, out autoMin, result); } }
/// <summary> /// Send exit command to service host async /// </summary> /// <remarks> /// When this method is called by Azure broker proxy, impersonation is not needed. /// </remarks> public IAsyncResult BeginExit(AsyncCallback callback, object state) { #if Broker using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); #endif return(this.Channel.BeginExit(callback, state)); #if Broker } #endif }
public Message ProcessMessage(Message request) { // Impersonate the broker's identity. If this is a non-failover BN, BrokerIdentity.Impersonate // does nothing and the computer account is used. If this is a failover BN, Impersonate will use // resource group's network name using (BrokerIdentity identity = new BrokerIdentity()) { identity.Impersonate(); // Call async version and block on completion in order to workaround System.Net.Socket bug #750028 IAsyncResult result = this.BeginProcessMessage(request, null, null); return(this.EndProcessMessage(result)); } }