Package org.apache.airavata.commons.gfac.type

Examples of org.apache.airavata.commons.gfac.type.ActualParameter


        MessageContext<ActualParameter> outputNew = new ParameterContextImpl();
        MessageContext<Object> input = invocationContext.getOutput();
        for (Iterator<String> iterator = input.getNames(); iterator.hasNext(); ) {
            String paramName = iterator.next();
            String paramValue = input.getStringValue(paramName);
            ActualParameter actualParameter = (ActualParameter) input
                    .getValue(paramName);
            //TODO: Review this with type
            GlobusHostType host = (GlobusHostType) invocationContext.getExecutionDescription().getHost().getType();
            GridFtp ftp = new GridFtp();
            gssContext = (GSISecurityContext) invocationContext.getSecurityContext(MYPROXY_SECURITY_CONTEXT);
            GSSCredential gssCred = null;
            try {
                gssCred = gssContext.getGssCredentails();
            } catch (SecurityException e) {
                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
            }
            try {
                if ("URI".equals(actualParameter.getType().getType().toString())) {
                    for (String endpoint : host.getGridFTPEndPointArray()) {
                        ((URIParameterType) actualParameter.getType()).setValue(doStaging(outputFileStagingPath,
                                paramValue, actualParameter, ftp, gssCred, endpoint));
                    }
                } else if ("URIArray".equals(actualParameter.getType().getType().toString())) {
                    List<String> split = Arrays.asList(paramValue.split(","));
                    List<String> newFiles = new ArrayList<String>();
                    for (String endpoint : host.getGridFTPEndPointArray()) {
                        for (String paramValueEach : split) {
                            newFiles.add(doStaging(outputFileStagingPath, paramValueEach, actualParameter, ftp, gssCred, endpoint));
                        }
                        ((URIArrayType) actualParameter.getType()).setValueArray(newFiles.toArray(new String[newFiles.size()]));
                    }

                }
            } catch (URISyntaxException e) {
                throw new ProviderException(e.getMessage(), e, invocationContext);
View Full Code Here


    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();
        for (String value : values) {
          cmd.append(value);
          cmd.append(SPACE);
        }
      } else {
View Full Code Here

            OutputParameterType[] outputParametersArray = jobExecutionContext.getApplicationContext().
                    getServiceDescription().getType().getOutputParametersArray();
            for(OutputParameterType outparamType : outputParametersArray){
                String paramName = outparamType.getParameterName();
                if(paramName.equals("test-hadoop")){
                    ActualParameter outParam = new ActualParameter();
                    outParam.getType().changeType(StringParameterType.type);
                    ((StringParameterType) outParam.getType()).setValue(job.getTrackingURL());
                    jobExecutionContext.getOutMessageContext().addParameter("test-hadoop", outParam);
                }
            }
        } catch (Exception e) {
            String errMessage = "Error occurred during Map-Reduce job execution.";
View Full Code Here

        }

        Map<String, ActualParameter> result = new HashMap<String, ActualParameter>();
        Set<String> keys = output.keySet();
        for (String paramName : keys) {
          ActualParameter actual = (ActualParameter) output.get(paramName);
            // if parameter value is not already set, we let it go
           
            if (actual == null) {
                continue;
            }
            if ("StdOut".equals(actual.getType().getType().toString())) {
                ((StdOutParameterType) actual.getType()).setValue(stdout);
                result.put(paramName, actual);
            } else if ("StdErr".equals(actual.getType().getType().toString())) {
                ((StdErrParameterType) actual.getType()).setValue(stderr);
                result.put(paramName, actual);
            } else {
                String parseStdout = parseStdout(stdout, paramName);
                if (parseStdout != null) {
                    MappingFactory.fromString(actual, parseStdout);
View Full Code Here

    Map<String, Object> outputParams = context.getOutMessageContext()
        .getParameters();

    for (String paramKey : outputParams.keySet()) {

      ActualParameter outParam = (ActualParameter) outputParams
          .get(paramKey);

      // if single urls then convert each url into jsdl source
      // elements,
      // that are formed by concat of gridftpurl+inputdir+filename

      String paramDataType = outParam.getType().getType().toString();

      if ("URI".equals(paramDataType)) {
        String uriPrm = ((URIParameterType) outParam.getType())
            .getValue();
        createOutURIElement(value, uriPrm);
      }

      // string params are converted into the job arguments

      else if (("URIArray").equals(paramDataType)) {
        String[] uriArray = ((URIArrayType) outParam.getType())
            .getValueArray();
        for (String u : uriArray) {
          createOutURIElement(value, u);
        }

      }
      else if ("String".equals(paramDataType)) {
        String stringPrm = ((StringParameterType) outParam
            .getType()).getValue();
        createOutStringElements(value, appDepType, gridftpEndpoint, stringPrm);
      }

      else if ("StringArray".equals(paramDataType)) {
        String[] valueArray = ((StringArrayType) outParam.getType())
            .getValueArray();
        for (String v : valueArray) {
          createOutStringElements(value, appDepType, gridftpEndpoint, v);
        }
      }
View Full Code Here

    Map<String, Object> inputParams = context.getInMessageContext()
        .getParameters();

    for (String paramKey : inputParams.keySet()) {

      ActualParameter inParam = (ActualParameter) inputParams
          .get(paramKey);

      // if single urls then convert each url into jsdl source
      // elements,
      // that are formed by concat of gridftpurl+inputdir+filename

      String paramDataType = inParam.getType().getType().toString();

      if ("URI".equals(paramDataType)) {
        createInURIElement(value, gridftpEndpoint,
            appDepType.getInputDataDirectory(), inParam);
      }

      // string params are converted into the job arguments

      else if ("String".equals(paramDataType)) {
        String stringPrm = ((StringParameterType) inParam.getType())
            .getValue();
                ApplicationProcessor.addApplicationArgument(value, appDepType, stringPrm);
      }
    }
   
View Full Code Here

          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())) {
                      List<String> split = Arrays.asList(StringUtil.getElementsFromString(paramValue));
                      List<String> newFiles = new ArrayList<String>();
                      for (String paramValueEach : split) {
                          newFiles.add(stageInputFiles(jobExecutionContext, paramValueEach));
                      }
                      ((URIArrayType) actualParameter.getType()).setValueArray(newFiles.toArray(new String[newFiles.size()]));
                  }
                  inputNew.getParameters().put(paramName, actualParameter);
              }
          } catch (Exception e) {
              log.error(e.getMessage());
View Full Code Here

            for(OutputParameterType outparamType : outputParametersArray){
                /* Assuming that there is just a single result. If you want to add more results, update the necessary
                   logic below */
                String paramName = outparamType.getParameterName();
                ActualParameter outParam = new ActualParameter();
                outParam.getType().changeType(StringParameterType.type);
                ((StringParameterType) outParam.getType()).setValue(executionResult);
                jobExecutionContext.getOutMessageContext().addParameter(paramName, outParam);
            }
            GFacUtils.updateApplicationJobStatus(jobExecutionContext, jobId, ApplicationJobStatus.FINISHED);
        } catch (InvalidSshKeyException e) {
            throw new GFacProviderException("Invalid SSH key", e);
View Full Code Here

    }

    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

    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

TOP

Related Classes of org.apache.airavata.commons.gfac.type.ActualParameter

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.