当前位置: 首页>>代码示例>>C#>>正文


C# Runtime.ActivationAddress类代码示例

本文整理汇总了C#中Orleans.Runtime.ActivationAddress的典型用法代码示例。如果您正苦于以下问题:C# ActivationAddress类的具体用法?C# ActivationAddress怎么用?C# ActivationAddress使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ActivationAddress类属于Orleans.Runtime命名空间,在下文中一共展示了ActivationAddress类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IdentifySelection

 public static PlacementResult IdentifySelection(ActivationAddress address)
 {
     return
         new PlacementResult
             {
                 Activation = address.Activation,
                 Silo = address.Silo
             };
 }
开发者ID:Rejendo,项目名称:orleans,代码行数:9,代码来源:PlacementResult.cs

示例2: TryForwardRequest

        internal void TryForwardRequest(Message message, ActivationAddress oldAddress, ActivationAddress forwardingAddress, string failedOperation, Exception exc = null)
        {
            bool forwardingSucceded = true;
            try
            {
                logger.Info(ErrorCode.Messaging_Dispatcher_TryForward, 
                    String.Format("Trying to forward after {0}, ForwardCount = {1}. Message {2}.", failedOperation, message.ForwardCount, message));

                MessagingProcessingStatisticsGroup.OnDispatcherMessageReRouted(message);
                if (oldAddress != null)
                {
                    message.AddToCacheInvalidationHeader(oldAddress);
                }
                forwardingSucceded = InsideRuntimeClient.Current.TryForwardMessage(message, forwardingAddress);
            }
            catch (Exception exc2)
            {
                forwardingSucceded = false;
                exc = exc2;
            }
            finally
            {
                if (!forwardingSucceded)
                {
                    var str = String.Format("Forwarding failed: tried to forward message {0} for {1} times after {2} to invalid activation. Rejecting now.", 
                        message, message.ForwardCount, failedOperation);
                    logger.Warn(ErrorCode.Messaging_Dispatcher_TryForwardFailed, str, exc);
                    RejectMessage(message, Message.RejectionTypes.Transient, exc, str);
                }
            }
        }
开发者ID:andrewalex,项目名称:orleans,代码行数:31,代码来源:Dispatcher.cs

示例3: ProcessRequestsToInvalidActivation

        internal void ProcessRequestsToInvalidActivation(
            List<Message> messages,
            ActivationAddress oldAddress,
            ActivationAddress forwardingAddress, 
            string failedOperation,
            Exception exc = null)
        {
            // Just use this opportunity to invalidate local Cache Entry as well. 
            if (oldAddress != null)
            {
                Silo.CurrentSilo.LocalGrainDirectory.InvalidateCacheEntry(oldAddress);
            }
            logger.Info(ErrorCode.Messaging_Dispatcher_ForwardingRequests, 
                String.Format("Forwarding {0} requests to old address {1} after {2}.", messages.Count, oldAddress, failedOperation));

            // IMPORTANT: do not do anything on activation context anymore, since this activation is invalid already.
            Scheduler.QueueWorkItem(new ClosureWorkItem(
                () =>
                {
                    foreach (var message in messages)
                    {
                        TryForwardRequest(message, oldAddress, forwardingAddress, failedOperation, exc);
                    }
                }
                ), catalog.SchedulingContext);
        }
开发者ID:andrewalex,项目名称:orleans,代码行数:26,代码来源:Dispatcher.cs

示例4: ProcessRequestToInvalidActivation

 internal void ProcessRequestToInvalidActivation(
     Message message, 
     ActivationAddress oldAddress, 
     ActivationAddress forwardingAddress, 
     string failedOperation, 
     Exception exc = null)
 {
     // Just use this opportunity to invalidate local Cache Entry as well. 
     if (oldAddress != null)
     {
         Silo.CurrentSilo.LocalGrainDirectory.InvalidateCacheEntry(oldAddress);
     }
     // IMPORTANT: do not do anything on activation context anymore, since this activation is invalid already.
     Scheduler.QueueWorkItem(new ClosureWorkItem(
         () => TryForwardRequest(message, oldAddress, forwardingAddress, failedOperation, exc)),
         catalog.SchedulingContext);
 }
开发者ID:andrewalex,项目名称:orleans,代码行数:17,代码来源:Dispatcher.cs

示例5: RerouteAllQueuedMessages

        private void RerouteAllQueuedMessages(ActivationData activation, ActivationAddress forwardingAddress, string failedOperation, Exception exc = null)
        {
            lock (activation)
            {
                List<Message> msgs = activation.DequeueAllWaitingMessages();
                if (msgs == null || msgs.Count <= 0) return;

                if (logger.IsVerbose) logger.Verbose(ErrorCode.Catalog_RerouteAllQueuedMessages, String.Format("RerouteAllQueuedMessages: {0} msgs from Invalid activation {1}.", msgs.Count(), activation));
                dispatcher.ProcessRequestsToInvalidActivation(msgs, activation.Address, forwardingAddress, failedOperation, exc);
            }
        }
开发者ID:kucheruk,项目名称:orleans,代码行数:11,代码来源:Catalog.cs

示例6: GetOrCreateActivation

        /// <summary>
        /// If activation already exists, use it
        /// Otherwise, create an activation of an existing grain by reading its state.
        /// Return immediately using a dummy that will queue messages.
        /// Concurrently start creating and initializing the real activation and replace it when it is ready.
        /// </summary>
        /// <param name="address">Grain's activation address</param>
        /// <param name="newPlacement">Creation of new activation was requested by the placement director.</param>
        /// <param name="grainType">The type of grain to be activated or created</param>
        /// <param name="genericArguments">Specific generic type of grain to be activated or created</param>
        /// <param name="activatedPromise"></param>
        /// <returns></returns>
        public ActivationData GetOrCreateActivation(
            ActivationAddress address,
            bool newPlacement,
            string grainType,
            string genericArguments,
            out Task activatedPromise)
        {
            ActivationData result;
            activatedPromise = TaskDone.Done;
            lock (activations)
            {
                if (TryGetActivationData(address.Activation, out result))
                {
                    ActivationCollector.TryRescheduleCollection(result);
                    return result;
                }
                
                if (newPlacement && !SiloStatusOracle.CurrentStatus.IsTerminating())
                {
                    // create a dummy activation that will queue up messages until the real data arrives
                    PlacementStrategy placement;
                    int typeCode = address.Grain.GetTypeCode();
                    string actualGrainType = null;

                    if (typeCode != 0) // special case for Membership grain.
                        GetGrainTypeInfo(typeCode, out actualGrainType, out placement);
                    else
                        placement = SystemPlacement.Singleton;

                    if (string.IsNullOrEmpty(grainType))
                    {
                        grainType = actualGrainType;
                    }

                    // We want to do this (RegisterMessageTarget) under the same lock that we tested TryGetActivationData. They both access ActivationDirectory.
                    result = new ActivationData(
                        address, 
                        genericArguments, 
                        placement, 
                        ActivationCollector, 
                        config.Application.GetCollectionAgeLimit(grainType));
                    RegisterMessageTarget(result);
                }
            } // End lock

            // Did not find and did not start placing new
            if (result == null)
            {
                var msg = String.Format("Non-existent activation: {0}, grain type: {1}.",
                                           address.ToFullString(), grainType);
                if (logger.IsVerbose) logger.Verbose(ErrorCode.CatalogNonExistingActivation2, msg);
                CounterStatistic.FindOrCreate(StatisticNames.CATALOG_ACTIVATION_NON_EXISTENT_ACTIVATIONS).Increment();
                throw new NonExistentActivationException(msg) { NonExistentActivation = address };
            }
   
            SetupActivationInstance(result, grainType, genericArguments);
            activatedPromise = InitActivation(result, grainType, genericArguments);
            return result;
        }
开发者ID:kucheruk,项目名称:orleans,代码行数:71,代码来源:Catalog.cs

示例7: Matches

 public bool Matches(ActivationAddress other)
 {
     return Equals(Grain, other.Grain) && Equals(Activation, other.Activation);
 }
开发者ID:PaulNorth,项目名称:orleans,代码行数:4,代码来源:ActivationAddress.cs

示例8: TryForwardMessage

        internal bool TryForwardMessage(Message message, ActivationAddress forwardingAddress)
        {
            if (!message.MayForward(Config.Globals)) return false;

            message.ForwardCount = message.ForwardCount + 1;
            MessagingProcessingStatisticsGroup.OnIgcMessageForwared(message);
            ResendMessageImpl(message, forwardingAddress);
            return true;
        }
开发者ID:PaulNorth,项目名称:orleans,代码行数:9,代码来源:InsideRuntimeClient.cs

示例9: DuplicateActivationException

 public DuplicateActivationException(ActivationAddress activationToUse, SiloAddress primaryDirectoryForGrain)
     : base("DuplicateActivationException")
 {
     ActivationToUse = activationToUse;
     PrimaryDirectoryForGrain = primaryDirectoryForGrain;
 }
开发者ID:naeemkhedarun,项目名称:orleans,代码行数:6,代码来源:Catalog.cs

示例10: NonExistentActivationException

 public NonExistentActivationException(string msg, ActivationAddress nonExistentActivation, bool isStatelessWorker)
     : base(msg)
 {
     NonExistentActivation = nonExistentActivation;
     IsStatelessWorker = isStatelessWorker;
 }
开发者ID:naeemkhedarun,项目名称:orleans,代码行数:6,代码来源:Catalog.cs

示例11: AddToCacheInvalidationHeader

        internal void AddToCacheInvalidationHeader(ActivationAddress address)
        {
            var list = new List<ActivationAddress>();
            if (CacheInvalidationHeader != null)
            {
                list.AddRange(CacheInvalidationHeader);
            }

            list.Add(address);
            CacheInvalidationHeader = list;
        }
开发者ID:osjimenez,项目名称:orleans,代码行数:11,代码来源:Message.cs

示例12: TryForwardRequest

        internal void TryForwardRequest(Message message, ActivationAddress oldAddress, ActivationAddress forwardingAddress, string failedOperation, Exception exc = null)
        {
            bool forwardingSucceded = true;
            try
            {

                logger.Info(ErrorCode.Messaging_Dispatcher_TryForward, 
                    String.Format("Trying to forward after {0}, ForwardCount = {1}. Message {2}.", failedOperation, message.ForwardCount, message));

                // if this message is from a different cluster and hit a non-existing activation
                // in this cluster (which can happen due to stale cache or directory states)
                // we forward it back to the original silo it came from in the original cluster,
                // and target it to a fictional activation that is guaranteed to not exist.
                // This ensures that the GSI protocol creates a new instance there instead of here.
                if (forwardingAddress == null
                    && message.TargetSilo != message.SendingSilo
                    && !Silo.CurrentSilo.LocalGrainDirectory.IsSiloInCluster(message.SendingSilo))
                {
                    message.IsReturnedFromRemoteCluster = true; // marks message to force invalidation of stale directory entry
                    forwardingAddress = ActivationAddress.NewActivationAddress(message.SendingSilo, message.TargetGrain);
                    logger.Info(ErrorCode.Messaging_Dispatcher_ReturnToOriginCluster,
                        String.Format("Forwarding back to origin cluster, to fictional activation {0}", message));
                }

                MessagingProcessingStatisticsGroup.OnDispatcherMessageReRouted(message);
                if (oldAddress != null)
                {
                    message.AddToCacheInvalidationHeader(oldAddress);
                }

                forwardingSucceded = InsideRuntimeClient.Current.TryForwardMessage(message, forwardingAddress);
            }
            catch (Exception exc2)
            {
                forwardingSucceded = false;
                exc = exc2;
            }
            finally
            {
                if (!forwardingSucceded)
                {
                    var str = String.Format("Forwarding failed: tried to forward message {0} for {1} times after {2} to invalid activation. Rejecting now.", 
                        message, message.ForwardCount, failedOperation);
                    logger.Warn(ErrorCode.Messaging_Dispatcher_TryForwardFailed, str, exc);
                    RejectMessage(message, Message.RejectionTypes.Transient, exc, str);
                }
            }
        }
开发者ID:Carlm-MS,项目名称:orleans,代码行数:48,代码来源:Dispatcher.cs

示例13: ActivationData

        public ActivationData(ActivationAddress addr, string genericArguments, PlacementStrategy placedUsing, MultiClusterRegistrationStrategy registrationStrategy, IActivationCollector collector, TimeSpan ageLimit)
        {
            if (null == addr) throw new ArgumentNullException("addr");
            if (null == placedUsing) throw new ArgumentNullException("placedUsing");
            if (null == collector) throw new ArgumentNullException("collector");

            logger = LogManager.GetLogger("ActivationData", LoggerType.Runtime);
            ResetKeepAliveRequest();
            Address = addr;
            State = ActivationState.Create;
            PlacedUsing = placedUsing;
            RegistrationStrategy = registrationStrategy;
            if (!Grain.IsSystemTarget && !Constants.IsSystemGrain(Grain))
            {
                this.collector = collector;
            }
            CollectionAgeLimit = ageLimit;

            GrainReference = GrainReference.FromGrainId(addr.Grain, genericArguments,
                Grain.IsSystemTarget ? addr.Silo : null);
        }
开发者ID:caomw,项目名称:orleans,代码行数:21,代码来源:ActivationData.cs

示例14: Write

        /// <summary> Write a <c>ActivationAddress</c> value to the stream. </summary>
        internal void Write(ActivationAddress addr)
        {
            Write(addr.Silo ?? SiloAddress.Zero);

            // GrainId must not be null
            Write(addr.Grain);
            Write(addr.Activation ?? ActivationId.Zero);
        }
开发者ID:taoliseki,项目名称:orleans,代码行数:9,代码来源:BinaryTokenStreamWriter.cs

示例15: RegisterActivationInGrainDirectory

        private async Task RegisterActivationInGrainDirectory(ActivationAddress address, bool singleActivationMode)
        {
            if (singleActivationMode)
            {
                ActivationAddress returnedAddress = await scheduler.RunOrQueueTask(() => directory.RegisterSingleActivationAsync(address), this.SchedulingContext);
                if (address.Equals(returnedAddress)) return;
                
                SiloAddress primaryDirectoryForGrain = directory.GetPrimaryForGrain(address.Grain);
                var dae = new DuplicateActivationException
                {
                    ActivationToUse = returnedAddress,
                    PrimaryDirectoryForGrain = primaryDirectoryForGrain
                };

                throw dae;
            }
            
            await scheduler.RunOrQueueTask(() => directory.RegisterAsync(address), this.SchedulingContext);
        }
开发者ID:kucheruk,项目名称:orleans,代码行数:19,代码来源:Catalog.cs


注:本文中的Orleans.Runtime.ActivationAddress类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。