private void RefreshActivationProxy(EndpointAddress suggestedAddress)
        {
            EndpointAddress address = suggestedAddress;

            if (address == null)
            {
                address = this.wsatConfig.LocalActivationService(this.protocolVersion);
                if (address == null)
                {
                    address = this.wsatConfig.RemoteActivationService(this.protocolVersion);
                }
            }
            if (address == null)
            {
                DiagnosticUtility.FailFast("Must have valid activation service address");
            }
            lock (this.proxyLock)
            {
                ActivationProxy proxy = this.CreateActivationProxy(address);
                if (this.activationProxy != null)
                {
                    this.activationProxy.Release();
                }
                this.activationProxy = proxy;
            }
        }
Example #2
0
        //=============================================================================================
        // The demand is not added now (in 4.5), to avoid a breaking change. To be considered in the next version.

        /*
         * // We demand full trust because we call ActivationProxy.Release(), which is defined in a non-APTCA assembly and can do Environment.FailFast.
         * // It's recommended to not let partially trusted callers to bring down the process.
         * // WSATs are not supported in partial trust, so customers should not be broken by this demand.
         * [PermissionSet(SecurityAction.Demand, Unrestricted = true)]
         */
        void RefreshActivationProxy(EndpointAddress suggestedAddress)
        {
            // Pick an address in the following order...
            EndpointAddress address = suggestedAddress;

            if (address == null)
            {
                address = this.wsatConfig.LocalActivationService(this.protocolVersion);

                if (address == null)
                {
                    address = this.wsatConfig.RemoteActivationService(this.protocolVersion);
                }
            }

            if (!(address != null))
            {
                // tx processing requires failfast when state is inconsistent
                DiagnosticUtility.FailFast("Must have valid activation service address");
            }

            lock (this.proxyLock)
            {
                ActivationProxy newProxy = CreateActivationProxy(address);
                if (this.activationProxy != null)
                {
                    this.activationProxy.Release();
                }
                this.activationProxy = newProxy;
            }
        }
Example #3
0
 public void SendFault(Microsoft.Transactions.Wsat.Messaging.RequestAsyncResult result, Fault fault)
 {
     this.state.Perf.FaultsSentCountPerInterval.Increment();
     if (DebugTrace.Warning)
     {
         DebugTrace.Trace(TraceLevel.Warning, "Sending {0} fault to activation participant", fault.Code.Name);
     }
     ActivationProxy.SendFaultResponse(result, fault);
 }
 private ActivationProxy GetActivationProxy()
 {
     if (this.activationProxy == null)
     {
         this.RefreshActivationProxy(null);
     }
     lock (this.proxyLock)
     {
         ActivationProxy activationProxy = this.activationProxy;
         activationProxy.AddRef();
         return(activationProxy);
     }
 }
Example #5
0
        //=============================================================================================
        // The demand is not added now (in 4.5), to avoid a breaking change. To be considered in the next version.

        /*
         * // We demand full trust because we call ActivationProxy.AddRef(), which is defined in a non-APTCA assembly and can do Environment.FailFast.
         * // It's recommended to not let partially trusted callers to bring down the process.
         * // WSATs are not supported in partial trust, so customers should not be broken by this demand.
         * [PermissionSet(SecurityAction.Demand, Unrestricted = true)]
         */
        ActivationProxy GetActivationProxy()
        {
            if (this.activationProxy == null)
            {
                RefreshActivationProxy(null);
            }

            lock (this.proxyLock)
            {
                ActivationProxy proxy = this.activationProxy;
                proxy.AddRef();
                return(proxy);
            }
        }
Example #6
0
        public void SendCreateCoordinationContextResponse(TransactionContext txContext, Microsoft.Transactions.Wsat.Messaging.RequestAsyncResult result)
        {
            CreateCoordinationContextResponse response = new CreateCoordinationContextResponse(this.state.ProtocolVersion)
            {
                CoordinationContext = txContext.CoordinationContext,
                IssuedToken         = txContext.IssuedToken
            };

            if (DebugTrace.Info)
            {
                DebugTrace.Trace(TraceLevel.Info, "Sending CreateCoordinationContextResponse");
            }
            ActivationProxy.SendCreateCoordinationContextResponse(result, ref response);
        }
Example #7
0
            public void ThreadProc()
            {
                string licensingData;

                try
                {
                    // build the xml
                    using (MemoryStream ms = new MemoryStream())
                    {
                        Encoding          Utf8     = new UTF8Encoding(false);
                        XmlWriterSettings settings = new XmlWriterSettings();
                        settings.OmitXmlDeclaration = true;
                        settings.Encoding           = Utf8;
                        XmlWriter writer = XmlWriter.Create(ms, settings);

                        writer.WriteStartDocument();
                        writer.WriteStartElement(LicensingAction);
                        foreach (XenAPI.Host host in Hosts.Keys)
                        {
                            ProduceXmlForHost(host, Hosts[host], writer);
                        }
                        writer.WriteEndElement();
                        writer.WriteEndDocument();
                        writer.Close();

                        licensingData = Utf8.GetString(ms.ToArray());
                    }

                    // send the xml
                    ActivationProxy proxy = XmlRpcProxyGen.Create <ActivationProxy>();
                    proxy.Url            = string.Format(InvisibleMessages.ACTIVATION_URL, InvisibleMessages.ACTIVATION_SERVER);
                    proxy.Timeout        = 30 * 1000;
                    proxy.UseIndentation = false;
                    proxy.UserAgent      = Session.UserAgent;
                    proxy.KeepAlive      = true;
                    proxy.Proxy          = Session.Proxy;

                    // response is the transaction id of this call to the activation service
                    string response = proxy.process_reactivation_request(licensingData);
                }
                catch (Exception)
                {
                }
            }
Example #8
0
        protected override void Run()
        {
            Description = Messages.ACTIVATION_REQUEST_TITLE;

            ActivationProxy proxy = XmlRpcProxyGen.Create <ActivationProxy>();

            proxy.Url            = string.Format(InvisibleMessages.ACTIVATION_URL, InvisibleMessages.ACTIVATION_SERVER);
            proxy.Timeout        = ACTIVATION_REQUEST_TIMEOUT;
            proxy.UseIndentation = false;
            proxy.UserAgent      = Session.UserAgent;
            proxy.KeepAlive      = true;
            proxy.RequestEvent  += LogRequest;
            proxy.ResponseEvent += LogResponse;
            proxy.Proxy          = Session.Proxy;

            // response is the transaction id of this call to the activation service

            Result      = proxy.process_reactivation_request(_requestString);
            Description = Messages.COMPLETED;
        }
        private CreateCoordinationContextResponse Enlist(ref Microsoft.Transactions.Wsat.Messaging.CreateCoordinationContext cccMessage)
        {
            int num = 0;

            while (true)
            {
                ActivationProxy activationProxy = this.GetActivationProxy();
                EndpointAddress to       = activationProxy.To;
                EndpointAddress objB     = this.wsatConfig.LocalActivationService(this.protocolVersion);
                EndpointAddress address3 = this.wsatConfig.RemoteActivationService(this.protocolVersion);
                try
                {
                    return(activationProxy.SendCreateCoordinationContext(ref cccMessage));
                }
                catch (WsatSendFailureException exception)
                {
                    DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Warning);
                    Exception innerException = exception.InnerException;
                    if (((innerException is TimeoutException) || (innerException is QuotaExceededException)) || (innerException is FaultException))
                    {
                        throw;
                    }
                    if (num > 10)
                    {
                        throw;
                    }
                    if (((num > 5) && (address3 != null)) && object.ReferenceEquals(to, objB))
                    {
                        to = address3;
                    }
                }
                finally
                {
                    activationProxy.Release();
                }
                this.TryStartMsdtcService();
                this.RefreshActivationProxy(to);
                Thread.Sleep(0);
                num++;
            }
        }
Example #10
0
        //=============================================================================================
        // The demand is not added now (in 4.5), to avoid a breaking change. To be considered in the next version.

        /*
         * [PermissionSet(SecurityAction.Demand, Unrestricted = true)] // because we call code from a non-APTCA assembly; WSATs are not supported in partial trust, so customers should not be broken by this demand
         */
        CreateCoordinationContextResponse Enlist(ref CreateCoordinationContext cccMessage)
        {
            int attempts = 0;

            while (true)
            {
                ActivationProxy proxy   = GetActivationProxy();
                EndpointAddress address = proxy.To;

                EndpointAddress localActivationService  = this.wsatConfig.LocalActivationService(this.protocolVersion);
                EndpointAddress remoteActivationService = this.wsatConfig.RemoteActivationService(this.protocolVersion);

                try
                {
                    return(proxy.SendCreateCoordinationContext(ref cccMessage));
                }
                catch (WsatSendFailureException e)
                {
                    DiagnosticUtility.TraceHandledException(e, TraceEventType.Warning);

                    // Don't retry if we're not likely to succeed on the next pass
                    Exception inner = e.InnerException;
                    if (inner is TimeoutException ||
                        inner is QuotaExceededException ||
                        inner is FaultException)
                    {
                        throw;
                    }

                    // Give up after 10 attempts
                    if (attempts > 10)
                    {
                        throw;
                    }

                    if (attempts > 5 &&
                        remoteActivationService != null &&
                        ReferenceEquals(address, localActivationService))
                    {
                        // Switch over to the remote activation service.
                        // In clustered scenarios this uses the cluster name,
                        // so it should always work if the resource is online
                        // This covers the case where we were using a local cluster
                        // resource which failed over to another node
                        address = remoteActivationService;
                    }
                }
                finally
                {
                    proxy.Release();
                }

                TryStartMsdtcService();

                // We need to refresh our proxy here because the channel is sessionful
                // and may simply decided to enter the faulted state if something fails.
                RefreshActivationProxy(address);

                // Don't spin
                Thread.Sleep(0);
                attempts++;
            }
        }