You are viewing a plain text version of this content. The canonical link for it is here.
Posted to client-dev@cassandra.apache.org by Kwasi Gyasi - Agyei <kw...@4things.co.za> on 2011/05/27 02:17:12 UTC

php cql driver issues

Hi,

in an attempt to get my hands dirty with Cassandra I decide to participate
in driver development, but I have come across a number of
problems am unable to debug regardless of what I try.

The first issue is that the driver I developed is able to run cql commands
USE <keyspacename> CREATE KEYSPACE..., but the CREATE
COLUMNFAMILY... fails with no meaning full errors.

The same command works perfectly in Eric Evans
http://caqel.deadcafe.org/<http://www.google.com/url?sa=D&q=http://caqel.deadcafe.org/>but
in php no
success...

My Code
------------

phpCQLAutoloader::register();

$socketPool               = new TSocketPool();
$socketPool->addServer( "127.0.0.1", 9160 );
$socketPool->setDebug( true );

$framedTransport  = new TFramedTransport( $socketPool, true, true );
$bufferedProtocol =  new
TBinaryProtocolAccelerated( $framedTransport );
$cassandraClient  = new CassandraClient( $bufferedProtocol,
$bufferedProtocol );

try{

        echo "opening connection <br>";
        $framedTransport->open();

        try{

                        echo "Executing create column query <br/>";
                        //$query = "CREATE KEYSPACE southafrica WITH
strategy_options:replication_factor = 1 AND strategy_class =
'SimpleStrategy'";
                        $query  = "CREATE COLUMNFAMILY smoke (KEY text
PRIMARY KEY, monkey
text) WITH comparator = text AND default_validation = text";
                        $result = $cassandraClient->execute_cql_query(
$query ,
cassandra_Compression::NONE );

                        echo "|". print_r($result) . "|" . "<br>";

        }catch( cassandra_InvalidRequestException $exrs ){
                echo "COLUMNFAMILY error occuired -- <br> " . $exrs-
>getTraceAsString() . " <br>";

        }

                echo "closing connnection <br>";
        $framedTransport->close();

PHP Output
----------------

opening connection
Executing create column query
COLUMNFAMILY error occuired --
#0 /Volumes/DATA/Project/libs/php/phpCQL/vendor/cassandra/
cassandra.Cassandra_execute_cql_query_result.php(52): TBase-
>_read('Cassandra_execu...', Array, Object(TBinaryProtocol)) #1 /

Volumes/DATA/Project/libs/php/phpCQL/vendor/cassandra/
cassandra.Cassandra.client.php(1771):
cassandra_Cassandra_execute_cql_query_result-
>read(Object(TBinaryProtocol)) #2 /Volumes/DATA/Project/libs/php/

phpCQL/vendor/cassandra/cassandra.Cassandra.client.php(1731):
CassandraClient->recv_execute_cql_query() #3 /Volumes/DATA/Project/
libs/php/phpCQL/test/index.php(36): CassandraClient-
>execute_cql_query('CREATE COLUMNFA...', 2) #4 {main}

closing connnection
phpCQL testing...

Cassandra log output
------------------------------

DEBUG 21:00:00,507 logged out: #<User allow_all groups=[]>
DEBUG 21:00:10,673 Disseminating load info ...
DEBUG 21:00:38,796 logged out: #<User allow_all groups=[]>
DEBUG 21:01:10,674 Disseminating load info ...
DEBUG 21:02:10,674 Disseminating load info ...
DEBUG 21:03:10,676 Disseminating load info ...
basically nothing happens in Cassandra in debug mode.

I'm totally lost...

-- 
*4Things*
Multimedia and Communication | Property | Entertainment
Kwasi Owusu Gyasi - Agyei

*cell*        (+27) (0) 76 466 4488
*website *www.4things.co.za
*email     *kwasi.gyasiagyei@4things.co.za
*skype    *kwasi.gyasiagyei
*role*        Developer.Designer.Software Architect

Re: php cql driver issues

Posted by Tyler Hobbs <ty...@datastax.com>.
Are you issuing a USE KEYSPACE after you create the keyspace but before you
CREATE COLUMN FAMILY?

On Fri, May 27, 2011 at 4:14 AM, Nick Telford <ni...@gmail.com>wrote:

> Your catch block is dumping the stack trace, which tells you *where* the
> error occurred, but it doesn't tell you *which* error occurred.
>
> Add the following to your catch-block to determine the actual error: echo
> $exrs->getMessage();
>
> On an aside, I'm currently working with Dave Gardner and Courtney Robinson
> on a PHP CQL driver. It's still early days as we've not had a huge amount
> of
> time to put in to it, but if you want to help out, you're more than
> welcome.
> The base repo (for now) is http://github.com/nicktelford/php-cql
>
> Regards,
>
> Nick Telford
>
> On 27 May 2011 01:17, Kwasi Gyasi - Agyei <kwasi.gyasiagyei@4things.co.za
> >wrote:
>
> > Hi,
> >
> > in an attempt to get my hands dirty with Cassandra I decide to
> participate
> > in driver development, but I have come across a number of
> > problems am unable to debug regardless of what I try.
> >
> > The first issue is that the driver I developed is able to run cql
> commands
> > USE <keyspacename> CREATE KEYSPACE..., but the CREATE
> > COLUMNFAMILY... fails with no meaning full errors.
> >
> > The same command works perfectly in Eric Evans
> > http://caqel.deadcafe.org/<
> > http://www.google.com/url?sa=D&q=http://caqel.deadcafe.org/>but
> > in php no
> > success...
> >
> > My Code
> > ------------
> >
> > phpCQLAutoloader::register();
> >
> > $socketPool               = new TSocketPool();
> > $socketPool->addServer( "127.0.0.1", 9160 );
> > $socketPool->setDebug( true );
> >
> > $framedTransport  = new TFramedTransport( $socketPool, true, true );
> > $bufferedProtocol =  new
> > TBinaryProtocolAccelerated( $framedTransport );
> > $cassandraClient  = new CassandraClient( $bufferedProtocol,
> > $bufferedProtocol );
> >
> > try{
> >
> >        echo "opening connection <br>";
> >        $framedTransport->open();
> >
> >        try{
> >
> >                        echo "Executing create column query <br/>";
> >                        //$query = "CREATE KEYSPACE southafrica WITH
> > strategy_options:replication_factor = 1 AND strategy_class =
> > 'SimpleStrategy'";
> >                        $query  = "CREATE COLUMNFAMILY smoke (KEY text
> > PRIMARY KEY, monkey
> > text) WITH comparator = text AND default_validation = text";
> >                        $result = $cassandraClient->execute_cql_query(
> > $query ,
> > cassandra_Compression::NONE );
> >
> >                        echo "|". print_r($result) . "|" . "<br>";
> >
> >        }catch( cassandra_InvalidRequestException $exrs ){
> >                echo "COLUMNFAMILY error occuired -- <br> " . $exrs-
> > >getTraceAsString() . " <br>";
> >
> >        }
> >
> >                echo "closing connnection <br>";
> >        $framedTransport->close();
> >
> > PHP Output
> > ----------------
> >
> > opening connection
> > Executing create column query
> > COLUMNFAMILY error occuired --
> > #0 /Volumes/DATA/Project/libs/php/phpCQL/vendor/cassandra/
> > cassandra.Cassandra_execute_cql_query_result.php(52): TBase-
> > >_read('Cassandra_execu...', Array, Object(TBinaryProtocol)) #1 /
> >
> > Volumes/DATA/Project/libs/php/phpCQL/vendor/cassandra/
> > cassandra.Cassandra.client.php(1771):
> > cassandra_Cassandra_execute_cql_query_result-
> > >read(Object(TBinaryProtocol)) #2 /Volumes/DATA/Project/libs/php/
> >
> > phpCQL/vendor/cassandra/cassandra.Cassandra.client.php(1731):
> > CassandraClient->recv_execute_cql_query() #3 /Volumes/DATA/Project/
> > libs/php/phpCQL/test/index.php(36): CassandraClient-
> > >execute_cql_query('CREATE COLUMNFA...', 2) #4 {main}
> >
> > closing connnection
> > phpCQL testing...
> >
> > Cassandra log output
> > ------------------------------
> >
> > DEBUG 21:00:00,507 logged out: #<User allow_all groups=[]>
> > DEBUG 21:00:10,673 Disseminating load info ...
> > DEBUG 21:00:38,796 logged out: #<User allow_all groups=[]>
> > DEBUG 21:01:10,674 Disseminating load info ...
> > DEBUG 21:02:10,674 Disseminating load info ...
> > DEBUG 21:03:10,676 Disseminating load info ...
> > basically nothing happens in Cassandra in debug mode.
> >
> > I'm totally lost...
> >
> > --
> > *4Things*
> > Multimedia and Communication | Property | Entertainment
> > Kwasi Owusu Gyasi - Agyei
> >
> > *cell*        (+27) (0) 76 466 4488
> > *website *www.4things.co.za
> > *email     *kwasi.gyasiagyei@4things.co.za
> > *skype    *kwasi.gyasiagyei
> > *role*        Developer.Designer.Software Architect
> >
>



-- 
Tyler Hobbs
Software Engineer, DataStax <http://datastax.com/>
Maintainer of the pycassa <http://github.com/pycassa/pycassa> Cassandra
Python client library

Re: php cql driver issues

Posted by Nick Telford <ni...@gmail.com>.
Your catch block is dumping the stack trace, which tells you *where* the
error occurred, but it doesn't tell you *which* error occurred.

Add the following to your catch-block to determine the actual error: echo
$exrs->getMessage();

On an aside, I'm currently working with Dave Gardner and Courtney Robinson
on a PHP CQL driver. It's still early days as we've not had a huge amount of
time to put in to it, but if you want to help out, you're more than welcome.
The base repo (for now) is http://github.com/nicktelford/php-cql

Regards,

Nick Telford

On 27 May 2011 01:17, Kwasi Gyasi - Agyei <kw...@4things.co.za>wrote:

> Hi,
>
> in an attempt to get my hands dirty with Cassandra I decide to participate
> in driver development, but I have come across a number of
> problems am unable to debug regardless of what I try.
>
> The first issue is that the driver I developed is able to run cql commands
> USE <keyspacename> CREATE KEYSPACE..., but the CREATE
> COLUMNFAMILY... fails with no meaning full errors.
>
> The same command works perfectly in Eric Evans
> http://caqel.deadcafe.org/<
> http://www.google.com/url?sa=D&q=http://caqel.deadcafe.org/>but
> in php no
> success...
>
> My Code
> ------------
>
> phpCQLAutoloader::register();
>
> $socketPool               = new TSocketPool();
> $socketPool->addServer( "127.0.0.1", 9160 );
> $socketPool->setDebug( true );
>
> $framedTransport  = new TFramedTransport( $socketPool, true, true );
> $bufferedProtocol =  new
> TBinaryProtocolAccelerated( $framedTransport );
> $cassandraClient  = new CassandraClient( $bufferedProtocol,
> $bufferedProtocol );
>
> try{
>
>        echo "opening connection <br>";
>        $framedTransport->open();
>
>        try{
>
>                        echo "Executing create column query <br/>";
>                        //$query = "CREATE KEYSPACE southafrica WITH
> strategy_options:replication_factor = 1 AND strategy_class =
> 'SimpleStrategy'";
>                        $query  = "CREATE COLUMNFAMILY smoke (KEY text
> PRIMARY KEY, monkey
> text) WITH comparator = text AND default_validation = text";
>                        $result = $cassandraClient->execute_cql_query(
> $query ,
> cassandra_Compression::NONE );
>
>                        echo "|". print_r($result) . "|" . "<br>";
>
>        }catch( cassandra_InvalidRequestException $exrs ){
>                echo "COLUMNFAMILY error occuired -- <br> " . $exrs-
> >getTraceAsString() . " <br>";
>
>        }
>
>                echo "closing connnection <br>";
>        $framedTransport->close();
>
> PHP Output
> ----------------
>
> opening connection
> Executing create column query
> COLUMNFAMILY error occuired --
> #0 /Volumes/DATA/Project/libs/php/phpCQL/vendor/cassandra/
> cassandra.Cassandra_execute_cql_query_result.php(52): TBase-
> >_read('Cassandra_execu...', Array, Object(TBinaryProtocol)) #1 /
>
> Volumes/DATA/Project/libs/php/phpCQL/vendor/cassandra/
> cassandra.Cassandra.client.php(1771):
> cassandra_Cassandra_execute_cql_query_result-
> >read(Object(TBinaryProtocol)) #2 /Volumes/DATA/Project/libs/php/
>
> phpCQL/vendor/cassandra/cassandra.Cassandra.client.php(1731):
> CassandraClient->recv_execute_cql_query() #3 /Volumes/DATA/Project/
> libs/php/phpCQL/test/index.php(36): CassandraClient-
> >execute_cql_query('CREATE COLUMNFA...', 2) #4 {main}
>
> closing connnection
> phpCQL testing...
>
> Cassandra log output
> ------------------------------
>
> DEBUG 21:00:00,507 logged out: #<User allow_all groups=[]>
> DEBUG 21:00:10,673 Disseminating load info ...
> DEBUG 21:00:38,796 logged out: #<User allow_all groups=[]>
> DEBUG 21:01:10,674 Disseminating load info ...
> DEBUG 21:02:10,674 Disseminating load info ...
> DEBUG 21:03:10,676 Disseminating load info ...
> basically nothing happens in Cassandra in debug mode.
>
> I'm totally lost...
>
> --
> *4Things*
> Multimedia and Communication | Property | Entertainment
> Kwasi Owusu Gyasi - Agyei
>
> *cell*        (+27) (0) 76 466 4488
> *website *www.4things.co.za
> *email     *kwasi.gyasiagyei@4things.co.za
> *skype    *kwasi.gyasiagyei
> *role*        Developer.Designer.Software Architect
>