Re: Using Cassandra via the Erlang Thrift Client API (HOW ??)

2010-03-04 Thread Jonathan Ellis
On Thu, Mar 4, 2010 at 11:27 AM, J T  wrote:
> Hi All,
> Many thanks for the responses. You helped enormously. I was in fact talking
> to the wrong port. It should have been 9160 rather than .
> I just assumed that the port the cassandra server displayed when starting up
> was the one I should be talking to, my bad. I should have read the config
> file.

Thanks for the feedback, I've made this more clear in
https://issues.apache.org/jira/browse/CASSANDRA-849 on the 0.6 branch.

> Once I have something working I'll write a new post back with a couple of
> examples here to help future newbies on how to talk to cassandra from
> erlang, since those examples are not present on the cassandra/thrift wiki as
> far as I can tell.

That would be great!


Re: Using Cassandra via the Erlang Thrift Client API (HOW ??)

2010-03-04 Thread Brandon Williams
On Thu, Mar 4, 2010 at 11:27 AM, J T  wrote:

> Once I have something working I'll write a new post back with a couple of
> examples here to help future newbies on how to talk to cassandra from
> erlang, since those examples are not present on the cassandra/thrift wiki as
> far as I can tell.
>

Could you update the wiki instead? :)
http://wiki.apache.org/cassandra/ClientExamples

-Brandon


Re: Using Cassandra via the Erlang Thrift Client API (HOW ??)

2010-03-04 Thread J T
Hi All,

Many thanks for the responses. You helped enormously. I was in fact talking
to the wrong port. It should have been 9160 rather than .
I just assumed that the port the cassandra server displayed when starting up
was the one I should be talking to, my bad. I should have read the config
file.

Once I have something working I'll write a new post back with a couple of
examples here to help future newbies on how to talk to cassandra from
erlang, since those examples are not present on the cassandra/thrift wiki as
far as I can tell.

Thanks,

Jason

On Thu, Mar 4, 2010 at 1:34 PM,  wrote:

> I think you want port 9160, not ... dt_socket != thrift.
>
> Jeremey.
>
> On Mar 4, 2010, at 2:02 AM, ext J T wrote:
>
> > Hi,
> >
> > I've been trying to piece together some notion of how to use cassandra
> from an erlang client.
> >
> > So far I have managed to come up with the following, but it doesn't work.
> >
> > Unfortunately there does not seem to be any decent documentation on the
> subject I can find with googling so I'm hoping some more experienced members
> of this mailing list can point out what I'm doing wrong.
> >
> > I'm using cassandra 0.5, and I think the latest version of thrift.
> >
> > I generated the thrift erlang client code using:
> >
> > $ thrift -r --gen erl cassandra.thrift
> >
> > And compiled and copied that into my ebin area, along with the rest of
> the thrift erlc library code.
> >
> > I start cassandra using its default config bin/cassandra -f and there are
> no apparent errors:
> >
> > $ bin/cassandra -f
> > Listening for transport dt_socket at address: 
> > INFO - Sampling index for
> /var/lib/cassandra/data/system/LocationInfo-9-Data.db
> > INFO - Replaying /var/lib/cassandra/commitlog/CommitLog-1267655779083.log
> > INFO - Log replay complete
> > INFO - Saved Token found: 14135473040163431347303685581151939
> > INFO - Starting up server gossip
> > INFO - Cassandra starting up...
> >
> > then after a few seconds, it displays this:
> >
> > Debugger failed to attach: timeout during handshake
> >
> > Then from an erl vm I try the following:
> >
> > rr(cassandra_types).
> > {ok, C} = thrift_client:start_link("localhost",, cassandra_thrift).
> > thrift_client:call( C,
> >   'insert',
> >   [ "Keyspace1",
> > "1",
> > #columnPath{column_family="Standard1",
> column="email"},
> > "t...@example.com",
> > 1,
> > 1
> > ] ).
> >
> > Unfortunately, although I get a cassandra_thrift client connection, the
> call to insert fails with :
> >
> > =ERROR REPORT 4-Mar-2010::07:57:50 ===
> > ** Generic server <0.333.0> terminating
> > ** Last message in was {call,insert,
> > ["Keyspace1","1",
> >  {columnPath,"Standard1",undefined,"email"},
> >  "t...@example.com >",1,1]}
> > ** When Server state == {state,cassandra_thrift,
> > {protocol,thrift_binary_protocol,
> >  {binary_protocol,
> >
> {transport,thrift_buffered_transport,<0.334.0>},
> >   true,true}},
> > 0}
> > ** Reason for termination ==
> > ** {{case_clause,{error,closed}},
> >[{thrift_client,read_result,3},
> > {thrift_client,catch_function_exceptions,2},
> > {thrift_client,handle_call,3},
> > {gen_server,handle_msg,5},
> > {proc_lib,init_p_do_apply,3}]}
> > ** exception exit: {case_clause,{error,closed}}
> > in function  thrift_client:read_result/3
> > in call from thrift_client:catch_function_exceptions/2
> > in call from thrift_client:handle_call/3
> > in call from gen_server:handle_msg/5
> > in call from proc_lib:init_p_do_apply/3
> >
> > Cassandra itself reports nothing.
> >
> > -- JT.
>
>


Re: Using Cassandra via the Erlang Thrift Client API (HOW ??)

2010-03-04 Thread Jeremey.Barrett
I think you want port 9160, not ... dt_socket != thrift.

Jeremey.

On Mar 4, 2010, at 2:02 AM, ext J T wrote:

> Hi,
> 
> I've been trying to piece together some notion of how to use cassandra from 
> an erlang client.
> 
> So far I have managed to come up with the following, but it doesn't work.
> 
> Unfortunately there does not seem to be any decent documentation on the 
> subject I can find with googling so I'm hoping some more experienced members 
> of this mailing list can point out what I'm doing wrong.
> 
> I'm using cassandra 0.5, and I think the latest version of thrift.
> 
> I generated the thrift erlang client code using:
> 
> $ thrift -r --gen erl cassandra.thrift
> 
> And compiled and copied that into my ebin area, along with the rest of the 
> thrift erlc library code.
> 
> I start cassandra using its default config bin/cassandra -f and there are no 
> apparent errors:
> 
> $ bin/cassandra -f
> Listening for transport dt_socket at address: 
> INFO - Sampling index for 
> /var/lib/cassandra/data/system/LocationInfo-9-Data.db
> INFO - Replaying /var/lib/cassandra/commitlog/CommitLog-1267655779083.log
> INFO - Log replay complete
> INFO - Saved Token found: 14135473040163431347303685581151939
> INFO - Starting up server gossip
> INFO - Cassandra starting up...
> 
> then after a few seconds, it displays this:
> 
> Debugger failed to attach: timeout during handshake
> 
> Then from an erl vm I try the following:
> 
> rr(cassandra_types).
> {ok, C} = thrift_client:start_link("localhost",, cassandra_thrift).
> thrift_client:call( C,
>   'insert',
>   [ "Keyspace1",
> "1",
> #columnPath{column_family="Standard1", column="email"},
> "t...@example.com",
> 1,
> 1
> ] ).
> 
> Unfortunately, although I get a cassandra_thrift client connection, the call 
> to insert fails with :
> 
> =ERROR REPORT 4-Mar-2010::07:57:50 ===
> ** Generic server <0.333.0> terminating
> ** Last message in was {call,insert,
> ["Keyspace1","1",
>  {columnPath,"Standard1",undefined,"email"},
>  "t...@example.com",1,1]}
> ** When Server state == {state,cassandra_thrift,
> {protocol,thrift_binary_protocol,
>  {binary_protocol,
>   {transport,thrift_buffered_transport,<0.334.0>},
>   true,true}},
> 0}
> ** Reason for termination ==
> ** {{case_clause,{error,closed}},
>[{thrift_client,read_result,3},
> {thrift_client,catch_function_exceptions,2},
> {thrift_client,handle_call,3},
> {gen_server,handle_msg,5},
> {proc_lib,init_p_do_apply,3}]}
> ** exception exit: {case_clause,{error,closed}}
> in function  thrift_client:read_result/3
> in call from thrift_client:catch_function_exceptions/2
> in call from thrift_client:handle_call/3
> in call from gen_server:handle_msg/5
> in call from proc_lib:init_p_do_apply/3
> 
> Cassandra itself reports nothing.
> 
> -- JT.



Re: Using Cassandra via the Erlang Thrift Client API (HOW ??)

2010-03-04 Thread Jonathan Ellis
You probably need to switch the server to framed thrift mode.

On Thu, Mar 4, 2010 at 2:02 AM, J T  wrote:
> Hi,
> I've been trying to piece together some notion of how to use cassandra from
> an erlang client.
> So far I have managed to come up with the following, but it doesn't work.
> Unfortunately there does not seem to be any decent documentation on the
> subject I can find with googling so I'm hoping some more experienced members
> of this mailing list can point out what I'm doing wrong.
> I'm using cassandra 0.5, and I think the latest version of thrift.
> I generated the thrift erlang client code using:
> $ thrift -r --gen erl cassandra.thrift
> And compiled and copied that into my ebin area, along with the rest of the
> thrift erlc library code.
> I start cassandra using its default config bin/cassandra -f and there are no
> apparent errors:
> $ bin/cassandra -f
> Listening for transport dt_socket at address: 
> INFO - Sampling index for
> /var/lib/cassandra/data/system/LocationInfo-9-Data.db
> INFO - Replaying /var/lib/cassandra/commitlog/CommitLog-1267655779083.log
> INFO - Log replay complete
> INFO - Saved Token found: 14135473040163431347303685581151939
> INFO - Starting up server gossip
> INFO - Cassandra starting up...
> then after a few seconds, it displays this:
> Debugger failed to attach: timeout during handshake
> Then from an erl vm I try the following:
> rr(cassandra_types).
> {ok, C} = thrift_client:start_link("localhost",, cassandra_thrift).
> thrift_client:call( C,
>                    'insert',
>                    [ "Keyspace1",
>                      "1",
>                      #columnPath{column_family="Standard1", column="email"},
>                      "t...@example.com",
>                      1,
>                      1
>                      ] ).
> Unfortunately, although I get a cassandra_thrift client connection, the call
> to insert fails with :
> =ERROR REPORT 4-Mar-2010::07:57:50 ===
> ** Generic server <0.333.0> terminating
> ** Last message in was {call,insert,
>                              ["Keyspace1","1",
>                               {columnPath,"Standard1",undefined,"email"},
>                               "t...@example.com",1,1]}
> ** When Server state == {state,cassandra_thrift,
>                          {protocol,thrift_binary_protocol,
>                           {binary_protocol,
>                            {transport,thrift_buffered_transport,<0.334.0>},
>                            true,true}},
>                          0}
> ** Reason for termination ==
> ** {{case_clause,{error,closed}},
>     [{thrift_client,read_result,3},
>      {thrift_client,catch_function_exceptions,2},
>      {thrift_client,handle_call,3},
>      {gen_server,handle_msg,5},
>      {proc_lib,init_p_do_apply,3}]}
> ** exception exit: {case_clause,{error,closed}}
>      in function  thrift_client:read_result/3
>      in call from thrift_client:catch_function_exceptions/2
>      in call from thrift_client:handle_call/3
>      in call from gen_server:handle_msg/5
>      in call from proc_lib:init_p_do_apply/3
> Cassandra itself reports nothing.
> -- JT.


Using Cassandra via the Erlang Thrift Client API (HOW ??)

2010-03-04 Thread J T
Hi,

I've been trying to piece together some notion of how to use cassandra from
an erlang client.

So far I have managed to come up with the following, but it doesn't work.

Unfortunately there does not seem to be any decent documentation on the
subject I can find with googling so I'm hoping some more experienced members
of this mailing list can point out what I'm doing wrong.

I'm using cassandra 0.5, and I think the latest version of thrift.

I generated the thrift erlang client code using:

$ thrift -r --gen erl cassandra.thrift

And compiled and copied that into my ebin area, along with the rest of the
thrift erlc library code.

I start cassandra using its default config bin/cassandra -f and there are no
apparent errors:

$ bin/cassandra -f
Listening for transport dt_socket at address: 
INFO - Sampling index for
/var/lib/cassandra/data/system/LocationInfo-9-Data.db
INFO - Replaying /var/lib/cassandra/commitlog/CommitLog-1267655779083.log
INFO - Log replay complete
INFO - Saved Token found: 14135473040163431347303685581151939
INFO - Starting up server gossip
INFO - Cassandra starting up...

then after a few seconds, it displays this:

Debugger failed to attach: timeout during handshake

Then from an erl vm I try the following:

rr(cassandra_types).
{ok, C} = thrift_client:start_link("localhost",, cassandra_thrift).
thrift_client:call( C,
   'insert',
   [ "Keyspace1",
 "1",
 #columnPath{column_family="Standard1", column="email"},
 "t...@example.com",
 1,
 1
 ] ).

Unfortunately, although I get a cassandra_thrift client connection, the call
to insert fails with :

=ERROR REPORT 4-Mar-2010::07:57:50 ===
** Generic server <0.333.0> terminating
** Last message in was {call,insert,
 ["Keyspace1","1",
  {columnPath,"Standard1",undefined,"email"},
  "t...@example.com",1,1]}
** When Server state == {state,cassandra_thrift,
 {protocol,thrift_binary_protocol,
  {binary_protocol,
   {transport,thrift_buffered_transport,<0.334.0>},
   true,true}},
 0}
** Reason for termination ==
** {{case_clause,{error,closed}},
[{thrift_client,read_result,3},
 {thrift_client,catch_function_exceptions,2},
 {thrift_client,handle_call,3},
 {gen_server,handle_msg,5},
 {proc_lib,init_p_do_apply,3}]}
** exception exit: {case_clause,{error,closed}}
 in function  thrift_client:read_result/3
 in call from thrift_client:catch_function_exceptions/2
 in call from thrift_client:handle_call/3
 in call from gen_server:handle_msg/5
 in call from proc_lib:init_p_do_apply/3

Cassandra itself reports nothing.

-- JT.