コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GrainContextActivator"/> class.
 /// </summary>
 /// <param name="providers">The grain context activator providers.</param>
 /// <param name="configureContextActions">The <see cref="IConfigureGrainContext"/> providers.</param>
 /// <param name="grainPropertiesResolver">The grain properties resolver.</param>
 public GrainContextActivator(
     IEnumerable <IGrainContextActivatorProvider> providers,
     IEnumerable <IConfigureGrainContextProvider> configureContextActions,
     GrainPropertiesResolver grainPropertiesResolver)
 {
     _resolver              = grainPropertiesResolver;
     _activatorProviders    = providers.ToArray();
     _configuratorProviders = configureContextActions.ToArray();
 }
コード例 #2
0
 /// <summary>
 /// Create a <see cref="PlacementStrategyResolver"/> instance.
 /// </summary>
 public PlacementStrategyResolver(
     IServiceProvider services,
     IEnumerable <IPlacementStrategyResolver> resolvers,
     GrainPropertiesResolver grainPropertiesResolver)
 {
     _getStrategyInternal      = GetPlacementStrategyInternal;
     _resolvers                = resolvers.ToArray();
     _services                 = services;
     _grainPropertiesResolver  = grainPropertiesResolver;
     _defaultPlacementStrategy = services.GetService <PlacementStrategy>();
     _strategies               = GetAllStrategies(services);
コード例 #3
0
ファイル: Catalog.cs プロジェクト: sun293529884/orleans
        public Catalog(
            ILocalSiloDetails localSiloDetails,
            GrainLocator grainLocator,
            GrainDirectoryResolver grainDirectoryResolver,
            ILocalGrainDirectory grainDirectory,
            ActivationDirectory activationDirectory,
            ActivationCollector activationCollector,
            IServiceProvider serviceProvider,
            ILoggerFactory loggerFactory,
            IOptions <GrainCollectionOptions> collectionOptions,
            RuntimeMessagingTrace messagingTrace,
            GrainContextActivator grainActivator,
            GrainPropertiesResolver grainPropertiesResolver)
            : base(Constants.CatalogType, localSiloDetails.SiloAddress, loggerFactory)
        {
            this.LocalSilo               = localSiloDetails.SiloAddress;
            this.localSiloName           = localSiloDetails.Name;
            this.grainLocator            = grainLocator;
            this.grainDirectoryResolver  = grainDirectoryResolver;
            this.directory               = grainDirectory;
            this.activations             = activationDirectory;
            this.serviceProvider         = serviceProvider;
            this.collectionOptions       = collectionOptions;
            this.grainActivator          = grainActivator;
            this.grainPropertiesResolver = grainPropertiesResolver;
            this.logger = loggerFactory.CreateLogger <Catalog>();
            this.activationCollector = activationCollector;
            this.RuntimeClient       = serviceProvider.GetRequiredService <InsideRuntimeClient>();

            GC.GetTotalMemory(true); // need to call once w/true to ensure false returns OK value

            IntValueStatistic.FindOrCreate(StatisticNames.CATALOG_ACTIVATION_COUNT, () => activations.Count);
            activationsCreated   = CounterStatistic.FindOrCreate(StatisticNames.CATALOG_ACTIVATION_CREATED);
            activationsDestroyed = CounterStatistic.FindOrCreate(StatisticNames.CATALOG_ACTIVATION_DESTROYED);
            IntValueStatistic.FindOrCreate(StatisticNames.MESSAGING_PROCESSING_ACTIVATION_DATA_ALL, () =>
            {
                long counter = 0;
                lock (activations)
                {
                    foreach (var activation in activations)
                    {
                        if (activation.Value is ActivationData data)
                        {
                            counter += data.GetRequestCount();
                        }
                    }
                }
                return(counter);
            });
            grainDirectory.SetSiloRemovedCatalogCallback(this.OnSiloStatusChange);
            RegisterSystemTarget(this);
        }
コード例 #4
0
        public GrainDirectoryResolver(
            IServiceProvider serviceProvider,
            GrainPropertiesResolver grainPropertiesResolver,
            IEnumerable <IGrainDirectoryResolver> resolvers)
        {
            this.getGrainDirectoryInternal = GetGrainDirectoryPerType;
            this.resolvers = resolvers.ToArray();

            // Load all registered directories
            var services = serviceProvider.GetService <IKeyedServiceCollection <string, IGrainDirectory> >()?.GetServices(serviceProvider)
                           ?? Enumerable.Empty <IKeyedService <string, IGrainDirectory> >();

            foreach (var svc in services)
            {
                this.directoryPerName.Add(svc.Key, svc.GetService(serviceProvider));
            }

            this.directoryPerName.TryGetValue(GrainDirectoryAttribute.DEFAULT_GRAIN_DIRECTORY, out var defaultDirectory);
            this.DefaultGrainDirectory   = defaultDirectory;
            this.grainPropertiesResolver = grainPropertiesResolver;
        }
コード例 #5
0
 public SiloLoggingHelper(GrainPropertiesResolver grainPropertiesResolver, IApplicationPartManager applicationPartManager)
     : base(grainPropertiesResolver, applicationPartManager)
 {
 }
コード例 #6
0
 public GrainTypeComponentsResolver(IEnumerable <IConfigureGrainTypeComponents> configurators, GrainPropertiesResolver resolver)
 {
     _configurators = configurators.ToArray();
     _resolver      = resolver;
     _createFunc    = this.Create;
 }