Package org.apache.airavata.gfac.context

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


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

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

        // added extra
        ActualParameter copy_input = new ActualParameter();
        copy_input.getType().changeType(URIParameterType.type);
        ((URIParameterType)copy_input.getType()).setValue("file:///tmp/tmpstrace");

        ActualParameter outlocation = new ActualParameter();
        ((StringParameterType)outlocation.getType()).setValue("./outputData/.");
        inMessage.addParameter("copy_input", copy_input);
        inMessage.addParameter("outputlocation", outlocation);

        // added extra



        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 testGramProvider() 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

    final String SPACE = " ";
    StringBuffer cmd = new StringBuffer();
    cmd.append(app.getExecutableLocation());
    cmd.append(SPACE);

    MessageContext input = context.getInMessageContext();
    ;
    Map<String, Object> inputs = input.getParameters();
    Set<String> keys = inputs.keySet();
    for (String paramName : keys) {
      ActualParameter actualParameter = (ActualParameter) inputs.get(paramName);
      if ("URIArray".equals(actualParameter.getType().getType().toString())) {
        String[] values = ((URIArrayType) actualParameter.getType()).getValueArray();
View Full Code Here

    private boolean isWhirrBasedDeployment = false;
    private File hadoopConfigDir;

    public void initialize(JobExecutionContext jobExecutionContext) throws GFacProviderException {
        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 GFacProviderException("Specified hadoop configuration directory doesn't exist.");
            } else if (FileUtils.listFiles(hadoopConfigDir, null, null).size() <= 0){
                throw new GFacProviderException("Cannot find any hadoop configuration files inside specified directory.");
View Full Code Here

    public void execute(JobExecutionContext jobExecutionContext) throws GFacProviderException {
        HadoopApplicationDeploymentDescriptionType hadoopAppDesc =
                (HadoopApplicationDeploymentDescriptionType)jobExecutionContext
                        .getApplicationContext().getApplicationDeploymentDescription().getType();
        MessageContext inMessageContext = jobExecutionContext.getInMessageContext();
        HadoopApplicationDeploymentDescriptionType.HadoopJobConfiguration jobConf = hadoopAppDesc.getHadoopJobConfiguration();

        try{
            // Preparing Hadoop configuration
            Configuration hadoopConf = HadoopUtils.createHadoopConfiguration(
                    jobExecutionContext, isWhirrBasedDeployment, hadoopConfigDir);

            // Load jar containing map-reduce job implementation
            ArrayList<URL> mapRedJars = new ArrayList<URL>();
            mapRedJars.add(new File(jobConf.getJarLocation()).toURL());
            URLClassLoader childClassLoader = new URLClassLoader(mapRedJars.toArray(new URL[mapRedJars.size()]),
                    this.getClass().getClassLoader());

            Job job = new Job(hadoopConf);

            job.setJobName(jobConf.getJobName());

            job.setOutputKeyClass(Class.forName(jobConf.getOutputKeyClass(), true, childClassLoader));
            job.setOutputValueClass(Class.forName(jobConf.getOutputValueClass(), true, childClassLoader));

            job.setMapperClass((Class<? extends Mapper>)Class.forName(jobConf.getMapperClass(), true, childClassLoader));
            job.setCombinerClass((Class<? extends Reducer>) Class.forName(jobConf.getCombinerClass(), true, childClassLoader));
            job.setReducerClass((Class<? extends Reducer>) Class.forName(jobConf.getCombinerClass(), true, childClassLoader));

            job.setInputFormatClass((Class<? extends InputFormat>)Class.forName(jobConf.getInputFormatClass(), true, childClassLoader));
            job.setOutputFormatClass((Class<? extends OutputFormat>) Class.forName(jobConf.getOutputFormatClass(), true, childClassLoader));

            FileInputFormat.setInputPaths(job, new Path(hadoopAppDesc.getInputDataDirectory()));
            FileOutputFormat.setOutputPath(job, new Path(hadoopAppDesc.getOutputDataDirectory()));

            job.waitForCompletion(true);
            System.out.println(job.getTrackingURL());
            if(jobExecutionContext.getOutMessageContext() == null){
                jobExecutionContext.setOutMessageContext(new MessageContext());
            }

            OutputParameterType[] outputParametersArray = jobExecutionContext.getApplicationContext().
                    getServiceDescription().getType().getOutputParametersArray();
            for(OutputParameterType outparamType : outputParametersArray){
View Full Code Here

  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

        return serv;
    }

    protected MessageContext getInMessageContext() {
        MessageContext inMessage = new MessageContext();

        ActualParameter i1 = new ActualParameter();
        i1.getType().changeType(URIParameterType.type);
        ((URIParameterType) i1.getType()).setValue("file:///tmp/ifile1");
        inMessage.addParameter("i1", i1);

        ActualParameter i2 = new ActualParameter();
        i2.getType().changeType(URIParameterType.type);
        ((URIParameterType) i2.getType()).setValue("file:///tmp/ifile2");
        inMessage.addParameter("i2", i2);

        ActualParameter i3 = new ActualParameter();
        i2.getType().changeType(URIParameterType.type);
        ((URIParameterType) i2.getType()).setValue("///tmp/ifile2");
        inMessage.addParameter("i3", i2);

        ActualParameter simpleArg = new ActualParameter();
        simpleArg.getType().changeType(StringParameterType.type);
        ((StringParameterType) simpleArg.getType()).setValue("argument1");
        inMessage.addParameter("a1", simpleArg);

        ActualParameter nameValueArg = new ActualParameter();
        nameValueArg.getType().changeType(StringParameterType.type);
        ((StringParameterType) nameValueArg.getType()).setValue("name1=value1");
        inMessage.addParameter("nameValueArg", nameValueArg);

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

        return inMessage;
    }
View Full Code Here

        return inMessage;
    }

    protected MessageContext getOutMessageContext() {
        MessageContext om1 = new MessageContext();

        // TODO: Aint the output parameters are only the name of the files staged out to the gridftp endpoint?
        ActualParameter o1 = new ActualParameter();
        ((StringParameterType) o1.getType()).setValue("tempfile");
        om1.addParameter("o1", o1);

        ActualParameter o2 = new ActualParameter();
        o2.getType().changeType(URIParameterType.type);

        ((URIParameterType) o2.getType()).setValue("http://path/to/upload");
        om1.addParameter("o2", o2);

        return om1;
    }
View Full Code Here

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

        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

            applicationContext.setServiceDescription(serviceDescription);

            jobExecutionContext.setApplicationContext(applicationContext);

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

            addSecurityContext(registeredHost, configurationProperties, jobExecutionContext,
                    configuration.getContextHeader());
            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

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.