http://git-wip-us.apache.org/repos/asf/airavata/blob/82773c73/modules/orchestrator/airavata-orchestrator-stubs/src/main/java/org/apache/airavata/orchestrator/cpi/orchestrator_cpi_serviceConstants.java ---------------------------------------------------------------------- diff --git a/modules/orchestrator/airavata-orchestrator-stubs/src/main/java/org/apache/airavata/orchestrator/cpi/orchestrator_cpi_serviceConstants.java b/modules/orchestrator/airavata-orchestrator-stubs/src/main/java/org/apache/airavata/orchestrator/cpi/orchestrator_cpi_serviceConstants.java deleted file mode 100644 index 3fa2946..0000000 --- a/modules/orchestrator/airavata-orchestrator-stubs/src/main/java/org/apache/airavata/orchestrator/cpi/orchestrator_cpi_serviceConstants.java +++ /dev/null @@ -1,55 +0,0 @@ - /* - * 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. - */ -/** - * Autogenerated by Thrift Compiler (0.9.1) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -package org.apache.airavata.orchestrator.cpi; - -import org.apache.thrift.scheme.IScheme; -import org.apache.thrift.scheme.SchemeFactory; -import org.apache.thrift.scheme.StandardScheme; - -import org.apache.thrift.scheme.TupleScheme; -import org.apache.thrift.protocol.TTupleProtocol; -import org.apache.thrift.protocol.TProtocolException; -import org.apache.thrift.EncodingUtils; -import org.apache.thrift.TException; -import org.apache.thrift.async.AsyncMethodCallback; -import org.apache.thrift.server.AbstractNonblockingServer.*; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.EnumMap; -import java.util.Set; -import java.util.HashSet; -import java.util.EnumSet; -import java.util.Collections; -import java.util.BitSet; -import java.nio.ByteBuffer; -import java.util.Arrays; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@SuppressWarnings("all") public class orchestrator_cpi_serviceConstants { - - public static final String ORCHESTRATOR_CPI_VERSION = "0.13.0"; - -}
http://git-wip-us.apache.org/repos/asf/airavata/blob/82773c73/modules/orchestrator/airavata-orchestrator-stubs/src/main/java/org/apache/airavata/orchestrator/sample/OrchestratorClientSample.java ---------------------------------------------------------------------- diff --git a/modules/orchestrator/airavata-orchestrator-stubs/src/main/java/org/apache/airavata/orchestrator/sample/OrchestratorClientSample.java b/modules/orchestrator/airavata-orchestrator-stubs/src/main/java/org/apache/airavata/orchestrator/sample/OrchestratorClientSample.java deleted file mode 100644 index 009d110..0000000 --- a/modules/orchestrator/airavata-orchestrator-stubs/src/main/java/org/apache/airavata/orchestrator/sample/OrchestratorClientSample.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * - * 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.sample; - -//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.model.appcatalog.appinterface.DataType; -import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType; -import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType; -import org.apache.airavata.model.util.ExperimentModelUtil; -import org.apache.airavata.model.workspace.experiment.ComputationalResourceScheduling; -import org.apache.airavata.model.workspace.experiment.Experiment; -import org.apache.airavata.model.workspace.experiment.UserConfigurationData; -import org.apache.airavata.orchestrator.cpi.OrchestratorService; -import org.apache.thrift.TException; - -import java.util.ArrayList; -import java.util.List; - -public class OrchestratorClientSample { -// private static DocumentCreator documentCreator; - private static OrchestratorService.Client orchestratorClient; -// private static Registry registry; - private static int NUM_CONCURRENT_REQUESTS = 1; - private static final String DEFAULT_USER = "default.registry.user"; - private static final String DEFAULT_USER_PASSWORD = "default.registry.password"; - private static final String DEFAULT_GATEWAY = "default.registry.gateway"; - private static String sysUser; - private static String sysUserPwd; - private static String gateway; -/* - - public static void main(String[] args) { - try { - AiravataUtils.setExecutionAsClient(); - sysUser = ClientSettings.getSetting(DEFAULT_USER); - sysUserPwd = ClientSettings.getSetting(DEFAULT_USER_PASSWORD); - gateway = ClientSettings.getSetting(DEFAULT_GATEWAY); - orchestratorClient = OrchestratorClientFactory.createOrchestratorClient("localhost", 8940); - registry = RegistryFactory.getRegistry(gateway, sysUser, sysUserPwd); - documentCreator = new DocumentCreator(getAiravataAPI()); - documentCreator.createLocalHostDocs(); - documentCreator.createGramDocs(); - documentCreator.createPBSDocsForOGCE(); - storeExperimentDetail(); - } catch (ApplicationSettingsException e) { - e.printStackTrace(); - } catch (RegistryException e) { - e.printStackTrace(); - } - - } - - private static AiravataAPI getAiravataAPI() { - AiravataAPI airavataAPI = null; - try { - airavataAPI = AiravataAPIFactory.getAPI(gateway, sysUser); - } catch (AiravataAPIInvocationException e) { - e.printStackTrace(); - } - return airavataAPI; - } -*/ - - public static void storeExperimentDetail() { - for (int i = 0; i < NUM_CONCURRENT_REQUESTS; i++) { - Thread thread = new Thread() { - public void run() { - List<InputDataObjectType> exInputs = new ArrayList<InputDataObjectType>(); - InputDataObjectType input = new InputDataObjectType(); - input.setName("echo_input"); - input.setType(DataType.STRING); - input.setValue("echo_output=Hello World"); - exInputs.add(input); - - - List<OutputDataObjectType> exOut = new ArrayList<OutputDataObjectType>(); - OutputDataObjectType output = new OutputDataObjectType(); - output.setName("echo_output"); - output.setType(DataType.STRING); - output.setValue(""); - exOut.add(output); - - Experiment simpleExperiment = ExperimentModelUtil.createSimpleExperiment("default", "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.setComputationalResourceScheduling(scheduling); - simpleExperiment.setUserConfigurationData(userConfigurationData); - String expId = null; - try { -// expId = (String) registry.add(ParentDataType.EXPERIMENT, simpleExperiment); - } catch (Exception e) { - e.printStackTrace(); - } - - try { - orchestratorClient.launchExperiment(expId, "airavataToken"); - } catch (TException e) { - e.printStackTrace(); - } - } - }; - thread.start(); - try { - thread.join(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/82773c73/modules/orchestrator/orchestrator-client/pom.xml ---------------------------------------------------------------------- diff --git a/modules/orchestrator/orchestrator-client/pom.xml b/modules/orchestrator/orchestrator-client/pom.xml new file mode 100644 index 0000000..0c439c9 --- /dev/null +++ b/modules/orchestrator/orchestrator-client/pom.xml @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!--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. --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <artifactId>orchestrator</artifactId> + <groupId>org.apache.airavata</groupId> + <version>0.16-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <name>Airavata Orchestrator Client SDK</name> + <artifactId>orchestrator-client</artifactId> + <packaging>jar</packaging> + <url>http://airavata.apache.org/</url> + + <dependencies> + <dependency> + <groupId>org.apache.thrift</groupId> + <artifactId>libthrift</artifactId> + <version>${thrift.version}</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>${org.slf4j.version}</version> + </dependency> + <dependency> + <groupId>org.apache.airavata</groupId> + <artifactId>airavata-data-models</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.airavata</groupId> + <artifactId>airavata-model-utils</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.airavata</groupId> + <artifactId>airavata-client-configuration</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + </properties> + +</project> http://git-wip-us.apache.org/repos/asf/airavata/blob/82773c73/modules/orchestrator/orchestrator-client/src/main/java/org/apache/airavata/orchestrator/client/OrchestratorClientFactory.java ---------------------------------------------------------------------- diff --git a/modules/orchestrator/orchestrator-client/src/main/java/org/apache/airavata/orchestrator/client/OrchestratorClientFactory.java b/modules/orchestrator/orchestrator-client/src/main/java/org/apache/airavata/orchestrator/client/OrchestratorClientFactory.java new file mode 100644 index 0000000..c2a31cc --- /dev/null +++ b/modules/orchestrator/orchestrator-client/src/main/java/org/apache/airavata/orchestrator/client/OrchestratorClientFactory.java @@ -0,0 +1,44 @@ +/* + * + * 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.client; + +import org.apache.airavata.model.error.AiravataClientConnectException; +import org.apache.airavata.orchestrator.cpi.OrchestratorService; +import org.apache.thrift.protocol.TBinaryProtocol; +import org.apache.thrift.protocol.TProtocol; +import org.apache.thrift.transport.TSocket; +import org.apache.thrift.transport.TTransport; +import org.apache.thrift.transport.TTransportException; + +public class OrchestratorClientFactory { + + public static OrchestratorService.Client createOrchestratorClient(String serverHost, int serverPort) throws AiravataClientConnectException{ + try { + TTransport transport = new TSocket(serverHost, serverPort); + transport.open(); + TProtocol protocol = new TBinaryProtocol(transport); + return new OrchestratorService.Client(protocol); + } catch (TTransportException e) { + throw new AiravataClientConnectException("Unable to connect to the server at "+serverHost+":"+serverPort); + } + } +}
