Package org.apache.airavata.gfac.provider

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


              String processers = Integer.toString(cpuCount);
            num.setStringValue(processers);
              JSDLUtils.getOrCreateSPMDApplication(value).setNumberOfProcesses(num);
                    }
                } catch (NullPointerException e) {
                    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){
                      appDepType.setNodeCount(nodeCount);
                    }
                } catch (NullPointerException e) {
                     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(appDepType.getQueue() == null){
                            QueueType queueType = appDepType.addNewQueue();
                            queueType.setQueueName(queueName);
                        }else{
                          appDepType.getQueue().setQueueName(queueName);
                        }
                    }
                } catch (NullPointerException e) {
                     new GFacProviderException("No Value sent in WorkflowContextHeader for Node Count, value in the Deployment Descriptor will be used",e);
                }
                try {
                    int maxwallTime = currentContextHeader.getWorkflowSchedulingContext().getApplicationSchedulingContextArray()[0].getMaxWallTime();
                    if(maxwallTime>0){
                      appDepType.setMaxWallTime(maxwallTime);
                    }
                } catch (NullPointerException e) {
                     new GFacProviderException("No Value sent in WorkflowContextHeader for Node Count, value in the Deployment Descriptor will be used",e);
                }
            }
        }
      }
   
View Full Code Here


        try {
            String value = ele.requiredTextContent();
            if (value != null) {
                this.dataID = new URI(value);
            } else {
                throw new GFacProviderException(
                        "Illegal InputMessage, No value content found for the parameter "
                                + ele.getName() + "/value. Invalid Local Argument");
            }
            String location = ele.getAttributeValue(null, DataIDType.LOCATION_ATTRIBUTE);
            if (location != null) {
                addDataLocation(new URI(location));
            }
        } catch (URISyntaxException e) {
            throw new GFacProviderException("Invalid Local Argument", e);
        }
    }
View Full Code Here

            FileUploader fileUploader = new FileUploader(
                uriWithoutProtocol, "input/" + fileName,
                Mode.overwrite);
            fileUploader.perform(storageClient);
          } catch (FileNotFoundException e3) {
            throw new GFacProviderException(
                "Error while staging-in, local file "+fileName+" not found", e3);
          } catch (Exception e) {
            throw new GFacProviderException("Cannot upload files", e);

          }

        }
      }
View Full Code Here

        try {
          fileDownloader.perform(storageClient);
           ((StringParameterType) outParam.getType()).setValue(outputLocation);
            stringMap.put(paramKey, outParam);
        } catch (Exception e) {
          throw new GFacProviderException(e.getLocalizedMessage(),e);
        }
      }

      else if ("StringArray".equals(paramDataType)) {
        String[] valueArray = ((StringArrayType) outParam.getType())
            .getValueArray();
        for (String v : valueArray) {
          String localFileName = v.substring(v.lastIndexOf("/")+1);;
          String outputLocation = downloadLocation+File.separator+localFileName;
          FileDownloader fileDownloader = new FileDownloader("output/"+v,outputLocation, Mode.overwrite);
          try {
            fileDownloader.perform(storageClient);
             ((StringParameterType) outParam.getType()).setValue(outputLocation);
            stringMap.put(paramKey, outParam);
          } catch (Exception e) {
            throw new GFacProviderException(e.getLocalizedMessage(),e);
          }
        }
      }
    }
     if (stringMap == null || stringMap.isEmpty()) {
             throw new GFacProviderException("Empty Output returned from the Application, Double check the application" +
                     "and ApplicationDescriptor output Parameter Names");
         }
   
    downloadStdOuts();
  }
View Full Code Here

    try {
      f1.perform(storageClient);
      String stdoutput = readFile(stdoutLocation);
      appDesc.setStandardOutput(stdoutput);
    } catch (Exception e) {
      throw new GFacProviderException(e.getLocalizedMessage(),e);
    }
    String stderrLocation = downloadLocation+File.separator+stderrFileName;
    FileDownloader f2 = new FileDownloader("output/"+stderrFileName,stderrLocation, Mode.overwrite);
    try {
      f2.perform(storageClient);
      String stderror = readFile(stderrLocation);
      appDesc.setStandardError(stderror);
    } catch (Exception e) {
      throw new GFacProviderException(e.getLocalizedMessage(),e);
    }
  }
View Full Code Here

        try {
            try {
                sc = storageCreator.createStorage();
            } catch (Exception e2) {
                log.error("Cannot create storage..");
                throw new GFacProviderException("Cannot create storage..", e2);
            }

            CreateActivityDocument cad = CreateActivityDocument.Factory.newInstance();
            JobDefinitionDocument jobDefDoc = JobDefinitionDocument.Factory.newInstance();

            JobDefinitionType jobDefinition = jobDefDoc.addNewJobDefinition();
            try {
                jobDefinition = JSDLGenerator.buildJSDLInstance(jobExecutionContext, sc.getUrl()).getJobDefinition();
                cad.addNewCreateActivity().addNewActivityDocument().setJobDefinition(jobDefinition);

                log.info("JSDL" + jobDefDoc.toString());
            } catch (Exception e1) {
                throw new GFacProviderException("Cannot generate JSDL instance from the JobExecutionContext.", e1);
            }

            // upload files if any
            DataTransferrer dt = new DataTransferrer(jobExecutionContext, sc);
            dt.uploadLocalFiles();

            FactoryClient factory = null;
            try {
                factory = new FactoryClient(eprt, secProperties);
            } catch (Exception e) {
                throw new GFacProviderException(e.getLocalizedMessage(), e);
            }

            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) {
                throw new GFacProviderException("Cannot create activity.", e);
            }
            EndpointReferenceType activityEpr = response.getCreateActivityResponse().getActivityIdentifier();

            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("JobID: " + jobId);
            jobExecutionContext.getNotifier().publish(new UnicoreJobIDEvent(jobId));
            saveApplicationJob(jobExecutionContext, jobDefinition, activityEpr.toString());

            factory.getActivityStatus(activityEpr);
            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)
                    && (factory.getActivityStatus(activityEpr) != ActivityStateEnumeration.CANCELLED)) {

                ActivityStatusType activityStatus = null;
                try {
                    activityStatus = getStatus(factory, activityEpr);
                    ApplicationJobStatus applicationJobStatus = getApplicationJobStatus(activityStatus);
                    String jobStatusMessage = "Status of job " + jobId + "is " + applicationJobStatus;
                    jobExecutionContext.getNotifier().publish(new StatusChangeEvent(jobStatusMessage));
                    GFacUtils.updateApplicationJobStatus(jobExecutionContext, jobId, applicationJobStatus);
                } catch (UnknownActivityIdentifierFault e) {
                    throw new GFacProviderException(e.getMessage(), e.getCause());
                }

                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                }
                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)) {
                String error = activityStatus.getFault().getFaultcode().getLocalPart() + "\n"
                        + activityStatus.getFault().getFaultstring() + "\n EXITCODE: " + activityStatus.getExitCode();
                log.info(error);
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                }
                dt.downloadStdOuts();
            } else if (activityStatus.getState() == ActivityStateEnumeration.CANCELLED) {
                String experimentID = (String) jobExecutionContext.getProperty(Constants.PROP_TOPIC);
                ApplicationJobStatus applicationJobStatus = ApplicationJobStatus.CANCELED;
                String jobStatusMessage = "Status of job " + jobId + "is " + applicationJobStatus;
                jobExecutionContext.getNotifier().publish(new StatusChangeEvent(jobStatusMessage));
                GFacUtils.updateApplicationJobStatus(jobExecutionContext, jobId, applicationJobStatus);
                throw new GFacProviderException(experimentID + "Job Canceled");
            }

            else if (activityStatus.getState() == ActivityStateEnumeration.FINISHED) {
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                }
                if (activityStatus.getExitCode() == 0) {
                    dt.downloadRemoteFiles();
                } else {
                    dt.downloadStdOuts();
                }
            }

        } catch (UnknownActivityIdentifierFault e1) {
            throw new GFacProviderException(e1.getLocalizedMessage(), e1);
        } finally {
            // destroy sms instance
            try {
                if (sc != null) {
                    sc.destroy();
View Full Code Here

            epr.addNewAddress().setStringValue(factoryUrl);

            FactoryClient factory = new FactoryClient(epr, secProperties);
            factory.terminateActivity(eprt);
        } catch (Exception e) {
            throw new GFacProviderException(e.getLocalizedMessage(),e);
        }

    }
View Full Code Here

            // may be use the below method before downloading for checking
            // the number of entries
            // sms.listDirectory(".");

        } catch (Exception e) {
            throw new GFacProviderException(e.getLocalizedMessage(), e);
        }
    }
View Full Code Here

            outHandlerLst.add("de.fzj.unicore.uas.security.ProxyCertOutHandler");

            secProperties.setOutHandlerClassNames(outHandlerLst.toArray(new String[outHandlerLst.size()]));

        } catch (Exception e) {
            throw new GFacProviderException(e.getMessage(), e);
        }
    }
View Full Code Here

                    }

                }
            } catch (URISyntaxException e) {
                log.error(e.getMessage());
                throw new GFacProviderException(e.getMessage(), e);
            } catch (ToolsException e) {
                log.error(e.getMessage());
                throw new GFacProviderException(e.getMessage(), e);
            }
            outputNew.getParameters().put(paramName, actualParameter);
        }
        jobExecutionContext.setOutMessageContext(outputNew);
    }
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.