/*private void resolveOper(String compId) {
         *
         *      ArchComponent archComponent = HPCStormObjectRepository
         *                      .getWorkflowEngine().getArchComponentByID(
         *                                      Integer.parseInt(compId));
         *      System.out.println("invoke resolve=> archComponent: ["+archComponent.getId()+"]" + archComponent.getName());
         *
         * }*/

        private void computeOper(String compId, string portId, string actionId)
        {
            /*ArchAction archAction = HPCStormObjectRepository.getWorkflowEngine()
             *              .getArchActionId(Integer.parseInt(actionId));
             * System.out.println("invoke compute=> archAction: ["+archAction.getId()+"]" + archAction.getName());
             *
             */string handle_fake = "handle perform " + compId + " " + portId + " " + actionId;

            CertifierConsoleLogger.write("perform compute => " + "CompID " + compId + " portId " + portId + " actId " + actionId);
            LogicActionCompute l;

            //	if(!Certifier.ComputeActions.ContainsKey(handle_fake)){
            //if (compId.Equals("79")){ // call alt-ergo
            l = new LogicActionCompute(compId, portId, actionId, handle_fake);
            //	else{// call z3

            //		l =  new LogicActionCompute(compId, actionId, Certifier.tacticalCommand2);
            //		}


            Certifier.ComputeActions.TryAdd(handle_fake, l);

            /*	}else{
             *              l= (LogicActionCompute)Certifier.ComputeActions[compId];
             *
             *      }
             *
             */
            l.run();
        }
Beispiel #2
0
        public override int logic(CertifierOrchestrationElement element)
        {
            CertifierConsoleLogger.write("CONTINUE OPERATION");
            return(CertifierConstants.CONTINUE_SIGNAL);

            //Certifier.BreakIterate = true;
        }
        private CerificationResult perform_certify(string orchestration)
        {
            CertifierOrchestrationParser parser = new CertifierOrchestrationParser();

            //parser.readOrchestrationXML(CertifierConstants.ORCHESTRATION_FILE_TEST);
            parser.readOrchestrationXML(Orchestration);
            CertifierConsoleLogger.write(parser.getOrchestration().toString());

            variables.Add("formal_properties", formal_properties);


            parser.getOrchestration().run();             //


            Console.WriteLine("iterating remaining start threads");
            foreach (KeyValuePair <String, LogicActionInstantiate> entry in InstantiateActions)
            {
                if (entry.Value._thread != null)
                {
                    entry.Value._thread.Join();
                }
            }
            foreach (KeyValuePair <String, LogicActionCompute> entry in ComputeActions)
            {
                if (entry.Value._thread != null)
                {
                    entry.Value._thread.Join();
                }
            }

            throw new Exception("TODO perform_certify");
        }
Beispiel #4
0
        /*private void resolveOper(String compId) {
         *
         *      ArchComponent archComponent = HPCStormObjectRepository
         *                      .getWorkflowEngine().getArchComponentByID(
         *                                      Integer.parseInt(compId));
         *      System.out.println("wait resolve=> archComponent: ["+archComponent.getId()+"]" + archComponent.getName());
         *
         * }*/

        private void computeOper(String handle_id)
        {
            /*ArchAction archAction = HPCStormObjectRepository.getWorkflowEngine()
             *              .getArchActionId(Integer.parseInt(actionId));
             * System.out.println("wait compute=> archAction: ["+archAction.getId()+"]" + archAction.getName());
             */
            CertifierConsoleLogger.write("wait compute => " + "handleId " + handle_id);
            LogicActionCompute l = null;

            if (!Certifier.ComputeActions.ContainsKey(handle_id))
            {
                CertifierConsoleLogger.write("Fatal Error: Waiting for inexistent handleid. handle_id: " + handle_id);
                System.Environment.Exit(0);
            }
            else
            {
                l = (LogicActionCompute)Certifier.ComputeActions[handle_id];
            }



            l._thread.Join();


            //System.out.println("ACTION! " + "prove "+ actionId);
        }
        private void instatiateOper(String compId)
        {
            /*ArchComponent archComponent = HPCStormObjectRepository
             *              .getWorkflowEngine().getArchComponentByID(
             *                              Integer.parseInt(compId));
             * System.out.println("invoke instantiate=> archComponent: ["+archComponent.getId()+"]" + archComponent.getName());*/
            CertifierConsoleLogger.write("perform instantiate => " + "CompID " + compId);

            string handle_fake = "handle perform " + compId;
            LogicActionInstantiate l;

            //	if(!Certifier.InstantiateActions.ContainsKey(handle_fake)){
            l = new LogicActionInstantiate(compId, handle_fake);

            Certifier.InstantiateActions.TryAdd(handle_fake, l);

            /*	}else{
             *
             *              l= (LogicActionInstantiate)Certifier.InstantiateActions[compId];
             *              //l =  new LogicActionInstantiate(compId, Certifier.tacticalCommand);
             *      }*/


            l.run();
        }
Beispiel #6
0
        private void instantiateOper(String handle_id)
        {
            /*ArchComponent archComponent = HPCStormObjectRepository
             *              .getWorkflowEngine().getArchComponentByID(
             *                              Integer.parseInt(compId));
             * System.out.println("wait instantiate=> archComponent: ["+archComponent.getId()+"]" + archComponent.getName());
             */
            CertifierConsoleLogger.write("wait instantiate => " + "HandleID" + handle_id);

            LogicActionInstantiate l = null;

            if (!Certifier.InstantiateActions.ContainsKey(handle_id))
            {
                CertifierConsoleLogger.write("Fatal Error: Waiting for inexistent handleID. handle_id: " + handle_id);
                System.Environment.Exit(0);
            }
            else
            {
                l = (LogicActionInstantiate)Certifier.InstantiateActions[handle_id];
            }



            l._thread.Join();

            //System.out.println("ACTION! " + "instantiate "+ compId);
        }
Beispiel #7
0
        /*private void resolveOper(String compId){
         *
         *      ArchComponent archComponent = HPCStormObjectRepository.getWorkflowEngine().getArchComponentByID(Integer.parseInt(compId));
         *      System.out.println("start resolve=> archComponent: ["+archComponent.getId()+"]" + archComponent.getName());
         *
         * }*/

        private void computeOper(String compId, string port_id, string action_id, string handle_id)
        {
            /*	ArchAction archAction = HPCStormObjectRepository.getWorkflowEngine().getArchActionId(Integer.parseInt(actionId));
             *      System.out.println("start compute=> archAction: ["+archAction.getId()+"]" + archAction.getName());
             */
            CertifierConsoleLogger.write("start compute => " + " CompID " + compId + " portid " + port_id + "actionId " + action_id);


            LogicActionCompute l;

            if (!Certifier.ComputeActions.ContainsKey(compId))
            {
                //if (compId.Equals("1")){// call alt-ergo
                l = new LogicActionCompute(compId, port_id, action_id, handle_id);
                //else{// call z3

                //			l =  new LogicActionCompute(compId, action_id, Certifier.tacticalCommand2);
                //	}


                Certifier.ComputeActions.TryAdd(compId, l);
            }
            else
            {
                l = (LogicActionCompute)Certifier.ComputeActions[compId];

                CertifierConsoleLogger.write("Action already exists. Waiting for it to finish in order to create a new one.");
                l._thread.Join();
                CertifierConsoleLogger.write("Previous action finished! Creating a new one.");


                //	if (compId.Equals("1")){ // call alt-ergo
                l = new LogicActionCompute(compId, port_id, action_id, handle_id);
                //		else{// call z3

                //			l =  new LogicActionCompute(compId, action_id, Certifier.tacticalCommand2);
                //		}

                Certifier.ComputeActions.TryUpdate(compId, l, Certifier.ComputeActions[compId]);
            }


            l.start();



            /*TacticInvoker ti = new TacticInvoker(Certifier.tacticalCommand);
             * Thread t = new Thread(ti);
             * t.start();*/
            /*try {
             *      t.Join();
             * } catch (InterruptedException e) {
             *      // TODO Auto-generated catch block
             *      e.printStackTrace();
             * }*/

            /*TacticInvoker t1 = new TacticInvoker(Certifier.tacticalCommand);
             * t1.start();*/
            //System.out.println("ACTION! " + "prove "+ actionId);
        }
Beispiel #8
0
 public override void run()
 {
     try {
         CertifierConsoleLogger.write("Instantiating component " + compId + " whose handleid informed is " + handleId);
     } catch (Exception e) {
         // TODO Auto-generated catch block
         CertifierConsoleLogger.write("Action was interrupted!" + e.Message);
         //e.printStackTrace();
     }
 }
        public override int logic(CertifierOrchestrationElement element)
        {
            int max = -1, ret = CertifierConstants.NORMAL_SIGNAL;

            if (typeof(RepeatOper).IsInstanceOfType(element.getElement()))
            {
                RepeatOper iterate_oper = (RepeatOper)element.getElement();
                // every children must run MAX
                max = iterate_oper.getMax();
            }



children:
            for (int i = 0; i < max; i++)
            {
                // inside children

                for (int j = element.getChildren().Count - 1; j >= 0; j--)
                {
                    CertifierOrchestrationElement child = element.getChildren()[j];

                    /*if(child.getOperation().Equals(CertifierOrchestrationOperation.BREAKOPER)){
                     *      break children;
                     * }else if(child.getOperation().Equals(CertifierOrchestrationOperation.CONTINUEOPER)){
                     *      continue children;
                     * }*/
                    ret = child.run();
                    if (ret == CertifierConstants.BREAK_SIGNAL)
                    {
                        CertifierConsoleLogger.write("BREAK Operation was found. Breaking inner iterate.");
                        goto _break;
                    }
                    if (ret == CertifierConstants.CONTINUE_SIGNAL)
                    {
                        CertifierConsoleLogger.write("CONTINUE Operation was found. Going back to the beginning of iterate.");

                        goto children;
                    }

                    /*if( ret == CertifierConstants.RETURN_CERTIFIED_SIGNAL || ret == CertifierConstants.RETURN_NOT_CERTIFIED_SIGNAL){
                     *      CertifierConsoleLogger.write("RETURN Operation was found. Stopping certification process and returning.");
                     *
                     *      return ret;
                     *
                     *
                     * }*/
                }
            }


            _break : return(CertifierConstants.NORMAL_SIGNAL);
        }
Beispiel #10
0
        public override void start()
        {
            _thread = new Thread((ThreadStart) delegate()
            {
                try {
                    CertifierConsoleLogger.write("Instantiating by thread component " + compId + " whose handle informed is " + handleId);
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    CertifierConsoleLogger.write("Action by thread was interrupted!" + e.Message);
                    //e.printStackTrace();
                }
            });


            _thread.Start();
        }
Beispiel #11
0
        private void instantiateOper(String compId, string handle_id)
        {
            /*ArchComponent archComponent = HPCStormObjectRepository.getWorkflowEngine().getArchComponentByID(Integer.parseInt(compId));
             * System.out.println("start instantiate=> archComponent: ["+archComponent.getId()+"]" + archComponent.getName());
             */
            CertifierConsoleLogger.write("start instantiate => " + "CompID " + compId + " handleid informed " + handle_id);

            LogicActionInstantiate l;

            if (!Certifier.InstantiateActions.ContainsKey(handle_id))
            {
                //if (compId.Equals("1")){// call alt-ergo
                l = new LogicActionInstantiate(compId, handle_id);
                //else{// call z3

                //		l =  new LogicActionInstantiate(compId, Certifier.tacticalCommand2);
                //		}


                Certifier.InstantiateActions.TryAdd(handle_id, l);
            }
            else
            {
                l = (LogicActionInstantiate)Certifier.InstantiateActions[handle_id];

                CertifierConsoleLogger.write("HandleId already exists. Waiting for respective action to finish in order to create a new one.");
                l._thread.Join();
                CertifierConsoleLogger.write("Previous action finished! Creating a new one.");


                //			if (compId.Equals("1")){// call alt-ergo
                l = new LogicActionInstantiate(compId, handle_id);
                //				else{// call z3

                //					l =  new LogicActionInstantiate(compId, Certifier.tacticalCommand2);
                //				}

                Certifier.InstantiateActions.TryUpdate(handle_id, l, Certifier.InstantiateActions[handle_id]);
            }


            l.start();


            //System.out.println("ACTION! " + "instantiate "+ compId);
        }
        public override int logic(CertifierOrchestrationElement element)
        {
            ParallelJob[] threads = new ParallelJob[element.getChildren().Count];

            //creating threads
            for (int i = element.getChildren().Count - 1, j = 0; i >= 0; i--, j++)
            {
                CertifierOrchestrationElement child = element.getChildren()[i];
                ParallelJob pj = new ParallelJob(child);
                threads[j] = pj;
            }

            //starting threads
            CertifierConsoleLogger.write("STARTING PARALLEL TASK");
            foreach (ParallelJob job in threads)
            {
                job.run();
            }


            //join threads
            foreach (ParallelJob job in threads)
            {
                if (!hasBreakOrContinue)
                {
                    job._thread.Join();
                    ret = job.ret;
                    Console.WriteLine(" parallel job. return of job " + ret);
                    if (ret > CertifierConstants.NORMAL_SIGNAL)                     //== CertifierConstants.BREAK_SIGNAL || ret == CertifierConstants.CONTINUE_SIGNAL || ret == CertifierConstants.RETURN_CERTIFIED||ret == CertifierConstants.RETURN_NOT_CERTIFIED ){

                    {
                        hasBreakOrContinue = true;
                        //break;
                    }
                }
                else
                {
                    CertifierConsoleLogger.write("Signal found in parallel tasks: " + ret + ". Interrupting all the remaining threads.");
                    job._thread.Interrupt();
                }
            }
            CertifierConsoleLogger.write("ENDED PARALLEL TASK");

            return(ret);
        }
Beispiel #13
0
        public override int logic(CertifierOrchestrationElement element)
        {
            int ret = CertifierConstants.NORMAL_SIGNAL;

            CertifierConsoleLogger.write("STARTING SEQUENCE TASKS");

            for (int i = element.getChildren().Count - 1; i >= 0; i--)
            {
                CertifierOrchestrationElement child = element.getChildren()[i];
                ret = child.run();
                if (ret > CertifierConstants.NORMAL_SIGNAL)       /*=CertifierConstants.BREAK_SIGNAL ||
                                                                   * ret==CertifierConstants.CONTINUE_SIGNAL ||ret==CertifierConstants.RETURN_CERTIFIED ||ret==CertifierConstants.RETURN_NOT_CERTIFIED){
                                                                   */
                {
                    CertifierConsoleLogger.write("Signal found: " + ret + ". Stopping sequence execution.");
                    break;
                }
            }
            CertifierConsoleLogger.write("ENDED SEQUENCE TASKS");
            return(ret);
        }
        public int visit(CertifierOrchestrationElement element)
        {
            int ret = CertifierConstants.NORMAL_SIGNAL;

            CertifierConsoleLogger.write("Enter visit for " + element.getOperationStr());
            CertifierConsoleLogger.write("operation " + element.getOperation());
            //this.operation = (CertifierOrchestrationOperation)Enum.Parse(typeof(CertifierOrchestrationOperation), oper);

            //first case, the workflow element. Justo go on...
            if (element.getOperationStr() == "orchestration")
            {
                CertifierConsoleLogger.write("operation entrei " + element.getOperation());
                foreach (CertifierOrchestrationElement child in element.getChildren())
                {
                    /* if(child.run()==CertifierConstants.BREAK_SIGNAL)
                     *       hasBreak=true;*/
                    ret = child.run();
                }
            }
            else
            {
                //calling logic for this type of operation via reflection
                String logicFullClassName = this.logicPkg + ".Logic" + element.getOperationStr();
                Console.WriteLine("logicfullclassname " + logicFullClassName);
                //Type c = Type.GetType(logicFullClassName);

                /*Class c =
                 *              Class.forName(logicFullClassName);*/
                var c = Activator.CreateInstance(null, logicFullClassName);
                AbstractCertifierElementLogic logicClass = (AbstractCertifierElementLogic)c.Unwrap();

                //AbstractCertifierElementLogic logicClass = (AbstractCertifierElementLogic)Activator.CreateInstance(null, logicFullClassName);

                ret = logicClass.logic(element);
                CertifierConsoleLogger.write("Element " + element.getOperationStr() + " returned: " + ret);
            }

            //System.out.println("certif vis impl" + hasBreak);
            return(ret);
        }
        public override int logic(CertifierOrchestrationElement element)
        {
            int ret = CertifierConstants.NORMAL_SIGNAL;

            CertifierConsoleLogger.write("STARTING SELECT TASK");

            selectoperComplexType select_oper = (selectoperComplexType)element.getElement();
            String chosen = select_oper.chosen;

            for (int i = element.getChildren().Count - 1; i >= 0; i--)
            {
                CertifierOrchestrationElement select      = element.getChildren()[i];
                selectoperComplexTypeChoice   choice_oper = (selectoperComplexTypeChoice)select.getElement();
                String port_id   = choice_oper.port_id;
                String action_id = choice_oper.action_id;
                //navegar no select
                if (string.Equals(action_id, chosen, StringComparison.OrdinalIgnoreCase))
                {
                    foreach (CertifierOrchestrationElement child in select.getChildren())
                    {
                        ret = child.run();
                        if (ret > CertifierConstants.NORMAL_SIGNAL)                       /*=CertifierConstants.BREAK_SIGNAL ||
                                                                                           * ret==CertifierConstants.CONTINUE_SIGNAL ||ret==CertifierConstants.RETURN_CERTIFIED ||ret==CertifierConstants.RETURN_NOT_CERTIFIED){
                                                                                           */
                        {
                            CertifierConsoleLogger.write("Signal found: " + ret + ". Stopping sequence execution.");
                            break;
                        }
                    }
                }
            }


            CertifierConsoleLogger.write("ENDED SELECT TASK");



            return(ret);
        }
/*	private void resolveOper(String compId) {
 *
 *              ArchComponent archComponent = HPCStormObjectRepository
 *                              .getWorkflowEngine().getArchComponentByID(
 *                                              Integer.parseInt(compId));
 *              System.out.println("ACTION: " + archComponent);
 *
 *      }*/

        private void computeOper(String handle_id)
        {
            /*ArchAction archAction = HPCStormObjectRepository.getWorkflowEngine()
             *              .getArchActionId(Integer.parseInt(actionId));
             * System.out.println("ACTION: " + archAction);*/
            CertifierConsoleLogger.write("cancel compute " + "handle_id " + handle_id);


            LogicActionCompute l = null;

            if (!Certifier.ComputeActions.ContainsKey(handle_id))
            {
                CertifierConsoleLogger.write("Fatal Error: Cancelling inexistent handle_id: handle_id  " + handle_id);
                System.Environment.Exit(0);
            }
            else
            {
                l = (LogicActionCompute)Certifier.ComputeActions[handle_id];
            }


            l._thread.Interrupt();
        }
Beispiel #17
0
        public override int logic(CertifierOrchestrationElement element)
        {
            int ret = CertifierConstants.NORMAL_SIGNAL;

            CertifierConsoleLogger.write("STARTING SWITCH TASK");

            //ChoiceOperComplexType choice_oper = (ChoiceOperComplexType)element.getElement();


            for (int i = element.getChildren().Count - 1; i >= 0; i--)
            {
                CertifierOrchestrationElement select = element.getChildren()[i];
                //System.out.println("Size " + element.getChildren().Count);
                switchoperComplexTypeChoice choice_oper = (switchoperComplexTypeChoice)select.getElement();

                String condition = choice_oper.condition;
                CertifierConsoleLogger.write("Condition: " + condition);
                //navegar no select



                //Integer x = 0;
                //String teste = "x == 0";
                //Certifier.variablesTryAdd(x,x);

                // System.out.println(x.toString());
                condition.Replace("&lt;", "<");
                condition.Replace("&gt;", ">");
                condition.Replace("&quot;", "\"");
                condition.Replace("&amp;", "&");
                condition.Replace("&apos;", "\'");

                /*if (Certifier.formal_properties.get ("mProjExecMPI1", "no deadlock")) {
                 *
                 *      Console.WriteLine ("no deadlock true");
                 * }*/

                //reg.Add.RegisterType ("C4Impl", C4Impl);
                var p = new CompiledExpression(condition)
                {
                    TypeRegistry = Certifier.variables
                };
                //p.Parse();
                p.Compile();
                //Console.WriteLine("Result: {0}", p.Eval());

                CertifierConsoleLogger.write("Condition evaluated: " + p.Eval());



                //System.out.println(cond.booleanValue());
                //System.out.println("Proved vc percent: "  + Certifier.provedVCPercent);
                if ((bool)p.Eval())
                {
                    //if(true)){
                    CertifierOrchestrationElement child = select.getChildren()[0];

                    ret = child.run();
                    //System.out.println("select" + ret);

                    break;
                }
            }
            CertifierConsoleLogger.write("ENDED SWITCH TASK");



            return(ret);
        }