Search in sources :

Example 1 with NumberOfProcessesType

use of org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.NumberOfProcessesType 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 2 with NumberOfProcessesType

use of org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.NumberOfProcessesType in project airavata by apache.

the class ApplicationProcessor method generateJobSpecificAppElements.

public static void generateJobSpecificAppElements(JobDefinitionType value, JobExecutionContext context) {
    String userName = getUserNameFromContext(context);
    // if (userName.equalsIgnoreCase("admin")){
    // userName = "CN=zdv575, O=Ultrascan Gateway, C=DE";
    // }
    ApplicationDeploymentDescription appDep = context.getApplicationContext().getApplicationDeploymentDescription();
    String appname = context.getApplicationContext().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.getStandardOutput();
    String stderr = context.getStandardError();
    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.getTaskData().getTaskScheduling().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.appcatalog.appdeployment.ApplicationParallelismType) ProcessesPerHostType(org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.ProcessesPerHostType)

Aggregations

ApplicationDeploymentDescription (org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription)2 ApplicationType (org.ggf.schemas.jsdl.x2005.x11.jsdl.ApplicationType)2 FileNameType (org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.FileNameType)2 UserNameType (org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.UserNameType)2 NumberOfProcessesType (org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.NumberOfProcessesType)2 ProcessesPerHostType (org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.ProcessesPerHostType)2 ThreadsPerProcessType (org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.ThreadsPerProcessType)2 ApplicationParallelismType (org.apache.airavata.model.appcatalog.appdeployment.ApplicationParallelismType)1 ApplicationParallelismType (org.apache.airavata.model.parallelism.ApplicationParallelismType)1