我有cassandra的问题我有以下错误。我链接了一张照片
代码语法:
public function find($db_table = null, $db_id = null) {
$filter = "";
$return = array();
$cluster = $this->cluster();
$session = $cluster->connect($this->keyspace);
if(isset($db_table)) {
$filter .= " WHERE db_table like '%".$db_table."%' ";
if($db_id != null) {
$filter .= " AND db_id = '".$db_id."' ALLOW FILTERING";
}
}
$query = new Cassandra\SimpleStatement("SELECT * FROM ".$this->keyspace.".log $filter;");
$result = $session->executeAsync($query);
$rows = $result->get();
更多细节可以在这里找到。
https://docs.datastax.com/en/developer/php-driver/1.2/api/Cassandra/Cluster/class.Builder/
使用withConnectTimeout可以帮助避免TimeoutException
$cluster = $this->cluster()->withConnectTimeout(60);
您可以增加超时值虽然您通过更改/etc/cassandra/cassandra.yaml中的值更新了更多
类似于以下 -
sudo nano /etc/cassandra/cassandra.yaml(用于编辑cassandra.yaml文件)
# How long the coordinator should wait for read operations to complete
read_request_timeout_in_ms: 50000
# How long the coordinator should wait for seq or index scans to complete
range_request_timeout_in_ms: 100000
# How long the coordinator should wait for writes to complete
write_request_timeout_in_ms: 20000
# How long the coordinator should wait for counter writes to complete
counter_write_request_timeout_in_ms: 50000
# How long a coordinator should continue to retry a CAS operation
# that contends with other proposals for the same row
cas_contention_timeout_in_ms: 10000
# How long the coordinator should wait for truncates to complete
# (This can be much longer, because unless auto_snapshot is disabled
# we need to flush first so we can snapshot before removing the data.)
truncate_request_timeout_in_ms: 600000
# The default timeout for other, miscellaneous operations
request_timeout_in_ms: 100000
# How long before a node logs slow queries. Select queries that take longer than
# this timeout to execute, will generate an aggregated log message, so that slow queries
# can be identified. Set this value to zero to disable slow query logging.
slow_query_log_timeout_in_ms: 5000
好吧,我可以列举10个不同的原因,你的代码不起作用,但这不是我的目标,我想要帮助你所以只是尝试一些简单的事情。
____好_____
<?
$cluster = Cassandra::cluster()
->withContactPoints('127.0.0.1')
->build();
$session = $cluster->connect("your_k_space");
$table_list = $session->execute("SELECT table_name FROM system_schema.tables WHERE keyspace_name = 'your_k_space'");
if (in_array($db_table, $table_list)) {
$options = array('arguments' => [$db_table,$db_id]);
$result = $session->execute("SELECT * FROM ? WHERE db_id = ? ALLOW FILTERING",$options);
foreach ($result as $key => $value) print_r($value);
}else{
die('table not found');
}