airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sma...@apache.org
Subject [1/4] airavata-sandbox git commit: adding PHP client for multiplexing AIRAVATA-1632
Date Wed, 18 Mar 2015 18:07:32 GMT
Repository: airavata-sandbox
Updated Branches:
  refs/heads/master e33bf99b0 -> 165a5113d


http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/165a5113/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Transport/TTransport.php
----------------------------------------------------------------------
diff --git a/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Transport/TTransport.php
b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Transport/TTransport.php
new file mode 100755
index 0000000..99c39ff
--- /dev/null
+++ b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Transport/TTransport.php
@@ -0,0 +1,95 @@
+<?php
+/*
+ * 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 thrift.transport
+ */
+
+namespace Thrift\Transport;
+
+use Thrift\Factory\TStringFuncFactory;
+
+/**
+ * Base interface for a transport agent.
+ *
+ * @package thrift.transport
+ */
+abstract class TTransport
+{
+  /**
+   * Whether this transport is open.
+   *
+   * @return boolean true if open
+   */
+  abstract public function isOpen();
+
+  /**
+   * Open the transport for reading/writing
+   *
+   * @throws TTransportException if cannot open
+   */
+  abstract public function open();
+
+  /**
+   * Close the transport.
+   */
+  abstract public function close();
+
+  /**
+   * Read some data into the array.
+   *
+   * @param int    $len How much to read
+   * @return string The data that has been read
+   * @throws TTransportException if cannot read any more data
+   */
+  abstract public function read($len);
+
+  /**
+   * Guarantees that the full amount of data is read.
+   *
+   * @return string The data, of exact length
+   * @throws TTransportException if cannot read data
+   */
+  public function readAll($len)
+  {
+    // return $this->read($len);
+
+    $data = '';
+    $got = 0;
+    while (($got = TStringFuncFactory::create()->strlen($data)) < $len) {
+      $data .= $this->read($len - $got);
+    }
+
+    return $data;
+  }
+
+  /**
+   * Writes the given data out.
+   *
+   * @param string $buf  The data to write
+   * @throws TTransportException if writing fails
+   */
+  abstract public function write($buf);
+
+  /**
+   * Flushes any pending data out of a buffer
+   *
+   * @throws TTransportException if a writing error occurs
+   */
+  public function flush() {}
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/165a5113/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Type/TConstant.php
----------------------------------------------------------------------
diff --git a/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Type/TConstant.php
b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Type/TConstant.php
new file mode 100755
index 0000000..7c8eceb
--- /dev/null
+++ b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Type/TConstant.php
@@ -0,0 +1,50 @@
+<?php
+/*
+ * 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 thrift
+ */
+
+namespace Thrift\Type;
+
+/**
+ * Base class for constant Management
+ */
+abstract class TConstant
+{
+    /**
+     * Don't instanciate this class
+     */
+    protected function __construct() {}
+
+    /**
+     * Get a constant value
+     * @param  string $constant
+     * @return mixed
+     */
+    public static function get($constant)
+    {
+        if (is_null(static::$$constant)) {
+            static::$$constant = call_user_func(
+                    sprintf('static::init_%s', $constant)
+                );
+        }
+
+        return static::$$constant;
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/165a5113/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Type/TMessageType.php
----------------------------------------------------------------------
diff --git a/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Type/TMessageType.php
b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Type/TMessageType.php
new file mode 100755
index 0000000..bff224f
--- /dev/null
+++ b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Type/TMessageType.php
@@ -0,0 +1,34 @@
+<?php
+/*
+ * 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 thrift
+ */
+
+namespace Thrift\Type;
+
+/**
+ * Message types for RPC
+ */
+class TMessageType
+{
+  const CALL  = 1;
+  const REPLY = 2;
+  const EXCEPTION = 3;
+  const ONEWAY = 4;
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/165a5113/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Type/TType.php
----------------------------------------------------------------------
diff --git a/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Type/TType.php
b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Type/TType.php
new file mode 100755
index 0000000..71219c2
--- /dev/null
+++ b/airavata-mock-multiplexed-api/mock-airavata-api-php-stubs/src/main/resources/lib/Thrift/Type/TType.php
@@ -0,0 +1,47 @@
+<?php
+/*
+ * 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 thrift
+ */
+
+namespace Thrift\Type;
+
+/**
+ * Data types that can be sent via Thrift
+ */
+class TType
+{
+  const STOP   = 0;
+  const VOID   = 1;
+  const BOOL   = 2;
+  const BYTE   = 3;
+  const I08    = 3;
+  const DOUBLE = 4;
+  const I16    = 6;
+  const I32    = 8;
+  const I64    = 10;
+  const STRING = 11;
+  const UTF7   = 11;
+  const STRUCT = 12;
+  const MAP    = 13;
+  const SET    = 14;
+  const LST    = 15;    // N.B. cannot use LIST keyword in PHP!
+  const UTF8   = 16;
+  const UTF16  = 17;
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/165a5113/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
index 81f624d..c4323e2 100755
--- 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
@@ -57,8 +57,8 @@ fi
 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'
+PHP_SDK_DIR='../mock-airavata-api-php-stubs/src/main/resources/lib'
 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.
@@ -187,60 +187,58 @@ generate_java_stubs() {
 }
 
 ####################################
-# Generate/Update C++ Client Stubs #
+# Generate/Update PHP Stubs #
 ####################################
 
-generate_cpp_stubs() {
+generate_php_stubs() {
 
-    #CPP generation directory
-    CPP_GEN_DIR=${BASE_TARGET_DIR}/gen-cpp
+    #PHP generation directory
+    PHP_GEN_DIR=${BASE_TARGET_DIR}/gen-php
 
     # As a precaution  remove and previously generated files if exists
-    rm -rf ${CPP_GEN_DIR}
+    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 cpp ${THRIFT_IDL_DIR}/airavataAPI.thrift || fail unable
to generate C++ thrift classes
+    thrift ${THRIFT_ARGS} --gen php:autoload mock-credential-management-api.thrift || fail
unable to generate PHP thrift classes
+    thrift ${THRIFT_ARGS} --gen php:autoload mock-gateway-management-api.thrift || fail unable
to generate PHP 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
+    # 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 ${CPP_GEN_DIR} ${CPP_SDK_DIR}
+    copy_changed_files ${PHP_GEN_DIR} ${PHP_SDK_DIR}
+
+    ####################
+    # Cleanup and Exit #
+    ####################
+    # CleanUp: Delete the base target build directory
+    #rm -rf ${BASE_TARGET_DIR}
 
 }
 
 ####################################
-# Generate/Update PHP Stubs #
+# Generate/Update C++ Client Stubs #
 ####################################
 
 generate_cpp_stubs() {
 
-    #PHP generation directory
-    PHP_GEN_DIR=${BASE_TARGET_DIR}/gen-php
+    #CPP generation directory
+    CPP_GEN_DIR=${BASE_TARGET_DIR}/gen-cpp
 
     # As a precaution  remove and previously generated files if exists
-    rm -rf ${PHP_GEN_DIR}
+    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 php:autoload ${THRIFT_IDL_DIR}/airavataAPI.thrift || fail
unable to generate PHP thrift classes
+    #thrift ${THRIFT_ARGS} --gen cpp ${THRIFT_IDL_DIR}/airavataAPI.thrift || fail unable
to generate C++ 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
+    #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 ${PHP_GEN_DIR} ${PHP_SDK_DIR}
-
-    ####################
-    # Cleanup and Exit #
-    ####################
-    # CleanUp: Delete the base target build directory
-    #rm -rf ${BASE_TARGET_DIR}
+    copy_changed_files ${CPP_GEN_DIR} ${CPP_SDK_DIR}
 
 }
 
@@ -248,6 +246,8 @@ for arg in "$@"
 do
     case "$arg" in
     all)    echo "Generate all stubs (Java, PHP, C++, Python) Stubs"
+            generate_java_stubs
+            generate_php_stubs
             ;;
     java)   echo "Generating Java Stubs"
             generate_java_stubs

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/165a5113/airavata-mock-multiplexed-api/pom.xml
----------------------------------------------------------------------
diff --git a/airavata-mock-multiplexed-api/pom.xml b/airavata-mock-multiplexed-api/pom.xml
index b4e8a1b..cbe90bd 100644
--- a/airavata-mock-multiplexed-api/pom.xml
+++ b/airavata-mock-multiplexed-api/pom.xml
@@ -155,6 +155,7 @@
 				<module>mock-airavata-api-java-stubs</module>
 				<module>mock-airavata-api-server</module>
                 <module>mock-airavata-api-client</module>
+                <module>mock-airavata-api-php-stubs</module>
 			</modules>
 		</profile>
 


Mime
View raw message