public async Task <Task> Commit(StreamMessage msg) { List <TopologyUnit> units = topology.GetAllTopologyUnits(); PrettyConsole.Line("Number of units: " + units.Count); msg.barrierOrCommitInfo = new BarrierOrCommitMsgTrackingInfo(Guid.NewGuid(), units.Count); msg.barrierOrCommitInfo.BatchID = msg.BatchID; await batchTracker.TrackingCommitMessages(msg); foreach (TopologyUnit unit in units) { if (unit.OperatorType == OperatorType.Source) { IStreamSource source = GrainFactory.GetGrain <IStreamSource>(unit.PrimaryKey); source.Commit(msg); } else if (unit.OperatorType == OperatorType.Stateful) { IStatefulOperator statefulOperator = GrainFactory.GetGrain <IStatefulOperator>(unit.PrimaryKey, Constants.Stateful_Operator_Prefix); statefulOperator.Commit(msg); } else if (unit.OperatorType == OperatorType.Stateless) { IStatelessOperator statelessOperator = GrainFactory.GetGrain <IStatelessOperator>(unit.PrimaryKey, Constants.Stateless_Operator_Prefix); statelessOperator.Commit(msg); } else { throw new ArgumentException("Commit: The operator type is in valid!"); } } return(Task.CompletedTask); }