Updated Branches:
  refs/heads/master 8d163f4db -> 029e604d0

changing orchestrator to use new gfac-cpi


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

Branch: refs/heads/master
Commit: 02606da17c4f7b570c27e987a5bb3e2a710e34d9
Parents: 8d163f4
Author: lahiru <[email protected]>
Authored: Wed Feb 12 15:32:51 2014 -0500
Committer: lahiru <[email protected]>
Committed: Wed Feb 12 15:32:51 2014 -0500

----------------------------------------------------------------------
 modules/orchestrator/orchestrator-core/pom.xml  |  5 ++
 .../core/impl/EmbeddedGFACJobSubmitter.java     | 84 +++-----------------
 .../core/utils/OrchestratorUtils.java           | 13 ---
 .../orchestrator/core/NewOrchestratorTest.java  |  1 -
 4 files changed, 14 insertions(+), 89 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/02606da1/modules/orchestrator/orchestrator-core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-core/pom.xml 
b/modules/orchestrator/orchestrator-core/pom.xml
index fbde87f..cbc4f80 100644
--- a/modules/orchestrator/orchestrator-core/pom.xml
+++ b/modules/orchestrator/orchestrator-core/pom.xml
@@ -36,6 +36,11 @@ the License. -->
         </dependency>
         <dependency>
             <groupId>org.apache.airavata</groupId>
+            <artifactId>airavata-registry-cpi</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
             <artifactId>airavata-jpa-registry</artifactId>
             <version>${project.version}</version>
         </dependency>

http://git-wip-us.apache.org/repos/asf/airavata/blob/02606da1/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/EmbeddedGFACJobSubmitter.java
----------------------------------------------------------------------
diff --git 
a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/EmbeddedGFACJobSubmitter.java
 
b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/EmbeddedGFACJobSubmitter.java
index d65eeb5..4519cf7 100644
--- 
a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/EmbeddedGFACJobSubmitter.java
+++ 
b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/EmbeddedGFACJobSubmitter.java
@@ -25,28 +25,13 @@ import java.io.File;
 import java.net.URL;
 import java.util.*;
 
-import org.apache.airavata.client.api.AiravataAPI;
-import org.apache.airavata.client.api.exception.AiravataAPIInvocationException;
 import org.apache.airavata.common.utils.AiravataJobState;
-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.Constants;
-import org.apache.airavata.gfac.cpi.GFacAPI;
-import org.apache.airavata.gfac.GFacConfiguration;
-import org.apache.airavata.gfac.context.ApplicationContext;
-import org.apache.airavata.gfac.context.JobExecutionContext;
-import org.apache.airavata.gfac.context.MessageContext;
-import org.apache.airavata.gfac.scheduler.HostScheduler;
-import org.apache.airavata.model.experiment.ConfigurationData;
 import org.apache.airavata.orchestrator.core.context.OrchestratorContext;
 import org.apache.airavata.orchestrator.core.exception.OrchestratorException;
 import org.apache.airavata.orchestrator.core.gfac.GFACInstance;
 import org.apache.airavata.orchestrator.core.job.JobSubmitter;
-import org.apache.airavata.orchestrator.core.utils.OrchestratorUtils;
-import org.apache.airavata.registry.api.AiravataRegistry2;
-import org.apache.airavata.registry.cpi.DataType;
+import org.apache.airavata.registry.cpi.Registry;
+import org.apache.airavata.gfac.cpi.GFac;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -60,7 +45,6 @@ public class EmbeddedGFACJobSubmitter implements JobSubmitter 
{
 
     private OrchestratorContext orchestratorContext;
 
-
     public void initialize(OrchestratorContext orchestratorContext) throws 
OrchestratorException {
         this.orchestratorContext = orchestratorContext;
     }
@@ -87,68 +71,18 @@ public class EmbeddedGFACJobSubmitter implements 
JobSubmitter {
     //FIXME: (MEP) This method is pretty gruesome.  If we really expect 
multiple implementations of the JobSubmitter
     // interface and at least some of them will need to do the stuff in this 
method, then we need a parent class GenericJobSubmitterImpl.java (maybe 
abstract) that includes launchGfacWithJobRequest() so that subclasses can 
inherit it.
     private void launchGfacWithJobRequest(String experimentID) throws 
OrchestratorException {
-        ConfigurationData configurationData = (ConfigurationData)
-                
orchestratorContext.getNewRegistry().get(DataType.EXPERIMENT_CONFIGURATION_DATA,
 experimentID);
-
-        String serviceName = configurationData.getApplicationId();
-
-        if (serviceName == null) {
-            throw new OrchestratorException("Error executing the job because 
there is not Application Name in this Experiment");
-        }
-        AiravataAPI airavataAPI = null;
+        Registry newRegistry = orchestratorContext.getNewRegistry();
         try {
-            airavataAPI = 
orchestratorContext.getOrchestratorConfiguration().getAiravataAPI();
-            AiravataRegistry2 registry = orchestratorContext.getRegistry();
-            List<HostDescription> registeredHosts = new 
ArrayList<HostDescription>();
-            Map<String, ApplicationDescription> applicationDescriptors = 
registry.getApplicationDescriptors(serviceName);
-            for (String hostDescName : applicationDescriptors.keySet()) {
-                registeredHosts.add(registry.getHostDescriptor(hostDescName));
-            }
-            Class<? extends HostScheduler> aClass = 
Class.forName(ServerSettings.getHostScheduler()).asSubclass(HostScheduler.class);
-            HostScheduler hostScheduler = aClass.newInstance();
-            HostDescription hostDescription = 
hostScheduler.schedule(registeredHosts);
-
-            ServiceDescription serviceDescription = 
registry.getServiceDescriptor(serviceName);
-
-            ApplicationDescription applicationDescription = 
registry.getApplicationDescriptors(serviceName, 
hostDescription.getType().getHostName());
-            // When we run getInParameters we set the actualParameter object, 
this has to be fixed
-            //FIXME: will these class loaders work correctly in Thrift?
-            //FIXME: gfac-config.xml is only under src/test.
-            URL resource = 
EmbeddedGFACJobSubmitter.class.getClassLoader().getResource("gfac-config.xml");
-            Properties configurationProperties = 
ServerSettings.getProperties();
-            GFacConfiguration gFacConfiguration = GFacConfiguration.create(new 
File(resource.getPath()), airavataAPI, configurationProperties);
-
-            JobExecutionContext jobExecutionContext = new 
JobExecutionContext(gFacConfiguration, serviceName);
-            //Here we get only the contextheader information sent specific for 
this node
-            //Add security context
-
-
-            ApplicationContext applicationContext = new ApplicationContext();
-            
applicationContext.setApplicationDeploymentDescription(applicationDescription);
-            applicationContext.setHostDescription(hostDescription);
-            applicationContext.setServiceDescription(serviceDescription);
-
-            jobExecutionContext.setApplicationContext(applicationContext);
-
-
-            Map<String, String> experimentInputs = 
configurationData.getExperimentInputs();
-
-            jobExecutionContext.setInMessageContext(new 
MessageContext(OrchestratorUtils.getMessageContext(experimentInputs,
-                    serviceDescription.getType().getInputParametersArray())));
-
-            HashMap<String, Object> outputData = new HashMap<String, Object>();
-            jobExecutionContext.setOutMessageContext(new 
MessageContext(outputData));
-
-            jobExecutionContext.setProperty(Constants.PROP_TOPIC, 
experimentID);
-            jobExecutionContext.setExperimentID(experimentID);
-            //FIXME: (MEP) GFacAPI.submitJob() throws a GFacException that 
isn't caught here. You want to catch this before updating the registry.
-            GFacAPI gfacAPI1 = new GFacAPI();
-            gfacAPI1.submitJob(jobExecutionContext);
+            //todo init this during submitter init
+            GFac gFac = new GFac(newRegistry, 
orchestratorContext.getOrchestratorConfiguration().getAiravataAPI(), 
orchestratorContext.getRegistry());
+            gFac.submitJob(experimentID);
             //FIXME: (MEP) It may be better to change the registry status in 
GFacAPI rather then here.
             orchestratorContext.getRegistry().changeStatus(experimentID, 
AiravataJobState.State.SUBMITTED);
-        } catch (Exception e) {
+        } catch (Exception e)
+        {
             throw new OrchestratorException("Error launching the Job", e);
         }
+
     }
 
     public boolean directJobSubmit(String experimentID) throws 
OrchestratorException {

http://git-wip-us.apache.org/repos/asf/airavata/blob/02606da1/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java
----------------------------------------------------------------------
diff --git 
a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java
 
b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java
index ba574a5..c65f1f4 100644
--- 
a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java
+++ 
b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java
@@ -60,18 +60,5 @@ public class OrchestratorUtils {
     }
 
 
-    public static Map<String, Object> getMessageContext(Map<String, String> 
experimentData,
-                                                        Parameter[] 
parameters) throws OrchestratorException {
-        HashMap<String, Object> stringObjectHashMap = new HashMap<String, 
Object>();
 
-        for (int i = 0; i < parameters.length; i++) {
-            String input = 
experimentData.get(parameters[i].getParameterName());
-            if (input != null) {
-                stringObjectHashMap.put(parameters[i].getParameterName(), 
GFacUtils.getInputActualParameter(parameters[i], input));
-            } else {
-                throw new OrchestratorException("Parameter:" + input + "is 
missing");
-            }
-        }
-        return stringObjectHashMap;
-    }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/02606da1/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/NewOrchestratorTest.java
----------------------------------------------------------------------
diff --git 
a/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/NewOrchestratorTest.java
 
b/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/NewOrchestratorTest.java
index 7402103..0bed552 100644
--- 
a/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/NewOrchestratorTest.java
+++ 
b/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/NewOrchestratorTest.java
@@ -34,7 +34,6 @@ import org.apache.airavata.model.experiment.*;
 import org.apache.airavata.orchestrator.cpi.Orchestrator;
 import org.apache.airavata.orchestrator.cpi.impl.SimpleOrchestratorImpl;
 import org.apache.airavata.persistance.registry.jpa.impl.RegistryImpl;
-import org.apache.airavata.registry.api.JobRequest;
 import org.apache.airavata.registry.cpi.ChildDataType;
 import org.apache.airavata.registry.cpi.ParentDataType;
 import org.apache.airavata.registry.cpi.Registry;

Reply via email to