airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sma...@apache.org
Subject [1/3] Initial version of the Orchestrator Thrift Service - AIRAVATA-1007
Date Tue, 25 Feb 2014 13:59:47 GMT
Repository: airavata
Updated Branches:
  refs/heads/master dd5dbbd76 -> 94aee747d


http://git-wip-us.apache.org/repos/asf/airavata/blob/94aee747/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/cpi/orchestrator_cpi_serviceConstants.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/cpi/orchestrator_cpi_serviceConstants.java
b/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/cpi/orchestrator_cpi_serviceConstants.java
new file mode 100644
index 0000000..9f62eeb
--- /dev/null
+++ b/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/cpi/orchestrator_cpi_serviceConstants.java
@@ -0,0 +1,55 @@
+    /*
+     * 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.12.0";
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/94aee747/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServer.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServer.java
b/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServer.java
new file mode 100644
index 0000000..c90a845
--- /dev/null
+++ b/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServer.java
@@ -0,0 +1,66 @@
+/*
+ *
+ * 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.server;
+
+import org.apache.airavata.orchestrator.cpi.OrchestratorService;
+import org.apache.thrift.server.TServer;
+import org.apache.thrift.server.TSimpleServer;
+import org.apache.thrift.transport.TServerSocket;
+import org.apache.thrift.transport.TServerTransport;
+import org.apache.thrift.transport.TTransportException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OrchestratorServer {
+
+    private final static Logger logger = LoggerFactory.getLogger(OrchestratorServer.class);
+
+    //FIXME: Read the port from airavata-server.config file
+    private static final int ORCHESTRATOT_SERVER_PORT = 8940;
+
+
+    public static void StartRegistryServer(OrchestratorService.Processor<OrchestratorServerHandler>
orchestratorServerHandlerProcessor)
+            throws Exception {
+        try {
+            TServerTransport serverTransport = new TServerSocket(ORCHESTRATOT_SERVER_PORT);
+            TServer server = new TSimpleServer(
+                    new TServer.Args(serverTransport).processor(orchestratorServerHandlerProcessor));
+            logger.info("Starting Orchestrator Server on Port " + ORCHESTRATOT_SERVER_PORT);
+            logger.info("Listening to Orchestrator Clients ....");
+            server.serve();
+        } catch (TTransportException e) {
+            logger.error(e.getMessage());
+        }
+    }
+
+    public static void main(String[] args) {
+        OrchestratorService.Processor<OrchestratorServerHandler> registryCPIServerHandlerProcessor
=
+                new OrchestratorService.Processor<OrchestratorServerHandler>(new OrchestratorServerHandler());
+        try {
+            StartRegistryServer(registryCPIServerHandlerProcessor);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/94aee747/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
b/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
new file mode 100644
index 0000000..9921047
--- /dev/null
+++ b/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
@@ -0,0 +1,59 @@
+/*
+ *
+ * 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.server;
+
+import org.apache.airavata.orchestrator.cpi.OrchestratorService;
+import org.apache.airavata.orchestrator.cpi.orchestrator_cpi_serviceConstants;
+import org.apache.thrift.TException;
+
+public class OrchestratorServerHandler implements OrchestratorService.Iface {
+
+    /**
+     * Query orchestrator server to fetch the CPI version
+     */
+    @Override
+    public String getOrchestratorCPIVersion() throws TException {
+        return orchestrator_cpi_serviceConstants.ORCHESTRATOR_CPI_VERSION;
+    }
+
+    /**
+     * * After creating the experiment Data user have the
+     * * experimentID as the handler to the experiment, during the launchExperiment
+     * * We just have to give the experimentID
+     * *
+     * * @param experimentID
+     * * @return sucess/failure
+     * *
+     * *
+     *
+     * @param experimentId
+     */
+    @Override
+    public boolean launchExperiment(String experimentId) throws TException {
+        return false;
+    }
+
+    @Override
+    public boolean terminateExperiment(String experimentId) throws TException {
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/94aee747/modules/orchestrator/orchestrator-thrift-descriptions/generate-orchestrator-stubs.sh
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-thrift-descriptions/generate-orchestrator-stubs.sh
b/modules/orchestrator/orchestrator-thrift-descriptions/generate-orchestrator-stubs.sh
new file mode 100755
index 0000000..5bb1ff9
--- /dev/null
+++ b/modules/orchestrator/orchestrator-thrift-descriptions/generate-orchestrator-stubs.sh
@@ -0,0 +1,132 @@
+#! /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 Orchestrator Server Skeltons and
Client Stubs.
+
+
+# Global Constants used across the script
+REQUIRED_THRIFT_VERSION='0.9.1'
+BASE_TARGET_DIR='target'
+ORCHESTRATOR_SERVICE_DIR='../airavata-orchestrator-service/src/main/java'
+
+# The Funcation fail prints error messages on failure and quits the script.
+fail() {
+    echo $@
+    exit 1
+}
+
+# The funcation add_license_header adds the ASF V2 license header to all java files within
the specified generated
+#   directory. The funcation 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 orginal 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 java file within the genrated directory, add the ASF V2 LICENSE header
+    for f in $(find ${GENERATED_CODE_DIR} -name '*.java'); 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
+}
+
+# The funcation compares every generated java file with the one in specified existing source
location. If the comparision
+#   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 funcation 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 targetted 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}
+}
+
+# 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.
+VERSION=$(thrift -version 2>/dev/null | grep -F "${REQUIRED_THRIFT_VERSION}" |  wc -l)
+if [ "$VERSION" -ne 1 ] ; then
+    echo "****************************************************"
+    echo "*** thrift is not installed or is not in the path"
+    echo "***   expecting 'thrift -version' to return ${REQUIRED_THRIFT_VERSION}"
+    echo "*** generated code will not be updated"
+    fail "****************************************************"
+fi
+
+# Initialize the thrift arguements.
+#  Since most of the Airavata API and Data Models have includes, use recursive option by
defualt.
+#  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}
+
+#######################################################################
+# Generate/Update the orchestrator CPI service stubs
+#  To start with both the servicer and client are in same package, but
+#  needs to be split using a common generated api-boilerplate-code
+#######################################################################
+
+#Java generation directory
+JAVA_GEN_DIR=${BASE_TARGET_DIR}/gen-java
+
+# As a precausion  remove and previously generated files if exists
+rm -rf ${JAVA_GEN_DIR}
+
+# Using thrify Java generator, generate the java classes based on Airavata API. This
+#   The airavataAPI.thrift includes rest of data models.
+thrift ${THRIFT_ARGS} --gen java orchestrator.cpi.service.thrift || fail unable to generate
java thrift classes
+
+# 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 skelton/stub sources and
replace the changed ones.
+copy_changed_files ${JAVA_GEN_DIR} ${ORCHESTRATOR_SERVICE_DIR}
+
+# CleanUp: Delete the base target build directory
+#rm -rf ${BASE_TARGET_DIR}
+
+echo "Successfully generated new sources, compared against exiting code and replaced the
changed files"
+exit 0

http://git-wip-us.apache.org/repos/asf/airavata/blob/94aee747/modules/orchestrator/orchestrator-thrift-descriptions/orchestrator.cpi.service.thrift
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-thrift-descriptions/orchestrator.cpi.service.thrift
b/modules/orchestrator/orchestrator-thrift-descriptions/orchestrator.cpi.service.thrift
new file mode 100644
index 0000000..c03e81f
--- /dev/null
+++ b/modules/orchestrator/orchestrator-thrift-descriptions/orchestrator.cpi.service.thrift
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ *
+ */
+
+/*
+ * Component Programming Interface definition for Apache Airavata Orchestration Service.
+ *
+*/
+
+namespace java org.apache.airavata.orchestrator.cpi
+
+const string ORCHESTRATOR_CPI_VERSION = "0.12.0"
+
+service OrchestratorService {
+
+  /** Query orchestrator server to fetch the CPI version */
+  string getOrchestratorCPIVersion(),
+
+    /**
+     * After creating the experiment Data user have the
+     * experimentID as the handler to the experiment, during the launchExperiment
+     * We just have to give the experimentID
+     *
+     * @param experimentID
+     * @return sucess/failure
+     *
+    **/
+  bool launchExperiment (1: required string experimentId),
+
+  bool terminateExperiment (1: required string experimentId)
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/94aee747/modules/orchestrator/pom.xml
----------------------------------------------------------------------
diff --git a/modules/orchestrator/pom.xml b/modules/orchestrator/pom.xml
index 3819627..6c45107 100644
--- a/modules/orchestrator/pom.xml
+++ b/modules/orchestrator/pom.xml
@@ -8,7 +8,8 @@
     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">
+<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">
 
     <parent>
         <groupId>org.apache.airavata</groupId>
@@ -22,7 +23,7 @@
     <packaging>pom</packaging>
     <name>Airavata Orchestrator</name>
     <url>http://airavata.apache.org/</url>
-    
+
     <profiles>
         <profile>
             <id>default</id>
@@ -31,11 +32,14 @@
             </activation>
             <modules>
                 <module>orchestrator-core</module>
+                <module>airavata-orchestrator-service</module>
             </modules>
         </profile>
     </profiles>
+
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
     </properties>
+
 </project>


Mime
View raw message