Source for file Client.php

Documentation is available at Client.php

  1. <?php
  2. /** 
  3.  *  PHP Version 5
  4.  *
  5.  *  @category    Amazon
  6.  *  @package     Amazon_SimpleDB
  7.  *  @copyright   Copyright 2008 Amazon Technologies, Inc.
  8.  *  @link        http://aws.amazon.com
  9.  *  @license     http://aws.amazon.com/apache2.0  Apache License, Version 2.0
  10.  *  @version     2007-11-07
  11.  */
  12. /******************************************************************************* 
  13.  *    __  _    _  ___ 
  14.  *   (  )( \/\/ )/ __)
  15.  *   /__\ \    / \__ \
  16.  *  (_)(_) \/\/  (___/
  17.  * 
  18.  *  Amazon Simple DB PHP5 Library
  19.  *  Generated: Thu Aug 28 06:20:51 PDT 2008
  20.  * 
  21.  */
  22.  
  23. /**
  24.  *  @see Amazon_SimpleDB_Interface
  25.  */
  26. require_once ('Amazon/SimpleDB/Interface.php')
  27.  
  28. /**
  29.  * Amazon SimpleDB is a web service for running queries on structured
  30.  * data in real time. This service works in close conjunction with Amazon
  31.  * Simple Storage Service (Amazon S3) and Amazon Elastic Compute Cloud
  32.  * (Amazon EC2), collectively providing the ability to store, process
  33.  * and query data sets in the cloud. These services are designed to make
  34.  * web-scale computing easier and more cost-effective for developers.
  35.  * Traditionally, this type of functionality has been accomplished with
  36.  * a clustered relational database that requires a sizable upfront
  37.  * investment, brings more complexity than is typically needed, and often
  38.  * requires a DBA to maintain and administer. In contrast, Amazon SimpleDB
  39.  * is easy to use and provides the core functionality of a database -
  40.  * real-time lookup and simple querying of structured data without the
  41.  * operational complexity.  Amazon SimpleDB requires no schema, automatically
  42.  * indexes your data and provides a simple API for storage and access.
  43.  * This eliminates the administrative burden of data modeling, index
  44.  * maintenance, and performance tuning. Developers gain access to this
  45.  * functionality within Amazon's proven computing environment, are able
  46.  * to scale instantly, and pay only for what they use.
  47.  * 
  48.  * Amazon_SimpleDB_Client is an implementation of Amazon_SimpleDB
  49.  *
  50.  */
  51. class Amazon_SimpleDB_Client implements Amazon_SimpleDB_Interface
  52. {
  53.  
  54.     const SERVICE_VERSION '2007-11-07';
  55.  
  56.     /** @var string */
  57.     private  $_awsAccessKeyId null;
  58.     
  59.     /** @var string */
  60.     private  $_awsSecretAccessKey null;
  61.     
  62.     /** @var array */
  63.     private  $_config array ('ServiceURL' => 'http://sdb.amazonaws.com'
  64.                                'UserAgent' => 'Amazon SimpleDB PHP5 Library',
  65.                                'SignatureVersion' => 1,
  66.                                'ProxyHost' => null,
  67.                                'ProxyPort' => -1,
  68.                                'MaxErrorRetry' => 3       
  69.                                );
  70.    
  71.     /**
  72.      * Construct new Client
  73.      * 
  74.      * @param string $awsAccessKeyId AWS Access Key ID
  75.      * @param string $awsSecretAccessKey AWS Secret Access Key
  76.      * @param array $config configuration options.
  77.      *  Valid configuration options are:
  78.      *  <ul>
  79.      *  <li>ServiceURL</li>
  80.      *  <li>UserAgent</li>
  81.      *  <li>SignatureVersion</li>
  82.      *  <li>TimesRetryOnError</li>
  83.      *  <li>ProxyHost</li>
  84.      *  <li>ProxyPort</li>
  85.      *  <li>MaxErrorRetry</li>
  86.      *  </ul>
  87.      */
  88.     public function __construct($awsAccessKeyId$awsSecretAccessKey$config null)
  89.     {
  90.         iconv_set_encoding('output_encoding''UTF-8');
  91.         iconv_set_encoding('input_encoding''UTF-8');
  92.         iconv_set_encoding('internal_encoding''UTF-8');
  93.  
  94.         $this->_awsAccessKeyId $awsAccessKeyId;
  95.         $this->_awsSecretAccessKey $awsSecretAccessKey;
  96.         if (!is_null($config)) $this->_config array_merge($this->_config$config);
  97.     }
  98.  
  99.     // Public API ------------------------------------------------------------//
  100.  
  101.  
  102.             
  103.     /**
  104.      * Create Domain
  105.      * The CreateDomain operation creates a new domain. The domain name must be unique
  106.      * among the domains associated with the Access Key ID provided in the request. The CreateDomain
  107.      * operation may take 10 or more seconds to complete.
  108.      *   
  109.      * @see http://docs.amazonwebservices.com/AmazonSimpleDB/2007-11-07/DeveloperGuide/SDB_API_CreateDomain.html
  110.      * @param mixed $request array of parameters for Amazon_SimpleDB_Model_CreateDomainRequest request
  111.      *  or Amazon_SimpleDB_Model_CreateDomainRequest object itself
  112.      * @see Amazon_SimpleDB_Model_CreateDomain
  113.      * @return Amazon_SimpleDB_Model_CreateDomainResponse Amazon_SimpleDB_Model_CreateDomainResponse
  114.      *
  115.      * @throws Amazon_SimpleDB_Exception
  116.      */
  117.     public function createDomain($request
  118.     {
  119.         if (!$request instanceof Amazon_SimpleDB_Model_CreateDomainRequest{
  120.             require_once ('Amazon/SimpleDB/Model/CreateDomainRequest.php');
  121.             $request new Amazon_SimpleDB_Model_CreateDomainRequest($request);
  122.         }
  123.         require_once ('Amazon/SimpleDB/Model/CreateDomainResponse.php');
  124.         return Amazon_SimpleDB_Model_CreateDomainResponse::fromXML($this->_invoke($this->_convertCreateDomain($request)));
  125.     }
  126.  
  127.  
  128.             
  129.     /**
  130.      * List Domains
  131.      * The ListDomains operaton lists all domains associated with the Access Key ID. It returns
  132.      * domain names up to the limit set by MaxNumberOfDomains. A NextToken is returned if there are more
  133.      * than MaxNumberOfDomains domains. Calling ListDomains successive times with the
  134.      * NextToken returns up to MaxNumberOfDomains more domain names each time.
  135.      *   
  136.      * @see http://docs.amazonwebservices.com/AmazonSimpleDB/2007-11-07/DeveloperGuide/SDB_API_ListDomains.html
  137.      * @param mixed $request array of parameters for Amazon_SimpleDB_Model_ListDomainsRequest request
  138.      *  or Amazon_SimpleDB_Model_ListDomainsRequest object itself
  139.      * @see Amazon_SimpleDB_Model_ListDomains
  140.      * @return Amazon_SimpleDB_Model_ListDomainsResponse Amazon_SimpleDB_Model_ListDomainsResponse
  141.      *
  142.      * @throws Amazon_SimpleDB_Exception
  143.      */
  144.     public function listDomains($request
  145.     {
  146.         if (!$request instanceof Amazon_SimpleDB_Model_ListDomainsRequest{
  147.             require_once ('Amazon/SimpleDB/Model/ListDomainsRequest.php');
  148.             $request new Amazon_SimpleDB_Model_ListDomainsRequest($request);
  149.         }
  150.         require_once ('Amazon/SimpleDB/Model/ListDomainsResponse.php');
  151.         return Amazon_SimpleDB_Model_ListDomainsResponse::fromXML($this->_invoke($this->_convertListDomains($request)));
  152.     }
  153.  
  154.  
  155.             
  156.     /**
  157.      * Delete Domain
  158.      * The DeleteDomain operation deletes a domain. Any items (and their attributes) in the domain
  159.      * are deleted as well. The DeleteDomain operation may take 10 or more seconds to complete.
  160.      *   
  161.      * @see http://docs.amazonwebservices.com/AmazonSimpleDB/2007-11-07/DeveloperGuide/SDB_API_DeleteDomain.html
  162.      * @param mixed $request array of parameters for Amazon_SimpleDB_Model_DeleteDomainRequest request
  163.      *  or Amazon_SimpleDB_Model_DeleteDomainRequest object itself
  164.      * @see Amazon_SimpleDB_Model_DeleteDomain
  165.      * @return Amazon_SimpleDB_Model_DeleteDomainResponse Amazon_SimpleDB_Model_DeleteDomainResponse
  166.      *
  167.      * @throws Amazon_SimpleDB_Exception
  168.      */
  169.     public function deleteDomain($request
  170.     {
  171.         if (!$request instanceof Amazon_SimpleDB_Model_DeleteDomainRequest{
  172.             require_once ('Amazon/SimpleDB/Model/DeleteDomainRequest.php');
  173.             $request new Amazon_SimpleDB_Model_DeleteDomainRequest($request);
  174.         }
  175.         require_once ('Amazon/SimpleDB/Model/DeleteDomainResponse.php');
  176.         return Amazon_SimpleDB_Model_DeleteDomainResponse::fromXML($this->_invoke($this->_convertDeleteDomain($request)));
  177.     }
  178.  
  179.  
  180.             
  181.     /**
  182.      * Put Attributes
  183.      * The PutAttributes operation creates or replaces attributes within an item. You specify new attributes
  184.      * using a combination of the Attribute.X.Name and Attribute.X.Value parameters. You specify
  185.      * the first attribute by the parameters Attribute.0.Name and Attribute.0.Value, the second
  186.      * attribute by the parameters Attribute.1.Name and Attribute.1.Value, and so on.
  187.      * Attributes are uniquely identified within an item by their name/value combination. For example, a single
  188.      * item can have the attributes { "first_name", "first_value" } and { "first_name",
  189.      * second_value" }. However, it cannot have two attribute instances where both the Attribute.X.Name and
  190.      * Attribute.X.Value are the same.
  191.      * Optionally, the requestor can supply the Replace parameter for each individual value. Setting this value
  192.      * to true will cause the new attribute value to replace the existing attribute value(s). For example, if an
  193.      * item has the attributes { 'a', '1' }, { 'b', '2'} and { 'b', '3' } and the requestor does a
  194.      * PutAttributes of { 'b', '4' } with the Replace parameter set to true, the final attributes of the
  195.      * item will be { 'a', '1' } and { 'b', '4' }, replacing the previous values of the 'b' attribute
  196.      * with the new value.
  197.      *   
  198.      * @see http://docs.amazonwebservices.com/AmazonSimpleDB/2007-11-07/DeveloperGuide/SDB_API_PutAttributes.html
  199.      * @param mixed $request array of parameters for Amazon_SimpleDB_Model_PutAttributesRequest request
  200.      *  or Amazon_SimpleDB_Model_PutAttributesRequest object itself
  201.      * @see Amazon_SimpleDB_Model_PutAttributes
  202.      * @return Amazon_SimpleDB_Model_PutAttributesResponse Amazon_SimpleDB_Model_PutAttributesResponse
  203.      *
  204.      * @throws Amazon_SimpleDB_Exception
  205.      */
  206.     public function putAttributes($request
  207.     {
  208.         if (!$request instanceof Amazon_SimpleDB_Model_PutAttributesRequest{
  209.             require_once ('Amazon/SimpleDB/Model/PutAttributesRequest.php');
  210.             $request new Amazon_SimpleDB_Model_PutAttributesRequest($request);
  211.         }
  212.         require_once ('Amazon/SimpleDB/Model/PutAttributesResponse.php');
  213.         return Amazon_SimpleDB_Model_PutAttributesResponse::fromXML($this->_invoke($this->_convertPutAttributes($request)));
  214.     }
  215.  
  216.  
  217.             
  218.     /**
  219.      * Get Attributes
  220.      * Returns all of the attributes associated with the item. Optionally, the attributes returned can be limited to
  221.      * the specified AttributeName parameter.
  222.      * If the item does not exist on the replica that was accessed for this operation, an empty attribute is
  223.      * returned. The system does not return an error as it cannot guarantee the item does not exist on other
  224.      * replicas.
  225.      *   
  226.      * @see http://docs.amazonwebservices.com/AmazonSimpleDB/2007-11-07/DeveloperGuide/SDB_API_GetAttributes.html
  227.      * @param mixed $request array of parameters for Amazon_SimpleDB_Model_GetAttributesRequest request
  228.      *  or Amazon_SimpleDB_Model_GetAttributesRequest object itself
  229.      * @see Amazon_SimpleDB_Model_GetAttributes
  230.      * @return Amazon_SimpleDB_Model_GetAttributesResponse Amazon_SimpleDB_Model_GetAttributesResponse
  231.      *
  232.      * @throws Amazon_SimpleDB_Exception
  233.      */
  234.     public function getAttributes($request
  235.     {
  236.         if (!$request instanceof Amazon_SimpleDB_Model_GetAttributesRequest{
  237.             require_once ('Amazon/SimpleDB/Model/GetAttributesRequest.php');
  238.             $request new Amazon_SimpleDB_Model_GetAttributesRequest($request);
  239.         }
  240.         require_once ('Amazon/SimpleDB/Model/GetAttributesResponse.php');
  241.         return Amazon_SimpleDB_Model_GetAttributesResponse::fromXML($this->_invoke($this->_convertGetAttributes($request)));
  242.     }
  243.  
  244.  
  245.             
  246.     /**
  247.      * Delete Attributes
  248.      * Deletes one or more attributes associated with the item. If all attributes of an item are deleted, the item is
  249.      * deleted.
  250.      *   
  251.      * @see http://docs.amazonwebservices.com/AmazonSimpleDB/2007-11-07/DeveloperGuide/SDB_API_DeleteAttributes.html
  252.      * @param mixed $request array of parameters for Amazon_SimpleDB_Model_DeleteAttributesRequest request
  253.      *  or Amazon_SimpleDB_Model_DeleteAttributesRequest object itself
  254.      * @see Amazon_SimpleDB_Model_DeleteAttributes
  255.      * @return Amazon_SimpleDB_Model_DeleteAttributesResponse Amazon_SimpleDB_Model_DeleteAttributesResponse
  256.      *
  257.      * @throws Amazon_SimpleDB_Exception
  258.      */
  259.     public function deleteAttributes($request
  260.     {
  261.         if (!$request instanceof Amazon_SimpleDB_Model_DeleteAttributesRequest{
  262.             require_once ('Amazon/SimpleDB/Model/DeleteAttributesRequest.php');
  263.             $request new Amazon_SimpleDB_Model_DeleteAttributesRequest($request);
  264.         }
  265.         require_once ('Amazon/SimpleDB/Model/DeleteAttributesResponse.php');
  266.         return Amazon_SimpleDB_Model_DeleteAttributesResponse::fromXML($this->_invoke($this->_convertDeleteAttributes($request)));
  267.     }
  268.  
  269.  
  270.             
  271.     /**
  272.      * Query
  273.      * The Query operation returns a set of ItemNames that match the query expression. Query operations that
  274.      * run longer than 5 seconds will likely time-out and return a time-out error response.
  275.      * A Query with no QueryExpression matches all items in the domain.
  276.      *   
  277.      * @see http://docs.amazonwebservices.com/AmazonSimpleDB/2007-11-07/DeveloperGuide/SDB_API_Query.html
  278.      * @param mixed $request array of parameters for Amazon_SimpleDB_Model_QueryRequest request
  279.      *  or Amazon_SimpleDB_Model_QueryRequest object itself
  280.      * @see Amazon_SimpleDB_Model_Query
  281.      * @return Amazon_SimpleDB_Model_QueryResponse Amazon_SimpleDB_Model_QueryResponse
  282.      *
  283.      * @throws Amazon_SimpleDB_Exception
  284.      */
  285.     public function query($request
  286.     {
  287.         if (!$request instanceof Amazon_SimpleDB_Model_QueryRequest{
  288.             require_once ('Amazon/SimpleDB/Model/QueryRequest.php');
  289.             $request new Amazon_SimpleDB_Model_QueryRequest($request);
  290.         }
  291.         require_once ('Amazon/SimpleDB/Model/QueryResponse.php');
  292.         return Amazon_SimpleDB_Model_QueryResponse::fromXML($this->_invoke($this->_convertQuery($request)));
  293.     }
  294.  
  295.  
  296.             
  297.     /**
  298.      * Query With Attributes
  299.      * The QueryWithAttributes operation returns a set of item names and associated attributes.
  300.      * The query semantics of this operation are identical to the Query operation.
  301.      *   
  302.      * @see http://docs.amazonwebservices.com/AmazonSimpleDB/2007-11-07/DeveloperGuide/SDB_API_QueryWithAttributes.html
  303.      * @param mixed $request array of parameters for Amazon_SimpleDB_Model_QueryWithAttributesRequest request
  304.      *  or Amazon_SimpleDB_Model_QueryWithAttributesRequest object itself
  305.      * @see Amazon_SimpleDB_Model_QueryWithAttributes
  306.      * @return Amazon_SimpleDB_Model_QueryWithAttributesResponse Amazon_SimpleDB_Model_QueryWithAttributesResponse
  307.      *
  308.      * @throws Amazon_SimpleDB_Exception
  309.      */
  310.     public function queryWithAttributes($request
  311.     {
  312.         if (!$request instanceof Amazon_SimpleDB_Model_QueryWithAttributesRequest{
  313.             require_once ('Amazon/SimpleDB/Model/QueryWithAttributesRequest.php');
  314.             $request new Amazon_SimpleDB_Model_QueryWithAttributesRequest($request);
  315.         }
  316.         require_once ('Amazon/SimpleDB/Model/QueryWithAttributesResponse.php');
  317.         return Amazon_SimpleDB_Model_QueryWithAttributesResponse::fromXML($this->_invoke($this->_convertQueryWithAttributes($request)));
  318.     }
  319.  
  320.         // Private API ------------------------------------------------------------//
  321.  
  322.     /**
  323.      * Invoke request and return response
  324.      */
  325.     private function _invoke(array $parameters)
  326.     {
  327.         $actionName $parameters["Action"];
  328.         $response array();
  329.         $responseBody null;
  330.         $statusCode 200;
  331.  
  332.         /* Submit the request and read response body */
  333.         try {
  334.         
  335.             /* Add required request parameters */
  336.             $parameters $this->_addRequiredParameters($parameters);
  337.  
  338.             $shouldRetry true;
  339.             $retries 0;
  340.             do {
  341.                 try {
  342.                         $response $this->_httpPost($parameters);
  343.                         if ($response['Status'=== 200{
  344.                             $shouldRetry false;
  345.                         else {
  346.                             if ($response['Status'=== 500 || $response['Status'=== 503{
  347.                                 $shouldRetry true;
  348.                                 $this->_pauseOnRetry(++$retries$response['Status']);
  349.                             else {    
  350.                                 throw $this->_reportAnyErrors($response['ResponseBody']$response['Status']);
  351.                             }
  352.                        }     
  353.                 /* Rethrow on deserializer error */
  354.                 catch (Exception $e{
  355.                     require_once ('Amazon/SimpleDB/Exception.php');
  356.                     if ($e instanceof Amazon_SimpleDB_Exception{
  357.                         throw $e;
  358.                     else {
  359.                         require_once ('Amazon/SimpleDB/Exception.php');
  360.                         throw new Amazon_SimpleDB_Exception(array('Exception' => $e'Message' => $e->getMessage()));   
  361.                     }
  362.                 }
  363.  
  364.             while ($shouldRetry);
  365.  
  366.         catch (Amazon_SimpleDB_Exception $se{
  367.             throw $se;
  368.         catch (Exception $t{
  369.             throw new Amazon_SimpleDB_Exception(array('Exception' => $t'Message' => $t->getMessage()));
  370.         }
  371.  
  372.         return $response['ResponseBody'];
  373.     }
  374.  
  375.     /**
  376.      * Look for additional error strings in the response and return formatted exception
  377.      */
  378.     private function _reportAnyErrors($responseBody$statusException $e =  null)
  379.     {
  380.         $ex null;
  381.         if (!is_null($responseBody&& strpos($responseBody'<'=== 0{
  382.             if (preg_match('@<RequestId>(.*)</RequestId>.*<Error><Code>(.*)</Code><Message>(.*)</Message></Error>.*(<Error>)?@mi',
  383.                 $responseBody$errorMatcherOne)) {
  384.                                 
  385.                 $requestId $errorMatcherOne[1];
  386.                 $code $errorMatcherOne[2];
  387.                 $message $errorMatcherOne[3];
  388.  
  389.                 require_once ('Amazon/SimpleDB/Exception.php');
  390.                 $ex new Amazon_SimpleDB_Exception(array ('Message' => $message'StatusCode' => $status'ErrorCode' => $code
  391.                                                            'ErrorType' => 'Unknown''RequestId' => $requestId'XML' => $responseBody));
  392.  
  393.             elseif (preg_match('@<Error><Code>(.*)</Code><Message>(.*)</Message></Error>.*(<Error>)?.*<RequestID>(.*)</RequestID>@mi',
  394.                 $responseBody$errorMatcherTwo)) {
  395.                                 
  396.                 $code $errorMatcherTwo[1];  
  397.                 $message $errorMatcherTwo[2];  
  398.                 $requestId $errorMatcherTwo[4];   
  399.                 require_once ('Amazon/SimpleDB/Exception.php');
  400.                 $ex new Amazon_SimpleDB_Exception(array ('Message' => $message'StatusCode' => $status'ErrorCode' => $code
  401.                                                               'ErrorType' => 'Unknown''RequestId' => $requestId'XML' => $responseBody));
  402.             elseif (preg_match('@<Error><Code>(.*)</Code><Message>(.*)</Message><BoxUsage>(.*)</BoxUsage></Error>.*(<Error>)?.*<RequestID>(.*)</RequestID>@mi',
  403.                 $responseBody$errorMatcherThree)) {
  404.                                 
  405.                 $code $errorMatcherThree[1];  
  406.                 $message $errorMatcherThree[2]
  407.                 $boxUsage $errorMatcherThree[3];   
  408.                 $requestId $errorMatcherThree[5];   
  409.                 require_once ('Amazon/SimpleDB/Exception.php');
  410.                 $ex new Amazon_SimpleDB_Exception(array ('Message' => $message'StatusCode' => $status'ErrorCode' => $code
  411.                                                               'ErrorType' => 'Unknown''BoxUsage' => $boxUsage'RequestId' => $requestId'XML' => $responseBody));
  412.  
  413.             else {
  414.                 require_once ('Amazon/SimpleDB/Exception.php');
  415.                 $ex new Amazon_SimpleDB_Exception(array('Message' => 'Internal Error''StatusCode' => $status));
  416.             }
  417.         else {
  418.             require_once ('Amazon/SimpleDB/Exception.php');
  419.             $ex new Amazon_SimpleDB_Exception(array('Message' => 'Internal Error''StatusCode' => $status));
  420.         }
  421.         return $ex;
  422.     }
  423.  
  424.  
  425.  
  426.     /**
  427.      * Perform HTTP post with exponential retries on error 500 and 503
  428.      * 
  429.      */
  430.     private function _httpPost(array $parameters
  431.     {
  432.         $query $this->_getParametersAsString($parameters);
  433.         $url parse_url ($this->_config['ServiceURL']);
  434.         $post  "POST / HTTP/1.0\r\n";
  435.         $post .= "Host: " $url['host'"\r\n";
  436.         $post .= "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n";
  437.         $post .= "Content-Length: " strlen($query"\r\n";
  438.         $post .= "User-Agent: " $this->_config['UserAgent'"\r\n";
  439.         $post .= "\r\n";
  440.         $post .= $query;
  441.  
  442.         $port array_key_exists('port',$url$url['port'null;
  443.         $scheme '';
  444.         
  445.         switch ($url['scheme']{
  446.             case 'https':
  447.                 $scheme 'ssl://';
  448.                 $port $port === null 443 $port;
  449.                 break;
  450.             default:
  451.                 $scheme '';
  452.                 $port $port == null 80 $port;
  453.         }
  454.               
  455.         $response '';
  456.         if ($socket @fsockopen($scheme $url['host']$port$errno$errstr10)) {
  457.   
  458.             fwrite($socket$post);
  459.  
  460.             while (!feof($socket)) {
  461.                 $response .= fgets($socket1160);
  462.             }
  463.             fclose($socket);
  464.         
  465.             list($other$responseBodyexplode("\r\n\r\n"$response2);
  466.             $other preg_split("/\r\n|\n|\r/"$other);
  467.             list($protocol$code$textexplode(' 'trim(array_shift($other))3);
  468.         else {
  469.             throw new Exception ("Unable to establish connection to host " $url['host'" $errstr");
  470.         }
  471.         return array ('Status' => (int)$code'ResponseBody' => $responseBody);
  472.     }
  473.  
  474.     /**
  475.      * Exponential sleep on failed request
  476.      * @param retries current retry
  477.      * @throws Amazon_SimpleDB_Exception if maximum number of retries has been reached
  478.      */
  479.     private function _pauseOnRetry($retries$status)
  480.     {
  481.         if ($retries <= $this->_config['MaxErrorRetry']{
  482.             $delay = (int) (pow(4$retries100000;
  483.             usleep($delay);
  484.         else {
  485.             require_once ('Amazon/SimpleDB/Exception.php');
  486.             throw new Amazon_SimpleDB_Exception (array ('Message' => "Maximum number of retry attempts reached :  $retries"'StatusCode' => $status));
  487.         }
  488.     }
  489.  
  490.     /**
  491.      * Add authentication related and version parameters
  492.      */
  493.     private function _addRequiredParameters(array&