【问题标题】:Cassandra Triggers Buggy CodeCassandra 触发错误代码
【发布时间】:2014-08-06 14:42:34
【问题描述】:

如何调试在 Cassandra 触发器中有错误的代码?

这是可能有错误的代码:

此代码将更新发送到另一个应用程序 SampleConsumer()

public Collection<Mutation> augment(ByteBuffer key, ColumnFamily update) {

    LinkedList<Mutation> dummyReturn = new LinkedList<Mutation>();
    SampleConsumer cons = new SampleConsumer();

    String payload = "key="+key.toString()+"&";

    // get the column names and their values in a string
    for (CellName columnName : update.getColumnNames()) {
        payload += (columnName.toString()+"="+update.getColumn(columnName).value().toString()+"&");
    }

    // This publishing to the consumer works perfectly if i hardcode a payload instead of calculating it.
    cons.write(payload);

    return dummyReturn;
}

使用 cqlsh 更新列族时出现此错误

[cqlsh 4.1.1 | Cassandra 2.0.7.31 | CQL spec 3.1.1 | Thrift protocol 19.39.0]
cqlsh> create TABLE store.users(user_name varchar PRIMARY KEY, password varchar);
cqlsh> CREATE TRIGGER ctrigger ON store.users USING 'com.castrigger.casNotify';
cqlsh> INSERT INTO store.users (user_name, password) VALUES ('sampleuser','samplepass');
**TSocket read 0 bytes**

【问题讨论】:

    标签: cassandra cassandra-2.0 datastax cassandra-cli cqlsh


    【解决方案1】:

    你可以看到 cassandra 的日志。默认情况下,它位于

    /var/log/cassandra/system.log

    【讨论】:

      【解决方案2】:

      在 Cassandra 中有多种调试触发器的方法。 如:

      1. 使用 Cassandra 系统日志
      2. 盯着单节点 Cassandra,这是一个带有
      3. 的 Debug 模式下的 java 应用程序

      -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=n

      然后从远程调试器连接[比如说 eclipse,您可能在其中有触发器的 coede]。

      【讨论】:

        猜你喜欢
        • 2015-11-21
        • 2018-06-26
        • 2015-06-15
        • 2018-07-26
        • 1970-01-01
        • 1970-01-01
        • 2015-09-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多