예제 #1
0
        public async Task <List <TexeraTuple> > DoClientWork(IClusterClient client, Guid workflowID, string plan)
        {
            RequestContext.Set("targetSilo", Constants.ClientIPAddress);
            var deployGrain     = client.GetGrain <IDeployGrain>(workflowID);
            var controllerGrain = await deployGrain.Init(workflowID, plan, false);

            var streamProvider = client.GetStreamProvider("SMSProvider");
            var so             = new StreamObserver();
            var stream         = streamProvider.GetStream <Immutable <PayloadMessage> >(controllerGrain.GetPrimaryKey(), "OutputStream");
            var handle         = await stream.SubscribeAsync(so);

            so.SetNumEndFlags(await controllerGrain.GetNumberOfOutputGrains());
            instance.IDToWorkflowEntry[workflowID] = controllerGrain;
            await so.Start();

            await controllerGrain.Start();

            while (!so.isFinished)
            {
            }
            await handle.UnsubscribeAsync();

            await controllerGrain.Deactivate();

            instance.IDToWorkflowEntry.Remove(workflowID);
            return(so.resultsToRet);
        }
예제 #2
0
        public async Task <List <TexeraTuple> > DoClientWork(IClusterClient client, Workflow workflow)
        {
            // code for testing the correctness of sequnece number:

            // IWorkerGrain grain=client.GetGrain<IWorkerGrain>(new Guid(),"2");
            // await grain.Init(grain,null,null);
            // List<ulong> seqnum=new List<ulong>{0,1,3,2,4,10,9,8,7,5,4,6};
            // foreach(ulong seq in seqnum)
            //     grain.ReceivePayloadMessage(new Immutable<PayloadMessage>(new PayloadMessage("123",seq,null,seq==10)));

            await workflow.Init(client);

            var streamProvider = client.GetStreamProvider("SMSProvider");
            var so             = new StreamObserver();
            var stream         = streamProvider.GetStream <Immutable <PayloadMessage> >(workflow.GetStreamGuid(), "OutputStream");
            await stream.SubscribeAsync(so);

            int numEndGrains = 0;

            foreach (Operator o in workflow.EndOperators)
            {
                numEndGrains += o.PrincipalGrain.GetOutputGrains().Result.Count;
            }
            so.SetNumEndFlags(numEndGrains);
            instance.IDToWorkflowEntry[workflow.WorkflowID] = workflow;
            await so.Start();

            foreach (Operator op in workflow.StartOperators)
            {
                await op.PrincipalGrain.Start();
            }

            while (!so.isFinished)
            {
            }
            instance.IDToWorkflowEntry.Remove(workflow.WorkflowID);
            return(so.resultsToRet);
        }