airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From samin...@apache.org
Subject [1/2] git commit: AIRAVATA-1309
Date Wed, 02 Jul 2014 20:43:07 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 07c3f788d -> 1fc241322


AIRAVATA-1309


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/720be044
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/720be044
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/720be044

Branch: refs/heads/master
Commit: 720be0449de60c430b75c97d09d876e050b0be61
Parents: c60ba81
Author: Saminda Wijeratne <samindaw@gmail.com>
Authored: Wed Jul 2 16:40:52 2014 -0400
Committer: Saminda Wijeratne <samindaw@gmail.com>
Committed: Wed Jul 2 16:40:52 2014 -0400

----------------------------------------------------------------------
 modules/gfac/gfac-core/pom.xml                  |  10 +
 .../airavata/gfac/core/cpi/BetterGfacImpl.java  | 266 ++++++++++++++++---
 .../apache/airavata/gfac/core/cpi/GFacImpl.java |   3 +-
 .../gfac/core/scheduler/HostScheduler.java      |   6 +-
 .../scheduler/impl/SimpleHostScheduler.java     |   8 +-
 .../airavata-orchestrator-service/pom.xml       |  10 +
 .../server/OrchestratorServerHandler.java       | 141 +++++-----
 pom.xml                                         |   2 +-
 8 files changed, 331 insertions(+), 115 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/720be044/modules/gfac/gfac-core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/pom.xml b/modules/gfac/gfac-core/pom.xml
index 19d5f09..e5a0f00 100644
--- a/modules/gfac/gfac-core/pom.xml
+++ b/modules/gfac/gfac-core/pom.xml
@@ -50,6 +50,16 @@
             <artifactId>airavata-registry-cpi</artifactId>
             <version>${project.version}</version>
         </dependency>
+                <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>app-catalog-data</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>app-catalog-cpi</artifactId>
+            <version>${project.version}</version>
+        </dependency>
          <dependency>
             <groupId>org.apache.airavata</groupId>
             <artifactId>airavata-jpa-registry</artifactId>

http://git-wip-us.apache.org/repos/asf/airavata/blob/720be044/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/BetterGfacImpl.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/BetterGfacImpl.java
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/BetterGfacImpl.java
index 67c7193..3ec1314 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/BetterGfacImpl.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/BetterGfacImpl.java
@@ -25,9 +25,13 @@ import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 import java.util.Properties;
 
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPathExpressionException;
+
+import org.airavata.appcatalog.cpi.AppCatalog;
+import org.apache.aiaravata.application.catalog.data.impl.AppCatalogFactory;
 import org.apache.airavata.client.api.AiravataAPI;
 import org.apache.airavata.common.exception.ApplicationSettingsException;
 import org.apache.airavata.common.utils.AiravataZKUtils;
@@ -42,8 +46,16 @@ import org.apache.airavata.gfac.Scheduler;
 import org.apache.airavata.gfac.core.context.ApplicationContext;
 import org.apache.airavata.gfac.core.context.JobExecutionContext;
 import org.apache.airavata.gfac.core.context.MessageContext;
-import org.apache.airavata.gfac.core.handler.*;
-import org.apache.airavata.gfac.core.monitor.*;
+import org.apache.airavata.gfac.core.handler.GFacHandler;
+import org.apache.airavata.gfac.core.handler.GFacHandlerConfig;
+import org.apache.airavata.gfac.core.handler.GFacHandlerException;
+import org.apache.airavata.gfac.core.handler.GFacRecoverableHandler;
+import org.apache.airavata.gfac.core.handler.ThreadedHandler;
+import org.apache.airavata.gfac.core.monitor.AbstractActivityListener;
+import org.apache.airavata.gfac.core.monitor.ExperimentIdentity;
+import org.apache.airavata.gfac.core.monitor.JobIdentity;
+import org.apache.airavata.gfac.core.monitor.MonitorID;
+import org.apache.airavata.gfac.core.monitor.TaskIdentity;
 import org.apache.airavata.gfac.core.monitor.state.ExperimentStatusChangeRequest;
 import org.apache.airavata.gfac.core.monitor.state.GfacExperimentStateChangeRequest;
 import org.apache.airavata.gfac.core.monitor.state.JobStatusChangeRequest;
@@ -55,14 +67,40 @@ import org.apache.airavata.gfac.core.notification.listeners.WorkflowTrackingList
 import org.apache.airavata.gfac.core.provider.GFacProvider;
 import org.apache.airavata.gfac.core.provider.GFacProviderException;
 import org.apache.airavata.gfac.core.provider.GFacRecoverableProvider;
-import org.apache.airavata.gfac.core.scheduler.HostScheduler;
+import org.apache.airavata.gfac.core.states.GfacExperimentState;
 import org.apache.airavata.gfac.core.states.GfacPluginState;
 import org.apache.airavata.gfac.core.utils.GFacUtils;
-import org.apache.airavata.gfac.core.states.GfacExperimentState;
-import org.apache.airavata.model.workspace.experiment.*;
+import org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription;
+import org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription;
+import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType;
+import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType;
+import org.apache.airavata.model.computehost.ComputeResourceDescription;
+import org.apache.airavata.model.computehost.DataMovementProtocol;
+import org.apache.airavata.model.computehost.GSISSHJobSubmission;
+import org.apache.airavata.model.computehost.GlobusJobSubmission;
+import org.apache.airavata.model.computehost.GridFTPDataMovement;
+import org.apache.airavata.model.computehost.JobSubmissionProtocol;
+import org.apache.airavata.model.computehost.SSHJobSubmission;
+import org.apache.airavata.model.workspace.experiment.DataObjectType;
+import org.apache.airavata.model.workspace.experiment.Experiment;
+import org.apache.airavata.model.workspace.experiment.ExperimentState;
+import org.apache.airavata.model.workspace.experiment.JobState;
+import org.apache.airavata.model.workspace.experiment.TaskDetails;
+import org.apache.airavata.model.workspace.experiment.TaskState;
 import org.apache.airavata.registry.api.AiravataRegistry2;
-import org.apache.airavata.registry.cpi.RegistryModelType;
 import org.apache.airavata.registry.cpi.Registry;
+import org.apache.airavata.registry.cpi.RegistryModelType;
+import org.apache.airavata.schemas.gfac.DataType;
+import org.apache.airavata.schemas.gfac.GlobusHostType;
+import org.apache.airavata.schemas.gfac.GsisshHostType;
+import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
+import org.apache.airavata.schemas.gfac.InputParameterType;
+import org.apache.airavata.schemas.gfac.JobTypeType;
+import org.apache.airavata.schemas.gfac.OutputParameterType;
+import org.apache.airavata.schemas.gfac.ParameterType;
+import org.apache.airavata.schemas.gfac.ProjectAccountType;
+import org.apache.airavata.schemas.gfac.QueueType;
+import org.apache.airavata.schemas.gfac.SSHHostType;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.ZKUtil;
 import org.apache.zookeeper.ZooKeeper;
@@ -70,9 +108,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.SAXException;
 
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.xpath.XPathExpressionException;
-
 /**
  * This is the GFac CPI class for external usage, this simply have a single method to submit
a job to
  * the resource, required data for the job has to be stored in registry prior to invoke this
object.
@@ -215,45 +250,194 @@ public class BetterGfacImpl implements GFac {
 
         // 1. Get the Task from the task ID and construct the Job object and save it in to
registry
         // 2. Add another property to jobExecutionContext and read them inside the provider
and use it.
-        String serviceName = taskData.getApplicationId();
-        if (serviceName == null) {
-            throw new GFacException("Error executing the job because there is not Application
Name in this Experiment:  " + serviceName);
+        String applicationId = taskData.getApplicationId();
+        if (applicationId == null) {
+            throw new GFacException("Error executing the job because there is not Application
Name in this Experiment:  " + applicationId);
         }
 
-        ServiceDescription serviceDescription = airavataRegistry2.getServiceDescriptor(serviceName);
-        if (serviceDescription == null) {
-            throw new GFacException("Error executing the job because there is not Application
Name in this Experiment:  " + serviceName);
-        }
-//        String hostName;
-//        HostDescription hostDescription = null;
-//        if (taskData.getTaskScheduling().getResourceHostId() != null) {
-//            hostName = taskData.getTaskScheduling().getResourceHostId();
-//            hostDescription = airavataRegistry2.getHostDescriptor(hostName);
-//        } else {
-//            List<HostDescription> registeredHosts = new ArrayList<HostDescription>();
-//            Map<String, ApplicationDescription> applicationDescriptors = airavataRegistry2.getApplicationDescriptors(serviceName);
-//            for (String hostDescName : applicationDescriptors.keySet()) {
-//                registeredHosts.add(airavataRegistry2.getHostDescriptor(hostDescName));
-//            }
-//            Class<? extends HostScheduler> aClass = Class.forName(ServerSettings.getHostScheduler()).asSubclass(HostScheduler.class);
-//            HostScheduler hostScheduler = aClass.newInstance();
-//            hostDescription = hostScheduler.schedule(registeredHosts);
-//            hostName = hostDescription.getType().getHostName();
-//        }
-//        if (hostDescription == null) {
-//            throw new GFacException("Error executing the job as the host is not registered
" + hostName);
-//        }
-//        ApplicationDescription applicationDescription = airavataRegistry2.getApplicationDescriptors(serviceName,
hostName);
-        HostDescription hostDescription = airavataRegistry2.getHostDescriptor(taskData.getHostDescriptorId());
-        ApplicationDescription applicationDescription = airavataRegistry2.getApplicationDescriptor(serviceName,
taskData.getHostDescriptorId(), taskData.getApplicationDescriptorId());
-        
+        AppCatalog appCatalog = AppCatalogFactory.getAppCatalog();
+		ApplicationDeploymentDescription applicationDeployement = appCatalog.getApplicationDeployment().getApplicationDeployement(taskData.getApplicationDeploymentId());
+		ComputeResourceDescription computeResource = appCatalog.getComputeResource().getComputeResource(applicationDeployement.getComputeHostId());
+
+		HostDescription hostDescription= new HostDescription();
+        ApplicationDescription applicationDescription = new ApplicationDescription();
+
+		hostDescription.getType().setHostName(computeResource.getHostName());
+		hostDescription.getType().setHostAddress(computeResource.getIpAddresses().iterator().next());
+		
+		String preferredJobSubmissionProtocol = computeResource.getPreferredJobSubmissionProtocol();

+		String preferredDataMovementProtocol = computeResource.getDataMovementProtocols().keySet().iterator().next();

+
+		if (preferredJobSubmissionProtocol==null){
+			preferredJobSubmissionProtocol=computeResource.getJobSubmissionProtocols().keySet().iterator().next();
+		}
+		JobSubmissionProtocol jobSubmissionProtocol = computeResource.getJobSubmissionProtocols().get(preferredJobSubmissionProtocol);
+		DataMovementProtocol dataMovementProtocol = computeResource.getDataMovementProtocols().get(preferredDataMovementProtocol);
+
+		if (jobSubmissionProtocol==JobSubmissionProtocol.GRAM){
+			hostDescription.getType().changeType(GlobusHostType.type);
+			
+			applicationDescription.getType().changeType(HpcApplicationDeploymentType.type);
+			HpcApplicationDeploymentType app=(HpcApplicationDeploymentType)applicationDescription.getType();
+			
+			GlobusJobSubmission globusJobSubmission = appCatalog.getComputeResource().getGlobusJobSubmission(preferredJobSubmissionProtocol);
+			((GlobusHostType)hostDescription.getType()).setGlobusGateKeeperEndPointArray(globusJobSubmission.getGlobusGateKeeperEndPoint().toArray(new
String[]{}));
+			if (dataMovementProtocol==DataMovementProtocol.GridFTP) {
+				GridFTPDataMovement gridFTPDataMovement = appCatalog.getComputeResource().getGridFTPDataMovement(preferredDataMovementProtocol);
+				((GlobusHostType) hostDescription.getType())
+						.setGridFTPEndPointArray(gridFTPDataMovement
+								.getGridFTPEndPoint().toArray(
+										new String[] {}));
+			}
+			////////////////
+			if (computeResource.getHostName().equalsIgnoreCase("trestles.sdsc.edu")){
+		        ProjectAccountType projectAccountType = app.addNewProjectAccount();
+		        projectAccountType.setProjectAccountNumber("sds128");
+	
+		        QueueType queueType = app.addNewQueue();
+		        queueType.setQueueName("normal");
+	
+		        app.setCpuCount(1);
+		        app.setJobType(JobTypeType.SERIAL);
+		        app.setNodeCount(1);
+		        app.setProcessorsPerNode(1);
+	
+		        String tempDir = "/home/ogce/scratch";
+		        app.setScratchWorkingDirectory(tempDir);
+		        app.setMaxMemory(10);
+			}
+			////////////////
+		} else if (jobSubmissionProtocol==JobSubmissionProtocol.GSISSH){
+			hostDescription.getType().changeType(GsisshHostType.type);
+			applicationDescription.getType().changeType(HpcApplicationDeploymentType.type);
+			HpcApplicationDeploymentType app=(HpcApplicationDeploymentType)applicationDescription.getType();
+			
+			GSISSHJobSubmission gsisshJobSubmission = appCatalog.getComputeResource().getGSISSHJobSubmission(preferredJobSubmissionProtocol);
+	        ((GsisshHostType) hostDescription.getType()).setPort(gsisshJobSubmission.getSshPort());
+	        ((GsisshHostType) hostDescription.getType()).setInstalledPath(gsisshJobSubmission.getInstalledPath());
+	        if (computeResource.getHostName().equalsIgnoreCase("lonestar.tacc.utexas.edu")){
+	        	((GsisshHostType) hostDescription.getType()).setJobManager("sge");
+	            ((GsisshHostType) hostDescription.getType()).setInstalledPath("/opt/sge6.2/bin/lx24-amd64/");
+	            ((GsisshHostType) hostDescription.getType()).setPort(22);
+	            ProjectAccountType projectAccountType = app.addNewProjectAccount();
+	            projectAccountType.setProjectAccountNumber("TG-STA110014S");
+	            QueueType queueType = app.addNewQueue();
+	            queueType.setQueueName("normal");
+	            app.setCpuCount(1);
+	            app.setJobType(JobTypeType.SERIAL);
+	            app.setNodeCount(1);
+	            app.setProcessorsPerNode(1);
+	            app.setMaxWallTime(10);
+	            String tempDir = "/home1/01437/ogce";
+	            app.setScratchWorkingDirectory(tempDir);
+	            app.setInstalledParentPath("/opt/sge6.2/bin/lx24-amd64/");
+	        } else if (computeResource.getHostName().equalsIgnoreCase("stampede.tacc.xsede.org")){
+		        ((GsisshHostType) hostDescription.getType()).setJobManager("slurm");
+		        ((GsisshHostType) hostDescription.getType()).setInstalledPath("/usr/bin/");
+		        ((GsisshHostType) hostDescription.getType()).setPort(2222);
+		        ((GsisshHostType) hostDescription.getType()).setMonitorMode("push");
+		        
+		        ProjectAccountType projectAccountType = app.addNewProjectAccount();
+		        projectAccountType.setProjectAccountNumber("TG-STA110014S");
+
+		        QueueType queueType = app.addNewQueue();
+		        queueType.setQueueName("normal");
+
+		        app.setCpuCount(1);
+		        app.setJobType(JobTypeType.SERIAL);
+		        app.setNodeCount(1);
+		        app.setProcessorsPerNode(1);
+		        app.setMaxWallTime(10);
+		        String tempDir = "/home1/01437/ogce";
+		        app.setScratchWorkingDirectory(tempDir);
+		        app.setInstalledParentPath("/usr/bin/");
+
+			} else if (computeResource.getHostName().equalsIgnoreCase("trestles.sdsc.edu")){
+	        	ProjectAccountType projectAccountType = app.addNewProjectAccount();
+	            projectAccountType.setProjectAccountNumber("sds128");
+
+	            QueueType queueType = app.addNewQueue();
+	            queueType.setQueueName("normal");
+
+	            app.setCpuCount(1);
+	            app.setJobType(JobTypeType.SERIAL);
+	            app.setNodeCount(1);
+	            app.setProcessorsPerNode(1);
+	            app.setMaxWallTime(10);
+	            String tempDir = "/oasis/scratch/trestles/ogce/temp_project/";
+	            app.setScratchWorkingDirectory(tempDir);
+	            app.setInstalledParentPath("/opt/torque/bin/");
+	        }
+		} else if (jobSubmissionProtocol==JobSubmissionProtocol.SSH){
+			hostDescription.getType().changeType(SSHHostType.type);
+			SSHJobSubmission sshJobSubmission = appCatalog.getComputeResource().getSSHJobSubmission(preferredJobSubmissionProtocol);
+			applicationDescription.getType().setExecutableLocation(applicationDeployement.getExecutablePath());
+			//TODO update scratch location
+			if (computeResource.getHostName().equalsIgnoreCase("gw111.iu.xsede.org")){
+				applicationDescription.getType().setScratchWorkingDirectory("/tmp");
+			}
+		}
+		
+		ApplicationInterfaceDescription applicationInterface = appCatalog.getApplicationInterface().getApplicationInterface(applicationId);
+		
+		ServiceDescription serviceDescription = new ServiceDescription();
+		List<InputParameterType> inputParameters = new ArrayList<InputParameterType>();
+		List<OutputParameterType> outputParameters = new ArrayList<OutputParameterType>();
+		serviceDescription.getType().setName(applicationInterface.getApplicationName());
+		serviceDescription.getType().setDescription(applicationInterface.getApplicationName());
+
+		List<InputDataObjectType> applicationInputs = applicationInterface.getApplicationInputs();
+		for (InputDataObjectType dataObjectType : applicationInputs) {
+			InputParameterType parameter = InputParameterType.Factory.newInstance();
+			parameter.setParameterName(dataObjectType.getApplicationArguement());
+			parameter.setParameterDescription(dataObjectType.getUserFriendlyDescription());
+			ParameterType parameterType = parameter.addNewParameterType();
+			switch (dataObjectType.getType()){
+				case FLOAT:
+					parameterType.setType(DataType.FLOAT); break;
+				case INTEGER:
+					parameterType.setType(DataType.INTEGER); break;
+				case STRING:
+					parameterType.setType(DataType.STRING); break;
+				case URI:
+					parameterType.setType(DataType.URI); break;
+			}
+			parameterType.setName(parameterType.getType().toString());
+			parameter.addParameterValue(dataObjectType.getValue());
+			inputParameters.add(parameter);
+		}
+		List<OutputDataObjectType> applicationOutputs = applicationInterface.getApplicationOutputs();
+		for (OutputDataObjectType dataObjectType : applicationOutputs) {
+			OutputParameterType parameter = OutputParameterType.Factory.newInstance();
+			parameter.setParameterName(dataObjectType.getName());
+			parameter.setParameterDescription(dataObjectType.getName());
+			ParameterType parameterType = parameter.addNewParameterType();
+			switch (dataObjectType.getType()){
+				case FLOAT:
+					parameterType.setType(DataType.FLOAT); break;
+				case INTEGER:
+					parameterType.setType(DataType.INTEGER); break;
+				case STRING:
+					parameterType.setType(DataType.STRING); break;
+				case URI:
+					parameterType.setType(DataType.URI); break;
+			}
+			parameterType.setName(parameterType.getType().toString());
+			outputParameters.add(parameter);
+		}
+		
+		serviceDescription.getType().setInputParametersArray(inputParameters.toArray(new InputParameterType[]{}));
+		serviceDescription.getType().setOutputParametersArray(outputParameters.toArray(new OutputParameterType[]{}));
+		
+		
+		
         URL resource = GFacImpl.class.getClassLoader().getResource(org.apache.airavata.common.utils.Constants.GFAC_CONFIG_XML);
         Properties configurationProperties = ServerSettings.getProperties();
         GFacConfiguration gFacConfiguration = GFacConfiguration.create(new File(resource.getPath()),
airavataAPI, configurationProperties);
 
 
         // start constructing jobexecutioncontext
-        jobExecutionContext = new JobExecutionContext(gFacConfiguration, serviceName);
+        jobExecutionContext = new JobExecutionContext(gFacConfiguration, applicationId);
 
         // setting experiment/task/workflownode related information
         Experiment experiment = (Experiment) registry.get(RegistryModelType.EXPERIMENT, experimentID);

http://git-wip-us.apache.org/repos/asf/airavata/blob/720be044/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/GFacImpl.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/GFacImpl.java
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/GFacImpl.java
index ebe60b5..c342886 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/GFacImpl.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/GFacImpl.java
@@ -235,7 +235,8 @@ public class GFacImpl implements GFac {
               }
               Class<? extends HostScheduler> aClass = Class.forName(ServerSettings.getHostScheduler()).asSubclass(HostScheduler.class);
              HostScheduler hostScheduler = aClass.newInstance();
-            hostDescription = hostScheduler.schedule(registeredHosts);
+             //TODO cleanup
+            hostDescription = registeredHosts.get(0);//hostScheduler.schedule(registeredHosts);
         	hostName = hostDescription.getType().getHostName();
         }
         if(hostDescription == null){

http://git-wip-us.apache.org/repos/asf/airavata/blob/720be044/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/scheduler/HostScheduler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/scheduler/HostScheduler.java
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/scheduler/HostScheduler.java
index 1971a7d..c53fcae 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/scheduler/HostScheduler.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/scheduler/HostScheduler.java
@@ -20,10 +20,10 @@
 */
 package org.apache.airavata.gfac.core.scheduler;
 
-import org.apache.airavata.commons.gfac.type.HostDescription;
-
 import java.util.List;
 
+import org.apache.airavata.model.computehost.ComputeResourceDescription;
+
 public  interface HostScheduler {
     /**
      * This method will pick a host among set of hosts based on the algorithm users wants
to implement, For a single instance
@@ -31,5 +31,5 @@ public  interface HostScheduler {
      * @param registeredHosts
      * @return
      */
-     public HostDescription schedule(List<HostDescription> registeredHosts);
+     public ComputeResourceDescription schedule(List<ComputeResourceDescription> registeredHosts);
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/720be044/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/scheduler/impl/SimpleHostScheduler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/scheduler/impl/SimpleHostScheduler.java
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/scheduler/impl/SimpleHostScheduler.java
index c74b6b3..3f879c5 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/scheduler/impl/SimpleHostScheduler.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/scheduler/impl/SimpleHostScheduler.java
@@ -20,13 +20,13 @@
 */
 package org.apache.airavata.gfac.core.scheduler.impl;
 
-import org.apache.airavata.commons.gfac.type.HostDescription;
-import org.apache.airavata.gfac.core.scheduler.HostScheduler;
-
 import java.util.List;
 
+import org.apache.airavata.gfac.core.scheduler.HostScheduler;
+import org.apache.airavata.model.computehost.ComputeResourceDescription;
+
 public class SimpleHostScheduler implements HostScheduler {
-    public HostDescription schedule(List<HostDescription> registeredHosts) {
+    public ComputeResourceDescription schedule(List<ComputeResourceDescription> registeredHosts)
{
          //todo implement an algorithm to pick a host among different hosts, ideally this
could be configurable in an xml
         return registeredHosts.get(0);
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/720be044/modules/orchestrator/airavata-orchestrator-service/pom.xml
----------------------------------------------------------------------
diff --git a/modules/orchestrator/airavata-orchestrator-service/pom.xml b/modules/orchestrator/airavata-orchestrator-service/pom.xml
index 63463c2..ca58413 100644
--- a/modules/orchestrator/airavata-orchestrator-service/pom.xml
+++ b/modules/orchestrator/airavata-orchestrator-service/pom.xml
@@ -40,6 +40,16 @@
             <artifactId>airavata-orchestrator-core</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>app-catalog-data</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>app-catalog-cpi</artifactId>
+            <version>${project.version}</version>
+        </dependency>
 	<dependency>
             <groupId>org.apache.airavata</groupId>
             <artifactId>airavata-model-utils</artifactId>

http://git-wip-us.apache.org/repos/asf/airavata/blob/720be044/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
b/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
index efa1862..3dc0b91 100644
--- a/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
+++ b/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
@@ -23,12 +23,18 @@ package org.apache.airavata.orchestrator.server;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Calendar;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Random;
 
+import org.airavata.appcatalog.cpi.AppCatalog;
+import org.airavata.appcatalog.cpi.AppCatalogException;
+import org.airavata.appcatalog.cpi.ComputeResource;
+import org.apache.aiaravata.application.catalog.data.impl.AppCatalogFactory;
+import org.apache.aiaravata.application.catalog.data.resources.AbstractResource;
 import org.apache.airavata.client.AiravataAPIFactory;
 import org.apache.airavata.client.api.AiravataAPI;
 import org.apache.airavata.client.api.exception.AiravataAPIInvocationException;
@@ -36,11 +42,10 @@ import org.apache.airavata.common.exception.ApplicationSettingsException;
 import org.apache.airavata.common.utils.AiravataZKUtils;
 import org.apache.airavata.common.utils.Constants;
 import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.commons.gfac.type.ApplicationDescription;
-import org.apache.airavata.commons.gfac.type.HostDescription;
-import org.apache.airavata.commons.gfac.type.ServiceDescription;
-import org.apache.airavata.gfac.GFacException;
 import org.apache.airavata.gfac.core.scheduler.HostScheduler;
+import org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription;
+import org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription;
+import org.apache.airavata.model.computehost.ComputeResourceDescription;
 import org.apache.airavata.model.error.LaunchValidationException;
 import org.apache.airavata.model.workspace.experiment.Experiment;
 import org.apache.airavata.model.workspace.experiment.ExperimentState;
@@ -417,67 +422,22 @@ public class OrchestratorServerHandler implements OrchestratorService.Iface,
 		try {
 			TaskDetails taskData = (TaskDetails) registry.get(
 					RegistryModelType.TASK_DETAIL, taskId);
-			String serviceName = taskData.getApplicationId();
-			if (serviceName == null) {
-				throw new GFacException(
+			String applicationId = taskData.getApplicationId();
+			if (applicationId == null) {
+				throw new OrchestratorException(
 						"Error executing the job because there is not Application Name in this Experiment:
 "
-								+ serviceName);
+								+ applicationId);
 			}
-			AiravataAPI airavataAPI = getAiravataAPI();
-
-			ServiceDescription serviceDescription = airavataAPI
-					.getApplicationManager().getServiceDescription(serviceName);
-			if (serviceDescription == null) {
-				throw new GFacException(
-						"Error executing the job because there is not Application Name in this Experiment:
 "
-								+ serviceName);
-			}
-			String hostName;
-			HostDescription hostDescription = null;
-			if (taskData.getTaskScheduling().getResourceHostId() != null) {
-				hostName = taskData.getTaskScheduling().getResourceHostId();
-				hostDescription = airavataAPI.getApplicationManager()
-						.getHostDescription(hostName);
-			} else {
-				List<HostDescription> registeredHosts = new ArrayList<HostDescription>();
-				Map<String, ApplicationDescription> applicationDescriptors = airavataAPI
-						.getApplicationManager().getApplicationDescriptors(
-								serviceName);
-				for (String hostDescName : applicationDescriptors.keySet()) {
-					registeredHosts.add(airavataAPI.getApplicationManager()
-							.getHostDescription(hostDescName));
-				}
-				Class<? extends HostScheduler> aClass = Class.forName(
-						ServerSettings.getHostScheduler()).asSubclass(
-						HostScheduler.class);
-				HostScheduler hostScheduler = aClass.newInstance();
-				hostDescription = hostScheduler.schedule(registeredHosts);
-				hostName = hostDescription.getType().getHostName();
-			}
-			if (hostDescription == null) {
-				throw new GFacException(
-						"Error executing the job as the host is not registered "
-								+ hostName);
-			}
-			ApplicationDescription applicationDescription = airavataAPI
-					.getApplicationManager().getApplicationDescription(
-							serviceName, hostName);
-			taskData.setHostDescriptorId(hostName);
-			taskData.setApplicationDescriptorId(applicationDescription
-					.getType().getApplicationName().getStringValue());
-			registry.update(RegistryModelType.TASK_DETAIL, taskData,
-					taskData.getTaskID());
-			List<Object> workflowNodeDetailList = registry
-					.get(RegistryModelType.WORKFLOW_NODE_DETAIL,
-							org.apache.airavata.registry.cpi.utils.Constants.FieldConstants.WorkflowNodeConstants.TASK_LIST,
-							taskData);
+			ApplicationDeploymentDescription applicationDeploymentDescription = getAppDeployment(taskData,
applicationId);
+			taskData.setApplicationDeploymentId(applicationDeploymentDescription.getAppDeploymentId());
+			registry.update(RegistryModelType.TASK_DETAIL, taskData,taskData.getTaskID());
+			List<Object> workflowNodeDetailList = registry.get(RegistryModelType.WORKFLOW_NODE_DETAIL,
+							org.apache.airavata.registry.cpi.utils.Constants.FieldConstants.WorkflowNodeConstants.TASK_LIST,
taskData);
 			if (workflowNodeDetailList != null
 					&& workflowNodeDetailList.size() > 0) {
-				List<Object> experimentList = registry
-						.get(RegistryModelType.EXPERIMENT,
+				List<Object> experimentList = registry.get(RegistryModelType.EXPERIMENT,
 								org.apache.airavata.registry.cpi.utils.Constants.FieldConstants.ExperimentConstants.WORKFLOW_NODE_LIST,
-								(WorkflowNodeDetails) workflowNodeDetailList
-										.get(0));
+								(WorkflowNodeDetails) workflowNodeDetailList.get(0));
 				if (experimentList != null && experimentList.size() > 0) {
 					return orchestrator
 							.launchExperiment(
@@ -496,13 +456,64 @@ public class OrchestratorServerHandler implements OrchestratorService.Iface,
 			e.printStackTrace();
 		} catch (RegistryException e) {
 			e.printStackTrace();
-		} catch (GFacException e) {
-			e.printStackTrace();
-		} catch (AiravataAPIInvocationException e) {
-			e.printStackTrace();
 		} catch (OrchestratorException e) {
 			e.printStackTrace();
+		} catch (AppCatalogException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
 		}
 		return false;
 	}
+
+	private ApplicationDeploymentDescription getAppDeployment(
+			TaskDetails taskData, String applicationId)
+			throws AppCatalogException, OrchestratorException,
+			ClassNotFoundException, ApplicationSettingsException,
+			InstantiationException, IllegalAccessException {
+		AppCatalog appCatalog = AppCatalogFactory.getAppCatalog();
+		String selectedModuleId = getModuleId(appCatalog, applicationId);
+		ApplicationDeploymentDescription applicationDeploymentDescription = getAppDeployment(
+				appCatalog, taskData, selectedModuleId);
+		return applicationDeploymentDescription;
+	}
+
+	private ApplicationDeploymentDescription getAppDeployment(
+			AppCatalog appCatalog, TaskDetails taskData, String selectedModuleId)
+			throws AppCatalogException, ClassNotFoundException,
+			ApplicationSettingsException, InstantiationException,
+			IllegalAccessException {
+		Map<String, String> moduleIdFilter = new HashMap<String, String>();
+		moduleIdFilter.put(AbstractResource.ApplicationDeploymentConstants.APP_MODULE_ID, selectedModuleId);
+		if (taskData.getTaskScheduling().getResourceHostId() != null) {
+		    moduleIdFilter.put(AbstractResource.ApplicationDeploymentConstants.COMPUTE_HOST_ID,
taskData.getTaskScheduling().getResourceHostId());
+		}
+		List<ApplicationDeploymentDescription> applicationDeployements = appCatalog.getApplicationDeployment().getApplicationDeployements(moduleIdFilter);
+		Map<ComputeResourceDescription, ApplicationDeploymentDescription> deploymentMap =
new HashMap<ComputeResourceDescription, ApplicationDeploymentDescription>();
+		ComputeResource computeResource = appCatalog.getComputeResource();
+		for (ApplicationDeploymentDescription deploymentDescription : applicationDeployements)
{
+			deploymentMap.put(computeResource.getComputeResource(deploymentDescription.getComputeHostId()),deploymentDescription);
+		}
+		List<ComputeResourceDescription> computeHostList = Arrays.asList(deploymentMap.keySet().toArray(new
ComputeResourceDescription[]{}));	
+		Class<? extends HostScheduler> aClass = Class.forName(
+				ServerSettings.getHostScheduler()).asSubclass(
+				HostScheduler.class);
+		HostScheduler hostScheduler = aClass.newInstance();
+		ComputeResourceDescription ComputeResourceDescription = hostScheduler.schedule(computeHostList);
+		ApplicationDeploymentDescription applicationDeploymentDescription = deploymentMap.get(ComputeResourceDescription);
+		return applicationDeploymentDescription;
+	}
+
+	private String getModuleId(AppCatalog appCatalog, String applicationId)
+			throws AppCatalogException, OrchestratorException {
+		ApplicationInterfaceDescription applicationInterface = appCatalog.getApplicationInterface().getApplicationInterface(applicationId);
+		List<String> applicationModules = applicationInterface.getApplicationModules();
+		if (applicationModules.size()==0){
+			throw new OrchestratorException(
+					"No modules defined for application "
+							+ applicationId);
+		}
+//			AiravataAPI airavataAPI = getAiravataAPI();
+		String selectedModuleId=applicationModules.get(0);
+		return selectedModuleId;
+	}
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/720be044/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 80e75b1..980f2a6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -507,7 +507,7 @@
                 <module>modules/test-suite</module>
                 <module>modules/distribution</module>
                 <module>modules/ws-messenger</module>
-                <module>modules/integration-tests</module>
+                <!--module>modules/integration-tests</module-->
             </modules>
         </profile>
         <profile>


Mime
View raw message