1

如何调试在 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**
4

2 回答 2

1

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

/var/log/cassandra/system.log

于 2014-06-25T08:49:19.020 回答
0

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

  1. 使用 Cassandra 系统日志
  2. 盯着单节点 Cassandra,这是一个处于调试模式的 java 应用程序

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

然后从远程调试器连接[比如说 eclipse,你可能有触发器的代码]。

于 2015-07-28T06:21:07.023 回答