Problem with libcassandra

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with libcassandra

Shubham Mittal
I am trying to run below code, but it gives this error. It compiles without any errors.  Kindly help me.
(source of the code : http://posulliv.github.io/2011/02/27/libcassandra-sec-indexes/)

terminate called after throwing an instance of 'org::apache::cassandra::InvalidRequestException'
  what():  Default TException.
Aborted


#include <string.h>
#include <sstream>
#include <iostream>
#include <stdlib.h>
#include <set>
#include <string>
#include <stdio.h>
#include <vector>

#include <libcassandra/cassandra_factory.h>
#include <libcassandra/cassandra.h>
#include <libcassandra/column_family_definition.h>
#include <libcassandra/keyspace.h>
#include <libcassandra/keyspace_definition.h>

using namespace std;
using namespace libcassandra;

static string host("127.0.0.1");
static int port= 9160;

int main()
{

    CassandraFactory cf(host, port);
    tr1::shared_ptr<Cassandra> c(cf.create());

    KeyspaceDefinition ks_def;
    ks_def.setName("demo");
    c->createKeyspace(ks_def);
    
    ColumnFamilyDefinition cf_def;
    cf_def.setName("users");
    cf_def.setKeyspaceName(ks_def.getName());
    
    ColumnDefinition name_col;
    name_col.setName("full_name");
    name_col.setValidationClass("UTF8Type");
    
    ColumnDefinition sec_col;
    sec_col.setName("birth_date");
    sec_col.setValidationClass("LongType");
    sec_col.setIndexType(org::apache::cassandra::IndexType::KEYS);
    
    ColumnDefinition third_col;
    third_col.setName("state");
    third_col.setValidationClass("UTF8Type");
    third_col.setIndexType(org::apache::cassandra::IndexType::KEYS);
    
    cf_def.addColumnMetadata(name_col);
    cf_def.addColumnMetadata(sec_col);
    cf_def.addColumnMetadata(third_col);
    
    c->setKeyspace(ks_def.getName());
    c->createColumnFamily(cf_def);
    
    return 0;
}

Reply | Threaded
Open this post in threaded view
|

Re: Problem with libcassandra

Aaron Turner
Have you tried running your code in GDB to find which line is causing the error?  That would be what I'd do first.

Aaron Turner
http://synfin.net/         Twitter: @synfinatic
https://github.com/synfinatic/tcpreplay - Pcap editing and replay tools for Unix & Windows
Those who would give up essential Liberty, to purchase a little temporary
Safety, deserve neither Liberty nor Safety. 
    -- Benjamin Franklin
"carpe diem quam minimum credula postero"


On Tue, Jul 2, 2013 at 3:18 AM, Shubham Mittal <[hidden email]> wrote:
I am trying to run below code, but it gives this error. It compiles without any errors.  Kindly help me.
(source of the code : http://posulliv.github.io/2011/02/27/libcassandra-sec-indexes/)

terminate called after throwing an instance of 'org::apache::cassandra::InvalidRequestException'
  what():  Default TException.
Aborted


#include <string.h>
#include <sstream>
#include <iostream>
#include <stdlib.h>
#include <set>
#include <string>
#include <stdio.h>
#include <vector>

#include <libcassandra/cassandra_factory.h>
#include <libcassandra/cassandra.h>
#include <libcassandra/column_family_definition.h>
#include <libcassandra/keyspace.h>
#include <libcassandra/keyspace_definition.h>

using namespace std;
using namespace libcassandra;

static string host("127.0.0.1");
static int port= 9160;

int main()
{

    CassandraFactory cf(host, port);
    tr1::shared_ptr<Cassandra> c(cf.create());

    KeyspaceDefinition ks_def;
    ks_def.setName("demo");
    c->createKeyspace(ks_def);
    
    ColumnFamilyDefinition cf_def;
    cf_def.setName("users");
    cf_def.setKeyspaceName(ks_def.getName());
    
    ColumnDefinition name_col;
    name_col.setName("full_name");
    name_col.setValidationClass("UTF8Type");
    
    ColumnDefinition sec_col;
    sec_col.setName("birth_date");
    sec_col.setValidationClass("LongType");
    sec_col.setIndexType(org::apache::cassandra::IndexType::KEYS);
    
    ColumnDefinition third_col;
    third_col.setName("state");
    third_col.setValidationClass("UTF8Type");
    third_col.setIndexType(org::apache::cassandra::IndexType::KEYS);
    
    cf_def.addColumnMetadata(name_col);
    cf_def.addColumnMetadata(sec_col);
    cf_def.addColumnMetadata(third_col);
    
    c->setKeyspace(ks_def.getName());
    c->createColumnFamily(cf_def);
    
    return 0;
}


Reply | Threaded
Open this post in threaded view
|

Re: Problem with libcassandra

Jeremiah Jordan-3
In reply to this post by Shubham Mittal
If you are using 1.2, I would checkout https://github.com/mstump/libcql

-Jeremiah

On Jul 2, 2013, at 5:18 AM, Shubham Mittal <[hidden email]> wrote:

I am trying to run below code, but it gives this error. It compiles without any errors.  Kindly help me.
(source of the code : http://posulliv.github.io/2011/02/27/libcassandra-sec-indexes/)

terminate called after throwing an instance of 'org::apache::cassandra::InvalidRequestException'
  what():  Default TException.
Aborted


#include <string.h>
#include <sstream>
#include <iostream>
#include <stdlib.h>
#include <set>
#include <string>
#include <stdio.h>
#include <vector>

#include <libcassandra/cassandra_factory.h>
#include <libcassandra/cassandra.h>
#include <libcassandra/column_family_definition.h>
#include <libcassandra/keyspace.h>
#include <libcassandra/keyspace_definition.h>

using namespace std;
using namespace libcassandra;

static string host("127.0.0.1");
static int port= 9160;

int main()
{

    CassandraFactory cf(host, port);
    tr1::shared_ptr<Cassandra> c(cf.create());

    KeyspaceDefinition ks_def;
    ks_def.setName("demo");
    c->createKeyspace(ks_def);
    
    ColumnFamilyDefinition cf_def;
    cf_def.setName("users");
    cf_def.setKeyspaceName(ks_def.getName());
    
    ColumnDefinition name_col;
    name_col.setName("full_name");
    name_col.setValidationClass("UTF8Type");
    
    ColumnDefinition sec_col;
    sec_col.setName("birth_date");
    sec_col.setValidationClass("LongType");
    sec_col.setIndexType(org::apache::cassandra::IndexType::KEYS);
    
    ColumnDefinition third_col;
    third_col.setName("state");
    third_col.setValidationClass("UTF8Type");
    third_col.setIndexType(org::apache::cassandra::IndexType::KEYS);
    
    cf_def.addColumnMetadata(name_col);
    cf_def.addColumnMetadata(sec_col);
    cf_def.addColumnMetadata(third_col);
    
    c->setKeyspace(ks_def.getName());
    c->createColumnFamily(cf_def);
    
    return 0;
}


Reply | Threaded
Open this post in threaded view
|

Re: Problem with libcassandra

Shubham Mittal
This is the gdb output

[Thread debugging using libthread_db enabled]
terminate called after throwing an instance of 'org::apache::cassandra::InvalidRequestException'
  what():  Default TException.

Program received signal SIGABRT, Aborted.
0x00007ffff70a0b25 in raise () from /lib/libc.so.6




On Wed, Jul 3, 2013 at 8:38 AM, Jeremiah D Jordan <[hidden email]> wrote:
If you are using 1.2, I would checkout https://github.com/mstump/libcql

-Jeremiah

On Jul 2, 2013, at 5:18 AM, Shubham Mittal <[hidden email]> wrote:

I am trying to run below code, but it gives this error. It compiles without any errors.  Kindly help me.
(source of the code : http://posulliv.github.io/2011/02/27/libcassandra-sec-indexes/)

terminate called after throwing an instance of 'org::apache::cassandra::InvalidRequestException'
  what():  Default TException.
Aborted


#include <string.h>
#include <sstream>
#include <iostream>
#include <stdlib.h>
#include <set>
#include <string>
#include <stdio.h>
#include <vector>

#include <libcassandra/cassandra_factory.h>
#include <libcassandra/cassandra.h>
#include <libcassandra/column_family_definition.h>
#include <libcassandra/keyspace.h>
#include <libcassandra/keyspace_definition.h>

using namespace std;
using namespace libcassandra;

static string host("127.0.0.1");
static int port= 9160;

int main()
{

    CassandraFactory cf(host, port);
    tr1::shared_ptr<Cassandra> c(cf.create());

    KeyspaceDefinition ks_def;
    ks_def.setName("demo");
    c->createKeyspace(ks_def);
    
    ColumnFamilyDefinition cf_def;
    cf_def.setName("users");
    cf_def.setKeyspaceName(ks_def.getName());
    
    ColumnDefinition name_col;
    name_col.setName("full_name");
    name_col.setValidationClass("UTF8Type");
    
    ColumnDefinition sec_col;
    sec_col.setName("birth_date");
    sec_col.setValidationClass("LongType");
    sec_col.setIndexType(org::apache::cassandra::IndexType::KEYS);
    
    ColumnDefinition third_col;
    third_col.setName("state");
    third_col.setValidationClass("UTF8Type");
    third_col.setIndexType(org::apache::cassandra::IndexType::KEYS);
    
    cf_def.addColumnMetadata(name_col);
    cf_def.addColumnMetadata(sec_col);
    cf_def.addColumnMetadata(third_col);
    
    c->setKeyspace(ks_def.getName());
    c->createColumnFamily(cf_def);
    
    return 0;
}



Reply | Threaded
Open this post in threaded view
|

Re: Problem with libcassandra

Shubham Mittal
no Jordan, the cassandra version I have is Cassandra 1.1.12 


On Wed, Jul 3, 2013 at 5:21 PM, Shubham Mittal <[hidden email]> wrote:
This is the gdb output

[Thread debugging using libthread_db enabled]
terminate called after throwing an instance of 'org::apache::cassandra::InvalidRequestException'
  what():  Default TException.

Program received signal SIGABRT, Aborted.
0x00007ffff70a0b25 in raise () from /lib/libc.so.6




On Wed, Jul 3, 2013 at 8:38 AM, Jeremiah D Jordan <[hidden email]> wrote:
If you are using 1.2, I would checkout https://github.com/mstump/libcql

-Jeremiah

On Jul 2, 2013, at 5:18 AM, Shubham Mittal <[hidden email]> wrote:

I am trying to run below code, but it gives this error. It compiles without any errors.  Kindly help me.
(source of the code : http://posulliv.github.io/2011/02/27/libcassandra-sec-indexes/)

terminate called after throwing an instance of 'org::apache::cassandra::InvalidRequestException'
  what():  Default TException.
Aborted


#include <string.h>
#include <sstream>
#include <iostream>
#include <stdlib.h>
#include <set>
#include <string>
#include <stdio.h>
#include <vector>

#include <libcassandra/cassandra_factory.h>
#include <libcassandra/cassandra.h>
#include <libcassandra/column_family_definition.h>
#include <libcassandra/keyspace.h>
#include <libcassandra/keyspace_definition.h>

using namespace std;
using namespace libcassandra;

static string host("127.0.0.1");
static int port= 9160;

int main()
{

    CassandraFactory cf(host, port);
    tr1::shared_ptr<Cassandra> c(cf.create());

    KeyspaceDefinition ks_def;
    ks_def.setName("demo");
    c->createKeyspace(ks_def);
    
    ColumnFamilyDefinition cf_def;
    cf_def.setName("users");
    cf_def.setKeyspaceName(ks_def.getName());
    
    ColumnDefinition name_col;
    name_col.setName("full_name");
    name_col.setValidationClass("UTF8Type");
    
    ColumnDefinition sec_col;
    sec_col.setName("birth_date");
    sec_col.setValidationClass("LongType");
    sec_col.setIndexType(org::apache::cassandra::IndexType::KEYS);
    
    ColumnDefinition third_col;
    third_col.setName("state");
    third_col.setValidationClass("UTF8Type");
    third_col.setIndexType(org::apache::cassandra::IndexType::KEYS);
    
    cf_def.addColumnMetadata(name_col);
    cf_def.addColumnMetadata(sec_col);
    cf_def.addColumnMetadata(third_col);
    
    c->setKeyspace(ks_def.getName());
    c->createColumnFamily(cf_def);
    
    return 0;
}




Reply | Threaded
Open this post in threaded view
|

Re: Problem with libcassandra

Shubham Mittal
Hey,

I found out that the problem is caused by this line :
c->createKeyspace(ks_def);

because the below code works fine.

#include <string.h>
#include <sstream>
#include <iostream>
#include <stdlib.h>
#include <set>
#include <string>
#include <stdio.h>
#include <vector>

#include <libcassandra/cassandra_factory.h>
#include <libcassandra/cassandra.h>
#include <libcassandra/column_family_definition.h>
#include <libcassandra/keyspace.h>
#include <libcassandra/keyspace_definition.h>

using namespace std;
using namespace libcassandra;

static string host("127.0.0.1");
static int port= 9160;

int main()
{

    CassandraFactory cf(host, port);
    tr1::shared_ptr<Cassandra> c(cf.create());

    KeyspaceDefinition ks_def;
    ks_def.setName("demo");
    return 0;
}


On Wed, Jul 3, 2013 at 5:22 PM, Shubham Mittal <[hidden email]> wrote:
no Jordan, the cassandra version I have is Cassandra 1.1.12 


On Wed, Jul 3, 2013 at 5:21 PM, Shubham Mittal <[hidden email]> wrote:
This is the gdb output

[Thread debugging using libthread_db enabled]
terminate called after throwing an instance of 'org::apache::cassandra::InvalidRequestException'
  what():  Default TException.

Program received signal SIGABRT, Aborted.
0x00007ffff70a0b25 in raise () from /lib/libc.so.6




On Wed, Jul 3, 2013 at 8:38 AM, Jeremiah D Jordan <[hidden email]> wrote:
If you are using 1.2, I would checkout https://github.com/mstump/libcql

-Jeremiah

On Jul 2, 2013, at 5:18 AM, Shubham Mittal <[hidden email]> wrote:

I am trying to run below code, but it gives this error. It compiles without any errors.  Kindly help me.
(source of the code : http://posulliv.github.io/2011/02/27/libcassandra-sec-indexes/)

terminate called after throwing an instance of 'org::apache::cassandra::InvalidRequestException'
  what():  Default TException.
Aborted


#include <string.h>
#include <sstream>
#include <iostream>
#include <stdlib.h>
#include <set>
#include <string>
#include <stdio.h>
#include <vector>

#include <libcassandra/cassandra_factory.h>
#include <libcassandra/cassandra.h>
#include <libcassandra/column_family_definition.h>
#include <libcassandra/keyspace.h>
#include <libcassandra/keyspace_definition.h>

using namespace std;
using namespace libcassandra;

static string host("127.0.0.1");
static int port= 9160;

int main()
{

    CassandraFactory cf(host, port);
    tr1::shared_ptr<Cassandra> c(cf.create());

    KeyspaceDefinition ks_def;
    ks_def.setName("demo");
    c->createKeyspace(ks_def);
    
    ColumnFamilyDefinition cf_def;
    cf_def.setName("users");
    cf_def.setKeyspaceName(ks_def.getName());
    
    ColumnDefinition name_col;
    name_col.setName("full_name");
    name_col.setValidationClass("UTF8Type");
    
    ColumnDefinition sec_col;
    sec_col.setName("birth_date");
    sec_col.setValidationClass("LongType");
    sec_col.setIndexType(org::apache::cassandra::IndexType::KEYS);
    
    ColumnDefinition third_col;
    third_col.setName("state");
    third_col.setValidationClass("UTF8Type");
    third_col.setIndexType(org::apache::cassandra::IndexType::KEYS);
    
    cf_def.addColumnMetadata(name_col);
    cf_def.addColumnMetadata(sec_col);
    cf_def.addColumnMetadata(third_col);
    
    c->setKeyspace(ks_def.getName());
    c->createColumnFamily(cf_def);
    
    return 0;
}





Reply | Threaded
Open this post in threaded view
|

Re: Problem with libcassandra

axs-mvd
That repo for libcassandra works for cassandra 0.7.x due to changes in the thrift interface we have faced some problems in the past.

May be you can take a look to my fork of libcassandra https://github.com/axs-mvd/libcassandra that we are using with cassandra 1.1.11. 

Besides that, I recommend that you use the cassandra-cli to create keyspaces and column families because that operations fails if some of your nodes is down, so by using cassandra-cli you force, in a way, the supervision of a human being :D.

good luck!


On Wed, Jul 3, 2013 at 9:12 AM, Shubham Mittal <[hidden email]> wrote:
Hey,

I found out that the problem is caused by this line :
c->createKeyspace(ks_def);

because the below code works fine.

#include <string.h>
#include <sstream>
#include <iostream>
#include <stdlib.h>
#include <set>
#include <string>
#include <stdio.h>
#include <vector>

#include <libcassandra/cassandra_factory.h>
#include <libcassandra/cassandra.h>
#include <libcassandra/column_family_definition.h>
#include <libcassandra/keyspace.h>
#include <libcassandra/keyspace_definition.h>

using namespace std;
using namespace libcassandra;

static string host("127.0.0.1");
static int port= 9160;

int main()
{

    CassandraFactory cf(host, port);
    tr1::shared_ptr<Cassandra> c(cf.create());

    KeyspaceDefinition ks_def;
    ks_def.setName("demo");
    return 0;
}


On Wed, Jul 3, 2013 at 5:22 PM, Shubham Mittal <[hidden email]> wrote:
no Jordan, the cassandra version I have is Cassandra 1.1.12 


On Wed, Jul 3, 2013 at 5:21 PM, Shubham Mittal <[hidden email]> wrote:
This is the gdb output

[Thread debugging using libthread_db enabled]
terminate called after throwing an instance of 'org::apache::cassandra::InvalidRequestException'
  what():  Default TException.

Program received signal SIGABRT, Aborted.
0x00007ffff70a0b25 in raise () from /lib/libc.so.6




On Wed, Jul 3, 2013 at 8:38 AM, Jeremiah D Jordan <[hidden email]> wrote:
If you are using 1.2, I would checkout https://github.com/mstump/libcql

-Jeremiah

On Jul 2, 2013, at 5:18 AM, Shubham Mittal <[hidden email]> wrote:

I am trying to run below code, but it gives this error. It compiles without any errors.  Kindly help me.
(source of the code : http://posulliv.github.io/2011/02/27/libcassandra-sec-indexes/)

terminate called after throwing an instance of 'org::apache::cassandra::InvalidRequestException'
  what():  Default TException.
Aborted


#include <string.h>
#include <sstream>
#include <iostream>
#include <stdlib.h>
#include <set>
#include <string>
#include <stdio.h>
#include <vector>

#include <libcassandra/cassandra_factory.h>
#include <libcassandra/cassandra.h>
#include <libcassandra/column_family_definition.h>
#include <libcassandra/keyspace.h>
#include <libcassandra/keyspace_definition.h>

using namespace std;
using namespace libcassandra;

static string host("127.0.0.1");
static int port= 9160;

int main()
{

    CassandraFactory cf(host, port);
    tr1::shared_ptr<Cassandra> c(cf.create());

    KeyspaceDefinition ks_def;
    ks_def.setName("demo");
    c->createKeyspace(ks_def);
    
    ColumnFamilyDefinition cf_def;
    cf_def.setName("users");
    cf_def.setKeyspaceName(ks_def.getName());
    
    ColumnDefinition name_col;
    name_col.setName("full_name");
    name_col.setValidationClass("UTF8Type");
    
    ColumnDefinition sec_col;
    sec_col.setName("birth_date");
    sec_col.setValidationClass("LongType");
    sec_col.setIndexType(org::apache::cassandra::IndexType::KEYS);
    
    ColumnDefinition third_col;
    third_col.setName("state");
    third_col.setValidationClass("UTF8Type");
    third_col.setIndexType(org::apache::cassandra::IndexType::KEYS);
    
    cf_def.addColumnMetadata(name_col);
    cf_def.addColumnMetadata(sec_col);
    cf_def.addColumnMetadata(third_col);
    
    c->setKeyspace(ks_def.getName());
    c->createColumnFamily(cf_def);
    
    return 0;
}






Reply | Threaded
Open this post in threaded view
|

Re: Problem with libcassandra

Shubham Mittal
hi Alexis,

Even if I create keyspaces, column families using cassandra-cli, the column creation and insertion work will still need thrift calls.


On Wed, Jul 3, 2013 at 6:05 PM, Alexis Rodríguez <[hidden email]> wrote:
That repo for libcassandra works for cassandra 0.7.x due to changes in the thrift interface we have faced some problems in the past.

May be you can take a look to my fork of libcassandra https://github.com/axs-mvd/libcassandra that we are using with cassandra 1.1.11. 

Besides that, I recommend that you use the cassandra-cli to create keyspaces and column families because that operations fails if some of your nodes is down, so by using cassandra-cli you force, in a way, the supervision of a human being :D.

good luck!


On Wed, Jul 3, 2013 at 9:12 AM, Shubham Mittal <[hidden email]> wrote:
Hey,

I found out that the problem is caused by this line :
c->createKeyspace(ks_def);

because the below code works fine.

#include <string.h>
#include <sstream>
#include <iostream>
#include <stdlib.h>
#include <set>
#include <string>
#include <stdio.h>
#include <vector>

#include <libcassandra/cassandra_factory.h>
#include <libcassandra/cassandra.h>
#include <libcassandra/column_family_definition.h>
#include <libcassandra/keyspace.h>
#include <libcassandra/keyspace_definition.h>

using namespace std;
using namespace libcassandra;

static string host("127.0.0.1");
static int port= 9160;

int main()
{

    CassandraFactory cf(host, port);
    tr1::shared_ptr<Cassandra> c(cf.create());

    KeyspaceDefinition ks_def;
    ks_def.setName("demo");
    return 0;
}


On Wed, Jul 3, 2013 at 5:22 PM, Shubham Mittal <[hidden email]> wrote:
no Jordan, the cassandra version I have is Cassandra 1.1.12 


On Wed, Jul 3, 2013 at 5:21 PM, Shubham Mittal <[hidden email]> wrote:
This is the gdb output

[Thread debugging using libthread_db enabled]
terminate called after throwing an instance of 'org::apache::cassandra::InvalidRequestException'
  what():  Default TException.

Program received signal SIGABRT, Aborted.
0x00007ffff70a0b25 in raise () from /lib/libc.so.6




On Wed, Jul 3, 2013 at 8:38 AM, Jeremiah D Jordan <[hidden email]> wrote:
If you are using 1.2, I would checkout https://github.com/mstump/libcql

-Jeremiah

On Jul 2, 2013, at 5:18 AM, Shubham Mittal <[hidden email]> wrote:

I am trying to run below code, but it gives this error. It compiles without any errors.  Kindly help me.
(source of the code : http://posulliv.github.io/2011/02/27/libcassandra-sec-indexes/)

terminate called after throwing an instance of 'org::apache::cassandra::InvalidRequestException'
  what():  Default TException.
Aborted


#include <string.h>
#include <sstream>
#include <iostream>
#include <stdlib.h>
#include <set>
#include <string>
#include <stdio.h>
#include <vector>

#include <libcassandra/cassandra_factory.h>
#include <libcassandra/cassandra.h>
#include <libcassandra/column_family_definition.h>
#include <libcassandra/keyspace.h>
#include <libcassandra/keyspace_definition.h>

using namespace std;
using namespace libcassandra;

static string host("127.0.0.1");
static int port= 9160;

int main()
{

    CassandraFactory cf(host, port);
    tr1::shared_ptr<Cassandra> c(cf.create());

    KeyspaceDefinition ks_def;
    ks_def.setName("demo");
    c->createKeyspace(ks_def);
    
    ColumnFamilyDefinition cf_def;
    cf_def.setName("users");
    cf_def.setKeyspaceName(ks_def.getName());
    
    ColumnDefinition name_col;
    name_col.setName("full_name");
    name_col.setValidationClass("UTF8Type");
    
    ColumnDefinition sec_col;
    sec_col.setName("birth_date");
    sec_col.setValidationClass("LongType");
    sec_col.setIndexType(org::apache::cassandra::IndexType::KEYS);
    
    ColumnDefinition third_col;
    third_col.setName("state");
    third_col.setValidationClass("UTF8Type");
    third_col.setIndexType(org::apache::cassandra::IndexType::KEYS);
    
    cf_def.addColumnMetadata(name_col);
    cf_def.addColumnMetadata(sec_col);
    cf_def.addColumnMetadata(third_col);
    
    c->setKeyspace(ks_def.getName());
    c->createColumnFamily(cf_def);
    
    return 0;
}







Reply | Threaded
Open this post in threaded view
|

Re: Problem with libcassandra

axs-mvd
Shubham, 

You are right, my point is that with non schema-update thrift calls you can tune the consistency level used. 

bye.


On Wed, Jul 3, 2013 at 10:10 AM, Shubham Mittal <[hidden email]> wrote:
hi Alexis,

Even if I create keyspaces, column families using cassandra-cli, the column creation and insertion work will still need thrift calls.


On Wed, Jul 3, 2013 at 6:05 PM, Alexis Rodríguez <[hidden email]> wrote:
That repo for libcassandra works for cassandra 0.7.x due to changes in the thrift interface we have faced some problems in the past.

May be you can take a look to my fork of libcassandra https://github.com/axs-mvd/libcassandra that we are using with cassandra 1.1.11. 

Besides that, I recommend that you use the cassandra-cli to create keyspaces and column families because that operations fails if some of your nodes is down, so by using cassandra-cli you force, in a way, the supervision of a human being :D.

good luck!


On Wed, Jul 3, 2013 at 9:12 AM, Shubham Mittal <[hidden email]> wrote:
Hey,

I found out that the problem is caused by this line :
c->createKeyspace(ks_def);

because the below code works fine.

#include <string.h>
#include <sstream>
#include <iostream>
#include <stdlib.h>
#include <set>
#include <string>
#include <stdio.h>
#include <vector>

#include <libcassandra/cassandra_factory.h>
#include <libcassandra/cassandra.h>
#include <libcassandra/column_family_definition.h>
#include <libcassandra/keyspace.h>
#include <libcassandra/keyspace_definition.h>

using namespace std;
using namespace libcassandra;

static string host("127.0.0.1");
static int port= 9160;

int main()
{

    CassandraFactory cf(host, port);
    tr1::shared_ptr<Cassandra> c(cf.create());

    KeyspaceDefinition ks_def;
    ks_def.setName("demo");
    return 0;
}


On Wed, Jul 3, 2013 at 5:22 PM, Shubham Mittal <[hidden email]> wrote:
no Jordan, the cassandra version I have is Cassandra 1.1.12 


On Wed, Jul 3, 2013 at 5:21 PM, Shubham Mittal <[hidden email]> wrote:
This is the gdb output

[Thread debugging using libthread_db enabled]
terminate called after throwing an instance of 'org::apache::cassandra::InvalidRequestException'
  what():  Default TException.

Program received signal SIGABRT, Aborted.
0x00007ffff70a0b25 in raise () from /lib/libc.so.6




On Wed, Jul 3, 2013 at 8:38 AM, Jeremiah D Jordan <[hidden email]> wrote:
If you are using 1.2, I would checkout https://github.com/mstump/libcql

-Jeremiah

On Jul 2, 2013, at 5:18 AM, Shubham Mittal <[hidden email]> wrote:

I am trying to run below code, but it gives this error. It compiles without any errors.  Kindly help me.
(source of the code : http://posulliv.github.io/2011/02/27/libcassandra-sec-indexes/)

terminate called after throwing an instance of 'org::apache::cassandra::InvalidRequestException'
  what():  Default TException.
Aborted


#include <string.h>
#include <sstream>
#include <iostream>
#include <stdlib.h>
#include <set>
#include <string>
#include <stdio.h>
#include <vector>

#include <libcassandra/cassandra_factory.h>
#include <libcassandra/cassandra.h>
#include <libcassandra/column_family_definition.h>
#include <libcassandra/keyspace.h>
#include <libcassandra/keyspace_definition.h>

using namespace std;
using namespace libcassandra;

static string host("127.0.0.1");
static int port= 9160;

int main()
{

    CassandraFactory cf(host, port);
    tr1::shared_ptr<Cassandra> c(cf.create());

    KeyspaceDefinition ks_def;
    ks_def.setName("demo");
    c->createKeyspace(ks_def);
    
    ColumnFamilyDefinition cf_def;
    cf_def.setName("users");
    cf_def.setKeyspaceName(ks_def.getName());
    
    ColumnDefinition name_col;
    name_col.setName("full_name");
    name_col.setValidationClass("UTF8Type");
    
    ColumnDefinition sec_col;
    sec_col.setName("birth_date");
    sec_col.setValidationClass("LongType");
    sec_col.setIndexType(org::apache::cassandra::IndexType::KEYS);
    
    ColumnDefinition third_col;
    third_col.setName("state");
    third_col.setValidationClass("UTF8Type");
    third_col.setIndexType(org::apache::cassandra::IndexType::KEYS);
    
    cf_def.addColumnMetadata(name_col);
    cf_def.addColumnMetadata(sec_col);
    cf_def.addColumnMetadata(third_col);
    
    c->setKeyspace(ks_def.getName());
    c->createColumnFamily(cf_def);
    
    return 0;
}