Package org.apache.airavata.gfac.context

Examples of org.apache.airavata.gfac.context.MessageContext


  public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException,GFacException {

      log.info("Invoking SCPInputHandler");


          MessageContext inputNew = new MessageContext();
          try {
              MessageContext input = jobExecutionContext.getInMessageContext();
              Set<String> parameters = input.getParameters().keySet();
              for (String paramName : parameters) {
                  ActualParameter actualParameter = (ActualParameter) input.getParameters().get(paramName);
                  String paramValue = MappingFactory.toString(actualParameter);
                  //TODO: Review this with type
                  if ("URI".equals(actualParameter.getType().getType().toString())) {
                      ((URIParameterType) actualParameter.getType()).setValue(stageInputFiles(jobExecutionContext, paramValue));
                  } else if ("URIArray".equals(actualParameter.getType().getType().toString())) {
View Full Code Here


    private boolean isWhirrBasedDeployment = false;
    private File hadoopConfigDir;

    public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
        MessageContext inMessageContext = jobExecutionContext.getInMessageContext();
        if(inMessageContext.getParameter("HADOOP_DEPLOYMENT_TYPE").equals("WHIRR")){
            isWhirrBasedDeployment = true;
        } else {
            String hadoopConfigDirPath = (String)inMessageContext.getParameter("HADOOP_CONFIG_DIR");
            File hadoopConfigDir = new File(hadoopConfigDirPath);
            if (!hadoopConfigDir.exists()){
                throw new GFacHandlerException("Specified hadoop configuration directory doesn't exist.");
            } else if (FileUtils.listFiles(hadoopConfigDir, null, null).size() <= 0){
                throw new GFacHandlerException("Cannot find any hadoop configuration files inside specified directory.");
View Full Code Here

            applicationContext.setServiceDescription(serviceDescription);

            jobExecutionContext.setApplicationContext(applicationContext);

            jobExecutionContext.setOutMessageContext(getOutParameters(serviceDescription));
            jobExecutionContext.setInMessageContext(new MessageContext(actualParameters));

            GFacAPI gfacAPI1 = new GFacAPI();
            gfacAPI1.submitJob(jobExecutionContext);

            OMFactory fac = OMAbstractFactory.getOMFactory();
            OMNamespace omNs = fac.createOMNamespace("http://ws.apache.org/axis2/xsd", "ns1");
            OMElement outputElement = fac.createOMElement("invokeResponse", omNs);
            MessageContext outMessageContext = jobExecutionContext.getOutMessageContext();
            Set<String> paramNames = outMessageContext.getParameters().keySet();
            for (String paramName : paramNames) {
                /*
                * Process Output
                */
                String outputString = ((ActualParameter) outMessageContext.getParameter(paramName)).toXML().replaceAll("GFacParameter", paramName);
                XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(outputString));
                StAXOMBuilder builder = new StAXOMBuilder(reader);
                outputElement.addChild(builder.getDocumentElement());
            }
            // Send notification
View Full Code Here

        /*
        * Host
        */
        applicationContext.setServiceDescription(serv);

        MessageContext inMessage = new MessageContext();
        ActualParameter echo_input = new ActualParameter();
    ((StringParameterType)echo_input.getType()).setValue("echo_output=hello");
        inMessage.addParameter("echo_input", echo_input);

        jobExecutionContext.setInMessageContext(inMessage);

        MessageContext outMessage = new MessageContext();
        ActualParameter echo_out = new ActualParameter();
//    ((StringParameterType)echo_input.getType()).setValue("echo_output=hello");
        outMessage.addParameter("echo_output", echo_out);

        jobExecutionContext.setOutMessageContext(outMessage);

    }
View Full Code Here

    @Test
    public void testLocalProvider() throws GFacException {
        GFacAPI gFacAPI = new GFacAPI();
        gFacAPI.submitJob(jobExecutionContext);
        MessageContext outMessageContext = jobExecutionContext.getOutMessageContext();
        Assert.assertEquals(MappingFactory.toString((ActualParameter)outMessageContext.getParameter("echo_output")), "hello");
    }
View Full Code Here

        applicationContext.setHostDescription(host);
        applicationContext.setApplicationDeploymentDescription(appDesc);
        jobExecutionContext.setApplicationContext(applicationContext);
        applicationContext.setServiceDescription(serv);

        MessageContext inMessage = new MessageContext();

        ActualParameter echo_input = new ActualParameter();
        ((StringParameterType) echo_input.getType()).setValue("ai");
        inMessage.addParameter("molecule_id", echo_input);

        ActualParameter geom_mol2 = new ActualParameter(URIParameterType.type);
        ((URIParameterType) geom_mol2.getType()).setValue("http://ccg-mw1.ncsa.uiuc.edu/cgenff/leoshen/cgenff_project/ai/ai.mol2");
        inMessage.addParameter("geom_mol2", geom_mol2);

        ActualParameter toppar_main_tgz = new ActualParameter(URIParameterType.type);
        ((URIParameterType) toppar_main_tgz.getType()).setValue("/home/gridchem/workflow_script/toppar/cgenff/releases/2b7/main.tgz");
        inMessage.addParameter("toppar_main_tgz", toppar_main_tgz);

        ActualParameter toppar_usr_tgz = new ActualParameter(URIParameterType.type);
        ((URIParameterType) toppar_usr_tgz.getType()).setValue("gsiftp://trestles.sdsc.edu");
        inMessage.addParameter("toppar_usr_tgz", toppar_usr_tgz);

        ActualParameter toppar_mol_str = new ActualParameter(URIParameterType.type);
        ((URIParameterType) toppar_mol_str.getType()).setValue("http://ccg-mw1.ncsa.uiuc.edu/cgenff/leoshen/cgenff_project/ai/toppar/ai.str");
        inMessage.addParameter("toppar_mol_str", toppar_mol_str);

        ActualParameter molecule_dir_in_tgz = new ActualParameter(URIParameterType.type);
        ((URIParameterType) molecule_dir_in_tgz.getType()).setValue("");
        inMessage.addParameter("molecule_dir_in_tgz", molecule_dir_in_tgz);

        ActualParameter GC_UserName = new ActualParameter();
        ((StringParameterType) GC_UserName.getType()).setValue("leoshen");
        inMessage.addParameter("GC_UserName", GC_UserName);

        ActualParameter GC_ProjectName = new ActualParameter();
        ((StringParameterType) GC_ProjectName.getType()).setValue("leoshen");
        inMessage.addParameter("GC_ProjectName", GC_ProjectName);

        ActualParameter GC_WorkflowName = new ActualParameter();
        ((StringParameterType) GC_WorkflowName.getType()).setValue("ai__1339258840");
        inMessage.addParameter("GC_WorkflowName", GC_WorkflowName);

        jobExecutionContext.setInMessageContext(inMessage);

        MessageContext outMessage = new MessageContext();

        ActualParameter opt_freq_input_gjf = new ActualParameter(URIParameterType.type);
        outMessage.addParameter("opt_freq_input_gjf", opt_freq_input_gjf);

        ActualParameter charmm_miminized_crd = new ActualParameter(URIParameterType.type);
        outMessage.addParameter("charmm_miminized_crd", charmm_miminized_crd);

        ActualParameter step1_log = new ActualParameter(URIParameterType.type);
        outMessage.addParameter("step1_log", step1_log);

        ActualParameter molecule_dir_out_tgz = new ActualParameter(URIParameterType.type);
        outMessage.addParameter("molecule_dir_out_tgz", molecule_dir_out_tgz);

        ActualParameter gcvars = new ActualParameter(URIParameterType.type);
        outMessage.addParameter("gcvars", gcvars);

        jobExecutionContext.setOutMessageContext(outMessage);

    }
View Full Code Here

        }
        return result;
    }

    private MessageContext getOutParameters(ServiceDescription serviceDescription) {
        MessageContext outContext = new MessageContext();
        for (OutputParameterType parameter : serviceDescription.getType().getOutputParametersArray()) {
            ActualParameter actualParameter = new ActualParameter();
            if ("String".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(StringParameterType.type);
            } else if ("Double".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(DoubleParameterType.type);
            } else if ("Integer".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(IntegerParameterType.type);
            } else if ("Float".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(FloatParameterType.type);
            } else if ("Boolean".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(BooleanParameterType.type);
            } else if ("File".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(FileParameterType.type);
            } else if ("URI".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(URIParameterType.type);
            } else if ("StringArray".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(StringArrayType.type);
            } else if ("DoubleArray".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(DoubleArrayType.type);
            } else if ("IntegerArray".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(IntegerArrayType.type);
            } else if ("FloatArray".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(FloatArrayType.type);
            } else if ("BooleanArray".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(BooleanArrayType.type);
            } else if ("FileArray".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(FileArrayType.type);
            } else if ("URIArray".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(URIArrayType.type);
            } else if ("StdOut".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(StdOutParameterType.type);
            } else if ("StdErr".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(StdErrParameterType.type);
            }
            outContext.addParameter(parameter.getParameterName(), actualParameter);
        }
        return outContext;
    }
View Full Code Here

        AmazonSecurityContext amazonSecurityContext =
                new AmazonSecurityContext(userName, accessKey, secretKey, instanceId);
        jobExecutionContext.addSecurityContext(AmazonSecurityContext.AMAZON_SECURITY_CONTEXT, amazonSecurityContext);

        MessageContext inMessage = new MessageContext();
        ActualParameter genomeInput1 = new ActualParameter();
        ((StringParameterType)genomeInput1.getType()).setValue(sequence1);
        inMessage.addParameter("genome_input1", genomeInput1);

        ActualParameter genomeInput2 = new ActualParameter();
        ((StringParameterType)genomeInput2.getType()).setValue(sequence2);
        inMessage.addParameter("genome_input2", genomeInput2);

        MessageContext outMessage = new MessageContext();
        ActualParameter echo_out = new ActualParameter();
        outMessage.addParameter("distance", echo_out);

        jobExecutionContext.setInMessageContext(inMessage);
        jobExecutionContext.setOutMessageContext(outMessage);
    }
View Full Code Here

    public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
        log.info("Invoking GridFTPInputHandler ...");


        MessageContext inputNew = new MessageContext();
        try {
            MessageContext input = jobExecutionContext.getInMessageContext();
            Set<String> parameters = input.getParameters().keySet();
            for (String paramName : parameters) {
                ActualParameter actualParameter = (ActualParameter) input.getParameters().get(paramName);
                String paramValue = MappingFactory.toString(actualParameter);
                //TODO: Review this with type
                if ("URI".equals(actualParameter.getType().getType().toString())) {
                    ((URIParameterType) actualParameter.getType()).setValue(stageInputFiles(jobExecutionContext, paramValue));
                } else if ("URIArray".equals(actualParameter.getType().getType().toString())) {
View Full Code Here

    @Test
    public void testGramProvider() throws GFacException {
        GFacAPI gFacAPI = new GFacAPI();
        gFacAPI.submitJob(jobExecutionContext);
        MessageContext outMessageContext = jobExecutionContext.getOutMessageContext();
        Assert.assertEquals(MappingFactory.
                toString((ActualParameter) outMessageContext.getParameter("genome_output")), "476");
    }
View Full Code Here

TOP

Related Classes of org.apache.airavata.gfac.context.MessageContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.