示例#1
0
 public function __construct($keyspace, $server, $credentials, $framed_transport, $send_timeout, $recv_timeout)
 {
     $host = $server['host'];
     $port = $server['port'];
     $socket = new TSocket($host, $port);
     if ($send_timeout) {
         $socket->setSendTimeout($send_timeout);
     }
     if ($recv_timeout) {
         $socket->setRecvTimeout($recv_timeout);
     }
     if ($framed_transport) {
         $transport = new TFramedTransport($socket, true, true);
     } else {
         $transport = new TBufferedTransport($socket, 1024, 1024);
     }
     $client = new CassandraClient(new TBinaryProtocolAccelerated($transport));
     $transport->open();
     # TODO check API major version match
     $client->set_keyspace($keyspace);
     if ($credentials) {
         $request = cassandra_AuthenticationRequest($credentials);
         $client->login($request);
     }
     $this->keyspace = $keyspace;
     $this->client = $client;
     $this->transport = $transport;
 }
 public function __construct($keyspace, $server, $credentials, $framed_transport, $send_timeout, $recv_timeout)
 {
     $host = $server['host'];
     $port = $server['port'];
     $socket = new TSocket($host, $port);
     if ($send_timeout) {
         $socket->setSendTimeout($send_timeout);
     }
     if ($recv_timeout) {
         $socket->setRecvTimeout($recv_timeout);
     }
     if ($framed_transport) {
         $transport = new TFramedTransport($socket, true, true);
     } else {
         $transport = new TBufferedTransport($socket, 1024, 1024);
     }
     $client = new CassandraClient(new TBinaryProtocolAccelerated($transport));
     $transport->open();
     # TODO check API major version match
     $server_version = explode(".", $client->describe_version());
     $server_version = $server_version[0];
     if ($server_version < self::LOWEST_COMPATIBLE_VERSION) {
         $ver = self::LOWEST_COMPATIBLE_VERSION;
         throw new IncompatbleAPIException("The server's API version is too " . "low to be comptible with phpcassa (server: {$server_version}, " . "lowest compatible version: {$ver})");
     }
     $client->set_keyspace($keyspace);
     if ($credentials) {
         $request = cassandra_AuthenticationRequest($credentials);
         $client->login($request);
     }
     $this->keyspace = $keyspace;
     $this->client = $client;
     $this->transport = $transport;
 }