Example #1
0
        /// <summary>
        /// Create a subscriptionId that is unique per grainId, grainType, namespace combination.
        /// </summary>
        /// <param name="grainId"></param>
        /// <param name="streamId"></param>
        /// <returns></returns>
        private Guid MakeSubscriptionGuid(GrainId grainId, StreamId streamId)
        {
            // first int in guid is grain type code
            int grainIdTypeCode = grainId.GetTypeCode();

            return(MakeSubscriptionGuid(grainIdTypeCode, streamId));
        }
Example #2
0
        public IGrainRegistrar GetRegistrarForGrain(GrainId grainId)
        {
            MultiClusterRegistrationStrategy strategy;

            var typeCode = grainId.GetTypeCode();

            if (typeCode != 0)
            {
                string            unusedGrainClass;
                PlacementStrategy unusedPlacement;
                this.grainTypeManager.GetTypeInfo(grainId.GetTypeCode(), out unusedGrainClass, out unusedPlacement, out strategy);
            }
            else
            {
                // special case for Membership grain or client grain.
                strategy = ClusterLocalRegistration.Singleton; // default
            }

            return(this.registrars[strategy.GetType()]);
        }
 private void OnCollectActivation(GrainId grainId)
 {
     int other = grainId.GetTypeCode();
     int self = Data.Address.Grain.GetTypeCode();
     if (other == self)
     {
         IBusyActivationGcTestGrain1 g = GrainFactory.GetGrain<IBusyActivationGcTestGrain1>(grainId.GetPrimaryKey());
         for (int i = 0; i < burstCount; ++i)
         {
             g.Delay(TimeSpan.FromMilliseconds(10)).Ignore();
         }
     }         
 }
Example #4
0
        /// <summary>
        /// Try to get the implicit subscriptionId.
        /// If an implicit subscription exists, return a subscription Id that is unique per grain type, grainId, namespace combination.
        /// </summary>
        /// <param name="grainId"></param>
        /// <param name="streamId"></param>
        /// <param name="subscriptionId"></param>
        /// <returns></returns>
        internal bool TryGetImplicitSubscriptionGuid(GrainId grainId, StreamId streamId, out Guid subscriptionId)
        {
            subscriptionId = Guid.Empty;

            if (!HasImplicitSubscription(streamId.Namespace, grainId.GetTypeCode()))
            {
                return(false);
            }

            // make subscriptionId
            subscriptionId = MakeSubscriptionGuid(grainId, streamId);

            return(true);
        }
Example #5
0
        private void OnCollectActivation(GrainId grainId)
        {
            int other = grainId.GetTypeCode();
            int self  = Data.Address.Grain.GetTypeCode();

            if (other == self)
            {
                IBusyActivationGcTestGrain1 g = GrainFactory.GetGrain <IBusyActivationGcTestGrain1>(grainId.GetPrimaryKey());
                for (int i = 0; i < burstCount; ++i)
                {
                    g.Delay(TimeSpan.FromMilliseconds(10)).Ignore();
                }
            }
        }
Example #6
0
 /// <summary>
 /// Determines whether the specified grain is an implicit subscriber of a given stream.
 /// </summary>
 /// <param name="grainId">The grain identifier.</param>
 /// <param name="streamId">The stream identifier.</param>
 /// <returns>true if the grain id describes an implicit subscriber of the stream described by the stream id.</returns>
 internal bool IsImplicitSubscriber(GrainId grainId, StreamId streamId)
 {
     return(HasImplicitSubscription(streamId.Namespace, grainId.GetTypeCode()));
 }
Example #7
0
        public DetailedGrainReport GetDetailedGrainReport(GrainId grain)
        {
            var report = new DetailedGrainReport
            {
                Grain = grain,
                SiloAddress = LocalSilo,
                SiloName = localSiloName,
                LocalCacheActivationAddresses = directory.GetLocalCacheData(grain),
                LocalDirectoryActivationAddresses = directory.GetLocalDirectoryData(grain),
                PrimaryForGrain = directory.GetPrimaryForGrain(grain)
            };
            try
            {
                PlacementStrategy unused;
                string grainClassName;
                GrainTypeManager.GetTypeInfo(grain.GetTypeCode(), out grainClassName, out unused);
                report.GrainClassTypeName = grainClassName;
            }
            catch (Exception exc)
            {
                report.GrainClassTypeName = exc.ToString();
            }

            List<ActivationData> acts = activations.FindTargets(grain);
            report.LocalActivations = acts != null ? 
                acts.Select(activationData => activationData.ToDetailedString()).ToList() : 
                new List<string>();
            return report;
        }
Example #8
0
 public static void GetGrainTypeInfo(this IPlacementContext @this, GrainId grainId, out string grainClass, out PlacementStrategy placement, out MultiClusterRegistrationStrategy activationStrategy, string genericArguments = null)
 {
     @this.GetGrainTypeInfo(grainId.GetTypeCode(), out grainClass, out placement, out activationStrategy, genericArguments);
 }
Example #9
0
 public static string GetGrainTypeName(this IPlacementContext @this, GrainId grainId, string genericArguments = null)
 {
     return(@this.GetGrainTypeName(grainId.GetTypeCode(), genericArguments));
 }
Example #10
0
 public static string SystemTargetName(GrainId id)
 {
     string name;
     if (singletonSystemTargetNames.TryGetValue(id, out name)) return name;
     if (nonSingletonSystemTargetNames.TryGetValue(id.GetTypeCode(), out name)) return name;
     return String.Empty;
 }
        /// <summary>
        /// Try to get the implicit subscriptionId.
        /// If an implicit subscription exists, return a subscription Id that is unique per grain type, grainId, namespace combination.
        /// </summary>
        /// <param name="grainId"></param>
        /// <param name="streamId"></param>
        /// <param name="subscriptionId"></param>
        /// <returns></returns>
        internal bool TryGetImplicitSubscriptionGuid(GrainId grainId, StreamId streamId, out Guid subscriptionId)
        {
            subscriptionId = Guid.Empty;

            if (!HasImplicitSubscription(streamId.Namespace, grainId.GetTypeCode()))
            {
                return false;
            }

            // make subscriptionId
            subscriptionId = MakeSubscriptionGuid(grainId, streamId);

            return true;
        }
 /// <summary>
 /// Determines whether the specified grain is an implicit subscriber of a given stream.
 /// </summary>
 /// <param name="grainId">The grain identifier.</param>
 /// <param name="streamId">The stream identifier.</param>
 /// <returns>true if the grain id describes an implicit subscriber of the stream described by the stream id.</returns>
 internal bool IsImplicitSubscriber(GrainId grainId, StreamId streamId)
 {
     return HasImplicitSubscription(streamId.Namespace, grainId.GetTypeCode());
 }
        /// <summary>
        /// Create a subscriptionId that is unique per grainId, grainType, namespace combination.
        /// </summary>
        /// <param name="grainId"></param>
        /// <param name="streamId"></param>
        /// <returns></returns>
        private Guid MakeSubscriptionGuid(GrainId grainId, StreamId streamId)
        {
            // first int in guid is grain type code
            int grainIdTypeCode = grainId.GetTypeCode();

            return MakeSubscriptionGuid(grainIdTypeCode, streamId);
        }
Example #14
0
 public static void GetGrainTypeInfo(this IPlacementContext @this, GrainId grainId, out string grainClass, out PlacementStrategy placement, string genericArguments = null)
 {
     @this.GetGrainTypeInfo(grainId.GetTypeCode(), out grainClass, out placement, genericArguments);
 }
        /// <summary>
        /// Determines whether the specified grain is an implicit subscriber of a given stream.
        /// </summary>
        /// <param name="grainId">The grain identifier.</param>
        /// <param name="streamId">The stream identifier.</param>
        /// <returns>true if the grain id describes an implicit subscriber of the stream described by the stream id.</returns>
        internal bool IsImplicitSubscriber(GrainId grainId, StreamId streamId)
        {
            if (String.IsNullOrWhiteSpace(streamId.Namespace))
            {
                return(false);
            }

            HashSet <int> entry;

            return(table.TryGetValue(streamId.Namespace, out entry) && entry.Contains(grainId.GetTypeCode()));
        }
Example #16
0
 public IList<SiloAddress> GetCompatibleSiloList(GrainId grain)
 {
     var typeCode = grain.GetTypeCode();
     var compatibleSilos = GrainTypeManager.GetSupportedSilos(typeCode).Intersect(AllActiveSilos).ToList();
     if (compatibleSilos.Count == 0)
         throw new OrleansException($"TypeCode ${typeCode} not supported in the cluster");
     return compatibleSilos;
 }
Example #17
0
 public static PlacementStrategy GetGrainPlacementStrategy(this IPlacementContext @this, GrainId grainId, string genericArguments = null)
 {
     return @this.GetGrainPlacementStrategy(grainId.GetTypeCode(), genericArguments);
 }
Example #18
0
 public static PlacementStrategy GetGrainPlacementStrategy(this IPlacementContext @this, GrainId grainId, string genericArguments = null)
 {
     return(@this.GetGrainPlacementStrategy(grainId.GetTypeCode(), genericArguments));
 }
Example #19
0
 public static string GetGrainTypeName(this IPlacementContext @this, GrainId grainId, string genericArguments = null)
 {
     return @this.GetGrainTypeName(grainId.GetTypeCode(), genericArguments);
 }
Example #20
0
 public static void GetGrainTypeInfo(this IPlacementContext @this, GrainId grainId, out string grainClass, out PlacementStrategy placement, out MultiClusterRegistrationStrategy activationStrategy, string genericArguments = null)
 {
     @this.GetGrainTypeInfo(grainId.GetTypeCode(), out grainClass, out placement, out activationStrategy, genericArguments);
 }
Example #21
0
 public static void GetGrainTypeInfo(this IPlacementContext @this, GrainId grainId, out string grainClass, out PlacementStrategy placement, string genericArguments = null)
 {
     @this.GetGrainTypeInfo(grainId.GetTypeCode(), out grainClass, out placement, genericArguments);
 }