Package org.airavata.appcatalog.cpi

Examples of org.airavata.appcatalog.cpi.AppCatalog


        }
        if (null == applicationDeploymentId) {
            throw new GFacException("Error executing the job. The required Application deployment Id is missing");
        }

        AppCatalog appCatalog = AppCatalogFactory.getAppCatalog();

        //fetch the compute resource, application interface and deployment information from app catalog
        ApplicationInterfaceDescription applicationInterface = appCatalog.
                getApplicationInterface().getApplicationInterface(applicationInterfaceId);
        ApplicationDeploymentDescription applicationDeployment = appCatalog.
                getApplicationDeployment().getApplicationDeployement(applicationDeploymentId);
        ComputeResourceDescription computeResource = appCatalog.getComputeResource().
                getComputeResource(applicationDeployment.getComputeHostId());
        ComputeResourcePreference gatewayResourcePreferences = appCatalog.getGatewayProfile().
                getComputeResourcePreference(gatewayID, applicationDeployment.getComputeHostId());
        if (gatewayResourcePreferences == null) {
            List<String> gatewayProfileIds = appCatalog.getGatewayProfile()
                    .getGatewayProfileIds(gatewayID);
            for (String profileId : gatewayProfileIds) {
                gatewayID = profileId;
                gatewayResourcePreferences = appCatalog.getGatewayProfile().
                        getComputeResourcePreference(gatewayID, applicationDeployment.getComputeHostId());
                if (gatewayResourcePreferences != null) {
                    break;
                }
            }
        }
        //Create the legacy schema docs to fill-in
        ServiceDescription legacyServiceDescription = new ServiceDescription();
        ServiceDescriptionType legacyServiceDescType = legacyServiceDescription.getType();
        ApplicationDescription legacyAppDescription = null;
        HostDescription legacyHostDescription = null;

        ///////////////SERVICE DESCRIPTOR///////////////////////////////
        //Fetch the application inputs and outputs from the app interface and create the legacy service description.
        legacyServiceDescType.setName(applicationInterface.getApplicationName());
        legacyServiceDescType.setDescription(applicationInterface.getApplicationName());
        List<InputParameterType> legacyInputParameters = new ArrayList<InputParameterType>();
        List<OutputParameterType> legacyOutputParameters = new ArrayList<OutputParameterType>();
        List<InputDataObjectType> applicationInputs = applicationInterface.getApplicationInputs();
        for (InputDataObjectType dataObjectType : applicationInputs) {
            InputParameterType parameter = InputParameterType.Factory.newInstance();
            parameter.setParameterName(dataObjectType.getName());
            parameter.setParameterDescription(dataObjectType.getUserFriendlyDescription());
            ParameterType parameterType = parameter.addNewParameterType();
            switch (dataObjectType.getType()) {
                case FLOAT:
                    parameterType.setType(DataType.FLOAT);
                    break;
                case INTEGER:
                    parameterType.setType(DataType.INTEGER);
                    break;
                case STRING:
                    parameterType.setType(DataType.STRING);
                    break;
                case URI:
                    parameterType.setType(DataType.URI);
                    break;
            }
            parameterType.setName(parameterType.getType().toString());
            parameter.addParameterValue(dataObjectType.getValue());
            legacyInputParameters.add(parameter);
        }

        List<OutputDataObjectType> applicationOutputs = applicationInterface.getApplicationOutputs();
        for (OutputDataObjectType dataObjectType : applicationOutputs) {
            OutputParameterType parameter = OutputParameterType.Factory.newInstance();
            parameter.setParameterName(dataObjectType.getName());
            parameter.setParameterDescription(dataObjectType.getName());
            ParameterType parameterType = parameter.addNewParameterType();
            switch (dataObjectType.getType()) {
                case FLOAT:
                    parameterType.setType(DataType.FLOAT);
                    break;
                case INTEGER:
                    parameterType.setType(DataType.INTEGER);
                    break;
                case STRING:
                    parameterType.setType(DataType.STRING);
                    break;
                case URI:
                    parameterType.setType(DataType.URI);
                    break;
            }
            parameterType.setName(parameterType.getType().toString());
            legacyOutputParameters.add(parameter);
        }

        legacyServiceDescType.setInputParametersArray(legacyInputParameters.toArray(new InputParameterType[]{}));
        legacyServiceDescType.setOutputParametersArray(legacyOutputParameters.toArray(new OutputParameterType[]{}));

        ////////////////////-----------  HOST DESCRIPTOR  -----------------//////////////////////
        //Fetch the host description details and fill-in legacy doc
        ResourceJobManager resourceJobManager = null;
        for (JobSubmissionInterface jobSubmissionInterface : computeResource.getJobSubmissionInterfaces()) {
            switch (jobSubmissionInterface.getJobSubmissionProtocol()) {
                case LOCAL:
                    legacyHostDescription = new HostDescription();
                    LOCALSubmission localSubmission =
                            appCatalog.getComputeResource().getLocalJobSubmission(jobSubmissionInterface.getJobSubmissionInterfaceId());
                    resourceJobManager = localSubmission.getResourceJobManager();
                    break;
                case SSH:
                    SSHJobSubmission sshJobSubmission =
                            appCatalog.getComputeResource().getSSHJobSubmission(jobSubmissionInterface.getJobSubmissionInterfaceId());
                    resourceJobManager = sshJobSubmission.getResourceJobManager();
                    switch (sshJobSubmission.getSecurityProtocol()) {
                        case GSI:
                            legacyHostDescription = new HostDescription(GsisshHostType.type);
                            ((GsisshHostType) legacyHostDescription.getType()).setJobManager
View Full Code Here


  private ApplicationDeploymentDescription getAppDeployment(
      TaskDetails taskData, String applicationId)
      throws AppCatalogException, OrchestratorException,
      ClassNotFoundException, ApplicationSettingsException,
      InstantiationException, IllegalAccessException {
    AppCatalog appCatalog = AppCatalogFactory.getAppCatalog();
    String selectedModuleId = getModuleId(appCatalog, applicationId);
    ApplicationDeploymentDescription applicationDeploymentDescription = getAppDeployment(
        appCatalog, taskData, selectedModuleId);
    return applicationDeploymentDescription;
  }
View Full Code Here

TOP

Related Classes of org.airavata.appcatalog.cpi.AppCatalog

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.