Package org.ogce.gfac.external

Examples of org.ogce.gfac.external.GridFtp


  public void initialize(InvocationContext invocationContext) throws GfacException {
    ExecutionContext appExecContext = invocationContext.getExecutionContext();
    ExecutionModel model = appExecContext.getExecutionModel();

    GridFtp ftp = new GridFtp();

    try {
      GSSCredential gssCred = ((GSISecurityContext) invocationContext.getSecurityContext(MYPROXY_SECURITY_CONTEXT)).getGssCredentails();

      // get Hostname
      String hostgridFTP = null;

      if (model.getHostDesc().getHostConfiguration().getGridFTPArray() != null && model.getHostDesc().getHostConfiguration().getGridFTPArray().length > 0) {
        hostgridFTP = model.getHostDesc().getHostConfiguration().getGridFTPArray(0).getEndPointReference();
      } else {
        hostgridFTP = model.getHost();
      }

      URI tmpdirURI = GfacUtils.createGsiftpURI(hostgridFTP, model.getTmpDir());
      URI workingDirURI = GfacUtils.createGsiftpURI(hostgridFTP, model.getWorkingDir());
      URI inputURI = GfacUtils.createGsiftpURI(hostgridFTP, model.getInputDataDir());
      URI outputURI = GfacUtils.createGsiftpURI(hostgridFTP, model.getOutputDataDir());

      log.info("Host FTP = " + hostgridFTP);
      log.info("temp directory = " + tmpdirURI);
      log.info("Working directory = " + workingDirURI);
      log.info("Input directory = " + inputURI);
      log.info("Output directory = " + outputURI);

      ftp.makeDir(tmpdirURI, gssCred);
      ftp.makeDir(workingDirURI, gssCred);
      ftp.makeDir(inputURI, gssCred);
      ftp.makeDir(outputURI, gssCred);

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here


      notifier.computationFinished(compObj);     

      /*
       * Stdout and Stderror
       */
      GridFtp ftp = new GridFtp();

      // get Hostname
      String hostgridFTP = null;

      if (invocationContext.getExecutionContext().getExecutionModel().getHostDesc().getHostConfiguration().getGridFTPArray() != null && invocationContext.getExecutionContext().getExecutionModel().getHostDesc().getHostConfiguration().getGridFTPArray().length > 0) {
        hostgridFTP = invocationContext.getExecutionContext().getExecutionModel().getHostDesc().getHostConfiguration().getGridFTPArray(0).getEndPointReference();
      } else {
        hostgridFTP = invocationContext.getExecutionContext().getExecutionModel().getHost();
      }     

      URI stdoutURI = GfacUtils.createGsiftpURI(hostgridFTP, invocationContext.getExecutionContext().getExecutionModel().getStdOut());
      URI stderrURI = GfacUtils.createGsiftpURI(hostgridFTP, invocationContext.getExecutionContext().getExecutionModel().getStderr());
     
      System.out.println(stdoutURI);
      System.out.println(stderrURI);
     
      File logDir = new File("./service_logs");
      if (!logDir.exists()) {
        logDir.mkdir();
      }

      // Get the Stdouts and StdErrs
      QName x = QName.valueOf(invocationContext.getServiceName());
      String timeStampedServiceName = GfacUtils.createServiceDirName(x);
      File localStdOutFile = new File(logDir, timeStampedServiceName + ".stdout");
      File localStdErrFile = new File(logDir, timeStampedServiceName + ".stderr");
     
      String stdout = ftp.readRemoteFile(stdoutURI, gssCred, localStdOutFile);
      String stderr = ftp.readRemoteFile(stderrURI, gssCred, localStdErrFile);
     
      //set to context
      OutputUtils.fillOutputFromStdout(invocationContext.getMessageContext("output"), stdout, stderr);
     
     
View Full Code Here

TOP

Related Classes of org.ogce.gfac.external.GridFtp

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.