Package org.apache.airavata.schemas.gfac

Examples of org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType


    appJob.setStatusUpdateTime(appJob.getSubmittedTime());
    GFacUtils.recordApplicationJob(jobExecutionContext, appJob);
  }

    public void dispose(JobExecutionContext jobExecutionContext) throws GFacProviderException {
        ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType();

        try {
            String stdOutStr = GFacUtils.readFileToString(app.getStandardOutput());
            String stdErrStr = GFacUtils.readFileToString(app.getStandardError());
      Map<String, Object> output = jobExecutionContext.getOutMessageContext().getParameters();
            OutputUtils.fillOutputFromStdout(output, stdOutStr, stdErrStr);
        } catch (XmlException e) {
            throw new GFacProviderException("Cannot read output:" + e.getMessage(), e, jobExecutionContext);
        } catch (IOException io) {
View Full Code Here


                command = "sh" + " " + type.getExecutable();
            }
            command = setCmdParams(jobExecutionContext, command);

        } else {
            ApplicationDeploymentDescriptionType type = appDesc.getType();
            command = "sh" + " " + type.getExecutableLocation();
            command = setCmdParams(jobExecutionContext, command);
        }

        return command + '\n';
    }
View Full Code Here

                command = "sh" + " " + type.getExecutable();
            }
            command = setCmdParams(jobExecutionContext, command);

        } else {
            ApplicationDeploymentDescriptionType type = appDesc.getType();
            command = "sh" + " " + type.getExecutableLocation();
            command = setCmdParams(jobExecutionContext, command);
        }

        return command + '\n';
    }
View Full Code Here

        else {
          //TODO
        }


        ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType();
        GridFtp ftp = new GridFtp();
        URI destURI = null;
        GSSCredential gssCred = ((GSISecurityContext)jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getGssCredentials();

        for (String endpoint : gridFTPEndpointArray) {
            URI inputURI = GFacUtils.createGsiftpURI(endpoint, app.getInputDataDirectory());
            String fileName = new File(gridftpURL.getPath()).getName();
            fileName = ftp.gridFTPFileExist(inputURI, fileName,gssCred);

            String destLocalPath = inputURI.getPath() + File.separator + fileName;
            //if user give a url just to refer an endpoint, not a web resource we are not doing any transfer
View Full Code Here

    public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
        log.info("Invoking GramDirectorySetupHandler ...");
        HostDescriptionType type = jobExecutionContext.getApplicationContext().getHostDescription().getType();
        ApplicationDescription applicationDeploymentDescription = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription();
        ApplicationDeploymentDescriptionType app = applicationDeploymentDescription.getType();
        log.debug("working diectroy = " + app.getStaticWorkingDirectory());
        log.debug("temp directory = " + app.getScratchWorkingDirectory());

        makeFileSystemDir(app.getStaticWorkingDirectory(),jobExecutionContext);
        makeFileSystemDir(app.getScratchWorkingDirectory(),jobExecutionContext);
        makeFileSystemDir(app.getInputDataDirectory(),jobExecutionContext);
        makeFileSystemDir(app.getOutputDataDirectory(),jobExecutionContext);
    }
View Full Code Here

  public void initialize(JobExecutionContext jobExecutionContext) throws GFacProviderException,GFacException {
    jobID="SSH_"+jobExecutionContext.getApplicationContext().getHostDescription().getType().getHostAddress()+"_"+Calendar.getInstance().getTimeInMillis();
   
    securityContext = (SSHSecurityContext) jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT);
    ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType();
    String remoteFile = app.getStaticWorkingDirectory() + File.separatorChar + Constants.EXECUTABLE_NAME;
    saveApplicationJob(jobExecutionContext, remoteFile);
    log.info(remoteFile);
    try {
      File runscript = createShellScript(jobExecutionContext);
      SCPFileTransfer fileTransfer = securityContext.getSSHClient().newSCPFileTransfer();
View Full Code Here

    job.setJobData(executableName);
    GFacUtils.recordApplicationJob(jobExecutionContext, job);
  }

  public void execute(JobExecutionContext jobExecutionContext) throws GFacProviderException {
    ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType();
    Session session = null;
    try {
      session = securityContext.getSession(jobExecutionContext.getApplicationContext().getHostDescription().getType().getHostAddress());
      /*
       * Execute
       */
      String execuable = app.getStaticWorkingDirectory() + File.separatorChar + Constants.EXECUTABLE_NAME;
      GFacUtils.updateApplicationJobStatus(jobExecutionContext, jobID, ApplicationJobStatus.SUBMITTED);
      Command cmd = session.exec("/bin/chmod 755 " + execuable + "; " + execuable);
      GFacUtils.updateApplicationJobStatus(jobExecutionContext, jobID, ApplicationJobStatus.RESULTS_RETRIEVE);
      log.info("stdout=" + GFacUtils.readFromStream(session.getInputStream()));
      cmd.join(Constants.COMMAND_EXECUTION_TIMEOUT, TimeUnit.SECONDS);
View Full Code Here

        throw new NotImplementedException();
    }


    private File createShellScript(JobExecutionContext context) throws IOException {
    ApplicationDeploymentDescriptionType app = context.getApplicationContext()
        .getApplicationDeploymentDescription().getType();
    String uniqueDir = app.getApplicationName().getStringValue() + System.currentTimeMillis()
        + new Random().nextLong();

    File shellScript = File.createTempFile(uniqueDir, "sh");
    OutputStream out = new FileOutputStream(shellScript);

    out.write("#!/bin/bash\n".getBytes());
    out.write(("cd " + app.getStaticWorkingDirectory() + "\n").getBytes());
    out.write(("export " + Constants.INPUT_DATA_DIR_VAR_NAME + "=" + app.getInputDataDirectory() + "\n").getBytes());
    out.write(("export " + Constants.OUTPUT_DATA_DIR_VAR_NAME + "=" + app.getOutputDataDirectory() + "\n")
        .getBytes());
    // get the env of the host and the application
    NameValuePairType[] env = app.getApplicationEnvironmentArray();

    Map<String, String> nv = new HashMap<String, String>();
    if (env != null) {
      for (int i = 0; i < env.length; i++) {
        String key = env[i].getName();
        String value = env[i].getValue();
        nv.put(key, value);
      }
    }
    for (Entry<String, String> entry : nv.entrySet()) {
      log.debug("Env[" + entry.getKey() + "] = " + entry.getValue());
      out.write(("export " + entry.getKey() + "=" + entry.getValue() + "\n").getBytes());

    }

    // prepare the command
    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();
        for (String value : values) {
          cmd.append(value);
          cmd.append(SPACE);
        }
      } else {
        String paramValue = MappingFactory.toString(actualParameter);
        cmd.append(paramValue);
        cmd.append(SPACE);
      }
    }
    // We redirect the error and stdout to remote files, they will be read
    // in later
    cmd.append(SPACE);
    cmd.append("1>");
    cmd.append(SPACE);
    cmd.append(app.getStandardOutput());
    cmd.append(SPACE);
    cmd.append("2>");
    cmd.append(SPACE);
    cmd.append(app.getStandardError());

    String cmdStr = cmd.toString();
    log.info("Command = " + cmdStr);
    out.write((cmdStr + "\n").getBytes());
    String message = "\"execuationSuceeded\"";
View Full Code Here

    private static final Logger log = LoggerFactory.getLogger(GridFTPOutputHandler.class);

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

       ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType();

      HostDescriptionType hostType = jobExecutionContext.getApplicationContext().getHostDescription().getType();
      String[] gridFTPEndpointArray = null;
      String hostName = null;
       if(jobExecutionContext.getApplicationContext().getHostDescription().getType() instanceof GlobusHostType){
          gridFTPEndpointArray = ((GlobusHostType) hostType).getGridFTPEndPointArray();
          hostName = ((GlobusHostType) hostType).getHostName();
       }
       else if (jobExecutionContext.getApplicationContext().getHostDescription().getType() instanceof UnicoreHostType){
          gridFTPEndpointArray = ((UnicoreHostType) hostType).getGridFTPEndPointArray();
          hostName = ((UnicoreHostType) hostType).getHostName();
       }
       else {
          //TODO
       }

       GridFtp ftp = new GridFtp();
       File localStdErrFile = null;
       Map<String, ActualParameter> stringMap = new HashMap<String, ActualParameter>();
       try {
          GSSCredential gssCred = ((GSISecurityContext)jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getGssCredentials();
          String[] hostgridFTP = gridFTPEndpointArray;
            if (hostgridFTP == null || hostgridFTP.length == 0) {
                hostgridFTP = new String[]{hostName};
            }
            for (String endpoint : gridFTPEndpointArray) {
                try {
                    /*
                     *  Read Stdout and Stderror
                     */
                    URI stdoutURI = GFacUtils.createGsiftpURI(endpoint, app.getStandardOutput());
                    URI stderrURI = GFacUtils.createGsiftpURI(endpoint, app.getStandardError());

                    log.info("STDOUT:" + stdoutURI.toString());
                    log.info("STDERR:" + stderrURI.toString());

                    File logDir = new File("./service_logs");
                    if (!logDir.exists()) {
                        logDir.mkdir();
                    }

                    String timeStampedServiceName = GFacUtils.createUniqueNameForService(jobExecutionContext
                            .getServiceName());
                    File localStdOutFile = File.createTempFile(timeStampedServiceName, "stdout");
                    localStdErrFile = File.createTempFile(timeStampedServiceName, "stderr");


                    String stdout = null;
                    String stderr = null;

                    // TODO: what if job is failed
                    // and this handler is not able to find std* files?
                    try {
                     stdout = ftp.readRemoteFile(stdoutURI, gssCred, localStdOutFile);
                     stderr = ftp.readRemoteFile(stderrURI, gssCred, localStdErrFile);
                     //TODO: do we also need to set them as output parameters for another job
                     ApplicationDescription application = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription();
                     ApplicationDeploymentDescriptionType appDesc = application.getType();
                     appDesc.setStandardOutput(stdout);
                     appDesc.setStandardError(stderr);
                     jobExecutionContext.getApplicationContext().setApplicationDeploymentDescription(application);
                    }
                    catch(ToolsException e) {
                        log.error("Cannot download stdout/err files. One reason could be the job is not successfully finished:  "+e.getMessage());
                    }
View Full Code Here

    }

    public void execute(JobExecutionContext jobExecutionContext) throws GFacProviderException, GFacException{
        jobExecutionContext.getNotifier().publish(new StartExecutionEvent());
        GlobusHostType host = (GlobusHostType) jobExecutionContext.getApplicationContext().getHostDescription().getType();
        ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType();

        StringBuffer buf = new StringBuffer();
        try {
            GSSCredential gssCred = ((GSISecurityContext)jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getGssCredentials();
            job.setCredentials(gssCred);
            // We do not support multiple gatekeepers in XBaya GUI, so we simply pick the 0th element in the array
            String gateKeeper = host.getGlobusGateKeeperEndPointArray(0);
            log.info("Request to contact:" + gateKeeper);

            buf.append("Finished launching job, Host = ").append(host.getHostAddress()).append(" RSL = ")
                    .append(job.getRSL()).append(" working directory = ").append(app.getStaticWorkingDirectory())
                    .append(" temp directory = ").append(app.getScratchWorkingDirectory())
                    .append(" Globus GateKeeper Endpoint = ").append(gateKeeper);

            /*
            * The first boolean is to specify the job is a batch job - use true for interactive and false for batch.
            * The second boolean is to specify to use the full proxy and not delegate a limited proxy.
View Full Code Here

TOP

Related Classes of org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType

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.