Package org.apache.airavata.gfac.provider

Examples of org.apache.airavata.gfac.provider.GFacProviderException


    private void makeFileSystemDir(String dir, JobExecutionContext jobExecutionContext) throws GFacProviderException {
        File f = new File(dir);
        if (f.isDirectory() && f.exists()) {
            return;
        } else if (!new File(dir).mkdir()) {
            throw new GFacProviderException("Cannot make directory " + dir, jobExecutionContext);
        }
    }
View Full Code Here


            log.debug("RSL = " + rsl);
            GramJob job = new GramJob(rsl);
            return job;
        } catch (ToolsException te) {
            throw new GFacProviderException(te.getMessage(), te, jobExecutionContext);
        }
    }
View Full Code Here

                    if(cpuCount>0){
                        app.setCpuCount(cpuCount);
                    }
                } catch (NullPointerException e) {
                    log.debug("No Value sent in WorkflowContextHeader for CPU Count, value in the Deployment Descriptor will be used");
                    new GFacProviderException("No Value sent in WorkflowContextHeader for Node Count, value in the Deployment Descriptor will be used",e);
                }
                try {
                    int nodeCount = currentContextHeader.getWorkflowSchedulingContext().getApplicationSchedulingContextArray()[0].getNodeCount();
                    if(nodeCount>0){
                        app.setNodeCount(nodeCount);
                    }
                } catch (NullPointerException e) {
                    log.debug("No Value sent in WorkflowContextHeader for Node Count, value in the Deployment Descriptor will be used");
                     new GFacProviderException("No Value sent in WorkflowContextHeader for Node Count, value in the Deployment Descriptor will be used",e);
                }
                try {
                    String queueName = currentContextHeader.getWorkflowSchedulingContext().getApplicationSchedulingContextArray()[0].getQueueName();
                    if (queueName != null) {
                        if(app.getQueue() == null){
                            QueueType queueType = app.addNewQueue();
                            queueType.setQueueName(queueName);
                        }else{
                            app.getQueue().setQueueName(queueName);
                        }
                    }
                } catch (NullPointerException e) {
                    log.debug("No Value sent in WorkflowContextHeader for Node Count, value in the Deployment Descriptor will be used");
                     new GFacProviderException("No Value sent in WorkflowContextHeader for Node Count, value in the Deployment Descriptor will be used",e);
                }
            }
        }
        if(currentContextHeader.getWorkflowOutputDataHandling() != null){
            if(currentContextHeader.getWorkflowOutputDataHandling().getApplicationOutputDataHandlingArray().length != 0)
View Full Code Here

                    }

                }
            } catch (URISyntaxException e) {
                log.error(e.getMessage());
                throw new GFacProviderException(e.getMessage(), e, jobExecutionContext);
            } catch (ToolsException e) {
                log.error(e.getMessage());
                throw new GFacProviderException(e.getMessage(), e, jobExecutionContext);
            }
            outputNew.getParameters().put(paramName, actualParameter);
        }
        jobExecutionContext.setOutMessageContext(outputNew);
    }
View Full Code Here

       
        try {
      cad.addNewCreateActivity().addNewActivityDocument()
              .setJobDefinition(JSDLGenerator.buildJSDLInstance(jobExecutionContext).getJobDefinition());
    } catch (Exception e1) {
      throw new GFacProviderException("Cannot generate JSDL instance from the JobExecutionContext.",e1);
    }
       
        FactoryClient factory = null;
        try {
            factory = new FactoryClient(eprt, secProperties);
        } catch (Exception e) {
            throw new GFacProviderException("");
        }
        CreateActivityResponseDocument response = null;
        try {
            log.info(String.format("Activity Submitting to %s ... \n", factoryUrl));
            response = factory.createActivity(cad);
            log.info(String.format("Activity Submitted to %s \n", factoryUrl));
        } catch (Exception e) {
          e.printStackTrace();
            throw new GFacProviderException("Cannot create activity.", e);
        }
        EndpointReferenceType activityEpr = response
                .getCreateActivityResponse().getActivityIdentifier();
       
        log.debug("Activity EPR: "+activityEpr);
       
        log.info("Activity: "+activityEpr.getAddress().getStringValue()" Submitted.");
       
        //factory.waitWhileActivityIsDone(activityEpr, 1000);
        jobId = WSUtilities.extractResourceID(activityEpr);
        if (jobId == null) {
            jobId = new Long(Calendar.getInstance().getTimeInMillis())
                    .toString();
        }
       
        log.info(formatStatusMessage(activityEpr.getAddress().getStringValue(), factory.getActivityStatus(activityEpr)
                .toString()));
       
       
        //TODO publish the status messages to the message bus
        while ((factory.getActivityStatus(activityEpr) != ActivityStateEnumeration.FINISHED) &&
                (factory.getActivityStatus(activityEpr) != ActivityStateEnumeration.FAILED)){
         
            ActivityStatusType activityStatus = null;
        try {
          activityStatus = getStatus(factory, activityEpr);
          log.info (subStatusAsString(activityStatus));
        } catch (UnknownActivityIdentifierFault e) {
          throw new GFacProviderException(e.getMessage(), e.getCause());
        }
 
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
            }
            continue;
        }
       
        ActivityStatusType activityStatus = null;
    try {
      activityStatus = getStatus(factory, activityEpr);
    } catch (UnknownActivityIdentifierFault e) {
      throw new GFacProviderException(e.getMessage(), e.getCause());
    }
       
        log.info(formatStatusMessage(activityEpr.getAddress().getStringValue(), activityStatus.getState().toString()));
       
    if ((activityStatus.getState() == ActivityStateEnumeration.FAILED)) {
View Full Code Here

          secProperties.setOutHandlerClassNames(outHandlerLst.toArray(new String[outHandlerLst.size()]));
         
         
    }
    catch (Exception e) {
      throw new GFacProviderException(e.getMessage(), e);
    }
    finally{
      try {
        if(bos!=null)bos.close();
        if(bufos!=null)bufos.close();
View Full Code Here

                    .append(String.valueOf(returnValue));

            log.info(buf.toString());

        } catch (IOException io) {
            throw new GFacProviderException(io.getMessage(), io,jobExecutionContext);
        } catch (InterruptedException e) {
            throw new GFacProviderException(e.getMessage(), e, jobExecutionContext);
        }
    }
View Full Code Here

        try {
            String stdOutStr = GFacUtils.readFileToString(app.getStandardOutput());
            String stdErrStr = GFacUtils.readFileToString(app.getStandardError());
            OutputUtils.fillOutputFromStdout(jobExecutionContext, stdOutStr, stdErrStr);
        } catch (XmlException e) {
            throw new GFacProviderException("Cannot read output:" + e.getMessage(), e, jobExecutionContext);
        } catch (IOException io) {
            throw new GFacProviderException(io.getMessage(), io, jobExecutionContext);
        } catch (Exception e){
          throw new GFacProviderException("Error in retrieving results",e,jobExecutionContext);
        }
    }
View Full Code Here

            String hostName = jobExecutionContext.getApplicationContext().getHostDescription().getType().getHostName();
            WorkflowNodeGramData workflowNodeGramData = new WorkflowNodeGramData(experimentID, nodeID, job.getRSL(),hostName , job.getIDAsString());
            try {
                jobExecutionContext.getGFacConfiguration().getAiravataAPI().getProvenanceManager().updateWorkflowNodeGramData(workflowNodeGramData);
            } catch (AiravataAPIInvocationException e) {
                throw new GFacProviderException(e.getMessage(), e, jobExecutionContext);
            }
            log.info(buf.toString());
            /*
            * Block untill job is done
            */
            listener.waitFor();


            /*
            * Fail job
            */
            int jobStatus = listener.getStatus();

//            if (job.getExitCode() != 0 || jobStatus == GramJob.STATUS_FAILED) {
              if (jobStatus == GramJob.STATUS_FAILED) {
                int errCode = listener.getError();
                String errorMsg = "Job " + job.getID() + " on host " + host.getHostAddress() + " Job Exit Code = "
                        + listener.getError();
                JobSubmissionFault error = new JobSubmissionFault(this, new Exception(errorMsg), "GFAC HOST",
                        gateKeeper, job.getRSL(), jobExecutionContext);
                throw error;
            }
        } catch (GramException e) {
            log.error(e.getMessage());
            JobSubmissionFault error = new JobSubmissionFault(this, e, host.getHostAddress(),
                    host.getGlobusGateKeeperEndPointArray(0), job.getRSL(), jobExecutionContext);
            throw error;
        } catch (GSSException e) {
            log.error(e.getMessage());
            throw new GFacProviderException(e.getMessage(), e, jobExecutionContext);
        } catch (InterruptedException e) {
            log.error(e.getMessage());
            throw new GFacProviderException("Thread", e, jobExecutionContext);
        } catch (SecurityException e) {
            log.error(e.getMessage());
            throw new GFacProviderException(e.getMessage(), e, jobExecutionContext);
        } finally {
            if (job != null) {
                try {
                   /*
                     * Remove listener
View Full Code Here

            if (jobExecutionContext.getSecurityContext(AmazonSecurityContext.AMAZON_SECURITY_CONTEXT)
                    instanceof AmazonSecurityContext) {
                this.amazonSecurityContext = (AmazonSecurityContext) jobExecutionContext.
                        getSecurityContext(AmazonSecurityContext.AMAZON_SECURITY_CONTEXT);
            } else {
                throw new GFacProviderException("Amazon Security Context is not set" + jobExecutionContext);
            }
        } else {
            throw new GFacProviderException("Job Execution Context is null" + jobExecutionContext);
        }

        if (log.isDebugEnabled()) {
            log.debug("ACCESS_KEY:" + amazonSecurityContext.getAccessKey());
            log.debug("SECRET_KEY:" + amazonSecurityContext.getSecretKey());
            log.debug("AMI_ID:" + amazonSecurityContext.getAmiId());
            log.debug("INS_ID:" + amazonSecurityContext.getInstanceId());
            log.debug("INS_TYPE:" + amazonSecurityContext.getInstanceType());
            log.debug("USERNAME:" + amazonSecurityContext.getUserName());
        }

        /* Validation */
        if (amazonSecurityContext.getAccessKey() == null || amazonSecurityContext.getAccessKey().isEmpty())
            throw new GFacProviderException("EC2 Access Key is empty", jobExecutionContext);
        if (amazonSecurityContext.getSecretKey() == null || amazonSecurityContext.getSecretKey().isEmpty())
            throw new GFacProviderException("EC2 Secret Key is empty", jobExecutionContext);
        if ((amazonSecurityContext.getAmiId() == null && amazonSecurityContext.getInstanceId() == null) ||
                (amazonSecurityContext.getAmiId() != null && amazonSecurityContext.getAmiId().isEmpty()) ||
                (amazonSecurityContext.getInstanceId() != null && amazonSecurityContext.getInstanceId().isEmpty()))
            throw new GFacProviderException("EC2 AMI or Instance ID is empty", jobExecutionContext);
        if (amazonSecurityContext.getUserName() == null || amazonSecurityContext.getUserName().isEmpty())
            throw new GFacProviderException("EC2 Username is empty", jobExecutionContext);

        /* Need to start EC2 instance before running it */
        AWSCredentials credential =
                new BasicAWSCredentials(amazonSecurityContext.getAccessKey(), amazonSecurityContext.getSecretKey());
        AmazonEC2Client ec2client = new AmazonEC2Client(credential);
View Full Code Here

TOP

Related Classes of org.apache.airavata.gfac.provider.GFacProviderException

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.