2012-04-02 8 views
1

の接続中の例外Thrift 0.8を使用してCassandra 1.0.8のクライアントを生成しました。私は次の例を試しました。 transport.open()を通過するが、しかし、私はdescribe_keyspaceすることはできませんかset_keyspaceThrift 0.8、Cassandra 1.0.8およびC#

TTransport transport = new TBufferedTransport(new TSocket("localhost", 9160)); 
      TProtocol protocol = new TBinaryProtocol(transport); 
      Cassandra.Client client = new Cassandra.Client(protocol); 

      Console.WriteLine("Opening connection"); 

      try 
       { 
       transport.Open(); 
       } 
      catch (Exception e) 
       { 
       Console.WriteLine("error connecting..."); 
       return; 
       } 

      KsDef def = client.describe_keyspace("nm_example"); // error here 
      client.set_keyspace("nm_example");// error here 

これは私がCLIを使用してキースペースに接続することができ

An unhandled exception of type 'Thrift.Transport.TTransportException' occurred in Thrift.dll 

Additional information: Cannot read, Remote side has closed 

を得る例外です。私は何か間違っていますか?クライアントは特定のバージョンでのみ動作しますか?誰もが最新のCassandraにThriftとC#を使って接続しましたか?

+3

本当にスリフトを使用するよりも上位レベルのライブラリを使用する必要があります。 http://code.google.com/p/cassandra-sharp/をご覧ください。 – psanford

答えて

2

カッサンドラは、ほとんどの場合あなたの問題であるスリフト0.7を使用してそれを構築します。あなた自身の倹約縛りを構築したい場合は、その倹約のバージョンを使うべきです。

psanfordに言及したように、あなたはより高いレベルのクライアントを使用しているはずです。参照:

http://wiki.apache.org/cassandra/ClientOptions

1

問題がtransport.Open() 以下の作品であり、

TSocket socket = null; 
    TTransport transport = null; 

    socket = new TSocket("localhost", 9160); 


    transport = new TFramedTransport(socket); 
    TProtocol protocol = new TBinaryProtocol(transport); 
    CassandraClient cassandraClient = new CassandraClient(protocol); 
    cassandraClient.InputProtocol.Transport.Open(); 

    string s = cassandraClient.describe_cluster_name(); 
    List<KsDef> keyspaces = cassandraClient.describe_keyspaces(); 

利用cassandraClient.InputProtocol.Transport.Open(); transport.open()ではなく

関連する問題