Exemple #1
0
        public override void run()
        {
            int compid = Convert.ToInt32(compId);



            Console.WriteLine("Computing action " + action_id + " of port " + port_id + " of component " + compid
                              + " whose handleid informed is " + handleId);
            ITaskBindingKind v = (ITaskBindingKind)Certifier.services.getPort(port_id);


            //Certifier.verify_actions.TryGetValue(compid, out v);
            //v.invoke (IVerify.VERIFY_PERFORM);
            v.invoke(action_id);
            IActionFutureSet future_iteration = null;

            IActionFuture future_conclusive = null;

            //v.invoke (IVerify.VERIFY_CONCLUSIVE, out future_conclusive);
            v.invoke("verify_conclusive", out future_conclusive);
            future_iteration = future_conclusive.createSet();

            IActionFuture future_inconclusive = null;

            //v.invoke (IVerify.VERIFY_INCONCLUSIVE, out future_inconclusive);
            v.invoke("verify_inconclusive", out future_inconclusive);
            future_iteration.addAction(future_inconclusive);

            IActionFuture r = future_iteration.waitAny();

            result = r == future_conclusive ? CerificationResult.Conclusive : CerificationResult.Inconclusive;
        }
        public override void main()
        {
            Console.WriteLine(this.ThisFacetInstance + "/" + this.Rank + ": WORKFLOW 1");

            Task_binding_data.TraceFlag = Task_gusty0.TraceFlag = Task_gusty1.TraceFlag = Task_binding_step1.TraceFlag = Task_binding_split_first.TraceFlag = Task_binding_split_next.TraceFlag = true;
            Task_binding_data.TraceFlag = Task_binding_step1.TraceFlag = Task_binding_split_first.TraceFlag = Task_binding_split_next.TraceFlag = true;

            IActionFutureSet future_iteration = null;

            Console.WriteLine(this.ThisFacetInstance + "/" + this.Rank + ": WORKFLOW 2-1");

            IActionFuture future_split_first_chunk_ready = null;

            Task_binding_split_first.invoke(ITaskPortAdvance.CHUNK_READY, out future_split_first_chunk_ready);
            int action_id_split_first_chunk_ready = future_split_first_chunk_ready.GetHashCode();

            future_iteration = future_split_first_chunk_ready.createSet();

            Console.WriteLine(this.ThisFacetInstance + "/" + this.Rank + ": WORKFLOW 2-2");

            IActionFuture future_split_next_chunk_ready = null;

            Task_binding_split_next.invoke(ITaskPortAdvance.CHUNK_READY, out future_split_next_chunk_ready);
            int action_id_split_next_chunk_ready = future_split_next_chunk_ready.GetHashCode();

            future_iteration.addAction(future_split_next_chunk_ready);

            Console.WriteLine(this.ThisFacetInstance + "/" + this.Rank + ": WORKFLOW 3");

            IActionFuture future_gusty0_chunk_ready = null;

            Task_gusty0.invoke(ITaskPortAdvance.CHUNK_READY, out future_gusty0_chunk_ready);
            int action_id_gusty0_chunk_ready = future_gusty0_chunk_ready.GetHashCode();

            future_iteration.addAction(future_gusty0_chunk_ready);

            Console.WriteLine(this.ThisFacetInstance + "/" + this.Rank + ": WORKFLOW 4");

            IActionFuture future_step1_chunk_ready = null;

            Task_binding_step1.invoke(ITaskPortAdvance.CHUNK_READY, out future_step1_chunk_ready);
            int action_id_step1_chunk_ready = future_step1_chunk_ready.GetHashCode();

            future_iteration.addAction(future_step1_chunk_ready);

            Console.WriteLine(this.ThisFacetInstance + "/" + this.Rank + ": WORKFLOW 4");

            IActionFuture future_gusty1_chunk_ready = null;

            Task_gusty1.invoke(ITaskPortAdvance.CHUNK_READY, out future_gusty1_chunk_ready);
            int action_id_gusty1_chunk_ready = future_gusty1_chunk_ready.GetHashCode();

            future_iteration.addAction(future_gusty1_chunk_ready);

            Console.WriteLine(this.ThisFacetInstance + "/" + this.Rank + ": WORKFLOW 5");

            IActionFuture future_data_terminate = null;

            Task_binding_data.invoke(ITaskPortData.TERMINATE, out future_data_terminate);
            future_iteration.addAction(future_data_terminate);
            int action_id_data_terminate = future_data_terminate.GetHashCode();

            Console.WriteLine(this.ThisFacetInstance + "/" + this.Rank + ": WORKFLOW 6-1");

            Task_binding_data.invoke(ITaskPortData.READ_SOURCE);

            Console.WriteLine(this.ThisFacetInstance + "/" + this.Rank + ": WORKFLOW 6-2");

            Task_binding_split_first.invoke(ITaskPortAdvance.READ_CHUNK);
            Task_binding_split_first.invoke(ITaskPortAdvance.PERFORM);

            Console.WriteLine(this.ThisFacetInstance + "/" + this.Rank + ": WORKFLOW 7");

            IList <Thread> bag_of_tasks = new List <Thread> ();


            bool terminate = false;

            do
            {
                Console.WriteLine(this.ThisFacetInstance + "/" + this.Rank + ": WORKFLOW 8 - LOOP");

                IActionFuture action = future_iteration.waitAny();

                int action_id = action.GetHashCode();
                if (action_id == action_id_split_first_chunk_ready)
                {
                    Thread t1 = new Thread((ThreadStart) delegate()
                    {
                        Console.WriteLine("INVOKE GUSTY0 READ_CHUNK - BEFORE");
                        Task_gusty0.invoke(ITaskPortAdvance.READ_CHUNK);
                        Console.WriteLine("INVOKE GUSTY0 READ_CHUNK - AFTER");
                        IActionFuture future_gusty0_perform = null;
                        Thread thread_gusty0_perform        = Task_gusty0.invoke(ITaskPortAdvance.PERFORM, gusty0_perform, out future_gusty0_perform);

                        Console.WriteLine("END INVOKE SPLITTER CHUNK_READY");
                    });

                    bag_of_tasks.Add(t1);
                    t1.Start();

                    Thread t2 = new Thread((ThreadStart) delegate()
                    {
                        Console.WriteLine("INVOKE SPLITTER READ_CHUNK");
                        Task_binding_split_first.invoke(ITaskPortAdvance.READ_CHUNK);
                        Console.WriteLine("INVOKE SPLITTER PERFORM");
                        Task_binding_split_first.invoke(ITaskPortAdvance.PERFORM);
                        Console.WriteLine("INVOKE SPLITTER READ_CHUNK/PERFORM - AFTER");
                        IActionFuture future_split_chunk_ready_ = null;
                        Task_binding_split_first.invoke(ITaskPortAdvance.CHUNK_READY, out future_split_chunk_ready_);
                        action_id_split_first_chunk_ready = future_split_chunk_ready_.GetHashCode();
                        future_iteration.addAction(future_split_chunk_ready_);
                    });

                    Console.WriteLine("THREAD LAUNCHED 1");

                    bag_of_tasks.Add(t2);
                    t2.Start();
                }
                else if (action_id == action_id_gusty0_chunk_ready)
                {
                    Task_gusty0.invoke(ITaskPortAdvance.CHUNK_READY, out future_gusty0_chunk_ready);
                    action_id_gusty0_chunk_ready = future_gusty0_chunk_ready.GetHashCode();
                    future_iteration.addAction(future_gusty0_chunk_ready);

                    Thread t = new Thread((ThreadStart) delegate()
                    {
                        Console.WriteLine("INVOKE STEP1 READ_CHUNK - BEFORE");                                   // 110 executados (o 48 completou nos pares, mas não progrediu aqui (????), motivo do erro.
                        Task_binding_step1.invoke(ITaskPortAdvance.READ_CHUNK);                                  //
                        Console.WriteLine("INVOKE STEP1 READ_CHUNK - AFTER");                                    // 47 completados
                        IActionFuture future_step1_perform = null;
                        Thread thread_step1_perform        = Task_binding_step1.invoke(ITaskPortAdvance.PERFORM, step1_perform, out future_step1_perform);

                        Console.WriteLine("END INVOKE GUSTY0 CHUNK_READY");
                    });
                    t.Start();
                    bag_of_tasks.Add(t);
                    Console.WriteLine("THREAD LAUNCHED 2");
                }
                else if (action_id == action_id_step1_chunk_ready)
                {
                    Task_binding_step1.invoke(ITaskPortAdvance.CHUNK_READY, out future_step1_chunk_ready);
                    action_id_step1_chunk_ready = future_step1_chunk_ready.GetHashCode();
                    future_iteration.addAction(future_step1_chunk_ready);

                    Thread t = new Thread((ThreadStart) delegate()
                    {
                        Console.WriteLine("INVOKE GUSTY1 READ_CHUNK - BEFORE");
                        Task_gusty1.invoke(ITaskPortAdvance.READ_CHUNK);                                  // ****
                        Console.WriteLine("INVOKE GUSTY1 READ_CHUNK - AFTER");
                        IActionFuture future_gusty1_perform = null;
                        Thread thread_gusty1_perform        = Task_gusty1.invoke(ITaskPortAdvance.PERFORM, gusty1_perform, out future_gusty1_perform);

                        Console.WriteLine("END INVOKE STEP1 CHUNK_READY");
                    });
                    t.Start();
                    bag_of_tasks.Add(t);
                    Console.WriteLine("THREAD LAUNCHED 3");
                }
                else if (action_id == action_id_gusty1_chunk_ready)
                {
                    Task_gusty1.invoke(ITaskPortAdvance.CHUNK_READY, out future_gusty1_chunk_ready);
                    action_id_gusty1_chunk_ready = future_gusty1_chunk_ready.GetHashCode();
                    future_iteration.addAction(future_gusty1_chunk_ready);

                    Thread t = new Thread((ThreadStart) delegate()
                    {
                        Console.WriteLine("INVOKE SPLITTER NEXT READ_CHUNK - BEFORE");
                        Task_binding_split_next.invoke(ITaskPortAdvance.READ_CHUNK);                                   // ****
                        Console.WriteLine("INVOKE SPLITTER NEXT READ_CHUNK - AFTER");
                        IActionFuture future_split_perform = null;
                        Thread thread_split_perform        = Task_binding_split_next.invoke(ITaskPortAdvance.PERFORM, split_perform, out future_split_perform);

                        Console.WriteLine("END INVOKE GUSTY1 CHUNK_READY");
                    });
                    t.Start();
                    bag_of_tasks.Add(t);
                    Console.WriteLine("THREAD LAUNCHED 4");
                }
                else if (action_id == action_id_split_next_chunk_ready)
                {
                    Thread t1 = new Thread((ThreadStart) delegate()
                    {
                        Console.WriteLine("INVOKE GUSTY0 READ_CHUNK NEXT - BEFORE");
                        Task_gusty0.invoke(ITaskPortAdvance.READ_CHUNK);                                    //
                        Console.WriteLine("INVOKE GUSTY0 READ_CHUNK NEXT - AFTER");
                        IActionFuture future_gusty0_perform = null;
                        Thread thread_gusty0_perform        = Task_gusty0.invoke(ITaskPortAdvance.PERFORM, gusty0_perform, out future_gusty0_perform);

                        Console.WriteLine("END INVOKE SPLIT NEXT CHUNK_READY");
                    });

                    bag_of_tasks.Add(t1);
                    t1.Start();

                    Thread t2 = new Thread((ThreadStart) delegate()
                    {
                        Console.WriteLine("INVOKE SPLITTER NEXT READ_CHUNK");
                        Task_binding_split_next.invoke(ITaskPortAdvance.READ_CHUNK);
                        Console.WriteLine("INVOKE SPLITTER NEXT PERFORM");
                        Task_binding_split_next.invoke(ITaskPortAdvance.PERFORM);
                        Console.WriteLine("INVOKE SPLITTER NEXT READ_CHUNK/PERFORM - AFTER");

                        IActionFuture future_split_next_chunk_ready_ = null;
                        Task_binding_split_next.invoke(ITaskPortAdvance.CHUNK_READY, out future_split_next_chunk_ready_);
                        action_id_split_next_chunk_ready = future_split_next_chunk_ready_.GetHashCode();
                        future_iteration.addAction(future_split_next_chunk_ready_);
                    });

                    Console.WriteLine("THREAD LAUNCHED 1");

                    bag_of_tasks.Add(t2);
                    t2.Start();

                    Console.WriteLine("THREAD LAUNCHED 5");
                }
                else if (action_id == action_id_data_terminate)
                {
                    Thread t = new Thread((ThreadStart) delegate()
                    {
                        Console.WriteLine("INVOKE DATA WRITE_SINK - BEFORE");
                        Task_binding_data.invoke(ITaskPortData.WRITE_SINK);
                        Console.WriteLine("INVOKE DATA WRITE_SINK - AFTER");
                        terminate = true;
                    });
                    t.Start();
                    bag_of_tasks.Add(t);
                    Console.WriteLine("THREAD LAUNCHED 6");
                }
                else
                {
                    Console.WriteLine("UNEXPECTED ERROR: ACTION FUTURE NOT RECOGNIZED ! ");
                }
            } while (!terminate);

            Console.WriteLine("WORKFLOW FINISHED ! ");

            foreach (Thread t in bag_of_tasks)
            {
                t.Join();
            }
        }