You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by David Replogle <da...@steketeegreiner.com> on 2010/11/08 19:55:28 UTC

Cassandra With C++

I'm using Cassandra 0.7beta3 and it's running on localhost:9160 and Python
works with it just fine. So, I go to run C++ against the system and I get:

TTransportException: No more data to read.

I did the thrift --gen cpp interface/cassandra.thrift in my 0.7beta3 folder
then included those files in the C++ code, and it builds fine, and runs.

It bombs out on the set_keyspace call... the code is short so I'll paste it
here (not counting includes and using calls):

---

const string host("localhost");
const int port= 9160;

int main()
{
    try {
        boost::shared_ptr<TSocket> socket(new TSocket(host, port));
        boost::shared_ptr<TTransport> transport(new
TBufferedTransport(socket));
        boost::shared_ptr<TProtocol> protocol(new
TBinaryProtocol(transport));

        CassandraClient client(protocol);
        transport->open();

        string version;
        client.set_keyspace("Crawldata");
        transport->close();
    } catch (apache::thrift::transport::TTransportException &tte) {
        cout << "TTransportException: " << tte.what() << endl;
    }
    return 0;
}

---

It throws this same error with a series of other calls. This is probably
(hopefully) something stupid I'm missing. Do I really need to run the C++
server component (which seems superfluous since it's not actually my
Cassandra instance) as detailed here:
http://wiki.apache.org/thrift/ThriftUsageC%2B%2B

-- 
David Replogle | Senior Programmer Analyst

Catalyst SGC
44 Grandville Ave SW, Ste. 270, Grand Rapids, MI 49503
Office: 616.855.5522 x204 | Mobile: 616.293.2788

Re: Cassandra With C++

Posted by Tyler Hobbs <ty...@riptano.com>.
TFramedTransport needs to be used with Cassandra 0.7.  Buffered transport
was the default for 0.6, but it was changed to framed for 0.7.

- Tyler

On Mon, Nov 8, 2010 at 12:55 PM, David Replogle <
david.replogle@steketeegreiner.com> wrote:

> I'm using Cassandra 0.7beta3 and it's running on localhost:9160 and Python
> works with it just fine. So, I go to run C++ against the system and I get:
>
> TTransportException: No more data to read.
>
> I did the thrift --gen cpp interface/cassandra.thrift in my 0.7beta3 folder
> then included those files in the C++ code, and it builds fine, and runs.
>
> It bombs out on the set_keyspace call... the code is short so I'll paste it
> here (not counting includes and using calls):
>
> ---
>
> const string host("localhost");
> const int port= 9160;
>
> int main()
> {
>     try {
>         boost::shared_ptr<TSocket> socket(new TSocket(host, port));
>         boost::shared_ptr<TTransport> transport(new
> TBufferedTransport(socket));
>         boost::shared_ptr<TProtocol> protocol(new
> TBinaryProtocol(transport));
>
>         CassandraClient client(protocol);
>         transport->open();
>
>         string version;
>         client.set_keyspace("Crawldata");
>         transport->close();
>     } catch (apache::thrift::transport::TTransportException &tte) {
>         cout << "TTransportException: " << tte.what() << endl;
>     }
>     return 0;
> }
>
> ---
>
> It throws this same error with a series of other calls. This is probably
> (hopefully) something stupid I'm missing. Do I really need to run the C++
> server component (which seems superfluous since it's not actually my
> Cassandra instance) as detailed here:
> http://wiki.apache.org/thrift/ThriftUsageC%2B%2B
>
> --
> David Replogle | Senior Programmer Analyst
>
> Catalyst SGC
> 44 Grandville Ave SW, Ste. 270, Grand Rapids, MI 49503
> Office: 616.855.5522 x204 | Mobile: 616.293.2788
>
>

Re: Cassandra With C++

Posted by David Replogle <da...@steketeegreiner.com>.
Needed to run schematool, and it clicked into place. Command for future
reference:

bin/schematool localhost 8080 import

--David

On Mon, Nov 8, 2010 at 3:03 PM, Aaron Morton <aa...@thelastpickle.com>wrote:

> Check that the nodes all have the same view of the schema, for a small
> cluster it's easy enough to just use jconsole.
>
> Then turn up the logging and see what happening server side.
>
> Aaron
>
>
> On 09 Nov, 2010,at 08:55 AM, David Replogle <
> david.replogle@steketeegreiner.com> wrote:
>
> With Python I'm using the fantastic Pycassa library by Tyler (who
> previously responded). Now I'm getting a "keyspace does not exist error"
> which I'm trying to sort out right now... because, well, it does exist. I
> added the following catch:
>
>  catch (org::apache::cassandra::InvalidRequestException &ire) {
>         cout << "InvalidRequestException: " << ire.why << endl;
>     }
>
> And now I get this output:
>
> InvalidRequestException: Keyspace does not exist
>
> On Mon, Nov 8, 2010 at 2:32 PM, Aaron Morton <aa...@thelastpickle.com>wrote:
>
>> Not sure if this is the problem but the default in 0.7* is to used framed
>> transport, which means creating the TFramedTransport rather than
>> TBufferedTransport
>>
>> How are you connecting with python? Is it using framed transport?
>>
>> Hope that helps.
>> Aaron
>>
>>
>> On 09 Nov, 2010,at 07:55 AM, David Replogle <
>> david.replogle@steketeegreiner.com> wrote:
>>
>> I'm using Cassandra 0.7beta3 and it's running on localhost:9160 and Python
>> works with it just fine. So, I go to run C++ against the system and I get:
>>
>> TTransportException: No more data to read.
>>
>> I did the thrift --gen cpp interface/cassandra.thrift in my 0.7beta3
>> folder
>> then included those files in the C++ code, and it builds fine, and runs.
>>
>> It bombs out on the set_keyspace call... the code is short so I'll paste
>> it here (not counting includes and using calls):
>>
>> ---
>>
>> const string host("localhost");
>> const int port= 9160;
>>
>> int main()
>> {
>>     try {
>>         boost::shared_ptr<TSocket> socket(new TSocket(host, port));
>>         boost::shared_ptr<TTransport> transport(new
>> TBufferedTransport(socket));
>>         boost::shared_ptr<TProtocol> protocol(new
>> TBinaryProtocol(transport));
>>
>>         CassandraClient client(protocol);
>>         transport->open();
>>
>>         string version;
>>         client.set_keyspace("Crawldata");
>>         transport->close();
>>     } catch (apache::thrift::transport::TTransportException &tte) {
>>         cout << "TTransportException: " << tte.what() << endl;
>>     }
>>     return 0;
>> }
>>
>> ---
>>
>> It throws this same error with a series of other calls. This is probably
>> (hopefully) something stupid I'm missing. Do I really need to run the C++
>> server component (which seems superfluous since it's not actually my
>> Cassandra instance) as detailed here:
>> http://wiki.apacheorg/thrift/ThriftUsageC%2B%2B<http://wiki.apache.org/thrift/ThriftUsageC%2B%2B>
>>
>> --
>> David Replogle | Senior Programmer Analyst
>>
>> Catalyst SGC
>> 44 Grandville Ave SW, Ste. 270, Grand Rapids, MI 49503
>> Office: 616.855.5522 x204 | Mobile: 616.293.2788
>>
>>
>
>
> --
> David Replogle | Senior Programmer Analyst
>
> Catalyst SGC
> 44 Grandville Ave SW, Ste. 270, Grand Rapids, MI 49503
> Office: 616.855.5522 x204 | Mobile: 616.293.2788
>
>


-- 
David Replogle | Senior Programmer Analyst

Catalyst SGC
44 Grandville Ave SW, Ste. 270, Grand Rapids, MI 49503
Office: 616.855.5522 x204 | Mobile: 616.293.2788

Re: Cassandra With C++

Posted by Aaron Morton <aa...@thelastpickle.com>.
Check that the nodes all have the same view of the schema, for a small cluster it's easy enough to just use jconsole. 

Then turn up the logging and see what happening server side. 

Aaron
 

On 09 Nov, 2010,at 08:55 AM, David Replogle <da...@steketeegreiner.com> wrote:

With Python I'm using the fantastic Pycassa library by Tyler (who previously responded). Now I'm getting a "keyspace does not exist error" which I'm trying to sort out right now... because, well, it does exist. I added the following catch:

 catch (org::apache::cassandra::InvalidRequestException &ire) {
        cout << "InvalidRequestException: " << ire.why << endl;
    }

And now I get this output:

InvalidRequestException: Keyspace does not exist

On Mon, Nov 8, 2010 at 2:32 PM, Aaron Morton <aa...@thelastpickle.com> wrote:
Not sure if this is the problem but the default in 0.7* is to used framed transport, which means creating the TFramedTransport rather than TBufferedTransport 

How are you connecting with python? Is it using framed transport?

Hope that helps. 
Aaron


On 09 Nov, 2010,at 07:55 AM, David Replogle <da...@steketeegreiner.com> wrote:

I'm using Cassandra 0.7beta3 and it's running on localhost:9160 and Python works with it just fine. So, I go to run C++ against the system and I get:

TTransportException: No more data to read.

I did the thrift --gen cpp interface/cassandra.thrift in my 0.7beta3 folder
then included those files in the C++ code, and it builds fine, and runs.

It bombs out on the set_keyspace call... the code is short so I'll paste it here (not counting includes and using calls):

---

const string host("localhost");
const int port= 9160;

int main()
{
    try {
        boost::shared_ptr<TSocket> socket(new TSocket(host, port));
        boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket));
        boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));

        CassandraClient client(protocol);
        transport->open();

        string version;
        client.set_keyspace("Crawldata");
        transport->close();
    } catch (apache::thrift::transport::TTransportException &tte) {
        cout << "TTransportException: " << tte.what() << endl;
    }
    return 0;
}

---

It throws this same error with a series of other calls. This is probably (hopefully) something stupid I'm missing. Do I really need to run the C++ server component (which seems superfluous since it's not actually my Cassandra instance) as detailed here: http://wiki.apacheorg/thrift/ThriftUsageC%2B%2B

-- 
David Replogle | Senior Programmer Analyst

Catalyst SGC
44 Grandville Ave SW, Ste. 270, Grand Rapids, MI 49503
Office: 616.855.5522 x204 | Mobile: 616.293.2788




-- 
David Replogle | Senior Programmer Analyst

Catalyst SGC
44 Grandville Ave SW, Ste. 270, Grand Rapids, MI 49503
Office: 616.855.5522 x204 | Mobile: 616.293.2788


Re: Cassandra With C++

Posted by David Replogle <da...@steketeegreiner.com>.
With Python I'm using the fantastic Pycassa library by Tyler (who previously
responded). Now I'm getting a "keyspace does not exist error" which I'm
trying to sort out right now... because, well, it does exist. I added the
following catch:

 catch (org::apache::cassandra::InvalidRequestException &ire) {
        cout << "InvalidRequestException: " << ire.why << endl;
    }

And now I get this output:

InvalidRequestException: Keyspace does not exist

On Mon, Nov 8, 2010 at 2:32 PM, Aaron Morton <aa...@thelastpickle.com>wrote:

> Not sure if this is the problem but the default in 0.7* is to used framed
> transport, which means creating the TFramedTransport rather than
> TBufferedTransport.
>
> How are you connecting with python? Is it using framed transport?
>
> Hope that helps.
> Aaron
>
>
> On 09 Nov, 2010,at 07:55 AM, David Replogle <
> david.replogle@steketeegreiner.com> wrote:
>
> I'm using Cassandra 0.7beta3 and it's running on localhost:9160 and Python
> works with it just fine. So, I go to run C++ against the system and I get:
>
> TTransportException: No more data to read.
>
> I did the thrift --gen cpp interface/cassandra.thrift in my 0.7beta3 folder
> then included those files in the C++ code, and it builds fine, and runs.
>
> It bombs out on the set_keyspace call... the code is short so I'll paste it
> here (not counting includes and using calls):
>
> ---
>
> const string host("localhost");
> const int port= 9160;
>
> int main()
> {
>     try {
>         boost::shared_ptr<TSocket> socket(new TSocket(host, port));
>         boost::shared_ptr<TTransport> transport(new
> TBufferedTransport(socket));
>         boost::shared_ptr<TProtocol> protocol(new
> TBinaryProtocol(transport));
>
>         CassandraClient client(protocol);
>         transport->open();
>
>         string version;
>         client.set_keyspace("Crawldata");
>         transport->close();
>     } catch (apache::thrift::transport::TTransportException &tte) {
>         cout << "TTransportException: " << tte.what() << endl;
>     }
>     return 0;
> }
>
> ---
>
> It throws this same error with a series of other calls. This is probably
> (hopefully) something stupid I'm missing. Do I really need to run the C++
> server component (which seems superfluous since it's not actually my
> Cassandra instance) as detailed here:
> http://wiki.apacheorg/thrift/ThriftUsageC%2B%2B<http://wiki.apache.org/thrift/ThriftUsageC%2B%2B>
>
> --
> David Replogle | Senior Programmer Analyst
>
> Catalyst SGC
> 44 Grandville Ave SW, Ste. 270, Grand Rapids, MI 49503
> Office: 616.855.5522 x204 | Mobile: 616.293.2788
>
>


-- 
David Replogle | Senior Programmer Analyst

Catalyst SGC
44 Grandville Ave SW, Ste. 270, Grand Rapids, MI 49503
Office: 616.855.5522 x204 | Mobile: 616.293.2788

Re: Cassandra With C++

Posted by Aaron Morton <aa...@thelastpickle.com>.
Not sure if this is the problem but the default in 0.7* is to used framed transport, which means creating the TFramedTransport rather than TBufferedTransport. 

How are you connecting with python? Is it using framed transport?

Hope that helps. 
Aaron

On 09 Nov, 2010,at 07:55 AM, David Replogle <da...@steketeegreiner.com> wrote:

I'm using Cassandra 0.7beta3 and it's running on localhost:9160 and Python works with it just fine. So, I go to run C++ against the system and I get:

TTransportException: No more data to read.

I did the thrift --gen cpp interface/cassandra.thrift in my 0.7beta3 folder
then included those files in the C++ code, and it builds fine, and runs.

It bombs out on the set_keyspace call... the code is short so I'll paste it here (not counting includes and using calls):

---

const string host("localhost");
const int port= 9160;

int main()
{
    try {
        boost::shared_ptr<TSocket> socket(new TSocket(host, port));
        boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket));
        boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));

        CassandraClient client(protocol);
        transport->open();

        string version;
        client.set_keyspace("Crawldata");
        transport->close();
    } catch (apache::thrift::transport::TTransportException &tte) {
        cout << "TTransportException: " << tte.what() << endl;
    }
    return 0;
}

---

It throws this same error with a series of other calls. This is probably (hopefully) something stupid I'm missing. Do I really need to run the C++ server component (which seems superfluous since it's not actually my Cassandra instance) as detailed here: http://wiki.apache.org/thrift/ThriftUsageC%2B%2B

-- 
David Replogle | Senior Programmer Analyst

Catalyst SGC
44 Grandville Ave SW, Ste. 270, Grand Rapids, MI 49503
Office: 616.855.5522 x204 | Mobile: 616.293.2788