Пример #1
0
        /// <summary>
        /// Async open service host.
        /// </summary>
        /// <param name="num"></param>
        /// <param name="taskInfo"></param>
        /// <param name="regPath"></param>
        /// <param name="svcName"></param>
        /// <returns></returns>
        private static async Task <ServiceTaskDispatcherInfo> OpenSvcHostAsync(
            string sessionId,
            ServiceTaskDispatcherInfo taskDispatcherInfo,
            string regPath,
            string svcName,
            Version svcVersion,
            Dictionary <string, string> environment,
            Dictionary <string, string> dependFilesInfo)
        {
            var invalidList = invalidIds;

            if (invalidList.Contains(taskDispatcherInfo.TaskId))
            {
                return(null);
            }
            string fileName = SoaRegistrationAuxModule.GetRegistrationFileName(svcName, svcVersion);

            BrokerTracing.TraceVerbose("[SvcHostHttpClient] Started send request, taskId is {0} and session id is {1}", taskDispatcherInfo.TaskId, sessionId);
            // HTTP POST
            var serviceInfo = new ServiceInfo(sessionId, taskDispatcherInfo.TaskId, taskDispatcherInfo.FirstCoreId, regPath + "\\", fileName, environment, dependFilesInfo);
            var result      = await SvcHostHttpClient.PostAsJsonAsync <ServiceInfo>(new Uri($"{Prefix}{taskDispatcherInfo.MachineName}:{Port}/{EndPointName}/api/{ApiName}"), serviceInfo);

            BrokerTracing.TraceVerbose("[OpenSvcHost].result:{0}", result);
            result.EnsureSuccessStatusCode();
            return(taskDispatcherInfo);
        }
        /// <summary>
        /// Prepare the message for sending: add some information into the
        /// message headers. Broker proxy will generate epr of the Azure
        /// svchost based on these information.
        /// </summary>
        /// <param name="message">request message</param>
        /// <param name="dispatchId">indicating the dispatch id</param>
        /// <param name="needBinding">
        /// add binding data to the message header or not
        /// </param>
        protected override void PrepareMessage(Message message, Guid dispatchId, bool needBinding)
        {
            ServiceTaskDispatcherInfo serviceTaskDispatcherInfo = this.Dispatcher.Info as ServiceTaskDispatcherInfo;

            if (serviceTaskDispatcherInfo != null)
            {
                message.Headers.Add(MessageHeader.CreateHeader(Constant.MessageHeaderMachineName, Constant.HpcHeaderNS, this.Dispatcher.Info.MachineName));
                message.Headers.Add(MessageHeader.CreateHeader(Constant.MessageHeaderCoreId, Constant.HpcHeaderNS, serviceTaskDispatcherInfo.FirstCoreId));
                message.Headers.Add(MessageHeader.CreateHeader(Constant.MessageHeaderJobId, Constant.HpcHeaderNS, serviceTaskDispatcherInfo.JobId));
                message.Headers.Add(MessageHeader.CreateHeader(Constant.MessageHeaderTaskId, Constant.HpcHeaderNS, serviceTaskDispatcherInfo.TaskId));

                if (needBinding)
                {
                    // carry backend binding info over message header
                    message.Headers.Add(MessageHeader.CreateHeader(Constant.MessageHeaderBinding, Constant.HpcHeaderNS, this.backendBindingData));

                    // also carry serviceOperationTimeout value over message header
                    message.Headers.Add(MessageHeader.CreateHeader(Constant.MessageHeaderServiceOperationTimeout, Constant.HpcHeaderNS, this.BackendServiceOperationTimeout));
                }
            }
            else
            {
                EprDispatcherInfo eprDispatcherInfo = this.Dispatcher.Info as EprDispatcherInfo;

                if (eprDispatcherInfo != null)
                {
                    // TODO: support Azure service host in in-proc broker
                }
            }

            // following method must be called, otherwise the dispatcher Id is not set
            // to the message header and the SoaDiagUserTrace can not be recorded.
            base.PrepareMessage(message, dispatchId, needBinding);
        }
Пример #3
0
        private static async Task <ServiceTaskDispatcherInfo> OpenSvcHostWithRetryAsync(
            string sessionId,
            ServiceTaskDispatcherInfo taskDispatcherInfo,
            string regPath,
            string svcName,
            Version svcVersion,
            Dictionary <string, string> environment,
            Dictionary <string, string> dependFilesInfo)
        {
            BrokerTracing.TraceVerbose("[OpenSvcHostWithRetryAsync] Started open service host {0} for session {1}", taskDispatcherInfo.MachineName, sessionId);
            RetryManager mgr = new RetryManager(new ExponentialRandomBackoffRetryTimer(1 * 1000, 10 * 1000), RetryManager.InfiniteRetries);

            return(await mgr.InvokeWithRetryAsync(() => OpenSvcHostAsync(sessionId, taskDispatcherInfo, regPath, svcName, svcVersion, environment, dependFilesInfo), ex => true));
        }
Пример #4
0
 internal static async Task <ServiceTaskDispatcherInfo> OpenSvcHostsAsync(string sessionId, SessionStartInfoContract startInfo, ServiceTaskDispatcherInfo taskDispatcherInfo)
 {
     return(await OpenSvcHostWithRetryAsync(sessionId, taskDispatcherInfo, startInfo.RegPath, startInfo.ServiceName, startInfo.ServiceVersion, startInfo.Environments, startInfo.DependFilesStorageInfo));
 }