连接到 .NET 中的 Cassandra 0.7

发布于 2024-09-17 10:43:18 字数 2287 浏览 13 评论 0原文

我在尝试将我的现有库从 Cassandra 0.6 升级到 0.7 beta1 时遇到了很多麻烦。我最初认为这是一个操作顺序问题,所以我决定将其分解为基础知识。

这是我将要使用的基本设置

TTransport framedTransport = new TFramedTransport(new TSocket("localhost", 9160));
TTransport socketTransport = new TSocket("localhost", 9160);
TProtocol framedProtocol = new TBinaryProtocol(framedTransport);
TProtocol socketProtocol = new TBinaryProtocol(socketTransport);

然后我尝试通过以下方式更改客户端的设置,切换输入和输出协议:

var client = new Cassandra.Client(framedProtocol, framedProtocol); // all framed
var client = new Cassandra.Client(socketProtocol, socketProtocol); // all socket
var client = new Cassandra.Client(framedProtocol, socketProtocol); // in: framed out: socket
var client = new Cassandra.Client(socketProtocol, framedProtocol); // in: socket out: framed

然后我执行以下程序,该程序使用 从下载 中,我正在执行一个简单的请求,例如计数,我希望它返回零,因为没有数据插入。

framedTransport.Open();
socketTransport.Open();
Console.WriteLine("Start");

client.set_keyspace("Keyspace1");

var key = System.Text.Encoding.ASCII.GetBytes("MyKey");
var columns = new List<byte[]>(new[] { System.Text.Encoding.ASCII.GetBytes("MyColumn") });
var column_parent = new ColumnParent {
    Column_family = "Standard1"
};
var predicate = new SlicePredicate {
    Column_names = columns
};
client.get_count(key, column_parent, predicate, ConsistencyLevel.ALL);

Console.WriteLine("Done");
Console.Read();

我上面提供的 4 种不同设置均无法执行。其中一些只是锁定,其他则抛出异常。所以基本上我一直在试图建立一个连接来使用新的 Cassandra 0.7 和 .NET 框架。

以下是我在每个问题中发现的问题类型:

  • all framed: locks up on set_keyspace
  • all socket: throws Invalid method name: 'set_keyspace' on set_keyspace
  • in:框架输出:套接字:锁定set_keyspace
  • 输入:套接字输出:框架:锁定set_keyspace

我99%确定它与我在Thrift层所做的事情有关Cassandra 因为我无法让这个简单的应用程序工作。但如果你想浏览我的 0.7 分支,你可以在这里找到它:

http://github.com / Managedfusion / Fluentcassandra / Tree / 0.7

I am having a lot of trouble trying to upgrade my existing library from Cassandra 0.6 to 0.7 beta1. I had originally thought it was a order of operations issue, so I decided to break it down to the basics.

Here is the basic setup that I will be suing

TTransport framedTransport = new TFramedTransport(new TSocket("localhost", 9160));
TTransport socketTransport = new TSocket("localhost", 9160);
TProtocol framedProtocol = new TBinaryProtocol(framedTransport);
TProtocol socketProtocol = new TBinaryProtocol(socketTransport);

Then I have tried to vary the setup of the client in the following ways switching the input and output protocols:

var client = new Cassandra.Client(framedProtocol, framedProtocol); // all framed
var client = new Cassandra.Client(socketProtocol, socketProtocol); // all socket
var client = new Cassandra.Client(framedProtocol, socketProtocol); // in: framed out: socket
var client = new Cassandra.Client(socketProtocol, framedProtocol); // in: socket out: framed

Then I execute the following program which uses the default Cassandra configuration that comes from the download and I am doing a simple request such as a count which I expect it to return zero since no data was inserted.

framedTransport.Open();
socketTransport.Open();
Console.WriteLine("Start");

client.set_keyspace("Keyspace1");

var key = System.Text.Encoding.ASCII.GetBytes("MyKey");
var columns = new List<byte[]>(new[] { System.Text.Encoding.ASCII.GetBytes("MyColumn") });
var column_parent = new ColumnParent {
    Column_family = "Standard1"
};
var predicate = new SlicePredicate {
    Column_names = columns
};
client.get_count(key, column_parent, predicate, ConsistencyLevel.ALL);

Console.WriteLine("Done");
Console.Read();

Each of the 4 different setups I provided above fail to execute. A couple of them just lock up and others throw an exception. So basically I am stuck trying to get a connection to work with the new Cassandra 0.7 with the .NET framework.

Here are the types of problems I found with each:

  • all framed: locks up on set_keyspace
  • all socket: throws Invalid method name: 'set_keyspace' on set_keyspace
  • in: framed out: socket: locks up on set_keyspace
  • in: socket out: framed: locks up on set_keyspace

I am 99% sure it has to do with something I am doing at the Thrift layer of Cassandra since I can't get this simple application to work. But if you want to browser my 0.7 branch you can find it here:

http://github.com/managedfusion/fluentcassandra/tree/0.7

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

葬花如无物 2024-09-24 10:44:00

C# thrift 框架模式代码可能有问题,因为服务器端所做的所有更改都是使框架成为默认模式而不是非框架。您可以在 cassandra.yaml 中将其切换回来作为解决方法。

(在连接的输入/输出端指定不同的协议有点疯狂。我所知道的其他 Thrift 语言都没有这样做。如果您深入研究代码生成,那是另一件事可能需要解决。)

Probably the C# thrift framed-mode code is buggy, because all that changed on the server side was making framed the default mode instead of unframed. You can switch it back in cassandra.yaml as a workaround.

(It's slightly insane to specify different protocols on the in/out sides of the connection. No other Thrift languages I know do that. If you dig into the code generation that is another thing to potentially fix.)

自控 2024-09-24 10:43:54

我没有更新 Windows 中的环境变量以指向 0.7 的新位置。所以它本质上是运行稳定版本而不是测试版本。在我更新环境变量以指向新位置后,一切都重新开始工作。

I didn't update the environment variables in Windows to point to the new location of 0.7. So it was essentially running the stable version instead of the beta version. After I updated thee environment variable to point to the new location everything started working again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文