Exemplo n.º 1
0
 public async Task <Task> AddCustomDownStreamOperators(List <TopologyUnit> units)
 {
     foreach (var unit in units)
     {
         if (unit.OperatorType == OperatorType.Stateful)
         {
             var op = GrainFactory.GetGrain <IStatefulOperator>(unit.PrimaryKey, Constants.Stateful_Operator_Prefix);
             op.IncrementNumberOfUpStreamOperator();
             downStreamOperators.Add(op);
             operatorSettings.AddOpratorToDict(op.GetPrimaryKey(), await op.GetOperatorSettings());
             topologyManager.ConnectUnits(topologyUnit.PrimaryKey, op.GetPrimaryKey());
         }
         else if (unit.OperatorType == OperatorType.Stateless)
         {
             var op = GrainFactory.GetGrain <IStatelessOperator>(unit.PrimaryKey, Constants.Stateless_Operator_Prefix);
             downStreamOperators.Add(op);
             topologyManager.ConnectUnits(topologyUnit.PrimaryKey, op.GetPrimaryKey());
         }
         else
         {
             throw new ArgumentException("The down stream operor cannot be a source");
         }
     }
     topologyManager.UpdateOperatorSettings(topologyUnit.PrimaryKey, operatorSettings);
     testAddNewOperatorGuid = units[0].PrimaryKey;
     return(Task.CompletedTask);
 }
        public async Task <Task> InitRandomOperators()
        {
            IStatefulOperator operatorOne = GrainFactory.GetGrain <IStatefulOperator>(Guid.NewGuid());
            IStatefulOperator operatorTwo = GrainFactory.GetGrain <IStatefulOperator>(Guid.NewGuid());

            downStreamOperators.Add(operatorOne);
            operatorOne.IncrementNumberOfUpStreamOperator();
            downStreamOperators.Add(operatorTwo);
            operatorTwo.IncrementNumberOfUpStreamOperator();
            operatorSettings.AddOpratorToDict(operatorOne.GetPrimaryKey(), await operatorOne.GetOperatorSettings());
            operatorSettings.AddOpratorToDict(operatorTwo.GetPrimaryKey(), await operatorTwo.GetOperatorSettings());

            topologyManager.UpdateOperatorSettings(this.GetPrimaryKey(), operatorSettings);
            topologyManager.ConnectUnits(this.GetPrimaryKey(), operatorOne.GetPrimaryKey());
            topologyManager.ConnectUnits(this.GetPrimaryKey(), operatorTwo.GetPrimaryKey());

            return(Task.CompletedTask);
        }