[英]AWS dynamodb PHP 'Command was not found matching Update_table'
I working on a web application and since a lot of read and write action happening in the amazon dynamodb table am facing a provisionthroughput
error. 我正在开发一个Web应用程序,因为在amazon dynamodb表中发生了很多读写操作,我遇到了一个
provisionthroughput
吞吐量错误。 Thinking of using a Update table I used below code but facing error. 考虑使用更新表我在下面的代码中使用但面临错误。 This error is not mentioned in error handling chart of dynamobb.
dynamobb的错误处理图表中未提及此错误。
<?php
use Aws\DynamoDb\DynamoDbClient;
$dynamoDB = DynamoDbClient::factory(array(
'key' => '',
'secret' => '',
'region' => Region::US_WEST_1
));
####################################################################
# Updating the table
// $dynamodb = new AmazonDynamoDB();
echo PHP_EOL . PHP_EOL;
echo "# Updating the \"${dynamo_db_table}\" table..." . PHP_EOL;
$up = $dynamoDB->Update_table(array(
'TableName' => $dynamo_db_table,
'ProvisionedThroughput' => array(
'ReadCapacityUnits' => 39,
'WriteCapacityUnits' => 37
)
));
$table_status = $dynamoDB->describe_table(array(
'TableName' => $dynamo_db_table
));
// Check for success...
if ($table_status->isOK())
{
print_r($table_status->body->Table->ProvisionedThroughput->to_array()->getArrayCopy());
}
else
{
print_r($table_status);
}
$count = 0;
do {
sleep(5);
$count += 5;
$response = $dynamoDB->describe_table(array(
'TableName' => $table_name
));
}
while ((string) $response->body->Table->TableStatus !== 'ACTIVE');
echo "The table \"${table_name}\" has been updated (slept ${count} seconds)." . PHP_EOL;
?>
I am facing below error: 我面临以下错误:
# Updating the "tablename" table...
Fatal error: Uncaught exception 'Guzzle\Common\Exception\InvalidArgumentException' with message 'Command was not found matching Update_table' in /home/phretscl/public_html/RETS/vendor/guzzle/guzzle/src/Guzzle/Service/Client.php:117 Stack trace: #0 /home/phretscl/public_html/RETS/vendor/guzzle/guzzle/src/Guzzle/Service/Client.php(94): Guzzle\Service\Client->getCommand('Update_table', Array) #1 /home/phretscl/public_html/RETS/vendor/aws/aws-sdk-php/src/Aws/Common/Client/AbstractClient.php(103): Guzzle\Service\Client->__call('Update_table', Array) #2 /home/phretscl/public_html/RETS/file.php(97): Aws\Common\Client\AbstractClient->__call('Update_table', Array) #3 /home/phretscl/public_html/RETS/file.php(97): Aws\DynamoDb\DynamoDbClient->Update_table(Array) #4 {main} thrown in /home/phretscl/public_html/RETS/vendor/guzzle/guzzle/src/Guzzle/Service/Client.php on line 117
The code you are using is not correct. 您使用的代码不正确。 From the error message, I can tell you are using version 2.x of the AWS SDK for PHP, but the code you using from
############
line down looks like it is meant for version 1.x of the AWS SDK for PHP. 从错误消息中,我可以告诉您正在使用适用于PHP的AWS开发工具包的2.x版本,但是您使用
############
行下载的代码看起来像是用于版本1适用于PHP的AWS开发工具包的.x The error is being thrown, because you are not calling the DynamoDbClient::updateTable()
method correctly. 抛出错误,因为您没有正确调用
DynamoDbClient::updateTable()
方法 。
You should checkout the AWS SDK for PHP User Guide , particularly the page about DynamoDB , which has a code sample for UpdateTable
. 您应该检出AWS SDK的PHP用户指南 ,特别是有关DynamoDB网页 ,其中有一个代码示例
UpdateTable
。
EDIT w/ regards to the comments : If this is a long running process, you should use the Aws\\Common\\Aws
way of instantiating the client, since it retains and reuses the client objects it creates. 编辑/评论 :如果这是一个长时间运行的过程,您应该使用
Aws\\Common\\Aws
实例化客户端的方式,因为它保留并重用它创建的客户端对象。 Replace you DynamoDbClient::factory(...)
code with this: 用以下代替您的
DynamoDbClient::factory(...)
代码:
use Aws\Common\Aws;
$aws = Aws::factory(array(
'key' => '...',
'secret' => '...',
'region' => Region::US_WEST_1
));
$dynamoDB = $aws->get('dynamodb');
You should provide the credentials like this Also, the region should be like this 'region'=>'us-east-1' 您应该提供这样的凭据此外,该区域应该像这样'region'=>'us-east-1'
$DDBClient = DynamoDbClient::factory([
'region'=>'us-east-1',
'version' => 'latest',
'credentials' => [
'key' => 'XXXXXXXXXX',
'secret' => 'XXXXXXXXXXXXX'
]
,'scheme' => 'http' // Use this if you don't have HTTPS
//, 'debug' => true
]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.