void EnforceStatelessServiceBehaviorPolicy(ServiceDescription serviceDescription)
        {
            ServiceBehaviorAttribute serviceBehavior = serviceDescription.Behaviors.FirstOrDefault(behavior => behavior is ServiceBehaviorAttribute) as ServiceBehaviorAttribute;

            if (serviceBehavior != null)
            {
                serviceBehavior.InstanceContextMode       = InstanceContextMode.PerCall;
                serviceBehavior.ConcurrencyMode           = ConcurrencyMode.Multiple;
                serviceBehavior.MaxItemsInObjectGraph     = int.MaxValue;
                serviceBehavior.UseSynchronizationContext = false;
            }
            serviceDescription.SetThrottle();
        }
示例#2
0
        void EnforceStatefulActorBehaviorPolicy(ServiceDescription serviceDescription)
        {
            ServiceBehaviorAttribute serviceBehavior = serviceDescription.Behaviors.Find <ServiceBehaviorAttribute>();

            if (serviceBehavior != null)
            {
                Debug.Assert(serviceBehavior.InstanceContextMode == InstanceContextMode.PerSession);
                Debug.Assert(serviceBehavior.ConcurrencyMode == ConcurrencyMode.Single);

                serviceBehavior.InstanceContextMode       = InstanceContextMode.PerSession;
                serviceBehavior.ConcurrencyMode           = ConcurrencyMode.Single;
                serviceBehavior.MaxItemsInObjectGraph     = int.MaxValue;
                serviceBehavior.UseSynchronizationContext = false;
            }
            DurableServiceAttribute durableService = new DurableServiceAttribute();

            durableService.SaveStateInOperationTransaction = true;
            serviceDescription.Behaviors.Add(durableService);
            if (serviceDescription.Behaviors.Any(behavior => behavior is ActorStateProviderAttribute) == false)
            {
                StatePersistenceAttribute persistenceMode = serviceDescription.ServiceType.GetCustomAttribute <StatePersistenceAttribute>();
                if (persistenceMode == null)
                {
                    throw new InvalidOperationException("Validation failed. Actor " + serviceDescription.ServiceType.Name + " is missing a StatePersistenceAttribute.");
                }
                else
                {
                    if (persistenceMode.StatePersistence != StatePersistence.Persisted)
                    {
                        serviceDescription.Behaviors.Add(new VolatileActorStateProviderAttribute());
                    }
                    else
                    {
                        serviceDescription.Behaviors.Add(new KvsActorStateProviderAttribute());
                    }
                }
            }
            serviceDescription.SetThrottle();
            ServiceThrottlingBehavior throttle = serviceDescription.Behaviors.Find <ServiceThrottlingBehavior>();

            if (throttle != null)
            {
                throttle.MaxConcurrentInstances = int.MaxValue;
            }
        }
        void EnforceStatefulActorBehaviorPolicy(ServiceDescription serviceDescription)
        {
            ServiceBehaviorAttribute serviceBehavior = serviceDescription.Behaviors.Find <ServiceBehaviorAttribute>();

            if (serviceBehavior != null)
            {
                Debug.Assert(serviceBehavior.InstanceContextMode == InstanceContextMode.PerSession);
                Debug.Assert(serviceBehavior.ConcurrencyMode == ConcurrencyMode.Single);

                serviceBehavior.InstanceContextMode       = InstanceContextMode.PerSession;
                serviceBehavior.ConcurrencyMode           = ConcurrencyMode.Single;
                serviceBehavior.MaxItemsInObjectGraph     = int.MaxValue;
                serviceBehavior.UseSynchronizationContext = false;
            }
            DurableServiceAttribute durableService = new DurableServiceAttribute();

            durableService.SaveStateInOperationTransaction = true;
            serviceDescription.Behaviors.Add(durableService);
            if (!serviceDescription.Behaviors.Any(behavior => behavior is ActorStateProviderAttribute))
            {
                serviceDescription.Behaviors.Add(new VolatileActorStateProviderAttribute());
            }
            serviceDescription.SetThrottle();
        }