Package org.apache.airavata.model.appcatalog.appinterface

Examples of org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription$ApplicationInterfaceDescriptionTupleScheme


        ApplicationModule amodule = DocumentCreatorUtils.createApplicationModule("Amber", "12.0", null);
        amodule.setAppModuleId(client.registerApplicationModule(amodule));


        ApplicationInterfaceDescription application = new ApplicationInterfaceDescription();
        application.setApplicationName("AmberTrestles");
        application.addToApplicationModules(amodule.getAppModuleId());
        application.addToApplicationInputs(DocumentCreatorUtils.createAppInput("AMBER_HEAT_RST", "AMBER_HEAT_RST", null, null, DataType.URI));
        application.addToApplicationInputs(DocumentCreatorUtils.createAppInput("AMBER_PROD_IN", "AMBER_PROD_IN", null, null, DataType.URI));
        application.addToApplicationInputs(DocumentCreatorUtils.createAppInput("AMBER_PRMTOP", "AMBER_PRMTOP", null, null, DataType.URI));
        application.addToApplicationOutputs(DocumentCreatorUtils.createAppOutput("AMBER_Prod.info", null, DataType.URI));
        application.addToApplicationOutputs(DocumentCreatorUtils.createAppOutput("AMBER_Prod.mdcrd", null, DataType.URI));
        application.addToApplicationOutputs(DocumentCreatorUtils.createAppOutput("AMBER_Prod.out", null, DataType.URI));
        application.addToApplicationOutputs(DocumentCreatorUtils.createAppOutput("AMBER_Prod.rst", null, DataType.URI));
        application.setApplicationInterfaceId(client.registerApplicationInterface(application));

        ApplicationDeploymentDescription deployment = DocumentCreatorUtils.createApplicationDeployment(host.getComputeResourceId(), amodule.getAppModuleId(), "/home/ogce/production/app_wrappers/amber_wrapper.sh", ApplicationParallelismType.SERIAL, "AmberStampede");
        deployment.setAppDeploymentId(client.registerApplicationDeployment(deployment));

        client.addGatewayComputeResourcePreference(getGatewayResourceProfile().getGatewayID(), host.getComputeResourceId(), DocumentCreatorUtils.createComputeResourcePreference(host.getComputeResourceId(), "/oasis/scratch/trestles/ogce/temp_project/", "sds128", false, null, null, null));


        return host.getComputeResourceId() + "," + application.getApplicationInterfaceId();

    }
View Full Code Here


        try {
            appCatalog = AppCatalogFactory.getAppCatalog();
            ApplicationDeployment applicationDeployment = appCatalog.getApplicationDeployment();
            Map<String, String> allComputeResources = appCatalog.getComputeResource().getAllComputeResourceIdList();
            Map<String, String> availableComputeResources = new HashMap<String, String>();
            ApplicationInterfaceDescription applicationInterface =
                    appCatalog.getApplicationInterface().getApplicationInterface(appInterfaceId);
            HashMap<String, String> filters = new HashMap<String,String>();
            List<String> applicationModules = applicationInterface.getApplicationModules();
            if (applicationModules != null && !applicationModules.isEmpty()){
                for (String moduleId : applicationModules) {
                    filters.put(AbstractResource.ApplicationDeploymentConstants.APP_MODULE_ID, moduleId);
                    List<ApplicationDeploymentDescription> applicationDeployments =
                            applicationDeployment.getApplicationDeployements(filters);
View Full Code Here

    @Test
    public void testAppInterface(){
        try {
            ApplicationInterface appInterface = appcatalog.getApplicationInterface();
            ApplicationInterfaceDescription description = new ApplicationInterfaceDescription();
            String wrfModuleId = addAppModule("WRF");
            String amberModuleId = addAppModule("AMBER");
            List<String> modules = new ArrayList<String>();
            modules.add(wrfModuleId);
            modules.add(amberModuleId);
            InputDataObjectType appInput1 = createAppInput("input1", "input1", DataType.STRING);
            InputDataObjectType appInput2 = createAppInput("input2", "input2", DataType.INTEGER);
            List<InputDataObjectType> inputs = new ArrayList<InputDataObjectType>();
            inputs.add(appInput1);
            inputs.add(appInput2);
            OutputDataObjectType output1 = createAppOutput("output1", "", DataType.STRING);
            OutputDataObjectType output2 = createAppOutput("output2", "", DataType.STRING);
            List<OutputDataObjectType> outputs = new ArrayList<OutputDataObjectType>();
            outputs.add(output1);
            outputs.add(output2);
            description.setApplicationName("testApplication");
            description.setApplicationDesription("my testApplication");
            description.setApplicationModules(modules);
            description.setApplicationInputs(inputs);
            description.setApplicationOutputs(outputs);
            String appID = appInterface.addApplicationInterface(description);
            System.out.println("********** application id ************* : " + appID);
            ApplicationInterfaceDescription ainterface = null;
            if (appInterface.isApplicationInterfaceExists(appID)){
                ainterface = appInterface.getApplicationInterface(appID);
                System.out.println("********** application name ************* : " + ainterface.getApplicationName());
                System.out.println("********** application description ************* : " + ainterface.getApplicationDesription());
            }
            ApplicationModule wrfModule = appInterface.getApplicationModule(wrfModuleId);
            System.out.println("********** WRF module name ************* : " + wrfModule.getAppModuleName());
            ApplicationModule amberModule = appInterface.getApplicationModule(amberModuleId);
            System.out.println("********** Amber module name ************* : " + amberModule.getAppModuleName());

            List<InputDataObjectType> applicationInputs = appInterface.getApplicationInputs(appID);
            System.out.println("********** App Input size ************* : " + applicationInputs.size());

            List<OutputDataObjectType> applicationOutputs = appInterface.getApplicationOutputs(appID);
            System.out.println("********** App output size ************* : " + applicationOutputs.size());

            description.setApplicationName("testApplication2");
            appInterface.updateApplicationInterface(appID, description);
            if (appInterface.isApplicationInterfaceExists(appID)){
                ainterface = appInterface.getApplicationInterface(appID);
                System.out.println("********** updated application name ************* : " + ainterface.getApplicationName());
            }

            wrfModule.setAppModuleVersion("1.0.1");
            appInterface.updateApplicationModule(wrfModuleId, wrfModule);
            wrfModule = appInterface.getApplicationModule(wrfModuleId);
View Full Code Here

        module.setAppModuleVersion(resource.getModuleVersion());
        return module;
    }

    public static ApplicationInterfaceDescription getApplicationInterfaceDescription (AppInterfaceResource resource) throws AppCatalogException {
        ApplicationInterfaceDescription description = new ApplicationInterfaceDescription();
        description.setApplicationInterfaceId(resource.getInterfaceId());
        description.setApplicationName(resource.getAppName());
        description.setApplicationDesription(resource.getAppDescription());

        AppModuleMappingResource appModuleMappingResource = new AppModuleMappingResource();
        List<Resource> appModules = appModuleMappingResource.get(AbstractResource.AppModuleMappingConstants.INTERFACE_ID, resource.getInterfaceId());
        if (appModules != null && !appModules.isEmpty()){
            description.setApplicationModules(getAppModuleIds(appModules));
        }

        ApplicationInputResource inputResource = new ApplicationInputResource();
        List<Resource> appInputs = inputResource.get(AbstractResource.AppInputConstants.INTERFACE_ID, resource.getInterfaceId());
        if (appInputs != null && !appInputs.isEmpty()){
            description.setApplicationInputs(getAppInputs(appInputs));
        }

        ApplicationOutputResource outputResource = new ApplicationOutputResource();
        List<Resource> appOutputs = outputResource.get(AbstractResource.AppOutputConstants.INTERFACE_ID, resource.getInterfaceId());
        if (appOutputs != null && !appOutputs.isEmpty()){
            description.setApplicationOutputs(getAppOutputs(appOutputs));
        }
        return description;
    }
View Full Code Here

    return applicationDeploymentDescription;
  }

  private String getModuleId(AppCatalog appCatalog, String applicationId)
      throws AppCatalogException, OrchestratorException {
    ApplicationInterfaceDescription applicationInterface = appCatalog.getApplicationInterface().getApplicationInterface(applicationId);
    List<String> applicationModules = applicationInterface.getApplicationModules();
    if (applicationModules.size()==0){
      throw new OrchestratorException(
          "No modules defined for application "
              + applicationId);
    }
View Full Code Here

    }

    public static ApplicationInterfaceDescription createApplicationInterfaceDescription
            (String applicationName, String applicationDesription, List<String> applicationModules,
            List<InputDataObjectType> applicationInputs, List<OutputDataObjectType>applicationOutputs) {
        ApplicationInterfaceDescription applicationInterfaceDescription = new ApplicationInterfaceDescription();

        applicationInterfaceDescription.setApplicationName(applicationName);
        if (applicationDesription != null) applicationInterfaceDescription.setApplicationDesription(applicationDesription);
        if (applicationModules != null) applicationInterfaceDescription.setApplicationModules(applicationModules);
        if (applicationInputs != null) applicationInterfaceDescription.setApplicationInputs(applicationInputs);
        if (applicationOutputs != null) applicationInterfaceDescription.setApplicationOutputs(applicationOutputs);

        return applicationInterfaceDescription;
    }
View Full Code Here

        }

        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
                                    (resourceJobManager.getResourceJobManagerType().name());
                            ((GsisshHostType) legacyHostDescription.getType()).setInstalledPath(resourceJobManager.getJobManagerBinPath());
                            // applicationDescription.setInstalledParentPath(resourceJobManager.getJobManagerBinPath());
                            ((GsisshHostType) legacyHostDescription.getType()).setPort(sshJobSubmission.getSshPort());
                            break;
                        case SSH_KEYS:
                            legacyHostDescription = new HostDescription(SSHHostType.type);
                            ((SSHHostType) legacyHostDescription.getType()).setHpcResource(true);
                            break;
                        default:
                            legacyHostDescription = new HostDescription(SSHHostType.type);
                            ((SSHHostType) legacyHostDescription.getType()).setHpcResource(true);
                            break;
                    }
                    break;
                default:
                    break;
            }
        }
        HostDescriptionType legacyHostDescType = legacyHostDescription.getType();
        legacyHostDescType.setHostName(computeResource.getHostName());
        String ipAddress = computeResource.getHostName();
        if (computeResource.getIpAddresses() != null && computeResource.getIpAddresses().size() > 0) {
            ipAddress = computeResource.getIpAddresses().iterator().next();
        } else if (computeResource.getHostAliases() != null && computeResource.getHostAliases().size() > 0) {
            ipAddress = computeResource.getHostAliases().iterator().next();
        }
        legacyHostDescType.setHostAddress(ipAddress);

        /////////////////////---------------- APPLICATION DESCRIPTOR ---------------------/////////////////////////
        //Fetch deployment information and fill-in legacy doc
        if ((legacyHostDescType instanceof GsisshHostType) || (legacyHostDescType instanceof SSHHostType)) {
            legacyAppDescription = new ApplicationDescription(HpcApplicationDeploymentType.type);
            HpcApplicationDeploymentType legacyHPCAppDescType = (HpcApplicationDeploymentType) legacyAppDescription.getType();
            switch (applicationDeployment.getParallelism()) {
                case SERIAL:
                    legacyHPCAppDescType.setJobType(JobTypeType.SERIAL);
                    break;
                case MPI:
                    legacyHPCAppDescType.setJobType(JobTypeType.MPI);
                    break;
                case OPENMP:
                    legacyHPCAppDescType.setJobType(JobTypeType.OPEN_MP);
                    break;
                default:
                    break;
            }
            //Fetch scheduling information from experiment request
            ComputationalResourceScheduling taskSchedule = taskData.getTaskScheduling();
            QueueType queueType = legacyHPCAppDescType.addNewQueue();
            queueType.setQueueName(taskSchedule.getQueueName());
            legacyHPCAppDescType.setCpuCount(taskSchedule.getTotalCPUCount());
            legacyHPCAppDescType.setNodeCount(taskSchedule.getNodeCount());
            legacyHPCAppDescType.setMaxWallTime(taskSchedule.getWallTimeLimit());
            if (resourceJobManager != null) {
                legacyHPCAppDescType.setInstalledParentPath(resourceJobManager.getJobManagerBinPath());
                if (resourceJobManager.getJobManagerCommands() != null) {
                    legacyHPCAppDescType.setJobSubmitterCommand(resourceJobManager.getJobManagerCommands().get(JobManagerCommand.SUBMISSION));
                }
            }
            ProjectAccountType projectAccountType = legacyHPCAppDescType.addNewProjectAccount();
            if (gatewayResourcePreferences != null) {
                projectAccountType.setProjectAccountNumber(gatewayResourcePreferences.getAllocationProjectNumber());
            }
        } else {
            legacyAppDescription = new ApplicationDescription();
        }
        ApplicationDeploymentDescriptionType legacyAppDescType = legacyAppDescription.getType();
        legacyAppDescType.addNewApplicationName().setStringValue(applicationInterface.getApplicationName().replaceAll(" ", "_"));
        legacyAppDescType.setExecutableLocation(applicationDeployment.getExecutablePath());
        if (gatewayResourcePreferences != null) {
            legacyAppDescType.setScratchWorkingDirectory(gatewayResourcePreferences.getScratchLocation());
        } else {
            legacyAppDescType.setScratchWorkingDirectory("/tmp");
View Full Code Here

public class AppInterfaceUtil {
    public static ApplicationInterfaceDescription createAppInterface (String applicationName,
                                                                      List<String> appModules,
                                                                      List<InputDataObjectType> appInputs,
                                                                      List<OutputDataObjectType> appOutputs){
        ApplicationInterfaceDescription interfaceDescription = new ApplicationInterfaceDescription();
        interfaceDescription.setApplicationName(applicationName);
        interfaceDescription.setApplicationModules(appModules);
        interfaceDescription.setApplicationInputs(appInputs);
        interfaceDescription.setApplicationOutputs(appOutputs);
        return interfaceDescription;
    }
View Full Code Here

TOP

Related Classes of org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription$ApplicationInterfaceDescriptionTupleScheme

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.