通过CQL创建了若干表格,比如:
CREATE TABLE fileindex( recid varchar, agentno varchar, customerno varchar, recfile varchar, createtime varchar, PRIMARY KEY(recid) ); CREATE INDEX ON fileindex(agentno); CREATE INDEX ON fileindex(customerno); CREATE INDEX ON fileindex(recfile); CREATE INDEX ON fileindex(createtime);
然后再表中插入若干数据,运行了一段时间后,重启Cassandra,报了下面的错:
java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.nio.ByteBuffer at org.apache.cassandra.db.marshal.UTF8Type.compare(UTF8Type.java:27) at org.apache.cassandra.dht.LocalToken.compareTo(LocalToken.java:45) at org.apache.cassandra.db.DecoratedKey.compareTo(DecoratedKey.java:89) at org.apache.cassandra.db.DecoratedKey.compareTo(DecoratedKey.java:38) at java.util.TreeMap.getEntry(TreeMap.java:328) at java.util.TreeMap.containsKey(TreeMap.java:209) at java.util.TreeSet.contains(TreeSet.java:217) at org.apache.cassandra.io.sstable.SSTableReader.load(SSTableReader.java:396) at org.apache.cassandra.io.sstable.SSTableReader.open(SSTableReader.java:187) at org.apache.cassandra.io.sstable.SSTableReader$1.run(SSTableReader.java:225) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.nio.ByteBuffer at org.apache.cassandra.db.marshal.UTF8Type.compare(UTF8Type.java:27) at org.apache.cassandra.dht.LocalToken.compareTo(LocalToken.java:45) at org.apache.cassandra.db.DecoratedKey.compareTo(DecoratedKey.java:89) at org.apache.cassandra.db.DecoratedKey.compareTo(DecoratedKey.java:38)
找了半天,终于找到答案,原来是Cassandra1.1.1的一个bug(将在Cassandra1.1.2中修复)。
https://issues.apache.org/jira/browse/CASSANDRA-4331
解决方法就是删除saved_caches_directory文件夹中的文件,默认位置是/var/lib/cassandra/saved_caches
然后再重启就没问题了