private static async Task StartDefaultTopology(IClusterClient client) { var source = client.GetGrain <IStreamSource>(joinedChannel); await source.InitDeaultOperators(); var coordinator = client.GetGrain <IBatchCoordinator>(Constants.Coordinator); await coordinator.StartBarrierTimer(); //var room2 = client.GetGrain<IStreamSource>("new"); var streamId = await source.Join(userName); //var streamId2 = await room2.Join(userName); var stream = client.GetStreamProvider(Constants.FaultTolerantStreamProvider) .GetStream <StreamMessage>(streamId, Constants.FaultTolerantStreamNameSpace); //subscribe to the stream to receiver furthur messages sent to the chatroom StatefulStreamObserver observer = new StatefulStreamObserver(client.ServiceProvider.GetService <ILoggerFactory>() .CreateLogger($"{joinedChannel} channel")); await stream.SubscribeAsync(observer); }
private static async Task TestCustomTopology(IClusterClient client) { var topologyManager = client.GetGrain <ITopology>(Constants.Topology_Manager); //Get and add source var sources = await topologyManager.GetRandomSources(1); var source = sources[0]; joinedChannel = source.GetPrimaryKey(); //Get and add stateless to sources var statelessOps = await topologyManager.GetRandomStatelessOperators(3); await topologyManager.AddCustomeOperatorsToSources(sources, statelessOps); //Get and Add stateful to stateless var statefulOps = await topologyManager.GetRandomStatefulOperators(2); await topologyManager.AddCustomeOperatorsToNonSourceOperators(statelessOps, statefulOps); PrettyConsole.Line("Stateless: " + statelessOps.Count + " StatefulOps: " + statefulOps.Count); //Start Timer var coordinator = client.GetGrain <IBatchCoordinator>(Constants.Coordinator); await coordinator.StartBarrierTimer(); await source.RegisterTimerForSources(); //Start Error Detector var detector = client.GetGrain <IErrorDetector>(Constants.Error_Detector); await detector.RegisterTimerToDetectFailures(); //var room2 = client.GetGrain<IStreamSource>("new"); var streamId = await source.Join(userName); //var streamId2 = await room2.Join(userName); var stream = client.GetStreamProvider(Constants.FaultTolerantStreamProvider) .GetStream <StreamMessage>(streamId, Constants.FaultTolerantStreamNameSpace); //subscribe to the stream to receiver furthur messages sent to the chatroom StatefulStreamObserver observer = new StatefulStreamObserver(client.ServiceProvider.GetService <ILoggerFactory>() .CreateLogger($"{joinedChannel} channel")); await stream.SubscribeAsync(observer); }