Return-Path: X-Original-To: apmail-cassandra-user-archive@www.apache.org Delivered-To: apmail-cassandra-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 15436782C for ; Thu, 28 Jul 2011 09:30:43 +0000 (UTC) Received: (qmail 52965 invoked by uid 500); 28 Jul 2011 09:30:40 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 50555 invoked by uid 500); 28 Jul 2011 09:30:30 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 50010 invoked by uid 99); 28 Jul 2011 09:30:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Jul 2011 09:30:22 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [85.15.227.50] (HELO mail.zabbix.com) (85.15.227.50) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Jul 2011 09:30:14 +0000 Received: from [192.168.3.24] (unknown [192.168.3.24]) by mail.zabbix.com (Postfix) with ESMTP id 2DFCF3325AF for ; Thu, 28 Jul 2011 12:32:28 +0300 (EEST) Message-ID: <4E312C12.705@zabbix.com> Date: Thu, 28 Jul 2011 12:29:54 +0300 From: Aleksandrs Saveljevs User-Agent: Mozilla/5.0 (X11; Linux i686; rv:5.0) Gecko/20110624 Thunderbird/5.0 MIME-Version: 1.0 To: user@cassandra.apache.org Subject: Problems using Thrift API in C Content-Type: multipart/mixed; boundary="------------060304030001040700070206" X-Virus-Checked: Checked by ClamAV on apache.org This is a multi-part message in MIME format. --------------060304030001040700070206 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Dear all, We are considering using Cassandra for storing gathered data in Zabbix (see https://support.zabbix.com/browse/ZBXNEXT-844 for more details). Because Zabbix is written in C, we are considering using Thrift API in C, too. However, we are running into problems trying to get even the basic code work. Consider the attached source code. This is essentially a rewrite of the first part of the C++ example given at http://wiki.apache.org/cassandra/ThriftExamples#C.2B-.2B- . If we run it under strace, we see that it hangs on the call to recv() when setting keyspace: $ strace -s 64 ./test ... socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3 connect(3, {sa_family=AF_INET, sin_port=htons(9160), sin_addr=inet_addr("127.0.0.1")}, 16) = 0 send(3, "\0\0\0/\200\1\0\1\0\0\0\fset_keyspace\0\0\0\0\v\0\1\0\0\0\vmy_keyspace\0", 47, 0) = 47 recv(3, ^C If we run the C++ example, it passes this step successfully. Does anybody know where the problem is? We are using Thrift 0.6.1 and Cassandra 0.8.1. Also, what is the current state of Thrift API in C? Can it be considered stable? Has anybody used it successfully? Any examples? Thanks, Aleksandrs --------------060304030001040700070206 Content-Type: text/x-csrc; name="test.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="test.c" #include #include #include #include #include #include #include "cassandra.h" int main() { ThriftSocket *tsocket; ThriftTransport *transport; ThriftBinaryProtocol *protocol2; ThriftProtocol *protocol; CassandraClient *client; g_type_init(); tsocket = g_object_new(THRIFT_TYPE_SOCKET, "hostname", "localhost", "port", 9160, NULL); transport = g_object_new(THRIFT_TYPE_FRAMED_TRANSPORT, "transport", THRIFT_TRANSPORT(tsocket), NULL); protocol2 = g_object_new(THRIFT_TYPE_BINARY_PROTOCOL, "transport", transport, NULL); protocol = THRIFT_PROTOCOL(protocol2); client = g_object_new(TYPE_CASSANDRA_CLIENT, "input_protocol", protocol, "output_protocol", protocol, NULL); thrift_framed_transport_open(transport, NULL); cassandra_client_set_keyspace(CASSANDRA_IF(client), "my_keyspace", NULL, NULL); // hangs here on recv() thrift_framed_transport_close(transport, NULL); g_object_unref(client); g_object_unref(protocol2); g_object_unref(transport); g_object_unref(tsocket); return 0; } --------------060304030001040700070206--