private async Task CreateGrainServices(GrainServiceConfigurations grainServiceConfigurations) { foreach (var serviceConfig in grainServiceConfigurations.GrainServices) { // Construct the Grain Service var serviceType = System.Type.GetType(serviceConfig.Value.ServiceType); if (serviceType == null) { throw new Exception(String.Format("Cannot find Grain Service type {0} of Grain Service {1}", serviceConfig.Value.ServiceType, serviceConfig.Value.Name)); } var grainServiceInterfaceType = serviceType.GetInterfaces().FirstOrDefault(x => x.GetInterfaces().Contains(typeof(IGrainService))); if (grainServiceInterfaceType == null) { throw new Exception(String.Format("Cannot find an interface on {0} which implements IGrainService", serviceConfig.Value.ServiceType)); } var typeCode = GrainInterfaceUtils.GetGrainClassTypeCode(grainServiceInterfaceType); var grainId = (IGrainIdentity)GrainId.GetGrainServiceGrainId(0, typeCode); var grainService = (GrainService)ActivatorUtilities.CreateInstance(this.Services, serviceType, grainId, serviceConfig.Value); RegisterSystemTarget(grainService); await this.scheduler.QueueTask(() => grainService.Init(Services), grainService.SchedulingContext).WithTimeout(this.initTimeout); await this.scheduler.QueueTask(grainService.Start, grainService.SchedulingContext).WithTimeout(this.initTimeout); if (this.logger.IsEnabled(LogLevel.Debug)) { logger.Debug(String.Format("{0} Grain Service started successfully.", serviceConfig.Value.Name)); } } }
internal IReminderService CreateReminderService( Silo silo, TimeSpan iniTimeSpan, ISiloRuntimeClient runtimeClient) { logger.Info( "Creating reminder grain service for type={0}", this.reminderTable.GetType()); // GrainInterfaceMap only holds IGrain types, not ISystemTarget types, so resolved via Orleans.CodeGeneration. // Resolve this before merge. var typeCode = GrainInterfaceUtils.GetGrainClassTypeCode(typeof(IReminderService)); var grainId = GrainId.GetGrainServiceGrainId(0, typeCode); return(new LocalReminderService(silo, grainId, this.reminderTable, iniTimeSpan, this.loggerFactory)); }
internal IReminderService CreateReminderService(Silo silo, IGrainFactory grainFactory, TimeSpan iniTimeSpan, ISiloRuntimeClient runtimeClient) { var reminderServiceType = silo.GlobalConfig.ReminderServiceType; logger.Info("Creating reminder grain service for type={0}", Enum.GetName(typeof(GlobalConfiguration.ReminderServiceProviderType), reminderServiceType)); // GrainInterfaceMap only holds IGrain types, not ISystemTarget types, so resolved via Orleans.CodeGeneration. // Resolve this before merge. var typeCode = GrainInterfaceUtils.GetGrainClassTypeCode(typeof(IReminderService)); var grainId = GrainId.GetGrainServiceGrainId(0, typeCode); ReminderTable.Initialize(silo, grainFactory, silo.GlobalConfig.ReminderTableAssembly); return(new LocalReminderService( silo, grainId, ReminderTable.Singleton, silo.GlobalConfig, iniTimeSpan)); }
public GrainReference MakeGrainServiceGrainReference(int typeData, string systemGrainId, SiloAddress siloAddress) => GrainReference.FromGrainId(GrainId.GetGrainServiceGrainId(typeData, systemGrainId), this.runtimeClient.GrainReferenceRuntime, systemTargetSilo: siloAddress);
public GrainReference MakeGrainServiceGrainReference(int typeData, string systemGrainId, SiloAddress siloAddress) => this.MakeGrainReference(GrainId.GetGrainServiceGrainId(typeData, systemGrainId), siloAddress);