You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2014/01/10 19:42:51 UTC

svn commit: r1557217 - in /airavata/trunk/modules/orchestrator/orchestrator-core: ./ src/main/java/org/apache/airavata/orchestrator/core/ src/main/java/org/apache/airavata/orchestrator/core/context/ src/main/java/org/apache/airavata/orchestrator/core/e...

Author: lahiru
Date: Fri Jan 10 18:42:50 2014
New Revision: 1557217

URL: http://svn.apache.org/r1557217
Log:
more orchestrator-core changes with test cases.

Added:
    airavata/trunk/modules/orchestrator/orchestrator-core/src/test/
      - copied from r1556863, airavata/trunk/modules/orchestrator/orchestrator-core/src/main/test/
    airavata/trunk/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/PullBasedOrchestratorTest.java
Removed:
    airavata/trunk/modules/orchestrator/orchestrator-core/src/main/test/
Modified:
    airavata/trunk/modules/orchestrator/orchestrator-core/pom.xml
    airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/ExperimentRequest.java
    airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/OrchestratorConfiguration.java
    airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/PullBasedOrchestrator.java
    airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/context/OrchestratorContext.java
    airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/exception/OrchestratorException.java
    airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/gfac/GFACInstance.java
    airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/job/JobSubmitter.java
    airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorConstants.java
    airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java

Modified: airavata/trunk/modules/orchestrator/orchestrator-core/pom.xml
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/orchestrator/orchestrator-core/pom.xml?rev=1557217&r1=1557216&r2=1557217&view=diff
==============================================================================
--- airavata/trunk/modules/orchestrator/orchestrator-core/pom.xml (original)
+++ airavata/trunk/modules/orchestrator/orchestrator-core/pom.xml Fri Jan 10 18:42:50 2014
@@ -46,8 +46,55 @@ the License. -->
         </dependency>
         <dependency>
             <groupId>org.apache.airavata</groupId>
+            <artifactId>airavata-workflow-execution-context</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
             <artifactId>airavata-gfac-core</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<scope>test</scope>
+		</dependency>
+        <dependency>
+			<groupId>org.testng</groupId>
+			<artifactId>testng</artifactId>
+			<version>6.1.1</version>
+			<scope>test</scope>
+		</dependency>
     </dependencies>
+    <build>
+            <plugins>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-compiler-plugin</artifactId>
+                    <configuration>
+                        <source>1.6</source>
+                        <target>1.6</target>
+                    </configuration>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-surefire-plugin</artifactId>
+                    <configuration>
+                     <excludes>
+                            <exclude>**/ssh/**</exclude>
+                        </excludes>
+                        <forkMode>always</forkMode>
+                        <failIfNoTests>false</failIfNoTests>
+                    </configuration>
+                </plugin>
+            </plugins>
+            <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
+            <testOutputDirectory>${project.build.directory}/test-classes</testOutputDirectory>
+            <testResources>
+                <testResource>
+                    <directory>${project.basedir}/src/test/resources</directory>
+                </testResource>
+            </testResources>
+        </build>
+
 </project>

Modified: airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/ExperimentRequest.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/ExperimentRequest.java?rev=1557217&r1=1557216&r2=1557217&view=diff
==============================================================================
--- airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/ExperimentRequest.java (original)
+++ airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/ExperimentRequest.java Fri Jan 10 18:42:50 2014
@@ -23,11 +23,26 @@ package org.apache.airavata.orchestrator
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+/**
+ * This is the initial experiment Creation request
+ * This is simple compair to JobRequest object in registry-api
+ * This contains user specified userExperimentID
+ */
 public class ExperimentRequest {
     private final static Logger logger = LoggerFactory.getLogger(ExperimentRequest.class);
 
     private String userName;
 
+    private String userExperimentID;
+
+    public String getUserExperimentID() {
+        return userExperimentID;
+    }
+
+    public void setUserExperimentID(String userExperimentID) {
+        this.userExperimentID = userExperimentID;
+    }
+
     public String getUserName() {
         return userName;
     }

Modified: airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/OrchestratorConfiguration.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/OrchestratorConfiguration.java?rev=1557217&r1=1557216&r2=1557217&view=diff
==============================================================================
--- airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/OrchestratorConfiguration.java (original)
+++ airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/OrchestratorConfiguration.java Fri Jan 10 18:42:50 2014
@@ -24,6 +24,10 @@ import org.apache.airavata.client.api.Ai
 
 import java.net.URL;
 
+/**
+ * This keeps configuration of orchestrator, mostly this keep static
+ * configuration, this can be accessed through orchestratorContext object
+ */
 public class OrchestratorConfiguration {
 
     private String submitterClass;

Modified: airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/PullBasedOrchestrator.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/PullBasedOrchestrator.java?rev=1557217&r1=1557216&r2=1557217&view=diff
==============================================================================
--- airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/PullBasedOrchestrator.java (original)
+++ airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/PullBasedOrchestrator.java Fri Jan 10 18:42:50 2014
@@ -111,7 +111,7 @@ public class PullBasedOrchestrator imple
             airavataRegistry.storeExperiment(username, experimentID);
             airavataRegistry.changeStatus(experimentID, AiravataJobState.State.CREATED);
         } catch (RegistryException e) {
-            //todo put more meaningful error message
+            //todo put more meaningful error  message
             logger.error("Failed to create experiment for the request from " + request.getUserName());
             throw new OrchestratorException(e);
         }

Modified: airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/context/OrchestratorContext.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/context/OrchestratorContext.java?rev=1557217&r1=1557216&r2=1557217&view=diff
==============================================================================
--- airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/context/OrchestratorContext.java (original)
+++ airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/context/OrchestratorContext.java Fri Jan 10 18:42:50 2014
@@ -28,6 +28,9 @@ import org.apache.airavata.registry.api.
 import java.util.ArrayList;
 import java.util.List;
 
+/**
+ * This is the context object used in orchestrator whic h
+ */
 public class OrchestratorContext {
     private List<GFACInstance> gfacInstanceList;
 

Modified: airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/exception/OrchestratorException.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/exception/OrchestratorException.java?rev=1557217&r1=1557216&r2=1557217&view=diff
==============================================================================
--- airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/exception/OrchestratorException.java (original)
+++ airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/exception/OrchestratorException.java Fri Jan 10 18:42:50 2014
@@ -20,6 +20,10 @@
 */
 package org.apache.airavata.orchestrator.core.exception;
 
+/**
+ * This is the main exception class for orchestrator, All the other
+ * exception classes has to extend this class
+ */
 public class OrchestratorException extends Exception{
     private static final long serialVersionUID = -2849422320139467602L;
 

Modified: airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/gfac/GFACInstance.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/gfac/GFACInstance.java?rev=1557217&r1=1557216&r2=1557217&view=diff
==============================================================================
--- airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/gfac/GFACInstance.java (original)
+++ airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/gfac/GFACInstance.java Fri Jan 10 18:42:50 2014
@@ -23,6 +23,12 @@ package org.apache.airavata.orchestrator
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+/**
+ * This class represent the data related to gfac instances
+ * if orchestrator is running on non-embedded mode,
+ * This information can be used to do better load balancing between
+ * different gfac instances
+ */
 public class GFACInstance {
     private final static Logger logger = LoggerFactory.getLogger(GFACInstance.class);
 

Modified: airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/job/JobSubmitter.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/job/JobSubmitter.java?rev=1557217&r1=1557216&r2=1557217&view=diff
==============================================================================
--- airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/job/JobSubmitter.java (original)
+++ airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/job/JobSubmitter.java Fri Jan 10 18:42:50 2014
@@ -25,6 +25,13 @@ import org.apache.airavata.orchestrator.
 
 import java.util.List;
 
+/**
+ * This is the submitter interface, orchestrator can
+ * submit jobs to gfac in different modes, gfac running embedded
+ * or gfac running in server mode. This can be configured in
+ * orchestrator.properties
+ * todo provide a way to configure this in a dynamic way
+ */
 public interface JobSubmitter {
 
     /**

Modified: airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorConstants.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorConstants.java?rev=1557217&r1=1557216&r2=1557217&view=diff
==============================================================================
--- airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorConstants.java (original)
+++ airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorConstants.java Fri Jan 10 18:42:50 2014
@@ -20,6 +20,10 @@
 */
 package org.apache.airavata.orchestrator.core.utils;
 
+/**
+ * This class contains all the constants in orchestrator-core
+ *
+ */
 public class OrchestratorConstants {
     private static final String SUBMITTER_PROPERTY = "job.submitter";
     public static final String ORCHESTRATOR_PROPERTIES = "orchestrator.properties";

Modified: airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java?rev=1557217&r1=1557216&r2=1557217&view=diff
==============================================================================
--- airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java (original)
+++ airavata/trunk/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java Fri Jan 10 18:42:50 2014
@@ -31,6 +31,9 @@ import java.io.IOException;
 import java.net.URL;
 import java.util.Properties;
 
+/**
+ * This contains orchestrator specific utilities
+ */
 public class OrchestratorUtils {
     private final static Logger logger = LoggerFactory.getLogger(OrchestratorUtils.class);
 

Added: airavata/trunk/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/PullBasedOrchestratorTest.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/PullBasedOrchestratorTest.java?rev=1557217&view=auto
==============================================================================
--- airavata/trunk/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/PullBasedOrchestratorTest.java (added)
+++ airavata/trunk/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/PullBasedOrchestratorTest.java Fri Jan 10 18:42:50 2014
@@ -0,0 +1,154 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.orchestrator.core;
+
+import junit.framework.Assert;
+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.registry.api.JobRequest;
+import org.apache.airavata.schemas.gfac.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.UUID;
+
+public class PullBasedOrchestratorTest {
+    private static final Logger log = LoggerFactory.getLogger(PullBasedOrchestratorTest.class);
+
+    private Orchestrator orchestrator;
+
+    @BeforeTest
+    public void setUp() throws Exception {
+//        System.setProperty("myproxy.user", "ogce");
+//        System.setProperty("myproxy.password", "");
+//        System.setProperty("basedir", "/Users/lahirugunathilake/work/airavata/sandbox/gsissh");
+//        System.setProperty("gsi.working.directory","/home/ogce");
+        orchestrator = new PullBasedOrchestrator();
+        orchestrator.initialize();
+    }
+
+    @Test
+    public void noUserIDTest() throws Exception {
+        ExperimentRequest experimentRequest = new ExperimentRequest();
+        //experimentRequest.setUserExperimentID("test-" + UUID.randomUUID().toString());
+        experimentRequest.setUserName("orchestrator");
+
+        String systemExpID = orchestrator.createExperiment(experimentRequest);
+
+        JobRequest jobRequest = createJobRequest(systemExpID);
+
+        boolean b = orchestrator.launchExperiment(jobRequest);
+
+        if(b){
+            // This means orchestrator successfully accepted the job
+            Assert.assertTrue(true);
+        }else {
+            Assert.assertFalse(true);
+        }
+    }
+
+    @Test
+    public void userIDTest() throws Exception {
+        ExperimentRequest experimentRequest = new ExperimentRequest();
+        experimentRequest.setUserExperimentID("test-" + UUID.randomUUID().toString());
+        experimentRequest.setUserName("orchestrator");
+
+        String systemExpID = orchestrator.createExperiment(experimentRequest);
+
+        JobRequest jobRequest = createJobRequest(systemExpID);
+
+        boolean b = orchestrator.launchExperiment(jobRequest);
+
+        if(b){
+            // This means orchestrator successfully accepted the job
+            Assert.assertTrue(true);
+        }else {
+            Assert.assertFalse(true);
+        }
+    }
+    private JobRequest createJobRequest(String systemExpID) {
+        JobRequest jobRequest = new JobRequest();
+
+        // creating host description
+        HostDescription descriptor = new HostDescription();
+        descriptor.getType().setHostName("localhost");
+        descriptor.getType().setHostAddress("127.0.0.1");
+
+
+        ServiceDescription serviceDescription = new ServiceDescription();
+        List<InputParameterType> inputParameters = new ArrayList<InputParameterType>();
+        List<OutputParameterType> outputParameters = new ArrayList<OutputParameterType>();
+        serviceDescription.getType().setName("Echo");
+        serviceDescription.getType().setDescription("Echo service");
+        // Creating input parameters
+        InputParameterType parameter = InputParameterType.Factory.newInstance();
+        parameter.setParameterName("echo_input");
+        parameter.setParameterDescription("echo input");
+        ParameterType parameterType = parameter.addNewParameterType();
+        parameterType.setType(DataType.STRING);
+        parameterType.setName("String");
+        inputParameters.add(parameter);
+
+        // Creating output parameters
+        OutputParameterType outputParameter = OutputParameterType.Factory.newInstance();
+        outputParameter.setParameterName("echo_output");
+        outputParameter.setParameterDescription("Echo output");
+        ParameterType outputParaType = outputParameter.addNewParameterType();
+        outputParaType.setType(DataType.STRING);
+        outputParaType.setName("String");
+        outputParameters.add(outputParameter);
+
+        // Setting input and output parameters to serviceDescriptor
+        serviceDescription.getType().setInputParametersArray(inputParameters.toArray(new InputParameterType[]{}));
+        serviceDescription.getType().setOutputParametersArray(outputParameters.toArray(new OutputParameterType[]{}));
+
+
+        ApplicationDescription applicationDeploymentDescription = new ApplicationDescription();
+        ApplicationDeploymentDescriptionType applicationDeploymentDescriptionType = applicationDeploymentDescription
+                .getType();
+        applicationDeploymentDescriptionType.addNewApplicationName().setStringValue("EchoApplication");
+        applicationDeploymentDescriptionType.setExecutableLocation("/bin/echo");
+        applicationDeploymentDescriptionType.setScratchWorkingDirectory("/tmp");
+
+        //creating input Map
+
+        HashMap<String, Object> inputData = new HashMap<String, Object>();
+        inputData.put("echo_input", "Hello World");
+
+        HashMap<String, Object> outputData = new HashMap<String, Object>();
+
+
+        // setting all the parameters to jobRequest
+        jobRequest.setExperimentID(systemExpID);
+        jobRequest.setHostDescription(descriptor);
+        jobRequest.setServiceDescription(serviceDescription);
+        jobRequest.setApplicationDescription(applicationDeploymentDescription);
+        return jobRequest;
+    }
+
+
+}