Пример #1
0
        public override void BeginExit(Action onFailed)
        {
            try
            {
                this.OnFailed = onFailed;
                Binding controllerBinding = null;

                if (this.https)
                {
                    controllerBinding = ProxyBinding.BrokerProxyControllerHttpBinding;
                }
                else
                {
                    controllerBinding = ProxyBinding.BrokerProxyControllerBinding;
                }

                BrokerTracing.TraceVerbose("[AzureServiceHostController].BeginExit: construct the client. Binding {0}, Endpoint {1} , https = {2}", controllerBinding, this.controllerEndpoint, this.https);

                ProxyServiceControlClient proxyServiceControlClient
                    = new ProxyServiceControlClient(controllerBinding, this.controllerEndpoint);
                proxyServiceControlClient.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
                Utility.SetAzureClientCertificate(proxyServiceControlClient.ChannelFactory.Credentials);
                BrokerTracing.TraceVerbose("[AzureServiceHostController].BeginExit: BeginExit. Binding {0}, Endpoint {1}", controllerBinding, this.controllerEndpoint);

                this.controllerClient = proxyServiceControlClient;

                BindingData bindingData = new BindingData(this.binding);

                proxyServiceControlClient.BeginExit(
                    this.dispatcherInfo.MachineName,
                    this.dispatcherInfo.JobId,
                    this.dispatcherInfo.TaskId,
                    this.dispatcherInfo.FirstCoreId,
                    bindingData,
                    this.EndExit,
                    proxyServiceControlClient);

                BrokerTracing.TraceVerbose("[AzureServiceHostController].BeginExit: Called. Binding {0}, Endpoint {1}", controllerBinding, this.controllerEndpoint);
            }
            catch (Exception e)
            {
                BrokerTracing.TraceWarning("[AzureServiceHostController].BeginExit: Error occurs, {0}", e);

                this.OnFailed();

                // If BeginExit fails, dont retry any further. The task likely terminated already
                if (this.controllerClient != null)
                {
                    Utility.AsyncCloseICommunicationObject(this.controllerClient);
                }
            }
        }
 public void Exit(string machine, int jobId, int taskId, int port, BindingData data)
 {
     this.Channel.Exit(machine, jobId, taskId, port, data);
 }
 public IAsyncResult BeginExit(string machine, string jobId, string taskId, int port, BindingData data, AsyncCallback callback, object state)
 {
     return(this.Channel.BeginExit(machine, jobId, taskId, port, data, callback, state));
 }