Package org.apache.airavata.gfac.context

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


    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

        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

  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

    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

        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

           else {
             //TODO
           }


        MessageContext outputNew = new MessageContext();
        MessageContext output = jobExecutionContext.getOutMessageContext();
        Map<String, Object> parameters = output.getParameters();
        for (String paramName : parameters.keySet()) {
            ActualParameter actualParameter = (ActualParameter) parameters
                    .get(paramName);

            GridFtp ftp = new GridFtp();
View Full Code Here

   

        if (app.getStandardInput() != null && !"".equals(app.getStandardInput())) {
            jobAttr.setStdin(app.getStandardInput());
        } else {
            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

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.