Orange-OpenSource / YACassandraPDO

Cassandra PDO Driver fork
Apache License 2.0
85 stars 32 forks source link

Connecting to a cluster with one of the nodes being down #55

Closed martin-marinov-securax closed 10 years ago

martin-marinov-securax commented 10 years ago

Hi,

I have two cassandra nodes set up in a cluster: 192.168.188.31 192.168.188.32

I have set the replication factor of my test keyspace to 2: CREATE KEYSPACE mykeyspace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 2 };

When I stop the cassandra service on the second node (192.168.188.32) : root@ubuntu:~# service cassandra stop

I can still connect to the first one (192.168.188.31) via cqlsh and select all the data.

However I can not connect via PHP.

My code:

<?php $dsn = "cassandra:host=192.168.188.31;port=9160;host=192.168.188.32;port=9160;"; $db = new \PDO($dsn);

It says: Fatal error: Uncaught exception 'PDOException' with message 'CQLSTATE[08006] [8] TTransportException: Transport not open' in /path/to/file

Is the PDO supposed to handle this or am I supposed to detect unavailable nodes in all datacenters and clusters I intend to connect to ?

Skunnyk commented 10 years ago

Use ',' instead of ';' between hosts declarations.

martin-marinov-securax commented 10 years ago

That worked. Thank you.