Package org.apache.airavata.schemas.gfac

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


              throw new GFacHandlerException("Error while input File Staging", jobExecutionContext, e, e.getLocalizedMessage());
          }
          jobExecutionContext.setInMessageContext(inputNew);
  }
   private static String stageInputFiles(JobExecutionContext context,String paramValue) throws IOException,GFacException{
     ApplicationDeploymentDescriptionType app = context.getApplicationContext().getApplicationDeploymentDescription().getType();

     SSHSecurityContext securityContext = (SSHSecurityContext)context.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT);
     SCPFileTransfer fileTransfer = securityContext.getSSHClient().newSCPFileTransfer();
     String remoteFile = app.getInputDataDirectory() + File.separatorChar + paramValue;

     File inputFile = new File(paramValue);
     fileTransfer.upload(inputFile.getAbsolutePath(), remoteFile);
     return remoteFile;
   }
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();
            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
            if (fileName != null && !"".equals(fileName)) {
                destURI = GFacUtils.createGsiftpURI(endpoint, destLocalPath);
View Full Code Here

        /*
        * App
        */
        ApplicationDescription appDesc =
                new ApplicationDescription(HpcApplicationDeploymentType.type);
        ApplicationDeploymentDescriptionType applicationDeploymentDescriptionType
                = appDesc.getType();
        applicationDeploymentDescriptionType.addNewApplicationName().setStringValue(serviceName);
        String tempDir = "/oasis/projects/nsf/uic151/gridchem/airavata-workdirs";
        String date = (new Date()).toString();
        date = date.replaceAll(" ", "_");
        date = date.replaceAll(":", "_");

        tempDir = tempDir + File.separator
                + serviceName + "_" + date + "_" + UUID.randomUUID();
        applicationDeploymentDescriptionType.setExecutableLocation("/home/gridchem/workflow_script/sys_exec/scripts/step1/step1_model_refdata_prep.sh");
        applicationDeploymentDescriptionType.setScratchWorkingDirectory(tempDir);
        applicationDeploymentDescriptionType.setStaticWorkingDirectory(tempDir);
        applicationDeploymentDescriptionType.setInputDataDirectory(tempDir + File.separator + "inputData");
        applicationDeploymentDescriptionType.setOutputDataDirectory(tempDir + File.separator + "outputData");
        applicationDeploymentDescriptionType.setStandardOutput(tempDir + File.separator + applicationDeploymentDescriptionType.getApplicationName().getStringValue() + ".stdout");
        applicationDeploymentDescriptionType.setStandardError(tempDir + File.separator + applicationDeploymentDescriptionType.getApplicationName().getStringValue() + ".stderr");

        ProjectAccountType projectAccountType = ((HpcApplicationDeploymentType) applicationDeploymentDescriptionType).addNewProjectAccount();
        projectAccountType.setProjectAccountNumber("uic151");

        QueueType queueType = ((HpcApplicationDeploymentType) applicationDeploymentDescriptionType).addNewQueue();
View Full Code Here

    public LocalProvider(){
        cmdList = new ArrayList<String>();
    }

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

        buildCommand(app.getExecutableLocation(), ProviderUtils.getInputParameters(jobExecutionContext));
        initProcessBuilder(app);

        // extra environment variables
        builder.environment().put(Constants.INPUT_DATA_DIR_VAR_NAME, app.getInputDataDirectory());
        builder.environment().put(Constants.OUTPUT_DATA_DIR_VAR_NAME, app.getOutputDataDirectory());

        // set working directory
        builder.directory(new File(app.getStaticWorkingDirectory()));

        // log info
        log.info("Command = " + InputUtils.buildCommand(cmdList));
        log.info("Working dir = " + builder.directory());
        for (String key : builder.environment().keySet()) {
View Full Code Here

        }
    }

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

        try {
            // running cmd
            Process process = builder.start();
            jobId="Local_"+Calendar.getInstance().getTimeInMillis();
            if(jobExecutionContext.getGFacConfiguration().getAiravataAPI() != null){
            saveApplicationJob(jobExecutionContext);
          }
            GFacUtils.updateApplicationJobStatus(jobExecutionContext,jobId, ApplicationJobStatus.INITIALIZE);
            Thread standardOutWriter = new InputStreamToFileWriter(process.getInputStream(), app.getStandardOutput());
            Thread standardErrorWriter = new InputStreamToFileWriter(process.getErrorStream(), app.getStandardError());

            // start output threads
            standardOutWriter.setDaemon(true);
            standardErrorWriter.setDaemon(true);
            standardOutWriter.start();
            standardErrorWriter.start();
            GFacUtils.updateApplicationJobStatus(jobExecutionContext,jobId, ApplicationJobStatus.EXECUTING);
            // wait for the process (application) to finish executing
            int returnValue = process.waitFor();
            GFacUtils.updateApplicationJobStatus(jobExecutionContext,jobId, ApplicationJobStatus.FINALIZE);

            // make sure other two threads are done
            standardOutWriter.join();
            standardErrorWriter.join();

            /*
             * check return value. usually not very helpful to draw conclusions based on return values so don't bother.
             * just provide warning in the log messages
             */
            if (returnValue != 0) {
              GFacUtils.updateApplicationJobStatus(jobExecutionContext,jobId, ApplicationJobStatus.FAILED);
                log.error("Process finished with non zero return value. Process may have failed");
            } else {
              GFacUtils.updateApplicationJobStatus(jobExecutionContext,jobId, ApplicationJobStatus.FINISHED);
                log.info("Process finished with return value of zero.");
            }

            StringBuffer buf = new StringBuffer();
            buf.append("Executed ").append(InputUtils.buildCommand(cmdList))
                    .append(" on the localHost, working directory = ").append(app.getStaticWorkingDirectory())
                    .append(" tempDirectory = ").append(app.getScratchWorkingDirectory()).append(" With the status ")
                    .append(String.valueOf(returnValue));

            log.info(buf.toString());

        } catch (IOException io) {
View Full Code Here

        }
    }

  private void saveApplicationJob(JobExecutionContext jobExecutionContext)
      throws GFacProviderException {
    ApplicationDeploymentDescriptionType app = jobExecutionContext.
                getApplicationContext().getApplicationDeploymentDescription().getType();
    ApplicationJob appJob = GFacUtils.createApplicationJob(jobExecutionContext);
    appJob.setJobId(jobId);
    LocalProviderJobData data = new LocalProviderJobData();
    data.setApplicationName(app.getExecutableLocation());
    data.setInputDir(app.getInputDataDirectory());
    data.setOutputDir(app.getOutputDataDirectory());
    data.setWorkingDir(builder.directory().toString());
    data.setInputParameters(ProviderUtils.getInputParameters(jobExecutionContext));
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    JAXB.marshal(data, stream);
    appJob.setJobData(stream.toString());
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

    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

    return serv;
  }

  private ApplicationDeploymentDescription createAppDeploymentDescription() {
    ApplicationDeploymentDescription appDesc = new ApplicationDeploymentDescription();
    ApplicationDeploymentDescriptionType app = appDesc.getType();
    ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory
        .newInstance();
    name.setStringValue("EchoLocal");
    app.setApplicationName(name);
    app.setExecutableLocation("/bin/echo");
    app.setScratchWorkingDirectory("/tmp");
    app.setStaticWorkingDirectory("/tmp");
    app.setInputDataDirectory("/tmp/input");
    app.setOutputDataDirectory("/tmp/output");
    app.setStandardOutput("/tmp/echo.stdout");
    app.setStandardError("/tmp/echo.stdout");
    return appDesc;
  }
View Full Code Here

      public void actionPerformed(ActionEvent e) {
        HostDeploymentDialog hostDeploymentDialog = new HostDeploymentDialog(getRegistry(),true,null,null,Arrays.asList(getDeployments().keySet().toArray(new String[]{})));
        try {
          HostDeployment deployDesc = hostDeploymentDialog.execute();
          if (deployDesc!=null){
            ApplicationDeploymentDescriptionType appType = deployDesc.getApplicationDescription().getType();
            if (appType.getApplicationName()==null){
              appType.addNewApplicationName();
              }
            HostDescriptionType hostType = deployDesc.getHostDescription().getType();
            appType.getApplicationName().setStringValue(hostType.getHostName()+"_application");
            getDeployments().put(hostType.getHostName(), deployDesc);
            updateDeploymentTable();
          }
        } catch (RegistryException e1) {
          setError(e1.getLocalizedMessage());
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.