Package org.apache.airavata.model.workspace.experiment

Examples of org.apache.airavata.model.workspace.experiment.DataTransferDetails


        return errorDetailsList;
    }

    public static DataTransferDetails getDataTransferDetail (DataTransferDetailResource resource) throws RegistryException {
        if (resource != null){
            DataTransferDetails details = new DataTransferDetails();
            details.setTransferID(resource.getTransferId());
            details.setCreationTime(resource.getCreationTime().getTime());
            details.setTransferDescription(resource.getTransferDescription());
            details.setTransferStatus(getTransferStatus(resource.getDataTransferStatus()));
            return details;
        }
        return null;
    }
View Full Code Here


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


    public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
        DataTransferDetails detail = new DataTransferDetails();
        TransferStatus status = new TransferStatus();
        MessageContext inputNew = new MessageContext();
        try {

            if (jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT) == null) {
                try {
                    GFACSSHUtils.addSecurityContext(jobExecutionContext);
                } catch (ApplicationSettingsException e) {
                    log.error(e.getMessage());
                    throw new GFacHandlerException("Error while creating SSHSecurityContext", e, e.getLocalizedMessage());
                }
            }
            log.info("Invoking SCPInputHandler");
            super.invoke(jobExecutionContext);


            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) {
                        String stageInputFiles = stageInputFiles(jobExecutionContext, paramValueEach);
                        status.setTransferState(TransferState.UPLOAD);
                        detail.setTransferStatus(status);
                        detail.setTransferDescription("Input Data Staged: " + stageInputFiles);
                        registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
                        newFiles.add(stageInputFiles);
                    }
                    ((URIArrayType) actualParameter.getType()).setValueArray(newFiles.toArray(new String[newFiles.size()]));
                }
                inputNew.getParameters().put(paramName, actualParameter);
            }
        } catch (Exception e) {
            log.error(e.getMessage());
            status.setTransferState(TransferState.FAILED);
            detail.setTransferStatus(status);
            try {
                GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE);
                registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
            } catch (Exception e1) {
                throw new GFacHandlerException("Error persisting status", e1, e1.getLocalizedMessage());
View Full Code Here

            String workingDirectory = app.getScratchWorkingDirectory();
            cluster.makeDirectory(workingDirectory);
            cluster.makeDirectory(app.getScratchWorkingDirectory());
            cluster.makeDirectory(app.getInputDataDirectory());
            cluster.makeDirectory(app.getOutputDataDirectory());
            DataTransferDetails detail = new DataTransferDetails();
            TransferStatus status = new TransferStatus();
            status.setTransferState(TransferState.DIRECTORY_SETUP);
            detail.setTransferStatus(status);
            detail.setTransferDescription("Working directory = " + workingDirectory);

            registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());

        } catch (SSHApiException e) {
            throw new GFacHandlerException("Error executing the Handler: " + SSHDirectorySetupHandler.class, e);
        } catch (Exception e) {
            DataTransferDetails detail = new DataTransferDetails();
            TransferStatus status = new TransferStatus();
            status.setTransferState(TransferState.FAILED);
            detail.setTransferStatus(status);
            try {
                registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
                GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE);
            } catch (Exception e1) {
                throw new GFacHandlerException("Error persisting status", e1, e1.getLocalizedMessage());
View Full Code Here

                    ftp.makeDir(tmpdirURI, gssCred);
                    ftp.makeDir(workingDirURI, gssCred);
                    ftp.makeDir(inputURI, gssCred);
                    ftp.makeDir(outputURI, gssCred);
                    success = true;
                    DataTransferDetails detail = new DataTransferDetails();
                    TransferStatus status = new TransferStatus();
                    status.setTransferState(TransferState.DIRECTORY_SETUP);
                    detail.setTransferStatus(status);
                    detail.setTransferDescription("Working directory = " + workingDirURI);
                    registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
                                 
                    break;
                } catch (URISyntaxException e) {
                    pe = new GFacHandlerException("URI is malformatted:" + e.getMessage(), e);
View Full Code Here

    private static final Logger log = LoggerFactory.getLogger(AppDescriptorCheckHandler.class);
    public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
        log.info("Invoking GridFTPInputHandler ...");
        super.invoke(jobExecutionContext);
        DataTransferDetails detail = new DataTransferDetails();
        TransferStatus status = new TransferStatus();
      
        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) {
                        String stageInputFiles = stageInputFiles(jobExecutionContext, paramValueEach);
                        detail.setTransferDescription("Input Data Staged: " + stageInputFiles);
                        status.setTransferState(TransferState.UPLOAD);
                        detail.setTransferStatus(status);
                        registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
                  
                        newFiles.add(stageInputFiles);
                    }
                    ((URIArrayType) actualParameter.getType()).setValueArray(newFiles.toArray(new String[newFiles.size()]));
                }
                inputNew.getParameters().put(paramName, actualParameter);
              
            }
        } catch (Exception e) {
           try {
               status.setTransferState(TransferState.FAILED);
         detail.setTransferStatus(status);
         registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
         GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE);
       } catch (Exception e1) {
            throw new GFacHandlerException("Error persisting status", e1, e1.getLocalizedMessage());
         }
View Full Code Here

       }

       GridFtp ftp = new GridFtp();
       File localStdErrFile = null;
       Map<String, ActualParameter> stringMap = new HashMap<String, ActualParameter>();
     DataTransferDetails detail = new DataTransferDetails();
     TransferStatus status = new TransferStatus();

       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 = GramProviderUtils.createGsiftpURI(endpoint, app.getStandardOutput());
                    URI stderrURI = GramProviderUtils.createGsiftpURI(endpoint, app.getStandardError());
                  status.setTransferState(TransferState.COMPLETE);
          detail.setTransferStatus(status);
          detail.setTransferDescription("STDOUT:" + stdoutURI.toString());
                    registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
                    status.setTransferState(TransferState.COMPLETE);
          detail.setTransferStatus(status);
          detail.setTransferDescription("STDERR:" + stderrURI.toString());
                    registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
                 
                    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());
                    }

                    List<DataObjectType> outputArray = new ArrayList<DataObjectType>();
                    Map<String, Object> output = jobExecutionContext.getOutMessageContext().getParameters();
                    Set<String> keys = output.keySet();
                    for (String paramName : keys) {
                        ActualParameter actualParameter = (ActualParameter) output.get(paramName);
                        if ("URIArray".equals(actualParameter.getType().getType().toString())) {
                            URI outputURI = GramProviderUtils.createGsiftpURI(endpoint, app.getOutputDataDirectory());
                            List<String> outputList = ftp.listDir(outputURI, gssCred);
                            String[] valueList = outputList.toArray(new String[outputList.size()]);
                            ((URIArrayType) actualParameter.getType()).setValueArray(valueList);
                            stringMap.put(paramName, actualParameter);
                        }else if ("StringArray".equals(actualParameter.getType().getType().toString())) {
                            String[] valueList = OutputUtils.parseStdoutArray(stdout, paramName);
                            ((StringArrayType) actualParameter.getType()).setValueArray(valueList);
                            stringMap.put(paramName, actualParameter);
                        } else if ("URI".equals(actualParameter.getType().getType().toString())) {
                            URI outputURI = GramProviderUtils.createGsiftpURI(endpoint, app.getOutputDataDirectory());
                              List<String> outputList = ftp.listDir(outputURI, gssCred);
              if (outputList.size() == 0 || outputList.get(0).isEmpty()) {
                OutputUtils.fillOutputFromStdout(output, stdout, stderr,outputArray);
              } else {
                String valueList = outputList.get(0);
                ((URIParameterType) actualParameter.getType()).setValue(valueList);
                stringMap = new HashMap<String, ActualParameter>();
                stringMap.put(paramName, actualParameter);
              }
                        }
                        else {
                            // This is to handle exception during the output parsing.
                            OutputUtils.fillOutputFromStdout(output, stdout, stderr,outputArray);
                        }
                        status.setTransferState(TransferState.DOWNLOAD);
              detail.setTransferStatus(status);
              detail.setTransferDescription("Output: " + stringMap.get(paramName).toString());
                        registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
                     
                    }
                    if (outputArray == null || outputArray.isEmpty()) {
                        throw new GFacHandlerException("Empty Output returned from the Application, Double check the application" +
                                "and ApplicationDescriptor output Parameter Names");
                    }
                    // If users has given an output Data path to download the output files this will download the file on machine where GFac is installed
                    TaskDetails taskData =  jobExecutionContext.getTaskData();
                    if(taskData != null && taskData.getAdvancedOutputDataHandling() != null){
                      String outputDataDirectory = taskData.getAdvancedOutputDataHandling().getOutputDataDir();
                            if(outputDataDirectory != null && !"".equals(outputDataDirectory)){
                                stageOutputFiles(jobExecutionContext,outputDataDirectory);
                            }
                    }
                } catch (ToolsException e) {
                    log.error(e.getMessage());
                    throw new GFacHandlerException(e.getMessage() + "\n StdError Data: \n" +readLastLinesofStdOut(localStdErrFile.getPath(), 20),e);
                } catch (URISyntaxException e) {
                    log.error(e.getMessage());
                    throw new GFacHandlerException("URI is malformatted:" + e.getMessage(), e, readLastLinesofStdOut(localStdErrFile.getPath(), 20));
                }
            }
        } catch (Exception e) {
           try {
              status.setTransferState(TransferState.FAILED);
        detail.setTransferStatus(status);
        registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
        GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE);
       } catch (Exception e1) {
           throw new GFacHandlerException("Error persisting status", e1, e1.getLocalizedMessage());
        }
View Full Code Here

TOP

Related Classes of org.apache.airavata.model.workspace.experiment.DataTransferDetails

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.