airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sma...@apache.org
Subject [3/3] git commit: Registry thrift CPI Service - AIRAVATA-1006
Date Fri, 21 Feb 2014 13:55:36 GMT
Registry thrift CPI Service - AIRAVATA-1006


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/757fbb64
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/757fbb64
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/757fbb64

Branch: refs/heads/master
Commit: 757fbb64aca7af1b4465807bac32485bb94403a0
Parents: 3628126
Author: Suresh Marru <smarru@apache.org>
Authored: Fri Feb 21 08:55:25 2014 -0500
Committer: Suresh Marru <smarru@apache.org>
Committed: Fri Feb 21 08:55:25 2014 -0500

----------------------------------------------------------------------
 .../generate-cpi-stubs.sh                       |  133 +
 .../cpi-thrift-descriptions/registryCPI.thrift  |   94 +
 .../airavata/registry/cpi/ChildDataType.java    |  106 +
 .../apache/airavata/registry/cpi/DataType.java  |  121 +
 .../airavata/registry/cpi/ParentDataType.java   |   70 +
 .../registry/cpi/RegistryCPIService.java        | 2797 ++++++++++++++++++
 .../registry/cpi/registryCPIConstants.java      |   55 +
 7 files changed, 3376 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/757fbb64/component-services/cpi-thrift-descriptions/generate-cpi-stubs.sh
----------------------------------------------------------------------
diff --git a/component-services/cpi-thrift-descriptions/generate-cpi-stubs.sh b/component-services/cpi-thrift-descriptions/generate-cpi-stubs.sh
new file mode 100755
index 0000000..da15244
--- /dev/null
+++ b/component-services/cpi-thrift-descriptions/generate-cpi-stubs.sh
@@ -0,0 +1,133 @@
+#! /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 Skeltons, Client Stubs
and Data Model java beans.
+#
+# Credit: This script was created referring to Apache Accumulo project and tuned to Airavata
Needs.
+
+# Global Constants used across the script
+REQUIRED_THRIFT_VERSION='0.9.1'
+BASE_TARGET_DIR='target'
+REGISTRY_CPI_DIR='../registry-cpi-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 registry 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 registryCPI.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} ${REGISTRY_CPI_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
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/757fbb64/component-services/cpi-thrift-descriptions/registryCPI.thrift
----------------------------------------------------------------------
diff --git a/component-services/cpi-thrift-descriptions/registryCPI.thrift b/component-services/cpi-thrift-descriptions/registryCPI.thrift
new file mode 100644
index 0000000..89060b4
--- /dev/null
+++ b/component-services/cpi-thrift-descriptions/registryCPI.thrift
@@ -0,0 +1,94 @@
+/*
+ * 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 Registry Service.
+ *
+*/
+
+
+namespace java org.apache.airavata.registry.cpi
+
+const string REGISTRY_CPI_VERSION = "0.12.0"
+
+enum ParentDataType {
+    APPLiCATION_CATALOG,
+    GROUP,
+    USER,
+    PROJECT,
+    EXPERIMENT
+}
+
+enum ChildDataType {
+    EXPERIMENT_INPUT,
+    EXPERIMENT_OUTPUT,
+    WORKFLOW_NODE_DETAIL,
+    TASK_DETAIL,
+    ERROR_DETAIL,
+    APPLICATION_INPUT,
+    APPLICATION_OUTPUT,
+    NODE_INPUT,
+    NODE_OUTPUT,
+    JOB_DETAIL,
+    DATA_TRANSFER_DETAIL,
+    STATUS,
+    EXPERIMENT_CONFIGURATION_DATA,
+    COMPUTATIONAL_RESOURCE_SCHEDULING,
+    ADVANCE_INPUT_DATA_HANDLING,
+    ADVANCE_OUTPUT_DATA_HANDLING,
+    QOS_PARAM
+}
+
+enum DataType {
+    APPLiCATION_CATALOG,
+    GROUP,
+    USER,
+    PROJECT,
+    EXPERIMENT,
+    EXPERIMENT_INPUT,
+    EXPERIMENT_OUTPUT,
+    WORKFLOW_NODE_DETAIL,
+    TASK_DETAIL,
+    ERROR_DETAIL,
+    APPLICATION_INPUT,
+    APPLICATION_OUTPUT,
+    NODE_INPUT,
+    NODE_OUTPUT,
+    JOB_DETAIL,
+    DATA_TRANSFER_DETAIL,
+    STATUS,
+    EXPERIMENT_CONFIGURATION_DATA,
+    COMPUTATIONAL_RESOURCE_SCHEDULING,
+    ADVANCE_INPUT_DATA_HANDLING,
+    ADVANCE_OUTPUT_DATA_HANDLING,
+    QOS_PARAM
+}
+
+service RegistryCPIService {
+
+  /** Query registry server to fetch the CPI version */
+  string getRegistryCPIVersion(),
+
+  string createParentObject (1: ParentDataType parentDataType
+                             2: binary objectToCreate)
+
+  bool isExists (1: DataType dataType
+                 2: string objectId)
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/757fbb64/component-services/registry-cpi-service/src/main/java/org/apache/airavata/registry/cpi/ChildDataType.java
----------------------------------------------------------------------
diff --git a/component-services/registry-cpi-service/src/main/java/org/apache/airavata/registry/cpi/ChildDataType.java
b/component-services/registry-cpi-service/src/main/java/org/apache/airavata/registry/cpi/ChildDataType.java
new file mode 100644
index 0000000..f6fe86f
--- /dev/null
+++ b/component-services/registry-cpi-service/src/main/java/org/apache/airavata/registry/cpi/ChildDataType.java
@@ -0,0 +1,106 @@
+    /*
+     * 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.registry.cpi;
+
+
+import java.util.Map;
+import java.util.HashMap;
+import org.apache.thrift.TEnum;
+
+@SuppressWarnings("all") public enum ChildDataType implements org.apache.thrift.TEnum {
+  EXPERIMENT_INPUT(0),
+  EXPERIMENT_OUTPUT(1),
+  WORKFLOW_NODE_DETAIL(2),
+  TASK_DETAIL(3),
+  ERROR_DETAIL(4),
+  APPLICATION_INPUT(5),
+  APPLICATION_OUTPUT(6),
+  NODE_INPUT(7),
+  NODE_OUTPUT(8),
+  JOB_DETAIL(9),
+  DATA_TRANSFER_DETAIL(10),
+  STATUS(11),
+  EXPERIMENT_CONFIGURATION_DATA(12),
+  COMPUTATIONAL_RESOURCE_SCHEDULING(13),
+  ADVANCE_INPUT_DATA_HANDLING(14),
+  ADVANCE_OUTPUT_DATA_HANDLING(15),
+  QOS_PARAM(16);
+
+  private final int value;
+
+  private ChildDataType(int value) {
+    this.value = value;
+  }
+
+  /**
+   * Get the integer value of this enum value, as defined in the Thrift IDL.
+   */
+  public int getValue() {
+    return value;
+  }
+
+  /**
+   * Find a the enum type by its integer value, as defined in the Thrift IDL.
+   * @return null if the value is not found.
+   */
+  public static ChildDataType findByValue(int value) { 
+    switch (value) {
+      case 0:
+        return EXPERIMENT_INPUT;
+      case 1:
+        return EXPERIMENT_OUTPUT;
+      case 2:
+        return WORKFLOW_NODE_DETAIL;
+      case 3:
+        return TASK_DETAIL;
+      case 4:
+        return ERROR_DETAIL;
+      case 5:
+        return APPLICATION_INPUT;
+      case 6:
+        return APPLICATION_OUTPUT;
+      case 7:
+        return NODE_INPUT;
+      case 8:
+        return NODE_OUTPUT;
+      case 9:
+        return JOB_DETAIL;
+      case 10:
+        return DATA_TRANSFER_DETAIL;
+      case 11:
+        return STATUS;
+      case 12:
+        return EXPERIMENT_CONFIGURATION_DATA;
+      case 13:
+        return COMPUTATIONAL_RESOURCE_SCHEDULING;
+      case 14:
+        return ADVANCE_INPUT_DATA_HANDLING;
+      case 15:
+        return ADVANCE_OUTPUT_DATA_HANDLING;
+      case 16:
+        return QOS_PARAM;
+      default:
+        return null;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/757fbb64/component-services/registry-cpi-service/src/main/java/org/apache/airavata/registry/cpi/DataType.java
----------------------------------------------------------------------
diff --git a/component-services/registry-cpi-service/src/main/java/org/apache/airavata/registry/cpi/DataType.java
b/component-services/registry-cpi-service/src/main/java/org/apache/airavata/registry/cpi/DataType.java
new file mode 100644
index 0000000..7c14e6b
--- /dev/null
+++ b/component-services/registry-cpi-service/src/main/java/org/apache/airavata/registry/cpi/DataType.java
@@ -0,0 +1,121 @@
+    /*
+     * 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.registry.cpi;
+
+
+import java.util.Map;
+import java.util.HashMap;
+import org.apache.thrift.TEnum;
+
+@SuppressWarnings("all") public enum DataType implements org.apache.thrift.TEnum {
+  APPLiCATION_CATALOG(0),
+  GROUP(1),
+  USER(2),
+  PROJECT(3),
+  EXPERIMENT(4),
+  EXPERIMENT_INPUT(5),
+  EXPERIMENT_OUTPUT(6),
+  WORKFLOW_NODE_DETAIL(7),
+  TASK_DETAIL(8),
+  ERROR_DETAIL(9),
+  APPLICATION_INPUT(10),
+  APPLICATION_OUTPUT(11),
+  NODE_INPUT(12),
+  NODE_OUTPUT(13),
+  JOB_DETAIL(14),
+  DATA_TRANSFER_DETAIL(15),
+  STATUS(16),
+  EXPERIMENT_CONFIGURATION_DATA(17),
+  COMPUTATIONAL_RESOURCE_SCHEDULING(18),
+  ADVANCE_INPUT_DATA_HANDLING(19),
+  ADVANCE_OUTPUT_DATA_HANDLING(20),
+  QOS_PARAM(21);
+
+  private final int value;
+
+  private DataType(int value) {
+    this.value = value;
+  }
+
+  /**
+   * Get the integer value of this enum value, as defined in the Thrift IDL.
+   */
+  public int getValue() {
+    return value;
+  }
+
+  /**
+   * Find a the enum type by its integer value, as defined in the Thrift IDL.
+   * @return null if the value is not found.
+   */
+  public static DataType findByValue(int value) { 
+    switch (value) {
+      case 0:
+        return APPLiCATION_CATALOG;
+      case 1:
+        return GROUP;
+      case 2:
+        return USER;
+      case 3:
+        return PROJECT;
+      case 4:
+        return EXPERIMENT;
+      case 5:
+        return EXPERIMENT_INPUT;
+      case 6:
+        return EXPERIMENT_OUTPUT;
+      case 7:
+        return WORKFLOW_NODE_DETAIL;
+      case 8:
+        return TASK_DETAIL;
+      case 9:
+        return ERROR_DETAIL;
+      case 10:
+        return APPLICATION_INPUT;
+      case 11:
+        return APPLICATION_OUTPUT;
+      case 12:
+        return NODE_INPUT;
+      case 13:
+        return NODE_OUTPUT;
+      case 14:
+        return JOB_DETAIL;
+      case 15:
+        return DATA_TRANSFER_DETAIL;
+      case 16:
+        return STATUS;
+      case 17:
+        return EXPERIMENT_CONFIGURATION_DATA;
+      case 18:
+        return COMPUTATIONAL_RESOURCE_SCHEDULING;
+      case 19:
+        return ADVANCE_INPUT_DATA_HANDLING;
+      case 20:
+        return ADVANCE_OUTPUT_DATA_HANDLING;
+      case 21:
+        return QOS_PARAM;
+      default:
+        return null;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/757fbb64/component-services/registry-cpi-service/src/main/java/org/apache/airavata/registry/cpi/ParentDataType.java
----------------------------------------------------------------------
diff --git a/component-services/registry-cpi-service/src/main/java/org/apache/airavata/registry/cpi/ParentDataType.java
b/component-services/registry-cpi-service/src/main/java/org/apache/airavata/registry/cpi/ParentDataType.java
new file mode 100644
index 0000000..a7074a5
--- /dev/null
+++ b/component-services/registry-cpi-service/src/main/java/org/apache/airavata/registry/cpi/ParentDataType.java
@@ -0,0 +1,70 @@
+    /*
+     * 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.registry.cpi;
+
+
+import java.util.Map;
+import java.util.HashMap;
+import org.apache.thrift.TEnum;
+
+@SuppressWarnings("all") public enum ParentDataType implements org.apache.thrift.TEnum {
+  APPLiCATION_CATALOG(0),
+  GROUP(1),
+  USER(2),
+  PROJECT(3),
+  EXPERIMENT(4);
+
+  private final int value;
+
+  private ParentDataType(int value) {
+    this.value = value;
+  }
+
+  /**
+   * Get the integer value of this enum value, as defined in the Thrift IDL.
+   */
+  public int getValue() {
+    return value;
+  }
+
+  /**
+   * Find a the enum type by its integer value, as defined in the Thrift IDL.
+   * @return null if the value is not found.
+   */
+  public static ParentDataType findByValue(int value) { 
+    switch (value) {
+      case 0:
+        return APPLiCATION_CATALOG;
+      case 1:
+        return GROUP;
+      case 2:
+        return USER;
+      case 3:
+        return PROJECT;
+      case 4:
+        return EXPERIMENT;
+      default:
+        return null;
+    }
+  }
+}


Mime
View raw message