public static void Initialize(Silo silo, IGrainFactory grainFactory, string reminderTableAssembly = null) { var config = silo.GlobalConfig; var serviceType = config.ReminderServiceType; var logger = TraceLogger.GetLogger("ReminderTable"); switch (serviceType) { default: throw new NotSupportedException( String.Format( "The reminder table does not currently support service provider {0}.", serviceType)); case GlobalConfiguration.ReminderServiceProviderType.SqlServer: Singleton = AssemblyLoader.LoadAndCreateInstance<IReminderTable>(Constants.ORLEANS_SQL_UTILS_DLL, logger); return; case GlobalConfiguration.ReminderServiceProviderType.AzureTable: Singleton = AssemblyLoader.LoadAndCreateInstance<IReminderTable>(Constants.ORLEANS_AZURE_UTILS_DLL, logger); return; case GlobalConfiguration.ReminderServiceProviderType.ReminderTableGrain: Singleton = grainFactory.GetGrain<IReminderTableGrain>(Constants.ReminderTableGrainId); return; case GlobalConfiguration.ReminderServiceProviderType.MockTable: Singleton = new MockReminderTable(config.MockReminderTableTimeout); return; case GlobalConfiguration.ReminderServiceProviderType.Custom: Singleton = AssemblyLoader.LoadAndCreateInstance<IReminderTable>(reminderTableAssembly, logger); return; } }
public ImplicitSubscritionRecoverableStreamTestRunner(IGrainFactory grainFactory, string streamProviderTypeName, string streamProviderName, GeneratorAdapterConfig adapterConfig) { this.grainFactory = grainFactory; this.streamProviderTypeName = streamProviderTypeName; this.streamProviderName = streamProviderName; this.adapterConfig = adapterConfig; }
public GrainRuntime(string siloId, IGrainFactory grainFactory, ITimerRegistry timerRegistry, IReminderRegistry reminderRegistry, IStreamProviderManager streamProviderManager) { SiloIdentity = siloId; GrainFactory = grainFactory; TimerRegistry = timerRegistry; ReminderRegistry = reminderRegistry; StreamProviderManager = streamProviderManager; }
//--------------------------------------------------------------------- public FriendInfoSync(GrainPlayer grain, IGrainFactory grain_factory, List<string> list_source) { GrainPlayer = grain; GrainFactory = grain_factory; QueSource = new Queue<string>(list_source); ListPlayerInfoPushClient = new List<PlayerInfo>(); HasClient = false; }
public GrainRuntime(Guid serviceId, string siloId, IGrainFactory grainFactory, ITimerRegistry timerRegistry, IReminderRegistry reminderRegistry, IStreamProviderManager streamProviderManager, IServiceProvider serviceProvider) { ServiceId = serviceId; SiloIdentity = siloId; GrainFactory = grainFactory; TimerRegistry = timerRegistry; ReminderRegistry = reminderRegistry; StreamProviderManager = streamProviderManager; ServiceProvider = serviceProvider; }
private static async Task PropigateStatisticsToCluster(IGrainFactory grainFactory) { // force the latched statistics to propigate throughout the cluster. IManagementGrain mgmtGrain = grainFactory.GetGrain<IManagementGrain>(0); var hosts = await mgmtGrain.GetHosts(true); var keys = hosts.Select(kvp => kvp.Key).ToArray(); await mgmtGrain.ForceRuntimeStatisticsCollection(keys); }
public DIGrainWithInjectedServices(IInjectedService injectedService, IGrainFactory injectedGrainFactory) { this.injectedService = injectedService; this.injectedGrainFactory = injectedGrainFactory; bool set; // get the object Id for injected GrainFactory, // object Id will be the same if the underlying object is the same, // this is one way to prove that this GrainFactory is injected from DI this.grainFactoryId = ObjectIdGenerator.GetId(this.injectedGrainFactory, out set); }
public GrainTypeManager(bool localTestMode, IGrainFactory grainFactory) { this.grainFactory = grainFactory; grainInterfaceMap = new GrainInterfaceMap(localTestMode); lock (lockable) { if (Instance != null) throw new InvalidOperationException("An attempt to create a second insance of GrainTypeManager."); Instance = this; } }
internal IReminderService CreateReminderService(Silo silo, IGrainFactory grainFactory, TimeSpan iniTimeSpan, ISiloRuntimeClient runtimeClient) { var reminderServiceType = silo.GlobalConfig.ReminderServiceType; logger.Info("Creating reminder system target for type={0}", Enum.GetName(typeof(GlobalConfiguration.ReminderServiceProviderType), reminderServiceType)); ReminderTable.Initialize(silo, grainFactory, silo.GlobalConfig.ReminderTableAssembly); return new LocalReminderService( silo.SiloAddress, Constants.ReminderServiceId, silo.RingProvider, silo.LocalScheduler, ReminderTable.Singleton, silo.GlobalConfig, iniTimeSpan); }
public GrainRuntime( GlobalConfiguration globalConfig, ILocalSiloDetails localSiloDetails, IGrainFactory grainFactory, ITimerRegistry timerRegistry, IReminderRegistry reminderRegistry, IStreamProviderManager streamProviderManager, IServiceProvider serviceProvider, IRuntimeClient runtimeClient) { this.runtimeClient = runtimeClient; ServiceId = globalConfig.ServiceId; SiloIdentity = localSiloDetails.SiloAddress.ToLongString(); GrainFactory = grainFactory; TimerRegistry = timerRegistry; ReminderRegistry = reminderRegistry; StreamProviderManager = streamProviderManager; ServiceProvider = serviceProvider; }
internal static Task CallNext(IGrainFactory grainFactory, List<Tuple<long, bool>> callChain, int currCallIndex) { if (currCallIndex >= callChain.Count) return TaskDone.Done; Tuple<long, bool> next = callChain[currCallIndex]; bool call_1 = (currCallIndex % 2) == 1; // odd (1) call 1, even (zero) - call 2. if (next.Item2) { IDeadlockNonReentrantGrain nextGrain = grainFactory.GetGrain<IDeadlockNonReentrantGrain>(next.Item1); if (call_1) return nextGrain.CallNext_1(callChain, currCallIndex + 1); else return nextGrain.CallNext_2(callChain, currCallIndex + 1); } else { IDeadlockReentrantGrain nextGrain = grainFactory.GetGrain<IDeadlockReentrantGrain>(next.Item1); if (call_1) return nextGrain.CallNext_1(callChain, currCallIndex + 1); else return nextGrain.CallNext_2(callChain, currCallIndex + 1); } }
public static IHubProxy GetHubProxy(this IGrainFactory grainFactory, IStreamProvider streamProvider, string hubName, Guid allStreamKey) { return(new HubProxy(grainFactory, streamProvider, hubName, allStreamKey)); }
protected TocGoldenPathTestRunner(IGrainFactory grainFactory, ITestOutputHelper output) : base(grainFactory, output) { }
/// <summary> /// Provides an ISagaBuilder which can be used to prepare and execute a saga. /// </summary> /// <param name="that"></param> /// <returns></returns> public static ISagaBuilder CreateSaga(this IGrainFactory that) { return(new SagaBuilder(that)); }
public ImplicitSubscritionRecoverableStreamTestRunner(IGrainFactory grainFactory, string streamProviderName) { this.grainFactory = grainFactory; this.streamProviderName = streamProviderName; }
public GrainCommandMiddleware(IGrainFactory grainFactory) { Guard.NotNull(grainFactory, nameof(grainFactory)); this.grainFactory = grainFactory; }
public StartEventConsumers(IGrainFactory grainFactory) { eventConsumerManager = grainFactory.GetGrain <IEventConsumerManagerGrain>(SingleGrain.Id); }
/// <summary> /// Grain implementers do NOT have to expose this constructor but can choose to do so. /// This constructor is particularly useful for unit testing where test code can create a Grain and replace /// the IGrainIdentity and IGrainRuntime with test doubles (mocks/stubs). /// </summary> /// <param name="identity"></param> /// <param name="runtime"></param> protected Grain(IGrainIdentity identity, IGrainRuntime runtime) { Identity = identity; Runtime = runtime; GrainFactory = runtime.GrainFactory; }
public async override Task <SetName_Res> Run(long userid, SetName_Req requst, IGrainFactory grainfactory) { var meg = grainfactory.GetGrain <IMainEntry>(0); var icr = await meg.GetIChatRoom(); var ichatuser = await icr.GetChatUser(userid); if (ichatuser == null) { return(null); } await ichatuser.SetName(requst.Name); return(new SetName_Res() { Result = 1 }); }
public EventConsumersController(ICommandBus commandBus, IGrainFactory grainFactory) : base(commandBus) { this.grainFactory = grainFactory; }
public InMemoryLeaseProvider(IGrainFactory grainFactory) { this.leaseProvider = grainFactory.GetGrain <IDevelopmentLeaseProviderGrain>(0); }
public Bootstrap(IGrainFactory grainFactory) { Guard.NotNull(grainFactory, nameof(grainFactory)); this.grainFactory = grainFactory; }
public RulesIndex(IGrainFactory grainFactory) { Guard.NotNull(grainFactory, nameof(grainFactory)); this.grainFactory = grainFactory; }
/// <summary> /// Returns a saga instance. /// </summary> /// <param name="that"></param> /// <param name="id">The id of the saga, provider by the ISagaBuilder.</param> /// <returns></returns> public static ISagaGrain GetSaga(this IGrainFactory that, Guid id) { return(that.GetGrain <ISagaGrain>(id)); }
public GrainBasedPubSubRuntime(IGrainFactory grainFactory) { this.grainFactory = grainFactory; }
public TransactionalStateFactory(IGrainActivationContext context, ITypeResolver typeResolver, IGrainFactory grainFactory) { this.context = context; this.serializerSettings = GetJsonSerializerSettings(typeResolver, grainFactory); }
public StorageProviderManager(IGrainFactory grainFactory, IServiceProvider serviceProvider) { GrainFactory = grainFactory; ServiceProvider = serviceProvider; }
public static JsonSerializerSettings GetJsonSerializerSettings(ITypeResolver typeResolver, IGrainFactory grainFactory) { var serializerSettings = OrleansJsonSerializer.GetDefaultSerializerSettings(typeResolver, grainFactory); serializerSettings.PreserveReferencesHandling = PreserveReferencesHandling.None; return(serializerSettings); }
public static T Get <T>(this IGrainFactory factory, IGrainWithGuidKey grain) where T : IComponent { return(factory.GetGrain <T>(grain.GetPrimaryKey())); }
public StorageHealthCheck(IGrainFactory client) { this.client = client; }
public StorageProviderManager(IGrainFactory grainFactory, IServiceProvider serviceProvider, IProviderRuntime providerRuntime) { this.providerRuntime = providerRuntime; GrainFactory = grainFactory; ServiceProvider = serviceProvider; }
public OrleansHealthCheck(IGrainFactory grainFactory) { Guard.NotNull(grainFactory, nameof(grainFactory)); managementGrain = grainFactory.GetGrain <IManagementGrain>(0); }
/// <summary> /// Initializes a new instance of the <see cref="GrainReferenceCodec"/> class. /// </summary> /// <param name="grainFactory">The grain factory.</param> /// <param name="surrogateSerializer">The serializer for the surrogate type used by this class.</param> public GrainReferenceCodec(IGrainFactory grainFactory, IValueSerializer <GrainReferenceSurrogate> surrogateSerializer) : base(surrogateSerializer) { _grainFactory = grainFactory; }
public static void SetErrorInjection(string providerName, ErrorInjectionBehavior errorInjectionBehavior, IGrainFactory grainFactory) { IManagementGrain mgmtGrain = grainFactory.GetGrain <IManagementGrain>(0); mgmtGrain.SendControlCommandToProvider( typeof(ErrorInjectionStorageProvider).FullName, providerName, (int)Commands.SetErrorInjection, errorInjectionBehavior) .Wait(); }
protected override async Task <BlockState> ConvertToBlock(IEntity entity, IGrainFactory grainFactory, IWorld world, BlockWorldPos position, Slot slot) { var facing = ChestBlockHandler.PlayerYawToFacing(await entity.GetYaw()); return(BlockStates.Furnace(facing)); }
/// <summary> /// This is the lock free version of uninitilize so we can share /// it between the public method and error paths inside initialize. /// This should only be called inside a lock(initLock) block. /// </summary> private static void InternalUninitialize() { // Update this first so IsInitialized immediately begins returning // false. Since this method should be protected externally by // a lock(initLock) we should be able to reset everything else // before the next init attempt. isFullyInitialized = false; LimitManager.UnInitialize(); if (RuntimeClient.Current != null) { try { RuntimeClient.Current.Reset(); } catch (Exception) { } RuntimeClient.Current = null; try { ClientProviderRuntime.UninitializeSingleton(); } catch (Exception) { } } outsideRuntimeClient = null; grainFactory = null; }
protected ScopedTransactionsTestRunner(IGrainFactory grainFactory, ITransactionClient transactionClient, Action <string> output) : base(grainFactory, output) { _transactionClient = transactionClient; }
protected GoldenPathTransactionTestRunner(IGrainFactory grainFactory, ITestOutputHelper output) : base(grainFactory, output) { }
/// <summary> /// Initializes client runtime from client configuration object. /// </summary> private static void DoInternalInitialize(ClientConfiguration config, OutsideRuntimeClient runtimeClient = null) { if (IsInitialized) return; lock (initLock) { if (!IsInitialized) { try { // this is probably overkill, but this ensures isFullyInitialized false // before we make a call that makes RuntimeClient.Current not null isFullyInitialized = false; grainFactory = new GrainFactory(); ClientProviderRuntime.InitializeSingleton(grainFactory); if (runtimeClient == null) { runtimeClient = new OutsideRuntimeClient(config, grainFactory); } outsideRuntimeClient = runtimeClient; // Keep reference, to avoid GC problems outsideRuntimeClient.Start(); LimitManager.Initialize(config); // this needs to be the last successful step inside the lock so // IsInitialized doesn't return true until we're fully initialized isFullyInitialized = true; } catch (Exception exc) { // just make sure to fully Uninitialize what we managed to partially initialize, so we don't end up in inconsistent state and can later on re-initialize. Console.WriteLine("Initialization failed. {0}", exc); InternalUninitialize(); throw; } } } }
public static IUserGrain GetUserGrain(this IGrainFactory grainFactory, string userId, string hubName) { return(grainFactory.GetGrain <IUserGrain>(userId.ToGrainHubKey(hubName, UserHubScopeName))); }
public CartController( IGrainFactory grainFactory) { _grainFactory = grainFactory; }
/// <summary> /// Constructor /// </summary> /// <param name="stateStorageFactory">factory to create ITransactionalStateStorage, the test runner are assuming the state /// in storage is empty when ITransactionalStateStorage was created </param> /// <param name="stateFactory">factory to create TState for test</param> /// <param name="grainFactory">grain Factory needed for test runner</param> /// <param name="testOutput">test output to helpful messages</param> public TransactionalStateStorageTestRunnerxUnit(Func <Task <ITransactionalStateStorage <TState> > > stateStorageFactory, Func <TState> stateFactory, IGrainFactory grainFactory, ITestOutputHelper testOutput) : base(stateStorageFactory, stateFactory, grainFactory, testOutput.WriteLine) { }
public OutsideRuntimeClient(ClientConfiguration cfg, IGrainFactory grainFactory, bool secondary = false) { this.grainFactory = grainFactory; this.clientId = GrainId.NewClientId(); if (cfg == null) { Console.WriteLine("An attempt to create an OutsideRuntimeClient with null ClientConfiguration object."); throw new ArgumentException("OutsideRuntimeClient was attempted to be created with null ClientConfiguration object.", "cfg"); } this.config = cfg; if (!TraceLogger.IsInitialized) TraceLogger.Initialize(config); StatisticsCollector.Initialize(config); SerializationManager.Initialize(config.UseStandardSerializer); logger = TraceLogger.GetLogger("OutsideRuntimeClient", TraceLogger.LoggerType.Runtime); appLogger = TraceLogger.GetLogger("Application", TraceLogger.LoggerType.Application); try { LoadAdditionalAssemblies(); PlacementStrategy.Initialize(); callbacks = new ConcurrentDictionary<CorrelationId, CallbackData>(); localObjects = new ConcurrentDictionary<GuidId, LocalObjectData>(); CallbackData.Config = config; if (!secondary) { UnobservedExceptionsHandlerClass.SetUnobservedExceptionHandler(UnhandledException); } // Ensure SerializationManager static constructor is called before AssemblyLoad event is invoked SerializationManager.GetDeserializer(typeof(String)); // Ensure that any assemblies that get loaded in the future get recorded AppDomain.CurrentDomain.AssemblyLoad += NewAssemblyHandler; // Load serialization info for currently-loaded assemblies foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { if (!assembly.ReflectionOnly) { SerializationManager.FindSerializationInfo(assembly); } } statisticsProviderManager = new StatisticsProviderManager("Statistics", ClientProviderRuntime.Instance); var statsProviderName = statisticsProviderManager.LoadProvider(config.ProviderConfigurations) .WaitForResultWithThrow(initTimeout); if (statsProviderName != null) { config.StatisticsProviderName = statsProviderName; } responseTimeout = Debugger.IsAttached ? Constants.DEFAULT_RESPONSE_TIMEOUT : config.ResponseTimeout; BufferPool.InitGlobalBufferPool(config); var localAddress = ClusterConfiguration.GetLocalIPAddress(config.PreferredFamily, config.NetInterface); // Client init / sign-on message logger.Info(ErrorCode.ClientInitializing, string.Format( "{0} Initializing OutsideRuntimeClient on {1} at {2} Client Id = {3} {0}", BARS, config.DNSHostName, localAddress, clientId)); string startMsg = string.Format("{0} Starting OutsideRuntimeClient with runtime Version='{1}'", BARS, RuntimeVersion.Current); startMsg = string.Format("{0} Config= " + Environment.NewLine + " {1}", startMsg, config); logger.Info(ErrorCode.ClientStarting, startMsg); if (TestOnlyThrowExceptionDuringInit) { throw new ApplicationException("TestOnlyThrowExceptionDuringInit"); } config.CheckGatewayProviderSettings(); var generation = -SiloAddress.AllocateNewGeneration(); // Client generations are negative var gatewayListProvider = GatewayProviderFactory.CreateGatewayListProvider(config) .WithTimeout(initTimeout).Result; transport = new ProxiedMessageCenter(config, localAddress, generation, clientId, gatewayListProvider); if (StatisticsCollector.CollectThreadTimeTrackingStats) { incomingMessagesThreadTimeTracking = new ThreadTrackingStatistic("ClientReceiver"); } } catch (Exception exc) { if (logger != null) logger.Error(ErrorCode.Runtime_Error_100319, "OutsideRuntimeClient constructor failed.", exc); ConstructorReset(); throw; } }
public static T Get <T>(this IGrainFactory factory, Guid entityId) where T : IComponent { return(factory.GetGrain <T>(entityId)); }
public StorageProviderManager(IGrainFactory grainFactory) { GrainFactory = grainFactory; }
public static T Get <T>(this IGrainFactory factory, IEntity entity) where T : IComponent { return(factory.GetGrain <T>(entity.GetPrimaryKey())); }
public CounterDeleter(IGrainFactory grainFactory) { this.grainFactory = grainFactory; }
public override async Task UseBy(IEntity entity, IGrainFactory grainFactory, IWorld world, BlockWorldPos blockPosition, Vector3 cursorPosition) { var blockEntity = (await world.GetBlockEntity(grainFactory, blockPosition)).Cast <IFurnaceBlockEntity>(); await blockEntity.Tell(new UseBy { Entity = entity }); }
public void InitializeClient() { WriteLog("Initializing Grain Client"); ClientConfiguration clientConfig = this.ClientConfiguration; if (Debugger.IsAttached) { // Test is running inside debugger - Make timeout ~= infinite clientConfig.ResponseTimeout = TimeSpan.FromMilliseconds(1000000); } GrainClient.Initialize(clientConfig); GrainFactory = GrainClient.GrainFactory; }
protected DisabledTransactionsTestRunner(IGrainFactory grainFactory, ITestOutputHelper output) : base(grainFactory, output) { }