Repository: airavata-php-gateway Updated Branches: refs/heads/master b545744c8 -> e5e190efd
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e5e190ef/app/libraries/Airavata/Model/Data/Resource/Types.php ---------------------------------------------------------------------- diff --git a/app/libraries/Airavata/Model/Data/Resource/Types.php b/app/libraries/Airavata/Model/Data/Resource/Types.php index 84e6c9c..cd5542a 100644 --- a/app/libraries/Airavata/Model/Data/Resource/Types.php +++ b/app/libraries/Airavata/Model/Data/Resource/Types.php @@ -2,7 +2,7 @@ namespace Airavata\Model\Data\Resource; /** - * Autogenerated by Thrift Compiler (0.9.2) + * Autogenerated by Thrift Compiler (0.9.3) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -39,6 +39,15 @@ final class ReplicaPersistentType { ); } +final class DataResourceType { + const COLLECTION = 0; + const FILE = 1; + static public $__names = array( + 0 => 'COLLECTION', + 1 => 'FILE', + ); +} + class DataResourceModel { static $_TSPEC; @@ -53,6 +62,10 @@ class DataResourceModel { /** * @var string */ + public $parentResourceId = null; + /** + * @var string + */ public $resourceName = null; /** * @var string @@ -65,6 +78,10 @@ class DataResourceModel { /** * @var int */ + public $dataResourceType = null; + /** + * @var int + */ public $resourceSize = null; /** * @var int @@ -81,7 +98,11 @@ class DataResourceModel { /** * @var \Airavata\Model\Data\Resource\DataReplicaLocationModel[] */ - public $dataReplicaLocations = null; + public $replicaLocations = null; + /** + * @var \Airavata\Model\Data\Resource\DataResourceModel[] + */ + public $childResources = null; public function __construct($vals=null) { if (!isset(self::$_TSPEC)) { @@ -95,30 +116,38 @@ class DataResourceModel { 'type' => TType::STRING, ), 3 => array( - 'var' => 'resourceName', + 'var' => 'parentResourceId', 'type' => TType::STRING, ), 4 => array( - 'var' => 'resourceDescription', + 'var' => 'resourceName', 'type' => TType::STRING, ), 5 => array( - 'var' => 'ownerName', + 'var' => 'resourceDescription', 'type' => TType::STRING, ), 6 => array( + 'var' => 'ownerName', + 'type' => TType::STRING, + ), + 7 => array( + 'var' => 'dataResourceType', + 'type' => TType::I32, + ), + 8 => array( 'var' => 'resourceSize', 'type' => TType::I32, ), - 7 => array( + 9 => array( 'var' => 'creationTime', 'type' => TType::I64, ), - 8 => array( + 10 => array( 'var' => 'lastModifiedTime', 'type' => TType::I64, ), - 9 => array( + 11 => array( 'var' => 'resourceMetadata', 'type' => TType::MAP, 'ktype' => TType::STRING, @@ -130,8 +159,8 @@ class DataResourceModel { 'type' => TType::STRING, ), ), - 10 => array( - 'var' => 'dataReplicaLocations', + 12 => array( + 'var' => 'replicaLocations', 'type' => TType::LST, 'etype' => TType::STRUCT, 'elem' => array( @@ -139,6 +168,15 @@ class DataResourceModel { 'class' => '\Airavata\Model\Data\Resource\DataReplicaLocationModel', ), ), + 13 => array( + 'var' => 'childResources', + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\Airavata\Model\Data\Resource\DataResourceModel', + ), + ), ); } if (is_array($vals)) { @@ -148,6 +186,9 @@ class DataResourceModel { if (isset($vals['gatewayId'])) { $this->gatewayId = $vals['gatewayId']; } + if (isset($vals['parentResourceId'])) { + $this->parentResourceId = $vals['parentResourceId']; + } if (isset($vals['resourceName'])) { $this->resourceName = $vals['resourceName']; } @@ -157,6 +198,9 @@ class DataResourceModel { if (isset($vals['ownerName'])) { $this->ownerName = $vals['ownerName']; } + if (isset($vals['dataResourceType'])) { + $this->dataResourceType = $vals['dataResourceType']; + } if (isset($vals['resourceSize'])) { $this->resourceSize = $vals['resourceSize']; } @@ -169,8 +213,11 @@ class DataResourceModel { if (isset($vals['resourceMetadata'])) { $this->resourceMetadata = $vals['resourceMetadata']; } - if (isset($vals['dataReplicaLocations'])) { - $this->dataReplicaLocations = $vals['dataReplicaLocations']; + if (isset($vals['replicaLocations'])) { + $this->replicaLocations = $vals['replicaLocations']; + } + if (isset($vals['childResources'])) { + $this->childResources = $vals['childResources']; } } } @@ -210,47 +257,61 @@ class DataResourceModel { break; case 3: if ($ftype == TType::STRING) { - $xfer += $input->readString($this->resourceName); + $xfer += $input->readString($this->parentResourceId); } else { $xfer += $input->skip($ftype); } break; case 4: if ($ftype == TType::STRING) { - $xfer += $input->readString($this->resourceDescription); + $xfer += $input->readString($this->resourceName); } else { $xfer += $input->skip($ftype); } break; case 5: if ($ftype == TType::STRING) { - $xfer += $input->readString($this->ownerName); + $xfer += $input->readString($this->resourceDescription); } else { $xfer += $input->skip($ftype); } break; case 6: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->ownerName); + } else { + $xfer += $input->skip($ftype); + } + break; + case 7: + if ($ftype == TType::I32) { + $xfer += $input->readI32($this->dataResourceType); + } else { + $xfer += $input->skip($ftype); + } + break; + case 8: if ($ftype == TType::I32) { $xfer += $input->readI32($this->resourceSize); } else { $xfer += $input->skip($ftype); } break; - case 7: + case 9: if ($ftype == TType::I64) { $xfer += $input->readI64($this->creationTime); } else { $xfer += $input->skip($ftype); } break; - case 8: + case 10: if ($ftype == TType::I64) { $xfer += $input->readI64($this->lastModifiedTime); } else { $xfer += $input->skip($ftype); } break; - case 9: + case 11: if ($ftype == TType::MAP) { $this->resourceMetadata = array(); $_size0 = 0; @@ -270,9 +331,9 @@ class DataResourceModel { $xfer += $input->skip($ftype); } break; - case 10: + case 12: if ($ftype == TType::LST) { - $this->dataReplicaLocations = array(); + $this->replicaLocations = array(); $_size7 = 0; $_etype10 = 0; $xfer += $input->readListBegin($_etype10, $_size7); @@ -281,7 +342,25 @@ class DataResourceModel { $elem12 = null; $elem12 = new \Airavata\Model\Data\Resource\DataReplicaLocationModel(); $xfer += $elem12->read($input); - $this->dataReplicaLocations []= $elem12; + $this->replicaLocations []= $elem12; + } + $xfer += $input->readListEnd(); + } else { + $xfer += $input->skip($ftype); + } + break; + case 13: + if ($ftype == TType::LST) { + $this->childResources = array(); + $_size13 = 0; + $_etype16 = 0; + $xfer += $input->readListBegin($_etype16, $_size13); + for ($_i17 = 0; $_i17 < $_size13; ++$_i17) + { + $elem18 = null; + $elem18 = new \Airavata\Model\Data\Resource\DataResourceModel(); + $xfer += $elem18->read($input); + $this->childResources []= $elem18; } $xfer += $input->readListEnd(); } else { @@ -311,33 +390,43 @@ class DataResourceModel { $xfer += $output->writeString($this->gatewayId); $xfer += $output->writeFieldEnd(); } + if ($this->parentResourceId !== null) { + $xfer += $output->writeFieldBegin('parentResourceId', TType::STRING, 3); + $xfer += $output->writeString($this->parentResourceId); + $xfer += $output->writeFieldEnd(); + } if ($this->resourceName !== null) { - $xfer += $output->writeFieldBegin('resourceName', TType::STRING, 3); + $xfer += $output->writeFieldBegin('resourceName', TType::STRING, 4); $xfer += $output->writeString($this->resourceName); $xfer += $output->writeFieldEnd(); } if ($this->resourceDescription !== null) { - $xfer += $output->writeFieldBegin('resourceDescription', TType::STRING, 4); + $xfer += $output->writeFieldBegin('resourceDescription', TType::STRING, 5); $xfer += $output->writeString($this->resourceDescription); $xfer += $output->writeFieldEnd(); } if ($this->ownerName !== null) { - $xfer += $output->writeFieldBegin('ownerName', TType::STRING, 5); + $xfer += $output->writeFieldBegin('ownerName', TType::STRING, 6); $xfer += $output->writeString($this->ownerName); $xfer += $output->writeFieldEnd(); } + if ($this->dataResourceType !== null) { + $xfer += $output->writeFieldBegin('dataResourceType', TType::I32, 7); + $xfer += $output->writeI32($this->dataResourceType); + $xfer += $output->writeFieldEnd(); + } if ($this->resourceSize !== null) { - $xfer += $output->writeFieldBegin('resourceSize', TType::I32, 6); + $xfer += $output->writeFieldBegin('resourceSize', TType::I32, 8); $xfer += $output->writeI32($this->resourceSize); $xfer += $output->writeFieldEnd(); } if ($this->creationTime !== null) { - $xfer += $output->writeFieldBegin('creationTime', TType::I64, 7); + $xfer += $output->writeFieldBegin('creationTime', TType::I64, 9); $xfer += $output->writeI64($this->creationTime); $xfer += $output->writeFieldEnd(); } if ($this->lastModifiedTime !== null) { - $xfer += $output->writeFieldBegin('lastModifiedTime', TType::I64, 8); + $xfer += $output->writeFieldBegin('lastModifiedTime', TType::I64, 10); $xfer += $output->writeI64($this->lastModifiedTime); $xfer += $output->writeFieldEnd(); } @@ -345,31 +434,48 @@ class DataResourceModel { if (!is_array($this->resourceMetadata)) { throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); } - $xfer += $output->writeFieldBegin('resourceMetadata', TType::MAP, 9); + $xfer += $output->writeFieldBegin('resourceMetadata', TType::MAP, 11); { $output->writeMapBegin(TType::STRING, TType::STRING, count($this->resourceMetadata)); { - foreach ($this->resourceMetadata as $kiter13 => $viter14) + foreach ($this->resourceMetadata as $kiter19 => $viter20) { - $xfer += $output->writeString($kiter13); - $xfer += $output->writeString($viter14); + $xfer += $output->writeString($kiter19); + $xfer += $output->writeString($viter20); } } $output->writeMapEnd(); } $xfer += $output->writeFieldEnd(); } - if ($this->dataReplicaLocations !== null) { - if (!is_array($this->dataReplicaLocations)) { + if ($this->replicaLocations !== null) { + if (!is_array($this->replicaLocations)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('replicaLocations', TType::LST, 12); + { + $output->writeListBegin(TType::STRUCT, count($this->replicaLocations)); + { + foreach ($this->replicaLocations as $iter21) + { + $xfer += $iter21->write($output); + } + } + $output->writeListEnd(); + } + $xfer += $output->writeFieldEnd(); + } + if ($this->childResources !== null) { + if (!is_array($this->childResources)) { throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); } - $xfer += $output->writeFieldBegin('dataReplicaLocations', TType::LST, 10); + $xfer += $output->writeFieldBegin('childResources', TType::LST, 13); { - $output->writeListBegin(TType::STRUCT, count($this->dataReplicaLocations)); + $output->writeListBegin(TType::STRUCT, count($this->childResources)); { - foreach ($this->dataReplicaLocations as $iter15) + foreach ($this->childResources as $iter22) { - $xfer += $iter15->write($output); + $xfer += $iter22->write($output); } } $output->writeListEnd(); @@ -413,15 +519,23 @@ class DataReplicaLocationModel { /** * @var int */ + public $validUntilTime = null; + /** + * @var int + */ public $replicaLocationCategory = null; /** * @var int */ public $replicaPersistentType = null; /** - * @var string[] + * @var string + */ + public $storageResourceId = null; + /** + * @var string */ - public $dataLocations = null; + public $fileAbsolutePath = null; /** * @var array */ @@ -455,22 +569,26 @@ class DataReplicaLocationModel { 'type' => TType::I64, ), 7 => array( - 'var' => 'replicaLocationCategory', - 'type' => TType::I32, + 'var' => 'validUntilTime', + 'type' => TType::I64, ), 8 => array( - 'var' => 'replicaPersistentType', + 'var' => 'replicaLocationCategory', 'type' => TType::I32, ), 9 => array( - 'var' => 'dataLocations', - 'type' => TType::LST, - 'etype' => TType::STRING, - 'elem' => array( - 'type' => TType::STRING, - ), + 'var' => 'replicaPersistentType', + 'type' => TType::I32, ), 10 => array( + 'var' => 'storageResourceId', + 'type' => TType::STRING, + ), + 11 => array( + 'var' => 'fileAbsolutePath', + 'type' => TType::STRING, + ), + 12 => array( 'var' => 'replicaMetadata', 'type' => TType::MAP, 'ktype' => TType::STRING, @@ -503,14 +621,20 @@ class DataReplicaLocationModel { if (isset($vals['lastModifiedTime'])) { $this->lastModifiedTime = $vals['lastModifiedTime']; } + if (isset($vals['validUntilTime'])) { + $this->validUntilTime = $vals['validUntilTime']; + } if (isset($vals['replicaLocationCategory'])) { $this->replicaLocationCategory = $vals['replicaLocationCategory']; } if (isset($vals['replicaPersistentType'])) { $this->replicaPersistentType = $vals['replicaPersistentType']; } - if (isset($vals['dataLocations'])) { - $this->dataLocations = $vals['dataLocations']; + if (isset($vals['storageResourceId'])) { + $this->storageResourceId = $vals['storageResourceId']; + } + if (isset($vals['fileAbsolutePath'])) { + $this->fileAbsolutePath = $vals['fileAbsolutePath']; } if (isset($vals['replicaMetadata'])) { $this->replicaMetadata = $vals['replicaMetadata']; @@ -580,50 +704,54 @@ class DataReplicaLocationModel { } break; case 7: - if ($ftype == TType::I32) { - $xfer += $input->readI32($this->replicaLocationCategory); + if ($ftype == TType::I64) { + $xfer += $input->readI64($this->validUntilTime); } else { $xfer += $input->skip($ftype); } break; case 8: if ($ftype == TType::I32) { - $xfer += $input->readI32($this->replicaPersistentType); + $xfer += $input->readI32($this->replicaLocationCategory); } else { $xfer += $input->skip($ftype); } break; case 9: - if ($ftype == TType::LST) { - $this->dataLocations = array(); - $_size16 = 0; - $_etype19 = 0; - $xfer += $input->readListBegin($_etype19, $_size16); - for ($_i20 = 0; $_i20 < $_size16; ++$_i20) - { - $elem21 = null; - $xfer += $input->readString($elem21); - $this->dataLocations []= $elem21; - } - $xfer += $input->readListEnd(); + if ($ftype == TType::I32) { + $xfer += $input->readI32($this->replicaPersistentType); } else { $xfer += $input->skip($ftype); } break; case 10: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->storageResourceId); + } else { + $xfer += $input->skip($ftype); + } + break; + case 11: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->fileAbsolutePath); + } else { + $xfer += $input->skip($ftype); + } + break; + case 12: if ($ftype == TType::MAP) { $this->replicaMetadata = array(); - $_size22 = 0; - $_ktype23 = 0; - $_vtype24 = 0; - $xfer += $input->readMapBegin($_ktype23, $_vtype24, $_size22); - for ($_i26 = 0; $_i26 < $_size22; ++$_i26) + $_size23 = 0; + $_ktype24 = 0; + $_vtype25 = 0; + $xfer += $input->readMapBegin($_ktype24, $_vtype25, $_size23); + for ($_i27 = 0; $_i27 < $_size23; ++$_i27) { - $key27 = ''; - $val28 = ''; - $xfer += $input->readString($key27); - $xfer += $input->readString($val28); - $this->replicaMetadata[$key27] = $val28; + $key28 = ''; + $val29 = ''; + $xfer += $input->readString($key28); + $xfer += $input->readString($val29); + $this->replicaMetadata[$key28] = $val29; } $xfer += $input->readMapEnd(); } else { @@ -673,38 +801,36 @@ class DataReplicaLocationModel { $xfer += $output->writeI64($this->lastModifiedTime); $xfer += $output->writeFieldEnd(); } + if ($this->validUntilTime !== null) { + $xfer += $output->writeFieldBegin('validUntilTime', TType::I64, 7); + $xfer += $output->writeI64($this->validUntilTime); + $xfer += $output->writeFieldEnd(); + } if ($this->replicaLocationCategory !== null) { - $xfer += $output->writeFieldBegin('replicaLocationCategory', TType::I32, 7); + $xfer += $output->writeFieldBegin('replicaLocationCategory', TType::I32, 8); $xfer += $output->writeI32($this->replicaLocationCategory); $xfer += $output->writeFieldEnd(); } if ($this->replicaPersistentType !== null) { - $xfer += $output->writeFieldBegin('replicaPersistentType', TType::I32, 8); + $xfer += $output->writeFieldBegin('replicaPersistentType', TType::I32, 9); $xfer += $output->writeI32($this->replicaPersistentType); $xfer += $output->writeFieldEnd(); } - if ($this->dataLocations !== null) { - if (!is_array($this->dataLocations)) { - throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); - } - $xfer += $output->writeFieldBegin('dataLocations', TType::LST, 9); - { - $output->writeListBegin(TType::STRING, count($this->dataLocations)); - { - foreach ($this->dataLocations as $iter29) - { - $xfer += $output->writeString($iter29); - } - } - $output->writeListEnd(); - } + if ($this->storageResourceId !== null) { + $xfer += $output->writeFieldBegin('storageResourceId', TType::STRING, 10); + $xfer += $output->writeString($this->storageResourceId); + $xfer += $output->writeFieldEnd(); + } + if ($this->fileAbsolutePath !== null) { + $xfer += $output->writeFieldBegin('fileAbsolutePath', TType::STRING, 11); + $xfer += $output->writeString($this->fileAbsolutePath); $xfer += $output->writeFieldEnd(); } if ($this->replicaMetadata !== null) { if (!is_array($this->replicaMetadata)) { throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); } - $xfer += $output->writeFieldBegin('replicaMetadata', TType::MAP, 10); + $xfer += $output->writeFieldBegin('replicaMetadata', TType::MAP, 12); { $output->writeMapBegin(TType::STRING, TType::STRING, count($this->replicaMetadata)); { http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e5e190ef/app/libraries/Airavata/Model/Experiment/Types.php ---------------------------------------------------------------------- diff --git a/app/libraries/Airavata/Model/Experiment/Types.php b/app/libraries/Airavata/Model/Experiment/Types.php index 1f0e20e..fdca5bd 100644 --- a/app/libraries/Airavata/Model/Experiment/Types.php +++ b/app/libraries/Airavata/Model/Experiment/Types.php @@ -2,7 +2,7 @@ namespace Airavata\Model\Experiment; /** - * Autogenerated by Thrift Compiler (0.9.2) + * Autogenerated by Thrift Compiler (0.9.3) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e5e190ef/app/libraries/Airavata/Model/Job/Types.php ---------------------------------------------------------------------- diff --git a/app/libraries/Airavata/Model/Job/Types.php b/app/libraries/Airavata/Model/Job/Types.php index c7d3dd8..22453c1 100644 --- a/app/libraries/Airavata/Model/Job/Types.php +++ b/app/libraries/Airavata/Model/Job/Types.php @@ -2,7 +2,7 @@ namespace Airavata\Model\Job; /** - * Autogenerated by Thrift Compiler (0.9.2) + * Autogenerated by Thrift Compiler (0.9.3) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e5e190ef/app/libraries/Airavata/Model/Messaging/Event/Types.php ---------------------------------------------------------------------- diff --git a/app/libraries/Airavata/Model/Messaging/Event/Types.php b/app/libraries/Airavata/Model/Messaging/Event/Types.php index 6fa7020..9c6a1e8 100644 --- a/app/libraries/Airavata/Model/Messaging/Event/Types.php +++ b/app/libraries/Airavata/Model/Messaging/Event/Types.php @@ -2,7 +2,7 @@ namespace Airavata\Model\Messaging\Event; /** - * Autogenerated by Thrift Compiler (0.9.2) + * Autogenerated by Thrift Compiler (0.9.3) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e5e190ef/app/libraries/Airavata/Model/Process/Types.php ---------------------------------------------------------------------- diff --git a/app/libraries/Airavata/Model/Process/Types.php b/app/libraries/Airavata/Model/Process/Types.php index 2712080..120c078 100644 --- a/app/libraries/Airavata/Model/Process/Types.php +++ b/app/libraries/Airavata/Model/Process/Types.php @@ -2,7 +2,7 @@ namespace Airavata\Model\Process; /** - * Autogenerated by Thrift Compiler (0.9.2) + * Autogenerated by Thrift Compiler (0.9.3) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e5e190ef/app/libraries/Airavata/Model/Scheduling/Types.php ---------------------------------------------------------------------- diff --git a/app/libraries/Airavata/Model/Scheduling/Types.php b/app/libraries/Airavata/Model/Scheduling/Types.php index 966792d..44c1180 100644 --- a/app/libraries/Airavata/Model/Scheduling/Types.php +++ b/app/libraries/Airavata/Model/Scheduling/Types.php @@ -2,7 +2,7 @@ namespace Airavata\Model\Scheduling; /** - * Autogenerated by Thrift Compiler (0.9.2) + * Autogenerated by Thrift Compiler (0.9.3) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e5e190ef/app/libraries/Airavata/Model/Security/Types.php ---------------------------------------------------------------------- diff --git a/app/libraries/Airavata/Model/Security/Types.php b/app/libraries/Airavata/Model/Security/Types.php index 7904fef..f388971 100644 --- a/app/libraries/Airavata/Model/Security/Types.php +++ b/app/libraries/Airavata/Model/Security/Types.php @@ -2,7 +2,7 @@ namespace Airavata\Model\Security; /** - * Autogenerated by Thrift Compiler (0.9.2) + * Autogenerated by Thrift Compiler (0.9.3) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e5e190ef/app/libraries/Airavata/Model/Status/Types.php ---------------------------------------------------------------------- diff --git a/app/libraries/Airavata/Model/Status/Types.php b/app/libraries/Airavata/Model/Status/Types.php index 2a21e14..8457502 100644 --- a/app/libraries/Airavata/Model/Status/Types.php +++ b/app/libraries/Airavata/Model/Status/Types.php @@ -2,7 +2,7 @@ namespace Airavata\Model\Status; /** - * Autogenerated by Thrift Compiler (0.9.2) + * Autogenerated by Thrift Compiler (0.9.3) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e5e190ef/app/libraries/Airavata/Model/Task/Types.php ---------------------------------------------------------------------- diff --git a/app/libraries/Airavata/Model/Task/Types.php b/app/libraries/Airavata/Model/Task/Types.php index deae011..fcf5994 100644 --- a/app/libraries/Airavata/Model/Task/Types.php +++ b/app/libraries/Airavata/Model/Task/Types.php @@ -2,7 +2,7 @@ namespace Airavata\Model\Task; /** - * Autogenerated by Thrift Compiler (0.9.2) + * Autogenerated by Thrift Compiler (0.9.3) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e5e190ef/app/libraries/Airavata/Model/Types.php ---------------------------------------------------------------------- diff --git a/app/libraries/Airavata/Model/Types.php b/app/libraries/Airavata/Model/Types.php index 1304f75..fe337a7 100644 --- a/app/libraries/Airavata/Model/Types.php +++ b/app/libraries/Airavata/Model/Types.php @@ -2,7 +2,7 @@ namespace Airavata\Model; /** - * Autogenerated by Thrift Compiler (0.9.2) + * Autogenerated by Thrift Compiler (0.9.3) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e5e190ef/app/libraries/Airavata/Model/Workspace/Types.php ---------------------------------------------------------------------- diff --git a/app/libraries/Airavata/Model/Workspace/Types.php b/app/libraries/Airavata/Model/Workspace/Types.php index 4523e3d..6903330 100644 --- a/app/libraries/Airavata/Model/Workspace/Types.php +++ b/app/libraries/Airavata/Model/Workspace/Types.php @@ -2,7 +2,7 @@ namespace Airavata\Model\Workspace; /** - * Autogenerated by Thrift Compiler (0.9.2) + * Autogenerated by Thrift Compiler (0.9.3) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e5e190ef/app/libraries/Thrift/Exception/TProtocolException.php ---------------------------------------------------------------------- diff --git a/app/libraries/Thrift/Exception/TProtocolException.php b/app/libraries/Thrift/Exception/TProtocolException.php index f2529f5..98a8d9d 100644 --- a/app/libraries/Thrift/Exception/TProtocolException.php +++ b/app/libraries/Thrift/Exception/TProtocolException.php @@ -41,8 +41,6 @@ class TProtocolException extends TException { const NEGATIVE_SIZE = 2; const SIZE_LIMIT = 3; const BAD_VERSION = 4; - const NOT_IMPLEMENTED = 5; - const DEPTH_LIMIT = 6; function __construct($message=null, $code=0) { parent::__construct($message, $code); http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e5e190ef/app/libraries/Thrift/Protocol/TBinaryProtocolAccelerated.php ---------------------------------------------------------------------- diff --git a/app/libraries/Thrift/Protocol/TBinaryProtocolAccelerated.php b/app/libraries/Thrift/Protocol/TBinaryProtocolAccelerated.php index 7a40ce9..392aa21 100644 --- a/app/libraries/Thrift/Protocol/TBinaryProtocolAccelerated.php +++ b/app/libraries/Thrift/Protocol/TBinaryProtocolAccelerated.php @@ -33,21 +33,6 @@ class TBinaryProtocolAccelerated extends TBinaryProtocol { public function __construct($trans, $strictRead=false, $strictWrite=true) { // If the transport doesn't implement putBack, wrap it in a // TBufferedTransport (which does) - - // NOTE (t.heintz): This is very evil to do, because the TBufferedTransport may swallow bytes, which - // are then never written to the underlying transport. This happens precisely when a number of bytes - // less than the max buffer size (512 by default) is written to the transport and then flush() is NOT - // called. In that case the data stays in the writeBuffer of the transport, from where it can never be - // accessed again (for example through read()). - // - // Since the caller of this method does not know about the wrapping transport, this creates bugs which - // are very difficult to find. Hence the wrapping of a transport in a buffer should be left to the - // calling code. An interface could used to mandate the presence of the putBack() method in the transport. - // - // I am leaving this code in nonetheless, because there may be applications depending on this behavior. - // - // @see THRIFT-1579 - if (!method_exists($trans, 'putBack')) { $trans = new TBufferedTransport($trans); } @@ -59,4 +44,4 @@ class TBinaryProtocolAccelerated extends TBinaryProtocol { public function isStrictWrite() { return $this->strictWrite_; } -} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e5e190ef/app/libraries/Thrift/Protocol/TCompactProtocol.php ---------------------------------------------------------------------- diff --git a/app/libraries/Thrift/Protocol/TCompactProtocol.php b/app/libraries/Thrift/Protocol/TCompactProtocol.php index b8a71d6..e637a59 100644 --- a/app/libraries/Thrift/Protocol/TCompactProtocol.php +++ b/app/libraries/Thrift/Protocol/TCompactProtocol.php @@ -61,7 +61,6 @@ class TCompactProtocol extends TProtocol { const VERSION = 1; const PROTOCOL_ID = 0x82; const TYPE_MASK = 0xe0; - const TYPE_BITS = 0x07; const TYPE_SHIFT_AMOUNT = 5; protected static $ctypes = array( @@ -309,7 +308,7 @@ class TCompactProtocol extends TProtocol { public function writeDouble($value) { $data = pack('d', $value); - $this->trans_->write($data, 8); + $this->trans_->write(strrev($data), 8); return 8; } @@ -382,13 +381,14 @@ class TCompactProtocol extends TProtocol { } $verType = 0; $result += $this->readUByte($verType); - $type = ($verType >> TCompactProtocol::TYPE_SHIFT_AMOUNT) & TCompactProtocol::TYPE_BITS; + $type = ($verType & TCompactProtocol::TYPE_MASK) >> + TCompactProtocol::TYPE_SHIFT_AMOUNT; $version = $verType & TCompactProtocol::VERSION_MASK; if ($version != TCompactProtocol::VERSION) { throw new TProtocolException('Bad version in TCompact message'); } - $result += $this->readVarint($seqid); - $result += $this->readString($name); + $result += $this->readVarint($seqId); + $name += $this->readString($name); return $result; } @@ -485,7 +485,7 @@ class TCompactProtocol extends TProtocol { } public function readDouble(&$value) { - $data = $this->trans_->readAll(8); + $data = strrev($this->trans_->readAll(8)); $arr = unpack('d', $data); $value = $arr[1]; return 8; http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e5e190ef/app/libraries/Thrift/Protocol/TJSONProtocol.php ---------------------------------------------------------------------- diff --git a/app/libraries/Thrift/Protocol/TJSONProtocol.php b/app/libraries/Thrift/Protocol/TJSONProtocol.php index 402401a..3d39583 100644 --- a/app/libraries/Thrift/Protocol/TJSONProtocol.php +++ b/app/libraries/Thrift/Protocol/TJSONProtocol.php @@ -57,10 +57,10 @@ class TJSONProtocol extends TProtocol 1, 1, '"', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 2 ); - public static $ESCAPE_CHARS = array('"', '\\', '/', "b", "f", "n", "r", "t"); + public static $ESCAPE_CHARS = array('"', '\\', "b", "f", "n", "r", "t"); public static $ESCAPE_CHAR_VALS = array( - '"', '\\', '/', "\x08", "\f", "\n", "\r", "\t", + '"', '\\', "\x08", "\f", "\n", "\r", "\t", ); const NAME_BOOL = "tf"; http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e5e190ef/app/libraries/Thrift/Serializer/TBinarySerializer.php ---------------------------------------------------------------------- diff --git a/app/libraries/Thrift/Serializer/TBinarySerializer.php b/app/libraries/Thrift/Serializer/TBinarySerializer.php index 4e0af87..2a7cc3e 100644 --- a/app/libraries/Thrift/Serializer/TBinarySerializer.php +++ b/app/libraries/Thrift/Serializer/TBinarySerializer.php @@ -59,14 +59,8 @@ class TBinarySerializer { $transport = new TMemoryBuffer(); $protocol = new TBinaryProtocolAccelerated($transport); if (function_exists('thrift_protocol_read_binary')) { - // NOTE (t.heintz) TBinaryProtocolAccelerated internally wraps our TMemoryBuffer in a - // TBufferedTransport, so we have to retrieve it again or risk losing data when writing - // less than 512 bytes to the transport (see the comment there as well). - // @see THRIFT-1579 $protocol->writeMessageBegin('', TMessageType::REPLY, 0); - $protocolTransport = $protocol->getTransport(); - $protocolTransport->write($string_object); - $protocolTransport->flush(); + $transport->write($string_object); return thrift_protocol_read_binary($protocol, $class_name, $protocol->isStrictRead()); } else { http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e5e190ef/app/libraries/Thrift/Thrift.php ---------------------------------------------------------------------- diff --git a/app/libraries/Thrift/Thrift.php b/app/libraries/Thrift/Thrift.php new file mode 100644 index 0000000..c845395 --- /dev/null +++ b/app/libraries/Thrift/Thrift.php @@ -0,0 +1,789 @@ +<?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 + */ + + +/** + * 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; +} + +/** + * Message types for RPC + */ +class TMessageType { + const CALL = 1; + const REPLY = 2; + const EXCEPTION = 3; + const ONEWAY = 4; +} + +/** + * NOTE(mcslee): This currently contains a ton of duplicated code from TBase + * because we need to save CPU cycles and this is not yet in an extension. + * Ideally we'd multiply-inherit TException from both Exception and Base, but + * that's not possible in PHP and there are no modules either, so for now we + * apologetically take a trip to HackTown. + * + * Can be called with standard Exception constructor (message, code) or with + * Thrift Base object constructor (spec, vals). + * + * @param mixed $p1 Message (string) or type-spec (array) + * @param mixed $p2 Code (integer) or values (array) + */ +class TException extends Exception { + function __construct($p1=null, $p2=0) { + if (is_array($p1) && is_array($p2)) { + $spec = $p1; + $vals = $p2; + foreach ($spec as $fid => $fspec) { + $var = $fspec['var']; + if (isset($vals[$var])) { + $this->$var = $vals[$var]; + } + } + } else { + parent::__construct($p1, $p2); + } + } + + static $tmethod = array(TType::BOOL => 'Bool', + TType::BYTE => 'Byte', + TType::I16 => 'I16', + TType::I32 => 'I32', + TType::I64 => 'I64', + TType::DOUBLE => 'Double', + TType::STRING => 'String'); + + private function _readMap(&$var, $spec, $input) { + $xfer = 0; + $ktype = $spec['ktype']; + $vtype = $spec['vtype']; + $kread = $vread = null; + if (isset(TBase::$tmethod[$ktype])) { + $kread = 'read'.TBase::$tmethod[$ktype]; + } else { + $kspec = $spec['key']; + } + if (isset(TBase::$tmethod[$vtype])) { + $vread = 'read'.TBase::$tmethod[$vtype]; + } else { + $vspec = $spec['val']; + } + $var = array(); + $_ktype = $_vtype = $size = 0; + $xfer += $input->readMapBegin($_ktype, $_vtype, $size); + for ($i = 0; $i < $size; ++$i) { + $key = $val = null; + if ($kread !== null) { + $xfer += $input->$kread($key); + } else { + switch ($ktype) { + case TType::STRUCT: + $class = $kspec['class']; + $key = new $class(); + $xfer += $key->read($input); + break; + case TType::MAP: + $xfer += $this->_readMap($key, $kspec, $input); + break; + case TType::LST: + $xfer += $this->_readList($key, $kspec, $input, false); + break; + case TType::SET: + $xfer += $this->_readList($key, $kspec, $input, true); + break; + } + } + if ($vread !== null) { + $xfer += $input->$vread($val); + } else { + switch ($vtype) { + case TType::STRUCT: + $class = $vspec['class']; + $val = new $class(); + $xfer += $val->read($input); + break; + case TType::MAP: + $xfer += $this->_readMap($val, $vspec, $input); + break; + case TType::LST: + $xfer += $this->_readList($val, $vspec, $input, false); + break; + case TType::SET: + $xfer += $this->_readList($val, $vspec, $input, true); + break; + } + } + $var[$key] = $val; + } + $xfer += $input->readMapEnd(); + return $xfer; + } + + private function _readList(&$var, $spec, $input, $set=false) { + $xfer = 0; + $etype = $spec['etype']; + $eread = $vread = null; + if (isset(TBase::$tmethod[$etype])) { + $eread = 'read'.TBase::$tmethod[$etype]; + } else { + $espec = $spec['elem']; + } + $var = array(); + $_etype = $size = 0; + if ($set) { + $xfer += $input->readSetBegin($_etype, $size); + } else { + $xfer += $input->readListBegin($_etype, $size); + } + for ($i = 0; $i < $size; ++$i) { + $elem = null; + if ($eread !== null) { + $xfer += $input->$eread($elem); + } else { + $espec = $spec['elem']; + switch ($etype) { + case TType::STRUCT: + $class = $espec['class']; + $elem = new $class(); + $xfer += $elem->read($input); + break; + case TType::MAP: + $xfer += $this->_readMap($elem, $espec, $input); + break; + case TType::LST: + $xfer += $this->_readList($elem, $espec, $input, false); + break; + case TType::SET: + $xfer += $this->_readList($elem, $espec, $input, true); + break; + } + } + if ($set) { + $var[$elem] = true; + } else { + $var []= $elem; + } + } + if ($set) { + $xfer += $input->readSetEnd(); + } else { + $xfer += $input->readListEnd(); + } + return $xfer; + } + + protected function _read($class, $spec, $input) { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + if (isset($spec[$fid])) { + $fspec = $spec[$fid]; + $var = $fspec['var']; + if ($ftype == $fspec['type']) { + $xfer = 0; + if (isset(TBase::$tmethod[$ftype])) { + $func = 'read'.TBase::$tmethod[$ftype]; + $xfer += $input->$func($this->$var); + } else { + switch ($ftype) { + case TType::STRUCT: + $class = $fspec['class']; + $this->$var = new $class(); + $xfer += $this->$var->read($input); + break; + case TType::MAP: + $xfer += $this->_readMap($this->$var, $fspec, $input); + break; + case TType::LST: + $xfer += $this->_readList($this->$var, $fspec, $input, false); + break; + case TType::SET: + $xfer += $this->_readList($this->$var, $fspec, $input, true); + break; + } + } + } else { + $xfer += $input->skip($ftype); + } + } else { + $xfer += $input->skip($ftype); + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + private function _writeMap($var, $spec, $output) { + $xfer = 0; + $ktype = $spec['ktype']; + $vtype = $spec['vtype']; + $kwrite = $vwrite = null; + if (isset(TBase::$tmethod[$ktype])) { + $kwrite = 'write'.TBase::$tmethod[$ktype]; + } else { + $kspec = $spec['key']; + } + if (isset(TBase::$tmethod[$vtype])) { + $vwrite = 'write'.TBase::$tmethod[$vtype]; + } else { + $vspec = $spec['val']; + } + $xfer += $output->writeMapBegin($ktype, $vtype, count($var)); + foreach ($var as $key => $val) { + if (isset($kwrite)) { + $xfer += $output->$kwrite($key); + } else { + switch ($ktype) { + case TType::STRUCT: + $xfer += $key->write($output); + break; + case TType::MAP: + $xfer += $this->_writeMap($key, $kspec, $output); + break; + case TType::LST: + $xfer += $this->_writeList($key, $kspec, $output, false); + break; + case TType::SET: + $xfer += $this->_writeList($key, $kspec, $output, true); + break; + } + } + if (isset($vwrite)) { + $xfer += $output->$vwrite($val); + } else { + switch ($vtype) { + case TType::STRUCT: + $xfer += $val->write($output); + break; + case TType::MAP: + $xfer += $this->_writeMap($val, $vspec, $output); + break; + case TType::LST: + $xfer += $this->_writeList($val, $vspec, $output, false); + break; + case TType::SET: + $xfer += $this->_writeList($val, $vspec, $output, true); + break; + } + } + } + $xfer += $output->writeMapEnd(); + return $xfer; + } + + private function _writeList($var, $spec, $output, $set=false) { + $xfer = 0; + $etype = $spec['etype']; + $ewrite = null; + if (isset(TBase::$tmethod[$etype])) { + $ewrite = 'write'.TBase::$tmethod[$etype]; + } else { + $espec = $spec['elem']; + } + if ($set) { + $xfer += $output->writeSetBegin($etype, count($var)); + } else { + $xfer += $output->writeListBegin($etype, count($var)); + } + foreach ($var as $key => $val) { + $elem = $set ? $key : $val; + if (isset($ewrite)) { + $xfer += $output->$ewrite($elem); + } else { + switch ($etype) { + case TType::STRUCT: + $xfer += $elem->write($output); + break; + case TType::MAP: + $xfer += $this->_writeMap($elem, $espec, $output); + break; + case TType::LST: + $xfer += $this->_writeList($elem, $espec, $output, false); + break; + case TType::SET: + $xfer += $this->_writeList($elem, $espec, $output, true); + break; + } + } + } + if ($set) { + $xfer += $output->writeSetEnd(); + } else { + $xfer += $output->writeListEnd(); + } + return $xfer; + } + + protected function _write($class, $spec, $output) { + $xfer = 0; + $xfer += $output->writeStructBegin($class); + foreach ($spec as $fid => $fspec) { + $var = $fspec['var']; + if ($this->$var !== null) { + $ftype = $fspec['type']; + $xfer += $output->writeFieldBegin($var, $ftype, $fid); + if (isset(TBase::$tmethod[$ftype])) { + $func = 'write'.TBase::$tmethod[$ftype]; + $xfer += $output->$func($this->$var); + } else { + switch ($ftype) { + case TType::STRUCT: + $xfer += $this->$var->write($output); + break; + case TType::MAP: + $xfer += $this->_writeMap($this->$var, $fspec, $output); + break; + case TType::LST: + $xfer += $this->_writeList($this->$var, $fspec, $output, false); + break; + case TType::SET: + $xfer += $this->_writeList($this->$var, $fspec, $output, true); + break; + } + } + $xfer += $output->writeFieldEnd(); + } + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +/** + * Base class from which other Thrift structs extend. This is so that we can + * cut back on the size of the generated code which is turning out to have a + * nontrivial cost just to load thanks to the wondrously abysmal implementation + * of PHP. Note that code is intentionally duplicated in here to avoid making + * function calls for every field or member of a container.. + */ +abstract class TBase { + + static $tmethod = array(TType::BOOL => 'Bool', + TType::BYTE => 'Byte', + TType::I16 => 'I16', + TType::I32 => 'I32', + TType::I64 => 'I64', + TType::DOUBLE => 'Double', + TType::STRING => 'String'); + + abstract function read($input); + + abstract function write($output); + + public function __construct($spec=null, $vals=null) { + if (is_array($spec) && is_array($vals)) { + foreach ($spec as $fid => $fspec) { + $var = $fspec['var']; + if (isset($vals[$var])) { + $this->$var = $vals[$var]; + } + } + } + } + + private function _readMap(&$var, $spec, $input) { + $xfer = 0; + $ktype = $spec['ktype']; + $vtype = $spec['vtype']; + $kread = $vread = null; + if (isset(TBase::$tmethod[$ktype])) { + $kread = 'read'.TBase::$tmethod[$ktype]; + } else { + $kspec = $spec['key']; + } + if (isset(TBase::$tmethod[$vtype])) { + $vread = 'read'.TBase::$tmethod[$vtype]; + } else { + $vspec = $spec['val']; + } + $var = array(); + $_ktype = $_vtype = $size = 0; + $xfer += $input->readMapBegin($_ktype, $_vtype, $size); + for ($i = 0; $i < $size; ++$i) { + $key = $val = null; + if ($kread !== null) { + $xfer += $input->$kread($key); + } else { + switch ($ktype) { + case TType::STRUCT: + $class = $kspec['class']; + $key = new $class(); + $xfer += $key->read($input); + break; + case TType::MAP: + $xfer += $this->_readMap($key, $kspec, $input); + break; + case TType::LST: + $xfer += $this->_readList($key, $kspec, $input, false); + break; + case TType::SET: + $xfer += $this->_readList($key, $kspec, $input, true); + break; + } + } + if ($vread !== null) { + $xfer += $input->$vread($val); + } else { + switch ($vtype) { + case TType::STRUCT: + $class = $vspec['class']; + $val = new $class(); + $xfer += $val->read($input); + break; + case TType::MAP: + $xfer += $this->_readMap($val, $vspec, $input); + break; + case TType::LST: + $xfer += $this->_readList($val, $vspec, $input, false); + break; + case TType::SET: + $xfer += $this->_readList($val, $vspec, $input, true); + break; + } + } + $var[$key] = $val; + } + $xfer += $input->readMapEnd(); + return $xfer; + } + + private function _readList(&$var, $spec, $input, $set=false) { + $xfer = 0; + $etype = $spec['etype']; + $eread = $vread = null; + if (isset(TBase::$tmethod[$etype])) { + $eread = 'read'.TBase::$tmethod[$etype]; + } else { + $espec = $spec['elem']; + } + $var = array(); + $_etype = $size = 0; + if ($set) { + $xfer += $input->readSetBegin($_etype, $size); + } else { + $xfer += $input->readListBegin($_etype, $size); + } + for ($i = 0; $i < $size; ++$i) { + $elem = null; + if ($eread !== null) { + $xfer += $input->$eread($elem); + } else { + $espec = $spec['elem']; + switch ($etype) { + case TType::STRUCT: + $class = $espec['class']; + $elem = new $class(); + $xfer += $elem->read($input); + break; + case TType::MAP: + $xfer += $this->_readMap($elem, $espec, $input); + break; + case TType::LST: + $xfer += $this->_readList($elem, $espec, $input, false); + break; + case TType::SET: + $xfer += $this->_readList($elem, $espec, $input, true); + break; + } + } + if ($set) { + $var[$elem] = true; + } else { + $var []= $elem; + } + } + if ($set) { + $xfer += $input->readSetEnd(); + } else { + $xfer += $input->readListEnd(); + } + return $xfer; + } + + protected function _read($class, $spec, $input) { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + if (isset($spec[$fid])) { + $fspec = $spec[$fid]; + $var = $fspec['var']; + if ($ftype == $fspec['type']) { + $xfer = 0; + if (isset(TBase::$tmethod[$ftype])) { + $func = 'read'.TBase::$tmethod[$ftype]; + $xfer += $input->$func($this->$var); + } else { + switch ($ftype) { + case TType::STRUCT: + $class = $fspec['class']; + $this->$var = new $class(); + $xfer += $this->$var->read($input); + break; + case TType::MAP: + $xfer += $this->_readMap($this->$var, $fspec, $input); + break; + case TType::LST: + $xfer += $this->_readList($this->$var, $fspec, $input, false); + break; + case TType::SET: + $xfer += $this->_readList($this->$var, $fspec, $input, true); + break; + } + } + } else { + $xfer += $input->skip($ftype); + } + } else { + $xfer += $input->skip($ftype); + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + private function _writeMap($var, $spec, $output) { + $xfer = 0; + $ktype = $spec['ktype']; + $vtype = $spec['vtype']; + $kwrite = $vwrite = null; + if (isset(TBase::$tmethod[$ktype])) { + $kwrite = 'write'.TBase::$tmethod[$ktype]; + } else { + $kspec = $spec['key']; + } + if (isset(TBase::$tmethod[$vtype])) { + $vwrite = 'write'.TBase::$tmethod[$vtype]; + } else { + $vspec = $spec['val']; + } + $xfer += $output->writeMapBegin($ktype, $vtype, count($var)); + foreach ($var as $key => $val) { + if (isset($kwrite)) { + $xfer += $output->$kwrite($key); + } else { + switch ($ktype) { + case TType::STRUCT: + $xfer += $key->write($output); + break; + case TType::MAP: + $xfer += $this->_writeMap($key, $kspec, $output); + break; + case TType::LST: + $xfer += $this->_writeList($key, $kspec, $output, false); + break; + case TType::SET: + $xfer += $this->_writeList($key, $kspec, $output, true); + break; + } + } + if (isset($vwrite)) { + $xfer += $output->$vwrite($val); + } else { + switch ($vtype) { + case TType::STRUCT: + $xfer += $val->write($output); + break; + case TType::MAP: + $xfer += $this->_writeMap($val, $vspec, $output); + break; + case TType::LST: + $xfer += $this->_writeList($val, $vspec, $output, false); + break; + case TType::SET: + $xfer += $this->_writeList($val, $vspec, $output, true); + break; + } + } + } + $xfer += $output->writeMapEnd(); + return $xfer; + } + + private function _writeList($var, $spec, $output, $set=false) { + $xfer = 0; + $etype = $spec['etype']; + $ewrite = null; + if (isset(TBase::$tmethod[$etype])) { + $ewrite = 'write'.TBase::$tmethod[$etype]; + } else { + $espec = $spec['elem']; + } + if ($set) { + $xfer += $output->writeSetBegin($etype, count($var)); + } else { + $xfer += $output->writeListBegin($etype, count($var)); + } + foreach ($var as $key => $val) { + $elem = $set ? $key : $val; + if (isset($ewrite)) { + $xfer += $output->$ewrite($elem); + } else { + switch ($etype) { + case TType::STRUCT: + $xfer += $elem->write($output); + break; + case TType::MAP: + $xfer += $this->_writeMap($elem, $espec, $output); + break; + case TType::LST: + $xfer += $this->_writeList($elem, $espec, $output, false); + break; + case TType::SET: + $xfer += $this->_writeList($elem, $espec, $output, true); + break; + } + } + } + if ($set) { + $xfer += $output->writeSetEnd(); + } else { + $xfer += $output->writeListEnd(); + } + return $xfer; + } + + protected function _write($class, $spec, $output) { + $xfer = 0; + $xfer += $output->writeStructBegin($class); + foreach ($spec as $fid => $fspec) { + $var = $fspec['var']; + if ($this->$var !== null) { + $ftype = $fspec['type']; + $xfer += $output->writeFieldBegin($var, $ftype, $fid); + if (isset(TBase::$tmethod[$ftype])) { + $func = 'write'.TBase::$tmethod[$ftype]; + $xfer += $output->$func($this->$var); + } else { + switch ($ftype) { + case TType::STRUCT: + $xfer += $this->$var->write($output); + break; + case TType::MAP: + $xfer += $this->_writeMap($this->$var, $fspec, $output); + break; + case TType::LST: + $xfer += $this->_writeList($this->$var, $fspec, $output, false); + break; + case TType::SET: + $xfer += $this->_writeList($this->$var, $fspec, $output, true); + break; + } + } + $xfer += $output->writeFieldEnd(); + } + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } +} + +class TApplicationException extends TException { + static $_TSPEC = + array(1 => array('var' => 'message', + 'type' => TType::STRING), + 2 => array('var' => 'code', + 'type' => TType::I32)); + + const UNKNOWN = 0; + const UNKNOWN_METHOD = 1; + const INVALID_MESSAGE_TYPE = 2; + const WRONG_METHOD_NAME = 3; + const BAD_SEQUENCE_ID = 4; + const MISSING_RESULT = 5; + const INTERNAL_ERROR = 6; + const PROTOCOL_ERROR = 7; + + function __construct($message=null, $code=0) { + parent::__construct($message, $code); + } + + public function read($output) { + return $this->_read('TApplicationException', self::$_TSPEC, $output); + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('TApplicationException'); + if ($message = $this->getMessage()) { + $xfer += $output->writeFieldBegin('message', TType::STRING, 1); + $xfer += $output->writeString($message); + $xfer += $output->writeFieldEnd(); + } + if ($code = $this->getCode()) { + $xfer += $output->writeFieldBegin('type', TType::I32, 2); + $xfer += $output->writeI32($code); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } +} + +/** + * Set global THRIFT ROOT automatically via inclusion here + */ +if (!isset($GLOBALS['THRIFT_ROOT'])) { + $GLOBALS['THRIFT_ROOT'] = dirname(__FILE__); +} +include_once $GLOBALS['THRIFT_ROOT'].'/protocol/TProtocol.php'; +include_once $GLOBALS['THRIFT_ROOT'].'/transport/TTransport.php'; +include_once $GLOBALS['THRIFT_ROOT'].'/TStringUtils.php'; + http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e5e190ef/app/libraries/Thrift/Transport/TBufferedTransport.php ---------------------------------------------------------------------- diff --git a/app/libraries/Thrift/Transport/TBufferedTransport.php b/app/libraries/Thrift/Transport/TBufferedTransport.php index 270c004..0d3ad98 100644 --- a/app/libraries/Thrift/Transport/TBufferedTransport.php +++ b/app/libraries/Thrift/Transport/TBufferedTransport.php @@ -156,13 +156,8 @@ class TBufferedTransport extends TTransport { public function flush() { if (TStringFuncFactory::create()->strlen($this->wBuf_) > 0) { - $out = $this->wBuf_; - - // Note that we clear the internal wBuf_ prior to the underlying write - // to ensure we're in a sane state (i.e. internal buffer cleaned) - // if the underlying write throws up an exception + $this->transport_->write($this->wBuf_); $this->wBuf_ = ''; - $this->transport_->write($out); } $this->transport_->flush(); } http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e5e190ef/app/libraries/Thrift/Transport/TSocket.php ---------------------------------------------------------------------- diff --git a/app/libraries/Thrift/Transport/TSocket.php b/app/libraries/Thrift/Transport/TSocket.php index eb7275c..3ad3bf7 100644 --- a/app/libraries/Thrift/Transport/TSocket.php +++ b/app/libraries/Thrift/Transport/TSocket.php @@ -261,8 +261,7 @@ class TSocket extends TTransport { $readable = @stream_select($read, $null, $null, $this->recvTimeoutSec_, $this->recvTimeoutUsec_); if ($readable > 0) { - //$data = @stream_socket_recvfrom($this->handle_, $len); - $data = @fread($this->handle_, $len); + $data = @stream_socket_recvfrom($this->handle_, $len); if ($data === false) { throw new TTransportException('TSocket: Could not read '.$len.' bytes from '. $this->host_.':'.$this->port_); @@ -295,8 +294,7 @@ class TSocket extends TTransport { $writable = @stream_select($null, $write, $null, $this->sendTimeoutSec_, $this->sendTimeoutUsec_); if ($writable > 0) { // write buffer to stream - //$written = @stream_socket_sendto($this->handle_, $buf); - $written = @fwrite($this->handle_, $buf); + $written = @stream_socket_sendto($this->handle_, $buf); if ($written === -1 || $written === false) { throw new TTransportException('TSocket: Could not write '.TStringFuncFactory::create()->strlen($buf).' bytes '. $this->host_.':'.$this->port_); http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e5e190ef/app/libraries/Thrift/autoload.php ---------------------------------------------------------------------- diff --git a/app/libraries/Thrift/autoload.php b/app/libraries/Thrift/autoload.php new file mode 100644 index 0000000..3a35545 --- /dev/null +++ b/app/libraries/Thrift/autoload.php @@ -0,0 +1,51 @@ +<?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 + */ + + +/** + * Include this file if you wish to use autoload with your PHP generated Thrift + * code. The generated code will *not* include any defined Thrift classes by + * default, except for the service interfaces. The generated code will populate + * values into $GLOBALS['THRIFT_AUTOLOAD'] which can be used by the autoload + * method below. If you have your own autoload system already in place, rename your + * __autoload function to something else and then do: + * $GLOBALS['AUTOLOAD_HOOKS'][] = 'my_autoload_func'; + * + * Generate this code using the --gen php:autoload Thrift generator flag. + */ + +$GLOBALS['THRIFT_AUTOLOAD'] = array(); +$GLOBALS['AUTOLOAD_HOOKS'] = array(); + +if (!function_exists('__autoload')) { + function __autoload($class) { + global $THRIFT_AUTOLOAD; + $classl = strtolower($class); + if (isset($THRIFT_AUTOLOAD[$classl])) { + include_once $GLOBALS['THRIFT_ROOT'].'/packages/'.$THRIFT_AUTOLOAD[$classl]; + } else if (!empty($GLOBALS['AUTOLOAD_HOOKS'])) { + foreach ($GLOBALS['AUTOLOAD_HOOKS'] as $hook) { + $hook($class); + } + } + } +}