I am working on Cassandra and Thrift. I understand that these are very early libraries, and at some point they (undoubtedly change).
I used the following link to help configure my C # code to write and read to my Cassandra server and from my server (which I have an instance of Ubuntu Server in the local VirtualBox). I confirmed that the trivial read / write function works.
In case of a problem, the following method occurs (which was generated for me using the sarge.definition file that comes with Cassandra):
public void send_get_count(string keyspace, string key, ColumnParent column_parent, ConsistencyLevel consistency_level)
Here is my installation code:
TTransport _transport; TProtocol _protocol; Cassandra.Client _client; public Test() { _transport = new TSocket("192.168.56.101", 9160); _protocol = new TBinaryProtocol(_transport); _client = new Cassandra.Client(_protocol); }
My calling code looks like this:
public void GetAllBlogEntries() { var timestamp = DateTime.Now.Millisecond; var keyspace = "Keyspace1"; var utf8Encoding = System.Text.Encoding.UTF8; var columnParent = new ColumnParent() {Column_family = "BlogEntries"}; var predicate = new SlicePredicate() { Slice_range = new SliceRange() { Start = new byte[0], Finish = new byte[0], Count = 10, Reversed = false } }; var results = _client.get_range_slice(keyspace, columnParent, predicate, "", "", 5, ConsistencyLevel.ONE); foreach(var slice in results) { Console.WriteLine("Found Key: {0}", slice.Key); foreach(var resultColumn in slice.Columns) { var column = resultColumn.Column; Console.WriteLine("\tName: {0}, value: {1}", utf8Encoding.GetString(column.Name), utf8Encoding.GetString(column.Value)); } } }
The first line of this method is where I get my exception:
oprot_.WriteMessageBegin(new TMessage("get_count", TMessageType.Call, seqid_));
And here is the exception:
Thrift.Transport.TTransportException: cannot write to the output stream on Thrift.Transport.TStreamTransport.Write (Byte [] buf, Int32 off, Int32 len) in Thrift.Protocol.TBinaryProtocol.WriteI32 (Int32 i32) in Thrift.Protocol.TBinaryP .WriteMessageBegin (TMessage message) in Apache.Cassandra.Cassandra.Client.send_get_range_slice (String keyspace, ColumnParent column_parent, Predicate SlicePredicate, String start_key, String finish_key, Int32 row_count, ConsistencyLevel consistency_level) in Cassandra. Cassandra.Client.get_range_slice (String keyspace, ColumnParent column_parent, Predicate SlicePredicate, String start_key, String finish_key, Int32 row_count, ConsistencyLevel consistency_level) in Cassandra.cs: line 335 in CassandraDemo.Models.Test.GetAll.Tet.GetABls.Tet.GetABls 212 in CassandraDemo.Tests.Models.TestTest.Test_GetAllBlogEntries_Success () in TestTe st.cs: line 42
Any ideas?