如何在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**
答案 0 :(得分:1)
你可以看到cassandra的日志。默认情况下,它位于
/var/log/cassandra/system.log
答案 1 :(得分:0)
在Cassandra中调试触发器的方法有很多种。 作为:
-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=n
然后从远程调试器连接[说eclipse,你可能有你的触发器的coede]。