I got it working by going to the thrift nightly build (Jenkins Thrift build 
#181).

Thanks to everyone who emailed me suggestions.

----- Original Message -----
From: "Anthony Molinaro" <[email protected]>
To: "Konstantin Naryshkin" <[email protected]>
Cc: [email protected]
Sent: Wednesday, June 29, 2011 6:04:37 PM
Subject: Re: Getting a bad argument exception in Erlang

What does your schema, access and password lists look like?  My understanding
was that login was required, but it looks like it might not be.  I don't
see your version failing with R14B02, cassandra 0.8.0 release and thrift
HEAD.  Does it fail first time thrift_client:call is invoked or after
some number (you could just add an io:format ("~p~n",[X]) into the
fun to find out.

If I have a chance I'll try to get a version of R13B04 somewhere and test
with that.

-Anthony

On Mon, Jun 27, 2011 at 03:55:30PM -0500, Konstantin  Naryshkin wrote:
> Thanks for the text case Anthony. I reporoduced my error using your test case 
> (slightly modified to fit my schema). In case it matters, I am running 
> Cassandra 0.8.0, Thrift 0.6.1, and Erlang R13B04. Thrift types was generated 
> by me using cassandra.thrift that I got out of the cassandra-0.8.0 tag in the 
> Cassandra repo.
> 
> The test that I ran is:
> 
> #cat test_cassandra_client.erl 
> -module(test_cassandra_client).
> 
> -export([my_test/0]).
> 
> -include("cassandra_types.hrl").
> 
> my_test() ->
>   {ok, Client0} =
>     thrift_client_util:new ("kon", 9160,
>                             cassandra_thrift, [{framed,true}]),
>         
>   %D0 = dict:new(),
>   %Auth =
>   %  #authenticationRequest {
>   %    credentials = dict:store ("dilbert","nomoovertime",D0)
>   %  },
>   %{Client1, {ok,ok}} =
>   %  thrift_client:call (Client0, login, [Auth]),
>   {Client2, {ok,ok}} =
>     thrift_client:call (Client0, set_keyspace, ["ipdr"]),
>   lists:foldl ( fun (I, C0) ->
>                   X = integer_to_list (I),
>                   {C1, {ok,ok}} =
>                     thrift_client:call (C0,
>                                         insert,
>                                         [ lists:append (["key",X]),
>                                           #columnParent {
>                                             column_family="Standard1"
>                                           },
>                                           #column {
>                                             name = lists:append (["name",X]),
>                                             value = lists:append (["val",X]),
>                                             timestamp = 1
>                                           },
>                                           ?cassandra_ConsistencyLevel_ONE
>                                         ]),
>                   C1
>                 end,
>                 Client2,                
>                 lists:seq(1,1000) ).
> 
> 
> My output is:
> 
> Erlang R13B04 (erts-5.7.5) [source] [64-bit] [smp:2:2] [rq:2] 
> [async-threads:0] [kernel-poll:false]
> 
> Eshell V5.7.5  (abort with ^G)
> 1>  c('test_cassandra_client').
> {ok,test_cassandra_client}
> 2> test_cassandra_client:my_test().
> ** exception error: bad argument
>      in function  iolist_size/1
>         called as 
> iolist_size([[[[[[[[[[[[[[[[[[[[[[[],<<128,1,0,1>>],<<0,0,0,6>>],
>                                                   <<"insert">>],
>                                                  <<0,0,0,0>>],
>                                                 <<"\v">>],
>                                                <<0,1>>],
>                                               <<0,0,0,4>>],
>                                              <<"key1">>],
>                                             <<"\f">>],
>                                            <<0,2>>],
>                                           <<"\v">>],
>                                          <<0,3>>],
>                                         <<0,0,0,9>>],
>                                        <<"Standard1">>],
>                                       <<0>>],
>                                      <<"\f">>],
>                                     <<0,3>>],
>                                    {{struct,[{1,string},{2,string},{3,i64}]},
>                                     {column,"name1","val1",1,undefined}}],
>                                   <<"\b">>],
>                                  <<0,4>>],
>                                 <<0,0,0,1>>],
>                                <<0>>])
>      in call from thrift_framed_transport:flush/1
>      in call from thrift_transport:flush/1
>      in call from thrift_binary_protocol:flush_transport/1
>      in call from thrift_protocol:flush_transport/1
>      in call from thrift_client:send_function_call/3
>      in call from thrift_client:call/3
>      in call from test_cassandra_client:'-my_test/0-fun-0-'/2
> 
> 
> ----- Original Message -----
> From: "Anthony Molinaro" <[email protected]>
> To: [email protected]
> Cc: "Konstantin Naryshkin" <[email protected]>
> Sent: Monday, June 27, 2011 5:39:00 PM
> Subject: Re: Getting a bad argument exception in Erlang
> 
> 
> Hi Konstantin,
> 
>    I attempted to reproduce, but am unable to, I used this code
> 
> -module(test_cassandra_client).
> 
> -export([my_test/0]).
> 
> -include("cassandra_types.hrl").
> 
> my_test() ->
>   {ok, Client0} =
>     thrift_client_util:new ("127.0.0.1", 9160,
>                             cassandra_thrift, [{framed,true}]),
>         
>   D0 = dict:new(),
>   Auth =
>     #authenticationRequest {
>       credentials = dict:store ("dilbert","nomoovertime",D0)
>     },
>   {Client1, {ok,ok}} =
>     thrift_client:call (Client0, login, [Auth]),
>   {Client2, {ok,ok}} =
>     thrift_client:call (Client1, set_keyspace, ["Keyspace1"]),
>   lists:foldl ( fun (I, C0) ->
>                   X = integer_to_list (I),
>                   {C1, {ok,ok}} =
>                     thrift_client:call (C0,
>                                         insert,
>                                         [ lists:append (["key",X]),
>                                           #columnParent {
>                                             column_family="Standard1"
>                                           },
>                                           #column {
>                                             name = lists:append (["name",X]),
>                                             value = lists:append (["val",X]),
>                                             timestamp = 1
>                                           },
>                                           ?cassandra_ConsistencyLevel_ONE
>                                         ]),
>                   C1
>                 end,
>                 Client2,                
>                 lists:seq(1,1000) ).    
> 
> To just insert 1000 entries into the schema defined in schema-sample.txt,
> and everything seems to work fine.  If you could provide a failing test
> it would allow me to dig a little deeper.
> 
> Thanks,
> 
> -Anthony
> 
> 
> On Tue, Jun 21, 2011 at 10:03:27AM -0500, Konstantin  Naryshkin wrote:
> > I am new to both Thrift and Erlang but need to uses Thrift to get an Erlang 
> > application to write to Cassandra. The relevant method from 
> > cassandra.thrift is: 
> > void insert(1:required binary key, 
> > 2:required ColumnParent column_parent, 
> > 3:required Column column, 
> > 4:required ConsistencyLevel consistency_level=ConsistencyLevel.ONE) 
> > throws (1:InvalidRequestException ire, 2:UnavailableException ue, 
> > 3:TimedOutException te), 
> > 
> > The full cassandra.thrift can be found at: 
> > https://svn.apache.org/repos/asf/cassandra/tags/cassandra-0.8.0/interface/cassandra.thrift
> >  
> > 
> > I am trying to run the following command via the erl cli: 
> > {C30,R30} =thrift_client:call( C29, 'insert', [ "keyz", ColPar1, Col4, 
> > 6]).). 
> > 
> > Where C29 is a #tclient returned by a previous call, ColPar1 is a 
> > #columnParent, and Col4 is a #column. The call throws a badarg exception 
> > of: 
> > ** exception error: bad argument 
> > in function iolist_size/1 
> > called as 
> > iolist_size([[[[[[[[[[[[[[[[[[[[[[[[[[[],<<128,...>>],<<0,0,...>>], 
> > <<"insert">>], 
> > <<0,0,0,0>>], 
> > <<"\v">>], 
> > <<0,1>>], 
> > <<0,0,0,4>>], 
> > <<"keyz">>], 
> > <<"\f">>], 
> > <<0,2>>], 
> > <<"\v">>], 
> > <<0,3>>], 
> > <<0,0,0,10>>], 
> > <<"ipdr_usage">>], 
> > <<"\v">>], 
> > <<0,4>>], 
> > <<0,0,0,5>>], 
> > <<"suppy">>], 
> > <<0>>], 
> > <<"\f">>], 
> > <<0,3>>], 
> > {{struct,[{1,string},{2,string},{3,i64}]}, 
> > #column{name = <<"haha">>,value = <<"0_0">>, 
> > timestamp = 1235234234234234234,ttl = undefined}}], 
> > <<"\b">>], 
> > <<0,4>>], 
> > <<0,0,0,6>>], 
> > <<0>>]) 
> > in call from thrift_framed_transport:flush/1 
> > in call from thrift_transport:flush/1 
> > in call from thrift_binary_protocol:flush_transport/1 
> > in call from thrift_protocol:flush_transport/1 
> > in call from thrift_client:send_function_call/3 
> > in call from thrift_client:call/3 
> > 
> > Any idea about what I may be doing wrong? Is there any information that I 
> > forgot to include? 
> > 
> > Thanks in advance, 
> > 
> > Konstantin 
> 
> -- 
> ------------------------------------------------------------------------
> Anthony Molinaro                           <[email protected]>

-- 
------------------------------------------------------------------------
Anthony Molinaro                           <[email protected]>

Reply via email to