Repository: airavata-sandbox Updated Branches: refs/heads/master ec6ba29a8 -> 62ad0a537
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/62ad0a53/airavata-mock-multiplexed-api/mock-airavata-api-server/pom.xml ---------------------------------------------------------------------- diff --git a/airavata-mock-multiplexed-api/mock-airavata-api-server/pom.xml b/airavata-mock-multiplexed-api/mock-airavata-api-server/pom.xml new file mode 100644 index 0000000..b547989 --- /dev/null +++ b/airavata-mock-multiplexed-api/mock-airavata-api-server/pom.xml @@ -0,0 +1,46 @@ +<?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>mock-airavata-api</artifactId> + <groupId>org.apache.airavata</groupId> + <version>0.15-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <name>Airavata API Server</name> + <artifactId>mock-airavata-api-server</artifactId> + <packaging>jar</packaging> + <url>http://airavata.apache.org/</url> + + <dependencies> + + <dependency> + <groupId>org.apache.airavata</groupId> + <artifactId>mock-airavata-api-stubs</artifactId> + <version>${project.version}</version> + </dependency> + <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> + </dependencies> + +</project> http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/62ad0a53/airavata-mock-multiplexed-api/mock-airavata-api-server/src/main/java/MockAiravataAPIServer.java ---------------------------------------------------------------------- diff --git a/airavata-mock-multiplexed-api/mock-airavata-api-server/src/main/java/MockAiravataAPIServer.java b/airavata-mock-multiplexed-api/mock-airavata-api-server/src/main/java/MockAiravataAPIServer.java new file mode 100644 index 0000000..4d465f7 --- /dev/null +++ b/airavata-mock-multiplexed-api/mock-airavata-api-server/src/main/java/MockAiravataAPIServer.java @@ -0,0 +1,328 @@ +/* + * + * 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.api.server; + +import java.io.File; +import java.io.IOException; +import java.net.InetSocketAddress; +import java.util.Random; + +import org.apache.airavata.api.Airavata; +import org.apache.airavata.api.server.handler.AiravataServerHandler; +import org.apache.airavata.api.server.util.AppCatalogInitUtil; +import org.apache.airavata.api.server.util.Constants; +import org.apache.airavata.api.server.util.RegistryInitUtil; +import org.apache.airavata.common.exception.ApplicationSettingsException; +import org.apache.airavata.common.utils.AiravataUtils; +import org.apache.airavata.common.utils.AiravataZKUtils; +import org.apache.airavata.common.utils.IServer; +import org.apache.airavata.common.utils.ServerSettings; +import org.apache.airavata.model.error.AiravataErrorType; +import org.apache.airavata.model.error.AiravataSystemException; +import org.apache.thrift.server.TServer; +import org.apache.thrift.server.TThreadPoolServer; +import org.apache.thrift.transport.TServerSocket; +import org.apache.thrift.transport.TServerTransport; +import org.apache.thrift.transport.TTransportException; +import org.apache.zookeeper.*; +import org.apache.zookeeper.data.Stat; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AiravataAPIServer implements IServer, Watcher{ + + private final static Logger logger = LoggerFactory.getLogger(AiravataAPIServer.class); + private static final String SERVER_NAME = "Airavata API Server"; + private static final String SERVER_VERSION = "1.0"; + private ZooKeeper zk; + private static Integer mutex = -1; + + private ServerStatus status; + + private TServer server; + + public AiravataAPIServer() { + setStatus(ServerStatus.STOPPED); + } + + public void startAiravataServer(Airavata.Processor<Airavata.Iface> airavataAPIServer) throws AiravataSystemException { + try { + AiravataUtils.setExecutionAsServer(); + RegistryInitUtil.initializeDB(); + AppCatalogInitUtil.initializeDB(); + final int serverPort = Integer.parseInt(ServerSettings.getSetting(Constants.API_SERVER_PORT,"8930")); + final String serverHost = ServerSettings.getSetting(Constants.API_SERVER_HOST, null); + + TServerTransport serverTransport; + + if(serverHost == null){ + serverTransport = new TServerSocket(serverPort); + }else{ + InetSocketAddress inetSocketAddress = new InetSocketAddress(serverHost, serverPort); + serverTransport = new TServerSocket(inetSocketAddress); + } + + TThreadPoolServer.Args options = new TThreadPoolServer.Args(serverTransport); + options.minWorkerThreads = Integer.parseInt(ServerSettings.getSetting(Constants.API_SERVER_MIN_THREADS, "50")); + server = new TThreadPoolServer(options.processor(airavataAPIServer)); + new Thread() { + public void run() { + server.serve(); + RegistryInitUtil.stopDerbyInServerMode(); + setStatus(ServerStatus.STOPPED); + logger.info("Airavata API Server Stopped."); + } + }.start(); + new Thread() { + public void run() { + while(!server.isServing()){ + try { + Thread.sleep(500); + } catch (InterruptedException e) { + break; + } + } + if (server.isServing()){ + setStatus(ServerStatus.STARTED); + logger.info("Starting Airavata API Server on Port " + serverPort); + logger.info("Listening to Airavata Clients ...."); + } + } + }.start(); + storeServerConfig(); + } catch (TTransportException e) { + logger.error(e.getMessage()); + setStatus(ServerStatus.FAILED); + RegistryInitUtil.stopDerbyInServerMode(); + throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR); + } + } + + public void storeServerConfig() throws AiravataSystemException{ + try { + String zkhostPort = AiravataZKUtils.getZKhostPort(); + String airavataServerHostPort = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.API_SERVER_HOST) + + ":" + ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.API_SERVER_PORT); + String experimentCatalogJDBCURL = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.REGISTRY_JDBC_URL); + String appCatalogJDBCURL = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.APPCATALOG_JDBC_URL); + String rabbitMqBrokerURL = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.RABBITMQ_BROKER_URL); + String rabbitMqExchange = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.RABBITMQ_EXCHANGE); + String rabbitMq = rabbitMqBrokerURL + File.separator + rabbitMqExchange; + zk = new ZooKeeper(zkhostPort, 6000, this); // no watcher is required, this will only use to store some data + String apiServer = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ZOOKEEPER_API_SERVER_NODE, "/airavata-server"); + String OrchServer = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ZOOKEEPER_ORCHESTRATOR_SERVER_NODE, "/orchestrator-server"); + String gfacServer = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ZOOKEEPER_GFAC_SERVER_NODE, "/gfac-server"); + String gfacExperiments = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ZOOKEEPER_GFAC_EXPERIMENT_NODE, "/gfac-experiments"); + String experimentCatalog = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ZOOKEEPER_EXPERIMENT_CATALOG, "/experiment-catalog"); + String appCatalog = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ZOOKEEPER_APPCATALOG, "/app-catalog"); + String rabbitMQ = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ZOOKEEPER_RABBITMQ, "/rabbitMq"); + Stat zkStat = zk.exists(experimentCatalog, false); + if (zkStat == null) { + zk.create(experimentCatalog, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, + CreateMode.PERSISTENT); + } + String exCatalogInstantNode = experimentCatalog + File.separator + String.valueOf(new Random().nextInt(Integer.MAX_VALUE)); + zkStat = zk.exists(exCatalogInstantNode, false); + if (zkStat == null) { + zk.create(exCatalogInstantNode, + experimentCatalogJDBCURL.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, + CreateMode.EPHEMERAL); // other component will watch these childeren creation deletion to monitor the status of the node + logger.info("Successfully created experiment-catalog node"); + } + zkStat = zk.exists(appCatalog, false); + if (zkStat == null) { + zk.create(appCatalog, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, + CreateMode.PERSISTENT); + } + String appCatalogInstantNode = appCatalog + File.separator + String.valueOf(new Random().nextInt(Integer.MAX_VALUE)); + zkStat = zk.exists(appCatalogInstantNode, false); + if (zkStat == null) { + zk.create(appCatalogInstantNode, + appCatalogJDBCURL.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, + CreateMode.EPHEMERAL); // other component will watch these childeren creation deletion to monitor the status of the node + logger.info("Successfully created app-catalog node"); + } + if (getStatus().equals(ServerStatus.STARTED)) { + zkStat = zk.exists(apiServer, false); + if (zkStat == null) { + zk.create(apiServer, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, + CreateMode.PERSISTENT); + } + String instantNode = apiServer + File.separator + String.valueOf(new Random().nextInt(Integer.MAX_VALUE)); + zkStat = zk.exists(instantNode, false); + if (zkStat == null) { + zk.create(instantNode, + airavataServerHostPort.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, + CreateMode.EPHEMERAL); // other component will watch these childeren creation deletion to monitor the status of the node + logger.info("Successfully created airavata-server node"); + } + + zkStat = zk.exists(OrchServer, false); + if (zkStat == null) { + zk.create(OrchServer, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, + CreateMode.PERSISTENT); + logger.info("Successfully created orchestrator-server node"); + } + zkStat = zk.exists(gfacServer, false); + if (zkStat == null) { + zk.create(gfacServer, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, + CreateMode.PERSISTENT); + logger.info("Successfully created gfac-server node"); + } + zkStat = zk.exists(gfacServer, false); + if (zkStat == null) { + zk.create(gfacExperiments, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, + CreateMode.PERSISTENT); + logger.info("Successfully created gfac-server node"); + } + zkStat = zk.exists(rabbitMQ, false); + if (zkStat == null) { + zk.create(rabbitMQ, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, + CreateMode.PERSISTENT); + } + if (ServerSettings.isRabbitMqPublishEnabled()) { + String rabbitMqInstantNode = rabbitMQ + File.separator + String.valueOf(new Random().nextInt(Integer.MAX_VALUE)); + zkStat = zk.exists(rabbitMqInstantNode, false); + if (zkStat == null) { + zk.create(rabbitMqInstantNode, + rabbitMq.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, + CreateMode.EPHEMERAL); // other component will watch these childeren creation deletion to monitor the status of the node + logger.info("Successfully created rabbitMQ node"); + } + } + logger.info("Finished starting ZK: " + zk); + } + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage()); + setStatus(ServerStatus.FAILED); + RegistryInitUtil.stopDerbyInServerMode(); + throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR); + } catch (IOException e) { + logger.error(e.getMessage()); + setStatus(ServerStatus.FAILED); + RegistryInitUtil.stopDerbyInServerMode(); + throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR); + } catch (InterruptedException e) { + logger.error(e.getMessage()); + setStatus(ServerStatus.FAILED); + RegistryInitUtil.stopDerbyInServerMode(); + throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR); + } catch (KeeperException e) { + logger.error(e.getMessage()); + setStatus(ServerStatus.FAILED); + RegistryInitUtil.stopDerbyInServerMode(); + throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR); + } catch (Exception e) { + logger.error(e.getMessage()); + setStatus(ServerStatus.FAILED); + RegistryInitUtil.stopDerbyInServerMode(); + throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR); + } + } + + public static void main(String[] args) { + try { + AiravataAPIServer server = new AiravataAPIServer(); + server.start(); + } catch (Exception e) { + logger.error("Error while initializing Airavata API server", e); + } + } + + @Override + public void start() throws Exception { + setStatus(ServerStatus.STARTING); + Airavata.Processor<Airavata.Iface> airavataAPIServer = + new Airavata.Processor<Airavata.Iface>(new AiravataServerHandler()); + startAiravataServer(airavataAPIServer); + } + + @Override + public void stop() throws Exception { + if (server.isServing()){ + setStatus(ServerStatus.STOPING); + server.stop(); + } + + } + + @Override + public void restart() throws Exception { + stop(); + start(); + } + + @Override + public void configure() throws Exception { + // TODO Auto-generated method stub + + } + + @Override + public ServerStatus getStatus() throws Exception { + return status; + } + + private void setStatus(ServerStatus stat){ + status=stat; + status.updateTime(); + } + + @Override + public String getName() { + return SERVER_NAME; + } + + @Override + public String getVersion() { + return SERVER_VERSION; + } + + @Override + synchronized public void process(WatchedEvent watchedEvent) { + synchronized (mutex) { + Event.KeeperState state = watchedEvent.getState(); + logger.info(state.name()); + switch(state){ + case SyncConnected: + mutex.notify(); + case Expired:case Disconnected: + try { + mutex = -1; + zk = new ZooKeeper(AiravataZKUtils.getZKhostPort(), 6000, this); + synchronized (mutex) { + mutex.wait(); // waiting for the syncConnected event + } + storeServerConfig(); + } catch (IOException e) { + logger.error("Error while synchronizing with zookeeper", e); + } catch (ApplicationSettingsException e) { + logger.error("Error while synchronizing with zookeeper", e); + } catch (InterruptedException e) { + logger.error("Error while synchronizing with zookeeper", e); + } catch (AiravataSystemException e) { + logger.error("Error while synchronizing with zookeeper", e); + } + } + } + } +} http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/62ad0a53/airavata-mock-multiplexed-api/mock-api-interface-descriptions/generate-thrift-stubs.sh ---------------------------------------------------------------------- diff --git a/airavata-mock-multiplexed-api/mock-api-interface-descriptions/generate-thrift-stubs.sh b/airavata-mock-multiplexed-api/mock-api-interface-descriptions/generate-thrift-stubs.sh new file mode 100755 index 0000000..3744494 --- /dev/null +++ b/airavata-mock-multiplexed-api/mock-api-interface-descriptions/generate-thrift-stubs.sh @@ -0,0 +1,269 @@ +#! /usr/bin/env bash + +# 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 script will regenerate the thrift code for Airavata Server Skeletons, Client Stubs and Data Model java beans. + +show_usage() { + echo -e "Usage: $0 [Languague to generate stubs]" + echo "" + echo "options:" + echo -e "\tjava Generate/Update Java Stubs" + echo -e "\tphp Generate/Update PHP Stubs" + echo -e "\tcpp Generate/Update C++ Stubs" + echo -e "\tpython Generate/Update Python Stubs." + echo -e "\tall Generate/Update all stubs (Java, PHP, C++, Python)." + echo -e "\t-h[elp] Print the usage options of this script" +} + +if [ $# -lt 1 ] +then + show_usage + exit 1 +fi + +if [[ $1 == "-h" ||$1 == "--help" ]] +then + show_usage + exit 0 +fi + +# Generation of thrift files will require installing Apache Thrift. Please add thrift to your path. +# Verify is thrift is installed, is in the path is at a specified version. + +REQUIRED_THRIFT_VERSION='0.9.2' + +VERSION=$(thrift -version 2>/dev/null | grep -F "${REQUIRED_THRIFT_VERSION}" | wc -l) +if [ "$VERSION" -ne 1 ] ; then + echo -e "ERROR:\t Apache Thrift version ${REQUIRED_THRIFT_VERSION} is required." + echo -e "It is either not installed or is not in the path" + exit 1 +fi + +# Global Constants used across the script +BASE_TARGET_DIR='target' +DATAMODEL_SRC_DIR='airavata-data-models/src/main/java' +JAVA_API_SDK_DIR='../mock-airavata-api-java-stubs/src/main/java' +CPP_SDK_DIR='airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/airavata/' +PHP_SDK_DIR='airavata-client-sdks/airavata-php-sdk/src/main/resources/lib' + +# Initialize the thrift arguments. +# Since most of the Airavata API and Data Models have includes, use recursive option by default. +# Generate all the files in target directory +THRIFT_ARGS="-r -o ${BASE_TARGET_DIR}" +# Ensure the required target directories exists, if not create. +mkdir -p ${BASE_TARGET_DIR} + +# The Function fail prints error messages on failure and quits the script. +fail() { + echo $@ + exit 1 +} + +# The function add_license_header adds the ASF V2 license header to all java files within the specified generated +# directory. The function also adds suppress all warnings annotation to all public classes and enum's +# To Call: +# add_license_header $generated_code_directory +add_license_header() { + + # Fetch the generated code directory passed as the argument + GENERATED_CODE_DIR=$1 + + # For all generated thrift code, add the suppress all warnings annotation + # NOTE: In order to save the original file as a backup, use sed -i.orig in place of sed -i '' + find ${GENERATED_CODE_DIR} -name '*.java' -print0 | xargs -0 sed -i '' -e 's/public class /@SuppressWarnings("all") public class /' + find ${GENERATED_CODE_DIR} -name '*.java' -print0 | xargs -0 sed -i '' -e 's/public enum /@SuppressWarnings("all") public enum /' + + # For each source file within the generated directory, add the ASF V2 LICENSE header + FILE_SUFFIXES=(.php .java .h .cpp) + for file in "${FILE_SUFFIXES[@]}"; do + for f in $(find ${GENERATED_CODE_DIR} -name "*$file"); do + cat - ${f} >${f}-with-license <<EOF +/** + * 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. + */ + +EOF + mv ${f}-with-license ${f} + done + done +} + +# The function compares every generated java file with the one in specified existing source location. If the comparison +# shows a difference, then it replaces with the newly generated file (with added license header). +# To Call: +# copy_changed_files $generated_code_directory $existing_source_directory +copy_changed_files() { + + # Read all the function arguments + GENERATED_CODE_DIR=$1 + WORKSPACE_SRC_DIR=$2 + + echo "Generated sources are in ${GENERATED_CODE_DIR}" + echo "Destination workspace is in ${WORKSPACE_SRC_DIR}" + + # Check if the newly generated files exist in the targeted workspace, if not copy. Only changed files will be synced. + # the extra slash to GENERATED_CODE_DIR is needed to ensure the parent directory itself is not copied. + rsync -auv ${GENERATED_CODE_DIR}/ ${WORKSPACE_SRC_DIR} +} + +####################################### +# Generate/Update Java Stubs # +####################################### + +generate_java_stubs() { + + #Java Beans generation directory + #JAVA_BEAN_GEN_DIR=${BASE_TARGET_DIR}/gen-javabean + + # As a precaution remove and previously generated files if exists + #rm -rf ${JAVA_BEAN_GEN_DIR} + + # Generate the Airavata Data Model using thrift Java Beans generator. This will take generate the classes in bean style + # with members being private and setters returning voids. + # The airavataDataModel.thrift includes rest of data models. + #thrift ${THRIFT_ARGS} --gen java:beans ${THRIFT_IDL_DIR}/airavataDataModel.thrift || fail unable to generate java bean thrift classes on base data model + + #thrift ${THRIFT_ARGS} --gen java:beans ${THRIFT_IDL_DIR}/appCatalogModels.thrift || fail unable to generate java bean thrift classes on app catalog data models + + #thrift ${THRIFT_ARGS} --gen java:beans ${THRIFT_IDL_DIR}/workflowDataModel.thrift || fail unable to generate java bean thrift classes on app workflow data models + + # For the generated java beans add the ASF V2 License header + #add_license_header $JAVA_BEAN_GEN_DIR + + # Compare the newly generated beans with existing sources and replace the changed ones. + #copy_changed_files ${JAVA_BEAN_GEN_DIR} ${DATAMODEL_SRC_DIR} + + ############################################################################### + # Generate/Update source used by Airavata Server Skeletons & Java Client Stubs # + # JAVA server and client both use generated api-boilerplate-code # + ############################################################################### + + #Java generation directory + JAVA_GEN_DIR=${BASE_TARGET_DIR}/gen-java + + # As a precaution remove and previously generated files if exists + rm -rf ${JAVA_GEN_DIR} + + # Using thrift Java generator, generate the java classes based on Airavata API. This + # The airavataAPI.thrift includes rest of data models. + thrift ${THRIFT_ARGS} --gen java mock-credential-management-api.thrift || fail unable to generate java thrift classes on AiravataAPI + + #thrift ${THRIFT_ARGS} --gen java ${THRIFT_IDL_DIR}/workflowAPI.thrift || fail unable to generate java thrift classes on WorkflowAPI + + # For the generated java classes add the ASF V2 License header + add_license_header $JAVA_GEN_DIR + + # Compare the newly generated classes with existing java generated skeleton/stub sources and replace the changed ones. + # Only copying the API related classes and avoiding copy of any data models which already exist in the data-models. + copy_changed_files ${JAVA_GEN_DIR}/org/apache/airavata/api ${JAVA_API_SDK_DIR}/org/apache/airavata/api + + echo "Successfully generated new sources, compared against exiting code and replaced the changed files" +} + +#################################### +# Generate/Update C++ Client Stubs # +#################################### + +generate_cpp_stubs() { + + #CPP generation directory + CPP_GEN_DIR=${BASE_TARGET_DIR}/gen-cpp + + # As a precaution remove and previously generated files if exists + rm -rf ${CPP_GEN_DIR} + + # Using thrift Java generator, generate the java classes based on Airavata API. This + # The airavataAPI.thrift includes rest of data models. + #thrift ${THRIFT_ARGS} --gen cpp ${THRIFT_IDL_DIR}/airavataAPI.thrift || fail unable to generate C++ thrift classes + + #thrift ${THRIFT_ARGS} --gen cpp ${THRIFT_IDL_DIR}/workflowAPI.thrift || fail unable to generate C++ thrift classes for WorkflowAPI + # For the generated CPP classes add the ASF V2 License header + add_license_header $CPP_GEN_DIR + + # Compare the newly generated classes with existing java generated skeleton/stub sources and replace the changed ones. + # Only copying the API related classes and avoiding copy of any data models which already exist in the data-models. + copy_changed_files ${CPP_GEN_DIR} ${CPP_SDK_DIR} + +} + +#################################### +# Generate/Update PHP Stubs # +#################################### + +generate_cpp_stubs() { + + #PHP generation directory + PHP_GEN_DIR=${BASE_TARGET_DIR}/gen-php + + # As a precaution remove and previously generated files if exists + rm -rf ${PHP_GEN_DIR} + + # Using thrift Java generator, generate the java classes based on Airavata API. This + # The airavataAPI.thrift includes rest of data models. + #thrift ${THRIFT_ARGS} --gen php:autoload ${THRIFT_IDL_DIR}/airavataAPI.thrift || fail unable to generate PHP thrift classes + + #thrift ${THRIFT_ARGS} --gen php:autoload ${THRIFT_IDL_DIR}/workflowAPI.thrift || fail unable to generate PHP thrift classes for WorkflowAPI + # For the generated java classes add the ASF V2 License header + ## TODO Write PHP license parser + + # Compare the newly generated classes with existing java generated skeleton/stub sources and replace the changed ones. + # Only copying the API related classes and avoiding copy of any data models which already exist in the data-models. + copy_changed_files ${PHP_GEN_DIR} ${PHP_SDK_DIR} + + #################### + # Cleanup and Exit # + #################### + # CleanUp: Delete the base target build directory + #rm -rf ${BASE_TARGET_DIR} + +} + +for arg in "$@" +do + case "$arg" in + all) echo "Generate all stubs (Java, PHP, C++, Python) Stubs" + ;; + java) echo "Generating Java Stubs" + generate_java_stubs + ;; + php) echo "Generate PHP Stubs" + ;; + cpp) echo "Generate C++ Stubs" + ;; + python) echo "Generate Python Stubs" + ;; + *) echo "Invalid or unsupported option" + show_usage + exit 1 + ;; + esac +done + +exit 0 http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/62ad0a53/airavata-mock-multiplexed-api/mock-api-interface-descriptions/mock-appcatalog-api.thrift ---------------------------------------------------------------------- diff --git a/airavata-mock-multiplexed-api/mock-api-interface-descriptions/mock-appcatalog-api.thrift b/airavata-mock-multiplexed-api/mock-api-interface-descriptions/mock-appcatalog-api.thrift new file mode 100644 index 0000000..ce60864 --- /dev/null +++ b/airavata-mock-multiplexed-api/mock-api-interface-descriptions/mock-appcatalog-api.thrift @@ -0,0 +1,23 @@ +/* + * 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. + * +*/ + +/** + * Mock Application Catalog API +*/ http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/62ad0a53/airavata-mock-multiplexed-api/mock-api-interface-descriptions/mock-application-execution-api.thrift ---------------------------------------------------------------------- diff --git a/airavata-mock-multiplexed-api/mock-api-interface-descriptions/mock-application-execution-api.thrift b/airavata-mock-multiplexed-api/mock-api-interface-descriptions/mock-application-execution-api.thrift new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/62ad0a53/airavata-mock-multiplexed-api/mock-api-interface-descriptions/mock-credential-management-api.thrift ---------------------------------------------------------------------- diff --git a/airavata-mock-multiplexed-api/mock-api-interface-descriptions/mock-credential-management-api.thrift b/airavata-mock-multiplexed-api/mock-api-interface-descriptions/mock-credential-management-api.thrift new file mode 100644 index 0000000..a5f6b84 --- /dev/null +++ b/airavata-mock-multiplexed-api/mock-api-interface-descriptions/mock-credential-management-api.thrift @@ -0,0 +1,56 @@ +/* + * 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. + * +*/ + +/** + * Mock Credential Store API +*/ + +namespace java org.apache.airavata.api.credentials +namespace php Airavata.API.Credentials +namespace cpp apache.airavata.api.credentials +namespace perl ApacheAiravataAPICredentials +namespace py apache.airavata.api.credentials +namespace js ApacheAiravataAPICredentials + +service CredentialManagementService { + + /** + * Generate and Register SSH Key Pair with Airavata Credential Store. + * + * @param gatewayId + * The identifier for the requested gateway. + * + * @param userName + * The User for which the credential should be registered. For community accounts, this user is the name of the + * community user name. For computational resources, this user name need not be the same user name on resoruces. + * + * @return airavataCredStoreToken + * An SSH Key pair is generated and stored in the credential store and associated with users or community account + * belonging to a gateway. + * + **/ + + string generateAndRegisterSSHKeys (1: required string gatewayId, 2: required string userName) + + string getSSHPubKey (1: required string airavataCredStoreToken) + + map<string, string> getAllUserSSHPubKeys (1: required string userName) + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/62ad0a53/airavata-mock-multiplexed-api/mock-api-interface-descriptions/mock-data-manegement-api.thrift ---------------------------------------------------------------------- diff --git a/airavata-mock-multiplexed-api/mock-api-interface-descriptions/mock-data-manegement-api.thrift b/airavata-mock-multiplexed-api/mock-api-interface-descriptions/mock-data-manegement-api.thrift new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/62ad0a53/airavata-mock-multiplexed-api/mock-api-interface-descriptions/mock-gateway-management-api.thrift ---------------------------------------------------------------------- diff --git a/airavata-mock-multiplexed-api/mock-api-interface-descriptions/mock-gateway-management-api.thrift b/airavata-mock-multiplexed-api/mock-api-interface-descriptions/mock-gateway-management-api.thrift new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/62ad0a53/airavata-mock-multiplexed-api/mock-api-interface-descriptions/mock-workflow-execution-api.thrift ---------------------------------------------------------------------- diff --git a/airavata-mock-multiplexed-api/mock-api-interface-descriptions/mock-workflow-execution-api.thrift b/airavata-mock-multiplexed-api/mock-api-interface-descriptions/mock-workflow-execution-api.thrift new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/62ad0a53/airavata-mock-multiplexed-api/pom.xml ---------------------------------------------------------------------- diff --git a/airavata-mock-multiplexed-api/pom.xml b/airavata-mock-multiplexed-api/pom.xml new file mode 100644 index 0000000..ee314bd --- /dev/null +++ b/airavata-mock-multiplexed-api/pom.xml @@ -0,0 +1,164 @@ +<?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/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <prerequisites> + <maven>3.0</maven> + </prerequisites> + + <parent> + <groupId>org.apache</groupId> + <artifactId>apache</artifactId> + <version>14</version> + </parent> + + <groupId>org.apache.airavata</groupId> + <artifactId>airavata-mock-api</artifactId> + <packaging>pom</packaging> + <name>Airavata Mock API</name> + <version>0.15-SNAPSHOT</version> + + <url>http://airavata.apache.org/</url> + <inceptionYear>2011</inceptionYear> + + <scm> + <connection>scm:git:https://git-wip-us.apache.org/repos/asf/airavata-sandbox.git</connection> + <developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/airavata-sandbox.git</developerConnection> + <url> https://git-wip-us.apache.org/repos/asf?p=airavata-sandbox.git</url> + <tag>HEAD</tag> + </scm> + + <mailingLists> + + <mailingList> + <name>Airavata Developer List</name> + <subscribe>[email protected]</subscribe> + <unsubscribe>[email protected]</unsubscribe> + <post>mailto:[email protected]</post> + <archive>http://mail-archives.apache.org/mod_mbox/airavata-dev/</archive> + </mailingList> + + <mailingList> + <name>Airavata Users List</name> + <subscribe>[email protected]</subscribe> + <unsubscribe>[email protected]</unsubscribe> + <post>mailto:[email protected]</post> + <archive>http://mail-archives.apache.org/mod_mbox/airavata-users/</archive> + </mailingList> + + </mailingLists> + + <issueManagement> + <url>https://issues.apache.org/jira/browse/AIRAVATA</url> + </issueManagement> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + <org.slf4j.version>1.7.6</org.slf4j.version> + <log4j.version>1.2.16</log4j.version> + <surefire.version>2.12</surefire.version> + <junit.version>4.7</junit.version> + <thrift.version>0.9.2</thrift.version> + </properties> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>${org.slf4j.version}</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + <version>${org.slf4j.version}</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jcl-over-slf4j</artifactId> + <version>${org.slf4j.version}</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>${org.slf4j.version}</version> + </dependency> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <version>${log4j.version}</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>${junit.version}</version> + </dependency> + </dependencies> + </dependencyManagement> + + <repositories> + <repository> + <id>apache.snapshots</id> + <name>Apache Snapshot Repository</name> + <url>http://repository.apache.org/snapshots</url> + <releases> + <enabled>false</enabled> + </releases> + </repository> + <repository> + <id>central</id> + <name>Maven Central</name> + <url>http://repo1.maven.org/maven2</url> + <releases> + <enabled>true</enabled> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> + </repositories> + + <profiles> + <profile> + <id>default</id> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.1</version> + <configuration> + <source>1.6</source> + <target>1.6</target> + </configuration> + </plugin> + </plugins> + </build> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + <modules> + <module>mock-airavata-api-java-stubs</module> + <module>mock-airavata-api-server</module> + </modules> + </profile> + + + </profiles> + + +</project>
