You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ch...@apache.org on 2014/03/04 15:42:44 UTC
git commit: adding sample to create and launch experiment -
AIRAVATA-1039
Repository: airavata
Updated Branches:
refs/heads/master 46b17de73 -> c897d30b3
adding sample to create and launch experiment - AIRAVATA-1039
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/c897d30b
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/c897d30b
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/c897d30b
Branch: refs/heads/master
Commit: c897d30b3f5596e31aef04cde32c05ef8938a006
Parents: 46b17de
Author: chathuri <ch...@apache.org>
Authored: Tue Mar 4 09:42:40 2014 -0500
Committer: chathuri <ch...@apache.org>
Committed: Tue Mar 4 09:42:40 2014 -0500
----------------------------------------------------------------------
.../java-client-samples/pom.xml | 20 +++
.../client/samples/CreateLaunchExperiment.java | 126 +++++++++++++++++--
.../main/resources/airavata-client.properties | 77 ++++++++++++
3 files changed, 212 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/c897d30b/airavata-api/airavata-client-sdks/java-client-samples/pom.xml
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/java-client-samples/pom.xml b/airavata-api/airavata-client-sdks/java-client-samples/pom.xml
index c3282e9..f5e543b 100644
--- a/airavata-api/airavata-client-sdks/java-client-samples/pom.xml
+++ b/airavata-api/airavata-client-sdks/java-client-samples/pom.xml
@@ -39,6 +39,26 @@
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-common-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-client-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-gfac-schema-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-jpa-registry</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
<artifactId>airavata-api-stubs</artifactId>
<version>${project.version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/airavata/blob/c897d30b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
index 4c8739b..8abe3b2 100644
--- a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
+++ b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
@@ -21,52 +21,156 @@
package org.apache.airavata.client.samples;
+import org.apache.airavata.api.error.ExperimentNotFoundException;
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.ClientSettings;
+import org.apache.airavata.schemas.gfac.DataType;
import org.apache.airavata.api.Airavata;
import org.apache.airavata.api.client.AiravataClientFactory;
import org.apache.airavata.api.error.AiravataClientException;
import org.apache.airavata.api.error.AiravataSystemException;
import org.apache.airavata.api.error.InvalidRequestException;
+import org.apache.airavata.client.AiravataAPIFactory;
+import org.apache.airavata.client.api.AiravataAPI;
+import org.apache.airavata.client.api.exception.AiravataAPIInvocationException;
+import org.apache.airavata.client.tools.DocumentCreator;
+import org.apache.airavata.common.utils.AiravataUtils;
import org.apache.airavata.model.util.ExperimentModelUtil;
+import org.apache.airavata.model.workspace.experiment.ComputationalResourceScheduling;
+import org.apache.airavata.model.workspace.experiment.DataObjectType;
+import org.apache.airavata.model.workspace.experiment.UserConfigurationData;
import org.apache.thrift.TException;
import org.apache.airavata.model.workspace.experiment.Experiment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.ArrayList;
+import java.util.List;
+
public class CreateLaunchExperiment {
//FIXME: Read from a config file
public static final String THRIFT_SERVER_HOST = "localhost";
public static final int THRIFT_SERVER_PORT = 8930;
- private static Airavata.Client airavata;
private final static Logger logger = LoggerFactory.getLogger(CreateLaunchExperiment.class);
+ private static final String DEFAULT_USER = "defauly.registry.user";
+ private static final String DEFAULT_GATEWAY = "default.registry.gateway";
public static void main(String[] args) {
- airavata = AiravataClientFactory.createAiravataClient(THRIFT_SERVER_HOST, THRIFT_SERVER_PORT);
try {
+ AiravataUtils.setExecutionAsClient();
+ Airavata.Client airavata = AiravataClientFactory.createAiravataClient(THRIFT_SERVER_HOST, THRIFT_SERVER_PORT);
System.out.println("API version is " + airavata.GetAPIVersion());
+ addDescriptors();
String expId = createExperiment(airavata);
- Experiment experiment = airavata.getExperiment(expId);
- System.out.println("retrieved exp id : " + experiment.getExperimentID());
+ System.out.println("Experiment ID : " + expId);
+ launchExperiment(airavata, expId);
+// Experiment experiment = airavata.getExperiment(expId);
+// System.out.println("retrieved exp id : " + experiment.getExperimentID());
} catch (TException e) {
- logger.error("Error while connecting with server", e.getMessage());
+ logger.error("Error while connecting with server", e.getMessage());
+ e.printStackTrace();
+ } catch (ApplicationSettingsException e) {
+ logger.error("Error while creating airavata API object", e.getMessage());
+ e.printStackTrace();
+ } catch (AiravataAPIInvocationException e) {
+ logger.error("Error while creating airavata API object", e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
+ public static void addDescriptors() throws AiravataAPIInvocationException,ApplicationSettingsException {
+ try {
+ DocumentCreator documentCreator = new DocumentCreator(getAiravataAPI());
+ documentCreator.createLocalHostDocs();
+ documentCreator.createGramDocs();
+ documentCreator.createGSISSHDocs();
+ } catch (AiravataAPIInvocationException e) {
+ logger.error("Unable to create airavata API", e.getMessage());
+ throw new AiravataAPIInvocationException(e);
+ } catch (ApplicationSettingsException e) {
+ logger.error("Unable to create airavata API", e.getMessage());
+ throw new ApplicationSettingsException(e.getMessage());
}
}
- public static String createExperiment (Airavata.Client client){
+ private static AiravataAPI getAiravataAPI() throws AiravataAPIInvocationException, ApplicationSettingsException {
+ AiravataAPI airavataAPI;
+ try {
+ String sysUser = ClientSettings.getSetting(DEFAULT_USER);
+ String gateway = ClientSettings.getSetting(DEFAULT_GATEWAY);
+ airavataAPI = AiravataAPIFactory.getAPI(gateway, sysUser);
+ } catch (AiravataAPIInvocationException e) {
+ logger.error("Unable to create airavata API", e.getMessage());
+ throw new AiravataAPIInvocationException(e);
+ } catch (ApplicationSettingsException e) {
+ logger.error("Unable to create airavata API", e.getMessage());
+ throw new ApplicationSettingsException(e.getMessage());
+ }
+ return airavataAPI;
+ }
+
+ public static String createExperiment (Airavata.Client client) throws AiravataSystemException, InvalidRequestException, AiravataClientException, TException {
try{
- Experiment experiment = ExperimentModelUtil.createSimpleExperiment("testProject", "admin", "experiment1", "testDescription", "testApp", null);
- String expId = client.createExperiment(experiment);
- System.out.println("Experiment ID : " + expId);
- return expId;
+ List<DataObjectType> exInputs = new ArrayList<DataObjectType>();
+ DataObjectType input = new DataObjectType();
+ input.setKey("echo_input");
+ input.setType(DataType.STRING.toString());
+ input.setValue("echo_output=Hello World");
+ exInputs.add(input);
+
+ List<DataObjectType> exOut = new ArrayList<DataObjectType>();
+ DataObjectType output = new DataObjectType();
+ output.setKey("echo_output");
+ output.setType(DataType.STRING.toString());
+ output.setValue("");
+ exOut.add(output);
+
+ Experiment simpleExperiment = ExperimentModelUtil.createSimpleExperiment("project1", "admin", "echoExperiment", "SimpleEcho2", "SimpleEcho2", exInputs);
+ simpleExperiment.setExperimentOutputs(exOut);
+
+ ComputationalResourceScheduling scheduling = ExperimentModelUtil.createComputationResourceScheduling("trestles.sdsc.edu", 1, 1, 1, "normal", 0, 0, 1, "sds128");
+ scheduling.setResourceHostId("gsissh-trestles");
+ UserConfigurationData userConfigurationData = new UserConfigurationData();
+ userConfigurationData.setAiravataAutoSchedule(false);
+ userConfigurationData.setOverrideManualScheduledParams(false);
+ userConfigurationData.setComputationalResourceScheduling(scheduling);
+ simpleExperiment.setUserConfigurationData(userConfigurationData);
+ return client.createExperiment(simpleExperiment);
} catch (AiravataSystemException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
+ throw new AiravataSystemException(e);
} catch (InvalidRequestException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
+ throw new InvalidRequestException(e);
} catch (AiravataClientException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
+ throw new AiravataClientException(e);
}catch (TException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
+ throw new TException(e);
+ }
+ }
+
+ public static void launchExperiment (Airavata.Client client, String expId)
+ throws ExperimentNotFoundException, AiravataSystemException, InvalidRequestException,AiravataClientException, TException{
+ try {
+ client.launchExperiment(expId, "testToken");
+ } catch (ExperimentNotFoundException e) {
+ logger.error("Error occured while launching the experiment...", e.getMessage());
+ throw new ExperimentNotFoundException(e);
+ } catch (AiravataSystemException e) {
+ logger.error("Error occured while launching the experiment...", e.getMessage());
+ throw new AiravataSystemException(e);
+ } catch (InvalidRequestException e) {
+ logger.error("Error occured while launching the experiment...", e.getMessage());
+ throw new InvalidRequestException(e);
+ } catch (AiravataClientException e) {
+ logger.error("Error occured while launching the experiment...", e.getMessage());
+ throw new AiravataClientException(e);
+ }catch (TException e) {
+ logger.error("Error occured while launching the experiment...", e.getMessage());
+ throw new TException(e);
}
- return null;
}
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/c897d30b/airavata-api/airavata-client-sdks/java-client-samples/src/main/resources/airavata-client.properties
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/java-client-samples/src/main/resources/airavata-client.properties b/airavata-api/airavata-client-sdks/java-client-samples/src/main/resources/airavata-client.properties
new file mode 100644
index 0000000..ff4de88
--- /dev/null
+++ b/airavata-api/airavata-client-sdks/java-client-samples/src/main/resources/airavata-client.properties
@@ -0,0 +1,77 @@
+#
+#
+# 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.
+#
+
+###########################################################################
+#
+# This properties file provides configuration for Airavata Clients:
+# XBaya and Airavata API
+#
+###########################################################################
+
+###---------------------------REGISTRY API IMPLEMENTATION---------------------------###
+
+class.registry.accessor=org.apache.airavata.persistance.registry.jpa.impl.AiravataJPARegistry
+#class.registry.accessor=org.apache.airavata.rest.client.RegistryClient
+
+###---------------------REGISTRY API IMPLEMENTATION - CUSTOM SETTINGS----------------------###
+
+########################Registry JPA Implementation Settings########################
+#for mysql [AiravataJPARegistry]
+#registry.jdbc.driver=com.mysql.jdbc.Driver
+#registry.jdbc.url=jdbc:mysql://localhost:3306/persistent_data
+
+#for derby [AiravataJPARegistry]
+registry.jdbc.driver=org.apache.derby.jdbc.ClientDriver
+registry.jdbc.url=jdbc:derby://localhost:1527/persistent_data;create=true;user=airavata;password=airavata
+registry.jdbc.user=airavata
+registry.jdbc.password=airavata
+start.derby.server.mode=true
+
+
+validationQuery=SELECT 1 from Configuration
+jpa.connection.properties=MaxActive=10,MaxIdle=5,MinIdle=2,MaxWait=60000,testWhileIdle=true,testOnBorrow=true
+defauly.registry.user=admin
+default.registry.password=admin
+default.registry.password.hash.method=SHA
+default.registry.gateway=default
+
+#user defined registry accessor classes
+#class.provenance.registry.accessor=org.apache.airavata.persistance.registry.jpa.impl.AiravataJPARegistry
+#class.configuration.registry.accessor=org.apache.airavata.persistance.registry.jpa.impl.AiravataJPARegistry
+#class.descriptor.registry.accessor=org.apache.airavata.persistance.registry.jpa.impl.AiravataJPARegistry
+#class.project.registry.accessor=org.apache.airavata.persistance.registry.jpa.impl.AiravataJPARegistry
+#class.user.workflow.registry.accessor=org.apache.airavata.persistance.registry.jpa.impl.AiravataJPARegistry
+#class.published.workflow.registry.accessor=org.apache.airavata.persistance.registry.jpa.impl.AiravataJPARegistry
+
+########################Registry Rest Implementation Settings########################
+
+trust.store=aiaravata.jks
+trust.store.password=airavata
+
+#####################################################################################
+
+#for xbaya
+xbaya.registry.user=admin
+xbaya.registry.url=http://localhost:8080/airavata/services/registry
+xbaya.default.gateway=default
+
+
+
+