Search in sources :

Example 1 with ApplicationDeploymentDescription

use of org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription in project airavata by apache.

the class AiravataServerHandler method getApplicationDeployment.

/**
 * Fetch a Application Deployment.
 *
 * @param appDeploymentId The identifier for the requested application module
 * @return applicationDeployment
 * Returns a application Deployment Object.
 */
@Override
@SecurityCheck
public ApplicationDeploymentDescription getApplicationDeployment(AuthzToken authzToken, String appDeploymentId) throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
    RegistryService.Client regClient = registryClientPool.getResource();
    try {
        ApplicationDeploymentDescription result = regClient.getApplicationDeployment(appDeploymentId);
        registryClientPool.returnResource(regClient);
        return result;
    } catch (Exception e) {
        logger.error(appDeploymentId, "Error while retrieving application deployment...", e);
        AiravataSystemException exception = new AiravataSystemException();
        exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
        exception.setMessage("Error while retrieving application deployment. More info : " + e.getMessage());
        registryClientPool.returnBrokenResource(regClient);
        throw exception;
    }
}
Also used : ApplicationDeploymentDescription(org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription) RegistryService(org.apache.airavata.registry.api.RegistryService) SharingRegistryService(org.apache.airavata.sharing.registry.service.cpi.SharingRegistryService) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) CredentialStoreException(org.apache.airavata.credential.store.exception.CredentialStoreException) AiravataException(org.apache.airavata.common.exception.AiravataException) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) SecurityCheck(org.apache.airavata.service.security.interceptor.SecurityCheck)

Example 2 with ApplicationDeploymentDescription

use of org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription in project airavata by apache.

the class ApplicationProcessor method isParallelJob.

public static boolean isParallelJob(ProcessContext context) {
    ApplicationDeploymentDescription appDep = context.getApplicationDeploymentDescription();
    ApplicationParallelismType parallelism = appDep.getParallelism();
    boolean isParallel = false;
    if (parallelism.equals(ApplicationParallelismType.MPI) || parallelism.equals(ApplicationParallelismType.OPENMP_MPI) || parallelism.equals(ApplicationParallelismType.OPENMP)) {
        isParallel = true;
    }
    return isParallel;
}
Also used : ApplicationDeploymentDescription(org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription) ApplicationParallelismType(org.apache.airavata.model.parallelism.ApplicationParallelismType)

Example 3 with ApplicationDeploymentDescription

use of org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription in project airavata by apache.

the class ApplicationProcessor method generateJobSpecificAppElements.

public static void generateJobSpecificAppElements(JobDefinitionType value, ProcessContext context) {
    String userName = getUserNameFromContext(context);
    // if (userName.equalsIgnoreCase("admin")){
    // userName = "CN=zdv575, O=Ultrascan Gateway, C=DE";
    // }
    ApplicationDeploymentDescription appDep = context.getApplicationDeploymentDescription();
    String appname = context.getApplicationInterfaceDescription().getApplicationName();
    ApplicationParallelismType parallelism = appDep.getParallelism();
    ApplicationType appType = JSDLUtils.getOrCreateApplication(value);
    appType.setApplicationName(appname);
    // if (appDep.getSetEnvironment().size() > 0) {
    // createApplicationEnvironment(value, appDep.getSetEnvironment(), parallelism);
    // }
    // 
    String stdout = context.getStdoutLocation();
    String stderr = context.getStderrLocation();
    if (stdout != null) {
        stdout = stdout.substring(stdout.lastIndexOf('/') + 1);
    }
    if (stderr != null) {
        stderr = stderr.substring(stderr.lastIndexOf('/') + 1);
    }
    stdout = (stdout == null || stdout.equals("")) ? "stdout" : stdout;
    stderr = (stdout == null || stderr.equals("")) ? "stderr" : stderr;
    if (appDep.getExecutablePath() != null) {
        FileNameType fNameType = FileNameType.Factory.newInstance();
        fNameType.setStringValue(appDep.getExecutablePath());
        if (isParallelJob(context)) {
            JSDLUtils.getOrCreateSPMDApplication(value).setExecutable(fNameType);
            if (parallelism.equals(ApplicationParallelismType.OPENMP_MPI)) {
                JSDLUtils.getSPMDApplication(value).setSPMDVariation(SPMDVariations.OpenMPI.value());
            } else if (parallelism.equals(ApplicationParallelismType.MPI)) {
                JSDLUtils.getSPMDApplication(value).setSPMDVariation(SPMDVariations.MPI.value());
            }
            // setting number of processes
            try {
                String np = getInputAsString(context, BESConstants.NUMBER_OF_PROCESSES);
                if ((np != null) && (Integer.parseInt(np) > 0)) {
                    NumberOfProcessesType num = NumberOfProcessesType.Factory.newInstance();
                    num.setStringValue(np);
                    JSDLUtils.getSPMDApplication(value).setNumberOfProcesses(num);
                }
            } catch (RuntimeException np) {
            // do nothing
            }
            try {
                // setting processes per host
                String pphost = getInputAsString(context, BESConstants.PROCESSES_PER_HOST);
                if ((pphost != null) && (Integer.parseInt(pphost) > 0)) {
                    ProcessesPerHostType pph = ProcessesPerHostType.Factory.newInstance();
                    pph.setStringValue(String.valueOf(pphost));
                    JSDLUtils.getSPMDApplication(value).setProcessesPerHost(pph);
                }
            } catch (RuntimeException np) {
            // do nothing
            }
            int totalThreadCount = context.getProcessModel().getProcessResourceSchedule().getNumberOfThreads();
            // we take it as threads per processes
            if (totalThreadCount > 0) {
                ThreadsPerProcessType tpp = ThreadsPerProcessType.Factory.newInstance();
                tpp.setStringValue(String.valueOf(totalThreadCount));
                JSDLUtils.getSPMDApplication(value).setThreadsPerProcess(tpp);
            }
            if (userName != null) {
                UserNameType userNameType = UserNameType.Factory.newInstance();
                userNameType.setStringValue(userName);
                JSDLUtils.getSPMDApplication(value).setUserName(userNameType);
            }
            if (stdout != null) {
                FileNameType fName = FileNameType.Factory.newInstance();
                fName.setStringValue(stdout);
                JSDLUtils.getOrCreateSPMDApplication(value).setOutput(fName);
            }
            if (stderr != null) {
                FileNameType fName = FileNameType.Factory.newInstance();
                fName.setStringValue(stderr);
                JSDLUtils.getOrCreateSPMDApplication(value).setError(fName);
            }
        } else {
            JSDLUtils.getOrCreatePOSIXApplication(value).setExecutable(fNameType);
            if (userName != null) {
                UserNameType userNameType = UserNameType.Factory.newInstance();
                userNameType.setStringValue(userName);
                JSDLUtils.getOrCreatePOSIXApplication(value).setUserName(userNameType);
            }
            if (stdout != null) {
                FileNameType fName = FileNameType.Factory.newInstance();
                fName.setStringValue(stdout);
                JSDLUtils.getOrCreatePOSIXApplication(value).setOutput(fName);
            }
            if (stderr != null) {
                FileNameType fName = FileNameType.Factory.newInstance();
                fName.setStringValue(stderr);
                JSDLUtils.getOrCreatePOSIXApplication(value).setError(fName);
            }
        }
    }
}
Also used : ApplicationType(org.ggf.schemas.jsdl.x2005.x11.jsdl.ApplicationType) ApplicationDeploymentDescription(org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription) FileNameType(org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.FileNameType) UserNameType(org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.UserNameType) ThreadsPerProcessType(org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.ThreadsPerProcessType) NumberOfProcessesType(org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.NumberOfProcessesType) ApplicationParallelismType(org.apache.airavata.model.parallelism.ApplicationParallelismType) ProcessesPerHostType(org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.ProcessesPerHostType)

Example 4 with ApplicationDeploymentDescription

use of org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription in project airavata by apache.

the class AiravataIT method testAddApplication.

@org.testng.annotations.Test(priority = 4)
public void testAddApplication() {
    try {
        logger.info("testAddApplication() -> Adding test application......");
        applicationProperties = setup.getApplicationRegister().addApplications();
        ;
        Assert.assertNotNull(applicationProperties);
        ApplicationModule applicationModule = setup.getApplicationRegister().getApplicationModule(applicationProperties.getApplicationModuleId());
        Assert.assertNotNull(applicationModule);
        Assert.assertEquals(applicationModule.getAppModuleName(), TestFrameworkConstants.AppcatalogConstants.LOCAL_ECHO_NAME);
        Assert.assertEquals(applicationModule.getAppModuleVersion(), LOCAL_ECHO_VERSION);
        Assert.assertEquals(applicationModule.getAppModuleDescription(), TestFrameworkConstants.AppcatalogConstants.LOCAL_ECHO_DESCRIPTION);
        Assert.assertEquals(applicationModule.getAppModuleName(), TestFrameworkConstants.AppcatalogConstants.LOCAL_ECHO_NAME);
        ApplicationInterfaceDescription applicationInterfaceDescription = setup.getApplicationRegister().getApplicationInterfaceDescription(applicationProperties.getApplicationInterfaceId());
        Assert.assertNotNull(applicationInterfaceDescription);
        Assert.assertEquals(applicationInterfaceDescription.getApplicationName(), TestFrameworkConstants.AppcatalogConstants.LOCAL_ECHO_NAME);
        Assert.assertEquals(applicationInterfaceDescription.getApplicationDescription(), TestFrameworkConstants.AppcatalogConstants.LOCAL_ECHO_DESCRIPTION);
        InputDataObjectType input = applicationInterfaceDescription.getApplicationInputs().get(0);
        Assert.assertNotNull(input);
        Assert.assertEquals(input.getName(), INPUT_NAME);
        Assert.assertEquals(input.getValue(), INPUT_VALUE);
        Assert.assertEquals(input.getType(), DataType.STRING);
        Assert.assertEquals(input.getApplicationArgument(), null);
        Assert.assertEquals(input.getInputOrder(), 0);
        Assert.assertEquals(input.isIsRequired(), true);
        Assert.assertEquals(input.isRequiredToAddedToCommandLine(), true);
        Assert.assertEquals(input.isStandardInput(), false);
        Assert.assertEquals(input.getUserFriendlyDescription(), INPUT_DESC);
        Assert.assertEquals(input.getMetaData(), null);
        List<OutputDataObjectType> outputDataObjectTypes = applicationInterfaceDescription.getApplicationOutputs();
        Assert.assertNotNull(outputDataObjectTypes.get(0));
        Assert.assertEquals(outputDataObjectTypes.get(0).getName(), STDERR_NAME);
        Assert.assertEquals(outputDataObjectTypes.get(0).getValue(), STDERR_VALUE);
        Assert.assertEquals(outputDataObjectTypes.get(0).getType(), DataType.URI);
        Assert.assertEquals(outputDataObjectTypes.get(0).isIsRequired(), true);
        Assert.assertEquals(outputDataObjectTypes.get(0).isRequiredToAddedToCommandLine(), true);
        Assert.assertEquals(outputDataObjectTypes.get(0).getApplicationArgument(), null);
        Assert.assertNotNull(outputDataObjectTypes.get(1));
        Assert.assertEquals(outputDataObjectTypes.get(1).getName(), STDOUT_NAME);
        Assert.assertEquals(outputDataObjectTypes.get(1).getValue(), STDOUT_VALUE);
        Assert.assertEquals(outputDataObjectTypes.get(1).getType(), DataType.URI);
        Assert.assertEquals(outputDataObjectTypes.get(1).isIsRequired(), true);
        Assert.assertEquals(outputDataObjectTypes.get(1).isRequiredToAddedToCommandLine(), true);
        Assert.assertEquals(outputDataObjectTypes.get(1).getApplicationArgument(), null);
        ApplicationDeploymentDescription applicationDeploymentDescription = setup.getApplicationRegister().getApplicationDeploymentDescription(applicationProperties.getApplicationDeployId());
        Assert.assertNotNull(applicationDeploymentDescription);
        Assert.assertEquals(applicationDeploymentDescription.getExecutablePath(), TestFrameworkConstants.LOCAL_ECHO_JOB_FILE_PATH);
        Assert.assertEquals(applicationDeploymentDescription.getParallelism(), ApplicationParallelismType.SERIAL);
        Assert.assertEquals(applicationDeploymentDescription.getAppDeploymentDescription(), TestFrameworkConstants.AppcatalogConstants.LOCAL_ECHO_DESCRIPTION);
        Assert.assertEquals(applicationDeploymentDescription.getModuleLoadCmds(), null);
        Assert.assertEquals(applicationDeploymentDescription.getPostJobCommands(), null);
        Assert.assertEquals(applicationDeploymentDescription.getPreJobCommands(), null);
        logger.info("testAddApplication() -> Adding test application." + applicationProperties.toString());
    } catch (Exception e) {
        logger.error("Error occured while testAddApplication", e);
        Assert.fail();
    }
}
Also used : ApplicationDeploymentDescription(org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) ApplicationInterfaceDescription(org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription) ApplicationModule(org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule)

Example 5 with ApplicationDeploymentDescription

use of org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription in project airavata by apache.

the class ApplicationProcessor method isParallelJob.

public static boolean isParallelJob(JobExecutionContext context) {
    ApplicationDeploymentDescription appDep = context.getApplicationContext().getApplicationDeploymentDescription();
    ApplicationParallelismType parallelism = appDep.getParallelism();
    boolean isParallel = false;
    if (parallelism.equals(ApplicationParallelismType.MPI) || parallelism.equals(ApplicationParallelismType.OPENMP_MPI) || parallelism.equals(ApplicationParallelismType.OPENMP)) {
        isParallel = true;
    }
    return isParallel;
}
Also used : ApplicationDeploymentDescription(org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription) ApplicationParallelismType(org.apache.airavata.model.appcatalog.appdeployment.ApplicationParallelismType)

Aggregations

ApplicationDeploymentDescription (org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription)34 ApplicationModule (org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule)13 ApplicationInterfaceDescription (org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription)13 ComputeResourceDescription (org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription)13 ResourceJobManager (org.apache.airavata.model.appcatalog.computeresource.ResourceJobManager)11 SSHJobSubmission (org.apache.airavata.model.appcatalog.computeresource.SSHJobSubmission)10 RegistryServiceException (org.apache.airavata.registry.api.exception.RegistryServiceException)5 TException (org.apache.thrift.TException)4 ArrayList (java.util.ArrayList)3 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)3 ApplicationParallelismType (org.apache.airavata.model.parallelism.ApplicationParallelismType)3 AiravataException (org.apache.airavata.common.exception.AiravataException)2 CommandObject (org.apache.airavata.model.appcatalog.appdeployment.CommandObject)2 JobManagerCommand (org.apache.airavata.model.appcatalog.computeresource.JobManagerCommand)2 ComputeResourcePreference (org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference)2 InputDataObjectType (org.apache.airavata.model.application.io.InputDataObjectType)2 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)2 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)2 Writable (groovy.lang.Writable)1 GStringTemplateEngine (groovy.text.GStringTemplateEngine)1