Ejemplo n.º 1
0
        /// <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;
        }
Ejemplo n.º 2
0
        /// <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;
                }
            }
        }
Ejemplo n.º 3
0
        /// <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));
        }
Ejemplo n.º 4
0
 /// <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));
     }
 }
Ejemplo n.º 5
0
 /// <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));
     }
 }
Ejemplo n.º 6
0
 /// <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));
     }
 }
Ejemplo n.º 7
0
 /// <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);
     }
 }
Ejemplo n.º 8
0
 /// <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));
     }
 }
Ejemplo n.º 9
0
 /// <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));
     }
 }
Ejemplo n.º 10
0
 /// <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));
     }
 }
Ejemplo n.º 11
0
 /// <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);
     }
 }
Ejemplo n.º 12
0
 /// <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));
     }
 }
Ejemplo n.º 13
0
 /// <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));
     }
 }
Ejemplo n.º 14
0
 /// <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));
     }
 }
Ejemplo n.º 15
0
 /// <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());
     }
 }
Ejemplo n.º 16
0
 /// <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));
     }
 }
Ejemplo n.º 17
0
 /// <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);
     }
 }
Ejemplo n.º 18
0
 /// <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());
     }
 }
Ejemplo n.º 19
0
 /// <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());
     }
 }
Ejemplo n.º 20
0
 /// <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));
     }
 }
Ejemplo n.º 21
0
 /// <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));
     }
 }
Ejemplo n.º 22
0
 /// <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));
     }
 }
Ejemplo n.º 23
0
 /// <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));
     }
 }
Ejemplo n.º 24
0
 /// <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));
     }
 }
Ejemplo n.º 25
0
        /// <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));
            }
        }
Ejemplo n.º 26
0
 /// <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));
     }
 }
Ejemplo n.º 27
0
        /// <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);
            }
        }
Ejemplo n.º 28
0
        /// <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);
            }
        }
Ejemplo n.º 29
0
        /// <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
        }
Ejemplo n.º 30
0
        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));
            }
        }