You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sm...@apache.org on 2013/04/24 12:12:44 UTC
svn commit: r1471342 - in /airavata/trunk/modules/gfac-core: ./
src/main/java/org/apache/airavata/gfac/provider/utils/
src/test/java/org/apache/airavata/core/gfac/services/impl/
Author: smarru
Date: Wed Apr 24 10:12:43 2013
New Revision: 1471342
URL: http://svn.apache.org/r1471342
Log:
undoing a partial committ committed by mistake in eclipse sync
Added:
airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/RangeValueType.java
- copied unchanged from r1471231, airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/RangeValueType.java
Removed:
airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/UCRangeValueType.java
Modified:
airavata/trunk/modules/gfac-core/pom.xml
airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ApplicationProcessor.java
airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/DataStagingProcessor.java
airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/JSDLGenerator.java
airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/JSDLUtils.java
airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ResourceProcessor.java
airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/SPMDProcessor.java
airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/JSDLGeneratorTest.java
Modified: airavata/trunk/modules/gfac-core/pom.xml
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/pom.xml?rev=1471342&r1=1471341&r2=1471342&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/pom.xml (original)
+++ airavata/trunk/modules/gfac-core/pom.xml Wed Apr 24 10:12:43 2013
@@ -135,6 +135,13 @@
<scope>test</scope>
</dependency>
+ <!-- Unicore dependencies -->
+ <dependency>
+ <groupId>eu.unicore</groupId>
+ <artifactId>ogsabes-client</artifactId>
+ <version>1.6.0</version>
+ </dependency>
+
<!-- Hadoop provider related dependencies -->
<dependency>
<groupId>org.apache.hadoop</groupId>
@@ -181,6 +188,11 @@
<artifactId>jopt-simple</artifactId>
<version>3.2</version>
</dependency>
+ <dependency>
+ <groupId>net.sf.wsag4j.types</groupId>
+ <artifactId>wsag4j-jsdl-types</artifactId>
+ <version>2.0.0</version>
+ </dependency>
<!-- Guava -->
<dependency>
<groupId>com.google.guava</groupId>
Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ApplicationProcessor.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ApplicationProcessor.java?rev=1471342&r1=1471341&r2=1471342&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ApplicationProcessor.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ApplicationProcessor.java Wed Apr 24 10:12:43 2013
@@ -17,7 +17,7 @@
* specific language governing permissions and limitations
* under the License.
*
- */
+*/
package org.apache.airavata.gfac.provider.utils;
import java.io.File;
@@ -27,197 +27,206 @@ import org.apache.airavata.schemas.gfac.
import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
import org.apache.airavata.schemas.gfac.JobTypeType;
import org.apache.airavata.schemas.gfac.NameValuePairType;
-import org.ogf.schemas.jsdl.ApplicationType;
-import org.ogf.schemas.jsdl.JobDefinitionType;
-import org.ogf.schemas.jsdl.posix.EnvironmentType;
-import org.ogf.schemas.jsdl.posix.FileNameType;
-import org.ogf.schemas.jsdl.spmd.NumberOfProcessesType;
-import org.ogf.schemas.jsdl.spmd.ProcessesPerHostType;
-import org.ogf.schemas.jsdl.spmd.ThreadsPerProcessType;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.ApplicationType;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionType;
+import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.EnvironmentType;
+import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.FileNameType;
+import org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.NumberOfProcessesType;
+import org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.ProcessesPerHostType;
+import org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.ThreadsPerProcessType;
-public class ApplicationProcessor {
-
- public static void generateJobSpecificAppElements(JobDefinitionType value, JobExecutionContext context) {
-
- HpcApplicationDeploymentType appDepType = (HpcApplicationDeploymentType) context.getApplicationContext()
- .getApplicationDeploymentDescription().getType();
-
- createGenericApplication(value, appDepType);
-
- if (appDepType.getApplicationEnvironmentArray().length > 0) {
- createApplicationEnvironment(value, appDepType.getApplicationEnvironmentArray(), appDepType);
- }
-
- if (appDepType.getExecutableLocation() != null) {
- FileNameType fNameType = FileNameType.Factory.newInstance();
- fNameType.setStringValue(appDepType.getExecutableLocation());
- if (isParallelJob(appDepType)) {
- JSDLUtils.getOrCreateSPMDApplication(value).setExecutable(fNameType);
- JSDLUtils.getSPMDApplication(value).setSPMDVariation(getSPMDVariation(appDepType));
-
- if (getValueFromMap(appDepType, JSDLUtils.NUMBEROFPROCESSES) != null) {
- NumberOfProcessesType num = NumberOfProcessesType.Factory.newInstance();
- num.setStringValue(getValueFromMap(appDepType, JSDLUtils.NUMBEROFPROCESSES));
- JSDLUtils.getSPMDApplication(value).setNumberOfProcesses(num);
- }
-
- if (getValueFromMap(appDepType, JSDLUtils.PROCESSESPERHOST) != null) {
- ProcessesPerHostType pph = ProcessesPerHostType.Factory.newInstance();
- pph.setStringValue(getValueFromMap(appDepType, JSDLUtils.PROCESSESPERHOST));
- JSDLUtils.getSPMDApplication(value).setProcessesPerHost(pph);
- }
-
- if (getValueFromMap(appDepType, JSDLUtils.THREADSPERHOST) != null) {
- ThreadsPerProcessType tpp = ThreadsPerProcessType.Factory.newInstance();
- tpp.setStringValue(getValueFromMap(appDepType, JSDLUtils.THREADSPERHOST));
- JSDLUtils.getSPMDApplication(value).setThreadsPerProcess(tpp);
- }
- } else
- JSDLUtils.getOrCreatePOSIXApplication(value).setExecutable(fNameType);
- }
-
- if (appDepType.getStandardOutput() != null) {
- String stdout = new File(appDepType.getStandardOutput()).getName();
- ApplicationProcessor.setApplicationStdOut(value, appDepType, stdout);
- }
-
- if (appDepType.getStandardError() != null) {
- String stderr = new File(appDepType.getStandardError()).getName();
- ApplicationProcessor.setApplicationStdErr(value, appDepType, stderr);
- }
-
- }
-
- public static boolean isParallelJob(HpcApplicationDeploymentType appDepType) {
-
- boolean isParallel = false;
-
- if (appDepType.getJobType() != null) {
- // TODO set data output directory
- int status = appDepType.getJobType().intValue();
-
- switch (status) {
- // TODO: this check should be done outside this class
- case JobTypeType.INT_MPI:
- case JobTypeType.INT_OPEN_MP:
- isParallel = true;
- break;
-
- case JobTypeType.INT_SERIAL:
- case JobTypeType.INT_SINGLE:
- isParallel = false;
- break;
-
- default:
- isParallel = false;
- break;
- }
- }
- return isParallel;
- }
-
- public static void createApplicationEnvironment(JobDefinitionType value, NameValuePairType[] nameValuePairs,
- HpcApplicationDeploymentType appDepType) {
-
- if (isParallelJob(appDepType)) {
- for (NameValuePairType nv : nameValuePairs) {
- EnvironmentType envType = JSDLUtils.getOrCreateSPMDApplication(value).addNewEnvironment();
- envType.setName(nv.getName());
- envType.setStringValue(nv.getValue());
- }
- } else {
- for (NameValuePairType nv : nameValuePairs) {
- EnvironmentType envType = JSDLUtils.getOrCreatePOSIXApplication(value).addNewEnvironment();
- envType.setName(nv.getName());
- envType.setStringValue(nv.getValue());
- }
- }
-
- }
-
- public static String getSPMDVariation(HpcApplicationDeploymentType appDepType) {
-
- String variation = null;
-
- if (appDepType.getJobType() != null) {
- // TODO set data output directory
- int status = appDepType.getJobType().intValue();
-
- switch (status) {
- // TODO: this check should be done outside this class
- case JobTypeType.INT_MPI:
- variation = SPMDVariations.MPI.value();
- break;
-
- case JobTypeType.INT_OPEN_MP:
- variation = SPMDVariations.OpenMPI.value();
- break;
-
- }
- }
- return variation;
- }
-
- public static void addApplicationArgument(JobDefinitionType value, HpcApplicationDeploymentType appDepType,
- String stringPrm) {
- if (isParallelJob(appDepType))
- JSDLUtils.getOrCreateSPMDApplication(value).addNewArgument().setStringValue(stringPrm);
- else
- JSDLUtils.getOrCreatePOSIXApplication(value).addNewArgument().setStringValue(stringPrm);
-
- }
-
- public static void setApplicationStdErr(JobDefinitionType value, HpcApplicationDeploymentType appDepType,
- String stderr) {
- FileNameType fName = FileNameType.Factory.newInstance();
- fName.setStringValue(stderr);
- if (isParallelJob(appDepType))
- JSDLUtils.getOrCreateSPMDApplication(value).setError(fName);
- else
- JSDLUtils.getOrCreatePOSIXApplication(value).setError(fName);
- }
-
- public static void setApplicationStdOut(JobDefinitionType value, HpcApplicationDeploymentType appDepType,
- String stderr) {
- FileNameType fName = FileNameType.Factory.newInstance();
- fName.setStringValue(stderr);
- if (isParallelJob(appDepType))
- JSDLUtils.getOrCreateSPMDApplication(value).setOutput(fName);
- else
- JSDLUtils.getOrCreatePOSIXApplication(value).setOutput(fName);
- }
-
- public static String getApplicationStdOut(JobDefinitionType value, HpcApplicationDeploymentType appDepType) {
- if (isParallelJob(appDepType))
- return JSDLUtils.getOrCreateSPMDApplication(value).getOutput().getStringValue();
- else
- return JSDLUtils.getOrCreatePOSIXApplication(value).getOutput().getStringValue();
- }
-
- public static String getApplicationStdErr(JobDefinitionType value, HpcApplicationDeploymentType appDepType) {
- if (isParallelJob(appDepType))
- return JSDLUtils.getOrCreateSPMDApplication(value).getError().getStringValue();
- else
- return JSDLUtils.getOrCreatePOSIXApplication(value).getError().getStringValue();
- }
-
- public static void createGenericApplication(JobDefinitionType value, HpcApplicationDeploymentType appDepType) {
- if (appDepType.getApplicationName() != null) {
- ApplicationType appType = JSDLUtils.getOrCreateApplication(value);
- String appName = appDepType.getApplicationName().getStringValue();
- appType.setApplicationName(appName);
- JSDLUtils.getOrCreateJobIdentification(value).setJobName(appName);
- }
- }
-
- public static String getValueFromMap(HpcApplicationDeploymentType appDepType, String name) {
- ExtendedKeyValueType[] extended = appDepType.getKeyValuePairsArray();
- for (ExtendedKeyValueType e : extended) {
- if (e.getName().equalsIgnoreCase(name)) {
- return e.getStringValue();
- }
- }
- return null;
- }
+public class ApplicationProcessor {
+
+ public static void generateJobSpecificAppElements(JobDefinitionType value, JobExecutionContext context){
+
+ HpcApplicationDeploymentType appDepType = (HpcApplicationDeploymentType) context
+ .getApplicationContext().getApplicationDeploymentDescription()
+ .getType();
+
+ createGenericApplication(value, appDepType);
+
+ if (appDepType.getApplicationEnvironmentArray().length > 0) {
+ createApplicationEnvironment(value,
+ appDepType.getApplicationEnvironmentArray(), appDepType);
+ }
+
+
+ if (appDepType.getExecutableLocation() != null) {
+ FileNameType fNameType = FileNameType.Factory.newInstance();
+ fNameType.setStringValue(appDepType.getExecutableLocation());
+ if(isParallelJob(appDepType)) {
+ JSDLUtils.getOrCreateSPMDApplication(value).setExecutable(fNameType);
+ JSDLUtils.getSPMDApplication(value).setSPMDVariation(getSPMDVariation(appDepType));
+
+ if(getValueFromMap(appDepType, JSDLUtils.NUMBEROFPROCESSES)!=null){
+ NumberOfProcessesType num = NumberOfProcessesType.Factory.newInstance();
+ num.setStringValue(getValueFromMap(appDepType, JSDLUtils.NUMBEROFPROCESSES));
+ JSDLUtils.getSPMDApplication(value).setNumberOfProcesses(num);
+ }
+
+ if(getValueFromMap(appDepType, JSDLUtils.PROCESSESPERHOST)!=null){
+ ProcessesPerHostType pph = ProcessesPerHostType.Factory.newInstance();
+ pph.setStringValue(getValueFromMap(appDepType, JSDLUtils.PROCESSESPERHOST));
+ JSDLUtils.getSPMDApplication(value).setProcessesPerHost(pph);
+ }
+
+ if(getValueFromMap(appDepType, JSDLUtils.THREADSPERHOST)!=null){
+ ThreadsPerProcessType tpp = ThreadsPerProcessType.Factory.newInstance();
+ tpp.setStringValue(getValueFromMap(appDepType, JSDLUtils.THREADSPERHOST));
+ JSDLUtils.getSPMDApplication(value).setThreadsPerProcess(tpp);
+ }
+ }
+ else
+ JSDLUtils.getOrCreatePOSIXApplication(value).setExecutable(fNameType);
+ }
+
+ if(appDepType.getStandardOutput() != null) {
+ String stdout = new File(appDepType.getStandardOutput()).getName();
+ ApplicationProcessor.setApplicationStdOut(value, appDepType, stdout);
+ }
+
+ if(appDepType.getStandardError() != null) {
+ String stderr = new File(appDepType.getStandardError()).getName();
+ ApplicationProcessor.setApplicationStdErr(value, appDepType, stderr);
+ }
+
+
+
+
+ }
+
+
+ public static boolean isParallelJob(HpcApplicationDeploymentType appDepType) {
+
+ boolean isParallel = false;
+
+ if (appDepType.getJobType() != null) {
+ // TODO set data output directory
+ int status = appDepType.getJobType().intValue();
+
+ switch (status) {
+ // TODO: this check should be done outside this class
+ case JobTypeType.INT_MPI:
+ case JobTypeType.INT_OPEN_MP:
+ isParallel = true;
+ break;
+
+ case JobTypeType.INT_SERIAL:
+ case JobTypeType.INT_SINGLE:
+ isParallel = false;
+ break;
+
+ default:
+ isParallel = false;
+ break;
+ }
+ }
+ return isParallel;
+ }
+
+
+ public static void createApplicationEnvironment(JobDefinitionType value, NameValuePairType[] nameValuePairs, HpcApplicationDeploymentType appDepType) {
+
+ if(isParallelJob(appDepType)) {
+ for (NameValuePairType nv : nameValuePairs) {
+ EnvironmentType envType = JSDLUtils.getOrCreateSPMDApplication(value).addNewEnvironment();
+ envType.setName(nv.getName());
+ envType.setStringValue(nv.getValue());
+ }
+ }
+ else {
+ for (NameValuePairType nv : nameValuePairs) {
+ EnvironmentType envType = JSDLUtils.getOrCreatePOSIXApplication(value).addNewEnvironment();
+ envType.setName(nv.getName());
+ envType.setStringValue(nv.getValue());
+ }
+ }
+
+ }
+
+
+ public static String getSPMDVariation (HpcApplicationDeploymentType appDepType) {
+
+ String variation = null;
+
+ if (appDepType.getJobType() != null) {
+ // TODO set data output directory
+ int status = appDepType.getJobType().intValue();
+
+ switch (status) {
+ // TODO: this check should be done outside this class
+ case JobTypeType.INT_MPI:
+ variation = SPMDVariations.MPI.value();
+ break;
+
+ case JobTypeType.INT_OPEN_MP:
+ variation = SPMDVariations.OpenMPI.value();
+ break;
+
+ }
+ }
+ return variation;
+ }
+
+
+ public static void addApplicationArgument(JobDefinitionType value, HpcApplicationDeploymentType appDepType, String stringPrm) {
+ if(isParallelJob(appDepType))
+ JSDLUtils.getOrCreateSPMDApplication(value)
+ .addNewArgument().setStringValue(stringPrm);
+ else
+ JSDLUtils.getOrCreatePOSIXApplication(value)
+ .addNewArgument().setStringValue(stringPrm);
+
+ }
+
+ public static void setApplicationStdErr(JobDefinitionType value, HpcApplicationDeploymentType appDepType, String stderr) {
+ FileNameType fName = FileNameType.Factory.newInstance();
+ fName.setStringValue(stderr);
+ if (isParallelJob(appDepType))
+ JSDLUtils.getOrCreateSPMDApplication(value).setError(fName);
+ else
+ JSDLUtils.getOrCreatePOSIXApplication(value).setError(fName);
+ }
+
+ public static void setApplicationStdOut(JobDefinitionType value, HpcApplicationDeploymentType appDepType, String stderr) {
+ FileNameType fName = FileNameType.Factory.newInstance();
+ fName.setStringValue(stderr);
+ if (isParallelJob(appDepType))
+ JSDLUtils.getOrCreateSPMDApplication(value).setOutput(fName);
+ else
+ JSDLUtils.getOrCreatePOSIXApplication(value).setOutput(fName);
+ }
+
+ public static String getApplicationStdOut(JobDefinitionType value, HpcApplicationDeploymentType appDepType) {
+ if (isParallelJob(appDepType)) return JSDLUtils.getOrCreateSPMDApplication(value).getOutput().getStringValue();
+ else return JSDLUtils.getOrCreatePOSIXApplication(value).getOutput().getStringValue();
+ }
+
+ public static String getApplicationStdErr(JobDefinitionType value, HpcApplicationDeploymentType appDepType) {
+ if (isParallelJob(appDepType)) return JSDLUtils.getOrCreateSPMDApplication(value).getError().getStringValue();
+ else return JSDLUtils.getOrCreatePOSIXApplication(value).getError().getStringValue();
+ }
+
+ public static void createGenericApplication(JobDefinitionType value, HpcApplicationDeploymentType appDepType) {
+ if (appDepType.getApplicationName() != null) {
+ ApplicationType appType = JSDLUtils.getOrCreateApplication(value);
+ String appName = appDepType.getApplicationName()
+ .getStringValue();
+ appType.setApplicationName(appName);
+ JSDLUtils.getOrCreateJobIdentification(value).setJobName(appName);
+ }
+ }
+
+
+ public static String getValueFromMap(HpcApplicationDeploymentType appDepType, String name) {
+ ExtendedKeyValueType[] extended = appDepType.getKeyValuePairsArray();
+ for(ExtendedKeyValueType e: extended) {
+ if(e.getName().equalsIgnoreCase(name)) {
+ return e.getStringValue();
+ }
+ }
+ return null;
+ }
+
}
Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/DataStagingProcessor.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/DataStagingProcessor.java?rev=1471342&r1=1471341&r2=1471342&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/DataStagingProcessor.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/DataStagingProcessor.java Wed Apr 24 10:12:43 2013
@@ -34,7 +34,7 @@ import org.apache.airavata.schemas.gfac.
import org.apache.airavata.schemas.gfac.URIArrayType;
import org.apache.airavata.schemas.gfac.URIParameterType;
import org.apache.airavata.schemas.gfac.UnicoreHostType;
-import org.ogf.schemas.jsdl.JobDefinitionType;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionType;
public class DataStagingProcessor {
Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/JSDLGenerator.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/JSDLGenerator.java?rev=1471342&r1=1471341&r2=1471342&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/JSDLGenerator.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/JSDLGenerator.java Wed Apr 24 10:12:43 2013
@@ -23,8 +23,8 @@ package org.apache.airavata.gfac.provide
import org.apache.airavata.gfac.context.JobExecutionContext;
import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
-import org.ogf.schemas.jsdl.JobDefinitionDocument;
-import org.ogf.schemas.jsdl.JobDefinitionType;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionDocument;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,7 +52,7 @@ public class JSDLGenerator {
// build Identification
createJobIdentification(value, appDepType);
- //ResourceProcessor.generateResourceElements(value, context);
+ ResourceProcessor.generateResourceElements(value, context);
ApplicationProcessor.generateJobSpecificAppElements(value, context);
@@ -60,6 +60,7 @@ public class JSDLGenerator {
return jobDefDoc;
}
+
private static void createJobIdentification(JobDefinitionType value, HpcApplicationDeploymentType appDepType){
if( appDepType.getProjectAccount() != null ){
Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/JSDLUtils.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/JSDLUtils.java?rev=1471342&r1=1471341&r2=1471342&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/JSDLUtils.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/JSDLUtils.java Wed Apr 24 10:12:43 2013
@@ -17,7 +17,7 @@
* specific language governing permissions and limitations
* under the License.
*
- */
+*/
package org.apache.airavata.gfac.provider.utils;
@@ -26,487 +26,508 @@ import javax.xml.namespace.QName;
import org.apache.commons.httpclient.URIException;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlObject;
-import org.ogf.schemas.jsdl.ApplicationType;
-import org.ogf.schemas.jsdl.BoundaryType;
-import org.ogf.schemas.jsdl.CPUArchitectureType;
-import org.ogf.schemas.jsdl.CandidateHostsType;
-import org.ogf.schemas.jsdl.CreationFlagEnumeration;
-import org.ogf.schemas.jsdl.DataStagingType;
-import org.ogf.schemas.jsdl.ExactType;
-import org.ogf.schemas.jsdl.JobDefinitionType;
-import org.ogf.schemas.jsdl.JobDescriptionType;
-import org.ogf.schemas.jsdl.JobIdentificationType;
-import org.ogf.schemas.jsdl.OperatingSystemType;
-import org.ogf.schemas.jsdl.OperatingSystemTypeEnumeration;
-import org.ogf.schemas.jsdl.OperatingSystemTypeType;
-import org.ogf.schemas.jsdl.ProcessorArchitectureEnumeration;
-import org.ogf.schemas.jsdl.RangeValueType;
-import org.ogf.schemas.jsdl.ResourcesType;
-import org.ogf.schemas.jsdl.SourceTargetType;
-import org.ogf.schemas.jsdl.hpcpa.HPCProfileApplicationDocument;
-import org.ogf.schemas.jsdl.hpcpa.HPCProfileApplicationType;
-import org.ogf.schemas.jsdl.posix.EnvironmentType;
-import org.ogf.schemas.jsdl.posix.POSIXApplicationDocument;
-import org.ogf.schemas.jsdl.posix.POSIXApplicationType;
-import org.ogf.schemas.jsdl.spmd.SPMDApplicationDocument;
-import org.ogf.schemas.jsdl.spmd.SPMDApplicationType;
-
-public class JSDLUtils {
-
- public static final int FLAG_OVERWRITE = 1;
- public static final int FLAG_APPEND = 2;
- public static final int FLAG_DELETE_ON_TERMINATE = 32;
-
- public static final QName POSIX_APPLICATION = POSIXApplicationDocument.type.getDocumentElementName();
-
- public static final QName HPC_PROFILE_APPLICATION = HPCProfileApplicationDocument.type.getDocumentElementName();
-
- public static final QName SPMD_APPLICATION = SPMDApplicationDocument.type.getDocumentElementName();
-
- public static final String PROCESSESPERHOST = "ProcessesPerHost";
- public static final String NUMBEROFPROCESSES = "NumberOfProcesses";
- public static final String THREADSPERHOST = "ThreadsPerHost";
-
- public static EnvironmentType addEnvVariable(JobDefinitionType def, String name, String value) {
- POSIXApplicationType posixApp = getOrCreatePOSIXApplication(def);
- EnvironmentType newEnv = posixApp.addNewEnvironment();
- newEnv.setName(name);
- newEnv.setStringValue(value);
- return newEnv;
- }
-
- public static void setApplicationName(JobDefinitionType value, String applicationName) {
- getOrCreateApplication(value).setApplicationName(applicationName);
- }
-
- public static void setApplicationVersion(JobDefinitionType value, String applicationVersion) {
- getOrCreateApplication(value).setApplicationVersion(applicationVersion);
- }
-
- public static void addProjectName(JobDefinitionType value, String projectName) {
- getOrCreateJobIdentification(value).addNewJobProject().setStringValue(projectName);
- }
-
- public static void addMultipleProjectNames(JobDefinitionType value, String[] projectNames) {
- for (String name : projectNames) {
- getOrCreateJobIdentification(value).addNewJobProject().setStringValue(name);
- }
- }
-
- public static void addCandidateHost(JobDefinitionType value, String host) {
- getOrCreateCandidateHosts(value).addHostName(host);
-
- }
-
- public static void addDataStagingTargetElement(JobDefinitionType value, String fileSystem, String file, String uri) {
- addDataStagingTargetElement(value, fileSystem, file, uri, 0);
- }
-
- public static void addDataStagingTargetElement(JobDefinitionType value, String fileSystem, String file, String uri,
- int flags) {
- JobDescriptionType jobDescr = getOrCreateJobDescription(value);
- DataStagingType newDS = jobDescr.addNewDataStaging();
- CreationFlagEnumeration.Enum creationFlag = CreationFlagEnumeration.DONT_OVERWRITE;
- if ((flags & FLAG_OVERWRITE) != 0)
- creationFlag = CreationFlagEnumeration.OVERWRITE;
- if ((flags & FLAG_APPEND) != 0)
- creationFlag = CreationFlagEnumeration.APPEND;
- boolean deleteOnTerminate = (flags & FLAG_DELETE_ON_TERMINATE) != 0;
- newDS.setCreationFlag(creationFlag);
- newDS.setDeleteOnTermination(deleteOnTerminate);
- SourceTargetType target = newDS.addNewTarget();
-
- try {
- uri = (uri == null) ? null : URIUtils.encodeAll(uri);
- } catch (URIException e) {
- }
- target.setURI(uri);
- newDS.setFileName(file);
- if (fileSystem != null && !fileSystem.equals("Work")) { //$NON-NLS-1$
- newDS.setFilesystemName(fileSystem);
- }
- }
-
- public static void addDataStagingSourceElement(JobDefinitionType value, String uri, String fileSystem, String file) {
- addDataStagingSourceElement(value, uri, fileSystem, file, 0);
- }
-
- public static void addDataStagingSourceElement(JobDefinitionType value, String uri, String fileSystem, String file,
- int flags) {
- JobDescriptionType jobDescr = getOrCreateJobDescription(value);
-
- try {
- uri = (uri == null) ? null : URIUtils.encodeAll(uri);
- } catch (URIException e) {
- }
- DataStagingType newDS = jobDescr.addNewDataStaging();
- CreationFlagEnumeration.Enum creationFlag = CreationFlagEnumeration.DONT_OVERWRITE;
- if ((flags & FLAG_OVERWRITE) != 0)
- creationFlag = CreationFlagEnumeration.OVERWRITE;
- if ((flags & FLAG_APPEND) != 0)
- creationFlag = CreationFlagEnumeration.APPEND;
- boolean deleteOnTerminate = (flags & FLAG_DELETE_ON_TERMINATE) != 0;
- newDS.setCreationFlag(creationFlag);
- newDS.setDeleteOnTermination(deleteOnTerminate);
- SourceTargetType source = newDS.addNewSource();
- source.setURI(uri);
- newDS.setFileName(file);
- if (fileSystem != null && !fileSystem.equals("Work")) { //$NON-NLS-1$
- newDS.setFilesystemName(fileSystem);
- }
- }
-
- public static ApplicationType getOrCreateApplication(JobDefinitionType value) {
- JobDescriptionType jobDescr = getOrCreateJobDescription(value);
- if (!jobDescr.isSetApplication()) {
- jobDescr.addNewApplication();
- }
- return jobDescr.getApplication();
- }
-
- public static CandidateHostsType getOrCreateCandidateHosts(JobDefinitionType value) {
- ResourcesType resources = getOrCreateResources(value);
- if (!resources.isSetCandidateHosts()) {
- resources.addNewCandidateHosts();
- }
- return resources.getCandidateHosts();
- }
-
- public static CPUArchitectureType getOrCreateCPUArchitecture(JobDefinitionType value) {
-
- ResourcesType jobResources = getOrCreateResources(value);
- if (!jobResources.isSetCPUArchitecture()) {
- jobResources.addNewCPUArchitecture();
- }
- return jobResources.getCPUArchitecture();
- }
-
- public static RangeValueType getOrCreateIndividualCPUCount(JobDefinitionType value) {
- ResourcesType jobResources = getOrCreateResources(value);
- if (!jobResources.isSetIndividualCPUCount()) {
- jobResources.addNewIndividualCPUCount();
- }
- return jobResources.getIndividualCPUCount();
- }
-
- public static org.ogf.schemas.jsdl.RangeValueType getOrCreateIndividualCPUSpeed(JobDefinitionType value) {
-
- ResourcesType jobResources = getOrCreateResources(value);
- if (!jobResources.isSetIndividualCPUSpeed()) {
- jobResources.addNewIndividualCPUSpeed();
- }
- return jobResources.getIndividualCPUSpeed();
- }
-
- public static RangeValueType getOrCreateIndividualCPUTime(JobDefinitionType value) {
-
- ResourcesType jobResources = getOrCreateResources(value);
- if (!jobResources.isSetIndividualCPUTime()) {
- jobResources.addNewIndividualCPUTime();
- }
- return jobResources.getIndividualCPUTime();
- }
-
- public static RangeValueType getOrCreateIndividualDiskSpace(JobDefinitionType value) {
-
- ResourcesType jobResources = getOrCreateResources(value);
- if (!jobResources.isSetIndividualDiskSpace()) {
- jobResources.addNewIndividualDiskSpace();
- }
- return jobResources.getIndividualDiskSpace();
- }
-
- public static RangeValueType getOrCreateIndividualPhysicalMemory(JobDefinitionType value) {
-
- ResourcesType jobResources = getOrCreateResources(value);
- if (!jobResources.isSetIndividualPhysicalMemory()) {
- jobResources.addNewIndividualPhysicalMemory();
- }
- return jobResources.getIndividualPhysicalMemory();
- }
-
- public static JobDescriptionType getOrCreateJobDescription(JobDefinitionType value) {
- if (value.getJobDescription() == null) {
- return value.addNewJobDescription();
- }
- return value.getJobDescription();
- }
-
- public static JobIdentificationType getOrCreateJobIdentification(JobDefinitionType value) {
- JobDescriptionType descr = getOrCreateJobDescription(value);
- if (descr.getJobIdentification() == null) {
- return descr.addNewJobIdentification();
- }
- return descr.getJobIdentification();
- }
-
- public static OperatingSystemType getOrCreateOperatingSystem(JobDefinitionType value) {
- ResourcesType jobResources = getOrCreateResources(value);
- if (!jobResources.isSetOperatingSystem()) {
- jobResources.addNewOperatingSystem();
- }
- return jobResources.getOperatingSystem();
- }
-
- public static ResourcesType getOrCreateResources(JobDefinitionType value) {
- JobDescriptionType jobDescr = getOrCreateJobDescription(value);
- if (!jobDescr.isSetResources()) {
- jobDescr.addNewResources();
- }
- return jobDescr.getResources();
- }
-
- public static RangeValueType getOrCreateTotalCPUCount(JobDefinitionType value) {
-
- ResourcesType jobResources = getOrCreateResources(value);
- if (!jobResources.isSetTotalCPUCount()) {
- jobResources.addNewTotalCPUCount();
- }
- return jobResources.getTotalCPUCount();
- }
-
- public static RangeValueType getOrCreateTotalResourceCount(JobDefinitionType value) {
-
- ResourcesType jobResources = getOrCreateResources(value);
- if (!jobResources.isSetTotalResourceCount()) {
- jobResources.addNewTotalResourceCount();
- }
- return jobResources.getTotalResourceCount();
- }
-
- public static POSIXApplicationType getOrCreatePOSIXApplication(JobDefinitionType value) {
-
- ApplicationType application = getOrCreateApplication(value);
-
- if (getHPCProfileApplication(value) != null) {
- // TODO handle: not creating POSIX element if HPCProfile already exists
- return getPOSIXApplication(value);
- }
-
- if (getPOSIXApplication(value) == null) {
- XmlCursor acursor = application.newCursor();
- acursor.toEndToken();
- acursor.insertElement(POSIX_APPLICATION);
- acursor.dispose();
- }
- return getPOSIXApplication(value);
- }
-
- public static SPMDApplicationType getOrCreateSPMDApplication(JobDefinitionType value) {
-
- ApplicationType application = getOrCreateApplication(value);
-
- if (getSPMDApplication(value) == null) {
- XmlCursor acursor = application.newCursor();
- acursor.toEndToken();
- acursor.insertElement(SPMD_APPLICATION);
- acursor.dispose();
- }
- return getSPMDApplication(value);
- }
-
- public static SPMDApplicationType getSPMDApplication(JobDefinitionType value) {
- if (value != null && value.getJobDescription() != null && value.getJobDescription().isSetApplication()) {
- XmlCursor acursor = value.getJobDescription().getApplication().newCursor();
- if (acursor.toFirstChild()) {
- do {
- if (acursor.getName().equals(SPMD_APPLICATION)) {
- XmlObject result = acursor.getObject();
- acursor.dispose();
- return (SPMDApplicationType) result;
- }
- } while (acursor.toNextSibling());
- acursor.dispose();
- return null;
- } else {
- acursor.dispose();
- return null;
- }
- } else {
- return null;
- }
- }
-
- public static POSIXApplicationType getPOSIXApplication(JobDefinitionType value) {
- if (value != null && value.getJobDescription() != null && value.getJobDescription().isSetApplication()) {
- XmlCursor acursor = value.getJobDescription().getApplication().newCursor();
- if (acursor.toFirstChild()) {
- do {
- if (acursor.getName().equals(POSIX_APPLICATION)) {
- XmlObject result = acursor.getObject();
- acursor.dispose();
- return (POSIXApplicationType) result;
- }
- } while (acursor.toNextSibling());
- acursor.dispose();
- return null;
- } else {
- acursor.dispose();
- return null;
- }
- } else {
- return null;
- }
- }
-
- public static HPCProfileApplicationType getOrCreateHPCProfileApplication(JobDefinitionType value) {
-
- ApplicationType application = getOrCreateApplication(value);
-
- if (getPOSIXApplication(value) != null) {
- // TODO handle: creating HPC element if POSIX already exists
- return getHPCProfileApplication(value);
- }
-
- if (getHPCProfileApplication(value) == null) {
- XmlCursor acursor = application.newCursor();
- acursor.toEndToken();
- acursor.insertElement(HPC_PROFILE_APPLICATION);
- acursor.dispose();
- }
- return getHPCProfileApplication(value);
- }
-
- public static HPCProfileApplicationType getHPCProfileApplication(JobDefinitionType value) {
- if (value != null && value.getJobDescription() != null && value.getJobDescription().isSetApplication()) {
- XmlCursor acursor = value.getJobDescription().getApplication().newCursor();
- if (acursor.toFirstChild()) {
- do {
- if (acursor.getName().equals(HPC_PROFILE_APPLICATION)) {
- XmlObject result = acursor.getObject();
- acursor.dispose();
- return (HPCProfileApplicationType) result;
- }
- } while (acursor.toNextSibling());
- acursor.dispose();
- return null;
- } else {
- acursor.dispose();
- return null;
- }
- } else {
- return null;
- }
- }
-
- public static RangeValueType getTotalCPUCountRequirements(JobDefinitionType value) {
- if (value != null && value.getJobDescription() != null && value.getJobDescription().isSetResources()
- && value.getJobDescription().getResources().isSetTotalCPUCount()) {
- return value.getJobDescription().getResources().getTotalCPUCount();
- } else
- return null;
- }
-
- public static RangeValueType getTotalResourceCountRequirements(JobDefinitionType value) {
- if (value != null && value.getJobDescription() != null && value.getJobDescription().isSetResources()
- && value.getJobDescription().getResources().isSetTotalResourceCount()) {
- return value.getJobDescription().getResources().getTotalResourceCount();
- } else
- return null;
- }
-
- public static UCRangeValueType toU6RangeValue(RangeValueType jsdlType) {
- UCRangeValueType result = new UCRangeValueType();
- if(jsdlType.getExactArray().length > 0){
- result.setExact(jsdlType.getExactArray(0).getDoubleValue());
- }
- if(jsdlType.isSetLowerBoundedRange()){
- result.setLowerBound(jsdlType.getLowerBoundedRange().getDoubleValue());
- }
- if(jsdlType.isSetUpperBoundedRange()){
- result.setUpperBound(jsdlType.getUpperBoundedRange().getDoubleValue());
- }
- return result;
- }
-
- public static void setCPUArchitectureRequirements(JobDefinitionType value, ProcessorRequirement cpuArchitecture) {
- if (cpuArchitecture == null || cpuArchitecture.getValue() == null)
- return;
- CPUArchitectureType cpuArch = getOrCreateCPUArchitecture(value);
- cpuArch.setCPUArchitectureName(ProcessorArchitectureEnumeration.Enum.forString(cpuArchitecture.getValue()));
- }
-
- public static void setIndividualCPUCountRequirements(JobDefinitionType value, UCRangeValueType cpuCount) {
- RangeValueType individualCPUCount = getOrCreateIndividualCPUCount(value);
- setRangeValue(cpuCount, individualCPUCount);
- }
-
- public static void setIndividualCPUSpeedRequirements(JobDefinitionType value, UCRangeValueType cpuSpeed) {
- RangeValueType individualCPUSpeed = getOrCreateIndividualCPUSpeed(value);
- setRangeValue(cpuSpeed, individualCPUSpeed);
- }
-
- public static void setIndividualCPUTimeRequirements(JobDefinitionType value, UCRangeValueType cpuTime) {
- RangeValueType cpuIndividualTime = getOrCreateIndividualCPUTime(value);
- setRangeValue(cpuTime, cpuIndividualTime);
- }
-
- public static void setIndividualDiskSpaceRequirements(JobDefinitionType value, UCRangeValueType diskSpace) {
- RangeValueType individualDiskSpace = getOrCreateIndividualDiskSpace(value);
- setRangeValue(diskSpace, individualDiskSpace);
- }
-
- public static void setIndividualPhysicalMemoryRequirements(JobDefinitionType value, UCRangeValueType physicalMemory) {
- RangeValueType individualPhysicalMemory = getOrCreateIndividualPhysicalMemory(value);
- setRangeValue(physicalMemory, individualPhysicalMemory);
- }
-
- public static void setName(JobDefinitionType value, String name) {
- getOrCreateJobIdentification(value).setJobName(name);
- }
-
- public static void setOperatingSystemRequirements(JobDefinitionType value, OSRequirement osType) {
- if (osType == null || osType.getOSType() == null)
- return;
- OperatingSystemType os_Type = getOrCreateOperatingSystem(value);
- OperatingSystemTypeType ostt = os_Type.addNewOperatingSystemType();
- ostt.setOperatingSystemName(OperatingSystemTypeEnumeration.Enum.forString(osType.getOSType().getValue()));
- if (osType.getOSVersion() != null) {
- os_Type.setOperatingSystemVersion(osType.getOSVersion());
- }
- }
-
- public static void setRangeValue(UCRangeValueType u6Type, RangeValueType jsdlType) {
- Double exact = u6Type.getExact();
- Double epsilon = u6Type.getEpsilon();
- Double lower = u6Type.getLowerBound();
- Double upper = u6Type.getUpperBound();
-
-
- if(lower.isNaN() && upper.isNaN())
- {
- ExactType exactType = jsdlType.getExactArray().length > 0 ? jsdlType.getExactArray(0) : jsdlType.addNewExact();
- exactType.setDoubleValue(exact);
- if(!epsilon.isNaN() && epsilon != 0)
- {
- exactType.setEpsilon(epsilon);
- }
- }
- else
- {
- if(!lower.isNaN())
- {
- BoundaryType lowerBound = jsdlType.isSetLowerBoundedRange() ? jsdlType.getLowerBoundedRange() : jsdlType.addNewLowerBoundedRange();
- lowerBound.setDoubleValue(lower);
- lowerBound.setExclusiveBound(!u6Type.isIncludeLowerBound());
- }
-
- if(!upper.isNaN())
- {
- BoundaryType upperBound = jsdlType.isSetUpperBoundedRange() ? jsdlType.getUpperBoundedRange() : jsdlType.addNewUpperBoundedRange();
- upperBound.setDoubleValue(upper);
- upperBound.setExclusiveBound(!u6Type.isIncludeUpperBound());
- }
- }
- }
-
- public static void setTotalCPUCountRequirements(JobDefinitionType value, UCRangeValueType cpuCount) {
- RangeValueType cpuTotalCount = getOrCreateTotalCPUCount(value);
- setRangeValue(cpuCount, cpuTotalCount);
- }
-
- public static void setTotalResourceCountRequirements(JobDefinitionType value, UCRangeValueType resourceCount) {
- RangeValueType totalCount = getOrCreateTotalResourceCount(value);
- setRangeValue(resourceCount, totalCount);
- }
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.ApplicationType;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.BoundaryType;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.CPUArchitectureType;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.CandidateHostsType;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.CreationFlagEnumeration;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.DataStagingType;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.ExactType;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionType;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDescriptionType;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobIdentificationType;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.OperatingSystemType;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.OperatingSystemTypeEnumeration;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.OperatingSystemTypeType;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.ProcessorArchitectureEnumeration;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.ResourcesType;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.SourceTargetType;
+import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.EnvironmentType;
+import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.POSIXApplicationDocument;
+import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.POSIXApplicationType;
+import org.ggf.schemas.jsdl.x2006.x07.jsdlHpcpa.HPCProfileApplicationDocument;
+import org.ggf.schemas.jsdl.x2006.x07.jsdlHpcpa.HPCProfileApplicationType;
+import org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.SPMDApplicationDocument;
+import org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.SPMDApplicationType;
+
+public class JSDLUtils
+{
+
+ public static final int FLAG_OVERWRITE = 1;
+ public static final int FLAG_APPEND = 2;
+ public static final int FLAG_DELETE_ON_TERMINATE = 32;
+
+ public static final QName POSIX_APPLICATION=POSIXApplicationDocument.type.getDocumentElementName();
+
+ public static final QName HPC_PROFILE_APPLICATION=HPCProfileApplicationDocument.type.getDocumentElementName();
+
+ public static final QName SPMD_APPLICATION=SPMDApplicationDocument.type.getDocumentElementName();
+
+ public static final String PROCESSESPERHOST = "ProcessesPerHost";
+ public static final String NUMBEROFPROCESSES = "NumberOfProcesses";
+ public static final String THREADSPERHOST = "ThreadsPerHost";
+
+
+
+ public static EnvironmentType addEnvVariable(JobDefinitionType def,String name, String value) {
+ POSIXApplicationType posixApp = getOrCreatePOSIXApplication(def);
+ EnvironmentType newEnv = posixApp.addNewEnvironment();
+ newEnv.setName(name);
+ newEnv.setStringValue(value);
+ return newEnv;
+ }
+
+ public static void setApplicationName(JobDefinitionType value, String applicationName) {
+ getOrCreateApplication(value).setApplicationName(applicationName);
+ }
+
+ public static void setApplicationVersion(JobDefinitionType value, String applicationVersion) {
+ getOrCreateApplication(value).setApplicationVersion(applicationVersion);
+ }
+
+ public static void addProjectName(JobDefinitionType value, String projectName) {
+ getOrCreateJobIdentification(value).addNewJobProject().setStringValue(projectName);
+ }
+
+ public static void addMultipleProjectNames(JobDefinitionType value, String[] projectNames) {
+ for (String name : projectNames) {
+ getOrCreateJobIdentification(value).addNewJobProject().setStringValue(name);
+ }
+ }
+
+ public static void addCandidateHost(JobDefinitionType value, String host) {
+ getOrCreateCandidateHosts(value).addHostName(host);
+
+ }
+ public static void addDataStagingTargetElement(JobDefinitionType value, String fileSystem, String file, String uri) {
+ addDataStagingTargetElement(value,fileSystem, file, uri, 0);
+ }
+
+ public static void addDataStagingTargetElement(JobDefinitionType value, String fileSystem, String file, String uri, int flags) {
+ JobDescriptionType jobDescr = getOrCreateJobDescription(value);
+ DataStagingType newDS = jobDescr.addNewDataStaging();
+ CreationFlagEnumeration.Enum creationFlag = CreationFlagEnumeration.DONT_OVERWRITE;
+ if((flags & FLAG_OVERWRITE) != 0) creationFlag = CreationFlagEnumeration.OVERWRITE;
+ if((flags & FLAG_APPEND) != 0) creationFlag = CreationFlagEnumeration.APPEND;
+ boolean deleteOnTerminate = (flags & FLAG_DELETE_ON_TERMINATE) != 0;
+ newDS.setCreationFlag(creationFlag);
+ newDS.setDeleteOnTermination(deleteOnTerminate);
+ SourceTargetType target = newDS.addNewTarget();
+
+ try {
+ uri = (uri == null) ? null : URIUtils.encodeAll(uri);
+ } catch (URIException e) {
+ }
+ target.setURI(uri);
+ newDS.setFileName(file);
+ if (fileSystem != null && !fileSystem.equals("Work")) { //$NON-NLS-1$
+ newDS.setFilesystemName(fileSystem);
+ }
+ }
+
+ public static void addDataStagingSourceElement(JobDefinitionType value, String uri, String fileSystem, String file) {
+ addDataStagingSourceElement(value, uri, fileSystem, file, 0);
+ }
+
+ public static void addDataStagingSourceElement(JobDefinitionType value, String uri, String fileSystem, String file, int flags) {
+ JobDescriptionType jobDescr = getOrCreateJobDescription(value);
+
+ try {
+ uri = (uri == null) ? null : URIUtils.encodeAll(uri);
+ } catch (URIException e) {
+ }
+ DataStagingType newDS = jobDescr.addNewDataStaging();
+ CreationFlagEnumeration.Enum creationFlag = CreationFlagEnumeration.DONT_OVERWRITE;
+ if((flags & FLAG_OVERWRITE) != 0) creationFlag = CreationFlagEnumeration.OVERWRITE;
+ if((flags & FLAG_APPEND) != 0) creationFlag = CreationFlagEnumeration.APPEND;
+ boolean deleteOnTerminate = (flags & FLAG_DELETE_ON_TERMINATE) != 0;
+ newDS.setCreationFlag(creationFlag);
+ newDS.setDeleteOnTermination(deleteOnTerminate);
+ SourceTargetType source = newDS.addNewSource();
+ source.setURI(uri);
+ newDS.setFileName(file);
+ if (fileSystem != null && !fileSystem.equals("Work")) { //$NON-NLS-1$
+ newDS.setFilesystemName(fileSystem);
+ }
+ }
+
+
+ public static ApplicationType getOrCreateApplication(JobDefinitionType value) {
+ JobDescriptionType jobDescr = getOrCreateJobDescription(value);
+ if (!jobDescr.isSetApplication()) {
+ jobDescr.addNewApplication();
+ }
+ return jobDescr.getApplication();
+ }
+
+ public static CandidateHostsType getOrCreateCandidateHosts(JobDefinitionType value) {
+ ResourcesType resources = getOrCreateResources(value);
+ if (!resources.isSetCandidateHosts()) {
+ resources.addNewCandidateHosts();
+ }
+ return resources.getCandidateHosts();
+ }
+
+ public static CPUArchitectureType getOrCreateCPUArchitecture(JobDefinitionType value) {
+
+ ResourcesType jobResources = getOrCreateResources(value);
+ if (!jobResources.isSetCPUArchitecture()) {
+ jobResources.addNewCPUArchitecture();
+ }
+ return jobResources.getCPUArchitecture();
+ }
+
+ public static org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType getOrCreateIndividualCPUCount(JobDefinitionType value) {
+ ResourcesType jobResources = getOrCreateResources(value);
+ if (!jobResources.isSetIndividualCPUCount()) {
+ jobResources.addNewIndividualCPUCount();
+ }
+ return jobResources.getIndividualCPUCount();
+ }
+
+
+ public static org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType getOrCreateIndividualCPUSpeed(JobDefinitionType value) {
+
+ ResourcesType jobResources = getOrCreateResources(value);
+ if (!jobResources.isSetIndividualCPUSpeed()) {
+ jobResources.addNewIndividualCPUSpeed();
+ }
+ return jobResources.getIndividualCPUSpeed();
+ }
+
+ public static org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType getOrCreateIndividualCPUTime(JobDefinitionType value) {
+
+ ResourcesType jobResources = getOrCreateResources(value);
+ if ( !jobResources.isSetIndividualCPUTime() ) {
+ jobResources.addNewIndividualCPUTime();
+ }
+ return jobResources.getIndividualCPUTime();
+ }
+
+ public static org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType getOrCreateIndividualDiskSpace(JobDefinitionType value) {
+
+ ResourcesType jobResources = getOrCreateResources(value);
+ if (!jobResources.isSetIndividualDiskSpace()) {
+ jobResources.addNewIndividualDiskSpace();
+ }
+ return jobResources.getIndividualDiskSpace();
+ }
+
+ public static org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType getOrCreateIndividualPhysicalMemory(JobDefinitionType value) {
+
+ ResourcesType jobResources = getOrCreateResources(value);
+ if (!jobResources.isSetIndividualPhysicalMemory()) {
+ jobResources.addNewIndividualPhysicalMemory();
+ }
+ return jobResources.getIndividualPhysicalMemory();
+ }
+
+ public static JobDescriptionType getOrCreateJobDescription(JobDefinitionType value) {
+ if (value.getJobDescription() == null) {
+ return value.addNewJobDescription();
+ }
+ return value.getJobDescription();
+ }
+
+ public static JobIdentificationType getOrCreateJobIdentification(JobDefinitionType value) {
+ JobDescriptionType descr = getOrCreateJobDescription(value);
+ if (descr.getJobIdentification() == null) {
+ return descr.addNewJobIdentification();
+ }
+ return descr.getJobIdentification();
+ }
+
+ public static OperatingSystemType getOrCreateOperatingSystem(JobDefinitionType value)
+ {
+ ResourcesType jobResources = getOrCreateResources(value);
+ if(!jobResources.isSetOperatingSystem()) {
+ jobResources.addNewOperatingSystem();
+ }
+ return jobResources.getOperatingSystem();
+ }
+
+ public static ResourcesType getOrCreateResources(JobDefinitionType value) {
+ JobDescriptionType jobDescr = getOrCreateJobDescription(value);
+ if (!jobDescr.isSetResources()) {
+ jobDescr.addNewResources();
+ }
+ return jobDescr.getResources();
+ }
+
+
+ public static org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType getOrCreateTotalCPUCount(JobDefinitionType value) {
+
+ ResourcesType jobResources = getOrCreateResources(value);
+ if ( !jobResources.isSetTotalCPUCount() ) {
+ jobResources.addNewTotalCPUCount();
+ }
+ return jobResources.getTotalCPUCount();
+ }
+
+
+ public static org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType getOrCreateTotalResourceCount(JobDefinitionType value) {
+
+ ResourcesType jobResources = getOrCreateResources(value);
+ if ( !jobResources.isSetTotalResourceCount())
+ {
+ jobResources.addNewTotalResourceCount();
+ }
+ return jobResources.getTotalResourceCount();
+ }
+
+ public static POSIXApplicationType getOrCreatePOSIXApplication(JobDefinitionType value) {
+
+ ApplicationType application = getOrCreateApplication(value);
+
+ if(getHPCProfileApplication(value) != null){
+ //TODO handle: not creating POSIX element if HPCProfile already exists
+ return getPOSIXApplication(value);
+ }
+
+ if (getPOSIXApplication(value) == null) {
+ XmlCursor acursor = application.newCursor();
+ acursor.toEndToken();
+ acursor.insertElement(POSIX_APPLICATION);
+ acursor.dispose();
+ }
+ return getPOSIXApplication(value);
+ }
+
+
+ public static SPMDApplicationType getOrCreateSPMDApplication(JobDefinitionType value) {
+
+ ApplicationType application = getOrCreateApplication(value);
+
+ if (getSPMDApplication(value) == null) {
+ XmlCursor acursor = application.newCursor();
+ acursor.toEndToken();
+ acursor.insertElement(SPMD_APPLICATION);
+ acursor.dispose();
+ }
+ return getSPMDApplication(value);
+ }
+
+ public static SPMDApplicationType getSPMDApplication(JobDefinitionType value) {
+ if (value != null &&
+ value.getJobDescription() != null &&
+ value.getJobDescription().isSetApplication() ) {
+ XmlCursor acursor = value.getJobDescription().getApplication().newCursor();
+ if (acursor.toFirstChild()) {
+ do {
+ if(acursor.getName().equals(SPMD_APPLICATION)) {
+ XmlObject result = acursor.getObject();
+ acursor.dispose();
+ return (SPMDApplicationType) result;
+ }
+ } while (acursor.toNextSibling());
+ acursor.dispose();
+ return null;
+ } else {
+ acursor.dispose();
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+
+
+ public static POSIXApplicationType getPOSIXApplication(JobDefinitionType value) {
+ if (value != null &&
+ value.getJobDescription() != null &&
+ value.getJobDescription().isSetApplication() ) {
+ XmlCursor acursor = value.getJobDescription().getApplication().newCursor();
+ if (acursor.toFirstChild()) {
+ do {
+ if(acursor.getName().equals(POSIX_APPLICATION)) {
+ XmlObject result = acursor.getObject();
+ acursor.dispose();
+ return (POSIXApplicationType) result;
+ }
+ } while (acursor.toNextSibling());
+ acursor.dispose();
+ return null;
+ } else {
+ acursor.dispose();
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+
+
+ public static HPCProfileApplicationType getOrCreateHPCProfileApplication(JobDefinitionType value) {
+
+ ApplicationType application = getOrCreateApplication(value);
+
+ if(getPOSIXApplication(value) != null){
+ //TODO handle: creating HPC element if POSIX already exists
+ return getHPCProfileApplication(value);
+ }
+
+ if (getHPCProfileApplication(value) == null) {
+ XmlCursor acursor = application.newCursor();
+ acursor.toEndToken();
+ acursor.insertElement(HPC_PROFILE_APPLICATION);
+ acursor.dispose();
+ }
+ return getHPCProfileApplication(value);
+ }
+
+
+ public static HPCProfileApplicationType getHPCProfileApplication(JobDefinitionType value) {
+ if (value != null &&
+ value.getJobDescription() != null &&
+ value.getJobDescription().isSetApplication() ) {
+ XmlCursor acursor = value.getJobDescription().getApplication().newCursor();
+ if (acursor.toFirstChild()) {
+ do {
+ if(acursor.getName().equals(HPC_PROFILE_APPLICATION)) {
+ XmlObject result = acursor.getObject();
+ acursor.dispose();
+ return (HPCProfileApplicationType) result;
+ }
+ } while (acursor.toNextSibling());
+ acursor.dispose();
+ return null;
+ } else {
+ acursor.dispose();
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+
+
+
+ public static RangeValueType getTotalCPUCountRequirements(JobDefinitionType value) {
+ if(value != null && value.getJobDescription() != null && value.getJobDescription().isSetResources() &&
+ value.getJobDescription().getResources().isSetTotalCPUCount()){
+ return toU6RangeValue(value.getJobDescription().getResources().getTotalCPUCount());
+ }
+ else
+ return null;
+ }
+
+ public static RangeValueType getTotalResourceCountRequirements(JobDefinitionType value) {
+ if(value != null && value.getJobDescription() != null && value.getJobDescription().isSetResources() &&
+ value.getJobDescription().getResources().isSetTotalResourceCount()){
+ return toU6RangeValue(value.getJobDescription().getResources().getTotalResourceCount());
+ }
+ else
+ return null;
+ }
+
+
+ public static RangeValueType toU6RangeValue(org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType jsdlType) {
+ RangeValueType result = new RangeValueType();
+ if(jsdlType.getExactArray().length > 0){
+ result.setExact(jsdlType.getExactArray(0).getDoubleValue());
+ }
+ if(jsdlType.isSetLowerBoundedRange()){
+ result.setLowerBound(jsdlType.getLowerBoundedRange().getDoubleValue());
+ }
+ if(jsdlType.isSetUpperBoundedRange()){
+ result.setUpperBound(jsdlType.getUpperBoundedRange().getDoubleValue());
+ }
+ return result;
+ }
+
+
+
+ public static void setCPUArchitectureRequirements(JobDefinitionType value, ProcessorRequirement cpuArchitecture) {
+ if(cpuArchitecture == null || cpuArchitecture.getValue() == null) return;
+ CPUArchitectureType cpuArch = getOrCreateCPUArchitecture(value);
+ cpuArch.setCPUArchitectureName(ProcessorArchitectureEnumeration.Enum.forString(cpuArchitecture.getValue()));
+ }
+
+ public static void setIndividualCPUCountRequirements(JobDefinitionType value, RangeValueType cpuCount) {
+ org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType individualCPUCount = getOrCreateIndividualCPUCount(value);
+ setRangeValue(cpuCount, individualCPUCount);
+ }
+
+ public static void setIndividualCPUSpeedRequirements(JobDefinitionType value, RangeValueType cpuSpeed) {
+ org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType individualCPUSpeed = getOrCreateIndividualCPUSpeed(value);
+ setRangeValue(cpuSpeed, individualCPUSpeed);
+ }
+
+ public static void setIndividualCPUTimeRequirements(JobDefinitionType value, RangeValueType cpuTime) {
+ org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType cpuIndividualTime = getOrCreateIndividualCPUTime(value);
+ setRangeValue(cpuTime, cpuIndividualTime);
+ }
+
+ public static void setIndividualDiskSpaceRequirements(JobDefinitionType value, RangeValueType diskSpace) {
+ org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType individualDiskSpace = getOrCreateIndividualDiskSpace(value);
+ setRangeValue(diskSpace, individualDiskSpace);
+ }
+
+ public static void setIndividualPhysicalMemoryRequirements(JobDefinitionType value, RangeValueType physicalMemory) {
+ org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType individualPhysicalMemory = getOrCreateIndividualPhysicalMemory(value);
+ setRangeValue(physicalMemory, individualPhysicalMemory);
+ }
+
+
+ public static void setName(JobDefinitionType value, String name) {
+ getOrCreateJobIdentification(value).setJobName(name);
+ }
+
+ public static void setOperatingSystemRequirements(JobDefinitionType value, OSRequirement osType) {
+ if(osType == null || osType.getOSType() == null) return;
+ OperatingSystemType os_Type = getOrCreateOperatingSystem(value);
+ OperatingSystemTypeType ostt = os_Type.addNewOperatingSystemType();
+ ostt.setOperatingSystemName(OperatingSystemTypeEnumeration.Enum.forString(osType.getOSType().getValue()));
+ if(osType.getOSVersion() != null)
+ {
+ os_Type.setOperatingSystemVersion(osType.getOSVersion());
+ }
+ }
+
+ public static void setRangeValue(RangeValueType u6Type, org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType jsdlType) {
+ Double exact = u6Type.getExact();
+ Double epsilon = u6Type.getEpsilon();
+ Double lower = u6Type.getLowerBound();
+ Double upper = u6Type.getUpperBound();
+
+
+ if(lower.isNaN() && upper.isNaN())
+ {
+ ExactType exactType = jsdlType.getExactArray().length > 0 ? jsdlType.getExactArray(0) : jsdlType.addNewExact();
+ exactType.setDoubleValue(exact);
+ if(!epsilon.isNaN() && epsilon != 0)
+ {
+ exactType.setEpsilon(epsilon);
+ }
+ }
+ else
+ {
+ if(!lower.isNaN())
+ {
+ BoundaryType lowerBound = jsdlType.isSetLowerBoundedRange() ? jsdlType.getLowerBoundedRange() : jsdlType.addNewLowerBoundedRange();
+ lowerBound.setDoubleValue(lower);
+ lowerBound.setExclusiveBound(!u6Type.isIncludeLowerBound());
+ }
+
+ if(!upper.isNaN())
+ {
+ BoundaryType upperBound = jsdlType.isSetUpperBoundedRange() ? jsdlType.getUpperBoundedRange() : jsdlType.addNewUpperBoundedRange();
+ upperBound.setDoubleValue(upper);
+ upperBound.setExclusiveBound(!u6Type.isIncludeUpperBound());
+ }
+ }
+ }
+
+ public static void setTotalCPUCountRequirements(JobDefinitionType value, RangeValueType cpuCount) {
+ org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType cpuTotalCount = getOrCreateTotalCPUCount(value);
+ setRangeValue(cpuCount, cpuTotalCount);
+ }
+
+ public static void setTotalResourceCountRequirements(JobDefinitionType value, RangeValueType resourceCount) {
+ org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType totalCount = getOrCreateTotalResourceCount(value);
+ setRangeValue(resourceCount, totalCount);
+ }
}
Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ResourceProcessor.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ResourceProcessor.java?rev=1471342&r1=1471341&r2=1471342&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ResourceProcessor.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ResourceProcessor.java Wed Apr 24 10:12:43 2013
@@ -22,7 +22,7 @@ package org.apache.airavata.gfac.provide
import org.apache.airavata.gfac.context.JobExecutionContext;
import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
-import org.ogf.schemas.jsdl.JobDefinitionType;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionType;
public class ResourceProcessor {
@@ -36,7 +36,7 @@ public class ResourceProcessor {
createMemory(value, appDepType);
if (appDepType.getCpuCount() > 0) {
- UCRangeValueType rangeType = new UCRangeValueType();
+ RangeValueType rangeType = new RangeValueType();
rangeType.setLowerBound(Double.NaN);
rangeType.setUpperBound(Double.NaN);
rangeType.setExact(appDepType.getCpuCount());
@@ -44,7 +44,7 @@ public class ResourceProcessor {
}
if (appDepType.getProcessorsPerNode() > 0) {
- UCRangeValueType rangeType = new UCRangeValueType();
+ RangeValueType rangeType = new RangeValueType();
rangeType.setLowerBound(Double.NaN);
rangeType.setUpperBound(Double.NaN);
rangeType.setExact(appDepType.getProcessorsPerNode());
@@ -52,7 +52,7 @@ public class ResourceProcessor {
}
if (appDepType.getNodeCount() > 0) {
- UCRangeValueType rangeType = new UCRangeValueType();
+ RangeValueType rangeType = new RangeValueType();
rangeType.setLowerBound(Double.NaN);
rangeType.setUpperBound(Double.NaN);
rangeType.setExact(appDepType.getNodeCount());
@@ -60,7 +60,7 @@ public class ResourceProcessor {
}
if(appDepType.getMaxWallTime() > 0) {
- UCRangeValueType cpuTime = new UCRangeValueType();
+ RangeValueType cpuTime = new RangeValueType();
cpuTime.setLowerBound(Double.NaN);
cpuTime.setUpperBound(Double.NaN);
long wallTime = appDepType.getMaxWallTime() * 60;
@@ -72,7 +72,7 @@ public class ResourceProcessor {
private static void createMemory(JobDefinitionType value, HpcApplicationDeploymentType appDepType){
if (appDepType.getMinMemory() > 0 && appDepType.getMaxMemory() > 0) {
- UCRangeValueType rangeType = new UCRangeValueType();
+ RangeValueType rangeType = new RangeValueType();
rangeType.setLowerBound(appDepType.getMinMemory());
rangeType.setUpperBound(appDepType.getMaxMemory());
JSDLUtils.setIndividualPhysicalMemoryRequirements(value, rangeType);
@@ -80,14 +80,14 @@ public class ResourceProcessor {
else if (appDepType.getMinMemory() > 0 && appDepType.getMaxMemory() <= 0) {
// TODO set Wall time
- UCRangeValueType rangeType = new UCRangeValueType();
+ RangeValueType rangeType = new RangeValueType();
rangeType.setLowerBound(appDepType.getMinMemory());
JSDLUtils.setIndividualPhysicalMemoryRequirements(value, rangeType);
}
else if (appDepType.getMinMemory() <= 0 && appDepType.getMaxMemory() > 0) {
// TODO set Wall time
- UCRangeValueType rangeType = new UCRangeValueType();
+ RangeValueType rangeType = new RangeValueType();
rangeType.setUpperBound(appDepType.getMinMemory());
JSDLUtils.setIndividualPhysicalMemoryRequirements(value, rangeType);
}
Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/SPMDProcessor.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/SPMDProcessor.java?rev=1471342&r1=1471341&r2=1471342&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/SPMDProcessor.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/SPMDProcessor.java Wed Apr 24 10:12:43 2013
@@ -22,7 +22,7 @@
package org.apache.airavata.gfac.provider.utils;
import org.apache.airavata.gfac.context.JobExecutionContext;
-import org.ogf.schemas.jsdl.JobDefinitionType;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionType;
public class SPMDProcessor {
Modified: airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/JSDLGeneratorTest.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/JSDLGeneratorTest.java?rev=1471342&r1=1471341&r2=1471342&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/JSDLGeneratorTest.java (original)
+++ airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/JSDLGeneratorTest.java Wed Apr 24 10:12:43 2013
@@ -54,9 +54,9 @@ import org.apache.airavata.schemas.gfac.
import org.apache.airavata.schemas.gfac.URIParameterType;
import org.apache.airavata.schemas.gfac.UnicoreHostType;
import org.apache.log4j.PropertyConfigurator;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionDocument;
import org.junit.Before;
import org.junit.Test;
-import org.ogf.schemas.jsdl.JobDefinitionDocument;
public class JSDLGeneratorTest {